merged with SVN HEAD
This commit is contained in:
commit
5222ad6be1
74 changed files with 10757 additions and 434 deletions
|
|
@ -1,5 +1,4 @@
|
|||
7.5.0
|
||||
- rfe: Default log level to ERROR
|
||||
- rfe: Search Asset returns URLs
|
||||
- Added link to return to inbox from message in inbox message template (Diona Kidd, Knowmad Technologies)
|
||||
- fix: Cannot delete private message (Diona Kidd, Knowmad Technologies)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ use lib "../../lib";
|
|||
use strict;
|
||||
use Getopt::Long;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::Asset;
|
||||
|
||||
|
||||
my $toVersion = "0.0.0"; # make this match what version you're going to
|
||||
|
|
@ -33,8 +35,71 @@ finish($session); # this line required
|
|||
#}
|
||||
|
||||
|
||||
# --------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
||||
# ---- DO NOT EDIT BELOW THIS LINE ----
|
||||
#----------------------------------------------------------------------------
|
||||
# Add a package to the import node
|
||||
sub addPackage {
|
||||
my $session = shift;
|
||||
my $file = shift;
|
||||
|
||||
# Make a storage location for the package
|
||||
my $storage = WebGUI::Storage->createTemp( $session );
|
||||
$storage->addFileFromFilesystem( $file );
|
||||
|
||||
# Import the package into the import node
|
||||
WebGUI::Asset->getImportNode($session)->importPackage( $storage );
|
||||
|
||||
# Make the package not a package anymore
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Add a template from a file
|
||||
sub addTemplate {
|
||||
my $session = shift;
|
||||
my $file = shift;
|
||||
my $newFolder = shift;
|
||||
|
||||
open(FILE,"<",$file);
|
||||
my $first = 1;
|
||||
my $create = 0;
|
||||
my $head = 0;
|
||||
my %properties = (className=>"WebGUI::Asset::Template");
|
||||
while (my $line = <FILE>) {
|
||||
if ($first) {
|
||||
$line =~ m/^\#(.*)$/;
|
||||
$properties{id} = $1;
|
||||
$first = 0;
|
||||
}
|
||||
elsif ($line =~ m/^\#create$/) {
|
||||
$create = 1;
|
||||
}
|
||||
elsif ($line =~ m/^\#(.*):(.*)$/) {
|
||||
$properties{$1} = $2;
|
||||
}
|
||||
elsif ($line =~ m/^~~~$/) {
|
||||
$head = 1;
|
||||
}
|
||||
elsif ($head) {
|
||||
$properties{headBlock} .= $line;
|
||||
}
|
||||
else {
|
||||
$properties{template} .= $line;
|
||||
}
|
||||
}
|
||||
close(FILE);
|
||||
if ($create) {
|
||||
$$newFolder = createNewTemplatesFolder(WebGUI::Asset->getImportNode($session))
|
||||
unless (defined $$newFolder);
|
||||
my $template = $$newFolder->addChild(\%properties, $properties{id});
|
||||
}
|
||||
else {
|
||||
my $template = WebGUI::Asset->new($session,$properties{id}, "WebGUI::Asset::Template");
|
||||
if (defined $template) {
|
||||
my $newRevision = $template->addRevision(\%properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub start {
|
||||
|
|
@ -63,49 +128,24 @@ sub finish {
|
|||
|
||||
#-------------------------------------------------
|
||||
sub updateTemplates {
|
||||
my $session = shift;
|
||||
return undef unless (-d "templates-".$toVersion);
|
||||
print "\tUpdating templates.\n" unless ($quiet);
|
||||
opendir(DIR,"templates-".$toVersion);
|
||||
my @files = readdir(DIR);
|
||||
closedir(DIR);
|
||||
my $importNode = WebGUI::Asset->getImportNode($session);
|
||||
my $newFolder = undef;
|
||||
foreach my $file (@files) {
|
||||
next unless ($file =~ /\.tmpl$/);
|
||||
open(FILE,"<templates-".$toVersion."/".$file);
|
||||
my $first = 1;
|
||||
my $create = 0;
|
||||
my $head = 0;
|
||||
my %properties = (className=>"WebGUI::Asset::Template");
|
||||
while (my $line = <FILE>) {
|
||||
if ($first) {
|
||||
$line =~ m/^\#(.*)$/;
|
||||
$properties{id} = $1;
|
||||
$first = 0;
|
||||
} elsif ($line =~ m/^\#create$/) {
|
||||
$create = 1;
|
||||
} elsif ($line =~ m/^\#(.*):\s*(.*)$/) {
|
||||
$properties{$1} = $2;
|
||||
} elsif ($line =~ m/^~~~$/) {
|
||||
$head = 1;
|
||||
} elsif ($head) {
|
||||
$properties{headBlock} .= $line;
|
||||
} else {
|
||||
$properties{template} .= $line;
|
||||
}
|
||||
}
|
||||
close(FILE);
|
||||
if ($create) {
|
||||
$newFolder = createNewTemplatesFolder($importNode) unless (defined $newFolder);
|
||||
my $template = $newFolder->addChild(\%properties, $properties{id});
|
||||
} else {
|
||||
my $template = WebGUI::Asset->new($session,$properties{id}, "WebGUI::Asset::Template");
|
||||
if (defined $template) {
|
||||
my $newRevision = $template->addRevision(\%properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
my $session = shift;
|
||||
return undef unless (-d "templates-".$toVersion);
|
||||
print "\tUpdating templates.\n" unless ($quiet);
|
||||
opendir(DIR,"templates-".$toVersion);
|
||||
my @files = readdir(DIR);
|
||||
closedir(DIR);
|
||||
my $newFolder = undef;
|
||||
foreach my $file (@files) {
|
||||
next unless ($file =~ /\.(tmpl|wgpkg)$/);
|
||||
my $type = $1;
|
||||
$file = "templates-" . $toVersion . "/" . $file;
|
||||
if ($type eq "tmpl") {
|
||||
addTemplate( $session, $file, \$newFolder );
|
||||
}
|
||||
elsif ($type eq "wgpkg") {
|
||||
addPackage( $session, $file );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -25,6 +25,9 @@ addUrlAndContentHandlers($session);
|
|||
addFriendsNetwork($session);
|
||||
addSearchWithContainers($session);
|
||||
addGroupToEditPost($session);
|
||||
installGalleryAsset($session);
|
||||
installGalleryAlbumAsset($session);
|
||||
installPhotoAsset($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
|
@ -143,8 +146,189 @@ EOSQL
|
|||
print "OK\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Install the GalleryAlbum asset
|
||||
sub installGalleryAlbumAsset {
|
||||
my $session = shift;
|
||||
print "\tInstalling GalleryAlbum asset..." unless $quiet;
|
||||
|
||||
$session->db->write(<<'ENDSQL');
|
||||
CREATE TABLE IF NOT EXISTS GalleryAlbum (
|
||||
assetId VARCHAR(22) BINARY NOT NULL,
|
||||
revisionDate BIGINT NOT NULL,
|
||||
allowComments INT,
|
||||
assetIdThumbnail VARCHAR(22) BINARY,
|
||||
othersCanAdd INT,
|
||||
PRIMARY KEY (assetId, revisionDate)
|
||||
)
|
||||
ENDSQL
|
||||
|
||||
# ---- DO NOT EDIT BELOW THIS LINE ----
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Install the Gallery asset
|
||||
sub installGalleryAsset {
|
||||
my $session = shift;
|
||||
print "\tInstalling Gallery asset..." unless $quiet;
|
||||
|
||||
$session->db->write(<<'ENDSQL');
|
||||
CREATE TABLE IF NOT EXISTS Gallery (
|
||||
assetId VARCHAR(22) BINARY NOT NULL,
|
||||
revisionDate BIGINT NOT NULL,
|
||||
groupIdAddComment VARCHAR(22) BINARY,
|
||||
groupIdAddFile VARCHAR(22) BINARY,
|
||||
groupIdModerator VARCHAR(22) BINARY,
|
||||
imageResolutions TEXT,
|
||||
imageViewSize INT,
|
||||
imageThumbnailSize INT,
|
||||
maxSpacePerUser VARCHAR(20),
|
||||
richEditIdComment VARCHAR(22) BINARY,
|
||||
templateIdAddArchive VARCHAR(22) BINARY,
|
||||
templateIdDeleteAlbum VARCHAR(22) BINARY,
|
||||
templateIdDeleteFile VARCHAR(22) BINARY,
|
||||
templateIdEditAlbum VARCHAR(22) BINARY,
|
||||
templateIdEditFile VARCHAR(22) BINARY,
|
||||
templateIdListAlbums VARCHAR(22) BINARY,
|
||||
templateIdListAlbumsRss VARCHAR(22) BINARY,
|
||||
templateIdListFilesForUser VARCHAR(22) BINARY,
|
||||
templateIdListFilesForUserRss VARCHAR(22) BINARY,
|
||||
templateIdMakeShortcut VARCHAR(22) BINARY,
|
||||
templateIdSearch VARCHAR(22) BINARY,
|
||||
templateIdViewSlideshow VARCHAR(22) BINARY,
|
||||
templateIdViewThumbnails VARCHAR(22) BINARY,
|
||||
templateIdViewAlbum VARCHAR(22) BINARY,
|
||||
templateIdViewAlbumRss VARCHAR(22) BINARY,
|
||||
templateIdViewFile VARCHAR(22) BINARY,
|
||||
viewAlbumAssetId VARCHAR(22),
|
||||
viewDefault ENUM('album','list'),
|
||||
viewListOrderBy VARCHAR(40),
|
||||
viewListOrderDirection ENUM('ASC','DESC'),
|
||||
workflowIdCommit VARCHAR(22) BINARY,
|
||||
PRIMARY KEY (assetId, revisionDate)
|
||||
)
|
||||
ENDSQL
|
||||
|
||||
$session->config->addToArray("assets","WebGUI::Asset::Wobject::Gallery");
|
||||
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Install the photo asset
|
||||
sub installPhotoAsset {
|
||||
my $session = shift;
|
||||
print "\tInstalling Photo asset..." unless $quiet;
|
||||
|
||||
# Photo Asset
|
||||
$session->db->write(<<'ENDSQL');
|
||||
CREATE TABLE IF NOT EXISTS Photo (
|
||||
assetId VARCHAR(22) BINARY NOT NULL,
|
||||
revisionDate BIGINT NOT NULL,
|
||||
exifData LONGTEXT,
|
||||
friendsOnly INT,
|
||||
location VARCHAR(255),
|
||||
rating INT,
|
||||
userDefined1 TEXT,
|
||||
userDefined2 TEXT,
|
||||
userDefined3 TEXT,
|
||||
userDefined4 TEXT,
|
||||
userDefined5 TEXT,
|
||||
PRIMARY KEY (assetId, revisionDate)
|
||||
)
|
||||
ENDSQL
|
||||
|
||||
$session->db->write(<<'ENDSQL');
|
||||
CREATE TABLE IF NOT EXISTS Photo_comment (
|
||||
assetId VARCHAR(22) BINARY NOT NULL,
|
||||
commentId VARCHAR(22) BINARY NOT NULL,
|
||||
userId VARCHAR(22) BINARY,
|
||||
visitorIp VARCHAR(255),
|
||||
creationDate DATETIME,
|
||||
bodyText LONGTEXT,
|
||||
INDEX (commentId),
|
||||
PRIMARY KEY (assetId, commentId)
|
||||
)
|
||||
ENDSQL
|
||||
|
||||
$session->db->write(<<'ENDSQL');
|
||||
CREATE TABLE IF NOT EXISTS Photo_rating (
|
||||
assetId VARCHAR(22) BINARY NOT NULL,
|
||||
userId VARCHAR(22) BINARY,
|
||||
visitorIp VARCHAR(255),
|
||||
rating INT,
|
||||
INDEX (assetId)
|
||||
)
|
||||
ENDSQL
|
||||
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
# --------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Add a package to the import node
|
||||
sub addPackage {
|
||||
my $session = shift;
|
||||
my $file = shift;
|
||||
|
||||
# Make a storage location for the package
|
||||
my $storage = WebGUI::Storage->createTemp( $session );
|
||||
$storage->addFileFromFilesystem( $file );
|
||||
|
||||
# Import the package into the import node
|
||||
WebGUI::Asset->getImportNode($session)->importPackage( $storage );
|
||||
|
||||
# Make the package not a package anymore
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Add a template from a file
|
||||
sub addTemplate {
|
||||
my $session = shift;
|
||||
my $file = shift;
|
||||
my $newFolder = shift;
|
||||
|
||||
open(FILE,"<",$file);
|
||||
my $first = 1;
|
||||
my $create = 0;
|
||||
my $head = 0;
|
||||
my %properties = (className=>"WebGUI::Asset::Template");
|
||||
while (my $line = <FILE>) {
|
||||
if ($first) {
|
||||
$line =~ m/^\#(.*)$/;
|
||||
$properties{id} = $1;
|
||||
$first = 0;
|
||||
}
|
||||
elsif ($line =~ m/^\#create$/) {
|
||||
$create = 1;
|
||||
}
|
||||
elsif ($line =~ m/^\#(.*):(.*)$/) {
|
||||
$properties{$1} = $2;
|
||||
}
|
||||
elsif ($line =~ m/^~~~$/) {
|
||||
$head = 1;
|
||||
}
|
||||
elsif ($head) {
|
||||
$properties{headBlock} .= $line;
|
||||
}
|
||||
else {
|
||||
$properties{template} .= $line;
|
||||
}
|
||||
}
|
||||
close(FILE);
|
||||
if ($create) {
|
||||
$$newFolder = createNewTemplatesFolder(WebGUI::Asset->getImportNode($session))
|
||||
unless (defined $$newFolder);
|
||||
my $template = $$newFolder->addChild(\%properties, $properties{id});
|
||||
}
|
||||
else {
|
||||
my $template = WebGUI::Asset->new($session,$properties{id}, "WebGUI::Asset::Template");
|
||||
if (defined $template) {
|
||||
my $newRevision = $template->addRevision(\%properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub start {
|
||||
|
|
@ -173,49 +357,24 @@ sub finish {
|
|||
|
||||
#-------------------------------------------------
|
||||
sub updateTemplates {
|
||||
my $session = shift;
|
||||
return undef unless (-d "templates-".$toVersion);
|
||||
print "\tUpdating templates.\n" unless ($quiet);
|
||||
opendir(DIR,"templates-".$toVersion);
|
||||
my @files = readdir(DIR);
|
||||
closedir(DIR);
|
||||
my $importNode = WebGUI::Asset->getImportNode($session);
|
||||
my $newFolder = undef;
|
||||
foreach my $file (@files) {
|
||||
next unless ($file =~ /\.tmpl$/);
|
||||
open(FILE,"<templates-".$toVersion."/".$file);
|
||||
my $first = 1;
|
||||
my $create = 0;
|
||||
my $head = 0;
|
||||
my %properties = (className=>"WebGUI::Asset::Template");
|
||||
while (my $line = <FILE>) {
|
||||
if ($first) {
|
||||
$line =~ m/^\#(.*)$/;
|
||||
$properties{id} = $1;
|
||||
$first = 0;
|
||||
} elsif ($line =~ m/^\#create$/) {
|
||||
$create = 1;
|
||||
} elsif ($line =~ m/^\#(.*):(.*)$/) {
|
||||
$properties{$1} = $2;
|
||||
} elsif ($line =~ m/^~~~$/) {
|
||||
$head = 1;
|
||||
} elsif ($head) {
|
||||
$properties{headBlock} .= $line;
|
||||
} else {
|
||||
$properties{template} .= $line;
|
||||
}
|
||||
}
|
||||
close(FILE);
|
||||
if ($create) {
|
||||
$newFolder = createNewTemplatesFolder($importNode) unless (defined $newFolder);
|
||||
my $template = $newFolder->addChild(\%properties, $properties{id});
|
||||
} else {
|
||||
my $template = WebGUI::Asset->new($session,$properties{id}, "WebGUI::Asset::Template");
|
||||
if (defined $template) {
|
||||
my $newRevision = $template->addRevision(\%properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
my $session = shift;
|
||||
return undef unless (-d "templates-".$toVersion);
|
||||
print "\tUpdating templates.\n" unless ($quiet);
|
||||
opendir(DIR,"templates-".$toVersion);
|
||||
my @files = readdir(DIR);
|
||||
closedir(DIR);
|
||||
my $newFolder = undef;
|
||||
foreach my $file (@files) {
|
||||
next unless ($file =~ /\.(tmpl|wgpkg)$/);
|
||||
my $type = $1;
|
||||
$file = "templates-" . $toVersion . "/" . $file;
|
||||
if ($type eq "tmpl") {
|
||||
addTemplate( $session, $file, \$newFolder );
|
||||
}
|
||||
elsif ($type eq "wgpkg") {
|
||||
addPackage( $session, $file );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
# system is capable of. To unleash the full power read the config file manual
|
||||
# http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl/Config.html
|
||||
|
||||
log4perl.logger = ERROR, mainlog
|
||||
log4perl.logger = WARN, mainlog
|
||||
log4perl.appender.mainlog = Log::Log4perl::Appender::File
|
||||
log4perl.appender.mainlog.filename = /var/log/webgui.log
|
||||
log4perl.appender.mainlog.layout = PatternLayout
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ package WebGUI::Asset;
|
|||
|
||||
=cut
|
||||
|
||||
use Carp qw( croak confess );
|
||||
|
||||
use WebGUI::AssetBranch;
|
||||
use WebGUI::AssetClipboard;
|
||||
use WebGUI::AssetExportHtml;
|
||||
|
|
@ -1337,12 +1339,12 @@ Loads an asset module if it's not already in memory. This is a class method. Ret
|
|||
|
||||
sub loadModule {
|
||||
my ($class, $session, $className) = @_;
|
||||
(my $module = $className . '.pm') =~ s{::|'}{/}g;
|
||||
(my $module = $className . '.pm') =~ s{::|'}{/}g;
|
||||
if (eval { require $module; 1 }) {
|
||||
return $className;
|
||||
}
|
||||
$session->errorHandler->error("Couldn't compile asset package: ".$className.". Root cause: ".$@);
|
||||
return;
|
||||
$session->errorHandler->error("Couldn't compile asset package: ".$className.". Root cause: ".$@);
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -1753,6 +1755,7 @@ A specific revision date for the asset to retrieve. If not specified, the most r
|
|||
sub newByDynamicClass {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
confess "newByDynamicClass requires WebGUI::Session" unless $session;
|
||||
my $assetId = shift;
|
||||
my $revisionDate = shift;
|
||||
return unless defined $assetId;
|
||||
|
|
@ -1896,6 +1899,7 @@ sub processPropertiesFromFormPost {
|
|||
$self->session->db->beginTransaction;
|
||||
$self->update(\%data);
|
||||
$self->session->db->commit;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1984,6 +1988,16 @@ sub publish {
|
|||
$cache->deleteChunk(["asset",$id]);
|
||||
}
|
||||
$self->{_properties}{state} = "published";
|
||||
|
||||
# Also publish any shortcuts to this asset that are in the trash
|
||||
my $shortcuts
|
||||
= WebGUI::Asset::Shortcut->getShortcutsForAssetId($self->session, $self->getId, {
|
||||
returnObjects => 1,
|
||||
statesToInclude => ['trash','trash-limbo'],
|
||||
});
|
||||
for my $shortcut ( @$shortcuts ) {
|
||||
$shortcut->publish;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2073,6 +2087,9 @@ Updates the properties of an existing revision. If you want to create a new revi
|
|||
|
||||
Hash reference of properties and values to set.
|
||||
|
||||
NOTE: C<keywords> is a special property that uses the WebGUI::Keyword API
|
||||
to set the keywords for this asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub update {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ package WebGUI::Asset::File;
|
|||
|
||||
use strict;
|
||||
use base 'WebGUI::Asset';
|
||||
use Carp;
|
||||
use WebGUI::Cache;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::SQL;
|
||||
|
|
@ -54,17 +55,17 @@ Override the default method in order to deal with attachments.
|
|||
=cut
|
||||
|
||||
sub addRevision {
|
||||
my $self = shift;
|
||||
my $properties = shift;
|
||||
|
||||
if ($self->get("storageId") ne "") {
|
||||
my $newStorage = WebGUI::Storage->get($self->session,$self->get("storageId"))->copy;
|
||||
$properties->{storageId} = $newStorage->getId;
|
||||
}
|
||||
|
||||
my $newSelf = $self->SUPER::addRevision($properties);
|
||||
|
||||
return $newSelf;
|
||||
my $self = shift;
|
||||
my $properties = shift;
|
||||
|
||||
if ($self->get("storageId") ne "") {
|
||||
my $newStorage = $self->getStorageClass->get($self->session,$self->get("storageId"))->copy;
|
||||
$properties->{storageId} = $newStorage->getId;
|
||||
}
|
||||
|
||||
my $newSelf = $self->SUPER::addRevision($properties, @_);
|
||||
|
||||
return $newSelf;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -172,23 +173,50 @@ Returns the TabForm object that will be used in generating the edit page for thi
|
|||
=cut
|
||||
|
||||
sub getEditForm {
|
||||
my $self = shift;
|
||||
my $tabform = $self->SUPER::getEditForm();
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset_File');
|
||||
if ($self->get("filename") ne "") {
|
||||
$tabform->getTab("properties")->readOnly(
|
||||
-label=>$i18n->get('current file'),
|
||||
-hoverHelp=>$i18n->get('current file description', 'Asset_File'),
|
||||
-value=>'<p style="display:inline;vertical-align:middle;"><a href="'.$self->getFileUrl.'"><img src="'.$self->getFileIconUrl.'" alt="'.$self->get("filename").'" style="border-style:none;vertical-align:middle;" /> '.$self->get("filename").'</a></p>'
|
||||
);
|
||||
my $self = shift;
|
||||
my $tabform = $self->SUPER::getEditForm();
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset_File');
|
||||
|
||||
}
|
||||
$tabform->getTab("properties")->file(
|
||||
-name => 'newFile',
|
||||
-label => $i18n->get('new file'),
|
||||
-hoverHelp => $i18n->get('new file description'),
|
||||
);
|
||||
return $tabform;
|
||||
$tabform->getTab("properties")->raw(
|
||||
'<tr><td>'.$i18n->get('new file').'<td colspan="2">'
|
||||
. $self->getEditFormUploadControl
|
||||
. '</td></tr>'
|
||||
);
|
||||
|
||||
return $tabform;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getEditFormUploadControl
|
||||
|
||||
Returns the HTML to render the upload box and link to delete the existing
|
||||
file, if necessary.
|
||||
|
||||
=cut
|
||||
|
||||
sub getEditFormUploadControl {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_File');
|
||||
my $html = '';
|
||||
|
||||
if ($self->get("filename") ne "") {
|
||||
$html .= WebGUI::Form::readOnly( $session, {
|
||||
label => $i18n->get('current file'),
|
||||
hoverHelp => $i18n->get('current file description', 'Asset_File'),
|
||||
value => '<p style="display:inline;vertical-align:middle;"><a href="'.$self->getFileUrl.'"><img src="'.$self->getFileIconUrl.'" alt="'.$self->get("filename").'" style="border-style:none;vertical-align:middle;" /> '.$self->get("filename").'</a></p>'
|
||||
});
|
||||
}
|
||||
|
||||
# Control to upload a new file
|
||||
$html .= WebGUI::Form::file( $session, {
|
||||
name => 'newFile',
|
||||
label => $i18n->get('new file'),
|
||||
hoverHelp => $i18n->get('new file description'),
|
||||
});
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -199,10 +227,10 @@ sub getFileUrl {
|
|||
return $self->getStorageLocation->getUrl($self->get("filename"));
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getFileIconUrl {
|
||||
my $self = shift;
|
||||
return unless $self->get("filename"); ## Why do I have to do this when creating new Files?
|
||||
return $self->getStorageLocation->getFileIconUrl($self->get("filename"));
|
||||
}
|
||||
|
||||
|
|
@ -221,20 +249,32 @@ sub getIcon {
|
|||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getStorageClass
|
||||
|
||||
Get the full classname of the WebGUI::Storage we should use for this asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub getStorageClass {
|
||||
return 'WebGUI::Storage';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getStorageFromPost
|
||||
|
||||
We have to wrap this operation because WebGUI::Asset::File::Image calls SUPER processPropertiesFormFormPost,
|
||||
which gives it the wrong type of Storage object.
|
||||
Get the storage location created by the form post.
|
||||
|
||||
=cut
|
||||
|
||||
sub getStorageFromPost {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my $storageId = shift;
|
||||
my $fileStorageId = WebGUI::Form::File->new($self->session, {name => 'newFile', value=>$storageId })->getValueFromPost;
|
||||
return WebGUI::Storage->get($self->session, $fileStorageId);
|
||||
$self->session->errorHandler->info( "File Storage Id: $fileStorageId" );
|
||||
return $self->getStorageClass->get($self->session, $fileStorageId);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -283,41 +323,21 @@ sub prepareView {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
|
||||
#Get the storage location out of memory. If you call getStorageLocation you risk creating another one.
|
||||
my $storageLocation = $self->{_storageLocation};
|
||||
my $storageId = undef;
|
||||
$storageId = $storageLocation->getId if(defined $storageLocation);
|
||||
|
||||
#Now remove the storage location to prevent wierd caching stuff.
|
||||
delete $self->{_storageLocation};
|
||||
|
||||
#Clear the storage location if a file was uploaded.
|
||||
if($session->form->get("newFile_file") ne "") {
|
||||
$storageLocation->clear();
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
my $errors = $self->SUPER::processPropertiesFromFormPost;
|
||||
return $errors if $errors;
|
||||
|
||||
if (my $storageId = $session->form->get('newFile','File')) {
|
||||
$session->errorHandler->info("Got a new file for asset " . $self->getId);
|
||||
my $storage = $self->getStorageClass->get( $session, $storageId);
|
||||
my $filePath = $storage->getPath( $storage->getFiles->[0] );
|
||||
$self->setFile( $filePath );
|
||||
$storage->delete;
|
||||
}
|
||||
|
||||
#Pass in the storage Id to prevent another one from being created.
|
||||
my $storage = $self->getStorageFromPost($storageId);
|
||||
|
||||
if (defined $storage) {
|
||||
my $filename = $storage->getFiles()->[0];
|
||||
|
||||
if (defined $filename) {
|
||||
my %data;
|
||||
$data{filename} = $filename;
|
||||
$data{storageId} = $storage->getId;
|
||||
$data{title} = $filename unless ($session->form->process("title"));
|
||||
$data{menuTitle} = $filename unless ($session->form->process("menuTitle"));
|
||||
$data{url} = $self->getParent->get('url').'/'.$filename unless ($session->form->process("url"));
|
||||
$self->setStorageLocation($storage);
|
||||
$self->update(\%data);
|
||||
}
|
||||
}
|
||||
$self->applyConstraints;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -327,7 +347,7 @@ sub purge {
|
|||
my $self = shift;
|
||||
my $sth = $self->session->db->read("select storageId from FileAsset where assetId=".$self->session->db->quote($self->getId));
|
||||
while (my ($storageId) = $sth->array) {
|
||||
WebGUI::Storage->get($self->session,$storageId)->delete;
|
||||
$self->getStorageClass->get($self->session,$storageId)->delete;
|
||||
}
|
||||
$sth->finish;
|
||||
return $self->SUPER::purge;
|
||||
|
|
@ -355,34 +375,68 @@ sub purgeRevision {
|
|||
return $self->SUPER::purgeRevision;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 setFile ( filename )
|
||||
|
||||
Set the file being handled by this storage location with a file from the
|
||||
system.
|
||||
|
||||
=cut
|
||||
|
||||
sub setFile {
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $storage = $self->getStorageLocation;
|
||||
|
||||
# Clear the old file if any
|
||||
$storage->clear;
|
||||
|
||||
$storage->addFileFromFilesystem($filename)
|
||||
|| croak "Couldn't setFile: " . join(", ",@{ $storage->getErrors });
|
||||
# NOTE: We should not croak here, the WebGUI::Storage should croak for us.
|
||||
|
||||
$self->updatePropertiesFromStorage;
|
||||
$self->applyConstraints;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setSize ( fileSize )
|
||||
|
||||
Set the size of this asset by including all the files in its storage
|
||||
location. C<fileSize> is an integer of additional bytes to include in
|
||||
the asset size.
|
||||
|
||||
=cut
|
||||
|
||||
sub setSize {
|
||||
my $self = shift;
|
||||
my $fileSize = shift || 0;
|
||||
my $storage = $self->getStorageLocation;
|
||||
if (defined $storage) {
|
||||
foreach my $file (@{$storage->getFiles}) {
|
||||
$fileSize += $storage->getFileSize($file);
|
||||
}
|
||||
}
|
||||
return $self->SUPER::setSize($fileSize);
|
||||
my $self = shift;
|
||||
my $fileSize = shift || 0;
|
||||
my $storage = $self->getStorageLocation;
|
||||
if (defined $storage) {
|
||||
foreach my $file (@{$storage->getFiles}) {
|
||||
$fileSize += $storage->getFileSize($file);
|
||||
}
|
||||
}
|
||||
return $self->SUPER::setSize($fileSize);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub setStorageLocation {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my $storage = shift;
|
||||
if (defined $storage) {
|
||||
if (defined $storage) {
|
||||
$self->{_storageLocation} = $storage;
|
||||
}
|
||||
elsif ($self->get("storageId") eq "") {
|
||||
$self->{_storageLocation} = WebGUI::Storage->create($self->session);
|
||||
$self->update({storageId=>$self->{_storageLocation}->getId});
|
||||
}
|
||||
}
|
||||
elsif ($self->get("storageId") eq "") {
|
||||
$self->{_storageLocation} = $self->getStorageClass->create($self->session);
|
||||
$self->update({storageId=>$self->{_storageLocation}->getId});
|
||||
}
|
||||
else {
|
||||
$self->{_storageLocation} = WebGUI::Storage->get($self->session,$self->get("storageId"));
|
||||
}
|
||||
$self->{_storageLocation} = $self->getStorageClass->get($self->session,$self->get("storageId"));
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -411,6 +465,27 @@ sub update {
|
|||
}
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 updatePropertiesFromStorage ( )
|
||||
|
||||
Updates the asset properties from the file tracked by this asset. Should be
|
||||
called every time the file is changed to ensure the correct filename is
|
||||
in the asset properties.
|
||||
|
||||
=cut
|
||||
|
||||
sub updatePropertiesFromStorage {
|
||||
my $self = shift;
|
||||
my $storage = $self->getStorageLocation;
|
||||
my $filename = $storage->getFiles->[0];
|
||||
$self->session->errorHandler->info("Updating file asset filename to $filename");
|
||||
$self->update({
|
||||
filename => $filename,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub view {
|
||||
my $self = shift;
|
||||
|
|
|
|||
|
|
@ -15,16 +15,12 @@ package WebGUI::Asset::File::Image;
|
|||
=cut
|
||||
|
||||
use strict;
|
||||
use WebGUI::Asset::File;
|
||||
use base 'WebGUI::Asset::File';
|
||||
use WebGUI::Storage::Image;
|
||||
use WebGUI::HTMLForm;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Form::Image;
|
||||
|
||||
|
||||
our @ISA = qw(WebGUI::Asset::File);
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Asset::File::Image
|
||||
|
|
@ -98,27 +94,27 @@ 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_Image");
|
||||
push(@{$definition}, {
|
||||
assetName=>$i18n->get('assetName'),
|
||||
tableName=>'ImageAsset',
|
||||
className=>'WebGUI::Asset::File::Image',
|
||||
icon=>'image.gif',
|
||||
properties=>{
|
||||
thumbnailSize=>{
|
||||
fieldType=>'integer',
|
||||
defaultValue=>$session->setting->get("thumbnailSize")
|
||||
},
|
||||
parameters=>{
|
||||
fieldType=>'textarea',
|
||||
defaultValue=>'style="border-style:none;"'
|
||||
}
|
||||
}
|
||||
});
|
||||
return $class->SUPER::definition($session,$definition);
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new($session,"Asset_Image");
|
||||
push @{$definition}, {
|
||||
assetName => $i18n->get('assetName'),
|
||||
tableName => 'ImageAsset',
|
||||
className => 'WebGUI::Asset::File::Image',
|
||||
icon => 'image.gif',
|
||||
properties => {
|
||||
thumbnailSize => {
|
||||
fieldType => 'integer',
|
||||
defaultValue => $session->setting->get("thumbnailSize"),
|
||||
},
|
||||
parameters => {
|
||||
fieldType => 'textarea',
|
||||
defaultValue => 'style="border-style:none;"',
|
||||
},
|
||||
},
|
||||
};
|
||||
return $class->SUPER::definition($session,$definition);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -184,37 +180,16 @@ sub getEditForm {
|
|||
return $tabform;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getStorageClass
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getStorageFromPost
|
||||
|
||||
Sub class this method from WebGUI::Asset::File so the storage object is the correct type.
|
||||
Returns the class name of the WebGUI::Storage we should use for this asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub getStorageFromPost {
|
||||
my $self = shift;
|
||||
my $storageId = shift;
|
||||
my $fileStorageId = WebGUI::Form::Image->new($self->session, {name => 'newFile', value=>$storageId })->getValueFromPost;
|
||||
return WebGUI::Storage::Image->get($self->session, $fileStorageId);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub getStorageLocation {
|
||||
my $self = shift;
|
||||
unless (exists $self->{_storageLocation}) {
|
||||
if ($self->get("storageId") eq "") {
|
||||
$self->{_storageLocation} = WebGUI::Storage::Image->create($self->session);
|
||||
$self->update({storageId=>$self->{_storageLocation}->getId});
|
||||
} else {
|
||||
$self->{_storageLocation} = WebGUI::Storage::Image->get($self->session,$self->get("storageId"));
|
||||
}
|
||||
}
|
||||
return $self->{_storageLocation};
|
||||
sub getStorageClass {
|
||||
return 'WebGUI::Storage::Image';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -253,31 +228,6 @@ sub prepareView {
|
|||
$self->{_viewTemplate} = $template;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
$self->applyConstraints;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub setStorageLocation {
|
||||
my $self = shift;
|
||||
my $storage = shift;
|
||||
if (defined $storage) {
|
||||
$self->{_storageLocation} = $storage;
|
||||
}
|
||||
elsif ($self->get("storageId") eq "") {
|
||||
$self->{_storageLocation} = WebGUI::Storage::Image->create($self->session);
|
||||
$self->update({storageId=>$self->{_storageLocation}->getId});
|
||||
}
|
||||
else {
|
||||
$self->{_storageLocation} = WebGUI::Storage::Image->get($self->session,$self->get("storageId"));
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub view {
|
||||
my $self = shift;
|
||||
|
|
@ -297,6 +247,20 @@ sub view {
|
|||
return $out;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 setFile ( filename )
|
||||
|
||||
Extend the superclass setFile to automatically generate thumbnails.
|
||||
|
||||
=cut
|
||||
|
||||
sub setFile {
|
||||
my $self = shift;
|
||||
$self->SUPER::setFile(@_);
|
||||
$self->generateThumbnail;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
|
|
|
|||
1020
lib/WebGUI/Asset/File/Image/Photo.pm
Normal file
1020
lib/WebGUI/Asset/File/Image/Photo.pm
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -11,6 +11,7 @@ package WebGUI::Asset::Shortcut;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use Carp;
|
||||
use Tie::IxHash;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::International;
|
||||
|
|
@ -605,6 +606,26 @@ sub getPrefFieldsToImport {
|
|||
return split("\n",$self->getValue("prefFieldsToImport"));
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getTemplateVars
|
||||
|
||||
Gets the template vars for this shortcut.
|
||||
|
||||
=cut
|
||||
|
||||
sub getTemplateVars {
|
||||
my $self = shift;
|
||||
|
||||
my $shortcut = $self->getShortcut;
|
||||
if ( $shortcut->can('getTemplateVars') ) {
|
||||
return $shortcut->getTemplateVars;
|
||||
}
|
||||
else {
|
||||
return $shortcut->get;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub isDashlet {
|
||||
my $self = shift;
|
||||
|
|
@ -648,6 +669,34 @@ sub processPropertiesFromFormPost {
|
|||
$self->uncacheOverrides;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 setOverride ( overrides )
|
||||
|
||||
Set this shortcut's overrides. C<overrides> is a hash reference of overrides
|
||||
to set.
|
||||
|
||||
=cut
|
||||
|
||||
sub setOverride {
|
||||
my $self = shift;
|
||||
my $override = shift;
|
||||
|
||||
croak "Shortcut->setOverride - first argument must be hash reference"
|
||||
unless $override && ref $override eq "HASH";
|
||||
|
||||
for my $key ( %$override ) {
|
||||
$self->session->db->write(
|
||||
"DELETE FROM Shortcut_overrides WHERE assetId=? AND fieldName=?",
|
||||
[$self->getId, $key],
|
||||
);
|
||||
$self->session->db->write(
|
||||
"INSERT INTO Shortcut_overrides VALUES (?,?,?)",
|
||||
[$self->getId, $key, $override->{$key}],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub purge {
|
||||
my $self = shift;
|
||||
|
|
@ -880,23 +929,23 @@ sub www_editOverride {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_saveOverride {
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
my $fieldName = $self->session->form->process("overrideFieldName");
|
||||
my %overrides = $self->getOverrides;
|
||||
my $output = '';
|
||||
my %props;
|
||||
foreach my $def (@{$self->getShortcutOriginal->definition($self->session)}) {
|
||||
%props = (%props,%{$def->{properties}});
|
||||
}
|
||||
my $fieldType = $props{$fieldName}{fieldType};
|
||||
my $value = $self->session->form->process($fieldName,$fieldType);
|
||||
$value = $self->session->form->process("newOverrideValueText") || $value;
|
||||
$self->session->db->write("delete from Shortcut_overrides where assetId=".$self->session->db->quote($self->getId)." and fieldName=".$self->session->db->quote($fieldName));
|
||||
$self->session->db->write("insert into Shortcut_overrides values (".$self->session->db->quote($self->getId).",".$self->session->db->quote($fieldName).",".$self->session->db->quote($value).")");
|
||||
$self->uncacheOverrides;
|
||||
$self->getShortcutOriginal->purgeCache();
|
||||
return $self->www_manageOverrides;
|
||||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
my $fieldName = $self->session->form->process("overrideFieldName");
|
||||
my %overrides = $self->getOverrides;
|
||||
my $output = '';
|
||||
my %props;
|
||||
foreach my $def (@{$self->getShortcutOriginal->definition($self->session)}) {
|
||||
%props = (%props,%{$def->{properties}});
|
||||
}
|
||||
my $fieldType = $props{$fieldName}{fieldType};
|
||||
my $value = $self->session->form->process($fieldName,$fieldType);
|
||||
$value = $self->session->form->process("newOverrideValueText") || $value;
|
||||
$self->session->db->write("delete from Shortcut_overrides where assetId=".$self->session->db->quote($self->getId)." and fieldName=".$self->session->db->quote($fieldName));
|
||||
$self->session->db->write("insert into Shortcut_overrides values (".$self->session->db->quote($self->getId).",".$self->session->db->quote($fieldName).",".$self->session->db->quote($value).")");
|
||||
$self->uncacheOverrides;
|
||||
$self->getShortcutOriginal->purgeCache();
|
||||
return $self->www_manageOverrides;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -928,5 +977,43 @@ sub www_view {
|
|||
return $output;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head1 STATIC METHODS
|
||||
|
||||
These methods are called using CLASS->method
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getShortcutsForAssetId ( session, assetId [, properties] )
|
||||
|
||||
Get an arrayref of assetIds of all the shortcuts for the passed-in assetId.
|
||||
|
||||
"properties" is a hash reference of properties to give to getLineage.
|
||||
Probably the only useful key will be "returnObjects".
|
||||
|
||||
=cut
|
||||
|
||||
sub getShortcutsForAssetId {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $assetId = shift;
|
||||
my $properties = shift || {};
|
||||
|
||||
croak "First argument to getShortcutsForAssetId must be WebGUI::Session"
|
||||
unless $session && $session->isa("WebGUI::Session");
|
||||
croak "Second argument to getShortcutsForAssetId must be assetId"
|
||||
unless $assetId;
|
||||
croak "Third argument to getShortcutsForAssetId must be hash reference"
|
||||
if $properties && !ref $properties eq "HASH";
|
||||
|
||||
my $db = $session->db;
|
||||
|
||||
$properties->{ joinClass } = 'WebGUI::Asset::Shortcut';
|
||||
$properties->{ whereClause } = 'Shortcut.shortcutToAssetId = ' . $db->quote($assetId);
|
||||
|
||||
return WebGUI::Asset->getRoot($session)->getLineage(['descendants'], $properties);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
1024
lib/WebGUI/Asset/Wobject/Gallery.pm
Normal file
1024
lib/WebGUI/Asset/Wobject/Gallery.pm
Normal file
File diff suppressed because it is too large
Load diff
882
lib/WebGUI/Asset/Wobject/GalleryAlbum.pm
Normal file
882
lib/WebGUI/Asset/Wobject/GalleryAlbum.pm
Normal file
|
|
@ -0,0 +1,882 @@
|
|||
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 base 'WebGUI::Asset::Wobject';
|
||||
use Carp qw( croak );
|
||||
use File::Find;
|
||||
use File::Spec;
|
||||
use File::Temp qw{ tempdir };
|
||||
use Tie::IxHash;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Utility;
|
||||
|
||||
use Archive::Any;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
=head1 DIAGNOSTICS
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( )
|
||||
|
||||
Define wobject properties for new GalleryAlbum wobjects.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = __PACKAGE__->i18n($session);
|
||||
|
||||
tie my %properties, 'Tie::IxHash', (
|
||||
allowComments => {
|
||||
fieldType => "yesNo",
|
||||
defaultValue => 1,
|
||||
},
|
||||
othersCanAdd => {
|
||||
fieldType => "yesNo",
|
||||
defaultValue => 0,
|
||||
},
|
||||
assetIdThumbnail => {
|
||||
fieldType => "asset",
|
||||
defaultValue => undef,
|
||||
},
|
||||
);
|
||||
|
||||
push @{$definition}, {
|
||||
assetName => $i18n->get('assetName'),
|
||||
autoGenerateForms => 0,
|
||||
icon => 'newWobject.gif',
|
||||
tableName => 'GalleryAlbum',
|
||||
className => __PACKAGE__,
|
||||
properties => \%properties,
|
||||
};
|
||||
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 addArchive ( filename, properties )
|
||||
|
||||
Add an archive of Files to this Album. C<filename> is the full path of the
|
||||
archive. C<properties> is a hash reference of properties to assign to the
|
||||
photos in the archive.
|
||||
|
||||
Will croak if cannot read the archive or if the archive will extract itself to
|
||||
a directory outside of the storage location.
|
||||
|
||||
Will only handle file types handled by the parent Gallery.
|
||||
|
||||
=cut
|
||||
|
||||
sub addArchive {
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $properties = shift;
|
||||
my $gallery = $self->getParent;
|
||||
|
||||
my $archive = Archive::Any->new( $filename );
|
||||
|
||||
croak "Archive will extract to directory outside of storage location!"
|
||||
if $archive->is_naughty;
|
||||
|
||||
my $tempdirName = tempdir( "WebGUI-Gallery-XXXXXXXX", TMPDIR => 1, CLEANUP => 1);
|
||||
$archive->extract( $tempdirName );
|
||||
|
||||
# Get all the files in the archive
|
||||
my @files;
|
||||
my $wanted = sub { push @files, $File::Find::name };
|
||||
find( {
|
||||
wanted => $wanted,
|
||||
}, $tempdirName );
|
||||
|
||||
for my $filePath (@files) {
|
||||
my ($volume, $directory, $filename) = File::Spec->splitpath( $filePath );
|
||||
$self->session->errorHandler->info( "trying $filename" );
|
||||
next if $filename =~ m{^[.]};
|
||||
my $class = $gallery->getAssetClassForFile( $filePath );
|
||||
next unless $class; # class is undef for those files the Gallery can't handle
|
||||
|
||||
$self->session->errorHandler->info( "Adding $filename to album!" );
|
||||
$properties->{ className } = $class;
|
||||
$properties->{ menuTitle } = $filename;
|
||||
$properties->{ title } = $filename;
|
||||
$properties->{ url } = $self->getUrl . "/" . $filename;
|
||||
|
||||
my $asset = $self->addChild( $properties, undef, undef, { skipAutoCommitWorkflows => 1 } );
|
||||
$asset->setFile( $filePath );
|
||||
}
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking( $self->session );
|
||||
$versionTag->set({
|
||||
"workflowId" => $self->getParent->get("workflowIdCommit"),
|
||||
});
|
||||
$versionTag->requestCommit;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 appendTemplateVarsFileLoop ( vars, assetIds )
|
||||
|
||||
Append template vars for a file loop for the specified assetIds. C<vars> is
|
||||
a hash reference to add the file loop to. C<assetIds> is an array reference
|
||||
of assetIds for the loop.
|
||||
|
||||
Returns the hash reference for convenience.
|
||||
|
||||
=cut
|
||||
|
||||
sub appendTemplateVarsFileLoop {
|
||||
my $self = shift;
|
||||
my $var = shift;
|
||||
my $assetIds = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
for my $assetId (@$assetIds) {
|
||||
push @{$var->{file_loop}},
|
||||
WebGUI::Asset->newByDynamicClass($session, $assetId)->getTemplateVars;
|
||||
}
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 canAddFile ( [userId] )
|
||||
|
||||
Returns true if the user can add a file to this album. C<userId> is a WebGUI
|
||||
user ID. If no userId is passed, will check the current user.
|
||||
|
||||
Users can add files to this album if they are the owner, or if
|
||||
C<othersCanAdd> is true and the Gallery allows them to add files.
|
||||
|
||||
=cut
|
||||
|
||||
sub canAddFile {
|
||||
my $self = shift;
|
||||
my $userId = shift || $self->session->user->userId;
|
||||
my $gallery = $self->getParent;
|
||||
|
||||
return 1 if $userId eq $self->get("ownerUserId");
|
||||
return 1 if $self->get("othersCanAdd") && $gallery->canAddFile( $userId );
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 canComment ( [userId] )
|
||||
|
||||
Returns true if the user is allowed to comment on files in this Album.
|
||||
C<userId> is a WebGUI user ID. If no userId is passed, will check the current
|
||||
user.
|
||||
|
||||
Users can comment on files if C<allowComments> is true and the parent Gallery
|
||||
allows comments.
|
||||
|
||||
=cut
|
||||
|
||||
sub canComment {
|
||||
my $self = shift;
|
||||
my $userId = shift || $self->session->user->userId;
|
||||
my $gallery = $self->getParent;
|
||||
|
||||
return 0 if !$self->get("allowComments");
|
||||
|
||||
return $gallery->canComment( $userId );
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=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.
|
||||
|
||||
Also handles adding of child assets by calling C<canAddFile>.
|
||||
|
||||
=cut
|
||||
|
||||
sub canEdit {
|
||||
my $self = shift;
|
||||
my $userId = shift || $self->session->user->userId;
|
||||
my $gallery = $self->getParent;
|
||||
my $form = $self->session->form;
|
||||
|
||||
# Handle adding a photo
|
||||
if ( $form->get("func") eq "add" ) {
|
||||
return $self->canAddFile;
|
||||
}
|
||||
elsif ( $form->get("func") eq "editSave" && $form->get("className") eq __PACKAGE__ ) {
|
||||
return $self->canAddFile;
|
||||
}
|
||||
else {
|
||||
return 1 if $userId eq $self->get("ownerUserId");
|
||||
|
||||
return $gallery->canEdit($userId);
|
||||
}
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 canView ( [userId] )
|
||||
|
||||
Returns true if the user can view this asset. C<userId> is a WebGUI user ID.
|
||||
If no userId is given, checks the current user.
|
||||
|
||||
Users can view this album if they can view the containing Gallery.
|
||||
|
||||
NOTE: It may be possible to view a GalleryAlbum that has no public files. In
|
||||
such cases, the GalleryAlbum will appear empty to unprivileged users. This is
|
||||
not a bug.
|
||||
|
||||
=cut
|
||||
|
||||
sub canView {
|
||||
my $self = shift;
|
||||
my $userId = shift || $self->session->user->userId;
|
||||
return $self->getParent->canView($userId);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 i18n ( session )
|
||||
|
||||
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.
|
||||
|
||||
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_GalleryAlbum");
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getAutoCommitWorkflowId ( )
|
||||
|
||||
Returns the workflowId of the Gallery's approval workflow.
|
||||
|
||||
=cut
|
||||
|
||||
sub getAutoCommitWorkflowId {
|
||||
my $self = shift;
|
||||
return $self->getParent->get("workflowIdCommit");
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getFileIds ( )
|
||||
|
||||
Gets an array reference of asset IDs for all the files in this album.
|
||||
|
||||
=cut
|
||||
|
||||
sub getFileIds {
|
||||
my $self = shift;
|
||||
my $gallery = $self->getParent;
|
||||
|
||||
return $self->getLineage( ['descendants'], { } );
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getFilePaginator ( paginatorUrl )
|
||||
|
||||
Gets a WebGUI::Paginator for the files in this album. C<paginatorUrl> is the
|
||||
url to the current page that will be given to the paginator.
|
||||
|
||||
=cut
|
||||
|
||||
sub getFilePaginator {
|
||||
my $self = shift;
|
||||
my $url = shift || $self->getUrl;
|
||||
|
||||
my $p = WebGUI::Paginator->new( $self->session, $url );
|
||||
$p->setDataByArrayRef( $self->getFileIds );
|
||||
|
||||
return $p;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getTemplateVars ( )
|
||||
|
||||
Gets template vars common to all views.
|
||||
|
||||
=cut
|
||||
|
||||
sub getTemplateVars {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $gallery = $self->getParent;
|
||||
my $var = $self->get;
|
||||
my $owner = WebGUI::User->new( $session, $self->get("ownerUserId") );
|
||||
|
||||
# Permissions
|
||||
$var->{ canAddFile } = $self->canAddFile;
|
||||
$var->{ canEdit } = $self->canEdit;
|
||||
|
||||
# Add some common template vars from Gallery
|
||||
$gallery->appendTemplateVarsSearchForm( $var );
|
||||
$var->{ url_listAlbums } = $gallery->getUrl('func=listAlbums');
|
||||
$var->{ url_listAlbumsRss } = $gallery->getUrl('func=listAlbumsRss');
|
||||
$var->{ url_listFilesForCurrentUser } = $gallery->getUrl('func=listFilesForUser');
|
||||
$var->{ url_search } = $gallery->getUrl('func=search');
|
||||
|
||||
# Friendly URLs
|
||||
$var->{ url } = $self->getUrl;
|
||||
$var->{ url_addArchive } = $self->getUrl('func=addArchive');
|
||||
$var->{ url_addPhoto } = $self->getUrl("func=add;class=WebGUI::Asset::File::Image::Photo");
|
||||
$var->{ url_addNoClass } = $self->getUrl("func=add");
|
||||
$var->{ url_delete } = $self->getUrl("func=delete");
|
||||
$var->{ url_edit } = $self->getUrl("func=edit");
|
||||
$var->{ url_listFilesForOwner } = $gallery->getUrl("func=listFilesForUser;userId=".$var->{ownerUserId});
|
||||
$var->{ url_viewRss } = $self->getUrl("func=viewRss");
|
||||
$var->{ url_slideshow } = $self->getUrl("func=slideshow");
|
||||
$var->{ url_thumbnails } = $self->getUrl("func=thumbnails");
|
||||
|
||||
$var->{ fileCount } = $self->getChildCount;
|
||||
$var->{ ownerUsername } = $owner->username;
|
||||
$var->{ thumbnailUrl } = $self->getThumbnailUrl;
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getThumbnailUrl ( )
|
||||
|
||||
Gets the URL for the thumbnail for this asset. If no asset is set, gets the
|
||||
first child.
|
||||
|
||||
NOTE: If the asset does not have a getThumbnailUrl method, this method will
|
||||
return undef.
|
||||
|
||||
=cut
|
||||
|
||||
sub getThumbnailUrl {
|
||||
my $self = shift;
|
||||
my $asset = undef;
|
||||
|
||||
if ( $self->get("assetIdThumbnail") ) {
|
||||
$asset = WebGUI::Asset->newByDynamicClass( $self->session, $self->get("assetIdThumbnail") );
|
||||
}
|
||||
elsif ( $self->getFirstChild ) {
|
||||
$asset = $self->getFirstChild;
|
||||
}
|
||||
else {
|
||||
return undef;
|
||||
}
|
||||
|
||||
if ( $asset->can("getThumbnailUrl") ) {
|
||||
return $asset->getThumbnailUrl;
|
||||
}
|
||||
else {
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 othersCanAdd ( )
|
||||
|
||||
Returns true if people other than the owner can add files to this album.
|
||||
|
||||
=cut
|
||||
|
||||
sub othersCanAdd {
|
||||
my $self = shift;
|
||||
return $self->get("othersCanAdd");
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 prepareView ( )
|
||||
|
||||
See WebGUI::Asset::prepareView() for details.
|
||||
|
||||
=cut
|
||||
|
||||
sub prepareView {
|
||||
my $self = shift;
|
||||
$self->SUPER::prepareView();
|
||||
|
||||
my $templateId = $self->getParent->get("templateIdViewAlbum");
|
||||
|
||||
my $template
|
||||
= WebGUI::Asset::Template->new($self->session, $templateId);
|
||||
$template->prepare;
|
||||
|
||||
$self->{_viewTemplate} = $template;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 processStyle ( )
|
||||
|
||||
Gets the parent Gallery's style template
|
||||
|
||||
=cut
|
||||
|
||||
sub processStyle {
|
||||
my $self = shift;
|
||||
return $self->getParent->processStyle(@_);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 processPropertiesFromFormPost ( )
|
||||
|
||||
Process the form to save the asset. Request approval from the Gallery's
|
||||
approval workflow.
|
||||
|
||||
=cut
|
||||
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
my $errors = $self->SUPER::processPropertiesFromFormPost || [];
|
||||
|
||||
# Return if error
|
||||
return $errors if @$errors;
|
||||
|
||||
# Passes all checks
|
||||
$self->requestAutoCommit;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=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->getTemplateVars;
|
||||
|
||||
my $p = $self->getFilePaginator;
|
||||
$p->appendTemplateVars( $var );
|
||||
$self->appendTemplateVarsFileLoop( $var, $p->getPageData );
|
||||
|
||||
return $self->processTemplate($var, undef, $self->{_viewTemplate});
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 view_slideshow ( )
|
||||
|
||||
method called by the www_slideshow method. Returns a processed template to be
|
||||
displayed within the page style.
|
||||
|
||||
Show a slideshow of the GalleryAlbum's files.
|
||||
|
||||
=cut
|
||||
|
||||
sub view_slideshow {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $var = $self->getTemplateVars;
|
||||
|
||||
$self->appendTemplateVarsFileLoop( $var, $self->getFileIds );
|
||||
|
||||
return $self->processTemplate($var, $self->getParent->get("templateIdViewSlideshow"));
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 view_thumbnails ( )
|
||||
|
||||
method called by the www_thumbnails method. Returns a processed template to be
|
||||
displayed within the page style.
|
||||
|
||||
Shows all the thumbnails for this GalleryAlbum. In addition, shows details
|
||||
about a specific thumbnail.
|
||||
|
||||
=cut
|
||||
|
||||
sub view_thumbnails {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $var = $self->getTemplateVars;
|
||||
|
||||
my $fileId = $session->form->get("fileId");
|
||||
|
||||
$self->appendTemplateVarsFileLoop( $var, $self->getFileIds );
|
||||
|
||||
# Process the file loop to add an additional URL
|
||||
for my $file ( @{ $var->{file_loop} } ) {
|
||||
$file->{ url_albumViewThumbnails }
|
||||
= $self->getUrl('func=thumbnails;fileId=' . $file->{assetId});
|
||||
}
|
||||
|
||||
# Add direct vars for the requested file
|
||||
my $asset;
|
||||
if ($fileId) {
|
||||
$asset = WebGUI::Asset->newByDynamicClass( $session, $fileId );
|
||||
}
|
||||
# If no fileId given or fileId does not exist
|
||||
if (!$asset) {
|
||||
$asset = $self->getFirstChild;
|
||||
}
|
||||
my %assetVars = %{ $asset->getTemplateVars };
|
||||
for my $key ( keys %assetVars ) {
|
||||
$var->{ 'file_' . $key } = $assetVars{ $key };
|
||||
}
|
||||
|
||||
return $self->processTemplate($var, $self->getParent->get("templateIdViewThumbnails"));
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_addArchive ( )
|
||||
|
||||
Show the form to add an archive of files to this gallery.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_addArchive {
|
||||
my $self = shift;
|
||||
|
||||
return $self->session->privilege->insufficient unless $self->canAddFile;
|
||||
|
||||
my $session = $self->session;
|
||||
my $form = $self->session->form;
|
||||
my $var = $self->getTemplateVars;
|
||||
|
||||
$var->{ form_start }
|
||||
= WebGUI::Form::formHeader( $session, {
|
||||
action => $self->getUrl('func=addArchiveSave'),
|
||||
});
|
||||
$var->{ form_end }
|
||||
= WebGUI::Form::formFooter( $session );
|
||||
|
||||
$var->{ form_submit }
|
||||
= WebGUI::Form::submit( $session, {
|
||||
name => "submit",
|
||||
value => "Submit",
|
||||
});
|
||||
|
||||
$var->{ form_archive }
|
||||
= WebGUI::Form::File( $session, {
|
||||
name => "archive",
|
||||
maxAttachments => 1,
|
||||
value => ( $form->get("archive") ),
|
||||
});
|
||||
|
||||
$var->{ form_keywords }
|
||||
= WebGUI::Form::text( $session, {
|
||||
name => "keywords",
|
||||
value => ( $form->get("keywords") ),
|
||||
});
|
||||
|
||||
$var->{ form_friendsOnly }
|
||||
= WebGUI::Form::yesNo( $session, {
|
||||
name => "friendsOnly",
|
||||
value => ( $form->get("friendsOnly") ),
|
||||
});
|
||||
|
||||
return $self->processStyle(
|
||||
$self->processTemplate($var, $self->getParent->get("templateIdAddArchive"))
|
||||
);
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_addArchiveSave ( )
|
||||
|
||||
Process the form for adding an archive.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_addArchiveSave {
|
||||
my $self = shift;
|
||||
|
||||
return $self->session->privilege->insufficient unless $self->canAddFile;
|
||||
|
||||
my $session = $self->session;
|
||||
my $form = $self->session->form;
|
||||
my $i18n = __PACKAGE__->i18n( $session );
|
||||
my $properties = {
|
||||
keywords => $form->get("keywords"),
|
||||
friendsOnly => $form->get("friendsOnly"),
|
||||
};
|
||||
|
||||
my $storageId = $form->get("archive", "File");
|
||||
my $storage = WebGUI::Storage->get( $session, $storageId );
|
||||
my $filename = $storage->getPath( $storage->getFiles->[0] );
|
||||
|
||||
$self->addArchive( $filename, $properties );
|
||||
|
||||
$storage->delete;
|
||||
|
||||
return $self->processStyle(
|
||||
sprintf $i18n->get('addArchive message'), $self->getUrl,
|
||||
);
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_delete ( )
|
||||
|
||||
Show the form to confirm deleting this album and all files inside of it.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_delete {
|
||||
my $self = shift;
|
||||
|
||||
return $self->session->privilege->insufficient unless $self->canEdit;
|
||||
|
||||
my $var = $self->getTemplateVars;
|
||||
$var->{ url_yes } = $self->getUrl("func=deleteConfirm");
|
||||
|
||||
return $self->processStyle(
|
||||
$self->processTemplate( $var, $self->getParent->get("templateIdDeleteAlbum") )
|
||||
);
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteConfirm ( )
|
||||
|
||||
Confirm deleting this album and all files inside of it.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_deleteConfirm {
|
||||
my $self = shift;
|
||||
|
||||
return $self->session->privilege->insufficient unless $self->canEdit;
|
||||
|
||||
my $gallery = $self->getParent;
|
||||
|
||||
$self->purge;
|
||||
|
||||
return $gallery->www_view;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_edit ( )
|
||||
|
||||
Show the form to add / edit a GalleryAlbum asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $form = $self->session->form;
|
||||
my $var = $self->getTemplateVars;
|
||||
my $i18n = __PACKAGE__->i18n($session);
|
||||
|
||||
# Generate the form
|
||||
if ($form->get("func") eq "add") {
|
||||
$var->{ form_start }
|
||||
= WebGUI::Form::formHeader( $session, {
|
||||
action => $self->getParent->getUrl('func=editSave;assetId=new;class='.__PACKAGE__),
|
||||
});
|
||||
}
|
||||
else {
|
||||
$var->{ form_start }
|
||||
= WebGUI::Form::formHeader( $session, {
|
||||
action => $self->getUrl('func=editSave'),
|
||||
});
|
||||
}
|
||||
$var->{ form_start }
|
||||
.= WebGUI::Form::hidden( $session, {
|
||||
name => "proceed",
|
||||
value => "showConfirmation",
|
||||
});
|
||||
|
||||
$var->{ form_end }
|
||||
= WebGUI::Form::formFooter( $session );
|
||||
|
||||
$var->{ form_cancel }
|
||||
= WebGUI::Form::button( $session, {
|
||||
name => "cancel",
|
||||
value => $i18n->get("cancel"),
|
||||
extras => 'onclick="history.go(-1)"',
|
||||
});
|
||||
|
||||
$var->{ form_submit }
|
||||
= WebGUI::Form::submit( $session, {
|
||||
name => "save",
|
||||
value => $i18n->get("save"),
|
||||
});
|
||||
|
||||
$var->{ form_title }
|
||||
= WebGUI::Form::text( $session, {
|
||||
name => "title",
|
||||
value => $form->get("title") || $self->get("title"),
|
||||
});
|
||||
|
||||
$var->{ form_description }
|
||||
= WebGUI::Form::HTMLArea( $session, {
|
||||
name => "description",
|
||||
value => $form->get("description") || $self->get("description"),
|
||||
});
|
||||
|
||||
# Generate the file loop
|
||||
my $thumbnailUrl = $self->getThumbnailUrl;
|
||||
$self->appendTemplateVarsFileLoop( $var, $self->getFileIds );
|
||||
for my $file ( @{ $var->{file_loop} } ) {
|
||||
if ( $thumbnailUrl eq $file->{thumbnailUrl} ) {
|
||||
$file->{ isAlbumThumbnail } = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return $self->processStyle(
|
||||
$self->processTemplate( $var, $self->getParent->get("templateIdEditAlbum") )
|
||||
);
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_editSave ( )
|
||||
|
||||
Save the asset edit form. Overridden to give a nice message when a photo or
|
||||
album is added
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editSave {
|
||||
my $self = shift;
|
||||
my $form = $self->session->form;
|
||||
my $i18n = __PACKAGE__->i18n($self->session);
|
||||
$self->SUPER::www_editSave;
|
||||
|
||||
if ( $form->get("assetId") eq "new" ) {
|
||||
return sprintf $i18n->get("addFile message"), $self->getUrl,
|
||||
}
|
||||
else {
|
||||
return sprintf $i18n->get("save message"), $self->getUrl,
|
||||
}
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_showConfirmation ( )
|
||||
|
||||
Shows the confirmation message after adding / editing a gallery album.
|
||||
Provides links to view the album.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_showConfirmation {
|
||||
my $self = shift;
|
||||
my $i18n = __PACKAGE__->i18n( $self->session );
|
||||
|
||||
my $output = sprintf $i18n->get('save message'), $self->getUrl;
|
||||
|
||||
return $self->processStyle(
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_slideshow ( )
|
||||
|
||||
Show a slideshow-type view of this album. The slideshow itself is powered by
|
||||
a javascript application in the template.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_slideshow {
|
||||
my $self = shift;
|
||||
|
||||
return $self->session->privilege->insufficient unless $self->canView;
|
||||
|
||||
return $self->processStyle( $self->view_slideshow );
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_thumbnails ( )
|
||||
|
||||
Show the thumbnails for the album.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_thumbnails {
|
||||
my $self = shift;
|
||||
|
||||
return $self->session->privilege->insufficient unless $self->canView;
|
||||
|
||||
return $self->processStyle( $self->view_thumbnails );
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_viewRss ( )
|
||||
|
||||
Display an RSS feed for this album.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewRss {
|
||||
my $self = shift;
|
||||
|
||||
return $self->session->privilege->insufficient unless $self->canView;
|
||||
|
||||
my $var = $self->getTemplateVars;
|
||||
$self->appendTemplateVarsFileLoop( $var, $self->getFileIds );
|
||||
|
||||
# Fix URLs to be full URLs
|
||||
for my $key ( qw( url url_viewRss ) ) {
|
||||
$var->{ $key } = $self->session->url->getSiteURL . $var->{ $key };
|
||||
}
|
||||
|
||||
# Process the file loop to add additional params
|
||||
for my $file ( @{ $var->{file_loop} } ) {
|
||||
# Fix URLs to be full URLs
|
||||
for my $key ( qw( url ) ) {
|
||||
$file->{ $key } = $self->session->url->getSiteURL . $file->{$key};
|
||||
}
|
||||
|
||||
$file->{ rssDate }
|
||||
= $self->session->datetime->epochToMail( $file->{creationDate} );
|
||||
}
|
||||
|
||||
$self->session->http->setMimeType('text/xml');
|
||||
return $self->processTemplate( $var, $self->getParent->get('templateIdViewAlbumRss') );
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -15,6 +15,7 @@ package WebGUI::Asset;
|
|||
=cut
|
||||
|
||||
use strict;
|
||||
use Carp qw( croak );
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -82,9 +83,9 @@ sub addChild {
|
|||
$self->session->db->commit;
|
||||
$properties->{assetId} = $id;
|
||||
$properties->{parentId} = $self->getId;
|
||||
my $temp = WebGUI::Asset->newByPropertyHashRef($self->session,$properties);
|
||||
my $temp = WebGUI::Asset->newByPropertyHashRef($self->session,$properties) || croak "Couldn't create a new $properties->{className} asset!";
|
||||
$temp->{_parent} = $self;
|
||||
my $newAsset = $temp->addRevision($properties,$now, {skipAutoCommitWorkflows=>$options->{skipAutoCommitWorkflows}});
|
||||
my $newAsset = $temp->addRevision($properties, $now, $options);
|
||||
$self->updateHistory("added child ".$id);
|
||||
$self->session->http->setStatus(201,"Asset Creation Successful");
|
||||
return $newAsset;
|
||||
|
|
|
|||
|
|
@ -125,12 +125,16 @@ A hash reference containing the exported data.
|
|||
=cut
|
||||
|
||||
sub importAssetData {
|
||||
my $self = shift;
|
||||
my $data = shift;
|
||||
my $error = $self->session->errorHandler;
|
||||
my $id = $data->{properties}{assetId};
|
||||
my $class = $data->{properties}{className};
|
||||
my $version = $data->{properties}{revisionDate};
|
||||
my $self = shift;
|
||||
my $data = shift;
|
||||
my $error = $self->session->errorHandler;
|
||||
my $id = $data->{properties}{assetId};
|
||||
my $class = $data->{properties}{className};
|
||||
my $version = $data->{properties}{revisionDate};
|
||||
|
||||
# Load the class
|
||||
WebGUI::Asset->loadModule( $self->session, $class );
|
||||
|
||||
my $asset;
|
||||
my $assetExists = WebGUI::Asset->assetExists($self->session, $id, $class, $version);
|
||||
if ($assetExists) { # update an existing revision
|
||||
|
|
@ -194,40 +198,40 @@ A reference to a WebGUI::Storage object that contains a webgui package file.
|
|||
=cut
|
||||
|
||||
sub importPackage {
|
||||
my $self = shift;
|
||||
my $storage = shift;
|
||||
my $decompressed = $storage->untar($storage->getFiles->[0]);
|
||||
my %assets = ();
|
||||
my $error = $self->session->errorHandler;
|
||||
$error->info("Importing package.");
|
||||
foreach my $file (sort(@{$decompressed->getFiles})) {
|
||||
next unless ($decompressed->getFileExtension($file) eq "json");
|
||||
$error->info("Found data file $file");
|
||||
my $data = eval{
|
||||
my $self = shift;
|
||||
my $storage = shift;
|
||||
my $decompressed = $storage->untar($storage->getFiles->[0]);
|
||||
my %assets = ();
|
||||
my $error = $self->session->errorHandler;
|
||||
$error->info("Importing package.");
|
||||
foreach my $file (sort(@{$decompressed->getFiles})) {
|
||||
next unless ($decompressed->getFileExtension($file) eq "json");
|
||||
$error->info("Found data file $file");
|
||||
my $data = eval{
|
||||
local $JSON::UnMapping = 1;
|
||||
JSON::jsonToObj($decompressed->getFileContentsAsScalar($file))
|
||||
};
|
||||
if ($@ || $data->{properties}{assetId} eq "" || $data->{properties}{className} eq "" || $data->{properties}{revisionDate} eq "") {
|
||||
$error->error("package corruption: ".$@) if ($@);
|
||||
return "corrupt";
|
||||
}
|
||||
$error->info("Data file $file is valid and represents asset ".$data->{properties}{assetId});
|
||||
foreach my $storageId (@{$data->{storage}}) {
|
||||
my $assetStorage = WebGUI::Storage->get($self->session, $storageId);
|
||||
$decompressed->untar($storageId.".storage", $assetStorage);
|
||||
}
|
||||
my $asset = $assets{$data->{properties}{parentId}} || $self;
|
||||
my $newAsset = $asset->importAssetData($data);
|
||||
if ($@ || $data->{properties}{assetId} eq "" || $data->{properties}{className} eq "" || $data->{properties}{revisionDate} eq "") {
|
||||
$error->error("package corruption: ".$@) if ($@);
|
||||
return "corrupt";
|
||||
}
|
||||
$error->info("Data file $file is valid and represents asset ".$data->{properties}{assetId});
|
||||
foreach my $storageId (@{$data->{storage}}) {
|
||||
my $assetStorage = WebGUI::Storage->get($self->session, $storageId);
|
||||
$decompressed->untar($storageId.".storage", $assetStorage);
|
||||
}
|
||||
my $asset = $assets{$data->{properties}{parentId}} || $self;
|
||||
my $newAsset = $asset->importAssetData($data);
|
||||
$newAsset->importAssetCollateralData($data);
|
||||
$assets{$newAsset->getId} = $newAsset;
|
||||
}
|
||||
if ($self->session->setting->get("autoRequestCommit")) {
|
||||
$assets{$newAsset->getId} = $newAsset;
|
||||
}
|
||||
if ($self->session->setting->get("autoRequestCommit")) {
|
||||
if ($self->session->setting->get("skipCommitComments")) {
|
||||
WebGUI::VersionTag->getWorking($self->session)->requestCommit;
|
||||
} else {
|
||||
$self->session->http->setRedirect($self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId));
|
||||
$self->session->http->setRedirect($self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId));
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ package WebGUI::Asset;
|
|||
=cut
|
||||
|
||||
use strict;
|
||||
use WebGUI::Asset::Shortcut;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -146,6 +147,16 @@ sub purge {
|
|||
}
|
||||
}
|
||||
|
||||
# Delete shortcuts to this asset
|
||||
# Also publish any shortcuts to this asset that are in the trash
|
||||
my $shortcuts
|
||||
= WebGUI::Asset::Shortcut->getShortcutsForAssetId($self->session, $self->getId, {
|
||||
returnObjects => 1,
|
||||
});
|
||||
for my $shortcut ( @$shortcuts ) {
|
||||
$shortcut->purge;
|
||||
}
|
||||
|
||||
# gotta delete stuff we've exported
|
||||
unless ($options->{skipExported}) {
|
||||
$self->_invokeWorkflowOnExportedFiles($self->session->setting->get('purgeWorkflow'), 1);
|
||||
|
|
@ -190,29 +201,40 @@ sub purge {
|
|||
|
||||
=head2 trash ( )
|
||||
|
||||
Removes asset from lineage, places it in trash state. The "gap" in the lineage is changed in state to trash-limbo.
|
||||
Removes asset from lineage, places it in trash state. The "gap" in the
|
||||
lineage is changed in state to trash-limbo.
|
||||
|
||||
=cut
|
||||
|
||||
sub trash {
|
||||
my $self = shift;
|
||||
return if ($self->getId eq $self->session->setting->get("defaultPage") || $self->getId eq $self->session->setting->get("notFoundPage"));
|
||||
foreach my $asset ($self, @{$self->getLineage(['descendants'], {returnObjects => 1})}) {
|
||||
$asset->_invokeWorkflowOnExportedFiles($self->session->setting->get('trashWorkflow'), 1);
|
||||
}
|
||||
my $self = shift;
|
||||
return if ($self->getId eq $self->session->setting->get("defaultPage") || $self->getId eq $self->session->setting->get("notFoundPage"));
|
||||
foreach my $asset ($self, @{$self->getLineage(['descendants'], {returnObjects => 1})}) {
|
||||
$asset->_invokeWorkflowOnExportedFiles($self->session->setting->get('trashWorkflow'), 1);
|
||||
}
|
||||
|
||||
my $db = $self->session->db;
|
||||
$db->beginTransaction;
|
||||
my $sth = $db->read("select assetId from asset where lineage like ?",[$self->get("lineage").'%']);
|
||||
while (my ($id) = $sth->array) {
|
||||
$db->write("delete from assetIndex where assetId=?",[$id]);
|
||||
}
|
||||
$db->write("update asset set state='trash-limbo' where lineage like ?",[$self->get("lineage").'%']);
|
||||
$db->write("update asset set state='trash', stateChangedBy=?, stateChanged=? where assetId=?",[$self->session->user->userId, $self->session->datetime->time(), $self->getId]);
|
||||
$db->commit;
|
||||
$self->{_properties}{state} = "trash";
|
||||
$self->updateHistory("trashed");
|
||||
$self->purgeCache;
|
||||
# Trash any shortcuts to this asset
|
||||
my $shortcuts
|
||||
= WebGUI::Asset::Shortcut->getShortcutsForAssetId($self->session, $self->getId, { returnObjects => 1});
|
||||
for my $shortcut ( @$shortcuts ) {
|
||||
$shortcut->trash;
|
||||
}
|
||||
|
||||
# Raw database work is more efficient than $asset->update
|
||||
my $db = $self->session->db;
|
||||
$db->beginTransaction;
|
||||
my $sth = $db->read("select assetId from asset where lineage like ?",[$self->get("lineage").'%']);
|
||||
while (my ($id) = $sth->array) {
|
||||
$db->write("delete from assetIndex where assetId=?",[$id]);
|
||||
}
|
||||
$db->write("update asset set state='trash-limbo' where lineage like ?",[$self->get("lineage").'%']);
|
||||
$db->write("update asset set state='trash', stateChangedBy=?, stateChanged=? where assetId=?",[$self->session->user->userId, $self->session->datetime->time(), $self->getId]);
|
||||
$db->commit;
|
||||
|
||||
# Update ourselves since we didn't use update()
|
||||
$self->{_properties}{state} = "trash";
|
||||
$self->updateHistory("trashed");
|
||||
$self->purgeCache;
|
||||
}
|
||||
|
||||
require WebGUI::Workflow::Activity::DeleteExportedFiles;
|
||||
|
|
|
|||
|
|
@ -87,12 +87,12 @@ Posts) will know not to send them under certain conditions.
|
|||
sub addRevision {
|
||||
my $self = shift;
|
||||
my $properties = shift;
|
||||
my $now = shift || $self->session->datetime->time();
|
||||
my $options = shift;
|
||||
|
||||
my $now = shift || $self->session->datetime->time();
|
||||
my $options = shift;
|
||||
|
||||
my $autoCommitId = $self->getAutoCommitWorkflowId() unless ($options->{skipAutoCommitWorkflows});
|
||||
|
||||
my $workingTag
|
||||
|
||||
my $workingTag
|
||||
= ($autoCommitId)
|
||||
? WebGUI::VersionTag->create($self->session, {groupToUse=>'12', workflowId=>$autoCommitId})
|
||||
: WebGUI::VersionTag->getWorking($self->session)
|
||||
|
|
@ -112,8 +112,7 @@ sub addRevision {
|
|||
$self->session->user->userId,
|
||||
$workingTag->getId,
|
||||
$self->getId,
|
||||
]
|
||||
);
|
||||
]);
|
||||
|
||||
foreach my $definition (@{$self->definition($self->session)}) {
|
||||
unless ($definition->{tableName} eq "assetData") {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ package WebGUI::Form;
|
|||
=cut
|
||||
|
||||
use strict;
|
||||
use Carp qw( croak );
|
||||
use Scalar::Util qw( blessed );
|
||||
use Tie::IxHash;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Asset::RichEdit;
|
||||
|
|
@ -92,7 +94,7 @@ sub formFooter {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 formHeader ( session, hashRef )
|
||||
=head2 formHeader ( session, options )
|
||||
|
||||
Returns a form header.
|
||||
|
||||
|
|
@ -100,7 +102,7 @@ Returns a form header.
|
|||
|
||||
A reference to the current session.
|
||||
|
||||
=head3 hashRef
|
||||
=head3 options
|
||||
|
||||
A hash reference that contains one or more of the following parameters.
|
||||
|
||||
|
|
@ -108,6 +110,9 @@ A hash reference that contains one or more of the following parameters.
|
|||
|
||||
The form action. Defaults to the current page.
|
||||
|
||||
NOTE: If the C<action> contains a query string (?param=value), C<formHeader>
|
||||
will translate the parameters into hidden form elements automatically.
|
||||
|
||||
=head4 method
|
||||
|
||||
The form method. Defaults to "post".
|
||||
|
|
@ -118,28 +123,36 @@ The form enctype. Defaults to "multipart/form-data".
|
|||
|
||||
=head4 extras
|
||||
|
||||
If you want to add anything special to the form header like javascript actions or stylesheet info, then use this.
|
||||
If you want to add anything special to the form header like javascript
|
||||
actions or stylesheet info, then use this.
|
||||
|
||||
=cut
|
||||
|
||||
sub formHeader {
|
||||
my $session = shift;
|
||||
my $params = shift;
|
||||
my $action = $params->{action} || $session->url->page();
|
||||
my $hidden;
|
||||
if ($action =~ /\?/) {
|
||||
my ($path,$query) = split(/\?/,$action);
|
||||
$action = $path;
|
||||
my @params = split(/\;/,$query);
|
||||
foreach my $param (@params) {
|
||||
$param =~ s/amp;(.*)/$1/;
|
||||
my ($name,$value) = split(/\=/,$param);
|
||||
$hidden .= hidden($session,{name=>$name,value=>$value});
|
||||
}
|
||||
}
|
||||
my $method = $params->{method} || "post";
|
||||
my $enctype = $params->{enctype} || "multipart/form-data";
|
||||
return '<form action="'.$action.'" enctype="'.$enctype.'" method="'.$method.'" '.$params->{extras}.'><div class="formContents">'.$hidden;
|
||||
my $session = shift;
|
||||
my $params = shift || {};
|
||||
|
||||
croak "First parameter must be WebGUI::Session object"
|
||||
unless blessed $session && $session->isa( "WebGUI::Session" );
|
||||
croak "Second parameter must be hash reference"
|
||||
if ref $params ne "HASH";
|
||||
|
||||
my $action = exists $params->{ action } ? $params->{ action } : $session->url->page();
|
||||
my $method = exists $params->{ method } ? $params->{ method } : "post";
|
||||
my $enctype = exists $params->{ enctype } ? $params->{ enctype } : "multipart/form-data";
|
||||
|
||||
# Fix a query string in the action URL
|
||||
my $hidden;
|
||||
if ($action =~ /\?/) {
|
||||
($action, my $query) = split /\?/, $action, 2;
|
||||
my @params = split /[&;]/, $query;
|
||||
foreach my $param ( @params ) {
|
||||
my ($name, $value) = split /=/, $param;
|
||||
$hidden .= hidden( $session, { name => $name, value => $value } );
|
||||
}
|
||||
}
|
||||
|
||||
return '<form action="'.$action.'" enctype="'.$enctype.'" method="'.$method.'" '.$params->{extras}.'><div class="formContents">'.$hidden;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
101
lib/WebGUI/Form/SelectRichEditor.pm
Normal file
101
lib/WebGUI/Form/SelectRichEditor.pm
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
package WebGUI::Form::SelectRichEditor;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2007 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 strict;
|
||||
use base 'WebGUI::Form::SelectBox';
|
||||
use WebGUI::International;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::Form::SelectRichEditor
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Creates a select box to choose a Rich Text Editor asset.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
This is a subclass of WebGUI::Form::SelectBox.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
The following methods are specifically available from this class. Check the superclass for additional methods.
|
||||
|
||||
=cut
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( [ additionalTerms ] )
|
||||
|
||||
See the super class for additional details.
|
||||
|
||||
=head3 additionalTerms
|
||||
|
||||
The following additional parameters have been added via this sub class.
|
||||
|
||||
=head4 defaultValue
|
||||
|
||||
Defaults to the Post Rich Editor, the least-featured Rich Text Editor and the
|
||||
one most likely to be selected by users of this form control.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session);
|
||||
push @{$definition}, {
|
||||
formName => {
|
||||
defaultValue => $i18n->get("475"),
|
||||
},
|
||||
defaultValue => {
|
||||
defaultValue => '',
|
||||
},
|
||||
};
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 new
|
||||
|
||||
Create a new WebGUI::Form::SelectRichEditor object and populate it with all
|
||||
the available Rich Text Editor assets.
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $self = $class->SUPER::new(@_);
|
||||
|
||||
# Get all the RTEs available to this site
|
||||
my $options
|
||||
= $self->session->db->buildHashRef( q{
|
||||
SELECT DISTINCT(assetData.assetId), assetData.title
|
||||
FROM asset, assetData
|
||||
WHERE asset.className='WebGUI::Asset::RichEdit'
|
||||
AND asset.assetId=assetData.assetId
|
||||
ORDER BY assetData.title
|
||||
});
|
||||
|
||||
$self->set( "options", $options );
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ sub sendMessage {
|
|||
userId => $userId,
|
||||
sentBy => $myId,
|
||||
status => 'unread',
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
229
lib/WebGUI/Help/Asset_Gallery.pm
Normal file
229
lib/WebGUI/Help/Asset_Gallery.pm
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
package WebGUI::Help::Asset_Gallery;
|
||||
|
||||
our $HELP = {
|
||||
'help searchForm' => {
|
||||
title => 'help searchForm title',
|
||||
body => 'help searchForm body',
|
||||
variables => [
|
||||
{
|
||||
name => 'searchForm_start',
|
||||
description => 'helpvar searchForm_start',
|
||||
},
|
||||
{
|
||||
name => 'searchForm_end',
|
||||
description => 'helpvar searchForm_end',
|
||||
},
|
||||
{
|
||||
name => 'searchForm_basicSearch',
|
||||
description => 'helpvar searchForm_basicSearch',
|
||||
},
|
||||
{
|
||||
name => 'searchForm_title',
|
||||
description => 'helpvar searchForm_title',
|
||||
},
|
||||
{
|
||||
name => 'searchForm_description',
|
||||
description => 'helpvar searchForm_description',
|
||||
},
|
||||
{
|
||||
name => 'searchForm_keywords',
|
||||
description => 'helpvar searchForm_keywords',
|
||||
},
|
||||
{
|
||||
name => 'searchForm_className',
|
||||
description => 'helpvar searchForm_className',
|
||||
},
|
||||
{
|
||||
name => 'searchForm_creationDate_after',
|
||||
description => 'helpvar searchForm_creationDate_after',
|
||||
},
|
||||
{
|
||||
name => 'searchForm_creationDate_before',
|
||||
description => 'helpvar searchForm_creationDate_before',
|
||||
},
|
||||
{
|
||||
name => 'searchForm_submit',
|
||||
description => 'helpvar searchForm_submit',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help common' => {
|
||||
title => 'help common title',
|
||||
body => 'help common body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help searchForm',
|
||||
namespace => 'Asset_Gallery',
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{
|
||||
name => 'url_addAlbum',
|
||||
description => 'helpvar url_addAlbum',
|
||||
},
|
||||
{
|
||||
name => 'url_listAlbums',
|
||||
description => 'helpvar url_listAlbums',
|
||||
},
|
||||
{
|
||||
name => 'url_listAlbumsRss',
|
||||
description => 'helpvar url_listAlbumsRss',
|
||||
},
|
||||
{
|
||||
name => 'url_listFilesForCurrentUser',
|
||||
description => 'helpvar url_listFilesForCurrentUser',
|
||||
},
|
||||
{
|
||||
name => 'url_search',
|
||||
description => 'helpvar url_search',
|
||||
},
|
||||
{
|
||||
name => 'canEdit',
|
||||
description => 'helpvar canEdit',
|
||||
},
|
||||
{
|
||||
name => 'canAddFile',
|
||||
description => 'helpvar canAddFile',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help listAlbums' => {
|
||||
title => 'help listAlbums title',
|
||||
body => 'help listAlbums body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_Gallery',
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{
|
||||
name => 'albums',
|
||||
description => 'helpvar albums',
|
||||
},
|
||||
],
|
||||
related => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help listAlbumsRss' => {
|
||||
title => 'help listAlbumsRss title',
|
||||
body => 'help listAlbumsRss body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_Gallery',
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{
|
||||
name => 'albums',
|
||||
description => 'helpvar albums rss',
|
||||
variables => [
|
||||
{
|
||||
name => 'rssDate',
|
||||
description => 'helpvar rssDate',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
related => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help search' => {
|
||||
title => 'help search title',
|
||||
body => 'help search body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_Gallery',
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{
|
||||
name => 'search_results',
|
||||
description => 'helpvar search_results',
|
||||
},
|
||||
],
|
||||
# All classes that can be found by a Gallery search go in here
|
||||
related => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_Photo',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help listFilesForUser' => {
|
||||
title => 'help listFilesForUser title',
|
||||
body => 'help listFilesForUser body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_Gallery',
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{
|
||||
name => 'user_albums',
|
||||
description => 'helpvar user_albums',
|
||||
},
|
||||
{
|
||||
name => 'user_files',
|
||||
description => 'helpvar user_files',
|
||||
},
|
||||
{
|
||||
name => 'userId',
|
||||
description => 'helpvar userId',
|
||||
},
|
||||
{
|
||||
name => 'url_rss',
|
||||
description => 'helpvar url_rss',
|
||||
},
|
||||
{
|
||||
name => 'username',
|
||||
description => 'helpvar username',
|
||||
},
|
||||
],
|
||||
# All classes that can be found by a Gallery search go in here
|
||||
related => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_Photo',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help listFilesForUserRss' => {
|
||||
title => 'help listFilesForUserRss title',
|
||||
body => 'help listFilesForUserRss body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help listFilesForUser',
|
||||
namespace => 'Asset_Gallery',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
309
lib/WebGUI/Help/Asset_GalleryAlbum.pm
Normal file
309
lib/WebGUI/Help/Asset_GalleryAlbum.pm
Normal file
|
|
@ -0,0 +1,309 @@
|
|||
package WebGUI::Help::Asset_GalleryAlbum;
|
||||
|
||||
our $HELP = {
|
||||
|
||||
'help common' => {
|
||||
title => 'help common title',
|
||||
body => 'help common body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help searchForm',
|
||||
namespace => 'Asset_Gallery',
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{
|
||||
name => 'canAddFile',
|
||||
description => 'helpvar canAddFile',
|
||||
},
|
||||
{
|
||||
name => 'canEdit',
|
||||
description => 'helpvar canEdit',
|
||||
},
|
||||
{
|
||||
name => 'url_listAlbums',
|
||||
description => 'helpvar url_listAlbums',
|
||||
},
|
||||
{
|
||||
name => 'url_listAlbumsRss',
|
||||
description => 'helpvar url_listAlbumsRss',
|
||||
},
|
||||
{
|
||||
name => 'url_listFilesForCurrentUser',
|
||||
description => 'helpvar url_listFilesForCurrentUser',
|
||||
},
|
||||
{
|
||||
name => 'url_search',
|
||||
description => 'helpvar url_search',
|
||||
},
|
||||
{
|
||||
name => 'url_addArchive',
|
||||
description => 'helpvar url_addArchive',
|
||||
},
|
||||
{
|
||||
name => 'url_addPhoto',
|
||||
description => 'helpvar url_addPhoto',
|
||||
},
|
||||
{
|
||||
name => 'url_addNoClass',
|
||||
description => 'helpvar url_addNoClass',
|
||||
},
|
||||
{
|
||||
name => 'url_delete',
|
||||
description => 'helpvar url_delete',
|
||||
},
|
||||
{
|
||||
name => 'url_edit',
|
||||
description => 'helpvar url_edit',
|
||||
},
|
||||
{
|
||||
name => 'url_listFilesForOwner',
|
||||
description => 'helpvar url_listFilesForOwner',
|
||||
},
|
||||
{
|
||||
name => 'url_viewRss',
|
||||
description => 'helpvar url_viewRss',
|
||||
},
|
||||
{
|
||||
name => 'url_slideshow',
|
||||
description => 'helpvar url_slideshow',
|
||||
},
|
||||
{
|
||||
name => 'url_thumbnails',
|
||||
description => 'helpvar url_thumbnails',
|
||||
},
|
||||
{
|
||||
name => 'fileCount',
|
||||
description => 'helpvar fileCount',
|
||||
},
|
||||
{
|
||||
name => 'ownerUsername',
|
||||
description => 'helpvar ownerUsername',
|
||||
},
|
||||
{
|
||||
name => 'thumbnailUrl',
|
||||
description => 'helpvar thumbnailUrl',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help fileLoop' => {
|
||||
title => 'help fileLoop title',
|
||||
body => 'help fileLoop body',
|
||||
variables => [
|
||||
{
|
||||
name => 'file_loop',
|
||||
description => 'helpvar file_loop',
|
||||
},
|
||||
],
|
||||
|
||||
# ADD ALL GalleryAlbum FILE CLASSES HERE!!!
|
||||
related => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_Photo',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help view' => {
|
||||
title => 'help view title',
|
||||
body => 'help view body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
{
|
||||
tag => 'help fileLoop',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help slideshow' => {
|
||||
title => 'help slideshow title',
|
||||
body => 'help slideshow body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
{
|
||||
tag => 'help fileLoop',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help thumbnails' => {
|
||||
title => 'help thumbnails title',
|
||||
body => 'help thumbnails body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
{
|
||||
tag => 'help fileLoop',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
],
|
||||
|
||||
variables => [
|
||||
{
|
||||
name => 'file_*',
|
||||
description => 'helpvar file_*',
|
||||
},
|
||||
],
|
||||
|
||||
# PUT ALL GalleryAlbum FILE CLASSES HERE ALSO!!!
|
||||
related => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_Photo',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help addArchive' => {
|
||||
title => 'help addArchive title',
|
||||
body => 'help addArchive body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
],
|
||||
variables => {
|
||||
{
|
||||
name => 'form_start',
|
||||
description => 'helpvar form_start',
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => 'form_end',
|
||||
description => 'helpvar form_end',
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => 'form_submit',
|
||||
description => 'helpvar form_submit',
|
||||
},
|
||||
{
|
||||
name => 'form_archive',
|
||||
description => 'helpvar form_archive',
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => 'form_keywords',
|
||||
description => 'helpvar form_keywords',
|
||||
},
|
||||
{
|
||||
name => 'form_friendsOnly',
|
||||
description => 'helpvar form_friendsOnly',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
'help delete' => {
|
||||
title => 'help delete title',
|
||||
body => 'help delete body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{
|
||||
name => 'url_yes',
|
||||
description => 'helpvar url_yes',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help edit' => {
|
||||
title => 'help edit title',
|
||||
body => 'help edit body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
{
|
||||
tag => 'help fileLoop',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{
|
||||
name => 'form_start',
|
||||
description => 'helpvar form_start',
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => 'form_end',
|
||||
description => 'helpvar form_end',
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => 'form_cancel',
|
||||
description => 'helpvar form_cancel',
|
||||
},
|
||||
{
|
||||
name => 'form_submit',
|
||||
description => 'helpvar form_submit',
|
||||
},
|
||||
{
|
||||
name => 'form_title',
|
||||
description => 'helpvar form_title',
|
||||
},
|
||||
{
|
||||
name => 'form_description',
|
||||
description => 'helpvar form_description',
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => 'file_loop',
|
||||
description => 'helpvar file_loop edit',
|
||||
variables => [
|
||||
{
|
||||
name => 'isAlbumThumbnail',
|
||||
description => 'helpvar isAlbumThumbnail',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help viewRss' => {
|
||||
title => 'help viewRss title',
|
||||
body => 'help viewRss body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
{
|
||||
tag => 'help fileLoop',
|
||||
namespace => 'Asset_GalleryAlbum',
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{
|
||||
name => 'file_loop',
|
||||
description => 'helpvar file_loop viewRss',
|
||||
variables => [
|
||||
{
|
||||
name => 'rssDate',
|
||||
description => 'helpvar rssDate',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
258
lib/WebGUI/Help/Asset_Photo.pm
Normal file
258
lib/WebGUI/Help/Asset_Photo.pm
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
package WebGUI::Help::Asset_Photo;
|
||||
|
||||
our $HELP = {
|
||||
'help commentForm' => {
|
||||
title => 'help commentForm title',
|
||||
body => 'help commentForm body',
|
||||
variables => [
|
||||
{
|
||||
name => 'commentForm_start',
|
||||
description => 'helpvar commentForm_start',
|
||||
},
|
||||
{
|
||||
name => 'commentForm_end',
|
||||
description => 'helpvar commentForm_end',
|
||||
},
|
||||
{
|
||||
name => 'commentForm_bodyText',
|
||||
description => 'helpvar commentForm_bodyText',
|
||||
},
|
||||
{
|
||||
name => 'commentForm_submit',
|
||||
description => 'helpvar commentForm_submit',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help common' => {
|
||||
title => 'help common title',
|
||||
body => 'help common body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help searchForm',
|
||||
namespace => 'Asset_Gallery',
|
||||
},
|
||||
{
|
||||
tag => 'help commentForm',
|
||||
namespace => 'Asset_Photo',
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{
|
||||
name => 'canComment',
|
||||
description => 'helpvar canComment',
|
||||
},
|
||||
{
|
||||
name => 'canEdit',
|
||||
description => 'helpvar canEdit',
|
||||
},
|
||||
{
|
||||
name => 'fileUrl',
|
||||
description => 'helpvar fileUrl',
|
||||
},
|
||||
{
|
||||
name => 'numberOfComments',
|
||||
description => 'helpvar numberOfComments',
|
||||
},
|
||||
{
|
||||
name => 'ownerUsername',
|
||||
description => 'helpvar ownerUsername',
|
||||
},
|
||||
{
|
||||
name => 'thumbnailUrl',
|
||||
description => 'helpvar thumbnailUrl',
|
||||
},
|
||||
{
|
||||
name => 'url_delete',
|
||||
description => 'helpvar url_delete',
|
||||
},
|
||||
{
|
||||
name => 'url_demote',
|
||||
description => 'helpvar url_demote',
|
||||
},
|
||||
{
|
||||
name => 'url_edit',
|
||||
description => 'helpvar url_edit',
|
||||
},
|
||||
{
|
||||
name => 'url_gallery',
|
||||
description => 'helpvar url_gallery',
|
||||
},
|
||||
{
|
||||
name => 'url_makeShortcut',
|
||||
description => 'helpvar url_makeShortcut',
|
||||
},
|
||||
{
|
||||
name => 'url_listFilesForOwner',
|
||||
description => 'helpvar url_listFilesForOwner',
|
||||
},
|
||||
{
|
||||
name => 'url_promote',
|
||||
description => 'helpvar url_promote',
|
||||
},
|
||||
{
|
||||
name => 'resolutions_loop',
|
||||
description => 'helpvar resolutions_loop',
|
||||
variables => [
|
||||
{
|
||||
name => 'url_download',
|
||||
description => 'helpvar resolutions_loop url_download',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name => 'exif_*',
|
||||
description => 'helpvar exif_*',
|
||||
},
|
||||
{
|
||||
name => 'exifLoop',
|
||||
description => 'helpvar exifLoop',
|
||||
variables => [
|
||||
{
|
||||
name => 'tag',
|
||||
description => 'helpvar exifLoop tag',
|
||||
},
|
||||
{
|
||||
name => 'value',
|
||||
description => 'helpvar exifLoop value',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help delete' => {
|
||||
title => 'help delete title',
|
||||
body => 'help delete body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_Photo',
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{
|
||||
name => 'url_yes',
|
||||
description => 'helpvar url_yes',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help edit' => {
|
||||
title => 'help edit title',
|
||||
body => 'htlp edit body',
|
||||
variables => [
|
||||
{
|
||||
name => 'url_addArchive',
|
||||
description => 'helpvar url_addArchive',
|
||||
},
|
||||
{
|
||||
name => 'form_start',
|
||||
description => 'helpvar form_start',
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => 'form_end',
|
||||
description => 'helpvar form_end',
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => 'form_submit',
|
||||
description => 'helpvar form_submit',
|
||||
},
|
||||
{
|
||||
name => 'form_title',
|
||||
description => 'helpvar form_title',
|
||||
},
|
||||
{
|
||||
name => 'form_synopsis',
|
||||
description => 'helpvar form_synopsis',
|
||||
},
|
||||
{
|
||||
name => 'form_photo',
|
||||
description => 'helpvar form_photo',
|
||||
},
|
||||
{
|
||||
name => 'form_keywords',
|
||||
description => 'helpvar form_keywords',
|
||||
},
|
||||
{
|
||||
name => 'form_location',
|
||||
description => 'helpvar form_location',
|
||||
},
|
||||
{
|
||||
name => 'form_friendsOnly',
|
||||
description => 'helpvar form_friendsOnly',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'help makeShortcut' => {
|
||||
title => 'help makeShortcut title',
|
||||
body => 'htlp makeShortcut body',
|
||||
variables => [
|
||||
{
|
||||
name => 'form_start',
|
||||
description => 'helpvar form_start',
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => 'form_end',
|
||||
description => 'helpvar form_end',
|
||||
required => 1,
|
||||
},
|
||||
{
|
||||
name => 'form_parentId',
|
||||
description => 'helpvar form_parentId',
|
||||
required => 1,
|
||||
},
|
||||
],
|
||||
}
|
||||
'help view' => {
|
||||
title => 'help view title',
|
||||
body => 'help view body',
|
||||
isa => [
|
||||
{
|
||||
tag => 'help common',
|
||||
namespace => 'Asset_Photo',
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{
|
||||
name => 'commentLoop',
|
||||
description => 'helpvar commentLoop',
|
||||
variables => [
|
||||
{
|
||||
name => 'userId',
|
||||
description => 'helpvar commentLoop userId',
|
||||
},
|
||||
{
|
||||
name => 'visitorIp',
|
||||
description => 'helpvar commentLoop visitorIp',
|
||||
},
|
||||
{
|
||||
name => 'creationDate',
|
||||
description => 'helpvar commentLoop creationDate',
|
||||
},
|
||||
{
|
||||
name => 'bodyText',
|
||||
description => 'helpvar commentLoop bodyText',
|
||||
},
|
||||
{
|
||||
name => 'username',
|
||||
description => 'helpvar commentLoop username',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name => 'commentLoop_pageBar',
|
||||
description => 'helpvar commentLoop_pageBar',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -27,6 +27,9 @@ Package WebGUI::Keyword
|
|||
|
||||
This package provides an API to create and modify keywords used by the asset sysetm.
|
||||
|
||||
Assets can use the C<keywords> property to set keywords automatically. See
|
||||
WebGUI::Asset::update() for more details.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Keyword;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ package WebGUI::Search;
|
|||
=cut
|
||||
|
||||
use strict;
|
||||
use Carp qw( croak );
|
||||
use WebGUI::Asset;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -329,6 +330,9 @@ This rule allows for an array reference of table join clauses.
|
|||
|
||||
join => 'join assetData on assetId = assetData.assetId'
|
||||
|
||||
NOTE: This rule is deprecated and will be removed in a future release. Use
|
||||
joinClass instead.
|
||||
|
||||
=head4 columns
|
||||
|
||||
This rule allows for additional columns to be returned by getResultSet().
|
||||
|
|
@ -344,6 +348,11 @@ placeholders and parameters.
|
|||
sub search {
|
||||
my $self = shift;
|
||||
my $rules = shift;
|
||||
|
||||
# Send the rules through some sanity checks
|
||||
croak "'lineage' rule must be array reference"
|
||||
if ( $rules->{lineage} && ref $rules->{lineage} ne "ARRAY" );
|
||||
|
||||
my @params = ();
|
||||
my $query = "";
|
||||
my @clauses = ();
|
||||
|
|
@ -410,10 +419,31 @@ sub search {
|
|||
if ($rules->{where}) {
|
||||
push(@clauses, $rules->{where});
|
||||
}
|
||||
if ($rules->{join}) { # This join happens in _getQuery
|
||||
$rules->{join} = [$rules->{join}]
|
||||
unless (ref $rules->{join} eq "ARRAY");
|
||||
$self->{_join} = $rules->{join};
|
||||
# deal with custom joined tables if we must
|
||||
if (exists $rules->{joinClass}) {
|
||||
my $join = [ "left join assetData on assetIndex.assetId=assetData.assetId" ];
|
||||
for my $className ( @{ $rules->{ joinClass } } ) {
|
||||
my $cmd = "use " . $className;
|
||||
eval { $cmd };
|
||||
$self->session->errorHandler->fatal("Couldn't compile asset package: ".$className.". Root cause: ".$@) if ($@);
|
||||
foreach my $definition (@{$className->definition($self->session)}) {
|
||||
unless ($definition->{tableName} eq "asset") {
|
||||
my $tableName = $definition->{tableName};
|
||||
push @$join,
|
||||
"left join $tableName on assetData.assetId=".$tableName.".assetId and assetData.revisionDate=".$tableName.".revisionDate";
|
||||
}
|
||||
last;
|
||||
}
|
||||
}
|
||||
# Get only the latest revision
|
||||
push @clauses, "assetData.revisionDate = (SELECT MAX(revisionDate) FROM assetData ad WHERE ad.assetId = assetData.assetId)";
|
||||
# Join happens in _getQuery
|
||||
$self->{_join} = $join;
|
||||
}
|
||||
elsif ($rules->{join}) { # This join happens in _getQuery
|
||||
$rules->{join} = [$rules->{join}]
|
||||
unless (ref $rules->{join} eq "ARRAY");
|
||||
$self->{_join} = $rules->{join};
|
||||
}
|
||||
if ($rules->{columns}) {
|
||||
$rules->{columns} = [$rules->{columns}]
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ package WebGUI::Storage;
|
|||
=cut
|
||||
|
||||
use Archive::Tar;
|
||||
use Carp qw( croak );
|
||||
use Cwd;
|
||||
use File::Copy qw(cp);
|
||||
use FileHandle;
|
||||
use File::Find;
|
||||
|
|
@ -24,7 +26,6 @@ use Storable qw(nstore retrieve);
|
|||
use strict;
|
||||
use warnings;
|
||||
use WebGUI::Utility;
|
||||
use Carp;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -64,6 +65,7 @@ This package provides a mechanism for storing and retrieving files that are not
|
|||
$newstore = $store->untar($filename);
|
||||
|
||||
|
||||
$store->copyFile($filename, $newFilename);
|
||||
$store->delete;
|
||||
$store->deleteFile($filename);
|
||||
$store->rename($filename, $newFilename);
|
||||
|
|
@ -202,6 +204,7 @@ sub addFileFromFormPost {
|
|||
my $filename;
|
||||
my $attachmentCount = 1;
|
||||
foreach my $upload ($self->session->request->upload($formVariableName)) {
|
||||
$self->session->errorHandler->info("Trying to get " . $upload->filename);
|
||||
return $filename if $attachmentCount > $attachmentLimit;
|
||||
my $tempFilename = $upload->filename();
|
||||
next unless $tempFilename;
|
||||
|
|
@ -225,6 +228,7 @@ sub addFileFromFormPost {
|
|||
print $file $buffer;
|
||||
}
|
||||
close($file);
|
||||
$self->session->errorHandler->info("Got ".$upload->filename);
|
||||
} else {
|
||||
$self->_addError("Couldn't open file ".$self->getPath($filename)." for writing due to error: ".$!);
|
||||
return;
|
||||
|
|
@ -343,6 +347,31 @@ sub copy {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 copyFile ( filename, newFilename )
|
||||
|
||||
Copy a file in this storage location. C<filename> is the file to copy.
|
||||
C<newFilename> is the new file to create.
|
||||
|
||||
=cut
|
||||
|
||||
sub copyFile {
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $newFilename = shift;
|
||||
|
||||
croak "Can't find '$filename' in storage location " . $self->getId
|
||||
unless -e $self->getPath($filename);
|
||||
croak "Second argument must be a filename"
|
||||
unless $newFilename;
|
||||
|
||||
cp( $self->getPath($filename), $self->getPath($newFilename) )
|
||||
|| croak "Couldn't copy '$filename' to '$newFilename': $!";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 create ( session )
|
||||
|
||||
Creates a new storage location on the file system.
|
||||
|
|
@ -354,9 +383,9 @@ A reference to the current session;
|
|||
=cut
|
||||
|
||||
sub create {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $id = $session->id->generate();
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $id = $session->id->generate();
|
||||
|
||||
#Determine whether or not to use case insensitive files
|
||||
my $config = $session->config;
|
||||
|
|
@ -365,14 +394,16 @@ sub create {
|
|||
|
||||
#$session->errorHandler->warn($caseInsensitive.": $id\n".Carp::longmess()."\n");
|
||||
#For case insensitive operating systems, convert guid to hex
|
||||
if($caseInsensitive) {
|
||||
if ($caseInsensitive) {
|
||||
my $hexId = $session->id->toHex($id);
|
||||
$db->write("insert into storageTranslation (guidValue,hexValue) values (?,?)",[$id,$hexId]);
|
||||
}
|
||||
|
||||
my $self = $class->get($session,$id);
|
||||
$self->_makePath;
|
||||
return $self;
|
||||
$self->_makePath;
|
||||
|
||||
$session->errorHandler->info("Created storage location $id as a $class");
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -446,6 +477,7 @@ sub delete {
|
|||
$db->write("delete from storageTranslation where guidValue=?",[$self->getId]);
|
||||
}
|
||||
}
|
||||
$self->session->errorHandler->info("Deleted storage ".$self->getId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -753,6 +785,8 @@ Returns a full path to this storage location.
|
|||
|
||||
If specified, we'll return a path to the file rather than the storage location.
|
||||
|
||||
NOTE: Does not check if the file exists. This is a feature.
|
||||
|
||||
=cut
|
||||
|
||||
sub getPath {
|
||||
|
|
@ -898,21 +932,22 @@ Pass in a storage location object to create the tar file in, instead of having a
|
|||
=cut
|
||||
|
||||
sub tar {
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $temp = shift || WebGUI::Storage->createTemp($self->session);
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $temp = shift || WebGUI::Storage->createTemp($self->session);
|
||||
chdir $self->getPath or croak 'Unable to chdir to ' . $self->getPath . ": $!";
|
||||
my @files = ();
|
||||
find(sub { push(@files, $File::Find::name)}, ".");
|
||||
if ($Archive::Tar::VERSION eq '0.072') {
|
||||
my $tar = Archive::Tar->new();
|
||||
$tar->add_files(@files);
|
||||
$tar->write($temp->getPath($filename),1);
|
||||
|
||||
} else {
|
||||
Archive::Tar->create_archive($temp->getPath($filename),1,@files);
|
||||
}
|
||||
return $temp;
|
||||
my @files = ();
|
||||
find(sub { push(@files, $File::Find::name)}, ".");
|
||||
if ($Archive::Tar::VERSION eq '0.072') {
|
||||
my $tar = Archive::Tar->new();
|
||||
$tar->add_files(@files);
|
||||
$tar->write($temp->getPath($filename),1);
|
||||
|
||||
}
|
||||
else {
|
||||
Archive::Tar->create_archive($temp->getPath($filename),1,@files);
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -932,12 +967,17 @@ Pass in a storage location object to extract the contents to, instead of having
|
|||
=cut
|
||||
|
||||
sub untar {
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $temp = shift || WebGUI::Storage->createTemp($self->session);
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $temp = shift || WebGUI::Storage->createTemp($self->session);
|
||||
|
||||
my $originalDir = cwd;
|
||||
chdir $temp->getPath;
|
||||
|
||||
Archive::Tar->extract_archive($self->getPath($filename),1);
|
||||
$self->_addError(Archive::Tar->error) if (Archive::Tar->error);
|
||||
|
||||
chdir $originalDir;
|
||||
return $temp;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@ use WebGUI::Storage::Image;
|
|||
|
||||
These methods are available from this class:
|
||||
|
||||
my $boolean = $self->generateThumbnail($filename);
|
||||
my $url = $self->getThumbnailUrl($filename);
|
||||
my $boolean = $self->isImage($filename);
|
||||
my ($captchaFile, $challenge) = $self->addFileFromCaptcha;
|
||||
$self->resize($imageFile, $width, $height);
|
||||
my $boolean = $self->generateThumbnail($filename);
|
||||
my $url = $self->getThumbnailUrl($filename);
|
||||
my $boolean = $self->isImage($filename);
|
||||
my ($captchaFile, $challenge) = $self->addFileFromCaptcha;
|
||||
$self->resize($imageFile, $width, $height);
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -313,7 +313,7 @@ sub getThumbnailUrl {
|
|||
return '';
|
||||
}
|
||||
if (! isIn($filename, @{ $self->getFiles() })) {
|
||||
$self->session->errorHandler->error("Can't make a thumbnail for a file that is not in my storage location.");
|
||||
$self->session->errorHandler->error("Can't make a thumbnail for a file named '$filename' that is not in my storage location.");
|
||||
return '';
|
||||
}
|
||||
return $self->getUrl("thumb-".$filename);
|
||||
|
|
@ -360,41 +360,42 @@ The new height of the image in pixels.
|
|||
=cut
|
||||
|
||||
sub resize {
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $width = shift;
|
||||
my $height = shift;
|
||||
unless (defined $filename) {
|
||||
$self->session->errorHandler->error("Can't resize when you haven't specified a file.");
|
||||
return 0;
|
||||
}
|
||||
unless ($self->isImage($filename)) {
|
||||
$self->session->errorHandler->error("Can't resize something that's not an image.");
|
||||
return 0;
|
||||
}
|
||||
unless ($width || $height) {
|
||||
$self->session->errorHandler->error("Can't resize with no resizing parameters.");
|
||||
return 0;
|
||||
}
|
||||
my $image = $graphicsPackage->new;
|
||||
my $error = $image->Read($self->getPath($filename));
|
||||
if ($error) {
|
||||
$self->session->errorHandler->error("Couldn't read image for resizing: ".$error);
|
||||
return 0;
|
||||
}
|
||||
my ($x, $y) = $image->Get('width','height');
|
||||
if ($width && !$height) { # proportional scale by width
|
||||
$height = $width / $x * $y;
|
||||
} elsif (!$width && $height) { # proportional scale by height
|
||||
$width = $height * $x / $y;
|
||||
}
|
||||
$image->Scale(width=>$width, height=>$height);
|
||||
$error = $image->Write($self->getPath($filename));
|
||||
if ($error) {
|
||||
$self->session->errorHandler->error("Couldn't create thumbnail: ".$error);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $width = shift;
|
||||
my $height = shift;
|
||||
unless (defined $filename) {
|
||||
$self->session->errorHandler->error("Can't resize when you haven't specified a file.");
|
||||
return 0;
|
||||
}
|
||||
unless ($self->isImage($filename)) {
|
||||
$self->session->errorHandler->error("Can't resize something that's not an image.");
|
||||
return 0;
|
||||
}
|
||||
unless ($width || $height) {
|
||||
$self->session->errorHandler->error("Can't resize with no resizing parameters.");
|
||||
return 0;
|
||||
}
|
||||
my $image = $graphicsPackage->new;
|
||||
my $error = $image->Read($self->getPath($filename));
|
||||
if ($error) {
|
||||
$self->session->errorHandler->error("Couldn't read image for resizing: ".$error);
|
||||
return 0;
|
||||
}
|
||||
my $geometry;
|
||||
if (!$width || !$height) {
|
||||
$geometry = $width || $height;
|
||||
}
|
||||
else {
|
||||
$geometry = $width . "x" . $height;
|
||||
}
|
||||
$image->Resize( geometry => $geometry, filter => "lanczos" );
|
||||
$error = $image->Write($self->getPath($filename));
|
||||
if ($error) {
|
||||
$self->session->errorHandler->error("Couldn't resize image: ".$error);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
558
lib/WebGUI/i18n/English/Asset_Gallery.pm
Normal file
558
lib/WebGUI/i18n/English/Asset_Gallery.pm
Normal file
|
|
@ -0,0 +1,558 @@
|
|||
package WebGUI::i18n::English::Asset_Gallery;
|
||||
|
||||
our $I18N = {
|
||||
'assetName' => {
|
||||
message => 'Gallery',
|
||||
lastUpdated => 1131394072,
|
||||
},
|
||||
"groupIdAddComment label" => {
|
||||
message => "Group to Add Comments",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"groupIdAddComment description" => {
|
||||
message => "The group that is allowed to add comments to files.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"groupIdAddFile label" => {
|
||||
message => "Group to Add Files",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"groupIdAddFile description" => {
|
||||
message => "The group that is allowed to add files and albums to this gallery",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"groupIdModerator label" => {
|
||||
message => "Group to Moderate Comments",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"groupIdModerator description" => {
|
||||
message => "The group that is allowed to edit / delete comments in this gallery",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"imageResolutions label" => {
|
||||
message => "Image Resolutions",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"imageResolutions description" => {
|
||||
message => "The sizes of images available for download.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"imageViewSize label" => {
|
||||
message => "Image View Size",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"imageViewSize description" => {
|
||||
message => "The size for images in the gallery. Will default to the Image Size
|
||||
in the site settings.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"imageThumbnailSize label" => {
|
||||
message => "Image Thumbnail Size",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"imageThumbnailSize description" => {
|
||||
message => "The size for thumbnails of images in the gallery. Will default to the
|
||||
Thumbnail Size in the site settings.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"maxSpacePerUser label" => {
|
||||
message => "Max Disk Space Per User",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"maxSpacePerUser description" => {
|
||||
message => "The maximum amount of disk space a user is allowed to use in this Gallery.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"richEditIdFileComment label" => {
|
||||
message => "Rich Editor for Comments",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"richEditIdFileComment description" => {
|
||||
message => "The Rich Text Editor to use for comments",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
'search class galleryalbum' => {
|
||||
message => 'Album',
|
||||
lastUpdated => 0,
|
||||
context => 'Asset name for WebGUI::Asset::Wobject::GalleryAlbum',
|
||||
},
|
||||
'search class any' => {
|
||||
message => 'Any',
|
||||
lastUpdated => 0,
|
||||
context => 'Label to not restrict gallery search by class',
|
||||
},
|
||||
'search class photo' => {
|
||||
message => "Photo",
|
||||
lastUpdated => 0,
|
||||
context => 'Asset name for WebGUI::Asset::File::Image::Photo class',
|
||||
},
|
||||
"search submit" => {
|
||||
message => "Search",
|
||||
lastUpdated => 0,
|
||||
context => 'Label for button to submit search form',
|
||||
},
|
||||
"templateIdAddArchive label" => {
|
||||
message => "Template to Add Multiple",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdAddArchive description" => {
|
||||
message => "Display the form to add an archive of files to the gallery.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdDeleteAlbum label" => {
|
||||
message => "Template to Delete Albums",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdDeleteAlbum description" => {
|
||||
message => "Display the confirmation to delete an album from the gallery.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdDeleteFile label" => {
|
||||
message => "Template to Delete Files",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdDeleteFile description" => {
|
||||
message => "Display the confirmation to delete a file from the gallery.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdEditAlbum label" => {
|
||||
message => "Template to Edit Albums",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdEditAlbum description" => {
|
||||
message => "The template to add / edit an album.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdEditFile label" => {
|
||||
message => "Template to Edit Files",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdEditFile description" => {
|
||||
message => "The template to add / edit a file.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdListAlbums label" => {
|
||||
message => "Template to List Albums",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdListAlbums description" => {
|
||||
message => "Template to show a list of albums in the gallery.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdListAlbumsRss label" => {
|
||||
message => "Template to List Albums RSS",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdListAlbumsRss description" => {
|
||||
message => "Template to show an RSS feed of the albums in this gallery.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdMakeShortcut label" => {
|
||||
message => "Template to Cross Post Files",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdMakeShortcut description" => {
|
||||
message => "Display the form to copy an image to another album.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdSearch label" => {
|
||||
message => "Template to Search",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdSearch description" => {
|
||||
message => "Display the form to search the gallery. Display search results.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdViewSlideshow label" => {
|
||||
message => "Template for Slideshow",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdViewSlideshow description" => {
|
||||
message => "Display all the images in an album as a slideshow.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdViewThumbnails label" => {
|
||||
message => "Template for Thumbnails",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdViewThumbnails description" => {
|
||||
message => "Display all the images in an album as their thumbnails",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdListFilesForUser label" => {
|
||||
message => "Template to List Files for User",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdListFilesForUser description" => {
|
||||
message => "Display all the files and albums for a specific user.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdListFilesForUserRss label" => {
|
||||
message => "Template to List Files for User RSS",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdListFilesForUserRss description" => {
|
||||
message => "RSS feed for all the files for a specific user.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdViewAlbum label" => {
|
||||
message => "Template to View Album",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdViewAlbum description" => {
|
||||
message => "Default view for albums",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdViewAlbumRss label" => {
|
||||
message => "Template to View Album RSS",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdViewAlbumRss description" => {
|
||||
message => "RSS feed for a single album",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdViewFile label" => {
|
||||
message => "Template to View a File",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"templateIdViewFile description" => {
|
||||
message => "Show the details and comments for a specific file",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"viewDefault label" => {
|
||||
message => "Default View",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"viewDefault description" => {
|
||||
message => "Select the default view when a user enters the gallery.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"viewDefault option list" => {
|
||||
message => "List Albums",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"viewDefault option album" => {
|
||||
message => "Single Album",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"viewAlbumAssetId label" => {
|
||||
message => "Default View Album",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"viewAlbumAssetId description" => {
|
||||
message => "The album to view when the default view is 'Album'",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"viewListOrderBy label" => {
|
||||
message => "List Albums Order By",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"viewListOrderBy description" => {
|
||||
message => "The field to order the album list by",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"viewListOrderBy option creationDate" => {
|
||||
message => "Creation Date",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"viewListOrderBy option lineage" => {
|
||||
message => "Sequence Number",
|
||||
lastUpdated => 0,
|
||||
context => 'Label to order by sequence (as in asset manager)',
|
||||
},
|
||||
"viewListOrderBy option revisionDate" => {
|
||||
message => "Revision Date",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"viewListOrderBy option title" => {
|
||||
message => "Title",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"viewListOrderDirection label" => {
|
||||
message => "List Albums Direction",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"viewListOrderDirection description" => {
|
||||
message => "The direction to order the album list",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"viewListOrderDirection option asc" => {
|
||||
message => "Ascending",
|
||||
lastUpdated => 0,
|
||||
context => 'Label for sorting in ascending order',
|
||||
},
|
||||
"viewListOrderDirection option desc" => {
|
||||
message => "Descending",
|
||||
lastUpdated => 0,
|
||||
context => 'Label for sorting in descending order',
|
||||
},
|
||||
"workflowIdCommit label" => {
|
||||
message => "Approval Workflow",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
"workflowIdCommit description" => {
|
||||
message => "Workflow to approve new Files.",
|
||||
lastUpdated => 0,
|
||||
context => '',
|
||||
},
|
||||
|
||||
'helpvar searchForm_start' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar searchForm_end' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar searchForm_basicSearch' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar searchForm_title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar searchForm_description' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar searchForm_keywords' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar searchForm_className' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar searchForm_creationDate_after' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar searchForm_creationDate_before' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar searchForm_submit' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_addAlbum' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_listAlbums' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_listAlbumsRss' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_listFilesForCurrentUser' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_search' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar canEdit' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar canAddFile' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar albums' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar albums rss' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar rssDate' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar search_results' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar user_albums' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar user_files' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar userId' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_rss' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar username' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help searchForm title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help searchForm body' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help common title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help common body' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help listAlbums title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help listAlbums body' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help listAlbumsRss title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help search body' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help search title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help listFilesForUser title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help listFilesForUser body' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help listFilesForUserRss title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help listFilesForUserRss body' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
299
lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm
Normal file
299
lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
package WebGUI::i18n::English::Asset_GalleryAlbum;
|
||||
|
||||
our $I18N = {
|
||||
'addArchive message' => {
|
||||
message => 'Your files have been submitted for approval and commit. <a href="%s">Return to Album</a>',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
'assetName' => {
|
||||
message => 'Gallery Album',
|
||||
lastUpdated => 1131394072,
|
||||
},
|
||||
'cancel' => {
|
||||
message => "Cancel",
|
||||
lastUpdated => 0,
|
||||
context => "Label for Cancel button",
|
||||
},
|
||||
'save' => {
|
||||
message => "Save",
|
||||
lastUpdated => 0,
|
||||
context => "Label for Save button",
|
||||
},
|
||||
'save message' => {
|
||||
message => 'Album settings saved. <a href="%s">Return to Album</a>',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help common title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help common body' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help fileLoop title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help fileLoop body' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help view title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help view body' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help slideshow title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help slideshow body' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help thumbnails title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help thumbnails body' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help addArchive title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help addArchive body' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help delete title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help delete body' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help edit title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help viewRss title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help viewRss body' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar canAddFile' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar canEdit' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_listAlbums' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_listAlbumsRss' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_listFilesForCurrentUser' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_search' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_addArchive' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_addPhoto' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_addNoClass' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_delete' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_edit' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_listFilesForOwner' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_viewRss' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_slideshow' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_thumbnails' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar fileCount' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar ownerUsername' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar thumbnailUrl' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar file_loop' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar file_*' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_start' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_end' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_submit' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_archive' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_keywords' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_friendsOnly' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_yes' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_start' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_end' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_cancel' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_submit' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_description' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar file_loop edit' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar isAlbumThumbnail' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar file_loop viewRss' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar rssDate' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
291
lib/WebGUI/i18n/English/Asset_Photo.pm
Normal file
291
lib/WebGUI/i18n/English/Asset_Photo.pm
Normal file
|
|
@ -0,0 +1,291 @@
|
|||
package WebGUI::i18n::English::Asset_Photo;
|
||||
|
||||
our $I18N = {
|
||||
'assetName' => {
|
||||
message => q{Photo},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'delete message' => {
|
||||
message => q{The photo has been deleted. <a href="%s">Return to Album</a>},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'save message' => {
|
||||
message => q{Your photo has been submitted for approval and commit. <a href="%s">View Photo</a>. <a href="%s">Add another photo</a>.},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help commentForm title' => {
|
||||
message => 'Photo -- Comment Form',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help commentForm body' => {
|
||||
message => 'These template variables make up the form to allow users to post comments on Photos',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help common title' => {
|
||||
message => 'Photo -- Common',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help common body' => {
|
||||
message => 'These template variables are shared by all views of the Photo asset.',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help edit title' => {
|
||||
message => 'Photo -- Edit Form',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help edit body' => {
|
||||
message => 'These template variables make up the form to add / edit Photo assets',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help makeShortcut title' => {
|
||||
message => 'Photo -- Make Shortcut Form',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help makeShortcut body' => {
|
||||
message => 'These template variables make up the form to cross-post Photo assets',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help view title' => {
|
||||
message => 'Photo -- Normal View',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'help view body' => {
|
||||
message => 'These template variables make up the normal view of Photo assets',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar commentForm_start' => {
|
||||
message => 'Begin the comment form',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar commentForm_end' => {
|
||||
message => 'End the comment form',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar commentForm_bodyText' => {
|
||||
message => 'The body of the comment. A rich editor as configured by the parent Gallery.',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar commentForm_submit' => {
|
||||
message => 'Submit the comment form',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar canComment' => {
|
||||
message => 'This is true if the current user can comment on this photo',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar canEdit' => {
|
||||
message => 'This is true if the current user can edit this photo',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar fileUrl' => {
|
||||
message => 'The URL to the normal-sized photo',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar numberOfComments' => {
|
||||
message => 'The total number of comments on this photo',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar ownerUsername' => {
|
||||
message => 'The username of the user who posted this photo',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar thumbnailUrl' => {
|
||||
message => 'The URL to the thumbnail of this photo',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_delete' => {
|
||||
message => 'The URL to delete this photo.',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_demote' => {
|
||||
message => 'The URL to demote this photo in rank. Will return the user directly to the parent GalleryAlbum edit form',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_edit' => {
|
||||
message => 'The URL to edit this photo',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_gallery' => {
|
||||
message => 'The URL to the Gallery that contains this photo.',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_makeShortcut' => {
|
||||
message => 'The URL to make a shortcut to this photo.',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_listFilesForOwner' => {
|
||||
message => 'The URL to list files and albums posted by the owner of this photo',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_promote' => {
|
||||
message => 'The URL to promote this photo in rank. Will return the user directly to the parent GalleryAlbum edit form',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar resolutions_loop' => {
|
||||
message => 'The available resolutions this photo has for download.',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar resolutions_loop url_download' => {
|
||||
message => 'The URL to the resolution to download.',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar exif_*' => {
|
||||
message => 'Each EXIF tag can be referenced by name.',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar exifLoop' => {
|
||||
message => 'A loop of EXIF tags',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar exifLoop tag' => {
|
||||
message => 'The name of the EXIF tag',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar exifLoop value' => {
|
||||
message => 'The value of the EXIF tag',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_addArchive' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_start' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_end' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_submit' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_title' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_synopsis' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_photo' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_keywords' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_location' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_friendsOnly' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_start' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_end' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar form_parentId' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar commentLoop' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar commentLoop userId' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar commentLoop visitorIp' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar commentLoop creationDate' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar commentLoop bodyText' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar commentLoop username' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar commentLoop_pageBar' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'helpvar url_yes' => {
|
||||
message => '',
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
@ -122,6 +122,8 @@ checkModule("Locale::US");
|
|||
checkModule("Weather::Com::Finder","0.5.1");
|
||||
checkModule("Class::InsideOut","1.06");
|
||||
checkModule("HTML::TagCloud","0.34");
|
||||
checkModule("Image::ExifTool","7.00");
|
||||
checkModule("Archive::Any","0.093");
|
||||
|
||||
|
||||
###################################
|
||||
|
|
@ -200,8 +202,8 @@ print "\nTesting complete!\n\n";
|
|||
#----------------------------------------
|
||||
sub checkModule {
|
||||
my $module = shift;
|
||||
my $version = shift || 0;
|
||||
my $skipInstall = shift;
|
||||
my $version = shift || 0;
|
||||
my $skipInstall = shift;
|
||||
my $afterinstall = shift;
|
||||
unless (defined $afterinstall) { $afterinstall = 0; }
|
||||
printTest("Checking for module $module");
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ use Test::More; # increment this value for each test you create
|
|||
use Test::Deep;
|
||||
plan tests => 9;
|
||||
|
||||
#TODO: This script tests certain aspects of WebGUI::Storage and it should not
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
##Create a storage location
|
||||
|
|
|
|||
83
t/Asset/File/Image/Photo/00base.t
Normal file
83
t/Asset/File/Image/Photo/00base.t
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the creation and deletion of photo assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
print "hi";
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 5;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test module compiles okay
|
||||
# plan tests => 1
|
||||
use_ok("WebGUI::Asset::File::Image::Photo");
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test creating a photo
|
||||
my $photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
is(
|
||||
blessed $photo, "WebGUI::Asset::File::Image::Photo",
|
||||
"Photo is a WebGUI::Asset::File::Image::Photo object",
|
||||
);
|
||||
|
||||
isa_ok(
|
||||
$photo, "WebGUI::Asset::File::Image",
|
||||
);
|
||||
|
||||
is(
|
||||
blessed $photo->getGallery, "WebGUI::Asset::Wobject::Gallery",
|
||||
"Photo->getGallery gets the gallery containing this photo",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting a photo
|
||||
my $properties = $photo->get;
|
||||
$photo->purge;
|
||||
|
||||
is(
|
||||
WebGUI::Asset->newByDynamicClass($session, $properties->{assetId}), undef,
|
||||
"Photo no longer able to be instanciated",
|
||||
);
|
||||
|
||||
53
t/Asset/File/Image/Photo/ajax.t
Normal file
53
t/Asset/File/Image/Photo/ajax.t
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# The goal of this test is to test the AJAX methods of the Photo asset
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
my $photo
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 0;
|
||||
|
||||
250
t/Asset/File/Image/Photo/comment.t
Normal file
250
t/Asset/File/Image/Photo/comment.t
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the adding, deleting, editing, and
|
||||
# getting comments for photos
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
groupIdAddComment => "2",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
my $photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 0;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test with no comments
|
||||
is(
|
||||
blessed $photo->getCommentPaginator, "WebGUI::Paginator",
|
||||
"Photo with no comments still provides comments paginator",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
$photo->getCommentIds, [],
|
||||
"Photo->getCommentIds returns an empty arrayref when no comments",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test the setComment requires two arguments
|
||||
ok(
|
||||
!eval{ $photo->setComment(); 1 },
|
||||
"Photo->setComment fails when no arguments given",
|
||||
);
|
||||
|
||||
ok(
|
||||
!eval{ $photo->setComment("new"); 1 },
|
||||
"Photo->setComment fails when no second argument given",
|
||||
);
|
||||
|
||||
ok(
|
||||
!eval{ $photo->setComment("new", "lulz"); 1 },
|
||||
"Photo->setComment fails when second argument is not a hashref",
|
||||
);
|
||||
|
||||
ok(
|
||||
!eval{ $photo->setComment("new", { lulz => "ohai" }); 1 },
|
||||
"Photo->setComment fails when hashref does not contain a bodyText key",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test adding a comment
|
||||
# - bodyText is defined
|
||||
# - All else is defaults
|
||||
my $commentId;
|
||||
ok(
|
||||
eval{ $commentId = $photo->setComment("new", { bodyText => "bodyText", }); 1 },
|
||||
"Photo->setComment succeeds",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
$photo->getCommentIds, [$commentId],
|
||||
"Photo->getCommentIds returns newly added comment's ID",
|
||||
);
|
||||
|
||||
my $comment;
|
||||
ok(
|
||||
eval{ $comment = $photo->getComment($commentId); 1},
|
||||
"Photo->getComment does not croak.",
|
||||
);
|
||||
|
||||
is(
|
||||
ref $comment, "HASH",
|
||||
"Photo->getComment returns a hash reference",
|
||||
);
|
||||
|
||||
is(
|
||||
$comment->{assetId}, $photo->getId,
|
||||
"Comment has correct assetId",
|
||||
);
|
||||
|
||||
is(
|
||||
$comment->{userId}, $session->user->userId,
|
||||
"Comment has correct userId",
|
||||
);
|
||||
|
||||
is(
|
||||
$comment->{visitorIp}, undef,
|
||||
"visitorIp is not defined if the user is not a visitor",
|
||||
);
|
||||
|
||||
like(
|
||||
$comment->{creationDate}, /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/,
|
||||
"creationDate is defined and is a MySQL-formatted date",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test adding a comment
|
||||
# - bodyText is defined
|
||||
# - userId is visitor
|
||||
# - all else is defaults
|
||||
ok(
|
||||
eval{ $commentId = $photo->setComment("new", { userId => 1, bodyText => "bodyText", }); 1 },
|
||||
"Photo->setComment succeeds",
|
||||
);
|
||||
|
||||
ok(
|
||||
grep { $_ eq $commentId } @{ $photo->getCommentIds },
|
||||
"Photo->getCommentIds returns newly added comment's ID",
|
||||
);
|
||||
|
||||
my $comment;
|
||||
ok(
|
||||
eval{ $comment = $photo->getComment($commentId); 1},
|
||||
"Photo->getComment does not croak.",
|
||||
);
|
||||
|
||||
is(
|
||||
ref $comment, "HASH",
|
||||
"Photo->getComment returns a hash reference",
|
||||
);
|
||||
|
||||
is(
|
||||
$comment->{assetId}, $photo->getId,
|
||||
"Comment has correct assetId",
|
||||
);
|
||||
|
||||
is(
|
||||
$comment->{userId}, 1,
|
||||
"Comment has correct userId",
|
||||
);
|
||||
|
||||
ok(
|
||||
$comment->{visitorIp},
|
||||
"visitorIp is defined since user is visitor",
|
||||
);
|
||||
|
||||
like(
|
||||
$comment->{creationDate}, /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/,
|
||||
"creationDate is defined and is a MySQL-formatted date",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting comment
|
||||
$photo->deleteComment($commentId);
|
||||
ok(
|
||||
!grep { $_ eq $commentId } @{ $photo->getCommentIds },
|
||||
"Photo->getCommentIds no longer contains deleted comment",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting asset deletes comments
|
||||
my $assetId = $photo->getId;
|
||||
$photo->purge;
|
||||
ok(
|
||||
!$session->db->quickScalar("SELECT commentId FROM Photo_comment WHERE assetId=?",[$assetId]),
|
||||
"Comments are purged along with asset",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test appendTemplateVarsForCommentForm
|
||||
TODO: {
|
||||
local $TODO = "Test appendTemplateVarsForCommentForm";
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_addCommentSave page sanity checks
|
||||
my $html;
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
# Permissions
|
||||
$html = WebGUI::Test->getPage($photo, "www_addCommentSave", {
|
||||
userId => 1,
|
||||
formParams => { bodyText => "yes?" },
|
||||
});
|
||||
|
||||
like(
|
||||
$html, qr/permission denied/i,
|
||||
"www_addCommentSave -- Permission denied if not Gallery->canAddComment",
|
||||
);
|
||||
|
||||
# Required fields
|
||||
$html = WebGUI::Test->getPage($photo, "www_addCommentSave", {
|
||||
userId => 2,
|
||||
formParams => { },
|
||||
});
|
||||
|
||||
like(
|
||||
$html, WebGUI::International->get($session, "Asset_Photo", "www_addCommentSave error missing required"),
|
||||
"www_addCommentSave -- Must have bodyText defined",
|
||||
);
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_addCommentSave functionality
|
||||
$html = WebGUI::Test->getPage($photo, "www_addCommentSave", {
|
||||
userId => 2,
|
||||
formParams => { bodyText => "YES!", },
|
||||
});
|
||||
|
||||
like(
|
||||
$html, WebGUI::International->get($session, "Asset_Photo", "www_addCommentSave success"),
|
||||
"www_addCommentSave -- page shows success message",
|
||||
);
|
||||
|
||||
my $ids = $photo->getCommentIds;
|
||||
is(
|
||||
scalar @$ids, 1,
|
||||
"www_addCommentSave -- Comment was added",
|
||||
);
|
||||
53
t/Asset/File/Image/Photo/delete.t
Normal file
53
t/Asset/File/Image/Photo/delete.t
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# The goal of this test is to test the www_delete() and www_deleteConfirm()
|
||||
# methods
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
my $photo
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 0;
|
||||
52
t/Asset/File/Image/Photo/download.t
Normal file
52
t/Asset/File/Image/Photo/download.t
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# The goal of this test is to get sthe getDownloadFileUrl and www_download()
|
||||
# methods
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
my $photo
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 0;
|
||||
107
t/Asset/File/Image/Photo/editSave.t
Normal file
107
t/Asset/File/Image/Photo/editSave.t
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# The goal of this test is to test the editSave,
|
||||
# processPropertiesFromFormPost, and applyConstraints methods.
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
$session->user( { userId => 3 } ); # Admins can do everything
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
});
|
||||
my $photo
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test permissions
|
||||
|
||||
# Edit an existing photo
|
||||
$maker->prepare({
|
||||
object => $photo,
|
||||
method => "www_edit",
|
||||
userId => "1",
|
||||
test_privilege => "insufficient",
|
||||
})->run;
|
||||
|
||||
# Save a new photo
|
||||
$maker->prepare({
|
||||
object => $photo,
|
||||
method => "www_editSave",
|
||||
userId => "1",
|
||||
test_privilege => "insufficient",
|
||||
})->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test processPropertiesFromFormPost errors
|
||||
# TODO: This test should use i18n.
|
||||
# TODO: This error / test should occur in File, not Photo
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_editSave",
|
||||
formParams => {
|
||||
assetId => "new",
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
},
|
||||
test_regex => [
|
||||
qr/You must select a file/,
|
||||
qr/You must enter a title/,
|
||||
],
|
||||
})->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test editSave success result
|
||||
# TODO: This test should use i18n
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_editSave",
|
||||
formParams => {
|
||||
assetId => "new",
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
},
|
||||
test_regex => [
|
||||
qr/awaiting approval and commit/,
|
||||
],
|
||||
})->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
79
t/Asset/File/Image/Photo/exif.t
Normal file
79
t/Asset/File/Image/Photo/exif.t
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the EXIF functionality of WebGUI's photo
|
||||
# asset
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use JSON;
|
||||
use Image::ExifTool;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
});
|
||||
my ( $photo );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test that exif data gets parsed from the file
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
$photo->setFile( WebGUI::Test->getTestCollateralPath("lamp.jpg") );
|
||||
my $exifData = $photo->get("exifData");
|
||||
|
||||
ok( defined $exifData, "exifData column is defined after setFile" );
|
||||
|
||||
my $exif = jsonToObj( $exifData );
|
||||
ok( ref $exif eq "HASH", "exifData is JSON hash" );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test getTemplateVars exif data
|
||||
my $var = $photo->getTemplateVars;
|
||||
|
||||
is_deeply(
|
||||
[ sort keys %$exif ],
|
||||
[ sort map { s/exif_// } keys %$var ],
|
||||
"getTemplateVars gets a hash of all exif tags",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
[ sort keys %$exif ],
|
||||
[ sort map { $_->{tag} } @{ $var->{exifLoop} } ],
|
||||
"getTemplateVars gets a loop over the tags",
|
||||
);
|
||||
203
t/Asset/File/Image/Photo/makeResolutions.t
Normal file
203
t/Asset/File/Image/Photo/makeResolutions.t
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the creation of photo download
|
||||
# resolutions
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
my $graphicsClass;
|
||||
BEGIN {
|
||||
if (eval { require Graphics::Magick; 1 }) {
|
||||
$graphicsClass = 'Graphics::Magick';
|
||||
}
|
||||
elsif (eval { require Image::Magick; 1 }) {
|
||||
$graphicsClass = 'Image::Magick';
|
||||
}
|
||||
}
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
|
||||
my ($gallery, $album, $photo);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Photo not added under a Photo Gallery asset does NOT generate any
|
||||
# default resolutions
|
||||
$photo
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
$photo->getStorageLocation->addFileFromFilesystem( WebGUI::Test->getTestCollateralPath('page_title.jpg') );
|
||||
|
||||
ok(
|
||||
eval{ $photo->makeResolutions(); 1 },
|
||||
"makeResolutions succeeds when photo not under photo gallery and no resolutions to make",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
$photo->getStorageLocation->getFiles, ['page_title.jpg'],
|
||||
"makeResolutions does not make any extra resolutions when photo not under photo gallery",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# makeResolutions allows API to specify resolutions to make as array reference
|
||||
# argument
|
||||
$photo
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
$photo->getStorageLocation->addFileFromFilesystem( WebGUI::Test->getTestCollateralPath('page_title.jpg') );
|
||||
|
||||
ok(
|
||||
!eval{ $photo->makeResolutions('100x100','200x200'); 1 },
|
||||
"makeResolutions fails when first argument is not array reference",
|
||||
);
|
||||
|
||||
ok(
|
||||
eval{ $photo->makeResolutions(['100x100','200x200']); 1 },
|
||||
"makeResolutions succeeds when first argument is array reference of resolutions to make",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
[ sort({ $a cmp $b} @{ $photo->getStorageLocation->getFiles }) ],
|
||||
['100x100.jpg', '200x200.jpg', 'page_title.jpg'],
|
||||
"makeResolutions makes all the required resolutions with the appropriate names.",
|
||||
);
|
||||
|
||||
TODO: {
|
||||
local $TODO = 'Test to ensure the files are created with correct resolution and density';
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# makeResolutions throws a warning on an invalid resolution but keeps going
|
||||
$photo
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
$photo->getStorageLocation->addFileFromFilesystem( WebGUI::Test->getTestCollateralPath('page_title.jpg') );
|
||||
{ # localize our signal handler
|
||||
my @warnings;
|
||||
local $SIG{__WARN__} = sub { push @warnings, $_[0]; };
|
||||
|
||||
ok(
|
||||
eval{ $photo->makeResolutions(['abc','200','3d400']); 1 },
|
||||
"makeResolutions succeeds when invalid resolutions are given",
|
||||
);
|
||||
|
||||
is(
|
||||
scalar @warnings, 2,
|
||||
"makeResolutions throws a warning for each invalid resolution given",
|
||||
);
|
||||
|
||||
like(
|
||||
$warnings[0], qr/abc/,
|
||||
"makeResolutions throws a warning for the correct invalid resolution 'abc'",
|
||||
);
|
||||
|
||||
like(
|
||||
$warnings[1], qr/3d400/,
|
||||
"makeResolutions throws a warning for the correct invalid resolution '3d400'",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
[ sort({ $a cmp $b} @{ $photo->getStorageLocation->getFiles }) ],
|
||||
['200.jpg', 'page_title.jpg'],
|
||||
"makeResolutions still makes valid resolutions when invalid resolutions given",
|
||||
);
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# makeResolutions gets default resolutions from a parent Photo Gallery asset
|
||||
$gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
imageResolutions => "1600x1200\n1024x768\n800x600\n640x480",
|
||||
});
|
||||
$album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
$photo->getStorageLocation->addFileFromFilesystem( WebGUI::Test->getTestCollateralPath('page_title.jpg') );
|
||||
|
||||
ok(
|
||||
eval{ $photo->makeResolutions; 1 },
|
||||
"makeResolutions succeeds when photo under photo gallery and no resolution given",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
[ sort({ $a cmp $b} @{ $photo->getStorageLocation->getFiles }) ],
|
||||
[ '1024x768.jpg', '1600x1200.jpg', '640x480.jpg', '800x600.jpg', 'page_title.jpg' ],
|
||||
"makeResolutions makes all the required resolutions with the appropriate names.",
|
||||
);
|
||||
|
||||
TODO: {
|
||||
local $TODO = 'Test to ensure the files are created with correct resolution and density';
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Array of resolutions passed to makeResolutions overrides defaults from
|
||||
# parent asset
|
||||
$gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
imageResolutions => "1600x1200\n1024x768\n800x600\n640x480",
|
||||
});
|
||||
$album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
$photo->getStorageLocation->addFileFromFilesystem( WebGUI::Test->getTestCollateralPath('page_title.jpg') );
|
||||
|
||||
ok(
|
||||
!eval{ $photo->makeResolutions('100x100','200x200'); 1 },
|
||||
"makeResolutions fails when first argument is not array reference",
|
||||
);
|
||||
|
||||
ok(
|
||||
eval{ $photo->makeResolutions(['100x100','200x200']); 1 },
|
||||
"makeResolutions succeeds when first argument is array reference of resolutions to make",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
[ sort({ $a cmp $b} @{ $photo->getStorageLocation->getFiles }) ],
|
||||
['100x100.jpg', '200x200.jpg', 'page_title.jpg'],
|
||||
"makeResolutions makes all the required resolutions with the appropriate names.",
|
||||
);
|
||||
|
||||
TODO: {
|
||||
local $TODO = 'Test to ensure the files are created with correct resolution and density';
|
||||
}
|
||||
|
||||
123
t/Asset/File/Image/Photo/makeShortcut.t
Normal file
123
t/Asset/File/Image/Photo/makeShortcut.t
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# The goal of this test is to test the makeShortcut method and www_makeShortcut
|
||||
# pages
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $otherParent
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Layout",
|
||||
});
|
||||
my $photo
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
userDefined1 => "ORIGINAL",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 0;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# makeShortcut argument checking
|
||||
ok(
|
||||
!eval{ $photo->makeShortcut(); 1 },
|
||||
"Photo->makeShortcut requires at least one argument",
|
||||
);
|
||||
|
||||
ok(
|
||||
!eval{ $photo->makeShortcut("", ""); 1},
|
||||
"Photo->makeShortcut fails if second argument is not hash reference",
|
||||
);
|
||||
|
||||
ok(
|
||||
!eval{ $photo->makeShortcut(""); 1},
|
||||
"Photo->makeShortcut fails if given parent cannot be instanciated",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# makeShortcut returns a reference to the new Shortcut asset
|
||||
my $shortcut;
|
||||
ok(
|
||||
eval{ $shortcut = $photo->makeShortcut($otherParent->getId); 1},
|
||||
"Photo->makeShortcut succeeds when valid assetId is given",
|
||||
);
|
||||
|
||||
is(
|
||||
blessed $shortcut, "WebGUI::Asset::Shortcut",
|
||||
"Photo->makeShortcut returns a WebGUI::Shortcut asset",
|
||||
);
|
||||
|
||||
is(
|
||||
$shortcut->getShortcutOriginal->getId, $photo->getId,
|
||||
"Photo->makeShortcut makes a shortcut to the correct asset",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# makeShortcut creates the appropriate overrides
|
||||
my $overrides = {
|
||||
userDefined1 => "OVERRIDDEN",
|
||||
};
|
||||
ok(
|
||||
eval{ $shortcut = $photo->makeShortcut($otherParent->getId, $overrides); 1},
|
||||
"Photo->makeShortcut succeeds when valid assetId is given",
|
||||
);
|
||||
|
||||
is(
|
||||
blessed $shortcut, "WebGUI::Asset::Shortcut",
|
||||
"Photo->makeShortcut returns a WebGUI::Shortcut asset",
|
||||
);
|
||||
|
||||
is(
|
||||
$shortcut->getShortcutOriginal->getId, $photo->getId,
|
||||
"Photo->makeShortcut makes a shortcut to the correct asset",
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
{$shortcut->getShortcutOverrides}, $overrides,
|
||||
"Photo->makeShortcut makes a shortcut with the correct overrides",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# www_makeShortcut is only available to those who can edit the photo
|
||||
$maker->prepare({
|
||||
object => $photo,
|
||||
method => "www_makeShortcut",
|
||||
userId => 1,
|
||||
test_privilege => "insufficient",
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# www_makeShortcut
|
||||
135
t/Asset/File/Image/Photo/permissions.t
Normal file
135
t/Asset/File/Image/Photo/permissions.t
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# Test permissions of Photo assets
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Friends;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my ($photo);
|
||||
$session->user({ userId => 3 });
|
||||
|
||||
my $friend = WebGUI::User->new($session, "new");
|
||||
WebGUI::Friends->new($session)->add( [ $friend->userId ] );
|
||||
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdView => "7",
|
||||
groupIdEdit => "3",
|
||||
ownerUserId => $session->user->userId,
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
groupIdView => "",
|
||||
groupIdEdit => "",
|
||||
ownerUserId => $session->user->userId,
|
||||
});
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
WebGUI::Friends->new($session)->delete( [ $friend->userId ] );
|
||||
$friend->delete;
|
||||
$versionTag->rollback;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Everyone can view, Admins can edit, Owned by current user
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
groupIdView => "7",
|
||||
groupIdEdit => "3",
|
||||
ownerUserId => $session->user->userId,
|
||||
});
|
||||
|
||||
ok( $photo->canView(1), "Visitor can view" );
|
||||
ok( !$photo->canEdit(1), "Visitor cannot edit" );
|
||||
ok( $photo->canView(2), "Registered users can view" );
|
||||
ok( !$photo->canEdit(2), "Registered users cannot edit" );
|
||||
ok( $photo->canView, "Current user can view" );
|
||||
ok( $photo->canEdit, "Current user can edit" );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Admins can view, Admins can edit, Owned by Admin, current user is Visitor
|
||||
my $oldUser = $session->user;
|
||||
$session->user( { user => WebGUI::User->new($session, "1") } );
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
groupIdView => "3",
|
||||
groupIdEdit => "3",
|
||||
ownerUserId => "3",
|
||||
});
|
||||
|
||||
ok( !$photo->canView, "Visitors cannot view" );
|
||||
ok( !$photo->canEdit, "Visitors cannot edit" );
|
||||
ok( !$photo->canView(2), "Registered Users cannot view" );
|
||||
ok( !$photo->canEdit(2), "Registered Users cannot edit" );
|
||||
ok( $photo->canView(3), "Admins can view" );
|
||||
ok( $photo->canEdit(3), "Admins can edit" );
|
||||
$session->user( { user => $oldUser } );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Photo without specific view/edit inherits from gallery properties
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
groupIdView => "",
|
||||
groupIdEdit => "",
|
||||
ownerUserId => $session->user->userId,
|
||||
});
|
||||
|
||||
ok( $photo->canView(1), "Visitors can view" );
|
||||
ok( !$photo->canEdit(1), "Visitors cannot edit" );
|
||||
ok( $photo->canView(2), "Registered Users can view" );
|
||||
ok( !$photo->canEdit(2), "Registered Users cannot edit" );
|
||||
ok( $photo->canView, "Owner can view" );
|
||||
ok( $photo->canEdit, "Owner can edit" );
|
||||
ok( $photo->canView(3), "Admin can view" );
|
||||
ok( $photo->canEdit(3), "Admin can edit" );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Friends are allowed to view friendsOnly photos
|
||||
$photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
groupIdEdit => "",
|
||||
ownerUserId => $session->user->userId,
|
||||
});
|
||||
|
||||
ok( !$photo->canView(1), "Visitors cannot view" );
|
||||
ok( !$photo->canEdit(1), "Visitors cannot edit" );
|
||||
ok( !$photo->canView(2), "Registered Users cannot view" );
|
||||
ok( !$photo->canEdit(2), "Registered Users cannot edit" );
|
||||
ok( $photo->canView, "Owner can view" );
|
||||
ok( $photo->canEdit, "Owner can edit" );
|
||||
ok( $photo->canView(3), "Admin can view" );
|
||||
ok( $photo->canEdit(3), "Admin can edit" );
|
||||
68
t/Asset/File/Image/Photo/setFile.t
Normal file
68
t/Asset/File/Image/Photo/setFile.t
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the creation and deletion of photo assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
imageResolutions => "1024x768",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
my $photo
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 2;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# setFile also makes download versions
|
||||
$photo->setFile( WebGUI::Test->getTestCollateralPath('page_title.jpg') );
|
||||
my $storage = $photo->getStorageLocation;
|
||||
|
||||
is_deeply(
|
||||
$storage->getFiles, ['page_title.jpg'],
|
||||
"Storage location contains only the file we added",
|
||||
);
|
||||
|
||||
ok(
|
||||
-e $storage->getPath($gallery->get('imageResolutions') . '.jpg'),
|
||||
"Generated resolution file exists on the filesystem",
|
||||
);
|
||||
|
||||
|
||||
53
t/Asset/File/Image/Photo/view.t
Normal file
53
t/Asset/File/Image/Photo/view.t
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# The goal of this test is to test the view and getTemplateVars methods
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
use WebGUI::Asset::File::Image::Photo;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Photo Test"});
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoGallery",
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::PhotoAlbum",
|
||||
});
|
||||
my $photo
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
});
|
||||
$photo->setFile( WebGUI::Test->getCollateralPath('page_title.jpg') );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 0;
|
||||
62
t/Asset/File/Image/setfile.t
Normal file
62
t/Asset/File/Image/setfile.t
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../lib";
|
||||
|
||||
## The goal of this test is to test the additional functionality of the
|
||||
# overridden setFile method
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::File::Image;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Image Test"});
|
||||
my $image
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::File::Image",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 2;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# setFile allows file path argument and adds the file
|
||||
# setFile also generates thumbnail
|
||||
# plan tests => 2
|
||||
$image->setFile( WebGUI::Test->getTestCollateralPath("page_title.jpg") );
|
||||
my $storage = $image->getStorageLocation;
|
||||
|
||||
is_deeply(
|
||||
$storage->getFiles, ['page_title.jpg'],
|
||||
"Storage location contains only the file we added",
|
||||
);
|
||||
|
||||
# We must do a filesystem test because getFiles doesn't include 'thumb-'
|
||||
ok(
|
||||
-e $storage->getPath('thumb-page_title.jpg'),
|
||||
"Thumbnail file exists on the filesystem",
|
||||
);
|
||||
|
||||
63
t/Asset/File/setfile.t
Normal file
63
t/Asset/File/setfile.t
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../lib";
|
||||
|
||||
## The goal of this test is to test the creation and deletion of photo assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::File;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"File Test"});
|
||||
my $file
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::File",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 2;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# setFile allows file path argument and fails if can't find file
|
||||
# plan tests => 1
|
||||
ok(
|
||||
!eval { $file->setFile( WebGUI::Test->getTestCollateralPath("DOES_NOT_EXIST.NO") ); 1},
|
||||
"setFile allows file path argument and croaks if can't find file"
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# setFile allows file path argument and adds the file
|
||||
# plan tests => 1
|
||||
$file->setFile( WebGUI::Test->getTestCollateralPath("WebGUI.pm") );
|
||||
my $storage = $file->getStorageLocation;
|
||||
|
||||
is_deeply(
|
||||
$storage->getFiles, ['WebGUI.pm'],
|
||||
"Storage location contains only the file we added",
|
||||
);
|
||||
|
||||
|
||||
74
t/Asset/Shortcut/000-create-delete.t
Normal file
74
t/Asset/Shortcut/000-create-delete.t
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../lib";
|
||||
|
||||
## The goal of this test is to test the creation and deletion of shortcut assets
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::Snippet;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Shortcut Test"});
|
||||
|
||||
# Make a snippet to shortcut
|
||||
my $snippet
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Snippet",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 3;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test module compiles okay
|
||||
# plan tests => 1
|
||||
use_ok("WebGUI::Asset::Shortcut");
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test creating a shortcut to snippet
|
||||
# plan tests => 2
|
||||
my $shortcut
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Shortcut",
|
||||
shortcutToAssetId => $snippet->getId,
|
||||
});
|
||||
|
||||
isa_ok(
|
||||
$shortcut, "WebGUI::Asset::Shortcut",
|
||||
);
|
||||
|
||||
isa_ok(
|
||||
$shortcut, "WebGUI::Asset",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting a shortcut
|
||||
# plan tests =>
|
||||
TODO: {
|
||||
local $TODO = "Test deleting a shortcut.";
|
||||
}
|
||||
|
||||
|
||||
126
t/Asset/Shortcut/010-linked-asset.t
Normal file
126
t/Asset/Shortcut/010-linked-asset.t
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../lib";
|
||||
|
||||
## The goal of this test is to test the link between the asset and its shortcut
|
||||
# and that changes to the asset are propagated to the shortcut
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::Shortcut;
|
||||
use WebGUI::Asset::Snippet;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Shortcut Test"});
|
||||
|
||||
# Make a snippet to shortcut
|
||||
my $snippet
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Snippet",
|
||||
});
|
||||
|
||||
my $shortcut
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Shortcut",
|
||||
shortcutToAssetId => $snippet->getId,
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 10;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test shortcut's link to original asset
|
||||
# plan => 3
|
||||
my $original = $shortcut->getShortcut;
|
||||
|
||||
ok(
|
||||
defined $original,
|
||||
"Original asset is defined",
|
||||
);
|
||||
|
||||
is(
|
||||
blessed $original, blessed $snippet,
|
||||
"Original asset class is correct",
|
||||
);
|
||||
|
||||
is(
|
||||
$original->getId, $snippet->getId,
|
||||
"Original assetId is correct"
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test trashing snippet trashes shortcut also
|
||||
# plan tests => 3
|
||||
$snippet->trash;
|
||||
$shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
||||
|
||||
ok(
|
||||
defined $shortcut,
|
||||
"Trash Linked Asset: Shortcut is defined",
|
||||
);
|
||||
|
||||
like(
|
||||
$shortcut->get("state"), qr/^trash/,
|
||||
"Trash Linked Asset: Shortcut state is trash",
|
||||
);
|
||||
|
||||
ok(
|
||||
grep({ $_->getId eq $shortcut->getId } @{ $snippet->getAssetsInTrash }),
|
||||
"Trash Linked Asset: Shortcut is in trash",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test restoring snippet restores shortcut also
|
||||
# plan tests => 3
|
||||
$snippet->publish;
|
||||
$shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
||||
|
||||
ok(
|
||||
defined $shortcut,
|
||||
"Restore Linked Asset: Shortcut is defined",
|
||||
);
|
||||
|
||||
ok(
|
||||
!grep({ $_->getId eq $shortcut->getId } @{ $snippet->getAssetsInTrash }),
|
||||
"Restore Linked Asset: Shortcut is not in trash",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test purging snippet purges shortcut also
|
||||
# plan tests => 2
|
||||
$snippet->purge;
|
||||
$shortcut = WebGUI::Asset->newByDynamicClass($session, $shortcut->getId);
|
||||
|
||||
ok(
|
||||
!defined $shortcut,
|
||||
"Purge Linked Asset: Shortcut is not defined",
|
||||
);
|
||||
|
||||
ok(
|
||||
!grep({ $_->getId eq $shortcut->getId } @{ $snippet->getAssetsInTrash }),
|
||||
"Purge Linked Asset: Shortcut is not in trash",
|
||||
);
|
||||
78
t/Asset/Wobject/Gallery/00base.t
Normal file
78
t/Asset/Wobject/Gallery/00base.t
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the creation and deletion of album assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 5;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test module compiles okay
|
||||
# plan tests => 1
|
||||
use_ok("WebGUI::Asset::Wobject::GalleryAlbum");
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test creating an album
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
});
|
||||
|
||||
is(
|
||||
blessed $album, "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
"Album is a WebGUI::Asset::Wobject::GalleryAlbum object",
|
||||
);
|
||||
|
||||
isa_ok(
|
||||
$album, "WebGUI::Asset::Wobject",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting a album
|
||||
my $properties = $album->get;
|
||||
$album->purge;
|
||||
|
||||
is(
|
||||
$album, undef,
|
||||
"Album is undefined",
|
||||
);
|
||||
|
||||
is(
|
||||
WebGUI::Asset->newByDynamicClass($session, $properties->{assetId}), undef,
|
||||
"Album no longer able to be instanciated",
|
||||
);
|
||||
|
||||
96
t/Asset/Wobject/Gallery/delete.t
Normal file
96
t/Asset/Wobject/Gallery/delete.t
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
# $vim: syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the deleting of GalleryAlbums
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::Html->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Delete page gives error for those who can't edit the GalleryAlbum
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_delete",
|
||||
test_privilege => "insufficient",
|
||||
userId => 1,
|
||||
}, {
|
||||
object => $album,
|
||||
method => "www_deleteConfirm",
|
||||
test_privilege => "insufficient",
|
||||
userId => 1,
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Delete confirm page appears for those allowed to edit the GalleryAlbum
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_delete",
|
||||
test_regex => [ qr/func=deleteConfirm/, ],
|
||||
userId => 3,
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# www_deleteConfirm deletes the asset
|
||||
my $assetId = $album->getId;
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_deleteConfirm",
|
||||
test_regex => [ qr/has been deleted/, ],
|
||||
userId => 3,
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
is(
|
||||
WebGUI::Asset->newByDynamicClass( $session, $assetId ),
|
||||
undef,
|
||||
"GalleryAlbum cannot be instanciated after www_deleteConfirm",
|
||||
);
|
||||
|
||||
78
t/Asset/Wobject/Gallery/listFilesForUser.t
Normal file
78
t/Asset/Wobject/Gallery/listFilesForUser.t
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the creation and deletion of album assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 5;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test module compiles okay
|
||||
# plan tests => 1
|
||||
use_ok("WebGUI::Asset::Wobject::GalleryAlbum");
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test creating an album
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
});
|
||||
|
||||
is(
|
||||
blessed $album, "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
"Album is a WebGUI::Asset::Wobject::GalleryAlbum object",
|
||||
);
|
||||
|
||||
isa_ok(
|
||||
$album, "WebGUI::Asset::Wobject",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting a album
|
||||
my $properties = $album->get;
|
||||
$album->purge;
|
||||
|
||||
is(
|
||||
$album, undef,
|
||||
"Album is undefined",
|
||||
);
|
||||
|
||||
is(
|
||||
WebGUI::Asset->newByDynamicClass($session, $properties->{assetId}), undef,
|
||||
"Album no longer able to be instanciated",
|
||||
);
|
||||
|
||||
107
t/Asset/Wobject/Gallery/permission.t
Normal file
107
t/Asset/Wobject/Gallery/permission.t
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the permissions of GalleryAlbum assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::Permission;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::Permission->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
|
||||
my %user;
|
||||
$user{"2"} = WebGUI::User->new( $session, "new" );
|
||||
$user{"2"}->addToGroups( ['2'] ); # Registered user
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
$user{"2"}->delete;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# By default, GalleryAlbum inherits its permissions from the Gallery, but
|
||||
# only the owner of the GalleryAlbum is allowed to add files
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "canView",
|
||||
pass => [ 1, 3, $user{"2"}, ],
|
||||
}, {
|
||||
object => $album,
|
||||
method => "canEdit",
|
||||
pass => [ 3, ],
|
||||
fail => [ 1, $user{"2"}, ],
|
||||
}, {
|
||||
object => $album,
|
||||
method => "canAddFile",
|
||||
pass => [ 3, ],
|
||||
fail => [ 1, $user{"2"}, ],
|
||||
}, {
|
||||
object => $album,
|
||||
method => "canAddComment",
|
||||
pass => [ 3, $user{"2"}, ],
|
||||
fail => [ 1, ],
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# GalleryAlbums with "allowComments" false do not allow anyone to comment
|
||||
$album->update({ allowComments => 0 });
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "canComment",
|
||||
fail => [ 1, 3, $user{"2"}, ],
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# GalleryAlbum with "othersCanAdd" true allows anyone who can add files to
|
||||
# the Gallery to add files to this GalleryAlbum
|
||||
$album->update({ othersCanAdd => 1 });
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "canAddFile",
|
||||
pass => [ 3, $user{"2"}, ],
|
||||
fail => [ 1, ],
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
66
t/Asset/Wobject/Gallery/rss.t
Normal file
66
t/Asset/Wobject/Gallery/rss.t
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# $vim: syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the rss view of GalleryAlbums
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
my @photos;
|
||||
for my $i ( 0 .. 5 ) {
|
||||
$photos[ $i ]
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
filename => "$i.jpg",
|
||||
});
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_viewRss
|
||||
|
||||
78
t/Asset/Wobject/Gallery/search.t
Normal file
78
t/Asset/Wobject/Gallery/search.t
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the creation and deletion of album assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 5;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test module compiles okay
|
||||
# plan tests => 1
|
||||
use_ok("WebGUI::Asset::Wobject::GalleryAlbum");
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test creating an album
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
});
|
||||
|
||||
is(
|
||||
blessed $album, "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
"Album is a WebGUI::Asset::Wobject::GalleryAlbum object",
|
||||
);
|
||||
|
||||
isa_ok(
|
||||
$album, "WebGUI::Asset::Wobject",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting a album
|
||||
my $properties = $album->get;
|
||||
$album->purge;
|
||||
|
||||
is(
|
||||
$album, undef,
|
||||
"Album is undefined",
|
||||
);
|
||||
|
||||
is(
|
||||
WebGUI::Asset->newByDynamicClass($session, $properties->{assetId}), undef,
|
||||
"Album no longer able to be instanciated",
|
||||
);
|
||||
|
||||
130
t/Asset/Wobject/Gallery/view.t
Normal file
130
t/Asset/Wobject/Gallery/view.t
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
# $vim: syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../lib";
|
||||
|
||||
## The goal of this test is to test the default view and associated subs
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 2, # Registered Users
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
my @photos;
|
||||
for my $i ( 0 .. 5 ) {
|
||||
$photos[ $i ]
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
filename => "$i.jpg",
|
||||
});
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test getFileIds and getFilePaginator
|
||||
cmp_bag( $album->getFileIds, [ map { $_->getId } @photos ] );
|
||||
|
||||
my $p = $album->getFilePaginator;
|
||||
isa_ok( $p, "WebGUI::Paginator" );
|
||||
cmp_deeply( $p->getPageData, subbagof( map { $_->getId } @photos ) );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test getTemplateVars
|
||||
|
||||
# Is a superset of Asset->get
|
||||
# NOTE: url is Asset->getUrl
|
||||
cmp_deeply( $album->getTemplateVars, superhashof( { %{$album->get}, url => $album->getUrl, } ) );
|
||||
|
||||
# Contains specific keys/values
|
||||
my $expected = {
|
||||
"url_addPhoto"
|
||||
=> all(
|
||||
re( qr/className=WebGUI::Asset::File::Image::Photo/ ),
|
||||
re( qr/func=add/ ),
|
||||
re( $album->getUrl ),
|
||||
),
|
||||
"url_addNoClass"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=add$/ ),
|
||||
),
|
||||
"url_slideshow"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=slideshow/ ),
|
||||
),
|
||||
"url_thumbnails"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=thumbnails/ ),
|
||||
),
|
||||
"url_viewRss"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=viewRss/ ),
|
||||
),
|
||||
};
|
||||
|
||||
cmp_deeply( $album->getTemplateVars, superhashof( $expected ) );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test appendTemplateVarsFileLoop
|
||||
$expected = {
|
||||
"file_loop" => bag( map { $_->getTemplateVars } @photos ),
|
||||
};
|
||||
cmp_deeply(
|
||||
$album->appendTemplateVarsFileLoop({},$self->getFilePaginator->getPageData),
|
||||
$expected
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_view() for those without permission to view
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_view",
|
||||
test_privilege => "insufficient",
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
78
t/Asset/Wobject/GalleryAlbum/00base.t
Normal file
78
t/Asset/Wobject/GalleryAlbum/00base.t
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the creation and deletion of album assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 5;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test module compiles okay
|
||||
# plan tests => 1
|
||||
use_ok("WebGUI::Asset::Wobject::GalleryAlbum");
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test creating an album
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
});
|
||||
|
||||
is(
|
||||
blessed $album, "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
"Album is a WebGUI::Asset::Wobject::GalleryAlbum object",
|
||||
);
|
||||
|
||||
isa_ok(
|
||||
$album, "WebGUI::Asset::Wobject",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test deleting a album
|
||||
my $properties = $album->get;
|
||||
$album->purge;
|
||||
|
||||
is(
|
||||
$album, undef,
|
||||
"Album is undefined",
|
||||
);
|
||||
|
||||
is(
|
||||
WebGUI::Asset->newByDynamicClass($session, $properties->{assetId}), undef,
|
||||
"Album no longer able to be instanciated",
|
||||
);
|
||||
|
||||
69
t/Asset/Wobject/GalleryAlbum/addArchive.t
Normal file
69
t/Asset/Wobject/GalleryAlbum/addArchive.t
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
# $vim: syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the permissions of GalleryAlbum assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::Permission;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::Permission->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 2;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test the addArchive sub
|
||||
# elephant_images.zip contains three jpgs: Aana1.jpg, Aana2.jpg, Aana3.jpg
|
||||
$album->addArchive( WebGUI::Test->getTestCollateralPath('elephant_images.zip') );
|
||||
my $images = $album->getLineage(['descendants'], { returnObjects => 1 });
|
||||
|
||||
is( scalar @$images, 3, "addArchive() adds one asset per image" );
|
||||
cmp_deeply(
|
||||
[ map { $_->get("filename") } @$images ],
|
||||
bag( "Aana1.jpg", "Aana2.jpg", "Aana3.jpg" ),
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test the www_addArchive page
|
||||
96
t/Asset/Wobject/GalleryAlbum/delete.t
Normal file
96
t/Asset/Wobject/GalleryAlbum/delete.t
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
# $vim: syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the deleting of GalleryAlbums
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::Html->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Delete page gives error for those who can't edit the GalleryAlbum
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_delete",
|
||||
test_privilege => "insufficient",
|
||||
userId => 1,
|
||||
}, {
|
||||
object => $album,
|
||||
method => "www_deleteConfirm",
|
||||
test_privilege => "insufficient",
|
||||
userId => 1,
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Delete confirm page appears for those allowed to edit the GalleryAlbum
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_delete",
|
||||
test_regex => [ qr/func=deleteConfirm/, ],
|
||||
userId => 3,
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# www_deleteConfirm deletes the asset
|
||||
my $assetId = $album->getId;
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_deleteConfirm",
|
||||
test_regex => [ qr/has been deleted/, ],
|
||||
userId => 3,
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
is(
|
||||
WebGUI::Asset->newByDynamicClass( $session, $assetId ),
|
||||
undef,
|
||||
"GalleryAlbum cannot be instanciated after www_deleteConfirm",
|
||||
);
|
||||
|
||||
107
t/Asset/Wobject/GalleryAlbum/permission.t
Normal file
107
t/Asset/Wobject/GalleryAlbum/permission.t
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the permissions of GalleryAlbum assets
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::Permission;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::Permission->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
|
||||
my %user;
|
||||
$user{"2"} = WebGUI::User->new( $session, "new" );
|
||||
$user{"2"}->addToGroups( ['2'] ); # Registered user
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
$user{"2"}->delete;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# By default, GalleryAlbum inherits its permissions from the Gallery, but
|
||||
# only the owner of the GalleryAlbum is allowed to add files
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "canView",
|
||||
pass => [ 1, 3, $user{"2"}, ],
|
||||
}, {
|
||||
object => $album,
|
||||
method => "canEdit",
|
||||
pass => [ 3, ],
|
||||
fail => [ 1, $user{"2"}, ],
|
||||
}, {
|
||||
object => $album,
|
||||
method => "canAddFile",
|
||||
pass => [ 3, ],
|
||||
fail => [ 1, $user{"2"}, ],
|
||||
}, {
|
||||
object => $album,
|
||||
method => "canAddComment",
|
||||
pass => [ 3, $user{"2"}, ],
|
||||
fail => [ 1, ],
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# GalleryAlbums with "allowComments" false do not allow anyone to comment
|
||||
$album->update({ allowComments => 0 });
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "canComment",
|
||||
fail => [ 1, 3, $user{"2"}, ],
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# GalleryAlbum with "othersCanAdd" true allows anyone who can add files to
|
||||
# the Gallery to add files to this GalleryAlbum
|
||||
$album->update({ othersCanAdd => 1 });
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "canAddFile",
|
||||
pass => [ 3, $user{"2"}, ],
|
||||
fail => [ 1, ],
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
66
t/Asset/Wobject/GalleryAlbum/rss.t
Normal file
66
t/Asset/Wobject/GalleryAlbum/rss.t
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# $vim: syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the rss view of GalleryAlbums
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
my @photos;
|
||||
for my $i ( 0 .. 5 ) {
|
||||
$photos[ $i ]
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
filename => "$i.jpg",
|
||||
});
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_viewRss
|
||||
|
||||
69
t/Asset/Wobject/GalleryAlbum/slideshow.t
Normal file
69
t/Asset/Wobject/GalleryAlbum/slideshow.t
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
# $vim: syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the slideshow view of GalleryAlbums
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
my @photos;
|
||||
for my $i ( 0 .. 5 ) {
|
||||
$photos[ $i ]
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
filename => "$i.jpg",
|
||||
});
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test view_slideshow
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_slideshow
|
||||
|
||||
69
t/Asset/Wobject/GalleryAlbum/thumbnails.t
Normal file
69
t/Asset/Wobject/GalleryAlbum/thumbnails.t
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
# $vim: syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../../lib";
|
||||
|
||||
## The goal of this test is to test the thumbnails view of GalleryAlbums
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 7, # Everyone
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
my @photos;
|
||||
for my $i ( 0 .. 5 ) {
|
||||
$photos[ $i ]
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
filename => "$i.jpg",
|
||||
});
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test view_thumbnails
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_thumbnails
|
||||
|
||||
132
t/Asset/Wobject/GalleryAlbum/view.t
Normal file
132
t/Asset/Wobject/GalleryAlbum/view.t
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
# $vim: syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../lib";
|
||||
|
||||
## The goal of this test is to test the default view and associated subs
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test::Maker::HTML;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $maker = WebGUI::Test::Maker::HTML->new;
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Album Test"});
|
||||
my $gallery
|
||||
= $node->addChild({
|
||||
className => "WebGUI::Asset::Wobject::Gallery",
|
||||
groupIdAddComment => 2, # Registered Users
|
||||
groupIdAddFile => 2, # Registered Users
|
||||
groupIdView => 2, # Registered Users
|
||||
groupIdEdit => 3, # Admins
|
||||
ownerUserId => 3, # Admin
|
||||
});
|
||||
my $album
|
||||
= $gallery->addChild({
|
||||
className => "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||
ownerUserId => "3", # Admin
|
||||
});
|
||||
my @photos;
|
||||
for my $i ( 0 .. 5 ) {
|
||||
$photos[ $i ]
|
||||
= $album->addChild({
|
||||
className => "WebGUI::Asset::File::Image::Photo",
|
||||
filename => "$i.jpg",
|
||||
});
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan no_plan => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test getFileIds and getFilePaginator
|
||||
cmp_bag( $album->getFileIds, [ map { $_->getId } @photos ] );
|
||||
|
||||
my $p = $album->getFilePaginator;
|
||||
isa_ok( $p, "WebGUI::Paginator" );
|
||||
cmp_deeply( $p->getPageData, subbagof( map { $_->getId } @photos ) );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test getTemplateVars
|
||||
|
||||
# Is a superset of Asset->get
|
||||
# NOTE: url is Asset->getUrl
|
||||
cmp_deeply( $album->getTemplateVars, superhashof( { %{$album->get}, url => $album->getUrl, } ) );
|
||||
|
||||
# Contains specific keys/values
|
||||
my $expected = {
|
||||
"url_addPhoto"
|
||||
=> all(
|
||||
re( qr/className=WebGUI::Asset::File::Image::Photo/ ),
|
||||
re( qr/func=add/ ),
|
||||
re( $album->getUrl ),
|
||||
),
|
||||
"url_addNoClass"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=add$/ ),
|
||||
),
|
||||
"url_slideshow"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=slideshow/ ),
|
||||
),
|
||||
"url_thumbnails"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=thumbnails/ ),
|
||||
),
|
||||
"url_viewRss"
|
||||
=> all(
|
||||
re( $album->getUrl ),
|
||||
re( qr/func=viewRss/ ),
|
||||
),
|
||||
"ownerUsername"
|
||||
=> WebGUI::User->new($session, 3)->username,
|
||||
};
|
||||
|
||||
cmp_deeply( $album->getTemplateVars, superhashof( $expected ) );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test appendTemplateVarsFileLoop
|
||||
$expected = {
|
||||
"file_loop" => bag( map { $_->getTemplateVars } @photos ),
|
||||
};
|
||||
cmp_deeply(
|
||||
$album->appendTemplateVarsFileLoop({},$self->getFilePaginator->getPageData),
|
||||
$expected
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test www_view() for those without permission to view
|
||||
$maker->prepare({
|
||||
object => $album,
|
||||
method => "www_view",
|
||||
test_privilege => "insufficient",
|
||||
});
|
||||
$maker->run;
|
||||
|
||||
104
t/Form.t
Normal file
104
t/Form.t
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 5; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test the formHeader method
|
||||
|
||||
ok(
|
||||
!eval{ WebGUI::Form::formHeader( "" ); 1 },
|
||||
"formHeader() dies if first parameter is not WebGUI Session",
|
||||
);
|
||||
|
||||
ok(
|
||||
!eval{ WebGUI::Form::formHeader( $session, ['foo'] ); 1 },
|
||||
"formHeader() dies if second parameter is not hash reference",
|
||||
);
|
||||
|
||||
# Test the defaults for formHeader()
|
||||
my $testDefaults = all(
|
||||
re( q{<form[^>]*>} ),
|
||||
re( q{action=} ),
|
||||
re( q{enctype="multipart/form-data"} ),
|
||||
re( q{method="post"} ),
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
WebGUI::Form::formHeader( $session ),
|
||||
$testDefaults,
|
||||
"formHeader called without an options hashref",
|
||||
);
|
||||
|
||||
# Test options passed into formHeader()
|
||||
my $testWithOptions = all(
|
||||
re( q{<form[^>]*>} ),
|
||||
re( q{action="action"} ),
|
||||
re( q{enctype="enctype"} ),
|
||||
re( q{method="method"} ),
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
WebGUI::Form::formHeader( $session, {
|
||||
action => "action",
|
||||
enctype => "enctype",
|
||||
method => "method",
|
||||
} ),
|
||||
$testWithOptions,
|
||||
"formHeader called with an options hashref",
|
||||
);
|
||||
|
||||
# Test "action" option containing query parameters
|
||||
my $testHiddenElements = all(
|
||||
re( q{<input type="hidden" name="func" value="edit"} ),
|
||||
re( q{<input type="hidden" name="a" value="1"} ),
|
||||
re( q{<input type="hidden" name="b" value="2"} ),
|
||||
);
|
||||
|
||||
cmp_deeply(
|
||||
WebGUI::Form::formHeader( $session, {
|
||||
action => "action?func=edit;a=1&b=2",
|
||||
}),
|
||||
$testHiddenElements,
|
||||
"formHeader 'action' option containing query parameters",
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Some things on the TODO list";
|
||||
# Test the formFooter method
|
||||
# Test that the autohandler works properly
|
||||
}
|
||||
59
t/Form/SelectRichEditor.t
Normal file
59
t/Form/SelectRichEditor.t
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
# $vim: syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2007 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
## The goal of this test is to test the SelectRichEditor form control
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
|
||||
use WebGUI::Form::SelectRichEditor;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $root = WebGUI::Asset->getRoot( $session );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 1;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test that SelectRichEditor control contains all RichEdit assets.
|
||||
my $richEditAssets
|
||||
= $root->getLineage( ['descendants'], {
|
||||
returnObjects => 1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::RichEdit'],
|
||||
});
|
||||
my $richEditOptions
|
||||
= {
|
||||
map { $_->getId => $_->get("title") } @$richEditAssets
|
||||
};
|
||||
|
||||
my $control
|
||||
= WebGUI::Form::SelectRichEditor->new( $session, { name => "richEditId" } );
|
||||
cmp_deeply(
|
||||
$control->get("options"),
|
||||
$richEditOptions,
|
||||
"SelectRichEditor control has options for all Rich Editors in this site",
|
||||
);
|
||||
10
t/Storage.t
10
t/Storage.t
|
|
@ -203,6 +203,16 @@ ok (-e $storage1->getPath("testfile-hash.file"), 'addFileFromHashRef creates fil
|
|||
my $thawedHash = $storage1->getFileContentsAsHashref('testfile-hash.file');
|
||||
cmp_deeply($storageHash, $thawedHash, 'getFileContentsAsHashref: thawed hash correctly');
|
||||
|
||||
####################################################
|
||||
#
|
||||
# copyFile
|
||||
#
|
||||
####################################################
|
||||
|
||||
$storage1->copyFile("testfile-hash.file", "testfile-hash-copied.file");
|
||||
ok (-e $storage1->getPath("testfile-hash-copied.file"),'copyFile created file with new name');
|
||||
ok (-e $storage1->getPath("testfile-hash.file"), "copyFile original file still exists");
|
||||
|
||||
####################################################
|
||||
#
|
||||
# renameFile
|
||||
|
|
|
|||
|
|
@ -1,24 +1,40 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2006 Plain Black Corporation.
|
||||
# WebGUI is Copyright 2001-2007 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
|
||||
#-------------------------------------------------------------------
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/lib";
|
||||
use WebGUI::Test;
|
||||
use Test::More;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Test;
|
||||
|
||||
# load your modules here
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
use Test::More tests => 1; # increment this value for each test you create
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 1; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use Config qw[];
|
|||
use IO::Handle qw[];
|
||||
use File::Spec qw[];
|
||||
use Test::MockObject::Extends;
|
||||
use WebGUI::PseudoRequest;
|
||||
|
||||
##Hack to get ALL test output onto STDOUT.
|
||||
use Test::Builder;
|
||||
|
|
@ -136,7 +137,8 @@ of options with keys outlined below.
|
|||
=cut
|
||||
|
||||
sub getPage {
|
||||
my $session = shift; # The session object
|
||||
my $class = shift;
|
||||
my $session = $SESSION; # The session object
|
||||
my $asset = shift; # The asset object
|
||||
my $page = shift; # The page subroutine
|
||||
my $optionsRef = shift; # A hashref of options
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package WebGUI::Test::Maker::HTML;
|
|||
|
||||
use base 'WebGUI::Test::Maker';
|
||||
use Scalar::Util qw( blessed );
|
||||
use Carp qw( croak );
|
||||
use Test::More;
|
||||
|
||||
|
||||
|
|
@ -72,6 +73,8 @@ Create a new WebGUI::Test::Maker::HTML object.
|
|||
|
||||
Get a setting. Set L<set> for a list of settings.
|
||||
|
||||
=cut
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 plan
|
||||
|
|
@ -187,7 +190,7 @@ sub prepare {
|
|||
croak("Couldn't prepare: Test $test_num, test_regex is not an array reference")
|
||||
if $test->{test_regex} && ref $test->{test_regex} ne "ARRAY";
|
||||
croak("Couldn't prepare: Test $test_num, $test->{test_privilege} is not a valid test_privilege value (adminOnly, insufficient, noAccess, notMember, vitalComponent)")
|
||||
if $test->{test_privilege} && $test->{test_privilege} =~ m/adminOnly|insufficient|noAccess|notMember|vitalComponent/;
|
||||
if $test->{test_privilege} && $test->{test_privilege} !~ m/adminOnly|insufficient|noAccess|notMember|vitalComponent/;
|
||||
|
||||
push @{$self->{_tests}}, $test;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,9 +55,13 @@ Test::More
|
|||
|
||||
Create a new WebGUI::Test::Maker::Permission object.
|
||||
|
||||
=cut
|
||||
|
||||
=head2 get
|
||||
|
||||
Get a setting. Set L<set> for a list of settings.
|
||||
Get a setting. See C<set> for a list of settings.
|
||||
|
||||
=cut
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -116,11 +120,13 @@ The permissions method to test
|
|||
|
||||
=item pass
|
||||
|
||||
An array reference of userIds that should pass the permissions test.
|
||||
An array reference of userIds or WebGUI::User objects that should pass the
|
||||
permissions test.
|
||||
|
||||
=item fail
|
||||
|
||||
An array reference of userIds that should fail the permissions test.
|
||||
An array reference of userIds or WebGUI::User objects that should fail the
|
||||
permissions test.
|
||||
|
||||
=back
|
||||
|
||||
|
|
@ -146,6 +152,16 @@ sub prepare {
|
|||
croak("Couldn't prepare: Test $test_num, fail is not an array reference")
|
||||
if $test->{fail} && ref $test->{fail} ne "ARRAY";
|
||||
|
||||
# Make sure pass and fail arrayrefs are userIds
|
||||
for my $array ( $test->{pass, fail} ) {
|
||||
for ( my $i = 0; $i < @$array; $i++ ) {
|
||||
# If is a User object, replace with userId
|
||||
if ( blessed $array->[$i] && $array->[$i]->isa("WebGUI::User") ) {
|
||||
$array->[$i] = $array->[$i]->userId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
push @{$self->{_tests}}, $test;
|
||||
}
|
||||
|
||||
|
|
|
|||
BIN
t/supporting_collateral/elephant_images.zip
Normal file
BIN
t/supporting_collateral/elephant_images.zip
Normal file
Binary file not shown.
BIN
t/supporting_collateral/lamp.jpg
Normal file
BIN
t/supporting_collateral/lamp.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 663 KiB |
115
www/extras/yui-carousel/carousel-min.js
vendored
Normal file
115
www/extras/yui-carousel/carousel-min.js
vendored
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/**
|
||||
* Copyright (c) 2006-2007, Bill W. Scott. All rights reserved.
|
||||
* This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy
|
||||
* of this license, visit http://creativecommons.org/licenses/by/2.5/ or send a letter to
|
||||
* Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
|
||||
* This work was created by Bill Scott (billwscott.com, looksgoodworkswell.com).
|
||||
* The only attribution I require is to keep this notice of copyright & license
|
||||
* in this original source file.
|
||||
* Version 0.6.1 - 07.08.2007
|
||||
*/
|
||||
|
||||
|
||||
YAHOO.namespace("extension");YAHOO.extension.Carousel=function(carouselElementID,carouselCfg){this.init(carouselElementID,carouselCfg);};YAHOO.extension.Carousel.prototype={UNBOUNDED_SIZE:1000000,init:function(carouselElementID,carouselCfg){var oThis=this;this.getCarouselItem=this.getItem;var carouselListClass="carousel-list";var carouselClipRegionClass="carousel-clip-region";var carouselNextClass="carousel-next";var carouselPrevClass="carousel-prev";this._carouselElemID=carouselElementID;this.carouselElem=YAHOO.util.Dom.get(carouselElementID);this._prevEnabled=true;this._nextEnabled=true;this.cfg=new YAHOO.util.Config(this);this.cfg.addProperty("scrollBeforeAmount",{value:0,handler:function(type,args,carouselElem){},validator:oThis.cfg.checkNumber});this.cfg.addProperty("scrollAfterAmount",{value:0,handler:function(type,args,carouselElem){},validator:oThis.cfg.checkNumber});this.cfg.addProperty("loadOnStart",{value:true,handler:function(type,args,carouselElem){},validator:oThis.cfg.checkBoolean});this.cfg.addProperty("orientation",{value:"horizontal",handler:function(type,args,carouselElem){oThis.reload();},validator:function(orientation){if(typeof orientation=="string"){return("horizontal,vertical".indexOf(orientation.toLowerCase())!=-1);}else{return false;}}});this.cfg.addProperty("size",{value:this.UNBOUNDED_SIZE,handler:function(type,args,carouselElem){oThis.reload();},validator:oThis.cfg.checkNumber});this.cfg.addProperty("numVisible",{value:3,handler:function(type,args,carouselElem){oThis.reload();},validator:oThis.cfg.checkNumber});this.cfg.addProperty("firstVisible",{value:1,handler:function(type,args,carouselElem){oThis.moveTo(args[0]);},validator:oThis.cfg.checkNumber});this.cfg.addProperty("scrollInc",{value:3,handler:function(type,args,carouselElem){},validator:oThis.cfg.checkNumber});this.cfg.addProperty("animationSpeed",{value:0.25,handler:function(type,args,carouselElem){oThis.animationSpeed=args[0];},validator:oThis.cfg.checkNumber});this.cfg.addProperty("animationMethod",{value:YAHOO.util.Easing.easeOut,handler:function(type,args,carouselElem){}});this.cfg.addProperty("animationCompleteHandler",{value:null,handler:function(type,args,carouselElem){if(oThis._animationCompleteEvt){oThis._animationCompleteEvt.unsubscribe(oThis._currAnimationCompleteHandler,oThis);}
|
||||
oThis._currAnimationCompleteHandler=args[0];if(oThis._currAnimationCompleteHandler){if(!oThis._animationCompleteEvt){oThis._animationCompleteEvt=new YAHOO.util.CustomEvent("onAnimationComplete",oThis);}
|
||||
oThis._animationCompleteEvt.subscribe(oThis._currAnimationCompleteHandler,oThis);}}});this.cfg.addProperty("autoPlay",{value:0,handler:function(type,args,carouselElem){var autoPlay=args[0];if(autoPlay>0)
|
||||
oThis.startAutoPlay();else
|
||||
oThis.stopAutoPlay();}});this.cfg.addProperty("wrap",{value:false,handler:function(type,args,carouselElem){},validator:oThis.cfg.checkBoolean});this.cfg.addProperty("navMargin",{value:0,handler:function(type,args,carouselElem){oThis.calculateSize();},validator:oThis.cfg.checkNumber});this.cfg.addProperty("revealAmount",{value:0,handler:function(type,args,carouselElem){oThis.reload();},validator:oThis.cfg.checkNumber});this.cfg.addProperty("prevElementID",{value:null,handler:function(type,args,carouselElem){if(oThis._carouselPrev){YAHOO.util.Event.removeListener(oThis._carouselPrev,"click",oThis._scrollPrev);}
|
||||
oThis._prevElementID=args[0];if(oThis._prevElementID==null){oThis._carouselPrev=YAHOO.util.Dom.getElementsByClassName(carouselPrevClass,"div",oThis.carouselElem)[0];}else{oThis._carouselPrev=YAHOO.util.Dom.get(oThis._prevElementID);}
|
||||
YAHOO.util.Event.addListener(oThis._carouselPrev,"click",oThis._scrollPrev,oThis);}});this.cfg.addProperty("prevElement",{value:null,handler:function(type,args,carouselElem){if(oThis._carouselPrev){YAHOO.util.Event.removeListener(oThis._carouselPrev,"click",oThis._scrollPrev);}
|
||||
oThis._prevElementID=args[0];if(oThis._prevElementID==null){oThis._carouselPrev=YAHOO.util.Dom.getElementsByClassName(carouselPrevClass,"div",oThis.carouselElem)[0];}else{oThis._carouselPrev=YAHOO.util.Dom.get(oThis._prevElementID);}
|
||||
YAHOO.util.Event.addListener(oThis._carouselPrev,"click",oThis._scrollPrev,oThis);}});this.cfg.addProperty("nextElementID",{value:null,handler:function(type,args,carouselElem){if(oThis._carouselNext){YAHOO.util.Event.removeListener(oThis._carouselNext,"click",oThis._scrollNext);}
|
||||
oThis._nextElementID=args[0];if(oThis._nextElementID==null){oThis._carouselNext=YAHOO.util.Dom.getElementsByClassName(carouselNextClass,"div",oThis.carouselElem);}else{oThis._carouselNext=YAHOO.util.Dom.get(oThis._nextElementID);}
|
||||
if(oThis._carouselNext){YAHOO.util.Event.addListener(oThis._carouselNext,"click",oThis._scrollNext,oThis);}}});this.cfg.addProperty("nextElement",{value:null,handler:function(type,args,carouselElem){if(oThis._carouselNext){YAHOO.util.Event.removeListener(oThis._carouselNext,"click",oThis._scrollNext);}
|
||||
oThis._nextElementID=args[0];if(oThis._nextElementID==null){oThis._carouselNext=YAHOO.util.Dom.getElementsByClassName(carouselNextClass,"div",oThis.carouselElem);}else{oThis._carouselNext=YAHOO.util.Dom.get(oThis._nextElementID);}
|
||||
if(oThis._carouselNext){YAHOO.util.Event.addListener(oThis._carouselNext,"click",oThis._scrollNext,oThis);}}});this.cfg.addProperty("loadInitHandler",{value:null,handler:function(type,args,carouselElem){if(oThis._loadInitHandlerEvt){oThis._loadInitHandlerEvt.unsubscribe(oThis._currLoadInitHandler,oThis);}
|
||||
oThis._currLoadInitHandler=args[0];if(oThis._currLoadInitHandler){if(!oThis._loadInitHandlerEvt){oThis._loadInitHandlerEvt=new YAHOO.util.CustomEvent("onLoadInit",oThis);}
|
||||
oThis._loadInitHandlerEvt.subscribe(oThis._currLoadInitHandler,oThis);}}});this.cfg.addProperty("loadNextHandler",{value:null,handler:function(type,args,carouselElem){if(oThis._loadNextHandlerEvt){oThis._loadNextHandlerEvt.unsubscribe(oThis._currLoadNextHandler,oThis);}
|
||||
oThis._currLoadNextHandler=args[0];if(oThis._currLoadNextHandler){if(!oThis._loadNextHandlerEvt){oThis._loadNextHandlerEvt=new YAHOO.util.CustomEvent("onLoadNext",oThis);}
|
||||
oThis._loadNextHandlerEvt.subscribe(oThis._currLoadNextHandler,oThis);}}});this.cfg.addProperty("loadPrevHandler",{value:null,handler:function(type,args,carouselElem){if(oThis._loadPrevHandlerEvt){oThis._loadPrevHandlerEvt.unsubscribe(oThis._currLoadPrevHandler,oThis);}
|
||||
oThis._currLoadPrevHandler=args[0];if(oThis._currLoadPrevHandler){if(!oThis._loadPrevHandlerEvt){oThis._loadPrevHandlerEvt=new YAHOO.util.CustomEvent("onLoadPrev",oThis);}
|
||||
oThis._loadPrevHandlerEvt.subscribe(oThis._currLoadPrevHandler,oThis);}}});this.cfg.addProperty("prevButtonStateHandler",{value:null,handler:function(type,args,carouselElem){if(oThis._currPrevButtonStateHandler){oThis._prevButtonStateHandlerEvt.unsubscribe(oThis._currPrevButtonStateHandler,oThis);}
|
||||
oThis._currPrevButtonStateHandler=args[0];if(oThis._currPrevButtonStateHandler){if(!oThis._prevButtonStateHandlerEvt){oThis._prevButtonStateHandlerEvt=new YAHOO.util.CustomEvent("onPrevButtonStateChange",oThis);}
|
||||
oThis._prevButtonStateHandlerEvt.subscribe(oThis._currPrevButtonStateHandler,oThis);}}});this.cfg.addProperty("nextButtonStateHandler",{value:null,handler:function(type,args,carouselElem){if(oThis._currNextButtonStateHandler){oThis._nextButtonStateHandlerEvt.unsubscribe(oThis._currNextButtonStateHandler,oThis);}
|
||||
oThis._currNextButtonStateHandler=args[0];if(oThis._currNextButtonStateHandler){if(!oThis._nextButtonStateHandlerEvt){oThis._nextButtonStateHandlerEvt=new YAHOO.util.CustomEvent("onNextButtonStateChange",oThis);}
|
||||
oThis._nextButtonStateHandlerEvt.subscribe(oThis._currNextButtonStateHandler,oThis);}}});if(carouselCfg){this.cfg.applyConfig(carouselCfg);}
|
||||
this._origFirstVisible=this.cfg.getProperty("firstVisible");this._currLoadInitHandler=this.cfg.getProperty("loadInitHandler");this._currLoadNextHandler=this.cfg.getProperty("loadNextHandler");this._currLoadPrevHandler=this.cfg.getProperty("loadPrevHandler");this._currPrevButtonStateHandler=this.cfg.getProperty("prevButtonStateHandler");this._currNextButtonStateHandler=this.cfg.getProperty("nextButtonStateHandler");this._currAnimationCompleteHandler=this.cfg.getProperty("animationCompleteHandler");this._nextElementID=this.cfg.getProperty("nextElementID");if(!this._nextElementID)
|
||||
this._nextElementID=this.cfg.getProperty("nextElement");this._prevElementID=this.cfg.getProperty("prevElementID");if(!this._prevElementID)
|
||||
this._prevElementID=this.cfg.getProperty("prevElement");this._autoPlayTimer=null;this._priorLastVisible=this._priorFirstVisible=this.cfg.getProperty("firstVisible");this._lastPrebuiltIdx=0;this.carouselList=YAHOO.util.Dom.getElementsByClassName(carouselListClass,"ul",this.carouselElem)[0];if(this._nextElementID==null){this._carouselNext=YAHOO.util.Dom.getElementsByClassName(carouselNextClass,"div",this.carouselElem)[0];}else{this._carouselNext=YAHOO.util.Dom.get(this._nextElementID);}
|
||||
if(this._prevElementID==null){this._carouselPrev=YAHOO.util.Dom.getElementsByClassName(carouselPrevClass,"div",this.carouselElem)[0];}else{this._carouselPrev=YAHOO.util.Dom.get(this._prevElementID);}
|
||||
this._clipReg=YAHOO.util.Dom.getElementsByClassName(carouselClipRegionClass,"div",this.carouselElem)[0];if(this.isVertical()){YAHOO.util.Dom.addClass(this.carouselList,"carousel-vertical");}
|
||||
this._scrollNextAnim=new YAHOO.util.Motion(this.carouselList,this.scrollNextParams,this.cfg.getProperty("animationSpeed"),this.cfg.getProperty("animationMethod"));this._scrollPrevAnim=new YAHOO.util.Motion(this.carouselList,this.scrollPrevParams,this.cfg.getProperty("animationSpeed"),this.cfg.getProperty("animationMethod"));if(this._carouselNext){YAHOO.util.Event.addListener(this._carouselNext,"click",this._scrollNext,this);}
|
||||
if(this._carouselPrev){YAHOO.util.Event.addListener(this._carouselPrev,"click",this._scrollPrev,this);}
|
||||
var loadInitHandler=this.cfg.getProperty("loadInitHandler");if(loadInitHandler){this._loadInitHandlerEvt=new YAHOO.util.CustomEvent("onLoadInit",this);this._loadInitHandlerEvt.subscribe(loadInitHandler,this);}
|
||||
var loadNextHandler=this.cfg.getProperty("loadNextHandler");if(loadNextHandler){this._loadNextHandlerEvt=new YAHOO.util.CustomEvent("onLoadNext",this);this._loadNextHandlerEvt.subscribe(loadNextHandler,this);}
|
||||
var loadPrevHandler=this.cfg.getProperty("loadPrevHandler");if(loadPrevHandler){this._loadPrevHandlerEvt=new YAHOO.util.CustomEvent("onLoadPrev",this);this._loadPrevHandlerEvt.subscribe(loadPrevHandler,this);}
|
||||
var animationCompleteHandler=this.cfg.getProperty("animationCompleteHandler");if(animationCompleteHandler){this._animationCompleteEvt=new YAHOO.util.CustomEvent("onAnimationComplete",this);this._animationCompleteEvt.subscribe(animationCompleteHandler,this);}
|
||||
var prevButtonStateHandler=this.cfg.getProperty("prevButtonStateHandler");if(prevButtonStateHandler){this._prevButtonStateHandlerEvt=new YAHOO.util.CustomEvent("onPrevButtonStateChange",this);this._prevButtonStateHandlerEvt.subscribe(prevButtonStateHandler,this);}
|
||||
var nextButtonStateHandler=this.cfg.getProperty("nextButtonStateHandler");if(nextButtonStateHandler){this._nextButtonStateHandlerEvt=new YAHOO.util.CustomEvent("onNextButtonStateChange",this);this._nextButtonStateHandlerEvt.subscribe(nextButtonStateHandler,this);}
|
||||
var visibleExtent=this._calculateVisibleExtent();YAHOO.util.Event.onAvailable(this._carouselElemID+"-item-"+
|
||||
visibleExtent.start,this._calculateSize,this);if(this.cfg.getProperty("loadOnStart"))
|
||||
this._loadInitial();},clear:function(){var loadInitHandler=this.cfg.getProperty("loadInitHandler");if(loadInitHandler){this._removeChildrenFromNode(this.carouselList);this._lastPrebuiltIdx=0;}
|
||||
this.stopAutoPlay();this._priorLastVisible=this._priorFirstVisible=this._origFirstVisible;this.cfg.setProperty("firstVisible",this._origFirstVisible,true);this.moveTo(this._origFirstVisible);},reload:function(numVisible){if(this._isValidObj(numVisible)){this.cfg.setProperty("numVisible",numVisible);}
|
||||
this.clear();var visibleExtent=this._calculateVisibleExtent();YAHOO.util.Event.onAvailable(this._carouselElemID+"-item-"+visibleExtent.start,this._calculateSize,this);this._loadInitial();},load:function(){var visibleExtent=this._calculateVisibleExtent();YAHOO.util.Event.onAvailable(this._carouselElemID+"-item-"+visibleExtent.start,this._calculateSize,this);this._loadInitial();},addItem:function(idx,innerHTMLOrElem,itemClass){if(idx>this.cfg.getProperty("size")){return null;}
|
||||
var liElem=this.getItem(idx);if(!this._isValidObj(liElem)){liElem=this._createItem(idx,innerHTMLOrElem);this.carouselList.appendChild(liElem);}else if(this._isValidObj(liElem.placeholder)){var newLiElem=this._createItem(idx,innerHTMLOrElem);this.carouselList.replaceChild(newLiElem,liElem);liElem=newLiElem;}
|
||||
if(this._isValidObj(itemClass)){YAHOO.util.Dom.addClass(liElem,itemClass);}
|
||||
if(this.isVertical())
|
||||
setTimeout(function(){liElem.style.display="block";},1);return liElem;},insertBefore:function(refIdx,innerHTML){if(refIdx>=this.cfg.getProperty("size")){return null;}
|
||||
if(refIdx<1){refIdx=1;}
|
||||
var insertionIdx=refIdx-1;if(insertionIdx>this._lastPrebuiltIdx){this._prebuildItems(this._lastPrebuiltIdx,refIdx);}
|
||||
var liElem=this._insertBeforeItem(refIdx,innerHTML);this._enableDisableControls();return liElem;},insertAfter:function(refIdx,innerHTML){if(refIdx>this.cfg.getProperty("size")){refIdx=this.cfg.getProperty("size");}
|
||||
var insertionIdx=refIdx+1;if(insertionIdx>this._lastPrebuiltIdx){this._prebuildItems(this._lastPrebuiltIdx,insertionIdx+1);}
|
||||
var liElem=this._insertAfterItem(refIdx,innerHTML);if(insertionIdx>this.cfg.getProperty("size")){this.cfg.setProperty("size",insertionIdx,true);}
|
||||
this._enableDisableControls();return liElem;},scrollNext:function(){this._scrollNext(null,this);this._autoPlayTimer=null;if(this.cfg.getProperty("autoPlay")!==0){this._autoPlayTimer=this.startAutoPlay();}},scrollPrev:function(){this._scrollPrev(null,this);},scrollTo:function(newStart){this._position(newStart,true);},moveTo:function(newStart){this._position(newStart,false);},startAutoPlay:function(interval){if(this._isValidObj(interval)){this.cfg.setProperty("autoPlay",interval,true);}
|
||||
if(this._autoPlayTimer!==null){return this._autoPlayTimer;}
|
||||
var oThis=this;var autoScroll=function(){oThis.scrollNext();};this._autoPlayTimer=setTimeout(autoScroll,this.cfg.getProperty("autoPlay"));return this._autoPlayTimer;},stopAutoPlay:function(){if(this._autoPlayTimer!==null){clearTimeout(this._autoPlayTimer);this._autoPlayTimer=null;}},isVertical:function(){return(this.cfg.getProperty("orientation")!="horizontal");},isItemLoaded:function(idx){var liElem=this.getItem(idx);if(this._isValidObj(liElem)&&!this._isValidObj(liElem.placeholder)){return true;}
|
||||
return false;},getItem:function(idx){var elemName=this._carouselElemID+"-item-"+idx;var liElem=YAHOO.util.Dom.get(elemName);return liElem;},show:function(){YAHOO.util.Dom.setStyle(this.carouselElem,"display","block");this.calculateSize();},hide:function(){YAHOO.util.Dom.setStyle(this.carouselElem,"display","none");},calculateSize:function(){var ulKids=this.carouselList.childNodes;var li=null;for(var i=0;i<ulKids.length;i++){li=ulKids[i];if(li.tagName=="LI"||li.tagName=="li"){break;}}
|
||||
var navMargin=this.cfg.getProperty("navMargin");var numVisible=this.cfg.getProperty("numVisible");var firstVisible=this.cfg.getProperty("firstVisible");var pl=this._getStyleVal(li,"paddingLeft");var pr=this._getStyleVal(li,"paddingRight");var ml=this._getStyleVal(li,"marginLeft");var mr=this._getStyleVal(li,"marginRight");var pt=this._getStyleVal(li,"paddingTop");var pb=this._getStyleVal(li,"paddingBottom");var mt=this._getStyleVal(li,"marginTop");var mb=this._getStyleVal(li,"marginBottom");YAHOO.util.Dom.removeClass(this.carouselList,"carousel-vertical");YAHOO.util.Dom.removeClass(this.carouselList,"carousel-horizontal");if(this.isVertical()){var liPaddingMarginWidth=pl+pr+ml+mr;YAHOO.util.Dom.addClass(this.carouselList,"carousel-vertical");var liPaddingMarginHeight=pt+pb+mt+mb;var upt=this._getStyleVal(this.carouselList,"paddingTop");var upb=this._getStyleVal(this.carouselList,"paddingBottom");var umt=this._getStyleVal(this.carouselList,"marginTop")
|
||||
var umb=this._getStyleVal(this.carouselList,"marginBottom")
|
||||
var ulPaddingHeight=upt+upb+umt+umb;var revealAmt=(this._isExtraRevealed())?(this.cfg.getProperty("revealAmount")+(liPaddingMarginHeight)/2):0;var liHeight=this._getStyleVal(li,"height",true);this.scrollAmountPerInc=(liHeight+liPaddingMarginHeight);var liWidth=this._getStyleVal(li,"width");this.carouselElem.style.width=(liWidth+liPaddingMarginWidth)+"px";this._clipReg.style.height=(this.scrollAmountPerInc*numVisible+revealAmt*2+
|
||||
ulPaddingHeight)+"px";this.carouselElem.style.height=(this.scrollAmountPerInc*numVisible+revealAmt*2+navMargin*2+
|
||||
ulPaddingHeight)+"px";var revealTop=(this._isExtraRevealed())?(revealAmt-(Math.abs(mt-mb)+Math.abs(pt-pb))/2):0;YAHOO.util.Dom.setStyle(this.carouselList,"position","relative");YAHOO.util.Dom.setStyle(this.carouselList,"top",""+revealTop+"px");var currY=YAHOO.util.Dom.getY(this.carouselList);YAHOO.util.Dom.setY(this.carouselList,currY-this.scrollAmountPerInc*(firstVisible-1));}else{YAHOO.util.Dom.addClass(this.carouselList,"carousel-horizontal");var upl=this._getStyleVal(this.carouselList,"paddingLeft");var upr=this._getStyleVal(this.carouselList,"paddingRight");var uml=this._getStyleVal(this.carouselList,"marginLeft")
|
||||
var umr=this._getStyleVal(this.carouselList,"marginRight")
|
||||
var ulPaddingWidth=upl+upr+uml+umr;var liMarginWidth=ml+mr;var liPaddingMarginWidth=liMarginWidth+pr+pl;var revealAmt=(this._isExtraRevealed())?(this.cfg.getProperty("revealAmount")+(liPaddingMarginWidth)/2):0;var liWidth=li.offsetWidth;this.scrollAmountPerInc=liWidth+liMarginWidth;this._clipReg.style.width=(this.scrollAmountPerInc*numVisible+revealAmt*2)+"px";this.carouselElem.style.width=(this.scrollAmountPerInc*numVisible+navMargin*2+revealAmt*2+
|
||||
ulPaddingWidth)+"px";var revealLeft=(this._isExtraRevealed())?(revealAmt-(Math.abs(mr-ml)+Math.abs(pr-pl))/2-(uml+upl)):0;YAHOO.util.Dom.setStyle(this.carouselList,"position","relative");YAHOO.util.Dom.setStyle(this.carouselList,"left",""+revealLeft+"px");var currX=YAHOO.util.Dom.getX(this.carouselList);YAHOO.util.Dom.setX(this.carouselList,currX-this.scrollAmountPerInc*(firstVisible-1));}},setProperty:function(property,value,silent){this.cfg.setProperty(property,value,silent);},getProperty:function(property){return this.cfg.getProperty(property);},getFirstItemRevealed:function(){return this._firstItemRevealed;},getLastItemRevealed:function(){return this._lastItemRevealed;},getFirstVisible:function(){return this.cfg.getProperty("firstVisible");},getLastVisible:function(){var firstVisible=this.cfg.getProperty("firstVisible");var numVisible=this.cfg.getProperty("numVisible");return firstVisible+numVisible-1;},_getStyleVal:function(li,style,returnFloat){var styleValStr=YAHOO.util.Dom.getStyle(li,style);var styleVal=returnFloat?parseFloat(styleValStr):parseInt(styleValStr,10);if(style=="height"&&isNaN(styleVal)){styleVal=li.offsetHeight;}else if(isNaN(styleVal)){styleVal=0;}
|
||||
return styleVal;},_calculateSize:function(me){me.calculateSize();me.show();},_removeChildrenFromNode:function(node)
|
||||
{if(!this._isValidObj(node))
|
||||
{return;}
|
||||
var len=node.childNodes.length;while(node.hasChildNodes())
|
||||
{node.removeChild(node.firstChild);}},_prebuildLiElem:function(idx){if(idx<1)return;var liElem=document.createElement("li");liElem.id=this._carouselElemID+"-item-"+idx;liElem.placeholder=true;this.carouselList.appendChild(liElem);this._lastPrebuiltIdx=(idx>this._lastPrebuiltIdx)?idx:this._lastPrebuiltIdx;},_createItem:function(idx,innerHTMLOrElem){if(idx<1)return;var liElem=document.createElement("li");liElem.id=this._carouselElemID+"-item-"+idx;if(typeof(innerHTMLOrElem)==="string"){liElem.innerHTML=innerHTMLOrElem;}else{liElem.appendChild(innerHTMLOrElem);}
|
||||
return liElem;},_insertAfterItem:function(refIdx,innerHTMLOrElem){return this._insertBeforeItem(refIdx+1,innerHTMLOrElem);},_insertBeforeItem:function(refIdx,innerHTMLOrElem){var refItem=this.getItem(refIdx);var size=this.cfg.getProperty("size");if(size!=this.UNBOUNDED_SIZE){this.cfg.setProperty("size",size+1,true);}
|
||||
for(var i=this._lastPrebuiltIdx;i>=refIdx;i--){var anItem=this.getItem(i);if(this._isValidObj(anItem)){anItem.id=this._carouselElemID+"-item-"+(i+1);}}
|
||||
var liElem=this._createItem(refIdx,innerHTMLOrElem);var insertedItem=this.carouselList.insertBefore(liElem,refItem);this._lastPrebuiltIdx+=1;return liElem;},insertAfterEnd:function(innerHTMLOrElem){return this.insertAfter(this.cfg.getProperty("size"),innerHTMLOrElem);},_position:function(newStart,showAnimation){var currStart=this._priorFirstVisible;if(newStart>currStart){var inc=newStart-currStart;this._scrollNextInc(inc,showAnimation);}else{var dec=currStart-newStart;this._scrollPrevInc(dec,showAnimation);}},_scrollPrev:function(e,carousel){if(e!==null){carousel.stopAutoPlay();}
|
||||
if(carousel._scrollPrevAnim.isAnimated()){return false;}
|
||||
carousel._scrollPrevInc(carousel.cfg.getProperty("scrollInc"),(carousel.cfg.getProperty("animationSpeed")!==0));},_scrollNext:function(e,carousel){if(e!==null){carousel.stopAutoPlay();}
|
||||
if(carousel._scrollNextAnim.isAnimated()){return false;}
|
||||
carousel._scrollNextInc(carousel.cfg.getProperty("scrollInc"),(carousel.cfg.getProperty("animationSpeed")!==0));},_handleAnimationComplete:function(type,args,argList){var carousel=argList[0];var direction=argList[1];carousel._animationCompleteEvt.fire(direction);},_areAllItemsLoaded:function(first,last){var itemsLoaded=true;for(var i=first;i<=last;i++){var liElem=this.getItem(i);if(!this._isValidObj(liElem)){this._prebuildLiElem(i);itemsLoaded=false;}else if(this._isValidObj(liElem.placeholder)){itemsLoaded=false;}}
|
||||
return itemsLoaded;},_prebuildItems:function(first,last){for(var i=first;i<=last;i++){var liElem=this.getItem(i);if(!this._isValidObj(liElem)){this._prebuildLiElem(i);}}},_isExtraRevealed:function(){return(this.cfg.getProperty("revealAmount")>0);},_scrollNextInc:function(inc,showAnimation){var numVisible=this.cfg.getProperty("numVisible");var currStart=this._priorFirstVisible;var currEnd=this._priorLastVisible;var size=this.cfg.getProperty("size");var scrollExtent=this._calculateAllowableScrollExtent();if(this.cfg.getProperty("wrap")&&currEnd==scrollExtent.end){this.scrollTo(scrollExtent.start);return;}
|
||||
var newStart=currStart+inc;var newEnd=newStart+numVisible-1;if(newEnd>scrollExtent.end){newEnd=scrollExtent.end;newStart=newEnd-numVisible+1;}
|
||||
inc=newStart-currStart;this.cfg.setProperty("firstVisible",newStart,true);if(inc>0){if(this._isValidObj(this.cfg.getProperty("loadNextHandler"))){var visibleExtent=this._calculateVisibleExtent(newStart,newEnd);var cacheStart=(currEnd+1)<visibleExtent.start?(currEnd+1):visibleExtent.start;var alreadyCached=this._areAllItemsLoaded(cacheStart,visibleExtent.end);this._loadNextHandlerEvt.fire(visibleExtent.start,visibleExtent.end,alreadyCached);}
|
||||
if(showAnimation){var nextParams={points:{by:[-this.scrollAmountPerInc*inc,0]}};if(this.isVertical()){nextParams={points:{by:[0,-this.scrollAmountPerInc*inc]}};}
|
||||
this._scrollNextAnim=new YAHOO.util.Motion(this.carouselList,nextParams,this.cfg.getProperty("animationSpeed"),this.cfg.getProperty("animationMethod"));if(this.cfg.getProperty("animationCompleteHandler")){this._scrollNextAnim.onComplete.subscribe(this._handleAnimationComplete,[this,"next"]);}
|
||||
this._scrollNextAnim.animate();}else{if(this.isVertical()){var currY=YAHOO.util.Dom.getY(this.carouselList);YAHOO.util.Dom.setY(this.carouselList,currY-this.scrollAmountPerInc*inc);}else{var currX=YAHOO.util.Dom.getX(this.carouselList);YAHOO.util.Dom.setX(this.carouselList,currX-this.scrollAmountPerInc*inc);}}}
|
||||
this._priorFirstVisible=newStart;this._priorLastVisible=newEnd;this._enableDisableControls();return false;},_scrollPrevInc:function(dec,showAnimation){var numVisible=this.cfg.getProperty("numVisible");var currStart=this._priorFirstVisible;var currEnd=this._priorLastVisible;var size=this.cfg.getProperty("size");var newStart=currStart-dec;var scrollExtent=this._calculateAllowableScrollExtent();newStart=(newStart<scrollExtent.start)?scrollExtent.start:newStart;var newEnd=newStart+numVisible-1;if(newEnd>scrollExtent.end){newEnd=scrollExtent.end;newStart=newEnd-numVisible+1;}
|
||||
dec=currStart-newStart;this.cfg.setProperty("firstVisible",newStart,true);if(dec>0){if(this._isValidObj(this.cfg.getProperty("loadPrevHandler"))){var visibleExtent=this._calculateVisibleExtent(newStart,newEnd);var cacheEnd=(currStart-1)>visibleExtent.end?(currStart-1):visibleExtent.end;var alreadyCached=this._areAllItemsLoaded(visibleExtent.start,cacheEnd);this._loadPrevHandlerEvt.fire(visibleExtent.start,visibleExtent.end,alreadyCached);}
|
||||
if(showAnimation){var prevParams={points:{by:[this.scrollAmountPerInc*dec,0]}};if(this.isVertical()){prevParams={points:{by:[0,this.scrollAmountPerInc*dec]}};}
|
||||
this._scrollPrevAnim=new YAHOO.util.Motion(this.carouselList,prevParams,this.cfg.getProperty("animationSpeed"),this.cfg.getProperty("animationMethod"));if(this.cfg.getProperty("animationCompleteHandler")){this._scrollPrevAnim.onComplete.subscribe(this._handleAnimationComplete,[this,"prev"]);}
|
||||
this._scrollPrevAnim.animate();}else{if(this.isVertical()){var currY=YAHOO.util.Dom.getY(this.carouselList);YAHOO.util.Dom.setY(this.carouselList,currY+
|
||||
this.scrollAmountPerInc*dec);}else{var currX=YAHOO.util.Dom.getX(this.carouselList);YAHOO.util.Dom.setX(this.carouselList,currX+
|
||||
this.scrollAmountPerInc*dec);}}}
|
||||
this._priorFirstVisible=newStart;this._priorLastVisible=newEnd;this._enableDisableControls();return false;},_enableDisableControls:function(){var firstVisible=this.cfg.getProperty("firstVisible");var lastVisible=this.getLastVisible();var scrollExtent=this._calculateAllowableScrollExtent();if(this._prevEnabled){if(firstVisible===scrollExtent.start){this._disablePrev();}}
|
||||
if(this._prevEnabled===false){if(firstVisible>scrollExtent.start){this._enablePrev();}}
|
||||
if(this._nextEnabled){if(lastVisible===scrollExtent.end){this._disableNext();}}
|
||||
if(this._nextEnabled===false){if(lastVisible<scrollExtent.end){this._enableNext();}}},_loadInitial:function(){var firstVisible=this.cfg.getProperty("firstVisible");this._priorLastVisible=this.getLastVisible();if(this._loadInitHandlerEvt){var visibleExtent=this._calculateVisibleExtent(firstVisible,this._priorLastVisible);var alreadyCached=this._areAllItemsLoaded(1,visibleExtent.end);this._loadInitHandlerEvt.fire(visibleExtent.start,visibleExtent.end,alreadyCached);}
|
||||
if(this.cfg.getProperty("autoPlay")!==0){this._autoPlayTimer=this.startAutoPlay();}
|
||||
this._enableDisableControls();},_calculateAllowableScrollExtent:function(){var scrollBeforeAmount=this.cfg.getProperty("scrollBeforeAmount");var scrollAfterAmount=this.cfg.getProperty("scrollAfterAmount");var size=this.cfg.getProperty("size");var extent={start:1-scrollBeforeAmount,end:size+scrollAfterAmount};return extent;},_calculateVisibleExtent:function(start,end){if(!start){start=this.cfg.getProperty("firstVisible");end=this.getLastVisible();}
|
||||
var size=this.cfg.getProperty("size");start=start<1?1:start;end=end>size?size:end;var extent={start:start,end:end};this._firstItemRevealed=-1;this._lastItemRevealed=-1;if(this._isExtraRevealed()){if(start>1){this._firstItemRevealed=start-1;extent.start=this._firstItemRevealed;}
|
||||
if(end<size){this._lastItemRevealed=end+1;extent.end=this._lastItemRevealed;}}
|
||||
return extent;},_disablePrev:function(){this._prevEnabled=false;if(this._prevButtonStateHandlerEvt){this._prevButtonStateHandlerEvt.fire(false,this._carouselPrev);}
|
||||
if(this._isValidObj(this._carouselPrev)){YAHOO.util.Event.removeListener(this._carouselPrev,"click",this._scrollPrev);}},_enablePrev:function(){this._prevEnabled=true;if(this._prevButtonStateHandlerEvt){this._prevButtonStateHandlerEvt.fire(true,this._carouselPrev);}
|
||||
if(this._isValidObj(this._carouselPrev)){YAHOO.util.Event.addListener(this._carouselPrev,"click",this._scrollPrev,this);}},_disableNext:function(){if(this.cfg.getProperty("wrap")){return;}
|
||||
this._nextEnabled=false;if(this._isValidObj(this._nextButtonStateHandlerEvt)){this._nextButtonStateHandlerEvt.fire(false,this._carouselNext);}
|
||||
if(this._isValidObj(this._carouselNext)){YAHOO.util.Event.removeListener(this._carouselNext,"click",this._scrollNext);}},_enableNext:function(){this._nextEnabled=true;if(this._isValidObj(this._nextButtonStateHandlerEvt)){this._nextButtonStateHandlerEvt.fire(true,this._carouselNext);}
|
||||
if(this._isValidObj(this._carouselNext)){YAHOO.util.Event.addListener(this._carouselNext,"click",this._scrollNext,this);}},_isValidObj:function(obj){if(null==obj){return false;}
|
||||
if("undefined"==typeof(obj)){return false;}
|
||||
return true;}};
|
||||
99
www/extras/yui-carousel/carousel.css
Normal file
99
www/extras/yui-carousel/carousel.css
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/**
|
||||
* Copyright (c) 2006-2007, Bill W. Scott
|
||||
* All rights reserved.
|
||||
*
|
||||
* This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy
|
||||
* of this license, visit http://creativecommons.org/licenses/by/2.5/ or send a letter to
|
||||
* Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
|
||||
*
|
||||
* This work was created by Bill Scott (billwscott.com, looksgoodworkswell.com).
|
||||
*
|
||||
* The only attribution I require is to keep this notice of copyright & license
|
||||
* in this original source file.
|
||||
*
|
||||
* Version 0.6.1 - 07.08.2007
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Standard Configuration. It is advised that this section NOT be modified as the
|
||||
* carousel.js expects the behavior outlined below.
|
||||
**/
|
||||
.carousel-component {
|
||||
position:relative;
|
||||
overflow:hidden; /* causes the clipping */
|
||||
display:none; /* component turns it on when first item is rendered */
|
||||
|
||||
}
|
||||
|
||||
.carousel-component ul.carousel-list {
|
||||
width:10000000px;
|
||||
position:relative;
|
||||
z-index:1;
|
||||
}
|
||||
|
||||
.carousel-component .carousel-list li {
|
||||
float:left;
|
||||
list-style:none;
|
||||
overflow:hidden;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* VERTICAL CAROUSEL DEFAULTS
|
||||
**/
|
||||
.carousel-component .carousel-vertical li {
|
||||
margin-bottom:0px;
|
||||
|
||||
/* Fix for extra spacing in IE */
|
||||
float:left;
|
||||
clear:left;
|
||||
|
||||
/* Force the LI to respect the HEIGHT specified */
|
||||
overflow:hidden;
|
||||
display:block;
|
||||
}
|
||||
|
||||
/* For vertical carousel, not set, width defaults to auto */
|
||||
/* Note if you explicitly set width to auto, this might cause */
|
||||
/* problems with Safari... as in up/down button not working in some examples. */
|
||||
.carousel-component ul.carousel-vertical {
|
||||
/* width:auto;*/
|
||||
}
|
||||
|
||||
.carousel-component .carousel-clip-region {
|
||||
overflow:hidden; /* Secret to the clipping */
|
||||
margin:0px auto;
|
||||
position:relative;
|
||||
}
|
||||
|
||||
/**
|
||||
* ==============================================================================
|
||||
* Safe to override. It is safe to override background, padding, margin, color,
|
||||
* text alignment, fonts, etc. Define a separate CSS file and override your style
|
||||
* preferences.
|
||||
**/
|
||||
|
||||
.carousel-component {
|
||||
background:#e2edfa;
|
||||
padding:0px;
|
||||
-moz-border-radius:6px;
|
||||
color:#618cbe;
|
||||
}
|
||||
.carousel-component ul.carousel-list {
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
line-height:0px;
|
||||
}
|
||||
.carousel-component .carousel-list li {
|
||||
text-align:center;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
font:10px verdana,arial,sans-serif;
|
||||
color:#666;
|
||||
}
|
||||
.carousel-component .carousel-vertical li {
|
||||
}
|
||||
.carousel-component ul.carousel-vertical {
|
||||
}
|
||||
1567
www/extras/yui-carousel/carousel.js
vendored
Normal file
1567
www/extras/yui-carousel/carousel.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue