[ 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\Stage; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Language\Text; 15 use Joomla\CMS\MVC\View\GenericDataException; 16 use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; 17 use Joomla\CMS\Toolbar\ToolbarHelper; 18 use Joomla\Component\Workflow\Administrator\Helper\StageHelper; 19 20 // phpcs:disable PSR1.Files.SideEffects 21 \defined('_JEXEC') or die; 22 // phpcs:enable PSR1.Files.SideEffects 23 24 /** 25 * View class to add or edit a stage of a workflow 26 * 27 * @since 4.0.0 28 */ 29 class HtmlView extends BaseHtmlView 30 { 31 /** 32 * The model state 33 * 34 * @var object 35 * @since 4.0.0 36 */ 37 protected $state; 38 39 /** 40 * From object to generate fields 41 * 42 * @var \Joomla\CMS\Form\Form 43 * 44 * @since 4.0.0 45 */ 46 protected $form; 47 48 /** 49 * Items array 50 * 51 * @var object 52 * @since 4.0.0 53 */ 54 protected $item; 55 56 /** 57 * The name of current extension 58 * 59 * @var string 60 * @since 4.0.0 61 */ 62 protected $extension; 63 64 /** 65 * The section of the current extension 66 * 67 * @var string 68 * @since 4.0.0 69 */ 70 protected $section; 71 72 /** 73 * Display item view 74 * 75 * @param string $tpl The name of the template file to parse; automatically searches through the template paths. 76 * 77 * @return void 78 * 79 * @since 4.0.0 80 */ 81 public function display($tpl = null) 82 { 83 // Get the Data 84 $this->state = $this->get('State'); 85 $this->form = $this->get('Form'); 86 $this->item = $this->get('Item'); 87 88 // Check for errors. 89 if (count($errors = $this->get('Errors'))) { 90 throw new GenericDataException(implode("\n", $errors), 500); 91 } 92 93 $extension = $this->state->get('filter.extension'); 94 95 $parts = explode('.', $extension); 96 97 $this->extension = array_shift($parts); 98 99 if (!empty($parts)) { 100 $this->section = array_shift($parts); 101 } 102 103 // Set the toolbar 104 $this->addToolbar(); 105 106 // Display the template 107 parent::display($tpl); 108 } 109 110 /** 111 * Add the page title and toolbar. 112 * 113 * @return void 114 * 115 * @since 4.0.0 116 */ 117 protected function addToolbar() 118 { 119 Factory::getApplication()->input->set('hidemainmenu', true); 120 121 $user = $this->getCurrentUser(); 122 $userId = $user->id; 123 $isNew = empty($this->item->id); 124 125 $canDo = StageHelper::getActions($this->extension, 'stage', $this->item->id); 126 127 ToolbarHelper::title(empty($this->item->id) ? Text::_('COM_WORKFLOW_STAGE_ADD') : Text::_('COM_WORKFLOW_STAGE_EDIT'), 'address'); 128 129 $toolbarButtons = []; 130 131 if ($isNew) { 132 // For new records, check the create permission. 133 if ($canDo->get('core.create')) { 134 ToolbarHelper::apply('stage.apply'); 135 $toolbarButtons = [['save', 'stage.save'], ['save2new', 'stage.save2new']]; 136 } 137 138 ToolbarHelper::saveGroup( 139 $toolbarButtons, 140 'btn-success' 141 ); 142 143 ToolbarHelper::cancel( 144 'stage.cancel' 145 ); 146 } else { 147 // Since it's an existing record, check the edit permission, or fall back to edit own if the owner. 148 $itemEditable = $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $userId); 149 150 if ($itemEditable) { 151 ToolbarHelper::apply('stage.apply'); 152 $toolbarButtons = [['save', 'stage.save']]; 153 154 // We can save this record, but check the create permission to see if we can return to make a new one. 155 if ($canDo->get('core.create')) { 156 $toolbarButtons[] = ['save2new', 'stage.save2new']; 157 $toolbarButtons[] = ['save2copy', 'stage.save2copy']; 158 } 159 } 160 161 ToolbarHelper::saveGroup( 162 $toolbarButtons, 163 'btn-success' 164 ); 165 166 ToolbarHelper::cancel( 167 'stage.cancel', 168 'JTOOLBAR_CLOSE' 169 ); 170 } 171 172 ToolbarHelper::divider(); 173 } 174 }
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 |