vBulletin v6.0.4

vB_Api_Template extends vB_Api
in package

vB_Api_Template

Tags
access

public

Table of Contents

Methods

__serialize()  : array<string|int, mixed>
__sleep()  : array<string|int, mixed>
__unserialize()  : void
__wakeup()  : void
cacheTemplates()  : none
Fetches a number of templates from the database and puts them into the templatecache
callNamed()  : The
Call the given api function by name with a named arguments list.
checkApiState()  : mixed
This method checks whether the API method is enabled.
clearCache()  : mixed
Clears all previously loaded API objects.
delete()  : mixed
Delete a template
deleteAllTemplateFiles()  : mixed
deleteHistoryVersion()  : mixed
Delete template history versions
deleteReplacementVar()  : array<string|int, mixed>
Delete a replacement variable
dismissMerge()  : array<string|int, mixed>
Dismiss automatical merge
fetch()  : mixed
Fetch one template based on its name and style ID.
fetchBulk()  : array<string|int, mixed>
Fetches a bulk of templates from the database
fetchByID()  : array<string|int, mixed>
Fetch template by its ID
fetchCommonTemplates()  : mixed
fetchOriginal()  : array<string|int, mixed>
Fetch original (not customized) template content
fetchReplacementVar()  : array<string|int, mixed>
Find the replacement var by title and styleid
fetchReplacementVarById()  : array<string|int, mixed>
Find the replacement var by templateid
fetchSpecialTemplates()  : mixed
fetchTemplateHooks()  : mixed
fetchUncompiled()  : mixed
Fetch one uncompiled template based on its name and style ID.
fetchVersion()  : mixed
Fetch current or historical uncompiled version of a template
findUpdates()  : array<string|int, mixed>
Find custom templates that need updating
getApiClassName()  : mixed
getCssTemplateSbEditor()  : array<string|int, mixed>
This is the counterpart to saveCssTemplateSbEditor(). Returns the template record, including template text and the textonly value.
getTemplateID()  : mixed
Get template ID by its template name and style id
getTemplateIds()  : array<string|int, mixed>
Get a list of template IDs by thier template names and style id
getTextonlyDS()  : mixed
gets the current textonly array
history()  : array<string|int, mixed>
Return editing history of a template, including old versions and diffs between versions
historyByTemplateID()  : array<string|int, mixed>
Return editing history of a template by its ID, including old versions and diffs between versions
insert()  : int
Insert a new template
insertReplacementVar()  : array<string|int, mixed>
Insert a replacement var
instance()  : vB_Api
Returns an instance of the API object which translates exceptions to an array Use this method for API clients.
instanceInternal()  : vB_Api
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
loadLanguage()  : mixed
Preload basic language information we're going to need.
map_vb4_input_to_vb5()  : string
Returns vb5 api method name.
map_vb5_errors_to_vb4()  : mixed
Alters the error array in any way necessary to interface correctly with vb4.
map_vb5_output_to_vb4()  : mixed
Alters the output array in any way necessary to interface correctly with vb4.
massMerge()  : int
Massive merge templates
processReplacementVars()  : string
Process the replacement variables.
revertAllInStyle()  : bool
Revert all templates in a style
revertCssTemplateSbEditor()  : mixed
Delete a template based on style and name
saveAllTemplatesToFile()  : mixed
saveCssTemplateSbEditor()  : bool
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'.
search()  : mixed
Search and fetch a list of templates
searchAndReplace()  : mixed
Search and Replace templates.
update()  : mixed
Update a template
updateReplacementVar()  : mixed
Update the replacement text for a replacement var

Methods

__serialize()

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__sleep()

public __sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>

__unserialize()

public __unserialize(array<string|int, mixed> $serialized) : void
Parameters
$serialized : array<string|int, mixed>

cacheTemplates()

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

public cacheTemplates(mixed $templates, mixed $templateidlist[, mixed $skip_bbcode_style = false ][, mixed $force_set = false ]) : none
Parameters
$templates : mixed
$templateidlist : mixed
$skip_bbcode_style : mixed = false
$force_set : mixed = false
Return values
none

callNamed()

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

public callNamed() : The

Used primarily to translate REST requests into API calls.

Return values
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.

checkApiState()

This method checks whether the API method is enabled.

public checkApiState(mixed $method) : mixed

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

Parameters
$method : mixed

clearCache()

Clears all previously loaded API objects.

public static clearCache() : mixed

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

delete()

Delete a template

public delete(int $templateid) : mixed
Parameters
$templateid : int

Template ID to be deleted.

deleteAllTemplateFiles()

public deleteAllTemplateFiles() : mixed

deleteHistoryVersion()

Delete template history versions

public deleteHistoryVersion(array<string|int, mixed> $historyids) : mixed
Parameters
$historyids : array<string|int, mixed>

History IDs to be deleted

deleteReplacementVar()

Delete a replacement variable

public deleteReplacementVar(mixed $replacevarid) : array<string|int, mixed>
@param integer $replacevarid -- templateid for the replacement variable
Parameters
$replacevarid : mixed
Return values
array<string|int, mixed>

