Merge branch 'WebGUI8' of github.com:plainblack/webgui into WebGUI8
This commit is contained in:
commit
14b79a671b
25 changed files with 684 additions and 1452 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1266,10 +1266,10 @@ sub _moveFileAjaxRequest {
|
|||
|
||||
# Instantiate file with ID in before/after argument
|
||||
$destId = $args->{before} ? $args->{before} : $args->{after};
|
||||
$dest = WebGUI::Asset->newById( $session, $destId );
|
||||
$dest = eval { WebGUI::Asset->newById( $session, $destId ); };
|
||||
|
||||
# Return if destination file could not be instantiated
|
||||
if ( Expeption::Class->caught() ) {
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -217,6 +217,7 @@ sub getRssFeedItems {
|
|||
author => $item->author,
|
||||
guid => $item->guid,
|
||||
);
|
||||
push @items, \%feed_item;
|
||||
}
|
||||
return \@items;
|
||||
}
|
||||
|
|
@ -294,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,
|
||||
|
|
@ -307,7 +309,7 @@ sub prepareView {
|
|||
}
|
||||
$template->prepare($self->getMetaDataAsTemplateVariables);
|
||||
$self->{_viewTemplate} = $template;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -359,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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 = @_;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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/;
|
||||
|
||||
|
|
|
|||
|
|
@ -134,11 +134,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'
|
||||
;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue