Added additional navigation to the photo asset (RFE 11412).

This commit is contained in:
kimd 2010-03-24 22:07:41 +01:00 committed by Doug Bell
parent 5ded2ea89d
commit 8104338da7
10 changed files with 505 additions and 2 deletions

View file

@ -438,6 +438,76 @@ sub getParent {
#----------------------------------------------------------------------------
=head2 getFirstFile ( )
Get the first file in the GalleryAlbum. Returns an instance of a GalleryFile
or undef if there is no first file.
=cut
sub getFirstFile {
my $self = shift;
my $allFileIds = $self->getParent->getFileIds;
return undef unless @{ $allFileIds };
return WebGUI::Asset->newByDynamicClass( $self->session, shift @{ $allFileIds });
}
#----------------------------------------------------------------------------
=head2 getLastFile ( )
Get the last file in the GalleryAlbum. Returns an instance of a GalleryFile
or undef if there is no last file.
=cut
sub getLastFile {
my $self = shift;
my $allFileIds = $self->getParent->getFileIds;
return undef unless @{ $allFileIds };
return WebGUI::Asset->newByDynamicClass( $self->session, pop @{ $allFileIds });
}
#----------------------------------------------------------------------------
=head2 getNextFile ( )
Get the next file in the GalleryAlbum. Returns an instance of a GalleryFile,
or undef if there is no next file.
=cut
sub getNextFile {
my $self = shift;
return $self->{_nextFile} if $self->{_nextFile};
my $nextId = $self->getParent->getNextFileId( $self->getId );
return undef unless $nextId;
$self->{_nextFile} = WebGUI::Asset->newByDynamicClass( $self->session, $nextId );
return $self->{_nextFile};
}
#----------------------------------------------------------------------------
=head2 getPreviousFile ( )
Get the previous file in the GalleryAlbum. Returns an instance of a GalleryFile,
or undef if there is no previous file.
=cut
sub getPreviousFile {
my $self = shift;
return $self->{_previousFile} if $self->{_previousFile};
my $previousId = $self->getParent->getPreviousFileId( $self->getId );
return undef unless $previousId;
$self->{_previousFile} = WebGUI::Asset->newByDynamicClass( $self->session, $previousId );
return $self->{_previousFile};
}
#----------------------------------------------------------------------------
=head2 getThumbnailUrl ( )
Gets the URL to the thumbnail for this GalleryFile. This should probably be
@ -512,10 +582,30 @@ sub getTemplateVars {
= $self->getGallery->getUrl('func=listFilesForUser;userId=' . $self->get("ownerUserId"));
$var->{ url_promote } = $self->getUrl('func=promote');
if ( my $firstFile = $self->getFirstFile ) {
$var->{ firstFile_url } = $firstFile->getUrl;
$var->{ firstFile_title } = $firstFile->get( "title" );
$var->{ firstFile_thumbnailUrl } = $firstFile->getThumbnailUrl;
}
if ( my $nextFile = $self->getNextFile ) {
$var->{ nextFile_url } = $nextFile->getUrl;
$var->{ nextFile_title } = $nextFile->get( "title" );
$var->{ nextFile_thumbnailUrl } = $nextFile->getThumbnailUrl;
}
if ( my $prevFile = $self->getPreviousFile ) {
$var->{ previousFile_url } = $prevFile->getUrl;
$var->{ previousFile_title } = $prevFile->get( "title" );
$var->{ previousFile_thumbnailUrl } = $prevFile->getThumbnailUrl;
}
if ( my $lastFile = $self->getLastFile ) {
$var->{ lastFile_url } = $lastFile->getUrl;
$var->{ lastFile_title } = $lastFile->get( "title" );
$var->{ lastFile_thumbnailUrl } = $lastFile->getThumbnailUrl;
}
return $var;
}
#----------------------------------------------------------------------------
=head2 isFriendsOnly ( )

View file

@ -460,6 +460,58 @@ sub getFileIds {
#----------------------------------------------------------------------------
=head2 getNextFileId ( fileId )
Gets the next fileId from the list of fileIds. C<fileId> is the base
fileId we want to find the next file for.
Returns C<undef> if there is no next fileId.
=cut
sub getNextFileId {
my $self = shift;
my $fileId = shift;
my $allFileIds = $self->getFileIds;
while ( my $checkId = shift @{ $allFileIds } ) {
# If this is the last albumId
return undef unless @{ $allFileIds };
if ( $fileId eq $checkId ) {
return shift @{ $allFileIds };
}
}
}
#----------------------------------------------------------------------------
=head2 getPreviousFileId ( fileId )
Gets the previous fileId from the list of fileIds. C<fileId> is the base
fileId we want to find the previous file for.
Returns C<undef> if there is no previous fileId.
=cut
sub getPreviousFileId {
my $self = shift;
my $fileId = shift;
my $allFileIds = $self->getFileIds;
while ( my $checkId = pop @{ $allFileIds } ) {
# If this is the last albumId
return undef unless @{ $allFileIds };
if ( $fileId eq $checkId ) {
return pop @{ $allFileIds };
}
}
}
#----------------------------------------------------------------------------
=head2 getFilePaginator ( paginatorUrl )
Gets a WebGUI::Paginator for the files in this album. C<paginatorUrl> is the

View file

@ -174,6 +174,54 @@ our $HELP = {
name => 'album_url',
description => 'helpvar album_url',
},
{
name => 'firstFile_url',
description => 'helpvar firstFile_url',
},
{
name => 'firstFile_title',
description => 'helpvar firstFile_title',
},
{
name => 'firstFile_thumbnailUrl',
description => 'helpvar firstFile_thumbnailUrl',
},
{
name => 'nextFile_url',
description => 'helpvar nextFile_url',
},
{
name => 'nextFile_title',
description => 'helpvar nextFile_title',
},
{
name => 'nextFile_thumbnailUrl',
description => 'helpvar nextFile_thumbnailUrl',
},
{
name => 'previousFile_url',
description => 'helpvar previousFile_url',
},
{
name => 'previousFile_title',
description => 'helpvar previousFile_title',
},
{
name => 'previousFile_thumbnailUrl',
description => 'helpvar previousFile_thumbnailUrl',
},
{
name => 'lastFile_url',
description => 'helpvar lastFile_url',
},
{
name => 'lastFile_title',
description => 'helpvar lastFile_title',
},
{
name => 'lastFile_thumbnailUrl',
description => 'helpvar lastFile_thumbnailUrl',
},
],
},

