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:
Doug Bell 2008-02-12 00:55:06 +00:00
parent 6c72ee9a41
commit fa156af1a9
7 changed files with 265 additions and 5 deletions

View file

@ -4,6 +4,12 @@
redirected to after the login / createAccount is done. redirected to after the login / createAccount is done.
- RFE: Spectre diagnostics on version tag commit (perlDreamer Consulting, LLC.) - RFE: Spectre diagnostics on version tag commit (perlDreamer Consulting, LLC.)
http://www.plainblack.com/rfe/request-for-enhancement/spectre-diagnostics-on-version-tag-commit 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 7.5.1
- fix: Extra head tags of unplaced assets included twice - fix: Extra head tags of unplaced assets included twice

View file

@ -23,6 +23,7 @@ my $quiet; # this line required
my $session = start(); # this line required my $session = start(); # this line required
# upgrade functions go here # upgrade functions go here
addViewsColumnToPhoto( $session );
finish($session); # this line required finish($session); # this line required
@ -34,6 +35,16 @@ finish($session); # this line required
# # and here's our code # # 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 -------------------------------- # --------------- DO NOT EDIT BELOW THIS LINE --------------------------------

View file

@ -20,6 +20,7 @@ use base 'WebGUI::Asset::File::Image';
use Carp qw( carp croak ); use Carp qw( carp croak );
use Image::ExifTool qw( :Public ); use Image::ExifTool qw( :Public );
use JSON qw/ to_json from_json /; use JSON qw/ to_json from_json /;
use URI::Escape;
use Tie::IxHash; use Tie::IxHash;
use WebGUI::DateTime; use WebGUI::DateTime;
@ -71,6 +72,9 @@ sub definition {
my $i18n = __PACKAGE__->i18n($session); my $i18n = __PACKAGE__->i18n($session);
tie my %properties, 'Tie::IxHash', ( tie my %properties, 'Tie::IxHash', (
views => {
defaultValue => 0,
},
exifData => { exifData => {
defaultValue => undef, defaultValue => undef,
}, },
@ -723,8 +727,23 @@ sub view {
$self->appendTemplateVarsForCommentForm( $var ); $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; my $p = $self->getCommentPaginator;
for my $comment ( @{ $p->getPageData } ) { for my $comment ( @{ $p->getPageData } ) {
$comment->{ url_deleteComment }
= $self->getUrl('func=deleteComment;commentId=' . $comment->{commentId} );
my $user = WebGUI::User->new( $session, $comment->{userId} ); my $user = WebGUI::User->new( $session, $comment->{userId} );
$comment->{ username } = $user->username; $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 ( ) =head2 www_deleteConfirm ( )
Confirm the deletion of this Photo. Show a message and a link back to the 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; 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->setLastModified($self->getContentLastModified);
$self->session->http->sendHeader; $self->session->http->sendHeader;
$self->prepareView; $self->prepareView;

View file

@ -21,7 +21,7 @@ Package WebGUI::Macro::International
Macro for displaying an internationalized label from WebGUI's internationalization system. 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 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 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. The namespace to pull the label from.
=head3 placeholder values
The values to be used in the field placeholders.
=cut =cut
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub process { sub process {
my ($session, $key, $namespace) = @_; my $session = shift;
my $key = shift;
my $namespace = shift;
my @args = @_;
my $i18n = WebGUI::International->new($session); 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);
}
} }

View file

@ -611,11 +611,46 @@ our $I18N = {
}, },
'template by' => { 'template by' => {
message => "By", message => 'By',
lastUpdated => 0, 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},
},
}; };

View file

@ -306,6 +306,53 @@ our $I18N = {
lastUpdated => 0, 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; 1;

View file

@ -296,6 +296,108 @@ our $I18N = {
lastUpdated => 0, 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; 1;