- md5
- 3aedd0ef6a326079ecb5b5a9b51dd40e
- sha1
- 5a52b9756d8d91c97f1608df67d7f22b24bdda15
- sha256
- be5390edb9af122c8edd760ae011528c28a4804ecd8b9e370708705478ecf3a9
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @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\Templates\Administrator\View\Style;
\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;
/**
* View to edit a template style.
*
* @since 1.6
*/
class HtmlView extends BaseHtmlView
{
/**
* The \JObject (on success, false on failure)
*
* @var \JObject
*/
protected $item;
/**
* The form object
*
* @var \JForm
*/
protected $form;
/**
* The model state
*
* @var \JObject
*/
protected $state;
/**
* The actions the user is authorised to perform
*
* @var \JObject
* @since 4.0.0
*/
protected $canDo;
/**
* Execute and display a template script.
*
* @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->item = $this->get('Item');
$this->state = $this->get('State');
$this->form = $this->get('Form');
$this->canDo = ContentHelper::getActions('com_templates');
// 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()
{
Factory::getApplication()->input->set('hidemainmenu', true);
$isNew = ($this->item->id == 0);
$canDo = $this->canDo;
ToolbarHelper::title(
$isNew ? Text::_('COM_TEMPLATES_MANAGER_ADD_STYLE')
: Text::_('COM_TEMPLATES_MANAGER_EDIT_STYLE'), 'paint-brush thememanager'
);
$toolbarButtons = [];
// If not checked out, can save the item.
if ($canDo->get('core.edit'))
{
ToolbarHelper::apply('style.apply');
$toolbarButtons[] = ['save', 'style.save'];
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create'))
{
$toolbarButtons[] = ['save2copy', 'style.save2copy'];
}
ToolbarHelper::saveGroup(
$toolbarButtons,
'btn-success'
);
if (empty($this->item->id))
{
ToolbarHelper::cancel('style.cancel');
}
else
{
ToolbarHelper::cancel('style.cancel', 'JTOOLBAR_CLOSE');
}
ToolbarHelper::divider();
// Get the help information for the template item.
$lang = Factory::getLanguage();
$help = $this->get('Help');
if ($lang->hasKey($help->url))
{
$debug = $lang->setDebug(false);
$url = Text::_($help->url);
$lang->setDebug($debug);
}
else
{
$url = null;
}
ToolbarHelper::help($help->key, false, $url);
}
}
The same content is in 20 releases, Joomla 4.0.0-rc4 to 4.1.0-beta2. See them all, or every version of this file.