[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_workflow 6 * 7 * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Workflow\Administrator\View\Stages; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Helper\ContentHelper; 15 use Joomla\CMS\Language\Text; 16 use Joomla\CMS\MVC\View\GenericDataException; 17 use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; 18 use Joomla\CMS\Router\Route; 19 use Joomla\CMS\Toolbar\Toolbar; 20 use Joomla\CMS\Toolbar\ToolbarHelper; 21 use Joomla\CMS\Workflow\Workflow; 22 23 // phpcs:disable PSR1.Files.SideEffects 24 \defined('_JEXEC') or die; 25 // phpcs:enable PSR1.Files.SideEffects 26 27 /** 28 * Stages view class for the Workflow package. 29 * 30 * @since 4.0.0 31 */ 32 class HtmlView extends BaseHtmlView 33 { 34 /** 35 * An array of stages 36 * 37 * @var array 38 * @since 4.0.0 39 */ 40 protected $stages; 41 42 /** 43 * The model stage 44 * 45 * @var object 46 * @since 4.0.0 47 */ 48 protected $stage; 49 50 /** 51 * The HTML for displaying sidebar 52 * 53 * @var string 54 * @since 4.0.0 55 */ 56 protected $sidebar; 57 58 /** 59 * The pagination object 60 * 61 * @var \Joomla\CMS\Pagination\Pagination 62 * 63 * @since 4.0.0 64 */ 65 protected $pagination; 66 67 /** 68 * Form object for search filters 69 * 70 * @var \Joomla\CMS\Form\Form 71 * 72 * @since 4.0.0 73 */ 74 public $filterForm; 75 76 /** 77 * The active search filters 78 * 79 * @var array 80 * @since 4.0.0 81 */ 82 public $activeFilters; 83 84 /** 85 * The current workflow 86 * 87 * @var object 88 * @since 4.0.0 89 */ 90 protected $workflow; 91 92 /** 93 * The ID of current workflow 94 * 95 * @var integer 96 * @since 4.0.0 97 */ 98 protected $workflowID; 99 100 /** 101 * The name of current extension 102 * 103 * @var string 104 * @since 4.0.0 105 */ 106 protected $extension; 107 108 /** 109 * The section of the current extension 110 * 111 * @var string 112 * @since 4.0.0 113 */ 114 protected $section; 115 116 /** 117 * Display the view 118 * 119 * @param string $tpl The name of the template file to parse; automatically searches through the template paths. 120 * 121 * @return void 122 * 123 * @since 4.0.0 124 */ 125 public function display($tpl = null) 126 { 127 $this->state = $this->get('State'); 128 $this->stages = $this->get('Items'); 129 $this->pagination = $this->get('Pagination'); 130 $this->filterForm = $this->get('FilterForm'); 131 $this->activeFilters = $this->get('ActiveFilters'); 132 $this->workflow = $this->get('Workflow'); 133 134 // Check for errors. 135 if (count($errors = $this->get('Errors'))) { 136 throw new GenericDataException(implode("\n", $errors), 500); 137 } 138 139 $this->workflowID = $this->workflow->id; 140 141 $parts = explode('.', $this->workflow->extension); 142 143 $this->extension = array_shift($parts); 144 145 if (!empty($parts)) { 146 $this->section = array_shift($parts); 147 } 148 149 if (!empty($this->stages)) { 150 $extension = Factory::getApplication()->input->getCmd('extension'); 151 $workflow = new Workflow($extension); 152 } 153 154 $this->addToolbar(); 155 156 parent::display($tpl); 157 } 158 159 /** 160 * Add the page title and toolbar. 161 * 162 * @return void 163 * 164 * @since 4.0.0 165 */ 166 protected function addToolbar() 167 { 168 $canDo = ContentHelper::getActions($this->extension, 'workflow', $this->workflowID); 169 170 $user = $this->getCurrentUser(); 171 172 $toolbar = Toolbar::getInstance('toolbar'); 173 174 ToolbarHelper::title(Text::sprintf('COM_WORKFLOW_STAGES_LIST', Text::_($this->state->get('active_workflow', ''))), 'address contact'); 175 176 $arrow = Factory::getLanguage()->isRtl() ? 'arrow-right' : 'arrow-left'; 177 178 ToolbarHelper::link( 179 Route::_('index.php?option=com_workflow&view=workflows&extension=' . $this->escape($this->workflow->extension)), 180 'JTOOLBAR_BACK', 181 $arrow 182 ); 183 184 if ($canDo->get('core.create')) { 185 $toolbar->addNew('stage.add'); 186 } 187 188 if ($canDo->get('core.edit.state') || $user->authorise('core.admin')) { 189 $dropdown = $toolbar->dropdownButton('status-group') 190 ->text('JTOOLBAR_CHANGE_STATUS') 191 ->toggleSplit(false) 192 ->icon('icon-ellipsis-h') 193 ->buttonClass('btn btn-action') 194 ->listCheck(true); 195 196 $childBar = $dropdown->getChildToolbar(); 197 198 $childBar->publish('stages.publish', 'JTOOLBAR_ENABLE')->listCheck(true); 199 $childBar->unpublish('stages.unpublish', 'JTOOLBAR_DISABLE')->listCheck(true); 200 $childBar->makeDefault('stages.setDefault', 'COM_WORKFLOW_TOOLBAR_DEFAULT'); 201 202 if ($canDo->get('core.admin')) { 203 $childBar->checkin('stages.checkin')->listCheck(true); 204 } 205 206 if ($this->state->get('filter.published') !== '-2') { 207 $childBar->trash('stages.trash'); 208 } 209 } 210 211 if ($this->state->get('filter.published') === '-2' && $canDo->get('core.delete')) { 212 $toolbar->delete('stages.delete') 213 ->text('JTOOLBAR_EMPTY_TRASH') 214 ->message('JGLOBAL_CONFIRM_DELETE') 215 ->listCheck(true); 216 } 217 218 $toolbar->help('Stages_List:_Basic_Workflow'); 219 } 220 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |