Helper methods to generate links to content.

Links generated by this are not necessarily HTML escaped. The calling code should escape them for the output context they apply to.

package XenForo_Core

 Methods

Constructor.

__construct(string $linkString, boolean $canPrependFull) 

Use the static methods in general. However, you can create an object of this type from a link builder to generate an arbitrary URL.

Parameters

$linkString

string

$canPrependFull

boolean

True if the default full link prefix can be prepended to make a full URL

__toString()

__toString() : string

Returns

stringLink

Builds a basic link for a request that may have an integer param.

buildBasicLinkWithIntegerParam(string $prefix, string $action, string $extension, mixed $data, string $intField, string $titleField) : false | string

Output will be in the format [prefix]/[title].[int]/[action]/ or similar, based on whether the correct values in data are set.

Parameters

$prefix

string

Link prefix

$action

string

Link action

$extension

string

Link extension (for content type)

$data

mixed

Specific data to link to. If available, an array or an object that implements ArrayAccess

$intField

string

The name of the field that holds the integer identifier

$titleField

string

If there is a title field, the name of the field that holds the title

Returns

falsestringFalse if no data is provided, the link otherwise

Builds a basic link for a request that may have a string param.

buildBasicLinkWithStringParam(string $prefix, string $action, string $extension, mixed $data, string $strField) : false | string

Output will be in the format [prefix]/[param]/[action].

Note that it is expected that the string param is already clean enough to be inserted into the link.

Parameters

$prefix

string

Link prefix

$action

string

Link action

$extension

string

Link extension (for content type)

$data

mixed

Specific data to link to. If available, an array or an object that implements ArrayAccess, or a simple string to be used directly

$strField

string

The name of the field that holds the string identifier

Returns

falsestringFalse if no data is provided, the link otherwise

Builds the URL component for an integer and title.

buildIntegerAndTitleUrlComponent(integer $integer, string $title, boolean $romanize) : string

