Commit e7d2b86c authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 301507: Move PutHeader and PutFooter into Template.pm - Patch by Frédéric…

Bug 301507: Move PutHeader and PutFooter into Template.pm - Patch by Frédéric Buclin <LpSolit@gmail.com> r/a=justdave
parent d0303ab3
......@@ -34,11 +34,13 @@ use strict;
use Bugzilla::Config qw(:DEFAULT $templatedir $datadir);
use Bugzilla::Util;
use Bugzilla::User;
use Bugzilla::Error;
# for time2str - replace by TT Date plugin??
use Date::Format ();
use base qw(Template);
use vars qw($vars);
# Convert the constants in the Bugzilla::Constants module into a hash we can
# pass to the template object for reflection into its "constants" namespace
......@@ -130,6 +132,23 @@ sub getTemplateIncludePath () {
@usedlanguages)];
}
# Write the header for non yet templatized .cgi files.
sub put_header {
my $self = shift;
($vars->{'title'}, $vars->{'h1'}, $vars->{'h2'}) = (@_);
$self->process("global/header.html.tmpl", $vars)
|| ThrowTemplateError($self->error());
$vars->{'header_done'} = 1;
}
# Write the footer for non yet templatized .cgi files.
sub put_footer {
my $self = shift;
$self->process("global/footer.html.tmpl", $vars)
|| ThrowTemplateError($self->error());
}
###############################################################################
# Templatization Code
......
......@@ -50,20 +50,7 @@ sub CGI_pl_sillyness {
require 'globals.pl';
use vars qw($template $vars);
sub PutHeader {
($vars->{'title'}, $vars->{'h1'}, $vars->{'h2'}) = (@_);
$::template->process("global/header.html.tmpl", $::vars)
|| ThrowTemplateError($::template->error());
$vars->{'header_done'} = 1;
}
sub PutFooter {
$::template->process("global/footer.html.tmpl", $::vars)
|| ThrowTemplateError($::template->error());
}
use vars qw($vars);
############# Live code below here (that is, not subroutine defs) #############
......
......@@ -35,6 +35,7 @@ require "CGI.pl";
Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
print $cgi->header();
......@@ -43,7 +44,7 @@ UserInGroup("tweakparams")
action => "modify",
object => "parameters"});
PutHeader("Saving new parameters");
$template->put_header("Saving new parameters");
my $howto = "";
......@@ -90,7 +91,7 @@ foreach my $i (GetParamList()) {
print "New value for " . html_quote($name) .
" is invalid: $ok<p>\n";
print "Please hit <b>Back</b> and try again.\n";
PutFooter();
$template->put_footer();
exit;
}
}
......@@ -115,4 +116,4 @@ print $howto;
print "<a href=\"editparams.cgi\">Edit the params some more.</a><p>\n";
print "<a href=\"query.cgi\">Go back to the query page.</a>\n";
PutFooter();
$template->put_footer();
......@@ -33,6 +33,8 @@ require "CGI.pl";
Bugzilla->login(LOGIN_REQUIRED);
my $template = Bugzilla->template;
print Bugzilla->cgi->header();
UserInGroup("tweakparams")
......@@ -40,7 +42,7 @@ UserInGroup("tweakparams")
action => "modify",
object => "parameters"});
PutHeader("Edit parameters");
$template->put_header("Edit parameters");
print "This lets you edit the basic operating parameters of bugzilla.\n";
print "Be careful!\n";
......@@ -141,4 +143,4 @@ print "<input type=submit value=\"Submit changes\">\n";
print "</form>\n";
print "<p><a href=query.cgi>Skip all this, and go back to the query page</a>\n";
PutFooter();
$template->put_footer();
......@@ -118,7 +118,7 @@ sub CheckClassification ($)
# For the transition period, as this file is templatised bit by bit,
# we need this routine, which does things properly, and will
# eventually be the only version. (The older versions assume a
# PutHeader() call has been made)
# $template->put_header() call has been made)
sub CheckClassificationNew ($)
{
my $cl = shift;
......@@ -271,7 +271,7 @@ sub PutTrailer (@)
}
$num++;
}
PutFooter();
$template->put_footer();
}
......@@ -408,7 +408,7 @@ if (!$action && !$product) {
#
if ($action eq 'add') {
PutHeader("Add product");
$template->put_header("Add product");
if (Param('useclassification')) {
CheckClassification($classification);
......@@ -449,7 +449,7 @@ if ($action eq 'add') {
#
if ($action eq 'new') {
PutHeader("Adding new product");
$template->put_header("Adding new product");
# Cleanups and validity checks
......@@ -777,7 +777,7 @@ if ($action eq 'delete') {
#
if ($action eq 'edit' || (!$action && $product)) {
PutHeader("Edit product");
$template->put_header("Edit product");
CheckProduct($product);
my $classification_id=1;
if (Param('useclassification')) {
......@@ -1003,7 +1003,7 @@ if ($action eq 'updategroupcontrols') {
exit;
}
}
PutHeader("Update group access controls for product \"$product\"");
$template->put_header("Update group access controls for product \"$product\"");
$headerdone = 1;
SendSQL("SELECT id, name FROM groups " .
"WHERE isbuggroup != 0 AND isactive != 0");
......@@ -1167,7 +1167,7 @@ if ($action eq 'updategroupcontrols') {
#
if ($action eq 'update') {
PutHeader("Update product");
$template->put_header("Update product");
my $productold = trim($cgi->param('productold') || '');
my $description = trim($cgi->param('description') || '');
......@@ -1448,5 +1448,5 @@ if ($action eq 'editgroupcontrols') {
# No valid action found
#
PutHeader("Error");
$template->put_header("Error");
print "I don't have a clue what you want.<BR>\n";
......@@ -81,12 +81,12 @@ sub Unlock {
if (!defined $cgi->param('buglist')) {
print $cgi->header();
PutHeader("Move Bugs");
$template->put_header("Move Bugs");
print "Move bugs either from the bug display page or perform a ";
print "<A HREF=\"query.cgi\">query</A> and change several bugs at once.\n";
print "If you don't see the move button, then you either aren't ";
print "logged in or aren't permitted to.";
PutFooter();
$template->put_footer();
exit;
}
......@@ -96,9 +96,9 @@ $movers =~ s/\s?,\s?/|/g;
$movers =~ s/@/\@/g;
unless ($exporter =~ /($movers)/) {
print $cgi->header();
PutHeader("Move Bugs");
$template->put_header("Move Bugs");
print "<P>You do not have permission to move bugs<P>\n";
PutFooter();
$template->put_footer();
exit;
}
......
......@@ -592,7 +592,7 @@ if (defined $cgi->param('action')) {
if (Param("move-enabled") && $action eq Param("move-button-text")) {
$cgi->param('buglist', join (":", @idlist));
do "move.pl" || die "Error executing move.cgi: $!";
PutFooter();
$template->put_footer();
exit;
}
......
......@@ -63,6 +63,7 @@ GetVersionTable();
Bugzilla->switch_to_shadow_db();
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
# We only want those products that the user has permissions for.
my @myproducts;
......@@ -72,7 +73,7 @@ push( @myproducts, GetSelectableProducts());
if (! defined $cgi->param('product')) {
choose_product(@myproducts);
PutFooter();
$template->put_footer();
} else {
my $product = $cgi->param('product');
......@@ -93,11 +94,11 @@ if (! defined $cgi->param('product')) {
print $cgi->header(-Content_Disposition=>'inline; filename=bugzilla_report.html');
PutHeader("Bug Charts");
$template->put_header("Bug Charts");
show_chart($product);
PutFooter();
$template->put_footer();
}
......@@ -119,7 +120,7 @@ sub choose_product {
|| ThrowCodeError("chart_file_open_fail", {filename => "$dir/$datafile"});
print $cgi->header();
PutHeader("Bug Charts");
$template->put_header("Bug Charts");
print <<FIN;
<center>
......
......@@ -75,6 +75,7 @@ Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $template = Bugzilla->template;
# Make sure the user is authorized to access sanitycheck.cgi. Access
# is restricted to logged-in users who have "editbugs" privileges,
......@@ -92,7 +93,7 @@ print $cgi->header();
my @row;
PutHeader("Bugzilla Sanity Check");
$template->put_header("Bugzilla Sanity Check");
###########################################################################
# Fix vote cache
......@@ -272,7 +273,7 @@ if (defined $cgi->param('rescanallBugMail')) {
Status("Unsent mail has been sent.");
}
PutFooter();
$template->put_footer();
exit;
}
......@@ -887,4 +888,4 @@ if (@badbugs > 0) {
###########################################################################
Status("Sanity check completed.");
PutFooter();
$template->put_footer();
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