1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 01:19:44 +01:00

Search config minor changes to spec.

This commit is contained in:
Cameron 2014-01-13 11:07:02 -08:00
parent dad25394fe
commit 1fc86ddd51
4 changed files with 32 additions and 16 deletions

View File

@ -546,7 +546,8 @@ class e_admin_log
{
if(empty($text))
{
e107::getMessage()->addDebug("Log Message was empty: ".print_a(debug_backtrace(true)),true);
$bt = debug_backtrace(true);
e107::getMessage()->addDebug("Log Message was empty: ".print_a($bt[1],true));
return $this; // changing to text will break chained methods.
}
if(!$type) $type = E_MESSAGE_INFO;
@ -660,7 +661,7 @@ class e_admin_log
{
$text = $array;
}
return $this->logMessage($text, $type, $type, $session);
}

View File

@ -98,7 +98,7 @@ class e_search
if(is_array($return_fields))
{
$return_fields = implode(",",$return_fields);
$return_fields = implode(", ",$return_fields);
}
$this -> query = $tp -> toDB($query);
@ -171,7 +171,8 @@ class e_search
}
$limit = $search_prefs['php_limit'] ? ' LIMIT 0,'.$search_prefs['php_limit'] : '';
$sql_query = "SELECT ".$return_fields." FROM #".$table." WHERE ".$where." (".$match_query.") ".$sql_order.$limit.";";
if ((($keycount = count($this -> keywords['split'])) > 1) && (strpos($query, '"') === FALSE) && (!isset($no_exact))) {
if ((($keycount = count($this -> keywords['split'])) > 1) && (strpos($query, '"') === FALSE) && (!isset($no_exact)))
{
$exact_query[] = $query;
$this -> keywords['split'] = array_merge($exact_query, $this -> keywords['split']);
}
@ -180,15 +181,22 @@ class e_search
{
$this -> query = str_replace('"', '"', $this -> query);
$field_query = implode(',', $search_fields);
foreach ($search_fields as $field_key => $field) {
$search_query[] = "(".$weights[$field_key]." * (MATCH(".$field.") AGAINST ('".$this -> query."' IN BOOLEAN MODE)))";
foreach ($search_fields as $field_key => $field)
{
$search_query[] = "(". varset($weights[$field_key],0.6)." * (MATCH(".$field.") AGAINST ('".$this -> query."' IN BOOLEAN MODE)))";
}
$match_query = implode(' + ', $search_query);
$sql_order = '';
foreach ($order as $sort_key => $sort_value) {
foreach ($order as $sort_key => $sort_value)
{
$sql_order .= ', '.$sort_key.' '.$sort_value;
}
$limit = " LIMIT ".$result_flag.",".$search_res;
$sql_query = "SELECT SQL_CALC_FOUND_ROWS ".$return_fields.", (".$match_query.") AS relevance FROM #".$table." WHERE ".$where." ( MATCH(".$field_query.") AGAINST ('".$this -> query."' IN BOOLEAN MODE) ) HAVING relevance > 0 ORDER BY relevance DESC ".$sql_order.$limit.";";
}

View File

@ -30,10 +30,8 @@ class chatbox_menu_search extends e_search // include plugin-folder in the name.
),
'return_fields' => array('cb_id', 'cb_nick', 'cb_message', 'cb_datestamp'),
'search_fields' => array('cb_nick', 'cb_message'),
'search_fields' => array('cb_nick' => '1', 'cb_message' => '1'), // fields and weights.
'weights' => array('1', '1'),
'order' => array('cb_datestamp' => DESC),
'refpage' => 'chat.php'
);

View File

@ -239,7 +239,10 @@ class search extends e_shortcode
if($obj = e107::getAddon($id,'e_search'))
{
$ret = $obj->config();
if(!$ret = $obj->config())
{
return false;
}
$ret['qtype'] = $ret['name'];
@ -247,6 +250,9 @@ class search extends e_shortcode
{
$ret['id'] = $ret['name'];
}
$ret['weights'] = array_values($ret['search_fields']);
$ret['search_fields'] = array_keys($ret['search_fields']);
}
@ -274,6 +280,7 @@ class search extends e_shortcode
function searchConfig()
{
//core search routines
$search_info = array();
@ -342,6 +349,9 @@ class search extends e_shortcode
$this->search_info = $search_info;
// print_a($this->search_prefs);
print_a($this->search_info);
return $search_info;
}
@ -478,8 +488,7 @@ class search extends e_shortcode
$pre_title = ($this->search_info[$key]['pre_title'] == 2) ? $this->search_info[$key]['pre_title_alt'] : $this->search_info[$key]['pre_title'];
$search_chars = $this->search_info[$key]['chars'];
$search_res = $this->search_info[$key]['results'];
if(vartrue($this->search_info[$key]['sfile']) && file_exists($this->search_info[$key]['sfile'])) // Legacy
{
$text .= '<div class="search-block">';
@ -623,14 +632,14 @@ class search extends e_shortcode
$perform_search = false;
$this->message = LAN_SEARCH_201;
}
elseif (strlen($full_query) < ($char_count = ($search_prefs['mysql_sort'] ? 4 : 3)))
elseif (strlen($full_query) < ($char_count = ($this->search_prefs['mysql_sort'] ? 4 : 3)))
{
$perform_search = false;
$this->message = str_replace('--CHARS--', $char_count, LAN_417);
}
elseif ($search_prefs['time_restrict'])
elseif ($this->search_prefs['time_restrict'])
{
$time = time() - $search_prefs['time_secs'];
$time = time() - $this->search_prefs['time_secs'];
$query_check = $tp -> toDB($full_query);
$ip = e107::getIPHandler()->getIP(FALSE);