primo commit
This commit is contained in:
@ -0,0 +1,175 @@
|
||||
<?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\Stage;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
use Joomla\Component\Workflow\Administrator\Helper\StageHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View class to add or edit a stage of a workflow
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var object
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* From object to generate fields
|
||||
*
|
||||
* @var \Joomla\CMS\Form\Form
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $form;
|
||||
|
||||
/**
|
||||
* Items array
|
||||
*
|
||||
* @var object
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* 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 item view
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
// Get the Data
|
||||
$this->state = $this->get('State');
|
||||
$this->form = $this->get('Form');
|
||||
$this->item = $this->get('Item');
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
$extension = $this->state->get('filter.extension');
|
||||
|
||||
$parts = explode('.', $extension);
|
||||
|
||||
$this->extension = array_shift($parts);
|
||||
|
||||
if (!empty($parts)) {
|
||||
$this->section = array_shift($parts);
|
||||
}
|
||||
|
||||
// Set the toolbar
|
||||
$this->addToolbar();
|
||||
|
||||
// Display the template
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function addToolbar()
|
||||
{
|
||||
Factory::getApplication()->getInput()->set('hidemainmenu', true);
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$userId = $user->id;
|
||||
$isNew = empty($this->item->id);
|
||||
$toolbar = $this->getDocument()->getToolbar();
|
||||
|
||||
$canDo = StageHelper::getActions($this->extension, 'stage', $this->item->id);
|
||||
|
||||
ToolbarHelper::title(empty($this->item->id) ? Text::_('COM_WORKFLOW_STAGE_ADD') : Text::_('COM_WORKFLOW_STAGE_EDIT'), 'address');
|
||||
|
||||
if ($isNew) {
|
||||
// For new records, check the create permission.
|
||||
if ($canDo->get('core.create')) {
|
||||
$toolbar->apply('stage.apply');
|
||||
}
|
||||
|
||||
$saveGroup = $toolbar->dropdownButton('save-group');
|
||||
$saveGroup->configure(
|
||||
function (Toolbar $childBar) use ($canDo) {
|
||||
// For new records, check the create permission.
|
||||
if ($canDo->get('core.create')) {
|
||||
$childBar->save('stage.save');
|
||||
$childBar->save2new('stage.save2new');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$toolbar->cancel('stage.cancel', 'JTOOLBAR_CANCEL');
|
||||
} else {
|
||||
// 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);
|
||||
|
||||
if ($itemEditable) {
|
||||
$toolbar->apply('stage.apply');
|
||||
|
||||
$saveGroup = $toolbar->dropdownButton('save-group');
|
||||
$saveGroup->configure(
|
||||
function (Toolbar $childBar) use ($canDo) {
|
||||
$childBar->save('stage.save');
|
||||
|
||||
// We can save this record, but check the create permission to see if we can return to make a new one.
|
||||
if ($canDo->get('core.create')) {
|
||||
$childBar->save2new('stage.save2new');
|
||||
$childBar->save2copy('stage.save2copy');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$toolbar->cancel('stage.cancel');
|
||||
}
|
||||
|
||||
$toolbar->divider();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,219 @@
|
||||
<?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\Stages;
|
||||
|
||||
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\Button\DropdownButton;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Stages view class for the Workflow package.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* An array of stages
|
||||
*
|
||||
* @var array
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $stages;
|
||||
|
||||
/**
|
||||
* The model stage
|
||||
*
|
||||
* @var object
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $stage;
|
||||
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* The HTML for displaying sidebar
|
||||
*
|
||||
* @var string
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $sidebar;
|
||||
|
||||
/**
|
||||
* The pagination object
|
||||
*
|
||||
* @var \Joomla\CMS\Pagination\Pagination
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $pagination;
|
||||
|
||||
/**
|
||||
* Form object for search filters
|
||||
*
|
||||
* @var \Joomla\CMS\Form\Form
|
||||
*
|
||||
* @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 void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->state = $this->get('State');
|
||||
$this->stages = $this->get('Items');
|
||||
$this->pagination = $this->get('Pagination');
|
||||
$this->filterForm = $this->get('FilterForm');
|
||||
$this->activeFilters = $this->get('ActiveFilters');
|
||||
$this->workflow = $this->get('Workflow');
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
$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();
|
||||
|
||||
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 = $this->getCurrentUser();
|
||||
|
||||
$toolbar = $this->getDocument()->getToolbar();
|
||||
|
||||
ToolbarHelper::title(Text::sprintf('COM_WORKFLOW_STAGES_LIST', Text::_($this->state->get('active_workflow', ''))), 'address contact');
|
||||
|
||||
$arrow = $this->getLanguage()->isRtl() ? 'arrow-right' : 'arrow-left';
|
||||
|
||||
$toolbar->link(
|
||||
'JTOOLBAR_BACK',
|
||||
Route::_('index.php?option=com_workflow&view=workflows&extension=' . $this->escape($this->workflow->extension))
|
||||
)
|
||||
->icon('icon-' . $arrow);
|
||||
|
||||
if ($canDo->get('core.create')) {
|
||||
$toolbar->addNew('stage.add');
|
||||
}
|
||||
|
||||
if ($canDo->get('core.edit.state') || $user->authorise('core.admin')) {
|
||||
/** @var DropdownButton $dropdown */
|
||||
$dropdown = $toolbar->dropdownButton('status-group', 'JTOOLBAR_CHANGE_STATUS')
|
||||
->toggleSplit(false)
|
||||
->icon('icon-ellipsis-h')
|
||||
->buttonClass('btn btn-action')
|
||||
->listCheck(true);
|
||||
|
||||
$childBar = $dropdown->getChildToolbar();
|
||||
|
||||
$childBar->publish('stages.publish', 'JTOOLBAR_ENABLE')->listCheck(true);
|
||||
$childBar->unpublish('stages.unpublish', 'JTOOLBAR_DISABLE')->listCheck(true);
|
||||
$childBar->makeDefault('stages.setDefault', 'COM_WORKFLOW_TOOLBAR_DEFAULT');
|
||||
|
||||
if ($canDo->get('core.admin')) {
|
||||
$childBar->checkin('stages.checkin')->listCheck(true);
|
||||
}
|
||||
|
||||
if ($this->state->get('filter.published') !== '-2') {
|
||||
$childBar->trash('stages.trash');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->state->get('filter.published') === '-2' && $canDo->get('core.delete')) {
|
||||
$toolbar->delete('stages.delete', 'JTOOLBAR_DELETE_FROM_TRASH')
|
||||
->message('JGLOBAL_CONFIRM_DELETE')
|
||||
->listCheck(true);
|
||||
}
|
||||
|
||||
$toolbar->help('Stages_List:_Basic_Workflow');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,216 @@
|
||||
<?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\Transition;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
use Joomla\Component\Workflow\Administrator\Helper\StageHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View class to add or edit a transition of a workflow
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var object
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Form object to generate fields
|
||||
*
|
||||
* @var \Joomla\CMS\Form\Form
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $form;
|
||||
|
||||
/**
|
||||
* Items array
|
||||
*
|
||||
* @var object
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* That is object of Application
|
||||
*
|
||||
* @var \Joomla\CMS\Application\CMSApplication
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* The application input object.
|
||||
*
|
||||
* @var \Joomla\CMS\Input\Input
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $input;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Array of fieldsets not to display
|
||||
*
|
||||
* @var string[]
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
public $ignore_fieldsets = [];
|
||||
|
||||
/**
|
||||
* Display item view
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->app = Factory::getApplication();
|
||||
$this->input = $this->app->getInput();
|
||||
|
||||
// Get the Data
|
||||
$this->state = $this->get('State');
|
||||
$this->form = $this->get('Form');
|
||||
$this->item = $this->get('Item');
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
$extension = $this->state->get('filter.extension');
|
||||
|
||||
$parts = explode('.', $extension);
|
||||
|
||||
$this->extension = array_shift($parts);
|
||||
|
||||
if (!empty($parts)) {
|
||||
$this->section = array_shift($parts);
|
||||
}
|
||||
|
||||
// Get the ID of workflow
|
||||
$this->workflowID = $this->input->getCmd("workflow_id");
|
||||
|
||||
// Set the toolbar
|
||||
$this->addToolbar();
|
||||
|
||||
// Display the template
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function addToolbar()
|
||||
{
|
||||
Factory::getApplication()->getInput()->set('hidemainmenu', true);
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$userId = $user->id;
|
||||
$isNew = empty($this->item->id);
|
||||
$toolbar = $this->getDocument()->getToolbar();
|
||||
$canDo = StageHelper::getActions($this->extension, 'transition', $this->item->id);
|
||||
$canCreate = $canDo->get('core.create');
|
||||
|
||||
ToolbarHelper::title(empty($this->item->id) ? Text::_('COM_WORKFLOW_TRANSITION_ADD') : Text::_('COM_WORKFLOW_TRANSITION_EDIT'), 'address');
|
||||
|
||||
if ($isNew) {
|
||||
// For new records, check the create permission.
|
||||
if ($canCreate) {
|
||||
$toolbar->apply('transition.apply');
|
||||
|
||||
$saveGroup = $toolbar->dropdownButton('save-group');
|
||||
|
||||
$saveGroup->configure(
|
||||
function (Toolbar $childBar) {
|
||||
// For new records, check the create permission.
|
||||
$childBar->save('transition.save');
|
||||
$childBar->save2new('transition.save2new');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$toolbar->cancel('transition.cancel', 'JTOOLBAR_CANCEL');
|
||||
} else {
|
||||
// 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);
|
||||
|
||||
if ($itemEditable) {
|
||||
$toolbar->apply('transition.apply');
|
||||
} else {
|
||||
$toolbar->save('transition.save');
|
||||
}
|
||||
|
||||
$saveGroup = $toolbar->dropdownButton('save-group');
|
||||
|
||||
$saveGroup->configure(
|
||||
function (Toolbar $childBar) use ($canCreate) {
|
||||
$childBar->save('transition.save');
|
||||
|
||||
// We can save this record, but check the create permission to see if we can return to make a new one.
|
||||
if ($canCreate) {
|
||||
$childBar->save2new('transition.save2new');
|
||||
$childBar->save2copy('transition.save2copy');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$toolbar->cancel('transition.cancel');
|
||||
}
|
||||
|
||||
$toolbar->divider();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,209 @@
|
||||
<?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;
|
||||
|
||||
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\Button\DropdownButton;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* 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 \Joomla\CMS\Pagination\Pagination
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $pagination;
|
||||
|
||||
/**
|
||||
* Form object for search filters
|
||||
*
|
||||
* @var \Joomla\CMS\Form\Form
|
||||
*
|
||||
* @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 void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$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');
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
$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();
|
||||
|
||||
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 = $this->getCurrentUser();
|
||||
$toolbar = $this->getDocument()->getToolbar();
|
||||
|
||||
ToolbarHelper::title(Text::sprintf('COM_WORKFLOW_TRANSITIONS_LIST', Text::_($this->state->get('active_workflow'))), 'address contact');
|
||||
|
||||
$arrow = $this->getLanguage()->isRtl() ? 'arrow-right' : 'arrow-left';
|
||||
|
||||
$toolbar->link(
|
||||
'JTOOLBAR_BACK',
|
||||
Route::_('index.php?option=com_workflow&view=workflows&extension=' . $this->escape($this->workflow->extension))
|
||||
)
|
||||
->icon('icon-' . $arrow);
|
||||
|
||||
if ($canDo->get('core.create')) {
|
||||
$toolbar->addNew('transition.add');
|
||||
}
|
||||
|
||||
if ($canDo->get('core.edit.state') || $user->authorise('core.admin')) {
|
||||
/** @var DropdownButton $dropdown */
|
||||
$dropdown = $toolbar->dropdownButton('status-group', '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', 'JTOOLBAR_DELETE_FROM_TRASH')
|
||||
->message('JGLOBAL_CONFIRM_DELETE')
|
||||
->listCheck(true);
|
||||
}
|
||||
|
||||
$toolbar->help('Transitions_List:_Basic_Workflow');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,176 @@
|
||||
<?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\Workflow;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
use Joomla\Component\Workflow\Administrator\Helper\WorkflowHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* View class to add or edit a workflow
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var object
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* The Form object
|
||||
*
|
||||
* @var \Joomla\CMS\Form\Form
|
||||
*/
|
||||
protected $form;
|
||||
|
||||
/**
|
||||
* The active item
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* 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 item view
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
// Get the Data
|
||||
$this->state = $this->get('State');
|
||||
$this->form = $this->get('Form');
|
||||
$this->item = $this->get('Item');
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
$extension = $this->state->get('filter.extension');
|
||||
|
||||
$parts = explode('.', $extension);
|
||||
|
||||
$this->extension = array_shift($parts);
|
||||
|
||||
if (!empty($parts)) {
|
||||
$this->section = array_shift($parts);
|
||||
}
|
||||
|
||||
// Set the toolbar
|
||||
$this->addToolbar();
|
||||
|
||||
// Display the template
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function addToolbar()
|
||||
{
|
||||
Factory::getApplication()->getInput()->set('hidemainmenu', true);
|
||||
|
||||
$user = $this->getCurrentUser();
|
||||
$userId = $user->id;
|
||||
$isNew = empty($this->item->id);
|
||||
$toolbar = $this->getDocument()->getToolbar();
|
||||
$canDo = WorkflowHelper::getActions($this->extension, 'workflow', $this->item->id);
|
||||
|
||||
ToolbarHelper::title(empty($this->item->id) ? Text::_('COM_WORKFLOW_WORKFLOWS_ADD') : Text::_('COM_WORKFLOW_WORKFLOWS_EDIT'), 'address');
|
||||
|
||||
if ($isNew) {
|
||||
// For new records, check the create permission.
|
||||
if ($canDo->get('core.create')) {
|
||||
$toolbar->apply('workflow.apply');
|
||||
|
||||
$saveGroup = $toolbar->dropdownButton('save-group');
|
||||
|
||||
$saveGroup->configure(
|
||||
function (Toolbar $childBar) {
|
||||
$childBar->save('workflow.save');
|
||||
$childBar->save2new('workflow.save2new');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$toolbar->cancel('workflow.cancel', 'JTOOLBAR_CANCEL');
|
||||
} else {
|
||||
// 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);
|
||||
|
||||
if ($itemEditable) {
|
||||
$toolbar->apply('workflow.apply');
|
||||
|
||||
$saveGroup = $toolbar->dropdownButton('save-group');
|
||||
|
||||
$saveGroup->configure(
|
||||
function (Toolbar $childBar) use ($canDo) {
|
||||
$childBar->save('workflow.save');
|
||||
|
||||
// We can save this record, but check the create permission to see if we can return to make a new one.
|
||||
if ($canDo->get('core.create')) {
|
||||
$childBar->save2new('workflow.save2new');
|
||||
$childBar->save2copy('workflow.save2copy');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$toolbar->cancel('workflow.cancel');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,186 @@
|
||||
<?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\Workflows;
|
||||
|
||||
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\Button\DropdownButton;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Workflows view class for the Workflow package.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
/**
|
||||
* An array of workflows
|
||||
*
|
||||
* @var array
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $workflows;
|
||||
|
||||
/**
|
||||
* The model state
|
||||
*
|
||||
* @var object
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* The pagination object
|
||||
*
|
||||
* @var \Joomla\CMS\Pagination\Pagination
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $pagination;
|
||||
|
||||
/**
|
||||
* The HTML for displaying sidebar
|
||||
*
|
||||
* @var string
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected $sidebar;
|
||||
|
||||
/**
|
||||
* Form object for search filters
|
||||
*
|
||||
* @var \Joomla\CMS\Form\Form
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public $filterForm;
|
||||
|
||||
/**
|
||||
* The active search filters
|
||||
*
|
||||
* @var array
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public $activeFilters;
|
||||
|
||||
/**
|
||||
* 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 void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->state = $this->get('State');
|
||||
$this->workflows = $this->get('Items');
|
||||
$this->pagination = $this->get('Pagination');
|
||||
$this->filterForm = $this->get('FilterForm');
|
||||
$this->activeFilters = $this->get('ActiveFilters');
|
||||
|
||||
// Check for errors.
|
||||
if (\count($errors = $this->get('Errors'))) {
|
||||
throw new GenericDataException(implode("\n", $errors), 500);
|
||||
}
|
||||
|
||||
$extension = $this->state->get('filter.extension');
|
||||
|
||||
$parts = explode('.', $extension);
|
||||
|
||||
$this->extension = array_shift($parts);
|
||||
|
||||
if (!empty($parts)) {
|
||||
$this->section = array_shift($parts);
|
||||
}
|
||||
|
||||
$this->addToolbar();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
protected function addToolbar()
|
||||
{
|
||||
$canDo = ContentHelper::getActions($this->extension, $this->section);
|
||||
$user = $this->getCurrentUser();
|
||||
$toolbar = $this->getDocument()->getToolbar();
|
||||
|
||||
ToolbarHelper::title(Text::_('COM_WORKFLOW_WORKFLOWS_LIST'), 'file-alt contact');
|
||||
|
||||
if ($canDo->get('core.create')) {
|
||||
$toolbar->addNew('workflow.add');
|
||||
}
|
||||
|
||||
if ($canDo->get('core.edit.state') || $user->authorise('core.admin')) {
|
||||
/** @var DropdownButton $dropdown */
|
||||
$dropdown = $toolbar->dropdownButton('status-group', 'JTOOLBAR_CHANGE_STATUS')
|
||||
->toggleSplit(false)
|
||||
->icon('icon-ellipsis-h')
|
||||
->buttonClass('btn btn-action')
|
||||
->listCheck(true);
|
||||
|
||||
$childBar = $dropdown->getChildToolbar();
|
||||
|
||||
$childBar->publish('workflows.publish', 'JTOOLBAR_ENABLE');
|
||||
$childBar->unpublish('workflows.unpublish', 'JTOOLBAR_DISABLE');
|
||||
$childBar->makeDefault('workflows.setDefault', 'COM_WORKFLOW_TOOLBAR_DEFAULT');
|
||||
|
||||
if ($canDo->get('core.admin')) {
|
||||
$childBar->checkin('workflows.checkin')->listCheck(true);
|
||||
}
|
||||
|
||||
if ($canDo->get('core.edit.state') && $this->state->get('filter.published') != -2) {
|
||||
$childBar->trash('workflows.trash');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->state->get('filter.published') === '-2' && $canDo->get('core.delete')) {
|
||||
$toolbar->delete('workflows.delete', 'JTOOLBAR_DELETE_FROM_TRASH')
|
||||
->message('JGLOBAL_CONFIRM_DELETE')
|
||||
->listCheck(true);
|
||||
}
|
||||
|
||||
if ($canDo->get('core.admin') || $canDo->get('core.options')) {
|
||||
$toolbar->preferences($this->extension);
|
||||
}
|
||||
|
||||
$toolbar->help('Workflows_List');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user