vB_Library_Template
extends vB_Library
in package
vB_Library_Template
Table of Contents
Methods
- __serialize() : array<string|int, mixed>
- __sleep() : array<string|int, mixed>
- __unserialize() : void
- __wakeup() : void
- cacheTemplates() : mixed
- Fetches a number of templates from the database and puts them into the templatecache
- clearCache() : mixed
- compile() : mixed
- Compile a template.
- delete() : mixed
- deleteAllTemplateFiles() : mixed
- deleteTemplateFromFileSystem() : mixed
- fetch() : array<string|int, mixed>
- Fetch one template based on its name and style ID.
- fetchBulk() : array<string|int, mixed>|string
- Fetches a bulk of templates from the database
- fetchByID() : array<string|int, mixed>
- Fetch template by its ID
- fetchReplacementVar() : false|array<string|int, mixed>
- Find the replacement var by title & styleid
- fetchReplacementVarById() : false|array<string|int, mixed>
- Find the replacement var by templateid
- fetchUncompiled() : array<string|int, mixed>
- Fetch the uncompiled code for one template based on its name and style ID.
- getContentInstance() : mixed
- getTemplateGroupPhrases() : mixed
- 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
- insert() : int
- Insert a new template
- insertReplacementVar() : int
- Insert a replacement var
- instance() : static
- Returns singleton instance of self.
- monitorWords() : mixed
- Checks if the text contains monitored words, and if so, sends notifications to admins and moderators if the setting is on.
- processReplacementVars() : string
- Process the replacement variables.
- rebuildTextonlyDS() : mixed
- Rebuilds the textonly array;
- saveAllTemplatesToFile() : mixed
- Rewrites the file cache for the templates for all styles.
- saveTemplatesToFile() : mixed
- 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>
__wakeup()
public
__wakeup() : void
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 ]) : mixed
Parameters
- $templates : mixed
- $templateidlist : mixed
- $skip_bbcode_style : mixed = false
- $force_set : mixed = false
clearCache()
public
static clearCache() : mixed
compile()
Compile a template.
public
compile(mixed $template, string $compiletype, bool $forcesaveonerror) : mixed
Parameters
- $template : mixed
- $compiletype : string
-
One of "textonly", "full" and "limited"
- $forcesaveonerror : bool
-
-- save the template even if there is an error.
delete()
public
delete(mixed $templateids) : mixed
Parameters
- $templateids : mixed
deleteAllTemplateFiles()
public
deleteAllTemplateFiles() : mixed
deleteTemplateFromFileSystem()
public
deleteTemplateFromFileSystem(mixed $templateid, mixed $template_path) : mixed
Parameters
- $templateid : mixed
- $template_path : mixed
fetch()
Fetch one template based on its name and style ID.
public
fetch(string $template_name[, int $styleid = -1 ][, bool $nopermissioncheck = false ]) : array<string|int, mixed>
Parameters
- $template_name : string
-
Template name.
- $styleid : int = -1
-
Style ID. If empty, this method will fetch template from default style.
- $nopermissioncheck : bool = false
Return values
array<string|int, mixed>fetchBulk()
Fetches a bulk of templates from the database
public
fetchBulk(array<string|int, mixed> $template_names[, int $styleid = -1 ][, string $type = 'compiled' ][, bool $nopermissioncheck = false ]) : array<string|int, mixed>|string
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 : string = 'compiled'
-
compiled -- default, return an array of the compiled template text and compile type. uncompiledtype -- return the same array but with the uncompiled text uncompiled -- return the uncompiled text string (deprecated)
- $nopermissioncheck : bool = false
Return values
array<string|int, mixed>|string —template info or uncompiled template code
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.
fetchReplacementVar()
Find the replacement var by title & styleid
public
fetchReplacementVar(string $findtext, int $dostyleid[, bool $inherit = false ]) : false|array<string|int, mixed>
Parameters
- $findtext : string
- $dostyleid : int
- $inherit : bool = false
-
-- do we check for variables in parent styles?
Return values
false|array<string|int, mixed> —-- template record for the replacement variable integer templateid 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) : false|array<string|int, mixed>
Parameters
- $replacevarid : int
Return values
false|array<string|int, mixed> —-- template record for the replacement variable integer templateid string title integer styleid integer dateline string username string template string template_un string version
fetchUncompiled()
Fetch the uncompiled code for one template based on its name and style ID.
public
fetchUncompiled(string $template_name[, int $styleid = -1 ]) : array<string|int, mixed>
Parameters
- $template_name : string
-
Template name.
- $styleid : int = -1
-
Style ID. If empty, this method will fetch template from default style.
Return values
array<string|int, mixed>getContentInstance()
public
static getContentInstance(mixed $contenttypeid) : mixed
Parameters
- $contenttypeid : mixed
getTemplateGroupPhrases()
public
getTemplateGroupPhrases() : mixed
getTemplateID()
Get template ID by its template name and style id
public
getTemplateID(mixed $template_name[, mixed $styleid = -1 ]) : mixed
Parameters
- $template_name : mixed
-
the name of the template
- $styleid : mixed = -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> —['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()
public
getTextonlyDS() : mixed
insert()
Insert a new template
public
insert(int $dostyleid, string $title, string $content[, string $product = 'vbulletin' ][, bool $savehistory = false ][, string $histcomment = '' ][, mixed $forcesaveonerror = false ][, array<string|int, mixed> $extra = ['compiletype' => 'full'] ]) : 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 : array<string|int, mixed> = ['compiletype' => 'full']
-
extra parameters for the function. Actually uses params: forcenotextonly which bypasses the canadmintemplate permission textonly which sets template text only setting
Return values
int —New inserted template ID.
insertReplacementVar()
Insert a replacement var
public
insertReplacementVar(int $dostyleid, string $findtext, string $replacetext) : int
Parameters
- $dostyleid : int
- $findtext : string
- $replacetext : string
-
@param string $product The product ID which the replacement var belongs to.
Tags
Return values
int —-- The id of the newly created replacement var
instance()
Returns singleton instance of self.
public
static instance(mixed $class) : static
Parameters
- $class : mixed
Return values
static —- Reference to singleton instance of the requested library class
monitorWords()
Checks if the text contains monitored words, and if so, sends notifications to admins and moderators if the setting is on.
public
monitorWords(mixed $text, mixed $type, mixed $nodeid[, mixed $userid = null ][, mixed $insertNotifications = true ][, mixed $currentuserid = 0 ]) : mixed
use the functions from the notification library directly.
Parameters
- $text : mixed
- $type : mixed
- $nodeid : mixed
- $userid : mixed = null
- $insertNotifications : mixed = true
- $currentuserid : mixed = 0
processReplacementVars()
Process the replacement variables.
public
processReplacementVars(mixed $html[, mixed $styleid = -1 ]) : string
Parameters
- $html : mixed
- $styleid : mixed = -1
Return values
string —The processed output
rebuildTextonlyDS()
Rebuilds the textonly array;
public
rebuildTextonlyDS() : mixed
saveAllTemplatesToFile()
Rewrites the file cache for the templates for all styles.
public
saveAllTemplatesToFile() : mixed
saveTemplatesToFile()
public
saveTemplatesToFile(mixed $templateids) : mixed
Parameters
- $templateids : mixed
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 = ['compiletype' => 'full'] ]) : 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 = ['compiletype' => 'full']
updateReplacementVar()
Update the replacement text for a replacement var
public
updateReplacementVar(int $replacevarid, mixed $replacetext) : mixed
Parameters
- $replacevarid : int
-
-- template id for the replace var
- $replacetext : mixed