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


PHP EasyBlogRouter::_encodeSegments方法代碼示例

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


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

示例1: EasyBlogParseRoute

function EasyBlogParseRoute(&$segments)
{
    JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
    $vars = array();
    $menu = JFactory::getApplication()->getMenu();
    $item = $menu->getActive();
    $config = EasyBlogHelper::getConfig();
    //feed view
    if (isset($segments[1])) {
        if ($segments[1] == 'rss' || $segments[1] == 'atom') {
            $vars['view'] = $segments[0];
            unset($segments);
            return $vars;
        }
    }
    // If user chooses to use the simple sef setup, we need to add the proper view
    if ($config->get('main_sef') == 'simple' && count($segments) == 1) {
        $files = JFolder::folders(JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'views');
        $views = array();
        foreach ($files as $file) {
            $views[] = EasyBlogSEFTranslation::_($file);
        }
        if (!in_array($segments[0], $views)) {
            array_unshift($segments, EasyBlogSEFTranslation::_('entry'));
        }
    }
    if ($config->get('main_sef') == 'simple' && count($segments) == 2 && $segments[0] == 'categories') {
        array_push($segments, EasyBlogSEFTranslation::_('listings'));
    }
    if (isset($segments[0]) && $segments[0] == EasyBlogSEFTranslation::_('entry')) {
        $count = count($segments);
        $entryId = '';
        if ($config->get('main_sef_unicode')) {
            // perform manual split on the string.
            $permalinkSegment = $segments[$count - 1];
            $permalinkArr = explode(':', $permalinkSegment);
            $entryId = $permalinkArr[0];
        } else {
            $table = EasyBlogHelper::getTable('Blog', 'Table');
            $table->load($segments[$count - 1], true);
            $entryId = $table->id;
        }
        if ($entryId) {
            $vars['id'] = $entryId;
        }
        $vars['view'] = 'entry';
    }
    if (isset($segments[0]) && $segments[0] == EasyBlogSEFTranslation::_('archive')) {
        $vars['view'] = 'archive';
        $count = count($segments);
        $totalSegments = $count - 1;
        if ($totalSegments >= 1) {
            $indexSegment = 1;
            if ($segments[1] == 'calendar') {
                $vars['layout'] = 'calendar';
                $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];
            }
        }
    }
    if (isset($segments[0]) && $segments[0] == EasyBlogSEFTranslation::_('categories')) {
        $count = count($segments);
        if ($count > 1) {
            $categoryId = '';
            if ($config->get('main_sef_unicode')) {
                $segmentIndex = $count - 1;
                if ($config->get('main_sef') == 'simple') {
                    $segmentIndex = 1;
                }
                // perform manual split on the string.
                $permalinkSegment = $segments[$segmentIndex];
                $permalinkArr = explode(':', $permalinkSegment);
                $categoryId = $permalinkArr[0];
            }
            $segments = EasyBlogRouter::_encodeSegments($segments);
            if (empty($categoryId)) {
                $table = EasyBlogHelper::getTable('Category', 'Table');
                $permalink = $segments[1];
                $table->load($permalink, true);
                if (!$table->id) {
                    $table->load($segments[$count - 1], true);
                }
                $categoryId = $table->id;
            }
            $vars['id'] = $categoryId;
            $vars['layout'] = 'listings';
        }
        $vars['view'] = 'categories';
    }
//.........這裏部分代碼省略.........
開發者ID:alexinteam,項目名稱:joomla3,代碼行數:101,代碼來源:router.php


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