0byt3m1n1-V2
Path:
/
home
/
a
/
c
/
a
/
academiac
/
www
/
[
Home
]
File: menu.php.tar
home/academiac/www/includes/menu.php 0000644 00000006603 15137254317 0013507 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access. defined('_JEXEC') or die; /** * JMenu class * * @package Joomla.Site * @subpackage Application * @since 1.5 */ class JMenuSite extends JMenu { /** * Loads the entire menu table into memory. * * @return array */ public function load() { // Initialise variables. $db = JFactory::getDbo(); $app = JApplication::getInstance('site'); $query = $db->getQuery(true); $query->select('m.id, m.menutype, m.title, m.alias, m.note, m.path AS route, m.link, m.type, m.level, m.language'); $query->select('m.browserNav, m.access, m.params, m.home, m.img, m.template_style_id, m.component_id, m.parent_id'); $query->select('e.element as component'); $query->from('#__menu AS m'); $query->leftJoin('#__extensions AS e ON m.component_id = e.extension_id'); $query->where('m.published = 1'); $query->where('m.parent_id > 0'); $query->where('m.client_id = 0'); $query->order('m.lft'); // Set the query $db->setQuery($query); if (!($this->_items = $db->loadObjectList('id'))) { JError::raiseWarning(500, JText::sprintf('JERROR_LOADING_MENUS', $db->getErrorMsg())); return false; } foreach($this->_items as &$item) { // Get parent information. $parent_tree = array(); if (isset($this->_items[$item->parent_id])) { $parent_tree = $this->_items[$item->parent_id]->tree; } // Create tree. $parent_tree[] = $item->id; $item->tree = $parent_tree; // Create the query array. $url = str_replace('index.php?', '', $item->link); $url = str_replace('&', '&', $url); parse_str($url, $item->query); } } /** * Gets menu items by attribute * * @param string $attributes The field name * @param string $values The value of the field * @param boolean $firstonly If true, only returns the first item found * * @return array */ public function getItems($attributes, $values, $firstonly = false) { $attributes = (array) $attributes; $values = (array) $values; $app = JApplication::getInstance('site'); if ($app->isSite()) { // Filter by language if not set if (($key = array_search('language', $attributes)) === false) { if ($app->getLanguageFilter()) { $attributes[] = 'language'; $values[] = array(JFactory::getLanguage()->getTag(), '*'); } } elseif ($values[$key] === null) { unset($attributes[$key]); unset($values[$key]); } // Filter by access level if not set if (($key = array_search('access', $attributes)) === false) { $attributes[] = 'access'; $values[] = JFactory::getUser()->getAuthorisedViewLevels(); } elseif ($values[$key] === null) { unset($attributes[$key]); unset($values[$key]); } } return parent::getItems($attributes, $values, $firstonly); } /** * Get menu item by id * * @param string $language The language code. * * @return object The item object * @since 1.5 */ public function getDefault($language = '*') { if (array_key_exists($language, $this->_default) && JApplication::getInstance('site')->getLanguageFilter()) { return $this->_items[$this->_default[$language]]; } elseif (array_key_exists('*', $this->_default)) { return $this->_items[$this->_default['*']]; } else { return 0; } } } home/academiac/www/libraries/joomla/html/html/menu.php 0000644 00000021151 15137262031 0017031 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage HTML * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * Utility class working with menu select lists * * @package Joomla.Platform * @subpackage HTML * @since 11.1 */ abstract class JHtmlMenu { /** * Cached array of the menus. * * @var array * @since 11.1 */ protected static $menus = null; /** * Cached array of the menus items. * * @var array * @since 11.1 */ protected static $items = null; /** * Get a list of the available menus. * * @return string * * @since 11.1 */ public static function menus() { if (empty(self::$menus)) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('menutype AS value, title AS text'); $query->from($db->quoteName('#__menu_types')); $query->order('title'); $db->setQuery($query); self::$menus = $db->loadObjectList(); } return self::$menus; } /** * Returns an array of menu items grouped by menu. * * @param array $config An array of configuration options. * * @return array */ public static function menuitems($config = array()) { if (empty(self::$items)) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('menutype AS value, title AS text'); $query->from($db->quoteName('#__menu_types')); $query->order('title'); $db->setQuery($query); $menus = $db->loadObjectList(); $query->clear(); $query->select('a.id AS value, a.title AS text, a.level, a.menutype'); $query->from('#__menu AS a'); $query->where('a.parent_id > 0'); $query->where('a.type <> ' . $db->quote('url')); $query->where('a.client_id = 0'); // Filter on the published state if (isset($config['published'])) { if (is_numeric($config['published'])) { $query->where('a.published = ' . (int) $config['published']); } elseif ($config['published'] === '') { $query->where('a.published IN (0,1)'); } } $query->order('a.lft'); $db->setQuery($query); $items = $db->loadObjectList(); // Collate menu items based on menutype $lookup = array(); foreach ($items as &$item) { if (!isset($lookup[$item->menutype])) { $lookup[$item->menutype] = array(); } $lookup[$item->menutype][] = &$item; $item->text = str_repeat('- ', $item->level) . $item->text; } self::$items = array(); foreach ($menus as &$menu) { // Start group: self::$items[] = JHtml::_('select.optgroup', $menu->text); // Special "Add to this Menu" option: self::$items[] = JHtml::_('select.option', $menu->value . '.1', JText::_('JLIB_HTML_ADD_TO_THIS_MENU')); // Menu items: if (isset($lookup[$menu->value])) { foreach ($lookup[$menu->value] as &$item) { self::$items[] = JHtml::_('select.option', $menu->value . '.' . $item->value, $item->text); } } // Finish group: self::$items[] = JHtml::_('select.optgroup', $menu->text); } } return self::$items; } /** * Displays an HTML select list of menu items. * * @param string $name The name of the control. * @param string $selected The value of the selected option. * @param string $attribs Attributes for the control. * @param array $config An array of options for the control. * * @return string */ public static function menuitemlist($name, $selected = null, $attribs = null, $config = array()) { static $count; $options = self::menuitems($config); return JHtml::_( 'select.genericlist', $options, $name, array( 'id' => isset($config['id']) ? $config['id'] : 'assetgroups_' . ++$count, 'list.attr' => (is_null($attribs) ? 'class="inputbox" size="1"' : $attribs), 'list.select' => (int) $selected, 'list.translate' => false ) ); } /** * Build the select list for Menu Ordering * * @param object &$row The row object * @param integer $id The id for the row. Must exist to enable menu ordering * * @return string * * @since 11.1 */ public static function ordering(&$row, $id) { $db = JFactory::getDbo(); $query = $db->getQuery(true); if ($id) { $query->select('ordering AS value, title AS text'); $query->from($db->quoteName('#__menu')); $query->where($db->quoteName('menutype') . ' = ' . $db->quote($row->menutype)); $query->where($db->quoteName('parent_id') . ' = ' . (int) $row->parent_id); $query->where($db->quoteName('published') . ' != -2'); $query->order('ordering'); $order = JHtml::_('list.genericordering', $query); $ordering = JHtml::_( 'select.genericlist', $order, 'ordering', array('list.attr' => 'class="inputbox" size="1"', 'list.select' => intval($row->ordering)) ); } else { $ordering = '<input type="hidden" name="ordering" value="' . $row->ordering . '" />' . JText::_('JGLOBAL_NEWITEMSLAST_DESC'); } return $ordering; } /** * Build the multiple select list for Menu Links/Pages * * @param boolean $all True if all can be selected * @param boolean $unassigned True if unassigned can be selected * * @return string * * @since 11.1 */ public static function linkoptions($all = false, $unassigned = false) { $db = JFactory::getDbo(); $query = $db->getQuery(true); // get a list of the menu items $query->select('m.id, m.parent_id, m.title, m.menutype'); $query->from($db->quoteName('#__menu') . ' AS m'); $query->where($db->quoteName('m.published') . ' = 1'); $query->order('m.menutype, m.parent_id, m.ordering'); $db->setQuery($query); $mitems = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { JError::raiseNotice(500, $db->getErrorMsg()); } if (!$mitems) { $mitems = array(); } $mitems_temp = $mitems; // Establish the hierarchy of the menu $children = array(); // First pass - collect children foreach ($mitems as $v) { $pt = $v->parent_id; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $v); $children[$pt] = $list; } // Second pass - get an indent list of the items $list = JHtmlMenu::TreeRecurse(intval($mitems[0]->parent_id), '', array(), $children, 9999, 0, 0); // Code that adds menu name to Display of Page(s) $mitems = array(); if ($all | $unassigned) { $mitems[] = JHtml::_('select.option', '<OPTGROUP>', JText::_('JOPTION_MENUS')); if ($all) { $mitems[] = JHtml::_('select.option', 0, JText::_('JALL')); } if ($unassigned) { $mitems[] = JHtml::_('select.option', -1, JText::_('JOPTION_UNASSIGNED')); } $mitems[] = JHtml::_('select.option', '</OPTGROUP>'); } $lastMenuType = null; $tmpMenuType = null; foreach ($list as $list_a) { if ($list_a->menutype != $lastMenuType) { if ($tmpMenuType) { $mitems[] = JHtml::_('select.option', '</OPTGROUP>'); } $mitems[] = JHtml::_('select.option', '<OPTGROUP>', $list_a->menutype); $lastMenuType = $list_a->menutype; $tmpMenuType = $list_a->menutype; } $mitems[] = JHtml::_('select.option', $list_a->id, $list_a->title); } if ($lastMenuType !== null) { $mitems[] = JHtml::_('select.option', '</OPTGROUP>'); } return $mitems; } /** * Build the list representing the menu tree * * @param integer $id Id of the menu item * @param string $indent The indentation string * @param array $list The list to process * @param array &$children The children of the current item * @param integer $maxlevel The maximum number of levels in the tree * @param integer $level The starting level * @param string $type Type of link: component, URL, alias, separator * * @return array * * @since 11.1 */ public static function treerecurse($id, $indent, $list, &$children, $maxlevel = 9999, $level = 0, $type = 1) { if (@$children[$id] && $level <= $maxlevel) { foreach ($children[$id] as $v) { $id = $v->id; if ($type) { $pre = '<sup>|_</sup> '; $spacer = '.      '; } else { $pre = '- '; $spacer = '  '; } if ($v->parent_id == 0) { $txt = $v->title; } else { $txt = $pre . $v->title; } $pt = $v->parent_id; $list[$id] = $v; $list[$id]->treename = "$indent$txt"; $list[$id]->children = count(@$children[$id]); $list = JHtmlMenu::TreeRecurse($id, $indent . $spacer, $list, $children, $maxlevel, $level + 1, $type); } } return $list; } } home/academiac/www/libraries/joomla/html/parameter/element/menu.php 0000644 00000003230 15137262460 0021502 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage HTML * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * Renders a menu element * * @package Joomla.Platform * @subpackage Parameter * @since 11.1 * @deprecated Use JFormMenu instead */ class JElementMenu extends JElement { /** * Element name * * @var string */ protected $_name = 'Menu'; /** * Fetch a html for a list of menus * * @param string $name Element name * @param string $value Element value * @param JXMLElement &$node JXMLElement node object containing the settings for the element * @param string $control_name Control name * * @return string * * @deprecated 12.1 Use JFormFieldMenu::getOptions instead * @since 11.1 */ public function fetchElement($name, $value, &$node, $control_name) { // Deprecation warning. JLog::add('JElementMenu::fetchElement() is deprecated.', JLog::WARNING, 'deprecated'); require_once JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php'; $menuTypes = MenusHelper::getMenuTypes(); foreach ($menuTypes as $menutype) { $options[] = JHtml::_('select.option', $menutype, $menutype); } array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_SELECT_MENU'))); return JHtml::_( 'select.genericlist', $options, $control_name . '[' . $name . ']', array('id' => $control_name . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value) ); } } home/academiac/www/libraries/joomla/application/menu.php 0000644 00000014211 15137264763 0017441 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Application * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * JMenu class * * @package Joomla.Platform * @subpackage Application * @since 11.1 */ class JMenu extends JObject { /** * Array to hold the menu items * * @var array * @since 11.1 */ protected $_items = array(); /** * Identifier of the default menu item * * @var integer * @since 11.1 */ protected $_default = array(); /** * Identifier of the active menu item * * @var integer * @since 11.1 */ protected $_active = 0; /** * @var array JMenu instances container. * @since 11.3 */ protected static $instances = array(); /** * Class constructor * * @param array $options An array of configuration options. * * @since 11.1 */ public function __construct($options = array()) { // Load the menu items $this->load(); foreach ($this->_items as $item) { if ($item->home) { $this->_default[trim($item->language)] = $item->id; } // Decode the item params $result = new JRegistry; $result->loadString($item->params); $item->params = $result; } } /** * Returns a JMenu object * * @param string $client The name of the client * @param array $options An associative array of options * * @return JMenu A menu object. * * @since 11.1 */ public static function getInstance($client, $options = array()) { if (empty(self::$instances[$client])) { //Load the router object $info = JApplicationHelper::getClientInfo($client, true); $path = $info->path . '/includes/menu.php'; if (file_exists($path)) { include_once $path; // Create a JPathway object $classname = 'JMenu' . ucfirst($client); $instance = new $classname($options); } else { //$error = JError::raiseError(500, 'Unable to load menu: '.$client); //TODO: Solve this $error = null; return $error; } self::$instances[$client] = & $instance; } return self::$instances[$client]; } /** * Get menu item by id * * @param integer $id The item id * * @return mixed The item object, or null if not found * * @since 11.1 */ public function getItem($id) { $result = null; if (isset($this->_items[$id])) { $result = &$this->_items[$id]; } return $result; } /** * Set the default item by id and language code. * * @param integer $id The menu item id. * @param string $language The language cod (since 1.6). * * @return boolean True, if successful * * @since 11.1 */ public function setDefault($id, $language = '') { if (isset($this->_items[$id])) { $this->_default[$language] = $id; return true; } return false; } /** * Get the default item by language code. * * @param string $language The language code, default value of * means all. * * @return object The item object * * @since 11.1 */ public function getDefault($language = '*') { if (array_key_exists($language, $this->_default)) { return $this->_items[$this->_default[$language]]; } elseif (array_key_exists('*', $this->_default)) { return $this->_items[$this->_default['*']]; } else { return 0; } } /** * Set the default item by id * * @param integer $id The item id * * @return mixed If successful the active item, otherwise null * * @since 11.1 */ public function setActive($id) { if (isset($this->_items[$id])) { $this->_active = $id; $result = &$this->_items[$id]; return $result; } return null; } /** * Get menu item by id. * * @return object The item object. * * @since 11.1 */ public function getActive() { if ($this->_active) { $item = &$this->_items[$this->_active]; return $item; } return null; } /** * Gets menu items by attribute * * @param mixed $attributes The field name(s). * @param mixed $values The value(s) of the field. If an array, need to match field names * each attribute may have multiple values to lookup for. * @param boolean $firstonly If true, only returns the first item found * * @return array * * @since 11.1 */ public function getItems($attributes, $values, $firstonly = false) { $items = array(); $attributes = (array) $attributes; $values = (array) $values; foreach ($this->_items as $item) { if (!is_object($item)) { continue; } $test = true; for ($i = 0, $count = count($attributes); $i < $count; $i++) { if (is_array($values[$i])) { if (!in_array($item->$attributes[$i], $values[$i])) { $test = false; break; } } else { if ($item->$attributes[$i] != $values[$i]) { $test = false; break; } } } if ($test) { if ($firstonly) { return $item; } $items[] = $item; } } return $items; } /** * Gets the parameter object for a certain menu item * * @param integer $id The item id * * @return JRegistry A JRegistry object * * @since 11.1 */ public function getParams($id) { if ($menu = $this->getItem($id)) { return $menu->params; } else { return new JRegistry; } } /** * Getter for the menu array * * @return array * * @since 11.1 */ public function getMenu() { return $this->_items; } /** * Method to check JMenu object authorization against an access control * object and optionally an access extension object * * @param integer $id The menu id * * @return boolean True if authorised * * @since 11.1 */ public function authorise($id) { $menu = $this->getItem($id); $user = JFactory::getUser(); if ($menu) { return in_array((int) $menu->access, $user->getAuthorisedViewLevels()); } else { return true; } } /** * Loads the menu items * * @return array * * @since 11.1 */ public function load() { return array(); } } home/academiac/www/libraries/joomla/database/table/menu.php 0000644 00000013314 15137272050 0017760 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Database * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; jimport('joomla.database.tablenested'); /** * Menu table * * @package Joomla.Platform * @subpackage Table * @since 11.1 */ class JTableMenu extends JTableNested { /** * Constructor * * @param JDatabase &$db A database connector object * * @since 11.1 */ public function __construct(&$db) { parent::__construct('#__menu', 'id', $db); // Set the default access level. $this->access = (int) JFactory::getConfig()->get('access'); } /** * Overloaded bind function * * @param array $array Named array * @param mixed $ignore An optional array or space separated list of properties to ignore while binding. * * @return mixed Null if operation was satisfactory, otherwise returns an error * * @see JTable::bind * @since 11.1 */ public function bind($array, $ignore = '') { // Verify that the default home menu is not unset if ($this->home == '1' && $this->language == '*' && ($array['home'] == '0')) { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_CANNOT_UNSET_DEFAULT_DEFAULT')); return false; } //Verify that the default home menu set to "all" languages" is not unset if ($this->home == '1' && $this->language == '*' && ($array['language'] != '*')) { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_CANNOT_UNSET_DEFAULT')); return false; } // Verify that the default home menu is not unpublished if ($this->home == '1' && $this->language == '*' && $array['published'] != '1') { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_UNPUBLISH_DEFAULT_HOME')); return false; } if (isset($array['params']) && is_array($array['params'])) { $registry = new JRegistry; $registry->loadArray($array['params']); $array['params'] = (string) $registry; } return parent::bind($array, $ignore); } /** * Overloaded check function * * @return boolean True on success * * @see JTable::check * @since 11.1 */ public function check() { // If the alias field is empty, set it to the title. $this->alias = trim($this->alias); if ((empty($this->alias)) && ($this->type != 'alias' && $this->type != 'url')) { $this->alias = $this->title; } // Make the alias URL safe. $this->alias = JApplication::stringURLSafe($this->alias); if (trim(str_replace('-', '', $this->alias)) == '') { $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s'); } // Cast the home property to an int for checking. $this->home = (int) $this->home; // Verify that a first level menu item alias is not 'component'. if ($this->parent_id == 1 && $this->alias == 'component') { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_COMPONENT')); return false; } // Verify that a first level menu item alias is not the name of a folder. jimport('joomla.filesystem.folders'); if ($this->parent_id == 1 && in_array($this->alias, JFolder::folders(JPATH_ROOT))) { $this->setError(JText::sprintf('JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_FOLDER', $this->alias, $this->alias)); return false; } // Verify that the home item a component. if ($this->home && $this->type != 'component') { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_COMPONENT')); return false; } return true; } /** * Overloaded store function * * @param boolean $updateNulls True to update fields even if they are null. * * @return mixed False on failure, positive integer on success. * * @see JTable::store * @since 11.1 */ public function store($updateNulls = false) { $db = JFactory::getDBO(); // Verify that the alias is unique $table = JTable::getInstance('Menu', 'JTable'); if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id, 'client_id' => $this->client_id, 'language' => $this->language)) && ($table->id != $this->id || $this->id == 0)) { if ($this->menutype == $table->menutype) { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS')); } else { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS_ROOT')); } return false; } // Verify that the home page for this language is unique if ($this->home == '1') { $table = JTable::getInstance('Menu', 'JTable'); if ($table->load(array('home' => '1', 'language' => $this->language))) { if ($table->checked_out && $table->checked_out != $this->checked_out) { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_DEFAULT_CHECKIN_USER_MISMATCH')); return false; } $table->home = 0; $table->checked_out = 0; $table->checked_out_time = $db->getNullDate(); $table->store(); } // Verify that the home page for this menu is unique. if ($table->load(array('home' => '1', 'menutype' => $this->menutype)) && ($table->id != $this->id || $this->id == 0)) { $this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_UNIQUE_IN_MENU')); return false; } } if (!parent::store($updateNulls)) { return false; } // Get the new path in case the node was moved $pathNodes = $this->getPath(); $segments = array(); foreach ($pathNodes as $node) { // Don't include root in path if ($node->alias != 'root') { $segments[] = $node->alias; } } $newPath = trim(implode('/', $segments), ' /\\'); // Use new path for partial rebuild of table // Rebuild will return positive integer on success, false on failure return ($this->rebuild($this->{$this->_tbl_key}, $this->lft, $this->level, $newPath) > 0); } } home/academiac/www/libraries/cms/form/field/menu.php 0000644 00000002015 15137273773 0016465 0 ustar 00 <?php /** * @package Joomla.Libraries * @subpackage Form * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; JFormHelper::loadFieldClass('list'); // Import the com_menus helper. require_once realpath(JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php'); /** * Supports an HTML select list of menus * * @package Joomla.Libraries * @subpackage Form * @since 1.6.0 */ class JFormFieldMenu extends JFormFieldList { /** * The form field type. * * @var string * @since 1.6.0 */ public $type = 'Menu'; /** * Method to get the list of menus for the field options. * * @return array The field option objects. * * @since 1.6.0 */ protected function getOptions() { // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), JHtml::_('menu.menus')); return $options; } } home/academiac/www/administrator/includes/menu.php 0000644 00000000565 15137315160 0016362 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access. defined('_JEXEC') or die; /** * JMenu class. * * @package Joomla.Administrator * @subpackage Application * @since 1.5 */ class JMenuAdministrator extends JMenu { } home/academiac/www/administrator/modules/mod_menu/menu.php 0000644 00000012060 15140144406 0020015 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; jimport('joomla.base.tree'); /** * @package Joomla.Administrator * @subpackage mod_menu */ class JAdminCssMenu extends JTree { /** * CSS string to add to document head * @var string */ protected $_css = null; function __construct() { $this->_root = new JMenuNode('ROOT'); $this->_current = & $this->_root; } function addSeparator() { $this->addChild(new JMenuNode(null, null, 'separator', false)); } function renderMenu($id = 'menu', $class = '') { $depth = 1; if (!empty($id)) { $id='id="'.$id.'"'; } if (!empty($class)) { $class='class="'.$class.'"'; } /* * Recurse through children if they exist */ while ($this->_current->hasChildren()) { echo "<ul ".$id." ".$class.">\n"; foreach ($this->_current->getChildren() as $child) { $this->_current = & $child; $this->renderLevel($depth++); } echo "</ul>\n"; } if ($this->_css) { // Add style to document head $doc = JFactory::getDocument(); $doc->addStyleDeclaration($this->_css); } } function renderLevel($depth) { /* * Build the CSS class suffix */ $class = ''; if ($this->_current->hasChildren()) { $class = ' class="node"'; } if ($this->_current->class == 'separator') { $class = ' class="separator"'; } if ($this->_current->class == 'disabled') { $class = ' class="disabled"'; } /* * Print the item */ echo "<li".$class.">"; /* * Print a link if it exists */ $linkClass = ''; if ($this->_current->link != null) { $linkClass = $this->getIconClass($this->_current->class); if (!empty($linkClass)) { $linkClass = ' class="'.$linkClass.'"'; } } if ($this->_current->link != null && $this->_current->target != null) { echo "<a".$linkClass." href=\"".$this->_current->link."\" target=\"".$this->_current->target."\" >".$this->_current->title."</a>"; } elseif ($this->_current->link != null && $this->_current->target == null) { echo "<a".$linkClass." href=\"".$this->_current->link."\">".$this->_current->title."</a>"; } elseif ($this->_current->title != null) { echo "<a>".$this->_current->title."</a>\n"; } else { echo "<span></span>"; } /* * Recurse through children if they exist */ while ($this->_current->hasChildren()) { if ($this->_current->class) { $id = ''; if (!empty($this->_current->id)) { $id = ' id="menu-'.strtolower($this->_current->id).'"'; } echo '<ul'.$id.' class="menu-component">'."\n"; } else { echo '<ul>'."\n"; } foreach ($this->_current->getChildren() as $child) { $this->_current = & $child; $this->renderLevel($depth++); } echo "</ul>\n"; } echo "</li>\n"; } /** * Method to get the CSS class name for an icon identifier or create one if * a custom image path is passed as the identifier * * @access public * @param string $identifier Icon identification string * @return string CSS class name * @since 1.5 */ function getIconClass($identifier) { static $classes; // Initialise the known classes array if it does not exist if (!is_array($classes)) { $classes = array(); } /* * If we don't already know about the class... build it and mark it * known so we don't have to build it again */ if (!isset($classes[$identifier])) { if (substr($identifier, 0, 6) == 'class:') { // We were passed a class name $class = substr($identifier, 6); $classes[$identifier] = "icon-16-$class"; } else { if ($identifier == null) { return null; } // Build the CSS class for the icon $class = preg_replace('#\.[^.]*$#', '', basename($identifier)); $class = preg_replace('#\.\.[^A-Za-z0-9\.\_\- ]#', '', $class); $this->_css .= "\n.icon-16-$class {\n" . "\tbackground: url($identifier) no-repeat;\n" . "}\n"; $classes[$identifier] = "icon-16-$class"; } } return $classes[$identifier]; } } /** * @package Joomla.Administrator * @subpackage mod_menu */ class JMenuNode extends JNode { /** * Node Title */ public $title = null; /** * Node Id */ public $id = null; /** * Node Link */ public $link = null; /** * Link Target */ public $target = null; /** * CSS Class for node */ public $class = null; /** * Active Node? */ public $active = false; public function __construct($title, $link = null, $class = null, $active = false, $target = null, $titleicon = null) { $this->title = $titleicon ? $title.$titleicon : $title; $this->link = JFilterOutput::ampReplace($link); $this->class = $class; $this->active = $active; $this->id = null; if (!empty($link) && $link !== '#') { $uri = new JURI($link); $params = $uri->getQuery(true); $parts = array(); foreach ($params as $name => $value) { $parts[] = str_replace(array('.', '_'), '-', $value); } $this->id = implode('-', $parts); } $this->target = $target; } } home/academiac/www/administrator/components/com_menus/tables/menu.php 0000644 00000001723 15140441511 0022167 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_menus * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; // Import JTableMenu JLoader::register('JTableMenu', JPATH_PLATFORM . '/joomla/database/table/menu.php'); /** * @package Joomla.Administrator * @subpackage com_menus */ class MenusTableMenu extends JTableMenu { /** * Method to delete a node and, optionally, its child nodes from the table. * * @param integer $pk The primary key of the node to delete. * @param boolean $children True to delete child nodes, false to move them up a level. * * @return boolean True on success. * * @see http://docs.joomla.org/JTableNested/delete * @since 2.5 */ public function delete($pk = null, $children = false) { return parent::delete($pk, $children); } } home/academiac/www/administrator/components/com_menus/models/menu.php 0000644 00000014556 15140441536 0022217 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; jimport('joomla.application.component.modelform'); /** * Menu Item Model for Menus. * * @package Joomla.Administrator * @subpackage com_menus * @version 1.6 */ class MenusModelMenu extends JModelForm { /** * @var string The prefix to use with controller messages. * @since 1.6 */ protected $text_prefix = 'COM_MENUS_MENU'; /** * Model context string. * * @var string */ protected $_context = 'com_menus.menu'; /** * Method to test whether a record can be deleted. * * @param object A record object. * * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. * @since 1.6 */ protected function canDelete($record) { $user = JFactory::getUser(); return $user->authorise('core.delete', 'com_menus.menu.'.(int) $record->id); } /** * Method to test whether a record can be deleted. * * @param object A record object. * * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. * @since 1.6 */ protected function canEditState($record) { $user = JFactory::getUser(); return $user->authorise('core.edit.state', 'com_menus.menu.'.(int) $record->id); } /** * Returns a Table object, always creating it * * @param type The table type to instantiate * @param string A prefix for the table class name. Optional. * @param array Configuration array for model. Optional. * @return JTable A database object */ public function getTable($type = 'MenuType', $prefix = 'JTable', $config = array()) { return JTable::getInstance($type, $prefix, $config); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState() { $app = JFactory::getApplication('administrator'); // Load the User state. $id = (int) JRequest::getInt('id'); $this->setState('menu.id', $id); // Load the parameters. $params = JComponentHelper::getParams('com_menus'); $this->setState('params', $params); } /** * Method to get a menu item. * * @param integer The id of the menu item to get. * * @return mixed Menu item data object on success, false on failure. */ public function &getItem($itemId = null) { // Initialise variables. $itemId = (!empty($itemId)) ? $itemId : (int)$this->getState('menu.id'); $false = false; // Get a menu item row instance. $table = $this->getTable(); // Attempt to load the row. $return = $table->load($itemId); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return $false; } $properties = $table->getProperties(1); $value = JArrayHelper::toObject($properties, 'JObject'); return $value; } /** * Method to get the menu item form. * * @param array $data Data for the form. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * @return JForm A JForm object on success, false on failure * @since 1.6 */ public function getForm($data = array(), $loadData = true) { // Get the form. $form = $this->loadForm('com_menus.menu', 'menu', array('control' => 'jform', 'load_data' => $loadData)); if (empty($form)) { return false; } return $form; } /** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * @since 1.6 */ protected function loadFormData() { // Check the session for previously entered form data. $data = JFactory::getApplication()->getUserState('com_menus.edit.menu.data', array()); if (empty($data)) { $data = $this->getItem(); } return $data; } /** * Method to save the form data. * * @param array The form data. * @return boolean True on success. */ public function save($data) { $id = (!empty($data['id'])) ? $data['id'] : (int)$this->getState('menu.id'); $isNew = true; // Get a row instance. $table = $this->getTable(); // Load the row if saving an existing item. if ($id > 0) { $table->load($id); $isNew = false; } // Bind the data. if (!$table->bind($data)) { $this->setError($table->getError()); return false; } // Check the data. if (!$table->check()) { $this->setError($table->getError()); return false; } // Store the data. if (!$table->store()) { $this->setError($table->getError()); return false; } $this->setState('menu.id', $table->id); // Clean the cache $this->cleanCache(); return true; } /** * Method to delete groups. * * @param array An array of item ids. * @return boolean Returns true on success, false on failure. */ public function delete($itemIds) { // Sanitize the ids. $itemIds = (array) $itemIds; JArrayHelper::toInteger($itemIds); // Get a group row instance. $table = $this->getTable(); // Iterate the items to delete each one. foreach ($itemIds as $itemId) { // TODO: Delete the menu associations - Menu items and Modules if (!$table->delete($itemId)) { $this->setError($table->getError()); return false; } } // Clean the cache $this->cleanCache(); return true; } /** * Gets a list of all mod_mainmenu modules and collates them by menutype * * @return array */ public function &getModules() { $db = $this->getDbo(); $query = $db->getQuery(true); $query->from('#__modules as a'); $query->select('a.id, a.title, a.params, a.position'); $query->where('module = '.$db->quote('mod_menu')); $query->select('ag.title AS access_title'); $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); $db->setQuery($query); $modules = $db->loadObjectList(); $result = array(); foreach ($modules as &$module) { $params = new JRegistry; $params->loadString($module->params); $menuType = $params->get('menutype'); if (!isset($result[$menuType])) { $result[$menuType] = array(); } $result[$menuType][] = &$module; } return $result; } /** * Custom clean cache method * * @since 1.6 */ protected function cleanCache($group = null, $client_id = 0) { parent::cleanCache('com_modules'); parent::cleanCache('mod_menu'); } }
©
2018.