#!/usr/bin/perl # editable-search.cgi - Example of ODP:: (Version 0.01) # Copyright (C)2002 Richard P. Fuller <rpfuller@rpfuller.org> # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use CGI qw(:standard); use ODP::Search; if (!param('search')) { &form; } else { print header(); print start_html('Editable Search Results'); my $search = new ODP::Search(param('search')); print $search->resultcount." results found."; my $results = $search->resultcount; if ($results > 30) { $results = 30; } print "<p>Here, have the first $results."; print "<ol>"; for ($n=1; $n<=$results; $n++) { my $result = $search->result($n); print '<li><a href="'.$result->editurl.'">[EDIT]</a> '."<a href=\"$result->{'url'}\">$result->{'title'}</a> - $result->{'desc'}</li>"; } print "</ol>"; print '<hr>'; print end_html; } exit; sub form() { print header().<<END_FORM; <html> <head> <title>Editable Search</title> </head> <body> <form action="editable-search.cgi"> Search term: <input name="search" size="20"> <hr> <input type="submit" value="Submit"> </form> </body> </html> END_FORM }