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


PHP IPSText::makeSeoTransliterate方法代碼示例

本文整理匯總了PHP中IPSText::makeSeoTransliterate方法的典型用法代碼示例。如果您正苦於以下問題:PHP IPSText::makeSeoTransliterate方法的具體用法?PHP IPSText::makeSeoTransliterate怎麽用?PHP IPSText::makeSeoTransliterate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在IPSText的用法示例。


在下文中一共展示了IPSText::makeSeoTransliterate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: formatUrl

 /**
  * Formats the URL (.htaccess SEO, etc)
  *
  * @access	public
  * @param	string	Raw URL
  * @param	string	Any special SEO title passed
  * @param	string	Any special SEO template to use. If none is passed but SEO is enabled, IPB will search all templates for a match
  * @return	string	Formatted  URL
  */
 public function formatUrl($url, $seoTitle = '', $seoTemplate = '')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     if (!ipsRegistry::$settings['use_friendly_urls']) {
         return $url;
     }
     $seoTitle = IPSText::makeSeoTransliterate($seoTitle);
     $_template = FALSE;
     $seoTitle = !empty($seoTitle) && !is_array($seoTitle) ? array($seoTitle) : $seoTitle;
     $_seoTitleForCache = is_array($seoTitle) ? implode(';', $seoTitle) : '';
     $_md5 = md5($url . $_seoTitleForCache . $seoTemplate);
     $_s = '';
     $cached = $this->getCachedFurl($_md5);
     if (!is_null($cached)) {
         return $cached;
     }
     //-----------------------------------------
     // If using URL sessions, fix the URL...
     //-----------------------------------------
     if (!IN_ACP and strstr($url, 's=')) {
         preg_match("/s=([a-zA-Z0-9]{32})(.*?)\$/", $url, $matches);
         if (!empty($matches[2])) {
             $url = preg_replace("/s=([a-zA-Z0-9]{32})(&|&)/", '', $url);
             $_s = $matches[1];
         }
         if (strstr($url, 's=0')) {
             $url = preg_replace("/(\\?|&|;)s=0(&|&)/", '', $url);
             $_s = '';
         }
     }
     if ($this->settings['use_friendly_urls'] and is_array($seoTitle) && count($seoTitle)) {
         /* SEO Tweak - if default app is forums then don't bother with act=idx nonsense */
         if (IPS_DEFAULT_APP == 'forums' and !$this->settings['actidx_override']) {
             if (stristr($url, 'act=idx')) {
                 $url = str_ireplace(array(IPS_PUBLIC_SCRIPT . '?act=idx', '?act=idx', 'act=idx'), '', $url);
             }
         }
         if ($seoTemplate and isset($this->seoTemplates[$seoTemplate])) {
             $_template = $seoTemplate;
         }
         /* Need to search for one - fast? */
         if ($_template === FALSE) {
             /* Search for one, then. Possibly a bit slower than we'd like! */
             foreach ($this->seoTemplates as $key => $data) {
                 if (stristr(str_replace($this->settings['board_url'], '', $url), $key)) {
                     $_template = $key;
                     break;
                 }
             }
         }
         /* Got one to work with? */
         if ($_template !== FALSE) {
             if (count($seoTitle) == 1 && (substr($seoTitle[0], 0, 2) == '%%' and substr($seoTitle[0], -2) == '%%')) {
                 $seoTitle[0] = IPSText::makeSeoTitle(substr($seoTitle[0], 2, -2));
             }
             /* Do we need to encode? */
             if (IPS_DOC_CHAR_SET != 'UTF-8') {
                 foreach ($seoTitle as $id => $item) {
                     $seoTitle[$id] = urlencode($item);
                 }
             }
             if (count($seoTitle) == 1) {
                 $replace = str_replace('#{__title__}', IPSText::convertUnicode($seoTitle[0]), $this->seoTemplates[$_template]['out'][1]);
                 // See http://community.invisionpower.com/resources/bugs.html/_/ip-board/transliteration-r37146
             } else {
                 $replace = $this->seoTemplates[$_template]['out'][1];
                 foreach ($seoTitle as $id => $item) {
                     $replace = str_replace('#{__title-' . $id . '__}', IPSText::convertUnicode($item), $replace);
                     // See http://community.invisionpower.com/resources/bugs.html/_/ip-board/transliteration-r37146
                 }
             }
             $url = preg_replace($this->seoTemplates[$_template]['out'][0], $replace, $url);
             $_anchor = '';
             $__url = $url;
             /* Protect html entities */
             $url = preg_replace('/&#(\\d)/', "~|~\\1", $url);
             if (strstr($url, '&')) {
                 $restUrl = substr($url, strpos($url, '&'));
                 $url = substr($url, 0, strpos($url, '&'));
             } else {
                 $restUrl = '';
             }
             /* Anchor */
             if (strstr($restUrl, '#')) {
                 $_anchor = substr($restUrl, strpos($restUrl, '#'));
                 $restUrl = substr($restUrl, 0, strpos($restUrl, '#'));
             }
             switch ($this->settings['url_type']) {
                 case 'path_info':
//.........這裏部分代碼省略.........
開發者ID:Advanture,項目名稱:Online-RolePlay,代碼行數:101,代碼來源:publicOutput.php


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