From d159763747ab68d6bfdf63195dbb038b393aec7b Mon Sep 17 00:00:00 2001 From: Cameron <e107inc@gmail.com> Date: Mon, 1 Feb 2016 20:29:46 -0800 Subject: [PATCH] Search Fixes. Forum search upgraded to v2.x spec. --- e107_core/shortcodes/single/nextprev.php | 2 +- e107_handlers/e_parse_class.php | 3 +- e107_handlers/search/search_user.php | 7 +- e107_handlers/search_class.php | 88 +++++++++--- e107_plugins/forum/e_search.php | 135 +++++++++++++++++- e107_plugins/forum/forum_viewtopic.php | 12 +- e107_plugins/forum/newforumposts_menu.php | 5 +- e107_plugins/forum/search/search_advanced.php | 44 ------ e107_plugins/forum/search/search_parser.php | 80 ----------- e107_web/css/backcompat.css | 3 +- e107_web/css/e107.css | 2 +- search.php | 51 +++++-- 12 files changed, 260 insertions(+), 172 deletions(-) delete mode 100644 e107_plugins/forum/search/search_advanced.php delete mode 100644 e107_plugins/forum/search/search_parser.php diff --git a/e107_core/shortcodes/single/nextprev.php b/e107_core/shortcodes/single/nextprev.php index e10fefa6d..d7c57ef3b 100644 --- a/e107_core/shortcodes/single/nextprev.php +++ b/e107_core/shortcodes/single/nextprev.php @@ -81,7 +81,7 @@ function nextprev_shortcode($parm = '') $LAN_NP_FIRST = $tp->toGlyph("icon-fast-backward.glyph",false); $LAN_NP_PREVIOUS = $tp->toGlyph("icon-backward.glyph",false); $LAN_NP_NEXT = $tp->toGlyph("icon-forward.glyph",false); - $LAN_NP_LAST = $tp->toGlyph("fa fa-fast-forward",false); + $LAN_NP_LAST = $tp->toGlyph("icon-fast-forward",false); } else { diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 0b67a6f10..764e48082 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -439,7 +439,8 @@ class e_parse extends e_parser case 0: return stristr($haystack, $needle, $before_needle); case 1: - return mb_substr($haystack, $needle, $before_needle); + //return mb_substr($haystack, $needle, $before_needle); + return mb_stristr($haystack, $needle, $before_needle); } // No utf8 pack backup return stristr($haystack, $needle, $before_needle); diff --git a/e107_handlers/search/search_user.php b/e107_handlers/search/search_user.php index b958db40a..dbc7cbdd8 100644 --- a/e107_handlers/search/search_user.php +++ b/e107_handlers/search/search_user.php @@ -12,6 +12,8 @@ if (!defined('e107_INIT')) { exit; } + +//TODO Move to e107_plugins/user/e_search.php and upgrade to v2.x spec. // advanced $advanced_where = ""; if (isset($_GET['time']) && is_numeric($_GET['time'])) { @@ -31,12 +33,13 @@ $text .= $ps['text']; $results = $ps['results']; function search_user($row) { - global $con; + + $tp = e107::getParser(); $res['link'] = e107::getUrl()->create('user/profile/view', array('id' => $row['user_id'], 'name' => $row['user_name']));//"user.php?id.".$row['user_id']; $res['pre_title'] = $row['user_id']." | "; $res['title'] = $row['user_name']; $res['summary'] = $row['user_signature'] ? LAN_SEARCH_72.": ".$row['user_signature'] : LAN_SEARCH_73; - $res['detail'] = LAN_SEARCH_74.": ".$con -> convert_date($row['user_join'], "long"); + $res['detail'] = LAN_SEARCH_74.": ".$tp->toDate($row['user_join'], "long"); return $res; } diff --git a/e107_handlers/search_class.php b/e107_handlers/search_class.php index 317473afb..6c135f906 100644 --- a/e107_handlers/search_class.php +++ b/e107_handlers/search_class.php @@ -19,8 +19,6 @@ if (!defined('e107_INIT')) { exit; } class e_search { - - var $query; var $text; var $pos; @@ -29,7 +27,7 @@ class e_search var $stopwords_php = "|a|about|an|and|are|as|at|be|by|com|edu|for|from|how|i|in|is|it|of|on|or|that|the|this|to|was|what|when|where|who|will|with|the|www|"; var $stopwords_mysql = "|a|a's|able|about|above|according|accordingly|across|actually|after|afterwards|again|against|ain't|all|allow|allows|almost|alone|along|already|also|although|always|am|among|amongst|an|and|another|any|anybody|anyhow|anyone|anything|anyway|anyways|anywhere|apart|appear|appreciate|appropriate|are|aren't|around|as|aside|ask|asking|associated|at|available|away|awfully|be|became|because|become|becomes|becoming|been|before|beforehand|behind|being|believe|below|beside|besides|best|better|between|beyond|both|brief|but|by|c'mon|c's|came|can|can't|cannot|cant|cause|causes|certain|certainly|changes|clearly|co|com|come|comes|concerning|consequently|consider|considering|contain|containing|contains|corresponding|could|couldn't|course|currently|definitely|described|despite|did|didn't|different|do|does|doesn't|doing|don't|done|down|downwards|during|each|edu|eg|eight|either|else|elsewhere|enough|entirely|especially|et|etc|even|ever|every|everybody|everyone|everything|everywhere|ex|exactly|example|except|far|few|fifth|first|five|followed|following|follows|for|former|formerly|forth|four|from|further|furthermore|get|gets|getting|given|gives|go|goes|going|gone|got|gotten|greetings|had|hadn't|happens|hardly|has|hasn't|have|haven't|having|he|he's|hello|help|hence|her|here|here's|hereafter|hereby|herein|hereupon|hers|herself|hi|him|himself|his|hither|hopefully|how|howbeit|however|i|i'd|i'll|i'm|i've|ie|if|ignored|immediate|in|inasmuch|inc|indeed|indicate|indicated|indicates|inner|insofar|instead|into|inward|is|isn't|it|it'd|it'll|it's|its|itself|just|keep|keeps|kept|know|knows|known|last|lately|later|latter|latterly|least|less|lest|let|let's|like|liked|likely|little|look|looking|looks|ltd|mainly|many|may|maybe|me|mean|meanwhile|merely|might|more|moreover|most|mostly|much|must|my|myself|name|namely|nd|near|nearly|necessary|need|needs|neither|never|nevertheless|new|next|nine|no|nobody|non|none|noone|nor|normally|not|nothing|novel|now|nowhere|obviously|of|off|often|oh|ok|okay|old|on|once|one|ones|only|onto|or|other|others|otherwise|ought|our|ours|ourselves|out|outside|over|overall|own|particular|particularly|per|perhaps|php|placed|please|plus|possible|presumably|probably|provides|que|quite|qv|rather|rd|re|really|reasonably|regarding|regardless|regards|relatively|respectively|right|said|same|saw|say|saying|says|second|secondly|see|seeing|seem|seemed|seeming|seems|seen|self|selves|sensible|sent|serious|seriously|seven|several|shall|she|should|shouldn't|since|six|so|some|somebody|somehow|someone|something|sometime|sometimes|somewhat|somewhere|soon|sorry|specified|specify|specifying|still|sub|such|sup|sure|t's|take|taken|tell|tends|th|than|thank|thanks|thanx|that|that's|thats|the|their|theirs|them|themselves|then|thence|there|there's|thereafter|thereby|therefore|therein|theres|thereupon|these|they|they'd|they'll|they're|they've|think|third|this|thorough|thoroughly|those|though|three|through|throughout|thru|thus|to|together|too|took|toward|towards|tried|tries|truly|try|trying|twice|two|un|under|unfortunately|unless|unlikely|until|unto|up|upon|us|use|used|useful|uses|using|usually|value|various|very|via|viz|vs|want|wants|was|wasn't|way|we|we'd|we'll|we're|we've|welcome|well|went|were|weren't|what|what's|whatever|when|whence|whenever|where|where's|whereafter|whereas|whereby|wherein|whereupon|wherever|whether|which|while|whither|who|who's|whoever|whole|whom|whose|why|will|willing|wish|with|within|without|won't|wonder|would|would|wouldn't|yes|yet|you|you'd|you'll|you're|you've|your|yours|yourself|yourselves|zero|"; - function __construct() + function __construct($query = '') { $tp = e107::getParser(); $this->query = $query; @@ -48,9 +46,12 @@ class e_search $this->bullet = '<img src="'.THEME_ABS.'images/bullet2.gif" alt="bullet" class="icon" />'; } - preg_match_all('/(\W?".*?")|(.*?)(\s|$)/', $this -> query, $boolean_keys); + preg_match_all('/(\W?".*?")|(.*?)(\s|$)/', $this->query, $boolean_keys); + sort($this -> keywords['split'] = array_unique(array_filter(str_replace('"', '', array_merge($boolean_keys[1], $boolean_keys[2]))))); - foreach ($this -> keywords['split'] as $k_key => $key) { + + foreach ($this -> keywords['split'] as $k_key => $key) + { if (!$this -> stopword($key)) { if ($key{($tp->ustrlen($key) - 1)} == '*') { $this -> keywords['wildcard'][$k_key] = TRUE; @@ -70,7 +71,8 @@ class e_search } $this -> keywords['exact'][$k_key] = ($tp->ustrpos($key, ' ') !== FALSE) ? TRUE : FALSE; $this -> keywords['match'][$k_key] = $tp -> toDB($this -> keywords['match'][$k_key]); - } else { + } + else { unset ($this -> keywords['split'][$k_key]); } } @@ -83,7 +85,7 @@ class e_search - function parsesearch($table, $return_fields, $search_fields, $weights, $handler, $no_results, $where, $order) + function parsesearch($table, $return_fields, $search_fields, $weights, $handler, $no_results, $where, $order) { global $query, $search_prefs, $pre_title, $search_chars, $search_res, $result_flag; @@ -91,7 +93,7 @@ class e_search $sql = e107::getDb('search'); $tp = e107::getParser(); - if($handler == 'self') //v2 use 'compile' function inside e_search.php; + if($handler == 'self') //v2 use 'compile' function inside e_search.php; { $handler = array($this,'compile'); } @@ -102,19 +104,28 @@ class e_search } $this -> query = $tp -> toDB($query); - + + $match_query = ''; + if (!$search_prefs['mysql_sort']) { + if(e_DEBUG) + { + echo e107::getMessage()->addDebug("Using PHP Sort Method")->render();; + } + $field_operator = 'AND '; foreach ($this -> keywords['match'] as $k_key => $key) { $boolean_regex = ''; + if ($this -> keywords['boolean'][$k_key] == '+') { $key_operator = 'OR '; $break = TRUE; $no_exact = TRUE; - } else if ($this -> keywords['boolean'][$k_key] == '-') + } + elseif ($this -> keywords['boolean'][$k_key] == '-') { foreach ($this -> keywords as $unset_key => $unset_value) { @@ -124,7 +135,7 @@ class e_search $boolean_regex = 'NOT'; $no_exact = TRUE; } - else if (!isset($break)) + elseif (!isset($break)) { $key_operator = 'OR '; if (isset($switch)) @@ -137,15 +148,23 @@ class e_search { break; } + $match_query .= isset($uninitial_field) ? " ".$field_operator." (" : "("; $uninitial_field = TRUE; - if ($this -> keywords['wildcard'][$k_key] || !$search_prefs['boundary']) { + + if ($this -> keywords['wildcard'][$k_key] || !$search_prefs['boundary']) + { $wildcard = ''; - } else { + } + else + { $wildcard = '[[:>:]]'; } + $key_count = 1; - foreach ($search_fields as $field) { + + foreach ($search_fields as $field) + { $regexp = $search_prefs['boundary'] ? "[[:<:]]".$key.$wildcard : $key; $match_query .= " ".$field." ".$boolean_regex." REGEXP '".$regexp."' "; if ($key_count != count($search_fields)) { @@ -153,32 +172,47 @@ class e_search } $key_count++; } + $match_query .= ")"; } - if ($order) { + + if ($order) + { $sql_order = 'ORDER BY '; $order_count = count($order); $i = 1; - foreach ($order as $sort_key => $sort_value) { + foreach ($order as $sort_key => $sort_value) + { $sql_order .= $sort_key.' '.$sort_value; - if ($i != $order_count) { + if ($i != $order_count) + { $sql_order .= ', '; } $i++; } - } else { + } else + { $sql_order = ''; } + $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))) { $exact_query[] = $query; $this -> keywords['split'] = array_merge($exact_query, $this -> keywords['split']); } } - else + else // MySQL Sorting. { + + if(e_DEBUG) + { + echo e107::getMessage()->addDebug("Using MYSQL Sort Method")->render(); + } + $this -> query = str_replace('"', '"', $this -> query); //$field_query = implode(',', $search_fields); @@ -192,7 +226,7 @@ class e_search $field_query = implode(' || ', $field_query); $sql_order = ''; - + foreach ($order as $sort_key => $sort_value) { $sql_order .= ', '.$sort_key.' '.$sort_value; @@ -201,6 +235,9 @@ class e_search $limit = " LIMIT ".$result_flag.",".$search_res; $sql_query = "SELECT SQL_CALC_FOUND_ROWS ".$return_fields.", (".$match_query.") AS relevance FROM #".$table." WHERE ".$where." (".$field_query.") HAVING relevance > 0 ORDER BY relevance DESC ".$sql_order.$limit.";"; + + + } if ($ps['results'] = $sql->gen($sql_query)) @@ -208,10 +245,12 @@ class e_search if (!$search_prefs['mysql_sort']) { $x = 0; - foreach ($search_fields as $field_key => $field) { + foreach ($search_fields as $field_key => $field) + { $crop_fields[] = preg_replace('/(.*?)\./', '', $field); } - while ($row = $sql -> db_Fetch()) + + while ($row = $sql->fetch()) { $weight = 0; foreach ($crop_fields as $field_key => $field) @@ -277,6 +316,7 @@ class e_search if(!empty($matches)) { + foreach ($matches as $this -> text) { $this -> text = nl2br($this -> text); @@ -292,6 +332,8 @@ class e_search if(!empty($this->keywords['match'])) { + + foreach ($this -> keywords['match'] as $match_id => $this -> query) { $boundary = $search_prefs['boundary'] ? '\b' : ''; @@ -308,7 +350,7 @@ class e_search $endcrop = TRUE; } $key = $tp->usubstr($this -> text, $this->pos, $tp->ustrlen($this -> query)); - $this -> text = preg_replace("#(".$boundary.$this -> query.$regex_append."#i", "<span class='searchhighlight'>\\1</span>", $this -> text); + $this -> text = preg_replace("#(".$boundary.$this -> query.$regex_append."#i", "<mark>\\1</mark>", $this -> text); } } } diff --git a/e107_plugins/forum/e_search.php b/e107_plugins/forum/e_search.php index 99ba3b146..b4d6ed6b5 100644 --- a/e107_plugins/forum/e_search.php +++ b/e107_plugins/forum/e_search.php @@ -4,10 +4,143 @@ if (!defined('e107_INIT')) { exit(); } e107::lan('forum', "search", true); //include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/'.e_LANGUAGE.'_search.php'); +class forum_search extends e_search // include plugin-folder in the name. +{ + + function config() + { + + $sql = e107::getDb(); + $catList = array(); + + $catList[] = array('id' => 'all', 'title' => LAN_PLUGIN_FORUM_ALLFORUMS); + + if ($sql ->gen("SELECT f.forum_id, f.forum_name FROM #forum AS f LEFT JOIN #forum AS fp ON fp.forum_id = f.forum_parent ")) + { + while($row = $sql->fetch()) + { + $catList[] = array('id' => $row['forum_id'], 'title' => $row['forum_name']); + } + } + + $matchList = array( + 0 => array('id' => 0, 'title' => FOR_SCH_LAN_4), + 1 => array('id' => 1, 'title' => LAN_SEARCH_54) + ); + + $search = array( + 'name' => LAN_PLUGIN_FORUM_NAME, + // 'table' => 'forum', + 'table' => 'forum_thread AS t LEFT JOIN #user AS u ON t.thread_user = u.user_id + LEFT JOIN #forum AS f ON t.thread_forum_id = f.forum_id + LEFT JOIN #forum AS fp ON f.forum_parent = fp.forum_id + LEFT JOIN #forum_post AS p ON p.post_thread = t.thread_id', + + 'advanced' => array( + 'forum' => array('type' => 'dropdown', 'text' => FOR_SCH_LAN_2, 'list'=>$catList), + 'date' => array('type' => 'date', 'text' => LAN_DATE_POSTED), + 'author'=> array('type' => 'author', 'text' => LAN_SEARCH_61), + 'match'=> array('type' => 'dropdown', 'text' => LAN_SEARCH_61, 'list'=>$matchList) + ), + + 'return_fields' => array('t.thread_id', 't.thread_name', 'p.post_id', 'p.post_entry', 't.thread_forum_id', 't.thread_datestamp', 't.thread_user', 'u.user_id', 'u.user_name', 'f.forum_class', 'f.forum_id', 'f.forum_name', 'f.forum_sef'), + 'search_fields' => array('t.thread_name'=>'1.2', 'p.post_entry'=>'0.6'), // fields and weights. + + 'order' => array('thread_datestamp' => DESC), + 'refpage' => 'forum' + ); + + + return $search; + } + + + + /* Compile Database data for output */ + function compile($row) + { + $tp = e107::getParser(); + + + + $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");*/ + + $datestamp = $tp->toDate($row['thread_datestamp'], "long"); + + if ($row['thread_parent']) + { + $title = $row['parent_name']; + } + else + { + $title = $row['thread_name']; + } + + $link_id = $row['thread_id']; + + //<a href='user.php?id.".$row['user_id']."'>".$row['user_name']."</a> + $uparams = array('id' => $row['user_id'], 'name' => $row['user_name']); + $link = e107::getUrl()->create('user/profile/view', $uparams); + $userlink = "<a href='".$link."'>".$row['user_name']."</a>"; + + $row['thread_sef'] = eHelper::title2sef($row['thread_name'],'dashl'); + + $res['link'] = e107::url('forum','topic', $row, array('query'=>array('f'=>'post','id'=>$row['post_id']))); // e_PLUGIN."forum/forum_viewtopic.php?".$link_id.".post"; + $res['pre_title'] = $title ? FOR_SCH_LAN_5.": " : ""; + $res['title'] = $title ? $title : LAN_SEARCH_9; + $res['pre_summary'] = "<div class='smalltext'><a href='".e107::url('forum','forum',$row)."'>".$row['forum_name']."</a></div>"; + $res['summary'] = $row['post_entry']; + $res['detail'] = LAN_SEARCH_7.$userlink.LAN_SEARCH_8.$datestamp; + + 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 = " f.forum_parent != 0 AND fp.forum_class IN (".USERCLASS_LIST.") AND f.forum_class IN (".USERCLASS_LIST.") AND "; + + if (!empty($parm['forum']) && is_numeric($parm['forum'])) + { + $qry .= " f.forum_id='".$parm['forum']."' AND"; + } + + if (!empty($parm['time']) && is_numeric($parm['time'])) + { + $qry .= " t.thread_datestamp ".($parm['on'] == 'new' ? '>=' : '<=')." '".(time() - $parm['time'])."' AND"; + } + + if (!empty($parm['author'])) + { + $qry .= " (u.user_id = '".$tp -> toDB($parm['author'])."' OR u.user_name = '".$tp -> toDB($parm['author'])."') AND"; + } + + return $qry; + } + + +} + + +/* $search_info[] = array( 'sfile' => e_PLUGIN.'forum/search/search_parser.php', 'qtype' => LAN_PLUGIN_FORUM_NAME, 'refpage' => 'forum', 'advanced' => e_PLUGIN.'forum/search/search_advanced.php', 'id' => 'forum' -); +);*/ diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php index ed285087e..a33a477e5 100644 --- a/e107_plugins/forum/forum_viewtopic.php +++ b/e107_plugins/forum/forum_viewtopic.php @@ -829,8 +829,16 @@ class e107ForumThread $postInfo = $forum->postGet($postId,'post'); $postNum = $forum->postGetPostNum($postInfo['post_thread'], $postId); $postPage = ceil($postNum / $forum->prefs->get('postspage')); - $url = e107::getUrl()->create('forum/thread/view', array('id' => $postInfo['post_thread'], 'name' => $postInfo['thread_name'], 'page' => $postPage), 'full=1&encode=0'); - header('location: '.$url); + + $url = e107::url('forum', 'topic', $postInfo, array( + 'query' => array( + 'p' => $postPage, // proper page number + ), + 'fragment' => 'post-' . $postId, // jump page to post + 'mode'=>'full' + )); + + e107::redirect($url); exit; break; diff --git a/e107_plugins/forum/newforumposts_menu.php b/e107_plugins/forum/newforumposts_menu.php index 090d4c072..e1c76ca16 100755 --- a/e107_plugins/forum/newforumposts_menu.php +++ b/e107_plugins/forum/newforumposts_menu.php @@ -90,7 +90,10 @@ if($results = $sql->gen($qry)) ), 'fragment' => 'post-' . $row['post_id'], // jump page to post )); - + + //FIXME Use f=post/id query. + + $text .= "<li>"; if ($menu_pref['newforumposts_title']) diff --git a/e107_plugins/forum/search/search_advanced.php b/e107_plugins/forum/search/search_advanced.php deleted file mode 100644 index 5d3b193bf..000000000 --- a/e107_plugins/forum/search/search_advanced.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/* - * e107 website system - * - * Copyright (C) 2008-2009 e107 Inc (e107.org) - * Released under the terms and conditions of the - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) - * - * - * - * $Source: /cvs_backup/e107_0.8/e107_plugins/forum/search/search_advanced.php,v $ - * $Revision$ - * $Date$ - * $Author$ - */ - -if (!defined('e107_INIT')) { exit; } - -$advanced['forum']['type'] = 'dropdown'; -$advanced['forum']['text'] = FOR_SCH_LAN_2.':'; -$advanced['forum']['list'][] = array('id' => 'all', 'title' => LAN_PLUGIN_FORUM_ALLFORUMS); - -$advanced_caption['id'] = 'forum'; -$advanced_caption['title']['all'] = LAN_PLUGIN_FORUM_ALLFORUMS; - -if ($sql -> db_Select_gen("SELECT f.forum_id, f.forum_name FROM #forum AS f LEFT JOIN #forum AS fp ON fp.forum_id = f.forum_parent WHERE f.forum_parent != 0 AND fp.forum_class IN (".USERCLASS_LIST.") AND f.forum_class IN (".USERCLASS_LIST.")")) { - while ($row = $sql -> db_Fetch()) { - $advanced['forum']['list'][] = array('id' => $row['forum_id'], 'title' => $row['forum_name']); - $advanced_caption['title'][$row['forum_id']] = LAN_PLUGIN_FORUM_NAME.' -> '.$row['forum_name']; - } -} - -$advanced['date']['type'] = 'date'; -$advanced['date']['text'] = LAN_DATE_POSTED.':'; - -$advanced['author']['type'] = 'author'; -$advanced['author']['text'] = LAN_SEARCH_61.':'; - -$advanced['match']['type'] = 'dropdown'; -$advanced['match']['text'] = LAN_SEARCH_52.':'; -$advanced['match']['list'][] = array('id' => 0, 'title' => FOR_SCH_LAN_4); -$advanced['match']['list'][] = array('id' => 1, 'title' => LAN_SEARCH_54); - -?> \ No newline at end of file diff --git a/e107_plugins/forum/search/search_parser.php b/e107_plugins/forum/search/search_parser.php deleted file mode 100644 index 036857ece..000000000 --- a/e107_plugins/forum/search/search_parser.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php -/* - * e107 website system - * - * Copyright (C) 2008-2013 e107 Inc (e107.org) - * Released under the terms and conditions of the - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) - * - */ - -if (!defined('e107_INIT')) { exit; } - -// advanced -$advanced_where = ""; -if (isset($_GET['forum']) && is_numeric($_GET['forum'])) { - $advanced_where .= " f.forum_id='".$_GET['forum']."' AND"; -} - -if (isset($_GET['time']) && is_numeric($_GET['time'])) { - $advanced_where .= " t.thread_datestamp ".($_GET['on'] == 'new' ? '>=' : '<=')." '".(time() - $_GET['time'])."' AND"; -} - -if (isset($_GET['author']) && $_GET['author'] != '') { - $advanced_where .= " (u.user_id = '".$tp -> toDB($_GET['author'])."' OR u.user_name = '".$tp -> toDB($_GET['author'])."') AND"; -} - -if (isset($_GET['match']) && $_GET['match']) { - $search_fields = array('t.thread_name'); -} else { - $search_fields = array('t.thread_name', 'p.post_entry'); -} - -// basic -$return_fields = 't.thread_id, t.thread_name, p.post_entry, t.thread_forum_id, t.thread_datestamp, t.thread_user, u.user_id, u.user_name, f.forum_class, f.forum_id, f.forum_name'; -$weights = array('1.2', '0.6'); -$no_results = LAN_198; - -$where = "f.forum_class REGEXP '".e_CLASS_REGEXP."' AND fp.forum_class REGEXP '".e_CLASS_REGEXP."' AND".$advanced_where; -$order = array('thread_datestamp' => DESC); -$table = "forum_thread AS t LEFT JOIN #user AS u ON t.thread_user = u.user_id - LEFT JOIN #forum AS f ON t.thread_forum_id = f.forum_id - LEFT JOIN #forum AS fp ON f.forum_parent = fp.forum_id - LEFT JOIN #forum_post AS p ON p.post_thread = t.thread_id - - "; - -$ps = $sch -> parsesearch($table, $return_fields, $search_fields, $weights, 'search_forum', $no_results, $where, $order); -$text .= $ps['text']; -$results = $ps['results']; - -function search_forum($row) -{ - global $con; - $datestamp = $con -> convert_date($row['thread_datestamp'], "long"); - if ($row['thread_parent']) - { - $title = $row['parent_name']; - } - else - { - $title = $row['thread_name']; - } - - $link_id = $row['thread_id']; - - //<a href='user.php?id.".$row['user_id']."'>".$row['user_name']."</a> - $uparams = array('id' => $row['user_id'], 'name' => $row['user_name']); - $link = e107::getUrl()->create('user/profile/view', $uparams); - $userlink = "<a href='".$link."'><b>".$row['user_name']."</b></a>"; - $res['link'] = e_PLUGIN."forum/forum_viewtopic.php?".$link_id.".post"; - $res['pre_title'] = $title ? FOR_SCH_LAN_5.": " : ""; - $res['title'] = $title ? $title : LAN_SEARCH_9; - $res['pre_summary'] = "<div class='smalltext' style='padding: 2px 0px'><a href='".e_PLUGIN."forum/forum.php'>".LAN_PLUGIN_FORUM_NAME."</a> -> <a href='".e_PLUGIN."forum/forum_viewforum.php?".$row['forum_id']."'>".$row['forum_name']."</a></div>"; - $res['summary'] = $row['post_entry']; - $res['detail'] = LAN_SEARCH_7.$userlink.LAN_SEARCH_8.$datestamp; - - return $res; -} - -?> \ No newline at end of file diff --git a/e107_web/css/backcompat.css b/e107_web/css/backcompat.css index 6d5c3f95e..79910ca0a 100644 --- a/e107_web/css/backcompat.css +++ b/e107_web/css/backcompat.css @@ -15,4 +15,5 @@ .close { float: right; font-size: 21px; line-height: 1; color: #000; text-shadow: 0 1px 0 #FFF; opacity: 0.2; } a.btn { } .s-message .s-message-title - { margin-top: 0; background: transparent none no-repeat scroll 0 50%; font-size:150% } \ No newline at end of file + { margin-top: 0; background: transparent none no-repeat scroll 0 50%; font-size:150% } +mark {text-decoration: underline; color:#FF0000; font-weight:bold; } /* .searchhighlight */ \ No newline at end of file diff --git a/e107_web/css/e107.css b/e107_web/css/e107.css index a541d5ec3..4af0f1784 100644 --- a/e107_web/css/e107.css +++ b/e107_web/css/e107.css @@ -1,6 +1,6 @@ /*table { margin-left:auto; margin-right:auto; }*/ -.searchhighlight{text-decoration: underline; color:#FF0000; font-weight:bold; } + /* * e107 v0.800 - new class definitions diff --git a/search.php b/search.php index 2ec4d86b1..66ce59eae 100644 --- a/search.php +++ b/search.php @@ -455,6 +455,7 @@ class search extends e_shortcode if ($plug_require) { + $search_info = array(); require_once($plug_require); $ret = $search_info[0]; } @@ -487,7 +488,7 @@ class search extends e_shortcode $ret['results'] = $this->search_prefs[$type.'_handlers'][$id]['results']; $ret['pre_title'] = $this->search_prefs[$type.'_handlers'][$id]['pre_title']; $ret['pre_title_alt'] = $tp -> toHtml($this->search_prefs[$type.'_handlers'][$id]['pre_title_alt']); - $ret['order'] = (isset($this->search_prefs[$type.'_handlers'][$id]['order']) && $this->search_prefs[$type.'_handlers'][$id]['order']) ? $this->search_prefs[$type.'_handlers'][$id]['order'] : $this->auto_order; + // $ret['order'] = (isset($this->search_prefs[$type.'_handlers'][$id]['order']) && $this->search_prefs[$type.'_handlers'][$id]['order']) ? $this->search_prefs[$type.'_handlers'][$id]['order'] : $this->auto_order; $this->auto_order++; @@ -522,6 +523,7 @@ class search extends e_shortcode { if ($search_info['comments'] = $this->search_info('comments', 'core', false, array('sfile' => e_HANDLER.'search/search_comment.php', 'qtype' => LAN_COMMENTS, 'refpage' => 'comment.php', 'advanced' => e_HANDLER.'search/advanced_comment.php', 'id' => 'comment'))) { // $search_id++; + $search_info['comments']['listorder'] = $this->search_prefs['core_handlers']['comments']['order']; } else { unset($search_info['comments']); } @@ -532,18 +534,20 @@ class search extends e_shortcode { if ($search_info['users'] = $this->search_info('users', 'core', false, array('sfile' => e_HANDLER.'search/search_user.php', 'qtype' => LAN_140, 'refpage' => 'user.php', 'advanced' => e_HANDLER.'search/advanced_user.php', 'id' => 'user'))) { // $search_id++; + $search_info['users']['listorder'] = $this->search_prefs['core_handlers']['users']['order']; + } else { unset($search_info['users']); } } - + /* if ($search_info['pages'] = $this->search_info('pages', 'core', false, array('sfile' => e_HANDLER.'search/search_pages.php', 'qtype' => LAN_418, 'refpage' => 'page.php', 'advanced' => e_HANDLER.'search/advanced_pages.php', 'id' => 'pages'))) { // $search_id++; } else { unset($search_info['pages']); } - + */ $e_searchList = e107::getConfig('core')->get('e_search_list'); @@ -559,26 +563,31 @@ class search extends e_shortcode { if ($search_info[$plug_dir] = $this->search_info($plug_dir, 'plug', e_PLUGIN.$plug_dir."/e_search.php")) { + $search_info[$plug_dir]['listorder'] = $active['order']; // $search_id++; } else { unset($search_info[$plug_dir]); } + + } } // order search routines - - $search_info = $this->array_sort($search_info, 'order', SORT_ASC); - + + + $search_info = $this->array_sort($search_info, 'listorder', SORT_ASC); $this->search_info = $search_info; - - // print_a($this->search_prefs); - // print_a($this->search_info); - + + if(e_DEBUG) + { + // echo e107::getMessage()->addDebug(print_a($this->search_info,true))->render(); + } + return $search_info; } @@ -692,11 +701,15 @@ class search extends e_shortcode global $query, $search_prefs, $pre_title, $search_chars, $search_res, $result_flag; $ns = e107::getRender(); - $sch = new e_search; + $tp = e107::getParser(); - + $con = e107::getDateConvert(); // BC Fix + + $sch = new e_search; // BC Fix + $query = $this->query; + $_GET['q'] = rawurlencode($_GET['q']); $_GET['t'] = preg_replace('/[^\w\-]/i', '', $_GET['t']); @@ -709,7 +722,8 @@ class search extends e_shortcode if (isset($this->searchtype[$key]) || isset($this->searchtype['all'])) { - unset($text); + $text = ""; + //if (file_exists($this->search_info[$key]['sfile'])) { $pre_title = ($this->search_info[$key]['pre_title'] == 2) ? $this->search_info[$key]['pre_title_alt'] : $this->search_info[$key]['pre_title']; @@ -732,12 +746,19 @@ class search extends e_shortcode continue; } - $obj = new $className; + $obj = new $className($this->query); $where = (method_exists($obj,'where')) ? $obj->where($_GET) : ""; $ps = $obj->parsesearch($this->search_info[$key]['table'], $this->search_info[$key]['return_fields'], $this->search_info[$key]['search_fields'], $this->search_info[$key]['weights'], 'self', varset($this->search_info[$key]['no_results'],"<div class='alert alert-danger'>".LAN_198."</div>"), $where , $this->search_info[$key]['order']); - + + if(e_DEBUG) + { + // echo e107::getMessage()->addDebug(print_a($this->search_info,true))->render();// "DEBUG: Order is missing"; + + } + + $text .= '<div class="search-block">'; $text .= $ps['text']; $text .= '</div>';