]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 318205: the path to the hook is incorrect when called from inside a block
authormkanat%bugzilla.org <>
Thu, 29 May 2008 03:46:28 +0000 (03:46 +0000)
committermkanat%bugzilla.org <>
Thu, 29 May 2008 03:46:28 +0000 (03:46 +0000)
Patch By Elliotte Martin <elliotte_martin@yahoo.com> r=mkanat, a=mkanat

Bugzilla/Template/Plugin/Hook.pm

index 4e3bf5cefcf72851c22b8f0ab06b3f92c857ceb4..05a1fdfd1beb54ca844ec17bdf0e873075147fad 100644 (file)
@@ -19,6 +19,7 @@
 #
 # Contributor(s): Myk Melez <myk@mozilla.org>
 #                 Zach Lipton <zach@zachlipton.com>
+#                 Elliotte Martin <everythingsolved.com>
 #
 
 package Bugzilla::Template::Plugin::Hook;
@@ -45,12 +46,11 @@ sub new {
 }
 
 sub process {
-    my ($self, $hook_name) = @_;
+    my ($self, $hook_name, $template) = @_;
+    $template ||= $self->{_CONTEXT}->stash->{component}->{name};
+
+    my @hooks;
 
-    my $paths = $self->{_CONTEXT}->{LOAD_TEMPLATES}->[0]->paths;
-    my $template = $self->{_CONTEXT}->stash->{component}->{name};
-    my @hooks = ();
-    
     # sanity check:
     if (!$template =~ /[\w\.\/\-_\\]+/) {
         ThrowCodeError('template_invalid', { name => $template});
@@ -79,6 +79,8 @@ sub process {
             }
         }
     }
+
+    my $paths = $self->{_CONTEXT}->{LOAD_TEMPLATES}->[0]->paths;
     
     # we keep this too since you can still put hook templates in 
     # template/en/custom/hook
@@ -116,9 +118,54 @@ Bugzilla::Template::Plugin::Hook
 
 Template Toolkit plugin to process hooks added into templates by extensions.
 
+=head1 METHODS
+
+=over
+
+=item B<process>
+
+=over
+
+=item B<Description>
+
+Processes hooks added into templates by extensions.
+
+=item B<Params>
+
+=over
+
+=item C<hook_name>
+
+The unique name of the template hook.
+
+=item C<template> (optional)
+
+The path of the calling template.
+This is used as a work around to a bug which causes the path to the hook
+to be incorrect when the hook is called from inside a block.
+
+Example: If the hook C<lastrow> is added to the template
+F<show-multiple.html.tmpl> and it is desired to force the correct template
+path, the template hook would be:
+
+ [% Hook.process("lastrow", "bug/show-multiple.html.tmpl") %]
+
+=back
+
+=item B<Returns> 
+
+Output from processing template extension.
+
+=back
+
+=back
+
 =head1 SEE ALSO
 
 L<Template::Plugin>
-L<http:E<sol>E<sol>www.bugzilla.orgE<sol>docsE<sol>tipE<sol>htmlE<sol>customization.html>
-L<http:E<sol>E<sol>bugzilla.mozilla.orgE<sol>show_bug.cgi?id=229658>
-L<http:E<sol>E<sol>bugzilla.mozilla.orgE<sol>show_bug.cgi?id=298341>
+
+L<http://www.bugzilla.org/docs/tip/html/customization.html>
+
+L<http://bugzilla.mozilla.org/show_bug.cgi?id=229658>
+
+L<http://bugzilla.mozilla.org/show_bug.cgi?id=298341>