Source for file view.html.php
Documentation is available at view.html.php
* @subpackage com_newsfeeds
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* HTML View class for the Newsfeeds component
* @subpackage com_newsfeeds
* Execute and display a template script.
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
* @return mixed A string if successful, otherwise a Error object.
public function display($tpl =
null)
// Get view related request variables.
$print =
$app->input->getBool('print');
$state =
$this->get('State');
$item =
$this->get('Item');
// Get Category Model data
$categoryModel->setState('category.id', $item->catid);
$categoryModel->setState('list.ordering', 'a.name');
$categoryModel->setState('list.direction', 'asc');
// TODO: $items is not used. Remove this line?
$items =
$categoryModel->getItems();
// @TODO Maybe this could go into JComponentHelper::raiseErrors($this->get('Errors'))
if (count($errors =
$this->get('Errors')))
$item->slug =
$item->alias ?
($item->id .
':' .
$item->alias) :
$item->id;
$item->catslug =
$item->category_alias ?
($item->catid .
':' .
$item->category_alias) :
$item->catid;
$item->parent_slug =
$item->category_alias ?
($item->parent_id .
':' .
$item->parent_alias) :
$item->parent_id;
// check if cache directory is writeable
// Merge newsfeed params. If this is single-newsfeed view, menu params override newsfeed params
// Otherwise, newsfeed params override menu item params
$params =
$state->get('params');
$newsfeed_params =
clone $item->params;
$active =
$app->getMenu()->getActive();
// Check to see which parameters should take priority
$currentLink =
$active->link;
// If the current view is the active item and an newsfeed view for this feed, then the menu item params take priority
if (strpos($currentLink, 'view=newsfeed') &&
(strpos($currentLink, '&id='.(string)
$item->id)))
// $item->params are the newsfeed params, $temp are the menu item params
// Merge so that the menu item params take priority
$newsfeed_params->merge($temp);
$item->params =
$newsfeed_params;
// Load layout from active query (in case it is an alternative menu item)
if (isset
($active->query['layout']))
// Current view is not a single newsfeed, so the newsfeed params take priority here
// Merge the menu item params with the newsfeed params so that the newsfeed params take priority
$temp->merge($newsfeed_params);
// Check for alternative layouts (since we are not in a single-newsfeed menu item)
if ($layout =
$item->params->get('newsfeed_layout'))
// Merge so that newsfeed params take priority
$temp->merge($newsfeed_params);
// Check for alternative layouts (since we are not in a single-newsfeed menu item)
if ($layout =
$item->params->get('newsfeed_layout'))
// Check the access to the newsfeed
$levels =
$user->getAuthorisedViewLevels();
if (!in_array($item->access, $levels) or ((in_array($item->access, $levels) and (!in_array($item->category_access, $levels)))))
// Get the current menu item
$params =
$app->getParams();
$temp->loadString($item->params);
$this->rssDoc =
$feed->getFeed($newsfeed->link);
catch
(InvalidArgumentException $e)
$msg =
JText::_('COM_NEWSFEEDS_ERRORS_FEED_NOT_RETRIEVED');
catch
(RunTimeException $e)
$msg =
JText::_('COM_NEWSFEEDS_ERRORS_FEED_NOT_RETRIEVED');
if (empty($this->rssDoc))
$msg =
JText::_('COM_NEWSFEEDS_ERRORS_FEED_NOT_RETRIEVED');
$feed_display_order =
$params->get('feed_display_order', 'des');
if ($feed_display_order ==
'asc')
//Escape strings for HTML output
$item->tags->getItemTags('com_newsfeeds.newsfeed', $item->id);
// Increment the hit counter of the newsfeed.
$menus =
$app->getMenu();
$pathway =
$app->getPathway();
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu =
$menus->getActive();
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
$this->params->def('page_heading', JText::_('COM_NEWSFEEDS_DEFAULT_PAGE_TITLE'));
$title =
$this->params->get('page_title', '');
$id = (int)
@$menu->query['id'];
// if the menu item does not concern this newsfeed
if ($menu &&
($menu->query['option'] !=
'com_newsfeeds' ||
$menu->query['view'] !=
'newsfeed' ||
$id !=
$this->item->id))
// If this is not a single newsfeed menu item, set the page title to the newsfeed title
$title =
$this->item->name;
$path =
array(array('title' =>
$this->item->name, 'link' =>
''));
while (($menu->query['option'] !=
'com_newsfeeds' ||
$menu->query['view'] ==
'newsfeed' ||
$id !=
$category->id) &&
$category->id >
1)
$category =
$category->getParent();
$pathway->addItem($item['title'], $item['link']);
$title =
$app->getCfg('sitename');
elseif ($app->getCfg('sitename_pagetitles', 0) ==
1)
$title =
JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
elseif ($app->getCfg('sitename_pagetitles', 0) ==
2)
$title =
JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
$title =
$this->item->name;
$this->document->setTitle($title);
if ($this->item->metadesc)
$this->document->setDescription($this->item->metadesc);
elseif (!$this->item->metadesc &&
$this->params->get('menu-meta_description'))
$this->document->setDescription($this->params->get('menu-meta_description'));
if ($this->item->metakey)
$this->document->setMetadata('keywords', $this->item->metakey);
elseif (!$this->item->metakey &&
$this->params->get('menu-meta_keywords'))
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
if ($this->params->get('robots'))
$this->document->setMetadata('robots', $this->params->get('robots'));
if ($app->getCfg('MetaTitle') ==
'1')
$this->document->setMetaData('title', $this->item->name);
if ($app->getCfg('MetaAuthor') ==
'1')
$this->document->setMetaData('author', $this->item->author);
$mdata =
$this->item->metadata->toArray();
foreach ($mdata as $k =>
$v)
$this->document->setMetadata($k, $v);
Documentation generated on Tue, 19 Nov 2013 15:17:20 +0100 by phpDocumentor 1.4.3