[svn r14745] forum search improvement

skala
Patrick Cool 17 years ago
parent 02eebe3a33
commit fbf2c5ccab
  1. 45
      main/forum/forumfunction.inc.php
  2. 6
      main/forum/viewforum.php
  3. 6
      main/forum/viewforumcategory.php
  4. 8
      main/forum/viewthread.php

@ -2645,11 +2645,25 @@ function store_move_thread($values)
*/
function prepare4display($input='')
{
$highlightcolors = array('yellow', '#33CC33','#3399CC', '#9999FF', '#33CC33');
if (!is_array($input))
{
if (isset($_GET['search']))
if (!empty($_GET['search']))
{
$input = str_replace($_GET['search'],'<span style="background-color: yellow">'.$_GET['search'].'</span>',$input);
if (strstr($_GET['search'],'+'))
{
$search_terms = explode('+',$_GET['search']);
}
else
{
$search_terms[] = trim($_GET['search']);
}
$counter = 0;
foreach ($search_terms as $key=>$search_term)
{
$input = str_replace(trim(html_entity_decode($search_term)),'<span style="background-color: '.$highlightcolors[$counter].'">'.trim(html_entity_decode($search_term)).'</span>',$input);
$counter++;
}
}
return stripslashes($input);
}
@ -2678,6 +2692,7 @@ function forum_search()
// settting the form elements
$form->addElement('header', '', get_lang('ForumSearch'));
$form->addElement('text', 'search_term', get_lang('SearchTerm'),'class="input_titles"');
$form->addElement('static', 'search_information', '', get_lang('ForumSearchInformation'), $dissertation[$_GET['opleidingsonderdeelcode']]['code']);
$form->addElement('submit', 'SubmitForumCategory', get_lang('Search'));
// setting the rules
@ -2709,9 +2724,25 @@ function display_forum_search_results($search_term)
{
global $table_categories, $table_forums, $table_threads, $table_posts;
// defining the search strings as an array
if (strstr($search_term,'+'))
{
$search_terms = explode('+',$search_term);
}
else
{
$search_terms[] = $search_term;
}
// search restriction
foreach ($search_terms as $key => $value)
{
$search_restriction[] = "(posts.post_title LIKE '%".Database::escape_string(trim($value))."%'
OR posts.post_text LIKE '%".Database::escape_string(trim($value))."%')";
}
$sql = "SELECT * FROM $table_posts posts
WHERE posts.post_title LIKE '%".Database::escape_string($search_term)."%'
OR posts.post_text LIKE '%".Database::escape_string($search_term)."%'
WHERE ".implode(' AND ',$search_restriction)."
/*AND posts.thread_id = threads.thread_id*/
GROUP BY posts.post_id";
@ -2746,10 +2777,10 @@ function display_forum_search_results($search_term)
if ($display_result == true)
{
$search_results_item = '<li><a href="viewforumcategory.php?forumcategory='.$forum_list[$row['forum_id']]['forum_category'].'&amp;search='.$search_term.'">'.$forum_categories_list[$row['forum_id']['forum_category']]['cat_title'].'</a> > ';
$search_results_item .= '<a href="viewforum.php?forum='.$row['forum_id'].'&amp;search='.$search_term.'">'.$forum_list[$row['forum_id']]['forum_title'].'</a> > ';
$search_results_item = '<li><a href="viewforumcategory.php?forumcategory='.$forum_list[$row['forum_id']]['forum_category'].'&amp;search='.urlencode($search_term).'">'.$forum_categories_list[$row['forum_id']['forum_category']]['cat_title'].'</a> > ';
$search_results_item .= '<a href="viewforum.php?forum='.$row['forum_id'].'&amp;search='.urlencode($search_term).'">'.$forum_list[$row['forum_id']]['forum_title'].'</a> > ';
//$search_results_item .= '<a href="">THREAD</a> > ';
$search_results_item .= '<a href="viewthread.php?forum='.$row['forum_id'].'&amp;thread='.$row['thread_id'].'&amp;search='.$search_term.'">'.$row['post_title'].'</a>';
$search_results_item .= '<a href="viewthread.php?forum='.$row['forum_id'].'&amp;thread='.$row['thread_id'].'&amp;search='.urlencode($search_term).'">'.$row['post_title'].'</a>';
$search_results_item .= '<br />';
if (strlen($row['post_title']) > 200 )
{

@ -103,8 +103,8 @@ $current_forum_category=get_forumcategory_information($current_forum['forum_cate
-----------------------------------------------------------
*/
$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS($_GET['search']),"name" => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;search=".Security::remove_XSS($_GET['search']),"name" => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;search=".Security::remove_XSS($_GET['search']),"name" => prepare4display($current_forum['forum_title']));
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum['forum_title']));
if($origin=='learnpath')
{
include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
@ -268,7 +268,7 @@ if(is_array($threads))
echo icon('../img/exclamation.gif');
}
echo "</td>\n";
echo "\t\t<td><a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".$row['thread_id'].$origin_string."&amp;search=".Security::remove_XSS($_GET['search'])."\" ".class_visible_invisible($row['visibility']).">".prepare4display($row['thread_title'])."</a></td>\n";
echo "\t\t<td><a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".$row['thread_id'].$origin_string."&amp;search=".Security::remove_XSS(urlencode($_GET['search']))."\" ".class_visible_invisible($row['visibility']).">".prepare4display($row['thread_title'])."</a></td>\n";
echo "\t\t<td>".$row['thread_replies']."</td>\n";
if ($row['user_id']=='0')
{

@ -90,8 +90,8 @@ if(!api_is_allowed_to_edit())
-----------------------------------------------------------
*/
$current_forum_category=get_forum_categories($_GET['forumcategory']);
$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS($_GET['search']),"name" => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;search=".Security::remove_XSS($_GET['search']),"name" => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS(url_encode($_GET['search'])),"name" => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;search=".Security::remove_XSS(url_encode($_GET['search'])),"name" => prepare4display($current_forum_category['cat_title']));
if (!empty($_GET['action']) && !empty($_GET['content']))
@ -303,7 +303,7 @@ foreach ($forum_list as $key=>$forum)
}
}
echo "</td>\n";
echo "\t\t<td><a href=\"viewforum.php?".api_get_cidreq()."&forum=".$forum['forum_id']."&amp;search=".Security::remove_XSS($_GET['search'])."\" ".class_visible_invisible($forum['visibility']).">".prepare4display($forum['forum_title']).'</a><br />'.prepare4display($forum['forum_comment'])."</td>\n";
echo "\t\t<td><a href=\"viewforum.php?".api_get_cidreq()."&forum=".$forum['forum_id']."&amp;search=".Security::remove_XSS(urlencode($_GET['search']))."\" ".class_visible_invisible($forum['visibility']).">".prepare4display($forum['forum_title']).'</a><br />'.prepare4display($forum['forum_comment'])."</td>\n";
//$number_forum_topics_and_posts=get_post_topics_of_forum($forum['forum_id']); // deprecated
// the number of topics and posts
echo "\t\t<td>".$forum['number_of_threads']."</td>\n";

@ -118,9 +118,9 @@ if($origin=='learnpath')
} else
{
$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS($_GET['search']),"name" => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;search=".Security::remove_XSS($_GET['search']),"name" => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;search=".Security::remove_XSS($_GET['search']),"name" => prepare4display($current_forum['forum_title']));
$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum['forum_title']));
if ($message<>'PostDeletedSpecial')
{
$interbreadcrumb[]=array("url" => "viewthread.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => prepare4display($current_thread['thread_title']));
@ -187,7 +187,7 @@ if ($message<>'PostDeletedSpecial') // in this case the first and only post of t
-----------------------------------------------------------
*/
echo '<div style="float:right;">';
$my_url = '<a href="viewthread.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;search='.Security::remove_XSS($_GET['search']);
$my_url = '<a href="viewthread.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;search='.Security::remove_XSS(urlencode($_GET['search']));
echo $my_url.'&amp;view=flat&origin='.$origin.'">'.get_lang('FlatView').'</a> | ';
echo $my_url.'&amp;view=threaded&origin='.$origin.'">'.get_lang('ThreadedView').'</a> | ';
echo $my_url.'&amp;view=nested&origin='.$origin.'">'.get_lang('NestedView').'</a>';

Loading…
Cancel
Save