From 1332b762e69c8eeb037050dfdaf15b4fc08b4400 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Tue, 9 Aug 2016 16:01:13 +0200 Subject: [PATCH] Allow custom prefix for Browser Search entries Prior to this, the prefix for OpenSearch entries generated by browser_search_plugin.php was hardcoded to 'MantisBT'. This defines a new '$g_search_title' config option (which defaults to the value of $g_window_title) to be used as prefix, allowing - administrators to customize the name of their browser search entries - users to have distinct search engines for multiple MantisBT instances $g_search_title should be shorter than 8 chars to be compliant with the maximum size of 16 chars for the ShortName element as per OpenSearch specification [1] Fixes #11964 [1] http://www.opensearch.org/Specifications/OpenSearch/1.1 --- browser_search_plugin.php | 9 +++++---- config_defaults_inc.php | 12 ++++++++++++ docbook/Admin_Guide/en-US/config/display.xml | 18 ++++++++++++++++-- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/browser_search_plugin.php b/browser_search_plugin.php index 5303184d3c..2ed9fa3435 100644 --- a/browser_search_plugin.php +++ b/browser_search_plugin.php @@ -37,16 +37,17 @@ $f_type = gpc_get_string( 'type', 'text' ); $t_path = config_get_global( 'path' ); +$t_title = config_get_global( 'search_title' ); $t_icon = $t_path . config_get_global( 'favicon_image' ); $t_searchform = $t_path . 'view_all_bug_page.php'; if( strtolower( $f_type ) == 'id' ) { - $t_shortname = 'MantisBT IssueId'; - $t_description = 'MantisBT Issue Id Search'; + $t_shortname = $t_title . ' IssueId'; + $t_description = $t_title .' Issue Id Search'; $t_url = $t_path . 'view.php?id={searchTerms}'; } else { - $t_shortname = 'MantisBT Search'; - $t_description = 'MantisBT Text Search'; + $t_shortname = $t_title . ' Search'; + $t_description = $t_title . ' Text Search'; $t_url = $t_path . 'view_all_set.php?type=1&temporary=y&handler_id=[all]&search={searchTerms}'; } diff --git a/config_defaults_inc.php b/config_defaults_inc.php index eba27226db..589ceb3950 100644 --- a/config_defaults_inc.php +++ b/config_defaults_inc.php @@ -850,6 +850,18 @@ */ $g_window_title = 'MantisBT'; +/** + * OpenSearch ShortName prefix. + * This is used to describe Browser Search entries, and must be 8 chars or + * less to be compliant with the OpenSearch specification (since we append up to + * 8 chars to differentiate text- and id-based searches, and the maximum length + * of the ShortName element is 16 chars). + * @link http://www.opensearch.org/Specifications/OpenSearch/1.1 + * @see $g_window_title + * @global string $g_search_title + */ +$g_search_title = '%window_title%'; + /** * Check for admin directory, database upgrades, etc. * @global integer $g_admin_checks diff --git a/docbook/Admin_Guide/en-US/config/display.xml b/docbook/Admin_Guide/en-US/config/display.xml index 842921c256..2a9744674a 100644 --- a/docbook/Admin_Guide/en-US/config/display.xml +++ b/docbook/Admin_Guide/en-US/config/display.xml @@ -9,11 +9,25 @@ $g_window_title - This is the browser window title (<TITLE> - tag). + This is the browser window title (<TITLE> tag). + + $g_search_title + + This is used as prefix for Browser Search entries, + and must be 8 chars or less to be compliant with the + + OpenSearch specification + + (since we append up to 8 chars to differentiate text- and + id-based searches, and the maximum length of the + ShortName element is 16 chars). + + Defaults to the value of $g_window_title. + + $g_favicon_image