[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/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.Site
  12   * @subpackage    mod_menu
  13   * @since        1.5
  14   */
  15  class modMenuHelper
  16  {
  17      /**
  18       * Get a list of the menu items.
  19       *
  20       * @param    JRegistry    $params    The module options.
  21       *
  22       * @return    array
  23       * @since    1.5
  24       */
  25  	static function getList(&$params)
  26      {
  27          $app = JFactory::getApplication();
  28          $menu = $app->getMenu();
  29  
  30          // If no active menu, use default
  31          $active = ($menu->getActive()) ? $menu->getActive() : $menu->getDefault();
  32  
  33          $user = JFactory::getUser();
  34          $levels = $user->getAuthorisedViewLevels();
  35          asort($levels);
  36          $key = 'menu_items'.$params.implode(',', $levels).'.'.$active->id;
  37          $cache = JFactory::getCache('mod_menu', '');
  38          if (!($items = $cache->get($key)))
  39          {
  40              // Initialise variables.
  41              $list        = array();
  42              $db            = JFactory::getDbo();
  43  
  44              $path        = $active->tree;
  45              $start        = (int) $params->get('startLevel');
  46              $end        = (int) $params->get('endLevel');
  47              $showAll    = $params->get('showAllChildren');
  48              $items         = $menu->getItems('menutype', $params->get('menutype'));
  49  
  50              $lastitem    = 0;
  51  
  52              if ($items) {
  53                  foreach($items as $i => $item)
  54                  {
  55                      if (($start && $start > $item->level)
  56                          || ($end && $item->level > $end)
  57                          || (!$showAll && $item->level > 1 && !in_array($item->parent_id, $path))
  58                          || ($start > 1 && !in_array($item->tree[$start-2], $path))
  59                      ) {
  60                          unset($items[$i]);
  61                          continue;
  62                      }
  63  
  64                      $item->deeper = false;
  65                      $item->shallower = false;
  66                      $item->level_diff = 0;
  67  
  68                      if (isset($items[$lastitem])) {
  69                          $items[$lastitem]->deeper        = ($item->level > $items[$lastitem]->level);
  70                          $items[$lastitem]->shallower    = ($item->level < $items[$lastitem]->level);
  71                          $items[$lastitem]->level_diff    = ($items[$lastitem]->level - $item->level);
  72                      }
  73  
  74                      $item->parent = (boolean) $menu->getItems('parent_id', (int) $item->id, true);
  75  
  76                      $lastitem            = $i;
  77                      $item->active        = false;
  78                      $item->flink = $item->link;
  79  
  80                      switch ($item->type)
  81                      {
  82                          case 'separator':
  83                              // No further action needed.
  84                              continue;
  85  
  86                          case 'url':
  87                              if ((strpos($item->link, 'index.php?') === 0) && (strpos($item->link, 'Itemid=') === false)) {
  88                                  // If this is an internal Joomla link, ensure the Itemid is set.
  89                                  $item->flink = $item->link.'&Itemid='.$item->id;
  90                              }
  91                              break;
  92  
  93                          case 'alias':
  94                              // If this is an alias use the item id stored in the parameters to make the link.
  95                              $item->flink = 'index.php?Itemid='.$item->params->get('aliasoptions');
  96                              break;
  97  
  98                          default:
  99                              $router = JSite::getRouter();
 100                              if ($router->getMode() == JROUTER_MODE_SEF) {
 101                                  $item->flink = 'index.php?Itemid='.$item->id;
 102                              }
 103                              else {
 104                                  $item->flink .= '&Itemid='.$item->id;
 105                              }
 106                              break;
 107                      }
 108  
 109                      if (strcasecmp(substr($item->flink, 0, 4), 'http') && (strpos($item->flink, 'index.php?') !== false)) {
 110                          $item->flink = JRoute::_($item->flink, true, $item->params->get('secure'));
 111                      }
 112                      else {
 113                          $item->flink = JRoute::_($item->flink);
 114                      }
 115  
 116                      $item->title = htmlspecialchars($item->title);
 117                      $item->anchor_css = htmlspecialchars($item->params->get('menu-anchor_css', ''));
 118                      $item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', ''));
 119                      $item->menu_image = $item->params->get('menu_image', '') ? htmlspecialchars($item->params->get('menu_image', '')) : '';
 120                  }
 121  
 122                  if (isset($items[$lastitem])) {
 123                      $items[$lastitem]->deeper        = (($start?$start:1) > $items[$lastitem]->level);
 124                      $items[$lastitem]->shallower    = (($start?$start:1) < $items[$lastitem]->level);
 125                      $items[$lastitem]->level_diff    = ($items[$lastitem]->level - ($start?$start:1));
 126                  }
 127              }
 128  
 129              $cache->store($items, $key);
 130          }
 131          return $items;
 132      }
 133  }


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