class vB_Api_Bbcode extends vB_Api

vB_Api_Bbcode

Traits

Constants

ALLOW_BBCODE_BASIC

ALLOW_BBCODE_COLOR

ALLOW_BBCODE_SIZE

ALLOW_BBCODE_FONT

ALLOW_BBCODE_ALIGN

ALLOW_BBCODE_LIST

ALLOW_BBCODE_URL

ALLOW_BBCODE_CODE

ALLOW_BBCODE_PHP

ALLOW_BBCODE_HTML

ALLOW_BBCODE_IMG

ALLOW_BBCODE_QUOTE

ALLOW_BBCODE_CUSTOM

ALLOW_BBCODE_USER

EDITOR_INDENT

Properties

protected bool $disabled Indicates whether the API was disabled from vB_Api
protected array $disableWhiteList Contains white listed methods which act as normal when API is disabled no matter of special scenarios like forum closed, password expiry, ip ban and others. from vB_Api
protected array $disableFalseReturnOnly {@inheritDoc} Methods include: getSignatureInfo
protected string $controller API Controller from vB_Api
protected vB_Database $db Database object. from vB_Api
protected array $customTags Contains an array of user specified custom BB code tags.

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()

Constructor

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
initInfo()

Returns an array of bbcode parsing information. {see vB_Api_Bbcode::fetchTagList}

array
fetchTagList(string $prepend_path = '', boolean $force_all = false)

Returns the list of default BB code tags

array
fetchCustomTags()

Loads any user specified custom BB code tags.

array
fetchBbcodeOptions()

Compiles and returns an array of various bbcode-related vboptions.

array
fetchCensorshipInfo()

Returns an array of information to apply censorship.

array
fetchSmilies()

Returns an array of smilie information.

mixed
extractVideo(string $rawtext)

Extracts the video and photo content from text.

string
parseWysiwygHtmlToBbcode(string $text)

Parses HTML produced by a WYSIWYG editor and produces the corresponding BBCode formatted text

string
convertWysiwygTextToBbcode(string $text, array $options)

Converts text from an editor into text ready to be saved with bbcode converted

string
convertUrlToBbcode(string $messagetext)

Converts URLs into bbcode with [URL]

text
convertUrlToBbcodePregReplace(array $matches)

Callback for preg_replace_callback in convertUrlToBbcode

bool
hasBbcode(string $text)

Determines if the text contains bbcode.

string
parseSignature($userid, $signature = false, $skipdupcheck = false) deprecated

Fetches and parses to html a user's signature

array
doParseSignature(int $userid, string|false $signature = false, bool $skipdupcheck = false)

Used by getSignatureInfo and parseSignatures to parse a signature

array
getSignatureInfo($userid, $signature = false, $skipdupcheck = false)

Fetches and parses to html a user's signature

array
parseSignatures(array $userIds, array $rawSignatures = array())

Fetches and parses to html signatures

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 64
protected __construct()

Constructor

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 81
array initInfo()

Returns an array of bbcode parsing information. {see vB_Api_Bbcode::fetchTagList}

Return Value

array Bbcode parsing information. Format:

array(
    defaultTags => array {see vB_Api_Bbcode::fetchTagList}
    customTags => array see vB_Api_Bbcode::fetchCustomTags
    defaultOptions => array {see vB_Api_Bbcode::fetchBbcodeOptions()}
)

See also

vB_Api_Bbcode::fetchTagList
vB_Api_Bbcode::fetchCustomTags

at line 119
array fetchTagList(string $prepend_path = '', boolean $force_all = false)

Returns the list of default BB code tags

Parameters

string $prepend_path Allows an optional path/URL to prepend to thread/post tags
boolean $force_all Force all BB codes to be returned?

Return Value

array Array of BB code tags. Format: array( defaultTags => array {see vB_Api_Bbcode::fetchTagList} customTags => array see vB_Api_Bbcode::fetchCustomTags defaultOptions => array {see vB_Api_Bbcode::fetchBbcodeOptions()} )

at line 547
protected array fetchCustomTags()

Loads any user specified custom BB code tags.

Return Value

