Phrase rendering class.

package XenForo_Core

 Methods

Constructor

__construct(string | array $phraseName, array $params, boolean | array $insertParamsEscaped) 

Parameters

$phraseName

stringarray

Phrase name (or, array(phraseName, arg1 => x, arg2 => y...)

$params

array

Key-value parameters

$insertParamsEscaped

booleanarray

See {@link $_insertParamsEscaped}

Implicit string cast renders the phrase.

__toString() : string

Returns

string

Gets the language ID that phrases will be retrieived from.

getLanguageId() : integer
Static

Returns

integer

Gets the params.

getParams() : array

Returns

array

Gets the phrase name.

getPhraseName() : string

Returns

string

Bulk load all phrases that are required.

loadPhrases() 
Static

Specify a phrase that needs to be preloaded for use later.

preloadPhrase(string $phraseName) 
Static

This is useful if you think a render is going to be called before the phrase you require is to be used.

Parameters

$phraseName

string

Phrase to preload

Renders the specified phrase and returns the output.

render(boolean | null $phraseNameOnInvalid) : string

Parameters

$phraseNameOnInvalid

booleannull

If the phrase is invalid, return the phrase name (otherwise, empty string); if null, use default setting

Returns

string

Resets the phrase system state.

reset() 
Static

Sets the param escaping callback function.

setEscapeCallback(false | callback $callback) 
Static

Parameters

$callback

falsecallback

Sets whether inserted parameters should be automatically escaped.

setInsertParamsEscaped(array | boolean $insertParamsEscaped) 
see \$_insertParamsEscaped

Parameters

$insertParamsEscaped

arrayboolean

Sets the language ID that phrases will be retrieved from.

setLanguageId(integer $languageId) 
Static

Parameters

$languageId

integer

Add an array of params to the phrase.

setParams(array $params) 

Overwrites parameters with the same name.

Parameters

$params

array

Manually sets a phrase.

setPhrase(string $phraseName, string $phraseValue) 
Static

This is primarily useful for testing.

Parameters

$phraseName

string

Name of the phrase

$phraseValue

string

Value for the phrase

Sets the value for the phrase name on invalid setting.

setPhraseNameOnInvalid(boolean $value) 

This controls the behavior with an invalid phrase name. If true, output phrase name; otherwise, nothing.

Parameters

$value

boolean

Manually sets the cache values for collection of phrases.

setPhrases(array $phrases) 
Static

Parameters

$phrases

array

Escapes the named parameter if necessary, based on {@link $_insertParamsEscaped).

_escapeParam(string $paramName, string $paramValue) : string

Parameters

$paramName

string

Name of parameter

$paramValue

string

Value of parameter

Returns

stringEscaped parameter

Load the named phrase.

_loadPhrase(string $phraseName) : string
Static

Parameters

$phraseName

string

Phrase name

Returns

stringCompiled version of the phrase

Callback function for regular expression to replace a named parameter with a value.

_replaceParam(array $match) : string

Parameters

$match

array

Match array. Looks in key "param".

Returns

stringReplaced value

 Properties

 

$_escapeCallback 

This should be set by the view renderer. Set it to false to disable escaping completely.

param
 

$_insertParamsEscaped : boolean | array

If this is true or false, it applies to all params. If it is an array, the individual params are looked up as keys and the value is treated as a a boolean; params that aren't set will be escaped.

 

$_languageId : integer
 

$_params : array
 

$_phraseCache : array

Key is the phrase name; value is the phrase text.

 

$_phraseName : string
 

$_phraseNameOnInvalid : boolean
 

$_toLoad : array

Key is the phrase name.