- md5
- 2a0226cac82a4aef70ebf0bbc614220d
- sha1
- e542a6c8e2fdf6212114ba77c6f1b05f183c9bcb
- sha256
- b3c1f0d39f0b83fa1ddd20ca624d752bc4da493d78c6a72198dc8922462981a5
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
<?php
/**
* @package Joomla.Administrator
* @subpackage com_menus
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @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\Helper\ContentHelper;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
/**
* 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 \JViewGenericdataexception(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);
ToolbarHelper::title(\JText::_($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'))
{
$toolbarButtons[] = ['apply', 'menu.apply'];
}
$toolbarButtons[] = ['save', 'menu.save'];
}
// If user can edit, can save the item.
if (!$isNew && $this->canDo->get('core.edit'))
{
$toolbarButtons[] = ['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('JHELP_MENUS_MENU_MANAGER_EDIT');
}
}
No other release has this exact content. See every version of this file.