| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Mambo 4 * @author Mambo Foundation Inc see README.php 5 * @copyright (C) 2000 - 2009 Mambo Foundation Inc. 6 * See COPYRIGHT.php for copyright notices and details. 7 * @license GNU/GPL Version 2, see LICENSE.php 8 * 9 * Redistributions of files must retain the above copyright notice. 10 * 11 * Mambo is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation; version 2 of the License. 14 */ 15 16 /** ensure this file is being included by a parent file */ 17 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 18 19 $_MAMBOTS->registerFunction( 'onSearch', 'botSearchSections' ); 20 21 /** 22 * Sections Search method 23 * 24 * The sql must return the following fields that are used in a common display 25 * routine: href, title, section, created, text, browsernav 26 * @param string Target search string 27 * @param string mathcing option, exact|any|all 28 * @param string ordering option, newest|oldest|popular|alpha|category 29 */ 30 function botSearchSections( $text, $phrase='', $ordering='' ) { 31 global $database, $my; 32 33 $text = trim( $text ); 34 if ($text == '') { 35 return array(); 36 } 37 38 switch ( $ordering ) { 39 case 'alpha': 40 $order = 'a.name ASC'; 41 break; 42 case 'category': 43 case 'popular': 44 case 'newest': 45 case 'oldest': 46 default: 47 $order = 'a.name DESC'; 48 } 49 50 $query = "SELECT a.name AS title," 51 . "\n a.description AS text," 52 . "\n '' AS created," 53 . "\n '2' AS browsernav," 54 . "\n a.id AS secid, m.id AS menuid, m.type AS menutype" 55 . "\n FROM #__sections AS a" 56 . "\n LEFT JOIN #__menu AS m ON m.componentid = a.id" 57 . "\n WHERE ( a.name LIKE '%$text%'" 58 . "\n OR a.title LIKE '%$text%'" 59 . "\n OR a.description LIKE '%$text%' )" 60 . "\n AND a.published = '1'" 61 . "\n AND a.access <= '$my->gid'" 62 . "\n AND ( m.type = 'content_section' OR m.type = 'content_blog_section' )" 63 . "\n ORDER BY $order" 64 ; 65 $database->setQuery( $query ); 66 $rows = $database->loadObjectList(); 67 68 $count = count( $rows ); 69 for ( $i = 0; $i < $count; $i++ ) { 70 if ( $rows[$i]->menutype == 'content_blog_section' ) { 71 $rows[$i]->href = 'index.php?option=com_content&task=blogsection&id='. $rows[$i]->secid .'&Itemid='. $rows[$i]->menuid; 72 $rows[$i]->section = T_('Section Blog'); 73 } else { 74 if ( $rows[$i]->menutype !== 'content_section' ) $rows[$i]->menuid = ''; 75 $rows[$i]->href = 'index.php?option=com_content&task=section&id='. $rows[$i]->secid . ($rows[$i]->menuid ? ('&Itemid='. $rows[$i]->menuid) : ''); 76 $rows[$i]->section = T_('Section List'); 77 } 78 } 79 return $rows; 80 } 81 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 8 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |