first commit

This commit is contained in:
2026-02-08 21:16:11 +01:00
commit e17b7026fd
8881 changed files with 1160453 additions and 0 deletions

View File

@@ -0,0 +1,208 @@
<?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
*/
namespace Joomla\Component\Menus\Administrator\View\Item;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* The HTML Menus Menu Item View.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* The Form object
*
* @var \Joomla\CMS\Form\Form
*/
protected $form;
/**
* The active item
*
* @var CMSObject
*/
protected $item;
/**
* @var mixed
*/
protected $modules;
/**
* The model state
*
* @var CMSObject
*/
protected $state;
/**
* The actions the user is authorised to perform
*
* @var CMSObject
* @since 3.7.0
*/
protected $canDo;
/**
* A list of view levels containing the id and title of the view level
*
* @var \stdClass[]
* @since 4.0.0
*/
protected $levels;
/**
* 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->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 = ContentHelper::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(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
}
// If we are forcing a language in modal (used for associations).
if ($this->getLayout() === 'modal' && $forcedLanguage = Factory::getApplication()->getInput()->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 = Factory::getApplication()->getInput();
$input->set('hidemainmenu', true);
$user = $this->getCurrentUser();
$isNew = ($this->item->id == 0);
$checkedOut = !(is_null($this->item->checked_out) || $this->item->checked_out == $user->get('id'));
$canDo = $this->canDo;
$clientId = $this->state->get('item.client_id', 0);
$toolbar = Toolbar::getInstance();
ToolbarHelper::title(Text::_($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')) {
$toolbar->apply('item.apply');
}
}
// If not checked out, can save the item.
if (!$isNew && !$checkedOut && $canDo->get('core.edit')) {
$toolbar->apply('item.apply');
}
$saveGroup = $toolbar->dropdownButton('save-group');
$saveGroup->configure(
function (Toolbar $childBar) use ($isNew, $checkedOut, $canDo) {
// 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')) {
$childBar->save('item.save');
}
// If not checked out, can save the item.
if (!$isNew && !$checkedOut && $canDo->get('core.edit')) {
$childBar->save('item.save');
}
// If the user can create new items, allow them to see Save & New
if ($canDo->get('core.create')) {
$childBar->save2new('item.save2new');
}
// If an existing item, can save to a copy only if we have create rights.
if (!$isNew && $canDo->get('core.create')) {
$childBar->save2copy('item.save2copy');
}
}
);
if (!$isNew && Associations::isEnabled() && ComponentHelper::isEnabled('com_associations') && $clientId != 1) {
$toolbar->standardButton('associations', 'JTOOLBAR_ASSOCIATIONS', 'item.editAssociations')
->icon('icon-contract')
->listCheck(false);
}
if ($isNew) {
$toolbar->cancel('item.cancel', 'JTOOLBAR_CANCEL');
} else {
$toolbar->cancel('item.cancel');
}
$toolbar->divider();
// Get the help information for the menu item.
$lang = $this->getLanguage();
$help = $this->get('Help');
if ($lang->hasKey($help->url)) {
$debug = $lang->setDebug(false);
$url = Text::_($help->url);
$lang->setDebug($debug);
} else {
$url = $help->url;
}
$toolbar->help($help->key, $help->local, $url);
}
}

View File

@@ -0,0 +1,381 @@
<?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
*/
namespace Joomla\Component\Menus\Administrator\View\Items;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* The HTML Menus Menu Items View.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* Array used for displaying the levels filter
*
* @var \stdClass[]
* @since 4.0.0
*/
protected $f_levels;
/**
* An array of items
*
* @var array
*/
protected $items;
/**
* The pagination object
*
* @var \Joomla\CMS\Pagination\Pagination
*/
protected $pagination;
/**
* The model state
*
* @var \Joomla\CMS\Object\CMSObject
*/
protected $state;
/**
* Form object for search filters
*
* @var \Joomla\CMS\Form\Form
*
* @since 4.0.0
*/
public $filterForm;
/**
* The active search filters
*
* @var array
* @since 4.0.0
*/
public $activeFilters;
/**
* Ordering of the items
*
* @var array
* @since 4.0.0
*/
protected $ordering;
/**
* 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 = $this->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');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
}
$this->ordering = [];
// 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 = Text::_('COM_MENUS_TYPE_EXTERNAL_URL');
break;
case 'alias':
$value = Text::_('COM_MENUS_TYPE_ALIAS');
break;
case 'separator':
$value = Text::_('COM_MENUS_TYPE_SEPARATOR');
break;
case 'heading':
$value = Text::_('COM_MENUS_TYPE_HEADING');
break;
case 'container':
$value = Text::_('COM_MENUS_TYPE_CONTAINER');
break;
case 'component':
default:
// Load language
$lang->load($item->componentname . '.sys', JPATH_ADMINISTRATOR)
|| $lang->load($item->componentname . '.sys', JPATH_ADMINISTRATOR . '/components/' . $item->componentname);
if (!empty($item->componentname)) {
$titleParts = [];
$titleParts[] = Text::_($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[] = Text::_($viewTitle);
}
}
}
}
$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)
|| $lang->load('tpl_' . $temp[0] . '.sys', JPATH_SITE . '/templates/' . $temp[0]);
} 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 . '/tmpl/' . $vars['view']
. '/' . $vars['layout'] . '.xml';
if (!file_exists($file)) {
$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[] = Text::_(trim((string) $layout[0]['title']));
}
}
if (!empty($layout[0]->message[0])) {
$item->item_type_desc = Text::_(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 = Text::sprintf('COM_MENUS_TYPE_UNEXISTING', $result[1]);
} else {
$value = Text::_('COM_MENUS_TYPE_UNKNOWN');
}
}
break;
}
$item->item_type = $value;
$item->protected = $item->menutype == 'main';
}
// Levels filter.
$options = [];
$options[] = HTMLHelper::_('select.option', '1', Text::_('J1'));
$options[] = HTMLHelper::_('select.option', '2', Text::_('J2'));
$options[] = HTMLHelper::_('select.option', '3', Text::_('J3'));
$options[] = HTMLHelper::_('select.option', '4', Text::_('J4'));
$options[] = HTMLHelper::_('select.option', '5', Text::_('J5'));
$options[] = HTMLHelper::_('select.option', '6', Text::_('J6'));
$options[] = HTMLHelper::_('select.option', '7', Text::_('J7'));
$options[] = HTMLHelper::_('select.option', '8', Text::_('J8'));
$options[] = HTMLHelper::_('select.option', '9', Text::_('J9'));
$options[] = HTMLHelper::_('select.option', '10', Text::_('J10'));
$this->f_levels = $options;
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal') {
$this->addToolbar();
// We do not need to filter by language when multilingual is disabled
if (!Multilanguage::isEnabled()) {
unset($this->activeFilters['language']);
$this->filterForm->removeField('language', 'filter');
}
} else {
// In menu associations modal we need to remove language filter if forcing a language.
if ($forcedLanguage = Factory::getApplication()->getInput()->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:
Factory::getApplication()->triggerEvent('onBeforeRenderMenuItems', [$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 = ContentHelper::getActions('com_menus', 'menu', (int) $menutypeId);
$user = $this->getCurrentUser();
// Get the menu title
$menuTypeTitle = $this->get('State')->get('menutypetitle');
// Get the toolbar object instance
$toolbar = Toolbar::getInstance('toolbar');
if ($menuTypeTitle) {
ToolbarHelper::title(Text::sprintf('COM_MENUS_VIEW_ITEMS_MENU_TITLE', $menuTypeTitle), 'list menumgr');
} else {
ToolbarHelper::title(Text::_('COM_MENUS_VIEW_ITEMS_ALL_TITLE'), 'list menumgr');
}
if ($canDo->get('core.create')) {
$toolbar->addNew('item.add');
}
$protected = $this->state->get('filter.menutype') == 'main';
if (
($canDo->get('core.edit.state') || $this->getCurrentUser()->authorise('core.admin')) && !$protected
|| $canDo->get('core.edit.state') && $this->state->get('filter.client_id') == 0
) {
$dropdown = $toolbar->dropdownButton('status-group')
->text('JTOOLBAR_CHANGE_STATUS')
->toggleSplit(false)
->icon('icon-ellipsis-h')
->buttonClass('btn btn-action')
->listCheck(true);
$childBar = $dropdown->getChildToolbar();
if ($canDo->get('core.edit.state') && !$protected) {
$childBar->publish('items.publish')->listCheck(true);
$childBar->unpublish('items.unpublish')->listCheck(true);
}
if ($this->getCurrentUser()->authorise('core.admin') && !$protected) {
$childBar->checkin('items.checkin')->listCheck(true);
}
if ($canDo->get('core.edit.state') && $this->state->get('filter.published') != -2) {
if ($this->state->get('filter.client_id') == 0) {
$childBar->makeDefault('items.setDefault')->listCheck(true);
}
if (!$protected) {
$childBar->trash('items.trash')->listCheck(true);
}
}
// 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')
) {
$childBar->popupButton('batch')
->text('JTOOLBAR_BATCH')
->selector('collapseModal')
->listCheck(true);
}
}
if ($this->getCurrentUser()->authorise('core.admin')) {
$toolbar->standardButton('refresh')
->text('JTOOLBAR_REBUILD')
->task('items.rebuild');
}
if (!$protected && $this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
$toolbar->delete('items.delete')
->text('JTOOLBAR_EMPTY_TRASH')
->message('JGLOBAL_CONFIRM_DELETE')
->listCheck(true);
}
if ($canDo->get('core.admin') || $canDo->get('core.options')) {
$toolbar->preferences('com_menus');
}
$toolbar->help('Menus:_Items');
}
}

View File

@@ -0,0 +1,145 @@
<?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
*/
namespace Joomla\Component\Menus\Administrator\View\Menu;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* The HTML Menus Menu Item View.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* The Form object
*
* @var \Joomla\CMS\Form\Form
*/
protected $form;
/**
* The active item
*
* @var object
*/
protected $item;
/**
* The model state
*
* @var CMSObject
*/
protected $state;
/**
* The actions the user is authorised to perform
*
* @var CMSObject
*/
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 = ContentHelper::getActions('com_menus', 'menu', $this->item->id);
// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
}
parent::display($tpl);
$this->addToolbar();
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$input = Factory::getApplication()->getInput();
$input->set('hidemainmenu', true);
$isNew = ($this->item->id == 0);
$toolbar = Toolbar::getInstance();
ToolbarHelper::title(Text::_($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') && $this->canDo->get('core.edit')) {
$toolbar->apply('menu.apply');
}
// If user can edit, can save the item.
if (!$isNew && $this->canDo->get('core.edit')) {
$toolbar->apply('menu.apply');
}
$saveGroup = $toolbar->dropdownButton('save-group');
$canDo = $this->canDo;
$saveGroup->configure(
function (Toolbar $childBar) use ($isNew, $canDo) {
// 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')) {
$childBar->save('menu.save');
}
// If user can edit, can save the item.
if (!$isNew && $canDo->get('core.edit')) {
$childBar->save('menu.save');
}
// If the user can create new items, allow them to see Save & New
if ($canDo->get('core.create')) {
$childBar->save2new('menu.save2new');
}
}
);
if ($isNew) {
$toolbar->cancel('menu.cancel', 'JTOOLBAR_CANCEL');
} else {
$toolbar->cancel('menu.cancel');
}
$toolbar->divider();
$toolbar->help('Menus:_Edit');
}
}

View File

@@ -0,0 +1,184 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Menus\Administrator\View\Menu;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Log\Log;
use Joomla\CMS\Menu\AdministratorMenuItem;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Router\Route;
use Joomla\Component\Menus\Administrator\Helper\MenusHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* The HTML Menus Menu Item View.
*
* @since 3.8.0
*/
class XmlView extends BaseHtmlView
{
/**
* @var \stdClass[]
*
* @since 3.8.0
*/
protected $items;
/**
* @var \Joomla\CMS\Object\CMSObject
*
* @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 = Factory::getApplication();
$menutype = $app->getInput()->getCmd('menutype');
if ($menutype) {
$root = MenusHelper::getMenuItems($menutype, true);
}
if (!$root->hasChildren()) {
Log::add(Text::_('COM_MENUS_SELECT_MENU_FIRST_EXPORT'), Log::WARNING, 'jerror');
$app->redirect(Route::_('index.php?option=com_menus&view=menus', false));
return;
}
$this->items = $root->getChildren();
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" ?><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)) {
Log::add("Headers already sent at $file:$line.", Log::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");
$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 AdministratorMenuItem $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');
if ($item->title) {
$node['title'] = htmlentities($item->title, ENT_XML1);
}
$node['type'] = $item->type;
if ($item->element) {
$node['element'] = $item->element;
}
if ($item->link) {
$node['link'] = $item->link;
}
if (isset($item->class) && trim($item->class)) {
$node['class'] = htmlentities(trim($item->class), ENT_XML1);
}
if ($item->access) {
$node['access'] = $item->access;
}
if ($item->browserNav) {
$node['target'] = '_blank';
}
if ($item->getParams()->get('ajax-badge')) {
$node['ajax-badge'] = $item->getParams()->get('ajax-badge');
}
if ($item->icon) {
$node['icon'] = $item->icon;
}
if ($item->getParams()->get('menu-quicktask')) {
$node['quicktask'] = $item->getParams()->get('menu-quicktask');
if ($item->getParams()->get('menu-quicktask-title')) {
$node['quicktask-title'] = $item->getParams()->get('menu-quicktask-title');
}
if ($item->getParams()->get('menu-quicktask-icon')) {
$node['quicktask-icon'] = $item->getParams()->get('menu-quicktask-icon');
}
if ($item->getParams()->get('menu-quicktask-permission')) {
$node['quicktask-permission'] = $item->getParams()->get('menu-quicktask-permission');
}
}
if ($item->getParams()->get('dashboard')) {
$node['dashboard'] = $item->getParams()->get('dashboard');
}
if ($item->getParams() && $hideitems = $item->getParams()->get('hideitems')) {
$item->getParams()->set('hideitems', $this->getModel('Menu')->getExtensionElementsForMenuItems($hideitems));
$node->addChild('params', htmlentities((string) $item->getParams(), ENT_XML1));
}
if ($item->hasChildren()) {
foreach ($item->getChildren() as $sub) {
$this->addXmlChild($node, $sub);
}
}
}
}

View File

@@ -0,0 +1,145 @@
<?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
*/
namespace Joomla\Component\Menus\Administrator\View\Menus;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* The HTML Menus Menu Menus View.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* An array of items
*
* @var array
*/
protected $items;
/**
* List of all mod_mainmenu modules collated by menutype
*
* @var array
*/
protected $modules;
/**
* The pagination object
*
* @var \Joomla\CMS\Pagination\Pagination
*/
protected $pagination;
/**
* The model state
*
* @var \Joomla\CMS\Object\CMSObject
*/
protected $state;
/**
* Form object for search filters
*
* @var \Joomla\CMS\Form\Form
*
* @since 4.0.0
*/
public $filterForm;
/**
* The active search filters
*
* @var array
* @since 4.0.0
*/
public $activeFilters;
/**
* 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');
}
// Check for errors.
if (count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
$canDo = ContentHelper::getActions('com_menus');
$toolbar = Toolbar::getInstance();
ToolbarHelper::title(Text::_('COM_MENUS_VIEW_MENUS_TITLE'), 'list menumgr');
if ($canDo->get('core.create')) {
$toolbar->addNew('menu.add');
}
if ($canDo->get('core.delete')) {
$toolbar->divider();
$toolbar->delete('menus.delete')
->message('COM_MENUS_MENU_CONFIRM_DELETE');
}
if ($canDo->get('core.admin') && $this->state->get('client_id') == 1) {
$toolbar->standardButton('download', 'COM_MENUS_MENU_EXPORT_BUTTON', 'menu.exportXml')
->icon('icon-download')
->listCheck(true);
}
if ($canDo->get('core.admin') || $canDo->get('core.options')) {
$toolbar->divider();
$toolbar->preferences('com_menus');
}
$toolbar->divider();
$toolbar->help('Menus');
}
}

View File

@@ -0,0 +1,167 @@
<?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
*/
namespace Joomla\Component\Menus\Administrator\View\Menutypes;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* The HTML Menus Menu Item Types View.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* The menu type id
*
* @var integer
* @since 4.0.0
*/
protected $recordId;
/**
* Array of menu types
*
* @var CMSObject[]
*
* @since 3.7.0
*/
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 = Factory::getApplication();
$this->recordId = $app->getInput()->getInt('recordId');
$types = $this->get('TypeOptions');
$this->addCustomTypes($types);
$sortedTypes = [];
foreach ($types as $name => $list) {
$tmp = [];
foreach ($list as $item) {
$tmp[Text::_($item->title)] = $item;
}
uksort($tmp, 'strcasecmp');
$sortedTypes[Text::_($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
ToolbarHelper::title(Text::_('COM_MENUS'), 'list menumgr');
$toolbar = Toolbar::getInstance();
// Cancel
$title = Text::_('JTOOLBAR_CANCEL');
$dhtml = "<button onClick=\"location.href='index.php?option=com_menus&view=items'\" class=\"btn\">
<span class=\"icon-times\" title=\"$title\"></span>
$title</button>";
$toolbar->customButton('new')
->html($dhtml);
}
/**
* 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 = [];
}
// Adding System Links
$list = [];
$o = new CMSObject();
$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 CMSObject();
$o->title = 'COM_MENUS_TYPE_ALIAS';
$o->type = 'alias';
$o->description = 'COM_MENUS_TYPE_ALIAS_DESC';
$o->request = null;
$list[] = $o;
$o = new CMSObject();
$o->title = 'COM_MENUS_TYPE_SEPARATOR';
$o->type = 'separator';
$o->description = 'COM_MENUS_TYPE_SEPARATOR_DESC';
$o->request = null;
$list[] = $o;
$o = new CMSObject();
$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 CMSObject();
$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;
}
}