Files
System-testowy/administrator/components/com_testquestions/src/View/Sets/HtmlView.php
T

70 lines
2.1 KiB
PHP

<?php
namespace Komponent\Component\Testquestions\Administrator\View\Sets;
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;
class HtmlView extends BaseHtmlView
{
protected $items;
protected $pagination;
protected $state;
protected $subjects;
protected $canUnpublishAll = false;
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->subjects = $this->get('Subjects');
$user = $this->getCurrentUser();
$this->canUnpublishAll = $user->authorise('core.edit.state', 'com_testquestions') || $user->authorise('core.edit', 'com_testquestions');
if (count($errors = $this->get('Errors'))) {
throw new \RuntimeException(implode("\n", $errors));
}
$this->addToolbar();
return parent::display($tpl);
}
protected function addToolbar()
{
$user = $this->getCurrentUser();
$this->getDocument()->setTitle(Text::_('COM_TESTQUESTIONS_SETS'));
if ($user->authorise('core.create', 'com_testquestions')) {
ToolbarHelper::addNew('set.add', 'JTOOLBAR_NEW');
}
if ($user->authorise('core.edit', 'com_testquestions')) {
ToolbarHelper::editList('set.edit', 'JTOOLBAR_EDIT');
}
if ($user->authorise('core.delete', 'com_testquestions')) {
ToolbarHelper::deleteList('', 'sets.delete', 'JTOOLBAR_DELETE');
}
ToolbarHelper::link(
'index.php?option=com_testquestions&view=questions',
'COM_TESTQUESTIONS_QUESTIONS',
'list'
);
ToolbarHelper::link(
'index.php?option=com_testquestions&view=subjects',
'COM_TESTQUESTIONS_SUBJECTS',
'list'
);
ToolbarHelper::link(
'index.php?option=com_testquestions&view=results',
'COM_TESTQUESTIONS_RESULTS',
'list'
);
}
}