当前位置: 首页>>代码示例>>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;未经允许,请勿转载。