From: jake%acutex.net <>
Date: Fri, 1 Feb 2002 04:12:47 +0000 (+0000)
Subject: Bug 122636 - Templatise colchange.cgi
X-Git-Tag: bugzilla-2.16rc1~256
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aba13714d24f0ab260b61eebba2e0be75df1019d;p=thirdparty%2Fbugzilla.git
Bug 122636 - Templatise colchange.cgi
Patch by David Lawrence and Christian Reis
r= kiko, jake
---
diff --git a/colchange.cgi b/colchange.cgi
index 89150b5d41..2125b75429 100755
--- a/colchange.cgi
+++ b/colchange.cgi
@@ -31,6 +31,38 @@ sub sillyness { # shut up "used only once" warnings
require "CGI.pl";
+# Use the template toolkit (http://www.template-toolkit.org/) to generate
+# the user interface (HTML pages and mail messages) using templates in the
+# "template/" subdirectory.
+use Template;
+
+# Create the global template object that processes templates and specify
+# configuration parameters that apply to all templates processed in this script.
+my $template = Template->new(
+{
+ # Colon-separated list of directories containing templates.
+ INCLUDE_PATH => "template/custom:template/default",
+ # Allow templates to be specified with relative paths.
+ RELATIVE => 1,
+ PRE_CHOMP => 1,
+});
+
+# Define the global variables and functions that will be passed to the UI
+# template. Individual functions add their own values to this hash before
+# sending them to the templates they process.
+my $vars =
+{
+ # Function for retrieving global parameters.
+ 'Param' => \&Param,
+
+ # Function for processing global parameters that contain references
+ # to other global parameters.
+ 'PerformSubsts' => \&PerformSubsts,
+
+ # Function to search an array for a value
+ 'lsearch' => \&lsearch,
+};
+
print "Content-type: text/html\n";
# The master list not only says what fields are possible, but what order
@@ -59,6 +91,7 @@ if (@::legal_keywords) {
push(@masterlist, ("summary", "summaryfull"));
+$vars->{masterlist} = \@masterlist;
my @collist;
if (defined $::FORM{'rememberedquery'}) {
@@ -95,13 +128,14 @@ if (defined $::COOKIE{'COLUMNLIST'}) {
@collist = @::default_column_list;
}
-my $splitheader = 0;
+$vars->{collist} = \@collist;
+
+$vars->{splitheader} = 0;
if ($::COOKIE{'SPLITHEADER'}) {
- $splitheader = 1;
+ $vars->{splitheader} = 1;
}
-
-my %desc;
+my %desc = ();
foreach my $i (@masterlist) {
$desc{$i} = $i;
}
@@ -109,36 +143,12 @@ foreach my $i (@masterlist) {
$desc{'summary'} = "Summary (first 60 characters)";
$desc{'summaryfull'} = "Full Summary";
+$vars->{desc} = \%desc;
+$vars->{buffer} = $::buffer;
-print "\n";
-PutHeader ("Change columns");
-print "Check which columns you wish to appear on the list, and then click\n";
-print "on submit. (Cookies are required.)\n";
-print "
\n";
-print "
\n";
-print "\n";
-PutFooter();
diff --git a/template/default/buglist/colchange.tmpl b/template/default/buglist/colchange.tmpl
new file mode 100644
index 0000000000..5ef71aa521
--- /dev/null
+++ b/template/default/buglist/colchange.tmpl
@@ -0,0 +1,50 @@
+[%# 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 Bug Tracking System.
+ #
+ # The Initial Developer of the Original Code is Netscape Communications
+ # Corporation. Portions created by Netscape are
+ # Copyright (C) 1998 Netscape Communications Corporation. All
+ # Rights Reserved.
+ #
+ # Contributor(s): Dave Lawrence
+ #%]
+
+[% INCLUDE global/header
+ title = "Change Columns"
+%]
+
+Check which columns you wish to appear on the list, and then click
+on submit. (Cookies are required.)
+