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


PHP KunenaRoute::time方法代码示例

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


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

示例1: KunenaParseRoute

function KunenaParseRoute($segments)
{
    // If Kunena Forum isn't installed do nothing
    if (!class_exists('KunenaForum') || !KunenaForum::isCompatible('3.0') || !KunenaForum::installed()) {
        return array();
    }
    $profiler = JProfiler::getInstance('Application');
    KUNENA_PROFILER ? $profiler->mark('kunenaRoute') : null;
    $starttime = $profiler->getmicrotime();
    // Get current menu item and get query variables from it
    $active = JFactory::getApplication()->getMenu()->getActive();
    $vars = isset($active->query) ? $active->query : array('view' => 'home');
    if (empty($vars['view']) || $vars['view'] == 'home' || $vars['view'] == 'entrypage') {
        $vars['view'] = '';
    }
    // Use category SEF feature?
    $sefcats = isset(KunenaRoute::$sefviews[$vars['view']]) && empty($vars['id']);
    // Handle all segments
    while (($segment = array_shift($segments)) !== null) {
        // Skip //
        if (!$segment) {
            continue;
        }
        if ($sefcats && class_exists('KunenaRoute') && method_exists('KunenaRoute', 'resolveAlias')) {
            // Find out if we have SEF alias (category, view or layout)
            $alias = strtr($segment, ':', '-');
            $variables = KunenaRoute::resolveAlias($alias);
            if ($variables) {
                $sefcats = false;
                $vars = $variables + $vars;
                continue;
            }
        }
        $sefcats = false;
        // Generate variable and value
        $seg = explode(':', $segment);
        $var = array_shift($seg);
        $value = array_shift($seg);
        if (empty($var) && empty($value)) {
            // Skip /-/
            continue;
        }
        if (is_numeric($var)) {
            // Handle variables starting by number
            $value = (int) $var;
            if ($vars['view'] == 'user') {
                // Special case: User view
                $var = 'userid';
            } elseif (empty($vars['catid'])) {
                // First number is always category
                $var = 'catid';
                $vars['view'] = 'category';
            } elseif (empty($vars['id'])) {
                // Second number is always topic
                $var = 'id';
                $vars['view'] = 'topic';
                $sefcats = false;
            } elseif (empty($vars['mesid'])) {
                // Third number is always message
                $var = 'mesid';
                $vars['view'] = 'topic';
            } else {
                // Invalid parameter, skip it
                continue;
            }
        } elseif ($value === null) {
            // Simple variable without value is always either view or layout
            $value = $var;
            if (empty($vars['view']) || $value == 'topic' && $vars['view'] == 'category') {
                // View
                $var = 'view';
            } elseif (empty($vars['layout'])) {
                // Layout
                $var = 'layout';
            } elseif (!empty($vars['view'])) {
                // Unknown parameter: skip
                if (!empty($vars['view'])) {
                    continue;
                }
            } else {
                // Unknown view or non-existing category
                $var = 'view';
            }
        }
        $vars[$var] = $value;
    }
    if (empty($vars['layout'])) {
        $vars['layout'] = 'default';
    }
    KunenaRoute::$time = $profiler->getmicrotime() - $starttime;
    foreach ($vars as $var => $value) {
        KunenaRoute::$current->setVar($var, $value);
    }
    return $vars;
}
开发者ID:madcsaba,项目名称:li-de,代码行数:95,代码来源:router.php


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