Skip to content

Commit

Permalink
Allow custom prefix for Browser Search entries
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dregad committed Aug 9, 2016
1 parent 9a587dd commit 1332b76
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
9 changes: 5 additions & 4 deletions browser_search_plugin.php
Expand Up @@ -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}';
}

Expand Down
12 changes: 12 additions & 0 deletions config_defaults_inc.php
Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions docbook/Admin_Guide/en-US/config/display.xml
Expand Up @@ -9,11 +9,25 @@
<varlistentry>
<term>$g_window_title</term>
<listitem>
<para>This is the browser window title (&lt;TITLE&gt;
tag).
<para>This is the browser window title (&lt;TITLE&gt; tag).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$g_search_title</term>
<listitem>
<para>This is used as prefix for Browser Search entries,
and must be 8 chars or less to be compliant with the
<ulink url="http://www.opensearch.org/Specifications/OpenSearch/1.1">
OpenSearch specification
</ulink>
(since we append up to 8 chars to differentiate text- and
id-based searches, and the maximum length of the
<emphasis>ShortName </emphasis> element is 16 chars).
</para>
<para>Defaults to the value of $g_window_title.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$g_favicon_image</term>
<listitem>
Expand Down

0 comments on commit 1332b76

Please sign in to comment.