Helper methods for the core template functions/tags.
package | XenForo_Template |
---|
addClass(string $class, string $classList) : string
string
Class to add / remove
string
Existing class defininition
string
adminLink(string $type, mixed $data, array $extraParams, callback | false $escapeCallback) : string
string
Type of data to link to. May also include a specific action.
mixed
Primary data about this link
array
Extra named params. Unhandled params will become the query string
callback
false
Callback method for escaping the link
string
adminPageNav(integer $perPage, integer $totalItems, integer $page, string $linkType, mixed $linkData, array $linkParams, array $options) : string | \XenForo_Template_Public
integer
Items to display per page
integer
Total number of items
integer
Current page number
string
Type of link to create
mixed
Data for the link
array
List of key value params for the link; page will be set as needed
array
Options to control the building
string
\XenForo_Template_Public
appendBreadCrumbs(array $existing, array $new) : array
array
Existing entries
array
New entries; if this is invalid, nothing will be appended
array
Existing entries with new entries appendedattributeTrue(mixed $attribute) : boolean
mixed
boolean
callHelper(string $helper, array $args) : string
string
Name of helper
array
All arguments passed to the helper.
string
convertUrlToActionAndNamedParams(string $url) : array
A route in the query string is converted to a named param "_".
string
array
Format: [action] => form action, [params] => key-value param pairsdate(integer $timestamp, string $format) : string
Format represents a string name of a format.
integer
Unix timestamp to format
string
Named format (name options TBD)
string
dateTime(integer $timestamp, string $format) : string
Format represents a string name of a format.
integer
Unix timestamp to format
string
Named format (name options TBD)
string
getAttributes(array $attributes) : string
array
string
' attr1="abc" attr2="def" attr3="ghi"'getAvatarUrl(array $user, string $size, string $forceType) : string
array
string
(s,m,l)
string
Force 'default' or 'custom' type
string
getAvatarUrls(array $user) : array
array
array
[$sizeCode => $url, $sizeCode => $url...]getDefaultLanguage() : array | null
array
null
getHiddenInputs(array $params) : string
array
string
getHiddenInputsFromUrl(string $url) : string
Note that the non-query string part of the URL will not be output in any way.
string
string
String of hidden form inputsgetInvalidStylePropertyAccessList() : array
getUserHref(array $user, array $attributes) : string
array
array
string
' href="members/example-user.234"' or emptyhelperAvatarCropCss(array $user)
array
helperAvatarHtml(array $user, boolean $img, array $attributes, string $content)
array
boolean
If true, use an tag, otherwise use a block with the avatar as a background image
array
Extra tag attributes
string
Additional tag contents (inserted after image element)
helperAvatarUrl(array $user, string $size, boolean $forceType, boolean $canonical) : string
array
User info
string
Size code
boolean
Serve the default gender avatar, even if the user has a custom avatar
boolean
Serve the full canonical URL
string
Path to avatarhelperBbCode(\XenForo_BbCode_Parser $parser, string $text) : string
helperBodyText(string $string) : string
HTML/BB code is not parsed within string.
string
string
helperDateTimeHtml(integer $timestamp, array $attributes) : string
integer
array
string
helperDump($data)
helperFollowHtml(array $user, array $attributes, string $wrapTag) : string
Designed to work with the XenForo.FollowLink javascript.
array
array
string
string
helperIgnoredCss(array $ignoredUsers)
helperImplode($data, $glue)
helperIsIgnored(integer | string $user, array $ignoredNames) : boolean
integer
string
boolean
helperIsMemberOf(array $user, $userGroupId, $multipleIds)
helperJavaScriptUrl($scriptUrl)
helperJson(mixed $data) : string
mixed
string
JSONhelperLikesHtml(integer $number, string $likesLink, integer $likeDate, array $users) : string
integer
Total number of likes
string
Link to page showing all users who liked this content
integer
Timestamp at which the visitor liked this content
array
Array of up to 3 users who liked this content - user_id, username required.
string
helperNodeClasses(array $nodeBreadCrumbs, array $currentNode) : string
array
array
string
'node5 node3 node1'helperPageNavHtml(string $callType, integer $perPage, integer $totalItems, integer $page, string $linkType, mixed $linkData, array $linkParams, string | false $unreadLink, array $options) : string
This simply ensures that some of the data is of the expected type.
string
Type of page to render: admin or public
integer
Items to display per page
integer
Total number of items
integer
Current page number
string
Type of link to create
mixed
Data for the link
array
List of key value params for the link; page will be set as needed
string
false
URL for to jump to the first unread
array
Options to control the building
string
helperPageNumber(integer $page) : string
integer
string
helperRichUserName(array $user, string $usernameHtml) : string
array
string
Alternative username HTML
string
helperSnippet(string $string, integer $maxLength, array $options) : string
string
Input text (bb code)
integer
array
Key-value options
string
HTMLhelperSortArrow(string $order, string $direction, string $fieldName, string $descOutput, string $ascOutput) : string
string
Name of the current ordering field
string
Direction (asc, desc)
string
Name of the field we're looking at
string
HTML to output for descending
string
HTML to output for ascending
string
helperStripHtml(string $string, string $allowedTags) : string
string
string
List of allowed tags for strip_tags
string
String with HTML removed or escaped if not removed.helperThreadPrefix(integer | array $prefixId, string $outputType, string | null $append) : string
Can take an array.
integer
array
Prefix ID or array with key of prefix_id
string
Type of output; options are html (marked up), plain (plain text), escaped (plain text escaped)
string
null
Value to append if there is a prefix (eg, a space); if null, defaults to space (html) or dash (plain)
string
helperThreadPrefixGroup($prefixGroupId)
helperTwitterLanguage($locale)
helperType($data)
helperUniqueId()
helperUserBlurb(array $user, boolean $includeUserTitle) : string
array
boolean
Include user title in blurb
string
helperUserFieldTitle($fieldId) : \XenForo_Phrase
helperUserFieldValue(array | string $field, array $user, mixed $fieldValue) : string | boolean
array
string
Either the field info array for a field, or just its field_id
array
User to whom the field belongs
mixed
Value of the field for $user
string
boolean
helperUserName(array $user, $class, $rich)
helperUserNameHtml(array $user, string $username, boolean $rich, array $attributes) : string
array
string
Used to override the username from $user
boolean
Render rich username markup
string
helperUserTitle(array $user, boolean $allowCustomTitle) : string
array
boolean
Allows the user title to come from the custom title
string
helperWordTrim(string $string, integer $trimLength)
string
integer
helperWrap(string $string, integer | null $breakLength)
string
integer
null
jsEscape(string $string, string $context) : string
The context represents whether it is within a double- or single-quoted string. This function does not support outputs in other contexts!
string
String to escape
string
Context (double or single)
string
link(string $type, mixed $data, array $extraParams, callback | false $escapeCallback) : string
string
Type of data to link to. May also include a specific action.
mixed
Primary data about this link
array
Extra named params. Unhandled params will become the query string
callback
false
Callback method for escaping the link
string
numberFormat(mixed $number, integer $decimals) : string
Behaves like PHP's number_format.
mixed
integer
string
pageNav(integer $perPage, integer $totalItems, integer $page, string $linkType, mixed $linkData, array $linkParams, array $options) : string | \XenForo_Template_Public
integer
Items to display per page
integer
Total number of items
integer
Current page number
string
Type of link to create
mixed
Data for the link
array
List of key value params for the link; page will be set as needed
array
Options to control the building
string
\XenForo_Template_Public
rawCondition(mixed $data, string $condition) : mixed
mixed
string
"Object" to return any object raw, otherwise a class name
mixed
Data escaped if neededresetInvalidStylePropertyAccessList()
setDefaultLanguage(array $language)
This should be unset after the specific context is complete.
array
null
setDisplayStyles(array $displayStyles)
array
setStyleProperties(array $properties, boolean $merge)
array
Style properties
boolean
True to merge with existing set
setThreadPrefixes(array $prefixes)
array
[prefix id] => class name
setUserTitles(array $userTitles)
array
string(string $functionList, array $args) : string
Function list is a string that may be delimited by " " (eg, 'nl2br trim'). Chained functions will be run from left to right. Chaining can only work when a single argument is provided. Functions requiring multiple args need separate calls.
string
array
string
styleProperty(string $propertyName) : string
See $_styleProperties for more information on the format. The property name may be in format "group" or "group.rule". Scalar properties cannot have a rule.
If no rule is specified, an entire group will be outputted, including rule names. If a rule is specified, only the value will be output.
string
string
time(integer $timestamp, string $format) : string
Format represents a string name of a format.
integer
Unix timestamp to format
string
Named format (name options TBD)
string
toggleClass(string $class, string $classList) : string
string
Class to add / remove
string
Existing class defininition
string
_getCustomAvatarUrl(array $user, string $size) : string
array
string
(s,m,l)
string
_getDefaultAvatarUrl(array $user, string $size) : string
string
(s,m,l)
string
_getGravatarUrl(array $user, string | integer $size, string $default)
array
string
integer
(s,m,l)
string
Override default (useful to use '404')
_getModelFromCache(string $modelName) : \XenForo_Model
_getPageNav(string $templateClass, string $linkFunction, integer $perPage, integer $totalItems, integer $currentPage, string $linkType, mixed $linkData, array $linkParams, array $options) : string | \XenForo_Template_Abstract
string
Name of the template class to instantiate
string
Name of the linking function to call (in this class)
integer
Items to display per page
integer
Total number of items
integer
Current page number
string
Type of link to create
mixed
Data for the link
array
List of key value params for the link; page will be set as needed
array
Options to control the building
_getPhraseText(string $phraseName) : string
string
string
__construct()
Don't instantiate this object. Use it statically.
$helperCallbacks : array
Maps the helper name (key) to a callback (value).
Data received by this callback is not escaped!
$stringCallbacks : array
To support chaining, the called function should tag the string as the first argument and only require one argument. If neither constraint is true, the function must be called on its own.
Data received by this call back may be escaped!
$_displayStyles : array
$_invalidStylePropertyAccess : array
If an invalid group is accessed: [group] => true; if an invalid property in a valid group is accessed: [group][property] => true.
$_language : array | null
Null uses the visitor's language.
$_modelCache : array
$_styleProperties : array
The first dimension is a group of properties; the second represents the actual rules. Rules should be keyed by the CSS property name so they can be output directly. Prefix non-direct CSS vars with an underscore.
$_threadPrefixes : array
$_uniqueId
$_userFieldsInfo : array
$_userFieldsValues : array
$_userTitles : array