thumb => 'Convert options',
wptitle => 'Wikipedia',
);
-my $find = $Request ? {id => $Request} : undef;
+my ($find) = map {{id => $_}} $fields{id} || $Request || ();
my $row;
-if ($ENV{REQUEST_METHOD} eq 'POST') {
+if (exists $get{copy}) {
+ $row = {%fields{ qw(lang cat) }};
+}
+elsif ($ENV{REQUEST_METHOD} eq 'POST') {
$row = {%post{ pairkeys @wordcols }};
$_ = length ? $_ : undef for values %{$row};
eval {
"Failed to convert source image, error code ".($status >> 8),
], "@cmds");
}
-
- $row = {map {$_ => $row->{$_}} qw(lang cat)} if not $Request;
}
elsif ($find) {
$row = $db->select(word => '*', $find)->hash
or Abort("Word not found", 404);
}
-my $title = $row ? "entry <small>#$row->{id}</small>" : 'new entry';
+my $title = $row->{id} ? "entry <small>#$row->{id}</small>" : 'new entry';
:>
<h1>Words <:= $title :></h1>
-<form action="" method="post">
+<form action="?" method="post">
+<input id="id" name="id" value="<:= $row->{id} // '' :>" type="hidden" />
<dl>
<:
$val = '{'.join(',', map {s/,/\\,/gr} @{$val}).'}' if ref $val eq 'ARRAY';
printf '<dt><label for="%s">%s</label></dt>'
. '<dd><input id="%1$s" name="%1$s" value="%s" />',
- $col->key, $col->value, $val;
+ $col->key, $col->value, Entity($val);
-e and printf ' <img src="/%s" alt="%s" />', $_, $row->{form} for
$col->key eq 'source' ? "data/word/org/$row->{id}.jpg" :
$col->key eq 'thumb' ? "data/word/eng/$row->{form}.jpg" :
}
:>
</dl>
-<p><input type="submit" value="Save" /></p>
+<p>
+ <input type="submit" value="Save" />
+ <input type="submit" value="New" formaction="/writer?copy=cat" />
+</p>
</form>