[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Site 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\Site\View\Tags; 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\Router\Route; 18 use Joomla\Registry\Registry; 19 20 // phpcs:disable PSR1.Files.SideEffects 21 \defined('_JEXEC') or die; 22 // phpcs:enable PSR1.Files.SideEffects 23 24 /** 25 * HTML View class for the Tags component 26 * 27 * @since 3.1 28 */ 29 class HtmlView extends BaseHtmlView 30 { 31 /** 32 * The model state 33 * 34 * @var \Joomla\CMS\Object\CMSObject 35 * 36 * @since 3.1 37 */ 38 protected $state; 39 40 /** 41 * The list of tags 42 * 43 * @var array|false 44 * @since 3.1 45 */ 46 protected $items; 47 48 /** 49 * The pagination object 50 * 51 * @var \Joomla\CMS\Pagination\Pagination 52 * @since 3.1 53 */ 54 protected $pagination; 55 56 /** 57 * The page parameters 58 * 59 * @var \Joomla\Registry\Registry|null 60 * @since 3.1 61 */ 62 protected $params = null; 63 64 /** 65 * The page class suffix 66 * 67 * @var string 68 * @since 4.0.0 69 */ 70 protected $pageclass_sfx = ''; 71 72 /** 73 * The logged in user 74 * 75 * @var \Joomla\CMS\User\User|null 76 * @since 4.0.0 77 */ 78 protected $user = null; 79 80 /** 81 * Execute and display a template script. 82 * 83 * @param string $tpl The name of the template file to parse; automatically searches through the template paths. 84 * 85 * @return mixed A string if successful, otherwise an Error object. 86 */ 87 public function display($tpl = null) 88 { 89 // Get some data from the models 90 $this->state = $this->get('State'); 91 $this->items = $this->get('Items'); 92 $this->pagination = $this->get('Pagination'); 93 $this->params = $this->state->get('params'); 94 $this->user = $this->getCurrentUser(); 95 96 if (count($errors = $this->get('Errors'))) { 97 throw new GenericDataException(implode("\n", $errors), 500); 98 } 99 100 // Flag indicates to not add limitstart=0 to URL 101 $this->pagination->hideEmptyLimitstart = true; 102 103 if (!empty($this->items)) { 104 foreach ($this->items as $itemElement) { 105 // Prepare the data. 106 $temp = new Registry($itemElement->params); 107 $itemElement->params = clone $this->params; 108 $itemElement->params->merge($temp); 109 $itemElement->params = (array) json_decode($itemElement->params); 110 } 111 } 112 113 // Escape strings for HTML output 114 $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx', '')); 115 116 $active = Factory::getApplication()->getMenu()->getActive(); 117 118 // Load layout from active query (in case it is an alternative menu item) 119 if ($active && isset($active->query['option']) && $active->query['option'] === 'com_tags' && $active->query['view'] === 'tags') { 120 if (isset($active->query['layout'])) { 121 $this->setLayout($active->query['layout']); 122 } 123 } else { 124 // Load default All Tags layout from component 125 if ($layout = $this->params->get('tags_layout')) { 126 $this->setLayout($layout); 127 } 128 } 129 130 $this->_prepareDocument(); 131 132 parent::display($tpl); 133 } 134 135 /** 136 * Prepares the document 137 * 138 * @return void 139 */ 140 protected function _prepareDocument() 141 { 142 // Because the application sets a default page title, 143 // we need to get it from the menu item itself 144 $menu = Factory::getApplication()->getMenu()->getActive(); 145 146 if ($menu) { 147 $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); 148 } else { 149 $this->params->def('page_heading', Text::_('COM_TAGS_DEFAULT_PAGE_TITLE')); 150 } 151 152 // Set metadata for all tags menu item 153 if ($this->params->get('menu-meta_description')) { 154 $this->document->setDescription($this->params->get('menu-meta_description')); 155 } 156 157 if ($this->params->get('robots')) { 158 $this->document->setMetaData('robots', $this->params->get('robots')); 159 } 160 161 // Respect configuration Sitename Before/After for TITLE in views All Tags. 162 $this->setDocumentTitle($this->document->getTitle()); 163 164 // Add alternative feed link 165 if ($this->params->get('show_feed_link', 1) == 1) { 166 $link = '&format=feed&limitstart='; 167 $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); 168 $this->document->addHeadLink(Route::_($link . '&type=rss'), 'alternate', 'rel', $attribs); 169 $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); 170 $this->document->addHeadLink(Route::_($link . '&type=atom'), 'alternate', 'rel', $attribs); 171 } 172 } 173 }
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 |