3 * @version $Id: frontend.html.php 2333 2009-09-19 14:15:28Z fishbone $
5 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
6 * @license http://www.gnu.org/copyleft/gpl.html 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.
15 defined( '_VALID_MOS' ) or die( 'Restricted access' );
22 function module( &$module, &$params, $Itemid, $style=0 ) {
23 // custom module params
24 $moduleclass_sfx = $params->get( 'moduleclass_sfx' );
25 //$rssurl = $params->get( 'rssurl' );
29 modules_html::modoutput_feed( $module, $params, $moduleclass_sfx );
34 // allows for rounded corners
35 modules_html::modoutput_rounded( $module, $params, $Itemid, $moduleclass_sfx, 1 );
39 // xhtml (divs and font headder tags)
40 modules_html::modoutput_xhtml( $module, $params, $Itemid, $moduleclass_sfx, 1 );
44 // show a naked module - no wrapper and no title
45 modules_html::modoutput_naked( $module, $params, $Itemid, $moduleclass_sfx, 1 );
49 // standard tabled output
50 modules_html::modoutput_table( $module, $params, $Itemid, $moduleclass_sfx, 1 );
60 * @param int The menu item ID
61 * @param int -1=show without wrapper and title, -2=xhtml style
63 function module2( &$module, &$params, $Itemid, $style=0, $count=0 ) {
64 global $mosConfig_lang, $mosConfig_absolute_path;
66 $moduleclass_sfx = $params->get( 'moduleclass_sfx' );
68 // check for custom language file
69 $path = $mosConfig_absolute_path . '/modules/' . $module->module . $mosConfig_lang .'.php';
70 if (file_exists( $path )) {
73 $path = $mosConfig_absolute_path .'/modules/'. $module->module .'.eng.php';
74 if (file_exists( $path )) {
81 $number = '<span>' . $count . '</span> ';
86 // allows for rounded corners
87 modules_html::modoutput_rounded( $module, $params, $Itemid, $moduleclass_sfx );
91 // xhtml (divs and font headder tags)
92 modules_html::modoutput_xhtml( $module, $params, $Itemid, $moduleclass_sfx );
96 // show a naked module - no wrapper and no title
97 modules_html::modoutput_naked( $module, $params, $Itemid, $moduleclass_sfx );
101 // standard tabled output
102 modules_html::modoutput_table( $module, $params, $Itemid, $moduleclass_sfx );
108 function modoutput_feed( &$module, &$params, $moduleclass_sfx ) {
111 global $mosConfig_absolute_path, $mosConfig_cachepath;
113 // check if cache directory is writeable
114 $cacheDir = $mosConfig_cachepath .'/';
115 if ( !is_writable( $cacheDir ) ) {
116 $module->content = 'Cache Directory Unwriteable';
120 $rssurl = $params->get( 'rssurl' );
121 $rssitems = $params->get( 'rssitems', 5 );
122 $rssdesc = $params->get( 'rssdesc', 1 );
123 $rssimage = $params->get( 'rssimage', 1 );
124 $rssitemdesc = $params->get( 'rssitemdesc', 1 );
125 $words = $params->def( 'word_count', 0 );
126 $rsstitle = $params->get( 'rsstitle', 1 );
130 $LitePath = $mosConfig_absolute_path .'/includes/Cache/Lite.php';
131 require_once( $mosConfig_absolute_path .'/includes/domit/xml_domit_rss.php' );
133 $rssDoc = new xml_domit_rss_document();
134 $rssDoc->useCacheLite(true, $LitePath, $cacheDir, 3600);
135 $rssDoc->useHTTPClient(true);
136 $success = $rssDoc->loadRSS( $rssurl );
139 // special handling for feed encoding
140 $encoding = mosCommonHTML::newsfeedEncoding( $rssDoc );
142 $content_buffer = '';
143 $totalChannels = $rssDoc->getChannelCount();
145 for ( $i = 0; $i < $totalChannels; $i++ ) {
146 $currChannel =& $rssDoc->getChannel($i);
147 $elements = $currChannel->getElementList();
149 foreach ( $elements as $element ) {
151 if ( $element == 'image' ) {
152 $image =& $currChannel->getElement( DOMIT_RSS_ELEMENT_IMAGE );
153 $iUrl = $image->getUrl();
154 $iTitle = $image->getTitle();
159 $content_buffer = '<table cellpadding="0" cellspacing="0" class="moduletable'.$moduleclass_sfx.'">' . "\n";
161 if ( $currChannel->getTitle() && $rsstitle ) {
162 $feed_title = $currChannel->getTitle();
163 $feed_title = $encoding( $feed_title );
164 $feed_title = html_entity_decode($feed_title);
165 $feed_title = str_replace(''', "'", $feed_title);
167 $content_buffer .= "<tr>\n";
168 $content_buffer .= " <td>\n";
169 $content_buffer .= " <strong>\n";
170 $content_buffer .= " <a href=\"" . ampReplace( $currChannel->getLink() ) . "\" target=\"_blank\">\n";
171 $content_buffer .= $feed_title . "</a>\n";
172 $content_buffer .= " </strong>\n";
173 $content_buffer .= " </td>\n";
174 $content_buffer .= "</tr>\n";
180 $feed_descrip = $currChannel->getDescription();
181 $feed_descrip = $encoding( $feed_descrip );
182 $feed_descrip = html_entity_decode($feed_descrip);
183 $feed_descrip = str_replace(''', "'", $feed_descrip);
185 $content_buffer .= "<tr>\n";
186 $content_buffer .= " <td>\n";
187 $content_buffer .= $feed_descrip;
188 $content_buffer .= " </td>\n";
189 $content_buffer .= "</tr>\n";
193 if ( $rssimage && $iUrl ) {
194 $content_buffer .= "<tr>\n";
195 $content_buffer .= " <td align=\"center\">\n";
196 $content_buffer .= " <image src=\"" . $iUrl . "\" alt=\"" . @$iTitle . "\"/>\n";
197 $content_buffer .= " </td>\n";
198 $content_buffer .= "</tr>\n";
201 $actualItems = $currChannel->getItemCount();
202 $setItems = $rssitems;
204 if ($setItems > $actualItems) {
205 $totalItems = $actualItems;
207 $totalItems = $setItems;
211 $content_buffer .= "<tr>\n";
212 $content_buffer .= " <td>\n";
213 $content_buffer .= " <ul class=\"newsfeed" . $moduleclass_sfx . "\">\n";
215 for ($j = 0; $j < $totalItems; $j++) {
216 $currItem =& $currChannel->getItem($j);
219 $item_title = $currItem->getTitle();
220 $item_title = $encoding( $item_title );
221 $item_title = html_entity_decode($item_title);
222 $item_title = str_replace(''', "'", $item_title);
224 // START fix for RSS enclosure tag url not showing
225 $content_buffer .= "<li class=\"newsfeed" . $moduleclass_sfx . "\">\n";
226 $content_buffer .= " <strong>\n";
227 if ($currItem->getLink()) {
228 $content_buffer .= " <a href=\"" . ampReplace( $currItem->getLink() ) . "\" target=\"_blank\">\n";
229 $content_buffer .= " " . $item_title . "</a>\n";
230 } else if ($currItem->getEnclosure()) {
231 $enclosure = $currItem->getEnclosure();
232 $eUrl = $enclosure->getUrl();
233 $content_buffer .= " <a href=\"" . ampReplace( $eUrl ) . "\" target=\"_blank\">\n";
234 $content_buffer .= " " . $item_title . "</a>\n";
235 } else if (($currItem->getEnclosure()) && ($currItem->getLink())) {
236 $enclosure = $currItem->getEnclosure();
237 $eUrl = $enclosure->getUrl();
238 $content_buffer .= " <a href=\"" . ampReplace( $currItem->getLink() ) . "\" target=\"_blank\">\n";
239 $content_buffer .= " " . $item_title . "</a><br/>\n";
240 $content_buffer .= " <a href=\"" . ampReplace( $eUrl ) . "\" target=\"_blank\"><u>Download</u></a>\n";
242 $content_buffer .= " </strong>\n";
243 // END fix for RSS enclosure tag url not showing
246 if ( $rssitemdesc ) {
248 $text = $currItem->getDescription();
249 $text = $encoding( $text );
250 $text = html_entity_decode($text);
251 $text = str_replace(''', "'", $text);
255 $texts = explode( ' ', $text );
256 $count = count( $texts );
257 if ( $count > $words ) {
259 for( $i=0; $i < $words; $i++ ) {
260 $text .= ' '. $texts[$i];
266 $content_buffer .= " <div>\n";
267 $content_buffer .= " " . $text;
268 $content_buffer .= " </div>\n";
271 $content_buffer .= "</li>\n";
273 $content_buffer .= " </ul>\n";
274 $content_buffer .= " </td>\n";
275 $content_buffer .= "</tr>\n";
276 $content_buffer .= "</table>\n";
278 $module->content = $content_buffer;
283 * standard tabled output
285 function modoutput_table( $module, $params, $Itemid, $moduleclass_sfx, $type=0 ) {
286 global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_lang, $mosConfig_absolute_path;
287 global $mainframe, $database, $my;
289 <table cellpadding="0" cellspacing="0" class="moduletable<?php echo $moduleclass_sfx; ?>">
291 if ( $module->showtitle != 0 ) {
295 <?php echo $module->title; ?>
305 echo $module->content;
307 include( $mosConfig_absolute_path . '/modules/' . $module->module . '.php' );
309 if (isset( $content)) {
321 * show a naked module - no wrapper and no title
323 function modoutput_naked( $module, $params, $Itemid, $moduleclass_sfx, $type=0 ) {
324 global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_lang, $mosConfig_absolute_path;
325 global $mainframe, $database, $my;
328 echo $module->content;
330 include( $mosConfig_absolute_path . '/modules/' . $module->module . '.php' );
332 if (isset( $content)) {
339 * xhtml (divs and font headder tags)
341 function modoutput_xhtml( $module, $params, $Itemid, $moduleclass_sfx, $type=0 ) {
342 global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_lang, $mosConfig_absolute_path;
343 global $mainframe, $database, $my;
345 <div class="moduletable<?php echo $moduleclass_sfx; ?>">
347 if ($module->showtitle != 0) {
351 <?php echo $module->title; ?>
357 echo $module->content;
359 include( $mosConfig_absolute_path . '/modules/' . $module->module . '.php' );
361 if (isset( $content)) {
371 * allows for rounded corners
373 function modoutput_rounded( $module, $params, $Itemid, $moduleclass_sfx, $type=0 ) {
374 global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_lang, $mosConfig_absolute_path;
375 global $mainframe, $database, $my;
377 <div class="module<?php echo $moduleclass_sfx; ?>">
382 if ($module->showtitle != 0) {
383 echo "<h3>$module->title</h3>";
387 echo $module->content;
389 include( $mosConfig_absolute_path . '/modules/' . $module->module . '.php' );
391 if (isset( $content)) {