[ 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\Workflows; 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\Toolbar\Toolbar; 19 use Joomla\CMS\Toolbar\ToolbarHelper; 20 21 // phpcs:disable PSR1.Files.SideEffects 22 \defined('_JEXEC') or die; 23 // phpcs:enable PSR1.Files.SideEffects 24 25 /** 26 * Workflows view class for the Workflow package. 27 * 28 * @since 4.0.0 29 */ 30 class HtmlView extends BaseHtmlView 31 { 32 /** 33 * An array of workflows 34 * 35 * @var array 36 * @since 4.0.0 37 */ 38 protected $workflows; 39 40 /** 41 * The model state 42 * 43 * @var object 44 * @since 4.0.0 45 */ 46 protected $state; 47 48 /** 49 * The pagination object 50 * 51 * @var \Joomla\CMS\Pagination\Pagination 52 * @since 4.0.0 53 */ 54 protected $pagination; 55 56 /** 57 * The HTML for displaying sidebar 58 * 59 * @var string 60 * @since 4.0.0 61 */ 62 protected $sidebar; 63 64 /** 65 * Form object for search filters 66 * 67 * @var \Joomla\CMS\Form\Form 68 * @since 4.0.0 69 */ 70 public $filterForm; 71 72 /** 73 * The active search filters 74 * 75 * @var array 76 * @since 4.0.0 77 */ 78 public $activeFilters; 79 80 /** 81 * The name of current extension 82 * 83 * @var string 84 * @since 4.0.0 85 */ 86 protected $extension; 87 88 /** 89 * The section of the current extension 90 * 91 * @var string 92 * @since 4.0.0 93 */ 94 protected $section; 95 96 /** 97 * Display the view 98 * 99 * @param string $tpl The name of the template file to parse; automatically searches through the template paths. 100 * 101 * @return void 102 * 103 * @since 4.0.0 104 */ 105 public function display($tpl = null) 106 { 107 $this->state = $this->get('State'); 108 $this->workflows = $this->get('Items'); 109 $this->pagination = $this->get('Pagination'); 110 $this->filterForm = $this->get('FilterForm'); 111 $this->activeFilters = $this->get('ActiveFilters'); 112 113 // Check for errors. 114 if (count($errors = $this->get('Errors'))) { 115 throw new GenericDataException(implode("\n", $errors), 500); 116 } 117 118 $extension = $this->state->get('filter.extension'); 119 120 $parts = explode('.', $extension); 121 122 $this->extension = array_shift($parts); 123 124 if (!empty($parts)) { 125 $this->section = array_shift($parts); 126 } 127 128 $this->addToolbar(); 129 130 parent::display($tpl); 131 } 132 133 /** 134 * Add the page title and toolbar. 135 * 136 * @return void 137 * 138 * @since 4.0.0 139 */ 140 protected function addToolbar() 141 { 142 $canDo = ContentHelper::getActions($this->extension, $this->section); 143 144 $user = Factory::getApplication()->getIdentity(); 145 146 // Get the toolbar object instance 147 $toolbar = Toolbar::getInstance('toolbar'); 148 149 ToolbarHelper::title(Text::_('COM_WORKFLOW_WORKFLOWS_LIST'), 'file-alt contact'); 150 151 if ($canDo->get('core.create')) { 152 $toolbar->addNew('workflow.add'); 153 } 154 155 if ($canDo->get('core.edit.state') || $user->authorise('core.admin')) { 156 $dropdown = $toolbar->dropdownButton('status-group') 157 ->text('JTOOLBAR_CHANGE_STATUS') 158 ->toggleSplit(false) 159 ->icon('icon-ellipsis-h') 160 ->buttonClass('btn btn-action') 161 ->listCheck(true); 162 163 $childBar = $dropdown->getChildToolbar(); 164 165 $childBar->publish('workflows.publish', 'JTOOLBAR_ENABLE'); 166 $childBar->unpublish('workflows.unpublish', 'JTOOLBAR_DISABLE'); 167 $childBar->makeDefault('workflows.setDefault', 'COM_WORKFLOW_TOOLBAR_DEFAULT'); 168 169 if ($canDo->get('core.admin')) { 170 $childBar->checkin('workflows.checkin')->listCheck(true); 171 } 172 173 if ($canDo->get('core.edit.state') && $this->state->get('filter.published') != -2) { 174 $childBar->trash('workflows.trash'); 175 } 176 } 177 178 if ($this->state->get('filter.published') === '-2' && $canDo->get('core.delete')) { 179 $toolbar->delete('workflows.delete') 180 ->text('JTOOLBAR_EMPTY_TRASH') 181 ->message('JGLOBAL_CONFIRM_DELETE') 182 ->listCheck(true); 183 } 184 185 if ($canDo->get('core.admin') || $canDo->get('core.options')) { 186 $toolbar->preferences($this->extension); 187 } 188 189 $toolbar->help('Workflows_List'); 190 } 191 }
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 |