[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/components/com_newsfeeds/views/newsfeed/ -> view.html.php (source)

   1  <?php
   2  /**
   3  * version $Id: view.html.php 14401 2010-01-26 14:10:00Z louis $
   4  * @package        Joomla
   5  * @subpackage    Newsfeeds
   6  * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   7  * @license        GNU/GPL, see LICENSE.php
   8  *
   9  * Joomla! is free software. This version may have been modified pursuant
  10  * to the GNU General Public License, and as distributed it includes or
  11  * is derivative of works licensed under the GNU General Public License or
  12  * other free or open source software licenses.
  13  * See COPYRIGHT.php for copyright notices and details.
  14  */
  15  
  16  // Check to ensure this file is included in Joomla!
  17  defined('_JEXEC') or die( 'Restricted access' );
  18  
  19  jimport( 'joomla.application.component.view');
  20  
  21  /**
  22   * HTML View class for the Newsfeeds component
  23   *
  24   * @static
  25   * @package        Joomla
  26   * @subpackage    Newsfeeds
  27   * @since 1.0
  28   */
  29  class NewsfeedsViewNewsfeed extends JView
  30  {
  31  	function display( $tpl = null)
  32      {
  33          global $mainframe;
  34  
  35          // check if cache directory is writeable
  36          $cacheDir = JPATH_BASE.DS.'cache'.DS;
  37          if ( !is_writable( $cacheDir ) ) {
  38              echo JText::_( 'Cache Directory Unwritable' );
  39              return;
  40          }
  41  
  42          // Get some objects from the JApplication
  43          $pathway  =& $mainframe->getPathway();
  44          $document =& JFactory::getDocument();
  45  
  46          // Get the current menu item
  47          $menus    = &JSite::getMenu();
  48          $menu    = $menus->getActive();
  49          $params    = &$mainframe->getParams();
  50  
  51          //get the newsfeed
  52          $newsfeed =& $this->get('data');
  53  
  54          //  get RSS parsed object
  55          $options = array();
  56          $options['rssUrl']        = $newsfeed->link;
  57          $options['cache_time']    = $newsfeed->cache_time;
  58  
  59          $rssDoc =& JFactory::getXMLparser('RSS', $options);
  60  
  61          if ( $rssDoc == false ) {
  62              $msg = JText::_('Error: Feed not retrieved');
  63              $mainframe->redirect('index.php?option=com_newsfeeds&view=category&id='. $newsfeed->catslug, $msg);
  64              return;
  65          }
  66          $lists = array();
  67  
  68          // channel header and link
  69          $newsfeed->channel['title']       = $rssDoc->get_title();
  70          $newsfeed->channel['link']           = $rssDoc->get_link();
  71          $newsfeed->channel['description'] = $rssDoc->get_description();
  72          $newsfeed->channel['language']       = $rssDoc->get_language();
  73  
  74          // channel image if exists
  75          $newsfeed->image['url']    = $rssDoc->get_image_url();
  76          $newsfeed->image['title']  = $rssDoc->get_image_title();
  77          $newsfeed->image['link']   = $rssDoc->get_image_link();
  78          $newsfeed->image['height'] = $rssDoc->get_image_height();
  79          $newsfeed->image['width']  = $rssDoc->get_image_width();
  80  
  81          // items
  82          $newsfeed->items = $rssDoc->get_items();
  83  
  84          // feed elements
  85          $newsfeed->items = array_slice($newsfeed->items, 0, $newsfeed->numarticles);
  86  
  87          // Set page title
  88          // because the application sets a default page title, we need to get it
  89          // right from the menu item itself
  90          if (is_object( $menu )) {
  91              $menu_params = new JParameter( $menu->params );
  92              if (!$menu_params->get( 'page_title')) {
  93                  $params->set('page_title',    $newsfeed->name);
  94              }
  95          } else {
  96              $params->set('page_title',    $newsfeed->name);
  97          }
  98          $document->setTitle( $params->get( 'page_title' ) );
  99  
 100          //set breadcrumbs
 101          $viewname    = JRequest::getString('view');
 102          if ( $viewname == 'categories' ) {
 103              $pathway->addItem($newsfeed->category, 'index.php?view=category&id='.$newsfeed->catslug);
 104          }
 105          $pathway->addItem($newsfeed->name, '');
 106  
 107          $this->assignRef('params'  , $params   );
 108          $this->assignRef('newsfeed', $newsfeed );
 109  
 110          parent::display($tpl);
 111      }
 112  
 113  	function limitText($text, $wordcount)
 114      {
 115          if(!$wordcount) {
 116              return $text;
 117          }
 118  
 119          $texts = explode( ' ', $text );
 120          $count = count( $texts );
 121  
 122          if ( $count > $wordcount )
 123          {
 124              $text = '';
 125              for( $i=0; $i < $wordcount; $i++ ) {
 126                  $text .= ' '. $texts[$i];
 127              }
 128              $text .= '...';
 129          }
 130  
 131          return $text;
 132      }
 133  }
 134  ?>


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1