diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index bcaaef1f6..97f813f84 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -4,6 +4,12 @@ redirected to after the login / createAccount is done. - RFE: Spectre diagnostics on version tag commit (perlDreamer Consulting, LLC.) http://www.plainblack.com/rfe/request-for-enhancement/spectre-diagnostics-on-version-tag-commit + - 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 7.5.1 - fix: Extra head tags of unplaced assets included twice diff --git a/docs/upgrades/upgrade_7.5.1-7.5.2.pl b/docs/upgrades/upgrade_7.5.1-7.5.2.pl index 279dd8b91..c6451de4e 100644 --- a/docs/upgrades/upgrade_7.5.1-7.5.2.pl +++ b/docs/upgrades/upgrade_7.5.1-7.5.2.pl @@ -23,6 +23,7 @@ my $quiet; # this line required my $session = start(); # this line required # upgrade functions go here +addViewsColumnToPhoto( $session ); finish($session); # this line required @@ -34,6 +35,16 @@ finish($session); # this line required # # and here's our code #} +#---------------------------------------------------------------------------- +# Add the views column to the Photo asset +sub addViewsColumnToPhoto { + my $session = shift; + print "\tAdding 'views' column to Photo asset... " unless $quiet; + $session->db->write( + "ALTER TABLE Photo ADD COLUMN views BIGINT" + ); + print "DONE!\n" unless $quiet; +} # --------------- DO NOT EDIT BELOW THIS LINE -------------------------------- diff --git a/lib/WebGUI/Asset/File/Image/Photo.pm b/lib/WebGUI/Asset/File/Image/Photo.pm index ccc75219c..58d4eca88 100644 --- a/lib/WebGUI/Asset/File/Image/Photo.pm +++ b/lib/WebGUI/Asset/File/Image/Photo.pm @@ -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; diff --git a/lib/WebGUI/Macro/International.pm b/lib/WebGUI/Macro/International.pm index 69c1e1af7..0fa866d4f 100644 --- a/lib/WebGUI/Macro/International.pm +++ b/lib/WebGUI/Macro/International.pm @@ -21,7 +21,7 @@ Package WebGUI::Macro::International Macro for displaying an internationalized label from WebGUI's internationalization system. -=head2 process ( label, namespace ) +=head2 process ( label, namespace [, placeholder values] ) Note that a particular language cannot be specified. It uses either the current User's setting or the default language for the site. English is @@ -35,14 +35,28 @@ The label to pull. The namespace to pull the label from. +=head3 placeholder values + +The values to be used in the field placeholders. + =cut #------------------------------------------------------------------- sub process { - my ($session, $key, $namespace) = @_; + my $session = shift; + my $key = shift; + my $namespace = shift; + my @args = @_; + my $i18n = WebGUI::International->new($session); - return $i18n->get($key, $namespace); + + if (@args) { + return sprintf $i18n->get($key, $namespace), @args; + } + else { + return $i18n->get($key, $namespace); + } } diff --git a/lib/WebGUI/i18n/English/Asset_Gallery.pm b/lib/WebGUI/i18n/English/Asset_Gallery.pm index 9fe2e6a4d..ca472955e 100644 --- a/lib/WebGUI/i18n/English/Asset_Gallery.pm +++ b/lib/WebGUI/i18n/English/Asset_Gallery.pm @@ -611,11 +611,46 @@ our $I18N = { }, 'template by' => { - message => "By", + message => 'By', lastUpdated => 0, - context => "Lead-in for the user the album or photo was uploaded by", + context => q{Lead-in for the author of an Album or Photo}, }, + 'template galleryalbum url' => { + message => 'View Album', + lastUpdated => 0, + context => 'Label for link from List Albums view to GalleryAlbum view', + }, + + 'template url_search' => { + message => 'Advanced Search', + lastUpdated => 0, + context => 'Label for link to the Gallery search page.', + }, + + 'template url_listFilesForCurrentUser' => { + message => 'My Gallery', + lastUpdated => 0, + context => q{Label for link to view the current user's files and albums.}, + }, + + 'template listFilesForUser title' => { + message => q{%s's Gallery}, + lastUpdated => 0, + context => q{Label for List Files For User view. '%s' will be replaced with the username}, + }, + + 'template listFilesForUser albums title' => { + message => q{Albums}, + lastUpdated => 0, + context => q{Title for list of user's Albums}, + }, + + 'template listFilesForUser albums files' => { + message => q{files}, + lastUpdated => 0, + context => q{Label for number of files in the Album}, + }, }; diff --git a/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm b/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm index c487e0ea8..ced250b8b 100644 --- a/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm +++ b/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm @@ -306,6 +306,53 @@ our $I18N = { lastUpdated => 0, }, + 'template url_addPhoto' => { + message => 'Add a Photo', + lastUpdated => 0, + context => 'Label for URL to add a new Photo asset.', + }, + + 'template url_delete' => { + message => 'Delete Album', + lastUpdated => 0, + context => 'Label for URL to delete this Album', + }, + + 'template url_edit' => { + message => 'Edit Album', + lastUpdated => 0, + context => 'Label for URL to edit this Album', + }, + + 'template url_thumbnails' => { + message => 'Thumbnails', + lastUpdated => 0, + context => 'Label for URL to the Thumbnails view of the Album', + }, + + 'template url_slideshow' => { + message => 'Slideshow', + lastUpdated => 0, + context => 'Label for URL to the Slideshow view of the album', + }, + + 'template url' => { + message => 'Album', + lastUpdated => 0, + context => 'Label for URL to the default view of the album', + }, + + 'template file creationDate' => { + message => 'Uploaded on', + lastUpdated => 0, + context => 'Label for the creation date of the file', + }, + + 'template file numberOfComments' => { + message => 'Comments', + lastUpdated => 0, + context => 'Label for the number of comments on the file', + }, }; 1; diff --git a/lib/WebGUI/i18n/English/Asset_Photo.pm b/lib/WebGUI/i18n/English/Asset_Photo.pm index b01714d40..5f7bd070b 100644 --- a/lib/WebGUI/i18n/English/Asset_Photo.pm +++ b/lib/WebGUI/i18n/English/Asset_Photo.pm @@ -296,6 +296,108 @@ our $I18N = { lastUpdated => 0, }, + 'template view title' => { + message => 'Photo Details', + lastUpdated => 0, + context => 'The title of the default view of Photo assets', + }, + + 'template url_edit' => { + message => 'Edit Photo', + lastUpdated => 0, + context => 'The label for the Edit Photo button', + }, + + 'template url_delete' => { + message => 'Delete Photo', + lastUpdated => 0, + context => 'The label for the delete photo button', + }, + + 'template url_makeShortcut' => { + message => 'Cross Publish', + lastUpdated => 0, + context => 'The label for the button to make a shortcut in another album', + }, + + 'template url_album' => { + message => 'Back to Album', + lastUpdated => 0, + context => 'Label for the link to go back to the album', + }, + + 'template fileUrl' => { + message => 'View Full Size Image', + lastUpdated => 0, + context => 'Link to the full size image', + }, + + 'template comments title' => { + message => 'Comments', + lastUpdated => 0, + context => 'Title for the comments section of the photo page.', + }, + + 'template comment creationDate' => { + message => 'Posted On', + lastUpdated => 0, + context => 'Label for creation date of comment', + }, + + 'template comment delete confirm' => { + message => 'Are you sure you want to delete this comment?', + lastUpdated => 0, + context => 'Confirmation message for deleting a comment.', + }, + + 'template url_deleteComment' => { + message => 'delete', + lastUpdated => 0, + context => 'Label for delete link for comments.', + }, + + 'template creationDate' => { + message => 'Uploaded on', + lastUpdated => 0, + context => 'Label for creation date of photo', + }, + + 'template views' => { + message => 'Views', + lastUpdated => 0, + context => 'Label for number of views of photo', + }, + + 'template keywords' => { + message => 'Tags', + lastUpdated => 0, + context => 'Label for the keywords of the photo', + }, + + 'template location' => { + message => 'Location', + lastUpdated => 0, + context => 'Label for the location of the photo', + }, + + 'template friendsOnly label' => { + message => 'Privacy', + lastUpdated => 0, + context => 'Label for the friends only setting.', + }, + + 'template friendsOnly yes' => { + message => 'Friends Only', + lastUpdated => 0, + context => 'Label for photos that are friends only', + }, + + 'template friendsOnly no' => { + message => 'Public', + lastUpdated => 0, + context => 'Label for photos that are not friends only', + }, + }; 1;