cat => [{-label => 'Category'}, 'ref'],
ref => {-label => 'Reference'},
prio => [
- {-label => 'Level', -select => [qw(
- essential basic common distinctive rare invisible
- )]},
+ {-label => 'Level', -select => sub {
+ my ($row) = @_;
+ my @enum = qw[ essential basic common distinctive optional invisible ];
+ return {
+ ('' => 'parent') x (defined $row->{ref}),
+ map { $_ => $enum[$_] } 0 .. $#enum
+ };
+ }},
'cover', 'grade',
],
cover => {-label => 'Highlighted', type => 'checkbox'},
while (my ($lang, $val) = each %post) {
my $field = $lang;
$lang =~ s/^trans-// or next;
- $db->insert(word => {
+ $val = parseinput($val) or next;
+ my %subrow = (
ref => $row->{id},
lang => $lang,
- form => $_,
- }) for parseinput($val);
+ form => $val,
+ prio => undef,
+ );
+ $subrow{wptitle} = $1 if $subrow{form} =~ s/\h*\[(.*)\]$//; # [Link] shorthand
+ $db->insert(word => \%subrow);
delete $fields{$field};
}
return 1;
}
@cmds = (
'convert',
+ $imgpath,
-delete => '1--1', -background => 'white',
-gravity => @cmds ? 'northwest' : 'center',
@cmds,
-resize => "$xyres^", -extent => $xyres,
'-strip', -quality => '60%', -interlace => 'plane',
- $imgpath => $thumbpath
+ $thumbpath
);
eval {
require IPC::Run;
}
}}
else {
- $row->{prio} //= 1;
$row->{lang} //= $user->{editlang}->[0];
$row->{$_} = $get{$_} for keys %get;
+ $row->{prio} = defined $row->{ref} ? undef : 1 unless exists $row->{prio};
}
my $title = $row->{id} ? "entry <small>#$row->{id}</small>" : 'new entry';
$html .= qq( $_="$attr->{$_}") for sort grep {!/^-/} keys %{$attr // {}};
if (my $options = $attr->{-select}) {
- $options = { map {$_ => $options->[$_]} 0 .. $#{$options} }
- if ref $options eq 'ARRAY';
+ $options = $options->(@_) if ref $options eq 'CODE';
$options->{$val} //= "unknown ($val)"; # preserve current
return (
sprintf('<select id="%s" name="%1$s">', $col),