From bab0c0b00d767a6191e533b6e0e829e850f094ad Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Sat, 26 Feb 2011 16:04:51 -0500 Subject: [PATCH] Bug 5810: Subject tracings search complete subfields This patch adds the syspref TraceCompleteSubfields. When TraceCompleteSubfields is set to "force," clicking on links in non-authority controlled subject tracings will only find other records where the entire subfields match. Leaving it at "don't force" keeps the current behavior of doing a keyword search of the subject indexes. This patch implements complete-subfield subject tracings in MARC21 XSLTs (OPAC and Staff) and all Normal mode interfaces. UNIMARC XSLTs have not been updated. This patch also adds the syspref UseAuthoritiesForTracings. When set to "Do not" tracings in the XSLT detail displays will never generate links using authority numbers, but rather use the heading strings (NB: the tracings currently use only subfield 'a' for generating links). Signed-off-by: Nicole C. Engard Signed-off-by: Jane Wagner --- C4/Biblio.pm | 4 +++- C4/XSLT.pm | 2 +- installer/data/mysql/de-DE/mandatory/sysprefs.sql | 2 ++ installer/data/mysql/en/mandatory/sysprefs.sql | 3 +++ .../1-Obligatoire/unimarc_standard_systemprefs.sql | 3 ++- installer/data/mysql/it-IT/necessari/sysprefs.sql | 4 +++- installer/data/mysql/pl-PL/mandatory/sysprefs.sql | 4 +++- ...m_preferences_full_optimal_for_install_only.sql | 2 ++ ...m_preferences_full_optimal_for_install_only.sql | 2 ++ installer/data/mysql/updatedatabase.pl | 8 ++++++++ .../en/modules/admin/preferences/authorities.pref | 7 +++++++ .../en/modules/admin/preferences/searching.pref | 7 +++++++ .../prog/en/xslt/MARC21slim2intranetDetail.xsl | 11 +++++++---- .../prog/en/xslt/MARC21slim2OPACDetail.xsl | 13 ++++++++----- 14 files changed, 58 insertions(+), 14 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 8ea5da5..7c60666 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1390,6 +1390,8 @@ sub GetMarcSubjects { my $subfield = ""; my $marcsubject; + my $subject_limit = C4::Context->preference("TraceCompleteSubfields") ? 'su,complete-subfield' : 'su'; + foreach my $field ( $record->field('6..') ) { next unless $field->tag() >= $mintag && $field->tag() <= $maxtag; my @subfields_loop; @@ -1416,7 +1418,7 @@ sub GetMarcSubjects { @link_loop = ( { 'limit' => 'an', link => "$linkvalue" } ); } if ( not $found9 ) { - push @link_loop, { 'limit' => 'su', link => $linkvalue, operator => $operator }; + push @link_loop, { 'limit' => $subject_limit, link => $linkvalue, operator => $operator }; } my $separator = C4::Context->preference("authoritysep") unless $counter == 0; diff --git a/C4/XSLT.pm b/C4/XSLT.pm index f1c5293..0c9e78b 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -128,7 +128,7 @@ sub XSLTParse4Display { my $itemsxml = buildKohaItemsNamespace($biblionumber); my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); my $sysxml = "\n"; - foreach my $syspref ( qw/OPACURLOpenInNewWindow DisplayOPACiconsXSLT URLLinkText viewISBD OPACBaseURL/ ) { + foreach my $syspref ( qw/OPACURLOpenInNewWindow DisplayOPACiconsXSLT URLLinkText viewISBD OPACBaseURL TraceCompleteSubfields UseAuthoritiesForTracings/ ) { my $sp = C4::Context->preference( $syspref ); next unless defined($sp); $sysxml .= "$sp\n"; diff --git a/installer/data/mysql/de-DE/mandatory/sysprefs.sql b/installer/data/mysql/de-DE/mandatory/sysprefs.sql index b752919..fe7684d 100644 --- a/installer/data/mysql/de-DE/mandatory/sysprefs.sql +++ b/installer/data/mysql/de-DE/mandatory/sysprefs.sql @@ -288,4 +288,6 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowFineOverride','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','0','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AuthoritiesLog','0','If ON, log edit/create/delete actions on authorities.','','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TraceCompleteSubfields','0','Force subject tracings to only match complete subfields.','0','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('UseAuthoritiesForTracings','1','Use authority record numbers for subject tracings instead of heading strings.','0','YesNo'); diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql index 3e03cad..2833c80 100644 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -289,3 +289,6 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AuthoritiesLog','0','If ON, log edit/create/delete actions on authorities.','0','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AuthoritiesLog','0','If ON, log edit/create/delete actions on authorities.','','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TraceCompleteSubfields','0','Force subject tracings to only match complete subfields.','0','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('UseAuthoritiesForTracings','1','Use authority record numbers for subject tracings instead of heading strings.','0','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 db61881..c13a673 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 @@ -290,4 +290,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowFineOverride','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','0','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AuthoritiesLog','0','If ON, log edit/create/delete actions on authorities.','','YesNo'); - +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TraceCompleteSubfields','0','Force subject tracings to only match complete subfields.','0','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('UseAuthoritiesForTracings','1','Use authority record numbers for subject tracings instead of heading strings.','0','YesNo'); diff --git a/installer/data/mysql/it-IT/necessari/sysprefs.sql b/installer/data/mysql/it-IT/necessari/sysprefs.sql index 27bb72e..7b12cb9 100644 --- a/installer/data/mysql/it-IT/necessari/sysprefs.sql +++ b/installer/data/mysql/it-IT/necessari/sysprefs.sql @@ -274,4 +274,6 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesCcode','1','Use the item collection code when finding items for the shelf browser.','0','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowFineOverride','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','0','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo'); -INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AuthoritiesLog','0','If ON, log edit/create/delete actions on authorities.','','YesNo'); \ No newline at end of file +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AuthoritiesLog','0','If ON, log edit/create/delete actions on authorities.','','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TraceCompleteSubfields','0','Force subject tracings to only match complete subfields.','0','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('UseAuthoritiesForTracings','1','Use authority record numbers for subject tracings instead of heading strings.','0','YesNo'); diff --git a/installer/data/mysql/pl-PL/mandatory/sysprefs.sql b/installer/data/mysql/pl-PL/mandatory/sysprefs.sql index 2743698..d231296 100644 --- a/installer/data/mysql/pl-PL/mandatory/sysprefs.sql +++ b/installer/data/mysql/pl-PL/mandatory/sysprefs.sql @@ -286,4 +286,6 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesCcode','1','Use the item collection code when finding items for the shelf browser.','0','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowFineOverride','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','0','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo'); -INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AuthoritiesLog','0','If ON, log edit/create/delete actions on authorities.','','YesNo'); \ No newline at end of file +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AuthoritiesLog','0','If ON, log edit/create/delete actions on authorities.','','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TraceCompleteSubfields','0','Force subject tracings to only match complete subfields.','0','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('UseAuthoritiesForTracings','1','Use authority record numbers for subject tracings instead of heading strings.','0','YesNo'); diff --git a/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql b/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql index b00c1e7..11d9178 100644 --- a/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql +++ b/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql @@ -342,3 +342,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowFineOverride','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','0','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AuthoritiesLog','0','If ON, log edit/create/delete actions on authorities.','','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TraceCompleteSubfields','0','Force subject tracings to only match complete subfields.','0','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('UseAuthoritiesForTracings','1','Use authority record numbers for subject tracings instead of heading strings.','0','YesNo'); diff --git a/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql b/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql index b9e1ca8..2e53d4c 100644 --- a/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql +++ b/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql @@ -367,3 +367,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowFineOverride','0','If on, staff will be able to issue books to patrons with fines greater than noissuescharge.','0','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllFinesNeedOverride','1','If on, staff will be asked to override every fine, even if it is below noissuescharge.','0','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AuthoritiesLog','0','If ON, log edit/create/delete actions on authorities.','','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TraceCompleteSubfields','0','Force subject tracings to only match complete subfields.','0','YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('UseAuthoritiesForTracings','1','Use authority record numbers for subject tracings instead of heading strings.','0','YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index d6b7322..902fcfe 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4051,6 +4051,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = '3.03.00.023'; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('TraceCompleteSubfields','0','Force subject tracings to only match complete subfields.','0','YesNo')"); + $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('UseAuthoritiesForTracings','1','Use authority record numbers for subject tracings instead of heading strings.','0','YesNo')"); + print "Upgrade to $DBversion done (Add syspref to force whole-subfield matching on subject tracings)\n"; + SetVersion($DBversion); +}; + =head1 FUNCTIONS =head2 DropAllForeignKeys($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref index f06d983..3d19af8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref @@ -14,3 +14,10 @@ Authorities: yes: "Don't" no: Do - automatically update attached biblios when changing an authority record. If this is off, please ask your administrator to enable the merge_authorities.pl cronjob. + - + - pref: UseAuthoritiesForTracings + default: yes + choices: + yes: Use + no: "Don't use" + - authority record numbers instead of text strings for searches from subject tracings. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref index cd924dc..5ff267f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -55,6 +55,13 @@ Searching: yes: Use no: "Don't use" - PazPar2 to group similar results on the OPAC. This requires that PazPar2 is set up and running. + - + - pref: TraceCompleteSubfields + default: 0 + choices: + yes: Force + no: "Don't force" + - subject tracings in the OPAC and Staff Client to search only for complete-subfield matches. Search Form: - - Show checkboxes to search by diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl index e3009d8..c96d82b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl +++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl @@ -19,6 +19,8 @@ + ,complete-subfield + @@ -121,8 +123,8 @@ - - + + Type: @@ -416,11 +418,11 @@ - + /cgi-bin/koha/catalogue/search.pl?q=an: - /cgi-bin/koha/catalogue/search.pl?q=su: + /cgi-bin/koha/catalogue/search.pl?q=su: @@ -791,6 +793,7 @@ +
diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl index 5703059..01e88f6 100755 --- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl +++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl @@ -22,6 +22,9 @@ + + ,complete-subfield + @@ -128,7 +131,7 @@ - + /cgi-bin/koha/opac-search.pl?q=an: @@ -143,7 +146,7 @@ - + /cgi-bin/koha/opac-search.pl?q=an: @@ -165,7 +168,7 @@ - + /cgi-bin/koha/opac-search.pl?q=an: @@ -479,11 +482,11 @@ - + /cgi-bin/koha/opac-search.pl?q=an: - /cgi-bin/koha/opac-search.pl?q=su: + /cgi-bin/koha/opac-search.pl?q=su: -- 1.5.6.5