Your IP : 216.73.216.248


Current Path : /home/digilove/www/41423/
Upload File :
Current File : /home/digilove/www/41423/com_menus.tar

js/admin-items-modal.js000064400000004671152344345070011036 0ustar00/**
 * @copyright  (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */
(function() {
	"use strict";
	/**
	 * Javascript to insert the link
	 * View element calls jSelectContact when a contact is clicked
	 * jSelectContact creates the link tag, sends it to the editor,
	 * and closes the select frame.
	 */

	window.jSelectMenuItem = function(id, title, uri, object, link, lang)
	{
		var thislang = '', tag, editor;

		if (!Joomla.getOptions('xtd-menus')) {
			// Something went wrong!
			window.parent.jModalClose();
			return false;
		}

		editor = Joomla.getOptions('xtd-menus').editor;

		if (lang !== '')
		{
			thislang = '&lang=';
		}

		tag = '<a href=\"' + uri + thislang + lang + '">' + title + '</a>';

		/** Use the API, if editor supports it **/
		if (window.parent.Joomla && window.parent.Joomla.editors && window.parent.Joomla.editors.instances && window.parent.Joomla.editors.instances.hasOwnProperty(editor)) {
			if (typeof window.parent.Joomla.editors.instances[editor]['getSelection'] !== 'undefined' && window.parent.Joomla.editors.instances[editor].getSelection()) {
				window.parent.Joomla.editors.instances[editor].replaceSelection('<a href=\"' + uri + thislang + lang + '">' + window.parent.Joomla.editors.instances[editor].getSelection() + '</a>');
			} else {
				window.parent.Joomla.editors.instances[editor].replaceSelection(tag)
			}
		} else {
			window.parent.jInsertEditorText(tag, editor);
		}

		window.parent.jModalClose();
	};

	document.addEventListener('DOMContentLoaded', function(){
		// Get the elements
		var elements = document.querySelectorAll('.select-link');

		for(var i = 0, l = elements.length; l>i; i++) {
			// Listen for click event
			elements[i].addEventListener('click', function (event) {
				event.preventDefault();
				var functionName = event.target.getAttribute('data-function');

				if (functionName === 'jSelectMenuItem') {
					// Used in xtd_contacts
					window[functionName](event.target.getAttribute('data-id'), event.target.getAttribute('data-title'), event.target.getAttribute('data-uri'), null, null, event.target.getAttribute('data-language'));
				} else {
					// Used in com_menus
					window.parent[functionName](event.target.getAttribute('data-id'), event.target.getAttribute('data-title'), null, null, event.target.getAttribute('data-uri'), event.target.getAttribute('data-language'), null);
				}
			})
		}
	});
})();
js/admin-items-modal.min.js000064400000002572152344345070011616 0ustar00!function(){"use strict";window.jSelectMenuItem=function(t,e,n,a,o,i){var r,d,l="";if(!Joomla.getOptions("xtd-menus"))return window.parent.jModalClose(),!1;d=Joomla.getOptions("xtd-menus").editor,""!==i&&(l="&lang="),r='<a href="'+n+l+i+'">'+e+"</a>",window.parent.Joomla&&window.parent.Joomla.editors&&window.parent.Joomla.editors.instances&&window.parent.Joomla.editors.instances.hasOwnProperty(d)?void 0!==window.parent.Joomla.editors.instances[d].getSelection&&window.parent.Joomla.editors.instances[d].getSelection()?window.parent.Joomla.editors.instances[d].replaceSelection('<a href="'+n+l+i+'">'+window.parent.Joomla.editors.instances[d].getSelection()+"</a>"):window.parent.Joomla.editors.instances[d].replaceSelection(r):window.parent.jInsertEditorText(r,d),window.parent.jModalClose()},document.addEventListener("DOMContentLoaded",function(){for(var t=document.querySelectorAll(".select-link"),e=0,n=t.length;e<n;e++)t[e].addEventListener("click",function(t){t.preventDefault();var e=t.target.getAttribute("data-function");"jSelectMenuItem"===e?window[e](t.target.getAttribute("data-id"),t.target.getAttribute("data-title"),t.target.getAttribute("data-uri"),null,null,t.target.getAttribute("data-language")):window.parent[e](t.target.getAttribute("data-id"),t.target.getAttribute("data-title"),null,null,t.target.getAttribute("data-uri"),t.target.getAttribute("data-language"),null)})})}();
models/forms/filter_items.xml000064400000007157152344362320012403 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<fieldset addfieldpath="/administrator/components/com_menus/models/fields" />
		<field
			name="menutype"
			type="menu"
			label="COM_MENUS_SELECT_MENU_FILTER"
			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"
			/>
			<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"
				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>
controller.php000064400000002124152344362320007443 0ustar00<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_menus
 *
 * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

/**
 * Menus manager master display controller.
 *
 * @since  3.7.0
 */
class MenusController extends JControllerLegacy
{
	/**
	 * Constructor.
	 *
	 * @param   array  $config  An optional associative array of configuration settings.
	 *                          Recognized key values include 'name', 'default_task', 'model_path', and
	 *                          'view_path' (this list is not meant to be comprehensive).
	 *
	 * @since   3.7.0
	 */
	public function __construct($config = array())
	{
		$this->input = JFactory::getApplication()->input;

		// Menus frontpage Editor Menu proxying:
		if ($this->input->get('view') === 'items' && $this->input->get('layout') === 'modal')
		{
			JHtml::_('stylesheet', 'system/adminlist.css', array(), true);
			$config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
		}

		parent::__construct($config);
	}
}
menus.php000064400000001455152344362320006415 0ustar00<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_menus
 *
 * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

// Load the required admin language files
$lang   = JFactory::getLanguage();
$app    = JFactory::getApplication();

if ($app->input->get('view') === 'items' && $app->input->get('layout') === 'modal')
{
	if (!JFactory::getUser()->authorise('core.create', 'com_menus'))
	{
		$app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'warning');

		return;
	}
}

$lang->load('com_menus', JPATH_ADMINISTRATOR);

// Trigger the controller
$controller = JControllerLegacy::getInstance('Menus');
$controller->execute($app->input->get('task'));
$controller->redirect();
controllers/ajax.json.php000064400000004544152346104050011525 0ustar00<?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);
		}
	}
}
controllers/index.html000064400000000037152346104050011107 0ustar00<!DOCTYPE html><title></title>
controllers/item.php000064400000037657152346104050010603 0ustar00<?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();
	}
}
controllers/items.php000064400000015571152346104050010755 0ustar00<?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;
		}
	}
}
controllers/menu.php000064400000014413152346104050010572 0ustar00<?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;
	}
}
controllers/menus.php000064400000011710152346104050010752 0ustar00<?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());
					}
				}
			}
		}
	}
}
helpers/html/index.html000064400000000037152346104050011147 0ustar00<!DOCTYPE html><title></title>
helpers/html/menus.php000064400000012676152346104050011026 0ustar00<?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>' : '';
	}
}
helpers/associations.php000064400000005671152346104050011427 0ustar00<?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
		);
	}
}
helpers/index.html000064400000000037152346104050010203 0ustar00<!DOCTYPE html><title></title>
helpers/menus.php000064400000033303152346104050010050 0ustar00<?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&amp;view=help&amp;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);
			}
		}
	}
}
layouts/joomla/menu/edit_modules.php000064400000002741152346104050013663 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  Layout
 *
 * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

$app       = JFactory::getApplication();
$form      = $displayData->getForm();
$input     = $app->input;
$component = $input->getCmd('option', 'com_content');

if ($component == 'com_categories')
{
	$extension = $input->getCmd('extension', 'com_content');
	$parts     = explode('.', $extension);
	$component = $parts[0];
}

$saveHistory = JComponentHelper::getParams($component)->get('save_history', 0);

$fields = $displayData->get('fields') ?: array(
	array('parent', 'parent_id'),
	array('published', 'state', 'enabled'),
	array('category', 'catid'),
	'featured',
	'sticky',
	'access',
	'language',
	'tags',
	'note',
	'version_note',
);

$hiddenFields = $displayData->get('hidden_fields') ?: array();

if (!$saveHistory)
{
	$hiddenFields[] = 'version_note';
}

$html   = array();
$html[] = '<fieldset class="form-horizontal"><ul class="horizontal-buttons unstyled">';

foreach ($fields as $field)
{
	$field = is_array($field) ? $field : array($field);

	foreach ($field as $f)
	{
		if ($form->getField($f))
		{
			if (in_array($f, $hiddenFields))
			{
				$form->setFieldAttribute($f, 'type', 'hidden');
			}

			$html[] = '<li>' . $form->renderField($f) . '</li>';
			break;
		}
	}
}

$html[] = '</ul></fieldset>';

