[ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * @version $Id: categories.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', 'botSearchCategories' ); 18 19 /** 20 * Categories 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 botSearchCategories( $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['categories']) ) { 33 // load mambot params info 34 $query = "SELECT params" 35 . "\n FROM #__mambots" 36 . "\n WHERE element = 'categories.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['categories'] = $mambot; 44 } 45 46 // pull query data from class variable 47 $mambot = $_MAMBOTS->_search_mambot_params['categories']; 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 '' AS section," 76 . "\n '' AS href," 77 . "\n s.id AS secid, a.id AS catid," 78 . "\n m.id AS menuid, m.type AS menutype" 79 . "\n FROM #__categories AS a" 80 . "\n INNER JOIN #__sections AS s ON s.id = a.section" 81 . "\n LEFT JOIN #__menu AS m ON m.componentid = a.id" 82 . "\n WHERE ( a.name LIKE '%$text%'" 83 . "\n OR a.title LIKE '%$text%'" 84 . "\n OR a.description LIKE '%$text%' )" 85 . "\n AND a.published = 1" 86 . "\n AND s.published = 1" 87 . "\n AND a.access <= " . (int) $my->gid 88 . "\n AND s.access <= " . (int) $my->gid 89 . "\n AND ( m.type = 'content_section' OR m.type = 'content_blog_section'" 90 . "\n OR m.type = 'content_category' OR m.type = 'content_blog_category')" 91 . "\n GROUP BY a.id" 92 . "\n ORDER BY $order" 93 ; 94 $database->setQuery( $query, 0, $limit ); 95 $rows = $database->loadObjectList(); 96 97 $count = count( $rows ); 98 for ( $i = 0; $i < $count; $i++ ) { 99 if ( $rows[$i]->menutype == 'content_blog_category' ) { 100 $rows[$i]->href = 'index.php?option=com_content&task=blogcategory&id='. $rows[$i]->catid .'&Itemid='. $rows[$i]->menuid; 101 $rows[$i]->section = _SEARCH_CATBLOG; 102 } else { 103 $rows[$i]->href = 'index.php?option=com_content&task=category§ionid='. $rows[$i]->secid .'&id='. $rows[$i]->catid .'&Itemid='. $rows[$i]->menuid; 104 $rows[$i]->section = _SEARCH_CATLIST; 105 } 106 } 107 108 return $rows; 109 } 110 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |