Source for file view.feed.php

Documentation is available at view.feed.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Site
  4.  * @subpackage  com_content
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC') or die;
  11.  
  12. /**
  13.  * Frontpage View class
  14.  *
  15.  * @package     Joomla.Site
  16.  * @subpackage  com_content
  17.  * @since       1.5
  18.  */
  19. {
  20.     public function display($tpl = null)
  21.     {
  22.         // Parameters
  23.         $app       = JFactory::getApplication();
  24.         $doc       = JFactory::getDocument();
  25.         $params    = $app->getParams();
  26.         $feedEmail = $app->getCfg('feed_email', 'author');
  27.         $siteEmail = $app->getCfg('mailfrom');
  28.  
  29.         $doc->link    = JRoute::_('index.php?option=com_content&view=featured');
  30.  
  31.         // Get some data from the model
  32.         $app->input->set('limit', $app->getCfg('feed_limit'));
  33.         $categories = JCategories::getInstance('Content');
  34.         $rows       = $this->get('Items');
  35.         foreach ($rows as $row)
  36.         {
  37.             // strip html from feed item title
  38.             $title = $this->escape($row->title);
  39.             $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
  40.  
  41.             // Compute the article slug
  42.             $row->slug = $row->alias ? ($row->id . ':' . $row->alias) : $row->id;
  43.  
  44.             // Url link to article
  45.             $link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid));
  46.  
  47.             // Get row fulltext
  48.             $db = JFactory::getDbo();
  49.             $query = 'SELECT' .$db->quoteName('fulltext'). 'FROM #__content WHERE id ='.$row->id;
  50.             $db->setQuery($query);
  51.             $row->fulltext = $db->loadResult();
  52.  
  53.             $description    = ($params->get('feed_summary', 0) ? $row->introtext.$row->fulltext : $row->introtext);
  54.             $author            = $row->created_by_alias ? $row->created_by_alias : $row->author;
  55.  
  56.             // Load individual item creator class
  57.             $item                = new JFeedItem;
  58.             $item->title        = $title;
  59.             $item->link            = $link;
  60.             $item->date            = $row->publish_up;
  61.             $item->category        = array();
  62.             $item->category[]    = JText::_('JFEATURED'); // All featured articles are categorized as "Featured"
  63.             for ($item_category = $categories->get($row->catid); $item_category !== null; $item_category = $item_category->getParent())
  64.             {
  65.                 if ($item_category->id > 1) { // Only add non-root categories
  66.                     $item->category[] = $item_category->title;
  67.                 }
  68.             }
  69.  
  70.             $item->author         = $author;
  71.             if ($feedEmail == 'site')
  72.             {
  73.                 $item->authorEmail = $siteEmail;
  74.             }
  75.             elseif ($feedEmail === 'author')
  76.             {
  77.                 $item->authorEmail = $row->author_email;
  78.             }
  79.  
  80.             // Add readmore link to description if introtext is shown, show_readmore is true and fulltext exists
  81.             if (!$params->get('feed_summary', 0) && $params->get('feed_show_readmore', 0) && $row->fulltext)
  82.             {
  83.                 $description .= '<p class="feed-readmore"><a target="_blank" href ="' . $item->link . '">' . JText::_('COM_CONTENT_FEED_READMORE') . '</a></p>';
  84.             }
  85.  
  86.             // Load item description and add div
  87.             $item->description    = '<div class="feed-description">'.$description.'</div>';
  88.  
  89.             // Loads item info into rss array
  90.             $doc->addItem($item);
  91.         }
  92.     }
  93. }

Documentation generated on Tue, 19 Nov 2013 15:16:47 +0100 by phpDocumentor 1.4.3