aboutsummaryrefslogtreecommitdiffstats
path: root/page.cgi
diff options
context:
space:
mode:
authorgerv%gerv.net <>2002-09-18 14:20:12 +0000
committergerv%gerv.net <>2002-09-18 14:20:12 +0000
commit1809e275fdbca3cb1607799a630489a3a9dc956d (patch)
tree8c7690d1c6ced8cffee4b13c684a86d278e593c0 /page.cgi
parentf48775a916e7c59da5ec59ad7f0dd729f5a80c17 (diff)
downloadbugs-1809e275fdbca3cb1607799a630489a3a9dc956d.tar
bugs-1809e275fdbca3cb1607799a630489a3a9dc956d.tar.gz
bugs-1809e275fdbca3cb1607799a630489a3a9dc956d.tar.bz2
bugs-1809e275fdbca3cb1607799a630489a3a9dc956d.tar.xz
bugs-1809e275fdbca3cb1607799a630489a3a9dc956d.zip
Bug 162151 - Fix page.cgi's method of finding templates. It now looks in a "pages" subdirectory of the template directory. Patch by gerv; r=bbaetz.
Diffstat (limited to 'page.cgi')
-rwxr-xr-xpage.cgi30
1 files changed, 16 insertions, 14 deletions
diff --git a/page.cgi b/page.cgi
index 2fcf1b9b7..3494b68dd 100755
--- a/page.cgi
+++ b/page.cgi
@@ -23,9 +23,9 @@
###############################################################################
# This CGI is a general template display engine. To display templates using it,
-# add them to the %pages hash in localconfig with a tag to refer to them by,
-# then call page.cgi?page=<tag> . Tags may only contain the letters A-Z (in
-# either case), numbers 0-9, the underscore "_" and the hyphen "-".
+# put them in the "pages" subdirectory of template/en/default, call them
+# "foo.<ctype>.tmpl" and use the URL page.cgi?id=foo.<ctype> , where <ctype> is
+# a content-type, e.g. html.
###############################################################################
use strict;
@@ -33,21 +33,23 @@ use strict;
use lib ".";
require "CGI.pl";
-use vars qw($template $vars %pages);
+use vars qw($template $vars);
ConnectToDatabase();
quietly_check_login();
if (defined $::FORM{'id'}) {
- $::FORM{'id'} =~ s/[^\w-]//g;
-
- if ($pages{$::FORM{'id'}}) {
- print "Content-Type: text/html\n\n";
- $template->process($pages{$::FORM{'id'}}, $vars)
- || ThrowTemplateError($template->error());
- exit;
- }
-}
+ $::FORM{'id'} =~ s/[^\w-\.]//g;
+ $::FORM{'id'} =~ /(.*)(\.(.*))?/;
+
+ my $format = GetFormat($1, undef, $3);
+
+ print "Content-Type: $format->{'ctype'}\n\n";
-ThrowUserError("page_not_found");
+ $template->process("pages/$format->{'template'}", $vars)
+ || ThrowTemplateError($template->error());
+}
+else {
+ ThrowUserError("no_page_specified");
+}