more tests, started Photo development, changed some naming
This commit is contained in:
parent
320c2c07b0
commit
32b27d0954
14 changed files with 1261 additions and 150 deletions
|
|
@ -297,10 +297,14 @@ sub prepareView {
|
|||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
|
||||
my $errors = $self->SUPER::processPropertiesFromFormPost;
|
||||
return $errors if $errors;
|
||||
|
||||
#Get the storage location out of memory. If you call getStorageLocation you risk creating another one.
|
||||
# How can this EVER be true?
|
||||
my $storageLocation = $self->{_storageLocation};
|
||||
$session->errorHandler->error("Storage Location set magically") if defined $storageLocation;
|
||||
my $storageId = undef;
|
||||
$storageId = $storageLocation->getId if(defined $storageLocation);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ package WebGUI::Asset::File::Image::Photo;
|
|||
|
||||
use strict;
|
||||
use Tie::IxHash;
|
||||
use Carp qw( croak );
|
||||
use base 'WebGUI::Asset::File::Image';
|
||||
use WebGUI::Utility;
|
||||
|
||||
|
|
@ -42,8 +43,7 @@ These methods are available from this class:
|
|||
|
||||
=head2 definition ( session, definition )
|
||||
|
||||
defines asset properties for New Asset instances. You absolutely need
|
||||
this method in your new Assets.
|
||||
Define the properties of the Photo asset.
|
||||
|
||||
=head3 session
|
||||
|
||||
|
|
@ -54,28 +54,251 @@ A hash reference passed in from a subclass definition.
|
|||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = $class->i18n($session);
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = __PACKAGE__->i18n($session);
|
||||
|
||||
tie my %properties, 'Tie::IxHash', (
|
||||
tie my %properties, 'Tie::IxHash', (
|
||||
friendsOnly => {
|
||||
defaultValue => 0,
|
||||
},
|
||||
rating => {
|
||||
defaultValue => 0,
|
||||
},
|
||||
storageIdPhoto => {
|
||||
defaultValue => undef,
|
||||
},
|
||||
);
|
||||
|
||||
# UserDefined Fields
|
||||
for my $i (1 .. 5) {
|
||||
$properties{"userDefined".$i} = {
|
||||
defaultValue => undef,
|
||||
};
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
push @{$definition}, {
|
||||
assetName => $i18n->get('assetName'),
|
||||
icon => 'Image.gif',
|
||||
tableName => 'Photo',
|
||||
className => 'WebGUI::Asset::File::Image::Photo',
|
||||
i18n => 'Asset_Photo',
|
||||
properties => \%properties,
|
||||
};
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
push @{$definition}, {
|
||||
assetName => $i18n->get('assetName'),
|
||||
icon => 'Image.gif',
|
||||
tableName => 'Photo',
|
||||
className => 'WebGUI::Asset::File::Image::Photo',
|
||||
i18n => 'Asset_Photo',
|
||||
properties => \%properties,
|
||||
};
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 appendTemplateVarsForCommentForm ( vars )
|
||||
|
||||
Add the template variables necessary for the comment form to the given hash
|
||||
reference. Returns the hash reference for convenience.
|
||||
|
||||
=cut
|
||||
|
||||
sub appendTemplateVarsForCommentForm {
|
||||
my $self = shift;
|
||||
my $vars = shift;
|
||||
|
||||
# ...
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 applyConstraints ( )
|
||||
|
||||
Apply the constraints to the original file. Called automatically by C<setFile>
|
||||
and C<processPropertiesFromFormPost>.
|
||||
|
||||
=cut
|
||||
|
||||
sub applyConstraints {
|
||||
my $self = shift;
|
||||
my $gallery = $self->getGallery;
|
||||
|
||||
# ...
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 canEdit ( [userId] )
|
||||
|
||||
Returns true if the user can edit this asset. C<userId> is a WebGUI user ID.
|
||||
If no userId is passed, check the current user.
|
||||
|
||||
Users can edit this Photo if they are the owner or if they are able to edit
|
||||
the parent Album asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub canEdit {
|
||||
my $self = shift;
|
||||
my $userId = shift || $self->session->user->userId;
|
||||
my $album = $self->getParent;
|
||||
|
||||
return 1 if $userId eq $self->get("ownerUserId");
|
||||
return $album->canEdit($userId);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 canView ( [userId] )
|
||||
|
||||
Returns true if the user can view this asset. C<userId> is a WebGUI user ID.
|
||||
If no user is passed, checks the current user.
|
||||
|
||||
=cut
|
||||
|
||||
# Inherited from superclass
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 deleteComment ( commentId )
|
||||
|
||||
Delete a comment from this asset. C<id> is the ID of the comment to delete.
|
||||
|
||||
=cut
|
||||
|
||||
sub deleteComment {
|
||||
my $self = shift;
|
||||
my $commentId = shift;
|
||||
|
||||
croak "Photo->deleteComment: No commentId specified."
|
||||
unless $commentId;
|
||||
|
||||
return $self->session->db->do(
|
||||
"DELETE FROM Photo_comment WHERE assetId=? AND commentId=?",
|
||||
[$self->getId, $commentId],
|
||||
);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getComment ( commentId )
|
||||
|
||||
Get a comment from this asset. C<id> is the ID of the comment to get. Returns
|
||||
a hash reference of comment information.
|
||||
|
||||
=cut
|
||||
|
||||
sub getComment {
|
||||
my $self = shift;
|
||||
my $commentId = shift;
|
||||
|
||||
return $self->session->db->quickHashRef(
|
||||
"SELECT * FROM Photo_comment WHERE assetId=? AND commentId=?",
|
||||
[$self->getId, $commentId],
|
||||
);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getCommentIds ( )
|
||||
|
||||
Get an array reference of comment IDs for this Photo, in chronological order.
|
||||
|
||||
=cut
|
||||
|
||||
sub getCommentIds {
|
||||
my $self = shift;
|
||||
|
||||
return [
|
||||
$self->session->db->buildArray(
|
||||
"SELECT commentId FROM Photo_comment WHERE assetId=?",
|
||||
[$self->getId],
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getCommentPaginator ( )
|
||||
|
||||
Get a WebGUI::Paginator for the comments for this Photo.
|
||||
|
||||
=cut
|
||||
|
||||
sub getCommentPaginator {
|
||||
my $self = shift;
|
||||
|
||||
# ...
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getDownloadFileUrl ( resolution )
|
||||
|
||||
Get the absolute URL to download the requested resolution. Will croak if the
|
||||
resolution doesn't exist.
|
||||
|
||||
=cut
|
||||
|
||||
sub getDownloadFileUrl {
|
||||
my $self = shift;
|
||||
my $resolution = shift;
|
||||
|
||||
croak "Photo->getDownloadFileUrl: resolution must be defined"
|
||||
unless $resolution;
|
||||
croak "Photo->getDownloadFileUrl: resolution doesn't exist for this Photo"
|
||||
unless grep /$resolution/, @{ $self->getResolutions };
|
||||
|
||||
# ...
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getGallery ( )
|
||||
|
||||
Gets the Gallery asset this Photo is a member of.
|
||||
|
||||
=cut
|
||||
|
||||
sub getGallery {
|
||||
my $self = shift;
|
||||
my $gallery = $self->getParent->getParent;
|
||||
return $gallery if $gallery->isa("WebGUI::Asset::Wobject::Gallery");
|
||||
return undef;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=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.
|
||||
|
||||
=cut
|
||||
|
||||
sub getResolutions {
|
||||
my $self = shift;
|
||||
my $storage = $self->getStorageLocation;
|
||||
|
||||
# ...
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getTemplateVars ( )
|
||||
|
||||
Get a hash reference of template variables shared by all views of this asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub getTemplateVars {
|
||||
my $self = shift;
|
||||
my $vars = $self->get;
|
||||
|
||||
# ...
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 i18n ( [ session ] )
|
||||
|
||||
|
|
@ -84,10 +307,72 @@ Get a WebGUI::International object for this class.
|
|||
Can be called as a class method, in which case a WebGUI::Session object
|
||||
must be passed in.
|
||||
|
||||
Can be called as an object method, in which case the session is
|
||||
filled in automatically.
|
||||
NOTE: This method can NOT be inherited, due to a current limitation
|
||||
in the i18n system. You must ALWAYS call this with C<__PACKAGE__>
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
=cut
|
||||
|
||||
sub i18n {
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
|
||||
return WebGUI::International->new($session, "Asset_Photo");
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 makeResolutions ( [resolutions] )
|
||||
|
||||
Create the specified resolutions for this Photo. If resolutions is not
|
||||
defined, will get the resolutions to make from the Gallery this Photo is
|
||||
contained in.
|
||||
|
||||
=cut
|
||||
|
||||
sub makeResolutions {
|
||||
my $self = shift;
|
||||
my $resolutions = shift;
|
||||
|
||||
croak "Photo->makeResolutions: resolutions must be an array reference"
|
||||
if $resolutions && ref $resolutions ne "ARRAY";
|
||||
|
||||
# Get default if necessary
|
||||
$resolutions ||= $self->getGallery->getImageResolutions;
|
||||
|
||||
for my $res ( @$resolutions ) {
|
||||
# carp if resolution is bad
|
||||
# ...
|
||||
}
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 makeShortcut ( parentId [, overrides ] )
|
||||
|
||||
Make a shortcut to this asset under the specified parent, optionally adding
|
||||
the specified overrides.
|
||||
|
||||
=cut
|
||||
|
||||
sub makeShortcut {
|
||||
my $self = shift;
|
||||
my $parentId = shift;
|
||||
my $overrides = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
croak "Photo->makeShortcut: parentId must be defined"
|
||||
unless $parentId;
|
||||
croak "Photo->makeShortcut: overrides must be hash reference"
|
||||
if $overrides && ref $overrides ne "HASH";
|
||||
|
||||
my $parent = WebGUI::Asset->newByDynamicClass($session, $parentId)
|
||||
|| croak "Photo->makeShortcut: Could not instanciate asset '$parentId'";
|
||||
|
||||
# ...
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 processPropertiesFromFormPost ( )
|
||||
|
||||
|
|
@ -98,42 +383,36 @@ when /yourAssetUrl?func=editSave is requested/posted.
|
|||
=cut
|
||||
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
my $self = shift;
|
||||
my $errors = $self->SUPER::processPropertiesFromFormPost || [];
|
||||
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
=head2 setComment ( commentId, properties )
|
||||
|
||||
=head2 purge ( )
|
||||
|
||||
This method is called when data is purged by the system.
|
||||
removes collateral data associated with a NewAsset when the system
|
||||
purges it's data. This method is unnecessary, but if you have
|
||||
auxiliary, ancillary, or "collateral" data or files related to your
|
||||
asset instances, you will need to purge them here.
|
||||
Set a comment. If C<commentId> is C<"new">, create a new comment. C<properties>
|
||||
is a hash reference of comment information.
|
||||
|
||||
=cut
|
||||
|
||||
sub purge {
|
||||
my $self = shift;
|
||||
return $self->SUPER::purge;
|
||||
sub setComment {
|
||||
my $self = shift;
|
||||
my $commentId = shift;
|
||||
my $properties = shift;
|
||||
|
||||
croak "Photo->setComment: commentId must be defined"
|
||||
unless $commentId;
|
||||
croak "Photo->setComment: properties must be a hash reference"
|
||||
unless $properties && ref $properties eq "HASH";
|
||||
|
||||
# ...
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 purgeRevision ( )
|
||||
|
||||
This method is called when data is purged by the system.
|
||||
|
||||
=cut
|
||||
|
||||
sub purgeRevision {
|
||||
my $self = shift;
|
||||
return $self->SUPER::purgeRevision;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
=head2 view ( )
|
||||
|
||||
method called by the container www_view method.
|
||||
|
|
@ -141,49 +420,175 @@ method called by the container www_view method.
|
|||
=cut
|
||||
|
||||
sub view {
|
||||
my $self = shift;
|
||||
my $var = $self->get; # $var is a hash reference.
|
||||
$var->{controls} = $self->getToolbar;
|
||||
$var->{fileUrl} = $self->getFileUrl;
|
||||
$var->{fileIcon} = $self->getFileIconUrl;
|
||||
return $self->processTemplate($var,undef, $self->{_viewTemplate});
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $var = $self->getTemplateVars;
|
||||
$var->{ controls } = $self->getToolbar;
|
||||
$var->{ fileUrl } = $self->getFileUrl;
|
||||
$var->{ fileIcon } = $self->getFileIconUrl;
|
||||
|
||||
|
||||
return $self->processTemplate($var,undef, $self->{_viewTemplate});
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_addCommentSave ( )
|
||||
|
||||
Save a new comment to the Photo.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_addCommentSave {
|
||||
my $self = shift;
|
||||
my $form = $self->session;
|
||||
|
||||
# ...
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_delete ( )
|
||||
|
||||
Show the page to confirm the deletion of this Photo. Show a list of albums
|
||||
this Photo exists in.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_delete {
|
||||
my $self = shift;
|
||||
|
||||
# ...
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteConfirm ( )
|
||||
|
||||
Confirm the deletion of this Photo. Show a message and a link back to the
|
||||
album.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_deleteConfirm {
|
||||
my $self = shift;
|
||||
|
||||
# ...
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_download
|
||||
|
||||
Download the Photo with the specified resolution. If no resolution specified,
|
||||
download the original file.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_download {
|
||||
my $self = shift;
|
||||
|
||||
# ...
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_edit ( )
|
||||
|
||||
Web facing method which is the default edit page
|
||||
|
||||
This page is only available to those who can edit this Photo.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get('edit asset',"Asset_NewAsset"));
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient unless $self->canEdit;
|
||||
return $self->session->privilege->locked unless $self->canEditIfLocked;
|
||||
|
||||
# Prepare the template variables
|
||||
my $var = $self->getTemplateVars;
|
||||
|
||||
$var->{ form_header } = WebGUI::Form::formHeader( $session );
|
||||
$var->{ form_footer } = WebGUI::Form::formFooter( $session );
|
||||
|
||||
$var->{ form_title }
|
||||
= WebGUI::Form::Text( $session, {
|
||||
name => "title",
|
||||
value => ( $form->get("title") || $self->get("title") ),
|
||||
});
|
||||
|
||||
$var->{ form_synopsis }
|
||||
= WebGUI::Form::HTMLArea( $session, {
|
||||
name => "synopsis",
|
||||
value => ( $form->get("synopsis") || $self->get("synopsis") ),
|
||||
richEditId => $self->getGallery->get("assetIdRichEditFile"),
|
||||
});
|
||||
|
||||
$var->{ form_storageIdPhoto }
|
||||
= WebGUI::Form::Image( $session, {
|
||||
name => "storageIdPhoto",
|
||||
value => ( $form->get("storageIdPhoto") || $self->get("storageIdPhoto") ),
|
||||
maxAttachments => 1,
|
||||
});
|
||||
|
||||
$var->{ form_keywords }
|
||||
= WebGUI::Form::Text( $session, {
|
||||
name => "keywords",
|
||||
value => ( $form->get("keywords") || $self->get("keywords") ),
|
||||
});
|
||||
|
||||
$var->{ form_location }
|
||||
= WebGUI::Form::Text( $session, {
|
||||
name => "location",
|
||||
value => ( $form->get("location") || $self->get("location") ),
|
||||
});
|
||||
|
||||
$var->{ form_friendsOnly }
|
||||
= WebGUI::Form::yesNo( $session, {
|
||||
name => "friendsOnly",
|
||||
value => ( $form->get("friendsOnly") || $self->get("friendsOnly") ),
|
||||
defaultValue => undef,
|
||||
});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_view ( )
|
||||
=head2 www_makeShortcut ( )
|
||||
|
||||
Web facing method which is the default view page. This method does a
|
||||
302 redirect to the "showPage" file in the storage location.
|
||||
Display the form to make a shortcut.
|
||||
|
||||
This page is only available to those who can edit this Photo.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_view {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->noAccess() unless $self->canView;
|
||||
if ($self->session->var->isAdminOn) {
|
||||
return $self->getContainer->www_view;
|
||||
}
|
||||
$self->session->http->setRedirect($self->getFileUrl($self->getValue("showPage")));
|
||||
return "";
|
||||
sub www_makeShortcut {
|
||||
my $self = shift;
|
||||
|
||||
return $self->session->privilege->insufficient unless $self->canEdit;
|
||||
|
||||
# ...
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_makeShortcutSave ( )
|
||||
|
||||
Make the shortcut.
|
||||
|
||||
This page is only available to those who can edit this Photo.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_makeShortcutSave {
|
||||
my $self = shift;
|
||||
my $form = $self->session->form;
|
||||
|
||||
return $self->session->privilege->insufficient unless $self->canEdit;
|
||||
|
||||
#...
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
304
lib/WebGUI/Asset/Wobject/Gallery.pm
Normal file
304
lib/WebGUI/Asset/Wobject/Gallery.pm
Normal file
|
|
@ -0,0 +1,304 @@
|
|||
package WebGUI::Asset::Wobject::Gallery;
|
||||
|
||||
$VERSION = "1.0.0";
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2006 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use Tie::IxHash;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Utility;
|
||||
use base 'WebGUI::Asset::Wobject';
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( )
|
||||
|
||||
defines wobject properties for New Wobject instances. You absolutely need
|
||||
this method in your new Wobjects. If you choose to "autoGenerateForms", the
|
||||
getEditForm method is unnecessary/redundant/useless.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_Gallery');
|
||||
|
||||
tie my %imageResolutionOptions, 'Tie::IxHash', (
|
||||
'640' => '640',
|
||||
'800' => '800',
|
||||
'1024' => '1024',
|
||||
'1260' => '1260',
|
||||
'1440' => '1440',
|
||||
'1600' => '1600',
|
||||
'2880' => '2880',
|
||||
);
|
||||
|
||||
tie my %properties, 'Tie::IxHash', (
|
||||
groupIdAddComment => {
|
||||
tab => "security",
|
||||
fieldType => "group",
|
||||
defaultValue => 2, # Registered Users
|
||||
label => $i18n->get("groupIdAddComment label"),
|
||||
hoverHelp => $i18n->get("groupIdAddComment description"),
|
||||
},
|
||||
groupIdAddFile => {
|
||||
tab => "security",
|
||||
fieldType => "group",
|
||||
defaultValue => 2, # Registered Users
|
||||
label => $i18n->get("groupIdAddFile label"),
|
||||
hoverHelp => $i18n->get("groupIdAddFile description"),
|
||||
},
|
||||
groupIdModerator => {
|
||||
tab => "security",
|
||||
fieldType => "group",
|
||||
defaultValue => 3, # Admins
|
||||
label => $i18n->get("groupIdModerator label"),
|
||||
hoverHelp => $i18n->get("groupIdModerator description"),
|
||||
},
|
||||
imageResolutions => {
|
||||
tab => "properties",
|
||||
fieldType => "checkList",
|
||||
defaultValue => ['800','1024','1200','1600'],
|
||||
options => \%imageResolutionOptions,
|
||||
label => $i18n->get("imageResolutions label"),
|
||||
hoverHelp => $i18n->get("imageResolutions description"),
|
||||
},
|
||||
imageViewSize => {
|
||||
tab => "properties",
|
||||
fieldType => "integer",
|
||||
defaultValue => 0,
|
||||
label => $i18n->get("imageViewSize label"),
|
||||
hoverHelp => $i18n->get("imageViewSize description"),
|
||||
},
|
||||
imageViewCompression => {
|
||||
tab => "properties",
|
||||
fieldType => "integer",
|
||||
defaultValue => 0,
|
||||
label => $i18n->get("imageViewCompression label"),
|
||||
hoverHelp => $i18n->get("imageViewCompression description"),
|
||||
},
|
||||
imageThumbnailSize => {
|
||||
tab => "properties",
|
||||
fieldType => "integer",
|
||||
defaultValue => 0,
|
||||
label => $i18n->get("imageThumbnailSize label"),
|
||||
hoverHelp => $i18n->get("imageThumbnailSize description"),
|
||||
},
|
||||
maxSpacePerUser => {
|
||||
tab => "properties",
|
||||
fieldType => "integer",
|
||||
defaultValue => 0,
|
||||
label => $i18n->get("maxSpacePerUser label"),
|
||||
hoverHelp => $i18n->get("maxSpacePerUser description"),
|
||||
},
|
||||
richEditIdFileComment => {
|
||||
tab => "properties",
|
||||
fieldType => "selectRichEditor",
|
||||
defaultValue => undef, # Rich Editor for Posts
|
||||
label => $i18n->get("richEditIdFileComment label"),
|
||||
hoverHelp => $i18n->get("richEditIdFileComment description"),
|
||||
},
|
||||
templateIdAddArchive => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "GalleryAlbum/AddArchive",
|
||||
label => $i18n->get("templateIdAddArchive label"),
|
||||
hoverHelp => $i18n->get("templateIdAddArchive description"),
|
||||
},
|
||||
templateIdDeleteAlbum => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "GalleryAlbum/Delete",
|
||||
label => $i18n->get("templateIdDeleteAlbum label"),
|
||||
hoverHelp => $i18n->get("templateIdDeleteAlbum description"),
|
||||
},
|
||||
templateIdDeleteFile => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "GalleryFile/Delete",
|
||||
label => $i18n->get("templateIdDeleteFile label"),
|
||||
hoverHelp => $i18n->get("templateIdDeleteFile description"),
|
||||
},
|
||||
templateIdEditFile => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "GalleryFile/Edit",
|
||||
label => $i18n->get("templateIdEditFile label"),
|
||||
hoverHelp => $i18n->get("templateIdEditFile description"),
|
||||
},
|
||||
templateIdListAlbums => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "Gallery/ListAlbums",
|
||||
label => $i18n->get("templateIdListAlbums label"),
|
||||
hoverHelp => $i18n->get("templateIdListAlbums description"),
|
||||
},
|
||||
templateIdListAlbumsRss => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "Gallery/ListAlbumsRss",
|
||||
label => $i18n->get("templateIdListAlbumsRss label"),
|
||||
hoverHelp => $i18n->get("templateIdListAlbumsRss description"),
|
||||
},
|
||||
templateIdListUserFiles => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "Gallery/ListUserFiles",
|
||||
label => $i18n->get("templateIdListUserFiles label"),
|
||||
hoverHelp => $i18n->get("templateIdListUserFiles description"),
|
||||
},
|
||||
templateIdListUserFilesRss => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "Gallery/ListUserFilesRss",
|
||||
label => $i18n->get("templateIdListUserFilesRss label"),
|
||||
hoverHelp => $i18n->get("templateIdListUserFilesRss description"),
|
||||
},
|
||||
templateIdMakeShortcut => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "GalleryFile/MakeShortcut",
|
||||
label => $i18n->get("templateIdMakeShortcut label"),
|
||||
hoverHelp => $i18n->get("templateIdMakeShortcut description"),
|
||||
},
|
||||
templateIdSearch => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "Gallery/Search",
|
||||
label => $i18n->get("templateIdSearch label"),
|
||||
hoverHelp => $i18n->get("templateIdSearch description"),
|
||||
},
|
||||
templateIdSlideshow => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "GalleryAlbum/Slideshow",
|
||||
label => $i18n->get("templateIdSlideshow label"),
|
||||
hoverHelp => $i18n->get("templateIdSlideshow description"),
|
||||
},
|
||||
templateIdThumbnails => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "GalleryAlbum/Thumbnails",
|
||||
label => $i18n->get("templateIdThumbnails label"),
|
||||
hoverHelp => $i18n->get("templateIdThumbnails description"),
|
||||
},
|
||||
templateIdViewAlbum => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "GalleryAlbum/View",
|
||||
label => $i18n->get("templateIdViewAlbum label"),
|
||||
hoverHelp => $i18n->get("templateIdViewAlbum description"),
|
||||
},
|
||||
templateIdViewAlbumRss => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "GalleryAlbum/ViewRss",
|
||||
label => $i18n->get("templateIdViewAlbumRss label"),
|
||||
hoverHelp => $i18n->get("templateIdViewAlbumRss description"),
|
||||
},
|
||||
templateIdViewFile => {
|
||||
tab => "display",
|
||||
fieldType => "template",
|
||||
defaultValue => "",
|
||||
namespace => "GalleryFile/View",
|
||||
label => $i18n->get("templateIdViewFile label"),
|
||||
hoverHelp => $i18n->get("templateIdViewFile description"),
|
||||
},
|
||||
workflowIdCommit => {
|
||||
tab => "security",
|
||||
fieldType => "workflow",
|
||||
defaultValue => "pbworkflow000000000003", # Commit without approval
|
||||
type => 'WebGUI::VersionTag',
|
||||
label => $i18n->get("workflowIdCommit label"),
|
||||
hoverHelp => $i18n->get("workflowIdCommit description"),
|
||||
},
|
||||
);
|
||||
|
||||
push @{$definition}, {
|
||||
assetName => $i18n->get('assetName'),
|
||||
icon => 'newWobject.gif',
|
||||
autoGenerateForms => 1,
|
||||
tableName => 'Gallery',
|
||||
className => __PACKAGE__,
|
||||
properties => \%properties,
|
||||
};
|
||||
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getTemplateEditFile ( )
|
||||
|
||||
Returns an instance of a WebGUI::Asset::Template for the template to edit
|
||||
files in this gallery
|
||||
|
||||
NOTE: This may need to change in the future to take into account different
|
||||
classes of files inside of a Gallery.
|
||||
|
||||
=cut
|
||||
|
||||
sub getTemplateEditFile {
|
||||
my $self = shift;
|
||||
return WebGUI::Asset::Template->new($self->session, $self->get("templateIdEditFile"));
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 prepareView ( )
|
||||
|
||||
See WebGUI::Asset::prepareView() for details.
|
||||
|
||||
=cut
|
||||
|
||||
sub prepareView {
|
||||
my $self = shift;
|
||||
$self->SUPER::prepareView();
|
||||
my $template = WebGUI::Asset::Template->new($self->session, $self->get("templateId"));
|
||||
$template->prepare;
|
||||
$self->{_viewTemplate} = $template;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 view ( )
|
||||
|
||||
method called by the www_view method. Returns a processed template
|
||||
to be displayed within the page style.
|
||||
|
||||
=cut
|
||||
|
||||
sub view {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $var = $self->get;
|
||||
|
||||
return $self->processTemplate($var, undef, $self->{_viewTemplate});
|
||||
}
|
||||
|
||||
1;
|
||||
118
lib/WebGUI/Asset/Wobject/GalleryAlbum.pm
Normal file
118
lib/WebGUI/Asset/Wobject/GalleryAlbum.pm
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
package WebGUI::Asset::Wobject::GalleryAlbum;
|
||||
|
||||
$VERSION = "1.0.0";
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2006 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use Tie::IxHash;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Utility;
|
||||
use base 'WebGUI::Asset::Wobject';
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( )
|
||||
|
||||
defines wobject properties for New Wobject instances. You absolutely need
|
||||
this method in your new Wobjects. If you choose to "autoGenerateForms", the
|
||||
getEditForm method is unnecessary/redundant/useless.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_GalleryAlbum');
|
||||
|
||||
tie my %properties, 'Tie::IxHash', (
|
||||
allowComments => {
|
||||
fieldType => "yesNo",
|
||||
defaultValue => 0,
|
||||
label => $i18n->get("allowComments label"),
|
||||
hoverHelp => $i18n->get("allowComments description"),
|
||||
},
|
||||
othersCanAdd => {
|
||||
fieldType => "yesNo",
|
||||
defaultValue => 0,
|
||||
label => $i18n->get("othersCanAdd label"),
|
||||
hoverHelp => $i18n->get("othersCanAdd description"),
|
||||
},
|
||||
);
|
||||
|
||||
push @{$definition}, {
|
||||
assetName => $i18n->get('assetName'),
|
||||
icon => 'newWobject.gif',
|
||||
autoGenerateForms => 1,
|
||||
tableName => 'GalleryAlbum',
|
||||
className => __PACKAGE__,
|
||||
properties => \%properties,
|
||||
};
|
||||
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 canEdit ( [userId] )
|
||||
|
||||
Returns true if the user can edit this asset. C<userId> is a WebGUI user ID.
|
||||
If no userId is passed, check the current user.
|
||||
|
||||
Users can edit this GalleryAlbum if they are the owner, or if they can edit
|
||||
the Gallery parent.
|
||||
|
||||
=cut
|
||||
|
||||
sub canEdit {
|
||||
my $self = shift;
|
||||
my $userId = shift || $self->session->user->userId;
|
||||
my $gallery = $self->getParent;
|
||||
|
||||
return 1 if $userId eq $self->get("ownerUserId");
|
||||
return $gallery->canEdit($userId);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 prepareView ( )
|
||||
|
||||
See WebGUI::Asset::prepareView() for details.
|
||||
|
||||
=cut
|
||||
|
||||
sub prepareView {
|
||||
my $self = shift;
|
||||
$self->SUPER::prepareView();
|
||||
my $template = WebGUI::Asset::Template->new($self->session, $self->get("templateId"));
|
||||
$template->prepare;
|
||||
$self->{_viewTemplate} = $template;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 view ( )
|
||||
|
||||
method called by the www_view method. Returns a processed template
|
||||
to be displayed within the page style.
|
||||
|
||||
=cut
|
||||
|
||||
sub view {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $var = $self->get;
|
||||
|
||||
return $self->processTemplate($var, undef, $self->{_viewTemplate});
|
||||
}
|
||||
|
||||
1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue