Add form fields for uploading images to the Story.
Help, i18n for those fields. Need to be added to the template.
This commit is contained in:
parent
734c48f525
commit
420a70531b
3 changed files with 97 additions and 5 deletions
|
|
@ -363,6 +363,31 @@ sub getEditForm {
|
|||
value => $i18n->get('save and add another photo'),
|
||||
}),
|
||||
};
|
||||
$var->{ photo_form_loop } = [];
|
||||
##Provide forms for the existing photos, if any
|
||||
##Existing photos get a delete Yes/No.
|
||||
##And a form for new ones
|
||||
push @{ $var->{ photo_form_loop } }, {
|
||||
imgUploadForm => WebGUI::Form::image($session, {
|
||||
name => 'newPhoto',
|
||||
maxAttachments => 1,
|
||||
}),
|
||||
imgCaptionForm => WebGUI::Form::text($session, {
|
||||
name => 'newImgCaption',
|
||||
}),
|
||||
imgByLineForm => WebGUI::Form::text($session, {
|
||||
name => 'newImgByline',
|
||||
}),
|
||||
imgAltForm => WebGUI::Form::text($session, {
|
||||
name => 'newImgAlt',
|
||||
}),
|
||||
imgTitleForm => WebGUI::Form::text($session, {
|
||||
name => 'newImgTitle',
|
||||
}),
|
||||
imgUrlForm => WebGUI::Form::url($session, {
|
||||
name => 'newImgUrl',
|
||||
}),
|
||||
};
|
||||
if ($isNew) {
|
||||
$var->{formHeader} .= WebGUI::Form::hidden($session, { name => 'assetId', value => 'new' })
|
||||
. WebGUI::Form::hidden($session, { name => 'class', value => $form->process('class', 'className') });
|
||||
|
|
@ -448,15 +473,30 @@ sub prepareView {
|
|||
|
||||
=head2 processPropertiesFromFormPost ( )
|
||||
|
||||
Used to process properties from the form posted. Do custom things with
|
||||
noFormPost fields here, or do whatever you want. This method is called
|
||||
when /yourAssetUrl?func=editSave is requested/posted.
|
||||
Handle photos and photo metadata, like captions, etc.
|
||||
|
||||
=cut
|
||||
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
my $session = $self->session;
|
||||
my $form = $session->form;
|
||||
##Handle old data first, to avoid iterating across a newly added photo.
|
||||
my $photoData = $self->getPhotoData;
|
||||
my $numberOfPhotos = scalar @{ $photoData };
|
||||
##Post process photo data here.
|
||||
my $newStorage = $form->process('newPhoto', 'image');
|
||||
if ($newStorage) {
|
||||
push @{ $photoData }, {
|
||||
caption => $form->process('newImgCaption', 'text'),
|
||||
title => $form->process('newImgTitle', 'text'),
|
||||
byLine => $form->process('newImgByline', 'text'),
|
||||
url => $form->process('newImgUrl', 'url'),
|
||||
storageId => $newStorage,
|
||||
};
|
||||
$self->setPhotoData($photoData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ our $HELP = {
|
|||
fields => [],
|
||||
variables => [
|
||||
{ name => 'formHeader',
|
||||
'required' => 1 },
|
||||
required => 1 },
|
||||
{ name => 'formTitle', },
|
||||
{ name => 'formFooter',
|
||||
'required' => 1 },
|
||||
required => 1 },
|
||||
{ name => 'titleForm', },
|
||||
{ name => 'subtitleForm', },
|
||||
{ name => 'bylineForm', },
|
||||
|
|
@ -30,6 +30,16 @@ our $HELP = {
|
|||
{ name => 'previewButton', },
|
||||
{ name => 'saveAndAddButton', },
|
||||
{ name => 'cancelButton', },
|
||||
{ name => 'photo_form_loop',
|
||||
variables => [
|
||||
{ name => 'imgUploadForm', },
|
||||
{ name => 'imgCaptionForm', },
|
||||
{ name => 'imgBylineForm', },
|
||||
{ name => 'imgAltForm', },
|
||||
{ name => 'imgTitleForm', },
|
||||
{ name => 'imgUrlForm', },
|
||||
],
|
||||
},
|
||||
],
|
||||
related => []
|
||||
},
|
||||
|
|
|
|||
|
|
@ -302,6 +302,48 @@ our $I18N = {
|
|||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'photo_form_loop' => {
|
||||
message => q|A loop containing subforms for all photos that have been loaded, and a blank form for uploading new photos.|,
|
||||
context => q|Template variable for edit form.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'imgUploadForm' => {
|
||||
message => q|A form field to upload an image.|,
|
||||
context => q|Template variable for edit form.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'imgCaptionForm' => {
|
||||
message => q|A form field for the caption for this image.|,
|
||||
context => q|Template variable for edit form.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'imgBylineForm' => {
|
||||
message => q|A form field for a by-line for this image.|,
|
||||
context => q|Template variable for edit form.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'imgAltForm' => {
|
||||
message => q|A form field for alternate text for the image, for the IMG tag ALT field.|,
|
||||
context => q|Template variable for edit form.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'imgTitleForm' => {
|
||||
message => q|A form field for the title for the image, for the IMG tag TITLE field.|,
|
||||
context => q|Template variable for edit form.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'imgUrlForm' => {
|
||||
message => q|A field for the URL for this image. If present, then the image will be rendered as a link to this URL.|,
|
||||
context => q|Template variable for edit form.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue