Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
700f6a06
Commit
700f6a06
authored
Oct 20, 2009
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 394438: Add a hook for adding template vars to any page (Override Template->process)
Patch by Matt Rogers <mattr@kde.org> r=mkanat, a=mkanat
parent
41d57c9f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
0 deletions
+77
-0
Hook.pm
Bugzilla/Hook.pm
+31
-0
Template.pm
Bugzilla/Template.pm
+13
-0
template-before_process.pl
extensions/example/code/template-before_process.pl
+33
-0
No files found.
Bugzilla/Hook.pm
View file @
700f6a06
...
...
@@ -649,6 +649,37 @@ to the user. (F<sanitycheck.cgi>'s C<Status>)
=back
=head2 template-before_process
This hook allows you to define additional variables that will be available to
the template being processed. You probably want to restrict your hook
to operating only if a certain file is being loaded (which is why you
get a C<file> argument below). Otherwise, modifying the C<vars> argument
will affect every single template in Bugzilla.
Params:
=over
=item C<vars>
The template vars hashref--these are the values that get passed to the
template. Adding new keys to this hashref will cause those new values
to also get passed to the template.
=item C<file>
The name of the template being processed. This is relative
to the main template directory for the language (i.e. for
F<template/en/default/bug/show.html.tmpl>, this variable will contain
C<bug/show.html.tmpl>).
=item C<template>
The L<Bugzilla::Template> object that C<process> was called on.
=back
=head2 webservice
This hook allows you to add your own modules to the WebService. (See
...
...
Bugzilla/Template.pm
View file @
700f6a06
...
...
@@ -79,6 +79,19 @@ sub _load_constants {
return
\%
constants
;
}
# Overload Template::Process in order to add a hook to allow additional
# variables to be made available by an extension
sub
process
{
my
$self
=
shift
;
my
(
$file
,
$vars
)
=
@_
;
Bugzilla::Hook::
process
(
"template-before_process"
,
{
vars
=>
$vars
,
file
=>
$file
,
template
=>
$self
});
return
$self
->
SUPER::
process
(
@_
);
}
# Returns the path to the templates based on the Accept-Language
# settings of the user and of the available languages
# If no Accept-Language is present it uses the defined default
...
...
extensions/example/code/template-before_process.pl
0 → 100644
View file @
700f6a06
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Example Plugin.
#
# The Initial Developer of the Original Code is Matt Rogers.
# Portions created by the Initial Developer are Copyright (C) 2009
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Matt Rogers <mattr@kde.org>
use
strict
;
use
warnings
;
use
Bugzilla
;
my
%
args
=
%
{
Bugzilla
->
hook_args
};
my
(
$vars
,
$file
,
$template
)
=
$args
{
qw(vars file template)
};
$vars
->
{
'example'
}
=
1
;
if
(
$file
=~
m{^bug/show}
)
{
$vars
->
{
'showing_a_bug'
}
=
1
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment