Файловый менеджер - Редактировать - /home/wuectly/www/03cbe/com_menus.zip
Назад
PK �s!]ż�1 1 menus.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_menus * * @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; if (!JFactory::getUser()->authorise('core.manage', 'com_menus')) { throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $controller = JControllerLegacy::getInstance('Menus'); $controller->execute(JFactory::getApplication()->input->get('task')); $controller->redirect(); PK �s!];�E� � controller.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_menus * * @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Base controller class for Menu Manager. * * @since 1.6 */ class MenusController extends JControllerLegacy { /** * Method to display a view. * * @param boolean $cachable If true, the view output will be cached * @param array|boolean $urlparams 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.5 */ public function display($cachable = false, $urlparams = false) { JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php'); // Check custom administrator menu modules if (JModuleHelper::isAdminMultilang()) { $languages = JLanguageHelper::getInstalledLanguages(1, true); $langCodes = array(); foreach ($languages as $language) { if (isset($language->metadata['nativeName'])) { $languageName = $language->metadata['nativeName']; } else { $languageName = $language->metadata['name']; } $langCodes[$language->metadata['tag']] = $languageName; } $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select($db->qn('m.language')) ->from($db->qn('#__modules', 'm')) ->where($db->qn('m.module') . ' = ' . $db->quote('mod_menu')) ->where($db->qn('m.published') . ' = 1') ->where($db->qn('m.client_id') . ' = 1') ->group($db->qn('m.language')); $mLanguages = $db->setQuery($query)->loadColumn(); // Check if we have a mod_menu module set to All languages or a mod_menu module for each admin language. if (!in_array('*', $mLanguages) && count($langMissing = array_diff(array_keys($langCodes), $mLanguages))) { $app = JFactory::getApplication(); $langMissing = array_intersect_key($langCodes, array_flip($langMissing)); $app->enqueueMessage(JText::sprintf('JMENU_MULTILANG_WARNING_MISSING_MODULES', implode(', ', $langMissing)), 'warning'); } } return parent::display(); } } PK �s!]&�� models/forms/filter_items.xmlnu &1i� <?xml version="1.0" encoding="utf-8"?> <form> <field name="client_id" type="list" label="" filtermode="selector" onchange="this.form.submit();" > <option value="0">JSITE</option> <option value="1">JADMINISTRATOR</option> </field> <field name="menutype" type="menu" label="COM_MENUS_FILTER_CATEGORY" description="JOPTION_FILTER_CATEGORY_DESC" accesstype="manage" clientid="" showAll="false" filtermode="selector" onchange="this.form.submit();" > <option value="">COM_MENUS_SELECT_MENU</option> </field> <fields name="filter"> <field name="search" type="text" inputmode="search" label="COM_MENUS_ITEMS_SEARCH_FILTER_LABEL" description="COM_MENUS_ITEMS_SEARCH_FILTER" hint="JSEARCH_FILTER" noresults="JGLOBAL_NO_MATCHING_RESULTS" /> <field name="published" type="status" label="COM_MENUS_FILTER_PUBLISHED" description="COM_MENUS_FILTER_PUBLISHED_DESC" filter="*,0,1,-2" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_PUBLISHED</option> </field> <field name="access" type="accesslevel" label="JOPTION_FILTER_ACCESS" description="JOPTION_FILTER_ACCESS_DESC" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_ACCESS</option> </field> <field name="language" type="contentlanguage" label="JOPTION_FILTER_LANGUAGE" description="JOPTION_FILTER_LANGUAGE_DESC" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_LANGUAGE</option> <option value="*">JALL</option> </field> <field name="level" type="integer" label="JOPTION_FILTER_LEVEL" description="JOPTION_FILTER_LEVEL_DESC" first="1" last="10" step="1" languages="*" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_MAX_LEVELS</option> </field> <field name="parent_id" type="menuitembytype" label="COM_MENUS_FILTER_PARENT_MENU_ITEM_LABEL" description="COM_MENUS_FILTER_PARENT_MENU_ITEM_DESC" onchange="this.form.submit();" > <option value="">COM_MENUS_FILTER_SELECT_PARENT_MENU_ITEM</option> </field> </fields> <fields name="list"> <field name="fullordering" type="list" label="JGLOBAL_SORT_BY" description="JGLOBAL_SORT_BY" statuses="*,0,1,2,-2" onchange="this.form.submit();" default="a.lft ASC" validate="options" > <option value="">JGLOBAL_SORT_BY</option> <option value="a.lft ASC">JGRID_HEADING_ORDERING_ASC</option> <option value="a.lft DESC">JGRID_HEADING_ORDERING_DESC</option> <option value="a.published ASC">JSTATUS_ASC</option> <option value="a.published DESC">JSTATUS_DESC</option> <option value="a.title ASC">JGLOBAL_TITLE_ASC</option> <option value="a.title DESC">JGLOBAL_TITLE_DESC</option> <option value="menutype_title ASC">COM_MENUS_HEADING_MENU_ASC</option> <option value="menutype_title DESC">COM_MENUS_HEADING_MENU_DESC</option> <option value="a.home ASC">COM_MENUS_HEADING_HOME_ASC</option> <option value="a.home DESC">COM_MENUS_HEADING_HOME_DESC</option> <option value="a.access ASC">JGRID_HEADING_ACCESS_ASC</option> <option value="a.access DESC">JGRID_HEADING_ACCESS_DESC</option> <option value="association ASC" requires="associations">JASSOCIATIONS_ASC</option> <option value="association DESC" requires="associations">JASSOCIATIONS_DESC</option> <option value="language ASC">JGRID_HEADING_LANGUAGE_ASC</option> <option value="language DESC">JGRID_HEADING_LANGUAGE_DESC</option> <option value="a.id ASC">JGRID_HEADING_ID_ASC</option> <option value="a.id DESC">JGRID_HEADING_ID_DESC</option> </field> <field name="limit" type="limitbox" label="COM_MENUS_LIST_LIMIT" description="COM_MENUS_LIST_LIMIT_DESC" class="input-mini" default="25" onchange="this.form.submit();" /> </fields> </form> PK �|!]�*�#y y controllers/items.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_menus * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\Utilities\ArrayHelper; /** * The Menu Item Controller * * @since 1.6 */ class MenusControllerItems extends JControllerAdmin { /** * Constructor * * @param array $config Optional configuration array * * @since 1.6 */ public function __construct($config = array()) { parent::__construct($config); $this->registerTask('unsetDefault', 'setDefault'); } /** * Proxy for getModel. * * @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 = 'Item', $prefix = 'MenusModel', $config = array()) { return parent::getModel($name, $prefix, array('ignore_request' => true)); } /** * Rebuild the nested set tree. * * @return boolean False on failure or error, true on success. * * @since 1.6 */ public function rebuild() { $this->checkToken(); $this->setRedirect('index.php?option=com_menus&view=items'); $model = $this->getModel(); if ($model->rebuild()) { // Reorder succeeded. $this->setMessage(JText::_('COM_MENUS_ITEMS_REBUILD_SUCCESS')); return true; } else { // Rebuild failed. $this->setMessage(JText::sprintf('COM_MENUS_ITEMS_REBUILD_FAILED'), 'error'); return false; } } /** * Save the manual order inputs from the menu items list view * * @return void * * @see JControllerAdmin::saveorder() * @deprecated 4.0 */ public function saveorder() { $this->checkToken(); try { JLog::add( sprintf('%s() is deprecated. Function will be removed in 4.0.', __METHOD__), JLog::WARNING, 'deprecated' ); } catch (RuntimeException $exception) { // Informational log only } // Get the arrays from the Request $order = $this->input->post->get('order', null, 'array'); $originalOrder = explode(',', $this->input->getString('original_order_values')); // Make sure something has changed if (!($order === $originalOrder)) { parent::saveorder(); } else { // Nothing to reorder $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false)); return true; } } /** * Method to set the home property for a list of items * * @return void * * @since 1.6 */ public function setDefault() { // Check for request forgeries $this->checkToken('request'); $app = JFactory::getApplication(); // Get items to publish from the request. $cid = (array) $this->input->get('cid', array(), 'int'); $data = array('setDefault' => 1, 'unsetDefault' => 0); $task = $this->getTask(); $value = ArrayHelper::getValue($data, $task, 0, 'int'); // Remove zero values resulting from input filter $cid = array_filter($cid); if (empty($cid)) { JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Publish the items. if (!$model->setHome($cid, $value)) { JError::raiseWarning(500, $model->getError()); } else { if ($value == 1) { $ntext = 'COM_MENUS_ITEMS_SET_HOME'; } else { $ntext = 'COM_MENUS_ITEMS_UNSET_HOME'; } $this->setMessage(JText::plural($ntext, count($cid))); } } $this->setRedirect( JRoute::_( 'index.php?option=' . $this->option . '&view=' . $this->view_list . '&menutype=' . $app->getUserState('com_menus.items.menutype'), false ) ); } /** * Method to publish a list of items * * @return void * * @since 3.6.0 */ public function publish() { // Check for request forgeries $this->checkToken(); // Get items to publish from the request. $cid = (array) JFactory::getApplication()->input->get('cid', array(), 'int'); $data = array('publish' => 1, 'unpublish' => 0, 'trash' => -2, 'report' => -3); $task = $this->getTask(); $value = ArrayHelper::getValue($data, $task, 0, 'int'); // Remove zero values resulting from input filter $cid = array_filter($cid); if (empty($cid)) { try { JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror'); } catch (RuntimeException $exception) { JFactory::getApplication()->enqueueMessage(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), 'warning'); } } else { // Get the model. $model = $this->getModel(); // Publish the items. try { $model->publish($cid, $value); $errors = $model->getErrors(); $messageType = 'message'; if ($value == 1) { if ($errors) { $messageType = 'error'; $ntext = $this->text_prefix . '_N_ITEMS_FAILED_PUBLISHING'; } else { $ntext = $this->text_prefix . '_N_ITEMS_PUBLISHED'; } } elseif ($value == 0) { $ntext = $this->text_prefix . '_N_ITEMS_UNPUBLISHED'; } else { $ntext = $this->text_prefix . '_N_ITEMS_TRASHED'; } $this->setMessage(JText::plural($ntext, count($cid)), $messageType); } catch (Exception $e) { $this->setMessage($e->getMessage(), 'error'); } } $this->setRedirect( JRoute::_( 'index.php?option=' . $this->option . '&view=' . $this->view_list . '&menutype=' . JFactory::getApplication()->getUserState('com_menus.items.menutype'), false ) ); } /** * Check in of one or more records. * * @return boolean True on success * * @since 3.6.0 */ public function checkin() { // Check for request forgeries. $this->checkToken(); // Read the Ids from the post data $cid = (array) JFactory::getApplication()->input->post->get('cid', array(), 'int'); // Remove zero values resulting from input filter $cid = array_filter($cid); // Run the model $model = $this->getModel(); $return = $model->checkin($cid); if ($return === false) { // Checkin failed. $message = JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()); $this->setRedirect( JRoute::_( 'index.php?option=' . $this->option . '&view=' . $this->view_list . '&menutype=' . JFactory::getApplication()->getUserState('com_menus.items.menutype'), false ), $message, 'error' ); return false; } else { // Checkin succeeded. $message = JText::plural($this->text_prefix . '_N_ITEMS_CHECKED_IN', count($cid)); $this->setRedirect( JRoute::_( 'index.php?option=' . $this->option . '&view=' . $this->view_list . '&menutype=' . JFactory::getApplication()->getUserState('com_menus.items.menutype'), false ), $message ); return true; } } } PK �|!]�ǽ�d d controllers/ajax.json.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_menus * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Language\LanguageHelper; /** * The menu controller for ajax requests * * @since 3.9.0 */ class MenusControllerAjax extends JControllerLegacy { /** * Method to fetch associations of a menu item * * The method assumes that the following http parameters are passed in an Ajax Get request: * token: the form token * assocId: the id of the menu item whose associations are to be returned * excludeLang: the association for this language is to be excluded * * @return null * * @since 3.9.0 */ public function fetchAssociations() { if (!JSession::checkToken('get')) { echo new JResponseJson(null, JText::_('JINVALID_TOKEN'), true); } else { $input = JFactory::getApplication()->input; $extension = $input->get('extension'); $assocId = $input->getInt('assocId', 0); if ($assocId == 0) { echo new JResponseJson(null, JText::sprintf('JLIB_FORM_VALIDATE_FIELD_INVALID', 'assocId'), true); return; } $excludeLang = $input->get('excludeLang', '', 'STRING'); $associations = JLanguageAssociations::getAssociations('com_menus', '#__menu', 'com_menus.item', (int) $assocId, 'id', '', ''); unset($associations[$excludeLang]); // Add the title to each of the associated records JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_menus/tables'); $menuTable = JTable::getInstance('Menu', 'JTable', array()); foreach ($associations as $lang => $association) { $menuTable->load($association->id); $associations[$lang]->title = $menuTable->title; } $countContentLanguages = count(LanguageHelper::getContentLanguages(array(0, 1))); if (count($associations) == 0) { $message = JText::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_NONE'); } elseif ($countContentLanguages > count($associations) + 2) { $tags = implode(', ', array_keys($associations)); $message = JText::sprintf('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_SOME', $tags); } else { $message = JText::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_MESSAGE_ALL'); } echo new JResponseJson($associations, $message); } } } PK �|!]���5 controllers/menu.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_menus * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * The Menu Type Controller * * @since 1.6 */ class MenusControllerMenu extends JControllerForm { /** * Dummy method to redirect back to standard controller * * @param boolean $cachable If true, the view output will be cached. * @param array $urlparams 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.5 */ public function display($cachable = false, $urlparams = false) { $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menus', false)); } /** * Method to save a menu item. * * @param string $key The name of the primary key of the URL variable. * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). * * @return boolean True if successful, false otherwise. * * @since 1.6 */ public function save($key = null, $urlVar = null) { // Check for request forgeries. $this->checkToken(); $app = JFactory::getApplication(); $data = $this->input->post->get('jform', array(), 'array'); $context = 'com_menus.edit.menu'; $task = $this->getTask(); $recordId = $this->input->getInt('id'); // Prevent using 'main' as menutype as this is reserved for backend menus if (strtolower($data['menutype']) == 'main') { $msg = JText::_('COM_MENUS_ERROR_MENUTYPE'); JFactory::getApplication()->enqueueMessage($msg, 'error'); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menu&layout=edit' . $this->getRedirectToItemAppend($recordId), false)); return false; } // Populate the row id from the session. $data['id'] = $recordId; // Get the model and attempt to validate the posted data. $model = $this->getModel('Menu'); $form = $model->getForm(); if (!$form) { JError::raiseError(500, $model->getError()); return false; } $validData = $model->validate($form, $data); // Check for validation errors. if ($validData === false) { // Get the validation messages. $errors = $model->getErrors(); // Push up to three validation messages out to the user. for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { if ($errors[$i] instanceof Exception) { $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); } else { $app->enqueueMessage($errors[$i], 'warning'); } } // Save the data in the session. $app->setUserState($context . '.data', $data); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menu&layout=edit' . $this->getRedirectToItemAppend($recordId), false)); return false; } if (isset($validData['preset'])) { $preset = trim($validData['preset']) ?: null; unset($validData['preset']); } // Attempt to save the data. if (!$model->save($validData)) { // Save the data in the session. $app->setUserState($context . '.data', $validData); // Redirect back to the edit screen. $this->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError()), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menu&layout=edit' . $this->getRedirectToItemAppend($recordId), false)); return false; } // Import the preset selected if (isset($preset) && $data['client_id'] == 1) { try { MenusHelper::installPreset($preset, $data['menutype']); $this->setMessage(JText::_('COM_MENUS_PRESET_IMPORT_SUCCESS')); } catch (Exception $e) { // Save was successful but the preset could not be loaded. Let it through with just a warning $this->setMessage(JText::sprintf('COM_MENUS_PRESET_IMPORT_FAILED', $e->getMessage())); } } else { $this->setMessage(JText::_('COM_MENUS_MENU_SAVE_SUCCESS')); } // Redirect the user and adjust session state based on the chosen task. switch ($task) { case 'apply': // Set the record data in the session. $recordId = $model->getState($this->context . '.id'); $this->holdEditId($context, $recordId); $app->setUserState($context . '.data', null); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menu&layout=edit' . $this->getRedirectToItemAppend($recordId), false)); break; case 'save2new': // Clear the record id and data from the session. $this->releaseEditId($context, $recordId); $app->setUserState($context . '.data', null); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menu&layout=edit', false)); break; default: // Clear the record id and data from the session. $this->releaseEditId($context, $recordId); $app->setUserState($context . '.data', null); // Redirect to the list screen. $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menus', false)); break; } } /** * Method to display a menu as preset xml. * * @return boolean True if successful, false otherwise. * * @since 3.8.0 */ public function exportXml() { // Check for request forgeries. $this->checkToken(); $cid = (array) $this->input->get('cid', array(), 'int'); // We know the first element is the one we need because we don't allow multi selection of rows $id = empty($cid) ? 0 : reset($cid); if ($id === 0) { $this->setMessage(JText::_('COM_MENUS_SELECT_MENU_FIRST_EXPORT'), 'warning'); $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menus', false)); return false; } $model = $this->getModel('Menu'); $item = $model->getItem($id); if (!$item->menutype) { $this->setMessage(JText::_('COM_MENUS_SELECT_MENU_FIRST_EXPORT'), 'warning'); $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menus', false)); return false; } $this->setRedirect(JRoute::_('index.php?option=com_menus&view=menu&menutype=' . $item->menutype . '&format=xml', false)); return true; } } PK �|!]�d:� � controllers/menus.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_menus * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * The Menu List Controller * * @since 1.6 */ class MenusControllerMenus extends JControllerLegacy { /** * Display the view * * @param boolean $cachable If true, the view output will be cached. * @param array $urlparams 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)) { return parent::getModel($name, $prefix, $config); } /** * Remove an item. * * @return void * * @since 1.6 */ public function delete() { // Check for request forgeries $this->checkToken(); $user = JFactory::getUser(); $app = JFactory::getApplication(); $cids = (array) $this->input->get('cid', array(), 'int'); // Remove zero values resulting from input filter $cids = array_filter($cids); if (empty($cids)) { $app->enqueueMessage(JText::_('COM_MENUS_NO_MENUS_SELECTED'), 'notice'); } else { // Access checks. foreach ($cids as $i => $id) { if (!$user->authorise('core.delete', 'com_menus.menu.' . (int) $id)) { // Prune items that you can't change. unset($cids[$i]); $app->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), 'error'); } } if (count($cids) > 0) { // Get the model. $model = $this->getModel(); // Remove the items. if (!$model->delete($cids)) { $this->setMessage($model->getError(), 'error'); } else { $this->setMessage(JText::plural('COM_MENUS_N_MENUS_DELETED', count($cids))); } } } $this->setRedirect('index.php?option=com_menus&view=menus'); } /** * Rebuild the menu tree. * * @return boolean False on failure or error, true on success. * * @since 1.6 */ public function rebuild() { $this->checkToken(); $this->setRedirect('index.php?option=com_menus&view=menus'); $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->getError()), 'error'); return false; } } /** * Temporary method. This should go into the 1.5 to 1.6 upgrade routines. * * @return JException|void JException instance on error * * @since 1.6 */ public function resync() { $db = JFactory::getDbo(); $query = $db->getQuery(true); $parts = null; try { $query->select('element, extension_id') ->from('#__extensions') ->where('type = ' . $db->quote('component')); $db->setQuery($query); $components = $db->loadAssocList('element', 'extension_id'); } catch (RuntimeException $e) { return JError::raiseWarning(500, $e->getMessage()); } // Load all the component menu links $query->select($db->quoteName('id')) ->select($db->quoteName('link')) ->select($db->quoteName('component_id')) ->from('#__menu') ->where($db->quoteName('type') . ' = ' . $db->quote('component.item')); $db->setQuery($query); try { $items = $db->loadObjectList(); } catch (RuntimeException $e) { return JError::raiseWarning(500, $e->getMessage()); } 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"; $query->clear(); $query->update('#__menu') ->set('component_id = ' . $componentId) ->where('id = ' . $item->id); try { $db->setQuery($query)->execute(); } catch (RuntimeException $e) { return JError::raiseWarning(500, $e->getMessage()); } } } } } } PK �|!]?(�e�? �? controllers/item.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_menus * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * The Menu Item Controller * * @since 1.6 */ class MenusControllerItem extends JControllerForm { /** * Method to check if you can add a new record. * * Extended classes can override this if necessary. * * @param array $data An array of input data. * * @return boolean * * @since 3.6 */ protected function allowAdd($data = array()) { $user = JFactory::getUser(); $menuType = JFactory::getApplication()->input->getCmd('menutype', isset($data['menutype']) ? $data['menutype'] : ''); $menutypeID = 0; // Load menutype ID if ($menuType) { $menutypeID = (int) $this->getMenuTypeId($menuType); } return $user->authorise('core.create', 'com_menus.menu.' . $menutypeID); } /** * Method to check if you edit a record. * * Extended classes can override this if necessary. * * @param array $data An array of input data. * @param string $key The name of the key for the primary key; default is id. * * @return boolean * * @since 3.6 */ protected function allowEdit($data = array(), $key = 'id') { $user = JFactory::getUser(); $menutypeID = 0; if (isset($data[$key])) { $model = $this->getModel(); $item = $model->getItem($data[$key]); if (!empty($item->menutype)) { // Protected menutype, do not allow edit if ($item->menutype == 'main') { return false; } $menutypeID = (int) $this->getMenuTypeId($item->menutype); } } return $user->authorise('core.edit', 'com_menus.menu.' . (int) $menutypeID); } /** * Loads the menutype ID by a given menutype string * * @param string $menutype The given menutype * * @return integer * * @since 3.6 */ protected function getMenuTypeId($menutype) { $model = $this->getModel(); $table = $model->getTable('MenuType', 'JTable'); $table->load(array('menutype' => $menutype)); return (int) $table->id; } /** * Method to add a new menu item. * * @return mixed True if the record can be added, a JError object if not. * * @since 1.6 */ public function add() { $app = JFactory::getApplication(); $context = 'com_menus.edit.item'; $result = parent::add(); if ($result) { $app->setUserState($context . '.type', null); $app->setUserState($context . '.link', null); } return $result; } /** * Method to run batch operations. * * @param object $model The model. * * @return boolean True if successful, false otherwise and internal error is set. * * @since 1.6 */ public function batch($model = null) { $this->checkToken(); $model = $this->getModel('Item', '', array()); // Preset the redirect $this->setRedirect(JRoute::_('index.php?option=com_menus&view=items' . $this->getRedirectToListAppend(), false)); return parent::batch($model); } /** * Method to cancel an edit. * * @param string $key The name of the primary key of the URL variable. * * @return boolean True if access level checks pass, false otherwise. * * @since 1.6 */ public function cancel($key = null) { $this->checkToken(); $app = JFactory::getApplication(); $context = 'com_menus.edit.item'; $result = parent::cancel(); if ($result) { // Clear the ancillary data from the session. $app->setUserState($context . '.type', null); $app->setUserState($context . '.link', null); // Redirect to the list screen. $this->setRedirect( JRoute::_( 'index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend() . '&menutype=' . $app->getUserState('com_menus.items.menutype'), false ) ); } return $result; } /** * Method to edit an existing record. * * @param string $key The name of the primary key of the URL variable. * @param string $urlVar The name of the URL variable if different from the primary key * (sometimes required to avoid router collisions). * * @return boolean True if access level check and checkout passes, false otherwise. * * @since 1.6 */ public function edit($key = null, $urlVar = null) { $app = JFactory::getApplication(); $result = parent::edit(); if ($result) { // Push the new ancillary data into the session. $app->setUserState('com_menus.edit.item.type', null); $app->setUserState('com_menus.edit.item.link', null); } return $result; } /** * Gets the URL arguments to append to an item redirect. * * @param integer $recordId The primary key id for the item. * @param string $urlVar The name of the URL variable for the id. * * @return string The arguments to append to the redirect URL. * * @since 3.0.1 */ protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') { $append = parent::getRedirectToItemAppend($recordId, $urlVar); if ($recordId) { $model = $this->getModel(); $item = $model->getItem($recordId); $clientId = $item->client_id; $append = '&client_id=' . $clientId . $append; } else { $app = JFactory::getApplication(); $clientId = $app->input->get('client_id', '0', 'int'); $menuType = $app->input->get('menutype', 'mainmenu', 'cmd'); $append = '&client_id=' . $clientId . ($menuType ? '&menutype=' . $menuType : '') . $append; } return $append; } /** * Method to save a record. * * @param string $key The name of the primary key of the URL variable. * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). * * @return boolean True if successful, false otherwise. * * @since 1.6 */ public function save($key = null, $urlVar = null) { // Check for request forgeries. $this->checkToken(); $app = JFactory::getApplication(); $model = $this->getModel('Item', '', array()); $table = $model->getTable(); $data = $this->input->post->get('jform', array(), 'array'); $task = $this->getTask(); $context = 'com_menus.edit.item'; // Set the menutype should we need it. if ($data['menutype'] !== '') { $app->input->set('menutype', $data['menutype']); } // Determine the name of the primary key for the data. if (empty($key)) { $key = $table->getKeyName(); } // To avoid data collisions the urlVar may be different from the primary key. if (empty($urlVar)) { $urlVar = $key; } $recordId = $this->input->getInt($urlVar); // Populate the row id from the session. $data[$key] = $recordId; // The save2copy task needs to be handled slightly differently. if ($task == 'save2copy') { // Check-in the original row. if ($model->checkin($data['id']) === false) { // Check-in failed, go back to the item and display a notice. $this->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()), 'warning'); return false; } // Reset the ID and then treat the request as for Apply. $data['id'] = 0; $data['associations'] = array(); $task = 'apply'; } // Access check. if (!$this->allowSave($data, $key)) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED')); $this->setMessage($this->getError(), 'error'); $this->setRedirect( JRoute::_( 'index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false ) ); return false; } // Validate the posted data. // This post is made up of two forms, one for the item and one for params. $form = $model->getForm($data); if (!$form) { JError::raiseError(500, $model->getError()); return false; } if ($data['type'] == 'url') { $data['link'] = str_replace(array('"', '>', '<'), '', $data['link']); if (strstr($data['link'], ':')) { $segments = explode(':', $data['link']); $protocol = strtolower($segments[0]); $scheme = array( 'http', 'https', 'ftp', 'ftps', 'gopher', 'mailto', 'news', 'prospero', 'telnet', 'rlogin', 'tn3270', 'wais', 'mid', 'cid', 'nntp', 'tel', 'urn', 'ldap', 'file', 'fax', 'modem', 'git', 'sms', ); if (!in_array($protocol, $scheme)) { $app->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED'), 'warning'); $this->setRedirect( JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId), false) ); return false; } } } $data = $model->validate($form, $data); // Preprocess request fields to ensure that we remove not set or empty request params $request = $form->getGroup('request', true); // Check for the special 'request' entry. if ($data['type'] == 'component' && !empty($request)) { $removeArgs = array(); if (!isset($data['request']) || !is_array($data['request'])) { $data['request'] = array(); } foreach ($request as $field) { $fieldName = $field->getAttribute('name'); if (!isset($data['request'][$fieldName]) || $data['request'][$fieldName] == '') { $removeArgs[$fieldName] = ''; } } // Parse the submitted link arguments. $args = array(); parse_str(parse_url($data['link'], PHP_URL_QUERY), $args); // Merge in the user supplied request arguments. $args = array_merge($args, $data['request']); // Remove the unused request params if (!empty($args) && !empty($removeArgs)) { $args = array_diff_key($args, $removeArgs); } $data['link'] = 'index.php?' . urldecode(http_build_query($args, '', '&')); unset($data['request']); } // Check for validation errors. if ($data === false) { // Get the validation messages. $errors = $model->getErrors(); // Push up to three validation messages out to the user. for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { if ($errors[$i] instanceof Exception) { $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); } else { $app->enqueueMessage($errors[$i], 'warning'); } } // Save the data in the session. $app->setUserState('com_menus.edit.item.data', $data); // Redirect back to the edit screen. $editUrl = 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId); $this->setRedirect(JRoute::_($editUrl, false)); return false; } // Attempt to save the data. if (!$model->save($data)) { // Save the data in the session. $app->setUserState('com_menus.edit.item.data', $data); // Redirect back to the edit screen. $editUrl = 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId); $this->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError()), 'error'); $this->setRedirect(JRoute::_($editUrl, false)); return false; } // Save succeeded, check-in the row. if ($model->checkin($data['id']) === false) { // Check-in failed, go back to the row and display a notice. $this->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()), 'warning'); $redirectUrl = 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId); $this->setRedirect(JRoute::_($redirectUrl, false)); return false; } $this->setMessage(JText::_('COM_MENUS_SAVE_SUCCESS')); // Redirect the user and adjust session state based on the chosen task. switch ($task) { case 'apply': // Set the row data in the session. $recordId = $model->getState($this->context . '.id'); $this->holdEditId($context, $recordId); $app->setUserState('com_menus.edit.item.data', null); $app->setUserState('com_menus.edit.item.type', null); $app->setUserState('com_menus.edit.item.link', null); // Redirect back to the edit screen. $editUrl = 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId); $this->setRedirect(JRoute::_($editUrl, false)); break; case 'save2new': // Clear the row id and data in the session. $this->releaseEditId($context, $recordId); $app->setUserState('com_menus.edit.item.data', null); $app->setUserState('com_menus.edit.item.type', null); $app->setUserState('com_menus.edit.item.link', null); // Redirect back to the edit screen. $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend(), false)); break; default: // Clear the row id and data in the session. $this->releaseEditId($context, $recordId); $app->setUserState('com_menus.edit.item.data', null); $app->setUserState('com_menus.edit.item.type', null); $app->setUserState('com_menus.edit.item.link', null); // Redirect to the list screen. $this->setRedirect( JRoute::_( 'index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend() . '&menutype=' . $app->getUserState('com_menus.items.menutype'), false ) ); break; } return true; } /** * Sets the type of the menu item currently being edited. * * @return void * * @since 1.6 */ public function setType() { $this->checkToken(); $app = JFactory::getApplication(); // Get the posted values from the request. $data = $this->input->post->get('jform', array(), 'array'); // Get the type. $type = $data['type']; $type = json_decode(base64_decode($type)); $title = isset($type->title) ? $type->title : null; $recordId = isset($type->id) ? $type->id : 0; $specialTypes = array('alias', 'separator', 'url', 'heading', 'container'); if (!in_array($title, $specialTypes)) { $title = 'component'; } else { // Set correct component id to ensure proper 404 messages with system links $data['component_id'] = 0; } $app->setUserState('com_menus.edit.item.type', $title); if ($title == 'component') { if (isset($type->request)) { // Clean component name $type->request->option = JFilterInput::getInstance()->clean($type->request->option, 'CMD'); $component = JComponentHelper::getComponent($type->request->option); $data['component_id'] = $component->id; $app->setUserState('com_menus.edit.item.link', 'index.php?' . JUri::buildQuery((array) $type->request)); } } // If the type is alias you just need the item id from the menu item referenced. elseif ($title == 'alias') { $app->setUserState('com_menus.edit.item.link', 'index.php?Itemid='); } unset($data['request']); $data['type'] = $title; if ($this->input->get('fieldtype') == 'type') { $data['link'] = $app->getUserState('com_menus.edit.item.link'); } // Save the data in the session. $app->setUserState('com_menus.edit.item.data', $data); $this->type = $type; $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId), false)); } /** * Gets the parent items of the menu location currently. * * @return void * * @since 3.2 */ public function getParentItem() { $app = JFactory::getApplication(); $results = array(); $menutype = $this->input->get->get('menutype'); if ($menutype) { $model = $this->getModel('Items', '', array()); $model->getState(); $model->setState('filter.menutype', $menutype); $model->setState('list.select', 'a.id, a.title, a.level'); $model->setState('list.start', '0'); $model->setState('list.limit', '0'); /** @var MenusModelItems $model */ $results = $model->getItems(); // Pad the option text with spaces using depth level as a multiplier. for ($i = 0, $n = count($results); $i < $n; $i++) { $results[$i]->title = str_repeat(' - ', $results[$i]->level) . $results[$i]->title; } } // Output a JSON object echo json_encode($results); $app->close(); } } PK �|!]�z' ' config.xmlnu &1i� <?xml version="1.0" encoding="utf-8"?> <config> <fieldset name="page-options" label="COM_MENUS_PAGE_OPTIONS_LABEL" > <field name="page_title" type="text" label="COM_MENUS_ITEM_FIELD_PAGE_TITLE_LABEL" description="COM_MENUS_ITEM_FIELD_PAGE_TITLE_DESC" default="" /> <field name="show_page_heading" type="radio" label="COM_MENUS_ITEM_FIELD_SHOW_PAGE_HEADING_LABEL" description="COM_MENUS_ITEM_FIELD_SHOW_PAGE_HEADING_DESC" class="btn-group btn-group-yesno" default="0" filter="integer" > <option value="1">JYES</option> <option value="0">JNO</option> </field> <field name="page_heading" type="text" label="COM_MENUS_ITEM_FIELD_PAGE_HEADING_LABEL" description="COM_MENUS_ITEM_FIELD_PAGE_HEADING_DESC" default="" showon="show_page_heading:1" /> <field name="pageclass_sfx" type="text" label="COM_MENUS_ITEM_FIELD_PAGE_CLASS_LABEL" description="COM_MENUS_ITEM_FIELD_PAGE_CLASS_DESC" default="" /> </fieldset> <fieldset name="permissions" label="JCONFIG_PERMISSIONS_LABEL" description="JCONFIG_PERMISSIONS_DESC" > <field name="rules" type="rules" label="JCONFIG_PERMISSIONS_LABEL" filter="rules" validate="rules" component="com_menus" section="component" /> </fieldset> </config> PK �|!]�Yײ� � menus.xmlnu &1i� <?xml version="1.0" encoding="utf-8"?> <extension type="component" version="3.1" method="upgrade"> <name>com_menus</name> <author>Joomla! Project</author> <creationDate>April 2006</creationDate> <copyright>(C) 2006 Open Source Matters, Inc.</copyright> <license>GNU General Public License version 2 or later; see LICENSE.txt</license> <authorEmail>admin@joomla.org</authorEmail> <authorUrl>www.joomla.org</authorUrl> <version>3.0.0</version> <description>COM_MENUS_XML_DESCRIPTION</description> <administration> <files folder="admin"> <filename>config.xml</filename> <filename>controller.php</filename> <filename>menus.php</filename> <folder>controllers</folder> <folder>helpers</folder> <folder>models</folder> <folder>views</folder> <folder>presets</folder> </files> <languages folder="admin"> <language tag="en-GB">language/en-GB.com_menus.ini</language> <language tag="en-GB">language/en-GB.com_menus.sys.ini</language> </languages> </administration> </extension> PK �|!]4P��H H access.xmlnu &1i� <?xml version="1.0" encoding="utf-8" ?> <access component="com_menus"> <section name="component"> <action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" /> <action name="core.options" title="JACTION_OPTIONS" description="JACTION_OPTIONS_COMPONENT_DESC" /> <action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" /> <action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" /> <action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" /> <action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" /> <action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" /> </section> <section name="menu"> <action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" /> <action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" /> <action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" /> <action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" /> <action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" /> </section> </access> PK �|!]��ǹ � helpers/associations.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_menus * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Association\AssociationExtensionHelper; /** * Menu associations helper. * * @since 3.7.0 */ class MenusAssociationsHelper extends AssociationExtensionHelper { /** * The extension name * * @var array $extension * * @since 3.7.0 */ protected $extension = 'com_menus'; /** * Array of item types * * @var array $itemTypes * * @since 3.7.0 */ protected $itemTypes = array('item'); /** * Has the extension association support * * @var boolean $associationsSupport * * @since 3.7.0 */ protected $associationsSupport = true; /** * Get the associated items for an item * * @param string $typeName The item type * @param int $id The id of item for which we need the associated items * * @return array * * @since 3.7.0 */ public function getAssociations($typeName, $id) { $type = $this->getType($typeName); $context = $this->extension . '.item'; // Get the associations. $associations = JLanguageAssociations::getAssociations( $this->extension, $type['tables']['a'], $context, $id, 'id', 'alias', '' ); return $associations; } /** * Get item information * * @param string $typeName The item type * @param int $id The id of item for which we need the associated items * * @return JTable|null * * @since 3.7.0 */ public function getItem($typeName, $id) { if (empty($id)) { return null; } $table = null; switch ($typeName) { case 'item': $table = JTable::getInstance('menu'); break; } if (is_null($table)) { return null; } $table->load($id); return $table; } /** * Get information about the type * * @param string $typeName The item type * * @return array Array of item types * * @since 3.7.0 */ public function getType($typeName = '') { $fields = $this->getFieldsTemplate(); $tables = array(); $joins = array(); $support = $this->getSupportTemplate(); $title = ''; if (in_array($typeName, $this->itemTypes)) { switch ($typeName) { case 'item': $fields['ordering'] = 'a.lft'; $fields['level'] = 'a.level'; $fields['catid'] = ''; $fields['state'] = 'a.published'; $fields['created_user_id'] = ''; $fields['menutype'] = 'a.menutype'; $support['state'] = true; $support['acl'] = true; $support['checkout'] = true; $support['level'] = true; $tables = array( 'a' => '#__menu' ); $title = 'menu'; break; } } return array( 'fields' => $fields, 'support' => $support, 'tables' => $tables, 'joins' => $joins, 'title' => $title ); } } PK �|!]�����6 �6 helpers/menus.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_menus * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ use Joomla\CMS\Menu\MenuHelper; use Joomla\Registry\Registry; use Joomla\Utilities\ArrayHelper; defined('_JEXEC') or die; /** * Menus component helper. * * @since 1.6 */ class MenusHelper { /** * Defines the valid request variables for the reverse lookup. * * @since 1.6 */ protected static $_filter = array('option', 'view', 'layout'); /** * Configure the Linkbar. * * @param string $vName The name of the active view. * * @return void * * @since 1.6 */ public static function addSubmenu($vName) { JHtmlSidebar::addEntry( JText::_('COM_MENUS_SUBMENU_MENUS'), 'index.php?option=com_menus&view=menus', $vName == 'menus' ); JHtmlSidebar::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 integer $parentId The menu ID. * * @return JObject * * @since 1.6 * @deprecated 3.2 Use JHelperContent::getActions() instead */ public static function getActions($parentId = 0) { // Log usage of deprecated function try { JLog::add( sprintf('%s() is deprecated. Use JHelperContent::getActions() with new arguments order instead.', __METHOD__), JLog::WARNING, 'deprecated' ); } catch (RuntimeException $exception) { // Informational log only } // Get list of actions return JHelperContent::getActions('com_menus'); } /** * Gets a standard form of a link for lookups. * * @param mixed $request 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. * * @since 1.6 */ 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 * * @param int $clientId Optional client id - viz 0 = site, 1 = administrator, can be NULL for all * * @return array The menu array list * * @since 1.6 */ public static function getMenuTypes($clientId = 0) { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('a.menutype') ->from('#__menu_types AS a'); if (isset($clientId)) { $query->where('a.client_id = ' . (int) $clientId); } $db->setQuery($query); return $db->loadColumn(); } /** * Get a list of menu links for one or all menus. * * @param string $menuType An option menu to filter the list on, otherwise all menu with given client id links * are returned as a grouped array. * @param integer $parentId An optional parent ID to pivot results around. * @param integer $mode An optional mode. If parent ID is set and mode=2, the parent and children are excluded from the list. * @param array $published An optional array of states * @param array $languages Optional array of specify which languages we want to filter * @param int $clientId Optional client id - viz 0 = site, 1 = administrator, can be NULL for all (used only if menutype not givein) * * @return array * * @since 1.6 */ public static function getMenuLinks($menuType = null, $parentId = 0, $mode = 0, $published = array(), $languages = array(), $clientId = 0) { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('DISTINCT(a.id) AS value, a.title AS text, a.alias, a.level, a.menutype, a.client_id, a.type, a.published, a.template_style_id, a.checked_out, a.language, a.lft' ) ->from('#__menu AS a'); $query->select('e.name as componentname, e.element') ->join('left', '#__extensions e ON e.extension_id = a.component_id'); if (JLanguageMultilang::isEnabled()) { $query->select('l.title AS language_title, l.image AS language_image, l.sef AS language_sef') ->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language'); } // Filter by the type if given, this is more specific than client id if ($menuType) { $query->where('(a.menutype = ' . $db->quote($menuType) . ' OR a.parent_id = 0)'); } elseif (isset($clientId)) { $query->where('a.client_id = ' . (int) $clientId); } // Prevent the parent and children from showing if requested. if ($parentId && $mode == 2) { $query->join('LEFT', '#__menu AS p ON p.id = ' . (int) $parentId) ->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->order('a.lft ASC'); // Get the options. $db->setQuery($query); try { $links = $db->loadObjectList(); } catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage()); return false; } if (empty($menuType)) { // If the menutype is empty, group the items by menutype. $query->clear() ->select('*') ->from('#__menu_types') ->where('menutype <> ' . $db->quote('')) ->order('title, menutype'); if (isset($clientId)) { $query->where('client_id = ' . (int) $clientId); } $db->setQuery($query); try { $menuTypes = $db->loadObjectList(); } catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage()); 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; } } /** * Get the associations * * @param integer $pk Menu item id * * @return array * * @since 3.0 */ public static function getAssociations($pk) { $langAssociations = JLanguageAssociations::getAssociations('com_menus', '#__menu', 'com_menus.item', $pk, 'id', '', ''); $associations = array(); foreach ($langAssociations as $langAssociation) { $associations[$langAssociation->language] = $langAssociation->id; } return $associations; } /** * Load the menu items from database for the given menutype * * @param string $menutype The selected menu type * @param boolean $enabledOnly Whether to load only enabled/published menu items. * @param int[] $exclude The menu items to exclude from the list * * @return array * * @since 3.8.0 * * @deprecated 4.0 This method will return a node object to iterate over in 4.0. */ public static function getMenuItems($menutype, $enabledOnly = false, $exclude = array()) { $db = JFactory::getDbo(); $query = $db->getQuery(true); // Prepare the query. $query->select('m.*') ->from('#__menu AS m') ->where('m.menutype = ' . $db->q($menutype)) ->where('m.client_id = 1') ->where('m.id > 1'); if ($enabledOnly) { $query->where('m.published = 1'); } // Filter on the enabled states. $query->select('e.element') ->join('LEFT', '#__extensions AS e ON m.component_id = e.extension_id') ->where('(e.enabled = 1 OR e.enabled IS NULL)'); if (count($exclude)) { $exId = array_filter($exclude, 'is_numeric'); $exEl = array_filter($exclude, 'is_string'); if ($exId) { $query->where('m.id NOT IN (' . implode(', ', array_map('intval', $exId)) . ')'); $query->where('m.parent_id NOT IN (' . implode(', ', array_map('intval', $exId)) . ')'); } if ($exEl) { $query->where('e.element NOT IN (' . implode(', ', $db->quote($exEl)) . ')'); } } // Order by lft. $query->order('m.lft'); $db->setQuery($query); try { $menuItems = $db->loadObjectList(); foreach ($menuItems as &$menuitem) { $menuitem->params = new Registry($menuitem->params); } } catch (RuntimeException $e) { $menuItems = array(); JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error'); } return $menuItems; } /** * Method to install a preset menu into database and link them to the given menutype * * @param string $preset The preset name * @param string $menutype The target menutype * * @return void * * @throws Exception * * @since 3.8.0 */ public static function installPreset($preset, $menutype) { $items = MenuHelper::loadPreset($preset, false); if (count($items) == 0) { throw new Exception(JText::_('COM_MENUS_PRESET_LOAD_FAILED')); } static::installPresetItems($items, $menutype, 1); } /** * Method to install a preset menu item into database and link it to the given menutype * * @param stdClass[] $items The single menuitem instance with a list of its descendants * @param string $menutype The target menutype * @param int $parent The parent id or object * * @return void * * @throws Exception * * @since 3.8.0 */ protected static function installPresetItems(&$items, $menutype, $parent = 1) { $db = JFactory::getDbo(); $query = $db->getQuery(true); static $components = array(); if (!$components) { $query->select('extension_id, element')->from('#__extensions')->where('type = ' . $db->q('component')); $components = $db->setQuery($query)->loadObjectList(); $components = ArrayHelper::getColumn((array) $components, 'element', 'extension_id'); } $dispatcher = JEventDispatcher::getInstance(); $dispatcher->trigger('onPreprocessMenuItems', array('com_menus.administrator.import', &$items, null, true)); foreach ($items as &$item) { /** @var JTableMenu $table */ $table = JTable::getInstance('Menu'); $item->alias = $menutype . '-' . $item->title; if ($item->type == 'separator') { // Do not reuse a separator $item->title = $item->title ?: '-'; $item->alias = microtime(true); } elseif ($item->type == 'heading' || $item->type == 'container') { // Try to match an existing record to have minimum collision for a heading $keys = array( 'menutype' => $menutype, 'type' => $item->type, 'title' => $item->title, 'parent_id' => $parent, 'client_id' => 1, ); $table->load($keys); } elseif ($item->type == 'url' || $item->type == 'component') { if (substr($item->link, 0, 8) === 'special:') { $special = substr($item->link, 8); if ($special === 'language-forum') { $item->link = 'index.php?option=com_admin&view=help&layout=langforum'; } elseif ($special === 'custom-forum') { $item->link = ''; } } // Try to match an existing record to have minimum collision for a link $keys = array( 'menutype' => $menutype, 'type' => $item->type, 'link' => $item->link, 'parent_id' => $parent, 'client_id' => 1, ); $table->load($keys); } // Translate "hideitems" param value from "element" into "menu-item-id" if ($item->type == 'container' && count($hideitems = (array) $item->params->get('hideitems'))) { foreach ($hideitems as &$hel) { if (!is_numeric($hel)) { $hel = array_search($hel, $components); } } $query->clear()->select('id')->from('#__menu')->where('component_id IN (' . implode(', ', $hideitems) . ')'); $hideitems = $db->setQuery($query)->loadColumn(); $item->params->set('hideitems', $hideitems); } $record = array( 'menutype' => $menutype, 'title' => $item->title, 'alias' => $item->alias, 'type' => $item->type, 'link' => $item->link, 'browserNav' => $item->browserNav ? 1 : 0, 'img' => $item->class, 'access' => $item->access, 'component_id' => array_search($item->element, $components), 'parent_id' => $parent, 'client_id' => 1, 'published' => 1, 'language' => '*', 'home' => 0, 'params' => (string) $item->params, ); if (!$table->bind($record)) { throw new Exception('Bind failed: ' . $table->getError()); } $table->setLocation($parent, 'last-child'); if (!$table->check()) { throw new Exception('Check failed: ' . $table->getError()); } if (!$table->store()) { throw new Exception('Saved failed: ' . $table->getError()); } $item->id = $table->get('id'); if (!empty($item->submenu)) { static::installPresetItems($item->submenu, $menutype, $item->id); } } } } PK �|!]l22� � helpers/html/menus.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_menus * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\Registry\Registry; JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php'); /** * Menus HTML helper class. * * @package Joomla.Administrator * @subpackage com_menus * @since 1.7 */ abstract class MenusHtmlMenus { /** * Generate the markup to display the item associations * * @param int $itemid The menu item id * * @return string * * @since 3.0 * * @throws Exception If there is an error on the query */ public static function association($itemid) { // Defaults $html = ''; // Get the associations if ($associations = MenusHelper::getAssociations($itemid)) { // Get the associated menu items $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('m.id, m.title') ->select('l.sef as lang_sef, l.lang_code') ->select('mt.title as menu_title') ->from('#__menu as m') ->join('LEFT', '#__menu_types as mt ON mt.menutype=m.menutype') ->where('m.id IN (' . implode(',', array_values($associations)) . ')') ->where('m.id != ' . $itemid) ->join('LEFT', '#__languages as l ON m.language=l.lang_code') ->select('l.image') ->select('l.title as language_title'); $db->setQuery($query); try { $items = $db->loadObjectList('id'); } catch (runtimeException $e) { throw new Exception($e->getMessage(), 500); } // Construct html if ($items) { foreach ($items as &$item) { $text = strtoupper($item->lang_sef); $url = JRoute::_('index.php?option=com_menus&task=item.edit&id=' . (int) $item->id); $tooltip = htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8') . '<br />' . JText::sprintf('COM_MENUS_MENU_SPRINTF', $item->menu_title); $classes = 'hasPopover label label-association label-' . $item->lang_sef; $item->link = '<a href="' . $url . '" title="' . $item->language_title . '" class="' . $classes . '" data-content="' . $tooltip . '" data-placement="top">' . $text . '</a>'; } } JHtml::_('bootstrap.popover'); $html = JLayoutHelper::render('joomla.content.associations', $items); } return $html; } /** * 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( 9 => array( 'unpublish', '', 'COM_MENUS_HTML_UNPUBLISH_HEADING', '', true, 'publish', 'publish', ), 8 => array( 'publish', '', 'COM_MENUS_HTML_PUBLISH_HEADING', '', true, 'unpublish', 'unpublish', ), 7 => array( 'unpublish', '', 'COM_MENUS_HTML_UNPUBLISH_SEPARATOR', '', true, 'publish', 'publish', ), 6 => array( 'publish', '', 'COM_MENUS_HTML_PUBLISH_SEPARATOR', '', true, 'unpublish', 'unpublish', ), 5 => array( 'unpublish', '', 'COM_MENUS_HTML_UNPUBLISH_ALIAS', '', true, 'publish', 'publish', ), 4 => array( 'publish', '', 'COM_MENUS_HTML_PUBLISH_ALIAS', '', true, 'unpublish', 'unpublish', ), 3 => array( 'unpublish', '', 'COM_MENUS_HTML_UNPUBLISH_URL', '', true, 'publish', 'publish', ), 2 => array( 'publish', '', 'COM_MENUS_HTML_PUBLISH_URL', '', true, '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, 'trash', 'trash', ), -3 => array( 'publish', '', 'COM_MENUS_HTML_PUBLISH', '', true, 'trash', 'trash', ), ); return JHtml::_('jgrid.state', $states, $value, $i, 'items.', $enabled, true, $checkbox); } /** * Returns a visibility state on a grid * * @param integer $params Params of item. * * @return string The Html code * * @since 3.7.0 */ public static function visibility($params) { $registry = new Registry; try { $registry->loadString($params); } catch (Exception $e) { // Invalid JSON } $show_menu = $registry->get('menu_show'); return ($show_menu === 0) ? '<span class="label">' . JText::_('COM_MENUS_LABEL_HIDDEN') . '</span>' : ''; } } PK �|!]�G�c� � views/menu/tmpl/edit.xmlnu &1i� <?xml version="1.0" encoding="utf-8"?> <metadata> <layout title="COM_MENUS_MENU_VIEW_EDIT_TITLE"> <message> <![CDATA[COM_MENUS_MENU_VIEW_EDIT_DESC]]> </message> </layout> </metadata> PK �|!]fp��r r views/menu/tmpl/edit.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_menus * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; // Include the component HTML helpers. JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); JHtml::_('behavior.core'); JHtml::_('behavior.formvalidator'); JHtml::_('formbehavior.chosen', 'select'); JText::script('ERROR'); JFactory::getDocument()->addScriptDeclaration(" Joomla.submitbutton = function(task) { var form = document.getElementById('item-form'); if (task == 'menu.cancel' || document.formvalidator.isValid(form)) { Joomla.submitform(task, form); } }; "); ?> <form action="<?php echo JRoute::_('index.php?option=com_menus&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="item-form"> <?php echo JLayoutHelper::render('joomla.edit.title_alias', $this); ?> <div class="form-horizontal"> <?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?> <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', JText::_('COM_MENUS_MENU_DETAILS')); ?> <?php echo $this->form->renderField('menutype'); echo $this->form->renderField('description'); echo $this->form->renderField('client_id'); echo $this->form->renderField('preset'); ?> <?php echo JHtml::_('bootstrap.endTab'); ?> <?php if ($this->canDo->get('core.admin')) : ?> <?php echo JHtml::_('bootstrap.addTab', 'myTab', 'permissions', JText::_('COM_MENUS_FIELDSET_RULES')); ?> <?php echo $this->form->getInput('rules'); ?> <?php echo JHtml::_('bootstrap.endTab'); ?> <?php endif; ?> <?php echo JHtml::_('bootstrap.endTabSet'); ?> <input type="hidden" name="task" value="" /> <?php echo JHtml::_('form.token'); ?> </div> </form> PK �|!]�� w w views/menu/view.html.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_menus * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * The HTML Menus Menu Item View. * * @since 1.6 */ class MenusViewMenu extends JViewLegacy { /** * @var JForm */ protected $form; /** * @var mixed */ protected $item; /** * @var JObject */ protected $state; /** * * @var JObject */ protected $canDo; /** * Display the view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void * * @since 1.6 */ public function display($tpl = null) { $this->form = $this->get('Form'); $this->item = $this->get('Item'); $this->state = $this->get('State'); $this->canDo = JHelperContent::getActions('com_menus', 'menu', $this->item->id); // Check for errors. if (count($errors = $this->get('Errors'))) { throw new Exception(implode("\n", $errors), 500); } parent::display($tpl); $this->addToolbar(); } /** * Add the page title and toolbar. * * @return void * * @since 1.6 */ protected function addToolbar() { $input = JFactory::getApplication()->input; $input->set('hidemainmenu', true); $isNew = ($this->item->id == 0); JToolbarHelper::title(JText::_($isNew ? 'COM_MENUS_VIEW_NEW_MENU_TITLE' : 'COM_MENUS_VIEW_EDIT_MENU_TITLE'), 'list menu'); // If a new item, can save the item. Allow users with edit permissions to apply changes to prevent returning to grid. if ($isNew && $this->canDo->get('core.create')) { if ($this->canDo->get('core.edit')) { JToolbarHelper::apply('menu.apply'); } JToolbarHelper::save('menu.save'); } // If user can edit, can save the item. if (!$isNew && $this->canDo->get('core.edit')) { JToolbarHelper::apply('menu.apply'); JToolbarHelper::save('menu.save'); } // If the user can create new items, allow them to see Save & New if ($this->canDo->get('core.create')) { JToolbarHelper::save2new('menu.save2new'); } if ($isNew) { JToolbarHelper::cancel('menu.cancel'); } else { JToolbarHelper::cancel('menu.cancel', 'JTOOLBAR_CLOSE'); } JToolbarHelper::divider(); JToolbarHelper::help('JHELP_MENUS_MENU_MANAGER_EDIT'); } } PK �|!]8� � views/menu/view.xml.phpnu &1i� <?php /** * @package Joomla.Administrator * @subpackage com_menus * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Menu\MenuHelper; /** * The HTML Menus Menu Item View. * * @since 3.8.0 */ class MenusViewMenu extends JViewLegacy { /** * @var stdClass[] * * @since 3.8.0 */ protected $items; /** * @var JObject * * @since 3.8.0 */ protected $state; /** * Display the view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void * * @since 3.8.0 */ public function display($tpl = null) { $app = JFactory::getApplication(); $menutype = $app->input->getCmd('menutype'); if ($menutype) { $items = MenusHelper::getMenuItems($menutype, true); } if (empty($items)) { JLog::add(JText::_('COM_MENUS_SELECT_MENU_FIRST_EXPORT'), JLog::WARNING, 'jerror'); $app->redirect(JRoute::_('index.php?option=com_menus&view=menus', false)); return; } $this->items = MenuHelper::createLevels($items); $xml = new SimpleXMLElement('<menu ' . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xmlns="urn:joomla.org" xsi:schemaLocation="urn:joomla.org menu.xsd"' . '></menu>' ); foreach ($this->items as $item) { $this->addXmlChild($xml, $item); } if (headers_sent($file, $line)) { JLog::add("Headers already sent at $file:$line.", JLog::ERROR, 'jerror'); return; } header('content-type: application/xml'); header('content-disposition: attachment; filename="' . $menutype . '.xml"'); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header('Pragma: private'); $dom = new DOMDocument; $dom->preserveWhiteSpace = true; $dom->formatOutput = true; $dom->loadXML($xml->asXML()); echo $dom->saveXML(); $app->close(); } /** * Add a child node to the xml * * @param SimpleXMLElement $xml The current XML node which would become the parent to the new node * @param stdClass $item The menuitem object to create the child XML node from * * @return void * * @since 3.8.0 */ protected function addXmlChild($xml, $item) { $node = $xml->addChild('menuitem'); $node['type'] = $item->type; if ($item->title) { $node['title'] = $item->title; } if ($item->link) { $node['link'] = $item->link; } if ($item->element) { $node['element'] = $item->element; } if ($item->class) { $node['class'] = $item->class; } if ($item->access) { $node['access'] = $item->access; } if ($item->browserNav) { $node['target'] = '_blank'; } if (count($item->params)) { $hideitems = $item->params->get('hideitems'); if (count($hideitems)) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('e.element')->from('#__extensions e') ->join('inner', '#__menu m ON m.component_id = e.extension_id') ->where('m.id IN (' . implode(', ', $db->quote($hideitems)) . ')'); $hideitems = $db->setQuery($query)->loadColumn(); $item->params->set('hideitems', $hideitems); } $node->addChild('params', (string) $item->params); } foreach ($item->submenu as $sub) { $this->addXmlChild($node, $sub); } } } PK �|!]�%�0 0 '