Commit 8762d1e6 authored by Albert Ting's avatar Albert Ting Committed by Dylan William Hardison

Bug 832095 - Request new buglist/query hooks

parent cde1c585
...@@ -533,6 +533,33 @@ table should be joined with the C<bugs> table. If omitted, LEFT is used. ...@@ -533,6 +533,33 @@ table should be joined with the C<bugs> table. If omitted, LEFT is used.
=back =back
=head2 buglist_format
This happens in F<buglist.cgi>, used to change the template variables before
processing the associated template hook.
Params:
=over
=item C<vars>
This is the entire set of variables that the current template
can see.
=item C<file>
The name of the template file being processed. This is
relative to the main template directory for the language (i.e. for
F<template/en/default/list/list.html.tmpl>, this variable will contain
C<list/list.html.tmpl>).
=item C<params>
A hashref. The set of named parameters extracted from cgi.
=back
=head2 search_operator_field_override =head2 search_operator_field_override
This allows you to modify L<Bugzilla::Search/OPERATOR_FIELD_OVERRIDE>, This allows you to modify L<Bugzilla::Search/OPERATOR_FIELD_OVERRIDE>,
...@@ -1417,6 +1444,45 @@ Params: ...@@ -1417,6 +1444,45 @@ Params:
=back =back
=head2 query_default_list
This happens in F<query.cgi>, used to include additional cgi params to be
searched for in order to create the set of default values.
Params:
=over
=item C<list>
The current list of cgi params to search for.
=back
=head2 query_format
This happens in F<query.cgi>, used to to add/modify $vars before
processing the template. For example, one could supply or modify the
default values for a custom query format.
Params:
=over
=item C<vars>
This is the entire set of variables that the current template
can see.
=item C<file>
The name of the template file being processed. This is
relative to the main template directory for the language (i.e. for
F<template/en/default/list/list.html.tmpl>, this variable will contain
C<list/list.html.tmpl>).
=back
=head2 quicksearch_map =head2 quicksearch_map
This hook allows you to alter the Quicksearch syntax to include e.g. special This hook allows you to alter the Quicksearch syntax to include e.g. special
......
...@@ -25,6 +25,7 @@ use Bugzilla::Product; ...@@ -25,6 +25,7 @@ use Bugzilla::Product;
use Bugzilla::Field; use Bugzilla::Field;
use Bugzilla::Status; use Bugzilla::Status;
use Bugzilla::Token; use Bugzilla::Token;
use Bugzilla::Hook;
use Date::Parse; use Date::Parse;
...@@ -447,8 +448,8 @@ if (!$params->param('query_format')) { ...@@ -447,8 +448,8 @@ if (!$params->param('query_format')) {
# Determine the format in which the user would like to receive the output. # Determine the format in which the user would like to receive the output.
# Uses the default format if the user did not specify an output format; # Uses the default format if the user did not specify an output format;
# otherwise validates the user's choice against the list of available formats. # otherwise validates the user's choice against the list of available formats.
my $format = $template->get_format("list/list", scalar $cgi->param('format'), my $format = $template->get_format("list/list", scalar $params->param('format'),
scalar $cgi->param('ctype')); scalar $params->param('ctype'));
# Use server push to display a "Please wait..." message for the user while # Use server push to display a "Please wait..." message for the user while
# executing their query if their browser supports it and they are viewing # executing their query if their browser supports it and they are viewing
...@@ -1124,6 +1125,10 @@ $cgi->close_standby_message($contenttype, $disposition, $disp_prefix, $format->{ ...@@ -1124,6 +1125,10 @@ $cgi->close_standby_message($contenttype, $disposition, $disp_prefix, $format->{
# Content Generation # Content Generation
################################################################################ ################################################################################
Bugzilla::Hook::process("buglist_format", {'vars' => $vars,
'format' => $format,
'params' => $params});
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process($format->{'template'}, $vars) $template->process($format->{'template'}, $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
......
...@@ -304,6 +304,17 @@ sub buglist_column_joins { ...@@ -304,6 +304,17 @@ sub buglist_column_joins {
}; };
} }
sub buglist_format {
my ($self, $args) = @_;
my $vars = $args->{'vars'};
my $format = $args->{'format'};
my $params = $args->{'params'};
if ($format->{'template'} eq "list/list-example.html.tmpl") {
$vars->{'example'} = $params->param('example');
}
}
sub search_operator_field_override { sub search_operator_field_override {
my ($self, $args) = @_; my ($self, $args) = @_;
...@@ -856,6 +867,18 @@ sub product_end_of_create { ...@@ -856,6 +867,18 @@ sub product_end_of_create {
} }
} }
sub query_format {
my ($self, $args) = @_;
my $vars = $args->{'vars'};
my $default = $vars->{'default'};
my $format = $args->{'format'};
# change some default values
if ($format->{'template'} eq "search/search-example.html.tmpl") {
$default->{'example'}[0] = $default->{'example'}[0] || "example";
}
}
sub quicksearch_map { sub quicksearch_map {
my ($self, $args) = @_; my ($self, $args) = @_;
my $map = $args->{'map'}; my $map = $args->{'map'};
......
...@@ -301,6 +301,8 @@ my $format = $template->get_format("search/search", ...@@ -301,6 +301,8 @@ my $format = $template->get_format("search/search",
$vars->{'query_format'} || $vars->{'format'}, $vars->{'query_format'} || $vars->{'format'},
scalar $cgi->param('ctype')); scalar $cgi->param('ctype'));
Bugzilla::Hook::process("query_format", {'vars' => $vars, 'format' => $format});
print $cgi->header($format->{'ctype'}); print $cgi->header($format->{'ctype'});
$template->process($format->{'template'}, $vars) $template->process($format->{'template'}, $vars)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment