[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/modules/ -> mod_related_items.php (source)

   1  <?php
   2  /**
   3  * @version $Id: mod_related_items.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, $option, $task;
  18  
  19  $id         = intval( mosGetParam( $_REQUEST, 'id', null ) );
  20  
  21  $now         = _CURRENT_SERVER_TIME;
  22  $nullDate     = $database->getNullDate();
  23  
  24  if ($option == 'com_content' && $task == 'view' && $id) {
  25      // select the meta keywords from the item
  26      $query = "SELECT metakey"
  27      . "\n FROM #__content"
  28      . "\n WHERE id = " . (int) $id
  29      ;
  30      $database->setQuery( $query );
  31      if ($metakey = trim( $database->loadResult() )) {
  32          // explode the meta keys on a comma
  33          $keys = explode( ',', $metakey );
  34          $likes = array();
  35  
  36          // assemble any non-blank word(s)
  37          foreach ($keys as $key) {
  38              $key = trim( $key );
  39              if ($key) {
  40                  $likes[] = $database->getEscaped( $key );
  41              }
  42          }
  43  
  44          if (count( $likes )) {
  45              // select other items based on the metakey field 'like' the keys found
  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 #__content_frontpage AS f ON f.content_id = a.id"
  49              . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid"
  50              . "\n LEFT JOIN #__sections AS s ON s.id = a.sectionid"
  51              . "\n WHERE a.id != " . (int) $id
  52              . "\n AND a.state = 1"
  53              . "\n AND a.access <= " . (int) $my->gid
  54              . "\n AND ( a.metakey LIKE '%" . implode( "%' OR a.metakey LIKE '%", $likes ) ."%' )"
  55              . "\n AND ( a.publish_up = " . $database->Quote( $nullDate ) . " OR a.publish_up <= " . $database->Quote( $now ) . " )"
  56              . "\n AND ( a.publish_down = " . $database->Quote( $nullDate ) . " OR a.publish_down >= " . $database->Quote( $now ) . " )"
  57              ;
  58              $database->setQuery( $query );
  59              $temp = $database->loadObjectList();
  60              
  61              $related = array();
  62              if (count($temp)) {
  63                  foreach ($temp as $row ) {
  64                      if (($row->cat_state == 1 || $row->cat_state == '') &&  ($row->sec_state == 1 || $row->sec_state == '') &&  ($row->cat_access <= $my->gid || $row->cat_access == '') &&  ($row->sec_access <= $my->gid || $row->sec_access == '')) {
  65                          $related[] = $row;
  66                      }
  67                  }
  68              }
  69              unset($temp);
  70              
  71              if ( count( $related ) ) {
  72                  ?>
  73                  <ul>
  74                      <?php
  75                      foreach ($related as $item) {
  76                          if ($option="com_content" && $task="view") {
  77                              $Itemid = $mainframe->getItemid($item->id);
  78                          }
  79                          $href = sefRelToAbs( "index.php?option=com_content&amp;task=view&amp;id=$item->id&amp;Itemid=$Itemid" );
  80                          ?>
  81                          <li>
  82                              <a href="<?php echo $href; ?>">
  83                                  <?php echo $item->title; ?></a>
  84                          </li>
  85                          <?php
  86                      }
  87                      ?>
  88                  </ul>
  89                  <?php
  90              }
  91          }
  92      }
  93  }
  94  ?>


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