예제 #1
0
 public static function renderMenus()
 {
     $menu = new JSNAdministratorMenu();
     $shownew = true;
     $showhelp = true;
     $user = JFactory::getUser();
     $lang = JFactory::getLanguage();
     //
     // Site SubMenu
     //
     $menu->addChild(new JAdministratorMenuNode(JText::_('JSITE'), '#'), true);
     $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_CONTROL_PANEL'), 'index.php', 'class:cpanel'));
     $menu->addSeparator();
     $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_USER_PROFILE'), 'index.php?option=com_admin&task=profile.edit&id=' . $user->id, 'class:profile'));
     $menu->addSeparator();
     if ($user->authorise('core.admin')) {
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_CONFIGURATION'), 'index.php?option=com_config', 'class:config'));
         $menu->addSeparator();
     }
     $chm = $user->authorise('core.admin', 'com_checkin');
     $cam = $user->authorise('core.manage', 'com_cache');
     if ($chm || $cam) {
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_MAINTENANCE'), 'index.php?option=com_checkin', 'class:maintenance'), true);
         if ($chm) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_GLOBAL_CHECKIN'), 'index.php?option=com_checkin', 'class:checkin'));
             $menu->addSeparator();
         }
         if ($cam) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_CLEAR_CACHE'), 'index.php?option=com_cache', 'class:clear'));
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_PURGE_EXPIRED_CACHE'), 'index.php?option=com_cache&view=purge', 'class:purge'));
         }
         $menu->getParent();
     }
     $menu->addSeparator();
     if ($user->authorise('core.admin')) {
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_SYSTEM_INFORMATION'), 'index.php?option=com_admin&view=sysinfo', 'class:info'));
         $menu->addSeparator();
     }
     $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_LOGOUT'), JRoute::_('index.php?option=com_login&task=logout&' . JSession::getFormToken() . '=1'), 'class:logout'));
     $menu->getParent();
     //
     // Users Submenu
     //
     if ($user->authorise('core.manage', 'com_users')) {
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_USERS_USERS'), '#'), true);
         $createUser = $shownew && $user->authorise('core.create', 'com_users');
         $createGrp = $user->authorise('core.admin', 'com_users');
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_USERS_USER_MANAGER'), 'index.php?option=com_users&view=users', 'class:user'), $createUser);
         if ($createUser) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_USERS_ADD_USER'), 'index.php?option=com_users&task=user.add', 'class:newarticle'));
             $menu->getParent();
         }
         if ($createGrp) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_USERS_GROUPS'), 'index.php?option=com_users&view=groups', 'class:groups'), $createUser);
             if ($createUser) {
                 $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_USERS_ADD_GROUP'), 'index.php?option=com_users&task=group.add', 'class:newarticle'));
                 $menu->getParent();
             }
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_USERS_LEVELS'), 'index.php?option=com_users&view=levels', 'class:levels'), $createUser);
             if ($createUser) {
                 $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_USERS_ADD_LEVEL'), 'index.php?option=com_users&task=level.add', 'class:newarticle'));
                 $menu->getParent();
             }
         }
         $menu->addSeparator();
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_USERS_NOTES'), 'index.php?option=com_users&view=notes', 'class:user-note'), $createUser);
         if ($createUser) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_USERS_ADD_NOTE'), 'index.php?option=com_users&task=note.add', 'class:newarticle'));
             $menu->getParent();
         }
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_USERS_NOTE_CATEGORIES'), 'index.php?option=com_categories&view=categories&extension=com_users.notes', 'class:category'), $createUser);
         if ($createUser) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_CONTENT_NEW_CATEGORY'), 'index.php?option=com_categories&task=category.add&extension=com_users', 'class:newarticle'));
             $menu->getParent();
         }
         $menu->addSeparator();
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_MASS_MAIL_USERS'), 'index.php?option=com_users&view=mail', 'class:massmail'));
         $menu->getParent();
     }
     //
     // Menus Submenu
     //
     if ($user->authorise('core.manage', 'com_menus')) {
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_MENUS'), '#'), true);
         $createMenu = $shownew && $user->authorise('core.create', 'com_menus');
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_MENU_MANAGER'), 'index.php?option=com_menus&view=menus', 'class:menumgr'), $createMenu);
         if ($createMenu) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_MENU_MANAGER_NEW_MENU'), 'index.php?option=com_menus&view=menu&layout=edit', 'class:newarticle'));
             $menu->getParent();
         }
         $menu->addSeparator();
         // Menu Types
         foreach (JSNPowerAdminMenuHelper::getMenus() as $menuType) {
             $alt = '*' . $menuType->sef . '*';
             if ($menuType->home == 0) {
                 $titleicon = '';
             } elseif ($menuType->home == 1 && $menuType->language == '*') {
                 $titleicon = ' <span><img src="' . JUri::root(true) . '/plugins/system/jsnpoweradmin/assets/images/menu/icon-16-default.png" alt="*" title="' . JText::_('MOD_MENU_HOME_DEFAULT') . '" /></span>';
             } elseif ($menuType->home > 1) {
                 $titleicon = ' <span><img src="' . JUri::root(true) . '/plugins/system/jsnpoweradmin/assets/images/menu/icon-16-language.png" alt="*" title="' . JText::_('MOD_MENU_HOME_MULTIPLE') . '" /></span>';
             } else {
                 $image = JHtml::_('image', 'mod_languages/' . $menuType->image . '.gif', NULL, NULL, true, true);
                 if (!$image) {
                     $titleicon = ' <span>' . JHtml::_('image', 'menu/icon-16-language.png', $alt, array('title' => $menuType->title_native), true) . '</span>';
                 } else {
                     $titleicon = ' <span>' . JHtml::_('image', 'mod_languages/' . $menuType->image . '.gif', $alt, array('title' => $menuType->title_native), true) . '</span>';
                 }
             }
             $menu->addChild(new JAdministratorMenuNode($menuType->title, 'index.php?option=com_menus&view=items&menutype=' . $menuType->menutype, 'class:menu', null, null, $titleicon), $createMenu);
             if ($createMenu) {
                 $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_MENU_MANAGER_NEW_MENU_ITEM'), 'index.php?option=com_menus&view=item&layout=edit&menutype=' . $menuType->menutype, 'class:newarticle'));
                 $menu->getParent();
             }
         }
         $menu->getParent();
     }
     //
     // Content Submenu
     //
     if ($user->authorise('core.manage', 'com_content')) {
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_CONTENT'), '#'), true);
         $createContent = $shownew && $user->authorise('core.create', 'com_content');
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_CONTENT_ARTICLE_MANAGER'), 'index.php?option=com_content', 'class:article'), $createContent);
         if ($createContent) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_CONTENT_NEW_ARTICLE'), 'index.php?option=com_content&task=article.add', 'class:newarticle'));
             $menu->getParent();
         }
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_CONTENT_CATEGORY_MANAGER'), 'index.php?option=com_categories&extension=com_content', 'class:category'), $createContent);
         if ($createContent) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_CONTENT_NEW_CATEGORY'), 'index.php?option=com_categories&task=category.add&extension=com_content', 'class:newarticle'));
             $menu->getParent();
         }
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COM_CONTENT_FEATURED'), 'index.php?option=com_content&view=featured', 'class:featured'));
         $menu->addSeparator();
         if ($user->authorise('core.manage', 'com_media')) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_MEDIA_MANAGER'), 'index.php?option=com_media', 'class:media'));
         }
         $menu->getParent();
     }
     //
     // Components Submenu
     //
     // Get the authorised components and sub-menus.
     $components = JSNPowerAdminMenuHelper::getComponents(true);
     // Check if there are any components, otherwise, don't render the menu
     if ($components) {
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_COMPONENTS'), '#'), true);
         foreach ($components as &$component) {
             if (!empty($component->submenu)) {
                 // This component has a db driven submenu.
                 $menu->addChild(new JAdministratorMenuNode($component->text, $component->link, $component->img), true);
                 foreach ($component->submenu as $sub) {
                     $menu->addChild(new JAdministratorMenuNode($sub->text, $sub->link, $sub->img));
                 }
                 $menu->getParent();
             } else {
                 $menu->addChild(new JAdministratorMenuNode($component->text, $component->link, $component->img));
             }
         }
         $menu->getParent();
     }
     //
     // Extensions Submenu
     //
     $im = $user->authorise('core.manage', 'com_installer');
     $mm = $user->authorise('core.manage', 'com_modules');
     $pm = $user->authorise('core.manage', 'com_plugins');
     $tm = $user->authorise('core.manage', 'com_templates');
     $lm = $user->authorise('core.manage', 'com_languages');
     if ($im || $mm || $pm || $tm || $lm) {
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_EXTENSIONS_EXTENSIONS'), '#'), true);
         if ($im) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_EXTENSIONS_EXTENSION_MANAGER'), 'index.php?option=com_installer', 'class:install'));
             $menu->addSeparator();
         }
         if ($mm) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_EXTENSIONS_MODULE_MANAGER'), 'index.php?option=com_modules', 'class:module'));
         }
         if ($pm) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_EXTENSIONS_PLUGIN_MANAGER'), 'index.php?option=com_plugins', 'class:plugin'));
         }
         if ($tm) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_EXTENSIONS_TEMPLATE_MANAGER'), 'index.php?option=com_templates', 'class:themes'));
         }
         if ($lm) {
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_EXTENSIONS_LANGUAGE_MANAGER'), 'index.php?option=com_languages', 'class:language'));
         }
         $menu->getParent();
     }
     //
     // Help Submenu
     //
     if ($showhelp == 1) {
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_HELP'), '#'), true);
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_HELP_JOOMLA'), 'index.php?option=com_admin&view=help', 'class:help'));
         $menu->addSeparator();
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_HELP_SUPPORT_OFFICIAL_FORUM'), 'http://forum.joomla.org', 'class:help-forum', false, '_blank'));
         $debug = $lang->setDebug(false);
         if ($lang->hasKey('MOD_MENU_HELP_SUPPORT_OFFICIAL_LANGUAGE_FORUM_VALUE') && JText::_('MOD_MENU_HELP_SUPPORT_OFFICIAL_LANGUAGE_FORUM_VALUE') != '') {
             $forum_url = 'http://forum.joomla.org/viewforum.php?f=' . (int) JText::_('MOD_MENU_HELP_SUPPORT_OFFICIAL_LANGUAGE_FORUM_VALUE');
             $lang->setDebug($debug);
             $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_HELP_SUPPORT_OFFICIAL_LANGUAGE_FORUM'), $forum_url, 'class:help-forum', false, '_blank'));
         }
         $lang->setDebug($debug);
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_HELP_DOCUMENTATION'), 'http://docs.joomla.org', 'class:help-docs', false, '_blank'));
         $menu->addSeparator();
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_HELP_LINKS'), '#', 'class:weblinks'), true);
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_HELP_EXTENSIONS'), 'http://extensions.joomla.org', 'class:help-jed', false, '_blank'));
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_HELP_TRANSLATIONS'), 'http://community.joomla.org/translations.html', 'class:help-trans', false, '_blank'));
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_HELP_RESOURCES'), 'http://resources.joomla.org', 'class:help-jrd', false, '_blank'));
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_HELP_COMMUNITY'), 'http://community.joomla.org', 'class:help-community', false, '_blank'));
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_HELP_SECURITY'), 'http://developer.joomla.org/security.html', 'class:help-security', false, '_blank'));
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_HELP_DEVELOPER'), 'http://developer.joomla.org', 'class:help-dev', false, '_blank'));
         $menu->addChild(new JAdministratorMenuNode(JText::_('MOD_MENU_HELP_SHOP'), 'http://shop.joomla.org', 'class:help-shop', false, '_blank'));
         $menu->getParent();
         $menu->getParent();
     }
     ob_start();
     $menu->renderMenu();
     $content = ob_get_clean();
     return $content;
 }
 /**
  * Before render needs using this function to make format of HTML of modules
  *
  * @return: Changed HTML format
  */
 public function onBeforeRender()
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     // Load custom assets for each menu
     if (!$this->_application->isAdmin() && $this->_params->get('custom_assets_enhance', true)) {
         require_once JPATH_ROOT . '/administrator/components/com_poweradmin/models/menuitem.php';
         $itemid = $input->getVar('Itemid');
         $menuCss = PoweradminModelMenuitem::loadMenuCustomAssets($itemid, 'css');
         $menuJs = PoweradminModelMenuitem::loadMenuCustomAssets($itemid, 'js');
         // Load css files from parent menu items
         $finalCssFiles = array();
         $parentLoadableCssFiles = array();
         PoweradminModelMenuitem::getInheritedAssetsFromParents($parentLoadableCssFiles, $itemid, 'css');
         if (count($parentLoadableCssFiles)) {
             foreach ($parentLoadableCssFiles as $key => $value) {
                 if ($value->loaded == 'true') {
                     array_push($finalCssFiles, $key);
                 }
             }
         }
         if (count($menuCss) && isset($menuCss->assets)) {
             foreach ($menuCss->assets as $key => $value) {
                 if ($value->loaded === "true") {
                     if (in_array($key, $finalCssFiles)) {
                         $_k = array_search($key, $finalCssFiles);
                         unset($finalCssFiles[$_k]);
                     }
                     array_push($finalCssFiles, $key);
                 }
             }
         }
         // Add computed css files
         if (count($finalCssFiles)) {
             foreach ($finalCssFiles as $_file) {
                 $_file = $this->addhttp($_file);
                 $this->_document->addStyleSheet($_file);
             }
         }
         // Load JS files from parent menu items
         $finalJsFiles = array();
         $parentLoadableJsFiles = array();
         PoweradminModelMenuitem::getInheritedAssetsFromParents($parentLoadableJsFiles, $itemid, 'js');
         if (count($parentLoadableJsFiles)) {
             foreach ($parentLoadableJsFiles as $key => $value) {
                 if ($value->loaded == 'true') {
                     array_push($finalJsFiles, $key);
                 }
             }
         }
         if (count($menuJs) && isset($menuJs->assets)) {
             foreach ($menuJs->assets as $key => $value) {
                 if ($value->loaded === "true") {
                     if (in_array($key, $finalJsFiles)) {
                         $_k = array_search($key, $finalJsFiles);
                         unset($finalJsFiles[$_k]);
                     }
                     array_push($finalJsFiles, $key);
                 }
             }
         }
         // Add computed css files
         if (count($finalJsFiles)) {
             foreach ($finalJsFiles as $_file) {
                 $_file = $this->addhttp($_file);
                 $this->_document->addScript($_file);
             }
         }
     }
     if ($this->_application->isAdmin() && $this->_user->id > 0 && $input->getVar('tmpl', '') != 'component' && $this->_params->get('enable_adminbar', true) == true) {
         JHtml::_('behavior.framework');
         $document = JFactory::getDocument();
         $template = isset($document->template) ? $document->template : null;
         if ($template != null && !in_array($template, array('rt_missioncontrol', 'hathor')) && ($input->getCmd('tmpl', '') != 'component' && $input->getCmd('format', '') != 'raw')) {
             require_once dirname(__FILE__) . '/libraries/administrator.menu.php';
             $this->loadLanguage('mod_menu');
             $this->_menuContent = JSNPowerAdminMenuHelper::renderMenus();
             $modules = JModuleHelper::getModules('menu');
             foreach ($modules as $module) {
                 if ($module->module == 'mod_menu') {
                     continue;
                 }
                 $this->_menuContent .= JModuleHelper::renderModule($module);
             }
             $this->_menuContent = '<div id="module-menu">' . $this->_menuContent . '</div>';
         }
     }
     if ($this->_application->isAdmin()) {
         return;
     }
 }