OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / include / mos / includes / frontend.html.php
1 <?php
2 /**
3 * @version $Id: frontend.html.php 2333 2009-09-19 14:15:28Z fishbone $
4 * @package Joomla
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.
12 */
13
14 // no direct access
15 defined( '_VALID_MOS' ) or die( 'Restricted access' );
16
17 /**
18 * @package Joomla
19 */
20 class modules_html {
21
22         function module( &$module, &$params, $Itemid, $style=0 ) {
23                 // custom module params
24                 $moduleclass_sfx        = $params->get( 'moduleclass_sfx' );
25                 //$rssurl                       = $params->get( 'rssurl' );
26                 
27                 /*if ( $rssurl ) {
28                         // feed output
29                         modules_html::modoutput_feed( $module, $params, $moduleclass_sfx );
30                 }*/
31
32                 switch ( $style ) {
33                         case -3:
34                         // allows for rounded corners
35                                 modules_html::modoutput_rounded( $module, $params, $Itemid, $moduleclass_sfx, 1 );
36                                 break;
37
38                         case -2:
39                         // xhtml (divs and font headder tags)
40                                 modules_html::modoutput_xhtml( $module, $params, $Itemid, $moduleclass_sfx, 1 );
41                                 break;
42
43                         case -1:
44                         // show a naked module - no wrapper and no title
45                                 modules_html::modoutput_naked( $module, $params, $Itemid, $moduleclass_sfx, 1 );
46                                 break;
47
48                         default:
49                         // standard tabled output
50                                 modules_html::modoutput_table( $module, $params, $Itemid, $moduleclass_sfx, 1 );
51                                 break;
52                 }
53
54                 
55         }
56
57         /**
58         * @param object
59         * @param object
60         * @param int The menu item ID
61         * @param int -1=show without wrapper and title, -2=xhtml style
62         */
63         function module2( &$module, &$params, $Itemid, $style=0, $count=0 ) {
64                 global $mosConfig_lang, $mosConfig_absolute_path;
65
66                 $moduleclass_sfx = $params->get( 'moduleclass_sfx' );
67
68                 // check for custom language file
69                 $path = $mosConfig_absolute_path . '/modules/' . $module->module . $mosConfig_lang .'.php';
70                 if (file_exists( $path )) {
71                         include( $path );
72                 } else {
73                         $path = $mosConfig_absolute_path .'/modules/'. $module->module .'.eng.php';
74                         if (file_exists( $path )) {
75                                 include( $path );
76                         }
77                 }
78
79                 $number = '';
80                 if ($count > 0) {
81                         $number = '<span>' . $count . '</span> ';
82                 }
83
84                 switch ( $style ) {
85                         case -3:
86                         // allows for rounded corners
87                                 modules_html::modoutput_rounded( $module, $params, $Itemid, $moduleclass_sfx );
88                                 break;
89
90                         case -2:
91                         // xhtml (divs and font headder tags)
92                                 modules_html::modoutput_xhtml( $module, $params, $Itemid, $moduleclass_sfx );
93                                 break;
94
95                         case -1:
96                         // show a naked module - no wrapper and no title
97                                 modules_html::modoutput_naked( $module, $params, $Itemid, $moduleclass_sfx );
98                                 break;
99
100                         default:
101                         // standard tabled output
102                                 modules_html::modoutput_table( $module, $params, $Itemid, $moduleclass_sfx );
103                                 break;
104                 }
105         }
106
107         // feed output
108         function modoutput_feed( &$module, &$params, $moduleclass_sfx ) {
109                 return;
110                 /*
111                 global $mosConfig_absolute_path, $mosConfig_cachepath;
112
113                 // check if cache directory is writeable
114                 $cacheDir               = $mosConfig_cachepath .'/';    
115                 if ( !is_writable( $cacheDir ) ) {      
116                         $module->content = 'Cache Directory Unwriteable';
117                         return;
118                 }
119                 
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 );
127
128                 $contentBuffer  = '';
129                 
130                 $LitePath               = $mosConfig_absolute_path .'/includes/Cache/Lite.php';
131                 require_once( $mosConfig_absolute_path .'/includes/domit/xml_domit_rss.php' );
132                 
133                 $rssDoc = new xml_domit_rss_document();
134                 $rssDoc->useCacheLite(true, $LitePath, $cacheDir, 3600);
135                 $rssDoc->useHTTPClient(true); 
136                 $success = $rssDoc->loadRSS( $rssurl );
137
138                 if ( $success ) {               
139                         // special handling for feed encoding
140                         $encoding = mosCommonHTML::newsfeedEncoding( $rssDoc );
141                         
142                         $content_buffer = '';
143                         $totalChannels  = $rssDoc->getChannelCount();
144         
145                         for ( $i = 0; $i < $totalChannels; $i++ ) {
146                                 $currChannel =& $rssDoc->getChannel($i);
147                                 $elements       = $currChannel->getElementList();
148                                 $iUrl           = 0;
149                                 foreach ( $elements as $element ) {
150                                         //image handling
151                                         if ( $element == 'image' ) {
152                                                 $image =& $currChannel->getElement( DOMIT_RSS_ELEMENT_IMAGE );
153                                                 $iUrl   = $image->getUrl();
154                                                 $iTitle = $image->getTitle();
155                                         }
156                                 }
157         
158                                 // feed title
159                                 $content_buffer = '<table cellpadding="0" cellspacing="0" class="moduletable'.$moduleclass_sfx.'">' . "\n";
160                                                         
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('&apos;', "'", $feed_title);
166
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";
175         
176                                 }
177         
178                                 // feed description
179                                 if ( $rssdesc ) {
180                                         $feed_descrip   = $currChannel->getDescription();
181                                         $feed_descrip   = $encoding( $feed_descrip );
182                                         $feed_descrip   = html_entity_decode($feed_descrip);
183                                         $feed_descrip   = str_replace('&apos;', "'", $feed_descrip);
184                                         
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";
190                                 }
191         
192                                 // feed image
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";
199                                 }
200         
201                                 $actualItems = $currChannel->getItemCount();
202                                 $setItems = $rssitems;
203         
204                                 if ($setItems > $actualItems) {
205                                         $totalItems = $actualItems;
206                                 } else {
207                                         $totalItems = $setItems;
208                                 }
209         
210         
211                                 $content_buffer .= "<tr>\n";
212                                 $content_buffer .= "    <td>\n";
213                                 $content_buffer .= "            <ul class=\"newsfeed" . $moduleclass_sfx . "\">\n";
214         
215                                                 for ($j = 0; $j < $totalItems; $j++) {
216                                                         $currItem =& $currChannel->getItem($j);
217                                                         // item title
218                                                         
219                                                         $item_title = $currItem->getTitle();
220                                                         $item_title = $encoding( $item_title );
221                                                         $item_title = html_entity_decode($item_title);
222                                                         $item_title = str_replace('&apos;', "'", $item_title);
223         
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";
241                                                         }
242                                                         $content_buffer .= "    </strong>\n";
243                                                         // END fix for RSS enclosure tag url not showing
244                                                         
245                                                                 // item description
246                                                                 if ( $rssitemdesc ) {
247                                                                         // item description
248                                                                         $text = $currItem->getDescription();
249                                                                         $text = $encoding( $text );
250                                                                         $text = html_entity_decode($text);
251                                                                         $text = str_replace('&apos;', "'", $text);
252
253                                                                         // word limit check
254                                                                         if ( $words ) {
255                                                                                 $texts = explode( ' ', $text );
256                                                                                 $count = count( $texts );
257                                                                                 if ( $count > $words ) {
258                                                                                         $text = '';
259                                                                                         for( $i=0; $i < $words; $i++ ) {
260                                                                                                 $text .= ' '. $texts[$i];
261                                                                                         }
262                                                                                         $text .= '...';
263                                                                                 }
264                                                                         }
265         
266                                                                         $content_buffer .= "     <div>\n";
267                                                                         $content_buffer .= "        " . $text;
268                                                                         $content_buffer .= "            </div>\n";
269         
270                                                                 }
271                                                         $content_buffer .= "</li>\n";
272                                                 }
273                                 $content_buffer .= "    </ul>\n";
274                                 $content_buffer .= "    </td>\n";
275                                 $content_buffer .= "</tr>\n";
276                                 $content_buffer .= "</table>\n";
277                         }
278                         $module->content = $content_buffer;
279                 }*/
280         }
281
282         /*
283         * standard tabled output
284         */
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;
288                 ?>
289                 <table cellpadding="0" cellspacing="0" class="moduletable<?php echo $moduleclass_sfx; ?>">
290                 <?php
291                 if ( $module->showtitle != 0 ) {
292                         ?>
293                         <tr>
294                                 <th valign="top">
295                                         <?php echo $module->title; ?>
296                                 </th>
297                         </tr>
298                         <?php
299                 }
300                 ?>
301                 <tr>
302                         <td>
303                                 <?php
304                                 if ( $type ) {
305                                         echo $module->content;
306                                 } else {
307                                         include( $mosConfig_absolute_path . '/modules/' . $module->module . '.php' );
308                                         
309                                         if (isset( $content)) {
310                                                 echo $content;
311                                         }
312                                 }
313                                 ?>
314                         </td>
315                 </tr>
316                 </table>
317                 <?php
318         }
319
320         /*
321         * show a naked module - no wrapper and no title
322         */
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;
326
327                 if ( $type ) {
328                         echo $module->content;
329                 } else {
330                         include( $mosConfig_absolute_path . '/modules/' . $module->module . '.php' );
331                         
332                         if (isset( $content)) {
333                                 echo $content;
334                         }
335                 }
336         }
337
338         /*
339         * xhtml (divs and font headder tags)
340         */
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;
344                 ?>
345                 <div class="moduletable<?php echo $moduleclass_sfx; ?>">
346                         <?php
347                         if ($module->showtitle != 0) {
348                                 //echo $number;
349                                 ?>
350                                 <h3>
351                                         <?php echo $module->title; ?>
352                                 </h3>
353                                 <?php
354                         }
355
356                         if ( $type ) {
357                                 echo $module->content;
358                         } else {
359                                 include( $mosConfig_absolute_path . '/modules/' . $module->module . '.php' );
360                                 
361                                 if (isset( $content)) {
362                                         echo $content;
363                                 }
364                         }
365                         ?>
366                 </div>
367                 <?php
368         }
369
370         /*
371         * allows for rounded corners
372         */
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;
376                 ?>
377                 <div class="module<?php echo $moduleclass_sfx; ?>">
378                         <div>
379                                 <div>
380                                         <div>
381                                                 <?php
382                                                 if ($module->showtitle != 0) {
383                                                         echo "<h3>$module->title</h3>";
384                                                 }
385
386                                                 if ( $type ) {
387                                                         echo $module->content;
388                                                 } else {
389                                                         include( $mosConfig_absolute_path . '/modules/' . $module->module . '.php' );
390                                                         
391                                                         if (isset( $content)) {
392                                                                 echo $content;
393                                                         }
394                                                 }
395                                                 ?>
396                                         </div>
397                                 </div>
398                         </div>
399                 </div>
400                 <?php
401         }
402 }
403 ?>