Apache-PageKit
view release on metacpan or search on metacpan
lib/Apache/PageKit.pm view on Meta::CPAN
package Apache::PageKit;
# $Id: PageKit.pm,v 1.236 2004/05/06 09:54:35 borisz Exp $
# required for UNIVERSAL->can
require 5.005;
use strict;
# CPAN Modules required for pagekit
use Apache::URI ();
use Apache::Cookie ();
use Apache::Request ();
use Apache::SessionX ();
use Apache::Util ();
use Compress::Zlib ();
use File::Find ();
use HTML::FillInForm ();
use HTML::Parser ();
use HTML::Entities ();
use HTML::Template ();
use Text::Iconv ();
use XML::LibXML ();
$| = 1;
# PageKit modules
use Apache::PageKit::Param ();
use Apache::PageKit::View ();
use Apache::PageKit::Content ();
use Apache::PageKit::Model ();
use Apache::PageKit::Config ();
use Apache::PageKit::Edit ();
use Apache::Constants qw(OK DONE REDIRECT DECLINED HTTP_NOT_MODIFIED);
use vars qw($VERSION);
$VERSION = '1.18';
%Apache::PageKit::DefaultMediaMap = (
pdf => 'application/pdf',
wml => 'text/vnd.wap.wml',
xml => 'application/xml');
# in httpd.conf file
sub startup {
my ($class, $pkit_root, $server) = @_;
my $s = Apache->server;
if ( defined $mod_perl::VERSION && $mod_perl::VERSION >= 1.26 ) {
$pkit_root ||= $s->dir_config('PKIT_ROOT') || die "PKIT_ROOT is not defined! Put PerlSetVar PKIT_ROOT /your/root/path in your httpd.conf";
$server ||= $s->dir_config('PKIT_SERVER') || die "PKIT_SERVER is not defined! Put PerlSetVar PKIT_SERVER servername in your httpd.conf";
} else {
$pkit_root || die 'must specify $pkit_root variable in startup. Usage: Apache::PageKit->startup($pkit_root, $server)';
$server || die 'must specify $server variable in startup. Usage: Apache::PageKit->startup($pkit_root, $server)';
}
# get user and group as specified by User and Group directives
my $uid = $s->uid;
my $gid = $s->gid;
# include user defined classes (Model) in perl search path
unshift(@INC,"$pkit_root/Model");
my $config_dir = $pkit_root . '/Config';
my $config = Apache::PageKit::Config->new(config_dir => $config_dir,
server => $server);
$config->parse_xml;
die "No config data for your server '$server' maybe you mistyped something?"
unless exists $Apache::PageKit::Config::server_attr->{$config_dir}->{$server};
my $upload_tmp_dir = $config->get_global_attr('upload_tmp_dir');
if ( $upload_tmp_dir && !-d $upload_tmp_dir ) {
die "your upload_tmp_dir ($upload_tmp_dir) did not exists";
}
my $cache_dir = $config->get_global_attr('cache_dir');
my $view_cache_dir = $cache_dir ? $cache_dir . '/pkit_cache' :
$pkit_root . '/View/pkit_cache';
unless(-e "$view_cache_dir"){
mkdir $view_cache_dir, 0755;
}
# User defined base model class
my $model_base_class = $config->get_global_attr('model_base_class') || "MyPageKit::Common";
eval "require $model_base_class";
if($@){
die "Failed to load $model_base_class ($@)";
}
# User defined session class
for ( qw /session_class page_session_class/ ) {
my $user_session_class = $config->get_global_attr($_) || next;
eval "require $user_session_class";
$@ && die "Failed to load $user_session_class ($@)";
}
# User defined template toolkit class
my $template_class = $config->get_global_attr('template_class');
if ( $template_class ) {
eval "require $template_class";
$@ && die "Failed to load $template_class ($@)";
}
# delete all cache files, since some of them might be stale
# and might not be checked for freshness, if reload is off
# even if reload is on, PageKit might change, so it should be refreshed
my $unlink_sub = sub {
-f && unlink;
};
File::Find::find($unlink_sub,$view_cache_dir);
# init gettext
if (($config->get_global_attr('use_locale') || 'no') eq 'yes') {
eval { require Locale::gettext };
unless ($@) {
( run in 1.558 second using v1.01-cache-2.11-cpan-ceb78f64989 )