1 <?php
2 3 4 5 6 7 8
9
10 defined('JPATH_PLATFORM') or die;
11
12 13 14 15 16
17 class JViewCategories extends JViewLegacy
18 {
19 20 21 22 23 24
25 protected $state;
26
27 28 29 30 31 32
33 protected $items;
34
35 36 37 38 39 40
41 protected $pageHeading;
42
43 44 45 46 47 48 49 50 51
52 public function display($tpl = null)
53 {
54 $state = $this->get('State');
55 $items = $this->get('Items');
56 $parent = $this->get('Parent');
57
58 $app = JFactory::getApplication();
59
60
61 if (count($errors = $this->get('Errors')))
62 {
63 $app->enqueueMessage($errors, 'error');
64
65 return false;
66 }
67
68 if ($items === false)
69 {
70 $app->enqueueMessage(JText::_('JGLOBAL_CATEGORY_NOT_FOUND'), 'error');
71
72 return false;
73 }
74
75 if ($parent == false)
76 {
77 $app->enqueueMessage(JText::_('JGLOBAL_CATEGORY_NOT_FOUND'), 'error');
78
79 return false;
80 }
81
82 $params = &$state->params;
83
84 $items = array($parent->id => $items);
85
86
87 $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'), ENT_COMPAT, 'UTF-8');
88
89 $this->maxLevelcat = $params->get('maxLevelcat', -1) < 0 ? PHP_INT_MAX : $params->get('maxLevelcat', PHP_INT_MAX);
90 $this->params = &$params;
91 $this->parent = &$parent;
92 $this->items = &$items;
93
94 $this->prepareDocument();
95
96 return parent::display($tpl);
97 }
98
99 100 101 102 103 104 105
106 protected function prepareDocument()
107 {
108 $app = JFactory::getApplication();
109 $menus = $app->getMenu();
110
111
112 $menu = $menus->getActive();
113
114 if ($menu)
115 {
116 $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
117 }
118 else
119 {
120 $this->params->def('page_heading', JText::_($this->pageHeading));
121 }
122
123 $title = $this->params->get('page_title', '');
124
125 if (empty($title))
126 {
127 $title = $app->get('sitename');
128 }
129 elseif ($app->get('sitename_pagetitles', 0) == 1)
130 {
131 $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title);
132 }
133 elseif ($app->get('sitename_pagetitles', 0) == 2)
134 {
135 $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename'));
136 }
137
138 $this->document->setTitle($title);
139
140 if ($this->params->get('menu-meta_description'))
141 {
142 $this->document->setDescription($this->params->get('menu-meta_description'));
143 }
144
145 if ($this->params->get('menu-meta_keywords'))
146 {
147 $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
148 }
149
150 if ($this->params->get('robots'))
151 {
152 $this->document->setMetadata('robots', $this->params->get('robots'));
153 }
154 }
155 }
156