use constant MAX_FILE_DISPLAYNAME_LENGTH => 255;
use constant ARTICLE_CUSTOM_FIELDS_CFG => "article custom fields";
-our $VERSION = "1.056";
+our $VERSION = "1.057";
=head1 NAME
if length $image->{name};
}
+ if ($cgi->param("_save_image_tags$image->{id}")) {
+ my @tags = $cgi->param("tags$image->{id}");
+ my @errors;
+ my $index = 0;
+ for my $tag (@tags) {
+ my $error;
+ if ($tag =~ /\S/
+ && !BSE::TB::Tags->valid_name($tag, \$error)) {
+ $errors[$index] = "msg:bse/admin/edit/tags/invalid/$error";
+ $errors{"tags$image->{id}"} = \@errors;
+ }
+ ++$index;
+ }
+ unless (@errors) {
+ $changes{$id}{tags} = [ grep /\S/, @tags ];
+ }
+ }
+
my $filename = $cgi->param("image$id");
if (defined $filename && length $filename) {
my $in_fh = $cgi->upload("image$id");
if ($changes{$id}) {
my $changes = $changes{$id};
++$changes_found;
-
+
for my $field (keys %$changes) {
+ my $tags = delete $changes->{$field};
+ if ($tags) {
+ my $error;
+ $image->set_tags($tags, \$error);
+ }
$image->{$field} = $changes->{$field};
}
$image->save;
<:.if images.size:><:.if article.id != -1
and cfg.entry("basic", "auto_images", 1)-:>
<tr>
- <th colspan="5">First Image Position</th>
+ <th colspan="6">First Image Position</th>
</tr>
<tr>
- <td colspan="5">
+ <td colspan="6">
<input type="radio" name="imagePos" value="tl" <:= article.imagePos eq "tl" ? "checked " : "":>/>Top Left
<input type="radio" name="imagePos" value="tr" <:= article.imagePos eq "tr" ? "checked " : "":>/>Top Right
<input type="radio" name="imagePos" value="bl" <:= article.imagePos eq "bl" ? "checked " : "":>/>Bottom Left
<tr>
<th>Image</th>
<th colspan="2"> </th>
+ <th class="col_tags">Tags</th>
<th class="col_modify"> Modify</th>
<th class="col_move"> Move</th>
</tr>
<td class="col_field">
<:.if can_save:><input type="text" name="alt<:= image.id:>" value="<:.call "old", field:"alt" _ image.id, default: image.alt :>" size="32" /><:.else:><:= image.alt :><:.end if:>
</td>
+ <td class="col_tags" rowspan="5">
+ <input type="hidden" name="_save_image_tags<:= image.id:>" value="1">
+ <div class="tags" data-name="tags<:= image.id :>">
+ <:.if cgi.param("_save_image_tags" _ image.id) -:>
+ <:.set image_tags = [ cgi.param("tags" _ image.id) ] -:>
+ <:.else -:>
+ <:.set image_tags = [ image.tags ] -:>
+ <:% image_tags.push("") -:>
+ <:.end if -:>
+ <:.for tag in image_tags :>
+ <div class="tag"><input type="text" name="tags<:= image.id :>" value="<:= tag :>"><:.call "error_img_n", field:"tags" _ image.id, index: loop.index :></div>
+ <:.end for :>
+ </div>
+ </td>
<td class="col_modify" rowspan="5">
<:.if can_delete -:>
<b><a href="<:= cfg.admin_url("add", { id:article.id, "removeimg_" _ image.id:1, _t:"img", _csrfp: delete_token}):>" onClick="return window.confirm('Are you sure you want to delete this Image')">Delete</a></b>
<:.end if:>
<:.if can_save:>
<tr>
- <td colspan="5" class="buttons">
+ <td colspan="6" class="buttons">
<input type="submit" name="process" value="Save changes" />
</td>
</tr>
</div>
<:-.end define -:>
-<:.define old -:>
-<:# parameters: field, default -:>
-<: .if cgi.param(field).defined -:>
-<:= cgi.param(field) -:>
+<:.define old; default: "", index: 0 -:>
+<:# parameters: field, default, index -:>
+<: .set vals = [ cgi.param(field) ] -:>
+<: .if index < vals.size -:>
+<:= vals[index] -:>
<: .else -:>
<:= default | html -:>
<: .end if -:>