[Koha-patches] [PATCH 23/54] MT4588: Adds coins to intranet Adds coins also in search result list
paul.poulain at biblibre.com
paul.poulain at biblibre.com
Thu Dec 16 11:54:17 CET 2010
From: Paul Poulain <paul.poulain at biblibre.com>
MT4046: Adding bc search on barcode
It has been reported that when having biblios with many items,
there is no way to search by barcode since we have to shrink biblio data
This patch adds a special behaviour when searching on barcode so that
a) search is based on mysql and no other index (barcode if provided is supposed to be unique)
b) biblio is opened in items edition
MT1654 followup:duplicate paging system at the top of search results tables
We've added a navigation bar at the top of most tables, but the search results of patrons and catalog returning too many res
MT3217 scan index intranet
Adding the phr modifier since any value searched should be searched as
exact
---
catalogue/search.pl | 45 +++++++++++++------
.../prog/en/modules/catalogue/results.tmpl | 19 ++++++--
2 files changed, 45 insertions(+), 19 deletions(-)
diff --git a/catalogue/search.pl b/catalogue/search.pl
index ac2209a..46de8e6 100755
--- a/catalogue/search.pl
+++ b/catalogue/search.pl
@@ -140,6 +140,7 @@ use strict; # always use
## load Koha modules
use C4::Context;
+use C4::Biblio;
use C4::Output;
use C4::Auth qw(:DEFAULT get_session);
use C4::Search;
@@ -320,7 +321,11 @@ if ( $template_type eq 'advsearch' ) {
$template->param( expanded_options => $cgi->param('expanded_options'));
}
- $template->param(virtualshelves => C4::Context->preference("virtualshelves"));
+ if ( C4::Context->preference("AdvancedSearchContent") ne '' ) {
+ $template->param( AdvancedSearchContent => C4::Context->preference("AdvancedSearchContent") );
+ }
+
+ $template->param( virtualshelves => C4::Context->preference("virtualshelves") );
output_html_with_http_headers $cgi, $cookie, $template->output;
exit;
@@ -341,7 +346,7 @@ my @sort_by;
my $default_sort_by = C4::Context->preference('defaultSortField')."_".C4::Context->preference('defaultSortOrder')
if (C4::Context->preference('defaultSortField') && C4::Context->preference('defaultSortOrder'));
- at sort_by = split("\0",$params->{'sort_by'}) if $params->{'sort_by'};
+ at sort_by = $cgi->param('sort_by');
$sort_by[0] = $default_sort_by unless $sort_by[0];
foreach my $sort (@sort_by) {
$template->param($sort => 1);
@@ -349,8 +354,7 @@ foreach my $sort (@sort_by) {
$template->param('sort_by' => $sort_by[0]);
# Use the servers defined, or just search our local catalog(default)
-my @servers;
- at servers = split("\0",$params->{'server'}) if $params->{'server'};
+my @servers = $cgi->param('server');
unless (@servers) {
#FIXME: this should be handled using Context.pm
@servers = ("biblioserver");
@@ -358,13 +362,11 @@ unless (@servers) {
}
# operators include boolean and proximity operators and are used
# to evaluate multiple operands
-my @operators;
- at operators = split("\0",$params->{'op'}) if $params->{'op'};
+my @operators = $cgi->param('op');
# indexes are query qualifiers, like 'title', 'author', etc. They
-# can be single or multiple parameters separated by comma: kw,right-Truncation
-my @indexes;
- at indexes = split("\0",$params->{'idx'});
+# can be single or multiple parameters separated by comma: kw,right-Truncation
+my @indexes = $cgi->param('idx');
# if a simple index (only one) display the index used in the top search box
if ($indexes[0] && !$indexes[1]) {
@@ -372,12 +374,10 @@ if ($indexes[0] && !$indexes[1]) {
# an operand can be a single term, a phrase, or a complete ccl query
-my @operands;
- at operands = split("\0",$params->{'q'}) if $params->{'q'};
+my @operands = $cgi->param('q');
# limits are use to limit to results to a pre-defined category such as branch or language
-my @limits;
- at limits = split("\0",$params->{'limit'}) if $params->{'limit'};
+my @limits = $cgi->param('limit');
if($params->{'multibranchlimit'}) {
push @limits, join(" or ", map { "branch: $_ "} @{GetBranchesInCategory($params->{'multibranchlimit'})}) ;
@@ -442,6 +442,17 @@ my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit
my @results;
+if ($indexes[0] eq "bc" ||$operands[0]=~/^\s*bc[=: ]/){
+ my $bc=$operands[0];
+ $bc=~s/bc[=:]//;
+ my $itemnumber=C4::Items::GetItemnumberFromBarcode($bc);
+ if ($itemnumber){
+ my $item=C4::Items::GetItem($itemnumber);
+ print $cgi->redirect(qq#/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=$item->{biblionumber}&itemnumber=$item->{itemnumber}#);
+ exit 1;
+ }
+}
+
## I. BUILD THE QUERY
my $lang = C4::Output::getlanguagecookie($cgi);
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by,$scan,$lang);
@@ -535,7 +546,13 @@ for (my $i=0;$i<@servers;$i++) {
if ($hits) {
- $template->param(total => $hits);
+
+ # Coins
+ foreach (@newresults) {
+ $_->{coins} = GetCOinSBiblio( $_->{'biblionumber'} );
+ }
+
+ $template->param( total => $hits );
my $limit_cgi_not_availablity = $limit_cgi;
$limit_cgi_not_availablity =~ s/&limit=available//g;
$template->param(limit_cgi_not_availablity => $limit_cgi_not_availablity);
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl
index f833f33..21971bc 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl
@@ -310,7 +310,7 @@ function GetZ3950Terms(){
<!-- TMPL_LOOP NAME="SEARCH_RESULTS" -->
<!-- TMPL_IF NAME="__odd__" --><tr><!-- TMPL_ELSE --><tr class="highlight"><!-- /TMPL_IF -->
<td>
- <a href="/cgi-bin/koha/catalogue/search.pl?idx=<!-- TMPL_VAR name="scan_index_to_use" -->&q=<!-- TMPL_VAR NAME="scan_use" escape="url" -->"<!-- TMPL_VAR NAME="title" -->""><!-- TMPL_VAR NAME="title" ESCAPE="html" --></a>
+ <a href="/cgi-bin/koha/catalogue/search.pl?idx=<!-- TMPL_VAR name="scan_index_to_use" -->,phr&q=<!-- TMPL_VAR NAME="scan_use" escape="url" -->"<!-- TMPL_VAR NAME="title" -->""><!-- TMPL_VAR NAME="title" --></a>
</td>
<td>
<!-- TMPL_VAR NAME="author" -->
@@ -360,7 +360,7 @@ function GetZ3950Terms(){
</dl>
</div>
<!-- ######### -->
-
+<!-- TMPL_INCLUDE NAME="page-numbers.inc" -->
<div id="searchresults">
<form action="/cgi-bin/koha/catalogue/search.pl" method="get" name="bookbag_form" id="bookbag_form">
<!-- TMPL_IF NAME="searchdesc" -->
@@ -393,6 +393,10 @@ function GetZ3950Terms(){
<input type="checkbox" class="selection" id="bib<!-- TMPL_VAR NAME="biblionumber" -->" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" style="display:none" />
</td>
<td>
+ <!-- TMPL_IF NAME="coins" -->
+ <!-- COinS / OpenURL --><span class="Z3988" title="<!-- TMPL_VAR NAME="coins" -->"></span>
+ <!-- /TMPL_IF -->
+
<p><!-- TMPL_VAR NAME="result_number" -->.
<!-- TMPL_INCLUDE NAME="biblio-default-view.inc" -->
<b><!-- TMPL_IF NAME="title" --><!-- TMPL_VAR NAME="title" ESCAPE="html" --><!-- TMPL_ELSE -->No title<!-- /TMPL_IF --></b>
@@ -464,11 +468,16 @@ function GetZ3950Terms(){
</td>
<td><div class="availability">
- <!-- TMPL_IF NAME="items_count" --><strong><!-- TMPL_VAR NAME="items_count" -->
- <!-- TMPL_IF NAME="itemsplural" -->items<!-- TMPL_ELSE -->item<!-- /TMPL_IF --><!-- TMPL_IF NAME="available_items_loop" -->, <!-- TMPL_IF NAME="availablecount" --><!-- TMPL_VAR NAME="availablecount" --> available:<!-- /TMPL_IF --><!-- TMPL_ELSE -->, None available<!-- /TMPL_IF --></strong>
+ <!-- TMPL_IF NAME="items_count" --><strong><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="items_count" -->
+ <!-- TMPL_IF NAME="itemsplural" -->items
+ <!-- TMPL_ELSE -->item
+ <!-- /TMPL_IF --></a>
+ <!-- TMPL_IF NAME="available_items_loop" -->,
+ <!-- TMPL_IF NAME="availablecount" --><!-- TMPL_VAR NAME="availablecount" --> available:<!-- /TMPL_IF -->
+ <!-- TMPL_ELSE -->, None available<!-- /TMPL_IF -->
+ </strong>
<!-- TMPL_IF NAME="available_items_loop" -->
- <!-- TMPL_IF NAME="availablecount" --><!-- TMPL_VAR NAME="availablecount" --><!-- /TMPL_IF --> available:
<ul>
<!-- TMPL_LOOP NAME="available_items_loop" -->
--
1.7.1
More information about the Koha-patches
mailing list