class vB_Api_Template extends vB_Api

vB_Api_Template

Traits

Properties

protected bool $disabled Indicates whether the API was disabled from vB_Api
protected $disableWhiteList
protected array $disableFalseReturnOnly Contains white listed methods which return a false response when API is disabled in special scenarios like forum closed, password expiry, ip ban and others. from vB_Api
protected string $controller API Controller from vB_Api
protected vB_Database $db Database object. from vB_Api
protected $library
static protected $special_templates
static protected $common_templates

Methods

__sleep()

No description

__wakeup()

No description

static 
getApiClassName($controller)

No description

from vB_Api
static 
getApiClassNameInternal($controller)

No description

from vB_Api
static 
getApiClass($controller, $errorCheck = true)

No description

from vB_Api
static vB_Api
instanceInternal(string $controller, bool $refresh_cache = false)

Returns an instance of the API object which doesn't handle exceptions This should only be used in other API objects, not for clients of the API

from vB_Api
static vB_Api
instance(string $controller, bool $refresh_cache = false)

Returns an instance of the API object which translates exceptions to an array Use this method for API clients.

from vB_Api
static 
clearCache()

Clears all previously loaded API objects.

from vB_Api
The
callNamed()

Call the given api function by name with a named arguments list.

from vB_Api
static string
map_vb4_input_to_vb5(string $method, array $request)

Returns vb5 api method name.

from vB_Api
static 
map_vb5_output_to_vb4(string $method, array $data)

Alters the output array in any way necessary to interface correctly with vb4.

from vB_Api
static 
map_vb5_errors_to_vb4(string $method, array $data)

Alters the error array in any way necessary to interface correctly with vb4.

from vB_Api
__construct()

No description

checkApiState($method)

This method checks whether the API method is enabled.

from vB_Api
bool
isWhiteListed(string $method)

Checks if method is white listed when API is disabled.

from vB_Api
bool
isDisableFalseReturnOnly(string $method)

Checks if method returns false response only when API is disabled.

from vB_Api
toSeoFriendly(string $str)

Replaces special characters in a given string with dashes to make the string SEO friendly

from vB_Api
none
checkHasAdminPermission(string $adminPermission)

Determines if the calling user has the given admin permission, and if not throws an exception

from vB_Api
boolean
hasAdminPermission(string $adminPermission)

Determines if the calling user has the given admin permission

from vB_Api
checkIsLoggedIn()

Determines if the calling user has the given admin permission, and if not throws an exception

from vB_Api
setController(string $controller)

Set controller

from vB_Api
inDebugMode()

No description

from vB_Api
mixed
fetch(string $template_name, integer $styleid = -1)

Fetch one template based on its name and style ID.

array
fetchBulk($template_names, $styleid = -1, $type = 'compiled')

Fetches a bulk of templates from the database

getTemplateID($template_name, $styleid = -1)

Get template ID by its template name and style id

array
getTemplateIds(array $template_names, array $styleid = -1)

Get a list of template IDs by thier template names and style id

array
fetchByID(integer $templateid)

Fetch template by its ID

fetchUncompiled(string $template_name, integer $styleid = -1)

Fetch one uncompiled template based on its name and style ID.

none
cacheTemplates(array $templates, string $templateidlist, bool $skip_bbcode_style = false, bool $force_set = false)

Fetches a number of templates from the database and puts them into the templatecache

integer
insert($dostyleid, $title, $content, $product = 'vbulletin', $savehistory = false, $histcomment = '', $forcesaveonerror = false, $extra = array())

Insert a new template

update($templateid, $title, $content, $product, $oldcontent, $savehistory, $histcomment, $forcesaveonerror = false, $additional = array())

Update a template

array
insertReplacementVar(integer $dostyleid, string $findtext, string $replacetext)

Insert a replacement var

updateReplacementVar($replacevarid, $replacetext)

Update the replacement text for a replacement var

array
deleteReplacementVar($replacevarid)

Delete a replacement variable

array
fetchReplacementVar(string $findtext, integer $dostyleid, boolean $inherit = false)

Find the replacement var by title and styleid

array
fetchReplacementVarById(integer $replacevarid)

Find the replacement var by templateid

array
getCssTemplateSbEditor(int $styleid, string $templateName)

This is the counterpart to saveCssTemplateSbEditor(). Returns the template record, including template text and the textonly value.

bool
saveCssTemplateSbEditor(string $text, int $styleid, string $templateName, bool $textonly = 1)

This is just a wrapper for delete, save, and update. The presentation layer doesn't actually know which is correct. This forces textonly = 1 if the user doesn't have 'canadmintemplates'.

delete(integer $templateid)

Delete a template

checkCanSaveTemplate($templateid, $existing, $extra)

This checks permissions for saving a template.

array
fetchOriginal(string $title)

Fetch original (not customized) template content

array
findUpdates()

Find custom templates that need updating

array
dismissMerge(array $templateids)

Dismiss automatical merge

mixed
search(integer $dostyleid, mixed $expandset = null, string $searchstring = '', boolean $titlesonly = true)

Search and fetch a list of templates

mixed
searchAndReplace(integer $dostyleid, string $searchstring, string $replacestring, boolean $case_insensitive, boolean $regex, boolean $test, integer $startat_style, integer $startat_template)

Search and Replace templates.

boolean
revertAllInStyle(integer $dostyleid)

Revert all templates in a style

integer
massMerge(string $product = 'vbulletin', integer $startat = 0)

Massive merge templates

array
history(string $title, integer $dostyleid)

Return editing history of a template, including old versions and diffs between versions

array
historyByTemplateID(integer $templateid)

Return editing history of a template by its ID, including old versions and diffs between versions

fetchVersion(integer $historyid, string $type)

Fetch current or historical uncompiled version of a template

deleteHistoryVersion(array $historyids)

Delete template history versions

fetchSpecialTemplates()

No description

fetchCommonTemplates()

No description

fetchTemplateHooks($hookName)

No description

saveAllTemplatesToFile()

No description

deleteAllTemplateFiles()

No description

loadLanguage()

Preload basic language information we're going to need.

deleteTemplateInternal($templateids, $styleid, $dobuildreplacements = 0)

No description

string
processReplacementVars(string $html, integer $syleid = -1)

Process the replacement variables.

mixed
getTextonlyDS()

gets the current textonly array

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

in vB_Api at line 63
static getApiClassName($controller)

Parameters

$controller

in vB_Api at line 69
static protected getApiClassNameInternal($controller)

Parameters

$controller

in vB_Api at line 97
static protected getApiClass($controller, $errorCheck = true)

Parameters

$controller
$errorCheck

in vB_Api at line 177
static vB_Api instanceInternal(string $controller, bool $refresh_cache = false)

Returns an instance of the API object which doesn't handle exceptions This should only be used in other API objects, not for clients of the API

Parameters

string $controller -- name of the API controller to load
bool $refresh_cache -- true if we want to force the cache to update with a new api object primarily intended for testing

Return Value

vB_Api

in vB_Api at line 203
static vB_Api instance(string $controller, bool $refresh_cache = false)

Returns an instance of the API object which translates exceptions to an array Use this method for API clients.

Parameters

string $controller -- name of the API controller to load
bool $refresh_cache -- true if we want to force the cache to update with a new api object primarily intended for testing

Return Value

vB_Api

in vB_Api at line 237
static clearCache()

Clears all previously loaded API objects.

Intended for use in tests where the loading pattern can cause issues with objects that cache thier own data.

in vB_Api at line 259
The callNamed()

Call the given api function by name with a named arguments list.

Used primarily to translate REST requests into API calls.

Return Value

The return of the method or an error if the method doesn't exist, or is static, a constructor or destructor, or otherwise shouldn't be callable as and API method. It is also an error if the value of a paramater is not provided and that parameter doesn't have a default value.

in vB_Api at line 313
static string map_vb4_input_to_vb5(string $method, array $request)

Returns vb5 api method name.

May alter request array.

Parameters

string $method -- vb4 method name
array $request -- $_REQUEST array for this api request

Return Value

string

in vB_Api at line 497
static map_vb5_output_to_vb4(string $method, array $data)

Alters the output array in any way necessary to interface correctly with vb4.

Parameters

string $method -- vb4 method name
array $data -- output array from vb5

in vB_Api at line 545
static map_vb5_errors_to_vb4(string $method, array $data)

Alters the error array in any way necessary to interface correctly with vb4.

Parameters

string $method -- vb4 method name
array $data -- error array from vb5

at line 36
protected __construct()

in vB_Api at line 631
checkApiState($method)

This method checks whether the API method is enabled.

For extensions check make sure $controller property is already set.

Parameters

$method

in vB_Api at line 657
protected bool isWhiteListed(string $method)

Checks if method is white listed when API is disabled.

Parameters

string $method API method to check.

Return Value

bool Indicates whether method is or is not a white list.

in vB_Api at line 685
protected bool isDisableFalseReturnOnly(string $method)

Checks if method returns false response only when API is disabled.

Parameters

string $method API method to check.

Return Value

bool Indicates whether method returns false response only.

in vB_Api at line 712
protected toSeoFriendly(string $str)

Replaces special characters in a given string with dashes to make the string SEO friendly

Parameters

string $str The string to be converted

in vB_Api at line 734
protected none checkHasAdminPermission(string $adminPermission)

Determines if the calling user has the given admin permission, and if not throws an exception

Checks for: * A valid CP Session * The passed adminpermission.

Parameters

string $adminPermission The admin permission to check

Return Value

none

Exceptions

inlinemodauth_required -- The current session is not a mod/admin session
nopermission_loggedin -- The user does not have the given permission
no_permission -- The user is not logged in at all.

in vB_Api at line 753
protected boolean hasAdminPermission(string $adminPermission)

Determines if the calling user has the given admin permission

Useful if you need to know if the calling user but do not care why they do not have that permission. Generally useful if there is a behavior difference between admins and non admins, but the call can be processed for either.

Parameters

string $adminPermission The admin permission to check

Return Value

boolean true if checks pass, false otherwise

in vB_Api at line 807
protected checkIsLoggedIn()

Determines if the calling user has the given admin permission, and if not throws an exception

in vB_Api at line 821
protected setController(string $controller)

Set controller

Parameters

string $controller Controller name

in vB_Api at line 831
protected inDebugMode()

at line 49
mixed fetch(string $template_name, integer $styleid = -1)

Fetch one template based on its name and style ID.

Parameters

string $template_name Template name.
integer $styleid Style ID. If empty, this method will fetch template from default style.

Return Value

mixed

at line 62
array fetchBulk($template_names, $styleid = -1, $type = 'compiled')

Fetches a bulk of templates from the database

Parameters

$template_names
$styleid
$type

Return Value

array Array of information about the imported style

at line 73
getTemplateID($template_name, $styleid = -1)

Get template ID by its template name and style id

Parameters

$template_name the name of the template
$styleid

at line 87
array getTemplateIds(array $template_names, array $styleid = -1)

Get a list of template IDs by thier template names and style id

Parameters

array $template_names -- a list of template names
array $styleid -- must be a style the user has access to. If not specified, the default style is used.

Return Value

array array('ids' => $ids) where $ids is a map of names to the template id for that name. If the name is not found, the entry for that name in the map will be false.

at line 100
array fetchByID(integer $templateid)

Fetch template by its ID

Parameters

integer $templateid Template ID.

Return Value

array Return template array if $templateid is valid.

at line 111
fetchUncompiled(string $template_name, integer $styleid = -1)

Fetch one uncompiled template based on its name and style ID.

Parameters

string $template_name Template name.
integer $styleid Style ID.

at line 135
none cacheTemplates(array $templates, string $templateidlist, bool $skip_bbcode_style = false, bool $force_set = false)

Fetches a number of templates from the database and puts them into the templatecache

Parameters

array $templates List of template names to be fetched
string $templateidlist Serialized array of template name => template id pairs
bool $skip_bbcode_style Whether to skip adding the bbcode style refs
bool $force_set Whether to force setting the template

Return Value

none

at line 153
integer insert($dostyleid, $title, $content, $product = 'vbulletin', $savehistory = false, $histcomment = '', $forcesaveonerror = false, $extra = array())

Insert a new template

Parameters

$dostyleid
$title
$content
$product
$savehistory
$histcomment
$forcesaveonerror
$extra

Return Value

integer New inserted template ID.

at line 183
update($templateid, $title, $content, $product, $oldcontent, $savehistory, $histcomment, $forcesaveonerror = false, $additional = array())

Update a template

Parameters

$templateid
$title
$content
$product
$oldcontent
$savehistory
$histcomment
$forcesaveonerror
$additional

at line 225
array insertReplacementVar(integer $dostyleid, string $findtext, string $replacetext)

Insert a replacement var

Parameters

integer $dostyleid
string $findtext
string $replacetext

Return Value

array integer id -- The id of the newly created replacement var

Exceptions

vB_Exception_Api 'no_permission' -- user does not have canadminstyles

at line 249
updateReplacementVar($replacevarid, $replacetext)

Update the replacement text for a replacement var

Parameters

$replacevarid
$replacetext

at line 276
array deleteReplacementVar($replacevarid)

Delete a replacement variable

@param integer $replacevarid -- templateid for the replacement variable

Parameters

$replacevarid

Return Value

array ('success' => true)

@throws vB_Exception_Api
'no_permission' -- user does not have canadminstyles
    'invalid_data_w_x_y_z' -- if the template does not exist or is not a replacement var

at line 312
array fetchReplacementVar(string $findtext, integer $dostyleid, boolean $inherit = false)

Find the replacement var by title and styleid

Parameters

string $findtext
integer $dostyleid
boolean $inherit -- do we check for variables in parent styles?

Return Value

array 'replacevar' => false|array -- template record for the replacement variable string title integer styleid integer dateline string username string template string template_un string version

at line 339
array fetchReplacementVarById(integer $replacevarid)

Find the replacement var by templateid

Parameters

integer $replacevarid

Return Value

array 'replacevar' => false|array -- template record for the replacement variable string title integer styleid integer dateline string username string template string template_un string version

at line 361
array getCssTemplateSbEditor(int $styleid, string $templateName)

This is the counterpart to saveCssTemplateSbEditor(). Returns the template record, including template text and the textonly value.

Parameters

int $styleid Style ID
string $templateName Template Name

Return Value

array Array containing the template info

at line 401
bool saveCssTemplateSbEditor(string $text, int $styleid, string $templateName, bool $textonly = 1)

This is just a wrapper for delete, save, and update. The presentation layer doesn't actually know which is correct. This forces textonly = 1 if the user doesn't have 'canadmintemplates'.

Parameters

string $text the content of the template
int $styleid the styleid
string $templateName the styleid
bool $textonly textonly value

Return Value

bool

at line 498
delete(integer $templateid)

Delete a template

Parameters

integer $templateid Template ID to be deleted.

at line 531
protected checkCanSaveTemplate($templateid, $existing, $extra)

This checks permissions for saving a template.

If textonly is set then the action requires only canadminstyles. Otherwise it requires canadmintemplates.

Parameters

$templateid
$existing
$extra

at line 575
array fetchOriginal(string $title)

Fetch original (not customized) template content

Parameters

string $title Template name.

Return Value

array Original template information

at line 598
array findUpdates()

Find custom templates that need updating

Return Value

array Templates that need updating.

at line 629
array dismissMerge(array $templateids)

Dismiss automatical merge

Parameters

array $templateids Template IDs which merge needs to be dismissed.

Return Value

array Number of affected templates.

Search and fetch a list of templates

Parameters

integer $dostyleid Style ID to be searched in. -1 means search in all styles.
mixed $expandset
string $searchstring Search for text.
boolean $titlesonly Wether to search template titles (names) only.

Return Value

mixed false if no templates are found. Otherwise an array will be returned with styleids as its keys.

at line 773
mixed searchAndReplace(integer $dostyleid, string $searchstring, string $replacestring, boolean $case_insensitive, boolean $regex, boolean $test, integer $startat_style, integer $startat_template)

Search and Replace templates.

Parameters

integer $dostyleid Style ID to be searched in. -1 means search in all styles.
string $searchstring Search for text.
string $replacestring Replace with text.
boolean $case_insensitive Case-Insensitive or not.
boolean $regex Whether to use regular expressions.
boolean $test Test only.
integer $startat_style Replacement startat style ID.
integer $startat_template Replacement startat template ID.

Return Value

mixed False if no templates found. Otherwise an array will be returned.

at line 1040
boolean revertAllInStyle(integer $dostyleid)

Revert all templates in a style

Parameters

integer $dostyleid Style ID where the custom templates in it will be reverted

Return Value

boolean False if nothing to do.

at line 1096
integer massMerge(string $product = 'vbulletin', integer $startat = 0)

Massive merge templates

Parameters

string $product Product string ID.
integer $startat Start offset of the merge.

Return Value

integer New startat value. -1 if no more to do.

at line 1150
array history(string $title, integer $dostyleid)

Return editing history of a template, including old versions and diffs between versions

Parameters

string $title Template name.
integer $dostyleid Style ID of the template.

Return Value

array Array of template history revisions.

at line 1205
array historyByTemplateID(integer $templateid)

Return editing history of a template by its ID, including old versions and diffs between versions

Parameters

integer $templateid Template ID.

Return Value

array Array of template history revisions.

at line 1219
fetchVersion(integer $historyid, string $type)

Fetch current or historical uncompiled version of a template

Parameters

integer $historyid The ID (in the appropriate table) of the record you want to fetch.
string $type Type of template you want to fetch; should be "current" or "historical"

at line 1235
deleteHistoryVersion(array $historyids)

Delete template history versions

Parameters

array $historyids History IDs to be deleted

at line 1250
fetchSpecialTemplates()

at line 1255
fetchCommonTemplates()

at line 1260
fetchTemplateHooks($hookName)

Parameters

$hookName

at line 1287
saveAllTemplatesToFile()

at line 1294
deleteAllTemplateFiles()

at line 1305
loadLanguage()

Preload basic language information we're going to need.

at line 1312
protected deleteTemplateInternal($templateids, $styleid, $dobuildreplacements = 0)

Parameters

$templateids
$styleid
$dobuildreplacements

at line 1368
string processReplacementVars(string $html, integer $syleid = -1)

Process the replacement variables.

Parameters

string $html The html to be processed
integer $syleid The styleid to use.

Return Value

string The processed output

at line 1378
mixed getTextonlyDS()

gets the current textonly array

Return Value

mixed array of styleid => array of template title => 1;