[ 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_tags 6 * 7 * @copyright (C) 2013 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\Tags\Administrator\View\Tags; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Helper\ContentHelper; 15 use Joomla\CMS\Language\Multilanguage; 16 use Joomla\CMS\Language\Text; 17 use Joomla\CMS\MVC\View\GenericDataException; 18 use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; 19 use Joomla\CMS\Object\CMSObject; 20 use Joomla\CMS\Toolbar\Toolbar; 21 use Joomla\CMS\Toolbar\ToolbarHelper; 22 23 // phpcs:disable PSR1.Files.SideEffects 24 \defined('_JEXEC') or die; 25 // phpcs:enable PSR1.Files.SideEffects 26 27 /** 28 * Tags view class for the Tags package. 29 * 30 * @since 3.1 31 */ 32 class HtmlView extends BaseHtmlView 33 { 34 /** 35 * An array of items 36 * 37 * @var array 38 */ 39 protected $items; 40 41 /** 42 * The pagination object 43 * 44 * @var \Joomla\CMS\Pagination\Pagination 45 */ 46 protected $pagination; 47 48 /** 49 * The model state 50 * 51 * @var CMSObject 52 */ 53 protected $state; 54 55 /** 56 * Form object for search filters 57 * 58 * @var \Joomla\CMS\Form\Form 59 * 60 * @since 4.0.0 61 */ 62 public $filterForm; 63 64 /** 65 * The active search filters 66 * 67 * @var array 68 * 69 * @since 4.0.0 70 */ 71 public $activeFilters; 72 73 /** 74 * Is this view an Empty State 75 * 76 * @var boolean 77 * 78 * @since 4.0.0 79 */ 80 private $isEmptyState = false; 81 82 /** 83 * Execute and display a template script. 84 * 85 * @param string $tpl The name of the template file to parse; automatically searches through the template paths. 86 * 87 * @return mixed A string if successful, otherwise an Error object. 88 */ 89 public function display($tpl = null) 90 { 91 $this->items = $this->get('Items'); 92 $this->pagination = $this->get('Pagination'); 93 $this->state = $this->get('State'); 94 $this->filterForm = $this->get('FilterForm'); 95 $this->activeFilters = $this->get('ActiveFilters'); 96 97 if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) { 98 $this->setLayout('emptystate'); 99 } 100 101 // Check for errors. 102 if (\count($errors = $this->get('Errors'))) { 103 throw new GenericDataException(implode("\n", $errors), 500); 104 } 105 106 // Preprocess the list of items to find ordering divisions. 107 foreach ($this->items as &$item) { 108 $this->ordering[$item->parent_id][] = $item->id; 109 } 110 111 // We don't need toolbar in the modal window. 112 if ($this->getLayout() !== 'modal') { 113 $this->addToolbar(); 114 115 // We do not need to filter by language when multilingual is disabled 116 if (!Multilanguage::isEnabled()) { 117 unset($this->activeFilters['language']); 118 $this->filterForm->removeField('language', 'filter'); 119 } 120 } 121 122 parent::display($tpl); 123 } 124 125 /** 126 * Add the page title and toolbar. 127 * 128 * @return void 129 * 130 * @since 3.1 131 */ 132 protected function addToolbar() 133 { 134 $canDo = ContentHelper::getActions('com_tags'); 135 $user = Factory::getApplication()->getIdentity(); 136 137 // Get the toolbar object instance 138 $toolbar = Toolbar::getInstance('toolbar'); 139 140 ToolbarHelper::title(Text::_('COM_TAGS_MANAGER_TAGS'), 'tags'); 141 142 if ($canDo->get('core.create')) { 143 $toolbar->addNew('tag.add'); 144 } 145 146 if (!$this->isEmptyState && ($canDo->get('core.edit.state') || $user->authorise('core.admin'))) { 147 $dropdown = $toolbar->dropdownButton('status-group') 148 ->text('JTOOLBAR_CHANGE_STATUS') 149 ->toggleSplit(false) 150 ->icon('icon-ellipsis-h') 151 ->buttonClass('btn btn-action') 152 ->listCheck(true); 153 154 $childBar = $dropdown->getChildToolbar(); 155 156 if ($canDo->get('core.edit.state')) { 157 $childBar->publish('tags.publish')->listCheck(true); 158 $childBar->unpublish('tags.unpublish')->listCheck(true); 159 $childBar->archive('tags.archive')->listCheck(true); 160 } 161 162 if ($user->authorise('core.admin')) { 163 $childBar->checkin('tags.checkin')->listCheck(true); 164 } 165 166 if ($canDo->get('core.edit.state') && $this->state->get('filter.published') != -2) { 167 $childBar->trash('tags.trash')->listCheck(true); 168 } 169 170 // Add a batch button 171 if ($canDo->get('core.create') && $canDo->get('core.edit') && $canDo->get('core.edit.state')) { 172 $childBar->popupButton('batch') 173 ->text('JTOOLBAR_BATCH') 174 ->selector('collapseModal') 175 ->listCheck(true); 176 } 177 } 178 179 if (!$this->isEmptyState && $this->state->get('filter.published') == -2 && $canDo->get('core.delete')) { 180 $toolbar->delete('tags.delete') 181 ->text('JTOOLBAR_EMPTY_TRASH') 182 ->message('JGLOBAL_CONFIRM_DELETE') 183 ->listCheck(true); 184 } 185 186 if ($canDo->get('core.admin') || $canDo->get('core.options')) { 187 $toolbar->preferences('com_tags'); 188 } 189 190 $toolbar->help('Tags'); 191 } 192 }
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 |