]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 301507: Move PutHeader and PutFooter into Template.pm - Patch by Frédéric Buclin...
authorlpsolit%gmail.com <>
Fri, 22 Jul 2005 12:13:36 +0000 (12:13 +0000)
committerlpsolit%gmail.com <>
Fri, 22 Jul 2005 12:13:36 +0000 (12:13 +0000)
Bugzilla/Template.pm
CGI.pl
doeditparams.cgi
editparams.cgi
editproducts.cgi
move.pl
process_bug.cgi
reports.cgi
sanitycheck.cgi

index 7efd3a16e55bc5e1a96b040959bbb064c430ae03..5c5aff574275d3ae94d8d17fbef09348fe58f5f4 100644 (file)
@@ -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
diff --git a/CGI.pl b/CGI.pl
index 4b7269358ae4c5addc10eb62a9383acec97e931e..c1b8aca1141f8f17d02c2c5f91383e925298d8c6 100644 (file)
--- a/CGI.pl
+++ b/CGI.pl
@@ -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) #############
 
index 028f28a60ff4290d6754438c1eb79a4f4efee90a..431aa91c2f510192bbcf9c10ef402a9bc49489d5 100755 (executable)
@@ -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();
index 620ae6baee1cb71446578362bbe5965d2dc1bc78..668a138017e34e6f3105290ac8f34ef90fdb72a5 100755 (executable)
@@ -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();
index 5e48b958e0a92a3648bc2d8590bf30a27a50312d..18e845efc51763e16e9c029ef0be1784343cb488 100755 (executable)
@@ -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";
diff --git a/move.pl b/move.pl
index 7747baaed1481dec3c56501ef851b03dc2c7e8ed..030d03ac0147913718f4a97ca719b189e4a53e1c 100755 (executable)
--- a/move.pl
+++ b/move.pl
@@ -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;
 }
 
index 7b4b299c3ab4fb1c823cfc9fb5ac6af956454a81..c8e1e81149e53db1c73fdb72140d71ffdee1a8c6 100755 (executable)
@@ -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;
 }
 
index c5314b33e79161fb959ec538382a1d84da51552e..bdd8e9352c22d9cb31df387a5a49ed1dbcad96fb 100755 (executable)
@@ -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>
index c091e1041d95974b9bde2b9bf389f01faf15138a..00a7ef0c5352cc7d6f9a56482f4513ceed03c91a 100755 (executable)
@@ -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();