echo implode('', $html);
layouts/joomla/searchtools/default/bar.php000064400000002442152346104050014756 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  Layout
 *
 * @copyright   (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

/** @var  array  $displayData */
$data = $displayData;

if ($data['view'] instanceof MenusViewItems)
{
	// We will get the menutype filter & remove it from the form filters
	$menuTypeField = $data['view']->filterForm->getField('menutype');

	// Add the client selector before the form filters.
	$clientIdField = $data['view']->filterForm->getField('client_id');

	if ($clientIdField): ?>
	<div class="js-stools-field-filter js-stools-client_id">
		<?php echo $clientIdField->input; ?>
	</div>
	<?php endif; ?>

	<div class="js-stools-field-filter js-stools-menutype">
		<?php echo $menuTypeField->input; ?>
	</div>
	<?php
}
elseif ($data['view'] instanceof MenusViewMenus)
{
	// Add the client selector before the form filters.
	$clientIdField = $data['view']->filterForm->getField('client_id');
	?>
	<div class="js-stools-field-filter js-stools-client_id">
		<?php echo $clientIdField->input; ?>
	</div>
	<?php
}

// Display the main joomla layout
echo JLayoutHelper::render('joomla.searchtools.default.bar', $data, null, array('component' => 'none'));
layouts/joomla/searchtools/default.php000064400000005761152346104050014221 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  Layout
 *
 * @copyright   (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

/** @var  array  $displayData */
$data = $displayData;

// Receive overridable options
$data['options'] = !empty($data['options']) ? $data['options'] : array();

if ($data['view'] instanceof MenusViewItems || $data['view'] instanceof MenusViewMenus)
{
	$doc = JFactory::getDocument();

	$doc->addStyleDeclaration("
		/* Fixed filter field in search bar */
		.js-stools .js-stools-menutype,
		.js-stools .js-stools-client_id {
			float: left;
			margin-right: 10px;
			min-width: 220px;
		}
		html[dir=rtl] .js-stools .js-stools-menutype,
		html[dir=rtl] .js-stools .js-stools-client_id {
			float: right;
			margin-left: 10px
			margin-right: 0;
		}
		.js-stools .js-stools-container-bar .js-stools-field-filter .chzn-container {
			padding: 3px 0;
		}
	");

	// Client selector doesn't have to activate the filter bar.
	unset($data['view']->activeFilters['client_id']);

	// Menutype filter doesn't have to activate the filter bar
	unset($data['view']->activeFilters['menutype']);
}

// Set some basic options
$customOptions = array(
	'filtersHidden'       => isset($data['options']['filtersHidden']) ? $data['options']['filtersHidden'] : empty($data['view']->activeFilters),
	'defaultLimit'        => isset($data['options']['defaultLimit']) ? $data['options']['defaultLimit'] : JFactory::getApplication()->get('list_limit', 20),
	'searchFieldSelector' => '#filter_search',
	'orderFieldSelector'  => '#list_fullordering',
	'totalResults'        => isset($data['options']['totalResults']) ? $data['options']['totalResults'] : -1,
	'noResultsText'       => isset($data['options']['noResultsText']) ? $data['options']['noResultsText'] : JText::_('JGLOBAL_NO_MATCHING_RESULTS'),
);

$data['options'] = array_merge($customOptions, $data['options']);

$formSelector = !empty($data['options']['formSelector']) ? $data['options']['formSelector'] : '#adminForm';

// Load search tools
JHtml::_('searchtools.form', $formSelector, $data['options']);

$filtersClass = isset($data['view']->activeFilters) && $data['view']->activeFilters ? ' js-stools-container-filters-visible' : '';
?>
<div class="js-stools clearfix">
	<div class="clearfix">
		<div class="js-stools-container-bar">
			<?php echo JLayoutHelper::render('joomla.searchtools.default.bar', $data); ?>
		</div>
		<div class="js-stools-container-list hidden-phone hidden-tablet">
			<?php echo JLayoutHelper::render('joomla.searchtools.default.list', $data); ?>
		</div>
	</div>
	<!-- Filters div -->
	<div class="js-stools-container-filters hidden-phone clearfix<?php echo $filtersClass; ?>">
		<?php echo JLayoutHelper::render('joomla.searchtools.default.filters', $data); ?>
	</div>
</div>
<?php if ($data['options']['totalResults'] === 0) : ?>
	<?php echo JLayoutHelper::render('joomla.searchtools.default.noitems', $data); ?>
<?php endif; ?>
models/fields/modal/menu.php000064400000031650152346104050012053 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_menus
 *
 * @copyright   (C) 2016 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;

JHtml::_('bootstrap.tooltip', '.hasTooltip');

/**
 * Supports a modal menu item picker.
 *
 * @since  3.7.0
 */
class JFormFieldModal_Menu extends JFormField
{
	/**
	 * The form field type.
	 *
	 * @var     string
	 * @since   3.7.0
	 */
	protected $type = 'Modal_Menu';

	/**
	 * Determinate, if the select button is shown
	 *
	 * @var     boolean
	 * @since   3.7.0
	 */
	protected $allowSelect = true;

	/**
	 * Determinate, if the clear button is shown
	 *
	 * @var     boolean
	 * @since   3.7.0
	 */
	protected $allowClear = true;

	/**
	 * Determinate, if the create button is shown
	 *
	 * @var     boolean
	 * @since   3.7.0
	 */
	protected $allowNew = false;

	/**
	 * Determinate, if the edit button is shown
	 *
	 * @var     boolean
	 * @since   3.7.0
	 */
	protected $allowEdit = false;

	/**
	 * Determinate, if the propagate button is shown
	 *
	 * @var     boolean
	 * @since   3.9.0
	 */
	protected $allowPropagate = false;

	/**
	 * Method to get certain otherwise inaccessible properties from the form field object.
	 *
	 * @param   string  $name  The property name for which to get the value.
	 *
	 * @return  mixed  The property value or null.
	 *
	 * @since   3.7.0
	 */
	public function __get($name)
	{
		switch ($name)
		{
			case 'allowSelect':
			case 'allowClear':
			case 'allowNew':
			case 'allowEdit':
			case 'allowPropagate':
				return $this->$name;
		}

		return parent::__get($name);
	}

	/**
	 * Method to set certain otherwise inaccessible properties of the form field object.
	 *
	 * @param   string  $name   The property name for which to set the value.
	 * @param   mixed   $value  The value of the property.
	 *
	 * @return  void
	 *
	 * @since   3.7.0
	 */
	public function __set($name, $value)
	{
		switch ($name)
		{
			case 'allowSelect':
			case 'allowClear':
			case 'allowNew':
			case 'allowEdit':
			case 'allowPropagate':
				$value = (string) $value;
				$this->$name = !($value === 'false' || $value === 'off' || $value === '0');
				break;

			default:
				parent::__set($name, $value);
		}
	}

	/**
	 * Method to attach a JForm object to the field.
	 *
	 * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the `<field>` tag for the form field object.
	 * @param   mixed             $value    The form field value to validate.
	 * @param   string            $group    The field name group control value. This acts as an array container for the field.
	 *                                      For example if the field has name="foo" and the group value is set to "bar" then the
	 *                                      full field name would end up being "bar[foo]".
	 *
	 * @return  boolean  True on success.
	 *
	 * @see     JFormField::setup()
	 * @since   3.7.0
	 */
	public function setup(SimpleXMLElement $element, $value, $group = null)
	{
		$return = parent::setup($element, $value, $group);

		if ($return)
		{
			$this->allowSelect = ((string) $this->element['select']) !== 'false';
			$this->allowClear = ((string) $this->element['clear']) !== 'false';
			$this->allowPropagate = ((string) $this->element['propagate']) === 'true';

			// Creating/editing menu items is not supported in frontend.
			$isAdministrator = JFactory::getApplication()->isClient('administrator');
			$this->allowNew = $isAdministrator ? ((string) $this->element['new']) === 'true' : false;
			$this->allowEdit = $isAdministrator ? ((string) $this->element['edit']) === 'true' : false;
		}

		return $return;
	}

	/**
	 * Method to get the field input markup.
	 *
	 * @return  string  The field input markup.
	 *
	 * @since   3.7.0
	 */
	protected function getInput()
	{
		$clientId    = (int) $this->element['clientid'];
		$languages   = LanguageHelper::getContentLanguages(array(0, 1));

		// Load language
		JFactory::getLanguage()->load('com_menus', JPATH_ADMINISTRATOR);

		// The active article id field.
		$value = (int) $this->value > 0 ? (int) $this->value : '';

		// Create the modal id.
		$modalId = 'Item_' . $this->id;

		// Add the modal field script to the document head.
		JHtml::_('jquery.framework');
		JHtml::_('script', 'system/modal-fields.js', array('version' => 'auto', 'relative' => true));

		// Script to proxy the select modal function to the modal-fields.js file.
		if ($this->allowSelect)
		{
			static $scriptSelect = null;

			if (is_null($scriptSelect))
			{
				$scriptSelect = array();
			}

			if (!isset($scriptSelect[$this->id]))
			{
				JFactory::getDocument()->addScriptDeclaration("
				function jSelectMenu_" . $this->id . "(id, title, object) {
					window.processModalSelect('Item', '" . $this->id . "', id, title, '', object);
				}
				"
				);

				JText::script('JGLOBAL_ASSOCIATIONS_PROPAGATE_FAILED');

				$scriptSelect[$this->id] = true;
			}
		}

		// Setup variables for display.
		$linkSuffix = '&amp;layout=modal&amp;client_id=' . $clientId . '&amp;tmpl=component&amp;' . JSession::getFormToken() . '=1';
		$linkItems  = 'index.php?option=com_menus&amp;view=items' . $linkSuffix;
		$linkItem   = 'index.php?option=com_menus&amp;view=item' . $linkSuffix;
		$modalTitle = JText::_('COM_MENUS_CHANGE_MENUITEM');

		if (isset($this->element['language']))
		{
			$linkItems  .= '&amp;forcedLanguage=' . $this->element['language'];
			$linkItem   .= '&amp;forcedLanguage=' . $this->element['language'];
			$modalTitle .= ' &#8212; ' . $this->element['label'];
		}

		$urlSelect = $linkItems . '&amp;function=jSelectMenu_' . $this->id;
		$urlEdit   = $linkItem . '&amp;task=item.edit&amp;id=\' + document.getElementById("' . $this->id . '_id").value + \'';
		$urlNew    = $linkItem . '&amp;task=item.add';

		if ($value)
		{
			$db    = JFactory::getDbo();
			$query = $db->getQuery(true)
				->select($db->quoteName('title'))
				->from($db->quoteName('#__menu'))
				->where($db->quoteName('id') . ' = ' . (int) $value);

			$db->setQuery($query);

			try
			{
				$title = $db->loadResult();
			}
			catch (RuntimeException $e)
			{
				JError::raiseWarning(500, $e->getMessage());
			}
		}

		// Placeholder if option is present or not
		if (empty($title))
		{
			if ($this->element->option && (string) $this->element->option['value'] == '')
			{
				$title_holder = JText::_($this->element->option);
			}
			else
			{
				$title_holder = JText::_('COM_MENUS_SELECT_A_MENUITEM');
			}
		}

		$title = empty($title) ? $title_holder : htmlspecialchars($title, ENT_QUOTES, 'UTF-8');

		// The current menu item display field.
		$html  = '<span class="input-append">';
		$html .= '<input class="input-medium" id="' . $this->id . '_name" type="text" value="' . $title . '" disabled="disabled" size="35" />';

		// Select menu item button
		if ($this->allowSelect)
		{
			$html .= '<button'
				. ' type="button"'
				. ' class="btn hasTooltip' . ($value ? ' hidden' : '') . '"'
				. ' id="' . $this->id . '_select"'
				. ' data-toggle="modal"'
				. ' data-target="#ModalSelect' . $modalId . '"'
				. ' title="' . JHtml::tooltipText('COM_MENUS_CHANGE_MENUITEM') . '">'
				. '<span class="icon-file" aria-hidden="true"></span> ' . JText::_('JSELECT')
				. '</button>';
		}

		// New menu item button
		if ($this->allowNew)
		{
			$html .= '<button'
				. ' type="button"'
				. ' class="btn hasTooltip' . ($value ? ' hidden' : '') . '"'
				. ' id="' . $this->id . '_new"'
				. ' data-toggle="modal"'
				. ' data-target="#ModalNew' . $modalId . '"'
				. ' title="' . JHtml::tooltipText('COM_MENUS_NEW_MENUITEM') . '">'
				. '<span class="icon-new" aria-hidden="true"></span> ' . JText::_('JACTION_CREATE')
				. '</button>';
		}

		// Edit menu item button
		if ($this->allowEdit)
		{
			$html .= '<button'
				. ' type="button"'
				. ' class="btn hasTooltip' . ($value ? '' : ' hidden') . '"'
				. ' id="' . $this->id . '_edit"'
				. ' data-toggle="modal"'
				. ' data-target="#ModalEdit' . $modalId . '"'
				. ' title="' . JHtml::tooltipText('COM_MENUS_EDIT_MENUITEM') . '">'
				. '<span class="icon-edit" aria-hidden="true"></span> ' . JText::_('JACTION_EDIT')
				. '</button>';
		}

		// Clear menu item button
		if ($this->allowClear)
		{
			$html .= '<button'
				. ' type="button"'
				. ' class="btn' . ($value ? '' : ' hidden') . '"'
				. ' id="' . $this->id . '_clear"'
				. ' onclick="window.processModalParent(\'' . $this->id . '\'); return false;">'
				. '<span class="icon-remove" aria-hidden="true"></span>' . JText::_('JCLEAR')
				. '</button>';
		}

		// Propagate menu item button
		if ($this->allowPropagate && count($languages) > 2)
		{
			// Strip off language tag at the end
			$tagLength = (int) strlen($this->element['language']);
			$callbackFunctionStem = substr("jSelectMenu_" . $this->id, 0, -$tagLength);

			$html .= '<a'
			. ' class="btn hasTooltip' . ($value ? '' : ' hidden') . '"'
			. ' id="' . $this->id . '_propagate"'
			. ' href="#"'
			. ' title="' . JHtml::tooltipText('JGLOBAL_ASSOCIATIONS_PROPAGATE_TIP') . '"'
			. ' onclick="Joomla.propagateAssociation(\'' . $this->id . '\', \'' . $callbackFunctionStem . '\');">'
			. '<span class="icon-refresh" aria-hidden="true"></span>' . JText::_('JGLOBAL_ASSOCIATIONS_PROPAGATE_BUTTON')
			. '</a>';
		}

		$html .= '</span>';


		// Select menu item modal
		if ($this->allowSelect)
		{
			$html .= JHtml::_(
				'bootstrap.renderModal',
				'ModalSelect' . $modalId,
				array(
					'title'       => $modalTitle,
					'url'         => $urlSelect,
					'height'      => '400px',
					'width'       => '800px',
					'bodyHeight'  => '70',
					'modalWidth'  => '80',
					'footer'      => '<button type="button" class="btn" data-dismiss="modal">' . JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>',
				)
			);
		}

		// New menu item modal
		if ($this->allowNew)
		{
			$html .= JHtml::_(
				'bootstrap.renderModal',
				'ModalNew' . $modalId,
				array(
					'title'       => JText::_('COM_MENUS_NEW_MENUITEM'),
					'backdrop'    => 'static',
					'keyboard'    => false,
					'closeButton' => false,
					'url'         => $urlNew,
					'height'      => '400px',
					'width'       => '800px',
					'bodyHeight'  => '70',
					'modalWidth'  => '80',
					'footer'      => '<button type="button" class="btn"'
							. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'item\', \'cancel\', \'item-form\'); return false;">'
							. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
							. '<button type="button" class="btn btn-primary"'
							. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'item\', \'save\', \'item-form\'); return false;">'
							. JText::_('JSAVE') . '</button>'
							. '<button type="button" class="btn btn-success"'
							. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'add\', \'item\', \'apply\', \'item-form\'); return false;">'
							. JText::_('JAPPLY') . '</button>',
				)
			);
		}

		// Edit menu item modal
		if ($this->allowEdit)
		{
			$html .= JHtml::_(
				'bootstrap.renderModal',
				'ModalEdit' . $modalId,
				array(
					'title'       => JText::_('COM_MENUS_EDIT_MENUITEM'),
					'backdrop'    => 'static',
					'keyboard'    => false,
					'closeButton' => false,
					'url'         => $urlEdit,
					'height'      => '400px',
					'width'       => '800px',
					'bodyHeight'  => '70',
					'modalWidth'  => '80',
					'footer'      => '<button type="button" class="btn"'
							. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'item\', \'cancel\', \'item-form\'); return false;">'
							. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
							. '<button type="button" class="btn btn-primary"'
							. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'item\', \'save\', \'item-form\'); return false;">'
							. JText::_('JSAVE') . '</button>'
							. '<button type="button" class="btn btn-success"'
							. ' onclick="window.processModalEdit(this, \'' . $this->id . '\', \'edit\', \'item\', \'apply\', \'item-form\'); return false;">'
							. JText::_('JAPPLY') . '</button>',
				)
			);
		}

		// Note: class='required' for client side validation.
		$class = $this->required ? ' class="required modal-value"' : '';

		// Placeholder if option is present or not when clearing field
		if ($this->element->option && (string) $this->element->option['value'] == '')
		{
			$title_holder = JText::_($this->element->option);
		}
		else
		{
			$title_holder = JText::_('COM_MENUS_SELECT_A_MENUITEM');
		}

		$html .= '<input type="hidden" id="' . $this->id . '_id" ' . $class . ' data-required="' . (int) $this->required . '" name="' . $this->name
			. '" data-text="' . htmlspecialchars($title_holder, ENT_COMPAT, 'UTF-8') . '" value="' . $value . '" />';

		return $html;
	}

	/**
	 * Method to get the field label markup.
	 *
	 * @return  string  The field label markup.
	 *
	 * @since   3.7.0
	 */
	protected function getLabel()
	{
		return str_replace($this->id, $this->id . '_id', parent::getLabel());
	}
}
models/fields/componentscategory.php000064400000003404152346104050013732 0ustar00<?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\Utilities\ArrayHelper;

JFormHelper::loadFieldClass('list');

/**
 * Components Category field.
 *
 * @since  1.6
 */
class JFormFieldComponentsCategory extends JFormFieldList
{
	/**
	 * The form field type.
	 *
	 * @var     string
	 * @since   3.7.0
	 */
	protected $type = 'ComponentsCategory';

	/**
	 * Method to get a list of options for a list input.
	 *
	 * @return	array  An array of JHtml options.
	 *
	 * @since   3.7.0
	 */
	protected function getOptions()
	{
		// Initialise variable.
		$db = JFactory::getDbo();
		$query = $db->getQuery(true)
			->select('DISTINCT a.name AS text, a.element AS value')
			->from('#__extensions as a')
			->where('a.enabled >= 1')
			->where('a.type =' . $db->quote('component'))
			->join('INNER', '#__categories as b ON a.element=b.extension');

		$items = $db->setQuery($query)->loadObjectList();

		if (count($items))
		{
			$lang = JFactory::getLanguage();

			foreach ($items as &$item)
			{
				// Load language
				$extension = $item->value;
				$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
				$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, true)
					|| $lang->load("$extension.sys", $source, null, false, true);

				// Translate component name
				$item->text = JText::_($item->text);
			}

			// Sort by component name
			$items = ArrayHelper::sortObjects($items, 'text', 1, true, true);
		}

		// Merge any additional options in the XML definition.
		$options = array_merge(parent::getOptions(), $items);

		return $options;
	}
}
models/fields/index.html000064400000000037152346104050011272 0ustar00<!DOCTYPE html><title></title>
models/fields/menuitembytype.php000064400000014365152346104050013077 0ustar00<?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('JPATH_PLATFORM') or die;

JFormHelper::loadFieldClass('groupedlist');

// Import the com_menus helper.
JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');

/**
 * Supports an HTML grouped select list of menu item grouped by menu
 *
 * @since  3.8.0
 */
class JFormFieldMenuitemByType extends JFormFieldGroupedList
{
	/**
	 * The form field type.
	 *
	 * @var    string
	 * @since  3.8.0
	 */
	public $type = 'MenuItemByType';

	/**
	 * The menu type.
	 *
	 * @var    string
	 * @since  3.8.0
	 */
	protected $menuType;

	/**
	 * The client id.
	 *
	 * @var    string
	 * @since  3.8.0
	 */
	protected $clientId;

	/**
	 * The language.
	 *
	 * @var    array
	 * @since  3.8.0
	 */
	protected $language;

	/**
	 * The published status.
	 *
	 * @var    array
	 * @since  3.8.0
	 */
	protected $published;

	/**
	 * The disabled status.
	 *
	 * @var    array
	 * @since  3.8.0
	 */
	protected $disable;

	/**
	 * Method to get certain otherwise inaccessible properties from the form field object.
	 *
	 * @param   string  $name  The property name for which to get the value.
	 *
	 * @return  mixed  The property value or null.
	 *
	 * @since   3.8.0
	 */
	public function __get($name)
	{
		switch ($name)
		{
			case 'menuType':
			case 'clientId':
			case 'language':
			case 'published':
			case 'disable':
				return $this->$name;
		}

		return parent::__get($name);
	}

	/**
	 * Method to set certain otherwise inaccessible properties of the form field object.
	 *
	 * @param   string  $name   The property name for which to set the value.
	 * @param   mixed   $value  The value of the property.
	 *
	 * @return  void
	 *
	 * @since   3.8.0
	 */
	public function __set($name, $value)
	{
		switch ($name)
		{
			case 'menuType':
				$this->menuType = (string) $value;
				break;

			case 'clientId':
				$this->clientId = (int) $value;
				break;

			case 'language':
			case 'published':
			case 'disable':
				$value = (string) $value;
				$this->$name = $value ? explode(',', $value) : array();
				break;

			default:
				parent::__set($name, $value);
		}
	}

	/**
	 * Method to attach a JForm object to the field.
	 *
	 * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the `<field>` tag for the form field object.
	 * @param   mixed             $value    The form field value to validate.
	 * @param   string            $group    The field name group control value. This acts as an array container for the field.
	 *                                      For example if the field has name="foo" and the group value is set to "bar" then the
	 *                                      full field name would end up being "bar[foo]".
	 *
	 * @return  boolean  True on success.
	 *
	 * @see     JFormField::setup()
	 * @since   3.8.0
	 */
	public function setup(SimpleXMLElement $element, $value, $group = null)
	{
		$result = parent::setup($element, $value, $group);

		if ($result == true)
		{
			$menuType = (string) $this->element['menu_type'];

			if (!$menuType)
			{
				$app = JFactory::getApplication('administrator');
				$currentMenuType = $app->getUserState('com_menus.items.menutype', '');
				$menuType        = $app->input->getString('menutype', $currentMenuType);
			}

			$this->menuType  = $menuType;
			$this->clientId  = (int) $this->element['client_id'];
			$this->published = $this->element['published'] ? explode(',', (string) $this->element['published']) : array();
			$this->disable   = $this->element['disable'] ? explode(',', (string) $this->element['disable']) : array();
			$this->language  = $this->element['language'] ? explode(',', (string) $this->element['language']) : array();
		}

		return $result;
	}

	/**
	 * Method to get the field option groups.
	 *
	 * @return  array  The field option objects as a nested array in groups.
	 *
	 * @since   3.8.0
	 */
	protected function getGroups()
	{
		$groups = array();

		$menuType = $this->menuType;

		// Get the menu items.
		$items = MenusHelper::getMenuLinks($menuType, 0, 0, $this->published, $this->language, $this->clientId);

		// Build group for a specific menu type.
		if ($menuType)
		{
			// If the menutype is empty, group the items by menutype.
			$db    = JFactory::getDbo();
			$query = $db->getQuery(true)
				->select($db->quoteName('title'))
				->from($db->quoteName('#__menu_types'))
				->where($db->quoteName('menutype') . ' = ' . $db->quote($menuType));
			$db->setQuery($query);

			try
			{
				$menuTitle = $db->loadResult();
			}
			catch (RuntimeException $e)
			{
				$menuTitle = $menuType;
			}

			// Initialize the group.
			$groups[$menuTitle] = array();

			// Build the options array.
			foreach ($items as $key => $link)
			{
				// Unset if item is menu_item_root
				if ($link->text === 'Menu_Item_Root')
				{
					unset($items[$key]);
					continue;
				}

				$levelPrefix = str_repeat('- ', max(0, $link->level - 1));

				// Displays language code if not set to All
				if ($link->language !== '*')
				{
					$lang = ' (' . $link->language . ')';
				}
				else
				{
					$lang = '';
				}

				$groups[$menuTitle][] = JHtml::_('select.option',
					$link->value, $levelPrefix . $link->text . $lang,
					'value',
					'text',
					in_array($link->type, $this->disable)
				);
			}
		}
		// Build groups for all menu types.
		else
		{
			// Build the groups arrays.
			foreach ($items as $menu)
			{
				// Initialize the group.
				$groups[$menu->title] = array();

				// Build the options array.
				foreach ($menu->links as $link)
				{
					$levelPrefix = str_repeat('- ', max(0, $link->level - 1));

					// Displays language code if not set to All
					if ($link->language !== '*')
					{
						$lang = ' (' . $link->language . ')';
					}
					else
					{
						$lang = '';
					}

					$groups[$menu->title][] = JHtml::_('select.option',
						$link->value,
						$levelPrefix . $link->text . $lang,
						'value',
						'text',
						in_array($link->type, $this->disable)
					);
				}
			}
		}

		// Merge any additional groups in the XML definition.
		$groups = array_merge(parent::getGroups(), $groups);

		return $groups;
	}
}
models/fields/menuordering.php000064400000004701152346104050012506 0ustar00<?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;

JFormHelper::loadFieldClass('list');

/**
 * Menu Ordering field.
 *
 * @since  1.6
 */
class JFormFieldMenuOrdering extends JFormFieldList
{
	/**
	 * The form field type.
	 *
	 * @var        string
	 * @since   1.7
	 */
	protected $type = 'MenuOrdering';

	/**
	 * Method to get the list of siblings in a menu.
	 * The method requires that parent be set.
	 *
	 * @return  array  The field option objects or false if the parent field has not been set
	 *
	 * @since   1.7
	 */
	protected function getOptions()
	{
		$options = array();

		// Get the parent
		$parent_id = $this->form->getValue('parent_id', 0);

		if (empty($parent_id))
		{
			return false;
		}

		$db = JFactory::getDbo();
		$query = $db->getQuery(true)
			->select('a.id AS value, a.title AS text, a.client_id AS ' . $db->quoteName('clientId'))
			->from('#__menu AS a')

			->where('a.published >= 0')
			->where('a.parent_id =' . (int) $parent_id);

		if ($menuType = $this->form->getValue('menutype'))
		{
			$query->where('a.menutype = ' . $db->quote($menuType));
		}
		else
		{
			$query->where('a.menutype != ' . $db->quote(''));
		}

		$query->order('a.lft ASC');

		// Get the options.
		$db->setQuery($query);

		try
		{
			$options = $db->loadObjectList();
		}
		catch (RuntimeException $e)
		{
			JError::raiseWarning(500, $e->getMessage());
		}

		// Allow translation of custom admin menus
		foreach ($options as &$option)
		{
			if ($option->clientId != 0)
			{
				$option->text = JText::_($option->text);
			}
		}

		$options = array_merge(
			array(array('value' => '-1', 'text' => JText::_('COM_MENUS_ITEM_FIELD_ORDERING_VALUE_FIRST'))),
			$options,
			array(array('value' => '-2', 'text' => JText::_('COM_MENUS_ITEM_FIELD_ORDERING_VALUE_LAST')))
		);

		// Merge any additional options in the XML definition.
		$options = array_merge(parent::getOptions(), $options);

		return $options;
	}

	/**
	 * Method to get the field input markup.
	 *
	 * @return  string  The field input markup.
	 *
	 * @since   1.7
	 */
	protected function getInput()
	{
		if ($this->form->getValue('id', 0) == 0)
		{
			return '<span class="readonly">' . JText::_('COM_MENUS_ITEM_FIELD_ORDERING_TEXT') . '</span>';
		}
		else
		{
			return parent::getInput();
		}
	}
}
models/fields/menuparent.php000064400000004507152346104050012172 0ustar00<?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;

JFormHelper::loadFieldClass('list');

/**
 * Menu Parent field.
 *
 * @since  1.6
 */
class JFormFieldMenuParent extends JFormFieldList
{
	/**
	 * The form field type.
	 *
	 * @var        string
	 * @since   1.6
	 */
	protected $type = 'MenuParent';

	/**
	 * Method to get the field options.
	 *
	 * @return  array  The field option objects.
	 *
	 * @since   1.6
	 */
	protected function getOptions()
	{
		$options = array();

		$db = JFactory::getDbo();
		$query = $db->getQuery(true)
			->select('DISTINCT(a.id) AS value, a.title AS text, a.level, a.lft')
			->from('#__menu AS a');

		// Filter by menu type.
		if ($menuType = $this->form->getValue('menutype'))
		{
			$query->where('a.menutype = ' . $db->quote($menuType));
		}
		else
		{
			// Skip special menu types
			$query->where('a.menutype != ' . $db->quote(''));
			$query->where('a.menutype != ' . $db->quote('main'));
		}

		// Filter by client id.
		$clientId = $this->getAttribute('clientid');

		if (!is_null($clientId))
		{
			$query->where($db->quoteName('a.client_id') . ' = ' . (int) $clientId);
		}

		// Prevent parenting to children of this item.
		if ($id = $this->form->getValue('id'))
		{
			$query->join('LEFT', $db->quoteName('#__menu') . ' AS p ON p.id = ' . (int) $id)
				->where('NOT(a.lft >= p.lft AND a.rgt <= p.rgt)');
		}

		$query->where('a.published != -2')
			->order('a.lft ASC');

		// Get the options.
		$db->setQuery($query);

		try
		{
			$options = $db->loadObjectList();
		}
		catch (RuntimeException $e)
		{
			JError::raiseWarning(500, $e->getMessage());
		}

		// Pad the option text with spaces using depth level as a multiplier.
		for ($i = 0, $n = count($options); $i < $n; $i++)
		{
			if ($clientId != 0)
			{
				// Allow translation of custom admin menus
				$options[$i]->text = str_repeat('- ', $options[$i]->level) . JText::_($options[$i]->text);
			}
			else
			{
				$options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
			}
		}

		// Merge any additional options in the XML definition.
		$options = array_merge(parent::getOptions(), $options);

		return $options;
	}
}
models/fields/menupreset.php000064400000001715152346104050012201 0ustar00<?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;

JFormHelper::loadFieldClass('list');

/**
 * Administrator Menu Presets list field.
 *
 * @since  3.8.0
 */
class JFormFieldMenuPreset extends JFormFieldList
{
	/**
	 * The form field type.
	 *
	 * @var     string
	 *
	 * @since   3.8.0
	 */
	protected $type = 'MenuPreset';

	/**
	 * Method to get the field options.
	 *
	 * @return  array  The field option objects.
	 *
	 * @since  3.8.0
	 */
	protected function getOptions()
	{
		$options = array();
		$presets = MenuHelper::getPresets();

		foreach ($presets as $preset)
		{
			$options[] = JHtml::_('select.option', $preset->name, JText::_($preset->title));
		}

		return array_merge(parent::getOptions(), $options);
	}
}
models/fields/menutype.php000064400000006642152346104050011664 0ustar00<?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;

JFormHelper::loadFieldClass('list');

/**
 * Menu Type field.
 *
 * @since  1.6
 */
class JFormFieldMenutype extends JFormFieldList
{
	/**
	 * The form field type.
	 *
	 * @var     string
	 * @since   1.6
	 */
	protected $type = 'menutype';

	/**
	 * Method to get the field input markup.
	 *
	 * @return  string  The field input markup.
	 *
	 * @since   1.6
	 */
	protected function getInput()
	{
		$html     = array();
		$recordId = (int) $this->form->getValue('id');
		$size     = (string) ($v = $this->element['size']) ? ' size="' . $v . '"' : '';
		$class    = (string) ($v = $this->element['class']) ? ' class="' . $v . '"' : 'class="text_area"';
		$required = (string) $this->element['required'] ? ' required="required"' : '';
		$clientId = (int) $this->element['clientid'] ?: 0;

		// Get a reverse lookup of the base link URL to Title
		switch ($this->value)
		{
			case 'url':
				$value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL');
				break;

			case 'alias':
				$value = JText::_('COM_MENUS_TYPE_ALIAS');
				break;

			case 'separator':
				$value = JText::_('COM_MENUS_TYPE_SEPARATOR');
				break;

			case 'heading':
				$value = JText::_('COM_MENUS_TYPE_HEADING');
				break;

			case 'container':
				$value = JText::_('COM_MENUS_TYPE_CONTAINER');
				break;

			default:
				$link = $this->form->getValue('link');

				/** @var  MenusModelMenutypes $model */
				$model = JModelLegacy::getInstance('Menutypes', 'MenusModel', array('ignore_request' => true));
				$model->setState('client_id', $clientId);

				$rlu   = $model->getReverseLookup();

				// Clean the link back to the option, view and layout
				$value = JText::_(ArrayHelper::getValue($rlu, MenusHelper::getLinkKey($link)));
				break;
		}

		// Include jQuery
		JHtml::_('jquery.framework');

		// Add the script to the document head.
		JFactory::getDocument()->addScriptDeclaration('
			function jSelectPosition_' . $this->id . '(name) {
				document.getElementById("' . $this->id . '").value = name;
			}
		'
		);

		$link = JRoute::_('index.php?option=com_menus&view=menutypes&tmpl=component&client_id=' . $clientId . '&recordId=' . $recordId);
		$html[] = '<span class="input-append"><input type="text" ' . $required . ' readonly="readonly" id="' . $this->id
			. '" value="' . $value . '" ' . $size . $class . ' />';
		$html[] = '<button type="button" data-target="#menuTypeModal" class="btn btn-primary" data-toggle="modal" title="' . JText::_('JSELECT') . '">'
			. '<span class="icon-list icon-white" aria-hidden="true"></span> '
			. JText::_('JSELECT') . '</button></span>';
		$html[] = JHtml::_(
			'bootstrap.renderModal',
			'menuTypeModal',
			array(
				'url'        => $link,
				'title'      => JText::_('COM_MENUS_ITEM_FIELD_TYPE_LABEL'),
				'width'      => '800px',
				'height'     => '300px',
				'modalWidth' => '80',
				'bodyHeight' => '70',
				'footer'     => '<button type="button" class="btn" data-dismiss="modal">'
						. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
			)
		);
		$html[] = '<input class="input-small" type="hidden" name="' . $this->name . '" value="'
			. htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';

		return implode("\n", $html);
	}
}
models/forms/filter_itemsadmin.xml000064400000004667152346104050013413 0ustar00<?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="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>
	</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.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>
models/forms/filter_menus.xml000064400000002231152346104050012371 0ustar00<?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>
	<fields name="filter">
		<field
			name="search"
			type="text"
			inputmode="search"
			label="COM_MENUS_MENUS_FILTER_SEARCH_LABEL"
			description="COM_MENUS_MENUS_FILTER_SEARCH_DESC"
			hint="JSEARCH_FILTER"
		/>
	</fields>
	<fields name="list">
		<field
			name="fullordering"
			type="list"
			label="JGLOBAL_SORT_BY"
			description="JGLOBAL_SORT_BY"
			onchange="this.form.submit();"
			default="a.title ASC"
			validate="options"
			>
			<option value="">JGLOBAL_SORT_BY</option>
			<option value="a.title ASC">JGLOBAL_TITLE_ASC</option>
			<option value="a.title DESC">JGLOBAL_TITLE_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="JGLOBAL_LIMIT"
			description="JGLOBAL_LIMIT"
			class="input-mini"
			default="5"
			onchange="this.form.submit();"
		/>
	</fields>
</form>
models/forms/index.html000064400000000037152346104050011152 0ustar00<!DOCTYPE html><title></title>
models/forms/item.xml000064400000011253152346104050010637 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<fieldset>
		<field
			name="id"
			type="hidden"
			label="JGLOBAL_FIELD_ID_LABEL"
			description="JGLOBAL_FIELD_ID_DESC"
			class="readonly"
			default="0"
			filter="int"
			readonly="true"
		/>

		<field
			name="title"
			type="text"
			label="COM_MENUS_ITEM_FIELD_TITLE_LABEL"
			description="COM_MENUS_ITEM_FIELD_TITLE_DESC"
			class="input-xxlarge input-large-text"
			size="40"
			required="true"
		/>

		<field
			name="alias"
			type="alias"
			label="JFIELD_ALIAS_LABEL"
			description="JFIELD_ALIAS_DESC"
			hint="JFIELD_ALIAS_PLACEHOLDER"
			size="40"
		/>

		<field
			name="note"
			type="text"
			label="JFIELD_NOTE_LABEL"
			description="COM_MENUS_ITEM_FIELD_NOTE_DESC"
			maxlength="255"
			class="span12"
			size="40"
		/>

		<field
			name="link"
			type="link"
			label="COM_MENUS_ITEM_FIELD_LINK_LABEL"
			description="COM_MENUS_ITEM_FIELD_LINK_DESC"
			readonly="true"
			class="input-xxlarge"
			size="50"
		/>

		<field
			name="menutype"
			type="menu"
			label="COM_MENUS_ITEM_FIELD_ASSIGNED_LABEL"
			description="COM_MENUS_ITEM_FIELD_ASSIGNED_DESC"
			required="true"
			clientid="0"
			size="1"
			>
			<option value="">COM_MENUS_SELECT_MENU</option>
		</field>

		<field
			name="type"
			type="menutype"
			label="COM_MENUS_ITEM_FIELD_TYPE_LABEL"
			description="COM_MENUS_ITEM_FIELD_TYPE_DESC"
			class="input-medium"
			required="true"
			size="40"
		/>

		<field
			name="published"
			type="list"
			label="JSTATUS"
			description="JFIELD_PUBLISHED_DESC"
			id="published"
			class="chzn-color-state"
			size="1"
			default="1"
			filter="integer"
			>
			<option value="1">JPUBLISHED</option>
			<option value="0">JUNPUBLISHED</option>
			<option value="-2">JTRASHED</option>
		</field>

		<field
			name="parent_id"
			type="menuparent"
			label="COM_MENUS_ITEM_FIELD_PARENT_LABEL"
			description="COM_MENUS_ITEM_FIELD_PARENT_DESC"
			default="1"
			filter="int"
			clientid="0"
			size="1"
			>
			<option value="1">COM_MENUS_ITEM_ROOT</option>
		</field>

		<field
			name="menuordering"
			type="menuordering"
			label="COM_MENUS_ITEM_FIELD_ORDERING_LABEL"
			description="COM_MENUS_ITEM_FIELD_ORDERING_DESC"
			filter="int"
			size="1">
		</field>

		<field
			name="component_id"
			type="hidden"
			filter="int"
		/>

		<field
			name="browserNav"
			type="list"
			label="COM_MENUS_ITEM_FIELD_BROWSERNAV_LABEL"
			description="COM_MENUS_ITEM_FIELD_BROWSERNAV_DESC"
			default="0"
			filter="int"
			>
			<option value="0">COM_MENUS_FIELD_VALUE_PARENT</option>
			<option value="1">COM_MENUS_FIELD_VALUE_NEW_WITH_NAV</option>
			<option value="2">COM_MENUS_FIELD_VALUE_NEW_WITHOUT_NAV</option>
		</field>

		<field
			name="access"
			type="accesslevel"
			label="JFIELD_ACCESS_LABEL"
			description="JFIELD_ACCESS_DESC"
			id="access"
			filter="integer"
			/>

		<field
			name="template_style_id"
			type="templatestyle"
			label="COM_MENUS_ITEM_FIELD_TEMPLATE_LABEL"
			description="COM_MENUS_ITEM_FIELD_TEMPLATE_DESC"
			client="site"
			filter="int"
			showon="type!:alias[OR]params.alias_redirect:0"
			>
			<option value="0">JOPTION_USE_DEFAULT</option>
		</field>

		<field
			name="home"
			type="radio"
			label="COM_MENUS_ITEM_FIELD_HOME_LABEL"
			description="COM_MENUS_ITEM_FIELD_HOME_DESC"
			default="0"
			class="btn-group btn-group-yesno"
			filter="integer"
			>
			<option value="1">JYES</option>
			<option value="0">JNO</option>
		</field>

		<field
			name="language"
			type="contentlanguage"
			label="JFIELD_LANGUAGE_LABEL"
			description="COM_MENUS_ITEM_FIELD_LANGUAGE_DESC"
			>
			<option value="*">JALL</option>
		</field>

		<field
			name="path"
			type="hidden"
			filter="unset"
		/>

		<field
			name="level"
			type="hidden"
			filter="unset"
		/>

		<field
			name="checked_out"
			type="hidden"
			filter="unset"
		/>

		<field
			name="checked_out_time"
			type="hidden"
			filter="unset"
		/>

		<field
			name="lft"
			type="hidden"
			filter="unset"
		/>

		<field
			name="rgt"
			type="hidden"
			filter="unset"
		/>

		<field
			name="toggle_modules_assigned"
			type="radio"
			label="COM_MENUS_ITEM_FIELD_HIDE_UNASSIGNED_LABEL"
			description="COM_MENUS_ITEM_FIELD_HIDE_UNASSIGNED_DESC"
			default="1"
			class="btn-group btn-group-yesno"
			filter="integer"
			>
			<option value="1">JSHOW</option>
			<option value="0">JHIDE</option>
		</field>

		<field
			name="toggle_modules_published"
			type="radio"
			label="COM_MENUS_ITEM_FIELD_HIDE_UNPUBLISHED_LABEL"
			description="COM_MENUS_ITEM_FIELD_HIDE_UNPUBLISHED_DESC"
			default="1"
			class="btn-group btn-group-yesno"
			filter="integer"
			>
			<option value="1">JSHOW</option>
			<option value="0">JHIDE</option>
		</field>
	</fieldset>

	<fields name="params">
	</fields>
</form>
models/forms/item_alias.xml000064400000004315152346104050012011 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<!-- Add fields to the request variables for the layout. -->

	<fields name="params">

		<fieldset name="aliasoptions">
			<field
				name="aliasoptions"
				type="modal_menu"
				label="COM_MENUS_ITEM_FIELD_ALIAS_MENU_LABEL"
				description="COM_MENUS_ITEM_FIELD_ALIAS_MENU_DESC"
				clientid="0"
				required="true"
				select="true"
				new="true"
				edit="true"
				clear="true"
			/>

			<field
				name="alias_redirect"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_ALIAS_REDIRECT_LABEL"
				description="COM_MENUS_ITEM_FIELD_ALIAS_REDIRECT_DESC"
				class="btn-group btn-group-yesno"
				default="0"
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>
		</fieldset>

		<fieldset name="menu-options"
				label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
			>

			<field
				name="menu-anchor_title"
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC"
			/>

			<field
				name="menu-anchor_css"
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
			/>

			<field
				name="menu_image"
				type="media"
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
			/>

			<field
				name="menu_image_css"
				type="text"
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC"
			/>

			<field
				name="menu_text"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
				class="btn-group btn-group-yesno"
				default="1"
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>

			<field
				name="menu_show"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
				default="1"
				filter="integer"
				class="btn-group btn-group-yesno"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>
		</fieldset>
	</fields>
	<help key="JHELP_MENUS_MENU_ITEM_MENU_ITEM_ALIAS" />
</form>
models/forms/item_component.xml000064400000007016152346104050012723 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<fields name="params" label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
	>
		<fieldset name="menu-options" label="COM_MENUS_LINKTYPE_OPTIONS_LABEL">

			<field
				name="menu-anchor_title"
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC"
			/>

			<field
				name="menu-anchor_css"
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
			/>

			<field
				name="menu_image"
				type="media"
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
			/>

			<field
				name="menu_image_css"
				type="text"
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC"
			/>

			<field
				name="menu_text"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
				class="btn-group btn-group-yesno"
				default="1" filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>

			<field
				name="menu_show"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
				class="btn-group btn-group-yesno"
				default="1"
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>
		</fieldset>

		<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"
				useglobal="true"
			/>

			<field
				name="show_page_heading"
				type="list"
				label="COM_MENUS_ITEM_FIELD_SHOW_PAGE_HEADING_LABEL"
				description="COM_MENUS_ITEM_FIELD_SHOW_PAGE_HEADING_DESC"
				class="chzn-color"
				default=""
				useglobal="true"
				>
				<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"
			/>

			<field
				name="pageclass_sfx"
				type="text"
				label="COM_MENUS_ITEM_FIELD_PAGE_CLASS_LABEL"
				description="COM_MENUS_ITEM_FIELD_PAGE_CLASS_DESC"
			/>

		</fieldset>

		<fieldset name="metadata" label="JGLOBAL_FIELDSET_METADATA_OPTIONS">
			<field
				name="menu-meta_description"
				type="textarea"
				label="JFIELD_META_DESCRIPTION_LABEL"
				description="JFIELD_META_DESCRIPTION_DESC"
				rows="3"
				cols="40"
			/>

			<field
				name="menu-meta_keywords"
				type="textarea"
				label="JFIELD_META_KEYWORDS_LABEL"
				description="JFIELD_META_KEYWORDS_DESC"
				rows="3"
				cols="40"
			/>

			<field
				name="robots"
				type="list"
				label="JFIELD_METADATA_ROBOTS_LABEL"
				description="JFIELD_METADATA_ROBOTS_DESC"
				>
				<option value="">JGLOBAL_USE_GLOBAL</option>
				<option value="index, follow"></option>
				<option value="noindex, follow"></option>
				<option value="index, nofollow"></option>
				<option value="noindex, nofollow"></option>
			</field>

			<field
				name="secure"
				type="list"
				label="COM_MENUS_ITEM_FIELD_SECURE_LABEL"
				description="COM_MENUS_ITEM_FIELD_SECURE_DESC"
				default="0"
				filter="integer"
				>
				<option value="-1">JOFF</option>
				<option value="1">JON</option>
				<option value="0">COM_MENUS_FIELD_VALUE_IGNORE</option>
			</field>
		</fieldset>

	</fields>

</form>
models/forms/item_heading.xml000064400000003022152346104050012311 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<fields name="params">
		<fieldset name="menu-options"
			label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
		>
			<field 
				name="menu-anchor_title" 
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC" 
			/>

			<field 
				name="menu-anchor_css" 
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC" 
			/>

			<field 
				name="menu_image" 
				type="media"
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC" 
			/>

			<field 
				name="menu_image_css"
				type="text" 
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC" 
			/>

			<field 
				name="menu_text" 
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
				class="btn-group btn-group-yesno"
				default="1" 
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>

			<field
				name="menu_show"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
				class="btn-group btn-group-yesno"
				default="1"
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>
		</fieldset>
	</fields>
	<help key="JHELP_MENUS_MENU_ITEM_MENU_ITEM_HEADING" />
</form>
models/forms/item_separator.xml000064400000002542152346104050012720 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<fields name="params">
		<fieldset name="menu-options"
			label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
		>

			<field 
				name="menu-anchor_css" 
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC" 
			/>

			<field 
				name="menu_image" 
				type="media"
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC" 
			/>

			<field 
				name="menu_image_css"
				type="text" 
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC" 
			/>

			<field 
				name="menu_text" 
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
				class="btn-group btn-group-yesno"
				default="1" 
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>

			<field
				name="menu_show"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
				class="btn-group btn-group-yesno"
				default="1"
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>
		</fieldset>
	</fields>
	<help key="JHELP_MENUS_MENU_ITEM_TEXT_SEPARATOR" />
</form>
models/forms/item_url.xml000064400000004253152346104050011523 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<fields name="params">
		<fieldset name="menu-options" label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
		>

			<field 
				name="menu-anchor_title"
				type="text" 
				label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC" 
			/>

			<field 
				name="menu-anchor_css"
				type="text" 
				label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC" 
			/>

			<field 
				name="menu-anchor_rel" 
				type="list"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_REL_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_REL_DESC"
				default=""
				>
				<option value="">JNONE</option>
				<option value="alternate"/>
				<option value="author"/>
				<option value="bookmark"/>
				<option value="help"/>
				<option value="license"/>
				<option value="next"/>
				<option value="nofollow"/>
				<option value="noopener"/>
				<option value="noreferrer"/>
				<option value="prefetch"/>
				<option value="prev"/>
				<option value="search"/>
				<option value="sponsored"/>
				<option value="tag"/>
				<option value="ugc"/>
			</field>

			<field 
				name="menu_image" 
				type="media"
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC" 
			/>

			<field 
				name="menu_image_css"
				type="text" 
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC" 
			/>

			<field 
				name="menu_text" 
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
				class="btn-group btn-group-yesno"
				default="1" 
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>

			<field
				name="menu_show"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
				class="btn-group btn-group-yesno"
				default="1"
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>
		</fieldset>
	</fields>
	<help key="JHELP_MENUS_MENU_ITEM_EXTERNAL_URL" />
</form>
models/forms/itemadmin.xml000064400000006451152346104050011654 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<fieldset>
		<field
			name="id"
			type="hidden"
			label="JGLOBAL_FIELD_ID_LABEL"
			description="JGLOBAL_FIELD_ID_DESC"
			class="readonly"
			default="0"
			filter="int"
			readonly="true"
		/>

		<field
			name="title"
			type="text"
			label="COM_MENUS_ITEM_FIELD_TITLE_LABEL"
			description="COM_MENUS_ITEM_FIELD_TITLE_DESC"
			class="input-xxlarge input-large-text"
			size="40"
			required="true"
		/>

		<field
			name="alias"
			type="alias"
			label="JFIELD_ALIAS_LABEL"
			description="JFIELD_ALIAS_DESC"
			hint="JFIELD_ALIAS_PLACEHOLDER"
			size="40"
		/>

		<field
			name="note"
			type="text"
			label="JFIELD_NOTE_LABEL"
			description="COM_MENUS_ITEM_FIELD_NOTE_DESC"
			maxlength="255"
			class="span12"
			size="40"
		/>

		<field
			name="link"
			type="link"
			label="COM_MENUS_ITEM_FIELD_LINK_LABEL"
			description="COM_MENUS_ITEM_FIELD_LINK_DESC"
			readonly="true"
			class="input-xxlarge"
			size="50"
		/>

		<field
			name="menutype"
			type="menu"
			label="COM_MENUS_ITEM_FIELD_ASSIGNED_LABEL"
			description="COM_MENUS_ITEM_FIELD_ASSIGNED_DESC"
			required="true"
			clientid="1"
			size="1"
			>
			<option value="">COM_MENUS_SELECT_MENU</option>
		</field>

		<field
			name="type"
			type="menutype"
			label="COM_MENUS_ITEM_FIELD_TYPE_LABEL"
			description="COM_MENUS_ITEM_FIELD_TYPE_DESC"
			class="input-medium"
			required="true"
			size="40"
		/>

		<field
			name="published"
			type="list"
			label="JSTATUS"
			description="JFIELD_PUBLISHED_DESC"
			class="chzn-color-state"
			id="published"
			size="1"
			default="1"
			filter="integer"
			>
			<option value="1">JPUBLISHED</option>
			<option value="0">JUNPUBLISHED</option>
			<option value="-2">JTRASHED</option>
		</field>

		<field
			name="parent_id"
			type="menuparent"
			label="COM_MENUS_ITEM_FIELD_PARENT_LABEL"
			description="COM_MENUS_ITEM_FIELD_PARENT_DESC"
			default="1"
			filter="int"
			clientid="1"
			size="1"
			>
			<option value="1">COM_MENUS_ITEM_ROOT</option>
		</field>

		<field
			name="menuordering"
			type="menuordering"
			label="COM_MENUS_ITEM_FIELD_ORDERING_LABEL"
			description="COM_MENUS_ITEM_FIELD_ORDERING_DESC"
			filter="int"
			size="1"
		/>

		<field
			name="component_id"
			type="hidden"
			filter="int"
		/>

		<field
			name="browserNav"
			type="list"
			label="COM_MENUS_ITEM_FIELD_BROWSERNAV_LABEL"
			description="COM_MENUS_ITEM_FIELD_BROWSERNAV_DESC"
			default="0"
			filter="int"
			>
			<option value="0">COM_MENUS_FIELD_VALUE_PARENT</option>
			<option value="1">COM_MENUS_FIELD_VALUE_NEW_WITH_NAV</option>
		</field>

		<field
			name="home"
			type="hidden"
			default="0"
		/>

		<field
			name="access"
			type="hidden"
			id="access"
			default="0"
		/>

		<field
			name="template_style_id"
			type="hidden"
			default="0"
		/>

		<field
			name="language"
			type="hidden"
			default="*"
		/>

		<field
			name="path"
			type="hidden"
			filter="unset"
		/>

		<field
			name="level"
			type="hidden"
			filter="unset"
		/>

		<field
			name="checked_out"
			type="hidden"
			filter="unset"
		/>

		<field
			name="checked_out_time"
			type="hidden"
			filter="unset"
		/>

		<field
			name="lft"
			type="hidden"
			filter="unset"
		/>

		<field
			name="rgt"
			type="hidden"
			filter="unset"
		/>
	</fieldset>

	<fields name="params">
	</fields>
</form>
models/forms/itemadmin_alias.xml000064400000003604152346104050013022 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<!-- Add fields to the request variables for the layout. -->
	<fields name="params">
		<fieldset name="aliasoptions">
			<field
				name="aliasoptions"
				type="modal_menu"
				label="COM_MENUS_ITEM_FIELD_ALIAS_MENU_LABEL"
				description="COM_MENUS_ITEM_FIELD_ALIAS_MENU_DESC"
				clientid="1"
				required="true"
				select="true"
				new="true"
				edit="true"
				clear="true"
			/>
		</fieldset>

		<fieldset
			name="menu-options"
			label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
		>

			<field
				name="menu-anchor_title"
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC"
			/>

			<field
				name="menu-anchor_css"
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
			/>

			<field
				name="menu_image"
				type="media"
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
			/>

			<field 
				name="menu_image_css"
				type="text" 
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC" 
			/>

			<field
				name="menu_text"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
				class="btn-group btn-group-yesno"
				default="1" 
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>

			<field
				name="menu_show"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
				class="btn-group btn-group-yesno"
				default="1"
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>
		</fieldset>
	</fields>
	<help key="JHELP_MENUS_MENU_ITEM_MENU_ITEM_ALIAS"/>
</form>
models/forms/itemadmin_component.xml000064400000003003152346104050013724 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<fields name="params" label="COM_MENUS_LINKTYPE_OPTIONS_LABEL">
		<fieldset name="menu-options"
			label="COM_MENUS_LINKTYPE_OPTIONS_LABEL"
		>

			<field 
				name="menu-anchor_title" 
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC" 
			/>

			<field
				name="menu-anchor_css" 
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC" 
			/>

			<field 
				name="menu_image" 
				type="media"
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC" 
			/>

			<field 
				name="menu_image_css"
				type="text" 
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC" 
			/>

			<field 
				name="menu_text" 
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
				class="btn-group btn-group-yesno"
				default="1" 
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>

			<field
				name="menu_show"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
				class="btn-group btn-group-yesno"
				default="1"
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>
		</fieldset>
	</fields>
</form>
models/forms/itemadmin_container.xml000064400000003646152346104050013721 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<fieldset>
		<!-- Container type menu item does not have a navigation -->
		<field
			name="link"
			type="hidden"
		/>

		<field
			name="browserNav"
			type="hidden"
			default="0"
		/>
	</fieldset>

	<fields name="params">
		<fieldset name="menu-options" label="COM_MENUS_LINKTYPE_OPTIONS_LABEL">
			<field
				name="menu-anchor_title"
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC"
			/>

			<field
				name="menu-anchor_css"
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
			/>

			<field
				name="menu_image"
				type="media"
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
			/>

			<field 
				name="menu_image_css"
				type="text" 
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC" 
			/>

			<field
				name="menu_text"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
				class="btn-group btn-group-yesno"
				default="1"
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>

			<field
				name="menu_show"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
				class="btn-group btn-group-yesno"
				default="1"
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>
		</fieldset>
		<field
			name="hideitems"
			type="checkboxes"
			label="COM_MENUS_ITEM_FIELD_COMPONENTS_CONTAINER_HIDE_ITEMS_LABEL"
			description="COM_MENUS_ITEM_FIELD_COMPONENTS_CONTAINER_HIDE_ITEMS_DESC"
			filter="array"
		/>
	</fields>
	<help key="JHELP_MENUS_MENU_ITEM_MENU_ITEM_CONTAINER"/>
</form>
models/forms/itemadmin_heading.xml000064400000003310152346104050013322 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<fieldset>
		<!-- Heading type menu item does not have a navigation -->
		<field
			name="link"
			type="hidden"
		/>

		<field
			name="browserNav"
			type="hidden"
			default="0"
		/>
	</fieldset>

	<fields name="params">
		<fieldset name="menu-options" label="COM_MENUS_LINKTYPE_OPTIONS_LABEL">
			<field
				name="menu-anchor_title"
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC"
			/>

			<field
				name="menu-anchor_css"
				type="text"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC"
			/>

			<field
				name="menu_image"
				type="media"
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC"
			/>

			<field 
				name="menu_image_css"
				type="text" 
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC" 
			/>

			<field
				name="menu_text"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
				class="btn-group btn-group-yesno"
				default="1"
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>

			<field
				name="menu_show"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
				class="btn-group btn-group-yesno"
				default="1"
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>
		</fieldset>
	</fields>
	<help key="JHELP_MENUS_MENU_ITEM_MENU_ITEM_HEADING"/>
</form>
models/forms/itemadmin_separator.xml000064400000001253152346104050013727 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<fieldset>
		<!-- Text separator type menu item does not have a navigation -->
		<field
			name="link"
			type="hidden"
		/>

		<field
			name="browserNav"
			type="hidden"
			default="0"
		/>

		<fields name="params">
			<field
				name="text_separator"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_TEXT_SEPARATOR_LABEL"
				description="COM_MENUS_ITEM_FIELD_TEXT_SEPARATOR_DESC"
				class="btn-group btn-group-yesno"
				default="0"
				filter="integer"
				>
				<option value="0">JNO</option>
				<option value="1">JYES</option>
			</field>
		</fields>
	</fieldset>

	<help key="JHELP_MENUS_MENU_ITEM_TEXT_SEPARATOR" />
</form>
models/forms/itemadmin_url.xml000064400000004111152346104050012525 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<fields name="params">
		<fieldset name="menu-options" label="COM_MENUS_LINKTYPE_OPTIONS_LABEL">
			<field 
				name="menu-anchor_title"
				type="text" 
				label="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC" 
			/>

			<field 
				name="menu-anchor_css"
				type="text" 
				label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC" 
			/>

			<field 
				name="menu-anchor_rel" 
				type="list"
				label="COM_MENUS_ITEM_FIELD_ANCHOR_REL_LABEL"
				description="COM_MENUS_ITEM_FIELD_ANCHOR_REL_DESC"
				default=""
				>
				<option value="">JNONE</option>
				<option value="alternate"/>
				<option value="author"/>
				<option value="bookmark"/>
				<option value="help"/>
				<option value="license"/>
				<option value="next"/>
				<option value="nofollow"/>
				<option value="noreferrer"/>
				<option value="prefetch"/>
				<option value="prev"/>
				<option value="search"/>
				<option value="tag"/>
			</field>

			<field 
				name="menu_image" 
				type="media"
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC" 
			/>

			<field 
				name="menu_image_css"
				type="text" 
				label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_CSS_DESC" 
			/>

			<field 
				name="menu_text" 
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_TEXT_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_TEXT_DESC"
				class="btn-group btn-group-yesno"
				default="1" filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>

			<field
				name="menu_show"
				type="radio"
				label="COM_MENUS_ITEM_FIELD_MENU_SHOW_LABEL"
				description="COM_MENUS_ITEM_FIELD_MENU_SHOW_DESC"
				class="btn-group btn-group-yesno"
				default="1"
				filter="integer"
				>
				<option value="1">JYES</option>
				<option value="0">JNO</option>
			</field>
		</fieldset>
	</fields>
	<help key="JHELP_MENUS_MENU_ITEM_EXTERNAL_URL" />
</form>
models/forms/menu.xml000064400000002771152346104050010652 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<fieldset>
		<field
			name="id"
			type="hidden"
			id="id"
			default="0"
			filter="int"
			readonly="true"
		/>
		<field
			name="asset_id"
			type="hidden"
			filter="unset"
		/>
		<field
			name="menutype"
			type="text"
			label="COM_MENUS_MENU_MENUTYPE_LABEL"
			description="COM_MENUS_MENU_MENUTYPE_DESC"
			id="menutype"
			size="30"
			maxlength="24"
			required="true"
		/>
		<field
			name="title"
			type="text"
			label="JGLOBAL_TITLE"
			description="COM_MENUS_MENU_TITLE_DESC"
			id="title"
			size="30"
			maxlength="48"
			required="true"
		/>
		<field
			name="description"
			type="text"
			label="JGLOBAL_DESCRIPTION"
			description="COM_MENUS_MENU_DESCRIPTION_DESC"
			id="menudescription"
			size="30"
			maxlength="255"
		/>
		<field
			name="client_id"
			type="radio"
			label="COM_MENUS_MENU_CLIENT_ID_LABEL"
			description="COM_MENUS_MENU_CLIENT_ID_DESC"
			id="client_id"
			default="0"
			class="btn-group btn-group-yesno btn-group-reversed"
			>
			<option value="0">JSITE</option>
			<option value="1">JADMINISTRATOR</option>
		</field>
		<field
			name="preset"
			type="menuPreset"
			label="COM_MENUS_FIELD_PRESET_LABEL"
			description="COM_MENUS_FIELD_PRESET_DESC"
			showon="client_id:1"
		>
			<option value="">JNONE</option>
		</field>
		<field
			name="rules"
			type="rules"
			label="JFIELD_RULES_LABEL"
			translate_label="false"
			filter="rules"
			component="com_menus"
			section="menu"
			validate="rules" 
		/>
	</fieldset>
</form>
models/index.html000064400000000037152346104050010024 0ustar00<!DOCTYPE html><title></title>
models/item.php000064400000125446152346104050007512 0ustar00<?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;

use Joomla\CMS\Factory;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;

jimport('joomla.filesystem.path');
JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');

/**
 * Menu Item Model for Menus.
 *
 * @since  1.6
 */
class MenusModelItem extends JModelAdmin
{
	/**
	 * The type alias for this content type.
	 *
	 * @var    string
	 * @since  3.4
	 */
	public $typeAlias = 'com_menus.item';

	/**
	 * The context used for the associations table
	 *
	 * @var    string
	 * @since  3.4.4
	 */
	protected $associationsContext = 'com_menus.item';

	/**
	 * @var    string  The prefix to use with controller messages.
	 * @since  1.6
	 */
	protected $text_prefix = 'COM_MENUS_ITEM';

	/**
	 * @var    string  The help screen key for the menu item.
	 * @since  1.6
	 */
	protected $helpKey = 'JHELP_MENUS_MENU_ITEM_MANAGER_EDIT';

	/**
	 * @var    string  The help screen base URL for the menu item.
	 * @since  1.6
	 */
	protected $helpURL;

	/**
	 * @var    boolean  True to use local lookup for the help screen.
	 * @since  1.6
	 */
	protected $helpLocal = false;

	/**
	 * Batch copy/move command. If set to false,
	 * the batch copy/move command is not supported
	 *
	 * @var   string
	 */
	protected $batch_copymove = 'menu_id';

	/**
	 * Allowed batch commands
	 *
	 * @var   array
	 */
	protected $batch_commands = array(
		'assetgroup_id' => 'batchAccess',
		'language_id'   => 'batchLanguage'
	);

	/**
	 * Method to test whether a record can be deleted.
	 *
	 * @param   object  $record  A record object.
	 *
	 * @return  boolean  True if allowed to delete the record. Defaults to the permission set in the component.
	 *
	 * @since   1.6
	 */
	protected function canDelete($record)
	{
		if (empty($record->id) || $record->published != -2)
		{
			return false;
		}

		$menuTypeId = 0;

		if (!empty($record->menutype))
		{
			$menuTypeId = $this->getMenuTypeId($record->menutype);
		}

		return JFactory::getUser()->authorise('core.delete', 'com_menus.menu.' . (int) $menuTypeId);
	}

	/**
	 * Method to test whether the state of a record can be edited.
	 *
	 * @param   object  $record  A record object.
	 *
	 * @return  boolean  True if allowed to change the state of the record. Defaults to the permission for the component.
	 *
	 * @since   3.6
	 */
	protected function canEditState($record)
	{
		$menuTypeId = !empty($record->menutype) ? $this->getMenuTypeId($record->menutype) : 0;
		$assetKey   = $menuTypeId ? 'com_menus.menu.' . (int) $menuTypeId : 'com_menus';

		return JFactory::getUser()->authorise('core.edit.state', $assetKey);
	}

	/**
	 * Batch copy menu items to a new menu or parent.
	 *
	 * @param   integer  $value     The new menu or sub-item.
	 * @param   array    $pks       An array of row IDs.
	 * @param   array    $contexts  An array of item contexts.
	 *
	 * @return  mixed  An array of new IDs on success, boolean false on failure.
	 *
	 * @since   1.6
	 */
	protected function batchCopy($value, $pks, $contexts)
	{
		// $value comes as {menutype}.{parent_id}
		$parts    = explode('.', $value);
		$menuType = $parts[0];
		$parentId = ArrayHelper::getValue($parts, 1, 0, 'int');

		$table  = $this->getTable();
		$db     = $this->getDbo();
		$query  = $db->getQuery(true);
		$newIds = array();

		// Check that the parent exists
		if ($parentId)
		{
			if (!$table->load($parentId))
			{
				if ($error = $table->getError())
				{
					// Fatal error
					$this->setError($error);

					return false;
				}
				else
				{
					// Non-fatal error
					$this->setError(JText::_('JGLOBAL_BATCH_MOVE_PARENT_NOT_FOUND'));
					$parentId = 0;
				}
			}
		}

		// If the parent is 0, set it to the ID of the root item in the tree
		if (empty($parentId))
		{
			if (!$parentId = $table->getRootId())
			{
				$this->setError($db->getErrorMsg());

				return false;
			}
		}

		// Check that user has create permission for menus
		$user = JFactory::getUser();

		$menuTypeId = (int) $this->getMenuTypeId($menuType);

		if (!$user->authorise('core.create', 'com_menus.menu.' . $menuTypeId))
		{
			$this->setError(JText::_('COM_MENUS_BATCH_MENU_ITEM_CANNOT_CREATE'));

			return false;
		}

		// We need to log the parent ID
		$parents = array();

		// Calculate the emergency stop count as a precaution against a runaway loop bug
		$query->select('COUNT(id)')
			->from($db->quoteName('#__menu'));
		$db->setQuery($query);

		try
		{
			$count = $db->loadResult();
		}
		catch (RuntimeException $e)
		{
			$this->setError($e->getMessage());

			return false;
		}

		// Parent exists so we let's proceed
		while (!empty($pks) && $count > 0)
		{
			// Pop the first id off the stack
			$pk = array_shift($pks);

			$table->reset();

			// Check that the row actually exists
			if (!$table->load($pk))
			{
				if ($error = $table->getError())
				{
					// Fatal error
					$this->setError($error);

					return false;
				}
				else
				{
					// Not fatal error
					$this->setError(JText::sprintf('JGLOBAL_BATCH_MOVE_ROW_NOT_FOUND', $pk));
					continue;
				}
			}

			// Copy is a bit tricky, because we also need to copy the children
			$query->clear()
				->select('id')
				->from($db->quoteName('#__menu'))
				->where('lft > ' . (int) $table->lft)
				->where('rgt < ' . (int) $table->rgt);
			$db->setQuery($query);
			$childIds = $db->loadColumn();

			// Add child ID's to the array only if they aren't already there.
			foreach ($childIds as $childId)
			{
				if (!in_array($childId, $pks))
				{
					$pks[] = $childId;
				}
			}

			// Make a copy of the old ID and Parent ID
			$oldId = $table->id;
			$oldParentId = $table->parent_id;

			// Reset the id because we are making a copy.
			$table->id = 0;

			// If we a copying children, the Old ID will turn up in the parents list
			// otherwise it's a new top level item
			$table->parent_id = isset($parents[$oldParentId]) ? $parents[$oldParentId] : $parentId;
			$table->menutype = $menuType;

			// Set the new location in the tree for the node.
			$table->setLocation($table->parent_id, 'last-child');

			// TODO: Deal with ordering?
			// $table->ordering = 1;
			$table->level = null;
			$table->lft   = null;
			$table->rgt   = null;
			$table->home  = 0;

			// Alter the title & alias
			list($title, $alias) = $this->generateNewTitle($table->parent_id, $table->alias, $table->title);
			$table->title = $title;
			$table->alias = $alias;

			// Check the row.
			if (!$table->check())
			{
				$this->setError($table->getError());

				return false;
			}

			// Store the row.
			if (!$table->store())
			{
				$this->setError($table->getError());

				return false;
			}

			// Get the new item ID
			$newId = $table->get('id');

			// Add the new ID to the array
			$newIds[$pk] = $newId;

			// Now we log the old 'parent' to the new 'parent'
			$parents[$oldId] = $table->id;
			$count--;
		}

		// Rebuild the hierarchy.
		if (!$table->rebuild())
		{
			$this->setError($table->getError());

			return false;
		}

		// Rebuild the tree path.
		if (!$table->rebuildPath($table->id))
		{
			$this->setError($table->getError());

			return false;
		}

		// Clean the cache
		$this->cleanCache();

		return $newIds;
	}

	/**
	 * Batch move menu items to a new menu or parent.
	 *
	 * @param   integer  $value     The new menu or sub-item.
	 * @param   array    $pks       An array of row IDs.
	 * @param   array    $contexts  An array of item contexts.
	 *
	 * @return  boolean  True on success.
	 *
	 * @since   1.6
	 */
	protected function batchMove($value, $pks, $contexts)
	{
		// $value comes as {menutype}.{parent_id}
		$parts    = explode('.', $value);
		$menuType = $parts[0];
		$parentId = ArrayHelper::getValue($parts, 1, 0, 'int');

		$table = $this->getTable();
		$db    = $this->getDbo();
		$query = $db->getQuery(true);

		// Check that the parent exists.
		if ($parentId)
		{
			if (!$table->load($parentId))
			{
				if ($error = $table->getError())
				{
					// Fatal error
					$this->setError($error);

					return false;
				}
				else
				{
					// Non-fatal error
					$this->setError(JText::_('JGLOBAL_BATCH_MOVE_PARENT_NOT_FOUND'));
					$parentId = 0;
				}
			}
		}

		// Check that user has create and edit permission for menus
		$user = JFactory::getUser();

		$menuTypeId = (int) $this->getMenuTypeId($menuType);

		if (!$user->authorise('core.create', 'com_menus.menu.' . $menuTypeId))
		{
			$this->setError(JText::_('COM_MENUS_BATCH_MENU_ITEM_CANNOT_CREATE'));

			return false;
		}

		if (!$user->authorise('core.edit', 'com_menus.menu.' . $menuTypeId))
		{
			$this->setError(JText::_('COM_MENUS_BATCH_MENU_ITEM_CANNOT_EDIT'));

			return false;
		}

		// We are going to store all the children and just moved the menutype
		$children = array();

		// Parent exists so we let's proceed
		foreach ($pks as $pk)
		{
			// Check that the row actually exists
			if (!$table->load($pk))
			{
				if ($error = $table->getError())
				{
					// Fatal error
					$this->setError($error);

					return false;
				}
				else
				{
					// Not fatal error
					$this->setError(JText::sprintf('JGLOBAL_BATCH_MOVE_ROW_NOT_FOUND', $pk));
					continue;
				}
			}

			// Set the new location in the tree for the node.
			$table->setLocation($parentId, 'last-child');

			// Set the new Parent Id
			$table->parent_id = $parentId;

			// Check if we are moving to a different menu
			if ($menuType != $table->menutype)
			{
				// Add the child node ids to the children array.
				$query->clear()
					->select($db->quoteName('id'))
					->from($db->quoteName('#__menu'))
					->where($db->quoteName('lft') . ' BETWEEN ' . (int) $table->lft . ' AND ' . (int) $table->rgt);
				$db->setQuery($query);
				$children = array_merge($children, (array) $db->loadColumn());
			}

			// Check the row.
			if (!$table->check())
			{
				$this->setError($table->getError());

				return false;
			}

			// Store the row.
			if (!$table->store())
			{
				$this->setError($table->getError());

				return false;
			}

			// Rebuild the tree path.
			if (!$table->rebuildPath())
			{
				$this->setError($table->getError());

				return false;
			}
		}

		// Process the child rows
		if (!empty($children))
		{
			// Remove any duplicates and sanitize ids.
			$children = array_unique($children);
			$children = ArrayHelper::toInteger($children);

			// Update the menutype field in all nodes where necessary.
			$query->clear()
				->update($db->quoteName('#__menu'))
				->set($db->quoteName('menutype') . ' = ' . $db->quote($menuType))
				->where($db->quoteName('id') . ' IN (' . implode(',', $children) . ')');
			$db->setQuery($query);

			try
			{
				$db->execute();
			}
			catch (RuntimeException $e)
			{
				$this->setError($e->getMessage());

				return false;
			}
		}

		// Clean the cache
		$this->cleanCache();

		return true;
	}

	/**
	 * Method to check if you can save a record.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key.
	 *
	 * @return  boolean
	 *
	 * @since   1.6
	 */
	protected function canSave($data = array(), $key = 'id')
	{
		return JFactory::getUser()->authorise('core.edit', $this->option);
	}

	/**
	 * Method to get the row form.
	 *
	 * @param   array    $data      Data for the form.
	 * @param   boolean  $loadData  True if the form is to load its own data (default case), false if not.
	 *
	 * @return  mixed  A JForm object on success, false on failure
	 *
	 * @since   1.6
	 */
	public function getForm($data = array(), $loadData = true)
	{
		// The folder and element vars are passed when saving the form.
		if (empty($data))
		{
			$item = $this->getItem();

			// The type should already be set.
			$this->setState('item.link', $item->link);
		}
		else
		{
			$this->setState('item.link', ArrayHelper::getValue($data, 'link'));
			$this->setState('item.type', ArrayHelper::getValue($data, 'type'));
		}

		$clientId = $this->getState('item.client_id');

		// Get the form.
		if ($clientId == 1)
		{
			$form = $this->loadForm('com_menus.item.admin', 'itemadmin', array('control' => 'jform', 'load_data' => $loadData), true);
		}
		else
		{
			$form = $this->loadForm('com_menus.item', 'item', array('control' => 'jform', 'load_data' => $loadData), true);
		}

		if (empty($form))
		{
			return false;
		}

		if ($loadData)
		{
			$data = $this->loadFormData();
		}

		// Modify the form based on access controls.
		if (!$this->canEditState((object) $data))
		{
			// Disable fields for display.
			$form->setFieldAttribute('menuordering', 'disabled', 'true');
			$form->setFieldAttribute('published', 'disabled', 'true');

			// Disable fields while saving.
			// The controller has already verified this is an article you can edit.
			$form->setFieldAttribute('menuordering', 'filter', 'unset');
			$form->setFieldAttribute('published', 'filter', 'unset');
		}

		// Filter available menus
		$action = $this->getState('item.id') > 0 ? 'edit' : 'create';

		$form->setFieldAttribute('menutype', 'accesstype', $action);
		$form->setFieldAttribute('type', 'clientid', $clientId);

		return $form;
	}

	/**
	 * Method to get the data that should be injected in the form.
	 *
	 * @return  mixed  The data for the form.
	 *
	 * @since   1.6
	 */
	protected function loadFormData()
	{

		// Check the session for previously entered form data, providing it has an ID and it is the same.
		$itemData = (array) $this->getItem();
		$sessionData = (array) JFactory::getApplication()->getUserState('com_menus.edit.item.data', array());

		// Only merge if there is a session and itemId or itemid is null.
		if (isset($sessionData['id']) && isset($itemData['id']) && $sessionData['id'] === $itemData['id']
			|| is_null($itemData['id']))
		{
			$data = array_merge($itemData, $sessionData);
		}
		else
		{
			$data = $itemData;
		}

		// For a new menu item, pre-select some filters (Status, Language, Access) in edit form if those have been selected in Menu Manager
		if ($this->getItem()->id == 0)
		{
			// Get selected fields
			$filters = JFactory::getApplication()->getUserState('com_menus.items.filter');
			$data['parent_id'] = (isset($filters['parent_id']) ? $filters['parent_id'] : null);
			$data['published'] = (isset($filters['published']) ? $filters['published'] : null);
			$data['language'] = (isset($filters['language']) ? $filters['language'] : null);
			$data['access'] = (!empty($filters['access']) ? $filters['access'] : JFactory::getConfig()->get('access'));
		}

		if (isset($data['menutype']) && !$this->getState('item.menutypeid'))
		{
			$menuTypeId = (int) $this->getMenuTypeId($data['menutype']);

			$this->setState('item.menutypeid', $menuTypeId);
		}

		$data = (object) $data;

		$this->preprocessData('com_menus.item', $data);

		return $data;
	}

	/**
	 * Get the necessary data to load an item help screen.
	 *
	 * @return  object  An object with key, url, and local properties for loading the item help screen.
	 *
	 * @since   1.6
	 */
	public function getHelp()
	{
		return (object) array('key' => $this->helpKey, 'url' => $this->helpURL, 'local' => $this->helpLocal);
	}

	/**
	 * Method to get a menu item.
	 *
	 * @param   integer  $pk  An optional id of the object to get, otherwise the id from the model state is used.
	 *
	 * @return  mixed  Menu item data object on success, false on failure.
	 *
	 * @since   1.6
	 */
	public function getItem($pk = null)
	{
		$pk = (!empty($pk)) ? $pk : (int) $this->getState('item.id');

		// Get a level row instance.
		$table = $this->getTable();

		// Attempt to load the row.
		$table->load($pk);

		// Check for a table object error.
		if ($error = $table->getError())
		{
			$this->setError($error);

			return false;
		}

		// Prime required properties.

		if ($type = $this->getState('item.type'))
		{
			$table->type = $type;
		}

		if (empty($table->id))
		{
			$table->parent_id = $this->getState('item.parent_id');
			$table->menutype  = $this->getState('item.menutype');
			$table->client_id = $this->getState('item.client_id');
			$table->params = '{}';
		}

		// If the link has been set in the state, possibly changing link type.
		if ($link = $this->getState('item.link'))
		{
			// Check if we are changing away from the actual link type.
			if (MenusHelper::getLinkKey($table->link) !== MenusHelper::getLinkKey($link) && (int) $table->id === (int) $this->getState('item.id'))
			{
				$table->link = $link;
			}
		}

		switch ($table->type)
		{
			case 'alias':
				$table->component_id = 0;
				$args = array();

				parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
				break;

			case 'separator':
			case 'heading':
			case 'container':
				$table->link = '';
				$table->component_id = 0;
				break;

			case 'url':
				$table->component_id = 0;

				$args = array();
				parse_str(parse_url($table->link, PHP_URL_QUERY), $args);
				break;

			case 'component':
			default:
				// Enforce a valid type.
				$table->type = 'component';

				// Ensure the integrity of the component_id field is maintained, particularly when changing the menu item type.
				$args = array();
				parse_str(parse_url($table->link, PHP_URL_QUERY), $args);

				if (isset($args['option']))
				{
					// Load the language file for the component.
					$lang = JFactory::getLanguage();
					$lang->load($args['option'], JPATH_ADMINISTRATOR, null, false, true)
					|| $lang->load($args['option'], JPATH_ADMINISTRATOR . '/components/' . $args['option'], null, false, true);

					// Determine the component id.
					$component = JComponentHelper::getComponent($args['option']);

					if (isset($component->id))
					{
						$table->component_id = $component->id;
					}
				}
				break;
		}

		// We have a valid type, inject it into the state for forms to use.
		$this->setState('item.type', $table->type);

		// Convert to the JObject before adding the params.
		$properties = $table->getProperties(1);
		$result = ArrayHelper::toObject($properties);

		// Convert the params field to an array.
		$registry = new Registry($table->params);
		$result->params = $registry->toArray();

		// Merge the request arguments in to the params for a component.
		if ($table->type == 'component')
		{
			// Note that all request arguments become reserved parameter names.
			$result->request = $args;
			$result->params = array_merge($result->params, $args);

			// Special case for the Login menu item.
			// Display the login or logout redirect URL fields if not empty
			if ($table->link == 'index.php?option=com_users&view=login')
			{
				if (!empty($result->params['login_redirect_url']))
				{
					$result->params['loginredirectchoice'] = '0';
				}

				if (!empty($result->params['logout_redirect_url']))
				{
					$result->params['logoutredirectchoice'] = '0';
				}
			}
		}

		if ($table->type == 'alias')
		{
			// Note that all request arguments become reserved parameter names.
			$result->params = array_merge($result->params, $args);
		}

		if ($table->type == 'url')
		{
			// Note that all request arguments become reserved parameter names.
			$result->params = array_merge($result->params, $args);
		}

		// Load associated menu items, only supported for frontend for now
		if ($this->getState('item.client_id') == 0 && JLanguageAssociations::isEnabled())
		{
			if ($pk != null)
			{
				$result->associations = MenusHelper::getAssociations($pk);
			}
			else
			{
				$result->associations = array();
			}
		}

		$result->menuordering = $pk;

		return $result;
	}

	/**
	 * Get the list of modules not in trash.
	 *
	 * @return  mixed  An array of module records (id, title, position), or false on error.
	 *
	 * @since   1.6
	 */
	public function getModules()
	{
		$db = $this->getDbo();
		$query = $db->getQuery(true);

		// Currently any setting that affects target page for a backend menu is not supported, hence load no modules.
		if ($this->getState('item.client_id') == 1)
		{
			return false;
		}

		/**
		 * Join on the module-to-menu mapping table.
		 * We are only interested if the module is displayed on ALL or THIS menu item (or the inverse ID number).
		 * sqlsrv changes for modulelink to menu manager
		 */
		$query->select('a.id, a.title, a.position, a.published, map.menuid')
			->from('#__modules AS a')
			->join('LEFT', sprintf('#__modules_menu AS map ON map.moduleid = a.id AND map.menuid IN (0, %1$d, -%1$d)', $this->getState('item.id')))
			->select('(SELECT COUNT(*) FROM #__modules_menu WHERE moduleid = a.id AND menuid < 0) AS ' . $db->quoteName('except'));

		// Join on the asset groups table.
		$query->select('ag.title AS access_title')
			->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access')
			->where('a.published >= 0')
			->where('a.client_id = ' . (int) $this->getState('item.client_id'))
			->order('a.position, a.ordering');

		$db->setQuery($query);

		try
		{
			$result = $db->loadObjectList();
		}
		catch (RuntimeException $e)
		{
			$this->setError($e->getMessage());

			return false;
		}

		return $result;
	}

	/**
	 * Get the list of all view levels
	 *
	 * @return  array|boolean  An array of all view levels (id, title).
	 *
	 * @since   3.4
	 */
	public function getViewLevels()
	{
		$db    = $this->getDbo();
		$query = $db->getQuery(true);

		// Get all the available view levels
		$query->select($db->quoteName('id'))
			->select($db->quoteName('title'))
			->from($db->quoteName('#__viewlevels'))
			->order($db->quoteName('id'));

		$db->setQuery($query);

		try
		{
			$result = $db->loadObjectList();
		}
		catch (RuntimeException $e)
		{
			$this->setError($e->getMessage());

			return false;
		}

		return $result;
	}

	/**
	 * A protected method to get the where clause for the reorder.
	 * This ensures that the row will be moved relative to a row with the same menutype.
	 *
	 * @param   JTableMenu  $table  instance.
	 *
	 * @return  array  An array of conditions to add to add to ordering queries.
	 *
	 * @since   1.6
	 */
	protected function getReorderConditions($table)
	{
		return array('menutype = ' . $this->_db->quote($table->get('menutype')));
	}

	/**
	 * Returns a Table object, always creating it
	 *
	 * @param   string  $type    The table type to instantiate.
	 * @param   string  $prefix  A prefix for the table class name. Optional.
	 * @param   array   $config  Configuration array for model. Optional.
	 *
	 * @return  JTable|JTableNested  A database object.
	 *
	 * @since   1.6
	 */
	public function getTable($type = 'Menu', $prefix = 'MenusTable', $config = array())
	{
		return JTable::getInstance($type, $prefix, $config);
	}

	/**
	 * Auto-populate the model state.
	 *
	 * Note. Calling getState in this method will result in recursion.
	 *
	 * @return  void
	 *
	 * @since   1.6
	 */
	protected function populateState()
	{
		$app = JFactory::getApplication('administrator');

		// Load the User state.
		$pk = $app->input->getInt('id');
		$this->setState('item.id', $pk);

		if (!($parentId = $app->getUserState('com_menus.edit.item.parent_id')))
		{
			$parentId = $app->input->getInt('parent_id');
		}

		$this->setState('item.parent_id', $parentId);

		$menuType = $app->getUserStateFromRequest('com_menus.items.menutype', 'menutype', '', 'string');

		// If we have a menutype we take client_id from there, unless forced otherwise
		if ($menuType)
		{
			$menuTypeObj = $this->getMenuType($menuType);

			// An invalid menutype will be handled as clientId = 0 and menuType = ''
			$menuType   = (string) $menuTypeObj->menutype;
			$menuTypeId = (int) $menuTypeObj->client_id;
			$clientId   = (int) $menuTypeObj->client_id;
		}
		else
		{
			$menuTypeId = 0;
			$clientId   = $app->getUserState('com_menus.items.client_id', 0);
		}

		// Forced client id will override/clear menuType if conflicted
		$forcedClientId = $app->input->get('client_id', null, 'string');

		// Current item if not new, we don't allow changing client id at all
		if ($pk)
		{
			$table = $this->getTable();
			$table->load($pk);
			$forcedClientId = $table->get('client_id', $forcedClientId);
		}

		if (isset($forcedClientId) && $forcedClientId != $clientId)
		{
			$clientId   = $forcedClientId;
			$menuType   = '';
			$menuTypeId = 0;
		}

		// Set the menu type and client id on the list view state, so we return to this menu after saving.
		$app->setUserState('com_menus.items.menutype', $menuType);
		$app->setUserState('com_menus.items.client_id', $clientId);

		$this->setState('item.menutype', $menuType);
		$this->setState('item.client_id', $clientId);
		$this->setState('item.menutypeid', $menuTypeId);

		if (!($type = $app->getUserState('com_menus.edit.item.type')))
		{
			$type = $app->input->get('type');

			/**
			 * Note: a new menu item will have no field type.
			 * The field is required so the user has to change it.
			 */
		}

		$this->setState('item.type', $type);

		if ($link = $app->getUserState('com_menus.edit.item.link'))
		{
			$this->setState('item.link', $link);
		}

		// Load the parameters.
		$params = JComponentHelper::getParams('com_menus');
		$this->setState('params', $params);
	}

	/**
	 * Loads the menutype object by a given menutype string
	 *
	 * @param   string  $menutype  The given menutype
	 *
	 * @return  stdClass
	 *
	 * @since   3.7.0
	 */
	protected function getMenuType($menutype)
	{
		$table = $this->getTable('MenuType', 'JTable');

		$table->load(array('menutype' => $menutype));

		return (object) $table->getProperties();
	}

	/**
	 * Loads the menutype ID by a given menutype string
	 *
	 * @param   string  $menutype  The given menutype
	 *
	 * @return  integer
	 *
	 * @since   3.6
	 */
	protected function getMenuTypeId($menutype)
	{
		$menu = $this->getMenuType($menutype);

		return (int) $menu->id;
	}

	/**
	 * Method to preprocess the form.
	 *
	 * @param   JForm   $form   A JForm object.
	 * @param   mixed   $data   The data expected for the form.
	 * @param   string  $group  The name of the plugin group to import.
	 *
	 * @return  void
	 *
	 * @since   1.6
	 * @throws  Exception if there is an error in the form event.
	 */
	protected function preprocessForm(JForm $form, $data, $group = 'content')
	{
		$link     = $this->getState('item.link');
		$type     = $this->getState('item.type');
		$clientId = $this->getState('item.client_id');
		$formFile = false;

		// Load the specific type file
		$typeFile   = $clientId == 1 ? 'itemadmin_' . $type : 'item_' . $type;
		$clientInfo = JApplicationHelper::getClientInfo($clientId);

		// Initialise form with component view params if available.
		if ($type == 'component')
		{
			$link = htmlspecialchars_decode($link);

			// Parse the link arguments.
			$args = array();
			parse_str(parse_url(htmlspecialchars_decode($link), PHP_URL_QUERY), $args);

			// Confirm that the option is defined.
			$option = '';
			$base = '';

			if (isset($args['option']))
			{
				// The option determines the base path to work with.
				$option = $args['option'];
				$base = $clientInfo->path . '/components/' . $option;
			}

			if (isset($args['view']))
			{
				$view = $args['view'];

				// Determine the layout to search for.
				if (isset($args['layout']))
				{
					$layout = $args['layout'];
				}
				else
				{
					$layout = 'default';
				}

				// Check for the layout XML file. Use standard xml file if it exists.
				$tplFolders = array(
					$base . '/views/' . $view . '/tmpl',
					$base . '/view/' . $view . '/tmpl'
				);
				$path = JPath::find($tplFolders, $layout . '.xml');

				if (is_file($path))
				{
					$formFile = $path;
				}

				// If custom layout, get the xml file from the template folder
				// template folder is first part of file name -- template:folder
				if (!$formFile && (strpos($layout, ':') > 0))
				{
					list($altTmpl, $altLayout) = explode(':', $layout);

					$templatePath = JPath::clean($clientInfo->path . '/templates/' . $altTmpl . '/html/' . $option . '/' . $view . '/' . $altLayout . '.xml');

					if (is_file($templatePath))
					{
						$formFile = $templatePath;
					}
				}
			}

			// Now check for a view manifest file
			if (!$formFile)
			{
				if (isset($view))
				{
					$metadataFolders = array(
						$base . '/view/' . $view,
						$base . '/views/' . $view
					);
					$metaPath = JPath::find($metadataFolders, 'metadata.xml');

					if (is_file($path = JPath::clean($metaPath)))
					{
						$formFile = $path;
					}
				}
				elseif ($base)
				{
					// Now check for a component manifest file
					$path = JPath::clean($base . '/metadata.xml');

					if (is_file($path))
					{
						$formFile = $path;
					}
				}
			}
		}

		if ($formFile)
		{
			// If an XML file was found in the component, load it first.
			// We need to qualify the full path to avoid collisions with component file names.

			if ($form->loadFile($formFile, true, '/metadata') == false)
			{
				throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
			}

			// Attempt to load the xml file.
			if (!$xml = simplexml_load_file($formFile))
			{
				throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
			}

			// Get the help data from the XML file if present.
			$help = $xml->xpath('/metadata/layout/help');
		}
		else
		{
			// We don't have a component. Load the form XML to get the help path
			$xmlFile = JPath::find(JPATH_ADMINISTRATOR . '/components/com_menus/models/forms', $typeFile . '.xml');

			if ($xmlFile)
			{
				if (!$xml = simplexml_load_file($xmlFile))
				{
					throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
				}

				// Get the help data from the XML file if present.
				$help = $xml->xpath('/form/help');
			}
		}

		if (!empty($help))
		{
			$helpKey = trim((string) $help[0]['key']);
			$helpURL = trim((string) $help[0]['url']);
			$helpLoc = trim((string) $help[0]['local']);

			$this->helpKey = $helpKey ?: $this->helpKey;
			$this->helpURL = $helpURL ?: $this->helpURL;
			$this->helpLocal = (($helpLoc == 'true') || ($helpLoc == '1') || ($helpLoc == 'local')) ? true : false;
		}

		if (!$form->loadFile($typeFile, true, false))
		{
			throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
		}

		// Association menu items, we currently do not support this for admin menu… may be later
		if ($clientId == 0 && JLanguageAssociations::isEnabled())
		{
			$languages = JLanguageHelper::getContentLanguages(false, true, null, 'ordering', 'asc');

			if (count($languages) > 1)
			{
				$addform = new SimpleXMLElement('<form />');
				$fields = $addform->addChild('fields');
				$fields->addAttribute('name', 'associations');
				$fieldset = $fields->addChild('fieldset');
				$fieldset->addAttribute('name', 'item_associations');

				foreach ($languages as $language)
				{
					$field = $fieldset->addChild('field');
					$field->addAttribute('name', $language->lang_code);
					$field->addAttribute('type', 'modal_menu');
					$field->addAttribute('language', $language->lang_code);
					$field->addAttribute('label', $language->title);
					$field->addAttribute('translate_label', 'false');
					$field->addAttribute('select', 'true');
					$field->addAttribute('new', 'true');
					$field->addAttribute('edit', 'true');
					$field->addAttribute('clear', 'true');
					$field->addAttribute('propagate', 'true');
					$option = $field->addChild('option', 'COM_MENUS_ITEM_FIELD_ASSOCIATION_NO_VALUE');
					$option->addAttribute('value', '');
				}

				$form->load($addform, false);
			}
		}

		// Trigger the default form events.
		parent::preprocessForm($form, $data, $group);
	}

	/**
	 * Method rebuild the entire nested set tree.
	 *
	 * @return  boolean|JException  Boolean true on success, boolean false or JException instance on error
	 *
	 * @since   1.6
	 */
	public function rebuild()
	{
		// Initialise variables.
		$db = $this->getDbo();
		$query = $db->getQuery(true);
		$table = $this->getTable();

		try
		{
			$rebuildResult = $table->rebuild();
		}
		catch (Exception $e)
		{
			$this->setError($e->getMessage());

			return false;
		}

		if (!$rebuildResult)
		{
			$this->setError($table->getError());

			return false;
		}

		$query->select('id, params')
			->from('#__menu')
			->where('params NOT LIKE ' . $db->quote('{%'))
			->where('params <> ' . $db->quote(''));
		$db->setQuery($query);

		try
		{
			$items = $db->loadObjectList();
		}
		catch (RuntimeException $e)
		{
			return JError::raiseWarning(500, $e->getMessage());
		}

		foreach ($items as &$item)
		{
			$registry = new Registry($item->params);
			$params = (string) $registry;

			$query->clear();
			$query->update('#__menu')
				->set('params = ' . $db->quote($params))
				->where('id = ' . $item->id);

			try
			{
				$db->setQuery($query)->execute();
			}
			catch (RuntimeException $e)
			{
				return JError::raiseWarning(500, $e->getMessage());
			}

			unset($registry);
		}

		// Clean the cache
		$this->cleanCache();

		return true;
	}

	/**
	 * Method to save the form data.
	 *
	 * @param   array  $data  The form data.
	 *
	 * @return  boolean  True on success.
	 *
	 * @since   1.6
	 */
	public function save($data)
	{
		$dispatcher = JEventDispatcher::getInstance();
		$pk         = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('item.id');
		$isNew      = true;
		$table   = $this->getTable();
		$context = $this->option . '.' . $this->name;

		// Include the plugins for the on save events.
		JPluginHelper::importPlugin($this->events_map['save']);

		// Load the row if saving an existing item.
		if ($pk > 0)
		{
			$table->load($pk);
			$isNew = false;
		}

		if (!$isNew)
		{
			if ($table->parent_id == $data['parent_id'])
			{
				// If first is chosen make the item the first child of the selected parent.
				if ($data['menuordering'] == -1)
				{
					$table->setLocation($data['parent_id'], 'first-child');
				}
				// If last is chosen make it the last child of the selected parent.
				elseif ($data['menuordering'] == -2)
				{
					$table->setLocation($data['parent_id'], 'last-child');
				}
				// Don't try to put an item after itself. All other ones put after the selected item.
				// $data['id'] is empty means it's a save as copy
				elseif ($data['menuordering'] && $table->id != $data['menuordering'] || empty($data['id']))
				{
					$table->setLocation($data['menuordering'], 'after');
				}
				// Just leave it where it is if no change is made.
				elseif ($data['menuordering'] && $table->id == $data['menuordering'])
				{
					unset($data['menuordering']);
				}
			}
			// Set the new parent id if parent id not matched and put in last position
			else
			{
				$table->setLocation($data['parent_id'], 'last-child');
			}
		}
		// We have a new item, so it is not a change.
		else
		{
			$menuType = $this->getMenuType($data['menutype']);

			$data['client_id'] = $menuType->client_id;

			$table->setLocation($data['parent_id'], 'last-child');
		}

		// Bind the data.
		if (!$table->bind($data))
		{
			$this->setError($table->getError());

			return false;
		}

		// Alter the title & alias for save as copy.  Also, unset the home record.
		if (!$isNew && $data['id'] == 0)
		{
			list($title, $alias) = $this->generateNewTitle($table->parent_id, $table->alias, $table->title);

			$table->title     = $title;
			$table->alias     = $alias;
			$table->published = 0;
			$table->home      = 0;
		}

		// Check the data.
		if (!$table->check())
		{
			$this->setError($table->getError());

			return false;
		}

		// Trigger the before save event.
		$result = $dispatcher->trigger($this->event_before_save, array($context, &$table, $isNew));

		// Store the data.
		if (in_array(false, $result, true)|| !$table->store())
		{
			$this->setError($table->getError());

			return false;
		}

		// Trigger the after save event.
		$dispatcher->trigger($this->event_after_save, array($context, &$table, $isNew));

		// Rebuild the tree path.
		if (!$table->rebuildPath($table->id))
		{
			$this->setError($table->getError());

			return false;
		}

		$this->setState('item.id', $table->id);
		$this->setState('item.menutype', $table->menutype);

		// Load associated menu items, for now not supported for admin menu… may be later
		if ($table->get('client_id') == 0 && JLanguageAssociations::isEnabled())
		{
			// Adding self to the association
			$associations = isset($data['associations']) ? $data['associations'] : array();

			// Unset any invalid associations
			$associations = Joomla\Utilities\ArrayHelper::toInteger($associations);

			foreach ($associations as $tag => $id)
			{
				if (!$id)
				{
					unset($associations[$tag]);
				}
			}

			// Detecting all item menus
			$all_language = $table->language == '*';

			if ($all_language && !empty($associations))
			{
				JError::raiseNotice(403, JText::_('COM_MENUS_ERROR_ALL_LANGUAGE_ASSOCIATED'));
			}

			// Get associationskey for edited item
			$db    = $this->getDbo();
			$query = $db->getQuery(true)
				->select($db->quoteName('key'))
				->from($db->quoteName('#__associations'))
				->where($db->quoteName('context') . ' = ' . $db->quote($this->associationsContext))
				->where($db->quoteName('id') . ' = ' . (int) $table->id);
			$db->setQuery($query);
			$old_key = $db->loadResult();

			// Deleting old associations for the associated items
			$query = $db->getQuery(true)
				->delete($db->quoteName('#__associations'))
				->where($db->quoteName('context') . ' = ' . $db->quote($this->associationsContext));

			if ($associations)
			{
				$query->where('(' . $db->quoteName('id') . ' IN (' . implode(',', $associations) . ') OR '
					. $db->quoteName('key') . ' = ' . $db->quote($old_key) . ')'
				);
			}
			else
			{
				$query->where($db->quoteName('key') . ' = ' . $db->quote($old_key));
			}

			$db->setQuery($query);

			try
			{
				$db->execute();
			}
			catch (RuntimeException $e)
			{
				$this->setError($e->getMessage());

				return false;
			}

			// Adding self to the association
			if (!$all_language)
			{
				$associations[$table->language] = (int) $table->id;
			}

			if (count($associations) > 1)
			{
				// Adding new association for these items
				$key = md5(json_encode($associations));
				$query->clear()
					->insert('#__associations');

				foreach ($associations as $id)
				{
					$query->values(((int) $id) . ',' . $db->quote($this->associationsContext) . ',' . $db->quote($key));
				}

				$db->setQuery($query);

				try
				{
					$db->execute();
				}
				catch (RuntimeException $e)
				{
					$this->setError($e->getMessage());

					return false;
				}
			}
		}

		// Clean the cache
		$this->cleanCache();

		if (isset($data['link']))
		{
			$base = JUri::base();
			$juri = JUri::getInstance($base . $data['link']);
			$option = $juri->getVar('option');

			// Clean the cache
			parent::cleanCache($option);
		}

		if (Factory::getApplication()->input->get('task') == 'editAssociations')
		{
			return $this->redirectToAssociations($data);
		}

		return true;
	}

	/**
	 * Method to save the reordered nested set tree.
	 * First we save the new order values in the lft values of the changed ids.
	 * Then we invoke the table rebuild to implement the new ordering.
	 *
	 * @param   array  $idArray   Rows identifiers to be reordered
	 * @param   array  $lftArray  lft values of rows to be reordered
	 *
	 * @return  boolean false on failure or error, true otherwise.
	 *
	 * @since   1.6
	 */
	public function saveorder($idArray = null, $lftArray = null)
	{
		// Get an instance of the table object.
		$table = $this->getTable();

		if (!$table->saveorder($idArray, $lftArray))
		{
			$this->setError($table->getError());

			return false;
		}

		// Clean the cache
		$this->cleanCache();

		return true;
	}

	/**
	 * Method to change the home state of one or more items.
	 *
	 * @param   array    $pks    A list of the primary keys to change.
	 * @param   integer  $value  The value of the home state.
	 *
	 * @return  boolean  True on success.
	 *
	 * @since   1.6
	 */
	public function setHome(&$pks, $value = 1)
	{
		$table = $this->getTable();
		$pks = (array) $pks;

		$languages = array();
		$onehome = false;

		// Remember that we can set a home page for different languages,
		// so we need to loop through the primary key array.
		foreach ($pks as $i => $pk)
		{
			if ($table->load($pk))
			{
				if (!array_key_exists($table->language, $languages))
				{
					$languages[$table->language] = true;

					if ($table->home == $value)
					{
						unset($pks[$i]);
						JError::raiseNotice(403, JText::_('COM_MENUS_ERROR_ALREADY_HOME'));
					}
					elseif ($table->menutype == 'main')
					{
						// Prune items that you can't change.
						unset($pks[$i]);
						JError::raiseWarning(403, JText::_('COM_MENUS_ERROR_MENUTYPE_HOME'));
					}
					else
					{
						$table->home = $value;

						if ($table->language == '*')
						{
							$table->published = 1;
						}

						if (!$this->canSave($table))
						{
							// Prune items that you can't change.
							unset($pks[$i]);
							JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED'));
						}
						elseif (!$table->check())
						{
							// Prune the items that failed pre-save checks.
							unset($pks[$i]);
							JError::raiseWarning(403, $table->getError());
						}
						elseif (!$table->store())
						{
							// Prune the items that could not be stored.
							unset($pks[$i]);
							JError::raiseWarning(403, $table->getError());
						}
					}
				}
				else
				{
					unset($pks[$i]);

					if (!$onehome)
					{
						$onehome = true;
						JError::raiseNotice(403, JText::sprintf('COM_MENUS_ERROR_ONE_HOME'));
					}
				}
			}
		}

		// Clean the cache
		$this->cleanCache();

		return true;
	}

	/**
	 * Method to change the published state of one or more records.
	 *
	 * @param   array    $pks    A list of the primary keys to change.
	 * @param   integer  $value  The value of the published state.
	 *
	 * @return  boolean  True on success.
	 *
	 * @since   1.6
	 */
	public function publish(&$pks, $value = 1)
	{
		$table = $this->getTable();
		$pks   = (array) $pks;

		// Default menu item existence checks.
		if ($value != 1)
		{
			foreach ($pks as $i => $pk)
			{
				if ($table->load($pk) && $table->home && $table->language == '*')
				{
					// Prune items that you can't change.
					JError::raiseWarning(403, JText::_('JLIB_DATABASE_ERROR_MENU_UNPUBLISH_DEFAULT_HOME'));
					unset($pks[$i]);
					break;
				}
			}
		}

		// Clean the cache
		$this->cleanCache();

		// Ensure that previous checks doesn't empty the array
		if (empty($pks))
		{
			return true;
		}

		return parent::publish($pks, $value);
	}

	/**
	 * Method to change the title & alias.
	 *
	 * @param   integer  $parentId  The id of the parent.
	 * @param   string   $alias     The alias.
	 * @param   string   $title     The title.
	 *
	 * @return  array  Contains the modified title and alias.
	 *
	 * @since   1.6
	 */
	protected function generateNewTitle($parentId, $alias, $title)
	{
		// Alter the title & alias
		$table = $this->getTable();

		while ($table->load(array('alias' => $alias, 'parent_id' => $parentId)))
		{
			if ($title == $table->title)
			{
				$title = StringHelper::increment($title);
			}

			$alias = StringHelper::increment($alias, 'dash');
		}

		return array($title, $alias);
	}

	/**
	 * Custom clean the cache
	 *
	 * @param   string   $group     Cache group name.
	 * @param   integer  $clientId  Application client id.
	 *
	 * @return  void
	 *
	 * @since   1.6
	 */
	protected function cleanCache($group = null, $clientId = 0)
	{
		parent::cleanCache('com_menus', 0);
		parent::cleanCache('com_modules');
		parent::cleanCache('mod_menu', 0);
		parent::cleanCache('mod_menu', 1);
	}
}
models/items.php000064400000041473152346104050007672 0ustar00<?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;

/**
 * Menu Item List Model for Menus.
 *
 * @since  1.6
 */
class MenusModelItems extends JModelList
{
	/**
	 * Constructor.
	 *
	 * @param   array  $config  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',
				'menutype', 'a.menutype', 'menutype_title',
				'title', 'a.title',
				'alias', 'a.alias',
				'published', 'a.published',
				'access', 'a.access', 'access_level',
				'language', 'a.language',
				'checked_out', 'a.checked_out',
				'checked_out_time', 'a.checked_out_time',
				'lft', 'a.lft',
				'rgt', 'a.rgt',
				'level', 'a.level',
				'path', 'a.path',
				'client_id', 'a.client_id',
				'home', 'a.home',
				'parent_id', 'a.parent_id',
				'a.ordering'
			);

			$app = JFactory::getApplication();
			$assoc = JLanguageAssociations::isEnabled();

			if ($assoc)
			{
				$config['filter_fields'][] = 'association';
			}
		}

		parent::__construct($config);
	}

	/**
	 * 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 = 'a.lft', $direction = 'asc')
	{
		$app = JFactory::getApplication('administrator');
		$user = JFactory::getUser();

		$forcedLanguage = $app->input->get('forcedLanguage', '', 'cmd');

		// Adjust the context to support modal layouts.
		if ($layout = $app->input->get('layout'))
		{
			$this->context .= '.' . $layout;
		}

		// Adjust the context to support forced languages.
		if ($forcedLanguage)
		{
			$this->context .= '.' . $forcedLanguage;
		}

		$search = $this->getUserStateFromRequest($this->context . '.search', 'filter_search');
		$this->setState('filter.search', $search);

		$published = $this->getUserStateFromRequest($this->context . '.published', 'filter_published', '');
		$this->setState('filter.published', $published);

		$access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access');
		$this->setState('filter.access', $access);

		$parentId = $this->getUserStateFromRequest($this->context . '.filter.parent_id', 'filter_parent_id');
		$this->setState('filter.parent_id', $parentId);

		$level = $this->getUserStateFromRequest($this->context . '.filter.level', 'filter_level');
		$this->setState('filter.level', $level);

		// Watch changes in client_id and menutype and keep sync whenever needed.
		$currentClientId = $app->getUserState($this->context . '.client_id', 0);
		$clientId        = $app->input->getInt('client_id', $currentClientId);

		// Load mod_menu.ini file when client is administrator
		if ($clientId == 1)
		{
			JFactory::getLanguage()->load('mod_menu', JPATH_ADMINISTRATOR, null, false, true);
		}

		$currentMenuType = $app->getUserState($this->context . '.menutype', '');
		$menuType        = $app->input->getString('menutype', $currentMenuType);

		// If client_id changed clear menutype and reset pagination
		if ($clientId != $currentClientId)
		{
			$menuType = '';

			$app->input->set('limitstart', 0);
			$app->input->set('menutype', '');
		}

		// If menutype changed reset pagination.
		if ($menuType != $currentMenuType)
		{
			$app->input->set('limitstart', 0);
		}

		if (!$menuType)
		{
			$app->setUserState($this->context . '.menutype', '');
			$this->setState('menutypetitle', '');
			$this->setState('menutypeid', '');
		}
		// Special menu types, if selected explicitly, will be allowed as a filter
		elseif ($menuType == 'main')
		{
			// Adjust client_id to match the menutype. This is safe as client_id was not changed in this request.
			$app->input->set('client_id', 1);

			$app->setUserState($this->context . '.menutype', $menuType);
			$this->setState('menutypetitle', ucfirst($menuType));
			$this->setState('menutypeid', -1);
		}
		// Get the menutype object with appropriate checks.
		elseif ($cMenu = $this->getMenu($menuType, true))
		{
			// Adjust client_id to match the menutype. This is safe as client_id was not changed in this request.
			$app->input->set('client_id', $cMenu->client_id);

			$app->setUserState($this->context . '.menutype', $menuType);
			$this->setState('menutypetitle', $cMenu->title);
			$this->setState('menutypeid', $cMenu->id);
		}
		// This menutype does not exist, leave client id unchanged but reset menutype and pagination
		else
		{
			$menuType = '';

			$app->input->set('limitstart', 0);
			$app->input->set('menutype', $menuType);

			$app->setUserState($this->context . '.menutype', $menuType);
			$this->setState('menutypetitle', '');
			$this->setState('menutypeid', '');
		}

		// Client id filter
		$clientId = (int) $this->getUserStateFromRequest($this->context . '.client_id', 'client_id', 0, 'int');
		$this->setState('filter.client_id', $clientId);

		// Use a different filter file when client is administrator
		if ($clientId == 1)
		{
			$this->filterFormName = 'filter_itemsadmin';
		}

		$this->setState('filter.menutype', $menuType);

		$language = $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '');
		$this->setState('filter.language', $language);

		// Component parameters.
		$params = JComponentHelper::getParams('com_menus');
		$this->setState('params', $params);

		// List state information.
		parent::populateState($ordering, $direction);

		// Force a language.
		if (!empty($forcedLanguage))
		{
			$this->setState('filter.language', $forcedLanguage);
		}
	}

	/**
	 * Method to get a store id based on model configuration state.
	 *
	 * This is necessary because the model is used by the component and
	 * different modules that might need different sets of data or different
	 * ordering requirements.
	 *
	 * @param   string  $id  A prefix for the store id.
	 *
	 * @return  string  A store id.
	 *
	 * @since   1.6
	 */
	protected function getStoreId($id = '')
	{
		// Compile the store id.
		$id .= ':' . $this->getState('filter.access');
		$id .= ':' . $this->getState('filter.published');
		$id .= ':' . $this->getState('filter.language');
		$id .= ':' . $this->getState('filter.search');
		$id .= ':' . $this->getState('filter.parent_id');
		$id .= ':' . $this->getState('filter.menutype');
		$id .= ':' . $this->getState('filter.client_id');

		return parent::getStoreId($id);
	}

	/**
	 * Builds an SQL query to load the list data.
	 *
	 * @return  JDatabaseQuery    A query object.
	 *
	 * @since   1.6
	 */
	protected function getListQuery()
	{
		// Create a new query object.
		$db = $this->getDbo();
		$query = $db->getQuery(true);
		$user = JFactory::getUser();
		$app = JFactory::getApplication();

		// Select all fields from the table.
		$query->select(
			$this->getState(
				'list.select',
				$db->quoteName(
					array(
						'a.id', 'a.menutype', 'a.title', 'a.alias', 'a.note', 'a.path', 'a.link', 'a.type', 'a.parent_id',
						'a.level', 'a.published', 'a.component_id', 'a.checked_out', 'a.checked_out_time', 'a.browserNav',
						'a.access', 'a.img', 'a.template_style_id', 'a.params', 'a.lft', 'a.rgt', 'a.home', 'a.language', 'a.client_id'
					),
					array(
						null, null, null, null, null, null, null, null, null,
						null, 'a.published', null, null, null, null,
						null, null, null, null, null, null, null, null, null
					)
				)
			)
		);
		$query->select(
			'CASE ' .
				' WHEN a.type = ' . $db->quote('component') . ' THEN a.published+2*(e.enabled-1) ' .
				' WHEN a.type = ' . $db->quote('url') . ' AND a.published != -2 THEN a.published+2 ' .
				' WHEN a.type = ' . $db->quote('url') . ' AND a.published = -2 THEN a.published-1 ' .
				' WHEN a.type = ' . $db->quote('alias') . ' AND a.published != -2 THEN a.published+4 ' .
				' WHEN a.type = ' . $db->quote('alias') . ' AND a.published = -2 THEN a.published-1 ' .
				' WHEN a.type = ' . $db->quote('separator') . ' AND a.published != -2 THEN a.published+6 ' .
				' WHEN a.type = ' . $db->quote('separator') . ' AND a.published = -2 THEN a.published-1 ' .
				' WHEN a.type = ' . $db->quote('heading') . ' AND a.published != -2 THEN a.published+8 ' .
				' WHEN a.type = ' . $db->quote('heading') . ' AND a.published = -2 THEN a.published-1 ' .
				' WHEN a.type = ' . $db->quote('container') . ' AND a.published != -2 THEN a.published+8 ' .
				' WHEN a.type = ' . $db->quote('container') . ' AND a.published = -2 THEN a.published-1 ' .
			' END AS published '
		);
		$query->from($db->quoteName('#__menu') . ' AS a');

		// Join over the language
		$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');

		// Join over the users.
		$query->select('u.name AS editor')
			->join('LEFT', $db->quoteName('#__users') . ' AS u ON u.id = a.checked_out');

		// Join over components
		$query->select('c.element AS componentname')
			->join('LEFT', $db->quoteName('#__extensions') . ' AS c ON c.extension_id = a.component_id');

		// Join over the asset groups.
		$query->select('ag.title AS access_level')
			->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');

		// Join over the menu types.
		$query->select($db->quoteName(array('mt.id', 'mt.title'), array('menutype_id', 'menutype_title')))
			->join('LEFT', $db->quoteName('#__menu_types', 'mt') . ' ON ' . $db->qn('mt.menutype') . ' = ' . $db->qn('a.menutype'));

		// Join over the associations.
		$assoc = JLanguageAssociations::isEnabled();

		if ($assoc)
		{
			$subQuery = $db->getQuery(true)
				->select('COUNT(' . $db->quoteName('asso1.id') . ') > 1')
				->from($db->quoteName('#__associations', 'asso1'))
				->join('INNER', $db->quoteName('#__associations', 'asso2') . ' ON ' . $db->quoteName('asso1.key') . ' = ' . $db->quoteName('asso2.key'))
				->where(
					array(
						$db->quoteName('asso1.id') . ' = ' . $db->quoteName('a.id'),
						$db->quoteName('asso1.context') . ' = ' . $db->quote('com_menus.item'),
					)
				);

			$query->select('(' . $subQuery . ') AS ' . $db->quoteName('association'));
		}

		// Join over the extensions
		$query->select('e.name AS name')
			->join('LEFT', '#__extensions AS e ON e.extension_id = a.component_id');

		// Exclude the root category.
		$query->where('a.id > 1')
			->where('a.client_id = ' . (int) $this->getState('filter.client_id'));

		// Filter on the published state.
		$published = $this->getState('filter.published');

		if (is_numeric($published))
		{
			$query->where('a.published = ' . (int) $published);
		}
		elseif ($published === '')
		{
			$query->where('a.published IN (0, 1)');
		}

		// Filter by search in title, alias or id
		if ($search = trim($this->getState('filter.search')))
		{
			if (stripos($search, 'id:') === 0)
			{
				$query->where('a.id = ' . (int) substr($search, 3));
			}
			elseif (stripos($search, 'link:') === 0)
			{
				if ($search = substr($search, 5))
				{
					$search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%'));
					$query->where('a.link LIKE ' . $search);
				}
			}
			else
			{
				$search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%'));
				$query->where('(' . 'a.title LIKE ' . $search . ' OR a.alias LIKE ' . $search . ' OR a.note LIKE ' . $search . ')');
			}
		}

		// Filter the items over the parent id if set.
		$parentId = $this->getState('filter.parent_id');

		if (!empty($parentId))
		{
			$level = $this->getState('filter.level');

			// Create a subquery for the sub-items list
			$subQuery = $db->getQuery(true)
				->select('sub.id')
				->from('#__menu as sub')
				->join('INNER', '#__menu as this ON sub.lft > this.lft AND sub.rgt < this.rgt')
				->where('this.id = ' . (int) $parentId);

			if ($level)
			{
				$subQuery->where('sub.level <= this.level + ' . (int) ($level - 1));
			}

			// Add the subquery to the main query
			$query->where('(a.parent_id = ' . (int) $parentId . ' OR a.parent_id IN (' . (string) $subQuery . '))');
		}

		// Filter on the level.
		elseif ($level = $this->getState('filter.level'))
		{
			$query->where('a.level <= ' . (int) $level);
		}

		// Filter the items over the menu id if set.
		$menuType = $this->getState('filter.menutype');

		// A value "" means all
		if ($menuType == '')
		{
			// Load all menu types we have manage access
			$query2 = $this->getDbo()->getQuery(true)
				->select($this->getDbo()->qn(array('id', 'menutype')))
				->from('#__menu_types')
				->where('client_id = ' . (int) $this->getState('filter.client_id'))
				->order('title');

			// Show protected items on explicit filter only
			$query->where('a.menutype != ' . $db->q('main'));

			$menuTypes = $this->getDbo()->setQuery($query2)->loadObjectList();

			if ($menuTypes)
			{
				$types = array();

				foreach ($menuTypes as $type)
				{
					if ($user->authorise('core.manage', 'com_menus.menu.' . (int) $type->id))
					{
						$types[] = $query->q($type->menutype);
					}
				}

				$query->where($types ? 'a.menutype IN(' . implode(',', $types) . ')' : 0);
			}
		}
		// Default behavior => load all items from a specific menu
		elseif (strlen($menuType))
		{
			$query->where('a.menutype = ' . $db->quote($menuType));
		}
		// Empty menu type => error
		else
		{
			$query->where('1 != 1');
		}

		// Filter on the access level.
		if ($access = $this->getState('filter.access'))
		{
			$query->where('a.access = ' . (int) $access);
		}

		// Implement View Level Access
		if (!$user->authorise('core.admin'))
		{
			$groups = $user->getAuthorisedViewLevels();

			if (!empty($groups))
			{
				$query->where('a.access IN (' . implode(',', $groups) . ')');
			}
		}

		// Filter on the language.
		if ($language = $this->getState('filter.language'))
		{
			$query->where('a.language = ' . $db->quote($language));
		}

		// Add the list ordering clause.
		$query->order($db->escape($this->getState('list.ordering', 'a.lft')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));

		return $query;
	}

	/**
	 * Method to allow derived classes to preprocess the form.
	 *
	 * @param   JForm   $form   A JForm object.
	 * @param   mixed   $data   The data expected for the form.
	 * @param   string  $group  The name of the plugin group to import (defaults to "content").
	 *
	 * @return  void
	 *
	 * @since   3.2
	 * @throws  Exception if there is an error in the form event.
	 */
	protected function preprocessForm(JForm $form, $data, $group = 'content')
	{
		$name = $form->getName();

		if ($name == 'com_menus.items.filter')
		{
			$clientId = $this->getState('filter.client_id');
			$form->setFieldAttribute('menutype', 'clientid', $clientId);
		}
		elseif (false !== strpos($name, 'com_menus.items.modal.'))
		{
			$form->removeField('client_id');

			$clientId = $this->getState('filter.client_id');
			$form->setFieldAttribute('menutype', 'clientid', $clientId);
		}
	}

	/**
	 * Get the client id for a menu
	 *
	 * @param   string   $menuType  The menutype identifier for the menu
	 * @param   boolean  $check     Flag whether to perform check against ACL as well as existence
	 *
	 * @return  integer
	 *
	 * @since   3.7.0
	 */
	protected function getMenu($menuType, $check = false)
	{
		$query = $this->_db->getQuery(true);

		$query->select('a.*')
			->from($this->_db->qn('#__menu_types', 'a'))
			->where('menutype = ' . $this->_db->q($menuType));

		$cMenu = $this->_db->setQuery($query)->loadObject();

		if ($check)
		{
			// Check if menu type exists.
			if (!$cMenu)
			{
				JLog::add(JText::_('COM_MENUS_ERROR_MENUTYPE_NOT_FOUND'), JLog::ERROR, 'jerror');

				return false;
			}
			// Check if menu type is valid against ACL.
			elseif (!JFactory::getUser()->authorise('core.manage', 'com_menus.menu.' . $cMenu->id))
			{
				JLog::add(JText::_('JERROR_ALERTNOAUTHOR'), JLog::ERROR, 'jerror');

				return false;
			}
		}

		return $cMenu;
	}

	/**
	 * Method to get an array of data items.
	 *
	 * @return  mixed  An array of data items on success, false on failure.
	 *
	 * @since   3.0.1
	 */
	public function getItems()
	{
		$store = $this->getStoreId();

		if (!isset($this->cache[$store]))
		{
			$items = parent::getItems();
			$lang  = JFactory::getLanguage();
			$client = $this->state->get('filter.client_id');

			if ($items)
			{
				foreach ($items as $item)
				{
					if ($extension = $item->componentname)
					{
						$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, true)
						|| $lang->load("$extension.sys", JPATH_ADMINISTRATOR . '/components/' . $extension, null, false, true);
					}

					// Translate component name
					if ($client === 1)
					{
						$item->title = JText::_($item->title);
					}
				}
			}

			$this->cache[$store] = $items;
		}

		return $this->cache[$store];
	}
}
models/menu.php000064400000020602152346104050007504 0ustar00<?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;

use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;

/**
 * Menu Item Model for Menus.
 *
 * @since  1.6
 */
class MenusModelMenu extends JModelForm
{
	/**
	 * The prefix to use with controller messages.
	 *
	 * @var    string
	 * @since  1.6
	 */
	protected $text_prefix = 'COM_MENUS_MENU';

	/**
	 * Model context string.
	 *
	 * @var  string
	 */
	protected $_context = 'com_menus.menu';

	/**
	 * Method to test whether a record can be deleted.
	 *
	 * @param   object  $record  A record object.
	 *
	 * @return  boolean  True if allowed to delete the record. Defaults to the permission set in the component.
	 *
	 * @since   1.6
	 */
	protected function canDelete($record)
	{
		return JFactory::getUser()->authorise('core.delete', 'com_menus.menu.' . (int) $record->id);
	}

	/**
	 * Method to test whether the state of a record can be edited.
	 *
	 * @param   object  $record  A record object.
	 *
	 * @return  boolean  True if allowed to change the state of the record. Defaults to the permission set in the component.
	 *
	 * @since   1.6
	 */
	protected function canEditState($record)
	{
		$user = JFactory::getUser();

		return $user->authorise('core.edit.state', 'com_menus.menu.' . (int) $record->id);
	}

	/**
	 * Returns a Table object, always creating it
	 *
	 * @param   string  $type    The table type to instantiate
	 * @param   string  $prefix  A prefix for the table class name. Optional.
	 * @param   array   $config  Configuration array for model. Optional.
	 *
	 * @return  JTable  A database object
	 *
	 * @since   1.6
	 */
	public function getTable($type = 'MenuType', $prefix = 'JTable', $config = array())
	{
		return JTable::getInstance($type, $prefix, $config);
	}

	/**
	 * Auto-populate the model state.
	 *
	 * Note. Calling getState in this method will result in recursion.
	 *
	 * @return  void
	 *
	 * @since   1.6
	 */
	protected function populateState()
	{
		$app = JFactory::getApplication('administrator');

		// Load the User state.
		$id = $app->input->getInt('id');
		$this->setState('menu.id', $id);

		// Load the parameters.
		$params = JComponentHelper::getParams('com_menus');
		$this->setState('params', $params);
	}

	/**
	 * Method to get a menu item.
	 *
	 * @param   integer  $itemId  The id of the menu item to get.
	 *
	 * @return  mixed  Menu item data object on success, false on failure.
	 *
	 * @since   1.6
	 */
	public function &getItem($itemId = null)
	{
		$itemId = (!empty($itemId)) ? $itemId : (int) $this->getState('menu.id');

		// Get a menu item row instance.
		$table = $this->getTable();

		// Attempt to load the row.
		$return = $table->load($itemId);

		// Check for a table object error.
		if ($return === false && $table->getError())
		{
			$this->setError($table->getError());

			return false;
		}

		$properties = $table->getProperties(1);
		$value      = ArrayHelper::toObject($properties, 'JObject');

		return $value;
	}

	/**
	 * Method to get the menu item form.
	 *
	 * @param   array    $data      Data for the form.
	 * @param   boolean  $loadData  True if the form is to load its own data (default case), false if not.
	 *
	 * @return  JForm    A JForm object on success, false on failure
	 *
	 * @since   1.6
	 */
	public function getForm($data = array(), $loadData = true)
	{
		// Get the form.
		$form = $this->loadForm('com_menus.menu', 'menu', array('control' => 'jform', 'load_data' => $loadData));

		if (empty($form))
		{
			return false;
		}

		return $form;
	}

	/**
	 * Method to get the data that should be injected in the form.
	 *
	 * @return  mixed  The data for the form.
	 *
	 * @since   1.6
	 */
	protected function loadFormData()
	{
		// Check the session for previously entered form data.
		$data = JFactory::getApplication()->getUserState('com_menus.edit.menu.data', array());

		if (empty($data))
		{
			$data = $this->getItem();
		}
		else
		{
			unset($data['preset']);
		}

		$this->preprocessData('com_menus.menu', $data);

		return $data;
	}

	/**
	 * Method to validate the form data.
	 *
	 * @param   JForm   $form   The form to validate against.
	 * @param   array   $data   The data to validate.
	 * @param   string  $group  The name of the field group to validate.
	 *
	 * @return  array|boolean  Array of filtered data if valid, false otherwise.
	 *
	 * @see     JFormRule
	 * @see     JFilterInput
	 * @since   3.9.23
	 */
	public function validate($form, $data, $group = null)
	{
		if (!JFactory::getUser()->authorise('core.admin', 'com_menus'))
		{
			if (isset($data['rules']))
			{
				unset($data['rules']);
			}
		}

		return parent::validate($form, $data, $group);
	}

	/**
	 * Method to save the form data.
	 *
	 * @param   array  $data  The form data.
	 *
	 * @return  boolean  True on success.
	 *
	 * @since   1.6
	 */
	public function save($data)
	{
		$dispatcher = JEventDispatcher::getInstance();
		$id         = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('menu.id');
		$isNew      = true;

		// Get a row instance.
		$table = $this->getTable();

		// Include the plugins for the save events.
		JPluginHelper::importPlugin('content');

		// Load the row if saving an existing item.
		if ($id > 0)
		{
			$isNew = false;
			$table->load($id);
		}

		// Bind the data.
		if (!$table->bind($data))
		{
			$this->setError($table->getError());

			return false;
		}

		// Check the data.
		if (!$table->check())
		{
			$this->setError($table->getError());

			return false;
		}

		// Trigger the before event.
		$result = $dispatcher->trigger('onContentBeforeSave', array($this->_context, &$table, $isNew));

		// Store the data.
		if (in_array(false, $result, true) || !$table->store())
		{
			$this->setError($table->getError());

			return false;
		}

		// Trigger the after save event.
		$dispatcher->trigger('onContentAfterSave', array($this->_context, &$table, $isNew));

		$this->setState('menu.id', $table->id);

		// Clean the cache
		$this->cleanCache();

		return true;
	}

	/**
	 * Method to delete groups.
	 *
	 * @param   array  $itemIds  An array of item ids.
	 *
	 * @return  boolean  Returns true on success, false on failure.
	 *
	 * @since   1.6
	 */
	public function delete($itemIds)
	{
		$dispatcher = JEventDispatcher::getInstance();

		// Sanitize the ids.
		$itemIds = ArrayHelper::toInteger((array) $itemIds);

		// Get a group row instance.
		$table = $this->getTable();

		// Include the plugins for the delete events.
		JPluginHelper::importPlugin('content');

		// Iterate the items to delete each one.
		foreach ($itemIds as $itemId)
		{
			if ($table->load($itemId))
			{
				// Trigger the before delete event.
				$result = $dispatcher->trigger('onContentBeforeDelete', array($this->_context, $table));

				if (in_array(false, $result, true) || !$table->delete($itemId))
				{
					$this->setError($table->getError());

					return false;
				}

				// Trigger the after delete event.
				$dispatcher->trigger('onContentAfterDelete', array($this->_context, $table));

				// TODO: Delete the menu associations - Menu items and Modules
			}
		}

		// Clean the cache
		$this->cleanCache();

		return true;
	}

	/**
	 * Gets a list of all mod_mainmenu modules and collates them by menutype
	 *
	 * @return  array
	 *
	 * @since   1.6
	 */
	public function &getModules()
	{
		$db = $this->getDbo();

		$query = $db->getQuery(true)
			->from('#__modules as a')
			->select('a.id, a.title, a.params, a.position')
			->where('module = ' . $db->quote('mod_menu'))
			->select('ag.title AS access_title')
			->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
		$db->setQuery($query);

		$modules = $db->loadObjectList();

		$result = array();

		foreach ($modules as &$module)
		{
			$params = new Registry($module->params);

			$menuType = $params->get('menutype');

			if (!isset($result[$menuType]))
			{
				$result[$menuType] = array();
			}

			$result[$menuType][] = & $module;
		}

		return $result;
	}

	/**
	 * Custom clean the cache
	 *
	 * @param   string   $group     Cache group name.
	 * @param   integer  $clientId  Application client id.
	 *
	 * @return  void
	 *
	 * @since   1.6
	 */
	protected function cleanCache($group = null, $clientId = 0)
	{
		parent::cleanCache('com_menus', 0);
		parent::cleanCache('com_modules');
		parent::cleanCache('mod_menu', 0);
		parent::cleanCache('mod_menu', 1);
	}
}
models/menus.php000064400000013636152346104050007700 0ustar00<?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;

/**
 * Menu List Model for Menus.
 *
 * @since  1.6
 */
class MenusModelMenus extends JModelList
{
	/**
	 * Constructor.
	 *
	 * @param   array  $config  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',
				'client_id', 'a.client_id',
			);
		}

		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 empty 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 = ArrayHelper::getColumn((array) $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);

		try
		{
			$countPublished = $db->loadAssocList('menutype', 'count_published');
		}
		catch (RuntimeException $e)
		{
			$this->setError($e->getMessage());

			return false;
		}

		// Get the unpublished menu counts.
		$query->clear('where')
			->where('m.published = 0')
			->where('m.menutype IN (' . $menuTypes . ')');
		$db->setQuery($query);

		try
		{
			$countUnpublished = $db->loadAssocList('menutype', 'count_published');
		}
		catch (RuntimeException $e)
		{
			$this->setError($e->getMessage());

			return false;
		}

		// Get the trashed menu counts.
		$query->clear('where')
			->where('m.published = -2')
			->where('m.menutype IN (' . $menuTypes . ')');
		$db->setQuery($query);

		try
		{
			$countTrashed = $db->loadAssocList('menutype', 'count_published');
		}
		catch (RuntimeException $e)
		{
			$this->setError($e->getMessage());

			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.id, a.menutype, a.title, a.description, a.client_id'))
			->from($db->quoteName('#__menu_types') . ' AS a')
			->where('a.id > 0');

		$query->where('a.client_id = ' . (int) $this->getState('client_id'));

		// Filter by search in title or menutype
		if ($search = trim($this->getState('filter.search')))
		{
			$search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%'));
			$query->where('(' . 'a.title LIKE ' . $search . ' OR a.menutype LIKE ' . $search . ')');
		}

		// 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 = 'a.title', $direction = 'asc')
	{
		$search   = $this->getUserStateFromRequest($this->context . '.search', 'filter_search');
		$this->setState('filter.search', $search);

		$clientId = (int) $this->getUserStateFromRequest($this->context . '.client_id', 'client_id', 0, 'int');
		$this->setState('client_id', $clientId);

		// List state information.
		parent::populateState($ordering, $direction);
	}

	/**
	 * 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)
			->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 = ' . (int) $this->getState('client_id'));
		$db->setQuery($query);

		return $db->loadResult();
	}

	/**
	 * Gets a list of all mod_mainmenu modules and collates them by menutype
	 *
	 * @return  array
	 *
	 * @since   1.6
	 */
	public function &getModules()
	{
		$model = JModelLegacy::getInstance('Menu', 'MenusModel', array('ignore_request' => true));
		$result = $model->getModules();

		return $result;
	}
}
models/menutypes.php000064400000036050152346104050010575 0ustar00<?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;

jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.path');
/**
 * Menu Item Types Model for Menus.
 *
 * @since  1.6
 */
class MenusModelMenutypes extends JModelLegacy
{
	/**
	 * A reverse lookup of the base link URL to Title
	 *
	 * @var  array
	 */
	protected $rlu = array();

	/**
	 * Method to auto-populate the model state.
	 *
	 * This method should only be called once per instantiation and is designed
	 * to be called on the first call to the getState() method unless the model
	 * configuration flag to ignore the request is set.
	 *
	 * @return  void
	 *
	 * @note    Calling getState in this method will result in recursion.
	 * @since   3.0.1
	 */
	protected function populateState()
	{
		parent::populateState();

		$app      = JFactory::getApplication();
		$clientId = $app->input->get('client_id', 0);

		$this->state->set('client_id', $clientId);
	}

	/**
	 * Method to get the reverse lookup of the base link URL to Title
	 *
	 * @return  array  Array of reverse lookup of the base link URL to Title
	 *
	 * @since   1.6
	 */
	public function getReverseLookup()
	{
		if (empty($this->rlu))
		{
			$this->getTypeOptions();
		}

		return $this->rlu;
	}

	/**
	 * Method to get the available menu item type options.
	 *
	 * @return  array  Array of groups with menu item types.
	 *
	 * @since   1.6
	 */
	public function getTypeOptions()
	{
		jimport('joomla.filesystem.file');

		$lang = JFactory::getLanguage();
		$list = array();

		// Get the list of components.
		$db    = $this->getDbo();
		$query = $db->getQuery(true)
			->select('name, element AS ' . $db->quoteName('option'))
			->from('#__extensions')
			->where('type = ' . $db->quote('component'))
			->where('enabled = 1')
			->order('name ASC');
		$db->setQuery($query);
		$components = $db->loadObjectList();

		foreach ($components as $component)
		{
			$options = $this->getTypeOptionsByComponent($component->option);

			if ($options)
			{
				$list[$component->name] = $options;

				// Create the reverse lookup for link-to-name.
				foreach ($options as $option)
				{
					if (isset($option->request))
					{
						$this->addReverseLookupUrl($option);

						if (isset($option->request['option']))
						{
							$componentLanguageFolder = JPATH_ADMINISTRATOR . '/components/' . $option->request['option'];
							$lang->load($option->request['option'] . '.sys', JPATH_ADMINISTRATOR, null, false, true)
								||	$lang->load($option->request['option'] . '.sys', $componentLanguageFolder, null, false, true);
						}
					}
				}
			}
		}

		// Allow a system plugin to insert dynamic menu types to the list shown in menus:
		JEventDispatcher::getInstance()->trigger('onAfterGetMenuTypeOptions', array(&$list, $this));

		return $list;
	}

	/**
	 * Method to create the reverse lookup for link-to-name.
	 * (can be used from onAfterGetMenuTypeOptions handlers)
	 *
	 * @param   JObject  $option  with request array or string and title public variables
	 *
	 * @return  void
	 *
	 * @since   3.1
	 */
	public function addReverseLookupUrl($option)
	{
		$this->rlu[MenusHelper::getLinkKey($option->request)] = $option->get('title');
	}

	/**
	 * Get menu types by component.
	 *
	 * @param   string  $component  Component URL option.
	 *
	 * @return  array
	 *
	 * @since   1.6
	 */
	protected function getTypeOptionsByComponent($component)
	{
		$options = array();
		$client  = JApplicationHelper::getClientInfo($this->getState('client_id'));
		$mainXML = $client->path . '/components/' . $component . '/metadata.xml';

		if (is_file($mainXML))
		{
			$options = $this->getTypeOptionsFromXml($mainXML, $component);
		}

		if (empty($options))
		{
			$options = $this->getTypeOptionsFromMvc($component);
		}

		if ($client->id == 1 && empty($options))
		{
			$options = $this->getTypeOptionsFromManifest($component);
		}

		return $options;
	}

	/**
	 * Get the menu types from an XML file
	 *
	 * @param   string  $file       File path
	 * @param   string  $component  Component option as in URL
	 *
	 * @return  array|boolean
	 *
	 * @since   1.6
	 */
	protected function getTypeOptionsFromXml($file, $component)
	{
		$options = array();

		// Attempt to load the xml file.
		if (!$xml = simplexml_load_file($file))
		{
			return false;
		}

		// Look for the first menu node off of the root node.
		if (!$menu = $xml->xpath('menu[1]'))
		{
			return false;
		}
		else
		{
			$menu = $menu[0];
		}

		// If we have no options to parse, just add the base component to the list of options.
		if (!empty($menu['options']) && $menu['options'] == 'none')
		{
			// Create the menu option for the component.
			$o = new JObject;
			$o->title       = (string) $menu['name'];
			$o->description = (string) $menu['msg'];
			$o->request     = array('option' => $component);

			$options[] = $o;

			return $options;
		}

		// Look for the first options node off of the menu node.
		if (!$optionsNode = $menu->xpath('options[1]'))
		{
			return false;
		}
		else
		{
			$optionsNode = $optionsNode[0];
		}

		// Make sure the options node has children.
		if (!$children = $optionsNode->children())
		{
			return false;
		}

		// Process each child as an option.
		foreach ($children as $child)
		{
			if ($child->getName() == 'option')
			{
				// Create the menu option for the component.
				$o = new JObject;
				$o->title       = (string) $child['name'];
				$o->description = (string) $child['msg'];
				$o->request     = array('option' => $component, (string) $optionsNode['var'] => (string) $child['value']);

				$options[] = $o;
			}
			elseif ($child->getName() == 'default')
			{
				// Create the menu option for the component.
				$o = new JObject;
				$o->title       = (string) $child['name'];
				$o->description = (string) $child['msg'];
				$o->request     = array('option' => $component);

				$options[] = $o;
			}
		}

		return $options;
	}

	/**
	 * Get menu types from MVC
	 *
	 * @param   string  $component  Component option like in URLs
	 *
	 * @return  array|boolean
	 *
	 * @since   1.6
	 */
	protected function getTypeOptionsFromMvc($component)
	{
		$options = array();
		$client  = JApplicationHelper::getClientInfo($this->getState('client_id'));

		// Get the views for this component.
		if (is_dir($client->path . '/components/' . $component))
		{
			$folders = JFolder::folders($client->path . '/components/' . $component, '^view[s]?$', false, true);
		}

		$path = '';

		if (!empty($folders[0]))
		{
			$path = $folders[0];
		}

		if (is_dir($path))
		{
			$views = JFolder::folders($path);
		}
		else
		{
			return false;
		}

		foreach ($views as $view)
		{
			// Ignore private views.
			if (strpos($view, '_') !== 0)
			{
				// Determine if a metadata file exists for the view.
				$file = $path . '/' . $view . '/metadata.xml';

				if (is_file($file))
				{
					// Attempt to load the xml file.
					if ($xml = simplexml_load_file($file))
					{
						// Look for the first view node off of the root node.
						if ($menu = $xml->xpath('view[1]'))
						{
							$menu = $menu[0];

							// If the view is hidden from the menu, discard it and move on to the next view.
							if (!empty($menu['hidden']) && $menu['hidden'] == 'true')
							{
								unset($xml);
								continue;
							}

							// Do we have an options node or should we process layouts?
							// Look for the first options node off of the menu node.
							if ($optionsNode = $menu->xpath('options[1]'))
							{
								$optionsNode = $optionsNode[0];

								// Make sure the options node has children.
								if ($children = $optionsNode->children())
								{
									// Process each child as an option.
									foreach ($children as $child)
									{
										if ($child->getName() == 'option')
										{
											// Create the menu option for the component.
											$o = new JObject;
											$o->title       = (string) $child['name'];
											$o->description = (string) $child['msg'];
											$o->request     = array('option' => $component, 'view' => $view, (string) $optionsNode['var'] => (string) $child['value']);

											$options[] = $o;
										}
										elseif ($child->getName() == 'default')
										{
											// Create the menu option for the component.
											$o = new JObject;
											$o->title       = (string) $child['name'];
											$o->description = (string) $child['msg'];
											$o->request     = array('option' => $component, 'view' => $view);

											$options[] = $o;
										}
									}
								}
							}
							else
							{
								$options = array_merge($options, (array) $this->getTypeOptionsFromLayouts($component, $view));
							}
						}

						unset($xml);
					}
				}
				else
				{
					$options = array_merge($options, (array) $this->getTypeOptionsFromLayouts($component, $view));
				}
			}
		}

		return $options;
	}

	/**
	 * Get menu types from Component manifest
	 *
	 * @param   string  $component  Component option like in URLs
	 *
	 * @return  array|boolean
	 *
	 * @since   3.7.0
	 */
	protected function getTypeOptionsFromManifest($component)
	{
		// Load the component manifest
		$fileName = JPATH_ADMINISTRATOR . '/components/' . $component . '/' . str_replace('com_', '', $component) . '.xml';

		if (!is_file($fileName))
		{
			return false;
		}

		if (!($manifest = simplexml_load_file($fileName)))
		{
			return false;
		}

		// Check for a valid XML root tag.
		if ($manifest->getName() != 'extension')
		{
			return false;
		}

		$options = array();

		// Start with the component root menu.
		$rootMenu = $manifest->administration->menu;

		// If the menu item doesn't exist or is hidden do nothing.
		if (!$rootMenu || in_array((string) $rootMenu['hidden'], array('true', 'hidden')))
		{
			return $options;
		}

		// Create the root menu option.
		$ro = new stdClass;
		$ro->title       = (string) trim($rootMenu);
		$ro->description = '';
		$ro->request     = array('option' => $component);

		// Process submenu options.
		$submenu = $manifest->administration->submenu;

		if (!$submenu)
		{
			return $options;
		}

		foreach ($submenu->menu as $child)
		{
			$attributes = $child->attributes();

			$o = new stdClass;
			$o->title       = (string) trim($child);
			$o->description = '';

			if ((string) $attributes->link)
			{
				parse_str((string) $attributes->link, $request);
			}
			else
			{
				$request = array();

				$request['option']     = $component;
				$request['act']        = (string) $attributes->act;
				$request['task']       = (string) $attributes->task;
				$request['controller'] = (string) $attributes->controller;
				$request['view']       = (string) $attributes->view;
				$request['layout']     = (string) $attributes->layout;
				$request['sub']        = (string) $attributes->sub;
			}

			$o->request = array_filter($request, 'strlen');
			$options[]  = new JObject($o);

			// Do not repeat the default view link (index.php?option=com_abc).
			if (count($o->request) == 1)
			{
				$ro = null;
			}
		}

		if ($ro)
		{
			$options[] = new JObject($ro);
		}

		return $options;
	}

	/**
	 * Get the menu types from component layouts
	 *
	 * @param   string  $component  Component option as in URLs
	 * @param   string  $view       Name of the view
	 *
	 * @return  array
	 *
	 * @since   1.6
	 */
	protected function getTypeOptionsFromLayouts($component, $view)
	{
		$options     = array();
		$layouts     = array();
		$layoutNames = array();
		$lang        = JFactory::getLanguage();
		$path        = '';
		$client      = JApplicationHelper::getClientInfo($this->getState('client_id'));

		// Get the views for this component.
		if (is_dir($client->path . '/components/' . $component))
		{
			$folders = JFolder::folders($client->path . '/components/' . $component, '^view[s]?$', false, true);
		}

		if (!empty($folders[0]))
		{
			$path = $folders[0] . '/' . $view . '/tmpl';
		}

		if (is_dir($path))
		{
			$layouts = array_merge($layouts, JFolder::files($path, '.xml$', false, true));
		}
		else
		{
			return $options;
		}

		// Build list of standard layout names
		foreach ($layouts as $layout)
		{
			// Ignore private layouts.
			if (strpos(basename($layout), '_') === false)
			{
				// Get the layout name.
				$layoutNames[] = basename($layout, '.xml');
			}
		}

		// Get the template layouts
		// TODO: This should only search one template -- the current template for this item (default of specified)
		$folders = JFolder::folders($client->path . '/templates', '', false, true);

		// Array to hold association between template file names and templates
		$templateName = array();

		foreach ($folders as $folder)
		{
			if (is_dir($folder . '/html/' . $component . '/' . $view))
			{
				$template = basename($folder);
				$lang->load('tpl_' . $template . '.sys', $client->path, null, false, true)
				|| $lang->load('tpl_' . $template . '.sys', $client->path . '/templates/' . $template, null, false, true);

				$templateLayouts = JFolder::files($folder . '/html/' . $component . '/' . $view, '.xml$', false, true);

				foreach ($templateLayouts as $layout)
				{
					// Get the layout name.
					$templateLayoutName = basename($layout, '.xml');

					// Add to the list only if it is not a standard layout
					if (array_search($templateLayoutName, $layoutNames) === false)
					{
						$layouts[] = $layout;

						// Set template name array so we can get the right template for the layout
						$templateName[$layout] = basename($folder);
					}
				}
			}
		}

		// Process the found layouts.
		foreach ($layouts as $layout)
		{
			// Ignore private layouts.
			if (strpos(basename($layout), '_') === false)
			{
				$file = $layout;

				// Get the layout name.
				$layout = basename($layout, '.xml');

				// Create the menu option for the layout.
				$o = new JObject;
				$o->title       = ucfirst($layout);
				$o->description = '';
				$o->request     = array('option' => $component, 'view' => $view);

				// Only add the layout request argument if not the default layout.
				if ($layout != 'default')
				{
					// If the template is set, add in format template:layout so we save the template name
					$o->request['layout'] = isset($templateName[$file]) ? $templateName[$file] . ':' . $layout : $layout;
				}

				// Load layout metadata if it exists.
				if (is_file($file))
				{
					// Attempt to load the xml file.
					if ($xml = simplexml_load_file($file))
					{
						// Look for the first view node off of the root node.
						if ($menu = $xml->xpath('layout[1]'))
						{
							$menu = $menu[0];

							// If the view is hidden from the menu, discard it and move on to the next view.
							if (!empty($menu['hidden']) && $menu['hidden'] == 'true')
							{
								unset($xml);
								unset($o);
								continue;
							}

							// Populate the title and description if they exist.
							if (!empty($menu['title']))
							{
								$o->title = trim((string) $menu['title']);
							}

							if (!empty($menu->message[0]))
							{
								$o->description = trim((string) $menu->message[0]);
							}
						}
					}
				}

				// Add the layout to the options array.
				$options[] = $o;
			}
		}

		return $options;
	}
}
presets/joomla.xml000064400000035627152346104050010251 0ustar00<?xml version="1.0"?>
<menu
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="urn:joomla.org"
	xsi:schemaLocation="urn:joomla.org menu.xsd">
	<menuitem
		title="MOD_MENU_SYSTEM"
		type="heading"
		>
		<menuitem
			type="component"
			title="MOD_MENU_CONTROL_PANEL"
			link="index.php"
			element="com_cpanel"
			class="class:cpanel"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_CONFIGURATION"
			type="component"
			element="com_config"
			link="index.php?option=com_config"
			class="class:config"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_GLOBAL_CHECKIN"
			type="component"
			element="com_checkin"
			link="index.php?option=com_checkin"
			class="class:checkin"
		/>
		<menuitem
			title="MOD_MENU_CLEAR_CACHE"
			type="component"
			element="com_cache"
			link="index.php?option=com_cache"
			class="class:clear"
		/>
		<menuitem
			title="MOD_MENU_PURGE_EXPIRED_CACHE"
			type="component"
			element="com_cache"
			link="index.php?option=com_cache&amp;view=purge"
			class="class:purge"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_SYSTEM_INFORMATION"
			type="component"
			element="com_admin"
			link="index.php?option=com_admin&amp;view=sysinfo"
			class="class:info"
		/>
	</menuitem>
	<menuitem
		title="MOD_MENU_COM_USERS_USERS"
		type="heading"
		>
		<menuitem
			title="MOD_MENU_COM_USERS_USER_MANAGER"
			type="component"
			element="com_users"
			link="index.php?option=com_users&amp;view=users"
			class="class:user">
			<menuitem
				title="MOD_MENU_COM_USERS_ADD_USER"
				type="component"
				element="com_users"
				link="index.php?option=com_users&amp;task=user.add"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			title="MOD_MENU_COM_USERS_GROUPS"
			type="component"
			element="com_users"
			link="index.php?option=com_users&amp;view=groups"
			class="class:groups">
			<menuitem
				title="MOD_MENU_COM_USERS_ADD_GROUP"
				type="component"
				element="com_users"
				link="index.php?option=com_users&amp;task=group.add"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			title="MOD_MENU_COM_USERS_LEVELS"
			type="component"
			element="com_users"
			link="index.php?option=com_users&amp;view=levels"
			class="class:levels">
			<menuitem
				title="MOD_MENU_COM_USERS_ADD_LEVEL"
				type="component"
				element="com_users"
				link="index.php?option=com_users&amp;task=level.add"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_FIELDS"
			type="component"
			element="com_fields"
			link="index.php?option=com_fields&amp;context=com_users.user"
			class="class:fields"
		/>
		<menuitem
			title="MOD_MENU_FIELDS_GROUP"
			type="component"
			element="com_fields"
			link="index.php?option=com_fields&amp;view=groups&amp;context=com_users.user"
			class="class:category"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_COM_USERS_NOTES"
			type="component"
			element="com_users"
			link="index.php?option=com_users&amp;view=notes"
			class="class:user-note">
			<menuitem
				title="MOD_MENU_COM_USERS_ADD_NOTE"
				type="component"
				element="com_users"
				link="index.php?option=com_users&amp;task=note.add"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			title="MOD_MENU_COM_USERS_NOTE_CATEGORIES"
			type="component"
			element="com_categories"
			link="index.php?option=com_categories&amp;view=categories&amp;extension=com_users"
			class="class:category">
			<menuitem
				title="MOD_MENU_COM_CONTENT_NEW_CATEGORY"
				type="component"
				element="com_categories"
				link="index.php?option=com_categories&amp;task=category.add&amp;extension=com_users"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_COM_PRIVACY"
			type="component"
			element="com_privacy"
			link="index.php?option=com_privacy"
			class="class:privacy"
		/>
		<menuitem
			title="MOD_MENU_COM_ACTIONLOGS"
			type="component"
			element="com_actionlogs"
			link="index.php?option=com_actionlogs"
			class="class:userlogs"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_MASS_MAIL_USERS"
			type="component"
			element="com_users"
			link="index.php?option=com_users&amp;view=mail"
			class="class:massmail"
			scope="massmail"
		/>
	</menuitem>
	<menuitem
		title="MOD_MENU_MENUS"
		type="heading"
		>
		<menuitem
			title="MOD_MENU_MENU_MANAGER"
			type="component"
			element="com_menus"
			link="index.php?option=com_menus&amp;view=menus"
			class="class:menumgr">
			<menuitem
				title="MOD_MENU_MENU_MANAGER_NEW_MENU"
				type="component"
				element="com_menus"
				link="index.php?option=com_menus&amp;view=menu&amp;layout=edit"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_MENUS_ALL_ITEMS"
			type="component"
			element="com_menus"
			link="index.php?option=com_menus&amp;view=items&amp;menutype="
			class="class:allmenu"
		/>
		<!--
		Following is an example of repeatable group based on simple database query.
		This requires sql_* attributes (sql_select and sql_from are required)
		The values can be used like - "{sql:columnName}" in any attribute of repeated elements.
		The repeated elements are place inside this xml node but they will be populated in the same level in the rendered menu
		-->
		<menuitem
			type="separator"
			title="JSITE"
			hidden="false"
			sql_select="a.title, a.menutype, CASE COALESCE(SUM(m.home), 0) WHEN 0 THEN '' WHEN 1 THEN CASE m.language WHEN '*' THEN 'class:icon-home' ELSE CONCAT('image:mod_languages/', l.image, '.gif') END ELSE 'image:mod_languages/icon-16-language.png' END AS icon"
			sql_from="#__menu_types AS a"
			sql_where="a.client_id = 0"
			sql_leftjoin="#__menu AS m ON m.menutype = a.menutype AND m.home = 1 LEFT JOIN #__languages AS l ON l.lang_code = m.language"
			sql_group="a.id, m.language, l.image"
			sql_order="a.title ASC">
			<menuitem
				title="{sql:title} "
				type="component"
				element="com_menus"
				link="index.php?option=com_menus&amp;view=items&amp;menutype={sql:menutype}"
				icon="{sql:icon}"
				class="class:menu">
				<menuitem
					title="MOD_MENU_MENU_MANAGER_NEW_MENU_ITEM"
					type="component"
					element="com_menus"
					link="index.php?option=com_menus&amp;view=item&amp;layout=edit&amp;menutype={sql:menutype}"
					class="class:menu"
					scope="edit"
				/>
			</menuitem>
		</menuitem>
		<menuitem
			type="separator"
			title="JADMINISTRATOR"
			hidden="false"
			sql_select="title, menutype"
			sql_from="#__menu_types"
			sql_where="client_id = 1"
			sql_order="title ASC">
			<menuitem
				title="{sql:title}"
				type="component"
				element="com_menus"
				link="index.php?option=com_menus&amp;view=items&amp;menutype={sql:menutype}"
				class="class:menu">
				<menuitem
					title="MOD_MENU_MENU_MANAGER_NEW_MENU_ITEM"
					type="component"
					element="com_menus"
					link="index.php?option=com_menus&amp;view=item&amp;layout=edit&amp;menutype={sql:menutype}"
					class="class:menu"
					scope="edit"
				/>
			</menuitem>
		</menuitem>
	</menuitem>
	<menuitem
		title="MOD_MENU_COM_CONTENT"
		type="heading"
		>
		<menuitem
			title="MOD_MENU_COM_CONTENT_ARTICLE_MANAGER"
			type="component"
			element="com_content"
			link="index.php?option=com_content"
			class="class:article">
			<menuitem
				title="MOD_MENU_COM_CONTENT_NEW_ARTICLE"
				type="component"
				element="com_content"
				link="index.php?option=com_content&amp;task=article.add"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			title="MOD_MENU_COM_CONTENT_CATEGORY_MANAGER"
			type="component"
			element="com_categories"
			link="index.php?option=com_categories&amp;extension=com_content"
			class="class:category">
			<menuitem
				title="MOD_MENU_COM_CONTENT_NEW_CATEGORY"
				type="component"
				element="com_categories"
				link="index.php?option=com_categories&amp;task=category.add&amp;extension=com_content"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			title="MOD_MENU_COM_CONTENT_FEATURED"
			type="component"
			element="com_content"
			link="index.php?option=com_content&amp;view=featured"
			class="class:featured"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_FIELDS"
			type="component"
			element="com_fields"
			link="index.php?option=com_fields&amp;context=com_content.article"
			class="class:fields"
		/>
		<menuitem
			title="MOD_MENU_FIELDS_GROUP"
			type="component"
			element="com_fields"
			link="index.php?option=com_fields&amp;view=groups&amp;context=com_content.article"
			class="class:category"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_MEDIA_MANAGER"
			type="component"
			element="com_media"
			link="index.php?option=com_media"
			class="class:media"
		/>
	</menuitem>
	<menuitem
		title="MOD_MENU_COMPONENTS"
		type="container"
	/>
	<menuitem
		title="MOD_MENU_EXTENSIONS_EXTENSIONS"
		type="heading"
		>
		<menuitem
			title="MOD_MENU_EXTENSIONS_EXTENSION_MANAGER"
			type="component"
			element="com_installer"
			link="index.php?option=com_installer&amp;view=manage"
			class="class:install">
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_INSTALL"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=install"
				class="class:install"
			/>
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_UPDATE"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=update"
				class="class:install"
			/>
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_MANAGE"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=manage"
				class="class:install"
			/>
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_DISCOVER"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=discover"
				class="class:install"
			/>
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_DATABASE"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=database"
				class="class:install"
			/>
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_WARNINGS"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=warnings"
				class="class:install"
			/>
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_LANGUAGES"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=languages"
				class="class:install"
			/>
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_UPDATESITES"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=updatesites"
				class="class:install"
			/>
		</menuitem>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_EXTENSIONS_MODULE_MANAGER"
			type="component"
			element="com_modules"
			link="index.php?option=com_modules"
			class="class:module"
		/>
		<menuitem
			title="MOD_MENU_EXTENSIONS_PLUGIN_MANAGER"
			type="component"
			element="com_plugins"
			link="index.php?option=com_plugins"
			class="class:plugin"
		/>
		<menuitem
			title="MOD_MENU_EXTENSIONS_TEMPLATE_MANAGER"
			type="component"
			element="com_templates"
			link="index.php?option=com_templates"
			class="class:themes">
			<menuitem
				title="MOD_MENU_COM_TEMPLATES_SUBMENU_STYLES"
				type="component"
				element="com_templates"
				link="index.php?option=com_templates&amp;view=styles"
				class="class:themes"
			/>
			<menuitem
				title="MOD_MENU_COM_TEMPLATES_SUBMENU_TEMPLATES"
				type="component"
				element="com_templates"
				link="index.php?option=com_templates&amp;view=templates"
				class="class:themes"
			/>
		</menuitem>
		<menuitem
			title="MOD_MENU_EXTENSIONS_LANGUAGE_MANAGER"
			type="component"
			element="com_languages"
			link="index.php?option=com_languages"
			class="class:language">
			<menuitem
				title="MOD_MENU_COM_LANGUAGES_SUBMENU_INSTALLED"
				type="component"
				element="com_languages"
				link="index.php?option=com_languages&amp;view=installed"
				class="class:language"
			/>
			<menuitem
				title="MOD_MENU_COM_LANGUAGES_SUBMENU_CONTENT"
				type="component"
				element="com_languages"
				link="index.php?option=com_languages&amp;view=languages"
				class="class:language"
			/>
			<menuitem
				title="MOD_MENU_COM_LANGUAGES_SUBMENU_OVERRIDES"
				type="component"
				element="com_languages"
				link="index.php?option=com_languages&amp;view=overrides"
				class="class:language"
			/>
		</menuitem>
	</menuitem>
	<menuitem
		title="MOD_MENU_HELP"
		type="heading"
		>
		<menuitem
			type="component"
			title="MOD_MENU_HELP_JOOMLA"
			element="com_admin"
			link="index.php?option=com_admin&amp;view=help"
			class="class:help"
			scope="help"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_SUPPORT_OFFICIAL_FORUM"
			link="https://forum.joomla.org"
			class="class:help-forum"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_SUPPORT_CUSTOM_FORUM"
			link="special:custom-forum"
			class="class:help-forum"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_SUPPORT_OFFICIAL_LANGUAGE_FORUM"
			link="special:language-forum"
			class="class:help-forum"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_DOCUMENTATION"
			link="https://docs.joomla.org"
			class="class:help-docs"
			scope="help"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_EXTENSIONS"
			link="https://extensions.joomla.org"
			class="class:help-jed"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_TRANSLATIONS"
			link="https://community.joomla.org/translations.html"
			class="class:help-trans"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_RESOURCES"
			link="https://community.joomla.org/service-providers-directory/"
			class="class:help-jrd"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_COMMUNITY"
			link="https://community.joomla.org"
			class="class:help-community"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_SECURITY"
			link="https://developer.joomla.org/security-centre.html"
			class="class:help-security"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_DEVELOPER"
			link="https://developer.joomla.org"
			class="class:help-dev"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_XCHANGE"
			link="https://joomla.stackexchange.com"
			class="class:help-dev"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_SHOP"
			link="https://community.joomla.org/the-joomla-shop.html"
			class="class:help-shop"
			scope="help"
		/>
	</menuitem>
</menu>
presets/menu.xsd000064400000005421152346104050007717 0ustar00<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
	attributeFormDefault="unqualified" elementFormDefault="qualified"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	targetNamespace="urn:joomla.org"
	xmlns="urn:joomla.org">
	<xs:element name="menu" type="menuType"/>
	<xs:simpleType name="typeType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="component" />
			<xs:enumeration value="container" />
			<xs:enumeration value="heading" />
			<xs:enumeration value="separator" />
			<xs:enumeration value="url" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="elementType">
		<xs:restriction base="xs:string">
			<xs:pattern value="com_(.+)" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="scopeType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="default" />
			<xs:enumeration value="edit" />
			<xs:enumeration value="help" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="trueFalse">
		<xs:restriction base="xs:string">
			<xs:enumeration value="true" />
			<xs:enumeration value="false"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="browserNavType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="_blank" />
			<xs:enumeration value=""/>
		</xs:restriction>
	</xs:simpleType>
	<xs:complexType name="menuType">
		<xs:sequence>
			<xs:element type="menuitemType" name="menuitem" maxOccurs="unbounded" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="menuitemType" mixed="true">
		<xs:sequence>
			<xs:element type="xs:string" name="params" minOccurs="0" maxOccurs="1"/>
			<xs:element type="menuitemType" name="menuitem" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute type="typeType" name="type" use="required"/>
		<xs:attribute type="xs:string" name="title" use="optional"/>
		<xs:attribute type="xs:string" name="link" use="optional"/>
		<xs:attribute type="xs:string" name="class" use="optional"/>
		<xs:attribute type="xs:string" name="icon" use="optional"/>
		<xs:attribute type="elementType" name="element" use="optional"/>
		<xs:attribute type="trueFalse" name="hidden" use="optional" default="false"/>
		<xs:attribute type="xs:string" name="sql_select" use="optional"/>
		<xs:attribute type="xs:string" name="sql_from" use="optional"/>
		<xs:attribute type="xs:string" name="sql_where" use="optional"/>
		<xs:attribute type="xs:string" name="sql_leftjoin" use="optional"/>
		<xs:attribute type="xs:string" name="sql_innerjoin" use="optional"/>
		<xs:attribute type="xs:string" name="sql_group" use="optional"/>
		<xs:attribute type="xs:string" name="sql_order" use="optional"/>
		<xs:attribute type="browserNavType" name="target" use="optional" default=""/>
		<xs:attribute type="scopeType" name="scope" use="optional" default="default"/>
	</xs:complexType>
</xs:schema>
presets/modern.xml000064400000037106152346104050010246 0ustar00<?xml version="1.0"?>
<menu
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="urn:joomla.org"
	xsi:schemaLocation="urn:joomla.org menu.xsd">
	<menuitem
		title="MOD_MENU_SYSTEM"
		type="heading"
		>
		<menuitem
			type="component"
			title="MOD_MENU_CONTROL_PANEL"
			link="index.php"
			element="com_cpanel"
			class="class:cpanel"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_CONFIGURATION"
			type="component"
			element="com_config"
			link="index.php?option=com_config"
			class="class:config"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_GLOBAL_CHECKIN"
			type="component"
			element="com_checkin"
			link="index.php?option=com_checkin"
			class="class:checkin"
		/>
		<menuitem
			title="MOD_MENU_CLEAR_CACHE"
			type="component"
			element="com_cache"
			link="index.php?option=com_cache"
			class="class:clear"
		/>
		<menuitem
			title="MOD_MENU_PURGE_EXPIRED_CACHE"
			type="component"
			element="com_cache"
			link="index.php?option=com_cache&amp;view=purge"
			class="class:purge"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_SYSTEM_INFORMATION"
			type="component"
			element="com_admin"
			link="index.php?option=com_admin&amp;view=sysinfo"
			class="class:info"
		/>
	</menuitem>
	<menuitem
		title="MOD_MENU_COM_USERS_USERS"
		type="heading"
		>
		<menuitem
			title="MOD_MENU_COM_USERS_USER_MANAGER"
			type="component"
			element="com_users"
			link="index.php?option=com_users&amp;view=users"
			class="class:user">
			<menuitem
				title="MOD_MENU_COM_USERS_ADD_USER"
				type="component"
				element="com_users"
				link="index.php?option=com_users&amp;task=user.add"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			title="MOD_MENU_COM_USERS_GROUPS"
			type="component"
			element="com_users"
			link="index.php?option=com_users&amp;view=groups"
			class="class:groups">
			<menuitem
				title="MOD_MENU_COM_USERS_ADD_GROUP"
				type="component"
				element="com_users"
				link="index.php?option=com_users&amp;task=group.add"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			title="MOD_MENU_COM_USERS_LEVELS"
			type="component"
			element="com_users"
			link="index.php?option=com_users&amp;view=levels"
			class="class:levels">
			<menuitem
				title="MOD_MENU_COM_USERS_ADD_LEVEL"
				type="component"
				element="com_users"
				link="index.php?option=com_users&amp;task=level.add"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_FIELDS"
			type="component"
			element="com_fields"
			link="index.php?option=com_fields&amp;context=com_users.user"
			class="class:fields"
		/>
		<menuitem
			title="MOD_MENU_FIELDS_GROUP"
			type="component"
			element="com_fields"
			link="index.php?option=com_fields&amp;view=groups&amp;context=com_users.user"
			class="class:category"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_COM_USERS_NOTES"
			type="component"
			element="com_users"
			link="index.php?option=com_users&amp;view=notes"
			class="class:user-note">
			<menuitem
				title="MOD_MENU_COM_USERS_ADD_NOTE"
				type="component"
				element="com_users"
				link="index.php?option=com_users&amp;task=note.add"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			title="MOD_MENU_COM_USERS_NOTE_CATEGORIES"
			type="component"
			element="com_categories"
			link="index.php?option=com_categories&amp;view=categories&amp;extension=com_users"
			class="class:category">
			<menuitem
				title="MOD_MENU_COM_CONTENT_NEW_CATEGORY"
				type="component"
				element="com_categories"
				link="index.php?option=com_categories&amp;task=category.add&amp;extension=com_users"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_COM_PRIVACY"
			type="component"
			element="com_privacy"
			link="index.php?option=com_privacy"
			class="class:privacy"
		/>
		<menuitem
			title="MOD_MENU_COM_ACTIONLOGS"
			type="component"
			element="com_actionlogs"
			link="index.php?option=com_actionlogs"
			class="class:userlogs"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_MASS_MAIL_USERS"
			type="component"
			element="com_users"
			link="index.php?option=com_users&amp;view=mail"
			class="class:massmail"
			scope="massmail"
		/>
	</menuitem>
	<menuitem
		title="MOD_MENU_MENUS"
		type="heading"
		>
		<menuitem
			title="MOD_MENU_MENU_MANAGER"
			type="component"
			element="com_menus"
			link="index.php?option=com_menus&amp;view=menus"
			class="class:menumgr">
			<menuitem
				title="MOD_MENU_MENU_MANAGER_NEW_MENU"
				type="component"
				element="com_menus"
				link="index.php?option=com_menus&amp;view=menu&amp;layout=edit"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_MENUS_ALL_ITEMS"
			type="component"
			element="com_menus"
			link="index.php?option=com_menus&amp;view=items&amp;menutype="
			class="class:allmenu"
		/>
		<!--
		Following is an example of repeatable group based on simple database query.
		This requires sql_* attributes (sql_select and sql_from are required)
		The values can be used like - "{sql:columnName}" in any attribute of repeated elements.
		The repeated elements are place inside this xml node but they will be populated in the same level in the rendered menu
		-->
		<menuitem
			type="separator"
			title="JSITE"
			hidden="false"
			sql_select="a.title, a.menutype, CASE COALESCE(SUM(m.home), 0) WHEN 0 THEN '' WHEN 1 THEN CASE m.language WHEN '*' THEN 'class:icon-home' ELSE CONCAT('image:mod_languages/', l.image, '.gif') END ELSE 'image:mod_languages/icon-16-language.png' END AS icon"
			sql_from="#__menu_types AS a"
			sql_where="a.client_id = 0"
			sql_leftjoin="#__menu AS m ON m.menutype = a.menutype AND m.home = 1 LEFT JOIN #__languages AS l ON l.lang_code = m.language"
			sql_group="a.id, m.language, l.image"
			sql_order="a.title ASC">
			<menuitem
				title="{sql:title} "
				type="component"
				element="com_menus"
				link="index.php?option=com_menus&amp;view=items&amp;menutype={sql:menutype}"
				icon="{sql:icon}"
				class="class:menu">
				<menuitem
					title="MOD_MENU_MENU_MANAGER_NEW_MENU_ITEM"
					type="component"
					element="com_menus"
					link="index.php?option=com_menus&amp;view=item&amp;layout=edit&amp;menutype={sql:menutype}"
					class="class:menu"
					scope="edit"
				/>
			</menuitem>
		</menuitem>
		<menuitem
			type="separator"
			title="JADMINISTRATOR"
			hidden="false"
			sql_select="title, menutype"
			sql_from="#__menu_types"
			sql_where="client_id = 1"
			sql_order="title ASC">
			<menuitem
				title="{sql:title}"
				type="component"
				element="com_menus"
				link="index.php?option=com_menus&amp;view=items&amp;menutype={sql:menutype}"
				class="class:menu">
				<menuitem
					title="MOD_MENU_MENU_MANAGER_NEW_MENU_ITEM"
					type="component"
					element="com_menus"
					link="index.php?option=com_menus&amp;view=item&amp;layout=edit&amp;menutype={sql:menutype}"
					class="class:menu"
					scope="edit"
				/>
			</menuitem>
		</menuitem>
	</menuitem>
	<menuitem
		title="MOD_MENU_COM_CONTENT"
		type="heading"
		>
		<menuitem
			title="MOD_MENU_COM_CONTENT_ARTICLE_MANAGER"
			type="component"
			element="com_content"
			link="index.php?option=com_content"
			class="class:article">
			<menuitem
				title="MOD_MENU_COM_CONTENT_NEW_ARTICLE"
				type="component"
				element="com_content"
				link="index.php?option=com_content&amp;task=article.add"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			title="MOD_MENU_COM_CONTENT_CATEGORY_MANAGER"
			type="component"
			element="com_categories"
			link="index.php?option=com_categories&amp;extension=com_content"
			class="class:category">
			<menuitem
				title="MOD_MENU_COM_CONTENT_NEW_CATEGORY"
				type="component"
				element="com_categories"
				link="index.php?option=com_categories&amp;task=category.add&amp;extension=com_content"
				class="class:newarticle"
				scope="edit"
			/>
		</menuitem>
		<menuitem
			title="MOD_MENU_COM_CONTENT_FEATURED"
			type="component"
			element="com_content"
			link="index.php?option=com_content&amp;view=featured"
			class="class:featured"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_FIELDS"
			type="component"
			element="com_fields"
			link="index.php?option=com_fields&amp;context=com_content.article"
			class="class:fields"
		/>
		<menuitem
			title="MOD_MENU_FIELDS_GROUP"
			type="component"
			element="com_fields"
			link="index.php?option=com_fields&amp;view=groups&amp;context=com_content.article"
			class="class:category"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_MEDIA_MANAGER"
			type="component"
			element="com_media"
			link="index.php?option=com_media"
			class="class:media"
		/>
	</menuitem>
	<menuitem
		title="MOD_MENU_COMPONENTS"
		type="container"
	>
		<params><![CDATA[{"hideitems":["com_joomlaupdate","com_postinstall"]}]]></params>
	</menuitem>
	<menuitem
		title="MOD_MENU_EXTENSIONS_EXTENSION_MANAGER"
		type="heading"
	>
		<menuitem
			title="COM_JOOMLAUPDATE"
			type="component"
			element="com_joomlaupdate"
			link="index.php?option=com_joomlaupdate"
			class="class:component"
		/>
		<menuitem
			title="COM_POSTINSTALL"
			type="component"
			element="com_postinstall"
			link="index.php?option=com_postinstall"
			class="class:component"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_SYSTEM"
			type="component"
			element="com_installer"
			link="index.php?option=com_installer&amp;view=database"
			class="class:install">

			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_DATABASE"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=database"
				class="class:install"
			/>
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_WARNINGS"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=warnings"
				class="class:install"
			/>
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_UPDATESITES"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=updatesites"
				class="class:install"
			/>
		</menuitem>
		<menuitem
			title="MOD_MENU_EXTENSIONS_EXTENSIONS"
			type="component"
			element="com_installer"
			link="index.php?option=com_installer&amp;view=manage"
			class="class:install">
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_INSTALL"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=install"
				class="class:install"
			/>
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_UPDATE"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=update"
				class="class:install"
			/>
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_MANAGE"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=manage"
				class="class:install"
			/>
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_DISCOVER"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=discover"
				class="class:install"
			/>
			<menuitem
				type="separator"
			/>
			<menuitem
				title="MOD_MENU_INSTALLER_SUBMENU_LANGUAGES"
				type="component"
				element="com_installer"
				link="index.php?option=com_installer&amp;view=languages"
				class="class:install"
			/>
		</menuitem>
		<menuitem
			type="separator"
		/>
		<menuitem
			title="MOD_MENU_EXTENSIONS_MODULE_MANAGER"
			type="component"
			element="com_modules"
			link="index.php?option=com_modules"
			class="class:module"
		/>
		<menuitem
			title="MOD_MENU_EXTENSIONS_PLUGIN_MANAGER"
			type="component"
			element="com_plugins"
			link="index.php?option=com_plugins"
			class="class:plugin"
		/>
		<menuitem
			title="MOD_MENU_EXTENSIONS_TEMPLATE_MANAGER"
			type="component"
			element="com_templates"
			link="index.php?option=com_templates"
			class="class:themes">
			<menuitem
				title="MOD_MENU_COM_TEMPLATES_SUBMENU_STYLES"
				type="component"
				element="com_templates"
				link="index.php?option=com_templates&amp;view=styles"
				class="class:themes"
			/>
			<menuitem
				title="MOD_MENU_COM_TEMPLATES_SUBMENU_TEMPLATES"
				type="component"
				element="com_templates"
				link="index.php?option=com_templates&amp;view=templates"
				class="class:themes"
			/>
		</menuitem>
		<menuitem
			title="MOD_MENU_EXTENSIONS_LANGUAGE_MANAGER"
			type="component"
			element="com_languages"
			link="index.php?option=com_languages"
			class="class:language">
			<menuitem
				title="MOD_MENU_COM_LANGUAGES_SUBMENU_INSTALLED"
				type="component"
				element="com_languages"
				link="index.php?option=com_languages&amp;view=installed"
				class="class:language"
			/>
			<menuitem
				title="MOD_MENU_COM_LANGUAGES_SUBMENU_CONTENT"
				type="component"
				element="com_languages"
				link="index.php?option=com_languages&amp;view=languages"
				class="class:language"
			/>
			<menuitem
				title="MOD_MENU_COM_LANGUAGES_SUBMENU_OVERRIDES"
				type="component"
				element="com_languages"
				link="index.php?option=com_languages&amp;view=overrides"
				class="class:language"
			/>
		</menuitem>
	</menuitem>
	<menuitem
		title="MOD_MENU_HELP"
		type="heading"
		>
		<menuitem
			type="component"
			title="MOD_MENU_HELP_JOOMLA"
			element="com_admin"
			link="index.php?option=com_admin&amp;view=help"
			class="class:help"
			scope="help"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_SUPPORT_OFFICIAL_FORUM"
			link="https://forum.joomla.org"
			class="class:help-forum"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_SUPPORT_CUSTOM_FORUM"
			link="special:custom-forum"
			class="class:help-forum"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_SUPPORT_OFFICIAL_LANGUAGE_FORUM"
			link="special:language-forum"
			class="class:help-forum"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_DOCUMENTATION"
			link="https://docs.joomla.org"
			class="class:help-docs"
			scope="help"
		/>
		<menuitem
			type="separator"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_EXTENSIONS"
			link="https://extensions.joomla.org"
			class="class:help-jed"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_TRANSLATIONS"
			link="https://community.joomla.org/translations.html"
			class="class:help-trans"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_RESOURCES"
			link="https://community.joomla.org/service-providers-directory/"
			class="class:help-jrd"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_COMMUNITY"
			link="https://community.joomla.org"
			class="class:help-community"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_SECURITY"
			link="https://developer.joomla.org/security-centre.html"
			class="class:help-security"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_DEVELOPER"
			link="https://developer.joomla.org"
			class="class:help-dev"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_XCHANGE"
			link="https://joomla.stackexchange.com"
			class="class:help-dev"
			scope="help"
		/>
		<menuitem
			type="url"
			target="_blank"
			title="MOD_MENU_HELP_SHOP"
			link="https://community.joomla.org/the-joomla-shop.html"
			class="class:help-shop"
			scope="help"
		/>
	</menuitem>
</menu>
tables/index.html000064400000000037152346104050010013 0ustar00<!DOCTYPE html><title></title>
tables/menu.php000064400000002055152346104050007475 0ustar00<?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;

/**
 * Menu table
 *
 * @since  1.6
 */
class MenusTableMenu extends JTableMenu
{
	/**
	 * Method to delete a node and, optionally, its child nodes from the table.
	 *
	 * @param   integer  $pk        The primary key of the node to delete.
	 * @param   boolean  $children  True to delete child nodes, false to move them up a level.
	 *
	 * @return  boolean  True on success.
	 *
	 * @since   2.5
	 */
	public function delete($pk = null, $children = false)
	{
		$return = parent::delete($pk, $children);

		if ($return)
		{
			// Delete key from the #__modules_menu table
			$db = JFactory::getDbo();
			$query = $db->getQuery(true)
				->delete($db->quoteName('#__modules_menu'))
				->where($db->quoteName('menuid') . ' = ' . $pk);
			$db->setQuery($query);
			$db->execute();
		}

		return $return;
	}
}
views/item/tmpl/edit.php000064400000017722152346104050011262 0ustar00<?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.tabstate');
JHtml::_('behavior.formvalidator');
JHtml::_('formbehavior.chosen', '#jform_request_filter_tag', null, array('placeholder_text_multiple' => JText::_('JGLOBAL_TYPE_OR_SELECT_SOME_TAGS')));
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('behavior.keepalive');

JText::script('ERROR');
JText::script('JGLOBAL_VALIDATION_FORM_FAILED');

$assoc = JLanguageAssociations::isEnabled();

// Ajax for parent items
$script = "
jQuery(document).ready(function ($){
	$('#jform_menutype').change(function(){
		var menutype = $(this).val();
		$.ajax({
			url: 'index.php?option=com_menus&task=item.getParentItem&menutype=' + menutype,
			dataType: 'json'
		}).done(function(data) {
			$('#jform_parent_id option').each(function() {
				if ($(this).val() != '1') {
					$(this).remove();
				}
			});

			$.each(data, function (i, val) {
				var option = $('<option>');
				option.text(val.title).val(val.id);
				$('#jform_parent_id').append(option);
			});
			$('#jform_parent_id').trigger('liszt:updated');
		});
	});

	// Menu type Login Form specific
	$('#item-form').on('submit', function() {
		if ($('#jform_params_login_redirect_url') && $('#jform_params_logout_redirect_url')) {
			// Login
			if ($('#jform_params_login_redirect_url').closest('.control-group').css('display') === 'block') {
				$('#jform_params_login_redirect_menuitem_id').val('');
			}
			if ($('#jform_params_login_redirect_menuitem_name').closest('.control-group').css('display') === 'block') {
				$('#jform_params_login_redirect_url').val('');

			}

			// Logout
			if ($('#jform_params_logout_redirect_url').closest('.control-group').css('display') === 'block') {
				$('#jform_params_logout_redirect_menuitem_id').val('');
			}
			if ($('#jform_params_logout_redirect_menuitem_id').closest('.control-group').css('display') === 'block') {
				$('#jform_params_logout_redirect_url').val('');
			}
		}
	});
});

Joomla.submitbutton = function(task, type){
	if (task == 'item.setType' || task == 'item.setMenuType')
	{
		if (task == 'item.setType')
		{
			jQuery('#item-form input[name=\"jform[type]\"]').val(type);
			jQuery('#fieldtype').val('type');
		} else {
			jQuery('#item-form input[name=\"jform[menutype]\"]').val(type);
		}
		Joomla.submitform('item.setType', document.getElementById('item-form'));
	} else if (task == 'item.cancel' || document.formvalidator.isValid(document.getElementById('item-form')))
	{
		Joomla.submitform(task, document.getElementById('item-form'));

		// @deprecated 4.0  The following js is not needed since 3.7.0.
		if (task !== 'item.apply')
		{
			window.parent.jQuery('#menuEdit" . (int) $this->item->id . "Modal').modal('hide');
		}
	}
	else
	{
		// special case for modal popups validation response
		jQuery('#item-form .modal-value.invalid').each(function(){
			var field = jQuery(this),
				idReversed = field.attr('id').split('').reverse().join(''),
				separatorLocation = idReversed.indexOf('_'),
				nameId = '#' + idReversed.substr(separatorLocation).split('').reverse().join('') + 'name';
			jQuery(nameId).addClass('invalid');
		});
	}
};
";

$input = JFactory::getApplication()->input;

// Add the script to the document head.
JFactory::getDocument()->addScriptDeclaration($script);
// In case of modal
$isModal  = $input->get('layout') == 'modal' ? true : false;
$layout   = $isModal ? 'modal' : 'edit';
$tmpl     = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=component' : '';
$clientId = $this->state->get('item.client_id', 0);
$lang     = JFactory::getLanguage()->getTag();

// Load mod_menu.ini file when client is administrator
if ($clientId === 1)
{
	JFactory::getLanguage()->load('mod_menu', JPATH_ADMINISTRATOR, null, false, true);
}
?>
<form action="<?php echo JRoute::_('index.php?option=com_menus&view=item&client_id=' . $clientId . '&layout=' . $layout . $tmpl . '&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="item-form" class="form-validate">

	<?php echo JLayoutHelper::render('joomla.edit.title_alias', $this); ?>

	<?php // Add the translation of the menu item title when client is administrator ?>
	<?php if ($clientId === 1 && $this->item->id != 0) : ?>
		<div class="form-inline form-inline-header">
			<div class="control-group">
				<div class="control-label">
					<label><?php echo JText::sprintf('COM_MENUS_TITLE_TRANSLATION', $lang); ?></label>
				</div>
				<div class="controls">
					<input class="input-xlarge" value="<?php echo JText::_($this->item->title); ?>" readonly="readonly" type="text">
				</div>
			</div>
		</div>
	<?php endif; ?>

	<div class="form-horizontal">
		<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?>

		<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', JText::_('COM_MENUS_ITEM_DETAILS')); ?>
		<div class="row-fluid">
			<div class="span9">
				<?php
				echo $this->form->renderField('type');

				if ($this->item->type == 'alias')
				{
					echo $this->form->renderField('aliasoptions', 'params');
				}

				if ($this->item->type == 'separator')
				{
					echo $this->form->renderField('text_separator', 'params');
				}

				echo $this->form->renderFieldset('request');

				if ($this->item->type == 'url')
				{
					$this->form->setFieldAttribute('link', 'readonly', 'false');
					$this->form->setFieldAttribute('link', 'required', 'true');
				}

				echo $this->form->renderField('link');

				if ($this->item->type == 'alias')
				{
					echo $this->form->renderField('alias_redirect', 'params');
				}

				echo $this->form->renderField('browserNav');
				echo $this->form->renderField('template_style_id');

				if (!$isModal && $this->item->type == 'container')
				{
					echo $this->loadTemplate('container');
				}
				?>
			</div>
			<div class="span3">
				<?php
				// Set main fields.
				$this->fields = array(
					'id',
					'client_id',
					'menutype',
					'parent_id',
					'menuordering',
					'published',
					'home',
					'access',
					'language',
					'note',
				);

				if ($this->item->type != 'component')
				{
					$this->fields = array_diff($this->fields, array('home'));
				}

				echo JLayoutHelper::render('joomla.edit.global', $this); ?>
			</div>
		</div>
		<?php echo JHtml::_('bootstrap.endTab'); ?>

		<?php
		$this->fieldsets = array();
		$this->ignore_fieldsets = array('aliasoptions', 'request', 'item_associations');
		echo JLayoutHelper::render('joomla.edit.params', $this);
		?>

		<?php if (!$isModal && $assoc && $this->state->get('item.client_id') != 1) : ?>
			<?php if ($this->item->type !== 'alias' && $this->item->type !== 'url'
				&& $this->item->type !== 'separator' && $this->item->type !== 'heading') : ?>
				<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'associations', JText::_('JGLOBAL_FIELDSET_ASSOCIATIONS')); ?>
				<?php echo $this->loadTemplate('associations'); ?>
				<?php echo JHtml::_('bootstrap.endTab'); ?>
			<?php endif; ?>
		<?php elseif ($isModal && $assoc && $this->state->get('item.client_id') != 1) : ?>
			<div class="hidden"><?php echo $this->loadTemplate('associations'); ?></div>
		<?php endif; ?>

		<?php if (!empty($this->modules)) : ?>
			<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'modules', JText::_('COM_MENUS_ITEM_MODULE_ASSIGNMENT')); ?>
			<?php echo $this->loadTemplate('modules'); ?>
			<?php echo JHtml::_('bootstrap.endTab'); ?>
		<?php endif; ?>

		<?php echo JHtml::_('bootstrap.endTabSet'); ?>
	</div>

	<input type="hidden" name="task" value="" />
	<input type="hidden" name="forcedLanguage" value="<?php echo $input->get('forcedLanguage', '', 'cmd'); ?>" />
	<?php echo $this->form->getInput('component_id'); ?>
	<?php echo JHtml::_('form.token'); ?>
	<input type="hidden" id="fieldtype" name="fieldtype" value="" />
