Changeset 801 for trunk


Ignore:
Timestamp:
12/24/15 13:14:27 (8 years ago)
Author:
Kris Deugau
Message:

/trunk

Extend template-replacement from r793 to search.cgi and admin.cgi

Location:
trunk/cgi-bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/admin.cgi

    r789 r801  
    5555
    5656# Set up some globals
    57 $ENV{HTML_TEMPLATE_ROOT} = $thingroot."templates";
     57$ENV{HTML_TEMPLATE_ROOT} = $thingroot;
     58my @templatepath = [ "localtemplates", "templates" ];
    5859
    5960# Why not a global DB handle?  (And a global statement handle, as well...)
     
    7576# handle DB error output
    7677if ($webvar{action} eq 'dberr') {
    77   my $page = HTML::Template->new(filename => "admin/dberr.tmpl");
     78  my $page = HTML::Template->new(filename => "admin/dberr.tmpl", path => @templatepath);
    7879  $page->param(errmsg => $errstr);
    7980  print "Content-Type: text/html\n\n".$page->output;
     
    8283
    8384if ($IPDBacl{$authuser} !~ /A/) {
    84   my $page = HTML::Template->new(filename => "admin/aclerr.tmpl");
     85  my $page = HTML::Template->new(filename => "admin/aclerr.tmpl", path => @templatepath);
    8586##fixme:  need params for IPDB admin email and name
    8687  $page->param(ipdbadmin_email => 'ipdbadmin@example.com');
     
    9091}
    9192
    92 my $header = HTML::Template->new(filename => "admin/header.tmpl");
     93my $header = HTML::Template->new(filename => "admin/header.tmpl", path => @templatepath);
    9394$header->param(mainpage => 1) if $webvar{action} eq 'main';
    9495$header->param(webpath => $IPDB::webpath);
     
    9697
    9798my $page;
    98 if (-e "$ENV{HTML_TEMPLATE_ROOT}/admin/$webvar{action}.tmpl") {
    99   $page = HTML::Template->new(filename => "admin/$webvar{action}.tmpl");
     99if (-e "$ENV{HTML_TEMPLATE_ROOT}/templates/admin/$webvar{action}.tmpl") {
     100  $page = HTML::Template->new(filename => "admin/$webvar{action}.tmpl", path => @templatepath);
    100101} else {
    101   $page = HTML::Template->new(filename => "admin/dunno.tmpl");
     102  $page = HTML::Template->new(filename => "admin/dunno.tmpl", path => @templatepath);
    102103}
    103104
     
    481482
    482483# We print the footer here, so we don't have to do it elsewhere.
    483 my $footer = HTML::Template->new(filename => "footer.tmpl");
     484my $footer = HTML::Template->new(filename => "footer.tmpl", path => @templatepath);
    484485# we're already in the admin tools, no need to provide a bottom link.  maybe.
    485486#$footer->param(adminlink => ($IPDBacl{$authuser} =~ /A/));
  • trunk/cgi-bin/search.cgi

    r670 r801  
    7171
    7272# Set up some globals
    73 $ENV{HTML_TEMPLATE_ROOT} = $thingroot."templates";
     73$ENV{HTML_TEMPLATE_ROOT} = $thingroot;
     74my @templatepath = [ "localtemplates", "templates" ];
    7475
    7576my $page;
    7677if (!defined($webvar{stype})) {
    7778  $webvar{stype} = "<NULL>";   #shuts up the warnings.
    78   $page = HTML::Template->new(filename => "search/compsearch.tmpl");
     79  $page = HTML::Template->new(filename => "search/compsearch.tmpl", path => @templatepath);
    7980} else {
    80   $page = HTML::Template->new(filename => "search/sresults.tmpl", global_vars => 1);
     81  $page = HTML::Template->new(filename => "search/sresults.tmpl", global_vars => 1, path => @templatepath);
    8182  $page->param(webpath => $IPDB::webpath);
    8283}
    8384
    84 my $header = HTML::Template->new(filename => "header.tmpl");
     85my $header = HTML::Template->new(filename => "header.tmpl", path => @templatepath);
    8586$header->param(version => $IPDB::VERSION);
    8687$header->param(addperm => $IPDBacl{$authuser} =~ /a/);
     
    9495# Handle the DB error first
    9596if (!$ip_dbh) {
    96   $page = HTML::Template->new(filename => "dberr.tmpl");
     97  $page = HTML::Template->new(filename => "dberr.tmpl", path => @templatepath);
    9798  $page->param(errmsg => $errstr);
    9899} elsif ($webvar{stype} eq 'q') {
     
    314315
    315316# We print the footer here, so we don't have to do it elsewhere.
    316 my $footer = HTML::Template->new(filename => "footer.tmpl");
     317my $footer = HTML::Template->new(filename => "footer.tmpl", path => @templatepath);
    317318# include the admin tools link in the output?
    318319$footer->param(adminlink => ($IPDBacl{$authuser} =~ /A/));
Note: See TracChangeset for help on using the changeset viewer.