[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/administrator/modules/mod_menu/ -> helper.php (source)

   1  <?php
   2  /**
   3  * @version        $Id:mod_menu.php 2463 2006-02-18 06:05:38Z webImagery $
   4  * @package        Joomla
   5  * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   6  * @license        GNU/GPL, see LICENSE.php
   7  * Joomla! is free software. This version may have been modified pursuant
   8  * to the GNU General Public License, and as distributed it includes or
   9  * is derivative of works licensed under the GNU General Public License or
  10  * other free or open source software licenses.
  11  * See COPYRIGHT.php for copyright notices and details.
  12  */
  13  
  14  // no direct access
  15  defined('_JEXEC') or die('Restricted access');
  16  
  17  require_once(dirname(__FILE__).DS.'menu.php');
  18  
  19  class modMenuHelper
  20  {
  21      /**
  22       * Show the menu
  23       * @param string The current user type
  24       */
  25  	function buildMenu()
  26      {
  27          global $mainframe;
  28  
  29          $lang        = & JFactory::getLanguage();
  30          $user        = & JFactory::getUser();
  31          $db            = & JFactory::getDBO();
  32          $usertype    = $user->get('usertype');
  33  
  34          // cache some acl checks
  35          $canCheckin            = $user->authorize('com_checkin', 'manage');
  36          $canConfig            = $user->authorize('com_config', 'manage');
  37          $manageTemplates    = $user->authorize('com_templates', 'manage');
  38          $manageTrash        = $user->authorize('com_trash', 'manage');
  39          $manageMenuMan        = $user->authorize('com_menus', 'manage');
  40          $manageLanguages    = $user->authorize('com_languages', 'manage');
  41          $installModules        = $user->authorize('com_installer', 'module');
  42          $editAllModules        = $user->authorize('com_modules', 'manage');
  43          $installPlugins        = $user->authorize('com_installer', 'plugin');
  44          $editAllPlugins        = $user->authorize('com_plugins', 'manage');
  45          $installComponents    = $user->authorize('com_installer', 'component');
  46          $editAllComponents    = $user->authorize('com_components', 'manage');
  47          $canMassMail        = $user->authorize('com_massmail', 'manage');
  48          $canManageUsers        = $user->authorize('com_users', 'manage');
  49  
  50          // Menu Types
  51          require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'helpers'.DS.'helper.php' );
  52          $menuTypes     = MenusHelper::getMenuTypelist();
  53  
  54          /*
  55           * Get the menu object
  56           */
  57          $menu = new JAdminCSSMenu();
  58  
  59          /*
  60           * Site SubMenu
  61           */
  62          $menu->addChild(new JMenuNode(JText::_('Site')), true);
  63          $menu->addChild(new JMenuNode(JText::_('Control Panel'), 'index.php', 'class:cpanel'));
  64          $menu->addSeparator();
  65          if ($canManageUsers) {
  66              $menu->addChild(new JMenuNode(JText::_('User Manager'), 'index.php?option=com_users&task=view', 'class:user'));
  67          }
  68          $menu->addChild(new JMenuNode(JText::_('Media Manager'), 'index.php?option=com_media', 'class:media'));
  69          $menu->addSeparator();
  70          if ($canConfig) {
  71              $menu->addChild(new JMenuNode(JText::_('Configuration'), 'index.php?option=com_config', 'class:config'));
  72              $menu->addSeparator();
  73          }
  74          $menu->addChild(new JMenuNode(JText::_('Logout'), 'index.php?option=com_login&task=logout', 'class:logout'));
  75  
  76          $menu->getParent();
  77  
  78          /*
  79           * Menus SubMenu
  80           */
  81          $menu->addChild(new JMenuNode(JText::_('Menus')), true);
  82          if ($manageMenuMan) {
  83              $menu->addChild(new JMenuNode(JText::_('Menu Manager'), 'index.php?option=com_menus', 'class:menu'));
  84          }
  85          if ($manageTrash) {
  86              $menu->addChild(new JMenuNode(JText::_('Menu Trash'), 'index.php?option=com_trash&task=viewMenu', 'class:trash'));
  87          }
  88  
  89          if($manageTrash || $manageMenuMan) {
  90              $menu->addSeparator();
  91          }
  92          /*
  93           * SPLIT HR
  94           */
  95          if (count($menuTypes)) {
  96              foreach ($menuTypes as $menuType) {
  97                  $menu->addChild(
  98                      new JMenuNode(
  99                          $menuType->title . ($menuType->home ? ' *' : ''), 
 100                          'index.php?option=com_menus&task=view&menutype='
 101                          . $menuType->menutype,
 102                          'class:menu'
 103                      )
 104                  );
 105              }
 106          }
 107  
 108          $menu->getParent();
 109  
 110          /*
 111           * Content SubMenu
 112           */
 113          $menu->addChild(new JMenuNode(JText::_('Content')), true);
 114          $menu->addChild(new JMenuNode(JText::_('Article Manager'), 'index.php?option=com_content', 'class:article'));
 115          if ($manageTrash) {
 116              $menu->addChild(new JMenuNode(JText::_('Article Trash'), 'index.php?option=com_trash&task=viewContent', 'class:trash'));
 117          }
 118          $menu->addSeparator();
 119          $menu->addChild(new JMenuNode(JText::_('Section Manager'), 'index.php?option=com_sections&scope=content', 'class:section'));
 120          $menu->addChild(new JMenuNode(JText::_('Category Manager'), 'index.php?option=com_categories&section=com_content', 'class:category'));
 121          $menu->addSeparator();
 122          $menu->addChild(new JMenuNode(JText::_('Frontpage Manager'), 'index.php?option=com_frontpage', 'class:frontpage'));
 123  
 124          $menu->getParent();
 125  
 126          /*
 127           * Components SubMenu
 128           */
 129          if ($editAllComponents)
 130          {
 131              $menu->addChild(new JMenuNode(JText::_('Components')), true);
 132  
 133              $query = 'SELECT *' .
 134                  ' FROM #__components' .
 135                  ' WHERE '.$db->NameQuote( 'option' ).' <> "com_frontpage"' .
 136                  ' AND '.$db->NameQuote( 'option' ).' <> "com_media"' .
 137                  ' AND enabled = 1' .
 138                  ' ORDER BY ordering, name';
 139              $db->setQuery($query);
 140              $comps = $db->loadObjectList(); // component list
 141              $subs = array(); // sub menus
 142              $langs = array(); // additional language files to load
 143  
 144              // first pass to collect sub-menu items
 145              foreach ($comps as $row)
 146              {
 147                  if ($row->parent)
 148                  {
 149                      if (!array_key_exists($row->parent, $subs)) {
 150                          $subs[$row->parent] = array ();
 151                      }
 152                      $subs[$row->parent][] = $row;
 153                      $langs[$row->option.'.menu'] = true;
 154                  } elseif (trim($row->admin_menu_link)) {
 155                      $langs[$row->option.'.menu'] = true;
 156                  }
 157              }
 158  
 159              // Load additional language files
 160              if (array_key_exists('.menu', $langs)) {
 161                  unset($langs['.menu']);
 162              }
 163              foreach ($langs as $lang_name => $nothing) {
 164                  $lang->load($lang_name);
 165              }
 166  
 167              foreach ($comps as $row)
 168              {
 169                  if ($editAllComponents | $user->authorize('administration', 'edit', 'components', $row->option))
 170                  {
 171                      if ($row->parent == 0 && (trim($row->admin_menu_link) || array_key_exists($row->id, $subs)))
 172                      {
 173                          $text = $lang->hasKey($row->option) ? JText::_($row->option) : $row->name;
 174                          $link = $row->admin_menu_link ? "index.php?$row->admin_menu_link" : "index.php?option=$row->option";
 175                          if (array_key_exists($row->id, $subs)) {
 176                              $menu->addChild(new JMenuNode($text, $link, $row->admin_menu_img), true);
 177                              foreach ($subs[$row->id] as $sub) {
 178                                  $key  = $row->option.'.'.$sub->name;
 179                                  $text = $lang->hasKey($key) ? JText::_($key) : $sub->name;
 180                                  $link = $sub->admin_menu_link ? "index.php?$sub->admin_menu_link" : null;
 181                                  $menu->addChild(new JMenuNode($text, $link, $sub->admin_menu_img));
 182                              }
 183                              $menu->getParent();
 184                          } else {
 185                              $menu->addChild(new JMenuNode($text, $link, $row->admin_menu_img));
 186                          }
 187                      }
 188                  }
 189              }
 190              $menu->getParent();
 191          }
 192  
 193          /*
 194           * Extensions SubMenu
 195           */
 196          if ($installModules)
 197          {
 198              $menu->addChild(new JMenuNode(JText::_('Extensions')), true);
 199  
 200              $menu->addChild(new JMenuNode(JText::_('Install/Uninstall'), 'index.php?option=com_installer', 'class:install'));
 201              $menu->addSeparator();
 202              if ($editAllModules) {
 203                  $menu->addChild(new JMenuNode(JText::_('Module Manager'), 'index.php?option=com_modules', 'class:module'));
 204              }
 205              if ($editAllPlugins) {
 206                  $menu->addChild(new JMenuNode(JText::_('Plugin Manager'), 'index.php?option=com_plugins', 'class:plugin'));
 207              }
 208              if ($manageTemplates) {
 209                  $menu->addChild(new JMenuNode(JText::_('Template Manager'), 'index.php?option=com_templates', 'class:themes'));
 210              }
 211              if ($manageLanguages) {
 212                  $menu->addChild(new JMenuNode(JText::_('Language Manager'), 'index.php?option=com_languages', 'class:language'));
 213              }
 214              $menu->getParent();
 215          }
 216  
 217          /*
 218           * System SubMenu
 219           */
 220          if ($canConfig || $canCheckin)
 221          {
 222              $menu->addChild(new JMenuNode(JText::_('Tools')), true);
 223  
 224              if ($canConfig) {
 225                  $menu->addChild(new JMenuNode(JText::_('Read Messages'), 'index.php?option=com_messages', 'class:messages'));
 226                  $menu->addChild(new JMenuNode(JText::_('Write Message'), 'index.php?option=com_messages&task=add', 'class:messages'));
 227                  $menu->addSeparator();
 228              }
 229              if ($canMassMail) {
 230                  $menu->addChild(new JMenuNode(JText::_('Mass Mail'), 'index.php?option=com_massmail', 'class:massmail'));
 231                  $menu->addSeparator();
 232              }
 233              if ($canCheckin) {
 234                  $menu->addChild(new JMenuNode(JText::_('Global Checkin'), 'index.php?option=com_checkin', 'class:checkin'));
 235                  $menu->addSeparator();
 236              }
 237              $menu->addChild(new JMenuNode(JText::_('Clean Cache'), 'index.php?option=com_cache', 'class:config'));
 238              $menu->addChild(new JMenuNode(JText::_('Purge Expired Cache'), 'index.php?option=com_cache&task=purgeadmin', 'class:config'));
 239  
 240              $menu->getParent();
 241          }
 242  
 243          /*
 244           * Help SubMenu
 245           */
 246          $menu->addChild(new JMenuNode(JText::_('Help')), true);
 247          $menu->addChild(new JMenuNode(JText::_('Joomla! Help'), 'index.php?option=com_admin&task=help', 'class:help'));
 248          $menu->addChild(new JMenuNode(JText::_('System Info'), 'index.php?option=com_admin&task=sysinfo', 'class:info'));
 249  
 250          $menu->getParent();
 251  
 252          $menu->renderMenu('menu', '');
 253      }
 254  
 255      /**
 256       * Show an disbaled version of the menu, used in edit pages
 257       *
 258       * @param string The current user type
 259       */
 260  	function buildDisabledMenu()
 261      {
 262          $lang     =& JFactory::getLanguage();
 263          $user     =& JFactory::getUser();
 264          $usertype = $user->get('usertype');
 265  
 266          $canConfig            = $user->authorize('com_config', 'manage');
 267          $installModules        = $user->authorize('com_installer', 'module');
 268          $editAllModules        = $user->authorize('com_modules', 'manage');
 269          $installPlugins        = $user->authorize('com_installer', 'plugin');
 270          $editAllPlugins        = $user->authorize('com_plugins', 'manage');
 271          $installComponents    = $user->authorize('com_installer', 'component');
 272          $editAllComponents    = $user->authorize('com_components', 'manage');
 273          $canMassMail            = $user->authorize('com_massmail', 'manage');
 274          $canManageUsers        = $user->authorize('com_users', 'manage');
 275  
 276          $text = JText::_('Menu inactive for this Page', true);
 277  
 278          // Get the menu object
 279          $menu = new JAdminCSSMenu();
 280  
 281          // Site SubMenu
 282          $menu->addChild(new JMenuNode(JText::_('Site'), null, 'disabled'));
 283  
 284          // Menus SubMenu
 285          $menu->addChild(new JMenuNode(JText::_('Menus'), null, 'disabled'));
 286  
 287          // Content SubMenu
 288          $menu->addChild(new JMenuNode(JText::_('Content'), null, 'disabled'));
 289  
 290          // Components SubMenu
 291          if ($installComponents) {
 292              $menu->addChild(new JMenuNode(JText::_('Components'), null, 'disabled'));
 293          }
 294  
 295          // Extensions SubMenu
 296          if ($installModules) {
 297              $menu->addChild(new JMenuNode(JText::_('Extensions'), null, 'disabled'));
 298          }
 299  
 300          // System SubMenu
 301          if ($canConfig) {
 302              $menu->addChild(new JMenuNode(JText::_('Tools'),  null, 'disabled'));
 303          }
 304  
 305          // Help SubMenu
 306          $menu->addChild(new JMenuNode(JText::_('Help'),  null, 'disabled'));
 307  
 308          $menu->renderMenu('menu', 'disabled');
 309      }
 310  }
 311  ?>


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1