class vB_Api_Phrase extends vB_Api

vB_Api_Phrase

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 $styles
protected $phrasecache
protected vB_Library_Phrase $library

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
array
fetchByGroup(mixed $groups, int $languageid = NULL)

Fetch phrases by group

array
getLanguageid(bool $getCharset = false)

Fetch the "best" languageid in the order of current session's languageid, the default languageid from datastore, or the master languageid (-1).

array
fetch(array $phrases, int $languageid = NULL) deprecated

Fetch phrases

array
getPhrases(array $phrases, int $languageid = NULL)

Fetch raw phrases

array
parsePhrases($phrasesdata, $phrases = array(), $languageid = -1)

Handled output from query from fetch() and fetchByGroup()

array
fetchOrphans()

Fetch orphan phrases

void
processOrphans(array $del, array $keep)

Process orphan phrases

array
findUpdates()

Find custom phrases that need updating

array
search(array $criteria)

Search phrases

void
replace(array $replace, string $searchstring, string $replacestring, int $languageid)

Find and replace phrases in languages

void
delete(int $phraseid)

Delete a phrase

standard
save(string $fieldname, string $varname, array $data)

Add a new phrase or update an existing phrase

array
fetch_phrasetypes(boolean $doUcFirst = false)

Fetches an array of existing phrase types from the database

array
fetchEmailPhrases(string $email_phrase, array $email_vars = array(), array $emailsub_vars = array(), int $languageid = 0, string $emailsub_phrase = '')

Returns message and subject for an email.

array
renderPhrases($phrases, $languageid = null)

Returns rendered phrases from phrase strings and/or data

clearPhraseCache()

Clears the phrase cache, needed primarily for unit test.

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 32
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 74
array fetchByGroup(mixed $groups, int $languageid = NULL)

Fetch phrases by group

Parameters

mixed $groups Groups(s) to retrieve
int $languageid Language ID. If not set, it will use current session's languageid

Return Value

array Phrase' texts

at line 112
array getLanguageid(bool $getCharset = false)

Fetch the "best" languageid in the order of current session's languageid, the default languageid from datastore, or the master languageid (-1).

This is the languageid that's used by fetch().

Parameters

bool $getCharset (Optional) true to also return charset of current languageid. Default false.

Return Value

array 'languageid' => languageid used for current session's phrases

at line 164
array fetch(array $phrases, int $languageid = NULL) deprecated

deprecated -- use renderPhrases or getPhrases depending on if you

Fetch phrases

Parameters

array $phrases An array of phrase ID to be fetched
int $languageid Language ID. If not set, it will use current session's languageid, if passed a 0, use the current user/forum default language.

Return Value

array -- phraseid => phrase value

at line 186
array getPhrases(array $phrases, int $languageid = NULL)

Fetch raw phrases

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

array $phrases An array of phrase ID to be fetched
int $languageid Language ID. If not set, it will use current session's languageid, if passed a 0, use the current user/forum default language.

Return Value

array -- 'phrases' -- array(phraseid => phrase value)

at line 290
protected array parsePhrases($phrasesdata, $phrases = array(), $languageid = -1)

Handled output from query from fetch() and fetchByGroup()

Parameters

$phrasesdata
$phrases
$languageid

Return Value

array Phrases phrases

at line 332
array fetchOrphans()

Fetch orphan phrases

Return Value

array Orphan phrases

at line 345
void processOrphans(array $del, array $keep)

Process orphan phrases

Parameters

array $del Orphan phrases to be deleted. In format array('varname@fieldname')
array $keep Orphan phrases to be kept

Return Value

void

at line 372
array findUpdates()

Find custom phrases that need updating

Return Value

array Updated phrases

Search phrases

Parameters

array $criteria Criteria to search phrases. It may have the following items: 'searchstring' => Search for Text 'searchwhere' => Search in: 0 - Phrase Text Only, 1 - Phrase Variable Name Only, 2 - Phrase Text and Phrase Variable Name 'casesensitive' => Case-Sensitive 1 - Yes, 0 - No 'exactmatch' => Exact Match 1 - Yes, 0 - No 'languageid' => Search in Language. The ID of the language 'phrasetype' => Phrase Type. Phrase group IDs to search in. 'transonly' => Search Translated Phrases Only 1 - Yes, 0 - No 'product' => Product ID to search in.

Return Value

array Phrases

at line 502
void replace(array $replace, string $searchstring, string $replacestring, int $languageid)

Find and replace phrases in languages

Parameters

array $replace A list of phrase ID to be replaced
string $searchstring Search string
string $replacestring Replace string
int $languageid Language ID

Return Value

void

at line 566
void delete(int $phraseid)

Delete a phrase

Parameters

int $phraseid Pharse ID to be deleted

Return Value

void

at line 608
standard save(string $fieldname, string $varname, array $data)

Add a new phrase or update an existing phrase

Parameters

string $fieldname New Phrase Type for adding, old Phrase Type for editing
string $varname New Varname for adding, old Varname for editing
array $data 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

Return Value

standard success array

at line 624
array fetch_phrasetypes(boolean $doUcFirst = false)

Fetches an array of existing phrase types from the database

Parameters

boolean $doUcFirst If true, will return names run through ucfirst()

Return Value

array

at line 658
array fetchEmailPhrases(string $email_phrase, array $email_vars = array(), array $emailsub_vars = array(), int $languageid = 0, string $emailsub_phrase = '')

Returns message and subject for an email.

Parameters

string $email_phrase Name of email phrase to fetch
array $email_vars Variables for the email message phrase
array $emailsub_vars Variables for the email subject phrase
int $languageid Language ID from which to pull the phrase (see fetch_phrase $languageid) note that 0 means forum default language while null means the language for the current user. The former is the better default for this function because we rarely send email to the current user. However we should really be passing that in consistantly.
string $emailsub_phrase If not empty, select the subject phrase with the given name

Return Value

array

at line 690
array renderPhrases($phrases, $languageid = null)

Returns rendered phrases from phrase strings and/or data

Parameters

$phrases
$languageid

Return Value

array 'phrases' => array('key' => rendered phrase)

at line 766
clearPhraseCache()

Clears the phrase cache, needed primarily for unit test.