Apache-SetWWWTheme
view release on metacpan or search on metacpan
SetWWWTheme.pm view on Meta::CPAN
use Apache::Constants ':common';
use Apache::File ();
use HTML::WWWTheme;
$VERSION = '1.06';
##################################################
my $r; # request object variable
my $Theme; # Theme object!
my $blankgif = ""; # the location of the blank gif. or png. Whatever.
my $allowbodymod; #
my ($nextlink, $lastlink, $uplink, $BGCOLOR); # vars we use to customize the page
my ($alink, $link, $text, $vlink); # <BODY> stuff
my @infolinks; # array to contain the links in the infobar
my $usenavbar; # flag that tells if we use the top and bottom navbar
my $serverconfig; # name of the server config file
my $localconfig; # name of the local config file
my $shortlocal; # short name of local config file
my $allowsidebartoggle; # flag set by server to allow turning on/off the sidebar
my $allowBGCOLOR; # flag set by the server to allow the local config to
# change the background color. HTML pages can *never*
# override the background color.
my $nosidebar; # flag set to turn off the sidebar. $allownosidebar
# must be set to use this.
my $allowbgpicture; # let us put in a background gif or something. I put this in
# so you could kill off animated bgs and other junk
my $bgpicture; # used to set the bg picture for the produced page.
#
my $allowsidebarmod; # sidebar modification variables...
my $sidebartop; #
my $sidebarmenutitle; #
my @sidebarmenulinks; #
my $nosidebarextras; #
my $morelinkstitle; #
my $sidebarsearchbox; #
my $sidebarcolor; #
my $sidebarwidth; #
my $searchtemplate; # a search template
my $topbar; #
my $bottombar; #
my @topbottomlinks; #
my $filename; #
my $printable; #
my $printabletag = "printable"; # what we tack on for the QUERY_STRING GET data
my $printableuri; #
##################################################
sub handler
{
$r = shift; # get request object
$Theme = new HTML::WWWTheme(); # grab our theme object.
my $content_type;
$content_type = $r->content_type() || return DECLINED;
# we only want to deal with html files
return DECLINED unless $content_type eq 'text/html';
$filename = $r->filename; # get the filename we're looking for
unless (-e $r->finfo) # Apache does a stat() and puts the results in finfo,
# this is faster than testing the filename.
{
$r->log_error("File does not exist: $filename");
return NOT_FOUND;
}
unless (-r _) # after finfo is used, it goes to perl's _ filehandle
{
$r->log_error("File permissions deny access: $filename");
return FORBIDDEN;
}
$r->send_http_header;
# reset all my vars.
# For now, it works, and I think we're ok for namespace issues since all vars have lexical scope.
# This part is here to let you configure defaults if you want to unleash this module on unsuspecting
# people that don't/won't put in a server config file or something. I dunno. If you can use it,
# great. If not, no big deal.
undef $serverconfig;
undef $localconfig;
$shortlocal = "LookAndFeelConfig"; # a default, if nothing else is set.
undef $nextlink;
undef $lastlink;
undef $uplink;
undef $BGCOLOR;
undef $alink;
undef $vlink;
undef $link;
undef $text;
undef $bgpicture;
undef @infolinks;
undef $usenavbar;
undef $allowsidebartoggle;
undef $allowBGCOLOR;
undef $allowbgpicture;
undef $allowsidebarmod;
undef $nosidebar;
undef $sidebartop;
undef $sidebarmenutitle;
undef @sidebarmenulinks;
undef $sidebarsearchbox;
undef $nosidebarextras;
undef $morelinkstitle;
undef $sidebarcolor;
undef $sidebarwidth;
undef $searchtemplate;
undef $topbar;
undef $bottombar;
undef @topbottomlinks;
undef $printable;
undef $printableuri;
# grabs the config file for the configuration. This is all the non-user
# stuff, and can only be changed by the web maintainers/admin people.
# first we'll see if maybe we can skip this whole module.
# if we have a ?printable query set, we'll skip this stuff.
( run in 3.125 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )