[ 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_banners 6 * 7 * @copyright (C) 2008 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\Banners\Administrator\View\Client; 12 13 use Exception; 14 use Joomla\CMS\Component\ComponentHelper; 15 use Joomla\CMS\Factory; 16 use Joomla\CMS\Form\Form; 17 use Joomla\CMS\Helper\ContentHelper; 18 use Joomla\CMS\Language\Text; 19 use Joomla\CMS\MVC\View\GenericDataException; 20 use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; 21 use Joomla\CMS\Object\CMSObject; 22 use Joomla\CMS\Toolbar\ToolbarHelper; 23 use Joomla\Component\Banners\Administrator\Model\ClientModel; 24 25 // phpcs:disable PSR1.Files.SideEffects 26 \defined('_JEXEC') or die; 27 // phpcs:enable PSR1.Files.SideEffects 28 29 /** 30 * View to edit a client. 31 * 32 * @since 1.5 33 */ 34 class HtmlView extends BaseHtmlView 35 { 36 /** 37 * The Form object 38 * 39 * @var Form 40 * @since 1.5 41 */ 42 protected $form; 43 44 /** 45 * The active item 46 * 47 * @var CMSObject 48 * @since 1.5 49 */ 50 protected $item; 51 52 /** 53 * The model state 54 * 55 * @var CMSObject 56 * @since 1.5 57 */ 58 protected $state; 59 60 /** 61 * Object containing permissions for the item 62 * 63 * @var CMSObject 64 * @since 1.5 65 */ 66 protected $canDo; 67 68 /** 69 * Display the view 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 * @since 1.5 76 * 77 * @throws Exception 78 */ 79 public function display($tpl = null): void 80 { 81 /** @var ClientModel $model */ 82 $model = $this->getModel(); 83 $this->form = $model->getForm(); 84 $this->item = $model->getItem(); 85 $this->state = $model->getState(); 86 $this->canDo = ContentHelper::getActions('com_banners'); 87 88 // Check for errors. 89 if (\count($errors = $this->get('Errors'))) { 90 throw new GenericDataException(implode("\n", $errors), 500); 91 } 92 93 $this->addToolbar(); 94 95 parent::display($tpl); 96 } 97 98 /** 99 * Add the page title and toolbar. 100 * 101 * @return void 102 * 103 * @since 1.6 104 * 105 * @throws Exception 106 */ 107 protected function addToolbar(): void 108 { 109 Factory::getApplication()->input->set('hidemainmenu', true); 110 111 $user = $this->getCurrentUser(); 112 $isNew = ($this->item->id == 0); 113 $checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $user->id); 114 $canDo = $this->canDo; 115 116 ToolbarHelper::title( 117 $isNew ? Text::_('COM_BANNERS_MANAGER_CLIENT_NEW') : Text::_('COM_BANNERS_MANAGER_CLIENT_EDIT'), 118 'bookmark banners-clients' 119 ); 120 121 $toolbarButtons = []; 122 123 // If not checked out, can save the item. 124 if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) { 125 ToolbarHelper::apply('client.apply'); 126 $toolbarButtons[] = ['save', 'client.save']; 127 } 128 129 if (!$checkedOut && $canDo->get('core.create')) { 130 $toolbarButtons[] = ['save2new', 'client.save2new']; 131 } 132 133 // If an existing item, can save to a copy. 134 if (!$isNew && $canDo->get('core.create')) { 135 $toolbarButtons[] = ['save2copy', 'client.save2copy']; 136 } 137 138 ToolbarHelper::saveGroup( 139 $toolbarButtons, 140 'btn-success' 141 ); 142 143 if (empty($this->item->id)) { 144 ToolbarHelper::cancel('client.cancel'); 145 } else { 146 ToolbarHelper::cancel('client.cancel', 'JTOOLBAR_CLOSE'); 147 148 if (ComponentHelper::isEnabled('com_contenthistory') && $this->state->params->get('save_history', 0) && $canDo->get('core.edit')) { 149 ToolbarHelper::versions('com_banners.client', $this->item->id); 150 } 151 } 152 153 ToolbarHelper::divider(); 154 ToolbarHelper::help('Banners:_New_or_Edit_Client'); 155 } 156 }
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 |