[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/modules/ -> mod_sections.php (source)

   1  <?php
   2  /**
   3  * @version $Id: mod_sections.php 5972 2006-12-10 21:58:09Z 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  global $mosConfig_offset;
  14  
  15  /// no direct access
  16  defined( '_VALID_MOS' ) or die( 'Restricted access' );
  17  
  18  $count         = intval( $params->get( 'count', 20 ) );
  19  $access     = !$mainframe->getCfg( 'shownoauth' );
  20  $now         = _CURRENT_SERVER_TIME;
  21  $nullDate     = $database->getNullDate();
  22  
  23  $query = "SELECT a.id AS id, a.title AS title, COUNT(b.id) as cnt"
  24  . "\n FROM #__sections as a"
  25  . "\n LEFT JOIN #__content as b ON a.id = b.sectionid"
  26  . ( $access ? "\n AND b.access <= " . (int) $my->gid : '' )
  27  . "\n AND ( b.publish_up = " . $database->Quote( $nullDate ) . " OR b.publish_up <= " . $database->Quote( $now ) . " )"
  28  . "\n AND ( b.publish_down = " . $database->Quote( $nullDate ) . " OR b.publish_down >= " . $database->Quote( $now ) . " )"
  29  . "\n WHERE a.scope = 'content'"
  30  . "\n AND a.published = 1"
  31  . ( $access ? "\n AND a.access <= " . (int) $my->gid : '' )
  32  . "\n GROUP BY a.id"
  33  . "\n HAVING COUNT( b.id ) > 0"
  34  . "\n ORDER BY a.ordering"
  35  ;
  36  $database->setQuery( $query, 0, $count );
  37  $rows = $database->loadObjectList();
  38  
  39  if ( $rows ) {
  40      // list of sectionids, used to find corresponding Itemids
  41      for( $i=0, $n=count( $rows ); $i<$n; $i++ ) {
  42          $sids[] = (int) $rows[$i]->id;
  43      }
  44      // add 0 to the list, to get the Itemid of a global blog section item as a fallback
  45      $sids[] = 0;
  46      
  47      // get Itemids of sections
  48      $query = "SELECT m.id AS Itemid, m.componentid AS sectionid"
  49      . "\n FROM #__menu AS m"
  50      . "\n WHERE ( m.type = 'content_section' OR m.type = 'content_blog_section' )"
  51      . "\n AND m.published = 1"
  52      . ( $access ? "\n AND m.access <= " . (int) $my->gid : '' )
  53      . "\n AND ( m.componentid=" . implode( " OR m.componentid=", $sids ) . " )"
  54      . "\n ORDER BY m.type DESC, m.id DESC"
  55      ;
  56      $database->setQuery( $query );
  57      $itemids = $database->loadObjectList( 'sectionid' );
  58      ?>
  59      <ul>
  60      <?php
  61          foreach ($rows as $row) {
  62              if (isset( $itemids[$row->id] )) {
  63                  $link = sefRelToAbs( "index.php?option=com_content&task=blogsection&id=". $row->id . "&Itemid=" . $itemids[$row->id]->Itemid );
  64              } else if (isset( $itemids[0] )) {
  65                  $link = sefRelToAbs( "index.php?option=com_content&task=blogsection&id=". $row->id . "&Itemid=" . $itemids[0]->Itemid );
  66              } else {
  67                  $link = sefRelToAbs( "index.php?option=com_content&task=blogsection&id=". $row->id );
  68              }
  69              ?>
  70              <li>
  71                  <a href="<?php echo $link;?>">
  72                      <?php echo $row->title;?></a>
  73              </li>
  74              <?php
  75          }
  76          ?>
  77      </ul>
  78      <?php
  79  }
  80  ?>


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