</form>
views/item/tmpl/edit.xml000064400000000763152346104050011270 0ustar00<?xml version="1.0" encoding="utf-8"?>
<metadata>
	<layout title="COM_MENUS_ITEM_VIEW_EDIT_TITLE">
		<message>
			<![CDATA[COM_MENUS_ITEM_VIEW_EDIT_DESC]]>
		</message>
	</layout>
	<fieldset name="request">
		<fields name="request">
			<field
				name="menutype"
				type="menu"
				label="COM_MENUS_ITEMS_CHOOSE_MENU_LABEL"
				description="COM_MENUS_ITEMS_CHOOSE_MENU_DESC"
				clientid=""
				>
				<option value="">COM_MENUS_SELECT_MENU</option>
			</field>
		</fields>
	</fieldset>
</metadata>
views/item/tmpl/edit_associations.php000064400000000506152346104050014031 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_menus
 *
 * @copyright   (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

echo JLayoutHelper::render('joomla.edit.associations', $this);
views/item/tmpl/edit_container.php000064400000011604152346104050013315 0ustar00<?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\Registry\Registry;

// Initialise related data.
$menuLinks = MenusHelper::getMenuLinks('main');

JHtml::_('script', 'jui/treeselectmenu.jquery.min.js', array('version' => 'auto', 'relative' => true));

$script = <<<'JS'
	jQuery(document).ready(function ($) {
		var propagate = function () {
			var $this = $(this);
			var sub = $this.closest('li').find('.treeselect-sub [type="checkbox"]');
			sub.prop('checked', this.checked);
			if ($this.val() == 1)
				sub.each(propagate);
			else
				sub.attr('disabled', this.checked ? 'disabled' : null);
		};
		$('.treeselect')
			.on('click', '[type="checkbox"]', propagate)
			.find('[type="checkbox"]:checked').each(propagate);
	});
JS;

$style = <<<'CSS'
	.checkbox-toggle {
		display: none !important;
	}
	.checkbox-toggle[disabled] ~ .btn-hide {
		opacity: 0.5;
	}
	.checkbox-toggle ~ .btn-show {
		display: inline;
	}
	.checkbox-toggle ~ .btn-hide {
		display: none;
	}
	.checkbox-toggle:checked ~ .btn-show {
		display: none;
	}
	.checkbox-toggle:checked ~ .btn-hide {
		display: inline;
	}
CSS;

JFactory::getDocument()->addScriptDeclaration($script);
JFactory::getDocument()->addStyleDeclaration($style);
?>
<div id="menuselect-group" class="control-group">
	<div class="control-label"><?php echo $this->form->getLabel('hideitems', 'params'); ?></div>

	<div id="jform_params_hideitems" class="controls">
		<?php if (!empty($menuLinks)) : ?>
		<?php $id = 'jform_params_hideitems'; ?>

		<div class="well well-small">
			<div class="form-inline">
				<span class="small"><?php echo JText::_('COM_MENUS_ACTION_EXPAND'); ?>:
					<a id="treeExpandAll" href="javascript://"><?php echo JText::_('JALL'); ?></a>,
					<a id="treeCollapseAll" href="javascript://"><?php echo JText::_('JNONE'); ?></a>|
					<?php echo JText::_('JSHOW'); ?>:
					<a id="treeUncheckAll" href="javascript://"><?php echo JText::_('JALL'); ?></a>,
					<a id="treeCheckAll" href="javascript://"><?php echo JText::_('JNONE'); ?></a>
				</span>
				<input type="text" id="treeselectfilter" name="treeselectfilter" class="input-medium search-query pull-right" size="16"
					autocomplete="off" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" aria-invalid="false" tabindex="-1">
			</div>

			<div class="clearfix"></div>

			<hr class="hr-condensed" />

			<ul class="treeselect">

				<?php if (count($menuLinks)) : ?>
					<?php $prevlevel = 0; ?>
					<div class="alert alert-info"><?php echo JText::_('COM_MENUS_ITEM_FIELD_COMPONENTS_CONTAINER_HIDE_ITEMS_DESC')?></div>
					<li>
					<?php
					$params      = new Registry($this->item->params);
					$hiddenLinks = (array) $params->get('hideitems');

					foreach ($menuLinks as $i => $link) : ?>
						<?php
						if ($extension = $link->element):
							$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, true)
							|| $lang->load("$extension.sys", JPATH_ADMINISTRATOR . '/components/' . $extension, null, false, true);
						endif;

						if ($prevlevel < $link->level)
						{
							echo '<ul class="treeselect-sub">';
						}
						elseif ($prevlevel > $link->level)
						{
							echo str_repeat('</li></ul>', $prevlevel - $link->level);
						}
						else
						{
							echo '</li>';
						}

						$selected = in_array($link->value, $hiddenLinks) ? 1 : 0;
						?>
							<li>
								<div class="treeselect-item pull-left">
									<input type="checkbox" <?php echo $link->value > 1 ? ' name="jform[params][hideitems][]" ' : ''; ?>
										   id="<?php echo $id . $link->value; ?>" value="<?php echo (int) $link->value; ?>" class="novalidate checkbox-toggle"
										<?php echo $selected ? ' checked="checked"' : ''; ?> />

									<?php if ($link->value == 1): ?>
										<label for="<?php echo $id . $link->value; ?>" class="btn btn-mini btn-info pull-left"><?php echo JText::_('JALL') ?></label>
									<?php else: ?>
										<label for="<?php echo $id . $link->value; ?>" class="btn btn-mini btn-danger btn-hide pull-left"><?php echo JText::_('JHIDE') ?></label>
										<label for="<?php echo $id . $link->value; ?>" class="btn btn-mini btn-success btn-show pull-left"><?php echo JText::_('JSHOW') ?></label>
										<label for="<?php echo $id . $link->value; ?>" class="pull-left"><?php echo JText::_($link->text); ?></label>
									<?php endif; ?>
								</div>
						<?php

						if (!isset($menuLinks[$i + 1]))
						{
							echo str_repeat('</li></ul>', $link->level);
						}
						$prevlevel = $link->level;
						?>
						<?php endforeach; ?>
					</li>
					<?php endif; ?>

			</ul>
			<div id="noresultsfound" style="display:none;" class="alert alert-no-items">
				<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
			</div>
		</div>
		<?php endif; ?>
	</div>
</div>
views/item/tmpl/edit_modules.php000064400000013123152346104050013001 0ustar00<?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;

JHtml::_('behavior.core');

foreach ($this->levels as $key => $value) {
	$allLevels[$value->id] = $value->title;
}

JFactory::getDocument()->addScriptDeclaration('
	var viewLevels = ' . json_encode($allLevels) . ',
		menuId = parseInt(' . (int) $this->item->id . ');

	jQuery(function($) {
		var baseLink = "index.php?option=com_modules&amp;client_id=0&amp;task=module.edit&amp;tmpl=component&amp;view=module&amp;layout=modal&amp;id=",
			iFrameAttr = "class=\"iframe jviewport-height70\"";

		$(document)
			.on("click", "input:radio[id^=\'jform_toggle_modules_assigned1\']", function (event) {
				$(".table tr.no").hide();
			})
			.on("click", "input:radio[id^=\'jform_toggle_modules_assigned0\']", function (event) {
				$(".table tr.no").show();
			})
			.on("click", "input:radio[id^=\'jform_toggle_modules_published1\']", function (event) {
				$(".table tr.unpublished").hide();
			})
			.on("click", "input:radio[id^=\'jform_toggle_modules_published0\']", function (event) {
				$(".table tr.unpublished").show();
			})
			.on("click", ".module-edit-link", function () {
				var link = baseLink + $(this).data("moduleId"),
					iFrame = $("<iframe src=\"" + link + "\" " + iFrameAttr + "></iframe>");

				$("#moduleEditModal").modal()
					.find(".modal-body").empty().prepend(iFrame);
			})
			.on("click", "#moduleEditModal .modal-footer .btn", function () {
				var target = $(this).data("target");

				if (target) {
					$("#moduleEditModal iframe").contents().find(target).click();
				}
			});
	});
');

JFactory::getDocument()->addStyleDeclaration('
ul.horizontal-buttons li {
  display: inline-block;
  padding-right: 10%;
}
');

// Set up the bootstrap modal that will be used for all module editors
echo JHtml::_(
	'bootstrap.renderModal',
	'moduleEditModal',
	array(
		'title'       => JText::_('COM_MENUS_EDIT_MODULE_SETTINGS'),
		'backdrop'    => 'static',
		'keyboard'    => false,
		'closeButton' => false,
		'bodyHeight'  => '70',
		'modalWidth'  => '80',
		'footer'      => '<button type="button" class="btn" data-dismiss="modal" data-target="#closeBtn">'
				. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
				. '<button type="button" class="btn btn-primary" data-dismiss="modal" data-target="#saveBtn">'
				. JText::_('JSAVE') . '</button>'
				. '<button type="button" class="btn btn-success" data-target="#applyBtn">'
				. JText::_('JAPPLY') . '</button>',
	)
);

?>
<?php
// Set main fields.
$this->fields = array('toggle_modules_assigned','toggle_modules_published');

echo JLayoutHelper::render('joomla.menu.edit_modules', $this); ?>

	<table class="table table-striped">
		<thead>
		<tr>
			<th class="left">
				<?php echo JText::_('COM_MENUS_HEADING_ASSIGN_MODULE'); ?>
			</th>
			<th>
				<?php echo JText::_('COM_MENUS_HEADING_LEVELS'); ?>
			</th>
			<th>
				<?php echo JText::_('COM_MENUS_HEADING_POSITION'); ?>
			</th>
			<th>
				<?php echo JText::_('COM_MENUS_HEADING_DISPLAY'); ?>
			</th>
			<th>
				<?php echo JText::_('COM_MENUS_HEADING_PUBLISHED_ITEMS'); ?>
			</th>
		</tr>
		</thead>
		<tbody>
		<?php foreach ($this->modules as $i => &$module) : ?>
			<?php if (is_null($module->menuid)) : ?>
				<?php if (!$module->except || $module->menuid < 0) : ?>
					<?php $no = 'no '; ?>
				<?php else : ?>
					<?php $no = ''; ?>
				<?php endif; ?>
			<?php else : ?>
				<?php $no = ''; ?>
			<?php endif; ?>
			<?php if ($module->published) : ?>
				<?php $status = ''; ?>
			<?php else : ?>
				<?php $status = 'unpublished '; ?>
			<?php endif; ?>
			<tr class="<?php echo $no; ?><?php echo $status; ?>row<?php echo $i % 2; ?>" id="tr-<?php echo $module->id; ?>" style="display:table-row">
				<td id="<?php echo $module->id; ?>">
					<button type="button"
						data-target="#moduleEditModal"
						class="btn btn-link module-edit-link"
						title="<?php echo JText::_('COM_MENUS_EDIT_MODULE_SETTINGS'); ?>"
						id="title-<?php echo $module->id; ?>"
						data-module-id="<?php echo $module->id; ?>">
						<?php echo $this->escape($module->title); ?></button>
				</td>
				<td id="access-<?php echo $module->id; ?>">
					<?php echo $this->escape($module->access_title); ?>
				</td>
				<td id="position-<?php echo $module->id; ?>">
					<?php echo $this->escape($module->position); ?>
				</td>
				<td id="menus-<?php echo $module->id; ?>">
					<?php if (is_null($module->menuid)) : ?>
						<?php if ($module->except) : ?>
							<span class="label label-success">
								<?php echo JText::_('JYES'); ?>
							</span>
						<?php else : ?>
							<span class="label label-important">
								<?php echo JText::_('JNO'); ?>
							</span>
						<?php endif; ?>
					<?php elseif ($module->menuid > 0) : ?>
						<span class="label label-success">
							<?php echo JText::_('JYES'); ?>
						</span>
					<?php elseif ($module->menuid < 0) : ?>
						<span class="label label-important">
							<?php echo JText::_('JNO'); ?>
						</span>
					<?php else : ?>
						<span class="label label-info">
							<?php echo JText::_('JALL'); ?>
						</span>
					<?php endif; ?>
				</td>
				<td id="status-<?php echo $module->id; ?>">
						<?php if ($module->published) : ?>
							<span class="label label-success">
								<?php echo JText::_('JYES'); ?>
							</span>
						<?php else : ?>
							<span class="label label-important">
								<?php echo JText::_('JNO'); ?>
							</span>
						<?php endif; ?>
				</td>
			</tr>
		<?php endforeach; ?>
		</tbody>
	</table>
views/item/tmpl/edit_options.php000064400000002666152346104050013036 0ustar00<?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;
?>
<?php
	echo JHtml::_('bootstrap.startAccordion', 'menuOptions', array('active' => 'collapse0'));
	$fieldSets = $this->form->getFieldsets('params');
	$i = 0;

	foreach ($fieldSets as $name => $fieldSet) :
		if (!(($this->item->link == 'index.php?option=com_wrapper&view=wrapper') && $fieldSet->name == 'request')
				&& !($this->item->link == 'index.php?Itemid=' && $fieldSet->name == 'aliasoptions')) :
			$label = !empty($fieldSet->label) ? $fieldSet->label : 'COM_MENUS_' . $name . '_FIELDSET_LABEL';
			echo JHtml::_('bootstrap.addSlide', 'menuOptions', JText::_($label), 'collapse' . ($i++));
				if (isset($fieldSet->description) && trim($fieldSet->description)) :
					echo '<p class="tip">' . $this->escape(JText::_($fieldSet->description)) . '</p>';
				endif;
				?>
					<?php foreach ($this->form->getFieldset($name) as $field) : ?>

						<div class="control-group">

							<div class="control-label">
								<?php echo $field->label; ?>
							</div>
							<div class="controls">
								<?php echo $field->input; ?>
							</div>

						</div>
					<?php endforeach;
			echo JHtml::_('bootstrap.endSlide');
		endif;
	endforeach; ?>
<?php

echo JHtml::_('bootstrap.endAccordion');
views/item/tmpl/index.html000064400000000037152346104050011610 0ustar00<!DOCTYPE html><title></title>
views/item/tmpl/modal.php000064400000002510152346104050011416 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_menus
 *
 * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

JHtml::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom'));

// @deprecated 4.0 the function parameter, the inline js and the buttons are not needed since 3.7.0.
$function  = JFactory::getApplication()->input->getCmd('function', 'jEditMenu_' . (int) $this->item->id);

// Function to update input title when changed
JFactory::getDocument()->addScriptDeclaration('
	function jEditMenuModal() {
		if (window.parent && document.formvalidator.isValid(document.getElementById("item-form"))) {
			return window.parent.' . $this->escape($function) . '(document.getElementById("jform_title").value);
		}
	}
');
?>
<button id="applyBtn" type="button" class="hidden" onclick="Joomla.submitbutton('item.apply'); jEditMenuModal();"></button>
<button id="saveBtn" type="button" class="hidden" onclick="Joomla.submitbutton('item.save'); jEditMenuModal();"></button>
<button id="closeBtn" type="button" class="hidden" onclick="Joomla.submitbutton('item.cancel');"></button>

<div class="container-popup">
	<?php $this->setLayout('edit'); ?>
	<?php echo $this->loadTemplate(); ?>
</div>
views/item/tmpl/modal_associations.php000064400000000506152346104050014200 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_menus
 *
 * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

echo JLayoutHelper::render('joomla.edit.associations', $this);
views/item/tmpl/modal_options.php000064400000002666152346104050013205 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_menus
 *
 * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;
?>
<?php
	echo JHtml::_('bootstrap.startAccordion', 'menuOptions', array('active' => 'collapse0'));
	$fieldSets = $this->form->getFieldsets('params');
	$i = 0;

	foreach ($fieldSets as $name => $fieldSet) :
		if (!(($this->item->link == 'index.php?option=com_wrapper&view=wrapper') && $fieldSet->name == 'request')
				&& !($this->item->link == 'index.php?Itemid=' && $fieldSet->name == 'aliasoptions')) :
			$label = !empty($fieldSet->label) ? $fieldSet->label : 'COM_MENUS_' . $name . '_FIELDSET_LABEL';
			echo JHtml::_('bootstrap.addSlide', 'menuOptions', JText::_($label), 'collapse' . ($i++));
				if (isset($fieldSet->description) && trim($fieldSet->description)) :
					echo '<p class="tip">' . $this->escape(JText::_($fieldSet->description)) . '</p>';
				endif;
				?>
					<?php foreach ($this->form->getFieldset($name) as $field) : ?>

						<div class="control-group">

							<div class="control-label">
								<?php echo $field->label; ?>
							</div>
							<div class="controls">
								<?php echo $field->input; ?>
							</div>

						</div>
					<?php endforeach;
			echo JHtml::_('bootstrap.endSlide');
		endif;
	endforeach; ?>
<?php

echo JHtml::_('bootstrap.endAccordion');
views/item/index.html000064400000000037152346104050010634 0ustar00<!DOCTYPE html><title></title>
views/item/view.html.php000064400000010475152346104050011274 0ustar00<?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 MenusViewItem extends JViewLegacy
{
	/**
	 * @var  JForm
	 */
	protected $form;

	/**
	 * @var  object
	 */
	protected $item;

	/**
	 * @var  mixed
	 */
	protected $modules;

	/**
	 * @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)
	{
		$user = JFactory::getUser();

		$this->state   = $this->get('State');
		$this->form    = $this->get('Form');
		$this->item    = $this->get('Item');
		$this->modules = $this->get('Modules');
		$this->levels  = $this->get('ViewLevels');
		$this->canDo   = JHelperContent::getActions('com_menus', 'menu', (int) $this->state->get('item.menutypeid'));

		// Check if we're allowed to edit this item
		// No need to check for create, because then the moduletype select is empty
		if (!empty($this->item->id) && !$this->canDo->get('core.edit'))
		{
			throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
		}

		// Check for errors.
		if (count($errors = $this->get('Errors')))
		{
			JError::raiseError(500, implode("\n", $errors));

			return;
		}

		// If we are forcing a language in modal (used for associations).
		if ($this->getLayout() === 'modal' && $forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd'))
		{
			// Set the language field to the forcedLanguage and disable changing it.
			$this->form->setValue('language', null, $forcedLanguage);
			$this->form->setFieldAttribute('language', 'readonly', 'true');

			// Only allow to select categories with All language or with the forced language.
			$this->form->setFieldAttribute('parent_id', 'language', '*,' . $forcedLanguage);
		}

		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);

		$user       = JFactory::getUser();
		$isNew      = ($this->item->id == 0);
		$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
		$canDo      = $this->canDo;
		$clientId   = $this->state->get('item.client_id', 0);

		JToolbarHelper::title(JText::_($isNew ? 'COM_MENUS_VIEW_NEW_ITEM_TITLE' : 'COM_MENUS_VIEW_EDIT_ITEM_TITLE'), 'list menu-add');

		// If a new item, can save the item.  Allow users with edit permissions to apply changes to prevent returning to grid.
		if ($isNew && $canDo->get('core.create'))
		{
			if ($canDo->get('core.edit'))
			{
				JToolbarHelper::apply('item.apply');
			}

			JToolbarHelper::save('item.save');
		}

		// If not checked out, can save the item.
		if (!$isNew && !$checkedOut && $canDo->get('core.edit'))
		{
			JToolbarHelper::apply('item.apply');
			JToolbarHelper::save('item.save');
		}

		// If the user can create new items, allow them to see Save & New
		if ($canDo->get('core.create'))
		{
			JToolbarHelper::save2new('item.save2new');
		}

		// If an existing item, can save to a copy only if we have create rights.
		if (!$isNew && $canDo->get('core.create'))
		{
			JToolbarHelper::save2copy('item.save2copy');
		}

		if (!$isNew && JLanguageAssociations::isEnabled() && JComponentHelper::isEnabled('com_associations') && $clientId != 1)
		{
			JToolbarHelper::custom('item.editAssociations', 'contract', 'contract', 'JTOOLBAR_ASSOCIATIONS', false, false);
		}

		if ($isNew)
		{
			JToolbarHelper::cancel('item.cancel');
		}
		else
		{
			JToolbarHelper::cancel('item.cancel', 'JTOOLBAR_CLOSE');
		}

		JToolbarHelper::divider();

		// Get the help information for the menu item.
		$lang = JFactory::getLanguage();

		$help = $this->get('Help');

		if ($lang->hasKey($help->url))
		{
			$debug = $lang->setDebug(false);
			$url   = JText::_($help->url);
			$lang->setDebug($debug);
		}
		else
		{
			$url = $help->url;
		}

		JToolbarHelper::help($help->key, $help->local, $url);
	}
}
views/items/tmpl/default.php000064400000027003152346104050012135 0ustar00<?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::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');

$user       = JFactory::getUser();
$app        = JFactory::getApplication();
$userId     = $user->get('id');
$listOrder  = $this->escape($this->state->get('list.ordering'));
$listDirn   = $this->escape($this->state->get('list.direction'));
$ordering   = ($listOrder == 'a.lft');
$saveOrder  = ($listOrder == 'a.lft' && strtolower($listDirn) == 'asc');
$menuType   = (string) $app->getUserState('com_menus.items.menutype', '', 'string');

if ($saveOrder && $menuType)
{
	$saveOrderingUrl = 'index.php?option=com_menus&task=items.saveOrderAjax&tmpl=component';
	JHtml::_('sortablelist.sortable', 'itemList', 'adminForm', strtolower($listDirn), $saveOrderingUrl, false, true);
}

$assoc   = JLanguageAssociations::isEnabled() && $this->state->get('filter.client_id') == 0;
$colSpan = $assoc ? 10 : 9;

if ($menuType == '')
{
	$colSpan--;
}
?>
<?php // Set up the filter bar. ?>
<form action="<?php echo JRoute::_('index.php?option=com_menus&view=items'); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
	<div id="j-sidebar-container" class="span2">
		<?php echo $this->sidebar; ?>
	</div>
	<div id="j-main-container" class="span10">
<?php else : ?>
	<div id="j-main-container">
<?php endif;?>
		<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this, 'options' => array('selectorFieldName' => 'menutype'))); ?>
		<?php if (empty($this->items)) : ?>
			<div class="alert alert-no-items">
				<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
			</div>
		<?php else : ?>
			<table class="table table-striped" id="itemList">
				<thead>
					<tr>
						<?php if ($menuType) : ?>
							<th width="1%" class="nowrap center hidden-phone">
								<?php echo JHtml::_('searchtools.sort', '', 'a.lft', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?>
							</th>
						<?php endif; ?>
						<th width="1%" class="nowrap center">
							<?php echo JHtml::_('grid.checkall'); ?>
						</th>
						<th width="1%" class="nowrap center">
							<?php echo JHtml::_('searchtools.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>
						</th>
						<th class="title">
							<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
						</th>
						<th class="nowrap hidden-phone">
							<?php echo JHtml::_('searchtools.sort', 'COM_MENUS_HEADING_MENU', 'menutype_title', $listDirn, $listOrder); ?>
						</th>
						<?php if ($this->state->get('filter.client_id') == 0) : ?>
						<th width="5%" class="center nowrap hidden-phone">
							<?php echo JHtml::_('searchtools.sort', 'COM_MENUS_HEADING_HOME', 'a.home', $listDirn, $listOrder); ?>
						</th>
						<?php endif; ?>
						<?php if ($this->state->get('filter.client_id') == 0) : ?>
						<th width="10%" class="nowrap hidden-phone">
							<?php echo JHtml::_('searchtools.sort',  'JGRID_HEADING_ACCESS', 'a.access', $listDirn, $listOrder); ?>
						</th>
						<?php endif; ?>
						<?php if ($assoc) : ?>
							<th width="5%" class="nowrap hidden-phone">
								<?php echo JHtml::_('searchtools.sort', 'COM_MENUS_HEADING_ASSOCIATION', 'association', $listDirn, $listOrder); ?>
							</th>
						<?php endif; ?>
						<?php if ($this->state->get('filter.client_id') == 0) : ?>
						<th width="15%" class="nowrap hidden-phone">
							<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language', $listDirn, $listOrder); ?>
						</th>
						<?php endif; ?>
						<th width="1%" class="nowrap hidden-phone">
							<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
						</th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<td colspan="<?php echo $colSpan; ?>">
							<?php echo $this->pagination->getListFooter(); ?>
						</td>
					</tr>
				</tfoot>

				<tbody>
				<?php

				foreach ($this->items as $i => $item) :
					$orderkey   = array_search($item->id, $this->ordering[$item->parent_id]);
					$canCreate  = $user->authorise('core.create',     'com_menus.menu.' . $item->menutype_id);
					$canEdit    = $user->authorise('core.edit',       'com_menus.menu.' . $item->menutype_id);
					$canCheckin = $user->authorise('core.manage',     'com_checkin') || $item->checked_out == $user->get('id')|| $item->checked_out == 0;
					$canChange  = $user->authorise('core.edit.state', 'com_menus.menu.' . $item->menutype_id) && $canCheckin;

					// Get the parents of item for sorting
					if ($item->level > 1)
					{
						$parentsStr = '';
						$_currentParentId = $item->parent_id;
						$parentsStr = ' ' . $_currentParentId;

						for ($j = 0; $j < $item->level; $j++)
						{
							foreach ($this->ordering as $k => $v)
							{
								$v = implode('-', $v);
								$v = '-' . $v . '-';

								if (strpos($v, '-' . $_currentParentId . '-') !== false)
								{
									$parentsStr .= ' ' . $k;
									$_currentParentId = $k;
									break;
								}
							}
						}
					}
					else
					{
						$parentsStr = '';
					}
					?>
					<tr class="row<?php echo $i % 2; ?>" sortable-group-id="<?php echo $item->parent_id; ?>" item-id="<?php echo $item->id; ?>" parents="<?php echo $parentsStr; ?>" level="<?php echo $item->level; ?>">
						<?php if ($menuType) : ?>
							<td class="order nowrap center hidden-phone">
								<?php
								$iconClass = '';

								if (!$canChange)
								{
									$iconClass = ' inactive';
								}
								elseif (!$saveOrder)
								{
									$iconClass = ' inactive tip-top hasTooltip" title="' . JHtml::_('tooltipText', 'JORDERINGDISABLED');
								}
								?>
								<span class="sortable-handler<?php echo $iconClass ?>">
									<span class="icon-menu" aria-hidden="true"></span>
								</span>
								<?php if ($canChange && $saveOrder) : ?>
									<input type="text" style="display:none" name="order[]" size="5" value="<?php echo $orderkey + 1; ?>" />
								<?php endif; ?>
							</td>
						<?php endif; ?>
						<td class="center">
							<?php echo JHtml::_('grid.id', $i, $item->id); ?>
						</td>
						<td class="center">
							<?php
							// Show protected items as published always. We don't allow state change for them. Show/Hide is the module's job.
							$published = $item->protected ? 3 : $item->published;
							echo JHtml::_('MenusHtml.Menus.state', $published, $i, $canChange && !$item->protected, 'cb'); ?>
						</td>
						<td>
							<?php $prefix = JLayoutHelper::render('joomla.html.treeprefix', array('level' => $item->level)); ?>
							<?php echo $prefix; ?>
							<?php if ($item->checked_out) : ?>
								<?php echo JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'items.', $canCheckin); ?>
							<?php endif; ?>
							<?php if ($canEdit && !$item->protected) : ?>
								<a class="hasTooltip" href="<?php echo JRoute::_('index.php?option=com_menus&task=item.edit&id=' . (int) $item->id); ?>" title="<?php echo JText::_('JACTION_EDIT'); ?>">
									<?php echo $this->escape($item->title); ?></a>
							<?php else : ?>
								<?php echo $this->escape($item->title); ?>
							<?php endif; ?>
							<span class="small">
							<?php if ($item->type != 'url') : ?>
								<?php if (empty($item->note)) : ?>
									<?php echo JText::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
								<?php else : ?>
									<?php echo JText::sprintf('JGLOBAL_LIST_ALIAS_NOTE', $this->escape($item->alias), $this->escape($item->note)); ?>
								<?php endif; ?>
							<?php elseif ($item->type == 'url' && $item->note) : ?>
								<?php echo JText::sprintf('JGLOBAL_LIST_NOTE', $this->escape($item->note)); ?>
							<?php endif; ?>
							</span>
							<?php echo JHtml::_('MenusHtml.Menus.visibility', $item->params); ?>
							<div title="<?php echo $this->escape($item->path); ?>">
								<?php echo $prefix; ?>
								<span class="small"  title="<?php echo isset($item->item_type_desc) ? htmlspecialchars($this->escape($item->item_type_desc), ENT_COMPAT, 'UTF-8') : ''; ?>">
									<?php echo $this->escape($item->item_type); ?></span>
							</div>
						</td>
						<td class="small hidden-phone">
							<?php echo $this->escape($item->menutype_title ?: ucwords($item->menutype)); ?>
						</td>
						<?php if ($this->state->get('filter.client_id') == 0) : ?>
						<td class="center hidden-phone">
							<?php if ($item->type == 'component') : ?>
								<?php if ($item->language == '*' || $item->home == '0') : ?>
									<?php echo JHtml::_('jgrid.isdefault', $item->home, $i, 'items.', ($item->language != '*' || !$item->home) && $canChange && !$item->protected); ?>
								<?php elseif ($canChange) : ?>
									<a href="<?php echo JRoute::_('index.php?option=com_menus&task=items.unsetDefault&cid[]=' . $item->id . '&' . JSession::getFormToken() . '=1'); ?>">
										<?php if ($item->language_image) : ?>
											<?php echo JHtml::_('image', 'mod_languages/' . $item->language_image . '.gif', $item->language_title, array('title' => JText::sprintf('COM_MENUS_GRID_UNSET_LANGUAGE', $item->language_title)), true); ?>
										<?php else : ?>
											<span class="label" title="<?php echo JText::sprintf('COM_MENUS_GRID_UNSET_LANGUAGE', $item->language_title); ?>"><?php echo $item->language_sef; ?></span>
										<?php endif; ?>
									</a>
								<?php else : ?>
									<?php if ($item->language_image) : ?>
										<?php echo JHtml::_('image', 'mod_languages/' . $item->language_image . '.gif', $item->language_title, array('title' => $item->language_title), true); ?>
									<?php else : ?>
										<span class="label" title="<?php echo $item->language_title; ?>"><?php echo $item->language_sef; ?></span>
									<?php endif; ?>
								<?php endif; ?>
							<?php endif; ?>
						</td>
						<?php endif; ?>
						<?php if ($this->state->get('filter.client_id') == 0) : ?>
						<td class="small hidden-phone">
							<?php echo $this->escape($item->access_level); ?>
						</td>
						<?php endif; ?>
						<?php if ($assoc) : ?>
							<td class="small hidden-phone">
								<?php if ($item->association) : ?>
									<?php echo JHtml::_('MenusHtml.Menus.association', $item->id); ?>
								<?php endif; ?>
							</td>
						<?php endif; ?>
						<?php if ($this->state->get('filter.client_id') == 0) : ?>
						<td class="small hidden-phone">
							<?php echo JLayoutHelper::render('joomla.content.language', $item); ?>
						</td>
						<?php endif; ?>
						<td class="hidden-phone">
							<span title="<?php echo sprintf('%d-%d', $item->lft, $item->rgt); ?>">
								<?php echo (int) $item->id; ?>
							</span>
						</td>
					</tr>
					<?php endforeach; ?>
				</tbody>
			</table>
			<?php // Load the batch processing form if user is allowed ?>
			<?php if ($user->authorise('core.create', 'com_menus') || $user->authorise('core.edit', 'com_menus')) : ?>
				<?php echo JHtml::_(
					'bootstrap.renderModal',
					'collapseModal',
					array(
						'title' => JText::_('COM_MENUS_BATCH_OPTIONS'),
						'footer' => $this->loadTemplate('batch_footer')
					),
					$this->loadTemplate('batch_body')
				); ?>
			<?php endif; ?>
		<?php endif; ?>

		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
		<?php echo JHtml::_('form.token'); ?>
	</div>
</form>
views/items/tmpl/default.xml000064400000000773152346104050012153 0ustar00<?xml version="1.0" encoding="utf-8"?>
<metadata>
	<layout title="COM_MENUS_ITEMS_VIEW_DEFAULT_TITLE">
		<message>
			<![CDATA[COM_MENUS_ITEMS_VIEW_DEFAULT_DESC]]>
		</message>
	</layout>
	<fieldset name="request">
		<fields name="request">
			<field
				name="menutype"
				type="menu"
				label="COM_MENUS_ITEMS_CHOOSE_MENU_LABEL"
				description="COM_MENUS_ITEMS_CHOOSE_MENU_DESC"
				clientid=""
				>
				<option value="">COM_MENUS_SELECT_MENU</option>
			</field>
		</fields>
	</fieldset>
</metadata>
views/items/tmpl/default_batch_body.php000064400000005460152346104050014316 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_menus
 *
 * @copyright   (C) 2015 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;

$options = array(
	JHtml::_('select.option', 'c', JText::_('JLIB_HTML_BATCH_COPY')),
	JHtml::_('select.option', 'm', JText::_('JLIB_HTML_BATCH_MOVE'))
);
$published = (int) $this->state->get('filter.published');
$clientId  = (int) $this->state->get('filter.client_id');
$menuType  = JFactory::getApplication()->getUserState('com_menus.items.menutype');
if ($clientId == 1) :
	JFactory::getDocument()->addScriptDeclaration(
		'
			jQuery(document).ready(function($){
				if ($("#batch-menu-id").length){var batchSelector = $("#batch-menu-id");}
				if ($("#batch-copy-move").length) {
					$("#batch-copy-move").hide();
					batchSelector.on("change", function(){
						if (batchSelector.val() != 0 || batchSelector.val() != "") {
							$("#batch-copy-move").show();
						} else {
							$("#batch-copy-move").hide();
						}
					});
				}
			});
		'
	);
endif;

?>
<div class="container-fluid">
	<?php if (strlen($menuType) && $menuType != '*') : ?>
	<?php if ($clientId != 1) : ?>
	<div class="row-fluid">
		<div class="control-group span6">
			<div class="controls">
				<?php echo JHtml::_('batch.language'); ?>
			</div>
		</div>
		<div class="control-group span6">
			<div class="controls">
				<?php echo JHtml::_('batch.access'); ?>
			</div>
		</div>
	</div>
	<?php endif; ?>
	<div class="row-fluid">
		<?php if ($published >= 0) : ?>
			<div id="batch-choose-action" class="combo control-group">
				<label id="batch-choose-action-lbl" class="control-label" for="batch-menu-id">
					<?php echo JText::_('COM_MENUS_BATCH_MENU_LABEL'); ?>
				</label>
				<div class="controls">
					<select name="batch[menu_id]" id="batch-menu-id">
						<option value=""><?php echo JText::_('JLIB_HTML_BATCH_NO_CATEGORY'); ?></option>
						<?php
						$opts     = array(
							'published' => $this->state->get('filter.published'),
							'checkacl'  => (int) $this->state->get('menutypeid'),
							'clientid'  => (int) $clientId,
						);
						echo JHtml::_('select.options', JHtml::_('menu.menuitems', $opts));
						?>
					</select>
				</div>
			</div>
			<div id="batch-copy-move" class="control-group radio">
				<?php echo JText::_('JLIB_HTML_BATCH_MOVE_QUESTION'); ?>
				<?php echo JHtml::_('select.radiolist', $options, 'batch[move_copy]', '', 'value', 'text', 'm'); ?>
			</div>
		<?php endif; ?>

		<?php if ($published < 0 && $clientId == 1): ?>
			<p><?php echo JText::_('COM_MENUS_SELECT_MENU_FILTER_NOT_TRASHED'); ?></p>
		<?php endif; ?>
	</div>
	<?php else : ?>
	<div class="row-fluid">
		<p><?php echo JText::_('COM_MENUS_SELECT_MENU_FIRST'); ?></p>
	</div>
	<?php endif; ?>
</div>
views/items/tmpl/default_batch_footer.php000064400000001763152346104050014661 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_menus
 *
 * @copyright   (C) 2015 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;
$published = $this->state->get('filter.published');
$clientId  = $this->state->get('filter.client_id');
$menuType = JFactory::getApplication()->getUserState('com_menus.items.menutype');
?>
<button type="button" class="btn" onclick="document.getElementById('batch-menu-id').value='';document.getElementById('batch-access').value='';document.getElementById('batch-language-id').value=''" data-dismiss="modal">
	<?php echo JText::_('JCANCEL'); ?>
</button>
<?php if ((strlen($menuType) && $menuType != '*' && $clientId == 0) || ($published >= 0 && $clientId == 1)): ?>
	<button type="submit" class="btn btn-success" onclick="Joomla.submitbutton('item.batch');return false;">
		<?php echo JText::_('JGLOBAL_BATCH_PROCESS'); ?>
	</button>
<?php endif; ?>
views/items/tmpl/index.html000064400000000037152346104050011773 0ustar00<!DOCTYPE html><title></title>
views/items/tmpl/modal.php000064400000016777152346104050011625 0ustar00<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_menus
 *
 * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

$app = JFactory::getApplication();

if ($app->isClient('site'))
{
	JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN'));
}

JHtml::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/helpers/html');

JHtml::_('behavior.core');
JHtml::_('behavior.polyfill', array('event'), 'lt IE 9');
JHtml::_('script', 'com_menus/admin-items-modal.min.js', array('version' => 'auto', 'relative' => true));
JHtml::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom'));
JHtml::_('bootstrap.popover', '.hasPopover', array('placement' => 'bottom'));
JHtml::_('formbehavior.chosen', 'select');

// Special case for the search field tooltip.
$searchFilterDesc = $this->filterForm->getFieldAttribute('search', 'description', null, 'filter');
JHtml::_('bootstrap.tooltip', '#filter_search', array('title' => JText::_($searchFilterDesc), 'placement' => 'bottom'));

$function     = $app->input->get('function', 'jSelectMenuItem', 'cmd');
$editor    = $app->input->getCmd('editor', '');
$listOrder    = $this->escape($this->state->get('list.ordering'));
$listDirn     = $this->escape($this->state->get('list.direction'));
$link         = 'index.php?option=com_menus&view=items&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1';

if (!empty($editor))
{
	// This view is used also in com_menus. Load the xtd script only if the editor is set!
	JFactory::getDocument()->addScriptOptions('xtd-menus', array('editor' => $editor));
	$onclick = "jSelectMenuItem";
	$link    = 'index.php?option=com_menus&view=items&layout=modal&tmpl=component&editor=' . $editor . '&' . JSession::getFormToken() . '=1';
}
?>
<div class="container-popup">

	<form action="<?php echo JRoute::_($link); ?>" method="post" name="adminForm" id="adminForm" class="form-inline">

		<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this, 'options' => array('selectorFieldName' => 'menutype'))); ?>

		<?php if (empty($this->items)) : ?>
			<div class="alert alert-no-items">
				<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
			</div>
		<?php else : ?>
			<table class="table table-striped table-condensed">
				<thead>
					<tr>
						<th width="1%" class="nowrap center">
							<?php echo JHtml::_('searchtools.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>
						</th>
						<th class="title">
							<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
						</th>
						<th class="nowrap hidden-phone">
							<?php echo JHtml::_('searchtools.sort', 'COM_MENUS_HEADING_MENU', 'menutype_title', $listDirn, $listOrder); ?>
						</th>
						<th width="5%" class="center nowrap hidden-phone">
							<?php echo JHtml::_('searchtools.sort', 'COM_MENUS_HEADING_HOME', 'a.home', $listDirn, $listOrder); ?>
						</th>
						<th width="10%" class="nowrap hidden-phone">
							<?php echo JHtml::_('searchtools.sort',  'JGRID_HEADING_ACCESS', 'a.access', $listDirn, $listOrder); ?>
						</th>
						<th width="15%" class="nowrap hidden-phone">
							<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_LANGUAGE', 'language', $listDirn, $listOrder); ?>
						</th>
						<th width="1%" class="nowrap hidden-phone">
							<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
						</th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<td colspan="7">
							<?php echo $this->pagination->getListFooter(); ?>
						</td>
					</tr>
				</tfoot>
				<tbody>
				<?php foreach ($this->items as $i => $item) : ?>
				<?php $uselessMenuItem = in_array($item->type, array('separator', 'heading', 'alias', 'url', 'container')); ?>
					<?php if ($item->language && JLanguageMultilang::isEnabled())
					{
						if ($item->language !== '*')
						{
							$language = $item->language;
						}
						else
						{
							$language = '';
						}
					}
					elseif (!JLanguageMultilang::isEnabled())
					{
						$language = '';
					}
					?>
					<tr class="row<?php echo $i % 2; ?>">
						<td class="center">
							<?php echo JHtml::_('MenusHtml.Menus.state', $item->published, $i, 0); ?>
						</td>
						<td>
							<?php $prefix = JLayoutHelper::render('joomla.html.treeprefix', array('level' => $item->level)); ?>
							<?php echo $prefix; ?>
							<?php if (!$uselessMenuItem) : ?>
								<a class="select-link" href="javascript:void(0)" data-function="<?php echo $this->escape($function); ?>" data-id="<?php echo $item->id; ?>" data-title="<?php echo $this->escape($item->title); ?>" data-uri="<?php echo 'index.php?Itemid=' . $item->id; ?>" data-language="<?php echo $this->escape($language); ?>">
									<?php echo $this->escape($item->title); ?>
								</a>
							<?php else : ?>
								<?php echo $this->escape($item->title); ?>
							<?php endif; ?>
							<span class="small">
								<?php if (empty($item->note)) : ?>
									<?php echo JText::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
								<?php else : ?>
									<?php echo JText::sprintf('JGLOBAL_LIST_ALIAS_NOTE', $this->escape($item->alias), $this->escape($item->note)); ?>
								<?php endif; ?>
							</span>
							<div title="<?php echo $this->escape($item->path); ?>">
								<?php echo $prefix; ?>
								<span class="small" title="<?php echo isset($item->item_type_desc) ? htmlspecialchars($this->escape($item->item_type_desc), ENT_COMPAT, 'UTF-8') : ''; ?>">
									<?php echo $this->escape($item->item_type); ?></span>
							</div>
						</td>
						<td class="small hidden-phone">
							<?php echo $this->escape($item->menutype_title); ?>
						</td>
						<td class="center hidden-phone">
							<?php if ($item->type == 'component') : ?>
								<?php if ($item->language == '*' || $item->home == '0') : ?>
									<?php echo JHtml::_('jgrid.isdefault', $item->home, $i, 'items.', ($item->language != '*' || !$item->home) && 0); ?>
								<?php else : ?>
									<?php if ($item->language_image) : ?>
										<?php echo JHtml::_('image', 'mod_languages/' . $item->language_image . '.gif', $item->language_title, array('title' => $item->language_title), true); ?>
									<?php else : ?>
										<span class="label" title="<?php echo $item->language_title; ?>"><?php echo $item->language_sef; ?></span>
									<?php endif; ?>
								<?php endif; ?>
							<?php endif; ?>
						</td>
						<td class="small hidden-phone">
							<?php echo $this->escape($item->access_level); ?>
						</td>
						<td class="small hidden-phone">
							<?php if ($item->language == '') : ?>
								<?php echo JText::_('JDEFAULT'); ?>
							<?php elseif ($item->language == '*') : ?>
								<?php echo JText::alt('JALL', 'language'); ?>
							<?php else : ?>
								<?php echo JLayoutHelper::render('joomla.content.language', $item); ?>
							<?php endif; ?>
						</td>
						<td class="hidden-phone">
							<span title="<?php echo sprintf('%d-%d', $item->lft, $item->rgt); ?>">
								<?php echo (int) $item->id; ?>
							</span>
						</td>
					</tr>
				<?php endforeach; ?>
				</tbody>
			</table>
		<?php endif; ?>

		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="function" value="<?php echo $function; ?>" />
		<input type="hidden" name="forcedLanguage" value="<?php echo $app->input->get('forcedLanguage', '', 'cmd'); ?>" />
		<?php echo JHtml::_('form.token'); ?>

	</form>
</div>
views/items/index.html000064400000000037152346104050011017 0ustar00<!DOCTYPE html><title></title>
views/items/view.html.php000064400000025773152346104050011466 0ustar00<?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 Items View.
 *
 * @since  1.6
 */
class MenusViewItems extends JViewLegacy
{
	/**
	 * @var  array
	 */
	protected $f_levels;

	/**
	 * @var  mixed
	 */
	protected $items;

	/**
	 * @var  JPagination
	 */
	protected $pagination;

	/**
	 * @var  JObject
	 */
	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   1.6
	 */
	public function display($tpl = null)
	{
		$lang = JFactory::getLanguage();
		$this->items         = $this->get('Items');
		$this->pagination    = $this->get('Pagination');
		$this->total         = $this->get('Total');
		$this->state         = $this->get('State');
		$this->filterForm    = $this->get('FilterForm');
		$this->activeFilters = $this->get('ActiveFilters');

		// We don't need toolbar in the modal window.
		if ($this->getLayout() !== 'modal')
		{
			MenusHelper::addSubmenu('items');
		}

		// Check for errors.
		if (count($errors = $this->get('Errors')))
		{
			throw new Exception(implode("\n", $errors), 500);
		}

		$this->ordering = array();

		// Preprocess the list of items to find ordering divisions.
		foreach ($this->items as $item)
		{
			$this->ordering[$item->parent_id][] = $item->id;

			// Item type text
			switch ($item->type)
			{
				case 'url':
					$value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL');
					break;

				case 'alias':
					$value = JText::_('COM_MENUS_TYPE_ALIAS');
					break;

				case 'separator':
					$value = JText::_('COM_MENUS_TYPE_SEPARATOR');
					break;

				case 'heading':
					$value = JText::_('COM_MENUS_TYPE_HEADING');
					break;

				case 'container':
					$value = JText::_('COM_MENUS_TYPE_CONTAINER');
					break;

				case 'component':
				default:
					// Load language
						$lang->load($item->componentname . '.sys', JPATH_ADMINISTRATOR, null, false, true)
					|| $lang->load($item->componentname . '.sys', JPATH_ADMINISTRATOR . '/components/' . $item->componentname, null, false, true);

					if (!empty($item->componentname))
					{
						$titleParts   = array();
						$titleParts[] = JText::_($item->componentname);
						$vars         = null;

						parse_str($item->link, $vars);

						if (isset($vars['view']))
						{
							// Attempt to load the view xml file.
							$file = JPATH_SITE . '/components/' . $item->componentname . '/views/' . $vars['view'] . '/metadata.xml';

							if (!is_file($file))
							{
								$file = JPATH_SITE . '/components/' . $item->componentname . '/view/' . $vars['view'] . '/metadata.xml';
							}

							if (is_file($file) && $xml = simplexml_load_file($file))
							{
								// Look for the first view node off of the root node.
								if ($view = $xml->xpath('view[1]'))
								{
									// Add view title if present.
									if (!empty($view[0]['title']))
									{
										$viewTitle = trim((string) $view[0]['title']);

										// Check if the key is valid. Needed due to B/C so we don't show untranslated keys. This check should be removed with Joomla 4.
										if ($lang->hasKey($viewTitle))
										{
											$titleParts[] = JText::_($viewTitle);
										}
									}
								}
							}

							$vars['layout'] = isset($vars['layout']) ? $vars['layout'] : 'default';

							// Attempt to load the layout xml file.
							// If Alternative Menu Item, get template folder for layout file
							if (strpos($vars['layout'], ':') > 0)
							{
								// Use template folder for layout file
								$temp = explode(':', $vars['layout']);
								$file = JPATH_SITE . '/templates/' . $temp[0] . '/html/' . $item->componentname . '/' . $vars['view'] . '/' . $temp[1] . '.xml';

								// Load template language file
								$lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE, null, false, true)
								||	$lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE . '/templates/' . $temp[0], null, false, true);
							}
							else
							{
								$base = $this->state->get('filter.client_id') == 0 ? JPATH_SITE : JPATH_ADMINISTRATOR;

								// Get XML file from component folder for standard layouts
								$file = $base . '/components/' . $item->componentname . '/views/' . $vars['view'] . '/tmpl/' . $vars['layout'] . '.xml';

								if (!file_exists($file))
								{
									$file = $base . '/components/' . $item->componentname . '/view/' . $vars['view'] . '/tmpl/' . $vars['layout'] . '.xml';
								}
							}

							if (is_file($file) && $xml = simplexml_load_file($file))
							{
								// Look for the first view node off of the root node.
								if ($layout = $xml->xpath('layout[1]'))
								{
									if (!empty($layout[0]['title']))
									{
										$titleParts[] = JText::_(trim((string) $layout[0]['title']));
									}
								}

								if (!empty($layout[0]->message[0]))
								{
									$item->item_type_desc = JText::_(trim((string) $layout[0]->message[0]));
								}
							}

							unset($xml);

							// Special case if neither a view nor layout title is found
							if (count($titleParts) == 1)
							{
								$titleParts[] = $vars['view'];
							}
						}

						$value = implode(' » ', $titleParts);
					}
					else
					{
						if (preg_match("/^index.php\?option=([a-zA-Z\-0-9_]*)/", $item->link, $result))
						{
							$value = JText::sprintf('COM_MENUS_TYPE_UNEXISTING', $result[1]);
						}
						else
						{
							$value = JText::_('COM_MENUS_TYPE_UNKNOWN');
						}
					}
					break;
			}

			$item->item_type = $value;
			$item->protected = $item->menutype == 'main';
		}

		// Levels filter.
		$options   = array();
		$options[] = JHtml::_('select.option', '1', JText::_('J1'));
		$options[] = JHtml::_('select.option', '2', JText::_('J2'));
		$options[] = JHtml::_('select.option', '3', JText::_('J3'));
		$options[] = JHtml::_('select.option', '4', JText::_('J4'));
		$options[] = JHtml::_('select.option', '5', JText::_('J5'));
		$options[] = JHtml::_('select.option', '6', JText::_('J6'));
		$options[] = JHtml::_('select.option', '7', JText::_('J7'));
		$options[] = JHtml::_('select.option', '8', JText::_('J8'));
		$options[] = JHtml::_('select.option', '9', JText::_('J9'));
		$options[] = JHtml::_('select.option', '10', JText::_('J10'));

		$this->f_levels = $options;

		// We don't need toolbar in the modal window.
		if ($this->getLayout() !== 'modal')
		{
			$this->addToolbar();
			$this->sidebar = JHtmlSidebar::render();
		}
		else
		{
			// In menu associations modal we need to remove language filter if forcing a language.
			if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'CMD'))
			{
				// If the language is forced we can't allow to select the language, so transform the language selector filter into a hidden field.
				$languageXml = new SimpleXMLElement('<field name="language" type="hidden" default="' . $forcedLanguage . '" />');
				$this->filterForm->setField($languageXml, 'filter', true);

				// Also, unset the active language filter so the search tools is not open by default with this filter.
				unset($this->activeFilters['language']);
			}
		}

		// Allow a system plugin to insert dynamic menu types to the list shown in menus:
		JEventDispatcher::getInstance()->trigger('onBeforeRenderMenuItems', array($this));

		parent::display($tpl);
	}

	/**
	 * Add the page title and toolbar.
	 *
	 * @return  void
	 *
	 * @since   1.6
	 */
	protected function addToolbar()
	{
		$menutypeId = (int) $this->state->get('menutypeid');

		$canDo = JHelperContent::getActions('com_menus', 'menu', (int) $menutypeId);
		$user  = JFactory::getUser();

		// Get the menu title
		$menuTypeTitle = $this->get('State')->get('menutypetitle');

		// Get the toolbar object instance
		$bar = JToolbar::getInstance('toolbar');

		if ($menuTypeTitle)
		{
			JToolbarHelper::title(JText::sprintf('COM_MENUS_VIEW_ITEMS_MENU_TITLE', $menuTypeTitle), 'list menumgr');
		}
		else
		{
			JToolbarHelper::title(JText::_('COM_MENUS_VIEW_ITEMS_ALL_TITLE'), 'list menumgr');
		}

		if ($canDo->get('core.create'))
		{
			JToolbarHelper::addNew('item.add');
		}

		$protected = $this->state->get('filter.menutype') == 'main';

		if ($canDo->get('core.edit') && !$protected)
		{
			JToolbarHelper::editList('item.edit');
		}

		if ($canDo->get('core.edit.state') && !$protected)
		{
			JToolbarHelper::publish('items.publish', 'JTOOLBAR_PUBLISH', true);
			JToolbarHelper::unpublish('items.unpublish', 'JTOOLBAR_UNPUBLISH', true);
		}

		if (JFactory::getUser()->authorise('core.admin') && !$protected)
		{
			JToolbarHelper::checkin('items.checkin', 'JTOOLBAR_CHECKIN', true);
		}

		if ($canDo->get('core.edit.state') && $this->state->get('filter.client_id') == 0)
		{
			JToolbarHelper::makeDefault('items.setDefault', 'COM_MENUS_TOOLBAR_SET_HOME');
		}

		if (JFactory::getUser()->authorise('core.admin'))
		{
			JToolbarHelper::custom('items.rebuild', 'refresh.png', 'refresh_f2.png', 'JToolbar_Rebuild', false);
		}

		// Add a batch button
		if (!$protected && $user->authorise('core.create', 'com_menus')
			&& $user->authorise('core.edit', 'com_menus')
			&& $user->authorise('core.edit.state', 'com_menus'))
		{
			$title = JText::_('JTOOLBAR_BATCH');

			// Instantiate a new JLayoutFile instance and render the batch button
			$layout = new JLayoutFile('joomla.toolbar.batch');

			$dhtml = $layout->render(array('title' => $title));
			$bar->appendButton('Custom', $dhtml, 'batch');
		}

		if (!$protected && $this->state->get('filter.published') == -2 && $canDo->get('core.delete'))
		{
			JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'items.delete', 'JTOOLBAR_EMPTY_TRASH');
		}
		elseif (!$protected && $canDo->get('core.edit.state'))
		{
			JToolbarHelper::trash('items.trash');
		}

		if ($canDo->get('core.admin') || $canDo->get('core.options'))
		{
			JToolbarHelper::divider();
			JToolbarHelper::preferences('com_menus');
		}

		JToolbarHelper::help('JHELP_MENUS_MENU_ITEM_MANAGER');
	}

	/**
	 * Returns an array of fields the table can be sorted by
	 *
	 * @return  array  Array containing the field name to sort by as the key and display text as value
	 *
	 * @since   3.0
	 */
	protected function getSortFields()
	{
		$this->state = $this->get('State');

		if ($this->state->get('filter.client_id') == 0)
		{
			return array(
				'a.lft'       => JText::_('JGRID_HEADING_ORDERING'),
				'a.published' => JText::_('JSTATUS'),
				'a.title'     => JText::_('JGLOBAL_TITLE'),
				'a.home'      => JText::_('COM_MENUS_HEADING_HOME'),
				'a.access'    => JText::_('JGRID_HEADING_ACCESS'),
				'association' => JText::_('COM_MENUS_HEADING_ASSOCIATION'),
				'language'    => JText::_('JGRID_HEADING_LANGUAGE'),
				'a.id'        => JText::_('JGRID_HEADING_ID')
			);
		}
		else
		{
			return array(
				'a.lft'       => JText::_('JGRID_HEADING_ORDERING'),
				'a.published' => JText::_('JSTATUS'),
				'a.title'     => JText::_('JGLOBAL_TITLE'),
				'a.id'        => JText::_('JGRID_HEADING_ID')
			);
		}
	}
}
views/menu/tmpl/edit.php000064400000003562152346104050011265 0ustar00<?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>
views/menu/tmpl/edit.xml000064400000000300152346104050011261 0ustar00<?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>
views/menu/tmpl/index.html000064400000000037152346104050011616 0ustar00<!DOCTYPE html><title></title>
views/menu/index.html000064400000000037152346104050010642 0ustar00<!DOCTYPE html><title></title>
views/menu/view.html.php000064400000004567152346104050011307 0ustar00<?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');
	}
}
views/menu/view.xml.php000064400000006624152346104050011137 0ustar00<?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);
		}
	}
}
views/menus/tmpl/default.php000064400000026731152346104050012152 0ustar00<?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;

// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');

JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');

$uri       = JUri::getInstance();
$return    = base64_encode($uri);
$user      = JFactory::getUser();
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn  = $this->escape($this->state->get('list.direction'));
$modMenuId = (int) $this->get('ModMenuId');

$script = array();
$script[] = 'jQuery(document).ready(function() {';

foreach ($this->items as $item) :
	if ($user->authorise('core.edit', 'com_menus')) :
		$script[] = '	function jSelectPosition_' . $item->id . '(name) {';
		$script[] = '		document.getElementById("' . $item->id . '").value = name;';
		$script[] = '		jQuery(".modal").modal("hide");';
		$script[] = '	};';
	endif;
endforeach;

$script[] = '	jQuery(".modal").on("hidden", function () {';
$script[] = '		setTimeout(function(){';
$script[] = '			window.parent.location.reload();';
$script[] = '		},1000);';
$script[] = '	});';
$script[] = '});';
$script[] = '
	(function (originalFn) {
		Joomla.submitform = function(task, form) {
		 	originalFn(task, form);
		 	if (task == "menu.exportXml") {
		 		document.adminForm.task.value = "";
		 	}
		};
	})(Joomla.submitform);
';

JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
?>
<form action="<?php echo JRoute::_('index.php?option=com_menus&view=menus'); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
	<div id="j-sidebar-container" class="span2">
		<?php echo $this->sidebar; ?>
	</div>
	<div id="j-main-container" class="span10">
