- md5
- 99614544a9ad1ff6652359f5edf95802
- sha1
- 4753c71daf9b5372bfb803626eb64e774f21d894
- sha256
- 8b8347a92b1c93d7a6ceca0ac56b3c046b9a848621236491a3b79f104f04b1fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
<?php
/**
* @package Joomla.Administrator
* @subpackage com_workflow
*
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Workflow\Administrator\View\Transitions;
\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\Router\Route;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
/**
* Transitions view class for the Workflow package.
*
* @since 4.0.0
*/
class HtmlView extends BaseHtmlView
{
/**
* An array of transitions
*
* @var array
* @since 4.0.0
*/
protected $transitions;
/**
* The model state
*
* @var object
* @since 4.0.0
*/
protected $state;
/**
* The HTML for displaying sidebar
*
* @var string
* @since 4.0.0
*/
protected $sidebar;
/**
* The pagination object
*
* @var \JPagination
* @since 4.0.0
*/
protected $pagination;
/**
* Form object for search filters
*
* @var \JForm
* @since 4.0.0
*/
public $filterForm;
/**
* The active search filters
*
* @var array
* @since 4.0.0
*/
public $activeFilters;
/**
* The current workflow
*
* @var object
* @since 4.0.0
*/
protected $workflow;
/**
* The ID of current workflow
*
* @var integer
* @since 4.0.0
*/
protected $workflowID;
/**
* The name of current extension
*
* @var string
* @since 4.0.0
*/
protected $extension;
/**
* The section of the current extension
*
* @var string
* @since 4.0.0
*/
protected $section;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*
* @since 4.0.0
*/
public function display($tpl = null)
{
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new GenericDataException(implode("\n", $errors), 500);
}
$this->state = $this->get('State');
$this->transitions = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
$this->workflow = $this->get('Workflow');
$this->workflowID = $this->workflow->id;
$parts = explode('.', $this->workflow->extension);
$this->extension = array_shift($parts);
if (!empty($parts))
{
$this->section = array_shift($parts);
}
$this->addToolbar();
return parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 4.0.0
*/
protected function addToolbar()
{
$canDo = ContentHelper::getActions($this->extension, 'workflow', $this->workflowID);
$user = Factory::getUser();
$toolbar = Toolbar::getInstance('toolbar');
ToolbarHelper::title(Text::sprintf('COM_WORKFLOW_TRANSITIONS_LIST', Text::_($this->state->get('active_workflow'))), 'address contact');
$arrow = Factory::getLanguage()->isRtl() ? 'arrow-right' : 'arrow-left';
ToolbarHelper::link(
Route::_('index.php?option=com_workflow&view=workflows&extension=' . $this->escape($this->workflow->extension)),
'JTOOLBAR_BACK',
$arrow
);
if ($canDo->get('core.create'))
{
$toolbar->addNew('transition.add');
}
if ($canDo->get('core.edit.state') || $user->authorise('core.admin'))
{
$dropdown = $toolbar->dropdownButton('status-group')
->text('JTOOLBAR_CHANGE_STATUS')
->toggleSplit(false)
->icon('icon-ellipsis-h')
->buttonClass('btn btn-action')
->listCheck(true);
$childBar = $dropdown->getChildToolbar();
$childBar->publish('transitions.publish', 'JTOOLBAR_ENABLE');
$childBar->unpublish('transitions.unpublish', 'JTOOLBAR_DISABLE');
if ($canDo->get('core.admin'))
{
$childBar->checkin('transitions.checkin')->listCheck(true);
}
if ($this->state->get('filter.published') !== '-2')
{
$childBar->trash('transitions.trash');
}
}
if ($this->state->get('filter.published') === '-2' && $canDo->get('core.delete'))
{
$toolbar->delete('transitions.delete')
->text('JTOOLBAR_EMPTY_TRASH')
->message('JGLOBAL_CONFIRM_DELETE')
->listCheck(true);
}
$toolbar->help('JHELP_COMPONENTS_WORKFLOW_TRANSITIONS_LIST');
}
}
The same content is in 2 releases, Joomla 4.0.0-beta6 to 4.0.0-beta7. See them all, or every version of this file.