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