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


PHP KunenaRoute::getCurrentMenu方法代码示例

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


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

示例1: displayMenu

 function displayMenu()
 {
     jimport('joomla.application.module.helper');
     $position = "kunena_menu";
     $options = array('style' => 'xhtml');
     $modules = JModuleHelper::getModules($position);
     foreach ($modules as $module) {
         if ($module->module == 'mod_mainmenu' || $module->module == 'mod_menu') {
             $app = JFactory::getApplication();
             $menu = JSite::getMenu();
             $active = $menu->getActive();
             $basemenu = KunenaRoute::getCurrentMenu();
             if ($basemenu) {
                 $module = clone $module;
                 if (version_compare(JVERSION, '1.6', '>')) {
                     // Joomla 1.6+
                     $search = array('/"menutype":"([^"]*)"/i', '/"startLevel":"([^"]*)"/', '/"endLevel":"([^"]*)"/');
                     $replace = array("\"menutype\":\"{$basemenu->menutype}\"", '"startLevel":"' . ($basemenu->level + 1) . '"', '"endLevel":"' . ($basemenu->level + 2) . '"');
                 } else {
                     // Joomla 1.5
                     $search = array('/menutype=(.*)(\\s)/', '/startLevel=(.*)(\\s)/', '/endLevel=(.*)(\\s)/');
                     $replace = array("menutype={$basemenu->menutype}\\2", 'startLevel=' . ($basemenu->sublevel + 1) . '\\2', 'endLevel=' . ($basemenu->sublevel + 2) . '\\2');
                 }
                 $module->params = preg_replace($search, $replace, $module->params);
             } else {
                 if ($active) {
                     KunenaError::warning(JText::sprintf('COM_KUNENA_WARNING_NOMENU_ITEMID', $active->route, $active->id), 'nomenu');
                 } else {
                     KunenaError::warning(JText::sprintf('COM_KUNENA_WARNING_NOMENU_COMPONENT'), 'nomenu');
                 }
             }
         }
         echo JModuleHelper::renderModule($module, $options);
     }
 }
开发者ID:vuchannguyen,项目名称:hoctap,代码行数:35,代码来源:class.kunena.php

示例2: __construct

    function __construct()
    {
        ob_start();
        // Display time it took to create the entire page in the footer
        jimport('joomla.error.profiler');
        $__kstarttime = JProfiler::getmicrotime();
        $kunena_config = KunenaFactory::getConfig();
        kimport('error');
        KunenaError::initialize();
        // First of all take a profiling information snapshot for JFirePHP
        if (JDEBUG) {
            require_once JPATH_COMPONENT . '/lib/kunena.profiler.php';
            $__profiler = KProfiler::GetInstance();
            $__profiler->mark('Start');
        }
        $func = JString::strtolower(JRequest::getCmd('func', JRequest::getCmd('view', '')));
        $do = JRequest::getCmd('do', '');
        $task = JRequest::getCmd('task', '');
        $format = JRequest::getCmd('format', 'html');
        JRequest::setVar('func', $func);
        // Workaround for Joomla 1.7.3 login bug, see: https://github.com/joomla/joomla-platform/pull/740
        if ($func == 'profile' && ($task == 'login' || $task == 'logout')) {
            require_once KUNENA_PATH_FUNCS . '/profile.php';
            $page = new CKunenaProfile(JFactory::getUser()->id, $task);
        }
        require_once KUNENA_PATH . '/router.php';
        if ($func && !isset(KunenaRouter::$functions[$func])) {
            // If func is not legal, raise joomla error
            return JError::raiseError(404, 'Kunena function "' . $func . '" not found');
        }
        $kunena_app = JFactory::getApplication();
        if (empty($_POST) && $format == 'html') {
            $me = KunenaFactory::getUser();
            $menu = JSite::getMenu();
            $active = $menu->getActive();
            // Joomla 1.6+ multi-language support
            if (isset($active->language) && $active->language != '*') {
                $language = JFactory::getDocument()->getLanguage();
                if (strtolower($active->language) != strtolower($language)) {
                    $this->redirect(KunenaRoute::_(null, false));
                }
            }
            // Legacy menu item and Itemid=0 support with redirect and notice
            if (empty($active->query['view'])) {
                $new = $menu->getItem(KunenaRoute::getItemID());
                if ($new) {
                    if ($active) {
                        if ($active->route == $new->route) {
                            KunenaError::warning(JText::sprintf('COM_KUNENA_WARNING_MENU_CONFLICT', $active->route, $active->id, $new->id), 'menu');
                            $menu->setActive($new->id);
                            $active = $new;
                        } else {
                            KunenaError::warning(JText::sprintf('COM_KUNENA_WARNING_MENU_LEGACY', $active->route, $active->id, $new->route, $new->id), 'menu');
                            $this->redirect(KunenaRoute::_(null, false));
                        }
                    } else {
                        KunenaError::warning(JText::sprintf('COM_KUNENA_WARNING_MENU_NO_ITEM_REDIRECT', $new->route, $new->id));
                        $this->redirect(KunenaRoute::_(null, false));
                    }
                } elseif (!$active) {
                    KunenaError::warning(JText::sprintf('COM_KUNENA_WARNING_MENU_NO_ITEM'));
                }
            }
            if (!$func || $func == 'entrypage') {
                // If we are currently in entry page, we need to show and highlight default menu item
                if (!empty($active->query['defaultmenu'])) {
                    $defaultitem = $active->query['defaultmenu'];
                    if ($defaultitem > 0) {
                        $newitem = $menu->getItem($defaultitem);
                        if (!$newitem) {
                            KunenaError::warning(JText::sprintf('COM_KUNENA_WARNING_MENU_NOT_EXISTS'), 'menu');
                        } elseif (empty($newitem->component) || $newitem->component != 'com_kunena') {
                            KunenaError::warning(JText::sprintf('COM_KUNENA_WARNING_MENU_NOT_KUNENA'), 'menu');
                        } elseif ($active->route == $newitem->route) {
                            // Special case: we are using Entry Page instead of menu alias and we have identical menu alias
                            if ($active->id != $newitem->id) {
                                $defaultitem = !empty($newitem->query['defaultmenu']) ? $newitem->query['defaultmenu'] : $newitem->id;
                                $newitem2 = $menu->getItem($defaultitem);
                                if (empty($newitem2->component) || $newitem2->component != 'com_kunena') {
                                    $defaultitem = $newitem->id;
                                }
                                if ($defaultitem) {
                                    $menu->setActive($defaultitem);
                                    $active = $menu->getActive();
                                }
                            }
                        } else {
                            $oldlocation = KunenaRoute::getCurrentMenu();
                            $menu->setActive($defaultitem);
                            $active = $menu->getActive();
                            $newlocation = KunenaRoute::getCurrentMenu();
                            if (!$oldlocation || $oldlocation->id != $newlocation->id) {
                                // Follow Default Menu Item if it's not in the same menu
                                $this->redirect(KunenaRoute::_($defaultitem, false));
                            }
                        }
                        if (is_object($active)) {
                            foreach ($active->query as $var => $value) {
                                if ($var == 'view') {
                                    $var = 'func';
//.........这里部分代码省略.........
开发者ID:redigy,项目名称:Kunena-1.6,代码行数:101,代码来源:kunena.php


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