]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 832095 - Request new buglist/query hooks review/832095/v6 review/8543809/v6
authorAlbert Ting <altlist@gmail.com>
Thu, 8 Jan 2015 17:49:25 +0000 (12:49 -0500)
committerDylan William Hardison <dylan@hardison.net>
Thu, 8 Jan 2015 17:49:25 +0000 (12:49 -0500)
Bugzilla/Hook.pm
buglist.cgi
extensions/Example/Extension.pm
query.cgi

index 430d5af49a6e67afe364e2fbb25e3789ea25219b..40fdff155ed4c3c30aec36f13c8b397c7f5ddca1 100644 (file)
@@ -533,6 +533,33 @@ table should be joined with the C<bugs> table. If omitted, LEFT is used.
 
 =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
 
 This allows you to modify L<Bugzilla::Search/OPERATOR_FIELD_OVERRIDE>,
@@ -1417,6 +1444,45 @@ Params:
 
 =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
 
 This hook allows you to alter the Quicksearch syntax to include e.g. special 
index b03cc9481804b23e3c8867f6abbe17677502c3d8..2d39367ab722a02e63c00c46d9e7c52c69b3a043 100755 (executable)
@@ -25,6 +25,7 @@ use Bugzilla::Product;
 use Bugzilla::Field;
 use Bugzilla::Status;
 use Bugzilla::Token;
+use Bugzilla::Hook;
 
 use Date::Parse;
 
@@ -447,8 +448,8 @@ if (!$params->param('query_format')) {
 # 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;
 # otherwise validates the user's choice against the list of available formats.
-my $format = $template->get_format("list/list", scalar $cgi->param('format'),
-                                   scalar $cgi->param('ctype'));
+my $format = $template->get_format("list/list", scalar $params->param('format'),
+                                   scalar $params->param('ctype'));
 
 # 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
@@ -1124,6 +1125,10 @@ $cgi->close_standby_message($contenttype, $disposition, $disp_prefix, $format->{
 # Content Generation
 ################################################################################
 
+Bugzilla::Hook::process("buglist_format", {'vars' => $vars,
+                                           'format' => $format,
+                                           'params' => $params});
+
 # Generate and return the UI (HTML page) from the appropriate template.
 $template->process($format->{'template'}, $vars)
   || ThrowTemplateError($template->error());
index af36b107af6a224e4b31c45b6cf8e9bd2eca4ec4..0ab5220a77e983dd316cd7b10788b91bb91f9bd8 100644 (file)
@@ -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 {
     my ($self, $args) = @_;
     
@@ -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 {
     my ($self, $args) = @_;
     my $map = $args->{'map'};
index faf670d231c8ecbf29bffa6c934389b044964fae..d98bb09795fdd984434c81360fdbdebe40da58b4 100755 (executable)
--- a/query.cgi
+++ b/query.cgi
@@ -301,6 +301,8 @@ my $format = $template->get_format("search/search",
                                    $vars->{'query_format'} || $vars->{'format'}, 
                                    scalar $cgi->param('ctype'));
 
+Bugzilla::Hook::process("query_format", {'vars' => $vars, 'format' => $format});
+
 print $cgi->header($format->{'ctype'});
 
 $template->process($format->{'template'}, $vars)