diff options
author | jake%acutex.net <> | 2002-02-01 05:12:47 +0100 |
---|---|---|
committer | jake%acutex.net <> | 2002-02-01 05:12:47 +0100 |
commit | aba13714d24f0ab260b61eebba2e0be75df1019d (patch) | |
tree | 7467a5d432ddb10179eb6210506a4d6dd3fa49ca | |
parent | 3cf287879c86a0b38049823235aa306e5269f1a7 (diff) | |
download | bugzilla-aba13714d24f0ab260b61eebba2e0be75df1019d.tar.gz bugzilla-aba13714d24f0ab260b61eebba2e0be75df1019d.tar.xz |
Bug 122636 - Templatise colchange.cgi
Patch by David Lawrence <dkl@redhat.com> and Christian Reis <kiko@async.com.br>
r= kiko, jake
-rwxr-xr-x | colchange.cgi | 80 | ||||
-rw-r--r-- | template/default/buglist/colchange.tmpl | 50 |
2 files changed, 95 insertions, 35 deletions
diff --git a/colchange.cgi b/colchange.cgi index 89150b5d4..2125b7542 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 "<p>\n"; -print "<FORM ACTION=colchange.cgi>\n"; -print "<INPUT TYPE=HIDDEN NAME=rememberedquery VALUE=$::buffer>\n"; +# Generate and return the UI (HTML page) from the appropriate template. +print "Content-type: text/html\n\n"; +$template->process("buglist/colchange.tmpl", $vars) + || DisplayError("Template process failed: " . $template->error()) + && exit; -foreach my $i (@masterlist) { - my $c; - if (lsearch(\@collist, $i) >= 0) { - $c = 'CHECKED'; - } else { - $c = ''; - } - print "<INPUT TYPE=checkbox NAME=column_$i $c>$desc{$i}<br>\n"; -} -print "<P>\n"; -print BuildPulldown("splitheader", - [["0", "Normal headers (prettier)"], - ["1", "Stagger headers (often makes list more compact)"]], - $splitheader); -print "<P>\n"; - -print "<INPUT TYPE=\"submit\" VALUE=\"Submit\">\n"; -print "</FORM>\n"; -print "<FORM ACTION=colchange.cgi>\n"; -print "<INPUT TYPE=HIDDEN NAME=rememberedquery VALUE=$::buffer>\n"; -print "<INPUT TYPE=HIDDEN NAME=resetit VALUE=1>\n"; -print "<INPUT TYPE=\"submit\" VALUE=\"Reset to Bugzilla default\">\n"; -print "</FORM>\n"; -PutFooter(); diff --git a/template/default/buglist/colchange.tmpl b/template/default/buglist/colchange.tmpl new file mode 100644 index 000000000..5ef71aa52 --- /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 <dkl@redhat.com> + #%] + +[% INCLUDE global/header + title = "Change Columns" +%] + +Check which columns you wish to appear on the list, and then click +on submit. (Cookies are required.) +<p> +<form action="colchange.cgi"> +<input type="hidden" name="rememberedquery" value="[% buffer FILTER uri %]"> +[% FOREACH column = masterlist %] + <input type="checkbox" id="[% column %]" name="column_[% column %]" [% "CHECKED" IF lsearch(collist, column) != -1 %]> + <label for="[% column %]">[% desc.${column} %]</label><br> +[% END %] +</p><p> +<input id="nosplitheader" type="radio" name="splitheader" value="0" [% "CHECKED" IF ! splitheader %]> +<label for="nosplitheader">Normal headers (prettier)</label><br> +<input id="splitheader" type="radio" name="splitheader" value="1" [% "CHECKED" IF splitheader %]> +<label for="splitheader">Stagger headers (often makes list more compact)</label> +</p><p> +<input type="submit" value="Submit"> +</form> +<form action="colchange.cgi"> +<input type="hidden" name="rememberedquery" value="[% buffer FILTER uri %]"> +<input type="hidden" name="resetit" value="1"> +<input type="submit" value="Reset to Bugzilla default"> +</form> +</p> + +[% INCLUDE global/footer %] + |