Refactor gallery code to use old i18n technologies so they can

be verified with the critic_labels test.
This commit is contained in:
Colin Kuskie 2009-01-28 22:20:39 +00:00
parent e345fd8706
commit 129d45ca2a
3 changed files with 13 additions and 72 deletions

View file

@ -50,7 +50,7 @@ sub definition {
my $class = shift; my $class = shift;
my $session = shift; my $session = shift;
my $definition = shift; my $definition = shift;
my $i18n = __PACKAGE__->i18n($session); my $i18n = WebGUI::International->new($session,'Asset_Photo');
tie my %properties, 'Tie::IxHash', ( tie my %properties, 'Tie::IxHash', (
views => { views => {
@ -508,23 +508,6 @@ sub getTemplateVars {
} }
#----------------------------------------------------------------------------
=head2 i18n ( session )
Get the i18n object for this class. This sub must not be inherited, so always
call it using C<__PACKAGE__>, not C<$self>.
=cut
sub i18n {
my $self = shift;
my $session = shift;
# TODO: Make a migration script to move the appropriate parts from
# Asset_Photo to Asset_GalleryFile
return WebGUI::International->new( $session, "Asset_Photo" );
}
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
=head2 isFriendsOnly ( ) =head2 isFriendsOnly ( )
@ -610,7 +593,7 @@ sub processCommentEditForm {
my $session = $self->session; my $session = $self->session;
my $form = $self->session->form; my $form = $self->session->form;
my $now = WebGUI::DateTime->new( $session, time ); my $now = WebGUI::DateTime->new( $session, time );
my $i18n = __PACKAGE__->i18n( $session ); my $i18n = WebGUI::International->new( $session,'Asset_Photo' );
# Using die here to suppress line number and file path info # Using die here to suppress line number and file path info
die $i18n->get("commentForm error no commentId") . "\n" die $i18n->get("commentForm error no commentId") . "\n"
@ -649,7 +632,7 @@ sub processCommentEditForm {
sub processPropertiesFromFormPost { sub processPropertiesFromFormPost {
my $self = shift; my $self = shift;
my $i18n = __PACKAGE__->i18n( $self->session ); my $i18n = WebGUI::International->new( $self->session,'Asset_Photo' );
my $form = $self->session->form; my $form = $self->session->form;
my $errors = $self->SUPER::processPropertiesFromFormPost || []; my $errors = $self->SUPER::processPropertiesFromFormPost || [];
@ -871,7 +854,7 @@ sub www_deleteComment {
return $session->privilege->insufficient unless $self->canEdit; return $session->privilege->insufficient unless $self->canEdit;
my $i18n = __PACKAGE__->i18n( $session ); my $i18n = WebGUI::International->new( $session,'Asset_Photo' );
my $commentId = $session->form->get('commentId'); my $commentId = $session->form->get('commentId');
$self->deleteComment( $commentId ); $self->deleteComment( $commentId );
@ -893,7 +876,7 @@ sub www_deleteConfirm {
return $self->session->privilege->insufficient unless $self->canEdit; return $self->session->privilege->insufficient unless $self->canEdit;
my $i18n = __PACKAGE__->i18n( $self->session ); my $i18n = WebGUI::International->new( $self->session,'Asset_Photo' );
$self->purge; $self->purge;
@ -965,7 +948,7 @@ Save a comment being edited
sub www_editCommentSave { sub www_editCommentSave {
my $self = shift; my $self = shift;
my $session = $self->session; my $session = $self->session;
my $i18n = __PACKAGE__->i18n( $session ); my $i18n = WebGUI::International->new( $session,'Asset_Photo' );
# Process the form first, so we can know how to check permissions # Process the form first, so we can know how to check permissions
my $comment = eval { $self->processCommentEditForm }; my $comment = eval { $self->processCommentEditForm };

View file

@ -70,7 +70,7 @@ sub definition {
my $class = shift; my $class = shift;
my $session = shift; my $session = shift;
my $definition = shift; my $definition = shift;
my $i18n = __PACKAGE__->i18n($session); my $i18n = WebGUI::International->new($session, 'Asset_Photo');
tie my %properties, 'Tie::IxHash', ( tie my %properties, 'Tie::IxHash', (
exifData => { exifData => {
@ -317,27 +317,6 @@ sub getThumbnailUrl {
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
=head2 i18n ( [ session ] )
Get a WebGUI::International object for this class.
Can be called as a class method, in which case a WebGUI::Session object
must be passed in.
NOTE: This method can NOT be inherited, due to a current limitation
in the i18n system. You must ALWAYS call this with C<__PACKAGE__>
=cut
sub i18n {
my $self = shift;
my $session = shift;
return WebGUI::International->new($session, "Asset_Photo");
}
#----------------------------------------------------------------------------
=head2 makeResolutions ( [resolutions] ) =head2 makeResolutions ( [resolutions] )
Create the specified resolutions for this Photo. If resolutions is not Create the specified resolutions for this Photo. If resolutions is not
@ -617,7 +596,7 @@ Provides links to view the photo and add more photos.
sub www_showConfirmation { sub www_showConfirmation {
my $self = shift; my $self = shift;
my $i18n = __PACKAGE__->i18n( $self->session ); my $i18n = WebGUI::International->new( $self->session, 'Asset_Photo' );
return $self->processStyle( return $self->processStyle(
sprintf( $i18n->get('save message'), sprintf( $i18n->get('save message'),

View file

@ -44,7 +44,7 @@ sub definition {
my $class = shift; my $class = shift;
my $session = shift; my $session = shift;
my $definition = shift; my $definition = shift;
my $i18n = __PACKAGE__->i18n($session); my $i18n = WebGUI::International->new($session, 'Asset_GalleryAlbum');
tie my %properties, 'Tie::IxHash', ( tie my %properties, 'Tie::IxHash', (
allowComments => { allowComments => {
@ -352,27 +352,6 @@ sub DESTROY {
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
=head2 i18n ( session )
Get a WebGUI::International object for this class.
Can be called as a class method, in which case a WebGUI::Session object
must be passed in.
NOTE: This method can NOT be inherited, due to a current limitation
in the i18n system. You must ALWAYS call this with C<__PACKAGE__>
=cut
sub i18n {
my $self = shift;
my $session = shift;
return WebGUI::International->new($session, "Asset_GalleryAlbum");
}
#----------------------------------------------------------------------------
=head2 getAutoCommitWorkflowId ( ) =head2 getAutoCommitWorkflowId ( )
Returns the workflowId of the Gallery's approval workflow. Returns the workflowId of the Gallery's approval workflow.
@ -937,7 +916,7 @@ sub www_addArchiveSave {
my $session = $self->session; my $session = $self->session;
my $form = $self->session->form; my $form = $self->session->form;
my $i18n = __PACKAGE__->i18n( $session ); my $i18n = WebGUI::International->new( $session, 'Asset_GalleryAlbum' );
my $properties = { my $properties = {
keywords => $form->get("keywords"), keywords => $form->get("keywords"),
friendsOnly => $form->get("friendsOnly"), friendsOnly => $form->get("friendsOnly"),
@ -1093,7 +1072,7 @@ sub www_deleteConfirm {
return $self->session->privilege->insufficient unless $self->canEdit; return $self->session->privilege->insufficient unless $self->canEdit;
my $gallery = $self->getParent; my $gallery = $self->getParent;
my $i18n = __PACKAGE__->i18n( $self->session ); my $i18n = WebGUI::International->new( $self->session, 'Asset_GalleryAlbum' );
$self->purge; $self->purge;
@ -1119,7 +1098,7 @@ sub www_edit {
my $session = $self->session; my $session = $self->session;
my $form = $self->session->form; my $form = $self->session->form;
my $var = $self->getTemplateVars; my $var = $self->getTemplateVars;
my $i18n = __PACKAGE__->i18n($session); my $i18n = WebGUI::International->new($session, 'Asset_GalleryAlbum');
return $session->privilege->insufficient unless $self->canEdit; return $session->privilege->insufficient unless $self->canEdit;
@ -1299,7 +1278,7 @@ Provides links to view the album.
sub www_showConfirmation { sub www_showConfirmation {
my $self = shift; my $self = shift;
my $i18n = __PACKAGE__->i18n( $self->session ); my $i18n = WebGUI::International->new( $self->session, 'Asset_GalleryAlbum' );
my $output = '<p>' . sprintf( $i18n->get('save message'), $self->getUrl ) . '</p>' my $output = '<p>' . sprintf( $i18n->get('save message'), $self->getUrl ) . '</p>'
. '<p>' . $i18n->get('what next') . '</p>' . '<p>' . $i18n->get('what next') . '</p>'