use constant MAX_FILE_DISPLAYNAME_LENGTH => 255;
use constant ARTICLE_CUSTOM_FIELDS_CFG => "article custom fields";
-our $VERSION = "1.039";
+our $VERSION = "1.040";
=head1 NAME
my $name = $cgi->param("name$id");
if (defined $name && $name ne $image->{name}) {
if ($name eq '') {
- if ($article->{id} > 0) {
- $changes{$id}{name} = '';
- }
- else {
- $errors{"name$id"} = "Identifiers are required for global images";
- }
+ $changes{$id}{name} = '';
}
elsif ($name =~ /^[a-z_]\w*$/i) {
my $msg;
}
}
else {
- if ($article->{id} == -1) {
- $errors{name} = "Identifiers are required for global images";
- }
- else {
- $image->{name} = '';
- }
+ $image->{name} = '';
}
}
my $filename = $cgi->param('image');
$file{category} ||= '';
defined $file{name} or $file{name} = '';
- if ($article->{id} == -1 && $file{name} eq '') {
- $errors{name} = 'Identifier is required for global files';
- }
if (!$errors{name} && length $file{name} && $file{name} !~/^\w+$/) {
$errors{name} = "Identifier must be a single word";
}
$errors{"name_$id"} = "Invalid file identifier $name";
}
}
- elsif ($article->{id} == -1) {
- $errors{"name_$id"} = "Identifier is required for global files";
- }
}
else {
push @{$names{$file->{name}}}, $id
$errors{name} = "Invalid file identifier $name";
}
}
- if (!$errors{name} && $article->{id} == -1) {
- length $name
- or $errors{name} = "Identifier is required for global files";
- }
}
my @meta;
=cut
-our $VERSION = "1.011";
+our $VERSION = "1.012";
use base 'BSE::Edit::Article';
use BSE::TB::Site;
Articles->global_files;
}
-sub validate_image_name {
- my ($self, $name, $rmsg) = @_;
-
- length $name and return 1;
-
- $$rmsg = "Name must be supplied for global images";
-
- return 0;
-}
-
sub req_tagshow {
my ($self, $req, $article, $articles, $msg, $errors) = @_;
@ISA = qw/Squirrel::Row/;
use Carp 'confess';
-our $VERSION = "1.009";
+our $VERSION = "1.010";
sub columns {
return qw/id articleId displayName filename sizeInBytes description
}
my $name = $opts{name};
- $self->id != -1 || defined $name && $name =~ /\S/
- or die "name is required for global files\n";
if (defined $name && $name =~ /\S/) {
$name =~ /^\w+$/
or die "name must be a single word\n";
use strict;
use Carp qw(confess);
-our $VERSION = "1.014";
+our $VERSION = "1.015";
=head1 NAME
}
my $name = $opts{name};
- $self->id != -1 || defined $name && $name =~ /\S/
- or die "name is required for global files\n";
if (defined $name && $name =~ /\S/) {
$name =~ /^\w+$/
or die "name must be a single word\n";
#!perl -w
use strict;
use BSE::Test qw(make_ua base_url);
-use Test::More tests => 67;
+use Test::More tests => 68;
use File::Spec;
use File::Slurp;
use Carp qw(confess);
);
ok($im3, "make a global image (a)");
+ my $im4 = bse_add_global_image
+ (
+ $cfg,
+ file => "t/data/govhouse.jpg",
+ );
+ ok($im4, "make a global image (no name)");
+
my $site = bse_site();
my @images = $site->images;
cmp_ok(@images, '>=', 3, "we have some global images");
my $named = $site->image_by_name($prefix . "A");
is($named->id, $im3->id, "check we got the right image by name");
- # fetch by index
- my $byindex = $site->image_by_index(1);
- is($byindex, undef, "all images named, none available by index");
-
+ ok($im4->remove, "remove the global image (no name)");
+ undef $im4;
ok($im3->remove, "remove the global image");
undef $im3;
ok($im2->remove, "remove the global image");
$im1->remove if $im1;
$im2->remove if $im2;
$im3->remove if $im3;
+ $im4->remove if $im4;
}
}