Outputs or -.</p></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$integer</h4> <code>integer</code></div> <div class="subelement argument"> <h4>$title</h4> <code>string</code></div> <div class="subelement argument"> <h4>$romanize</h4> <code>boolean</code><p>If true, non-latin strings are romanized</p> </div> <h3>Returns</h3> <div class="subelement response"> <code>string</code></div> </div></div> </div> <a name="buildPublicLink" id="buildPublicLink"></a><div class="element clickable method public buildPublicLink" data-toggle="collapse" data-target=".buildPublicLink .collapse"> <h2>Builds a link to a public resource.</h2> <pre>buildPublicLink(string $type, mixed $data, array $extraParams, $skipPrepend) : string</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"><p>The type should contain a prefix optionally split by a "/" with the specific action (eg "templates/edit").</p></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$type</h4> <code>string</code><p>Prefix and action</p></div> <div class="subelement argument"> <h4>$data</h4> <code>mixed</code><p>Data that the prefix/action should be applied to, if applicable</p> </div> <div class="subelement argument"> <h4>$extraParams</h4> <code>array</code><p>Additional params</p></div> <div class="subelement argument"> <h4>$skipPrepend</h4></div> <h3>Returns</h3> <div class="subelement response"> <code>string</code>The link</div> </div></div> </div> <a name="buildQueryString" id="buildQueryString"></a><div class="element clickable method public buildQueryString" data-toggle="collapse" data-target=".buildQueryString .collapse"> <h2>Builds a query string from an array of items.</h2> <pre>buildQueryString(array $elements, string $prefix) : string</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"><p>Keys of the array will become names of items in the query string. Nested arrays are supported.</p></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$elements</h4> <code>array</code><p>Elements to build the query string from</p></div> <div class="subelement argument"> <h4>$prefix</h4> <code>string</code><p>For nested arrays, specifies the base context we're in. Leave default unless wanting all elements inside an array.</p> </div> <h3>Returns</h3> <div class="subelement response"> <code>string</code></div> </div></div> </div> <a name="buildSubComponentLink" id="buildSubComponentLink"></a><div class="element clickable method public buildSubComponentLink" data-toggle="collapse" data-target=".buildSubComponentLink .collapse"> <h2>Builds a link along the lines of <prefix>/<sub-component>/<data.id>/<action>.</h2> <pre>buildSubComponentLink(array $subComponents, string $outputPrefix, string $action, string $extension, mixed $data) : string | false</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$subComponents</h4> <code>array</code><p>List of sub-components that are valid as keys, with specific child keys (title, intId, stringId)</p> </div> <div class="subelement argument"> <h4>$outputPrefix</h4> <code>string</code></div> <div class="subelement argument"> <h4>$action</h4> <code>string</code></div> <div class="subelement argument"> <h4>$extension</h4> <code>string</code></div> <div class="subelement argument"> <h4>$data</h4> <code>mixed</code></div> <h3>Returns</h3> <div class="subelement response"> <code>string</code><code>false</code>String if sub-component matched with appropriate data, false otherwise</div> </div></div> </div> <a name="canPrependFull" id="canPrependFull"></a><div class="element clickable method public canPrependFull" data-toggle="collapse" data-target=".canPrependFull .collapse"> <h2>canPrependFull() </h2> <pre>canPrependFull() : boolean</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"></p> <h3>Returns</h3> <div class="subelement response"> <code>boolean</code></div> </div></div> </div> <a name="convertUriToAbsoluteUri" id="convertUriToAbsoluteUri"></a><div class="element clickable method public convertUriToAbsoluteUri" data-toggle="collapse" data-target=".convertUriToAbsoluteUri .collapse"> <h2>Converts what may be a relative link into an absolute URI.</h2> <pre>convertUriToAbsoluteUri(string $uri, boolean $includeHost, array $paths) : string</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$uri</h4> <code>string</code><p>URI to convert</p></div> <div class="subelement argument"> <h4>$includeHost</h4> <code>boolean</code><p>If true, includes host, port, and protocol</p></div> <div class="subelement argument"> <h4>$paths</h4> <code>array</code><code>null</code><p>Paths to override (uses application level if not provided)</p> </div> <h3>Returns</h3> <div class="subelement response"> <code>string</code></div> </div></div> </div> <a name="getCanonicalLinkPrefix" id="getCanonicalLinkPrefix"></a><div class="element clickable method public getCanonicalLinkPrefix" data-toggle="collapse" data-target=".getCanonicalLinkPrefix .collapse"> <h2>Gets the canonical link prefix to use for generating canonical links.</h2> <pre>getCanonicalLinkPrefix() : string</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"></p> <h3>Returns</h3> <div class="subelement response"> <code>string</code></div> </div></div> </div> <a name="getPageNumberAsAction" id="getPageNumberAsAction"></a><div class="element clickable method public getPageNumberAsAction" data-toggle="collapse" data-target=".getPageNumberAsAction .collapse"> <h2>Examines action and extra parameters from a link build call and formulates a page number link parameter if applicable.</h2> <pre>getPageNumberAsAction(string $action, array $params) : string</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$action</h4> <code>string</code></div> <div class="subelement argument"> <h4>$params</h4> <code>array</code></div> <h3>Returns</h3> <div class="subelement response"> <code>string</code>$action</div> </div></div> </div> <a name="getPrefixHandlerClassName" id="getPrefixHandlerClassName"></a><div class="element clickable method public getPrefixHandlerClassName" data-toggle="collapse" data-target=".getPrefixHandlerClassName .collapse"> <h2>Gets the name of the specified prefix handler class.</h2> <pre>getPrefixHandlerClassName(string $group, string $prefix) : string | false</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$group</h4> <code>string</code></div> <div class="subelement argument"> <h4>$prefix</h4> <code>string</code></div> <h3>Returns</h3> <div class="subelement response"> <code>string</code><code>false</code></div> </div></div> </div> <a name="getTitleForUrl" id="getTitleForUrl"></a><div class="element clickable method public getTitleForUrl" data-toggle="collapse" data-target=".getTitleForUrl .collapse"> <h2>Gets version of a title that is valid in a URL.</h2> <pre>getTitleForUrl(string $title, boolean $romanize) : string</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"><p>Invalid elements are stripped or replaced with '-'. It may not be possible to reverse a URL'd title to the original title.</p></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$title</h4> <code>string</code></div> <div class="subelement argument"> <h4>$romanize</h4> <code>boolean</code><p>If true, non-latin strings are romanized</p> </div> <h3>Returns</h3> <div class="subelement response"> <code>string</code></div> </div></div> </div> <a name="prepareExtensionAndAction" id="prepareExtensionAndAction"></a><div class="element clickable method public prepareExtensionAndAction" data-toggle="collapse" data-target=".prepareExtensionAndAction .collapse"> <h2>Prepares the link extension and action, if necessary.</h2> <pre>prepareExtensionAndAction(string $extension, string $action, $prepareAction) </pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"><p>If an extension is specified, the provided value will be prefixed with a ".". If there is an extension and there's no action, an explicit "index" action will be specified.</p></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$extension</h4> <code>string</code><p>Initially, the extension to the link specified; prefixed with "." if necessary</p> </div> <div class="subelement argument"> <h4>$action</h4> <code>string</code><p>The link action; modified if necessary</p></div> <div class="subelement argument"> <h4>$prepareAction</h4></div> </div></div> </div> <a name="resetHandlerInfo" id="resetHandlerInfo"></a><div class="element clickable method public resetHandlerInfo" data-toggle="collapse" data-target=".resetHandlerInfo .collapse"> <h2>Resets the handlers for all groups or for a particular group.</h2> <pre>resetHandlerInfo(string | false $group) </pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"><p>Mainly used for testing.</p></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$group</h4> <code>string</code><code>false</code><p>If false, resets all handlers; otherwise, resets the specified handler group</p></div> </div></div> </div> <a name="setCanonicalLinkPrefix" id="setCanonicalLinkPrefix"></a><div class="element clickable method public setCanonicalLinkPrefix" data-toggle="collapse" data-target=".setCanonicalLinkPrefix .collapse"> <h2>Set the prefix for links that are generated as canonical links.</h2> <pre>setCanonicalLinkPrefix(string $linkPrefix) </pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$linkPrefix</h4> <code>string</code></div> </div></div> </div> <a name="setHandlerInfoForGroup" id="setHandlerInfoForGroup"></a><div class="element clickable method public setHandlerInfoForGroup" data-toggle="collapse" data-target=".setHandlerInfoForGroup .collapse"> <h2>Helper to manually set handler info for a group.</h2> <pre>setHandlerInfoForGroup(string $group, array $info) </pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"><p>Keys should be "original prefixes" and values should be arrays with keys matching the xf_route_prefix table.</p></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$group</h4> <code>string</code><p>Type of prefix to handle (public or admin)</p> </div> <div class="subelement argument"> <h4>$info</h4> <code>array</code><p>Info to set</p></div> </div></div> </div> <a name="useFriendlyUrls" id="useFriendlyUrls"></a><div class="element clickable method public useFriendlyUrls" data-toggle="collapse" data-target=".useFriendlyUrls .collapse"> <h2>Sets whether friendly URLs should be used for generating links.</h2> <pre>useFriendlyUrls(boolean $value) </pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$value</h4> <code>boolean</code></div> </div></div> </div> <a name="_buildLink" id="_buildLink"></a><div class="element clickable method protected _buildLink" data-toggle="collapse" data-target="._buildLink .collapse"> <h2>Internal link builder.</h2> <pre>_buildLink(string $group, string $type, mixed $data, array $extraParams) : string</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$group</h4> <code>string</code><p>Type of link being built (admin or public)</p> </div> <div class="subelement argument"> <h4>$type</h4> <code>string</code><p>Type of data the link is for (prefix and action)</p> </div> <div class="subelement argument"> <h4>$data</h4> <code>mixed</code></div> <div class="subelement argument"> <h4>$extraParams</h4> <code>array</code></div> <h3>Returns</h3> <div class="subelement response"> <code>string</code></div> </div></div> </div> <a name="_checkForFullLink" id="_checkForFullLink"></a><div class="element clickable method protected _checkForFullLink" data-toggle="collapse" data-target="._checkForFullLink .collapse"> <h2>Check to see if a full link is requested.</h2> <pre>_checkForFullLink(string $type, boolean $fullLink, string $fullLinkPrefix) : string</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$type</h4> <code>string</code><p>Link type</p></div> <div class="subelement argument"> <h4>$fullLink</h4> <code>boolean</code><p>Modified by ref. Returns whether a full link is requested.</p></div> <div class="subelement argument"> <h4>$fullLinkPrefix</h4> <code>string</code><p>If a full link is requested, the prefix to use</p></div> <h3>Returns</h3> <div class="subelement response"> <code>string</code>Link type, with full link param stripped off if necessary</div> </div></div> </div> <a name="_getPrefixHandler" id="_getPrefixHandler"></a><div class="element clickable method protected _getPrefixHandler" data-toggle="collapse" data-target="._getPrefixHandler .collapse"> <h2>Gets the object that should handle building the link for this prefix.</h2> <pre>_getPrefixHandler(string $group, string $originalPrefix, boolean $haveData) : object | false</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"><p>May also return false if only the standard behavior is desired.</p></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$group</h4> <code>string</code><p>Type of link (public or admin)</p> </div> <div class="subelement argument"> <h4>$originalPrefix</h4> <code>string</code><p>Prefix to build the link for (should be the "original prefix" in the DB)</p> </div> <div class="subelement argument"> <h4>$haveData</h4> <code>boolean</code><p>Whether we have a data element</p></div> <h3>Returns</h3> <div class="subelement response"> <code>object</code><code>false</code>Object with "buildLink" method or false</div> </div></div> </div> <a name="_loadHandlerInfoForGroup" id="_loadHandlerInfoForGroup"></a><div class="element clickable method protected _loadHandlerInfoForGroup" data-toggle="collapse" data-target="._loadHandlerInfoForGroup .collapse"> <h2>Loads all the link build handler data for an entire group of prefixes.</h2> <pre>_loadHandlerInfoForGroup(string $group) : array</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$group</h4> <code>string</code><p>Type of prefix (public or admin)</p> </div> <h3>Returns</h3> <div class="subelement response"> <code>array</code>Keys are "original prefixes" and values are info about output prefix/class/build settings</div> </div></div> </div> <a name="_loadPrefixHandlerClass" id="_loadPrefixHandlerClass"></a><div class="element clickable method protected _loadPrefixHandlerClass" data-toggle="collapse" data-target="._loadPrefixHandlerClass .collapse"> <h2>Load the prefix link build handler class based on current settings.</h2> <pre>_loadPrefixHandlerClass(array $info, boolean $haveData) : object | false</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"> <p class="long_description"></p> <h3>Parameters</h3> <div class="subelement argument"> <h4>$info</h4> <code>array</code><p>Info about how to build this link (includes build_link, route_class keys)</p> </div> <div class="subelement argument"> <h4>$haveData</h4> <code>boolean</code><p>True if we have a data param for this link</p></div> <h3>Returns</h3> <div class="subelement response"> <code>object</code><code>false</code>Object with "buildLink" method or false</div> </div></div> </div> <h3> <i class="icon-custom icon-property"></i> Properties</h3> <a name="%24_canPrependFull" id="$_canPrependFull"> </a><div class="element clickable property protected $_canPrependFull" data-toggle="collapse" data-target=".$_canPrependFull .collapse"> <h2>$_canPrependFull</h2> <pre>$_canPrependFull </pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"><p class="long_description"></p></div></div> </div> <a name="%24_canonicalLinkPrefix" id="$_canonicalLinkPrefix"> </a><div class="element clickable property protected $_canonicalLinkPrefix" data-toggle="collapse" data-target=".$_canonicalLinkPrefix .collapse"> <h2>URL prefix to use when generating a canonical link.</h2> <pre>$_canonicalLinkPrefix : string | null</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"><p class="long_description"></p></div></div> </div> <a name="%24_handlerCache" id="$_handlerCache"> </a><div class="element clickable property protected $_handlerCache" data-toggle="collapse" data-target=".$_handlerCache .collapse"> <h2>Stores a cache of handlers for prefixes.</h2> <pre>$_handlerCache : array</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"><p class="long_description"><p>Many types of links will be generated multiple times on a page, so this cache reduces the amount of object creation/validation necessary.</p></p></div></div> </div> <a name="%24_linkString" id="$_linkString"> </a><div class="element clickable property protected $_linkString" data-toggle="collapse" data-target=".$_linkString .collapse"> <h2>$_linkString</h2> <pre>$_linkString </pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"><p class="long_description"></p></div></div> </div> <a name="%24_useFriendlyUrls" id="$_useFriendlyUrls"> </a><div class="element clickable property protected $_useFriendlyUrls" data-toggle="collapse" data-target=".$_useFriendlyUrls .collapse"> <h2>If true, uses friendly URLs that don't include index.php or a query string (unless required).</h2> <pre>$_useFriendlyUrls : boolean</pre> <div class="labels"></div> <div class="row collapse"><div class="detail-description"><p class="long_description"></p></div></div> </div> </div> </div> </div> </div> <div class="row"><footer class="span12"> Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br> Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a10</a> and<br> generated on 2013-04-30T01:57:42-05:00.<br></footer></div> </div> </body> </html>