本文整理汇总了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;
}