This syspref suffers from poor design and marginal integration. It was not
added to the
english sysprefs, should be type Integer not "free", and it does not operate as
billed.
It regulates the max number of items displayed in EACH of three categories such
that the
max displayed is actually between maxItemsInSearchResults and 3 *
maxItemsInSearchResults.
Search.pm misspelled the syspref resulting in failover to the inappropriate
default of 1.
These patches do NOT fix all problems with maxItemsInSearchResults. A DB
revision is
needed to convert the existing variables to type Integer, the templates should
reflect
when more items are suppressed from the display, and the basic operation should
be that
the number specified is the max number displayed TOTAL.
---
C4/Search.pm | 26 ++++++++-----------
installer/data/mysql/en/mandatory/sysprefs.sql | 6 +++-
.../1-Obligatoire/unimarc_standard_systemprefs.sql | 2 +-
installer/data/mysql/updatedatabase.pl | 2 +-
4 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/C4/Search.pm b/C4/Search.pm
index ecb1e77..f7e2a90 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -1252,6 +1252,12 @@ sub searchResults {
$times = $hits; # FIXME: if $hits is undefined, why do we want
to equal it?
}
+ my $maxitems = C4::Context->preference('maxItemsInSearchResults');
+ (defined $maxitems) or $maxitems = 20; # reasonable default
+ my $hbranch = C4::Context->preference('HomeOrHoldingBranch') eq
'homebranch' ? 'homebranch' : 'holdingbranch';
+ my $otherbranch = C4::Context->preference('HomeOrHoldingBranch') eq
'homebranch' ? 'holdingbranch' : 'homebranch';
+
+ warn "maxitems: $maxitems";
# loop through all of the records we've retrieved
for ( my $i = $offset ; $i <= $times - 1 ; $i++ ) {
my $marcrecord = MARC::File::USMARC::decode( $marcresults[$i] );
@@ -1359,11 +1365,6 @@
s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
my $item_in_transit_count = 0;
my $can_place_holds = 0;
my $items_count = scalar(@fields);
- my $maxitems =
- ( C4::Context->preference('maxItemsinSearchResults') )
- ? C4::Context->preference('maxItemsinSearchResults') - 1
- : 1;
-
# loop through every item
foreach my $field (@fields) {
my $item;
@@ -1372,8 +1373,6 @@
s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
foreach my $code ( keys %subfieldstosearch ) {
$item->{$code} = $field->subfield( $subfieldstosearch{$code} );
}
- my $hbranch =
C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'homebranch'
: 'holdingbranch';
- my $otherbranch =
C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ?
'holdingbranch' : 'homebranch';
# set item's branch name, use HomeOrHoldingBranch syspref first,
fall back to the other one
if ($item->{$hbranch}) {
$item->{'branchname'} = $branches{$item->{$hbranch}};
@@ -1472,24 +1471,21 @@
s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
}
}
} # notforloan, item level and biblioitem level
- my ( $availableitemscount, $onloanitemscount, $otheritemscount );
- $maxitems =
- ( C4::Context->preference('maxItemsinSearchResults') )
- ? C4::Context->preference('maxItemsinSearchResults') - 1
- : 1;
+ my ($availableitemscount, $onloanitemscount, $otheritemscount) =
(0,0,0);
for my $key ( sort keys %$onloan_items ) {
- (++$onloanitemscount > $maxitems) and last;
+ (++$onloanitemscount >= $maxitems) and last;
push @onloan_items_loop, $onloan_items->{$key};
}
for my $key ( sort keys %$other_items ) {
- (++$otheritemscount > $maxitems) and last;
+ (++$otheritemscount >= $maxitems) and last;
push @other_items_loop, $other_items->{$key};
}
for my $key ( sort keys %$available_items ) {
- (++$availableitemscount > $maxitems) and last;
+ (++$availableitemscount >= $maxitems) and last;
push @available_items_loop, $available_items->{$key}
}
+ # warn scalar(@newresults) . ":
(onloanitemscount,otheritemscount,availableitemscount)=($onloanitemscount,$otheritemscount,$availableitemscount)
vs. $maxitems)";
# XSLT processing of some stuff
if (C4::Context->preference("XSLTResultsDisplay") && !$scan) {
my $newxmlrecord =
XSLTParse4Display($oldbiblio->{biblionumber},C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPACResults.xsl");
diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql
b/installer/data/mysql/en/mandatory/sysprefs.sql
index 3f54c67..cb12f00 100644
--- a/installer/data/mysql/en/mandatory/sysprefs.sql
+++ b/installer/data/mysql/en/mandatory/sysprefs.sql
@@ -55,6 +55,7 @@ INSERT INTO `systempreferences`
(variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('MaxFine',9999,'Maximum fine a patron can have for a single late
return','','Integer');
INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('maxoutstanding',5,'maximum amount withstanding to be able make
holds','','Integer');
INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('maxreserves',50,'Define maximum number of holds a patron can
place','','Integer');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('maxItemsInSearchResults',20,'Specify the maximum number of items to
display for each result on a page of results',NULL,'Integer');
INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('memberofinstitution',0,'If ON, patrons can be linked to
institutions',NULL,'YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('MIME','EXCEL','Define the default application for exporting report
data','EXCEL|OPENOFFICE.ORG','Choice');
INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('noissuescharge',5,'Define maximum amount withstanding before check outs
are blocked','','Integer');
@@ -209,6 +210,7 @@ INSERT INTO `systempreferences`
(variable,value,options,explanation,type) VALUES
INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES('AllowHoldsOnDamagedItems', '1', '', 'Allow hold requests to be placed
on damaged items', 'YesNo');
INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES('OpacSuppression', '0', '', 'Turn ON the OPAC Suppression feature,
requires further setup, ask your system administrator for details', 'YesNo');
-- FIXME: add FrameworksLoaded, noOPACUserLogin, ReadingHistory ?
-INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES ('SMSSendDriver','','','Sets which SMS::Send driver is used to send SMS
messages.','free');
-INSERT INTO systempreferences (variable,value,explanation,options,type)
VALUES('AllowRenewalLimitOverride', '0', 'if ON, allows renewal limits to be
overridden on the circulation screen',NULL,'YesNo');
+INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES('SMSSendDriver','','','Sets which SMS::Send driver is used to send SMS
messages.','free');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('AllowRenewalLimitOverride', '0', 'if ON, allows renewal limits to be
overridden on the circulation screen',NULL,'YesNo');
INSERT INTO `systempreferences` (variable,value,options,explanation,type)
VALUES ('OPACDisplayRequestPriority','0','','Show patrons the priority level on
holds in the OPAC','YesNo');
+
diff --git
a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
index 5124a33..347cfbe 100644
--- a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
+++ b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
@@ -138,7 +138,7 @@ INSERT INTO `systempreferences`
(variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('WebBasedSelfCheck',0,'Si activé, permet le système de prêt
auto-controlé à partir de l''opac (/cgi-bin/koha/sco/sco-main.pl',NULL,'YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('numSearchResults',20,'Spécifie le nombre maximum de réponses à afficher
sur les pages de résultats',NULL,'free');
INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('OPACnumSearchResults',20,'Spécifie le nombre maximum de réponses à
afficher sur les pages de résultats',NULL,'free');
-INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('maxItemsInSearchResults',20,'Spécifie le nombre maximum d''exemplaires
à afficher sur les pages de résultats',NULL,'free');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('maxItemsInSearchResults',20,'Spécifie le nombre maximum d''exemplaires
à afficher sur les pages de résultats',NULL,'Integer');
INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('defaultSortField',NULL,'Spécifie le champ utilisé par défaut pour le
tri','relevance|popularity|call_number|pubdate|acqdate|title|author','Choice');
INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('defaultSortOrder',NULL,'Spécifie le sens du tri par
défaut','asc|dsc|az|za','Choice');
INSERT INTO `systempreferences` (variable,value,explanation,options,type)
VALUES('OPACdefaultSortField',NULL,'Spécifie le champ utilisé par défaut pour
le
tri','relevance|popularity|call_number|pubdate|acqdate|title|author','Choice');
diff --git a/installer/data/mysql/updatedatabase.pl
b/installer/data/mysql/updatedatabase.pl
index d592e2e..99f09f1 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -721,7 +721,7 @@ $dbh->do("INSERT INTO `systempreferences`
(variable,value,explanation,options,ty
$dbh->do("INSERT INTO `systempreferences`
(variable,value,explanation,options,type) VALUES('WebBasedSelfCheck',0,'If ON,
enables the web-based self-check system',NULL,'YesNo')");
$dbh->do("INSERT INTO `systempreferences`
(variable,value,explanation,options,type) VALUES('numSearchResults',20,'Specify
the maximum number of results to display on a page of results',NULL,'free')");
$dbh->do("INSERT INTO `systempreferences`
(variable,value,explanation,options,type)
VALUES('OPACnumSearchResults',20,'Specify the maximum number of results to
display on a page of results',NULL,'free')");
-$dbh->do("INSERT INTO `systempreferences`
(variable,value,explanation,options,type)
VALUES('maxItemsInSearchResults',20,'Specify the maximum number of items to
display for each result on a page of results',NULL,'free')");
+$dbh->do("INSERT INTO `systempreferences`
(variable,value,explanation,options,type)
VALUES('maxItemsInSearchResults',20,'Specify the maximum number of items to
display for each result on a page of results',NULL,'Integer')");
$dbh->do("INSERT INTO `systempreferences`
(variable,value,explanation,options,type)
VALUES('defaultSortField',NULL,'Specify the default field used for
sorting','relevance|popularity|call_number|pubdate|acqdate|title|author','Choice')");
$dbh->do("INSERT INTO `systempreferences`
(variable,value,explanation,options,type)
VALUES('defaultSortOrder',NULL,'Specify the default sort
order','asc|dsc|az|za','Choice')");
$dbh->do("INSERT INTO `systempreferences`
(variable,value,explanation,options,type)
VALUES('OPACdefaultSortField',NULL,'Specify the default field used for
sorting','relevance|popularity|call_number|pubdate|acqdate|title|author','Choice')");
--
1.5.5.GIT
_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha.org/mailman/listinfo/koha-patches