| [ 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_newsfeeds 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 // Check to ensure this file is included in Joomla! 10 defined('_JEXEC') or die; 11 12 jimport('joomla.application.component.view'); 13 14 /** 15 * HTML View class for the Newsfeeds component 16 * 17 * @package Joomla.Site 18 * @subpackage com_newsfeeds 19 * @since 1.0 20 */ 21 class NewsfeedsViewCategory extends JView 22 { 23 protected $state; 24 protected $items; 25 protected $category; 26 protected $categories; 27 protected $pagination; 28 29 function display($tpl = null) 30 { 31 $app = JFactory::getApplication(); 32 $user = JFactory::getUser(); 33 $params = $app->getParams(); 34 35 // Get some data from the models 36 $state = $this->get('State'); 37 $items = $this->get('Items'); 38 $category = $this->get('Category'); 39 $children = $this->get('Children'); 40 $parent = $this->get('Parent'); 41 $pagination = $this->get('Pagination'); 42 43 // Check for errors. 44 if (count($errors = $this->get('Errors'))) { 45 JError::raiseError(500, implode("\n", $errors)); 46 return false; 47 } 48 49 if ($category == false) { 50 return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND')); 51 } 52 53 if ($parent == false) { 54 return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND')); 55 } 56 57 // Check whether category access level allows access. 58 $groups = $user->getAuthorisedViewLevels(); 59 if (!in_array($category->access, $groups)) { 60 return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR')); 61 } 62 63 // Prepare the data. 64 // Compute the newsfeed slug. 65 for ($i = 0, $n = count($items); $i < $n; $i++) 66 { 67 $item = &$items[$i]; 68 $item->slug = $item->alias ? ($item->id.':'.$item->alias) : $item->id; 69 $temp = new JRegistry(); 70 $temp->loadString($item->params); 71 $item->params = clone($params); 72 $item->params->merge($temp); 73 } 74 75 // Setup the category parameters. 76 $cparams = $category->getParams(); 77 $category->params = clone($params); 78 $category->params->merge($cparams); 79 80 $children = array($category->id => $children); 81 82 //Escape strings for HTML output 83 $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); 84 85 $maxLevel = $params->get('maxLevel', -1); 86 $this->assignRef('maxLevel', $maxLevel); 87 $this->assignRef('state', $state); 88 $this->assignRef('items', $items); 89 $this->assignRef('category', $category); 90 $this->assignRef('children', $children); 91 $this->assignRef('params', $params); 92 $this->assignRef('parent', $parent); 93 $this->assignRef('pagination', $pagination); 94 95 // Check for layout override only if this is not the active menu item 96 // If it is the active menu item, then the view and category id will match 97 $active = $app->getMenu()->getActive(); 98 if ((!$active) || ((strpos($active->link, 'view=category') === false) || (strpos($active->link, '&id=' . (string) $this->category->id) === false))) { 99 if ($layout = $category->params->get('category_layout')) { 100 $this->setLayout($layout); 101 } 102 } 103 elseif (isset($active->query['layout'])) { 104 // We need to set the layout in case this is an alternative menu item (with an alternative layout) 105 $this->setLayout($active->query['layout']); 106 } 107 108 $this->_prepareDocument(); 109 110 parent::display($tpl); 111 } 112 113 /** 114 * Prepares the document 115 */ 116 protected function _prepareDocument() 117 { 118 $app = JFactory::getApplication(); 119 $menus = $app->getMenu(); 120 $pathway = $app->getPathway(); 121 $title = null; 122 123 // Because the application sets a default page title, 124 // we need to get it from the menu item itself 125 $menu = $menus->getActive(); 126 127 if ($menu) { 128 $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); 129 } 130 else { 131 $this->params->def('page_heading', JText::_('COM_NEWSFEEDS_DEFAULT_PAGE_TITLE')); 132 } 133 134 $id = (int) @$menu->query['id']; 135 136 if ($menu && ($menu->query['option'] != 'com_newsfeeds' || $menu->query['view'] == 'newsfeed' || $id != $this->category->id)) { 137 $path = array(array('title' => $this->category->title, 'link' => '')); 138 $category = $this->category->getParent(); 139 140 while (($menu->query['option'] != 'com_newsfeeds' || $menu->query['view'] == 'newsfeed' || $id != $category->id) && $category->id > 1) 141 { 142 $path[] = array('title' => $category->title, 'link' => NewsfeedsHelperRoute::getCategoryRoute($category->id)); 143 $category = $category->getParent(); 144 } 145 146 $path = array_reverse($path); 147 148 foreach($path as $item) 149 { 150 $pathway->addItem($item['title'], $item['link']); 151 } 152 } 153 154 $title = $this->params->get('page_title', ''); 155 156 if (empty($title)) { 157 $title = $app->getCfg('sitename'); 158 } 159 elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { 160 $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); 161 } 162 elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { 163 $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); 164 } 165 166 $this->document->setTitle($title); 167 168 if ($this->category->metadesc) 169 { 170 $this->document->setDescription($this->category->metadesc); 171 } 172 elseif (!$this->category->metadesc && $this->params->get('menu-meta_description')) 173 { 174 $this->document->setDescription($this->params->get('menu-meta_description')); 175 } 176 177 if ($this->category->metakey) 178 { 179 $this->document->setMetadata('keywords', $this->category->metakey); 180 } 181 elseif (!$this->category->metakey && $this->params->get('menu-meta_keywords')) 182 { 183 $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); 184 } 185 186 if ($this->params->get('robots')) 187 { 188 $this->document->setMetadata('robots', $this->params->get('robots')); 189 } 190 191 if ($app->getCfg('MetaAuthor') == '1') { 192 $this->document->setMetaData('author', $this->category->getMetadata()->get('author')); 193 } 194 195 $mdata = $this->category->getMetadata()->toArray(); 196 197 foreach ($mdata as $k => $v) 198 { 199 if ($v) { 200 $this->document->setMetadata($k, $v); 201 } 202 } 203 } 204 }
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 |