[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/modules/ -> mod_mostread.php (source)

   1  <?php
   2  /**
   3  * @version $Id: mod_mostread.php 5071 2006-09-15 16:16:55Z friesengeist $
   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  global $mosConfig_offset, $mosConfig_live_site;
  18  
  19  $type         = intval( $params->get( 'type', 1 ) );
  20  $count         = intval( $params->get( 'count', 5 ) );
  21  $catid         = trim( $params->get( 'catid' ) );
  22  $secid         = trim( $params->get( 'secid' ) );
  23  $show_front    = $params->get( 'show_front', 1 );
  24  
  25  $now         = _CURRENT_SERVER_TIME;
  26  $access     = !$mainframe->getCfg( 'shownoauth' );
  27  $nullDate     = $database->getNullDate();
  28  // select between Content Items, Static Content or both
  29  switch ( $type ) {
  30      case 2:
  31      //Static Content only
  32          $query = "SELECT a.id, a.title"
  33          . "\n FROM #__content AS a"
  34          . "\n WHERE ( a.state = 1 AND a.sectionid = 0 )"
  35          . "\n AND ( a.publish_up = " . $database->Quote( $nullDate ) . " OR a.publish_up <= " . $database->Quote( $now ) . " )"
  36          . "\n AND ( a.publish_down = " . $database->Quote( $nullDate ) . " OR a.publish_down >= " . $database->Quote( $now ) . " )"
  37          . ( $access ? "\n AND a.access <= " . (int) $my->gid : '' )
  38          . "\n ORDER BY a.hits DESC"
  39          ;
  40          $database->setQuery( $query, 0, $count );
  41          $rows = $database->loadObjectList();
  42          break;
  43  
  44      case 3:
  45      //Both
  46          $query = "SELECT a.id, a.title, a.sectionid, a.catid, cc.access AS cat_access, s.access AS sec_access, cc.published AS cat_state, s.published AS sec_state"
  47          . "\n FROM #__content AS a"
  48          . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid"
  49          . "\n LEFT JOIN #__sections AS s ON s.id = a.sectionid"
  50          . "\n WHERE a.state = 1"
  51          . "\n AND ( a.publish_up = " . $database->Quote( $nullDate ) . " OR a.publish_up <= " . $database->Quote( $now ) . " )"
  52          . "\n AND ( a.publish_down = " . $database->Quote( $nullDate ) . " OR a.publish_down >= " . $database->Quote( $now ) . " )"
  53          . ( $access ? "\n AND a.access <= " . (int) $my->gid : '' )
  54          . "\n ORDER BY a.hits DESC"
  55          ;
  56          $database->setQuery( $query, 0, $count );
  57          $temp = $database->loadObjectList();
  58          
  59          $rows = array();
  60          if (count($temp)) {
  61              foreach ($temp as $row ) {
  62                  if (($row->cat_state == 1 || $row->cat_state == '') &&  ($row->sec_state == 1 || $row->sec_state == '') &&  ($row->cat_access <= $my->gid || $row->cat_access == '' || !$access) &&  ($row->sec_access <= $my->gid || $row->sec_access == '' || !$access)) {
  63                      $rows[] = $row;
  64                  }
  65              }
  66          }
  67          unset($temp);
  68          break;
  69  
  70      case 1:
  71      default:
  72      //Content Items only
  73          $whereCatid = '';
  74          if ($catid) {
  75              $catids = explode( ',', $catid );
  76              mosArrayToInts( $catids );
  77              $whereCatid = "\n AND ( a.catid=" . implode( " OR a.catid=", $catids ) . " )";
  78          }
  79          $whereSecid = '';
  80          if ($secid) {
  81              $secids = explode( ',', $secid );
  82              mosArrayToInts( $secids );
  83              $whereSecid = "\n AND ( a.sectionid=" . implode( " OR a.sectionid=", $secids ) . " )";
  84          }
  85          $query = "SELECT a.id, a.title, a.sectionid, a.catid"
  86          . "\n FROM #__content AS a"
  87          . "\n LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id"
  88          . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
  89          . "\n INNER JOIN #__sections AS s ON s.id = a.sectionid"
  90          . "\n WHERE ( a.state = 1 AND a.sectionid > 0 )"
  91          . "\n AND ( a.publish_up = " . $database->Quote( $nullDate ) . " OR a.publish_up <= " . $database->Quote( $now ) . " )"
  92          . "\n AND ( a.publish_down = " . $database->Quote( $nullDate ) . " OR a.publish_down >= " . $database->Quote( $now ) . " )"
  93          . ( $access ? "\n AND a.access <= " . (int) $my->gid . " AND cc.access <= " . (int) $my->gid . " AND s.access <= " . (int) $my->gid : '' )
  94          . $whereCatid
  95          . $whereSecid
  96          . ( $show_front == "0" ? "\n AND f.content_id IS NULL" : '' )
  97          . "\n AND s.published = 1"
  98          . "\n AND cc.published = 1"
  99          . "\n ORDER BY a.hits DESC"
 100          ;
 101          $database->setQuery( $query, 0, $count );
 102          $rows = $database->loadObjectList();
 103  
 104          break;
 105  }
 106  
 107  // needed to reduce queries used by getItemid for Content Items
 108  if ( ( $type == 1 ) || ( $type == 3 ) ) {
 109      $bs     = $mainframe->getBlogSectionCount();
 110      $bc     = $mainframe->getBlogCategoryCount();
 111      $gbs     = $mainframe->getGlobalBlogSectionCount();
 112  }
 113  
 114  // Output
 115  ?>
 116  <ul class="mostread<?php echo $moduleclass_sfx; ?>">
 117  <?php
 118  foreach ($rows as $row) {
 119      // get Itemid
 120      switch ( $type ) {
 121          case 2:
 122              $query = "SELECT id"
 123              . "\n FROM #__menu"
 124              . "\n WHERE type = 'content_typed'"
 125              . "\n AND componentid = " . (int) $row->id
 126              ;
 127              $database->setQuery( $query );
 128              $Itemid = $database->loadResult();
 129              break;
 130  
 131          case 3:
 132              if ( $row->sectionid ) {
 133                  $Itemid = $mainframe->getItemid( $row->id, 0, 0, $bs, $bc, $gbs );
 134              } else {
 135                  $query = "SELECT id"
 136                  . "\n FROM #__menu"
 137                  . "\n WHERE type = 'content_typed'"
 138                  . "\n AND componentid = " . (int) $row->id
 139                  ;
 140                  $database->setQuery( $query );
 141                  $Itemid = $database->loadResult();
 142              }
 143              break;
 144  
 145          case 1:
 146          default:
 147              $Itemid = $mainframe->getItemid( $row->id, 0, 0, $bs, $bc, $gbs );
 148              break;
 149      }
 150  
 151      // Blank itemid checker for SEF
 152      if ($Itemid == NULL) {
 153          $Itemid = '';
 154      } else {
 155          $Itemid = '&amp;Itemid='.$Itemid;
 156      }
 157  
 158       $link = sefRelToAbs( 'index.php?option=com_content&amp;task=view&amp;id='. $row->id . $Itemid );
 159       ?>
 160       <li class="mostread<?php echo $moduleclass_sfx; ?>">
 161          <a href="<?php echo $link; ?>" class="mostread<?php echo $moduleclass_sfx; ?>">
 162              <?php echo $row->title; ?></a>
 163       </li>
 164       <?php
 165  }
 166  ?>
 167  </ul>


Généré le : Wed Nov 21 14:43:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics