當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XenForo_Link::_buildLink方法代碼示例

本文整理匯總了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);
 }
開發者ID:burtay,項目名稱:bdApi,代碼行數:61,代碼來源:Link.php


注:本文中的XenForo_Link::_buildLink方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。