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


PHP EBR::encodeSegments方法代碼示例

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


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

示例1: EasyBlogParseRoute


//.........這裏部分代碼省略.........
                $indexSegment = 2;
            }
            // First segment is always the year
            if (isset($segments[$indexSegment])) {
                $vars['archiveyear'] = $segments[$indexSegment];
            }
            // Second segment is always the month
            if (isset($segments[$indexSegment + 1])) {
                $vars['archivemonth'] = $segments[$indexSegment + 1];
            }
            // Third segment is always the day
            if (isset($segments[$indexSegment + 2])) {
                $vars['archiveday'] = $segments[$indexSegment + 2];
            }
        }
    }
    // Process categories sef links
    // index.php?option=com_easyblog&view=categories
    if (isset($segments[0]) && $segments[0] == EBR::translate('categories')) {
        // Set the view
        $vars['view'] = 'categories';
        // Get the total number of segments
        $count = count($segments);
        // Ensure that the first index is not a system layout
        $layouts = array('listings', 'simple');
        if ($count == 2 && !in_array($segments[1], $layouts)) {
            $id = null;
            // If unicode alias is enabled, just explode the data
            if ($config->get('main_sef_unicode')) {
                $tmp = explode(':', $segments[1]);
                $id = $tmp[0];
            }
            // Encode segments
            $segments = EBR::encodeSegments($segments);
            if (!$id) {
                $category = EB::table('Category');
                $category->load(array('alias' => $segments[1]));
                $id = $category->id;
            }
            $vars['id'] = $id;
            $vars['layout'] = 'listings';
        }
        // index.php?option=com_easyblog&view=categories&layout=simple
        if ($count == 2 && in_array($segments[1], $layouts)) {
            $vars['layout'] = $segments[1];
        }
    }
    if (isset($segments[0]) && $segments[0] == EBR::translate('tags')) {
        $count = count($segments);
        if ($count > 1) {
            $tagId = '';
            if ($config->get('main_sef_unicode')) {
                // perform manual split on the string.
                $permalinkSegment = $segments[$count - 1];
                $permalinkArr = explode(':', $permalinkSegment);
                $tagId = $permalinkArr[0];
            }
            $segments = EBR::encodeSegments($segments);
            if (empty($tagId)) {
                $table = EB::table('Tag');
                $table->load($segments[$count - 1], true);
                $tagId = $table->id;
            }
            $vars['id'] = $tagId;
            $vars['layout'] = 'tag';
        }
開發者ID:BetterBetterBetter,項目名稱:B3App,代碼行數:67,代碼來源:router.php


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