本文整理汇总了PHP中XenForo_Link::_buildLink方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Link::_buildLink方法的具体用法?PHP XenForo_Link::_buildLink怎么用?PHP XenForo_Link::_buildLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Link
的用法示例。
在下文中一共展示了XenForo_Link::_buildLink方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildApiLink
public static function buildApiLink($type, $data = null, array $extraParams = array(), $skipPrepend = false)
{
// the type MUST BE full:type
// NOTE: this is the opposite with public links
if (strpos($type, 'canonical:') === 0) {
// replace canonical: with full:
$type = str_replace('canonical:', 'full:', $type);
} elseif (strpos($type, 'full:') === false) {
// enforce full:
$type = 'full:' . $type;
}
// auto appends oauth_token param from the session
if (!isset($extraParams['oauth_token'])) {
$session = bdApi_Data_Helper_Core::safeGetSession();
if (!empty($session)) {
$oauthToken = $session->getOAuthTokenText();
if (!empty($oauthToken) && !empty($_REQUEST['oauth_token']) && $_REQUEST['oauth_token'] === $oauthToken) {
// only append token to built link if the current request has token in query too
// this will prevent token in links if it's requested with OTT, token in Auth header
// or token in body (PUT/POST requests)
$extraParams['oauth_token'] = $oauthToken;
}
}
}
$type = XenForo_Link::_checkForFullLink($type, $fullLink, $fullLinkPrefix);
$link = XenForo_Link::_buildLink(self::API_LINK_GROUP, $type, $data, $extraParams);
$queryString = XenForo_Link::buildQueryString($extraParams);
if ($link instanceof XenForo_Link) {
$canPrependFull = $link->canPrependFull();
} else {
$canPrependFull = true;
if (strpos($link, '#') !== false) {
list($link, $hash) = explode('#', $link);
}
}
if ($queryString !== '' && $link !== '') {
$append = "?{$link}&{$queryString}";
} else {
// 1 or neither of these has content
$append = $link . $queryString;
if ($append !== '') {
$append = "?{$append}";
}
}
if ($skipPrepend) {
$outputLink = $append;
} else {
$outputLink = 'index.php' . $append;
}
if ($fullLink && $canPrependFull) {
$outputLink = $fullLinkPrefix . $outputLink;
}
// deal with a hash in the $type {xen:link prefix#hash..}
if (($hashPos = strpos($type, '#')) !== false) {
$hash = substr($type, $hashPos + 1);
}
if ($outputLink === '') {
$outputLink = '.';
}
return $outputLink . (empty($hash) ? '' : '#' . $hash);
}