| [ Index ] |
PHP Cross Reference of Joomla 2.5.4 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Joomla.Site 4 * @subpackage com_weblinks 5 * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. 6 * @license GNU General Public License version 2 or later; see LICENSE.txt 7 */ 8 9 // no direct access 10 defined('_JEXEC') or die; 11 12 jimport('joomla.application.component.view'); 13 14 /** 15 * HTML View class for the WebLinks component 16 * 17 * @package Joomla.Site 18 * @subpackage com_weblinks 19 * @since 1.5 20 */ 21 class WeblinksViewCategory extends JView 22 { 23 protected $state; 24 protected $items; 25 protected $category; 26 protected $children; 27 protected $pagination; 28 29 function display($tpl = null) 30 { 31 $app = JFactory::getApplication(); 32 $params = $app->getParams(); 33 34 // Get some data from the models 35 $state = $this->get('State'); 36 $items = $this->get('Items'); 37 $category = $this->get('Category'); 38 $children = $this->get('Children'); 39 $parent = $this->get('Parent'); 40 $pagination = $this->get('Pagination'); 41 42 // Check for errors. 43 if (count($errors = $this->get('Errors'))) { 44 JError::raiseError(500, implode("\n", $errors)); 45 return false; 46 } 47 48 if ($category == false) { 49 return JError::raiseWarning(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND')); 50 } 51 52 if ($parent == false) { 53 return JError::raiseWarning(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND')); 54 } 55 56 // Check whether category access level allows access. 57 // TODO: SHould already be computed in $category->params->get('access-view') 58 $user = JFactory::getUser(); 59 $groups = $user->getAuthorisedViewLevels(); 60 if (!in_array($category->access, $groups)) { 61 return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR')); 62 } 63 64 // Prepare the data. 65 // Compute the weblink slug & link url. 66 for ($i = 0, $n = count($items); $i < $n; $i++) 67 { 68 $item = &$items[$i]; 69 $item->slug = $item->alias ? ($item->id.':'.$item->alias) : $item->id; 70 71 if ($item->params->get('count_clicks', $params->get('count_clicks')) == 1) { 72 $item->link = JRoute::_('index.php?option=com_weblinks&task=weblink.go&&id='. $item->id); 73 } 74 else { 75 $item->link = $item->url; 76 } 77 78 $temp = new JRegistry(); 79 $temp->loadString($item->params); 80 $item->params = clone($params); 81 $item->params->merge($temp); 82 } 83 84 // Setup the category parameters. 85 $cparams = $category->getParams(); 86 $category->params = clone($params); 87 $category->params->merge($cparams); 88 89 $children = array($category->id => $children); 90 $maxLevel = $params->get('maxLevel', -1); 91 92 $this->assignRef('maxLevel', $maxLevel); 93 $this->assignRef('state', $state); 94 $this->assignRef('items', $items); 95 $this->assignRef('category', $category); 96 $this->assignRef('children', $children); 97 $this->assignRef('params', $params); 98 $this->assignRef('parent', $parent); 99 $this->assignRef('pagination', $pagination); 100 101 //Escape strings for HTML output 102 $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); 103 104 // Check for layout override only if this is not the active menu item 105 // If it is the active menu item, then the view and category id will match 106 $active = $app->getMenu()->getActive(); 107 if ((!$active) || ((strpos($active->link, 'view=category') === false) || (strpos($active->link, '&id=' . (string) $this->category->id) === false))) { 108 if ($layout = $category->params->get('category_layout')) { 109 $this->setLayout($layout); 110 } 111 } 112 elseif (isset($active->query['layout'])) { 113 // We need to set the layout in case this is an alternative menu item (with an alternative layout) 114 $this->setLayout($active->query['layout']); 115 } 116 117 $this->_prepareDocument(); 118 119 parent::display($tpl); 120 } 121 122 /** 123 * Prepares the document 124 */ 125 protected function _prepareDocument() 126 { 127 $app = JFactory::getApplication(); 128 $menus = $app->getMenu(); 129 $pathway = $app->getPathway(); 130 $title = null; 131 132 // Because the application sets a default page title, 133 // we need to get it from the menu item itself 134 $menu = $menus->getActive(); 135 136 if ($menu) { 137 $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); 138 } 139 else { 140 $this->params->def('page_heading', JText::_('COM_WEBLINKS_DEFAULT_PAGE_TITLE')); 141 } 142 143 $id = (int) @$menu->query['id']; 144 145 if ($menu && ($menu->query['option'] != 'com_weblinks' || $id != $this->category->id)) { 146 $this->params->set('page_subheading', $this->category->title); 147 $path = array(array('title' => $this->category->title, 'link' => '')); 148 $category = $this->category->getParent(); 149 150 while (($menu->query['option'] != 'com_weblinks' || $id != $category->id) && $category->id > 1) 151 { 152 $path[] = array('title' => $category->title, 'link' => WeblinksHelperRoute::getCategoryRoute($category->id)); 153 $category = $category->getParent(); 154 } 155 156 $path = array_reverse($path); 157 158 foreach($path as $item) 159 { 160 $pathway->addItem($item['title'], $item['link']); 161 } 162 } 163 164 $title = $this->params->get('page_title', ''); 165 166 if (empty($title)) { 167 $title = $app->getCfg('sitename'); 168 } 169 elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { 170 $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); 171 } 172 elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { 173 $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); 174 } 175 176 $this->document->setTitle($title); 177 178 if ($this->category->metadesc) 179 { 180 $this->document->setDescription($this->category->metadesc); 181 } 182 elseif (!$this->category->metadesc && $this->params->get('menu-meta_description')) 183 { 184 $this->document->setDescription($this->params->get('menu-meta_description')); 185 } 186 187 if ($this->category->metakey) 188 { 189 $this->document->setMetadata('keywords', $this->category->metakey); 190 } 191 elseif (!$this->category->metakey && $this->params->get('menu-meta_keywords')) 192 { 193 $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); 194 } 195 196 if ($this->params->get('robots')) 197 { 198 $this->document->setMetadata('robots', $this->params->get('robots')); 199 } 200 201 if ($app->getCfg('MetaAuthor') == '1') { 202 $this->document->setMetaData('author', $this->category->getMetadata()->get('author')); 203 } 204 205 $mdata = $this->category->getMetadata()->toArray(); 206 207 foreach ($mdata as $k => $v) 208 { 209 if ($v) { 210 $this->document->setMetadata($k, $v); 211 } 212 } 213 214 // Add alternative feed link 215 if ($this->params->get('show_feed_link', 1) == 1) 216 { 217 $link = '&format=feed&limitstart='; 218 $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); 219 $this->document->addHeadLink(JRoute::_($link.'&type=rss'), 'alternate', 'rel', $attribs); 220 $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); 221 $this->document->addHeadLink(JRoute::_($link.'&type=atom'), 'alternate', 'rel', $attribs); 222 } 223 } 224 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Apr 3 11:40:28 2012 | Cross-referenced by PHPXref 0.7.1 |