View file

@ -307,6 +307,66 @@ our $I18N = {
lastUpdated => 0,
},
'helpvar firstFile_url' => {
message => 'The URL of the first file in the album.',
lastUpdated => 0,
},
'helpvar firstFile_title' => {
message => 'The title of the first file in the album.',
lastUpdated => 0,
},
'helpvar firstFile_thumbnailUrl' => {
message => 'The URL of the thumbnail of the first file in the album.',
lastUpdated => 0,
},
'helpvar nextFile_url' => {
message => 'The URL of the next file in the album. Undefined if no next file.',
lastUpdated => 0,
},
'helpvar nextFile_title' => {
message => 'The title of the next file in the album. Undefined if no next file.',
lastUpdated => 0,
},
'helpvar nextFile_thumbnailUrl' => {
message => 'The URL of the thumbnail of the next file in the album. Undefined if no next file.',
lastUpdated => 0,
},
'helpvar previousFile_url' => {
message => 'The URL of the previous file in the album. Undefined if no previous file.',
lastUpdated => 0,
},
'helpvar previousFile_title' => {
message => 'The title of the previous file in the album. Undefined if no previous file.',
lastUpdated => 0,
},
'helpvar previousFile_thumbnailUrl' => {
message => 'The URL of the thumbnail of the previous file in the album. Undefined if no previous file.',
lastUpdated => 0,
},
'helpvar lastFile_url' => {
message => 'The URL of the last file in the album.',
lastUpdated => 0,
},
'helpvar lastFile_title' => {
message => 'The title of the last file in the album.',
lastUpdated => 0,
},
'helpvar lastFile_thumbnailUrl' => {
message => 'The URL of the thumbnail of the last file in the album.',
lastUpdated => 0,
},
'template view title' => {
message => 'Photo Details',
lastUpdated => 0,