diff options
author | stevendegroote <stevendegroote@gmail.com> | 2019-09-17 23:15:54 +0200 |
---|---|---|
committer | stevendegroote <stevendegroote@gmail.com> | 2019-09-17 23:15:54 +0200 |
commit | f8967fec78d826ea8d9ca34f65966ff8a7674b47 (patch) | |
tree | f9c5f408e7764ec6343e084e7fc6d62d07e3400f /phpBB/search.php | |
parent | ce93b224107a65b43253c36812b636321eb55a78 (diff) | |
parent | 4db585a4cb2e5359074a82ef088574609155294b (diff) | |
download | forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar.gz forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar.bz2 forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.tar.xz forums-f8967fec78d826ea8d9ca34f65966ff8a7674b47.zip |
Merge branch '3.2.x' into ticket/16159
Diffstat (limited to 'phpBB/search.php')
-rw-r--r-- | phpBB/search.php | 60 |
1 files changed, 40 insertions, 20 deletions
diff --git a/phpBB/search.php b/phpBB/search.php index f3988d7d04..791e5cc448 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -198,7 +198,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $sql_author_match = (strpos($author, '*') !== false) ? ' ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " = '" . $db->sql_escape(utf8_clean_string($author)) . "'"; } - if (!sizeof($author_id_ary)) + if (!count($author_id_ary)) { trigger_error('NO_SEARCH_RESULTS'); } @@ -220,7 +220,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) } // Which forums should not be searched? Author searches are also carried out in unindexed forums - if (empty($keywords) && sizeof($author_id_ary)) + if (empty($keywords) && count($author_id_ary)) { $ex_fid_ary = array_keys($auth->acl_getf('!f_read', true)); } @@ -229,7 +229,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true)))); } - $not_in_fid = (sizeof($ex_fid_ary)) ? 'WHERE ' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . " OR (f.forum_password <> '' AND fa.user_id <> " . (int) $user->data['user_id'] . ')' : ""; + $not_in_fid = (count($ex_fid_ary)) ? 'WHERE ' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . " OR (f.forum_password <> '' AND fa.user_id <> " . (int) $user->data['user_id'] . ')' : ""; $sql = 'SELECT f.forum_id, f.forum_name, f.parent_id, f.forum_type, f.right_id, f.forum_password, f.forum_flags, fa.user_id FROM ' . FORUMS_TABLE . ' f @@ -256,7 +256,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) continue; } - if (sizeof($search_forum)) + if (count($search_forum)) { if ($search_child) { @@ -309,9 +309,9 @@ if ($keywords || $author || $author_id || $search_id || $submit) { $correct_query = $search->split_keywords($keywords, $search_terms); $common_words = $search->get_common_words(); - if (!$correct_query || (!$search->get_search_query() && !sizeof($author_id_ary) && !$search_id)) + if (!$correct_query || (!$search->get_search_query() && !count($author_id_ary) && !$search_id)) { - $ignored = (sizeof($common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $common_words)) . '<br />' : ''; + $ignored = (count($common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $common_words)) . '<br />' : ''; $word_length = $search->get_word_length(); if ($word_length) { @@ -324,7 +324,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) } } - if (!$keywords && sizeof($author_id_ary)) + if (!$keywords && count($author_id_ary)) { // if it is an author search we want to show topics by default $show_results = ($topic_id) ? 'posts' : $request->variable('sr', ($search_id == 'egosearch') ? 'topics' : 'posts'); @@ -384,7 +384,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) WHERE t.topic_moved_id = 0 $last_post_time_sql AND " . $m_approve_topics_fid_sql . ' - ' . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . ' + ' . ((count($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'; break; @@ -422,7 +422,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) AND p.topic_id = t.topic_id $last_post_time AND $m_approve_posts_fid_sql - " . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " + " . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " $sql_sort"; $field = 'post_id'; } @@ -435,7 +435,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) AND p.topic_id = t.topic_id $last_post_time AND $m_approve_topics_fid_sql - " . ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " + " . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " $sql_sort"; $field = 'topic_id'; } @@ -451,7 +451,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $sql_where = 'AND t.topic_moved_id = 0 AND ' . $m_approve_topics_fid_sql . ' - ' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : ''); + ' . ((count($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); $s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = ''; @@ -477,7 +477,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) FROM ' . POSTS_TABLE . ' p 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) : '') . " + ' . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . " $sql_sort"; $field = 'post_id'; } @@ -488,7 +488,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . ' AND t.topic_moved_id = 0 AND ' . $m_approve_topics_fid_sql . ' - ' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . " + ' . ((count($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . " $sql_sort"; /* [Fix] queued replies missing from "view new posts" (Bug #42705 - Patch by Paul) @@ -562,7 +562,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $search_id = ''; } - $total_match_count = sizeof($id_ary); + $total_match_count = count($id_ary); if ($total_match_count) { // Limit the number to $total_matches_limit for pre-made searches @@ -592,7 +592,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) { $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)) + else if (count($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_posts_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); @@ -642,10 +642,10 @@ if ($keywords || $author || $author_id || $search_id || $submit) $sql_where = ''; - if (sizeof($id_ary)) + if (count($id_ary)) { $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 .= (count($ex_fid_ary)) ? ' AND (' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . ' OR f.forum_id IS NULL)' : ''; $sql_where .= ' AND ' . (($show_results == 'posts') ? $m_approve_posts_fid_sql : $m_approve_topics_fid_sql); } @@ -883,7 +883,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $db->sql_freeresult($result); // If we have some shadow topics, update the rowset to reflect their topic information - if (sizeof($shadow_topic_list)) + if (count($shadow_topic_list)) { $sql = 'SELECT * FROM ' . TOPICS_TABLE . ' @@ -932,6 +932,26 @@ if ($keywords || $author || $author_id || $search_id || $submit) while ($row = $db->sql_fetchrow($result)) { + /** + * Modify the row of a post result before the post_text is trimmed + * + * @event core.search_modify_post_row + * @var string hilit String to highlight + * @var array row Array with the post data + * @var string u_hilit Highlight string to be injected into URL + * @var string view Search results view mode + * @var array zebra Array with zebra data for the current user + * @since 3.2.2-RC1 + */ + $vars = array( + 'hilit', + 'row', + 'u_hilit', + 'view', + 'zebra', + ); + extract($phpbb_dispatcher->trigger_event('core.search_modify_post_row', compact($vars))); + // We pre-process some variables here for later usage $row['post_text'] = censor_text($row['post_text']); @@ -967,7 +987,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) unset($text_only_message); // Pull attachment data - if (sizeof($attach_list)) + if (count($attach_list)) { $use_attach_list = $attach_list; $attach_list = array(); @@ -981,7 +1001,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) } } - if (sizeof($attach_list)) + if (count($attach_list)) { $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' |