vB_Library_Phrase
extends vB_Library
in package
vB_Library_Phrase
Tags
Table of Contents
Constants
- VALID_CLASS = 'A-Za-z0-9_\\.\\[\\]'
- Characters that are valid for use in a phrase varname. Alphanumeric and underscore (_) are commonly used everywhere. CKEditor phrase varnames use periods (.), and help phrase varnames use square brackets ([]).
Methods
- __serialize() : array<string|int, mixed>
- __sleep() : array<string|int, mixed>
- __unserialize() : void
- __wakeup() : void
- cleanGuidForPhrase() : string
- Cleans a guid to match phrase valid class (self::VALID_CLASS).
- clearCache() : mixed
- deleteByVarname() : void
- Deletes a phrase from all languages
- doShortcodeReplacements() : mixed
- getBasePhrases() : array<string|int, mixed>
- Fetch raw phrases from the master language
- getContentInstance() : mixed
- getLanguageid() : array<string|int, mixed>
- Fetch the "best" languageid in the order of current session's languageid, the default languageid from datastore, or the master languageid (-1).
- getPhrases() : array<string|int, mixed>
- Fetch raw phrases
- instance() : static
- Returns singleton instance of self.
- isValidPhraseSnippet() : bool
- Checks that a string is a valid snippet for building custom phrase names
- monitorWords() : mixed
- Checks if the text contains monitored words, and if so, sends notifications to admins and moderators if the setting is on.
- parsePhrases() : array<string|int, mixed>
- Handled output from query from fetch() and fetchByGroup()
- renamePhrase() : mixed
- renderPhrase() : string
- Renders the tokens in a string with the given values.
- renderPhrases() : array<string|int, mixed>
- Returns rendered phrases from phrase strings and/or data
- renderPhrasesNoShortcode() : array<string|int, mixed>
- Returns rendered phrases from phrase strings and/or data
- replaceOptionsAndConfigValuesInPhrase() : string
- Replaces instances of vBulletin options and config variables in a phrase with the value held in the variable.
- save() : void
- Add a new phrase or update an existing phrase
- saveCustom() : mixed
- saveMaster() : mixed
- setPhraseDate() : mixed
- Resets the phrase cachebuster date.
Constants
VALID_CLASS
Characters that are valid for use in a phrase varname. Alphanumeric and underscore (_) are commonly used everywhere. CKEditor phrase varnames use periods (.), and help phrase varnames use square brackets ([]).
public
string
VALID_CLASS
= 'A-Za-z0-9_\\.\\[\\]'
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
cleanGuidForPhrase()
Cleans a guid to match phrase valid class (self::VALID_CLASS).
public
cleanGuidForPhrase(string $guid) : string
This is used to build phrases for import items. Example: title and description for pages - 'page_' . $guidforphrase . 'title' - 'page' . $guidforphrase . '_description'
Parameters
- $guid : string
-
GUID string.
Return values
string —GUID for phrase.
clearCache()
public
static clearCache() : mixed
deleteByVarname()
Deletes a phrase from all languages
public
deleteByVarname(string $varname[, bool $skipBuildLanguage = false ]) : void
Parameters
- $varname : string
-
-- name of the string
- $skipBuildLanguage : bool = false
-
-- if true skip rebuilding the language
doShortcodeReplacements()
public
doShortcodeReplacements(mixed $phrases[, mixed $userid = null ]) : mixed
Parameters
- $phrases : mixed
- $userid : mixed = null
getBasePhrases()
Fetch raw phrases from the master language
public
getBasePhrases(array<string|int, mixed>|string $phrases) : array<string|int, mixed>
This will pull the phrases from the either the custom phrases or master language even if a translation is available in the user's language. It is mostly intended for fetching phrase values for editing purposes.
Note that these are not suitable for display to the user as is since many phrases have placeholders and this will not substitute them. It is available in situations where the client expects to render the phrases itself (particularly in situations where the phrase can be cached and reused client side).
Parameters
- $phrases : array<string|int, mixed>|string
-
An array of phraseids to be fetched, a string will be treatd as an array of one phraseid
Return values
array<string|int, mixed> —-- 'phrases' -- [phraseid => phrase value]
getContentInstance()
public
static getContentInstance(mixed $contenttypeid) : mixed
Parameters
- $contenttypeid : mixed
getLanguageid()
Fetch the "best" languageid in the order of current session's languageid, the default languageid from datastore, or the master languageid (-1).
public
getLanguageid([bool $getCharset = false ]) : array<string|int, mixed>
This is the languageid that's used by fetch().
Parameters
- $getCharset : bool = false
-
(Optional) true to also return charset of current languageid. Default false.
Return values
array<string|int, mixed> —'languageid' => languageid used for current session's phrases
getPhrases()
Fetch raw phrases
public
getPhrases(array<string|int, mixed>|string $phrases, int $languageid) : array<string|int, mixed>
Note that these are not suitable for display to the user as is since many phrases have placeholders and this will not substitute them. It is available in situations where the client expects to render the phrases itself (particularly in situations where the phrase can be cached and reused client side).
Parameters
- $phrases : array<string|int, mixed>|string
-
An array of phraseids to be fetched, a string will be treatd as an array of one phraseid
- $languageid : int
-
Language ID. If passed a 0, use the current user/forum default language.
Return values
array<string|int, mixed> —-- 'phrases' -- [phraseid => phrase value]
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
isValidPhraseSnippet()
Checks that a string is a valid snippet for building custom phrase names
public
isValidPhraseSnippet(string $snippet) : bool
@param string $string
Parameters
- $snippet : string
Return values
boolmonitorWords()
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
Parameters
- $text : mixed
- $type : mixed
- $nodeid : mixed
- $userid : mixed = null
- $insertNotifications : mixed = true
- $currentuserid : mixed = 0
Tags
parsePhrases()
Handled output from query from fetch() and fetchByGroup()
public
parsePhrases(mixed $phrasesdata[, mixed $phrases = [] ][, mixed $languageid = -1 ]) : array<string|int, mixed>
Parameters
- $phrasesdata : mixed
- $phrases : mixed = []
- $languageid : mixed = -1
Return values
array<string|int, mixed> —Phrases phrases
renamePhrase()
public
renamePhrase(mixed $oldname, mixed $newname[, mixed $skipBuildLanguage = false ]) : mixed
Parameters
- $oldname : mixed
- $newname : mixed
- $skipBuildLanguage : mixed = false
renderPhrase()
Renders the tokens in a string with the given values.
public
renderPhrase(string $phrasestring, array<string|int, mixed> $args) : string
Parameters
- $phrasestring : string
-
- The phrase string to render. This isn't the phrase ID but rather the loaded phrase transformed into the sprintf format.
- $args : array<string|int, mixed>
-
- The values to parse into the phrase
Return values
string —- The resulting string
renderPhrases()
Returns rendered phrases from phrase strings and/or data
public
renderPhrases(mixed $phrases[, mixed $languageid = null ]) : array<string|int, mixed>
Parameters
- $phrases : mixed
- $languageid : mixed = null
Return values
array<string|int, mixed> —'phrases' => ['key' => rendered phrase]
renderPhrasesNoShortcode()
Returns rendered phrases from phrase strings and/or data
public
renderPhrasesNoShortcode(mixed $phrases[, mixed $languageid = null ]) : array<string|int, mixed>
In some circumstances, primarily email, we need to defer shortcode replacement because we need to handle things for a user other than the current logged in user (many of the shortcodes are user specific). This allows us to do that.
Parameters
- $phrases : mixed
- $languageid : mixed = null
Return values
array<string|int, mixed> —'phrases' => ['key' => rendered phrase]
replaceOptionsAndConfigValuesInPhrase()
Replaces instances of vBulletin options and config variables in a phrase with the value held in the variable.
public
replaceOptionsAndConfigValuesInPhrase(string $text) : string
This function currently supports variables such as $vbulletin->config[xxx][yyy] and $vbulletin->options[xxx], and is intended to be used in Admin CP phrases, primarily help phrases.
This function is placed here in the spirit of DRY, since it's needed in various places, and for namespacing. It's not dependent on anything else in the phrase library.
Parameters
- $text : string
-
The phrase text
Return values
string —The phrase text after replacements are done.
save()
Add a new phrase or update an existing phrase
public
save(string $fieldname, string $varname, array<string|int, mixed> $data[, bool $skipBuildLanguage = false ]) : void
Parameters
- $fieldname : string
-
New Phrase Type for adding, old Phrase Type for editing
- $varname : string
-
New Varname for adding, old Varname for editing
- $data : array<string|int, mixed>
-
Phrase data to be added or updated 'text' => Phrase text array. 'oldvarname' => Old varname for editing only 'oldfieldname' => Old fieldname for editing only 't' => 'ismaster' => 'product' => Product ID of the phrase
- $skipBuildLanguage : bool = false
-
(Optional) Set to true to skip build_language() call. Used by the page importer to delay build_language until the old page title & desc restore queries are finished.
saveCustom()
public
saveCustom(mixed $product, mixed $fieldname, mixed $phrasename, mixed $value[, mixed $skipBuildLanguage = false ]) : mixed
Parameters
- $product : mixed
- $fieldname : mixed
- $phrasename : mixed
- $value : mixed
- $skipBuildLanguage : mixed = false
saveMaster()
public
saveMaster(mixed $product, mixed $fieldname, mixed $phrasename, mixed $value[, mixed $skipBuildLanguage = false ]) : mixed
Parameters
- $product : mixed
- $fieldname : mixed
- $phrasename : mixed
- $value : mixed
- $skipBuildLanguage : mixed = false
setPhraseDate()
Resets the phrase cachebuster date.
public
setPhraseDate() : mixed