[ Index ]

PHP Cross Reference of Mambo 4.6.5

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

title

Body

[close]

/modules/ -> mod_newsflash.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  require_once( $mainframe->getPath( 'front_html', 'com_content') );
  20  require_once ($mosConfig_absolute_path.'/components/com_content/content.class.php');
  21  
  22  global $my, $mosConfig_shownoauth, $mosConfig_offset, $acl;
  23  
  24  // Disable edit ability icon
  25  $access = new stdClass();
  26  $access->canEdit     = 0;
  27  $access->canEditOwn = 0;
  28  $access->canPublish = 0;
  29  
  30  $now = date( 'Y-m-d H:i:s', time()+$mosConfig_offset*60*60 );
  31  
  32  $catid                 = intval( $params->get( 'catid' ) );
  33  $style                 = $params->get( 'style' );
  34  $image                 = $params->get( 'image' );
  35  $readmore             = $params->get( 'readmore' );
  36  $items                 = intval( $params->get( 'items' ) );
  37  $moduleclass_sfx     = $params->get( 'moduleclass_sfx' );
  38  
  39  $params->set( 'intro_only', 1 );
  40  $params->set( 'hide_author', 1 );
  41  $params->set( 'hide_createdate', 0 );
  42  $params->set( 'hide_modifydate', 1 );
  43  $params->set( 'introtext', $image);
  44  
  45  if ( $items ) {
  46      $limit = "LIMIT ". $items;
  47  } else {
  48      $limit = "";
  49  }
  50  
  51  $noauth = !$mainframe->getCfg( 'shownoauth' );
  52  
  53  // query to determine article count
  54  $query = "SELECT a.id"
  55  ."\n FROM #__content AS a"
  56  ."\n INNER JOIN #__categories AS b ON b.id = a.catid"
  57  ."\n WHERE a.state = 1"
  58  . ( $noauth ? "\n AND a.access <= '". $my->gid ."' AND b.access <= '". $my->gid ."'" : '' )
  59  ."\n AND (a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '". $now ."') "
  60  ."\n AND (a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '". $now ."')"
  61  ."\n AND catid='". $catid ."' "
  62  ."\n ORDER BY a.ordering"
  63  ."\n ". $limit
  64  ;
  65  $database->setQuery( $query );
  66  $rows = $database->loadResultArray();
  67  
  68  $row = new mosContent( $database );
  69  if (!count($rows)) {
  70      return;
  71  }
  72  $numrows = count( $rows );
  73  
  74  switch ($style) {
  75      case 'horiz':
  76          echo "\n<table class=\"moduletable" . $moduleclass_sfx . "\">\n";
  77          echo "<tr>\n";
  78          foreach ($rows as $id) {
  79              $row->load( $id );
  80              $row->text = $row->introtext;
  81              if ($image == 0) $row->text = preg_replace('/\<img[^>]+\>/i', '', $row->text); 
  82              $row->groups = '';
  83              echo '<td>';
  84              HTML_content::show( $row, $params, $access, 0, 'com_content' );
  85              echo "</td>\n";
  86          }
  87          echo "</tr>\n</table>\n";
  88      break;
  89      
  90      case 'vert':
  91          foreach ($rows as $id) {
  92              $row->load( $id );
  93              $row->text = $row->introtext;
  94              if ($image == 0) $row->text = preg_replace('/\<img[^>]+\>/i', '', $row->text); 
  95              $row->groups = '';
  96      
  97              HTML_content::show( $row, $params, $access, 0, 'com_content' );
  98          }
  99      break;
 100      
 101      case 'flash':
 102          default:
 103          if ($numrows > 0) {
 104              srand ((double) microtime() * 1000000);
 105              $flashnum = $rows[rand( 0, $numrows-1 )];
 106          } else {
 107              $flashnum = 0;
 108          }
 109          $row->load( $flashnum );
 110          $row->text = $row->introtext;
 111          if ($image == 0) $row->text = preg_replace('/\<img[^>]+\>/i', '', $row->text); 
 112          $row->groups = '';
 113      
 114          HTML_content::show( $row, $params, $access, 0, 'com_content' );
 115          break;
 116  }
 117  ?>