X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/24d7164ce1fd20686e5091d6446b3408a1c71c73..77eb26995a1185e50b2b275f058264857bed9cc7:/writer.plp?ds=inline diff --git a/writer.plp b/writer.plp index 11754e8..275909b 100644 --- a/writer.plp +++ b/writer.plp @@ -108,13 +108,14 @@ my $db = eval { } or Abort('Database error', 501, $@); my @wordcols = ( + lang => 'Language', + cat => 'Category', form => 'Translation', wptitle => 'Wikipedia', - ref => 'Reference', - cat => 'Category', - lang => 'Language', source => 'Image URL', thumb => 'Convert options', + prio => 'Level', + ref => 'Reference', ); my ($find) = map {{id => $_}} $fields{id} || $Request || (); @@ -125,9 +126,9 @@ if ($find) { } if (exists $get{copy}) { - $row = {%{$row}{ qw(lang cat) }}; + $row = {%{$row}{ qw(prio lang cat) }}; } -elsif ($ENV{REQUEST_METHOD} eq 'POST') { +elsif ($ENV{REQUEST_METHOD} eq 'POST') {{ my $replace = $row; $row = {%post{ pairkeys @wordcols }}; $_ = length ? $_ : undef for values %{$row}; @@ -137,7 +138,10 @@ elsif ($ENV{REQUEST_METHOD} eq 'POST') { my $query = $find ? $db->update(word => $row, $find, \%res) : $db->insert(word => $row, \%res); $row = $query->hash; - } or Alert("Entry could not be saved", $@); + } or do { + Alert("Entry could not be saved", $@); + next; + }; my $imgpath = "data/word/org/$row->{id}.jpg"; if (($row->{source} // '') ne ($replace->{source} // '')) { @@ -182,8 +186,9 @@ elsif ($ENV{REQUEST_METHOD} eq 'POST') { unlink $thumbpath; } } -} +}} else { + $row->{prio} //= 1; $row->{$_} = $get{$_} for keys %get; }