From: <ir...@us...> - 2012-10-10 11:01:42
|
Revision: 10211 http://sourceforge.net/p/xoops/svn/10211 Author: irmtfan Date: 2012-10-10 11:01:37 +0000 (Wed, 10 Oct 2012) Log Message: ----------- bug fix: search.php, list.topic.php - feature add: topic search, highlight keywords, show post text in search Modified Paths: -------------- XoopsModules/newbb/branches/irmtfan/newbb/changelog-rev10109.txt XoopsModules/newbb/branches/irmtfan/newbb/class/forum.php XoopsModules/newbb/branches/irmtfan/newbb/class/post.php XoopsModules/newbb/branches/irmtfan/newbb/class/topic.renderer.php XoopsModules/newbb/branches/irmtfan/newbb/docs/lang_diff.txt XoopsModules/newbb/branches/irmtfan/newbb/include/plugin.php XoopsModules/newbb/branches/irmtfan/newbb/include/search.inc.php XoopsModules/newbb/branches/irmtfan/newbb/language/english/main.php XoopsModules/newbb/branches/irmtfan/newbb/language/persian/main.php XoopsModules/newbb/branches/irmtfan/newbb/search.php XoopsModules/newbb/branches/irmtfan/newbb/templates/css/language/english/style.css XoopsModules/newbb/branches/irmtfan/newbb/templates/css/language/persian/style.css XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_index.html XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_search.html XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_searchresults.html XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewall.html XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewforum.html XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewpost.html XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewtopic.html Added Paths: ----------- XoopsModules/newbb/branches/irmtfan/newbb/include/functions.text.php Modified: XoopsModules/newbb/branches/irmtfan/newbb/changelog-rev10109.txt =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/changelog-rev10109.txt 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/changelog-rev10109.txt 2012-10-10 11:01:37 UTC (rev 10211) @@ -1,3 +1,52 @@ +date 2012-10-10 +=================================== +1- bug fix: in list.topic.php: remove empty arrays in getStatus function +in newbb/class/topic.renderer.php + +2- bug fix: add template smarty variables to search.php to save the user inputs in submit. move select boxes from template to php file +in newbb/templates/newbb_search.html, newbb/search.php + +3- bug fix: in search.php (previously in newbb_search.html): wrongly the andor value="all" (it should be value="AND"), change default andor="OR" to andor="AND" to be like XOOPS CORE setting +in newbb/search.php + +4- bug fix: wrongly p.post_time = since (should be >= since) +in newbb/class/topic.renderer.php + +5- bug fix: $hidvar should be <{$hidvar}> smarty. Improve $hidvar and $hidval in template +in newbb/templates/newbb_viewall.html + +6- bug fix: we need old vars for selection boxes. +in newbb/class/topic.renderer.php, newbb/templates/newbb_viewall.html + +7- bug fix: remove name attribute from submit buttons when method=get +in newbb/templates/newbb_index.html, newbb/templates/newbb_viewall.html, newbb/templates/newbb_viewforum.html, newbb/templates/newbb_search.html + +8- bug fix: wrongly dont parse negative values (categories) when newbb_forumSelectBox is multiple. add a new getIdsByValues function to class/forum.php +in newbb/class/forum.php, newbb/include/search.inc.php, newbb/include/topic.renderer.php, + +9- bug fix: id="xo-pagenav" is hardcoded in the XOOPS Core 2.5.5 and 2.6 (mrphilong/irmtfan) +in newbb/templates/newbb_viewall.html, newbb/templates/newbb_viewforum.html, +newbb/templates/newbb_viewpost.html, newbb/templates/newbb_viewtopic.html + +10- feature add: add newbb_forumSelectBox multiple to list.topic.php +in newbb/class/topic.renderer.php, newbb/templates/newbb_viewall.html + +11- feature add: show search results: 1- post title 2- post text +in newbb/search.php, newbb/templates/newbb_search.html, newbb/templates/newbb_searchresults.html, newbb/language/LANG/main.php, newbb/docs/lang_diff.txt + +12- feature add: add "select text" and "highlighter" to search keywords. add a new file include/functions.text.php to handle text +in newbb/include/functions.text.php, newbb/include/plugin.php, newbb/class/post.php, newbb/include/search.inc.php, newbb/search.php +newbb/templates/css/language/LANG/style.css + +13- bug fix: remove hardcode database access, solve order issues, reduce queries, permissions issues. file include/search.inc.php is completely rewritten (important) +in newbb/include/search.inc.php + +14- feature add: add topic search to viewtopic and viewpost +in newbb/templates/newbb_viewtopic.html, newbb/search.php, newbb/language/LANG/main.php, newbb/docs/lang_diff.txt + +15- bug fix: in list.topic.php the topic_link is hardcoded. add topic_excerpt +in newbb/class/topic.renderer.php + date 2012-10-02 =================================== 1- feature add: jump to last post read in the topic when the post_id is not in the URL(kwaltman/irmtfan) Modified: XoopsModules/newbb/branches/irmtfan/newbb/class/forum.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/class/forum.php 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/class/forum.php 2012-10-10 11:01:37 UTC (rev 10211) @@ -917,5 +917,44 @@ unset($parents, $parents_list); return $ret; } + + // START irmtfan - get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums + /** + * function for get forum Ids by positive and negative values + * + * @param text $values: positive values = forums | negative values = cats | $values=0 = all valid forums, $permission , true/false $parse_cats + * @return $valid_forums + */ + function getIdsByValues($values = 0, $permission = "access", $parse_cats = true) { + // Get all valid forums with this permission + $valid_forums = $this->getIdsByPermission($permission); + // if no value or value=0 return all valid forums + if ( empty($values) ) { + return $valid_forums; + } + $values = is_numeric($values) ? array($values) : $values; + //parse negative values to category IDs + $forums = array(); + $cats = array(); + foreach ($values as $val) { + if ($val == 0) { + // value=0 => all valid forums + return $valid_forums; + } elseif ($val > 0) { + $forums[] = $val; + } else { + $cats[] = abs($val); + } + } + // if dont want to parse categories OR no cats return all forums + if ( empty($parse_cats) || empty($cats) ) { + return array_intersect($valid_forums, $forums); + } + // Get all forums by category IDs + $forumObjs = $this->getForumsByCategory($cats, $permission, true); + $forums = array_merge( $forums, array_keys($forumObjs) ); + return array_intersect($valid_forums, $forums); + } + // END irmtfan - get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums } ?> \ No newline at end of file Modified: XoopsModules/newbb/branches/irmtfan/newbb/class/post.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/class/post.php 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/class/post.php 2012-10-10 11:01:37 UTC (rev 10211) @@ -348,6 +348,7 @@ mod_loadFunctions("time", "newbb"); mod_loadFunctions("render", "newbb"); + mod_loadFunctions("text", "newbb"); // irmtfan add text functions $post_id = $this->getVar('post_id'); $topic_id = $this->getVar('topic_id'); @@ -388,6 +389,15 @@ $post_text = $this->getVar('post_text'); $post_attachment = $this->displayAttachment(); } + // START irmtfan add highlight feature + // Hightlighting searched words + $post_title = $this->getVar('subject'); + if (isset($_GET['keywords']) && !empty($_GET['keywords'])) { + $keywords = $myts->htmlSpecialChars(trim(urldecode($_GET['keywords']))); + $post_text = newbb_highlightText($post_text, $keywords); + $post_title = newbb_highlightText($post_title, $keywords); + } + // END irmtfan add highlight feature if ( isset($viewtopic_users[$this->getVar('uid')]) ) { $poster = $viewtopic_users[$this->getVar('uid')]; } else { @@ -547,7 +557,7 @@ 'post_parent_id' => $this->getVar('pid'), 'post_date' => newbb_formatTimestamp($this->getVar('post_time')), 'post_image' => $post_image, - 'post_title' => $this->getVar('subject'), + 'post_title' => $post_title, // irmtfan $post_title to add highlight keywords 'post_text' => $post_text, 'post_attachment' => $post_attachment, 'post_edit' => $this->displayPostEdit(), Modified: XoopsModules/newbb/branches/irmtfan/newbb/class/topic.renderer.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/class/topic.renderer.php 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/class/topic.renderer.php 2012-10-10 11:01:37 UTC (rev 10211) @@ -101,9 +101,13 @@ case "forum": if (is_numeric($val)) { $val = intval($val); - } elseif (!empty($val)) { - $val = implode("|", array_map("intval", explode(", ", $val))); + // START irmtfan - if the forum is array + } elseif (is_array($val)) { + $val = implode("|", $val); + //} elseif (!empty($val)) { + // $val = implode("|", array_map("intval", explode(", ", $val))); } + // END irmtfan - if the forum is array break; case "uid": @@ -199,12 +203,16 @@ switch($var) { case "forum": $forum_handler = xoops_getmodulehandler('forum', 'newbb'); + // START irmtfan - get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums // Get accessible forums - $access_forums = $forum_handler->getIdsByPermission(); + $access_forums = $forum_handler->getIdsByValues(array_map("intval", @explode("|", $val))); // Filter specified forums if any - if (!empty($val) && $_forums = @explode("|", $val)) { - $access_forums = array_intersect($access_forums, array_map("intval", $_forums)); - } + //if (!empty($val) && $_forums = @explode("|", $val)) { + //$access_forums = array_intersect($access_forums, array_map("intval", $_forums)); + //} + $this->vars["forum"] = $this->setVar("forum", $access_forums); + // END irmtfan - get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums + if (empty($access_forums)) { $this->noperm = true; // irmtfan - it just return return the forum_id only when the forum_id is the first allowed forum - no need for this code implode is enough removed. @@ -223,7 +231,8 @@ case "since": if (!empty($val)) { - $this->query["where"][] = "p.post_time = ". (time() - newbb_getSinceTime($val)); + // irmtfan - should be >= instead of = + $this->query["where"][] = "p.post_time >= ". (time() - newbb_getSinceTime($val)); } break; @@ -320,14 +329,14 @@ function getStatus($type = null, $status = null) { $links = array( - "" => "", + //"" => "", /* irmtfan remove empty array */ "all" => _ALL, "digest" => _MD_DIGEST, "unreplied" => _MD_UNREPLIED, "unread" => _MD_UNREAD, ); $links_admin = array( - " " => "", + //" " => "", /* irmtfan remove empty array */ "active" => _MD_TYPE_ADMIN, "pending" => _MD_TYPE_PENDING, "deleted" => _MD_TYPE_DELETED, @@ -356,8 +365,17 @@ { $selection = array("action" => $this->page); $selection["vars"] = $this->vars; - $selection["vars"]["order"] = $selection["vars"]["since"] = null; - + // irmtfan need vars for other selections + //$selection["vars"]["order"] = $selection["vars"]["since"] = null; + // START irmtfan add forum selection box + mod_loadFunctions("forum", "newbb"); + $forum_selected = empty($this->vars["forum"]) ? null : explode("|", @$this->vars["forum"]); + $selection["forum"] = '<select name="forum[]" multiple="multiple">'; + $selection["forum"] .= '<option value="0">'._MD_ALL.'</option>'; + $selection["forum"] .= newbb_forumSelectBox($forum_selected); + $selection["forum"] .= '</select>'; + // END irmtfan add forum selection box + $sort_selected = empty($this->vars["sort"]) ? "lastpost" : $this->vars["sort"]; $sorts = $this->getSort("", "title"); $selection["sort"] = "<select name='sort'>"; @@ -677,7 +695,8 @@ 'topic_icon' => $topic_icon, 'type_id' => $myrow['type_id'], 'topic_title' => $topic_title, - 'topic_link' => XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $myrow['topic_id'], // . '&forum=' . $myrow['forum_id'], + //'topic_link' => XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $myrow['topic_id'], // . '&forum=' . $myrow['forum_id'], // irmtfan comment + 'topic_link' => 'viewtopic.php?topic_id=' . $myrow['topic_id'], // irmtfan remove hardcode link 'rating_img' => $rating_img, 'topic_page_jump' => $topic_page_jump, 'topic_page_jump_icon' => $topic_page_jump_icon, Modified: XoopsModules/newbb/branches/irmtfan/newbb/docs/lang_diff.txt =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/docs/lang_diff.txt 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/docs/lang_diff.txt 2012-10-10 11:01:37 UTC (rev 10211) @@ -58,6 +58,11 @@ define("_MI_SINCE_DEFAULT","'Since' default value in selection box"); define("_MI_SINCE_DEFAULT_DESC","Default value in the selection box if not specified by users. Positive value for days and negative value for hours. (0=From the beginning) (365=From the last year)"); +add: +define('_MD_SEARCHTOPIC','Search Topic'); +define('_MD_SHOWSEARCH','Show results:'); +define('_MD_SEARCHPOSTTEXT','posts text'); + admin.php --------- define('_AM_NEWBB_REPORTSAVE','Selected Reports have been processed successfully'); Added: XoopsModules/newbb/branches/irmtfan/newbb/include/functions.text.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/include/functions.text.php (rev 0) +++ XoopsModules/newbb/branches/irmtfan/newbb/include/functions.text.php 2012-10-10 11:01:37 UTC (rev 10211) @@ -0,0 +1,102 @@ +<?php +/** + * CBB 4.0, or newbb, the forum module for XOOPS project + * + * @copyright The XOOPS Project http://xoops.sf.net + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @author Taiwen Jiang (phppp or D.J.) <ph...@us...>, irmtfan <ir...@us...> + * @since 4.3 + * @version $Id $ + * @package module::newbb + */ + +if (!defined('XOOPS_ROOT_PATH')) { exit(); } + +define("NEWBB_FUNCTIONS_TEXT_LOADED", TRUE); + +IF (!defined("NEWBB_FUNCTIONS_TEXT")): +define("NEWBB_FUNCTIONS_TEXT", 1); +/** +* function for select from a text where it have some keywords +* +* @param text $text, array text $queryarray, int $selectlength = 200, int $selectstartlag = 100, int $highlight = true +* @return text $select_text +*/ + +function newbb_selectText($text, $queryarray, $selectstartlag = 100, $selectlength = 200, $striptags = true, $excludetags = '<br>') { + $sanitized_text = $striptags ? strip_tags($text, $excludetags) : $text; + $queryarray = newbb_str2array($queryarray); + $text_i = strtolower($sanitized_text); + $queryarray = array_map('strtolower', $queryarray); + $lengtharray = array_map('strlen', $queryarray); + $maxlengthquery = max($lengtharray); + $select_text = ""; + $startpos = 0; + $endpos = strlen($sanitized_text); + while ($startpos < $endpos) { + $pos = $endpos; + foreach ($queryarray as $query) { + if ( ($thispos = strpos($text_i, $query, $startpos)) !== false) { + $pos = min($thispos, $pos); + } + } + if ($pos == $endpos) break; + $start = max(($pos - $selectstartlag), ($startpos - $maxlengthquery), 0); // $startpos is the last position in the previous select text + $length = $maxlengthquery + $selectlength; //xoops_local("strlen", $query) + 200; + $select_text .= "<p>[...] " . xoops_substr($sanitized_text, $start, $length, " [...]") . "</p>"; + $startpos = $start + $length + 1; // start searching from next position. + } + return '<span class="newbb_select_text">' . $select_text . '</span>'; + +} +/** +* function for highlight a text when it have some keywords +* +* @param text $text, array text $queryarray +* @return text $highlight_text +*/ + +function newbb_highlightText($text, $queryarray) { + global $xoopsModuleConfig; + if (empty($xoopsModuleConfig['highlight_search_enable'])) return $text; + $queryarray = newbb_str2array($queryarray); + // if $queryarray is string + $highlight_text = $text; + foreach ($queryarray as $key => $query) { + // use preg_replace instead of str_replace to exclude all $queries inside html span tag + $highlight_text = preg_replace("/(?!(?:[^<]+>|[^>]+<\/a>))(". preg_quote($query) .")/si", newbb_highlighter($query, $key), $highlight_text); + } + return $highlight_text; +} +/** +* function for highlighting search results +* +* @param text $query, int $i +* @return unknown +*/ +function newbb_highlighter($query, $i) { + return '<span class="newbb_highlight term' . $i . '">' . $query . '</span>'; +} +/** +* function for convert string to array +* +* @param text/array $str +* @return unknown +*/ + +function newbb_str2array($str) { + if (!is_array($str)) { + // split the phrase by any number of commas or space characters, + // which include " ", \r, \t, \n and \f + $temp_str = preg_split('/[\s,]+/', $str); + $strarray = array(); + foreach ($temp_str as $s) { + $strarray[] = addSlashes($s); + } + return $strarray; + } else { + return $str; + } +} +ENDIF; +?> \ No newline at end of file Modified: XoopsModules/newbb/branches/irmtfan/newbb/include/plugin.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/include/plugin.php 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/include/plugin.php 2012-10-10 11:01:37 UTC (rev 10211) @@ -96,6 +96,8 @@ $customConfig["display_text_each_link"] = include XOOPS_ROOT_PATH."/modules/newbb/include/display.php"; // jump to last post read in the topic $customConfig["jump_to_topic_last_post_read_enabled"] = true; +// highlight keywords in search +$customConfig["highlight_search_enable"] = true; // END hacked by irmtfan return $customConfig; Modified: XoopsModules/newbb/branches/irmtfan/newbb/include/search.inc.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/include/search.inc.php 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/include/search.inc.php 2012-10-10 11:01:37 UTC (rev 10211) @@ -1,160 +1,116 @@ <?php -// $Id: search.inc.php 62 2012-08-17 10:15:26Z alfred $ -// ------------------------------------------------------------------------ // -// XOOPS - PHP Content Management System // -// Copyright (c) 2000 XOOPS.org // -// <http://www.xoops.org/> // -// ------------------------------------------------------------------------ // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// You may not change or alter any portion of this comment or credits // -// of supporting developers from this source code or any supporting // -// source code which is considered copyrighted (c) material of the // -// original comment or credit authors. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// ------------------------------------------------------------------------ // -// Author: phppp (D.J., in...@gm...) // -// URL: http://xoopsforge.com, http://xoops.org.cn // -// Project: Article Project // -// ------------------------------------------------------------------------ // +/** + * CBB 4.0, or newbb, the forum module for XOOPS project + * + * @copyright The XOOPS Project http://xoops.sf.net + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @author Taiwen Jiang (phppp or D.J.) <ph...@us...>, irmtfan <ir...@us...> + * @since 4.3 + * @version $Id $ + * @package module::newbb + */ +// completely rewrite by irmtfan - remove hardcode database access, solve order issues, add post_text & topic_id, add highlight and reduce queries if (!defined('XOOPS_ROOT_PATH')) { exit(); } -require_once(XOOPS_ROOT_PATH.'/modules/newbb/include/functions.php'); -function newbb_search($queryarray, $andor, $limit, $offset, $userid, $forums = 0, $sortby = 0, $searchin = "both", $subquery = "") +function newbb_search($queryarray, $andor, $limit, $offset, $userid, $forums = 0, $sortby = 0, $searchin = "both", $criteriaExtra = "") { - global $xoopsDB, $xoopsConfig, $myts, $xoopsUser; + global $myts; - $uid = ( is_object($xoopsUser) && $xoopsUser->isactive() ) ? $xoopsUser->getVar('uid') : 0; - $forum_handler = xoops_getmodulehandler('forum', 'newbb'); - $valid_forums = $forum_handler->getIdsByPermission(); + $valid_forums = $forum_handler->getIdsByValues($forums); // can we use view permission? $forum_handler->getIdsByValues($forums, "view") + + $criteriaPost = new CriteriaCompo(); + $criteriaPost->add(new Criteria('p.approved', 1), 'AND'); // only active posts - if (is_array($forums) && count($forums) > 0) { - $valid_forums = array_intersect($valid_forums, $forums); - } elseif (is_numeric($forums) && $forums > 0) { - $valid_forums = array_intersect($valid_forums, array($forums)); + $forum_list = array();// get forum lists just for forum names + if (count($valid_forums) > 0) { + $criteriaPermissions = new CriteriaCompo(); + $criteriaPermissions->add(new Criteria("p.forum_id", "(".implode(",",$valid_forums).")", "IN"), 'AND'); + $forum_list = $forum_handler->getAll(new Criteria("forum_id", "(".implode(", ", $valid_forums).")", "IN"), "forum_name" , false); } - - $sql = 'SELECT p.uid,f.forum_id, p.topic_id, p.poster_name, p.post_time,'; - $sql .= ' f.forum_name, p.post_id, p.subject - FROM '.$xoopsDB->prefix('bb_posts').' p, - '.$xoopsDB->prefix('bb_posts_text').' pt, - '.$xoopsDB->prefix('bb_forums').' f'; - $sql .= ' WHERE p.post_id = pt.post_id'; - $sql .= ' AND p.approved = 1'; - $sql .= ' AND p.forum_id = f.forum_id'; -// AND p.uid = u.uid'; // In case exists a userid with which the associated user is removed, this line will block search results. Can do nothing unless xoops changes its way dealing with user removal - if (!empty($valid_forums)) { - $sql .= ' AND f.forum_id IN ('.implode(',', $valid_forums).')'; - } - - $isUser=false; + if ( is_numeric($userid) && $userid != 0 ) { - $sql .= " AND p.uid=".$userid." "; - $isUser=true; - } else - // TODO - if (is_array($userid) && count($userid) > 0) { + $criteriaUser = new CriteriaCompo(); + $criteriaUser->add(new Criteria('p.uid', $userid), 'OR'); + } elseif (is_array($userid) && count($userid) > 0) { $userid = array_map('intval', $userid); - $sql .= " AND p.uid IN (".implode(',', $userid).") "; - $isUser=true; + $criteriaUser = new CriteriaCompo(); + $criteriaUser->add(new Criteria('p.uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR'); } - + $count = count($queryarray); + $hightlight_key = ""; if ( is_array($queryarray) && $count > 0) { - switch ($searchin) { - case 'title': - $sql .= " AND ((p.subject LIKE '%$queryarray[0]%')"; - for ($i = 1; $i < $count; $i++) { - $sql .= " $andor "; - $sql .= "(p.subject LIKE '%$queryarray[$i]%')"; - } - $sql .= ") "; - break; - - case 'text': - $sql .= " AND ((pt.post_text LIKE '%$queryarray[0]%')"; - for ($i = 1; $i < $count; $i++) { - $sql .= " $andor "; - $sql .= "(pt.post_text LIKE '%$queryarray[$i]%')"; - } - $sql .= ") "; - break; - case 'both' : - default; - $sql .= " AND ((p.subject LIKE '%$queryarray[0]%' OR pt.post_text LIKE '%$queryarray[0]%')"; - for ($i = 1; $i < $count; $i++) { - $sql .= " $andor "; - $sql .= "(p.subject LIKE '%$queryarray[$i]%' OR pt.post_text LIKE '%$queryarray[$i]%')"; - } - $sql .= ") "; - break; - } + $criteriaKeywords = new CriteriaCompo(); + for ($i = 0; $i < $count; $i++) { + $criteriaKeyword = new CriteriaCompo(); + switch ($searchin) { + case 'title': + $criteriaKeyword->add(new Criteria('p.subject', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR'); + break; + case 'text': + $criteriaKeyword->add(new Criteria('t.post_text', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR'); + break; + case 'both' : + default : + $criteriaKeyword->add(new Criteria('p.subject', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR'); + $criteriaKeyword->add(new Criteria('t.post_text', '%' . $queryarray[$i] . '%', 'LIKE'), 'OR'); + break; + } + $criteriaKeywords->add($criteriaKeyword, $andor); + unset($criteriaKeyword); + } + // add highlight keywords to post links + $hightlight_key = "&keywords=" . implode('+', $queryarray); } + $criteria = new CriteriaCompo(); + $criteria->add($criteriaPost, 'AND'); + if (!empty($criteriaPermissions)) { + $criteria->add($criteriaPermissions, 'AND'); + } + if (!empty($criteriaUser)) { + $criteria->add($criteriaUser, 'AND'); + } + if (!empty($criteriaKeywords)) { + $criteria->add($criteriaKeywords, 'AND'); + } + if (!empty($criteriaExtra)) { + $criteria->add($criteriaExtra, 'AND'); + } + //$criteria->setLimit($limit); // no need for this + //$criteria->setStart($offset); // no need for this + + if (empty($sortby)) { + $sortby = "p.post_time"; + } + $criteria->setSort($sortby); + $order = 'ASC'; + if ($sortby == "p.post_time") { + $order = 'DESC'; + } + $criteria->setOrder($order); + + $post_handler =& xoops_getmodulehandler('post', 'newbb'); + $posts = $post_handler->getPostsByLimit($criteria, $limit, $offset); - if (!$sortby) { - $sortby = "p.post_time DESC"; - } - $sql .= $subquery." ORDER BY ".$sortby; - $result = $xoopsDB->query($sql,$limit,$offset); - $ret = array(); - $users = array(); + $ret = array(); $i = 0; - while($myrow = $xoopsDB->fetchArray($result)) { - $ret[$i]['link'] = XOOPS_URL . "/modules/newbb/viewtopic.php?post_id=".$myrow['post_id']; - $ret[$i]['title'] = $myrow['subject']; - $ret[$i]['time'] = $myrow['post_time']; - $ret[$i]['uid'] = $myrow['uid']; - $ret[$i]['forum_name'] = $myts->htmlSpecialChars($myrow['forum_name']); - $ret[$i]['forum_link'] = XOOPS_URL . "/modules/newbb/viewforum.php?forum=".$myrow['forum_id']; - $users[$myrow['uid']] = 1; - $ret[$i]['poster_name'] = $myrow['poster_name']; + foreach (array_keys($posts) as $id) { + $post =& $posts[$id]; + $post_data = $post->getPostBody(); + $ret[$i]['topic_id'] = $post->getVar('topic_id'); + $ret[$i]['link'] = XOOPS_URL . "/modules/newbb/viewtopic.php?post_id=" . $post->getVar('post_id') . $hightlight_key; // add highlight key + $ret[$i]['title'] = $post_data['subject']; + $ret[$i]['time'] = $post_data['date']; + $ret[$i]['forum_name'] = $myts->htmlSpecialChars($forum_list[$post->getVar('forum_id')]["forum_name"]); + $ret[$i]['forum_link'] = XOOPS_URL . "/modules/newbb/viewforum.php?forum=" .$post->getVar('forum_id'); + $ret[$i]['post_text'] = $post_data['text']; + $ret[$i]['uid'] = $post->getVar('uid'); + $ret[$i]['poster'] = $post->getVar('uid') ? '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$ret[$i]['uid'].'">' . $post_data['author'] . '</a>' : $post_data['author']; $i++; } - - if (count($users)>0) { - $member_handler = xoops_gethandler('member'); - $userid_array = array_keys($users); - $user_criteria = "(".implode(",",$userid_array).")"; - $users = $member_handler->getUsers( new Criteria('uid', $user_criteria, 'IN'), true); - } else { - $users = null; - } - - $newbbConfig = newbb_load_config(); - - $count = count($ret); - for($i =0; $i < $count; $i ++ ) { - if ($ret[$i]['uid'] >0) { - if ( isset($users[$ret[$i]['uid']]) && (is_object($users[$ret[$i]['uid']])) && ($users[$ret[$i]['uid']]->isActive()) ) { - $poster = ($newbbConfig['show_realname'] && $users[$ret[$i]['uid']]->getVar('name'))? $users[$ret[$i]['uid']]->getVar('name') : $users[$ret[$i]['uid']]->getVar('uname'); - $poster = $myts->htmlSpecialChars($poster); - $ret[$i]['poster'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$ret[$i]['uid'].'">'.$poster.'</a>'; - $title = $myts->htmlSpecialChars($ret[$i]['title']); - } else { - $ret[$i]['poster'] = $xoopsConfig['anonymous']; - $ret[$i]['uid'] = 0; // Have to force this to fit xoops search.php - } - } else { - $ret[$i]['poster'] = (empty($ret[$i]['poster_name']))?$xoopsConfig['anonymous']:$myts->htmlSpecialChars($ret[$i]['poster_name']); - $ret[$i]['uid'] = 0; - } - } - unset($users); - return $ret; } ?> \ No newline at end of file Modified: XoopsModules/newbb/branches/irmtfan/newbb/language/english/main.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/language/english/main.php 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/language/english/main.php 2012-10-10 11:01:37 UTC (rev 10211) @@ -497,4 +497,7 @@ define('_MD_NEWBB_SEE','See'); // votepolls.php - irmtfan define('_MD_POLL_NOOPTION','You must choose an option !!'); +define('_MD_SEARCHTOPIC','Search Topic'); +define('_MD_SHOWSEARCH','Show results:'); +define('_MD_SEARCHPOSTTEXT','Posts text'); ?> \ No newline at end of file Modified: XoopsModules/newbb/branches/irmtfan/newbb/language/persian/main.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/language/persian/main.php 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/language/persian/main.php 2012-10-10 11:01:37 UTC (rev 10211) @@ -495,4 +495,7 @@ define('_MD_NEWBB_SEE','نمایش'); // votepolls.php - irmtfan define('_MD_POLL_NOOPTION','شما باید یکی از گزینه ها را انتخاب کنید!!'); +define('_MD_SEARCHTOPIC','جستجو تاپیک'); +define('_MD_SHOWSEARCH','نمایش نتایج:'); +define('_MD_SEARCHPOSTTEXT','متن پست'); ?> \ No newline at end of file Modified: XoopsModules/newbb/branches/irmtfan/newbb/search.php =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/search.php 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/search.php 2012-10-10 11:01:37 UTC (rev 10211) @@ -45,6 +45,7 @@ mod_loadFunctions("render", "newbb"); mod_loadFunctions("forum", "newbb"); mod_loadFunctions("time", "newbb"); +mod_loadFunctions("text", "newbb"); // irmtfan add text functions include_once XOOPS_ROOT_PATH.'/modules/newbb/include/search.inc.php'; $limit = $xoopsModuleConfig['topics_per_page']; @@ -54,8 +55,8 @@ $start = 0; $uid = 0; $forum = 0; -$sortby = 'p.post_time DESC'; -$subquery = ""; +$sortby = 'p.post_time'; // irmtfan remove DESC +$criteriaExtra = "";// irmtfan change to criteria $searchin = "both"; $sort = ""; $since = isset($_POST['since']) ? $_POST['since'] : (isset($_GET['since']) ? $_GET['since'] : null); @@ -80,18 +81,26 @@ $forum = array_map("intval",explode("|", $forum)); } $next_search['forum'] = implode("|", $forum); + // START irmtfan topic search + $topic = isset($_POST['topic']) ? $_POST['topic'] : (isset($_GET['topic']) ? $_GET['topic'] : null); + $next_search['topic'] = $topic; + // END irmtfan topic search + // START irmtfan add show search + $show_search = isset($_POST['show_search']) ? $_POST['show_search'] : (isset($_GET['show_search']) ? $_GET['show_search'] : 'post_text'); + $next_search['show_search'] = $show_search; + // START irmtfan add show search $addterms = isset($_POST['andor']) ? $_POST['andor'] : (isset($_GET['andor']) ? $_GET['andor'] : ""); $next_search['andor'] = $addterms; if ( !in_array(strtolower($addterms), array("or", "and", "exact"))) { - $andor = "OR"; + // irmtfan change default to AND + $andor = "AND"; } else { $andor = strtoupper($addterms); } $uname_required = false; - $search_username = $uname; - $search_username = trim($search_username); + $search_username = trim($uname);// irmtfan one line is enough $next_search['uname'] = $search_username; if ( !empty($search_username) ) { $uname_required = true; @@ -136,77 +145,154 @@ } // entries must be lowercase - //$allowed = array('t.topic_last_post_id desc', 'p.post_time desc', 't.topic_title', 't.topic_views', 't.topic_replies', 'f.forum_name', 'u.uname'); - $allowed = array('p.post_time desc', 't.topic_title', 't.topic_views', 't.topic_replies', 'f.forum_name', 'u.uname'); + $allowed = array('p.post_time', 'p.subject'); // irmtfan just post time and subject $sortby = isset($_POST['sortby']) ? $_POST['sortby'] : (isset($_GET['sortby']) ? $_GET['sortby'] : null); $next_search['sortby'] = $sortby; - //$sortby = (in_array(strtolower($sortby), $allowed)) ? $sortby : 't.topic_last_post_id desc'; - $sortby = (in_array(strtolower($sortby), $allowed)) ? $sortby : 'p.post_time desc'; + //$sortby = (in_array(strtolower($sortby), $allowed)) ? $sortby : 't.topic_last_post_id'; + $sortby = (in_array(strtolower($sortby), $allowed)) ? $sortby : 'p.post_time'; $searchin = isset($_POST['searchin']) ? $_POST['searchin'] : (isset($_GET['searchin']) ? $_GET['searchin'] : 'both'); $next_search['searchin'] = $searchin; + // START irmtfan use criteria - add topic search if (!empty($since)) { - $subquery = ' AND p.post_time >= ' . (time() - newbb_getSinceTime($since)); - } - - if ($uname_required&&(!$uid||count($uid)<1)) $result = false; - else $results = newbb_search($queries, $andor, $limit, $start, $uid, $forum, $sortby, $searchin, $subquery); - - if ( count($results) < 1 ) { + $criteriaExtra = new CriteriaCompo(); + $criteriaExtra->add(new Criteria('p.post_time', (time() - newbb_getSinceTime($since)), '>='), 'OR'); + } elseif (is_numeric($topic) && !empty($topic)) { + $criteriaExtra = new CriteriaCompo(); + $criteriaExtra->add(new Criteria('p.topic_id', $topic), 'OR'); + } + // END irmtfan use criteria - add topic search + + if ($uname_required&&(!$uid||count($uid)<1)) $results = array(); // irmtfan bug fix array() + else $results = newbb_search($queries, $andor, $limit, $start, $uid, $forum, $sortby, $searchin, $criteriaExtra); // irmtfan $criteriaExtra + + // add newbb_highlightText function to keywords + $search_info_keywords=newbb_highlightText($myts->htmlSpecialChars($term), $queries); + // add number of results + $num_results = count($results); + if ( $num_results < 1 ) { $xoopsTpl->assign("lang_nomatch", _SR_NOMATCH); } else { + // START irmtfan add show search post_text foreach ($results as $row) { - $xoopsTpl->append('results', array('forum_name' => $myts->htmlSpecialChars($row['forum_name']), 'forum_link' => $row['forum_link'], 'link' => $row['link'], 'title' => $row['title'], 'poster' => $row['poster'], 'post_time' => formatTimestamp($row['time'], "m"))); + $post_text = ""; + if ($show_search == 'post_text') { + $post_text = newbb_selectText($row['post_text'], $queries, 100, 200, false); // strip html tags = false + $post_text = newbb_highlightText($post_text, $queries); + } + // add newbb_highlightText function to subject - add post_text + $xoopsTpl->append('results', array('forum_name' => $row['forum_name'], 'forum_link' => $row['forum_link'], 'link' => $row['link'], 'title' => newbb_highlightText($row['title'],$queries), 'poster' => $row['poster'], 'post_time' => formatTimestamp($row['time'], "m"), 'post_text' => $post_text)); } + // END irmtfan add show search post_text unset($results); if (count($next_search)>0) { $items = array(); foreach ($next_search as $para => $val) { - if (!empty($val)) $items[] = "$para=$val"; + if (!empty($val)) $items[] = "{$para}={$val}";// irmtfan add { and } } if (count($items)>0) $paras = implode("&",$items); unset($next_search); unset($items); } $search_url = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname')."/search.php?".$paras; - - $next_results = newbb_search($queries, $andor, 1, $start + $limit, $uid, $forum, $sortby, $searchin, $subquery); - $next_count = count($next_results); - $has_next = false; - if (is_array($next_results) && $next_count >0) { - $has_next = true; - } - if (false != $has_next) { + // irmtfan remove to have just one query and appropriate next and prev links + //$next_results = newbb_search($queries, $andor, 1, $start + $limit, $uid, $forum, $sortby, $searchin, $subquery); + //$next_count = count($next_results); + //$has_next = false; + //if (is_array($next_results) && $next_count >0) { + //$has_next = true; + //} + // irmtfan if $results < $limit => it is impossible to have next + if ($num_results == $limit) { $next = $start + $limit; $queries = implode(',',$queries); - $search_url_next = $search_url."&start=$next"; + $search_url_next = $search_url."&start={$next}"; // irmtfan add { and } $search_next = '<a href="'.htmlspecialchars($search_url_next).'">'._SR_NEXT.'</a>'; $xoopsTpl->assign("search_next", $search_next); } if ( $start > 0 ) { $prev = $start - $limit; - $search_url_prev = $search_url."&start=$prev"; + $search_url_prev = $search_url."&start={$prev}"; // irmtfan add { and } $search_prev = '<a href="'.htmlspecialchars($search_url_prev).'">'._SR_PREVIOUS.'</a>'; $xoopsTpl->assign("search_prev", $search_prev); } } - - $search_info = _SR_KEYWORDS.": ".$myts->htmlSpecialChars($term); + // irmtfan add newbb_highlightText function + $search_info = _SR_KEYWORDS.": ".$search_info_keywords; if ($uname_required) { if ($search_info) $search_info .= "<br />"; $search_info .= _MD_USERNAME.": ".$myts->htmlSpecialChars($search_username); } + // add num_results + $search_info .= "<br />" . sprintf(_SR_SHOWING, $start + 1, $start + $num_results); $xoopsTpl->assign("search_info", $search_info); } +// START irmtfan - assign template vars for search +/* term */ +$xoopsTpl->assign("search_term", $term); +/* andor */ +$andor_select = "<select name=\"andor\">"; +$andor_select .= "<option value=\"OR\""; +if ("OR" == $andor) $andor_select .= " selected=\"selected\""; +$andor_select .= ">" . _SR_ANY . "</option>"; +$andor_select .= "<option value=\"AND\""; +if ("AND" == $andor || empty($andor)) $andor_select .= " selected=\"selected\""; +$andor_select .= ">" . _SR_ALL . "</option>"; +$andor_select .= "<option value=\"EXACT\""; +if ("EXACT" == $andor) $andor_select .= " selected=\"selected\""; +$andor_select .= ">" . _SR_EXACT . "</option>"; +$andor_select .= "</select>"; +$xoopsTpl->assign("andor_selection_box", $andor_select); + +/* forum */ $select_forum = '<select name="forum[]" size="5" multiple="multiple">'; $select_forum .= '<option value="all">'._MD_SEARCHALLFORUMS.'</option>'; -$select_forum .= newbb_forumSelectBox(); +$select_forum .= newbb_forumSelectBox($forum); $select_forum .= '</select>'; $xoopsTpl->assign_by_ref("forum_selection_box", $select_forum); + +/* searchin */ +$searchin_select = ""; +$searchin_select .= "<input type=\"radio\" name=\"searchin\" value=\"title\""; +if ("title" == $searchin) $searchin_select .= " checked"; +$searchin_select .= " />" . _MD_SUBJECT . " "; +$searchin_select .= "<input type=\"radio\" name=\"searchin\" value=\"text\""; +if ("text" == $searchin) $searchin_select .= " checked"; +$searchin_select .= " />" . _MD_BODY . " "; +$searchin_select .= "<input type=\"radio\" name=\"searchin\" value=\"both\""; +if ("both" == $searchin || empty($searchin)) $searchin_select .= " checked"; +$searchin_select .= " />" . _MD_SUBJECT . " & " . _MD_BODY. " "; +$xoopsTpl->assign("searchin_radio", $searchin_select); + +/* show_search */ +$show_search_select = ""; +$show_search_select .= "<input type=\"radio\" name=\"show_search\" value=\"post\""; +if ("post" == $show_search) $show_search_select .= " checked"; +$show_search_select .= " />" . _MD_POSTS . " "; +$show_search_select .= "<input type=\"radio\" name=\"show_search\" value=\"post_text\""; +if ("post_text" == $show_search || empty($show_search)) $show_search_select .= " checked"; +$show_search_select .= " />" . _MD_SEARCHPOSTTEXT. " "; +$xoopsTpl->assign("show_search_radio", $show_search_select); + +/* author */ +$xoopsTpl->assign("author_select", $search_username); + +/* sortby */ +$sortby_select = "<select name=\"sortby\">"; +$sortby_select .= "<option value=\"p.post_time\""; +if ("p.post_time" == $sortby || empty($sortby)) $sortby_select .= " selected=\"selected\""; +$sortby_select .= ">" . _MD_DATE . "</option>"; +$sortby_select .= "<option value=\"p.subject\""; +if ("p.subject" == $sortby) $sortby_select .= " selected=\"selected\""; +$sortby_select .= ">" . _MD_TOPIC . "</option>"; +$sortby_select .= "</select>"; +$xoopsTpl->assign("sortby_selection_box", $sortby_select); +// END irmtfan - assign template vars for search + // irmtfan get since from the user for selction box $since = isset($_GET['since']) ? intval($_GET['since']) : $xoopsModuleConfig["since_default"]; $select_since = newbb_sinceSelectBox($since); Modified: XoopsModules/newbb/branches/irmtfan/newbb/templates/css/language/english/style.css =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/templates/css/language/english/style.css 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/templates/css/language/english/style.css 2012-10-10 11:01:37 UTC (rev 10211) @@ -355,4 +355,19 @@ border-color: white #a1c1e6 black #a1c1e6; font-weight: normal; } + +span.newbb_highlight { +background-color: #FFFF80 !important; +font-weight: bold !important; +} +span.term0 { +background-color: #00FF00 !important; +} +span.term1 { +background-color: #FF0000 !important; +} +span.term2 { +background-color: #0000FF !important; +} + /* color - end */ \ No newline at end of file Modified: XoopsModules/newbb/branches/irmtfan/newbb/templates/css/language/persian/style.css =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/templates/css/language/persian/style.css 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/templates/css/language/persian/style.css 2012-10-10 11:01:37 UTC (rev 10211) @@ -358,4 +358,18 @@ border-color: white #a1c1e6 black #a1c1e6; font-weight: normal; } +span.newbb_highlight { +background-color: #FFFF80 !important; +font-weight: bold !important; +} +span.term0 { +background-color: #00FF00 !important; +} +span.term1 { +background-color: #FF0000 !important; +} +span.term2 { +background-color: #0000FF !important; +} + /* color - end */ \ No newline at end of file Modified: XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_index.html =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_index.html 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_index.html 2012-10-10 11:01:37 UTC (rev 10211) @@ -307,7 +307,8 @@ <input type="hidden" name="forum" id="forum" value="all" /> <input type="hidden" name="sortby" id="sortby" value="p.post_time desc" /> <input type="hidden" name="searchin" id="searchin" value="both" /> - <input type="submit" name="submit" id="submit" value="<{$smarty.const._MD_SEARCH}>" /> + <!-- irmtfan remove name="submit" --> + <input type="submit" id="submit" value="<{$smarty.const._MD_SEARCH}>" /> <br /> [ <a href="<{$xoops_url}>/modules/<{$xoops_dirname}>/search.php"><{$smarty.const._MD_ADVSEARCH}></a> ] </form> Modified: XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_search.html =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_search.html 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_search.html 2012-10-10 11:01:37 UTC (rev 10211) @@ -14,18 +14,13 @@ <tr> <!-- irmtfan hardcode removed align="right" --> <td class="head" width="10%" id="align_right"><strong><{$smarty.const._SR_KEYWORDS}></strong> </td> - <td class="even"><input type="text" name="term" /></td> +<!-- irmtfan add value="$search_term" --> + <td class="even"><input type="text" name="term" value="<{$search_term}>" /></td> </tr> <tr> -<!-- irmtfan hardcode removed align="right" --> +<!-- irmtfan hardcode removed align="right" add $andor_selection_box --> <td class="head" id="align_right"><strong><{$smarty.const._SR_TYPE}></strong> </td> - <td class="even"> - <select name="andor"> - <option value="or" selected="selected"><{$smarty.const._SR_ANY}></option> - <option value="all"><{$smarty.const._SR_ALL}></option> - <option value="exact"><{$smarty.const._SR_EXACT}></option> - </select> - </td> + <td class="even"><{$andor_selection_box}></td> </tr> <tr> <!-- irmtfan hardcode removed align="right" --> @@ -33,34 +28,31 @@ <td class="even"><{$forum_selection_box}></td> </tr> <tr> -<!-- irmtfan hardcode removed align="right" --> +<!-- irmtfan hardcode removed align="right" add $searchin_radio --> <td class="head" id="align_right"><strong><{$smarty.const._SR_SEARCHIN}></strong> </td> - <td class="even"><input type="radio" name="searchin" value="title" /><{$smarty.const._MD_SUBJECT}> - <input type="radio" name="searchin" value="text" /><{$smarty.const._MD_BODY}> - <input type="radio" name="searchin" value="both" checked="checked" /><{$smarty.const._MD_SUBJECT}> & <{$smarty.const._MD_BODY}> </td> + <td class="even"><{$searchin_radio}></td> </tr> <tr> -<!-- irmtfan hardcode removed align="right" --> +<!-- irmtfan hardcode removed align="right" add value="$author_select"--> <td class="head" id="align_right"><strong><{$smarty.const._MD_AUTHOR}></strong> </td> - <td class="even"><input type="text" name="uname" value="" /></td> + <td class="even"><input type="text" name="uname" value="<{$author_select}>" /></td> </tr> <tr> -<!-- irmtfan hardcode removed align="right" --> +<!-- irmtfan hardcode removed align="right" add $sortby_selection_box --> <td class="head" id="align_right"><strong><{$smarty.const._MD_SORTBY}></strong> </td> - <td class="even"> - <select name=="sortby"> - <option value="p.post_time desc" selected="selected"><{$smarty.const._MD_DATE}></option> - <option value="t.topic_title"><{$smarty.const._MD_TOPIC}></option> - <option value="f.forum_name"><{$smarty.const._MD_FORUM}></option> - <option value="u.uname"><{$smarty.const._MD_USERNAME}></option> - </select> - </td> + <td class="even"><{$sortby_selection_box}></td> </tr> <tr> <!-- irmtfan hardcode removed align="right" --> <td class="head" id="align_right"><strong><{$smarty.const._MD_SINCE}></strong> </td> <td class="even"><{$since_selection_box}></td> </tr> +<!-- START irmtfan add show search --> + <tr> + <td class="head" id="align_right"><strong><{$smarty.const._MD_SHOWSEARCH}></strong> </td> + <td class="even"><{$show_search_radio}></td> + </tr> +<!-- START irmtfan add show search --> <{if $search_rule}> <tr> <!-- irmtfan hardcode removed align="right" --> @@ -71,7 +63,8 @@ <tr> <!-- irmtfan hardcode removed align="right" --> <td class="head" id="align_right"> </td> - <td class="even"><input type="submit" name="submit" value="<{$smarty.const._MD_SEARCH}>" /></td> + <!-- irmtfan remove name="submit" --> + <td class="even"><input type="submit" value="<{$smarty.const._MD_SEARCH}>" /></td> </table></td> </tr> </table> Modified: XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_searchresults.html =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_searchresults.html 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_searchresults.html 2012-10-10 11:01:37 UTC (rev 10211) @@ -20,6 +20,18 @@ <td class="even"><{$results[i].poster}></a></td> <td class="odd"><{$results[i].post_time}></td> </tr> +<!-- START irmtfan add show search --> + <{if $results[i].post_text }> + <tr align="center"> + <td class="even"></td> + <td class="odd"> + <{$results[i].post_text}> + </td> + <td class="even"></td> + <td class="odd"></td> + </tr> + <{/if}> +<!-- END irmtfan add show search --> <!-- end each result --> <{/section}> <!-- end search results --> Modified: XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewall.html =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewall.html 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewall.html 2012-10-10 11:01:37 UTC (rev 10211) @@ -75,6 +75,8 @@ <option value=""><{$smarty.const._MD_TOPICOPTION}></option> <option value="<{$post_link}>"><{$smarty.const._MD_VIEW}> <{$smarty.const._MD_ALLPOSTS}></option> <option value="<{$newpost_link}>"><{$smarty.const._MD_VIEW}> <{$smarty.const._MD_NEWPOSTS}></option> + <!-- irmtfan add a separator --> + <option value="">--------</option> <{foreach item=filter from=$filters}> <option value="<{$filter.link}>"><{$filter.title}></option> <{/foreach}> @@ -123,7 +125,7 @@ </div> <!-- irmtfan hardcode removed style="padding: 5px;float: right; text-align:right;" --> <div class="pagenav"> -<{$pagenav|replace:'form':'div'}> <!-- irmtfan to solve nested forms issue --> +<{$pagenav|replace:'form':'div'|replace:'id="xo-pagenav"':''}> <!-- irmtfan to solve nested forms and id="xo-pagenav" issue --> </div> </div> <div class="clear"></div> @@ -159,7 +161,8 @@ <{/if}> </td> <td width="4%" align="center"><{$topic.topic_icon}></td> - <td> <a href="<{$topic.topic_link}>"> +<!-- irmtfan remove topic_link hardcode and add topic_excerpt --> + <td> <a href="<{$xoops_url}>/modules/<{$xoops_dirname}>/<{$topic.topic_link}>" title="<{$topic.topic_excerpt}>"> <{if $topic.allow_prefix AND $topic.topic_subject}> <{$topic.topic_subject}> <{/if}> @@ -191,9 +194,13 @@ <{$selection.order}> <{$selection.since}> <{foreach item=hidval key=hidvar from=$selection.vars}> - <input type="hidden" name="$hidvar" value="<{$hidval}>" /> + <{if $hidval && $hidvar neq "sort" && $hidvar neq "order" && $hidvar neq "since"}> + <!-- irmtfan correct name="$hidvar" --> + <input type="hidden" name="<{$hidvar}>" value="<{$hidval}>" /> + <{/if}> <{/foreach}> - <input type="submit" name="refresh" value="<{$smarty.const._SUBMIT}>" /> + <!-- irmtfan remove name="refresh" --> + <input type="submit" value="<{$smarty.const._SUBMIT}>" /> </form> <{/strip}> </td> @@ -203,7 +210,7 @@ <{if $pagenav}> <!-- irmtfan hardcode removed style="padding: 5px;float: right; text-align:right;" --> -<div class="pagenav"><{$pagenav|replace:'form':'div'}> <!-- irmtfan to solve nested forms issue --></div> +<div class="pagenav"><{$pagenav|replace:'form':'div'|replace:'id="xo-pagenav"':''}> <!-- irmtfan to solve nested forms and id="xo-pagenav" issue --></div> <br /> <{/if}> <div class="clear"></div> @@ -222,12 +229,28 @@ <form action="<{$xoops_url}>/modules/<{$xoops_dirname}>/search.php" method="get"> <input name="term" id="term" type="text" size="15" /> <{foreach item=hidval key=hidvar from=$search}> - <input type="hidden" name="$hidvar" value="<{$hidval}>" /> + <{if $hidval }> + <!-- irmtfan correct name="$hidvar" --> + <input type="hidden" name="<{$hidvar}>" value="<{$hidval}>" /> + <{/if}> <{/foreach}> <input type="submit" class="formButton" value="<{$smarty.const._MD_SEARCH}>" /><br /> [<a href="<{$xoops_url}>/modules/<{$xoops_dirname}>/search.php"><{$smarty.const._MD_ADVSEARCH}></a>] </form><br /> - <{$forum_jumpbox}> + <!-- START irmtfan add forum selection box --> + <{if $forum_jumpbox }> + <form method="get" action="<{$selection.action}>"> + <{$selection.forum}> + <{foreach item=hidval key=hidvar from=$selection.vars}> + <{if $hidval && $hidvar neq "forum"}> + <input type="hidden" name="<{$hidvar}>" value="<{$hidval}>" /> + <{/if}> + <{/foreach}> + <input type="submit" value="<{$smarty.const._SUBMIT}>" /> + </form><br /> + <{$forum_jumpbox}> + <{/if}> + <!-- END irmtfan add forum selection box --> </div> </div> <div class="clear"></div> Modified: XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewforum.html =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewforum.html 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewforum.html 2012-10-10 11:01:37 UTC (rev 10211) @@ -76,7 +76,7 @@ </div> <!-- irmtfan hardcode removed style="float: right; text-align:right;" --> <div class="icon_right"> - <{$forum_pagenav|replace:'form':'div'}> <!-- irmtfan to solve nested forms issue --> + <{$forum_pagenav|replace:'form':'div'|replace:'id="xo-pagenav"':''}> <!-- irmtfan to solve nested forms and id="xo-pagenav" issue --> </div> </div> <div class="clear"></div> @@ -172,7 +172,8 @@ <strong><{$smarty.const._MD_SORTEDBY}></strong> <{$forum_selection_sort}> <{$forum_selection_order}> <{$forum_selection_since}> <input type="hidden" name="forum" id="forum" value="<{$forum_id}>" /> <input type="hidden" name="status" value="<{$status}>" /> - <input type="submit" name="refresh" value="<{$smarty.const._SUBMIT}>" /> + <!-- irmtfan remove name="submit" --> + <input type="submit" value="<{$smarty.const._SUBMIT}>" /> </form> <{/strip}> </td> @@ -187,7 +188,7 @@ <{$forum_addpoll}> <{$forum_post_or_register}> </div> <div class="right"> - <{$forum_pagenav|replace:'form':'div'}> <!-- irmtfan to solve nested forms issue --> + <{$forum_pagenav|replace:'form':'div'|replace:'id="xo-pagenav"':''}> <!-- irmtfan to solve nested forms and id="xo-pagenav" issue --> </div> </div> <div class="clear"></div> Modified: XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewpost.html =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewpost.html 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewpost.html 2012-10-10 11:01:37 UTC (rev 10211) @@ -82,7 +82,7 @@ </div> <!-- irmtfan hardcode removed style="padding: 5px;float: right; text-align:right;" --> <div class="pagenav"> - <{$pagenav|replace:'form':'div'}> <!-- irmtfan to solve nested forms issue --> + <{$pagenav|replace:'form':'div'|replace:'id="xo-pagenav"':''}> <!-- irmtfan to solve nested forms and id="xo-pagenav" issue --> </div> </div> <div class="clear"></div> @@ -116,7 +116,7 @@ </div> <!-- irmtfan hardcode removed style="float: right; text-align:right;" --> <div class="icon_right"> - <{$pagenav|replace:'form':'div'}> <!-- irmtfan to solve nested forms issue --> + <{$pagenav|replace:'form':'div'|replace:'id="xo-pagenav"':''}> <!-- irmtfan to solve nested forms and id="xo-pagenav" issue --> </div> </div> <div class="clear"></div> Modified: XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewtopic.html =================================================================== --- XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewtopic.html 2012-10-09 22:03:21 UTC (rev 10210) +++ XoopsModules/newbb/branches/irmtfan/newbb/templates/newbb_viewtopic.html 2012-10-10 11:01:37 UTC (rev 10211) @@ -148,10 +148,26 @@ <option value="<{$act.link}>"><{$act.title}></option> <{/foreach}> </select> + <!-- START irmtfan add topic search --> + <{if $mode lte 1}> + <form id="search-topic" action="<{$xoops_url}>/modules/<{$xoops_dirname}>/search.php" method="get"> + <fieldset> + <input name="term" id="term" type="text" size="15" value="<{$smarty.const._MD_SEARCHTOPIC}>..." onBlur="if(this.value=='') this.value='<{$smarty.const._MD_SEARCHTOPIC}>...'" onFocus="if(this.v... [truncated message content] |