- md5
- eeb96195a22e96d4498e72e2ff6c52bb
- sha1
- bb78d8e3637e77935be64273ec07c00db8dd5f16
- sha256
- 9e0147693de640d0feb00e30d893baa1408eaf3726beb8b7c176b00e7376e314
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
<?php
/**
* @package Joomla.Administrator
* @subpackage com_scheduler
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Scheduler\Administrator\View\Tasks;
// Restrict direct access
\defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
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\Pagination\Pagination;
use Joomla\CMS\Toolbar\Button\DropdownButton;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
/**
* MVC View for the Tasks list page.
*
* @since 4.1.0
*/
class HtmlView extends BaseHtmlView
{
/**
* Array of task items.
*
* @var array
* @since 4.1.0
*/
protected $items;
/**
* The pagination object.
*
* @var Pagination
* @since 4.1.0
* @todo Test pagination.
*/
protected $pagination;
/**
* The model state.
*
* @var CMSObject
* @since 4.1.0
*/
protected $state;
/**
* A Form object for search filters.
*
* @var Form
* @since 4.1.0
*/
public $filterForm;
/**
* The active search filters.
*
* @var array
* @since 4.1.0
*/
public $activeFilters;
/**
* Is this view in an empty state?
*
* @var boolean
* @since 4.1.0
*/
private $isEmptyState = false;
/**
* @inheritDoc
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*
* @since 4.1.0
* @throws \Exception
*/
public function display($tpl = null): void
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState'))
{
$this->setLayout('empty_state');
}
// Check for errors.
if (\count($errors = $this->get('Errors')))
{
throw new GenericDataException(implode("\n", $errors), 500);
}
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')
{
$this->addToolbar();
}
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 4.1.0
* @throws \Exception
*/
protected function addToolbar(): void
{
$canDo = ContentHelper::getActions('com_scheduler');
$user = Factory::getApplication()->getIdentity();
/*
* Get the toolbar object instance
* !! @todo : Replace usage with ToolbarFactoryInterface
*/
$toolbar = Toolbar::getInstance();
ToolbarHelper::title(Text::_('COM_SCHEDULER_MANAGER_TASKS'), 'clock');
if ($canDo->get('core.create'))
{
$toolbar->linkButton('new', 'JTOOLBAR_NEW')
->url('index.php?option=com_scheduler&view=select&layout=default')
->buttonClass('btn btn-success')
->icon('icon-new');
}
if (!$this->isEmptyState && ($canDo->get('core.edit.state') || $user->authorise('core.admin')))
{
/** @var DropdownButton $dropdown */
$dropdown = $toolbar->dropdownButton('status-group')
->toggleSplit(false)
->text('JTOOLBAR_CHANGE_STATUS')
->icon('icon-ellipsis-h')
->buttonClass('btn btn-action')
->listCheck(true);
$childBar = $dropdown->getChildToolbar();
// Add the batch Enable, Disable and Trash buttons if privileged
if ($canDo->get('core.edit.state'))
{
$childBar->publish('tasks.publish', 'JTOOLBAR_ENABLE')->listCheck(true);
$childBar->unpublish('tasks.unpublish', 'JTOOLBAR_DISABLE')->listCheck(true);
if ($canDo->get('core.admin'))
{
$childBar->checkin('tasks.checkin')->listCheck(true);
}
$childBar->checkin('tasks.unlock', 'COM_SCHEDULER_TOOLBAR_UNLOCK')->listCheck(true)->icon('icon-unlock');
// We don't want the batch Trash button if displayed entries are all trashed
if ($this->state->get('filter.state') != -2)
{
$childBar->trash('tasks.trash')->listCheck(true);
}
}
}
// Add "Empty Trash" button if filtering by trashed.
if ($this->state->get('filter.state') == -2 && $canDo->get('core.delete'))
{
$toolbar->delete('tasks.delete')
->message('JGLOBAL_CONFIRM_DELETE')
->text('JTOOLBAR_EMPTY_TRASH')
->listCheck(true);
}
// Link to component preferences if user has admin privileges
if ($canDo->get('core.admin') || $canDo->get('core.options'))
{
$toolbar->preferences('com_scheduler');
}
$toolbar->help('Scheduled_Tasks');
}
}
The same content is in 16 releases, Joomla 4.1.1-rc1 to 4.2.0-beta2. See them all, or every version of this file.