fixed some bugs in URL/Content handlers. fixed some bugs in Gallery.
This commit is contained in:
parent
4c70aa4c71
commit
30f22c9b7a
10 changed files with 96 additions and 67 deletions
Binary file not shown.
Binary file not shown.
|
|
@ -390,6 +390,3 @@ sub createNewTemplatesFolder {
|
|||
return $newFolder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
>>>>>>> .merge-right.r5144
|
||||
|
|
|
|||
|
|
@ -564,14 +564,18 @@ sub view_thumbnails {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_addArchive ( )
|
||||
=head2 www_addArchive ( params )
|
||||
|
||||
Show the form to add an archive of files to this gallery.
|
||||
Show the form to add an archive of files to this gallery. C<params> is a hash
|
||||
reference of parameters with the following keys:
|
||||
|
||||
error => An error message to show to the user.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_addArchive {
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
|
||||
return $self->session->privilege->insufficient unless $self->canAddFile;
|
||||
|
||||
|
|
@ -579,6 +583,8 @@ sub www_addArchive {
|
|||
my $form = $self->session->form;
|
||||
my $var = $self->getTemplateVars;
|
||||
|
||||
$var->{ error } = $params->{ error };
|
||||
|
||||
$var->{ form_start }
|
||||
= WebGUI::Form::formHeader( $session, {
|
||||
action => $self->getUrl('func=addArchiveSave'),
|
||||
|
|
@ -639,6 +645,11 @@ sub www_addArchiveSave {
|
|||
|
||||
my $storageId = $form->get("archive", "File");
|
||||
my $storage = WebGUI::Storage->get( $session, $storageId );
|
||||
if (!$storage) {
|
||||
return $self->www_addArchive({
|
||||
error => sprintf $i18n->get('addArchive error too big'),
|
||||
});
|
||||
}
|
||||
my $filename = $storage->getPath( $storage->getFiles->[0] );
|
||||
|
||||
$self->addArchive( $filename, $properties );
|
||||
|
|
|
|||
|
|
@ -276,12 +276,12 @@ Returns a tarball file for the user to download containing the package data.
|
|||
=cut
|
||||
|
||||
sub www_exportPackage {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless ($self->get("isPackage") && $self->canEdit && $self->session->user->isInGroup(4));
|
||||
my $storage = $self->exportPackage;
|
||||
my $filename = $storage->getFiles->[0];
|
||||
$self->session->http->setRedirect($storage->getUrl($storage->getFiles->[0]));
|
||||
return "redirect";
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless ($self->get("isPackage") && $self->canEdit && $self->session->user->isInGroup(4));
|
||||
my $storage = $self->exportPackage;
|
||||
my $filename = $storage->getFiles->[0];
|
||||
$self->session->http->setRedirect($storage->getUrl($storage->getFiles->[0]));
|
||||
return "redirect";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -84,60 +84,65 @@ sub handler {
|
|||
my ($session) = @_;
|
||||
my ($errorHandler, $http, $var, $asset, $request, $config) = $session->quick(qw(errorHandler http var asset request config));
|
||||
my $output = "";
|
||||
if ($errorHandler->canShowPerformanceIndicators) { #show performance indicators if required
|
||||
my $t = [Time::HiRes::gettimeofday()];
|
||||
$output = page($session);
|
||||
$t = Time::HiRes::tv_interval($t) ;
|
||||
if ($output =~ /<\/title>/) {
|
||||
$output =~ s/<\/title>/ : ${t} seconds<\/title>/i;
|
||||
}
|
||||
else {
|
||||
# Kludge.
|
||||
my $mimeType = $http->getMimeType();
|
||||
if ($mimeType eq 'text/css') {
|
||||
$session->output->print("\n/* Page generated in $t seconds. */\n");
|
||||
}
|
||||
elsif ($mimeType eq 'text/html') {
|
||||
$session->output->print("\nPage generated in $t seconds.\n");
|
||||
}
|
||||
else {
|
||||
# Don't apply to content when we don't know how
|
||||
# to modify it semi-safely.
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($errorHandler->canShowPerformanceIndicators) { #show performance indicators if required
|
||||
my $t = [Time::HiRes::gettimeofday()];
|
||||
$output = page($session);
|
||||
$t = Time::HiRes::tv_interval($t) ;
|
||||
if ($output =~ /<\/title>/) {
|
||||
$output =~ s/<\/title>/ : ${t} seconds<\/title>/i;
|
||||
}
|
||||
else {
|
||||
# Kludge.
|
||||
my $mimeType = $http->getMimeType();
|
||||
if ($mimeType eq 'text/css') {
|
||||
$session->output->print("\n/* Page generated in $t seconds. */\n");
|
||||
}
|
||||
elsif ($mimeType eq 'text/html') {
|
||||
$session->output->print("\nPage generated in $t seconds.\n");
|
||||
}
|
||||
else {
|
||||
# Don't apply to content when we don't know how
|
||||
# to modify it semi-safely.
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
my $asset = getAsset($session, getRequestedAssetUrl($session));
|
||||
my $asset = getAsset($session, getRequestedAssetUrl($session));
|
||||
|
||||
# display from cache if page hasn't been modified.
|
||||
if ($var->get("userId") eq "1" && defined $asset && !$http->ifModifiedSince($asset->getContentLastModified)) {
|
||||
$http->setStatus("304","Content Not Modified");
|
||||
$http->sendHeader;
|
||||
$session->close;
|
||||
return Apache2::Const::OK;
|
||||
}
|
||||
# display from cache if page hasn't been modified.
|
||||
if ($var->get("userId") eq "1" && defined $asset && !$http->ifModifiedSince($asset->getContentLastModified)) {
|
||||
$http->setStatus("304","Content Not Modified");
|
||||
$http->sendHeader;
|
||||
$session->close;
|
||||
return Apache2::Const::OK;
|
||||
}
|
||||
|
||||
# return the page.
|
||||
else {
|
||||
$output = page($session, undef, $asset);
|
||||
}
|
||||
}
|
||||
|
||||
my $filename = $http->getStreamedFile();
|
||||
if ((defined $filename) && ($config->get("enableStreamingUploads") eq "1")) {
|
||||
my $ct = guess_media_type($filename);
|
||||
my $oldContentType = $request->content_type($ct);
|
||||
if ($request->sendfile($filename) ) {
|
||||
$session->close;
|
||||
return Apache2::Const::OK;
|
||||
}
|
||||
else {
|
||||
$request->content_type($oldContentType);
|
||||
}
|
||||
}
|
||||
|
||||
# Uhm... why here and not somewhere else? Do content handlers manage their own content
|
||||
# or should the URL handlers do it for them?
|
||||
if ($output eq "redirect") {
|
||||
$http->sendHeader;
|
||||
}
|
||||
|
||||
# return the page.
|
||||
else {
|
||||
$output = page($session, undef, $asset);
|
||||
}
|
||||
}
|
||||
my $filename = $http->getStreamedFile();
|
||||
if ((defined $filename) && ($config->get("enableStreamingUploads") eq "1")) {
|
||||
my $ct = guess_media_type($filename);
|
||||
my $oldContentType = $request->content_type($ct);
|
||||
if ($request->sendfile($filename) ) {
|
||||
$session->close;
|
||||
return Apache2::Const::OK;
|
||||
} else {
|
||||
$request->content_type($oldContentType);
|
||||
}
|
||||
}
|
||||
$http->sendHeader(); #http object will only send the header once per request, so if the above sent a header as part of it's operation, this will do nothing.
|
||||
unless ($http->isRedirect()) {
|
||||
$session->output->print($output);
|
||||
}
|
||||
# ...
|
||||
return $output;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,6 +176,11 @@ our $HELP = {
|
|||
},
|
||||
],
|
||||
variables => {
|
||||
{
|
||||
name => 'error',
|
||||
description => 'helpvar error',
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => 'form_start',
|
||||
description => 'helpvar form_start',
|
||||
|
|
|
|||
|
|
@ -207,7 +207,8 @@ our $HELP = {
|
|||
required => 1,
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
|
||||
'help view' => {
|
||||
title => 'help view title',
|
||||
body => 'help view body',
|
||||
|
|
|
|||
|
|
@ -68,15 +68,15 @@ sub handler {
|
|||
$session->http->sendHeader();
|
||||
$session->output->print($output)
|
||||
}
|
||||
if ($session->errorHandler->canShowDebug()) {
|
||||
$session->output->print($session->errorHandler->showDebug(),1);
|
||||
}
|
||||
if ($session->errorHandler->canShowDebug()) {
|
||||
$session->output->print($session->errorHandler->showDebug(),1);
|
||||
}
|
||||
}
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
WebGUI::Affiliate::grabReferral($session); # process affiliate tracking request
|
||||
}
|
||||
WebGUI::Affiliate::grabReferral($session); # process affiliate tracking request
|
||||
$session->close;
|
||||
return Apache2::Const::OK;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -294,6 +294,16 @@ our $I18N = {
|
|||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar error' => {
|
||||
message => 'An error message to show the user. Only defined when something went wrong.',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'addArchive error too big' => {
|
||||
message => 'The archive you are trying to upload is too big. Please try again.',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue