Merge branch 'master' into WebGUI8

This commit is contained in:
Graham Knop 2010-04-13 07:50:02 -05:00
commit 2400f19099
797 changed files with 33894 additions and 27196 deletions

View file

@ -298,8 +298,11 @@ A string representing the output format for the date. Defaults to '%z %Z'. You c
=cut
sub epochToHuman {
my $self = shift;
my $epoch = shift || time();
my $self = shift;
my $epoch = shift;
if (!defined $epoch || $epoch eq '') {
$epoch = time();
}
my $i18n = WebGUI::International->new($self->session);
my $language = $i18n->getLanguage($self->session->user->profileField('language'));
my $locale = $language->{languageAbbreviation} || 'en';
@ -950,7 +953,7 @@ sub setToEpoch {
}
unless ($dt) {
$self->session->errorHandler->warn("Could not format date $set for epoch. Returning current time");
return $self->time();
return time();
}
return $dt->epoch;
}
@ -959,7 +962,8 @@ sub setToEpoch {
=head2 time ( )
Returns an epoch date for now.
DEPRECATED - This method is deprecated, and should not be used in new code. Use
the perl built in function time().
=cut

View file

@ -188,6 +188,9 @@ sub requestNotViewed {
Returns true if a https request was made.
HTTP_SSLPROXY is set by mod_proxy in the WRE so that WebGUI knows that the original request
was made via SSL.
=cut
sub sslRequest {

View file

@ -232,6 +232,7 @@ sub fatal {
if (! defined $self->session->db(1)) {
# We can't even _determine_ whether we can show the debug text. Punt.
$self->session->output->print("<h1>Fatal Internal Error</h1>");
$self->session->output->print("<p>".$message."</p>");
}
elsif ($self->canShowDebug()) {
$self->session->output->print("<h1>WebGUI Fatal Error</h1><p>Something unexpected happened that caused this system to fault.</p>\n",1);

View file

@ -205,19 +205,36 @@ sub getStreamedFile {
#-------------------------------------------------------------------
=head2 ifModifiedSince ( epoch )
=head2 ifModifiedSince ( epoch [, maxCacheTimeout] )
Returns 1 if the epoch is greater than the modified date check.
=head3 epoch
The date that the requested content was last modified in epoch format.
=head3 maxCacheTimeout
A modifier to the epoch, that allows us to set a maximum timeout where content will appear to
have changed and a new page request will be allowed to be processed.
=cut
sub ifModifiedSince {
my $self = shift;
my $epoch = shift;
my $self = shift;
my $epoch = shift;
my $maxCacheTimeout = shift;
require APR::Date;
my $modified = $self->session->request->headers_in->{'If-Modified-Since'};
return 1 if ($modified eq "");
$modified = APR::Date::parse_http($modified);
##Implement a step function that increments the epoch time in integer multiples of
##the maximum cache time. Used to handle the case where layouts containing macros
##(like assetproxied Navigations) can be periodically updated.
if ($maxCacheTimeout) {
my $delta = time() - $epoch;
$epoch += $delta - ($delta % $maxCacheTimeout);
}
return ($epoch > $modified);
}
@ -291,8 +308,14 @@ sub sendHeader {
}
# in all other cases, set cache, but tell it to ask us every time so we don't mess with recently logged in users
else {
$request->headers_out->set('Last-Modified' => $date);
$request->headers_out->set('Cache-Control' => "must-revalidate, max-age=" . $cacheControl);
if ( $cacheControl eq "none" ) {
$request->headers_out->set("Cache-Control" => "private, max-age=1");
$request->no_cache(1);
}
else {
$request->headers_out->set('Last-Modified' => $date);
$request->headers_out->set('Cache-Control' => "must-revalidate, max-age=" . $cacheControl);
}
# do an extra incantation if the HTTP protocol is really old
if ($request->protocol =~ /(\d\.\d)/ && $1 < 1.1) {
my $date = $datetime->epochToHttp(time() + $cacheControl);

View file

@ -167,7 +167,7 @@ sub delete {
my $pageURL = shift || $self->session->url->getRequestedUrl;
my $confirmText = shift;
if($confirmText) {
$confirmText = qq| onclick="return confirm('$confirmText')" |;
$confirmText = qq| onclick="return confirm('$confirmText');" |;
}
my $i18n = WebGUI::International->new($self->session,'Icon');
my $output = '<p class="toolbarIcon" style="display:inline;vertical-align:middle;"><a href="'.$self->session->url->gateway($pageURL,$urlParams).'" '.$confirmText.'>';

View file

@ -15,6 +15,7 @@ package WebGUI::Session::Scratch;
=cut
use strict;
use WebGUI::International;
=head1 NAME
@ -169,6 +170,19 @@ sub get {
return $self->{_data}{$var};
}
#-------------------------------------------------------------------
=head2 getLanguageOverride ()
Retrieves the language of the session scratch
=cut
sub getLanguageOverride {
my $self = shift;
my $languageOverride = $self->session->scratch->get('language');
return $languageOverride;
}
#-------------------------------------------------------------------
@ -191,7 +205,18 @@ sub new {
bless {_session=>$session, _data=>$scratch}, $class;
}
#-------------------------------------------------------------------
=head2 removeLanguageOverride()
Removes the language scratch variable from the session
=cut
sub removeLanguageOverride {
my $self = shift;
$self->session->scratch->delete('language');
}
#-------------------------------------------------------------------
=head2 session ( )
@ -232,5 +257,30 @@ sub set {
$session->db->write("replace into userSessionScratch (sessionId, name, value) values (?,?,?)", [$id, $name, $value]);
}
#----------------------------------------------------------------------
=head2 setLanguageOverride ( language )
Sets a scratch variable language in the session if the language is installed
=head3 language
The language that should be set into the session
=cut
sub setLanguageOverride {
my $self = shift;
my $language = shift;
my $i18n = WebGUI::International->new($self->session);
if($i18n->getLanguages()->{$language}) {
$self->session->scratch->set("language",$language);
return undef;
}
else {
$self->session->log->error("Language $language is not installed in this site");
return undef;
}
}
1;

View file

@ -64,10 +64,7 @@ The initial value of the setting.
sub add {
my $self = shift;
my $name = shift;
my $value = shift;
$self->{_settings}{$name} = $value;
$self->session->db->write("insert into settings (name,value) values (?,?)",[$name, $value]);
$self->set(@_);
}
#-------------------------------------------------------------------
@ -208,7 +205,7 @@ sub set {
my $name = shift;
my $value = shift;
$self->{_settings}{$name} = $value;
$self->session->db->write("update settings set value=? where name=?",[$value, $name]);
$self->session->db->write("REPLACE INTO settings (name, value) VALUES (?, ?)", [$name, $value]);
}

View file

@ -20,7 +20,7 @@ use Tie::CPHash;
use WebGUI::International;
use WebGUI::Macro;
require WebGUI::Asset;
use WebGUI;
BEGIN { eval { require WebGUI; WebGUI->import } }
use HTML::Entities ();
=head1 NAME

View file

@ -193,7 +193,7 @@ sub gateway {
my $url = $self->session->config->get("gateway").'/'.$pageUrl;
$url =~ s/\/+/\//g;
if ($self->session->setting->get("preventProxyCache") == 1 and !$skipPreventProxyCache) {
$url = $self->append($url,"noCache=".randint(0,1000).':'.$self->session->datetime->time());
$url = $self->append($url,"noCache=".randint(0,1000).':'.time());
}
if ($pairs) {
$url = $self->append($url,$pairs);

View file

@ -186,12 +186,12 @@ sub new {
$self->session->{_sessionId} = $self->{_var}{sessionId};
return $self;
}
if ($self->{_var}{expires} && $self->{_var}{expires} < $session->datetime->time()) { ##Session expired, start a new one with the same Id
if ($self->{_var}{expires} && $self->{_var}{expires} < time()) { ##Session expired, start a new one with the same Id
$self->end;
$self->start(1,$sessionId);
}
elsif ($self->{_var}{sessionId} ne "") { ##Fetched an existing session. Update variables with recent data.
my $time = $session->datetime->time();
my $time = time();
my $timeout = $session->setting->get("sessionTimeout");
$self->{_var}{lastPageView} = $time;
$self->{_var}{lastIP} = $session->env->getIp;
@ -255,7 +255,7 @@ sub start {
my $id = $session->id;
$sessionId = $id->generate if ($sessionId eq "");
my $timeout = $session->setting->get('sessionTimeout');
my $time = $session->datetime->time();
my $time = time();
$self->{_var} = {
expires => $time + $timeout,
lastPageView => $time,