added Next and Previous GalleryAlbum links in the Album Views

This commit is contained in:
Doug Bell 2008-06-19 18:49:47 +00:00
parent 5c2b9351fd
commit f2679ae07e
5 changed files with 165 additions and 5 deletions

View file

@ -21,6 +21,7 @@
- fixed: Gallery Edit Album buttons did not work properly in IE
- fixed: Cannot embed YouTube videos in IE6/7. Fixed by adding an "Allow Media"
switch to the RichEdit asset.
- added: Next and Previous GalleryAlbum links in the GalleryAlbum views
7.5.12
- skipping this release

View file

@ -554,7 +554,9 @@ sub canView {
Gets an array reference of all the album IDs under this Gallery. C<options>
is a hash reference with the following keys.
orderBy => An SQL ORDER BY clause to sort the albums
orderBy => An SQL ORDER BY clause to sort the albums.
By default, uses the viewListOrderBy and viewListOrderDirection keys from
the asset properties.
=cut
@ -562,7 +564,12 @@ sub getAlbumIds {
my $self = shift;
my $options = shift;
my $orderBy = $options->{ orderBy } || "lineage ASC";
my $orderBy = $options->{ orderBy }
? $options->{ orderBy }
: $self->get( 'viewListOrderBy' )
? join( " ", $self->get( 'viewListOrderBy' ), $self->get( 'viewListOrderDirection' ) )
: "lineage ASC"
;
# Deal with "pending" albums.
my %pendingRules;
@ -668,6 +675,58 @@ sub getImageResolutions {
#----------------------------------------------------------------------------
=head2 getNextAlbumId ( albumId )
Gets the next albumId from the list of albumIds. C<albumId> is the base
albumId we want to find the next album for.
Returns C<undef> if there is no next albumId.
=cut
sub getNextAlbumId {
my $self = shift;
my $albumId = shift;
my $allAlbumIds = $self->getAlbumIds;
while ( my $checkId = shift @{ $allAlbumIds } ) {
# If this is the last albumId
return undef unless @{ $allAlbumIds };
if ( $albumId eq $checkId ) {
return shift @{ $allAlbumIds };
}
}
}
#----------------------------------------------------------------------------
=head2 getPreviousAlbumId ( albumId )
Gets the previous albumId from the list of albumIds. C<albumId> is the base
albumId we want to find the previous album for.
Returns C<undef> if there is no previous albumId.
=cut
sub getPreviousAlbumId {
my $self = shift;
my $albumId = shift;
my $allAlbumIds = $self->getAlbumIds;
while ( my $checkId = pop @{ $allAlbumIds } ) {
# If this is the last albumId
return undef unless @{ $allAlbumIds };
if ( $albumId eq $checkId ) {
return pop @{ $allAlbumIds };
}
}
}
#----------------------------------------------------------------------------
=head2 getSearchPaginator ( rules )
Gets a WebGUI::Paginator for a search. C<rules> is a hash reference of
@ -925,12 +984,9 @@ sub view_listAlbums {
my $var = $self->getTemplateVars;
my $form = $self->session->form;
my $orderBy = $self->get('viewListOrderBy')
. q{ } . $self->get('viewListOrderDirection');
my $p
= $self->getAlbumPaginator( {
perpage => ( $form->get('perpage') || 20 ),
orderBy => $orderBy,
} );
$p->appendTemplateVars( $var );

View file

@ -450,6 +450,38 @@ sub getFilePaginator {
#----------------------------------------------------------------------------
=head2 getNextAlbum ( )
Get the next album from the Gallery. Returns an instance of a GalleryAlbum,
or undef if there is no next album.
=cut
sub getNextAlbum {
my $self = shift;
my $nextId = $self->getParent->getNextAlbumId( $self->getId );
return undef unless $nextId;
return WebGUI::Asset->newByDynamicClass( $self->session, $nextId );
}
#----------------------------------------------------------------------------
=head2 getPreviousAlbum ( )
Get the previous album from the Gallery. Returns an instance of a GalleryAlbum,
or undef if there is no previous album.
=cut
sub getPreviousAlbum {
my $self = shift;
my $previousId = $self->getParent->getPreviousAlbumId( $self->getId );
return undef unless $previousId;
return WebGUI::Asset->newByDynamicClass( $self->session, $previousId );
}
#----------------------------------------------------------------------------
=head2 getTemplateVars ( )
Gets template vars common to all views.
@ -491,6 +523,17 @@ sub getTemplateVars {
$var->{ url_viewRss } = $self->getUrl("func=viewRss");
$var->{ url_slideshow } = $self->getUrl("func=slideshow");
$var->{ url_thumbnails } = $self->getUrl("func=thumbnails");
if ( my $nextAlbum = $self->getNextAlbum ) {
$var->{ nextAlbum_url } = $nextAlbum->getUrl;
$var->{ nextAlbum_title } = $nextAlbum->get( "title" );
$var->{ nextAlbum_thumbnailUrl } = $nextAlbum->getThumbnailUrl;
}
if ( my $prevAlbum = $self->getPreviousAlbum ) {
$var->{ previousAlbum_url } = $prevAlbum->getUrl;
$var->{ previousAlbum_title } = $prevAlbum->get( "title" );
$var->{ previousAlbum_thumbnailUrl } = $prevAlbum->getThumbnailUrl;
}
$var->{ fileCount } = $self->getChildCount;
$var->{ ownerUsername } = $owner->username;

View file

@ -76,6 +76,30 @@ our $HELP = {
name => 'url_thumbnails',
description => 'helpvar url_thumbnails',
},
{
name => 'nextAlbum_url',
description => 'helpvar nextAlbum_url',
},
{
name => 'nextAlbum_title',
description => 'helpvar nextAlbum_title',
},
{
name => 'nextAlbum_thumbnailUrl',
description => 'helpvar nextAlbum_thumbnailUrl',
},
{
name => 'previousAlbum_url',
description => 'helpvar previousAlbum_url',
},
{
name => 'previousAlbum_title',
description => 'helpvar previousAlbum_title',
},
{
name => 'previousAlbum_thumbnailUrl',
description => 'helpvar previousAlbum_thumbnailUrl',
},
{
name => 'fileCount',
description => 'helpvar fileCount',

View file

@ -514,6 +514,42 @@ our $I18N = {
context => q{Description of template variable},
},
'helpvar nextAlbum_url' => {
message => q{The URL to the next album in the list, in the order that is shown on the Gallery List Albums view. If there is no next album, this variable will not exist.},
lastUpdated => 0,
context => q{Description of template variable},
},
'helpvar previousAlbum_url' => {
message => q{The URL to the previous album in the list, in the order that is shown on the Gallery List Albums view. If there is no previous album, this variable will not exist.},
lastUpdated => 0,
context => q{Description of template variable},
},
'helpvar nextAlbum_title' => {
message => q{The title for the next album in the list.},
lastUpdated => 0,
context => q{Description of template variable},
},
'helpvar nextAlbum_thumbnailUrl' => {
message => q{The URL to the thumbnail image for the next album in the list.},
lastUpdated => 0,
context => q{Description of template variable},
},
'helpvar previousAlbum_title' => {
message => q{The title for the previous album in the list.},
lastUpdated => 0,
context => q{Description of template variable},
},
'helpvar previousAlbum_thumbnailUrl' => {
message => q{The URL to the thumbnail image for the previous album in the list.},
lastUpdated => 0,
context => q{Description of template variable},
},
};
1;