[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/administrator/modules/mod_submenu/ -> mod_submenu.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  // Lets get some variables we will need to render the menu
  18  $lang    =& JFactory::getLanguage();
  19  $doc    =& JFactory::getDocument();
  20  $user    =& JFactory::getUser();
  21  
  22  // If hidemainmenu is true, we don't want to render this module at all
  23  echo JAdminSubMenu::get();
  24  
  25  /**
  26   * Admin Submenu
  27   *
  28   * @package        Joomla
  29   * @since 1.5
  30   */
  31  class JAdminSubMenu
  32  {
  33  	function get()
  34      {
  35          global $mainframe;
  36  
  37          // Lets get some variables we are going to need
  38          $menu = JToolBar::getInstance('submenu');
  39          $list = $menu->_bar;
  40          if(!is_array($list) || !count($list))
  41          {
  42              $option = JRequest::getCmd('option');
  43              if($option == 'com_categories')
  44              {
  45                  $section = JRequest::getCmd('section');
  46                  if ($section) {
  47                      if ($section != 'content') {
  48                          // special handling for specific core components
  49                          $map['com_contact_details']    = 'com_contact';
  50                          $map['com_banner']            = 'com_banners';
  51  
  52                          $option = isset( $map[$section] ) ? $map[$section] : $section;
  53                      }
  54                  }
  55              }
  56              $list = JAdminSubMenu::_loadDBList($option);
  57          }
  58  
  59          if (!is_array($list) || !count($list)) {
  60              return null;
  61          }
  62  
  63          $hide = JRequest::getInt('hidemainmenu');
  64          $txt = "<ul id=\"submenu\">\n";
  65  
  66          /*
  67           * Iterate through the link items for building the menu items
  68           */
  69          foreach ($list as $item)
  70          {
  71              $txt .= "<li>\n";
  72              if ($hide)
  73              {
  74                  if (isset ($item[2]) && $item[2] == 1) {
  75                      $txt .= "<span class=\"nolink active\">".$item[0]."</span>\n";
  76                  }
  77                  else {
  78                      $txt .= "<span class=\"nolink\">".$item[0]."</span>\n";
  79                  }
  80              }
  81              else
  82              {
  83                  if (isset ($item[2]) && $item[2] == 1) {
  84                      $txt .= "<a class=\"active\" href=\"".JFilterOutput::ampReplace($item[1])."\">".$item[0]."</a>\n";
  85                  }
  86                  else {
  87                      $txt .= "<a href=\"".JFilterOutput::ampReplace($item[1])."\">".$item[0]."</a>\n";
  88                  }
  89              }
  90              $txt .= "</li>\n";
  91          }
  92  
  93          $txt .= "</ul>\n";
  94  
  95          return $txt;
  96      }
  97  
  98  	function _loadDBList( $componentOption )
  99      {
 100          $db   =& JFactory::getDBO();
 101          $lang =& JFactory::getLanguage();
 102  
 103          $lang->load($componentOption.'.menu');
 104  
 105          $query = 'SELECT a.name, a.admin_menu_link, a.admin_menu_img' .
 106          ' FROM #__components AS a' .
 107          ' INNER JOIN #__components AS b ON b.id = a.parent' .
 108          ' WHERE b.option = ' . $db->Quote( $componentOption ) .
 109          ' AND b.parent = 0'.
 110          ' ORDER BY a.ordering ASC';
 111  
 112          $db->setQuery($query);
 113          $items = $db->loadObjectList();
 114  
 115          // Process the items
 116          $subMenuList = array();
 117  
 118          foreach ($items as $item)
 119          {
 120              if (trim($item->admin_menu_link))
 121              {
 122                  // handling for active sub menu item
 123                  $active = 0;
 124                  if (strpos( @$_SERVER['QUERY_STRING'], $item->admin_menu_link ) !== false ) {
 125                      $active = 1;
 126                  }
 127  
 128                  $key = $componentOption.'.'.$item->name;
 129                  $subMenuItem[0]    = $lang->hasKey($key) ? JText::_($key) : $item->name;
 130                  $subMenuItem[1]    = 'index.php?'. $item->admin_menu_link;
 131                  $subMenuItem[2]    = $active;
 132  
 133                  $subMenuList[] = $subMenuItem;
 134              }
 135          }
 136  
 137          return $subMenuList;
 138      }
 139  }


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