Annotation of /mambo/branches/4.6/mambots/search/sections.searchbot.php
Parent Directory
|
Revision Log
Revision 39 - (view) (download)
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | * @version $Id: sections.searchbot.php,v 1.1 2005/07/22 01:58:25 eddieajau Exp $ | ||
| 4 : | * @package Mambo | ||
| 5 : | * @copyright (C) 2000 - 2005 Miro International Pty Ltd | ||
| 6 : | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL | ||
| 7 : | * Mambo is Free Software | ||
| 8 : | */ | ||
| 9 : | |||
| 10 : | /** ensure this file is being included by a parent file */ | ||
| 11 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 12 : | |||
| 13 : | $_MAMBOTS->registerFunction( 'onSearch', 'botSearchSections' ); | ||
| 14 : | |||
| 15 : | /** | ||
| 16 : | * Sections Search method | ||
| 17 : | * | ||
| 18 : | * The sql must return the following fields that are used in a common display | ||
| 19 : | * routine: href, title, section, created, text, browsernav | ||
| 20 : | * @param string Target search string | ||
| 21 : | * @param string mathcing option, exact|any|all | ||
| 22 : | * @param string ordering option, newest|oldest|popular|alpha|category | ||
| 23 : | */ | ||
| 24 : | function botSearchSections( $text, $phrase='', $ordering='' ) { | ||
| 25 : | global $database, $my; | ||
| 26 : | |||
| 27 : | $text = trim( $text ); | ||
| 28 : | if ($text == '') { | ||
| 29 : | return array(); | ||
| 30 : | } | ||
| 31 : | |||
| 32 : | switch ( $ordering ) { | ||
| 33 : | case 'alpha': | ||
| 34 : | $order = 'a.name ASC'; | ||
| 35 : | break; | ||
| 36 : | case 'category': | ||
| 37 : | case 'popular': | ||
| 38 : | case 'newest': | ||
| 39 : | case 'oldest': | ||
| 40 : | default: | ||
| 41 : | $order = 'a.name DESC'; | ||
| 42 : | } | ||
| 43 : | |||
| 44 : | $query = "SELECT a.name AS title," | ||
| 45 : | . "\n a.description AS text," | ||
| 46 : | . "\n '' AS created," | ||
| 47 : | . "\n '2' AS browsernav," | ||
| 48 : | . "\n a.id AS secid, m.id AS menuid, m.type AS menutype" | ||
| 49 : | . "\n FROM #__sections AS a" | ||
| 50 : | . "\n LEFT JOIN #__menu AS m ON m.componentid = a.id" | ||
| 51 : | . "\n WHERE ( a.name LIKE '%$text%'" | ||
| 52 : | . "\n OR a.title LIKE '%$text%'" | ||
| 53 : | . "\n OR a.description LIKE '%$text%' )" | ||
| 54 : | . "\n AND a.published = '1'" | ||
| 55 : | . "\n AND a.access <= '$my->gid'" | ||
| 56 : | . "\n AND ( m.type = 'content_section' OR m.type = 'content_blog_section' )" | ||
| 57 : | . "\n ORDER BY $order" | ||
| 58 : | ; | ||
| 59 : | $database->setQuery( $query ); | ||
| 60 : | $rows = $database->loadObjectList(); | ||
| 61 : | |||
| 62 : | $count = count( $rows ); | ||
| 63 : | for ( $i = 0; $i < $count; $i++ ) { | ||
| 64 : | if ( $rows[$i]->menutype == 'content_section' ) { | ||
| 65 : | $rows[$i]->href = 'index.php?option=com_content&task=section&id='. $rows[$i]->secid .'&Itemid='. $rows[$i]->menuid; | ||
| 66 : | csouza | 39 | $rows[$i]->section = T_('Section List'); |
| 67 : | root | 1 | } |
| 68 : | if ( $rows[$i]->menutype == 'content_blog_section' ) { | ||
| 69 : | $rows[$i]->href = 'index.php?option=com_content&task=blogsection&id='. $rows[$i]->secid .'&Itemid='. $rows[$i]->menuid; | ||
| 70 : | csouza | 39 | $rows[$i]->section = T_('Section Blog'); |
| 71 : | root | 1 | } |
| 72 : | } | ||
| 73 : | return $rows; | ||
| 74 : | } | ||
| 75 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

