add: i18n for more Gallery templates
add: International macro now takes sprintf arguments as third and subsequent parameters add: Keywords are now processed and given to the photo template, along with a url to search the gallery for the keyword. add: Photos now track views
This commit is contained in:
parent
6c72ee9a41
commit
fa156af1a9
7 changed files with 265 additions and 5 deletions
|
|
@ -20,6 +20,7 @@ use base 'WebGUI::Asset::File::Image';
|
|||
use Carp qw( carp croak );
|
||||
use Image::ExifTool qw( :Public );
|
||||
use JSON qw/ to_json from_json /;
|
||||
use URI::Escape;
|
||||
use Tie::IxHash;
|
||||
|
||||
use WebGUI::DateTime;
|
||||
|
|
@ -71,6 +72,9 @@ sub definition {
|
|||
my $i18n = __PACKAGE__->i18n($session);
|
||||
|
||||
tie my %properties, 'Tie::IxHash', (
|
||||
views => {
|
||||
defaultValue => 0,
|
||||
},
|
||||
exifData => {
|
||||
defaultValue => undef,
|
||||
},
|
||||
|
|
@ -723,8 +727,23 @@ sub view {
|
|||
|
||||
$self->appendTemplateVarsForCommentForm( $var );
|
||||
|
||||
# Keywords
|
||||
my $k = WebGUI::Keyword->new( $session );
|
||||
my $keywords = $k->getKeywordsForAsset( { asArrayRef => 1, asset => $self } );
|
||||
for my $keyword ( @{ $keywords } ) {
|
||||
push @{ $var->{keywords} }, {
|
||||
url_searchKeyword
|
||||
=> $self->getGallery->getUrl("func=search;submit=1;keywords=" . uri_escape($keyword) ),
|
||||
keyword => $keyword,
|
||||
};
|
||||
}
|
||||
|
||||
# Comments
|
||||
my $p = $self->getCommentPaginator;
|
||||
for my $comment ( @{ $p->getPageData } ) {
|
||||
$comment->{ url_deleteComment }
|
||||
= $self->getUrl('func=deleteComment;commentId=' . $comment->{commentId} );
|
||||
|
||||
my $user = WebGUI::User->new( $session, $comment->{userId} );
|
||||
$comment->{ username } = $user->username;
|
||||
|
||||
|
|
@ -797,6 +816,29 @@ sub www_delete {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteComment ( )
|
||||
|
||||
Delete a comment immediately. Only those who can edit this Photo can delete
|
||||
comments on it.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_deleteComment {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
return $session->privilege->insufficient unless $self->canEdit;
|
||||
|
||||
my $i18n = __PACKAGE__->i18n( $session );
|
||||
my $commentId = $session->form->get('commentId');
|
||||
|
||||
$self->deleteComment( $commentId );
|
||||
|
||||
return $self->www_view;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_deleteConfirm ( )
|
||||
|
||||
Confirm the deletion of this Photo. Show a message and a link back to the
|
||||
|
|
@ -1107,6 +1149,9 @@ sub www_view {
|
|||
|
||||
return $self->session->privilege->insufficient unless $self->canView;
|
||||
|
||||
# Add to views
|
||||
$self->update({ views => $self->get('views') + 1 });
|
||||
|
||||
$self->session->http->setLastModified($self->getContentLastModified);
|
||||
$self->session->http->sendHeader;
|
||||
$self->prepareView;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue