[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\MVC\View; 11 12 use Joomla\CMS\Factory; 13 use Joomla\CMS\Language\Text; 14 15 // phpcs:disable PSR1.Files.SideEffects 16 \defined('JPATH_PLATFORM') or die; 17 // phpcs:enable PSR1.Files.SideEffects 18 19 /** 20 * Categories view base class. 21 * 22 * @since 3.2 23 */ 24 class CategoriesView extends HtmlView 25 { 26 /** 27 * State data 28 * 29 * @var \Joomla\Registry\Registry 30 * @since 3.2 31 */ 32 protected $state; 33 34 /** 35 * Category items data 36 * 37 * @var array 38 * @since 3.2 39 */ 40 protected $items; 41 42 /** 43 * Language key for default page heading 44 * 45 * @var string 46 * @since 3.2 47 */ 48 protected $pageHeading; 49 50 /** 51 * Execute and display a template script. 52 * 53 * @param string $tpl The name of the template file to parse; automatically searches through the template paths. 54 * 55 * @return void|boolean 56 * 57 * @since 3.2 58 * @throws \Exception 59 */ 60 public function display($tpl = null) 61 { 62 $state = $this->get('State'); 63 $items = $this->get('Items'); 64 $parent = $this->get('Parent'); 65 66 $app = Factory::getApplication(); 67 68 // Check for errors. 69 if (\count($errors = $this->get('Errors'))) { 70 $app->enqueueMessage($errors, 'error'); 71 72 return false; 73 } 74 75 if ($items === false) { 76 $app->enqueueMessage(Text::_('JGLOBAL_CATEGORY_NOT_FOUND'), 'error'); 77 78 return false; 79 } 80 81 if ($parent == false) { 82 $app->enqueueMessage(Text::_('JGLOBAL_CATEGORY_NOT_FOUND'), 'error'); 83 84 return false; 85 } 86 87 $params = &$state->params; 88 89 $items = array($parent->id => $items); 90 91 // Escape strings for HTML output 92 $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx', ''), ENT_COMPAT, 'UTF-8'); 93 94 $this->maxLevelcat = $params->get('maxLevelcat', -1) < 0 ? PHP_INT_MAX : $params->get('maxLevelcat', PHP_INT_MAX); 95 $this->params = &$params; 96 $this->parent = &$parent; 97 $this->items = &$items; 98 99 $this->prepareDocument(); 100 101 parent::display($tpl); 102 } 103 104 /** 105 * Prepares the document 106 * 107 * @return void 108 * 109 * @since 3.2 110 */ 111 protected function prepareDocument() 112 { 113 // Because the application sets a default page title, we need to get it from the menu item itself 114 $menu = Factory::getApplication()->getMenu()->getActive(); 115 116 if ($menu) { 117 $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); 118 } else { 119 $this->params->def('page_heading', Text::_($this->pageHeading)); 120 } 121 122 $this->setDocumentTitle($this->params->get('page_title', '')); 123 124 if ($this->params->get('menu-meta_description')) { 125 $this->document->setDescription($this->params->get('menu-meta_description')); 126 } 127 128 if ($this->params->get('robots')) { 129 $this->document->setMetaData('robots', $this->params->get('robots')); 130 } 131 } 132 }
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 |