array Array of custom BB code tags. Format:

              array(
                  option => array(
                      bbcode_tag => array(
                          html => replacement string
                          strip_empty => int
                          stop_parse => int
                          disable_smilies => int
                          disable_wordwrap => int
                      )
                      [...]
                  )
                  no_option => array(
                      bbcode_tag => array(
                          html => replacement string
                          strip_empty => int
                          stop_parse => int
                          disable_smilies => int
                          disable_wordwrap => int
                      )
                      [...]
                  )
              )
              

at line 596
protected array fetchBbcodeOptions()

Compiles and returns an array of various bbcode-related vboptions.

Return Value

array Array of various bbcode-related vboptions.

    array(
        privatemessage => array(
            allowhtml
            allowbbcode
            allowimagecode
            allowsmilies
        )
        nonforum => array(
            dohtml
            dobbcode
            doimagecode
            dosmilies
        )
        arrays similar to 'nonforum' for visitormessage, groupmessage,
            picturecomment, and socialmessage.
    )
    

at line 643
protected array fetchCensorshipInfo()

Returns an array of information to apply censorship.

Return Value

array Censorship information.

    array(
        words => array() // array of words that should be redacted
        char => censor char from vboption 'censorchar'
    )
    

at line 664
array fetchSmilies()

Returns an array of smilie information.

Return Value

array Smilie information corresponding to the data in the "smilie" field, with one extra column "smilielen".

at line 689
mixed extractVideo(string $rawtext)

Extracts the video and photo content from text.

Parameters

string $rawtext Rawtext from a post

Return Value

mixed Array of 'url', 'provider', 'code'

at line 738
string parseWysiwygHtmlToBbcode(string $text)

Parses HTML produced by a WYSIWYG editor and produces the corresponding BBCode formatted text

Parameters

string $text HTML text

Return Value

string BBCode text

at line 754
string convertWysiwygTextToBbcode(string $text, array $options)

Converts text from an editor into text ready to be saved with bbcode converted

Parameters

string $text Text to convert
array $options Options - autoparselinks

Return Value

string Converted Text

at line 775
string convertUrlToBbcode(string $messagetext)

Converts URLs into bbcode with [URL]

Parameters

string $messagetext Text potentially containing a URL

Return Value

string Converted text

at line 816
protected text convertUrlToBbcodePregReplace(array $matches)

Callback for preg_replace_callback in convertUrlToBbcode

Parameters

array $matches Array of matches from preg_replace_callback

Return Value

text Text with the URLs converted to BBcode

at line 889
bool hasBbcode(string $text)

Determines if the text contains bbcode.

Parameters

string $text Text to test

Return Value

bool True if the text contains valid bbcode, false if not.

at line 913
string parseSignature($userid, $signature = false, $skipdupcheck = false) deprecated

deprecated Please use getSignatureInfo instead

Fetches and parses to html a user's signature

Parameters

$userid
$signature
$skipdupcheck

Return Value

string the parsed (html) signature

at line 943
protected array doParseSignature(int $userid, string|false $signature = false, bool $skipdupcheck = false)

Used by getSignatureInfo and parseSignatures to parse a signature

Parameters

int $userid User ID
string|false $signature (Optional) Signature text or false if unknown
bool $skipdupcheck (Optional) Flag to control skipping the dupe check or not.

Return Value

array Array containing the parsed signature:

                     array(
                         signature => parsed signature
                         allowed => array of bbcode tags the user is allowed to use in their signature
                         disabled => array of bbcode tags the user is NOT allowed to use in their signature
                     )
                     

at line 997
array getSignatureInfo($userid, $signature = false, $skipdupcheck = false)

Fetches and parses to html a user's signature

Parameters

$userid
$signature
$skipdupcheck

Return Value

array Array containing the parsed signature: (same as {see doParseSignature})

               array(
                   signature => parsed HTML signature
                   allowed => array of bbcode tags the user is allowed to use in their signature
                   disabled => array of bbcode tags the user is NOT allowed to use in their signature
               )
               

at line 1021
array parseSignatures(array $userIds, array $rawSignatures = array())

Fetches and parses to html signatures

Parameters

array $userIds
array $rawSignatures (Optional) Raw signatures to avoid fetching them again

Return Value

array the parsed (html) signatures keyed by the userid.