[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/includes/ -> frontend.html.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @author Mambo Foundation Inc see README.php
   5  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   6  * See COPYRIGHT.php for copyright notices and details.
   7  * @license GNU/GPL Version 2, see LICENSE.php
   8  *
   9  * Redistributions of files must retain the above copyright notice.
  10  *
  11  * Mambo is free software; you can redistribute it and/or
  12  * modify it under the terms of the GNU General Public License
  13  * as published by the Free Software Foundation; version 2 of the License.
  14  */
  15  
  16  /** ensure this file is being included by a parent file */
  17  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  18  
  19  class modules_html {
  20  
  21  	function module( &$module, &$params, $Itemid, $style=0, $isBuffered=false ) {
  22          global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_lang;
  23          $mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path');
  24          $m_handler =& mosModuleHandler::getInstance();
  25          $isBuffered = $m_handler->get('_isBuffered');
  26  
  27          // custom module params
  28          $rssurl             = $params->get( 'rssurl' );
  29          $rssitems             = $params->get( 'rssitems', 5 );
  30          $rssdesc             = $params->get( 'rssdesc', 1 );
  31          $rssimage             = $params->get( 'rssimage', 1 );
  32          $rssitemdesc        = $params->get( 'rssitemdesc', 1 );
  33          $moduleclass_sfx     = $params->get( 'moduleclass_sfx' );
  34          $words                 = $params->def( 'word_count', 0 );
  35  
  36          if ($style == -1 && !$rssurl) {
  37              if($isBuffered)
  38                  echo $module->buffer;
  39              else
  40                  echo $module->content;
  41              return;
  42          } else {
  43              ?>
  44              <table cellpadding="0" cellspacing="0" class="moduletable<?php echo $moduleclass_sfx; ?>">
  45              <?php
  46              if ( $module->showtitle != 0 ) {
  47                  ?>
  48                  <tr>
  49                      <th valign="top">
  50                      <?php echo $module->title; ?>
  51                      </th>
  52                  </tr>
  53                  <?php
  54              }
  55  
  56              if ( $module->content ) {
  57                  ?>
  58                  <tr>
  59                      <td>
  60                      <?php 
  61                      if($isBuffered)
  62                          echo $module->buffer;
  63                      else
  64                          echo $module->content;
  65                      ?>
  66                      </td>
  67                  </tr>
  68                  <?php
  69              }
  70          }
  71          // feed output
  72          if ( $rssurl ) {
  73              if (!defined('MAGPIE_CACHE_DIR')) define ('MAGPIE_CACHE_DIR', mamboCore::get('mosConfig_absolute_path').'/includes/magpie_cache');
  74              require_once (mamboCore::get('mosConfig_absolute_path').'/includes/magpierss/rss_fetch.php');
  75              $rss = fetch_rss($rssurl);
  76              if (isset($rss->image['title'])) $iTitle = $rss->image['title'];
  77              if (isset($rss->image['url'])) $iUrl = $rss->image['url'];
  78              // feed title
  79              ?>
  80              <tr>
  81                  <td>
  82                  <strong>
  83                  <a href="<?php echo $rss->channel['link']; ?>" target="_blank">
  84                  <?php echo $rss->channel['title']; ?>
  85                  </a>
  86                  </strong>
  87                  </td>
  88              </tr>
  89              <?php
  90              // feed description
  91              if ( $rssdesc ) {
  92                  ?>
  93                  <tr>
  94                      <td>
  95                      <?php echo $rss->channel['description']; ?>
  96                      </td>
  97                  </tr>
  98                  <?php
  99              }
 100              // feed image
 101              if ( $rssimage AND isset($iUrl) ) {
 102                  ?>
 103                  <tr>
 104                      <td align="center">
 105                      <image src="<?php echo $iUrl; ?>" alt="<?php echo $iTitle; ?>"/>
 106                      </td>
 107                  </tr>
 108                  <?php
 109              }
 110              $itemnumber = 1;
 111              ?>
 112              <tr>
 113                  <td>
 114                  <ul class="newsfeed<?php echo $moduleclass_sfx; ?>">
 115              <?php
 116              foreach ($rss->items as $item) {
 117                  if ($itemnumber > $rssitems) break;
 118                  $itemnumber++;
 119                  // item title
 120                  ?>
 121                  <li class="newsfeed<?php echo $moduleclass_sfx; ?>">
 122                  <strong>
 123                  <a href="<?php echo $item['link']; ?>" target="_blank">
 124                  <?php echo $item['title']; ?>
 125                  </a>
 126                  </strong>
 127                  <?php
 128                  // item description
 129                  if ( $rssitemdesc ) {
 130                      // item description
 131                      $text = html_entity_decode( $item['description'] );
 132                          // word limit check
 133                      if ( $words ) {
 134                          $texts = explode( ' ', $text );
 135                          $count = count( $texts );
 136                          if ( $count > $words ) {
 137                              $text = '';
 138                              for( $i=0; $i < $words; $i++ ) {
 139                                  $text .= ' '. $texts[$i];
 140                              }
 141                              $text .= '...';
 142                          }
 143                      }
 144                      ?>
 145                      <div>
 146                      <?php echo $text; ?>
 147                      </div>
 148                      <?php
 149                  }
 150                  ?>
 151                  </li>
 152                  <?php
 153              }
 154              ?>
 155              </ul>
 156              </td>
 157              </tr>
 158              <?php
 159          }
 160          ?>
 161          </table>
 162          <?php
 163      }
 164  
 165      /**
 166      * @param object
 167      * @param object
 168      * @param int The menu item ID
 169      * @param int -1=show without wrapper and title, -2=x-mambo style
 170      */
 171  	function module2( &$module, &$params, $Itemid, $style=0, $count=0, $isBuffered=false) {
 172          global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_lang;
 173          global $mainframe, $database, $my;
 174          $mosConfig_absolute_path = mamboCore::get('mosConfig_absolute_path');
 175          $m_handler =& mosModuleHandler::getInstance();
 176          $isBuffered = $m_handler->get('_isBuffered');
 177  
 178          $moduleclass_sfx         = $params->get( 'moduleclass_sfx' );
 179          $number = '';
 180          if ($count > 0) $number = '<span>' . $count . '</span> ';
 181          
 182          if ($style == -3) {
 183              // allows for rounded corners
 184              echo "\n<div class=\"module$moduleclass_sfx\"><div><div><div>";
 185              if ($module->showtitle != 0) echo "<h3>$module->title</h3>\n";
 186              if ($isBuffered)
 187                  echo $module->buffer;
 188              else
 189                  include( $mosConfig_absolute_path .'/modules/'. $module->module .'.php' );
 190              if (isset( $content)) echo $content;
 191              echo "\n\n</div></div></div></div>\n";
 192              
 193          } else if ($style == -2) {
 194              // headder and content encapsulated with div tag
 195              ?>
 196              <div class="moduletable<?php echo $moduleclass_sfx; ?>">
 197              <?php
 198              if ($module->showtitle != 0) {
 199                  ?>
 200                  <h2><?php echo $module->title; ?></h2>
 201                  <?php
 202              }
 203              if ($isBuffered)
 204                  echo $module->buffer;
 205              else
 206                  include( $mosConfig_absolute_path .'/modules/'. $module->module .'.php' );
 207              if (isset( $content)) echo $content;
 208              ?>
 209              </div>
 210              <?php
 211              
 212          } else if ($style == -1) {
 213              // show a naked module - no wrapper and no title
 214              if ($isBuffered) {
 215                  if (isset( $module->buffer))
 216                      echo $module->buffer;
 217                  else { // run when buffered but nothing in it
 218                      include( $mosConfig_absolute_path .'/modules/'. $module->module.'.php' );
 219                      if (isset( $content)) echo $content;
 220                  }
 221              } else { // run when not buffered
 222                  include( $mosConfig_absolute_path .'/modules/'. $module->module.'.php' );
 223                  if (isset( $content)) echo $content;
 224              }            
 225          } else {
 226              ?>
 227              <table cellpadding="0" cellspacing="0" class="moduletable<?php echo $moduleclass_sfx; ?>">
 228              <?php
 229              if ( $module->showtitle != 0 ) {
 230                  ?>
 231                  <tr>
 232                      <th valign="top">
 233                      <?php echo $module->title; ?>
 234                      </th>
 235                  </tr>
 236                  <?php
 237              }
 238              ?>
 239              <tr>
 240                  <td>
 241                  <?php
 242              if ($isBuffered)
 243                  echo $module->buffer;
 244              else
 245                  include( $mosConfig_absolute_path .'/modules/'. $module->module .'.php' );
 246                  if (isset( $content)) echo $content;
 247                  ?>
 248                  </td>
 249              </tr>
 250              </table>
 251              <?php
 252          }
 253      }
 254  }
 255  ?>