1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 04:10:38 +02:00

Search upgrades - new e_search.php standard added.

This commit is contained in:
Cameron
2014-01-05 11:25:30 -08:00
parent a790848bdb
commit 42c3588e29
8 changed files with 507 additions and 93 deletions

View File

@@ -1,11 +1,97 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2014 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Chatbox e_search addon
*/
if (!defined('e107_INIT')) { exit; }
if (file_exists(e_PLUGIN."chatbox_menu/languages/".e_LANGUAGE."/lan_chatbox_search.php")) {
include_once(e_PLUGIN."chatbox_menu/languages/".e_LANGUAGE."/lan_chatbox_search.php");
} else {
include_once(e_PLUGIN."chatbox_menu/languages/English/lan_chatbox_search.php");
// v2 e_search addon.
// Removes the need for search_parser.php, search_advanced.php and in most cases search language files.
class chatbox_menu_search extends e_search // include plugin-folder in the name.
{
function config()
{
$search = array(
'name' => LAN_PLUGIN_CHATBOX_MENU_NAME,
'table' => 'chatbox',
'advanced' => array(
'date' => array('type' => 'date', 'text' => LAN_SEARCH_50),
'author'=> array('type' => 'author', 'text' => LAN_SEARCH_61)
),
'return_fields' => array('cb_id', 'cb_nick', 'cb_message', 'cb_datestamp'),
'search_fields' => array('cb_nick', 'cb_message'),
'weights' => array('1', '1'),
'order' => array('cb_datestamp' => DESC),
'refpage' => 'chat.php'
);
return $search;
}
/* Compile Database data for output */
function compile($row)
{
$tp = e107::getParser();
preg_match("/([0-9]+)\.(.*)/", $row['cb_nick'], $user);
$res = array();
$res['link'] = e_PLUGIN."chatbox_menu/chat.php?".$row['cb_id'].".fs";
$res['pre_title'] = LAN_SEARCH_7;
$res['title'] = $user[2];
$res['summary'] = $row['cb_message'];
$res['detail'] = $tp->toDate($row['cb_datestamp'], "long");
return $res;
}
/**
* Optional - Advanced Where
* @param $parm - data returned from $_GET (ie. advanced fields included. in this case 'date' and 'author' )
*/
function where($parm='')
{
$tp = e107::getParser();
$qry = "";
if (vartrue($parm['time']) && is_numeric($parm['time']))
{
$qry .= " cb_datestamp ".($parm['on'] == 'new' ? '>=' : '<=')." '".(time() - $parm['time'])."' AND";
}
if (vartrue($parm['author']))
{
$qry .= " cb_nick LIKE '%".$tp -> toDB($parm['author'])."%' AND";
}
return $qry;
}
}
$search_info[] = array('sfile' => e_PLUGIN.'chatbox_menu/search/search_parser.php', 'qtype' => CB_SCH_LAN_1, 'refpage' => 'chat.php', 'advanced' => e_PLUGIN.'chatbox_menu/search/search_advanced.php');
//Old v1.
// $search_info[] = array('sfile' => e_PLUGIN.'chatbox_menu/search/search_parser.php', 'qtype' => CB_SCH_LAN_1, 'refpage' => 'chat.php', 'advanced' => e_PLUGIN.'chatbox_menu/search/search_advanced.php');
?>

View File

@@ -40,6 +40,8 @@ $ps = $sch -> parsesearch('chatbox', $return_fields, $search_fields, $weights, '
$text .= $ps['text'];
$results = $ps['results'];
echo "result = ".$ps['results'];
function search_chatbox($row) {
global $con, $cb_count;
preg_match("/([0-9]+)\.(.*)/", $row['cb_nick'], $user);