[svn r14739] highlight search results

skala
Patrick Cool 18 years ago
parent 34da4017de
commit 02eebe3a33
  1. 49
      main/forum/forumfunction.inc.php
  2. 4
      main/forum/index.php
  3. 10
      main/forum/viewforum.php
  4. 8
      main/forum/viewforumcategory.php
  5. 8
      main/forum/viewthread.php

@ -448,13 +448,13 @@ function store_forum($values)
$sql="SELECT MAX(forum_order) as sort_max FROM ".$table_forums." WHERE forum_category=".mysql_real_escape_string($values['forum_category']);
$result=api_sql_query($sql);
$row=mysql_fetch_array($result);
$new_max=$row['sort_max']+1;
$new_max=$row['sort_max']+1;
$session_id = isset($_SESSION['id_session']) ? $_SESSION['id_session'] : 0;
$clean_title=Security::remove_XSS(mysql_real_escape_string(htmlspecialchars($values['forum_title'])));
if (isset($values['forum_id']))
{
{
// storing an edit
$sql="UPDATE ".$table_forums." SET
@ -2647,6 +2647,10 @@ function prepare4display($input='')
{
if (!is_array($input))
{
if (isset($_GET['search']))
{
$input = str_replace($_GET['search'],'<span style="background-color: yellow">'.$_GET['search'].'</span>',$input);
}
return stripslashes($input);
}
else
@ -2663,8 +2667,8 @@ function prepare4display($input='')
/**
* Display the search form for the forum and display the search results
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version march 2008, dokeos 1.8.5
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version march 2008, dokeos 1.8.5
*/
function forum_search()
{
@ -2698,8 +2702,8 @@ function forum_search()
/**
* Display the search results
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version march 2008, dokeos 1.8.5
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version march 2008, dokeos 1.8.5
*/
function display_forum_search_results($search_term)
{
@ -2742,10 +2746,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'].'">'.$forum_categories_list[$row['forum_id']['forum_category']]['cat_title'].'</a> > ';
$search_results_item .= '<a href="viewforum.php?forum='.$row['forum_id'].'">'.$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='.$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 .= '<a href="">THREAD</a> > ';
$search_results_item .= '<a href="viewthread.php?forum='.$row['forum_id'].'&amp;thread='.$row['thread_id'].'">'.$row['post_title'].'</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 .= '<br />';
if (strlen($row['post_title']) > 200 )
{
@ -2767,4 +2771,31 @@ function display_forum_search_results($search_term)
echo implode($search_results);
echo '</ol>';
}
/**
* Return the link to the forum search page
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version April 2008, dokeos 1.8.5
*/
function search_link()
{
$return = '<a href="forumsearch.php?'.api_get_cidreq().'&action=search"> '.Display::return_icon('search.gif').' '.get_lang('Search').'</a>';
if (!empty($_GET['search']))
{
$return .= ': '.Security::remove_XSS($_GET['search']).' ';
$url = api_get_self().'?';
foreach ($_GET as $key=>$value)
{
if ($key<>'search')
{
$url_parameter[]=Security::remove_XSS($key).'='.Security::remove_XSS($value);
}
}
$url = $url.implode('&amp;',$url_parameter);
$return .= '<a href="'.$url.'">'.Display::return_icon('delete.gif', get_lang('RemoveSearchResults')).'</a>';
}
return $return;
}
?>

@ -85,7 +85,7 @@ if(!api_is_allowed_to_edit()) $fck_attribute['Config']['UserStatus'] = 'student'
Header
-----------------------------------------------------------
*/
$interbreadcrumb[]=array("url" => "index.php","name" => $nameTools);
$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS($_GET['search']),"name" => $nameTools);
if ($_GET['action']=='add' ) {
@ -170,7 +170,7 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' )
------------------------------------------------------------------------------------------------------
*/
//if (api_is_allowed_to_edit() and !$_GET['action'])
echo '<span style="float:right;"><a href="forumsearch.php?'.api_get_cidreq().'&action=search"> '.Display::return_icon('search.gif').' '.get_lang('Search').'</a></span>';
echo '<span style="float:right;">'.search_link().'</span>';
if (api_is_allowed_to_edit())
{
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=add&amp;content=forumcategory"> '.Display::return_icon('forum_category_new.gif').' '.get_lang('AddForumCategory').'</a> ';

@ -102,9 +102,9 @@ $current_forum_category=get_forumcategory_information($current_forum['forum_cate
Header and Breadcrumbs
-----------------------------------------------------------
*/
$interbreadcrumb[]=array("url" => "index.php","name" => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum']),"name" => prepare4display($current_forum['forum_title']));
$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']));
if($origin=='learnpath')
{
include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
@ -170,7 +170,7 @@ if (isset($message))
Action Links
-----------------------------------------------------------
*/
echo '<span style="float:right;"><a href="forumsearch.php?'.api_get_cidreq().'&action=search"> '.Display::return_icon('search.gif').' '.get_lang('Search').'</a></span>';
echo '<span style="float:right;">'.search_link().'</span>';
// The link should appear when
// 1. the course admin is here
// 2. the course member is here and new threads are allowed
@ -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."\" ".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($_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","name" => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => prepare4display($current_forum_category['cat_title']));
$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']));
if (!empty($_GET['action']) && !empty($_GET['content']))
@ -166,7 +166,7 @@ $groups_of_user=GroupManager::get_group_ids($_course['dbName'], $_user['user_id'
Action Links
-----------------------------------------------------------
*/
echo '<span style="float:right;"><a href="forumsearch.php?'.api_get_cidreq().'&action=search"> '.Display::return_icon('search.gif').' '.get_lang('Search').'</a></span>';
echo '<span style="float:right;">'.search_link().'</span>';
if (api_is_allowed_to_edit())
{
//echo '<a href="'.api_get_self().'?forumcategory='.$_GET['forumcategory'].'&amp;action=add&amp;content=forumcategory">'.get_lang('AddForumCategory').'</a> | ';
@ -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']."\" ".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($_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","name" => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id'],"name" => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum']),"name" => prepare4display($current_forum['forum_title']));
$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']));
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().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']);
$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']);
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