diff options
Diffstat (limited to 'phpBB/search.php')
-rw-r--r-- | phpBB/search.php | 209 |
1 files changed, 103 insertions, 106 deletions
diff --git a/phpBB/search.php b/phpBB/search.php index ad9c371f63..ae573b18e8 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -2,9 +2,8 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -73,7 +72,7 @@ switch ($search_id) login_box('', $user->lang['LOGIN_EXPLAIN_UNREADSEARCH']); } break; - + // The "new posts" search uses user_lastvisit which is user based, so it should require user to log in. case 'newposts': if ($user->data['user_id'] == ANONYMOUS) @@ -81,7 +80,7 @@ switch ($search_id) login_box('', $user->lang['LOGIN_EXPLAIN_NEWPOSTS']); } break; - + default: // There's nothing to do here for now ;) break; @@ -120,6 +119,8 @@ $sort_by_text = array('a' => $user->lang['SORT_AUTHOR'], 't' => $user->lang['SOR $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); +$phpbb_content_visibility = $phpbb_container->get('content.visibility'); + if ($keywords || $author || $author_id || $search_id || $submit) { // clear arrays @@ -136,7 +137,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) { if ((strpos($author, '*') !== false) && (utf8_strlen(str_replace(array('*', '%'), '', $author)) < $config['min_search_author_chars'])) { - trigger_error(sprintf($user->lang['TOO_FEW_AUTHOR_CHARS'], $config['min_search_author_chars'])); + trigger_error($user->lang('TOO_FEW_AUTHOR_CHARS', (int) $config['min_search_author_chars'])); } $sql_where = (strpos($author, '*') !== false) ? ' username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " username_clean = '" . $db->sql_escape(utf8_clean_string($author)) . "'"; @@ -250,22 +251,9 @@ if ($keywords || $author || $author_id || $search_id || $submit) } $db->sql_freeresult($result); - // find out in which forums the user is allowed to view approved posts - if ($auth->acl_get('m_approve')) - { - $m_approve_fid_ary = array(-1); - $m_approve_fid_sql = ''; - } - else if ($auth->acl_getf_global('m_approve')) - { - $m_approve_fid_ary = array_diff(array_keys($auth->acl_getf('!m_approve', true)), $ex_fid_ary); - $m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')'; - } - else - { - $m_approve_fid_ary = array(); - $m_approve_fid_sql = ' AND p.post_approved = 1'; - } + // find out in which forums the user is allowed to view posts + $m_approve_posts_fid_sql = $phpbb_content_visibility->get_global_visibility_sql('post', $ex_fid_ary, 'p.'); + $m_approve_topics_fid_sql = $phpbb_content_visibility->get_global_visibility_sql('topic', $ex_fid_ary, 't.'); if ($reset_search_forum) { @@ -273,32 +261,39 @@ if ($keywords || $author || $author_id || $search_id || $submit) } // Select which method we'll use to obtain the post_id or topic_id information - $search_type = basename($config['search_type']); + $search_type = $config['search_type']; - if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) + if (!class_exists($search_type)) { trigger_error('NO_SUCH_SEARCH_MODULE'); } - - require("{$phpbb_root_path}includes/search/$search_type.$phpEx"); - // We do some additional checks in the module to ensure it can actually be utilised $error = false; - $search = new $search_type($error); + $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); if ($error) { trigger_error($error); } + $common_words = $search->get_common_words(); + // let the search module split up the keywords if ($keywords) { $correct_query = $search->split_keywords($keywords, $search_terms); - if (!$correct_query || (empty($search->search_query) && !sizeof($author_id_ary) && !$search_id)) + if (!$correct_query || (!$search->get_search_query() && !sizeof($author_id_ary) && !$search_id)) { - $ignored = (sizeof($search->common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $search->common_words)) . '<br />' : ''; - trigger_error($ignored . sprintf($user->lang['NO_KEYWORDS'], $search->word_length['min'], $search->word_length['max'])); + $ignored = (sizeof($common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $common_words)) . '<br />' : ''; + $word_length = $search->get_word_length(); + if ($word_length) + { + trigger_error($ignored . $user->lang('NO_KEYWORDS', $user->lang('CHARACTERS', (int) $word_length['min']), $user->lang('CHARACTERS', (int) $word_length['max']))); + } + else + { + trigger_error($ignored); + } } } @@ -336,7 +331,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) FROM ' . TOPICS_TABLE . " t WHERE t.topic_moved_id = 0 $last_post_time_sql - " . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . ' + AND " . $m_approve_topics_fid_sql . ' ' . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . ' ORDER BY t.topic_last_post_time DESC'; $field = 'topic_id'; @@ -371,10 +366,10 @@ if ($keywords || $author || $author_id || $search_id || $submit) { $sql = "SELECT p.post_id FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t - WHERE t.topic_replies = 0 + WHERE t.topic_posts_approved = 1 AND p.topic_id = t.topic_id $last_post_time - $m_approve_fid_sql + AND $m_approve_posts_fid_sql " . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " $sql_sort"; $field = 'post_id'; @@ -383,11 +378,11 @@ if ($keywords || $author || $author_id || $search_id || $submit) { $sql = 'SELECT DISTINCT ' . $sort_by_sql[$sort_key] . ", p.topic_id FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t - WHERE t.topic_replies = 0 + WHERE t.topic_posts_approved = 1 AND t.topic_moved_id = 0 AND p.topic_id = t.topic_id $last_post_time - $m_approve_fid_sql + AND $m_approve_topics_fid_sql " . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " $sql_sort"; $field = 'topic_id'; @@ -403,7 +398,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC'); $sql_where = 'AND t.topic_moved_id = 0 - ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . ' + AND ' . $m_approve_topics_fid_sql . ' ' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : ''); gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); @@ -426,9 +421,9 @@ if ($keywords || $author || $author_id || $search_id || $submit) { $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p - WHERE p.post_time > ' . $user->data['user_lastvisit'] . " - $m_approve_fid_sql - " . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " + WHERE p.post_time > ' . $user->data['user_lastvisit'] . ' + AND ' . $m_approve_posts_fid_sql . ' + ' . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " $sql_sort"; $field = 'post_id'; } @@ -438,7 +433,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) FROM ' . TOPICS_TABLE . ' t WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . ' AND t.topic_moved_id = 0 - ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . ' + AND ' . $m_approve_topics_fid_sql . ' ' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . " $sql_sort"; /* @@ -450,8 +445,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) WHERE p.post_time > ' . $user->data['user_lastvisit'] . ' AND t.topic_id = p.topic_id AND t.topic_moved_id = 0 - ' . $m_approve_fid_sql . ' - ' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . " + AND ' . $m_approve_topics_fid_sql . " GROUP BY t.topic_id $sql_sort"; */ @@ -527,17 +521,16 @@ if ($keywords || $author || $author_id || $search_id || $submit) // make sure that some arrays are always in the same order sort($ex_fid_ary); - sort($m_approve_fid_ary); sort($author_id_ary); - if (!empty($search->search_query)) + if ($search->get_search_query()) { - $total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); + $total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_posts_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); } else if (sizeof($author_id_ary)) { $firstpost_only = ($search_fields === 'firstpost' || $search_fields == 'titleonly') ? true : false; - $total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); + $total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_posts_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); } // For some searches we need to print out the "no results" page directly to allow re-sorting/refining the search options. @@ -552,7 +545,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) { $sql_where .= $db->sql_in_set(($show_results == 'posts') ? 'p.post_id' : 't.topic_id', $id_ary); $sql_where .= (sizeof($ex_fid_ary)) ? ' AND (' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . ' OR f.forum_id IS NULL)' : ''; - $sql_where .= ($show_results == 'posts') ? $m_approve_fid_sql : str_replace(array('p.post_approved', 'p.forum_id'), array('t.topic_approved', 't.forum_id'), $m_approve_fid_sql); + $sql_where .= ' AND ' . (($show_results == 'posts') ? $m_approve_posts_fid_sql : $m_approve_topics_fid_sql); } if ($show_results == 'posts') @@ -572,11 +565,11 @@ if ($keywords || $author || $author_id || $search_id || $submit) // Output header if ($found_more_search_matches) { - $l_search_matches = sprintf($user->lang['FOUND_MORE_SEARCH_MATCHES'], $total_match_count); + $l_search_matches = $user->lang('FOUND_MORE_SEARCH_MATCHES', (int) $total_match_count); } else { - $l_search_matches = ($total_match_count == 1) ? sprintf($user->lang['FOUND_SEARCH_MATCH'], $total_match_count) : sprintf($user->lang['FOUND_SEARCH_MATCHES'], $total_match_count); + $l_search_matches = $user->lang('FOUND_SEARCH_MATCHES', (int) $total_match_count); } // define some vars for urls @@ -600,14 +593,25 @@ if ($keywords || $author || $author_id || $search_id || $submit) $u_search .= ($search_fields != 'all') ? '&sf=' . $search_fields : ''; $u_search .= ($return_chars != 300) ? '&ch=' . $return_chars : ''; + // Check if search backend supports phrase search or not + $phrase_search_disabled = ''; + if (strpos(html_entity_decode($keywords), '"') !== false && method_exists($search, 'supports_phrase_search')) + { + $phrase_search_disabled = $search->supports_phrase_search() ? false : true; + } + + phpbb_generate_template_pagination($template, $u_search, 'pagination', 'start', $total_match_count, $per_page, $start); + $template->assign_vars(array( 'SEARCH_TITLE' => $l_search_title, 'SEARCH_MATCHES' => $l_search_matches, 'SEARCH_WORDS' => $keywords, - 'SEARCHED_QUERY' => $search->search_query, - 'IGNORED_WORDS' => (sizeof($search->common_words)) ? implode(' ', $search->common_words) : '', - 'PAGINATION' => generate_pagination($u_search, $total_match_count, $per_page, $start), - 'PAGE_NUMBER' => on_page($total_match_count, $per_page, $start), + 'SEARCHED_QUERY' => $search->get_search_query(), + 'IGNORED_WORDS' => (sizeof($common_words)) ? implode(' ', $common_words) : '', + 'PAGE_NUMBER' => phpbb_on_page($template, $user, $u_search, $total_match_count, $per_page, $start), + + 'PHRASE_SEARCH_DISABLED' => $phrase_search_disabled, + 'TOTAL_MATCHES' => $total_match_count, 'SEARCH_IN_RESULTS' => ($search_id) ? false : true, @@ -621,6 +625,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), + 'DELETED_IMG' => $user->img('icon_topic_deleted', 'TOPIC_DELETED'), 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'U_SEARCH_WORDS' => $u_search, @@ -678,10 +683,22 @@ if ($keywords || $author || $author_id || $search_id || $submit) if ($config['load_anon_lastread'] || ($user->data['is_registered'] && !$config['load_db_lastread'])) { - $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? ((STRIP) ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track']) : ''; + $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); } + /** + * Event to modify the SQL query before the topic data is retrieved + * + * @event core.search_get_topic_data + * @var string sql_select The SQL SELECT string used by search to get topic data + * @var string sql_from The SQL FROM string used by search to get topic data + * @var string sql_where The SQL WHERE string used by search to get topic data + * @since 3.1-A1 + */ + $vars = array('sql_select', 'sql_from', 'sql_where'); + extract($phpbb_dispatcher->trigger_event('core.search_get_topic_data', compact($vars))); + $sql = "SELECT $sql_select FROM $sql_from WHERE $sql_where"; @@ -745,11 +762,11 @@ if ($keywords || $author || $author_id || $search_id || $submit) { if ($user->data['is_registered'] && $config['load_db_lastread']) { - $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time']), ($forum_id) ? false : $forum['topic_list']); + $topic_tracking_info[$forum_id] = get_topic_tracking($forum_id, $forum['topic_list'], $forum['rowset'], array($forum_id => $forum['mark_time'])); } else if ($config['load_anon_lastread'] || $user->data['is_registered']) { - $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list'], ($forum_id) ? false : $forum['topic_list']); + $topic_tracking_info[$forum_id] = get_complete_topic_tracking($forum_id, $forum['topic_list']); if (!$user->data['is_registered']) { @@ -857,40 +874,11 @@ if ($keywords || $author || $author_id || $search_id || $submit) $forum_id = $row['forum_id']; $result_topic_id = $row['topic_id']; $topic_title = censor_text($row['topic_title']); + $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1; - // we need to select a forum id for this global topic - if (!$forum_id) - { - if (!isset($g_forum_id)) - { - // Get a list of forums the user cannot read - $forum_ary = array_unique(array_keys($auth->acl_getf('!f_read', true))); - - // Determine first forum the user is able to read (must not be a category) - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type = ' . FORUM_POST; - - if (sizeof($forum_ary)) - { - $sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true); - } - - $result = $db->sql_query_limit($sql, 1); - $g_forum_id = (int) $db->sql_fetchfield('forum_id'); - } - $u_forum_id = $g_forum_id; - } - else - { - $u_forum_id = $forum_id; - } - - $view_topic_url_params = "f=$u_forum_id&t=$result_topic_id" . (($u_hilit) ? "&hilit=$u_hilit" : ''); + $view_topic_url_params = "f=$forum_id&t=$result_topic_id" . (($u_hilit) ? "&hilit=$u_hilit" : ''); $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); - $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies']; - if ($show_results == 'topics') { if ($config['load_db_track'] && $author_id === $user->data['user_id']) @@ -903,9 +891,11 @@ if ($keywords || $author || $author_id || $search_id || $submit) $unread_topic = (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']]) ? true : false; - $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; - $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; + $topic_unapproved = ($row['topic_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $forum_id)) ? true : false; + $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; + $topic_deleted = $row['topic_visibility'] == ITEM_DELETED; $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$result_topic_id", true, $user->session_id) : ''; + $u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&mode=deleted_topics&t=$result_topic_id", true, $user->session_id) : ''; $row['topic_title'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">$1</span>', $row['topic_title']); @@ -921,14 +911,11 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), - 'PAGINATION' => topic_generate_pagination($replies, $view_topic_url), 'TOPIC_TYPE' => $topic_type, + 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt), - 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'), 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt], - 'TOPIC_FOLDER_IMG_WIDTH'=> $user->img($folder_img, '', false, '', 'width'), - 'TOPIC_FOLDER_IMG_HEIGHT' => $user->img($folder_img, '', false, '', 'height'), 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', @@ -936,7 +923,6 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', - 'S_TOPIC_GLOBAL' => (!$forum_id) ? true : false, 'S_TOPIC_TYPE' => $row['topic_type'], 'S_USER_POSTED' => (!empty($row['topic_posted'])) ? true : false, 'S_UNREAD_TOPIC' => $unread_topic, @@ -944,6 +930,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $forum_id)) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, + 'S_TOPIC_DELETED' => $topic_deleted, 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), @@ -977,14 +964,8 @@ if ($keywords || $author || $author_id || $search_id || $submit) } else { - // Second parse bbcode here - if ($row['bbcode_bitfield']) - { - $bbcode->bbcode_second_pass($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield']); - } - - $row['post_text'] = bbcode_nl2br($row['post_text']); - $row['post_text'] = smiley_text($row['post_text']); + $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $row['post_text'] = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); if (!empty($attachments[$row['post_id']])) { @@ -1014,7 +995,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) ); } - $template->assign_block_vars('searchresults', array_merge($tpl_ary, array( + $tpl_ary = array_merge($tpl_ary, array( 'FORUM_ID' => $forum_id, 'TOPIC_ID' => $result_topic_id, 'POST_ID' => ($show_results == 'posts') ? $row['post_id'] : false, @@ -1026,8 +1007,26 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'U_VIEW_TOPIC' => $view_topic_url, 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id), - 'U_VIEW_POST' => (!empty($row['post_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . (($u_hilit) ? '&hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '') + 'U_VIEW_POST' => (!empty($row['post_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . (($u_hilit) ? '&hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '', )); + + /** + * Modify the topic data before it is assigned to the template + * + * @event core.search_modify_tpl_ary + * @var array row Array with topic data + * @var array tpl_ary Template block array with topic data + * @since 3.1-A1 + */ + $vars = array('row', 'tpl_ary'); + extract($phpbb_dispatcher->trigger_event('core.search_modify_tpl_ary', compact($vars))); + + $template->assign_block_vars('searchresults', $tpl_ary); + + if ($show_results == 'topics') + { + phpbb_generate_template_pagination($template, $view_topic_url, 'searchresults.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true); + } } if ($topic_id && ($topic_id == $result_topic_id)) @@ -1236,5 +1235,3 @@ $template->set_filenames(array( make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); page_footer(); - -?>
\ No newline at end of file |