diff options
author | Marc Alexander <admin@m-a-styles.de> | 2015-10-08 15:09:56 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2015-10-08 15:11:12 +0200 |
commit | c38a128663aada4a6c9a9d4ce4159dc193e00513 (patch) | |
tree | faf9778137c228ac2a4a29b4f874b56c9d311c78 /phpBB/search.php | |
parent | c05a27396d7a93eab1a793b10021cbb19a41cefb (diff) | |
parent | c4bc5f39307103ceba51b3fecbd324df1a771f1d (diff) | |
download | forums-c38a128663aada4a6c9a9d4ce4159dc193e00513.tar forums-c38a128663aada4a6c9a9d4ce4159dc193e00513.tar.gz forums-c38a128663aada4a6c9a9d4ce4159dc193e00513.tar.bz2 forums-c38a128663aada4a6c9a9d4ce4159dc193e00513.tar.xz forums-c38a128663aada4a6c9a9d4ce4159dc193e00513.zip |
Merge pull request #3824 from rxu/ticket/14088
[ticket/14088] Add more core events to the search.php
Diffstat (limited to 'phpBB/search.php')
-rw-r--r-- | phpBB/search.php | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/phpBB/search.php b/phpBB/search.php index d8f0bd1426..c2f2d6de0d 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -483,6 +483,24 @@ if ($keywords || $author || $author_id || $search_id || $submit) } } + /** + * Event to modify data after pre-made searches + * + * @event core.search_modify_param_after + * @var string l_search_title The title of the search page + * @var string search_id Predefined search type name + * @var string show_results Display topics or posts + * @var string sql SQL query corresponding to the pre-made search id + * @since 3.1.7-RC1 + */ + $vars = array( + 'l_search_title', + 'search_id', + 'show_results', + 'sql', + ); + extract($phpbb_dispatcher->trigger_event('core.search_modify_param_after', compact($vars))); + // show_results should not change after this $per_page = ($show_results == 'posts') ? $config['posts_per_page'] : $config['topics_per_page']; $total_match_count = 0; @@ -594,6 +612,20 @@ if ($keywords || $author || $author_id || $search_id || $submit) $u_search .= ($search_fields != 'all') ? '&sf=' . $search_fields : ''; $u_search .= ($return_chars != 300) ? '&ch=' . $return_chars : ''; + /** + * Event to add or modify search URL parameters + * + * @event core.search_modify_url_parameters + * @var string u_search Search URL parameters string + * @var string search_id Predefined search type name + * @since 3.1.7-RC1 + */ + $vars = array( + 'u_search', + 'search_id', + ); + extract($phpbb_dispatcher->trigger_event('core.search_modify_url_parameters', compact($vars))); + if ($sql_where) { if ($show_results == 'posts') @@ -704,6 +736,8 @@ if ($keywords || $author || $author_id || $search_id || $submit) $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); } + $sql_order_by = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); + /** * Event to modify the SQL query before the topic data is retrieved * @@ -712,16 +746,30 @@ if ($keywords || $author || $author_id || $search_id || $submit) * @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 * @var int total_match_count The total number of search matches + * @var array sort_by_sql Array of SQL sorting instructions + * @var string sort_dir The sorting direction + * @var string sort_key The sorting key + * @var string sql_order_by The SQL ORDER BY string used by search to get topic data * @since 3.1.0-a1 * @changed 3.1.0-RC5 Added total_match_count + * @changed 3.1.7-RC1 Added sort_by_sql, sort_dir, sort_key, sql_order_by */ - $vars = array('sql_select', 'sql_from', 'sql_where', 'total_match_count'); + $vars = array( + 'sql_select', + 'sql_from', + 'sql_where', + 'total_match_count', + 'sort_by_sql', + 'sort_dir', + 'sort_key', + 'sql_order_by', + ); extract($phpbb_dispatcher->trigger_event('core.search_get_topic_data', compact($vars))); $sql = "SELECT $sql_select FROM $sql_from - WHERE $sql_where"; - $sql .= ' ORDER BY ' . $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); + WHERE $sql_where + ORDER BY $sql_order_by"; } $result = $db->sql_query($sql); $result_topic_id = 0; |