[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

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

   1  <?php
   2  /**
   3   * @copyright    Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   4   * @license        GNU General Public License version 2 or later; see LICENSE.txt
   5   */
   6  
   7  // no direct access
   8  defined('_JEXEC') or die;
   9  
  10  /**
  11   * @package        Joomla.Administrator
  12   * @subpackage    mod_menu
  13   * @since        1.5
  14   */
  15  abstract class ModMenuHelper
  16  {
  17      /**
  18       * Get a list of the available menus.
  19       *
  20       * @return    array    An array of the available menus (from the menu types table).
  21       * @since    1.6
  22       */
  23  	public static function getMenus()
  24      {
  25          $db        = JFactory::getDbo();
  26          $query    = $db->getQuery(true);
  27  
  28          $query->select('a.*, SUM(b.home) AS home');
  29          $query->from('#__menu_types AS a');
  30          $query->leftJoin('#__menu AS b ON b.menutype = a.menutype AND b.home != 0');
  31          $query->select('b.language');
  32          $query->leftJoin('#__languages AS l ON l.lang_code = language');
  33          $query->select('l.image');
  34          $query->select('l.sef');
  35          $query->select('l.title_native');
  36          $query->where('(b.client_id = 0 OR b.client_id IS NULL)');
  37          //sqlsrv change
  38          $query->group('a.id, a.menutype, a.description, a.title, b.menutype,b.language,l.image,l.sef,l.title_native');
  39  
  40          $db->setQuery($query);
  41  
  42          $result = $db->loadObjectList();
  43  
  44          return $result;
  45      }
  46  
  47      /**
  48       * Get a list of the authorised, non-special components to display in the components menu.
  49       *
  50       * @param    boolean    $authCheck    An optional switch to turn off the auth check (to support custom layouts 'grey out' behaviour).
  51       *
  52       * @return    array    A nest array of component objects and submenus
  53       * @since    1.6
  54       */
  55  	public static function getComponents($authCheck = true)
  56      {
  57          // Initialise variables.
  58          $lang    = JFactory::getLanguage();
  59          $user    = JFactory::getUser();
  60          $db        = JFactory::getDbo();
  61          $query    = $db->getQuery(true);
  62          $result    = array();
  63          $langs    = array();
  64  
  65          // Prepare the query.
  66          $query->select('m.id, m.title, m.alias, m.link, m.parent_id, m.img, e.element');
  67          $query->from('#__menu AS m');
  68  
  69          // Filter on the enabled states.
  70          $query->leftJoin('#__extensions AS e ON m.component_id = e.extension_id');
  71          $query->where('m.client_id = 1');
  72          $query->where('e.enabled = 1');
  73          $query->where('m.id > 1');
  74  
  75          // Order by lft.
  76          $query->order('m.lft');
  77  
  78          $db->setQuery($query);
  79          // component list
  80          $components    = $db->loadObjectList();
  81  
  82          // Parse the list of extensions.
  83          foreach ($components as &$component) {
  84              // Trim the menu link.
  85              $component->link = trim($component->link);
  86  
  87              if ($component->parent_id == 1) {
  88                  // Only add this top level if it is authorised and enabled.
  89                  if ($authCheck == false || ($authCheck && $user->authorise('core.manage', $component->element))) {
  90                      // Root level.
  91                      $result[$component->id] = $component;
  92                      if (!isset($result[$component->id]->submenu)) {
  93                          $result[$component->id]->submenu = array();
  94                      }
  95  
  96                      // If the root menu link is empty, add it in.
  97                      if (empty($component->link)) {
  98                          $component->link = 'index.php?option='.$component->element;
  99                      }
 100  
 101                      if (!empty($component->element)) {
 102                          // Load the core file then
 103                          // Load extension-local file.
 104                          $lang->load($component->element.'.sys', JPATH_BASE, null, false, false)
 105                      ||    $lang->load($component->element.'.sys', JPATH_ADMINISTRATOR.'/components/'.$component->element, null, false, false)
 106                      ||    $lang->load($component->element.'.sys', JPATH_BASE, $lang->getDefault(), false, false)
 107                      ||    $lang->load($component->element.'.sys', JPATH_ADMINISTRATOR.'/components/'.$component->element, $lang->getDefault(), false, false);
 108                      }
 109                      $component->text = $lang->hasKey($component->title) ? JText::_($component->title) : $component->alias;
 110                  }
 111              } else {
 112                  // Sub-menu level.
 113                  if (isset($result[$component->parent_id])) {
 114                      // Add the submenu link if it is defined.
 115                      if (isset($result[$component->parent_id]->submenu) && !empty($component->link)) {
 116                          $component->text = $lang->hasKey($component->title) ? JText::_($component->title) : $component->alias;
 117                          $result[$component->parent_id]->submenu[] = &$component;
 118                      }
 119                  }
 120              }
 121          }
 122  
 123          $result = JArrayHelper::sortObjects($result, 'text', 1, true, $lang->getLocale());
 124  
 125          return $result;
 126      }
 127  }


Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1