[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/mambots/search/ -> sections.searchbot.php (source)

   1  <?php
   2  /**
   3  * @version $Id: sections.searchbot.php 5057 2006-09-14 16:38:01Z 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  $_MAMBOTS->registerFunction( 'onSearch', 'botSearchSections' );
  18  
  19  /**
  20  * Sections Search method
  21  *
  22  * The sql must return the following fields that are used in a common display
  23  * routine: href, title, section, created, text, browsernav
  24  * @param string Target search string
  25  * @param string mathcing option, exact|any|all
  26  * @param string ordering option, newest|oldest|popular|alpha|category
  27  */
  28  function botSearchSections( $text, $phrase='', $ordering='' ) {
  29      global $database, $my, $_MAMBOTS;
  30      
  31      // check if param query has previously been processed
  32      if ( !isset($_MAMBOTS->_search_mambot_params['sections']) ) {
  33          // load mambot params info
  34          $query = "SELECT params"
  35          . "\n FROM #__mambots"
  36          . "\n WHERE element = 'sections.searchbot'"
  37          . "\n AND folder = 'search'"
  38          ;
  39          $database->setQuery( $query );
  40          $database->loadObject($mambot);        
  41          
  42          // save query to class variable
  43          $_MAMBOTS->_search_mambot_params['sections'] = $mambot;
  44      }
  45      
  46      // pull query data from class variable
  47      $mambot = $_MAMBOTS->_search_mambot_params['sections'];    
  48      
  49      $botParams = new mosParameters( $mambot->params );
  50      
  51      $limit = $botParams->def( 'search_limit', 50 );
  52      
  53       $text = trim( $text );
  54      if ($text == '') {
  55          return array();
  56      }
  57  
  58      switch ( $ordering ) {
  59          case 'alpha':
  60              $order = 'a.name ASC';
  61              break;
  62              
  63          case 'category':
  64          case 'popular':
  65          case 'newest':
  66          case 'oldest':
  67          default:
  68              $order = 'a.name DESC';
  69      }
  70  
  71      $query = "SELECT a.name AS title,"
  72      . "\n a.description AS text,"
  73      . "\n '' AS created,"
  74      . "\n '2' AS browsernav,"
  75      . "\n a.id AS secid, m.id AS menuid, m.type AS menutype"
  76      . "\n FROM #__sections AS a"
  77      . "\n LEFT JOIN #__menu AS m ON m.componentid = a.id"
  78      . "\n WHERE ( a.name LIKE '%$text%'"
  79      . "\n OR a.title LIKE '%$text%'"
  80      . "\n OR a.description LIKE '%$text%' )"
  81      . "\n AND a.published = 1"
  82      . "\n AND a.access <= " . (int) $my->gid
  83      . "\n AND ( m.type = 'content_section' OR m.type = 'content_blog_section' )"
  84      . "\n GROUP BY a.id"
  85      . "\n ORDER BY $order"
  86      ;
  87      $database->setQuery( $query, 0, $limit );
  88      $rows = $database->loadObjectList();
  89  
  90      $count = count( $rows );
  91      for ( $i = 0; $i < $count; $i++ ) {
  92          if ( $rows[$i]->menutype == 'content_section' ) {
  93              $rows[$i]->href     = 'index.php?option=com_content&task=section&id='. $rows[$i]->secid .'&Itemid='. $rows[$i]->menuid;
  94              $rows[$i]->section     = _SEARCH_SECLIST;
  95          }
  96          if ( $rows[$i]->menutype == 'content_blog_section' ) {
  97              $rows[$i]->href     = 'index.php?option=com_content&task=blogsection&id='. $rows[$i]->secid .'&Itemid='. $rows[$i]->menuid;
  98              $rows[$i]->section     = _SEARCH_SECBLOG;
  99          }
 100      }
 101      
 102      return $rows;
 103  }
 104  ?>


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