class vB_Api_Style extends vB_Api

vB_Api_Style

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 $library
protected $userContext
protected $cssFileLocation

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
getValidStyleFromPreference(array $stylePreference)

Get the style from the list of preferences -- will check that the desired styles exist and are available for the user to

fetchStyleVars(array $stylePreference)

Get Style Vars

array
fetchStyles($withdepthmark = false, $userselectonly = false, $nocache = false, $options = array())

Fetch All styles

array
insertStyle($title, $parentid, $userselect, $displayorder, $guid = '', $icon = '', $previewImage = '', $styleattributes = vB_Library_Style::ATTR_DEFAULT, $dateline = null)

Insert style

updateStyle(integer $dostyleid, string $title, integer $parentid, boolean $userselect, integer $displayorder, boolean $rebuild = false, string $guid = '', binary $icon = '', boolean $iconRemove = false, binary $previewImage = '', boolean $previewImageRemove = false)

Update style

addThemeData($dostyleid, $guid, $icon, $iconRemove, $previewImage, $previewImageRemove)

Adds theme data (GUID, icon, preview image) to a style if in debug mode. (used by update & insert)

deleteStyle($dostyleid, $skipRebuild = false)

Delete style

buildAllStyles($renumber = 0, $install = 0, $resetcache = false)

Builds all data from the template table into the fields in the style table

generateStyle($scheme, $type, $parentid, $title, $displayorder = 1, $userselect = false)

No description

string.
fetchCssLocation()

gets the css File Location, which only means something if storecssasfiles is set to 2.

array
getThemeInfo()

Returns an array of theme information if the user has permission.

array
setDefaultStyle(int $styleid)

Sets the site default style

array
checkCanImportStyleXML(string $xmlString)

This is used mostly by the adminCP style importer. This checks if the current user has enough permissions to import the specified XML data.

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 31
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 43
getValidStyleFromPreference(array $stylePreference)

Get the style from the list of preferences -- will check that the desired styles exist and are available for the user to

Parameters

array $stylePreference -- various styles in the order we should check them

at line 54
fetchStyleVars(array $stylePreference)

Get Style Vars

Parameters

array $stylePreference -- various styles in the order we should check them

at line 81
array fetchStyles($withdepthmark = false, $userselectonly = false, $nocache = false, $options = array())

Fetch All styles

Parameters

$withdepthmark
$userselectonly
$nocache
$options

Return Value

array All styles' information

at line 123
array insertStyle($title, $parentid, $userselect, $displayorder, $guid = '', $icon = '', $previewImage = '', $styleattributes = vB_Library_Style::ATTR_DEFAULT, $dateline = null)

Insert style

Parameters

$title
$parentid
$userselect
$displayorder
$guid
$icon
$previewImage
$styleattributes
$dateline

Return Value

array array('styleid' => newstyleid)

at line 191
updateStyle(integer $dostyleid, string $title, integer $parentid, boolean $userselect, integer $displayorder, boolean $rebuild = false, string $guid = '', binary $icon = '', boolean $iconRemove = false, binary $previewImage = '', boolean $previewImageRemove = false)

Update style

Parameters

integer $dostyleid Style ID to be updated.
string $title Style title.
integer $parentid New parent style ID for the style.
boolean $userselect Whether user is able to choose the style.
integer $displayorder Display order of the style.
boolean $rebuild Whether to rebuild style
string $guid Theme GUID
binary $icon Theme icon
boolean $iconRemove Whether to remove the current icon (if there is one, and we're not uploading a new one)
binary $previewImage Theme preview image
boolean $previewImageRemove Whether to remove the current preview image (if there is one, and we're not uploading a new one)

at line 270
protected addThemeData($dostyleid, $guid, $icon, $iconRemove, $previewImage, $previewImageRemove)

Adds theme data (GUID, icon, preview image) to a style if in debug mode. (used by update & insert)

Parameters

$dostyleid
$guid
$icon
$iconRemove
$previewImage
$previewImageRemove

at line 349
deleteStyle($dostyleid, $skipRebuild = false)

Delete style

Parameters

$dostyleid
$skipRebuild

at line 454
buildAllStyles($renumber = 0, $install = 0, $resetcache = false)

Builds all data from the template table into the fields in the style table

Parameters

$renumber
$install
$resetcache

at line 469
generateStyle($scheme, $type, $parentid, $title, $displayorder = 1, $userselect = false)

Parameters

$scheme
$type
$parentid
$title
$displayorder
$userselect

at line 575
string. fetchCssLocation()

gets the css File Location, which only means something if storecssasfiles is set to 2.

Return Value

string.

at line 615
array getThemeInfo()

Returns an array of theme information if the user has permission.

The theme parent style is skipped.

Return Value

array array where each element contains an array of theme information, eg: array( "themes" => array( 0 => array( "styleid" => {theme1's styleid} "title" => {theme1's title}, "iconurl" => {URL to theme1's icon}, "previewurl" => {URL to theme1's preview image (empty if there is no preview image)}, ), 1 => array( "styleid" => {theme2's styleid} "title" => {theme2's title}, "iconurl" => {URL to theme2's icon}, "previewurl" => {URL to theme2's preview image (empty if there is no preview image)}, ), [...] ) )

at line 730
array setDefaultStyle(int $styleid)

Sets the site default style

Parameters

int $styleid Styleid to set as default

Return Value

array Array containing the bool 'success' element

at line 760
array checkCanImportStyleXML(string $xmlString)

This is used mostly by the adminCP style importer. This checks if the current user has enough permissions to import the specified XML data.

Caller using this function must ensure that the $xmlString data matches what's in an uploaded XML file, if they are separately specified.

Parameters

string $xmlString XML data

Return Value

array Array containing the bool 'canimport' & string 'reason'. - canimport : true if user has enough perms - reason : only set if canimport is false. Phrase label for the reason why the current user cannot import the XML.