<?php /** * Main File * * @package CustoMenu * @version 2.5.1 * * @author Peter van Westen <*****@*****.**> * @link http://www.nonumber.nl * @copyright Copyright (C) 2010 NoNumber! All Rights Reserved * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ // Ensure this file is being included by a parent file defined('_JEXEC') or die('Restricted access'); // Include the syndicate functions only once require_once dirname(__FILE__) . DS . 'customenu' . DS . 'helper.php'; $show_page = JRequest::getVar('controller') == 'menuitems'; $output = modCustoMenuHelper::getOutput($params); require JModuleHelper::getLayoutPath('mod_customenu' . DS . 'customenu');
function getItems() { global $Itemid, $cm_active_ids; $items = array(); $db =& JFactory::getDBO(); if ($this->_params->use_menu) { $query = 'SELECT *' . ' FROM #__menu' . ' WHERE menutype = "' . $this->_params->use_menu_stucture . '"' . ' AND parent = 0' . ' AND published != -2' . ' ORDER BY ordering'; $db->setQuery($query); $rows = $db->loadObjectList(); $i = 1; foreach ($rows as $row) { if ($row->type != 'separator') { // check whether item should be displayed // published & acceslevel if (($row->published == 1 || $this->_params->show_unpublished) && ($row->access <= $this->_params->access || $this->_params->show_non_access)) { $curr_item = modCustoMenuHelper::getDefaultItem(); $curr_item->text = $row->name; if ($row->type == 'menulink') { $itemid = (int) str_replace('menu_item=', '', $row->params); $query = 'SELECT *' . ' FROM #__menu' . ' WHERE id = ' . $itemid . ' LIMIT 1'; $db->setQuery($query); $row = $db->loadObject(); } $curr_item->link = $row->link; // Only attach Itemid if link is internal if (modCustoMenuHelper::isInternal($curr_item->link)) { $curr_item->link .= strpos($curr_item->link, '?') === false ? '?' : '&'; $curr_item->link .= 'Itemid=' . $row->id; // Translates an internal Joomla URL to a humanly readible URL. $curr_item->link = JRoute::_($curr_item->link, false); } // Check if menu item should be set to active $active_on_ids = array($row->id); if ($this->_params->active_on_child_ids) { $child_ids = modCustoMenuHelper::getMenuItemChildIds($row->id); $active_on_ids = array_merge($active_on_ids, $child_ids); } if ($Itemid && in_array($Itemid, $active_on_ids)) { $cm_active_ids = $active_on_ids; $curr_item->active = 1; // Stylesheet if ($this->_params->extra_item_css) { JHTML::stylesheet($this->_params->extra_item_css_prefix . $i . '.css', 'modules/mod_customenu/customenu/css_extra/'); } } // Target $curr_item->target = $row->browserNav ? 1 : 0; $i++; $items[$i] = $curr_item; } } } } else { for ($i = 1; $i <= $this->_params->nrOfItems; $i++) { $item = $this->_params->items[$i]; if ($item->menu_id || $item->overrule_text) { $ok = 1; $access = $item->overrule_access; $curr_item = modCustoMenuHelper::getDefaultItem(); $curr_item->link = $item->overrule_link; $curr_item->text = $item->overrule_text; // Target $curr_item->target = $item->target; // Get menu item data from database if ($item->menu_id) { $query = 'SELECT name, link, browserNav, published, access' . ' FROM #__menu' . ' WHERE id = ' . $item->menu_id; $db->setQuery($query); $row = $db->loadObject(); if ($row) { // check whether item should be displayed // published if (!$item->show_unpublished && !$row->published) { $ok = 0; } // acces level if ($access == -1) { $access = $row->access; } // Set the text if (!$curr_item->text) { $curr_item->text = $row->name; } // Set the link if (!$curr_item->link) { $curr_item->link = $row->link; } // Target if ($curr_item->target == -1) { $curr_item->target = $row->browserNav ? 1 : 0; } } } // acces level if ($access == -1) { $access = 0; } if (!$item->show_non_access && $access > $this->_params->access) { $ok = 0; } if ($ok) { // Only attach Itemid if link is internal if (modCustoMenuHelper::isInternal($curr_item->link)) { $curr_item->link .= strpos($curr_item->link, '?') === false ? '?' : '&'; $curr_item->link .= 'Itemid=' . $item->menu_id; // Translates an internal Joomla URL to a humanly readible URL. $curr_item->link = JRoute::_($curr_item->link, false); } // Check if menu item should be set to active $active_on_ids = array($item->menu_id); $active_on_ids = array_merge($active_on_ids, explode(',', $item->active_on_extra_ids)); if ($item->active_on_child_ids) { $child_ids = modCustoMenuHelper::getMenuItemChildIds($item->menu_id); $active_on_ids = array_merge($active_on_ids, $child_ids); } if (!$Itemid && $item->active_by_default || $Itemid && in_array($Itemid, $active_on_ids)) { $cm_active_ids = $active_on_ids; $curr_item->active = 1; // Stylesheet if ($item->stylesheet) { JHTML::stylesheet($item->stylesheet, 'modules/mod_customenu/customenu/css_extra/'); } } // Target if ($curr_item->target == -1) { $curr_item->target = 0; } // Hide text $curr_item->hide_text = $item->hide_text; // Extra class name $curr_item->class = $item->class_name; $items[$i] = $curr_item; } } } } return $items; }