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
360c7807
Commit
360c7807
authored
Aug 06, 2009
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 508199: A hook for page.cgi
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=dkl, a=mkanat
parent
c0486757
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
1 deletion
+98
-1
Hook.pm
Bugzilla/Hook.pm
+27
-0
page-before_template.pl
extensions/example/code/page-before_template.pl
+33
-0
example.html.tmpl
...sions/example/template/en/default/pages/example.html.tmpl
+32
-0
page.cgi
page.cgi
+6
-1
No files found.
Bugzilla/Hook.pm
View file @
360c7807
...
...
@@ -478,6 +478,33 @@ Params:
=back
=head2 page-before_template
This is a simple way to add your own pages to Bugzilla. This hooks C<page.cgi>,
which loads templates from F<template/en/default/pages>. For example,
C<page.cgi?id=fields.html> loads F<template/en/default/pages/fields.html.tmpl>.
This hook is called right before the template is loaded, so that you can
pass your own variables to your own pages.
Params:
=over
=item C<page_id>
This is the name of the page being loaded, like C<fields.html>.
Note that if two extensions use the same name, it is uncertain which will
override the others, so you should be careful with how you name your pages.
=item C<vars>
This is a hashref--put variables into here if you want them passed to
your template.
=back
=head2 product-confirm_delete
Called before displaying the confirmation message when deleting a product.
...
...
extensions/example/code/page-before_template.pl
0 → 100644
View file @
360c7807
# -*- 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 Canonical Ltd.
# Portions created by Canonical Ltd. are Copyright (C) 2009
# Canonical Ltd. All Rights Reserved.
#
# Contributor(s):
# Max Kanat-Alexander <mkanat@bugzilla.org>
use
strict
;
use
warnings
;
use
Bugzilla
;
my
%
args
=
%
{
Bugzilla
->
hook_args
};
my
(
$vars
,
$page
)
=
@args
{
qw(vars page_id)
};
# You can see this hook in action by loading page.cgi?id=example.html
if
(
$page
eq
'example.html'
)
{
$vars
->
{
cgi_variables
}
=
{
Bugzilla
->
cgi
->
Vars
};
}
extensions/example/template/en/default/pages/example.html.tmpl
0 → 100644
View file @
360c7807
[%#
# 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 Canonical Ltd.
# Portions created by Canonical Ltd. are Copyright (C) 2009
# Canonical Ltd. All Rights Reserved.
#
# Contributor(s):
# Max Kanat-Alexander <mkanat@bugzilla.org>
#%]
[% PROCESS global/header.html.tmpl
title = "Example Page"
%]
<p>Here's what you passed me:</p>
[% USE Dumper %]
<pre>
[% Dumper.dump_html(cgi_variables) %]
</pre>
[% PROCESS global/footer.html.tmpl %]
page.cgi
View file @
360c7807
...
...
@@ -34,6 +34,7 @@ use lib qw(. lib);
use
Bugzilla
;
use
Bugzilla::
Error
;
use
Bugzilla::
Hook
;
Bugzilla
->
login
();
...
...
@@ -50,13 +51,17 @@ if ($id) {
ThrowCodeError
(
"bad_page_cgi_id"
,
{
"page_id"
=>
$id
});
}
my
%
vars
;
Bugzilla::Hook::
process
(
'page-before_template'
,
{
page_id
=>
$id
,
vars
=>
\%
vars
});
my
$format
=
$template
->
get_format
(
"pages/$1"
,
undef
,
$2
);
$cgi
->
param
(
'id'
,
$id
);
print
$cgi
->
header
(
$format
->
{
'ctype'
});
$template
->
process
(
"$format->{'template'}"
)
$template
->
process
(
"$format->{'template'}"
,
\%
vars
)
||
ThrowTemplateError
(
$template
->
error
());
}
else
{
...
...
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