本文整理汇总了PHP中prepare4display函数的典型用法代码示例。如果您正苦于以下问题:PHP prepare4display函数的具体用法?PHP prepare4display怎么用?PHP prepare4display使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了prepare4display函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
$class = 'row_even';
}
echo "<tr class=\"{$class}\">";
echo '<td>';
$my_whatsnew_post_info = isset($whatsnew_post_info[$my_forum][$row['thread_id']]) ? $whatsnew_post_info[$my_forum][$row['thread_id']] : null;
if (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) {
echo Display::return_icon('forumthread.gif');
} else {
echo Display::return_icon('forumthread.gif');
}
if ($row['thread_sticky'] == 1) {
echo Display::return_icon('exclamation.gif');
}
echo '</td>';
echo '<td>';
echo '<a href="viewthread.php?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . '&origin=' . $origin . '&thread=' . $row['thread_id'] . $origin_string . '&search=' . Security::remove_XSS(urlencode($my_search)) . '" ' . class_visible_invisible($row['visibility']) . '>' . prepare4display($row['thread_title']) . '</a></td>';
echo '<td>' . $row['thread_replies'] . '</td>';
echo '<td>' . $row['thread_views'] . '</td>';
// display the author name
$tab_poster_info = api_get_user_info($row['user_id']);
$poster_username = sprintf(get_lang('LoginX'), $tab_poster_info['username']);
if ($origin != 'learnpath') {
echo '<td>' . display_user_link($row['user_id'], api_get_person_name($row['firstname'], $row['lastname']), '', $poster_username) . '</td>';
} else {
echo '<td>' . Display::tag('span', api_get_person_name($row['firstname'], $row['lastname']), array("title" => api_htmlentities($poster_username, ENT_QUOTES))) . '</td>';
}
$last_post_info = get_last_post_by_thread($row['c_id'], $row['thread_id'], $row['forum_id'], is_allowed_to_edit());
$last_post = null;
if ($last_post_info) {
$poster_info = api_get_user_info($last_post_info['poster_id']);
$post_date = api_convert_and_format_date($last_post_info['post_date']);
示例2: api_convert_and_format_date
$messageclass = 'forum_message_post_text';
$leftclass = 'forum_message_left';
}
echo "<tr>";
echo "<td rowspan=\"3\" class=\"{$leftclass}\">";
echo '<br /><b>' . api_convert_and_format_date($row['post_date'], DATE_TIME_FORMAT_LONG) . '</b><br />';
if (api_is_allowed_to_edit(null, true)) {
echo $url_post;
}
echo "</td>";
// The post title
echo "<td class=\"{$titleclass}\">" . prepare4display($row['post_title']) . "</td>";
echo "</tr>";
// The post message
echo "<tr >";
echo "<td class=\"{$messageclass}\">" . prepare4display($row['post_text']) . "</td>";
echo "</tr>";
// The check if there is an attachment
$attachment_list = getAllAttachment($row['post_id']);
if (!empty($attachment_list)) {
foreach ($attachment_list as $attachment) {
echo '<tr ><td height="50%">';
$realname = $attachment['path'];
$user_filename = $attachment['filename'];
echo Display::return_icon('attachment.gif', get_lang('Attachment'));
echo '<a href="download.php?file=';
echo $realname;
echo ' "> ' . $user_filename . ' </a>';
echo '<span class="forum_attach_comment" >' . $attachment['comment'] . '</span><br />';
echo '</td></tr>';
}
示例3: search_link
echo '<div class="actions">';
echo '<span style="float:right;">' . search_link() . '</span>';
if ($origin == 'group') {
echo '<a href="../group/group_space.php?' . api_get_cidreq() . '&gidReq=' . Security::remove_XSS($_GET['gidReq']) . '&gradebook=' . $gradebook . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('Groups'), '', ICON_SIZE_MEDIUM) . '</a>';
} else {
echo '<a href="index.php?gradebook=' . $gradebook . '">' . Display::return_icon('back.png', get_lang('BackToForumOverview'), '', ICON_SIZE_MEDIUM) . '</a>';
}
echo '<a href="viewforum.php?forum=' . Security::remove_XSS($_GET['forum']) . '&gidReq=' . Security::remove_XSS($_GET['gidReq']) . '&origin=' . $origin . '">' . Display::return_icon('forum.png', get_lang('BackToForum'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '</div>';
}
/* Display Forum Category and the Forum information */
echo "<table class=\"forum_table\" width=\"100%\">";
// The forum category
echo "<tr><th class=\"forum_head\" colspan=\"2\">";
echo '<a href="viewforum.php?&origin=' . $origin . '&forum=' . $current_forum['forum_id'] . '" ' . class_visible_invisible($current_forum['visibility']) . '>' . prepare4display($current_forum['forum_title']) . '</a><br />';
echo '<span class="forum_description">' . prepare4display($current_forum['forum_comment']) . '</span>';
echo "</th>";
echo "</tr>";
echo '</table>';
// The form for the reply
$values = show_edit_post_form($current_post, $current_thread, $current_forum, isset($_SESSION['formelements']) ? $_SESSION['formelements'] : '');
if (!empty($values) and isset($_POST['SubmitPost'])) {
store_edit_post($values);
$option_chek = isset($values['thread_qualify_gradebook']) ? $values['thread_qualify_gradebook'] : null;
// values 1 or 0
if (1 == $option_chek) {
$id = $values['thread_id'];
$title_gradebook = Security::remove_XSS(stripslashes($values['calification_notebook_title']));
$value_calification = $values['numeric_calification'];
$weight_calification = $values['weight_calification'];
$description = '';
示例4: array
$viewmode = $_SESSION['view'];
}
$viewmode_whitelist = array('flat', 'threaded', 'nested');
if (isset($_GET['view']) && in_array($_GET['view'], $viewmode_whitelist)) {
$viewmode = Database::escape_string($_GET['view']);
$_SESSION['view'] = $viewmode;
}
if (empty($viewmode)) {
$viewmode = 'flat';
}
/* Display Forum Category and the Forum information */
// we are getting all the information about the current forum and forum category.
// note pcool: I tried to use only one sql statement (and function) for this
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
echo "<table class=\"data_table\" width=\"100%\">\n";
// The thread
echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"6\">";
echo '<span class="forum_title">' . prepare4display($current_thread['thread_title']) . '</span><br />';
if ($origin != 'learnpath') {
echo '<span class="forum_low_description">' . prepare4display($current_forum_category['cat_title']) . ' - ';
}
echo prepare4display($current_forum['forum_title']) . '<br />';
echo "</th>\n";
echo "\t</tr>\n";
echo '<span>' . prepare4display($current_thread['thread_comment']) . '</span>';
echo "</table>";
include_once 'viewpost.inc.php';
}
if ($origin != 'learnpath') {
Display::display_footer();
}
示例5: isset
}
echo '</td>';
if ($forum['forum_of_group'] != '0') {
$my_all_groups_forum_name = isset($all_groups[$forum['forum_of_group']]['name']) ? $all_groups[$forum['forum_of_group']]['name'] : null;
$my_all_groups_forum_id = isset($all_groups[$forum['forum_of_group']]['id']) ? $all_groups[$forum['forum_of_group']]['id'] : null;
$group_title = api_substr($my_all_groups_forum_name, 0, 30);
$forum_title_group_addition = ' (<a href="../group/group_space.php?' . api_get_cidreq() . '&gidReq=' . $my_all_groups_forum_id . '" class="forum_group_link">' . get_lang('GoTo') . ' ' . $group_title . '</a>)';
} else {
$forum_title_group_addition = '';
}
if ((!isset($_SESSION['id_session']) || $_SESSION['id_session'] == 0) && !empty($forum['session_name'])) {
$session_displayed = ' (' . $forum['session_name'] . ')';
} else {
$session_displayed = '';
}
echo '<td><a href="viewforum.php?' . api_get_cidreq() . '&gidReq=' . $forum['forum_of_group'] . '&forum=' . $forum['forum_id'] . '&origin=' . $origin . '&search=' . Security::remove_XSS(urlencode(isset($_GET['search']) ? $_GET['search'] : '')) . '" ' . class_visible_invisible($forum['visibility']) . '>' . prepare4display($forum['forum_title']) . $session_displayed . '</a>' . $forum_title_group_addition . '<br />' . prepare4display($forum['forum_comment']) . '</td>';
//$number_forum_topics_and_posts=get_post_topics_of_forum($forum['forum_id']); // deprecated
// the number of topics and posts
$my_number_threads = isset($forum['number_of_threads']) ? $forum['number_of_threads'] : '';
$my_number_posts = isset($forum['number_of_posts']) ? $forum['number_of_posts'] : '';
echo '<td>' . $my_number_threads . '</td>';
echo '<td>' . $my_number_posts . '</td>';
// the last post in the forum
if ($forum['last_poster_name'] != '') {
$name = $forum['last_poster_name'];
$poster_id = 0;
} else {
$name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']);
$poster_id = $forum['last_poster_id'];
}
echo '<td>';
示例6: get_lang
$origin = '';
if (isset($_GET['origin'])) {
$origin = Security::remove_XSS($_GET['origin']);
}
// Name of the tool
$nameTools = get_lang('ToolForum');
// Breadcrumbs
if (api_is_in_gradebook()) {
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'gradebook/index.php?' . api_get_cidreq(), 'name' => get_lang('ToolGradebook'));
}
$groupId = api_get_group_id();
if ($origin == 'group') {
$group_properties = GroupManager::get_group_properties($groupId);
$interbreadcrumb[] = array('url' => '../group/group.php?' . api_get_cidreq(), 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => '../group/group_space.php?' . api_get_cidreq(), 'name' => get_lang('GroupSpace') . ' (' . $group_properties['name'] . ')');
$interbreadcrumb[] = array('url' => 'viewforum.php?origin=' . $origin . '&forum=' . intval($_GET['forum']) . '&' . api_get_cidreq(), 'name' => prepare4display($current_forum['forum_title']));
$interbreadcrumb[] = array('url' => 'forumsearch.php?' . api_get_cidreq(), 'name' => get_lang('ForumSearch'));
} else {
$interbreadcrumb[] = array('url' => 'index.php?' . api_get_cidreq(), 'name' => $nameTools);
$nameTools = get_lang('ForumSearch');
}
// Display the header.
if ($origin == 'learnpath') {
Display::display_reduced_header();
} else {
Display::display_header($nameTools);
}
// Tool introduction
Display::display_introduction_section(TOOL_FORUM);
// Tracking
Event::event_access_tool(TOOL_FORUM);
示例7: display_forum_search_results
/**
* Display the search results
* @param string
* @return void display the results
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version march 2008, dokeos 1.8.5
*/
function display_forum_search_results($search_term)
{
$table_threads = Database::get_course_table(TABLE_FORUM_THREAD);
$table_posts = Database::get_course_table(TABLE_FORUM_POST);
$table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$session_id = api_get_session_id();
$course_id = api_get_course_int_id();
// 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 $value) {
$search_restriction[] = "\n (posts.post_title LIKE '%" . Database::escape_string(trim($value)) . "%'\n OR posts.post_text LIKE '%" . Database::escape_string(trim($value)) . "%')";
}
$sql = "SELECT posts.*\n FROM {$table_posts} posts, {$table_threads} threads, {$table_item_property} item_property\n WHERE\n posts.c_id = {$course_id}\n AND item_property.c_id = {$course_id}\n AND posts.thread_id = threads.thread_id\n AND item_property.ref = threads.thread_id\n AND item_property.visibility = 1\n AND item_property.session_id = {$session_id}\n AND posts.visible = 1\n AND item_property.tool = '" . TOOL_FORUM_THREAD . "'\n AND " . implode(' AND ', $search_restriction) . "\n GROUP BY posts.post_id";
// Getting all the information of the forum categories.
$forum_categories_list = get_forum_categories();
// Getting all the information of the forums.
$forum_list = get_forums();
$result = Database::query($sql);
$search_results = [];
while ($row = Database::fetch_array($result, 'ASSOC')) {
$display_result = false;
/*
We only show it when
1. forum category is visible
2. forum is visible
3. thread is visible (to do)
4. post is visible
*/
if (!api_is_allowed_to_edit(null, true)) {
if ($forum_categories_list[$forum_list[$row['forum_id']]['forum_category']]['visibility'] == '1' and $forum_list[$row['forum_id']]['visibility'] == '1' and $row['visible'] == '1') {
$display_result = true;
}
} else {
$display_result = true;
}
if ($display_result) {
$search_results_item = '<li><a href="viewforumcategory.php?' . api_get_cidreq() . '&forumcategory=' . $forum_list[$row['forum_id']]['forum_category'] . '&search=' . urlencode($search_term) . '">' . prepare4display($forum_categories_list[$row['forum_id']['forum_category']]['cat_title']) . '</a> > ';
$search_results_item .= '<a href="viewforum.php?' . api_get_cidreq() . '&forum=' . $row['forum_id'] . '&search=' . urlencode($search_term) . '">' . prepare4display($forum_list[$row['forum_id']]['forum_title']) . '</a> > ';
//$search_results_item .= '<a href="">THREAD</a> > ';
$search_results_item .= '<a href="viewthread.php?' . api_get_cidreq() . '&forum=' . $row['forum_id'] . '&thread=' . $row['thread_id'] . '&search=' . urlencode($search_term) . '">' . prepare4display($row['post_title']) . '</a>';
$search_results_item .= '<br />';
if (api_strlen($row['post_title']) > 200) {
$search_results_item .= prepare4display(api_substr(strip_tags($row['post_title']), 0, 200)) . '...';
} else {
$search_results_item .= prepare4display($row['post_title']);
}
$search_results_item .= '</li>';
$search_results[] = $search_results_item;
}
}
echo '<legend>' . count($search_results) . ' ' . get_lang('ForumSearchResults') . '</legend>';
echo '<ol>';
if ($search_results) {
echo implode($search_results);
}
echo '</ol>';
}
示例8: api_get_session_id
$sessionId = api_get_session_id();
$_user = api_get_user_info();
$userId = api_get_user_id();
$groupId = api_get_group_id();
$sortDirection = isset($_GET['posts_order']) && $_GET['posts_order'] === 'desc' ? 'DESC' : 'ASC';
if (isset($current_thread['thread_id'])) {
$rows = getPosts($current_thread['thread_id'], $sortDirection);
$increment = 0;
$clean_forum_id = intval($_GET['forum']);
$clean_thread_id = intval($_GET['thread']);
$locked = api_resource_is_locked_by_gradebook($clean_thread_id, LINK_FORUM_THREAD);
$closedPost = null;
if (!empty($rows)) {
foreach ($rows as $row) {
if ($row['user_id'] == '0') {
$name = prepare4display($row['poster_name']);
} else {
$name = api_get_person_name($row['firstname'], $row['lastname']);
}
$username = sprintf(get_lang('LoginX'), $row['username']);
if ($current_forum_category && $current_forum_category['locked'] == 0 && $current_forum['locked'] == 0 && $current_thread['locked'] == 0 || api_is_allowed_to_edit(false, true)) {
if ($_user['user_id'] || $current_forum['allow_anonymous'] == 1 && !$_user['user_id']) {
if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
$buttonReply = Display::tag('a', '<i class="fa fa-reply"></i> ' . get_lang('ReplyToMessage'), array('href' => 'reply.php?' . api_get_cidreq() . "&forum={$clean_forum_id}&thread={$clean_thread_id}&post=" . "{$row['post_id']}&action=replymessage&origin={$origin}", 'class' => 'btn btn-primary'));
$buttonQuote = Display::tag('a', '<i class="fa fa-quote-left"></i> ' . get_lang('QuoteMessage'), array('href' => 'reply.php?' . api_get_cidreq() . "&forum={$clean_forum_id}&thread={$clean_thread_id}" . "&post={$row['post_id']}&action=quote&origin={$origin}", 'class' => 'btn btn-success'));
}
}
} else {
if ($current_forum_category && $current_forum_category['locked'] == 1) {
$closedPost = Display::tag('div', '<i class="fa fa-exclamation-triangle"></i> ' . get_lang('ForumcategoryLocked'), array('class' => 'alert alert-warning post-closed'));
}
示例9: array
$interbreadcrumb[] = array("url" => "#", "name" => get_lang('QualifyThread'));
// the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
Display::display_header('');
api_display_tool_title($nameTools);
} else {
$search = isset($_GET['search']) ? Security::remove_XSS(urlencode($_GET['search'])) : '';
$info_thread = get_thread_information($_GET['thread']);
$interbreadcrumb[] = array("url" => "index.php?" . api_get_cidreq() . "&search=" . $search, "name" => $nameTools);
$interbreadcrumb[] = array("url" => "viewforumcategory.php?forumcategory=" . $currentForumCategory['cat_id'] . "&search=" . $search, "name" => prepare4display($currentForumCategory['cat_title']));
$interbreadcrumb[] = array("url" => "viewforum.php?forum=" . Security::remove_XSS($_GET['forum']) . "&origin=" . $origin . "&search=" . $search, "name" => prepare4display($currentForum['forum_title']));
if ($message != 'PostDeletedSpecial') {
if (isset($_GET['gradebook']) and $_GET['gradebook'] == 'view') {
$info_thread = get_thread_information(Security::remove_XSS($_GET['thread']));
$interbreadcrumb[] = array("url" => "viewthread.php?" . api_get_cidreq() . "&forum=" . $info_thread['forum_id'] . "&thread=" . Security::remove_XSS($_GET['thread']), "name" => prepare4display($currentThread['thread_title']));
} else {
$interbreadcrumb[] = array("url" => "viewthread.php?" . api_get_cidreq() . "&forum=" . Security::remove_XSS($_GET['forum']) . "&thread=" . Security::remove_XSS($_GET['thread']), "name" => prepare4display($currentThread['thread_title']));
}
}
// the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
$interbreadcrumb[] = array("url" => "#", "name" => get_lang('QualifyThread'));
Display::display_header('');
}
}
/*
Actions
*/
$action = isset($_GET['action']) ? $_GET['action'] : '';
if ($action == 'delete' && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_edit(false, true)) {
$message = delete_post($_GET['id']);
}
if (($action == 'invisible' || $action == 'visible') && isset($_GET['id']) && api_is_allowed_to_edit(false, true)) {
示例10: isset
}
}
/* Header and Breadcrumbs */
$my_search = isset($_GET['search']) ? $_GET['search'] : '';
$my_action = isset($_GET['action']) ? $_GET['action'] : '';
if (api_is_in_gradebook()) {
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'gradebook/index.php?' . api_get_cidreq(), 'name' => get_lang('ToolGradebook'));
}
$forumUrl = api_get_path(WEB_CODE_PATH) . 'forum/';
if ($origin == 'group') {
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'group/group.php?' . api_get_cidreq(), 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'group/group_space.php?' . api_get_cidreq(), 'name' => get_lang('GroupSpace') . ' ' . $group_properties['name']);
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Forum') . ' ' . Security::remove_XSS($current_forum['forum_title']));
} else {
$interbreadcrumb[] = array('url' => $forumUrl . 'index.php?search=' . Security::remove_XSS($my_search), 'name' => get_lang('ForumCategories'));
$interbreadcrumb[] = array('url' => $forumUrl . 'viewforumcategory.php?forumcategory=' . $current_forum_category['cat_id'] . '&search=' . Security::remove_XSS(urlencode($my_search)), 'name' => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[] = array('url' => '#', 'name' => Security::remove_XSS($current_forum['forum_title']));
}
if ($origin == 'learnpath') {
Display::display_reduced_header();
} else {
// The last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string.
Display::display_header('');
}
/* Actions */
// Change visibility of a forum or a forum category.
if (($my_action == 'invisible' || $my_action == 'visible') && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_edit(false, true) && api_is_allowed_to_session_edit(false, true)) {
$message = change_visibility($_GET['content'], $_GET['id'], $_GET['action']);
}
// Locking and unlocking.
if (($my_action == 'lock' || $my_action == 'unlock') && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_edit(false, true) && api_is_allowed_to_session_edit(false, true)) {
示例11: array
if (isset($_SESSION['gradebook'])) {
$gradebook = $_SESSION['gradebook'];
}
if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array('url' => '../gradebook/' . $_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
}
if (!empty($_GET['gidReq'])) {
$toolgroup = Database::escape_string($_GET['gidReq']);
Session::write('toolgroup', $toolgroup);
}
if ($origin == 'group') {
$_clean['toolgroup'] = (int) $_SESSION['toolgroup'];
$group_properties = GroupManager::get_group_properties($_clean['toolgroup']);
$interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq=' . $_SESSION['toolgroup'], 'name' => get_lang('GroupSpace') . ' (' . $group_properties['name'] . ')');
$interbreadcrumb[] = array('url' => 'viewforum.php?origin=' . $origin . '&gidReq=' . $_SESSION['toolgroup'] . '&forum=' . Security::remove_XSS($_GET['forum']), 'name' => prepare4display($current_forum['forum_title']));
$interbreadcrumb[] = array('url' => 'forumsearch.php', 'name' => get_lang('ForumSearch'));
} else {
$interbreadcrumb[] = array('url' => 'index.php?gradebook=' . $gradebook . '', 'name' => $nameTools);
//$interbreadcrumb[] = array('url' => 'forumsearch.php', 'name' => );
$nameTools = get_lang('ForumSearch');
}
// Display the header.
if ($origin == 'learnpath') {
Display::display_reduced_header();
} else {
Display::display_header($nameTools);
}
// Display the tool title.
// api_display_tool_title($nameTools);
// Tool introduction
示例12: display_forum_search_results
/**
* Display the search results
* @param string
* @return void display the results
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version march 2008, dokeos 1.8.5
*/
function display_forum_search_results($search_term)
{
global $origin;
$table_categories = Database::get_course_table(TABLE_FORUM_CATEGORY);
$table_forums = Database::get_course_table(TABLE_FORUM);
$table_threads = Database::get_course_table(TABLE_FORUM_THREAD);
$table_posts = Database::get_course_table(TABLE_FORUM_POST);
$gradebook = Security::remove_XSS($_GET['gradebook']);
$course_id = api_get_course_int_id();
// 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)) . "%'\n OR posts.post_text LIKE '%" . Database::escape_string(trim($value)) . "%')";
}
$sql = "SELECT * FROM {$table_posts} posts\n WHERE c_id = {$course_id} AND " . implode(' AND ', $search_restriction) . "\n GROUP BY posts.post_id";
// Getting all the information of the forum categories.
$forum_categories_list = get_forum_categories();
// Getting all the information of the forums.
$forum_list = get_forums();
$result = Database::query($sql);
while ($row = Database::fetch_array($result, 'ASSOC')) {
$display_result = false;
/*
We only show it when
1. forum cateogory is visible
2. forum is visible
3. thread is visible (to do)
4. post is visible
*/
if (!api_is_allowed_to_edit(null, true)) {
if ($forum_categories_list[$row['forum_id']['forum_category']]['visibility'] == '1' and $forum_list[$row['forum_id']]['visibility'] == '1' and $row['visible'] == '1') {
$display_result = true;
}
} else {
$display_result = true;
}
if ($display_result) {
$search_results_item = '<li><a href="viewforumcategory.php?forumcategory=' . $forum_list[$row['forum_id']]['forum_category'] . '&origin=' . $origin . '&search=' . urlencode($search_term) . '">' . prepare4display($forum_categories_list[$row['forum_id']['forum_category']]['cat_title']) . '</a> > ';
$search_results_item .= '<a href="viewforum.php?forum=' . $row['forum_id'] . '&origin=' . $origin . '&search=' . urlencode($search_term) . '">' . prepare4display($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'] . '&gradebook=' . $gradebook . '&origin=' . $origin . '&thread=' . $row['thread_id'] . '&search=' . urlencode($search_term) . '">' . prepare4display($row['post_title']) . '</a>';
$search_results_item .= '<br />';
if (api_strlen($row['post_title']) > 200) {
$search_results_item .= prepare4display(api_substr(strip_tags($row['post_title']), 0, 200)) . '...';
} else {
$search_results_item .= prepare4display($row['post_title']);
}
$search_results_item .= '</li>';
$search_results[] = $search_results_item;
}
}
echo '<legend>' . count($search_results) . ' ' . get_lang('ForumSearchResults') . '</legend>';
echo '<ol>';
if ($search_results) {
echo implode($search_results);
}
echo '</ol>';
}