[Koha-cvs] koha/C4 Search.pm [rel_3_0]
Antoine Farnault
antoine at koha-fr.org
Tue Nov 21 12:06:45 CET 2006
CVSROOT: /sources/koha
Module name: koha
Branch: rel_3_0
Changes by: Antoine Farnault <toins> 06/11/21 11:06:45
Modified files:
C4 : Search.pm
Log message:
add an exemple of usage for SimpleSearch in the POD
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Search.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.120.2.29&r2=1.120.2.30
Patches:
Index: Search.pm
===================================================================
RCS file: /sources/koha/koha/C4/Search.pm,v
retrieving revision 1.120.2.29
retrieving revision 1.120.2.30
diff -u -b -r1.120.2.29 -r1.120.2.30
--- Search.pm 20 Nov 2006 10:18:41 -0000 1.120.2.29
+++ Search.pm 21 Nov 2006 11:06:45 -0000 1.120.2.30
@@ -39,7 +39,7 @@
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.120.2.29 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.120.2.30 $' =~ /\d+/g;
shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
};
@@ -2549,18 +2549,51 @@
=item SimpleSearch
-($error,\@results) = SimpleSearch($query, at servers);
+($error,$results) = SimpleSearch($query, at servers);
this function performs a simple search on the catalog using zoom.
-C<input arg:>
+=item C<input arg:>
+
* $query could be a simple keyword or a complete CCL query wich is depending on your ccl file.
* @servers is optionnal. default one is read on koha.xml
-C<Output arg:>
+=item C<Output arg:>
* $error is a string which containt the description error if there is one. Else it's empty.
* \@results is an array of marc record.
+=item C<usage in the script:>
+
+my ($error, $marcresults) = SimpleSearch($query);
+
+if (defined $error) {
+ $template->param(query_error => $error);
+ warn "error: ".$error;
+ output_html_with_http_headers $input, $cookie, $template->output;
+ exit;
+}
+
+my $hits = scalar @$marcresults;
+my @results;
+
+for(my $i=0;$i<$hits;$i++) {
+ my %resultsloop;
+ my $marcrecord = MARC::File::USMARC::decode($marcresults->[$i]);
+ my $biblio = MARCmarc2koha(C4::Context->dbh,$marcrecord,'');
+
+ #build the hash for the template.
+ $resultsloop{highlight} = ($i % 2)?(1):(0);
+ $resultsloop{title} = $biblio->{'title'};
+ $resultsloop{subtitle} = $biblio->{'subtitle'};
+ $resultsloop{biblionumber} = $biblio->{'biblionumber'};
+ $resultsloop{author} = $biblio->{'author'};
+ $resultsloop{publishercode} = $biblio->{'publishercode'};
+ $resultsloop{publicationyear} = $biblio->{'publicationyear'};
+
+ push @results, \%resultsloop;
+}
+$template->param(result=>\@results);
+
=cut
sub SimpleSearch {
More information about the Koha-cvs
mailing list