Annotation of /mambo/branches/4.6/mambots/search/newsfeeds.searchbot.php
Parent Directory
|
Revision Log
Revision 3 - (view) (download)
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | * @version $Id: newsfeeds.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', 'botSearchNewsfeedslinks' ); | ||
| 14 : | |||
| 15 : | /** | ||
| 16 : | * Contacts 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 botSearchNewsfeedslinks( $text, $phrase='', $ordering='' ) { | ||
| 25 : | global $database, $my; | ||
| 26 : | |||
| 27 : | $text = trim( $text ); | ||
| 28 : | if ($text == '') { | ||
| 29 : | return array(); | ||
| 30 : | } | ||
| 31 : | |||
| 32 : | $wheres = array(); | ||
| 33 : | switch ($phrase) { | ||
| 34 : | case 'exact': | ||
| 35 : | $wheres2 = array(); | ||
| 36 : | $wheres2[] = "LOWER(a.name) LIKE '%$text%'"; | ||
| 37 : | $wheres2[] = "LOWER(a.link) LIKE '%$text%'"; | ||
| 38 : | $where = '(' . implode( ') OR (', $wheres2 ) . ')'; | ||
| 39 : | break; | ||
| 40 : | case 'all': | ||
| 41 : | case 'any': | ||
| 42 : | default: | ||
| 43 : | $words = explode( ' ', $text ); | ||
| 44 : | $wheres = array(); | ||
| 45 : | foreach ($words as $word) { | ||
| 46 : | $wheres2 = array(); | ||
| 47 : | $wheres2[] = "LOWER(a.name) LIKE '%$word%'"; | ||
| 48 : | $wheres2[] = "LOWER(a.link) LIKE '%$word%'"; | ||
| 49 : | $wheres[] = implode( ' OR ', $wheres2 ); | ||
| 50 : | } | ||
| 51 : | $where = '(' . implode( ($phrase == 'all' ? ') AND (' : ') OR ('), $wheres ) . ')'; | ||
| 52 : | break; | ||
| 53 : | } | ||
| 54 : | |||
| 55 : | |||
| 56 : | switch ( $ordering ) { | ||
| 57 : | case 'alpha': | ||
| 58 : | $order = 'a.name ASC'; | ||
| 59 : | break; | ||
| 60 : | |||
| 61 : | case 'category': | ||
| 62 : | $order = 'b.title ASC, a.name ASC'; | ||
| 63 : | break; | ||
| 64 : | |||
| 65 : | case 'oldest': | ||
| 66 : | case 'popular': | ||
| 67 : | case 'newest': | ||
| 68 : | default: | ||
| 69 : | $order = 'a.name ASC'; | ||
| 70 : | } | ||
| 71 : | |||
| 72 : | $query = "SELECT a.name AS title," | ||
| 73 : | . "\n a.link AS text," | ||
| 74 : | . "\n '' AS created," | ||
| 75 : | . "\n CONCAT_WS( ' / ','Newsfeeds', b.title )AS section," | ||
| 76 : | . "\n '1' AS browsernav," | ||
| 77 : | . "\n CONCAT( 'index.php?option=com_newsfeeds&task=view&feedid=', a.id ) AS href" | ||
| 78 : | . "\n FROM #__newsfeeds AS a" | ||
| 79 : | . "\n INNER JOIN #__categories AS b ON b.id = a.catid AND b.access <= '$my->gid'" | ||
| 80 : | . "\n WHERE ( $where )" | ||
| 81 : | . "\n AND a.published = 1" | ||
| 82 : | . "\n ORDER BY $order" | ||
| 83 : | ; | ||
| 84 : | $database->setQuery( $query ); | ||
| 85 : | $rows = $database->loadObjectList(); | ||
| 86 : | return $rows; | ||
| 87 : | } | ||
| 88 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