<?php else : ?>
	<div id="j-main-container">
<?php endif; ?>
		<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this, 'options' => array('filterButton' => false))); ?>
		<div class="clearfix"> </div>
		<?php if (empty($this->items)) : ?>
			<div class="alert alert-no-items">
				<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
			</div>
		<?php else : ?>
			<table class="table table-striped" id="menuList">
				<thead>
					<tr>
						<th width="1%">
							<?php echo JHtml::_('grid.checkall'); ?>
						</th>
						<th>
							<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
						</th>
						<th width="10%" class="nowrap center">
							<span class="icon-publish" aria-hidden="true"></span>
							<span class="hidden-phone"><?php echo JText::_('COM_MENUS_HEADING_PUBLISHED_ITEMS'); ?></span>
						</th>
						<th width="10%" class="nowrap center">
							<span class="icon-unpublish" aria-hidden="true"></span>
							<span class="hidden-phone"><?php echo JText::_('COM_MENUS_HEADING_UNPUBLISHED_ITEMS'); ?></span>
						</th>
						<th width="10%" class="nowrap center">
							<span class="icon-trash" aria-hidden="true"></span>
							<span class="hidden-phone"><?php echo JText::_('COM_MENUS_HEADING_TRASHED_ITEMS'); ?></span>
						</th>
						<th width="20%" class="nowrap center">
							<span class="icon-cube" aria-hidden="true"></span>
							<span class="hidden-phone"><?php echo JText::_('COM_MENUS_HEADING_LINKED_MODULES'); ?></span>
						</th>
						<th width="1%" class="nowrap hidden-phone">
							<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
						</th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<td colspan="15">
							<?php echo $this->pagination->getListFooter(); ?>
						</td>
					</tr>
				</tfoot>
				<tbody>
				<?php foreach ($this->items as $i => $item) :
					$canEdit        = $user->authorise('core.edit',   'com_menus.menu.' . (int) $item->id);
					$canManageItems = $user->authorise('core.manage', 'com_menus.menu.' . (int) $item->id);
				?>
					<tr class="row<?php echo $i % 2; ?>">
						<td class="center">
							<?php echo JHtml::_('grid.id', $i, $item->id); ?>
						</td>
						<td>
							<?php if ($canManageItems) : ?>
							<a href="<?php echo JRoute::_('index.php?option=com_menus&view=items&menutype=' . $item->menutype); ?>">
								<?php echo $this->escape($item->title); ?></a>
							<?php else : ?>
								<?php echo $this->escape($item->title); ?>
							<?php endif; ?>
							<div class="small">
								<?php echo JText::_('COM_MENUS_MENU_MENUTYPE_LABEL'); ?>:
								<?php if ($canEdit) : ?>
									<a href="<?php echo JRoute::_('index.php?option=com_menus&task=menu.edit&id=' . $item->id); ?>" title="<?php echo $this->escape($item->description); ?>">
									<?php echo $this->escape($item->menutype); ?></a>
								<?php else : ?>
									<?php echo $this->escape($item->menutype); ?>
								<?php endif; ?>
							</div>
						</td>
						<td class="center btns">
							<?php if ($canManageItems) : ?>
								<a class="badge<?php if ($item->count_published > 0) echo ' badge-success'; ?>" href="<?php echo JRoute::_('index.php?option=com_menus&view=items&menutype=' . $item->menutype . '&filter[published]=1'); ?>">
									<?php echo $item->count_published; ?></a>
							<?php else : ?>
								<span class="badge<?php if ($item->count_published > 0) echo ' badge-success'; ?>">
									<?php echo $item->count_published; ?></span>
							<?php endif; ?>
						</td>
						<td class="center btns">
							<?php if ($canManageItems) : ?>
								<a class="badge<?php if ($item->count_unpublished > 0) echo ' badge-important'; ?>" href="<?php echo JRoute::_('index.php?option=com_menus&view=items&menutype=' . $item->menutype . '&filter[published]=0'); ?>">
									<?php echo $item->count_unpublished; ?></a>
							<?php else : ?>
								<span class="badge<?php if ($item->count_unpublished > 0) echo ' badge-important'; ?>">
									<?php echo $item->count_unpublished; ?></span>
							<?php endif; ?>
						</td>
						<td class="center btns">
							<?php if ($canManageItems) : ?>
								<a class="badge<?php if ($item->count_trashed > 0) echo ' badge-inverse'; ?>" href="<?php echo JRoute::_('index.php?option=com_menus&view=items&menutype=' . $item->menutype . '&filter[published]=-2'); ?>">
									<?php echo $item->count_trashed; ?></a>
							<?php else : ?>
								<span class="badge<?php if ($item->count_trashed > 0) echo ' badge-inverse'; ?>">
									<?php echo $item->count_trashed; ?></span>
							<?php endif; ?>
						</td>
						<td class="center">
							<?php if (isset($this->modules[$item->menutype])) : ?>
								<div class="btn-group">
									<button type="button" class="btn btn-small dropdown-toggle" data-toggle="dropdown">
										<?php echo JText::_('COM_MENUS_MODULES'); ?>
										<span class="caret"></span>
									</button>
									<ul class="dropdown-menu dropdown-reverse">
										<?php foreach ($this->modules[$item->menutype] as &$module) : ?>
											<li>
												<?php if ($user->authorise('core.edit', 'com_modules.module.' . (int) $module->id)) : ?>
													<?php $link = JRoute::_('index.php?option=com_modules&task=module.edit&id=' . $module->id . '&return=' . $return . '&tmpl=component&layout=modal'); ?>
													<a role="button" href="#moduleEdit<?php echo $module->id; ?>Modal" class="button" data-toggle="modal" title="<?php echo JText::_('COM_MENUS_EDIT_MODULE_SETTINGS'); ?>">
														<?php echo JText::sprintf('COM_MENUS_MODULE_ACCESS_POSITION', $this->escape($module->title), $this->escape($module->access_title), $this->escape($module->position)); ?></a>
												<?php else : ?>
													<a href="#" class="disabled" disabled="disabled">
														<?php echo JText::sprintf('COM_MENUS_MODULE_ACCESS_POSITION', $this->escape($module->title), $this->escape($module->access_title), $this->escape($module->position)); ?></a>
												<?php endif; ?>
											</li>
										<?php endforeach; ?>
									</ul>
								 </div>
								<?php foreach ($this->modules[$item->menutype] as &$module) : ?>
									<?php if ($user->authorise('core.edit', 'com_modules.module.' . (int) $module->id)) : ?>
										<?php $link = JRoute::_('index.php?option=com_modules&task=module.edit&id=' . $module->id . '&return=' . $return . '&tmpl=component&layout=modal'); ?>
										<?php echo JHtml::_(
												'bootstrap.renderModal',
												'moduleEdit' . $module->id . 'Modal',
												array(
													'title'       => JText::_('COM_MENUS_EDIT_MODULE_SETTINGS'),
													'backdrop'    => 'static',
													'keyboard'    => false,
													'closeButton' => false,
													'url'         => $link,
													'height'      => '400px',
													'width'       => '800px',
													'bodyHeight'  => '70',
													'modalWidth'  => '80',
													'footer'      => '<button type="button" class="btn" data-dismiss="modal"'
															. ' onclick="jQuery(\'#moduleEdit' . $module->id . 'Modal iframe\').contents().find(\'#closeBtn\').click();">'
															. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
															. '<button type="button" class="btn btn-primary"'
															. ' onclick="jQuery(\'#moduleEdit' . $module->id . 'Modal iframe\').contents().find(\'#saveBtn\').click();">'
															. JText::_('JSAVE') . '</button>'
															. '<button type="button" class="btn btn-success"'
															. ' onclick="jQuery(\'#moduleEdit' . $module->id . 'Modal iframe\').contents().find(\'#applyBtn\').click();">'
															. JText::_('JAPPLY') . '</button>',
												)
											); ?>
									<?php endif; ?>
								<?php endforeach; ?>
							<?php elseif ($modMenuId) : ?>
								<?php $link = JRoute::_('index.php?option=com_modules&task=module.add&eid=' . $modMenuId . '&params[menutype]=' . $item->menutype . '&tmpl=component&layout=modal'); ?>
								<button type="button" class="btn btn-small btn-primary" data-toggle="modal" data-target="#moduleAddModal"><?php echo JText::_('COM_MENUS_ADD_MENU_MODULE'); ?></button>
								<?php echo JHtml::_(
										'bootstrap.renderModal',
										'moduleAddModal',
										array(
											'title'       => JText::_('COM_MENUS_ADD_MENU_MODULE'),
											'backdrop'    => 'static',
											'keyboard'    => false,
											'closeButton' => false,
											'url'         => $link,
											'height'      => '400px',
											'width'       => '800px',
											'bodyHeight'  => '70',
											'modalWidth'  => '80',
											'footer'      => '<button type="button" class="btn" data-dismiss="modal"'
													. ' onclick="jQuery(\'#moduleAddModal iframe\').contents().find(\'#closeBtn\').click();">'
													. JText::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
													. '<button type="button" class="btn btn-primary"'
													. ' onclick="jQuery(\'#moduleAddModal iframe\').contents().find(\'#saveBtn\').click();">'
													. JText::_('JSAVE') . '</button>'
													. '<button type="button" class="btn btn-success"'
													. ' onclick="jQuery(\'#moduleAddModal iframe\').contents().find(\'#applyBtn\').click();">'
													. JText::_('JAPPLY') . '</button>',
										)
									); ?>
							<?php endif; ?>
						</td>
						<td class="hidden-phone">
							<?php echo $item->id; ?>
						</td>
					</tr>
					<?php endforeach; ?>
				</tbody>
			</table>
		<?php endif; ?>

		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
		<?php echo JHtml::_('form.token'); ?>
	</div>
</form>
views/menus/tmpl/default.xml000064400000000310152346104050012144 0ustar00<?xml version="1.0" encoding="utf-8"?>
<metadata>
	<layout title="COM_MENUS_MENUS_VIEW_DEFAULT_TITLE">
		<message>
			<![CDATA[COM_MENUS_MENUS_VIEW_DEFAULT_DESC]]>
		</message>
	</layout>
</metadata>
views/menus/tmpl/index.html000064400000000037152346104050012001 0ustar00<!DOCTYPE html><title></title>
views/menus/index.html000064400000000037152346104050011025 0ustar00<!DOCTYPE html><title></title>
views/menus/view.html.php000064400000004733152346104050011465 0ustar00<?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 Menus View.
 *
 * @since  1.6
 */
class MenusViewMenus extends JViewLegacy
{
	/**
	 * @var  mixed
	 */
	protected $items;

	/**
	 * @var  array
	 */
	protected $modules;

	/**
	 * @var  JPagination
	 */
	protected $pagination;

	/**
	 * @var  JObject
	 */
	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   1.6
	 */
	public function display($tpl = null)
	{
		$this->items      = $this->get('Items');
		$this->modules    = $this->get('Modules');
		$this->pagination = $this->get('Pagination');
		$this->state      = $this->get('State');

		if ($this->getLayout() == 'default')
		{
			$this->filterForm    = $this->get('FilterForm');
			$this->activeFilters = $this->get('ActiveFilters');
		}

		MenusHelper::addSubmenu('menus');

		// Check for errors.
		if (count($errors = $this->get('Errors')))
		{
			throw new Exception(implode("\n", $errors), 500);
		}

		$this->addToolbar();
		$this->sidebar = JHtmlSidebar::render();
		parent::display($tpl);
	}

	/**
	 * Add the page title and toolbar.
	 *
	 * @return  void
	 *
	 * @since   1.6
	 */
	protected function addToolbar()
	{
		$canDo = JHelperContent::getActions('com_menus');

		JToolbarHelper::title(JText::_('COM_MENUS_VIEW_MENUS_TITLE'), 'list menumgr');

		if ($canDo->get('core.create'))
		{
			JToolbarHelper::addNew('menu.add');
		}

		if ($canDo->get('core.edit'))
		{
			JToolbarHelper::editList('menu.edit');
		}

		if ($canDo->get('core.delete'))
		{
			JToolbarHelper::divider();
			JToolbarHelper::deleteList('COM_MENUS_MENU_CONFIRM_DELETE', 'menus.delete', 'JTOOLBAR_DELETE');
		}

		JToolbarHelper::custom('menus.rebuild', 'refresh.png', 'refresh_f2.png', 'JTOOLBAR_REBUILD', false);

		if ($canDo->get('core.admin') && $this->state->get('client_id') == 1)
		{
			JToolbarHelper::custom('menu.exportXml', 'download', 'download', 'COM_MENUS_MENU_EXPORT_BUTTON', true);
		}

		if ($canDo->get('core.admin') || $canDo->get('core.options'))
		{
			JToolbarHelper::divider();
			JToolbarHelper::preferences('com_menus');
		}

		JToolbarHelper::divider();
		JToolbarHelper::help('JHELP_MENUS_MENU_MANAGER');
	}
}
views/menutypes/tmpl/default.php000064400000003564152346104050013053 0ustar00<?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;

$input = JFactory::getApplication()->input;

// Checking if loaded via index.php or component.php
$tmpl = ($input->getCmd('tmpl') != '') ? '1' : '';

JHtml::_('behavior.core');
JFactory::getDocument()->addScriptDeclaration('
		setmenutype = function(type) {
			var tmpl = ' . json_encode($tmpl) . ';
			if (tmpl)
			{
				window.parent.Joomla.submitbutton("item.setType", type);
				window.parent.jQuery("#menuTypeModal").modal("hide");
			}
			else
			{
				window.location="index.php?option=com_menus&view=item&task=item.setType&layout=edit&type=" + type;
			}
		};
');

?>
<?php echo JHtml::_('bootstrap.startAccordion', 'collapseTypes', array('active' => 'slide1')); ?>
	<?php $i = 0; ?>
	<?php foreach ($this->types as $name => $list) : ?>
		<?php echo JHtml::_('bootstrap.addSlide', 'collapseTypes', $name, 'collapse' . ($i++)); ?>
			<ul class="nav nav-tabs nav-stacked">
				<?php foreach ($list as $title => $item) : ?>
					<li>
						<?php $menutype = array('id' => $this->recordId, 'title' => isset($item->type) ? $item->type : $item->title, 'request' => $item->request); ?>
						<?php $menutype = base64_encode(json_encode($menutype)); ?>
						<a class="choose_type" href="#" title="<?php echo JText::_($item->description); ?>"
							onclick="setmenutype('<?php echo $menutype; ?>')">
							<?php echo $title;?>
							<small class="muted">
								<?php echo JText::_($item->description); ?>
							</small>
						</a>
					</li>
				<?php endforeach; ?>
			</ul>
		<?php echo JHtml::_('bootstrap.endSlide'); ?>
	<?php endforeach; ?>
<?php echo JHtml::_('bootstrap.endSlide'); ?>
<?php echo JHtml::_('bootstrap.endAccordion');
views/menutypes/tmpl/index.html000064400000000032152346104050012676 0ustar00<html><body></body></html>views/menutypes/index.html000064400000000032152346104050011722 0ustar00<html><body></body></html>views/menutypes/view.html.php000064400000006332152346104050012364 0ustar00<?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;

/**
 * The HTML Menus Menu Item Types View.
 *
 * @since  1.6
 */
class MenusViewMenutypes extends JViewLegacy
{
	/**
	 * @var  JObject[]
	 */
	protected $types;

	/**
	 * 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)
	{
		$app            = JFactory::getApplication();
		$this->recordId = $app->input->getInt('recordId');

		$types = $this->get('TypeOptions');

		$this->addCustomTypes($types);

		$sortedTypes = array();

		foreach ($types as $name => $list)
		{
			$tmp = array();

			foreach ($list as $item)
			{
				$tmp[JText::_($item->title)] = $item;
			}

			uksort($tmp, 'strcasecmp');
			$sortedTypes[JText::_($name)] = $tmp;
		}

		uksort($sortedTypes, 'strcasecmp');

		$this->types = $sortedTypes;

		$this->addToolbar();

		parent::display($tpl);
	}

	/**
	 * Add the page title and toolbar.
	 *
	 * @return  void
	 *
	 * @since   3.0
	 */
	protected function addToolbar()
	{
		// Add page title
		JToolbarHelper::title(JText::_('COM_MENUS'), 'list menumgr');

		// Get the toolbar object instance
		$bar = JToolbar::getInstance('toolbar');

		// Cancel
		$title = JText::_('JTOOLBAR_CANCEL');
		$dhtml = "<button onClick=\"location.href='index.php?option=com_menus&view=items'\" class=\"btn\">
					<span class=\"icon-remove\" title=\"$title\"></span>
					$title</button>";
		$bar->appendButton('Custom', $dhtml, 'new');
	}

	/**
	 * Method to add system link types to the link types array
	 *
	 * @param   array  $types  The list of link types
	 *
	 * @return  void
	 *
	 * @since   3.7.0
	 */
	protected function addCustomTypes(&$types)
	{
		if (empty($types))
		{
			$types = array();
		}

		// Adding System Links
		$list           = array();
		$o              = new JObject;
		$o->title       = 'COM_MENUS_TYPE_EXTERNAL_URL';
		$o->type        = 'url';
		$o->description = 'COM_MENUS_TYPE_EXTERNAL_URL_DESC';
		$o->request     = null;
		$list[]         = $o;

		$o              = new JObject;
		$o->title       = 'COM_MENUS_TYPE_ALIAS';
		$o->type        = 'alias';
		$o->description = 'COM_MENUS_TYPE_ALIAS_DESC';
		$o->request     = null;
		$list[]         = $o;

		$o              = new JObject;
		$o->title       = 'COM_MENUS_TYPE_SEPARATOR';
		$o->type        = 'separator';
		$o->description = 'COM_MENUS_TYPE_SEPARATOR_DESC';
		$o->request     = null;
		$list[]         = $o;

		$o              = new JObject;
		$o->title       = 'COM_MENUS_TYPE_HEADING';
		$o->type        = 'heading';
		$o->description = 'COM_MENUS_TYPE_HEADING_DESC';
		$o->request     = null;
		$list[]         = $o;

		if ($this->get('state')->get('client_id') == 1)
		{
			$o              = new JObject;
			$o->title       = 'COM_MENUS_TYPE_CONTAINER';
			$o->type        = 'container';
			$o->description = 'COM_MENUS_TYPE_CONTAINER_DESC';
			$o->request     = null;
			$list[]         = $o;
		}

		$types['COM_MENUS_TYPE_SYSTEM'] = $list;
	}
}
views/index.html000064400000000037152346104050007676 0ustar00<!DOCTYPE html><title></title>
access.xml000064400000002510152346104050006525 0ustar00<?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>
config.xml000064400000002447152346104050006542 0ustar00<?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>
index.html000064400000000037152346104050006541 0ustar00<!DOCTYPE html><title></title>
menus.xml000064400000001771152346104050006423 0ustar00<?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>