0byt3m1n1-V2
Path:
/
home
/
a
/
c
/
a
/
academiac
/
www
/
[
Home
]
File: menus.php.tar
home/academiac/www/administrator/components/com_menus/helpers/menus.php 0000644 00000014646 15140414377 0022564 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; /** * Menus component helper. * * @package Joomla.Administrator * @subpackage com_menus * @since 1.6 */ class MenusHelper { /** * Defines the valid request variables for the reverse lookup. */ protected static $_filter = array('option', 'view', 'layout'); /** * Configure the Linkbar. * * @param string The name of the active view. */ public static function addSubmenu($vName) { JSubMenuHelper::addEntry( JText::_('COM_MENUS_SUBMENU_MENUS'), 'index.php?option=com_menus&view=menus', $vName == 'menus' ); JSubMenuHelper::addEntry( JText::_('COM_MENUS_SUBMENU_ITEMS'), 'index.php?option=com_menus&view=items', $vName == 'items' ); } /** * Gets a list of the actions that can be performed. * * @param int The menu ID. * * @return JObject * @since 1.6 */ public static function getActions($parentId = 0) { $user = JFactory::getUser(); $result = new JObject; if (empty($parentId)) { $assetName = 'com_menus'; } else { $assetName = 'com_menus.item.'.(int) $parentId; } $actions = JAccess::getActions('com_menus'); foreach ($actions as $action) { $result->set($action->name, $user->authorise($action->name, $assetName)); } return $result; } /** * Gets a standard form of a link for lookups. * * @param mixed A link string or array of request variables. * * @return mixed A link in standard option-view-layout form, or false if the supplied response is invalid. */ public static function getLinkKey($request) { if (empty($request)) { return false; } // Check if the link is in the form of index.php?... if (is_string($request)) { $args = array(); if (strpos($request, 'index.php') === 0) { parse_str(parse_url(htmlspecialchars_decode($request), PHP_URL_QUERY), $args); } else { parse_str($request, $args); } $request = $args; } // Only take the option, view and layout parts. foreach ($request as $name => $value) { if ((!in_array($name, self::$_filter)) && (!($name == 'task' && !array_key_exists('view', $request)))) { // Remove the variables we want to ignore. unset($request[$name]); } } ksort($request); return 'index.php?'.http_build_query($request, '', '&'); } /** * Get the menu list for create a menu module * * @return array The menu array list * @since 1.6 */ public static function getMenuTypes() { $db = JFactory::getDbo(); $db->setQuery('SELECT a.menutype FROM #__menu_types AS a'); return $db->loadColumn(); } /** * Get a list of menu links for one or all menus. * * @param string An option menu to filter the list on, otherwise all menu links are returned as a grouped array. * @param int An optional parent ID to pivot results around. * @param int An optional mode. If parent ID is set and mode=2, the parent and children are excluded from the list. * @param array An optional array of states */ public static function getMenuLinks($menuType = null, $parentId = 0, $mode = 0, $published=array(), $languages=array()) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('a.id AS value, a.title AS text, a.level, a.menutype, a.type, a.template_style_id, a.checked_out'); $query->from('#__menu AS a'); $query->join('LEFT', $db->quoteName('#__menu').' AS b ON a.lft > b.lft AND a.rgt < b.rgt'); // Filter by the type if ($menuType) { $query->where('(a.menutype = '.$db->quote($menuType).' OR a.parent_id = 0)'); } if ($parentId) { if ($mode == 2) { // Prevent the parent and children from showing. $query->join('LEFT', '#__menu AS p ON p.id = '.(int) $parentId); $query->where('(a.lft <= p.lft OR a.rgt >= p.rgt)'); } } if (!empty($languages)) { if (is_array($languages)) { $languages = '(' . implode(',', array_map(array($db, 'quote'), $languages)) . ')'; } $query->where('a.language IN ' . $languages); } if (!empty($published)) { if (is_array($published)) $published = '(' . implode(',', $published) .')'; $query->where('a.published IN ' . $published); } $query->where('a.published != -2'); $query->group('a.id, a.title, a.level, a.menutype, a.type, a.template_style_id, a.checked_out, a.lft'); $query->order('a.lft ASC'); // Get the options. $db->setQuery($query); $links = $db->loadObjectList(); // Check for a database error. if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } // Pad the option text with spaces using depth level as a multiplier. foreach ($links as &$link) { $link->text = str_repeat('- ', $link->level).$link->text; } if (empty($menuType)) { // If the menutype is empty, group the items by menutype. $query->clear(); $query->select('*'); $query->from('#__menu_types'); $query->where('menutype <> '.$db->quote('')); $query->order('title, menutype'); $db->setQuery($query); $menuTypes = $db->loadObjectList(); // Check for a database error. if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } // Create a reverse lookup and aggregate the links. $rlu = array(); foreach ($menuTypes as &$type) { $rlu[$type->menutype] = &$type; $type->links = array(); } // Loop through the list of menu links. foreach ($links as &$link) { if (isset($rlu[$link->menutype])) { $rlu[$link->menutype]->links[] = &$link; // Cleanup garbage. unset($link->menutype); } } return $menuTypes; } else { return $links; } } static public function getAssociations($pk) { $associations = array(); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->from('#__menu as m'); $query->innerJoin('#__associations as a ON a.id=m.id AND a.context='.$db->quote('com_menus.item')); $query->innerJoin('#__associations as a2 ON a.key=a2.key'); $query->innerJoin('#__menu as m2 ON a2.id=m2.id'); $query->where('m.id='.(int)$pk); $query->select('m2.language, m2.id'); $db->setQuery($query); $menuitems = $db->loadObjectList('language'); // Check for a database error. if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } foreach ($menuitems as $tag=>$item) { $associations[$tag] = $item->id; } return $associations; } } home/academiac/www/administrator/components/com_menus/models/menus.php 0000644 00000012414 15140441467 0022374 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 * * @package Joomla.Administrator * @subpackage com_menus */ // no direct access defined('_JEXEC') or die; jimport('joomla.application.component.modellist'); /** * Menu List Model for Menus. * * @package Joomla.Administrator * @subpackage com_menus * @since 1.6 */ class MenusModelMenus extends JModelList { /** * Constructor. * * @param array An optional associative array of configuration settings. * * @see JController * @since 1.6 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'id', 'a.id', 'title', 'a.title', 'menutype', 'a.menutype', ); } parent::__construct($config); } /** * Overrides the getItems method to attach additional metrics to the list. * * @return mixed An array of data items on success, false on failure. * * @since 1.6.1 */ public function getItems() { // Get a storage key. $store = $this->getStoreId('getItems'); // Try to load the data from internal storage. if (!empty($this->cache[$store])) { return $this->cache[$store]; } // Load the list items. $items = parent::getItems(); // If emtpy or an error, just return. if (empty($items)) { return array(); } // Getting the following metric by joins is WAY TOO SLOW. // Faster to do three queries for very large menu trees. // Get the menu types of menus in the list. $db = $this->getDbo(); $menuTypes = JArrayHelper::getColumn($items, 'menutype'); // Quote the strings. $menuTypes = implode( ',', array_map(array($db, 'quote'), $menuTypes) ); // Get the published menu counts. $query = $db->getQuery(true) ->select('m.menutype, COUNT(DISTINCT m.id) AS count_published') ->from('#__menu AS m') ->where('m.published = 1') ->where('m.menutype IN ('.$menuTypes.')') ->group('m.menutype') ; $db->setQuery($query); $countPublished = $db->loadAssocList('menutype', 'count_published'); if ($db->getErrorNum()) { $this->setError($db->getErrorMsg()); return false; } // Get the unpublished menu counts. $query->clear('where') ->where('m.published = 0') ->where('m.menutype IN ('.$menuTypes.')'); $db->setQuery($query); $countUnpublished = $db->loadAssocList('menutype', 'count_published'); if ($db->getErrorNum()) { $this->setError($db->getErrorMsg()); return false; } // Get the trashed menu counts. $query->clear('where') ->where('m.published = -2') ->where('m.menutype IN ('.$menuTypes.')'); $db->setQuery($query); $countTrashed = $db->loadAssocList('menutype', 'count_published'); if ($db->getErrorNum()) { $this->setError($db->getErrorMsg()); return false; } // Inject the values back into the array. foreach ($items as $item) { $item->count_published = isset($countPublished[$item->menutype]) ? $countPublished[$item->menutype] : 0; $item->count_unpublished = isset($countUnpublished[$item->menutype]) ? $countUnpublished[$item->menutype] : 0; $item->count_trashed = isset($countTrashed[$item->menutype]) ? $countTrashed[$item->menutype] : 0; } // Add the items to the internal cache. $this->cache[$store] = $items; return $this->cache[$store]; } /** * Method to build an SQL query to load the list data. * * @return string An SQL query * * @since 1.6 */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select all fields from the table. $query->select($this->getState('list.select', 'a.*')); $query->from($db->quoteName('#__menu_types').' AS a'); $query->group('a.id, a.menutype, a.title, a.description'); // Add the list ordering clause. $query->order($db->escape($this->getState('list.ordering', 'a.id')).' '.$db->escape($this->getState('list.direction', 'ASC'))); return $query; } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication('administrator'); // List state information. parent::populateState('a.id', 'asc'); } /** * Gets the extension id of the core mod_menu module. * * @return integer * * @since 2.5 */ public function getModMenuId() { $db = $this->getDbo(); $query = $db->getQuery(true); $query->select('e.extension_id') ->from('#__extensions AS e') ->where('e.type = ' . $db->quote('module')) ->where('e.element = ' . $db->quote('mod_menu')) ->where('e.client_id = 0'); $db->setQuery($query); return $db->loadResult(); } /** * Gets a list of all mod_mainmenu modules and collates them by menutype * * @return array */ public function &getModules() { $model = JModelLegacy::getInstance('Menu', 'MenusModel', array('ignore_request' => true)); $result = &$model->getModules(); return $result; } } home/academiac/www/administrator/components/com_menus/menus.php 0000644 00000001071 15140646637 0021114 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 */ defined('_JEXEC') or die; // Access check. if (!JFactory::getUser()->authorise('core.manage', 'com_menus')) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } // Execute the task. $controller = JControllerLegacy::getInstance('Menus'); $controller->execute(JRequest::getCmd('task')); $controller->redirect(); home/academiac/www/administrator/components/com_menus/controllers/menus.php 0000644 00000010504 15145344011 0023445 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 */ defined('_JEXEC') or die; /** * The Menu List Controller * * @package Joomla.Administrator * @subpackage com_menus * @since 1.6 */ class MenusControllerMenus extends JControllerLegacy { /** * Display the view * * @param boolean If true, the view output will be cached * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.6 */ public function display($cachable = false, $urlparams = false) { } /** * Method to get a model object, loading it if required. * * @param string $name The model name. Optional. * @param string $prefix The class prefix. Optional. * @param array $config Configuration array for model. Optional. * * @return object The model. * * @since 1.6 */ public function getModel($name = 'Menu', $prefix = 'MenusModel', $config = array('ignore_request' => true)) { $model = parent::getModel($name, $prefix, $config); return $model; } /** * Removes an item */ public function delete() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Get items to remove from the request. $cid = JRequest::getVar('cid', array(), '', 'array'); if (!is_array($cid) || count($cid) < 1) { JError::raiseWarning(500, JText::_('COM_MENUS_NO_MENUS_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers jimport('joomla.utilities.arrayhelper'); JArrayHelper::toInteger($cid); // Remove the items. if (!$model->delete($cid)) { $this->setMessage($model->getError()); } else { $this->setMessage(JText::plural('COM_MENUS_N_MENUS_DELETED', count($cid))); } } $this->setRedirect('index.php?option=com_menus&view=menus'); } /** * Rebuild the menu tree. * * @return bool False on failure or error, true on success. */ public function rebuild() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $this->setRedirect('index.php?option=com_menus&view=menus'); // Initialise variables. $model = $this->getModel('Item'); if ($model->rebuild()) { // Reorder succeeded. $this->setMessage(JText::_('JTOOLBAR_REBUILD_SUCCESS')); return true; } else { // Rebuild failed. $this->setMessage(JText::sprintf('JTOOLBAR_REBUILD_FAILED', $model->getMessage())); return false; } } /** * Temporary method. This should go into the 1.5 to 1.6 upgrade routines. */ public function resync() { // Initialise variables. $db = JFactory::getDbo(); $parts = null; // Load a lookup table of all the component id's. $components = $db->setQuery( 'SELECT element, extension_id' . ' FROM #__extensions' . ' WHERE type = '.$db->quote('component') )->loadAssocList('element', 'extension_id'); if ($error = $db->getErrorMsg()) { return JError::raiseWarning(500, $error); } // Load all the component menu links $items = $db->setQuery( 'SELECT id, link, component_id' . ' FROM #__menu' . ' WHERE type = '.$db->quote('component') )->loadObjectList(); if ($error = $db->getErrorMsg()) { return JError::raiseWarning(500, $error); } foreach ($items as $item) { // Parse the link. parse_str(parse_url($item->link, PHP_URL_QUERY), $parts); // Tease out the option. if (isset($parts['option'])) { $option = $parts['option']; // Lookup the component ID if (isset($components[$option])) { $componentId = $components[$option]; } else { // Mismatch. Needs human intervention. $componentId = -1; } // Check for mis-matched component id's in the menu link. if ($item->component_id != $componentId) { // Update the menu table. $log = "Link $item->id refers to $item->component_id, converting to $componentId ($item->link)"; echo "<br/>$log"; $db->setQuery( 'UPDATE #__menu' . ' SET component_id = '.$componentId. ' WHERE id = '.$item->id )->query(); //echo "<br>".$db->getQuery(); if ($error = $db->getErrorMsg()) { return JError::raiseWarning(500, $error); } } } } } } home/academiac/www/administrator/components/com_menus/helpers/html/menus.php 0000644 00000007770 15146602100 0023515 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; JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php'); /** * @package Joomla.Administrator * @subpackage com_menus */ abstract class MenusHtmlMenus { /** * @param int $itemid The menu item id */ static function association($itemid) { // Get the associations $associations = MenusHelper::getAssociations($itemid); // Get the associated menu items $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('m.*'); $query->select('mt.title as menu_title'); $query->from('#__menu as m'); $query->leftJoin('#__menu_types as mt ON mt.menutype=m.menutype'); $query->where('m.id IN ('.implode(',', array_values($associations)).')'); $query->leftJoin('#__languages as l ON m.language=l.lang_code'); $query->select('l.image'); $query->select('l.title as language_title'); $db->setQuery($query); $items = $db->loadObjectList('id'); // Check for a database error. if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return false; } // Construct html $text = array(); foreach ($associations as $tag=>$associated) { if ($associated != $itemid) { $text[] = JText::sprintf('COM_MENUS_TIP_ASSOCIATED_LANGUAGE', JHtml::_('image', 'mod_languages/'.$items[$associated]->image.'.gif', $items[$associated]->language_title, array('title'=>$items[$associated]->language_title), true), $items[$associated]->title, $items[$associated]->menu_title); } } return JHtml::_('tooltip', implode('<br />', $text), JText::_('COM_MENUS_TIP_ASSOCIATION'), 'menu/icon-16-links.png'); } /** * Returns a published state on a grid * * @param integer $value The state value. * @param integer $i The row index * @param boolean $enabled An optional setting for access control on the action. * @param string $checkbox An optional prefix for checkboxes. * * @return string The Html code * * @see JHtmlJGrid::state * * @since 1.7.1 */ public static function state($value, $i, $enabled = true, $checkbox = 'cb') { $states = array( 7 => array( 'unpublish', '', 'COM_MENUS_HTML_UNPUBLISH_SEPARATOR', '', false, 'publish', 'publish' ), 6 => array( 'publish', '', 'COM_MENUS_HTML_PUBLISH_SEPARATOR', '', false, 'unpublish', 'unpublish' ), 5 => array( 'unpublish', '', 'COM_MENUS_HTML_UNPUBLISH_ALIAS', '', false, 'publish', 'publish' ), 4 => array( 'publish', '', 'COM_MENUS_HTML_PUBLISH_ALIAS', '', false, 'unpublish', 'unpublish' ), 3 => array( 'unpublish', '', 'COM_MENUS_HTML_UNPUBLISH_URL', '', false, 'publish', 'publish' ), 2 => array( 'publish', '', 'COM_MENUS_HTML_PUBLISH_URL', '', false, 'unpublish', 'unpublish' ), 1 => array( 'unpublish', 'COM_MENUS_EXTENSION_PUBLISHED_ENABLED', 'COM_MENUS_HTML_UNPUBLISH_ENABLED', 'COM_MENUS_EXTENSION_PUBLISHED_ENABLED', true, 'publish', 'publish' ), 0 => array( 'publish', 'COM_MENUS_EXTENSION_UNPUBLISHED_ENABLED', 'COM_MENUS_HTML_PUBLISH_ENABLED', 'COM_MENUS_EXTENSION_UNPUBLISHED_ENABLED', true, 'unpublish', 'unpublish' ), -1 => array( 'unpublish', 'COM_MENUS_EXTENSION_PUBLISHED_DISABLED', 'COM_MENUS_HTML_UNPUBLISH_DISABLED', 'COM_MENUS_EXTENSION_PUBLISHED_DISABLED', true, 'warning', 'warning' ), -2 => array( 'publish', 'COM_MENUS_EXTENSION_UNPUBLISHED_DISABLED', 'COM_MENUS_HTML_PUBLISH_DISABLED', 'COM_MENUS_EXTENSION_UNPUBLISHED_DISABLED', true, 'unpublish', 'unpublish' ), ); return JHtml::_('jgrid.state', $states, $value, $i, 'items.', $enabled, true, $checkbox); } }
©
2018.