- md5
- 17801876ce969890a5bb6e6da9f3f5fd
- sha1
- 90b58e8ccbd9c8ceae23f14f5bf9c0266caf64e1
- sha256
- 2f640dcc49b56888d63b061fea2fc36da159d1848ec68661c814c86609d35a73
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
<?php
/**
* @package Joomla.Administrator
* @subpackage com_workflow
*
* @copyright (C) 2026 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\Graph;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\Component\Workflow\Administrator\Model\GraphModel;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* View class to display the entire workflow graph
*
* @since 6.1.0
*/
class HtmlView extends BaseHtmlView
{
/**
* The model state
*
* @var object
* @since 6.1.0
*/
protected $state;
/**
* Items array
*
* @var object
* @since 6.1.0
*/
protected $item;
/**
* The name of current extension
*
* @var string
* @since 6.1.0
*/
protected $extension;
/**
* The ID of current workflow
*
* @var integer
* @since 6.1.0
*/
protected $workflow;
/**
* The section of the current extension
*
* @var string
* @since 6.1.0
*/
protected $section;
/**
* Display the view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*
* @since 6.1.0
*/
public function display($tpl = null)
{
/** @var GraphModel $model */
$model = $this->getModel();
// Get the data
try {
$this->state = $model->getState();
$this->item = $model->getItem();
} catch (\Exception $e) {
throw new GenericDataException(Text::_('COM_WORKFLOW_GRAPH_ERROR_FETCHING_MODEL') . $e->getMessage(), 500, $e);
}
$extension = $this->state->get('filter.extension');
$parts = explode('.', $extension);
$this->extension = array_shift($parts);
if (!empty($parts)) {
$this->section = array_shift($parts);
}
// Prepare workflow data for frontend
$options = [
'apiBaseUrl' => Route::_('index.php?option=com_workflow'),
'extension' => $this->escape($this->extension),
'workflowId' => $this->item->id,
];
// Set the toolbar
$this->addToolbar();
// Inject workflow data as JS options for frontend
$this->getDocument()->addScriptOptions('com_workflow', $options);
// Display the template
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 6.1.0
*/
protected function addToolbar()
{
Factory::getApplication()->getInput()->set('hidemainmenu', true);
$user = $this->getCurrentUser();
$userId = $user->id;
$toolbar = $this->getDocument()->getToolbar();
$canDo = ContentHelper::getActions($this->extension, 'workflow', $this->item->id);
ToolbarHelper::title(Text::_('COM_WORKFLOW_GRAPH_WORKFLOWS_EDIT'), 'file-alt contact');
// Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
$itemEditable = $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $userId);
$toolbar->link(
'JTOOLBAR_CLOSE',
Route::_('index.php?option=com_workflow&view=workflows&extension=' . $this->escape($this->item->extension))
)
->icon('icon-cancel')->buttonClass('btn btn-danger');
if ($itemEditable) {
$toolbar->help('Workflow');
$shortcutsLayout = new FileLayout('toolbar.shortcuts', JPATH_ADMINISTRATOR . '/components/com_workflow/layouts');
$toolbar->customButton('Shortcuts')
->html($shortcutsLayout->render([]));
}
}
}
The same content is in 28 releases, Joomla 6.1.0-beta1 to 6.2.1-rc1. See them all, or every version of this file.