('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

dismissMerge()

Dismiss automatical merge

public dismissMerge(mixed $templateids) : array<string|int, mixed>
Parameters
$templateids : mixed
Return values
array<string|int, mixed>

Number of affected templates.

fetch()

Fetch one template based on its name and style ID.

public fetch(string $template_name[, int $styleid = -1 ]) : mixed
Parameters
$template_name : string

Template name.

$styleid : int = -1

Style ID. If empty, this method will fetch template from default style.

fetchBulk()

Fetches a bulk of templates from the database

public fetchBulk(array<string|int, mixed> $template_names[, int $styleid = -1 ][, mixed $type = 'compiled' ]) : array<string|int, mixed>
Parameters
$template_names : array<string|int, mixed>

List of template names to be fetched.

$styleid : int = -1

Style ID. If empty, this method will fetch template from default style.

$type : mixed = 'compiled'
Return values
array<string|int, mixed>

Array of information about the imported style

fetchByID()

Fetch template by its ID

public fetchByID(int $templateid) : array<string|int, mixed>
Parameters
$templateid : int

Template ID.

Return values
array<string|int, mixed>

Return template array if $templateid is valid.

fetchCommonTemplates()

public fetchCommonTemplates() : mixed

fetchOriginal()

Fetch original (not customized) template content

public fetchOriginal(string $title) : array<string|int, mixed>
Parameters
$title : string

Template name.

Return values
array<string|int, mixed>

Original template information

fetchReplacementVar()

Find the replacement var by title and styleid

public fetchReplacementVar(string $findtext, int $dostyleid[, bool $inherit = false ]) : array<string|int, mixed>
Parameters
$findtext : string
$dostyleid : int
$inherit : bool = false

-- do we check for variables in parent styles?

Return values
array<string|int, mixed>

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

fetchReplacementVarById()

Find the replacement var by templateid

public fetchReplacementVarById(int $replacevarid) : array<string|int, mixed>
Parameters
$replacevarid : int
Return values
array<string|int, mixed>

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

fetchSpecialTemplates()

public fetchSpecialTemplates() : mixed

fetchTemplateHooks()

public fetchTemplateHooks(mixed $hookName) : mixed
Parameters
$hookName : mixed

fetchUncompiled()

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

public fetchUncompiled(string $template_name[, int $styleid = -1 ]) : mixed
Parameters
$template_name : string

Template name.

$styleid : int = -1

Style ID.

fetchVersion()

Fetch current or historical uncompiled version of a template

public fetchVersion(mixed $historyid, mixed $type) : mixed
Parameters
$historyid : mixed
$type : mixed

findUpdates()

Find custom templates that need updating

public findUpdates() : array<string|int, mixed>
Return values
array<string|int, mixed>

Templates that need updating.

getApiClassName()

public static getApiClassName(mixed $controller) : mixed
Parameters
$controller : mixed

getCssTemplateSbEditor()

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

public getCssTemplateSbEditor(mixed $styleid, mixed $templateName) : array<string|int, mixed>
Parameters
$styleid : mixed
$templateName : mixed
Return values
array<string|int, mixed>

Array containing the template info

getTemplateID()

Get template ID by its template name and style id

public getTemplateID( $template_name[,  $styleid = -1 ]) : mixed
Parameters
$template_name :

the name of the template

$styleid : = -1

getTemplateIds()

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

public getTemplateIds(array<string|int, mixed> $template_names[, array<string|int, mixed> $styleid = -1 ]) : array<string|int, mixed>
Parameters
$template_names : array<string|int, mixed>

-- a list of template names

$styleid : array<string|int, mixed> = -1

-- must be a style the user has access to. If not specified, the default style is used.

Return values
array<string|int, mixed>

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.

getTextonlyDS()

gets the current textonly array

public getTextonlyDS() : mixed
Return values
mixed

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

history()

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

public history(string $title, int $dostyleid) : array<string|int, mixed>
Parameters
$title : string

Template name.

$dostyleid : int

Style ID of the template.

Return values
array<string|int, mixed>

Array of template history revisions.

historyByTemplateID()

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

public historyByTemplateID(int $templateid) : array<string|int, mixed>
Parameters
$templateid : int

Template ID.

Return values
array<string|int, mixed>

Array of template history revisions.

insert()

Insert a new template

public insert(int $dostyleid, string $title, string $content[, string $product = 'vbulletin' ][, bool $savehistory = false ][, string $histcomment = '' ][, mixed $forcesaveonerror = false ][, mixed $extra = array() ]) : int
Parameters
$dostyleid : int

Style ID which the new template belongs to.

$title : string

Template name.

$content : string

Template content.

$product : string = 'vbulletin'

The product ID which the template belongs to.

$savehistory : bool = false

Whether to save the change in template history.

$histcomment : string = ''

Comment of the change to be saved to template history.

$forcesaveonerror : mixed = false
$extra : mixed = array()
Return values
int

New inserted template ID.

insertReplacementVar()

Insert a replacement var

public insertReplacementVar(int $dostyleid, string $findtext, string $replacetext) : array<string|int, mixed>
Parameters
$dostyleid : int
$findtext : string
$replacetext : string
Tags
throws
vB_Exception_Api

'no_permission' -- user does not have canadminstyles

Return values
array<string|int, mixed>

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

instance()

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

public static instance(string $controller[, bool $refresh_cache = false ]) : vB_Api
Parameters
$controller : string

-- name of the API controller to load

$refresh_cache : bool = false

-- true if we want to force the cache to update with a new api object primarily intended for testing

Return values
vB_Api

instanceInternal()

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

public static instanceInternal(string $controller[, bool $refresh_cache = false ]) : vB_Api
Parameters
$controller : string

-- name of the API controller to load

$refresh_cache : bool = false

-- true if we want to force the cache to update with a new api object primarily intended for testing

Return values
vB_Api

loadLanguage()

Preload basic language information we're going to need.

public loadLanguage() : mixed

map_vb4_input_to_vb5()

Returns vb5 api method name.

public static map_vb4_input_to_vb5(string $method, array<string|int, mixed> &$request) : string

May alter request array.

Parameters
$method : string

-- vb4 method name

$request : array<string|int, mixed>

-- $_REQUEST array for this api request

Return values
string

map_vb5_errors_to_vb4()

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

public static map_vb5_errors_to_vb4(string $method, array<string|int, mixed> &$data) : mixed
Parameters
$method : string

-- vb4 method name

$data : array<string|int, mixed>

-- error array from vb5

map_vb5_output_to_vb4()

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

public static map_vb5_output_to_vb4(string $method, array<string|int, mixed> &$data) : mixed
Parameters
$method : string

-- vb4 method name

$data : array<string|int, mixed>

-- output array from vb5

massMerge()

Massive merge templates

public massMerge([string $product = 'vbulletin' ][, int $startat = 0 ]) : int
Parameters
$product : string = 'vbulletin'

Product string ID.

$startat : int = 0

Start offset of the merge.

Return values
int

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

processReplacementVars()

Process the replacement variables.

public processReplacementVars(mixed $html[, mixed $syleid = -1 ]) : string
Parameters
$html : mixed
$syleid : mixed = -1
Return values
string

The processed output

revertAllInStyle()

Revert all templates in a style

public revertAllInStyle(int $dostyleid) : bool
Parameters
$dostyleid : int

Style ID where the custom templates in it will be reverted

Return values
bool

False if nothing to do.

revertCssTemplateSbEditor()

Delete a template based on style and name

public revertCssTemplateSbEditor(mixed $styleid, mixed $templateName) : mixed

This will delete the template for the given style if it exists If the template doesn't exist we will quietly do nothing.

Parameters
$styleid : mixed
$templateName : mixed

saveAllTemplatesToFile()

public saveAllTemplatesToFile() : mixed

saveCssTemplateSbEditor()

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'.

public saveCssTemplateSbEditor(mixed $text, mixed $styleid, mixed $templateName[, mixed $textonly = 1 ]) : bool
Parameters
$text : mixed
$styleid : mixed
$templateName : mixed
$textonly : mixed = 1
Return values
bool

Search and fetch a list of templates

public search(int $dostyleid[, mixed $expandset = null ][, string $searchstring = '' ][, bool $titlesonly = true ]) : mixed
Parameters
$dostyleid : int

Style ID to be searched in. -1 means search in all styles.

$expandset : mixed = null
$searchstring : string = ''

Search for text.

$titlesonly : bool = true

Wether to search template titles (names) only.

Return values
mixed

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

searchAndReplace()

Search and Replace templates.

public searchAndReplace(int $dostyleid, string $searchstring, string $replacestring, bool $case_insensitive, bool $regex, bool $test, int $startat_style, int $startat_template) : mixed
Parameters
$dostyleid : int

Style ID to be searched in. -1 means search in all styles.

$searchstring : string

Search for text.

$replacestring : string

Replace with text.

$case_insensitive : bool

Case-Insensitive or not.

$regex : bool

Whether to use regular expressions.

$test : bool

Test only.

$startat_style : int

Replacement startat style ID.

$startat_template : int

Replacement startat template ID.

Return values
mixed

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

update()

Update a template

public update(int $templateid, string $title, string $content, string $product, string $oldcontent, bool $savehistory, string $histcomment[, bool $forcesaveonerror = false ][, mixed $additional = [] ]) : mixed
Parameters
$templateid : int

Template ID to be updated

$title : string

Template name.

$content : string

Template content.

$product : string

The product ID which the template belongs to.

$oldcontent : string

The content of the template at the time it was loaded. This is used to prevent cases where the template was changed while editing. Pass false to force an update.

$savehistory : bool

Whether to save the change in template history.

$histcomment : string

Comment of the change to be saved to template history.

$forcesaveonerror : bool = false

save the template even though there are errors.

$additional : mixed = []

updateReplacementVar()

Update the replacement text for a replacement var

public updateReplacementVar(int $replacevarid, mixed $replacetext) : mixed
Parameters
$replacevarid : int

-- templateid for the replacement variable

$replacetext : mixed
Tags
paramstring

$replacetext

@return 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


        
On this page

Search results