|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /home/pathumthani_integration/p_sdoc/plugins/search/ |
Upload File : |
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
$mainframe->registerEvent( 'onSearch', 'botSearchGoogle' );
$mainframe->registerEvent( 'onSearchAreas', 'botSearchGoogleAreas' );
function &botSearchGoogleAreas() {
static $areas = array(
'google' => 'GoogleMaps'
);
return $areas;
}
function botSearchGoogle ( $text, $phrase='', $ordering='', $areas=null )
{
if (!$text) {
return array();
}
if (is_array( $areas )) {
if (!array_intersect( $areas, array_keys( botSearchGoogleAreas() ) )) {
return array();
}
}
$plugin =& JPluginHelper::getPlugin('search', 'google');
$pluginParams = new JParameter( $plugin->params );
$limit = $pluginParams->get( 'search_limit', 50 );
$db =& JFactory::getDBO();
if ($phrase == 'exact')
{
$where = "(LOWER(name) LIKE '%$text%')";
}
else
{
$words = explode( ' ', $text );
$wheres = array();
foreach ($words as $word) {
$wheres[] = "(LOWER(name) LIKE '%$word%') ";
}
if($phrase == 'all')
{
$separator = "AND";
}
else
{
$separator = "OR";
}
$where = '(' . implode( ") $separator (" , $wheres ) . ')';
}
$where .= ' AND published = 1';
switch ($ordering) {
case 'oldest':
$order = 'id ASC';
break;
case 'alpha':
$order = 'name ASC';
break;
case 'newest':
default:
$order = 'id DESC';
break;
}
$query = "SELECT name AS title, name AS text, google_date AS created, " .
"\n 'GoogleMaps' AS section," .
"\n CONCAT('index.php?option=com_google&view=standard&id=', id) AS href," .
"\n '2' AS browsernav" .
"\n FROM #__google" .
"\n WHERE $where" .
"\n ORDER BY $order";
$db->setQuery( $query, 0, $limit );
$rows = $db->loadObjectList();
return $rows;
}
?>