コード例 #1
0
ファイル: osmap.php プロジェクト: alesconti/FF_2015
 public static function &getMenuItems($selections)
 {
     $db = JFactory::getDbo();
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $list = array();
     foreach ($selections as $menutype => $menuOptions) {
         // Initialize variables.
         // Get the menu items as a tree.
         $query = $db->getQuery(true);
         $query->select('n.id, n.title, n.alias, n.path, n.level, n.link, ' . 'n.type, n.params, n.home, n.parent_id' . ',n.' . $db->quoteName('browserNav'));
         $query->from('#__menu AS n');
         $query->join('INNER', ' #__menu AS p ON p.lft = 0');
         $query->where('n.lft > p.lft');
         $query->where('n.lft < p.rgt');
         $query->order('n.lft');
         // Filter over the appropriate menu.
         $query->where('n.menutype = ' . $db->quote($menutype));
         // Filter over authorized access levels and publishing state.
         $query->where('n.published = 1');
         $query->where('n.access IN (' . implode(',', (array) $user->getAuthorisedViewLevels()) . ')');
         // Filter by language
         if ($app->getLanguageFilter()) {
             $query->where('n.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
         }
         // Get the list of menu items.
         $db->setQuery($query);
         $tmpList = $db->loadObjectList('id');
         $list[$menutype] = array();
         // Check for a database error.
         if ($db->getErrorNum()) {
             JError::raiseWarning(021, $db->getErrorMsg());
             return array();
         }
         // Set some values to make nested HTML rendering easier.
         foreach ($tmpList as $id => $item) {
             $item->items = array();
             $params = new JRegistry($item->params);
             $item->uid = 'itemid' . $item->id;
             if (preg_match('#^/?index.php.*option=(com_[^&]+)#', $item->link, $matches)) {
                 $item->option = $matches[1];
                 $componentParams = clone JComponentHelper::getParams($item->option);
                 $componentParams->merge($params);
                 //$params->merge($componentParams);
                 $params = $componentParams;
             } else {
                 $item->option = null;
             }
             $item->params = $params;
             if ($item->type != 'separator') {
                 $item->priority = $menuOptions['priority'];
                 $item->changefreq = $menuOptions['changefreq'];
                 OSMapHelper::prepareMenuItem($item);
             } else {
                 $item->priority = null;
                 $item->changefreq = null;
             }
             if ($item->parent_id > 1) {
                 $tmpList[$item->parent_id]->items[$item->id] = $item;
             } else {
                 $list[$menutype][$item->id] = $item;
             }
         }
     }
     return $list;
 }
コード例 #2
0
ファイル: navigator_class.php プロジェクト: alesconti/FF_2015
 function &expandLink(&$parent)
 {
     $items =& JSite::getMenu();
     $extensions =& $this->_extensions;
     $rows = null;
     if (strpos($parent->link, '-menu-') === 0) {
         $menutype = str_replace('-menu-', '', $parent->link);
         // Get Menu Items
         $rows = $items->getItems('menutype', $menutype);
     } elseif ($parent->id) {
         $rows = $items->getItems('parent_id', $parent->id);
     }
     if ($rows) {
         foreach ($rows as $item) {
             if ($item->parent_id == $parent->id) {
                 $node = new stdclass();
                 $node->name = $item->title;
                 $node->id = $item->id;
                 $node->uid = 'itemid' . $item->id;
                 $node->link = $item->link;
                 $node->expandible = true;
                 $node->selectable = true;
                 // Prepare the node link
                 OSMapHelper::prepareMenuItem($node);
                 if ($item->home) {
                     $node->link = JURI::root();
                 } elseif (substr($item->link, 0, 9) == 'index.php' && $item->type != 'url') {
                     if ($item->type == 'menulink') {
                         // For Joomla 1.5 SEF compatibility
                         $params = new JParameter($item->params);
                         $node->link = 'index.php?Itemid=' . $params->get('menu_item');
                     } elseif (strpos($item->link, 'Itemid=') === FALSE) {
                         $node->link = 'index.php?Itemid=' . $node->id;
                     }
                 } elseif ($item->type == 'separator') {
                     $node->selectable = false;
                 }
                 $this->printNode($node);
                 // Add to the internal list
             }
         }
     }
     if ($parent->id) {
         $option = null;
         if (preg_match('#^/?index.php.*option=(com_[^&]+)#', $parent->link, $matches)) {
             $option = $matches[1];
         }
         $Itemid = JRequest::getInt('Itemid');
         if (!$option && $Itemid) {
             $item = $items->getItem($Itemid);
             $link_query = parse_url($item->link);
             parse_str(html_entity_decode($link_query['query']), $link_vars);
             $option = JArrayHelper::getValue($link_vars, 'option', '');
             if ($option) {
                 $parent->link = $item->link;
             }
         }
         if ($option) {
             if (!empty($extensions[$option])) {
                 $parent->uid = $option;
                 $className = 'xmap_' . $option;
                 $result = call_user_func_array(array($className, 'getTree'), array(&$this, &$parent, $extensions[$option]->params));
             }
         }
     }
     return $this->_list;
 }