performance increases to the Gallery, bug #4103

This commit is contained in:
Doug Bell 2008-10-28 21:52:05 +00:00
parent fec49433c3
commit f5aafd53e0
3 changed files with 107 additions and 49 deletions

View file

@ -472,35 +472,16 @@ sub getTemplateVars {
}
}
# Add some things from Gallery
my $galleryVar = $self->getGallery->getTemplateVars;
for my $key ( qw{ url_listFilesForCurrentUser url_search } ) {
$var->{ $key } = $galleryVar->{ $key };
}
# More things from Gallery, but with different names
for my $key ( qw{ title menuTitle url } ) {
$var->{ "gallery_" . $key } = $galleryVar->{ $key };
}
# Add some things from Album
my $album = $self->getParent;
my $albumVar = $album->getTemplateVars;
for my $key ( qw{ title menuTitle url thumbnailUrl } ) {
$var->{ "album_" . $key } = $albumVar->{ $key };
}
# Add the search form
$self->getGallery->appendTemplateVarsSearchForm( $var );
# Add a text-only synopsis
$var->{ synopsis_textonly } = WebGUI::HTML::filter( $self->get('synopsis'), "all" );
# Figure out on what page of the album the gallery file belongs.
my $album = $self->getParent;
my $fileIdsInAlbum = $album->getFileIds;
my $id = $self->getId;
my $pageNumber =
int (
( first_index { $_ eq $self->getId } @{ $fileIdsInAlbum } ) # Get index of file in album
( first_index { $_ eq $id } @{ $fileIdsInAlbum } ) # Get index of file in album
/ $album->getParent->get( 'defaultFilesPerPage' ) # Divide by the number of files per page
) + 1; # Round upwards
@ -773,6 +754,27 @@ sub view {
$self->appendTemplateVarsCommentForm( $var );
# Add the search form
$self->getGallery->appendTemplateVarsSearchForm( $var );
# Add some things from Gallery
my $galleryVar = $self->getGallery->getTemplateVars;
for my $key ( qw{ url_listFilesForCurrentUser url_search } ) {
$var->{ $key } = $galleryVar->{ $key };
}
# More things from Gallery, but with different names
for my $key ( qw{ title menuTitle url } ) {
$var->{ "gallery_" . $key } = $galleryVar->{ $key };
}
# Add some things from Album
my $album = $self->getParent;
my $albumVar = $album->getTemplateVars;
for my $key ( qw{ title menuTitle url thumbnailUrl } ) {
$var->{ "album_" . $key } = $albumVar->{ $key };
}
# Keywords
my $k = WebGUI::Keyword->new( $session );
my $keywords = $k->getKeywordsForAsset( { asArrayRef => 1, asset => $self } );