Translation Area body<= prepare("SELECT lnid, lncode, lnname, lastupdate FROM ml_langs"); $sth->execute; my %lang; $lang{$_->{'lnid'}} = $_ while $_ = $sth->fetchrow_hashref; $sth = $dbr->prepare("SELECT lnid, staleness > 1, COUNT(*) FROM ml_latest GROUP by 1, 2"); $sth->execute; while (my ($lnid, $stale, $ct) = $sth->fetchrow_array) { next unless exists $lang{$lnid}; $lang{$lnid}->{'_total'} += $ct; $lang{$lnid}->{'_good'} += (1-$stale) * $ct; $lang{$lnid}->{'percent'} = 100 * $lang{$lnid}->{'_good'} / ($lang{$lnid}->{'_total'}||1); } my $sortcol = exists $lang{'1'}->{$FORM{'s'}} ? $FORM{'s'} : "lnname"; my @cols = (['lncode','Code'], ['lnname','Language Name', sub { my $r = shift; "$r->{'lnname'}"; }], ['percent','% Done', sub { my $r = shift; "" . sprintf("%.02f%%", $r->{'percent'}) . "
" . "$r->{'_good'}/$r->{'_total'}" . ""; }, sub { $b->{'percent'} <=> $a->{'percent'} || $b->{'_total'} <=> $a->{'_total'} }], ['lastupdate','Last Update',undef, sub { $b->{'lastupdate'} cmp $a->{'lastupdate'} }]); my $ret; my $sorter = sub { $a->{$sortcol} cmp $b->{$sortcol} }; $ret .= "The following table lists the progress by each of the different translation teams."; $ret .= "

"; foreach (@cols) { if ($sortcol eq $_->[0]) { $ret .= ""; } else { $ret .= ""; } if ($_->[0] eq $sortcol && $_->[3]) { $sorter = $_->[3]; } } $ret .= "\n"; foreach my $r (sort $sorter values %lang) { $ret .= ""; foreach (@cols) { $ret .= $_->[2] ? $_->[2]->($r) : ""; } $ret .= "\n"; } $ret .= "
$_->[1][0]\">$_->[1]
$r->{$_->[0]}
\n"; return $ret; _code?> <=body page?>