diff --git a/docs/upgrades/packages-7.7.0/root_import_storymanager.wgpkg b/docs/upgrades/packages-7.7.0/root_import_storymanager.wgpkg index f0afef65e..ca8add516 100644 Binary files a/docs/upgrades/packages-7.7.0/root_import_storymanager.wgpkg and b/docs/upgrades/packages-7.7.0/root_import_storymanager.wgpkg differ diff --git a/lib/WebGUI/Asset/Story.pm b/lib/WebGUI/Asset/Story.pm index 7db6d342f..228f4868f 100644 --- a/lib/WebGUI/Asset/Story.pm +++ b/lib/WebGUI/Asset/Story.pm @@ -145,7 +145,7 @@ sub definition { }, photo => { fieldType => 'text', - defaultValue => '{}', + defaultValue => '[]', }, storageId => { fieldType => 'hidden', @@ -249,7 +249,6 @@ sub getAutoCommitWorkflowId { my $self = shift; my $archive = $self->getArchive; if ($archive->hasBeenCommitted) { - $self->session->log->warn($archive->get('approvalWorkflowId')); return $archive->get('approvalWorkflowId') || $self->session->setting->get('defaultVersionTagWorkflow'); } @@ -490,6 +489,7 @@ sub processPropertiesFromFormPost { if ($newStorage) { push @{ $photoData }, { caption => $form->process('newImgCaption', 'text'), + alt => $form->process('newImgAlt', 'text'), title => $form->process('newImgTitle', 'text'), byLine => $form->process('newImgByline', 'text'), url => $form->process('newImgUrl', 'url'), @@ -538,9 +538,7 @@ sub purgeRevision { =head2 setPhotoData ( $perlStructure ) -Returns the storage location for this Story. If it does not exist, -then it creates it via setStorageLocation. Subsequent lookups return -an internally cached Storage object to save time. +Sets the photo data from the JSON stored in the object. =head3 $perlStructure @@ -577,7 +575,7 @@ want in there so there's no valid content checking. sub setPhotoData { my $self = shift; - my $photoData = shift || {}; + my $photoData = shift || []; my $photo = to_json($photoData); $self->update({photo => $photo}); delete $self->{_photoData}; diff --git a/lib/WebGUI/i18n/English/Asset_Story.pm b/lib/WebGUI/i18n/English/Asset_Story.pm index 051ce9755..f23de7694 100644 --- a/lib/WebGUI/i18n/English/Asset_Story.pm +++ b/lib/WebGUI/i18n/English/Asset_Story.pm @@ -344,6 +344,36 @@ our $I18N = { lastUpdated => 0, }, + 'photo caption' => { + message => q|Photo Caption|, + context => q|Label in the edit story form. Short for Photograph Caption.|, + lastUpdated => 0, + }, + + 'photo byline' => { + message => q|Photo By Line|, + context => q|Label in the edit story form. The person who took, or owns this photo.|, + lastUpdated => 0, + }, + + 'photo alt' => { + message => q|Photo Alternate Text|, + context => q|Label in the edit story form. Text for the ALT attribute of an IMG tag.|, + lastUpdated => 0, + }, + + 'photo title' => { + message => q|Photo Alternate Title|, + context => q|Label in the edit story form. Text for the TITLE attribute of an IMG tag.|, + lastUpdated => 0, + }, + + 'photo url' => { + message => q|Photo URL|, + context => q|Label in the edit story form. A link from the photo to more information about it, or referring to it.|, + lastUpdated => 0, + }, + }; 1; diff --git a/t/Asset/Story.t b/t/Asset/Story.t index 0325e1fb5..635828a4a 100644 --- a/t/Asset/Story.t +++ b/t/Asset/Story.t @@ -81,7 +81,7 @@ $story = $archive->addChild({ isa_ok($story, 'WebGUI::Asset::Story', 'Created a Story asset'); is($story->get('storageId'), '', 'by default, there is no storageId'); -is($story->get('photo'), '{}', 'by default, photos is an empty JSON hash'); +is($story->get('photo'), '[]', 'by default, photos is an empty JSON array'); is($story->get('isHidden'), 1, 'by default, stories are hidden'); $story->update({isHidden => 0}); is($story->get('isHidden'), 1, 'stories cannot be set to not be hidden'); @@ -111,36 +111,36 @@ is($story->getArchive->getId, $archive->getId, 'getArchive gets the parent archi my $photoData = $story->getPhotoData(); cmp_deeply( - $photoData, {}, - 'getPhotoData: returns an empty hash with no JSON data' + $photoData, [], + 'getPhotoData: returns an empty array ref with no JSON data' ); -$story->setPhotoData({ - filename1 => { +$story->setPhotoData([ + { byLine => 'Andrew Dufresne', caption => 'Shawshank Prison', }, -}); +]); -is($story->get('photo'), q|{"filename1":{"caption":"Shawshank Prison","byLine":"Andrew Dufresne"}}|, 'setPhotoData: set JSON in the photo property'); +is($story->get('photo'), q|[{"caption":"Shawshank Prison","byLine":"Andrew Dufresne"}]|, 'setPhotoData: set JSON in the photo property'); $photoData = $story->getPhotoData(); -$photoData->{filename1}->{caption}="My cell"; +$photoData->[0]->{caption}="My cell"; cmp_deeply( $story->getPhotoData, - { - filename1 => { + [ + { byLine => 'Andrew Dufresne', caption => 'Shawshank Prison', }, - }, + ], 'getPhotoData does not return an unsafe reference' ); $story->setPhotoData(); cmp_deeply( - $story->getPhotoData, {}, + $story->getPhotoData, [], 'setPhotoData: wipes the stored data if nothing is passed' );