[ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * @version $Id: contacts.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', 'botSearchContacts' ); 18 19 /** 20 * Contacts 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 botSearchContacts( $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['contacts']) ) { 33 // load mambot params info 34 $query = "SELECT params" 35 . "\n FROM #__mambots" 36 . "\n WHERE element = 'contacts.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['contacts'] = $mambot; 44 } 45 46 // pull query data from class variable 47 $mambot = $_MAMBOTS->_search_mambot_params['contacts']; 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 $section = _CONTACT_TITLE; 59 60 switch ( $ordering ) { 61 case 'alpha': 62 $order = 'a.name ASC'; 63 break; 64 65 case 'category': 66 $order = 'b.title ASC, a.name ASC'; 67 break; 68 69 case 'popular': 70 case 'newest': 71 case 'oldest': 72 default: 73 $order = 'a.name DESC'; 74 break; 75 } 76 77 $query = "SELECT a.name AS title," 78 . "\n CONCAT_WS( ', ', a.name, a.con_position, a.misc ) AS text," 79 . "\n '' AS created," 80 . "\n CONCAT_WS( ' / ', " . $database->Quote( $section ) . ", b.title ) AS section," 81 . "\n '2' AS browsernav," 82 . "\n CONCAT( 'index.php?option=com_contact&task=view&contact_id=', a.id ) AS href" 83 . "\n FROM #__contact_details AS a" 84 . "\n INNER JOIN #__categories AS b ON b.id = a.catid" 85 . "\n WHERE ( a.name LIKE '%$text%'" 86 . "\n OR a.misc LIKE '%$text%'" 87 . "\n OR a.con_position LIKE '%$text%'" 88 . "\n OR a.address LIKE '%$text%'" 89 . "\n OR a.suburb LIKE '%$text%'" 90 . "\n OR a.state LIKE '%$text%'" 91 . "\n OR a.country LIKE '%$text%'" 92 . "\n OR a.postcode LIKE '%$text%'" 93 . "\n OR a.telephone LIKE '%$text%'" 94 . "\n OR a.fax LIKE '%$text%' )" 95 . "\n AND a.published = 1" 96 . "\n AND b.published = 1" 97 . "\n AND a.access <= " . (int) $my->gid 98 . "\n AND b.access <= " . (int) $my->gid 99 . "\n GROUP BY a.id" 100 . "\n ORDER BY $order" 101 ; 102 $database->setQuery( $query, 0, $limit ); 103 $rows = $database->loadObjectList(); 104 105 return $rows; 106 } 107 ?>
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 |
![]() |