- moved Gallery utility methods to WebGUI::Utility::Gallery
- Added tests for GalleryAlbum RSS - More tests for comments - Test International Macro sprintf as third+ arguments - Add Gallery search limiting by user ID - Remaining i18n for Gallery templates - Fix: Search form now visible in Photo assets Moved a lot of stuff from Photo to GalleryFile
This commit is contained in:
parent
38256af5f6
commit
ab6f4defe3
25 changed files with 1386 additions and 905 deletions
|
|
@ -82,13 +82,6 @@ sub definition {
|
|||
label => $i18n->get("groupIdAddFile label"),
|
||||
hoverHelp => $i18n->get("groupIdAddFile description"),
|
||||
},
|
||||
groupIdModerator => {
|
||||
tab => "security",
|
||||
fieldType => "group",
|
||||
defaultValue => 3, # Admins
|
||||
label => $i18n->get("groupIdModerator label"),
|
||||
hoverHelp => $i18n->get("groupIdModerator description"),
|
||||
},
|
||||
imageResolutions => {
|
||||
tab => "properties",
|
||||
fieldType => "checkList",
|
||||
|
|
@ -963,6 +956,11 @@ sub www_search {
|
|||
. $db->quote( '%' . $form->get("description") . '%' )
|
||||
;
|
||||
}
|
||||
if ( $form->get("userId") ) {
|
||||
$where .= q{ AND assetData.ownerUserId = }
|
||||
. $db->quote( $form->get("userId") )
|
||||
;
|
||||
}
|
||||
|
||||
my $joinClass = [
|
||||
'WebGUI::Asset::Wobject::GalleryAlbum',
|
||||
|
|
@ -983,6 +981,7 @@ sub www_search {
|
|||
. 'className=' . $form->get('className') . ';'
|
||||
. 'creationDate_after=' . $form->get('creationDate_after') . ';'
|
||||
. 'creationDate_before=' . $form->get('creationDate_before') . ';'
|
||||
. 'userId=' . $form->get("userId") . ';'
|
||||
);
|
||||
|
||||
my $p
|
||||
|
|
|
|||
|
|
@ -1,212 +0,0 @@
|
|||
package WebGUI::Asset::Wobject::Gallery::Utility;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2008 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 Carp qw( carp croak );
|
||||
use File::Find;
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Asset::Wobject::Collaboration;
|
||||
use WebGUI::Asset::Wobject::Gallery;
|
||||
use WebGUI::Asset::Post::Thread;
|
||||
use WebGUI::Storage::Image;
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::Asset::Wobject::Gallery::Utility -- Utility functions for working
|
||||
with Gallery assets.
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module provides utility functions to work with Gallery assets from
|
||||
utility scripts.
|
||||
|
||||
This module is B<NOT> to be used by the Gallery asset itself!
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Asset::Wobject::Gallery::Utility;
|
||||
my $utility = "WebGUI::Asset::Wobject::Gallery::Utility" # <- not as cumbersome
|
||||
|
||||
# Add albums from a collaboration system's threads
|
||||
my $gallery = WebGUI::Asset::Wobject::Gallery->new( ... );
|
||||
my $collab = WebGUI::Asset::Wobject::Collaboration->new( ... );
|
||||
$utility->addAlbumFromCollaboration( $gallery, $collab );
|
||||
|
||||
# Add a single album from a collaboration system thread
|
||||
my $thread = WebGUI::Asset::Post::Thread->new( ... );
|
||||
$utility->addAlbumFromThread( $gallery, $thread );
|
||||
|
||||
# Add a single album from a filesystem branch
|
||||
$utility->addAlbumFromFilesystem( $gallery, "/Users/Doug/Photos" );
|
||||
|
||||
# Add a single album for every folder in a filesystem branch
|
||||
$utility->addAlbumFromFilesystem(
|
||||
$gallery, "/Users/Doug/Photos",
|
||||
{
|
||||
multiple => 1,
|
||||
}
|
||||
);
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 addAlbumFromCollaboration ( gallery, collab )
|
||||
|
||||
Add an album or albums to the gallery from the given Collaboration System.
|
||||
C<gallery> is an instanciated Gallery asset. C<collab> is an instanciated
|
||||
Collaboration System asset.
|
||||
|
||||
Will add one album for every thread in the Collaboration System. Will call
|
||||
C<addAlbumFromThread> to do its dirty work.
|
||||
|
||||
=cut
|
||||
|
||||
sub addAlbumFromCollaboration {
|
||||
my $class = shift;
|
||||
my $gallery = shift;
|
||||
my $collab = shift;
|
||||
|
||||
croak "First argument must be Gallery asset"
|
||||
unless blessed $gallery && $gallery->isa('WebGUI::Asset::Wobject::Gallery');
|
||||
croak "Second argument must be Collaboration System asset"
|
||||
unless blessed $collab && $collab->isa('WebGUI::Asset::Wobject::Collaboration');
|
||||
|
||||
my $threads
|
||||
= $collab->getLineage(['descendants'], {
|
||||
returnObjects => 1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::Post::Thread'],
|
||||
statesToInclude => ['published'],
|
||||
statusToInclude => ['approved', 'archived', 'pending'],
|
||||
});
|
||||
|
||||
for my $thread ( @$threads ) {
|
||||
$class->addAlbumFromThread( $gallery, $thread );
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 addAlbumFromFilesystem ( gallery, root [, options] )
|
||||
|
||||
Add an album to the gallery from the file system. C<gallery> is an
|
||||
instanciated Gallery asset. C<root> is a location on the file system.
|
||||
|
||||
C<options> is a hash reference of options with the following keys:
|
||||
|
||||
multiple - Create multiple albums, one for each folder.
|
||||
|
||||
=cut
|
||||
|
||||
sub addAlbumFromFilesystem {
|
||||
my $class = shift;
|
||||
my $gallery = shift;
|
||||
my $root = shift;
|
||||
my $options = shift;
|
||||
|
||||
# TODO!!!
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 addAlbumFromThread ( gallery, thread )
|
||||
|
||||
Add an album to the gallery from the given Collaboration System thread.
|
||||
C<gallery> is an instanciated Gallery asset. C<thread> is an instanciated
|
||||
Thread asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub addAlbumFromThread {
|
||||
my $class = shift;
|
||||
my $gallery = shift;
|
||||
my $thread = shift;
|
||||
|
||||
croak "First argument must be Gallery asset"
|
||||
unless blessed $gallery && $gallery->isa('WebGUI::Asset::Wobject::Gallery');
|
||||
croak "Second argument must be Thread asset"
|
||||
unless blessed $thread && $thread->isa('WebGUI::Asset::Post::Thread');
|
||||
|
||||
my $session = $gallery->session;
|
||||
my $addOptions = { skipAutoCommitWorkflows => 1 };
|
||||
|
||||
# Create the new album
|
||||
my $album = $gallery->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::GalleryAlbum',
|
||||
description => $thread->get('content'),
|
||||
menuTitle => $thread->get('menuTitle'),
|
||||
createdBy => $thread->get('createdBy'),
|
||||
creationDate => $thread->get('creationDate'),
|
||||
ownerUserId => $thread->get('ownerUserId'),
|
||||
synopsis => $thread->get('synopsis'),
|
||||
title => $thread->get('title'),
|
||||
url => $session->url->urlize( $gallery->get('url') . "/" . $thread->get('title') ),
|
||||
userDefined1 => $thread->get('userDefined1'),
|
||||
userDefined2 => $thread->get('userDefined2'),
|
||||
userDefined3 => $thread->get('userDefined3'),
|
||||
userDefined4 => $thread->get('userDefined4'),
|
||||
userDefined5 => $thread->get('userDefined5'),
|
||||
}, undef, $thread->get('revisionDate'), $addOptions );
|
||||
|
||||
for my $post ( @{ $thread->getPosts } ) {
|
||||
if ( my $storageId = $post->get('storageId') ) {
|
||||
# Use WebGUI::Storage::Image to avoid thumbnails if there
|
||||
my $storage = WebGUI::Storage::Image->get( $session, $storageId );
|
||||
|
||||
for my $filename ( @{$storage->getFiles} ) {
|
||||
my $className = $gallery->getAssetClassForFile( $filename );
|
||||
if ( !$className ) {
|
||||
warn "Skipping $filename because Gallery doesn't handle this file type";
|
||||
next;
|
||||
}
|
||||
|
||||
# Get rid of that file extention
|
||||
my ($title) = $filename =~ m{(.*)\.[^.]*$};
|
||||
|
||||
my $file = $album->addChild({
|
||||
className => $className,
|
||||
createdBy => $post->get('createdBy'),
|
||||
creationDate => $post->get('creationDate'),
|
||||
menuTitle => $title,
|
||||
ownerUserId => $post->get('ownerUserId'),
|
||||
synopsis => $post->get('content'),
|
||||
title => $title,
|
||||
url => $session->url->urlize( $album->get('url') . "/" . $title ),
|
||||
userDefined1 => $post->get('userDefined1'),
|
||||
userDefined2 => $post->get('userDefined2'),
|
||||
userDefined3 => $post->get('userDefined3'),
|
||||
userDefined4 => $post->get('userDefined4'),
|
||||
userDefined5 => $post->get('userDefined5'),
|
||||
}, undef, $post->get('revisionDate'), $addOptions );
|
||||
|
||||
$file->setFile( $storage->getPath( $filename ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -120,16 +120,18 @@ sub addArchive {
|
|||
|
||||
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!" );
|
||||
# Remove the file extention
|
||||
$filename =~ s{\.[^.]+}{};
|
||||
|
||||
$properties->{ className } = $class;
|
||||
$properties->{ menuTitle } = $filename;
|
||||
$properties->{ title } = $filename;
|
||||
$properties->{ url } = $self->getUrl . "/" . $filename;
|
||||
$properties->{ url } = $self->session->url->urlize( $self->getUrl . "/" . $filename );
|
||||
|
||||
my $asset = $self->addChild( $properties, undef, undef, { skipAutoCommitWorkflows => 1 } );
|
||||
$asset->setFile( $filePath );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue