Merge branch 'WebGUI8' into psgi
Conflicts: sbin/testEnvironment.pl
This commit is contained in:
commit
f16ba76b86
109 changed files with 1546 additions and 2197 deletions
|
|
@ -80,7 +80,7 @@ property url => (
|
|||
builder => '_default_url',
|
||||
);
|
||||
sub _default_url {
|
||||
return $_[0]->assetId;
|
||||
return $_[0]->fixUrl;
|
||||
}
|
||||
|
||||
around url => sub {
|
||||
|
|
@ -307,25 +307,16 @@ sub _build_className {
|
|||
}
|
||||
has keywords => (
|
||||
is => 'rw',
|
||||
init_arg => undef,
|
||||
builder => '_build_assetKeywords',
|
||||
lazy => 1,
|
||||
traits => [ 'WebGUI::Definition::Meta::Settable' ],
|
||||
);
|
||||
sub _build_assetKeywords {
|
||||
my $session = shift->session;
|
||||
return WebGUI::Keyword->new($session);
|
||||
}
|
||||
|
||||
around keywords => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
if (@_) {
|
||||
return $self->$orig->setKeywordsForAsset({asset => $self, keywords => $_[0], });
|
||||
}
|
||||
else {
|
||||
return $self->$orig->getKeywordsForAsset({asset => $self});
|
||||
}
|
||||
};
|
||||
my $session = $self->session;
|
||||
my $keywords = WebGUI::Keyword->new($session);
|
||||
return $keywords->getKeywordsForAsset({asset => $self, asArrayRef => 1 });
|
||||
}
|
||||
|
||||
around BUILDARGS => sub {
|
||||
my $orig = shift;
|
||||
|
|
@ -374,7 +365,7 @@ around BUILDARGS => sub {
|
|||
if (defined $properties) {
|
||||
$properties->{session} = $session;
|
||||
return $className->$orig($properties);
|
||||
}
|
||||
}
|
||||
$session->errorHandler->error("Something went wrong trying to instanciate a '$className' with assetId '$assetId', but I don't know what!");
|
||||
return undef;
|
||||
};
|
||||
|
|
@ -710,7 +701,9 @@ sub fixUrl {
|
|||
|
||||
# build a URL from the parent
|
||||
unless ($url) {
|
||||
$url = $self->getParent->url;
|
||||
if (my $parent = $self->getParent) {
|
||||
$url = $parent->url;
|
||||
}
|
||||
$url =~ s/(.*)\..*/$1/;
|
||||
$url .= '/'.$self->menuTitle;
|
||||
}
|
||||
|
|
@ -845,26 +838,6 @@ sub getClassById {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getWwwCacheKey ( )
|
||||
|
||||
Returns a cache object specific to this asset, and whether or not the request is in SSL mode.
|
||||
|
||||
=cut
|
||||
|
||||
sub getWwwCacheKey {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $method = shift;
|
||||
my $cacheKey = join '_', @_, $self->getId;
|
||||
if ($session->env->sslRequest) {
|
||||
$cacheKey .= '_ssl';
|
||||
}
|
||||
return $cacheKey;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getContainer ( )
|
||||
|
|
@ -883,6 +856,23 @@ sub getContainer {
|
|||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getContentLastModified
|
||||
|
||||
Returns the overall modification time of the object and its content in Unix
|
||||
epoch format, for the purpose of the Last-Modified HTTP header. Override this
|
||||
for subclasses that contain content that is not solely lastModified property,
|
||||
which gets updated every time update() is called.
|
||||
|
||||
=cut
|
||||
|
||||
sub getContentLastModified {
|
||||
my $self = shift;
|
||||
return $self->get("lastModified");
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDefault ( session )
|
||||
|
|
@ -1711,18 +1701,34 @@ sub getUrl {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getContentLastModified
|
||||
=head2 getViewCacheKey ( )
|
||||
|
||||
Returns the overall modification time of the object and its content in Unix
|
||||
epoch format, for the purpose of the Last-Modified HTTP header. Override this
|
||||
for subclasses that contain content that is not solely lastModified property,
|
||||
which gets updated every time update() is called.
|
||||
Returns the cache key for content generated by this Asset's view method.
|
||||
|
||||
=cut
|
||||
|
||||
sub getContentLastModified {
|
||||
sub getViewCacheKey {
|
||||
my $self = shift;
|
||||
return $self->get("lastModified");
|
||||
return 'view_'.$self->assetId;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getWwwCacheKey ( )
|
||||
|
||||
Returns a cache object specific to this asset, and whether or not the request is in SSL mode.
|
||||
|
||||
=cut
|
||||
|
||||
sub getWwwCacheKey {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $method = shift;
|
||||
my $cacheKey = join '_', @_, $self->getId;
|
||||
if ($session->env->sslRequest) {
|
||||
$cacheKey .= '_ssl';
|
||||
}
|
||||
return $cacheKey;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2468,6 +2474,7 @@ sub write {
|
|||
|
||||
# update the asset's size, which also purges the cache.
|
||||
$self->setSize();
|
||||
WebGUI::Keyword->new($self->session)->setKeywordsForAsset({ asset => $self, keywords => $self->keywords });
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -346,8 +346,8 @@ sub www_editSubmission {
|
|||
my $assetId = $self ? $self->getId : $params->{assetId} || $session->form->get('assetId') || 'new';
|
||||
|
||||
if( $assetId ne 'new' ) {
|
||||
$self ||= WebGUI::Asset->newByDynamicClass($session,$assetId);
|
||||
if (!defined $self) {
|
||||
$self ||= eval { WebGUI::Asset->newById($session,$assetId); };
|
||||
if (Exception::Class->caught()) {
|
||||
$session->errorHandler->error(__PACKAGE__ . " - failed to instanciate asset with assetId $assetId");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,70 @@ package WebGUI::Asset::EMSSubmissionForm;
|
|||
=cut
|
||||
|
||||
use strict;
|
||||
use Moose;
|
||||
use WebGUI::Definition::Asset;
|
||||
extends 'WebGUI::Asset';
|
||||
|
||||
define assetName => ['assetName','Asset_EMSSubmissionForm'];
|
||||
define icon => 'EMSSubmissionForm.gif';
|
||||
define tableName => 'EMSSubmissionForm';
|
||||
|
||||
property canSubmitGroupId => (
|
||||
tab => "security",
|
||||
fieldType => "group",
|
||||
default => 2,
|
||||
label => ["can submit group label", 'Asset_EMSSubmissionForm'],
|
||||
hoverHelp => ["can submit group label help", 'Asset_EMSSubmissionForm']
|
||||
);
|
||||
property daysBeforeCleanup => (
|
||||
tab => "properties",
|
||||
fieldType => "integer",
|
||||
default => 7,
|
||||
label => ["days before cleanup label", 'Asset_EMSSubmissionForm'],
|
||||
hoverHelp => ["days before cleanup label help", 'Asset_EMSSubmissionForm']
|
||||
);
|
||||
property deleteCreatedItems => (
|
||||
tab => "properties",
|
||||
fieldType => "yesNo",
|
||||
default => undef,
|
||||
label => ["delete created items label", 'Asset_EMSSubmissionForm'],
|
||||
hoverHelp => ["delete created items label help", 'Asset_EMSSubmissionForm']
|
||||
);
|
||||
property submissionDeadline => (
|
||||
tab => "properties",
|
||||
fieldType => "Date",
|
||||
builder => '_default_submissionDeadline',
|
||||
label => ["submission deadline label", 'Asset_EMSSubmissionForm'],
|
||||
hoverHelp => ["submission deadline label help", 'Asset_EMSSubmissionForm']
|
||||
);
|
||||
sub _default_submissionDeadline {
|
||||
return time() + ( 30 * 24 * 60 * 60 ); # 30 days
|
||||
}
|
||||
property pastDeadlineMessage => (
|
||||
tab => "properties",
|
||||
fieldType => "HTMLArea",
|
||||
builder => '_default_pastDeadlineMessage',
|
||||
lazy => 1,
|
||||
label => ["past deadline label", 'Asset_EMSSubmissionForm'],
|
||||
hoverHelp => ["past deadline label help", 'Asset_EMSSubmissionForm']
|
||||
);
|
||||
sub _default_pastDeadlineMessage {
|
||||
my $self = shift;
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset_EMSSubmissionForm');
|
||||
return $i18n->get('past deadline message');
|
||||
}
|
||||
property formDescription => (
|
||||
tab => "properties",
|
||||
fieldType => "textarea",
|
||||
default => '{ }',
|
||||
label => ["form dscription label", 'Asset_EMSSubmissionForm'],
|
||||
hoverHelp => ["form dscription label help", 'Asset_EMSSubmissionForm']
|
||||
);
|
||||
|
||||
use Tie::IxHash;
|
||||
use base 'WebGUI::Asset';
|
||||
use JSON;
|
||||
use WebGUI::Utility;
|
||||
with 'WebGUI::Role::Asset::AlwaysHidden';
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -84,81 +144,6 @@ sub canSubmit {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, definition )
|
||||
|
||||
defines asset properties for New Asset instances. You absolutely need
|
||||
this method in your new Assets.
|
||||
|
||||
=head3 session
|
||||
|
||||
=head3 definition
|
||||
|
||||
A hash reference passed in from a subclass definition.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmissionForm" );
|
||||
tie my %properties, 'Tie::IxHash', (
|
||||
canSubmitGroupId => {
|
||||
tab => "security",
|
||||
fieldType => "group",
|
||||
defaultValue => 2,
|
||||
label => $i18n->get("can submit group label"),
|
||||
hoverHelp => $i18n->get("can submit group label help")
|
||||
},
|
||||
daysBeforeCleanup => {
|
||||
tab => "properties",
|
||||
fieldType => "integer",
|
||||
defaultValue => 7,
|
||||
label => $i18n->get("days before cleanup label"),
|
||||
hoverHelp => $i18n->get("days before cleanup label help")
|
||||
},
|
||||
deleteCreatedItems => {
|
||||
tab => "properties",
|
||||
fieldType => "yesNo",
|
||||
defaultValue => undef,
|
||||
label => $i18n->get("delete created items label"),
|
||||
hoverHelp => $i18n->get("delete created items label help")
|
||||
},
|
||||
submissionDeadline => {
|
||||
tab => "properties",
|
||||
fieldType => "Date",
|
||||
defaultValue => time + ( 30 * 24 * 60 * 60 ) , # 30 days
|
||||
label => $i18n->get("submission deadline label"),
|
||||
hoverHelp => $i18n->get("submission deadline label help")
|
||||
},
|
||||
pastDeadlineMessage => {
|
||||
tab => "properties",
|
||||
fieldType => "HTMLArea",
|
||||
defaultValue => $i18n->get('past deadline message'),
|
||||
label => $i18n->get("past deadline label"),
|
||||
hoverHelp => $i18n->get("past deadline label help")
|
||||
},
|
||||
formDescription => {
|
||||
tab => "properties",
|
||||
fieldType => "textarea",
|
||||
defaultValue => '{ }',
|
||||
label => $i18n->get("form dscription label"),
|
||||
hoverHelp => $i18n->get("form dscription label help")
|
||||
},
|
||||
);
|
||||
push @{$definition}, {
|
||||
assetName => $i18n->get('assetName'),
|
||||
icon => 'EMSSubmissionForm.gif',
|
||||
autoGenerateForms => 1,
|
||||
tableName => 'EMSSubmissionForm',
|
||||
className => 'WebGUI::Asset::EMSSubmissionForm',
|
||||
properties => \%properties,
|
||||
};
|
||||
return $class->SUPER::definition( $session, $definition );
|
||||
} ## end sub definition
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 ems
|
||||
|
||||
returns the ems ansestor of this asset
|
||||
|
|
@ -187,131 +172,154 @@ optional set of possibly incorrect submission form params
|
|||
=cut
|
||||
|
||||
sub www_editSubmissionForm {
|
||||
my $this = shift;
|
||||
my $self;
|
||||
my $parent;
|
||||
if( $this eq __PACKAGE__ ) { # called as constructor or menu
|
||||
$parent = shift;
|
||||
} else {
|
||||
$self = $this;
|
||||
$parent = $self->getParent;
|
||||
}
|
||||
my $params = shift || { };
|
||||
my $session = $parent->session;
|
||||
my $i18n = WebGUI::International->new($session,'Asset_EventManagementSystem');
|
||||
my $assetId = $self ? $self->getId : $params->{assetId} || $session->form->get('assetId');
|
||||
my $this = shift;
|
||||
my $self;
|
||||
my $parent;
|
||||
if ( $this eq __PACKAGE__ ) { # called as constructor or menu
|
||||
$parent = shift;
|
||||
}
|
||||
else {
|
||||
$self = $this;
|
||||
$parent = $self->getParent;
|
||||
}
|
||||
my $params = shift || {};
|
||||
my $session = $parent->session;
|
||||
my $i18n = WebGUI::International->new( $session, 'Asset_EventManagementSystem' );
|
||||
my $assetId = $self ? $self->getId : $params->{assetId} || $session->form->get('assetId');
|
||||
|
||||
if( ! defined( $assetId ) ) {
|
||||
my $res = $parent->getLineage(['children'],{ returnObjects => 1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
|
||||
} );
|
||||
if( scalar(@$res) == 1 ) {
|
||||
$self = $res->[0];
|
||||
$assetId = $self->getId;
|
||||
} else {
|
||||
my $makeAnchorList =sub{ my $u=shift; my $n=shift; my $d=shift;
|
||||
return qq{<li><a href='$u' title='$d'>$n</a></li>} } ;
|
||||
my $listOfLinks = join '', ( map {
|
||||
$makeAnchorList->(
|
||||
$_->getQueueUrl,
|
||||
$_->get('title'),
|
||||
WebGUI::HTML::filter($_->get('description'),'all')
|
||||
)
|
||||
} ( @$res ) );
|
||||
my $title = $i18n->get('select form to edit') ;
|
||||
my $content = '<h1>' . $title . '</h1><ul>' . $listOfLinks . '</ul>' ;
|
||||
if( $params->{asHashRef} ) {
|
||||
return { text => $content, title => $title, } ;
|
||||
} elsif( $session->form->get('asJson') ) {
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
return JSON->new->encode( { text => $content, title => $title, id => 'list' . rand } );
|
||||
} else {
|
||||
$session->http->setMimeType( 'text/html' );
|
||||
return $parent->ems->processStyle( $content );
|
||||
}
|
||||
}
|
||||
} elsif( $assetId ne 'new' ) {
|
||||
$self ||= WebGUI::Asset->newByDynamicClass($session,$assetId);
|
||||
if (!defined($self)) {
|
||||
$session->errorHandler->error(__PACKAGE__ . " - failed to instanciate asset with assetId $assetId");
|
||||
}
|
||||
if ( !defined($assetId) ) {
|
||||
my $res = $parent->getLineage(
|
||||
['children'], {
|
||||
returnObjects => 1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
|
||||
}
|
||||
);
|
||||
if ( scalar(@$res) == 1 ) {
|
||||
$self = $res->[0];
|
||||
$assetId = $self->getId;
|
||||
}
|
||||
my $asset = $self || $parent;
|
||||
my $url = $asset->getUrl('func=editSubmissionFormSave');
|
||||
my $newform = WebGUI::HTMLForm->new( $session, action => $url );
|
||||
$newform->hidden(name => 'assetId', value => $assetId);
|
||||
my @fieldNames = qw/title description startDate duration seatsAvailable location/;
|
||||
my $fields;
|
||||
my @defs = reverse @{WebGUI::Asset::EMSSubmission->definition($session)};
|
||||
for my $def ( @defs ) {
|
||||
foreach my $fieldName ( @fieldNames ) {
|
||||
my $properties = $def->{properties};
|
||||
if( defined $properties->{$fieldName} ) {
|
||||
$fields->{$fieldName} = { %{$properties->{$fieldName}} }; # a simple first level copy
|
||||
# field definitions don't contain their own name, we will need it later on
|
||||
$fields->{$fieldName}{fieldId} = $fieldName;
|
||||
};
|
||||
}
|
||||
}
|
||||
for my $metaField ( @{$parent->getEventMetaFields} ) {
|
||||
push @fieldNames, $metaField->{fieldId};
|
||||
$fields->{$metaField->{fieldId}} = { %$metaField }; # a simple first level copy
|
||||
# meta fields call it data type, we copy it to simplify later on
|
||||
$fields->{$metaField->{fieldId}}{fieldType} = $metaField->{dataType};
|
||||
$fields->{$metaField->{fieldId}}{hoverHelp} = $metaField->{helpText};
|
||||
}
|
||||
$newform->hidden( name => 'fieldNames', value => join( ' ', @fieldNames ) );
|
||||
@defs = reverse @{WebGUI::Asset::EMSSubmissionForm->definition($session)};
|
||||
for my $def ( @defs ) {
|
||||
my $properties = $def->{properties};
|
||||
for my $fieldName ( qw/title menuTitle url description canSubmitGroupId daysBeforeCleanup
|
||||
deleteCreatedItems submissionDeadline pastDeadlineMessage/ ) {
|
||||
if( defined $properties->{$fieldName} ) {
|
||||
my %fieldParams = %{$properties->{$fieldName}};
|
||||
$fieldParams{name} = $fieldName;
|
||||
$fieldParams{value} = $params->{$fieldName} || $self ? $self->get($fieldName) : undef ;
|
||||
$newform->dynamicField(%fieldParams);
|
||||
}
|
||||
}
|
||||
else {
|
||||
my $makeAnchorList = sub {
|
||||
my $u = shift;
|
||||
my $n = shift;
|
||||
my $d = shift;
|
||||
return qq{<li><a href='$u' title='$d'>$n</a></li>};
|
||||
};
|
||||
my $listOfLinks = join '', (
|
||||
map {
|
||||
$makeAnchorList->(
|
||||
$_->getQueueUrl, $_->get('title'), WebGUI::HTML::filter( $_->get('description'), 'all' )
|
||||
)
|
||||
} (@$res)
|
||||
);
|
||||
my $title = $i18n->get('select form to edit');
|
||||
my $content = '<h1>' . $title . '</h1><ul>' . $listOfLinks . '</ul>';
|
||||
if ( $params->{asHashRef} ) {
|
||||
return { text => $content, title => $title, };
|
||||
}
|
||||
elsif ( $session->form->get('asJson') ) {
|
||||
$session->http->setMimeType('application/json');
|
||||
return JSON->new->encode( { text => $content, title => $title, id => 'list' . rand } );
|
||||
}
|
||||
else {
|
||||
$session->http->setMimeType('text/html');
|
||||
return $parent->ems->processStyle($content);
|
||||
}
|
||||
} ## end else [ if ( scalar(@$res) == ...)]
|
||||
} ## end if ( !defined($assetId...))
|
||||
elsif ( $assetId ne 'new' ) {
|
||||
$self ||= WebGUI::Asset->newById( $session, $assetId );
|
||||
if ( !defined($self) ) {
|
||||
$session->errorHandler->error( __PACKAGE__ . " - failed to instanciate asset with assetId $assetId" );
|
||||
}
|
||||
}
|
||||
my $asset = $self || $parent;
|
||||
my $url = $asset->getUrl('func=editSubmissionFormSave');
|
||||
my $newform = WebGUI::HTMLForm->new( $session, action => $url );
|
||||
$newform->hidden( name => 'assetId', value => $assetId );
|
||||
my @fieldNames = qw/title description startDate duration seatsAvailable location/;
|
||||
my $fields;
|
||||
my @defs = reverse @{ WebGUI::Asset::EMSSubmission->definition($session) };
|
||||
|
||||
my $formDescription = $params->{formDescription} || $self ? $self->getFormDescription : { };
|
||||
for my $fieldId ( @fieldNames ) {
|
||||
next if $fieldId eq 'submissionStatus';
|
||||
my $field = $fields->{$fieldId};
|
||||
$newform->yesNo(
|
||||
label => $field->{label},
|
||||
name => $field->{fieldId} . '_yesNo',
|
||||
defaultValue => 0,
|
||||
value => $formDescription->{$field->{fieldId}},
|
||||
);
|
||||
}
|
||||
$newform->submit;
|
||||
my $title = $assetId eq 'new' ? $i18n->get('new form') || 'new' : $asset->get('title');
|
||||
if( $params->{asHashRef} ) {
|
||||
; # not setting mimie type
|
||||
} elsif( $session->form->get('asJson') ) {
|
||||
$session->http->setMimeType( 'application/json' );
|
||||
} else {
|
||||
$session->http->setMimeType( 'text/html' );
|
||||
}
|
||||
my $content = $asset->processTemplate({
|
||||
errors => $params->{errors} || [],
|
||||
isDynamic => $session->form->get('asJson') || 0,
|
||||
backUrl => $parent->getUrl,
|
||||
pageTitle => $title,
|
||||
pageForm => $newform->print,
|
||||
},$parent->get('eventSubmissionTemplateId'));
|
||||
WebGUI::Macro::process( $session, \$content );
|
||||
if( $params->{asHashRef} ) {
|
||||
return { text => $content, title => $title };
|
||||
} elsif( $session->form->get('asJson') ) {
|
||||
return JSON->new->encode( { text => $content, title => $title, id => $assetId ne 'new' ? $assetId : 'new' . rand } );
|
||||
} else {
|
||||
return $asset->ems->processStyle( $content );
|
||||
}
|
||||
for my $def (@defs) {
|
||||
foreach my $fieldName (@fieldNames) {
|
||||
my $properties = $def->{properties};
|
||||
if ( defined $properties->{$fieldName} ) {
|
||||
$fields->{$fieldName} = { %{ $properties->{$fieldName} } }; # a simple first level copy
|
||||
# field definitions don't contain their own name, we will need it later on
|
||||
$fields->{$fieldName}{fieldId} = $fieldName;
|
||||
}
|
||||
}
|
||||
}
|
||||
for my $metaField ( @{ $parent->getEventMetaFields } ) {
|
||||
push @fieldNames, $metaField->{fieldId};
|
||||
$fields->{ $metaField->{fieldId} } = {%$metaField}; # a simple first level copy
|
||||
# meta fields call it data type, we copy it to simplify later on
|
||||
$fields->{ $metaField->{fieldId} }{fieldType} = $metaField->{dataType};
|
||||
$fields->{ $metaField->{fieldId} }{hoverHelp} = $metaField->{helpText};
|
||||
}
|
||||
$newform->hidden( name => 'fieldNames', value => join( ' ', @fieldNames ) );
|
||||
@defs = reverse @{ WebGUI::Asset::EMSSubmissionForm->definition($session) };
|
||||
for my $def (@defs) {
|
||||
my $properties = $def->{properties};
|
||||
for my $fieldName (
|
||||
qw/title menuTitle url description canSubmitGroupId daysBeforeCleanup
|
||||
deleteCreatedItems submissionDeadline pastDeadlineMessage/
|
||||
)
|
||||
{
|
||||
if ( defined $properties->{$fieldName} ) {
|
||||
my %fieldParams = %{ $properties->{$fieldName} };
|
||||
$fieldParams{name} = $fieldName;
|
||||
$fieldParams{value} = $params->{$fieldName} || $self ? $self->get($fieldName) : undef;
|
||||
$newform->dynamicField(%fieldParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
my $formDescription = $params->{formDescription} || $self ? $self->getFormDescription : {};
|
||||
for my $fieldId (@fieldNames) {
|
||||
next if $fieldId eq 'submissionStatus';
|
||||
my $field = $fields->{$fieldId};
|
||||
$newform->yesNo(
|
||||
label => $field->{label},
|
||||
name => $field->{fieldId} . '_yesNo',
|
||||
defaultValue => 0,
|
||||
value => $formDescription->{ $field->{fieldId} },
|
||||
);
|
||||
}
|
||||
$newform->submit;
|
||||
my $title = $assetId eq 'new' ? $i18n->get('new form') || 'new' : $asset->get('title');
|
||||
if ( $params->{asHashRef} ) {
|
||||
; # not setting mimie type
|
||||
}
|
||||
elsif ( $session->form->get('asJson') ) {
|
||||
$session->http->setMimeType('application/json');
|
||||
}
|
||||
else {
|
||||
$session->http->setMimeType('text/html');
|
||||
}
|
||||
my $content = $asset->processTemplate( {
|
||||
errors => $params->{errors} || [],
|
||||
isDynamic => $session->form->get('asJson') || 0,
|
||||
backUrl => $parent->getUrl,
|
||||
pageTitle => $title,
|
||||
pageForm => $newform->print,
|
||||
},
|
||||
$parent->get('eventSubmissionTemplateId')
|
||||
);
|
||||
WebGUI::Macro::process( $session, \$content );
|
||||
if ( $params->{asHashRef} ) {
|
||||
return { text => $content, title => $title };
|
||||
}
|
||||
elsif ( $session->form->get('asJson') ) {
|
||||
return JSON->new->encode(
|
||||
{ text => $content, title => $title, id => $assetId ne 'new' ? $assetId : 'new' . rand } );
|
||||
}
|
||||
else {
|
||||
return $asset->ems->processStyle($content);
|
||||
}
|
||||
|
||||
} ## end sub www_editSubmissionForm
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -491,14 +499,15 @@ We overload the update method from WebGUI::Asset in order to handle file system
|
|||
|
||||
=cut
|
||||
|
||||
sub update {
|
||||
around update => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
my $properties = shift;
|
||||
if( ref $properties->{formDescription} eq 'HASH' ) {
|
||||
$properties->{formDescription} = JSON->new->encode($properties->{formDescription});
|
||||
}
|
||||
$self->SUPER::update({%$properties, isHidden => 1});
|
||||
}
|
||||
$self->$orig({%$properties});
|
||||
};
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -435,7 +435,7 @@ sub getFirstFile {
|
|||
my $allFileIds = $self->getParent->getFileIds;
|
||||
|
||||
return undef unless @{ $allFileIds };
|
||||
return WebGUI::Asset->newByDynamicClass( $self->session, shift @{ $allFileIds });
|
||||
return WebGUI::Asset->newById( $self->session, shift @{ $allFileIds });
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -452,7 +452,7 @@ sub getLastFile {
|
|||
my $allFileIds = $self->getParent->getFileIds;
|
||||
|
||||
return undef unless @{ $allFileIds };
|
||||
return WebGUI::Asset->newByDynamicClass( $self->session, pop @{ $allFileIds });
|
||||
return WebGUI::Asset->newById( $self->session, pop @{ $allFileIds });
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -469,7 +469,7 @@ sub getNextFile {
|
|||
return $self->{_nextFile} if $self->{_nextFile};
|
||||
my $nextId = $self->getParent->getNextFileId( $self->getId );
|
||||
return undef unless $nextId;
|
||||
$self->{_nextFile} = WebGUI::Asset->newByDynamicClass( $self->session, $nextId );
|
||||
$self->{_nextFile} = WebGUI::Asset->newById( $self->session, $nextId );
|
||||
return $self->{_nextFile};
|
||||
}
|
||||
|
||||
|
|
@ -487,7 +487,7 @@ sub getPreviousFile {
|
|||
return $self->{_previousFile} if $self->{_previousFile};
|
||||
my $previousId = $self->getParent->getPreviousFileId( $self->getId );
|
||||
return undef unless $previousId;
|
||||
$self->{_previousFile} = WebGUI::Asset->newByDynamicClass( $self->session, $previousId );
|
||||
$self->{_previousFile} = WebGUI::Asset->newById( $self->session, $previousId );
|
||||
return $self->{_previousFile};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,6 @@ override applyConstraints => sub {
|
|||
# Update the asset's size and make a thumbnail
|
||||
my $maxImageSize = $gallery->imageViewSize
|
||||
|| $self->session->setting->get("maxImageSize");
|
||||
my $parameters = $self->parameters;
|
||||
my $storage = $self->getStorageLocation;
|
||||
my $file = $self->filename;
|
||||
|
||||
|
|
@ -214,7 +213,7 @@ sub getExifData {
|
|||
=head2 getResolutions ( )
|
||||
|
||||
Get an array reference of download resolutions that exist for this image.
|
||||
Does not include the web view image or the thumbnail image.
|
||||
Does not include the web view image or the thumbnail images.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -223,7 +222,7 @@ sub getResolutions {
|
|||
my $storage = $self->getStorageLocation;
|
||||
|
||||
# Return a list not including the web view image.
|
||||
return [ sort { $a <=> $b } grep { $_ ne $self->filename } @{ $storage->getFiles } ];
|
||||
return [ sort { $a cmp $b } grep { $_ ne $self->filename } @{ $storage->getFiles } ];
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ override applyConstraints => sub {
|
|||
my $self = shift;
|
||||
my $options = shift;
|
||||
super();
|
||||
my $maxImageSize = $options->{maxImageSize} || $self->maxImageSize || $self->session->setting->get("maxImageSize");
|
||||
my $maxImageSize = $options->{maxImageSize} || $self->session->setting->get("maxImageSize");
|
||||
my $thumbnailSize = $options->{thumbnailSize} || $self->thumbnailSize || $self->session->setting->get("thumbnailSize");
|
||||
my $storage = $self->getStorageLocation;
|
||||
my $file = $self->filename;
|
||||
|
|
@ -244,7 +244,7 @@ sub view {
|
|||
$var{fileIcon} = $self->getFileIconUrl;
|
||||
$var{thumbnail} = $self->getThumbnailUrl;
|
||||
$var{annotateJs} = $crop_js . $domMe;
|
||||
$var{parameters} .= sprintf("id=%s", $self->getId);
|
||||
$var{parameters} .= sprintf(q{ id="%s"}, $self->getId);
|
||||
my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate});
|
||||
if (!$session->var->isAdminOn && $self->cacheTimeout > 10) {
|
||||
$cache->set( $cacheKey, $out, $self->get("cacheTimeout") );
|
||||
|
|
|
|||
|
|
@ -410,12 +410,12 @@ Fetches the last post in this thread, otherwise, returns itself.
|
|||
sub getLastPost {
|
||||
my $self = shift;
|
||||
my $lastPostId = $self->lastPostId;
|
||||
my $lastPost;
|
||||
if ($lastPostId) {
|
||||
$lastPost = WebGUI::Asset::Post->newById($self->session, $lastPostId);
|
||||
}
|
||||
return $lastPost if (defined $lastPost);
|
||||
return $self;
|
||||
return $self unless $lastPostId;
|
||||
my $lastPost = eval { WebGUI::Asset->newById($self->session, $lastPostId); };
|
||||
if (Exception::Class->caught()) {
|
||||
return $self;
|
||||
}
|
||||
return $lastPost;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -497,9 +497,9 @@ sub getOverrides {
|
|||
my $orig = $self->getShortcutOriginal;
|
||||
if (defined $orig) {
|
||||
unless ( exists $orig->{_propertyDefinitions}) {
|
||||
my %properties;
|
||||
foreach my $definition (@{$orig->definition($self->session)}) {
|
||||
%properties = (%properties, %{$definition->{properties}});
|
||||
my %properties;
|
||||
foreach my $property ($orig->getProperties) {
|
||||
$properties{$property} = $orig->getFormProperties($property);
|
||||
}
|
||||
$orig->{_propertyDefinitions} = \%properties;
|
||||
}
|
||||
|
|
@ -1150,14 +1150,7 @@ sub www_editOverride {
|
|||
);
|
||||
|
||||
# Fetch the parameters for the dynamic field.
|
||||
my (%params, %props);
|
||||
foreach my $def (@{$self->getShortcutOriginal->definition($self->session)}) {
|
||||
%props = (%props,%{$def->{properties}});
|
||||
}
|
||||
foreach my $key (keys %{$props{$fieldName}}) {
|
||||
next if ($key eq "tab");
|
||||
$params{$key} = $props{$fieldName}{$key};
|
||||
}
|
||||
my %params = %{ $self->getShortcutOriginal->getFormProperties($fieldName) };
|
||||
$params{value} = $origValue;
|
||||
$params{name} = $fieldName;
|
||||
$params{label} = $params{label} || $i18n->get("Edit Field Directly");
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ property vendorId => (
|
|||
property taxConfiguration => (
|
||||
noFormPost => 1,
|
||||
fieldType => 'hidden',
|
||||
defaultValue => '{}',
|
||||
default => '{}',
|
||||
);
|
||||
property shipsSeparately => (
|
||||
tab => 'shop',
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ property snippet => (
|
|||
label => ['assetName','Asset_Snippet'],
|
||||
hoverHelp => ['snippet description','Asset_Snippet'],
|
||||
default => undef,
|
||||
trigger => \&_trigger_snippet,
|
||||
);
|
||||
sub _trigger_snippet {
|
||||
my $self = shift;
|
||||
|
|
|
|||
|
|
@ -289,8 +289,8 @@ sub getTemplateVars {
|
|||
});
|
||||
PAGE: foreach my $assetId (@{ $paginator->getPageData }) {
|
||||
next PAGE if $assetId->{assetId} eq $self->getId;
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($session, $assetId->{assetId});
|
||||
next PAGE unless $asset;
|
||||
my $asset = eval { WebGUI::Asset->newById($session, $assetId->{assetId}); };
|
||||
next PAGE if Exception::Class->caught();
|
||||
push @keyword_pages, {
|
||||
title => $asset->getTitle,
|
||||
url => $asset->getUrl,
|
||||
|
|
|
|||
|
|
@ -836,9 +836,9 @@ sub www_addSubmission {
|
|||
}
|
||||
}
|
||||
}
|
||||
$form = WebGUI::Asset->newByDynamicClass($session,$formId);
|
||||
if (!defined $form) {
|
||||
$session->errorHandler->error(__PACKAGE__ . " - failed to instanciate asset with assetId $formId");
|
||||
$form = eval { WebGUI::Asset->newById($session, $formId); };
|
||||
if (Exception::Class->caught()) {
|
||||
$session->errorHandler->error(__PACKAGE__ . " - failed to instanciate asset with assetId $formId");
|
||||
}
|
||||
return $form->www_addSubmission;
|
||||
}
|
||||
|
|
@ -1351,7 +1351,7 @@ sub www_getAllSubmissions {
|
|||
$tableInfo->{'records' } = [];
|
||||
|
||||
for my $record ( @{ $p->getPageData } ) {
|
||||
my $asset = WebGUI::Asset->newByDynamicClass( $session, $record->{assetId} );
|
||||
my $asset = WebGUI::Asset->newById( $session, $record->{assetId} );
|
||||
|
||||
my $lastReplyBy = $asset->get("lastReplyBy");
|
||||
if ($lastReplyBy) {
|
||||
|
|
|
|||
|
|
@ -551,7 +551,7 @@ sub getAlbumIds {
|
|||
my $orderBy = $options->{ orderBy }
|
||||
? $options->{ orderBy }
|
||||
: $self->viewListOrderBy
|
||||
? join( " ", $self->getviewListOrderBy, $self->viewListOrderDirection )
|
||||
? join( " ", $self->viewListOrderBy, $self->viewListOrderDirection )
|
||||
: "lineage ASC"
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ use Carp qw( croak );
|
|||
use File::Find;
|
||||
use File::Spec;
|
||||
use File::Temp qw{ tempdir };
|
||||
use JSON ();
|
||||
use JSON qw();
|
||||
use WebGUI::International;
|
||||
use WebGUI::HTML;
|
||||
use WebGUI::ProgressBar;
|
||||
|
|
@ -1171,7 +1171,7 @@ sub www_ajax {
|
|||
my $result;
|
||||
|
||||
# Get arguments encoded in json format
|
||||
my $args = decode_json($form->get("args"));
|
||||
my $args = JSON::from_json($form->get("args"));
|
||||
|
||||
# Log some debug information
|
||||
$session->log->debug("Ajax service called with args=" . $form->get("args"));
|
||||
|
|
@ -1198,7 +1198,7 @@ sub www_ajax {
|
|||
$result->{ err } = -1 if $result->{ errMessage };
|
||||
|
||||
# Return results encoded in json format
|
||||
return encode_json( $result );
|
||||
return JSON::to_json( $result );
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1247,10 +1247,10 @@ sub _moveFileAjaxRequest {
|
|||
|
||||
# Get Id of target photo and instantiate asset
|
||||
my $targetId = $args->{target};
|
||||
my $target = WebGUI::Asset->newByDynamicClass( $session, $targetId );
|
||||
my $target = eval { WebGUI::Asset->newById( $session, $targetId ); };
|
||||
|
||||
# Return if target photo could not be instantiated
|
||||
unless ( $target ) {
|
||||
if ( Exception::Class->caught() ) {
|
||||
$session->log->error("Couldn't move file '$targetId' because we couldn't instantiate it.");
|
||||
$result{ errMessage } = "ID of target file seems to be invalid.";
|
||||
return \%result;
|
||||
|
|
@ -1266,10 +1266,10 @@ sub _moveFileAjaxRequest {
|
|||
|
||||
# Instantiate file with ID in before/after argument
|
||||
$destId = $args->{before} ? $args->{before} : $args->{after};
|
||||
$dest = WebGUI::Asset->newByDynamicClass( $session, $destId );
|
||||
$dest = eval { WebGUI::Asset->newById( $session, $destId ); };
|
||||
|
||||
# Return if destination file could not be instantiated
|
||||
unless ( $dest ) {
|
||||
if ( Exception::Class->caught() ) {
|
||||
$session->log->error("Couldn't move file '$targetId' before/after file '$destId' because we couldn't instantiate the latter.");
|
||||
$result{ errMessage } = "ID in before/after argument seems to be invalid.";
|
||||
return \%result;
|
||||
|
|
@ -1286,14 +1286,14 @@ sub _moveFileAjaxRequest {
|
|||
# Get ID of next sibling
|
||||
$destId = $self->getNextFileId( $destId );
|
||||
# Instantiate next sibling
|
||||
$dest = WebGUI::Asset->newByDynamicClass( $session, $destId );
|
||||
$dest = WebGUI::Asset->newById( $session, $destId );
|
||||
}
|
||||
# Check for use of before argument when increasing the rank
|
||||
if ( $args->{before} && $target->getRank() < $dest->getRank() ) {
|
||||
# Get ID of previous sibling
|
||||
$destId = $self->getPreviousFileId( $destId );
|
||||
# Instantiate previous sibling
|
||||
$dest = WebGUI::Asset->newByDynamicClass( $session, $destId );
|
||||
$dest = WebGUI::Asset->newById( $session, $destId );
|
||||
}
|
||||
|
||||
# Update rank of target photo
|
||||
|
|
|
|||
|
|
@ -265,8 +265,7 @@ part of the C<groupToAdd> group.
|
|||
|
||||
=cut
|
||||
|
||||
sub canEdit {
|
||||
my $orig = shift;
|
||||
override canEdit => sub {
|
||||
my $self = shift;
|
||||
my $userId = shift || $self->session->user->userId;
|
||||
|
||||
|
|
@ -276,14 +275,8 @@ sub canEdit {
|
|||
&& $form->get( 'class' )->isa( 'WebGUI::Asset::MatrixListing' ) ) {
|
||||
return $self->canAddMatrixListing();
|
||||
}
|
||||
else {
|
||||
if ($userId eq $self->ownerUserId) {
|
||||
return 1;
|
||||
}
|
||||
my $user = WebGUI::User->new($self->session, $userId);
|
||||
return $user->isInGroup($self->groupIdEdit);
|
||||
}
|
||||
}
|
||||
return super();
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use HTML::Entities;
|
|||
use WebGUI::Exception;
|
||||
use WebGUI::HTML;
|
||||
use WebGUI::International;
|
||||
use LWP::UserAgent;
|
||||
|
||||
use Moose;
|
||||
use WebGUI::Definition::Asset;
|
||||
|
|
@ -216,6 +217,7 @@ sub getRssFeedItems {
|
|||
author => $item->author,
|
||||
guid => $item->guid,
|
||||
);
|
||||
push @items, \%feed_item;
|
||||
}
|
||||
return \@items;
|
||||
}
|
||||
|
|
@ -293,11 +295,12 @@ See WebGUI::Asset::prepareView() for details.
|
|||
|
||||
=cut
|
||||
|
||||
sub prepareView {
|
||||
around prepareView => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
$self->next::method;
|
||||
my $template = WebGUI::Asset::Template->newById($self->session, $self->templateId);
|
||||
if (!$template) {
|
||||
$self->$orig();
|
||||
my $template = eval { WebGUI::Asset->newById($self->session, $self->templateId); };
|
||||
if (Exception::Class->caught()) {
|
||||
WebGUI::Error::ObjectNotFound::Template->throw(
|
||||
error => qq{Template not found},
|
||||
templateId => $self->templateId,
|
||||
|
|
@ -306,7 +309,7 @@ sub prepareView {
|
|||
}
|
||||
$template->prepare($self->getMetaDataAsTemplateVariables);
|
||||
$self->{_viewTemplate} = $template;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -358,63 +361,11 @@ See WebGUI::Asset::Wobject::www_view() for details.
|
|||
|
||||
=cut
|
||||
|
||||
sub www_view {
|
||||
my $self = shift;
|
||||
$self->session->http->setCacheControl($self->cacheTimeout);
|
||||
$self->next::method(@_);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewRSS090 ( )
|
||||
|
||||
Deprecated. Use www_viewRss() instead.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewRSS090 {
|
||||
my $self = shift;
|
||||
return $self->www_viewRss;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewRSS091 ( )
|
||||
|
||||
Deprecated. Use www_viewRss() instead.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewRSS091 {
|
||||
my $self = shift;
|
||||
return $self->www_viewRss;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewRSS10 ( )
|
||||
|
||||
Deprecated. Use www_viewRdf() instead.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewRSS10 {
|
||||
my $self = shift;
|
||||
return $self->www_viewRdf;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewRSS20 ( )
|
||||
|
||||
Deprecated. Use www_viewRss() instead.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewRSS20 {
|
||||
my $self = shift;
|
||||
return $self->www_viewRss;
|
||||
}
|
||||
override www_view => sub {
|
||||
my $self = shift;
|
||||
$self->session->http->setCacheControl($self->cacheTimeout);
|
||||
super();
|
||||
};
|
||||
|
||||
__PACKAGE__->meta->make_immutable;
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -199,18 +199,19 @@ sub paste {
|
|||
my $outputSub = shift;
|
||||
my $session = $self->session;
|
||||
my $pastedAsset = WebGUI::Asset->newById($session,$assetId);
|
||||
return 0 unless ($self->get("state") eq "published");
|
||||
return 0 unless ($self->state eq "published");
|
||||
return 0 unless ($pastedAsset->canPaste()); ##Allow pasted assets to have a say about pasting.
|
||||
|
||||
# Don't allow a shortcut to create an endless loop
|
||||
return 0 if ($pastedAsset->get("className") eq "WebGUI::Asset::Shortcut" && $pastedAsset->get("shortcutToAssetId") eq $self->getId);
|
||||
return 0 if ($pastedAsset->isa("WebGUI::Asset::Shortcut") && $pastedAsset->shortcutToAssetId eq $self->getId);
|
||||
my $i18n=WebGUI::International->new($session, 'Asset');
|
||||
$outputSub->(sprintf $i18n->get('pasting %s'), $pastedAsset->getTitle) if defined $outputSub;
|
||||
if ($self->getId eq $pastedAsset->get("parentId") || $pastedAsset->setParent($self)) {
|
||||
if ($self->getId eq $pastedAsset->parentId || $pastedAsset->setParent($self)) {
|
||||
$pastedAsset->publish(['clipboard','clipboard-limbo']); # Paste only clipboard items
|
||||
$pastedAsset->updateHistory("pasted to parent ".$self->getId);
|
||||
|
||||
# Update lineage in search index.
|
||||
$self->purgeCache;
|
||||
my $updateAssets = $pastedAsset->getLineage(['self', 'descendants'], {returnObjects => 1});
|
||||
|
||||
foreach (@{$updateAssets}) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package WebGUI::AssetHelper::Lock;
|
|||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
use WebGUI::International;
|
||||
use base qw/WebGUI::AssetHelper/;
|
||||
|
||||
=head1 LEGAL
|
||||
|
|
@ -18,7 +19,7 @@ use base qw/WebGUI::AssetHelper/;
|
|||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetHelper::Locks
|
||||
Package WebGUI::AssetHelper::Lock
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
|
|
@ -52,7 +53,6 @@ sub process {
|
|||
}
|
||||
|
||||
$asset = $asset->addRevision;
|
||||
|
||||
return {
|
||||
message => sprintf($i18n->get('locked asset'), $asset->getTitle),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ sub getFirstChild {
|
|||
$assetLineage->{firstChild}{$self->getId} = $lineage;
|
||||
$self->session->stow->set("assetLineage", $assetLineage);
|
||||
}
|
||||
$child = WebGUI::Asset->newByLineage($self->session,$lineage);
|
||||
$child = eval { WebGUI::Asset->newByLineage($self->session,$lineage); };
|
||||
$self->cacheChild(first => $child);
|
||||
}
|
||||
return $child;
|
||||
|
|
@ -301,7 +301,7 @@ sub getLastChild {
|
|||
$assetLineage->{lastChild}{$self->getId} = $lineage;
|
||||
$self->session->stow->set("assetLineage", $assetLineage);
|
||||
}
|
||||
$child = WebGUI::Asset->newByLineage($self->session,$lineage);
|
||||
$child = eval { WebGUI::Asset->newByLineage($self->session,$lineage); };
|
||||
$self->cacheChild(last => $child);
|
||||
}
|
||||
return $child;
|
||||
|
|
@ -829,8 +829,7 @@ sub newByLineage {
|
|||
unless ($id) {
|
||||
($id) = $session->db->quickArray("select assetId from asset where lineage=?",[$lineage]);
|
||||
if (!$id) {
|
||||
$session->errorHandler->error("Couldn't instantiate asset from lineage: ".$lineage. ": assetId missing");
|
||||
return undef;
|
||||
WebGUI::Error::InvalidParam->throw(error => "Cannot find lineage date for assetId", param => $id);
|
||||
}
|
||||
$assetLineage->{$lineage}{id} = $id;
|
||||
$session->stow->set("assetLineage",$assetLineage);
|
||||
|
|
@ -1000,6 +999,7 @@ sub validParent {
|
|||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $asset = shift || $session->asset;
|
||||
return 0 unless $asset;
|
||||
my $parent_classes = $class->valid_parent_classes;
|
||||
foreach my $parentClass (@{ $class->valid_parent_classes}) {
|
||||
return 1 if $asset->isa($parentClass);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ Converts all the properties of this asset into a hash reference and then returns
|
|||
sub exportAssetData {
|
||||
my $self = shift;
|
||||
my %data = %{$self->get};
|
||||
delete $data{'session'};
|
||||
my %hash = ( properties => \%data, storage=>[] );
|
||||
return \%hash;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ sub getAssetsInTrash {
|
|||
my $sth = $self->session->db->read("
|
||||
select
|
||||
asset.assetId,
|
||||
assetData.revisionDate,
|
||||
assetData.revisionDate
|
||||
from
|
||||
asset
|
||||
left join
|
||||
|
|
|
|||
|
|
@ -73,6 +73,20 @@ sub import {
|
|||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 init_meta ( )
|
||||
|
||||
A custom init_meta, so that if inported into a class, it applies the roles
|
||||
to the class, and applies the meta-role to the meta-class.
|
||||
|
||||
But, if it is applied to a Role, then only the meta-role is applied, since we want
|
||||
the final application to be in the end user of the Role.
|
||||
|
||||
This permits using this to compose Asset Roles with their own database tables.
|
||||
|
||||
=cut
|
||||
|
||||
sub init_meta {
|
||||
my $class = shift;
|
||||
my %args = @_;
|
||||
|
|
|
|||
|
|
@ -148,6 +148,21 @@ sub get_all_property_list {
|
|||
return @names;
|
||||
}
|
||||
|
||||
sub get_all_settable_list {
|
||||
my $self = shift;
|
||||
my @names = ();
|
||||
my %seen = ();
|
||||
foreach my $meta ($self->get_all_class_metas) {
|
||||
push @names,
|
||||
grep { !$seen{$_}++ }
|
||||
map { $_->name }
|
||||
sort { $a->insertion_order <=> $b->insertion_order }
|
||||
grep { $_->does('WebGUI::Definition::Meta::Settable') }
|
||||
$meta->get_attributes;
|
||||
}
|
||||
return @names;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 get_attributes ( )
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ no warnings qw(uninitialized);
|
|||
|
||||
our $VERSION = '0.0.1';
|
||||
|
||||
with 'WebGUI::Definition::Meta::Settable';
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Definition::Meta::Property
|
||||
|
|
|
|||
39
lib/WebGUI/Definition/Meta/Settable.pm
Normal file
39
lib/WebGUI/Definition/Meta/Settable.pm
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package WebGUI::Definition::Meta::Settable;
|
||||
|
||||
=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 5.010;
|
||||
use Moose::Role;
|
||||
use namespace::autoclean;
|
||||
no warnings qw(uninitialized);
|
||||
|
||||
our $VERSION = '0.0.1';
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Definition::Meta::Property
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Moose-based meta class for all properties in WebGUI::Definition.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
WebGUI::Definition::Meta::Property extends Moose::Meta::Attribute to include
|
||||
a read-only form method, that provides the form properties for the attribute.
|
||||
|
||||
=cut
|
||||
|
||||
1;
|
||||
|
|
@ -62,12 +62,13 @@ sub get {
|
|||
my $self = shift;
|
||||
if (@_) {
|
||||
my $property = shift;
|
||||
if ($self->meta->find_attribute_by_name($property)) {
|
||||
if ($self->can($property)) {
|
||||
return $self->$property;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
my %properties = map { $_ => scalar $self->$_ } $self->meta->get_all_attributes_list;
|
||||
delete $properties{session};
|
||||
return \%properties;
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +88,7 @@ is not an attribute of the object, then it is silently ignored.
|
|||
sub set {
|
||||
my $self = shift;
|
||||
my $properties = @_ % 2 ? shift : { @_ };
|
||||
my @orderedProperties = $self->getProperties;
|
||||
my @orderedProperties = $self->meta->get_all_settable_list;
|
||||
KEY: for my $property ( @orderedProperties ) {
|
||||
next KEY unless exists $properties->{$property};
|
||||
$self->$property($properties->{$property});
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package WebGUI::FilePump::Bundle;
|
|||
|
||||
use base qw/WebGUI::Crud WebGUI::JSONCollateral/;
|
||||
use strict;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Exception;
|
||||
use WebGUI::Utility;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ sub getValue {
|
|||
my $self = shift;
|
||||
my $value = $self->SUPER::getValue(@_);
|
||||
$value =~ tr/\r\n//d;
|
||||
$value =~ tr/a-z/A-Z/d;
|
||||
$value =~ tr/a-z/A-Z/;
|
||||
if ($value =~ /^[A-Z\d\s\-]+$/) {
|
||||
return $value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ use WebGUI::Utility;
|
|||
use WebGUI::Pluggable;
|
||||
require WebGUI::Asset;
|
||||
use WebGUI::International;
|
||||
use WebGUI::DatabaseLink;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ sub process {
|
|||
if (Exception::Class->caught()) {
|
||||
return $i18n->get('invalid url');
|
||||
}
|
||||
my $storageId = $asset->storageId;
|
||||
my $storageId = $asset->can('storageId') ? $asset->storageId : undef;
|
||||
if (not defined $storageId) {
|
||||
return $i18n->get('no storage');
|
||||
}
|
||||
my $filename = $asset->filename;
|
||||
my $filename = $asset->can('filename') ? $asset->filename : undef;
|
||||
if (not defined $filename) {
|
||||
return $i18n->get('no filename');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,8 +44,10 @@ This macro takes a templateId to show the links
|
|||
sub process {
|
||||
my $session = shift;
|
||||
my $templateId = shift || "_aE16Rr1-bXBf8SIaLZjCg";
|
||||
my $template = WebGUI::Asset::Template->new($session, $templateId);
|
||||
my $template = eval { WebGUI::Asset::Template->newById($session, $templateId); };
|
||||
if (Exception::Class->caught()) {
|
||||
return "Could not instanciate template with id [$templateId]" unless $template;
|
||||
}
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
my $languages = $i18n->getLanguages();
|
||||
my @lang_loop = ();
|
||||
|
|
|
|||
|
|
@ -32,13 +32,15 @@ Image Asset can be found with that URL, then undef will be returned.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my $url = shift;
|
||||
if (my $image = WebGUI::Asset::File::Image->newByUrl($session,$url)) {
|
||||
return $image->getThumbnailUrl;
|
||||
} else {
|
||||
return undef;
|
||||
}
|
||||
my $session = shift;
|
||||
my $url = shift;
|
||||
my $image = eval { WebGUI::Asset::File::Image->newByUrl($session,$url) };
|
||||
if (Exception::Class->caught()) {
|
||||
return undef;
|
||||
}
|
||||
else {
|
||||
return $image->getThumbnailUrl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -479,10 +479,11 @@ Extend the master class to insert head links via addHeaderLinks.
|
|||
|
||||
=cut
|
||||
|
||||
override prepareView => sub {
|
||||
around prepareView => sub {
|
||||
my $orig = shift;
|
||||
my $self = shift;
|
||||
$self->addHeaderLinks;
|
||||
return super();
|
||||
return $self->$orig;
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -173,9 +173,10 @@ Returns an instanciated WebGUI::Asset::Sku object for this cart item.
|
|||
|
||||
sub getSku {
|
||||
my ($self) = @_;
|
||||
my $asset = '';
|
||||
$asset = WebGUI::Asset->newById($self->cart->session, $self->get("assetId"));
|
||||
$asset->applyOptions($self->get("options")) if $asset;
|
||||
my $asset = eval { WebGUI::Asset->newById($self->cart->session, $self->get("assetId")); };
|
||||
if (!Exception::Class->caught) {
|
||||
$asset->applyOptions($self->get("options"));
|
||||
}
|
||||
return $asset;
|
||||
}
|
||||
|
||||
|
|
@ -229,7 +230,7 @@ Removes this item from the cart and calls $sku->onRemoveFromCart. See also delet
|
|||
|
||||
sub remove {
|
||||
my $self = shift;
|
||||
my $sku = $self->getSku;
|
||||
my $sku = eval { $self->getSku; };
|
||||
$sku->onRemoveFromCart($self) if $sku;
|
||||
return $self->delete;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ sub www_selectPaymentGateway {
|
|||
}
|
||||
$var->{ paymentGateways } = \@paymentGateways;
|
||||
$var->{ choose } = $i18n->get('choose payment gateway message');
|
||||
my $template = WebGUI::Asset::Template->new($session, $session->setting->get("selectGatewayTemplateId"));
|
||||
my $template = WebGUI::Asset::Template->newById($session, $session->setting->get("selectGatewayTemplateId"));
|
||||
return $session->style->userStyle($template->process($var));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ use strict;
|
|||
use XML::Simple;
|
||||
use Data::Dumper;
|
||||
use Tie::IxHash;
|
||||
use LWP::UserAgent;
|
||||
use HTTP::Request;
|
||||
|
||||
use base qw/WebGUI::Shop::PayDriver/;
|
||||
|
||||
|
|
|
|||
|
|
@ -632,7 +632,7 @@ sub sendNotifications {
|
|||
my $var = $self->getTransactionVars;
|
||||
|
||||
# render
|
||||
my $template = WebGUI::Asset::Template->new( $session, $session->setting->get("shopReceiptEmailTemplateId") );
|
||||
my $template = WebGUI::Asset::Template->newById( $session, $session->setting->get("shopReceiptEmailTemplateId") );
|
||||
my $inbox = WebGUI::Inbox->new($session);
|
||||
my $receipt = $template->process( $var );
|
||||
WebGUI::Macro::process($session, \$receipt);
|
||||
|
|
|
|||
|
|
@ -133,11 +133,11 @@ sub getSku {
|
|||
my ($self) = @_;
|
||||
my $asset = eval { WebGUI::Asset->newById($self->transaction->session, $self->get("assetId")); };
|
||||
if (Exception::Class->caught()) {
|
||||
$asset->applyOptions($self->get("options"));
|
||||
return $asset;
|
||||
WebGUI::Error::ObjectNotFound->throw(error=>'SKU Asset '.$self->get('assetId').' could not be instanciated. Perhaps it no longer exists.', id=>$self->get('assetId'));
|
||||
return undef;
|
||||
}
|
||||
WebGUI::Error::ObjectNotFound->throw(error=>'SKU Asset '.$self->get('assetId').' could not be instanciated. Perhaps it no longer exists.', id=>$self->get('assetId'));
|
||||
return undef;
|
||||
$asset->applyOptions($self->get("options"));
|
||||
return $asset;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1,8 +1,49 @@
|
|||
package WebGUI::Types;
|
||||
|
||||
=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 Moose;
|
||||
use Moose::Util::TypeConstraints;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Types
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
A package to hold all Moose types for WebGUI::Definition based classes.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Types;
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These types are provided by this class:
|
||||
|
||||
=head2 WebGUI::Type::JSONArray
|
||||
|
||||
The JSONArray is an subtype of ArrayRef, with coercions. If a string is applied to the property
|
||||
with this type, it ties to pass it through JSON::from_json. If that fails, then it returns an
|
||||
empty arrayref.
|
||||
|
||||
Similarly, if an undef value is applied, it is coerced into an empty arrayref.
|
||||
|
||||
=cut
|
||||
|
||||
subtype 'WebGUI::Type::JSONArray'
|
||||
=> as 'ArrayRef'
|
||||
;
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ exhausted the recurrence, false otherwise.
|
|||
sub processRecurrence {
|
||||
my ( $self, $recurId, $timeLimit ) = @_;
|
||||
my $eventId = $self->findLastEventId($recurId);
|
||||
my $event = WebGUI::Asset::Event->new( $self->session, $eventId );
|
||||
my $event = WebGUI::Asset::Event->newById( $self->session, $eventId );
|
||||
my $recur = $event->getRecurrence;
|
||||
|
||||
my $start = $event->getDateTimeStart->truncate(to => 'day');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue