[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/administrator/modules/mod_feed/ -> helper.php (source)

   1  <?php
   2  /**
   3  * @version        $Id: helper.php 14401 2010-01-26 14:10:00Z louis $
   4  * @package        Joomla
   5  * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   6  * @license        GNU/GPL, see LICENSE.php
   7  * Joomla! is free software. This version may have been modified pursuant
   8  * to the GNU General Public License, and as distributed it includes or
   9  * is derivative of works licensed under the GNU General Public License or
  10  * other free or open source software licenses.
  11  * See COPYRIGHT.php for copyright notices and details.
  12  */
  13  
  14  /** ensure this file is being included by a parent file */
  15  defined('_JEXEC') or die( 'Restricted access' );
  16  
  17  class modFeedHelper
  18  {
  19  	function render($params)
  20      {
  21          // module params
  22          $rssurl                = $params->get('rssurl', '');
  23          $rssitems            = $params->get('rssitems', 5);
  24          $rssdesc                = $params->get('rssdesc', 1);
  25          $rssimage            = $params->get('rssimage', 1);
  26          $rssitemdesc            = $params->get('rssitemdesc', 1);
  27          $words                = $params->def('word_count', 0);
  28          $rsstitle            = $params->get('rsstitle', 1);
  29          $rssrtl                = $params->get('rssrtl', 0);
  30          $moduleclass_sfx        = $params->get('moduleclass_sfx', '');
  31  
  32          //  get RSS parsed object
  33          $options = array();
  34          $options['rssUrl']         = $rssurl;
  35          if ($params->get('cache')) {
  36              $options['cache_time']  = $params->get('cache_time', 15) ;
  37              $options['cache_time']    *= 60;
  38          } else {
  39              $options['cache_time'] = null;
  40          }
  41  
  42          $rssDoc =& JFactory::getXMLparser('RSS', $options);
  43  
  44          if ($rssDoc != false)
  45          {
  46              // channel header and link
  47              $channel['title'] = $rssDoc->get_title();
  48              $channel['link'] = $rssDoc->get_link();
  49              $channel['description'] = $rssDoc->get_description();
  50  
  51              // channel image if exists
  52              $image['url'] = $rssDoc->get_image_url();
  53              $image['title'] = $rssDoc->get_image_title();
  54  
  55              //image handling
  56              $iUrl     = isset($image['url']) ? $image['url'] : null;
  57              $iTitle = isset($image['title']) ? $image['title'] : null;
  58  
  59              // items
  60              $items = $rssDoc->get_items();
  61  
  62              // feed elements
  63              $items = array_slice($items, 0, $rssitems);
  64              ?>
  65              <table cellpadding="0" cellspacing="0" class="moduletable<?php echo $params->get('moduleclass_sfx'); ?>">
  66              <?php
  67              // feed description
  68              if (!is_null( $channel['title'] ) && $rsstitle) {
  69              ?>
  70                  <tr>
  71                  <td>
  72                      <strong>
  73                          <a href="<?php echo str_replace( '&', '&amp;', $channel['link']); ?>" target="_blank">
  74                          <?php echo $channel['title']; ?></a>
  75                      </strong>
  76                  </td>
  77                  </tr>
  78              <?php
  79              }
  80  
  81              // feed description
  82              if ($rssdesc) {
  83              ?>
  84                  <tr>
  85                      <td>
  86                          <?php echo $channel['description']; ?>
  87                      </td>
  88                  </tr>
  89              <?php
  90              }
  91  
  92              // feed image
  93              if ($rssimage && $iUrl) {
  94              ?>
  95                  <tr>
  96                      <td align="center">
  97                          <img src="<?php echo $iUrl; ?>" alt="<?php echo @$iTitle; ?>"/>
  98                      </td>
  99                  </tr>
 100              <?php
 101              }
 102  
 103              $actualItems = count( $items );
 104              $setItems = $rssitems;
 105  
 106              if ($setItems > $actualItems) {
 107                  $totalItems = $actualItems;
 108              } else {
 109                  $totalItems = $setItems;
 110              }
 111              ?>
 112              <tr>
 113              <td>
 114                  <ul class="newsfeed<?php echo $moduleclass_sfx; ?>"  >
 115                  <?php
 116                  for ($j = 0; $j < $totalItems; $j ++)
 117                  {
 118                      $currItem = & $items[$j];
 119                      // item title
 120                      ?>
 121                      <li>
 122                      <?php
 123                      if ( !is_null( $currItem->get_link() ) ) {
 124                      ?>
 125                          <a href="<?php echo $currItem->get_link(); ?>" target="_child">
 126                          <?php echo $currItem->get_title(); ?></a>
 127                      <?php
 128                      }
 129  
 130                      // item description
 131                      if ($rssitemdesc)
 132                      {
 133                          // item description
 134                          $text = html_entity_decode($currItem->get_description());
 135                          $text = str_replace('&apos;', "'", $text);
 136  
 137                          // word limit check
 138                          if ($words) {
 139                              $texts = explode(' ', $text);
 140                              $count = count($texts);
 141                              if ($count > $words) {
 142                                  $text = '';
 143                                  for ($i = 0; $i < $words; $i ++)
 144                                  {
 145                                      $text .= ' '.$texts[$i];
 146                                  }
 147                                  $text .= '...';
 148                              }
 149                          }
 150                          ?>
 151                          <div style="text-align: <?php echo $rssrtl ? 'right': 'left'; ?> ! important">
 152                              <?php echo $text; ?>
 153                          </div>
 154                          <?php
 155                      }
 156                      ?>
 157                      </li>
 158                      <?php
 159                  }
 160                  ?>
 161                  </ul>
 162              </td>
 163              </tr>
 164          </table>
 165          <?php
 166          }
 167      }
 168  }


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