当前位置: 首页>>代码示例>>PHP>>正文


PHP seo::convertURI方法代码示例

本文整理汇总了PHP中seo::convertURI方法的典型用法代码示例。如果您正苦于以下问题:PHP seo::convertURI方法的具体用法?PHP seo::convertURI怎么用?PHP seo::convertURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在seo的用法示例。


在下文中一共展示了seo::convertURI方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parseURI

 /**
  * Parse SEO URI for setRouteByPathInfo.
  *
  * @param uri
  * return string
  */
 public static function parseURI($uri)
 {
     global $config;
     if (!helper::inSeoMode()) {
         return $uri;
     }
     $categoryAlias = $config->seo->alias->category;
     $pageAlias = $config->seo->alias->page;
     $forumAlias = isset($config->seo->alias->forum) ? $config->seo->alias->forum : array();
     $methodAlias = $config->seo->alias->method;
     $params = array();
     if (strpos($uri, '_') !== false) {
         $uri = substr($uri, 0, strpos($uri, '_'));
     }
     /* Is there a pageID variable in the url?  */
     $pageID = 0;
     if (preg_match('/\\/p\\d+$/', $uri, $matches)) {
         $pageID = str_replace('/p', '', $matches[0]);
         // Get pageID thus the flowing logic can use it.
         $uri = str_replace($matches[0], '', $uri);
         // Remove the pageID part from the url.
     }
     /* Split uri to items and try to get module and params from it. */
     $items = explode('/', $uri);
     $module = $items[0];
     /* Use book instead of help. */
     if ($module == 'help') {
         $module = $items[0] = 'book';
     }
     /* There's no '/' in uri. */
     if (strpos($uri, '/') === false) {
         /* Use book instead of help. */
         if ($uri == 'help') {
             $uri = 'book';
         }
         if ($pageID and $module == 'blog' and count($items) == 1) {
             $params['category'] = 0;
             return seo::convertURI($module, 'index', $params, $pageID);
         }
         /* Not an alias, return directly. */
         if (empty($categoryAlias[$uri])) {
             return $uri;
         }
         /* The module is an alias of a category. */
         $module = $categoryAlias[$uri]->module;
         $params['category'] = $categoryAlias[$uri]->category;
         return seo::convertURI($module, 'browse', $params, $pageID);
     }
     /* Is the module an alias of a category? */
     if (isset($categoryAlias[$module])) {
         $category = $categoryAlias[$module]->category;
         // Get the category.
         $module = $categoryAlias[$module]->module;
         // Get the module of the alias category.
         /* If the first param is number, like article/123.html, should call view method. */
         if (is_numeric($items[1])) {
             $params['id'] = $items[1];
             return seo::convertURI($module, 'view', $params, $pageID);
         } else {
             if (!empty($items[1])) {
                 $viewparams = explode('-', $items[1]);
                 $id = end($viewparams);
             }
             if (is_numeric($id)) {
                 $params['id'] = $id;
                 return seo::convertURI($module, 'view', $params, $pageID);
             }
         }
         $params['category'] = $category;
         return seo::convertURI($module, 'browse', $params, $pageID);
     }
     //------------- The module is an system module-------------- */
     /* Is the module an alias of a page. */
     if ($module == 'page' && isset($pageAlias[$items[1]])) {
         $params['page'] = $items[1];
         return seo::convertURI($module, 'view', $params, $pageID);
     }
     if ($module == 'page' && !isset($pageAlias[$items[1]])) {
         $params['page'] = $items[1];
         return seo::convertURI($module, 'view', $params, $pageID);
     }
     if ($module == 'book' && count($items) > 2) {
         $uri = str_replace('/' . $items[1], '', $uri);
         $items[1] = $items[2];
     }
     if ($module == 'forum' && isset($pageAlias[$items[1]])) {
         $method = $methodAlias[$module]['browse'];
         return seo::convertURI($module, $method, $params, $pageID);
     }
     /*  If the first param is a category id, like news/c123.html. */
     if (preg_match('/^c\\d+$/', $items[1])) {
         $params['category'] = str_replace('c', '', $items[1]);
         $method = $methodAlias[$module]['browse'];
         return seo::convertURI($module, $method, $params, $pageID);
//.........这里部分代码省略.........
开发者ID:hansen1416,项目名称:eastsoft,代码行数:101,代码来源:seo.class.php


注:本文中的seo::convertURI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。