| [ 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', 'botSearchCategories' ); 20 21 /** 22 * Categories 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 botSearchCategories( $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 43 case 'category': 44 case 'popular': 45 case 'newest': 46 case 'oldest': 47 default: 48 $order = 'a.name DESC'; 49 } 50 51 $query = "SELECT a.name AS title," 52 . "\n a.description AS text," 53 . "\n '' AS created," 54 . "\n '2' AS browsernav," 55 . "\n s.id AS secid, a.id AS catid," 56 . "\n m.id AS menuid, m.type AS menutype" 57 . "\n FROM #__categories AS a" 58 . "\n INNER JOIN #__sections AS s ON s.id = a.section" 59 . "\n LEFT JOIN #__menu AS m ON m.componentid = a.id" 60 . "\n WHERE ( a.name LIKE '%$text%'" 61 . "\n OR a.title LIKE '%$text%'" 62 . "\n OR a.description LIKE '%$text%' )" 63 . "\n AND a.published = '1'" 64 . "\n AND a.access <= '$my->gid'" 65 . "\n AND ( m.type = 'content_section' OR m.type = 'content_blog_section'" 66 . "\n OR m.type = 'content_category' OR m.type = 'content_blog_category')" 67 . "\n ORDER BY $order" 68 ; 69 $database->setQuery( $query ); 70 $rows = $database->loadObjectList(); 71 72 $count = count( $rows ); 73 for ( $i = 0; $i < $count; $i++ ) { 74 if ( $rows[$i]->menutype == 'content_blog_category' ) { 75 $rows[$i]->href = 'index.php?option=com_content&task=blogcategory&id='. $rows[$i]->catid .'&Itemid='. $rows[$i]->menuid; 76 $rows[$i]->section = T_('Category Blog'); 77 } else { 78 // remove Itemid if there is a menutype mismatch 79 // this can happen if there is no menu item for a category 80 if ( $rows[$i]->menutype !== 'content_category' ) $rows[$i]->menuid = ''; 81 $rows[$i]->href = 'index.php?option=com_content&task=category§ionid='. $rows[$i]->secid .'&id='. $rows[$i]->catid . ($rows[$i]->menuid ? ('&Itemid='. $rows[$i]->menuid) : ''); 82 $rows[$i]->section = T_('Category List'); 83 } 84 } 85 86 return $rows; 87 } 88 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed May 23 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 |