progress and WebGUI::Paths conversion
This commit is contained in:
parent
90d63c6713
commit
29df110409
23 changed files with 63 additions and 333 deletions
|
|
@ -196,13 +196,7 @@ sub exportAssetCollateral {
|
|||
}
|
||||
|
||||
# open another session to handle printing...
|
||||
my $printSession = WebGUI::Session->open(
|
||||
$self->session->config->getWebguiRoot,
|
||||
$self->session->config->getFilename,
|
||||
undef,
|
||||
undef,
|
||||
$self->session->getId,
|
||||
);
|
||||
my $printSession = WebGUI::Session->duplicate;
|
||||
|
||||
my $keywordObj = WebGUI::Keyword->new($printSession);
|
||||
my $keywords = $keywordObj->findKeywords({
|
||||
|
|
|
|||
|
|
@ -265,7 +265,6 @@ sub exportAsHtml {
|
|||
# now, create a new session as the user doing the exports. this is so that
|
||||
# the exported assets are taken from that user's perspective.
|
||||
my $exportSession = WebGUI::Session->open(
|
||||
$session->config->getWebguiRoot,
|
||||
$session->config->getFilename,
|
||||
);
|
||||
my $esGuard = Scope::Guard->new(sub {
|
||||
|
|
@ -499,7 +498,6 @@ sub exportGetDescendants {
|
|||
# assets that they can't see
|
||||
if ( ref $user && $user->isa('WebGUI::User') ) {
|
||||
$session = WebGUI::Session->open(
|
||||
$session->config->getWebguiRoot,
|
||||
$session->config->getFilename,
|
||||
);
|
||||
$session->user( { userId => $user->userId } );
|
||||
|
|
|
|||
|
|
@ -15,8 +15,9 @@ package WebGUI::Config;
|
|||
=cut
|
||||
|
||||
use strict;
|
||||
use Class::InsideOut qw(readonly id register);
|
||||
use WebGUI::Paths;
|
||||
use Cwd ();
|
||||
use File::Spec;
|
||||
use base 'Config::JSON';
|
||||
|
||||
my %config = ();
|
||||
|
|
@ -50,7 +51,6 @@ This package parses the WebGUI config file.
|
|||
$config->addToArray($name, $value);
|
||||
|
||||
my $configFileName = $config->getFilename;
|
||||
my $webguiRoot = $config->getWebguiRoot;
|
||||
|
||||
=head1 ISA
|
||||
|
||||
|
|
@ -109,17 +109,6 @@ sub getCookieTTL {
|
|||
return defined($configTTL)? $configTTL : "+10y";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getWebguiRoot ( )
|
||||
|
||||
Returns the path to the WebGUI installation.
|
||||
|
||||
=cut
|
||||
|
||||
readonly getWebguiRoot => my %webguiRoot;
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 loadAllConfigs ( webguiRoot )
|
||||
|
|
@ -166,57 +155,39 @@ A boolean value that when set to true tells the config system not to store the c
|
|||
=cut
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $webguiPath = Cwd::realpath(shift);
|
||||
my $filename = shift;
|
||||
my $noCache = shift;
|
||||
my $fullPath = Cwd::realpath($webguiPath.'/etc/'.$filename);
|
||||
if (exists $config{$fullPath}) {
|
||||
return $config{$fullPath};
|
||||
} else {
|
||||
my $self = Config::JSON->new($fullPath);
|
||||
register($self, $class);
|
||||
$webguiRoot{id $self} = $webguiPath;
|
||||
$config{$filename} = $self unless $noCache;
|
||||
return $self;
|
||||
}
|
||||
my $class = shift;
|
||||
my $filename = shift;
|
||||
my $noCache = shift;
|
||||
if (!File::Spec->file_name_is_absolute($filename)) {
|
||||
Cwd::realpath($filename = File::Spec->catfile(WebGUI::Paths->configBase, $filename));
|
||||
}
|
||||
if (exists $config{$filename}) {
|
||||
return $config{$filename};
|
||||
}
|
||||
else {
|
||||
my $self = $class->SUPER::new($fullPath);
|
||||
$config{$filename} = $self unless $noCache;
|
||||
return $self;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 readAllConfigs ( webguiRoot )
|
||||
=head2 readAllConfigs ( )
|
||||
|
||||
Reads all the config file data for all defined sites and returns a hash reference containing WebGUI::Config objects keyed by filename. This is a class method.
|
||||
|
||||
Example: $configs->{$filename};
|
||||
|
||||
=head3 webguiRoot
|
||||
|
||||
The path to the WebGUI installation.
|
||||
|
||||
=cut
|
||||
|
||||
sub readAllConfigs {
|
||||
my $class = shift;
|
||||
my $webguiPath = shift;
|
||||
opendir my $dh, $webguiPath."/etc";
|
||||
my @files = readdir $dh;
|
||||
closedir $dh;
|
||||
my %configs;
|
||||
foreach my $file (@files) {
|
||||
next
|
||||
if $file !~ /\.conf$/
|
||||
|| $file =~ /^\./
|
||||
|| $file eq 'log.conf'
|
||||
|| $file eq 'spectre.conf';
|
||||
eval {
|
||||
$configs{$file} = WebGUI::Config->new($webguiPath,$file)
|
||||
};
|
||||
if ($@) {
|
||||
warn "Config file ".$file." looks to be corrupt or have a syntax error.";
|
||||
}
|
||||
}
|
||||
my @configs = WebGUI::Paths->siteConfigs;
|
||||
my %configs = map {
|
||||
$_ => $class->new($_);
|
||||
} @configs
|
||||
return \%configs;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,12 +48,9 @@ sub handler {
|
|||
my $session = shift;
|
||||
if ($session->setting->get("specialState") eq "upgrading") {
|
||||
$session->http->sendHeader;
|
||||
my $output = "";
|
||||
open(my $FILE,"<",$session->config->getWebguiRoot."/www/maintenance.html");
|
||||
while (<$FILE>) {
|
||||
$output .= $_;
|
||||
}
|
||||
close($FILE);
|
||||
open my $fh, '<', $session->config->get('maintenancePage');
|
||||
my $output = do { local $/; <$fh> };
|
||||
close $fh;
|
||||
return $output;
|
||||
}
|
||||
return undef;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package WebGUI::Image::Font;
|
|||
|
||||
use strict;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::Paths;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -72,7 +73,7 @@ sub getFile {
|
|||
if ($self->getStorageId) {
|
||||
return WebGUI::Storage->get($self->session, $self->getStorageId)->getPath($self->getFilename);
|
||||
} else {
|
||||
return $self->session->config->getWebguiRoot."/lib/default.ttf"
|
||||
return WebGUI::Paths->var . '/default.ttf';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use WebGUI::Asset::Template;
|
|||
use WebGUI::Macro;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::TabForm;
|
||||
use WebGUI::Pluggable;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -190,29 +191,6 @@ sub _linkTOC {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _getHelpFilesList ( $session )
|
||||
|
||||
Utility routine for returning a list of all Help files in the lib/WebGUI/Help folder.
|
||||
|
||||
=cut
|
||||
|
||||
sub _getHelpFilesList {
|
||||
my $session = shift;
|
||||
my $dir = join '/', $session->config->getWebguiRoot,"lib","WebGUI","Help";
|
||||
opendir (DIR,$dir) or $session->errorHandler->fatal("Can't open Help directory!");
|
||||
my @files;
|
||||
foreach my $file (readdir DIR) {
|
||||
next unless $file =~ /.pm$/;
|
||||
my $modName;
|
||||
($modName = $file) =~ s/\.pm$//;
|
||||
push @files, [ $file, $modName ];
|
||||
}
|
||||
closedir(DIR);
|
||||
return @files;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _related ( $session, $related )
|
||||
|
||||
Utility routine for returning a list of topics related the the current help
|
||||
|
|
@ -380,18 +358,18 @@ sub www_viewHelpIndex {
|
|||
my $session = shift;
|
||||
return $session->privilege->insufficient() unless canView($session);
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
my @helpIndex;
|
||||
my @files = _getHelpFilesList($session,);
|
||||
foreach my $fileSet (@files) {
|
||||
my $namespace = $fileSet->[1];
|
||||
my $help = _load($session,$namespace);
|
||||
foreach my $key (keys %{$help}) {
|
||||
my @helpIndex;
|
||||
my @modules = WebGUI::Pluggable::findAndLoad('WebGUI::Help');
|
||||
for my $namespace (@modules) {
|
||||
$namespace =~ s/^WebGUI::Help:://;
|
||||
my $help = _load($session,$namespace);
|
||||
foreach my $key (keys %{$help}) {
|
||||
next if $help->{$key}{private};
|
||||
my $title = $i18n->get($help->{$key}{title},$namespace);
|
||||
next unless $title;
|
||||
push @helpIndex, [$namespace, $key, $title];
|
||||
}
|
||||
push @helpIndex, [$namespace, $key, $title];
|
||||
}
|
||||
}
|
||||
my $output = '<table width="100%" class="content"><tr><td valign="top">';
|
||||
my $halfway = round(@helpIndex / 2);
|
||||
my $i = 0;
|
||||
|
|
|
|||
|
|
@ -44,12 +44,13 @@ BEGIN {
|
|||
configBase => catdir($root, 'etc'),
|
||||
logConfig => catfile($root, 'etc', 'log.conf'),
|
||||
spectreConfig => catfile($root, 'etc', 'spectre.conf'),
|
||||
upgradesPath => catfile($root, 'var', 'upgrades'),
|
||||
upgrades => catfile($root, 'docs', 'upgrades'),
|
||||
preloadCustom => catfile($root, 'sbin', 'preload.custom'),
|
||||
preloadExclusions => catfile($root, 'sbin', 'preload.exclude'),
|
||||
extras => catdir($root, 'www', 'extras'),
|
||||
defaultUploads => catdir($root, 'www', 'uploads'),
|
||||
defaultCreateSQL => catdir($root, 'var', 'create.sql'),
|
||||
defaultCreateSQL => catdir($root, 'docs', 'create.sql'),
|
||||
var => catdir($root, 'var'),
|
||||
);
|
||||
for my $sub (keys %paths) {
|
||||
my $path = $paths{$sub};
|
||||
|
|
|
|||
|
|
@ -209,13 +209,7 @@ sub exportAssetCollateral {
|
|||
$reportSession->output->print(
|
||||
' ' . $message . '<br />');
|
||||
}
|
||||
my $exportSession = WebGUI::Session->open(
|
||||
$self->session->config->getWebguiRoot,
|
||||
$self->session->config->getFilename,
|
||||
undef,
|
||||
undef,
|
||||
$self->session->getId,
|
||||
);
|
||||
my $exportSession = WebGUI::Session->duplicate;
|
||||
|
||||
# open another session as the user doing the exporting...
|
||||
my $selfdupe = WebGUI::Asset->newById( $exportSession, $self->getId );
|
||||
|
|
|
|||
|
|
@ -273,7 +273,6 @@ Creates a new session using the same WebGUI root, config file, and user.
|
|||
sub duplicate {
|
||||
my $self = shift;
|
||||
my $newSession = WebGUI::Session->open(
|
||||
$self->config->getWebguiRoot,
|
||||
$self->config->getFilename,
|
||||
undef,
|
||||
undef,
|
||||
|
|
@ -460,7 +459,7 @@ sub open {
|
|||
my $configFile = shift;
|
||||
my $request = shift;
|
||||
my $server = shift;
|
||||
my $config = WebGUI::Config->new($webguiRoot,$configFile);
|
||||
my $config = WebGUI::Config->new($configFile);
|
||||
my $self = {_config=>$config, _server=>$server};
|
||||
bless $self , $class;
|
||||
$self->{_request} = $request if (defined $request);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package WebGUI::Session::ErrorHandler;
|
|||
|
||||
use strict;
|
||||
use Log::Log4perl;
|
||||
use WebGUI::Paths;
|
||||
#use Apache2::RequestUtil;
|
||||
use JSON;
|
||||
use HTML::Entities qw(encode_entities);
|
||||
|
|
@ -324,7 +325,7 @@ An active WebGUI::Session object.
|
|||
sub new {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
Log::Log4perl->init_once( $session->config->getWebguiRoot."/etc/log.conf" );
|
||||
Log::Log4perl->init_once( WebGUI::Paths->logConfig );
|
||||
my $logger = Log::Log4perl->get_logger($session->config->getFilename);
|
||||
bless {_queryCount=>0, _logger=>$logger, _session=>$session}, $class;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ use Image::Magick;
|
|||
use Path::Class::Dir;
|
||||
use Storable ();
|
||||
use WebGUI::Utility qw(isIn);
|
||||
use WebGUI::Paths;
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -257,7 +258,7 @@ sub addFileFromCaptcha {
|
|||
$self->session->errorHandler->warn("Error adding noise: $error");
|
||||
}
|
||||
# AddNoise generates a different average color depending on library. This is ugly, but the best I can see for now
|
||||
$error = $image->Annotate(font=>$self->session->config->getWebguiRoot."/lib/default.ttf", pointsize=>40, skewY=>0, skewX=>0, gravity=>'center', fill=>'#ffffff', antialias=>'true', text=>$challenge);
|
||||
$error = $image->Annotate(font=>WebGUI::Paths->var.'/default.ttf', pointsize=>40, skewY=>0, skewX=>0, gravity=>'center', fill=>'#ffffff', antialias=>'true', text=>$challenge);
|
||||
if($error) {
|
||||
$self->session->errorHandler->warn("Error Annotating image: $error");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,65 +0,0 @@
|
|||
package WebGUI::URL::Credits;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use Apache2::Const -compile => qw(OK DECLINED);
|
||||
use APR::Finfo ();
|
||||
use APR::Const -compile => qw(FINFO_NORM);
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::URL::Credits
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
A URL handler that displays the credits file.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::URL::Credits;
|
||||
my $status = WebGUI::URL::Credits::handler($r, $s, $config);
|
||||
|
||||
=head1 SUBROUTINES
|
||||
|
||||
These subroutines are available from this package:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 handler ( request, server, config )
|
||||
|
||||
The Apache request handler for this package.
|
||||
|
||||
=cut
|
||||
|
||||
sub handler {
|
||||
my ($request, $server, $config) = @_;
|
||||
my $filename = $config->getWebguiRoot."/docs/credits.txt";
|
||||
$request->push_handlers(PerlResponseHandler => sub {
|
||||
$request->content_type('text/plain');
|
||||
$request->sendfile($filename);
|
||||
return Apache2::Const::OK;
|
||||
});
|
||||
$request->push_handlers(PerlTransHandler => sub { return Apache2::Const::OK });
|
||||
$request->push_handlers(PerlMapToStorageHandler => sub { return Apache2::Const::OK });
|
||||
return Apache2::Const::OK;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ sub execute {
|
|||
$self->session->errorHandler->warn("More than 1 old userLoginLog rows found, removing offending rows");
|
||||
$self->session->db->write("delete from userLoginLog where lastPageViewed = timeStamp and sessionId = ? ", [$sessionId] );
|
||||
}
|
||||
my $session = WebGUI::Session->open($self->session->config->getWebguiRoot, $self->session->config->getFilename, undef, undef, $sessionId, 1);
|
||||
my $session = WebGUI::Session->open($self->session->config->getFilename, undef, undef, $sessionId, 1);
|
||||
if (defined $session) {
|
||||
$session->var->end;
|
||||
$session->close;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue