- md5
- e3c49ab248fc1a2888c7222d89c2dac0
- sha1
- 1db2467f15d49b69d4a87b3603831072132fa57d
- sha256
- 34d5c7bc6607fde5e3498d5a73a51d9e251038900f10b8823d7ecf971e53b7c8
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
<?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;
\defined('_JEXEC') or die;
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\Toolbar\ToolbarHelper;
/**
* The HTML Menus Menu Item View.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* The \JForm object
*
* @var \JForm
*/
protected $form;
/**
* The active item
*
* @var object
*/
protected $item;
/**
* The model state
*
* @var \JObject
*/
protected $state;
/**
* The actions the user is authorised to perform
*
* @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 = 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()->input;
$input->set('hidemainmenu', true);
$isNew = ($this->item->id == 0);
ToolbarHelper::title(Text::_($isNew ? 'COM_MENUS_VIEW_NEW_MENU_TITLE' : 'COM_MENUS_VIEW_EDIT_MENU_TITLE'), 'list menu');
$toolbarButtons = [];
// 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'))
{
ToolbarHelper::apply('menu.apply');
}
$toolbarButtons[] = ['save', 'menu.save'];
}
// If user can edit, can save the item.
if (!$isNew && $this->canDo->get('core.edit'))
{
ToolbarHelper::apply('menu.apply');
$toolbarButtons[] = ['save', 'menu.save'];
}
// If the user can create new items, allow them to see Save & New
if ($this->canDo->get('core.create'))
{
$toolbarButtons[] = ['save2new', 'menu.save2new'];
}
ToolbarHelper::saveGroup(
$toolbarButtons,
'btn-success'
);
if ($isNew)
{
ToolbarHelper::cancel('menu.cancel');
}
else
{
ToolbarHelper::cancel('menu.cancel', 'JTOOLBAR_CLOSE');
}
ToolbarHelper::divider();
ToolbarHelper::help('Menus:_Edit');
}
}
The same content is in 12 releases, Joomla 4.0.4-rc1 to 4.1.0-beta2. See them all, or every version of this file.