| |
<html> <head> <title>Top Ten Documents</title> </head>
<body bgcolor="#ffffff">
<h1>
[$ if $ENV{QUERY_STRING} eq 'all' $]
All
[$ else $]
Top Ten
[$ endif $]
Tracked Documents
</h1>
[!
sub colorsub { return shift() % 2 ? '#ffffff' : '#cccccc'; }
!]
[-
##
Connect to database
use DBI;
my $dbh = DBI->connect( "dbi:Pg:dbname=tpj", "ap_auth" )
or die "Can't connect: $DBI::errstr\n";
my $sth = $dbh->prepare( qq{
select title, path, hits, rating from documents
order by rating desc, hits desc;
});
$sth->execute or die "Can't execute: $DBI::errstr";
## Slurp first 10 results (or all results if
## $ENV{QUERY_STRING} is 'all') into arrayref and
## store that into $indexdata
$indexdata = $ENV{QUERY_STRING} eq 'all' ?
$sth->fetchall_arrayref :
[@{$sth->fetchall_arrayref}[0..9]];
$sth->finish;
$dbh->disconnect;
-]
<table border="0" width="75%">
<tr><th>#</th><th>Title</th><th>Hits</th><th>Rating</th></tr>
<tr bgcolor="[+ colorsub( $row ) +]">
<td>
<a href="[+ $row + 1 +]">[+ $row + 1 +]</a>
</td>
<td width="50%">
[- $escmode = 0; -]
<a href="[+ "$indexdata->[$row]->[1]" +]">
[- $escmode = 1; -]
[+ $indexdata->[$row]->[0] +]</a>
</td>
<td>[+ $indexdata->[$row]->[2] +]</td>
<td>[+ sprintf "%-0.2f", $indexdata->[$row]->[3] +]</td>
</tr>
</table>
[$ if $ENV{QUERY_STRING} eq 'all' $]
<a href="/[+
$req_rec->dir_config( 'TopTenPrefix')||'topten'
+]/">Top Ten Documents</a>
[$ else $]
<a href="/[+
($req_rec->dir_config( ‘TopTenPrefix')||'topten')
. '/?all'
+]">All Tracked Documents</a>
[$ endif $]
</body>
</html>
|