AAAAhome/academiac/www/includes/menu.php000064400000006603151372543170013507 0ustar00getQuery(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.php000064400000021151151372620310017031 0ustar00getQuery(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 = '' . 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', '', 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', ''); } $lastMenuType = null; $tmpMenuType = null; foreach ($list as $list_a) { if ($list_a->menutype != $lastMenuType) { if ($tmpMenuType) { $mitems[] = JHtml::_('select.option', ''); } $mitems[] = JHtml::_('select.option', '', $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', ''); } 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 = '|_ '; $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.php000064400000003230151372624600021502 0ustar00 $control_name . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value) ); } } home/academiac/www/libraries/joomla/application/menu.php000064400000014211151372647630017441 0ustar00load(); 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.php000064400000013314151372720500017760 0ustar00access = (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.php000064400000002015151372737730016465 0ustar00