[ 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_privacy 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\Privacy\Administrator\View\Request; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Form\Form; 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\Object\CMSObject; 19 use Joomla\CMS\Router\Route; 20 use Joomla\CMS\Session\Session; 21 use Joomla\CMS\Toolbar\Toolbar; 22 use Joomla\CMS\Toolbar\ToolbarHelper; 23 use Joomla\Component\Privacy\Administrator\Model\RequestsModel; 24 25 // phpcs:disable PSR1.Files.SideEffects 26 \defined('_JEXEC') or die; 27 // phpcs:enable PSR1.Files.SideEffects 28 29 /** 30 * Request view class 31 * 32 * @since 3.9.0 33 */ 34 class HtmlView extends BaseHtmlView 35 { 36 /** 37 * The action logs for the item 38 * 39 * @var array 40 * @since 3.9.0 41 */ 42 protected $actionlogs; 43 44 /** 45 * The form object 46 * 47 * @var Form 48 * @since 3.9.0 49 */ 50 protected $form; 51 52 /** 53 * The item record 54 * 55 * @var CMSObject 56 * @since 3.9.0 57 */ 58 protected $item; 59 60 /** 61 * The state information 62 * 63 * @var CMSObject 64 * @since 3.9.0 65 */ 66 protected $state; 67 68 /** 69 * Execute and display a template script. 70 * 71 * @param string $tpl The name of the template file to parse; automatically searches through the template paths. 72 * 73 * @return void 74 * 75 * @see BaseHtmlView::loadTemplate() 76 * @since 3.9.0 77 * @throws \Exception 78 */ 79 public function display($tpl = null) 80 { 81 /** @var RequestsModel $model */ 82 $model = $this->getModel(); 83 $this->item = $model->getItem(); 84 $this->state = $model->getState(); 85 86 // Variables only required for the default layout 87 if ($this->getLayout() === 'default') { 88 /** @var \Joomla\Component\Actionlogs\Administrator\Model\ActionlogsModel $logsModel */ 89 $logsModel = $this->getModel('actionlogs'); 90 91 $this->actionlogs = $logsModel->getLogsForItem('com_privacy.request', $this->item->id); 92 93 // Load the com_actionlogs language strings for use in the layout 94 $lang = Factory::getLanguage(); 95 $lang->load('com_actionlogs', JPATH_ADMINISTRATOR) 96 || $lang->load('com_actionlogs', JPATH_ADMINISTRATOR . '/components/com_actionlogs'); 97 } 98 99 // Variables only required for the edit layout 100 if ($this->getLayout() === 'edit') { 101 $this->form = $this->get('Form'); 102 } 103 104 // Check for errors. 105 if (count($errors = $this->get('Errors'))) { 106 throw new GenericDataException(implode("\n", $errors), 500); 107 } 108 109 $this->addToolbar(); 110 111 parent::display($tpl); 112 } 113 114 /** 115 * Add the page title and toolbar. 116 * 117 * @return void 118 * 119 * @since 3.9.0 120 */ 121 protected function addToolbar() 122 { 123 Factory::getApplication()->input->set('hidemainmenu', true); 124 125 // Set the title and toolbar based on the layout 126 if ($this->getLayout() === 'edit') { 127 ToolbarHelper::title(Text::_('COM_PRIVACY_VIEW_REQUEST_ADD_REQUEST'), 'lock'); 128 129 ToolbarHelper::save('request.save'); 130 ToolbarHelper::cancel('request.cancel'); 131 ToolbarHelper::help('Privacy:_New_Information_Request'); 132 } else { 133 ToolbarHelper::title(Text::_('COM_PRIVACY_VIEW_REQUEST_SHOW_REQUEST'), 'lock'); 134 135 $bar = Toolbar::getInstance('toolbar'); 136 137 // Add transition and action buttons based on item status 138 switch ($this->item->status) { 139 case '0': 140 $bar->appendButton('Standard', 'cancel-circle', 'COM_PRIVACY_TOOLBAR_INVALIDATE', 'request.invalidate', false); 141 142 break; 143 144 case '1': 145 $return = '&return=' . base64_encode('index.php?option=com_privacy&view=request&id=' . (int) $this->item->id); 146 147 $bar->appendButton('Standard', 'apply', 'COM_PRIVACY_TOOLBAR_COMPLETE', 'request.complete', false); 148 $bar->appendButton('Standard', 'cancel-circle', 'COM_PRIVACY_TOOLBAR_INVALIDATE', 'request.invalidate', false); 149 150 if ($this->item->request_type === 'export') { 151 ToolbarHelper::link( 152 Route::_('index.php?option=com_privacy&task=request.export&format=xml&id=' . (int) $this->item->id . $return), 153 'COM_PRIVACY_ACTION_EXPORT_DATA', 154 'download' 155 ); 156 157 if (Factory::getApplication()->get('mailonline', 1)) { 158 ToolbarHelper::link( 159 Route::_( 160 'index.php?option=com_privacy&task=request.emailexport&id=' . (int) $this->item->id . $return 161 . '&' . Session::getFormToken() . '=1' 162 ), 163 'COM_PRIVACY_ACTION_EMAIL_EXPORT_DATA', 164 'mail' 165 ); 166 } 167 } 168 169 if ($this->item->request_type === 'remove') { 170 $bar->appendButton('Standard', 'delete', 'COM_PRIVACY_ACTION_DELETE_DATA', 'request.remove', false); 171 } 172 173 break; 174 175 // Item is in a "locked" state and cannot transition 176 default: 177 break; 178 } 179 180 ToolbarHelper::cancel('request.cancel', 'JTOOLBAR_CLOSE'); 181 ToolbarHelper::help('Privacy:_Review_Information_Request'); 182 } 183 } 184 }
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 |