[ 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_redirect 6 * 7 * @copyright (C) 2009 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\Redirect\Administrator\View\Links; 12 13 use Joomla\CMS\Component\ComponentHelper; 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\Plugin\PluginHelper; 19 use Joomla\CMS\Toolbar\Toolbar; 20 use Joomla\CMS\Toolbar\ToolbarHelper; 21 use Joomla\Component\Redirect\Administrator\Helper\RedirectHelper; 22 23 // phpcs:disable PSR1.Files.SideEffects 24 \defined('_JEXEC') or die; 25 // phpcs:enable PSR1.Files.SideEffects 26 27 /** 28 * View class for a list of redirection links. 29 * 30 * @since 1.6 31 */ 32 class HtmlView extends BaseHtmlView 33 { 34 /** 35 * True if "System - Redirect Plugin" is enabled 36 * 37 * @var boolean 38 */ 39 protected $enabled; 40 41 /** 42 * True if "Collect URLs" is enabled 43 * 44 * @var boolean 45 */ 46 protected $collect_urls_enabled; 47 48 /** 49 * The id of the redirect plugin in mysql 50 * 51 * @var integer 52 * @since 3.8.0 53 */ 54 protected $redirectPluginId = 0; 55 56 /** 57 * An array of items 58 * 59 * @var array 60 */ 61 protected $items; 62 63 /** 64 * The pagination object 65 * 66 * @var \Joomla\CMS\Pagination\Pagination 67 */ 68 protected $pagination; 69 70 /** 71 * The model state 72 * 73 * @var \Joomla\CMS\Object\CMSObject 74 */ 75 protected $state; 76 77 /** 78 * The model state 79 * 80 * @var \Joomla\Registry\Registry 81 */ 82 protected $params; 83 84 /** 85 * Form object for search filters 86 * 87 * @var \Joomla\CMS\Form\Form 88 * 89 * @since 4.0.0 90 */ 91 public $filterForm; 92 93 /** 94 * The active search filters 95 * 96 * @var array 97 * @since 4.0.0 98 */ 99 public $activeFilters; 100 101 /** 102 * Is this view an Empty State 103 * 104 * @var boolean 105 * @since 4.0.0 106 */ 107 private $isEmptyState = false; 108 109 /** 110 * Display the view. 111 * 112 * @param string $tpl The name of the template file to parse; automatically searches through the template paths. 113 * 114 * @return void 115 * 116 * @throws GenericDataException 117 * @since 1.6 118 */ 119 public function display($tpl = null) 120 { 121 // Set variables 122 $this->items = $this->get('Items'); 123 $this->pagination = $this->get('Pagination'); 124 $this->state = $this->get('State'); 125 $this->filterForm = $this->get('FilterForm'); 126 $this->activeFilters = $this->get('ActiveFilters'); 127 $this->params = ComponentHelper::getParams('com_redirect'); 128 129 if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) { 130 $this->setLayout('emptystate'); 131 } 132 133 // Check for errors. 134 if (\count($errors = $this->get('Errors'))) { 135 throw new GenericDataException(implode("\n", $errors), 500); 136 } 137 138 if (!(PluginHelper::isEnabled('system', 'redirect') && RedirectHelper::collectUrlsEnabled())) { 139 $this->redirectPluginId = RedirectHelper::getRedirectPluginId(); 140 } 141 142 $this->addToolbar(); 143 144 parent::display($tpl); 145 } 146 147 /** 148 * Add the page title and toolbar. 149 * 150 * @return void 151 * 152 * @since 1.6 153 */ 154 protected function addToolbar() 155 { 156 $state = $this->get('State'); 157 $canDo = ContentHelper::getActions('com_redirect'); 158 159 $toolbar = Toolbar::getInstance('toolbar'); 160 161 ToolbarHelper::title(Text::_('COM_REDIRECT_MANAGER_LINKS'), 'map-signs redirect'); 162 163 if ($canDo->get('core.create')) { 164 $toolbar->addNew('link.add'); 165 } 166 167 if (!$this->isEmptyState && ($canDo->get('core.edit.state') || $canDo->get('core.admin'))) { 168 $dropdown = $toolbar->dropdownButton('status-group') 169 ->text('JTOOLBAR_CHANGE_STATUS') 170 ->toggleSplit(false) 171 ->icon('icon-ellipsis-h') 172 ->buttonClass('btn btn-action') 173 ->listCheck(true); 174 175 $childBar = $dropdown->getChildToolbar(); 176 177 if ($state->get('filter.state') != 2) { 178 $childBar->publish('links.publish', 'JTOOLBAR_ENABLE')->listCheck(true); 179 $childBar->unpublish('links.unpublish', 'JTOOLBAR_DISABLE')->listCheck(true); 180 } 181 182 if ($state->get('filter.state') != -1) { 183 if ($state->get('filter.state') != 2) { 184 $childBar->archive('links.archive')->listCheck(true); 185 } elseif ($state->get('filter.state') == 2) { 186 $childBar->unarchive('links.unarchive')->listCheck(true); 187 } 188 } 189 190 if (!$state->get('filter.state') == -2) { 191 $childBar->trash('links.trash')->listCheck(true); 192 } 193 } 194 195 if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { 196 $toolbar->delete('links.delete') 197 ->text('JTOOLBAR_EMPTY_TRASH') 198 ->message('JGLOBAL_CONFIRM_DELETE') 199 ->listCheck(true); 200 } 201 202 if (!$this->isEmptyState && (!$state->get('filter.state') == -2 && $canDo->get('core.delete'))) { 203 $toolbar->confirmButton('delete') 204 ->text('COM_REDIRECT_TOOLBAR_PURGE') 205 ->message('COM_REDIRECT_CONFIRM_PURGE') 206 ->task('links.purge'); 207 } 208 209 if ($canDo->get('core.create')) { 210 $toolbar->popupButton('batch') 211 ->text('JTOOLBAR_BULK_IMPORT') 212 ->selector('collapseModal') 213 ->listCheck(false); 214 } 215 216 if ($canDo->get('core.admin') || $canDo->get('core.options')) { 217 $toolbar->preferences('com_redirect'); 218 } 219 220 $toolbar->help('Redirects:_Links'); 221 } 222 }
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 |