Bug 7092 - Complete-subfield searches TraceCompleteSubfields syspref not working...
authorMagnus Enger <magnus@enger.priv.no>
Mon, 5 Mar 2012 12:36:43 +0000 (13:36 +0100)
committerPaul Poulain <paul.poulain@biblibre.com>
Wed, 21 Mar 2012 13:53:14 +0000 (14:53 +0100)
This patch adds a syspref UseICU for toggling between using "" and {} for
quoting in subject tracings. With normal Zebra indexing, "" must be used. With
ICU Zebra indexing, {} must be used.

This syspref interacts with TraceCompleteSubfields and TraceSubjectSubdivisions.

To test:

- marcflavour = MARC21
- make sure you have a record with a "complex subject", like
  "Internet -- Law and legislation"

Toggle UseICU, TraceCompleteSubfields, and TraceSubjectSubdivisions and check
that you get the expected results for the clickable links in the OPAC detail
view:

TraceCompleteSubfields   = Don't force
TraceSubjectSubdivisions = Don't include
UseICU                   = Not using
  opac-search.pl?q=su:"Internet"
UseICU                   = Using
  opac-search.pl?q=su:{Internet}

TraceCompleteSubfields   = Force
TraceSubjectSubdivisions = Don't include
UseICU                   = Not using
  opac-search.pl?q=su,complete-subfield:"Internet"
UseICU                   = Using
  opac-search.pl?q=su,complete-subfield:{Internet}

TraceCompleteSubfields   = Don't force
TraceSubjectSubdivisions = Include
UsingICU                 = Not using
  opac-search.pl?q=(su:"Internet") and (su:"Law and legislation.")
UsingICU                 = Using
  opac-search.pl?q=(su:{Internet}) and (su:{Law and legislation.})

TraceCompleteSubfields   = Force
TraceSubjectSubdivisions = Include
UseICU                   = Not using
  opac-search.pl?q=(su,complete-subfield:"Internet") and (su,complete-subfield:"Law and legislation.")
UseICU                   = Using
  opac-search.pl?q=(su,complete-subfield:{Internet}) and (su,complete-subfield:{Law and legislation.})

Check that clicking on the generated links gives the expected search results,
but with normal and ICU indexing. (I have actually not tested this with ICU, so
doing that before signing off is crucial.)

UPDATE 2012-03-16:

Changed the name of the syspref from TracingQuotes to UseICU after a suggestion
from Paul P., to make it more generally useful.

I have used "Using/Not using" instead of "Use/Don't use" in the description of
the syspref, to reflect the fact that this syspref will not change how Zebra
does its indexing - it's just a way of telling Koha how the indexing is
actually done.

I have also set UseICU = 1 in updatedatabase.pl, since that will preserve the
current behaviour of Koha, but UseICU = 0 in sysprefs.sql, since most new
installations will not have ICU activated.

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
C4/XSLT.pm
installer/data/mysql/sysprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl
koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl

index 06dfaf4..7557efe 100644 (file)
@@ -131,7 +131,7 @@ sub XSLTParse4Display {
     my $sysxml = "<sysprefs>\n";
     foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow
                               DisplayOPACiconsXSLT URLLinkText viewISBD
-                              OPACBaseURL TraceCompleteSubfields
+                              OPACBaseURL TraceCompleteSubfields UseICU
                               UseAuthoritiesForTracings TraceSubjectSubdivisions
                               Display856uAsImage OPACDisplay856uAsImage 
                               UseControlNumber
index 8810aef..fe69552 100644 (file)
@@ -315,6 +315,7 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES (
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacFavicon','','Enter a complete URL to an image to replace the default Koha favicon on the OPAC','','free');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('IntranetFavicon','','Enter a complete URL to an image to replace the default Koha favicon on the Staff client','','free');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('TraceSubjectSubdivisions', '0', 'Create searches on all subdivisions for subject tracings.','1','YesNo');
+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UseICU', '0', 'Tell Koha if ICU indexing is in use for Zebra or not.','1','YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('StaffAuthorisedValueImages','1','',NULL,'YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACDisplay856uAsImage','OFF','Display the URI in the 856u field as an image, the corresponding OPACXSLT option must be on','OFF|Details|Results|Both','Choice');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('Display856uAsImage','OFF','Display the URI in the 856u field as an image, the corresponding Staff Client XSLT option must be on','OFF|Details|Results|Both','Choice');
index a2335af..eb5f58a 100755 (executable)
@@ -4960,6 +4960,13 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion = "3.07.00.031";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('UseICU', '1', 'Tell Koha if ICU indexing is in use for Zebra or not.','1','YesNo')");
+    print "Upgrade to $DBversion done (Add syspref to tell Koha if ICU indexing is in use for Zebra or not.)\n";
+    SetVersion ($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 DropAllForeignKeys($table)
index e187702..3d7dd64 100644 (file)
@@ -69,6 +69,13 @@ Searching:
                   yes: Include
                   no: "Don't include"
             - subdivisions for searches generated by clicking on subject tracings.
+        -
+            - pref: UseICU
+              default: 0
+              choices:
+                  yes: Using
+                  no: "Not using"
+            - 'ICU Zebra indexing. Please note: This setting will not affect Zebra indexing, it should only be used to tell Koha that you have activated ICU indexing if you have actually done so, since there is no way for Koha to figure this out on its own.'
     Search Form:
         -
             - Show tabs in OPAC and staff-side advanced search for limiting searches on the
index a367de0..157aab7 100644 (file)
         <xsl:variable name="SubjectModifier"><xsl:if test="marc:sysprefs/marc:syspref[@name='TraceCompleteSubfields']='1'">,complete-subfield</xsl:if></xsl:variable>
         <xsl:variable name="UseAuthoritiesForTracings" select="marc:sysprefs/marc:syspref[@name='UseAuthoritiesForTracings']"/>
         <xsl:variable name="TraceSubjectSubdivisions" select="marc:sysprefs/marc:syspref[@name='TraceSubjectSubdivisions']"/>
-
         <xsl:variable name="Show856uAsImage" select="marc:sysprefs/marc:syspref[@name='Display856uAsImage']"/>
+        <xsl:variable name="TracingQuotesLeft">
+           <xsl:choose>
+             <xsl:when test="marc:sysprefs/marc:syspref[@name='UseICU']='1'">{</xsl:when>
+             <xsl:otherwise>"</xsl:otherwise>
+           </xsl:choose>
+        </xsl:variable>
+        <xsl:variable name="TracingQuotesRight">
+          <xsl:choose>
+            <xsl:when test="marc:sysprefs/marc:syspref[@name='UseICU']='1'">}</xsl:when>
+            <xsl:otherwise>"</xsl:otherwise>
+          </xsl:choose>
+        </xsl:variable>
         <xsl:variable name="leader" select="marc:leader"/>
         <xsl:variable name="leader6" select="substring($leader,7,1)"/>
         <xsl:variable name="leader7" select="substring($leader,8,1)"/>
                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:call-template name="subfieldSelect">
                         <xsl:with-param name="codes">abcdfgklmnopqrstvxyz</xsl:with-param>
                         <xsl:with-param name="delimeter"> and </xsl:with-param>
-                        <xsl:with-param name="prefix">(su<xsl:value-of select="$SubjectModifier"/>:{</xsl:with-param>
-                        <xsl:with-param name="suffix">})</xsl:with-param>
+                        <xsl:with-param name="prefix">(su<xsl:value-of select="$SubjectModifier"/>:<xsl:value-of select="$TracingQuotesLeft"/></xsl:with-param>
+                        <xsl:with-param name="suffix"><xsl:value-of select="$TracingQuotesRight"/>)</xsl:with-param>
                     </xsl:call-template>
                 </xsl:attribute>
             </xsl:when>
             <xsl:otherwise>
-                <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=su<xsl:value-of select="$SubjectModifier"/>:{<xsl:value-of select="marc:subfield[@code='a']"/>}</xsl:attribute>
+               <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=su<xsl:value-of select="$SubjectModifier"/>:<xsl:value-of select="$TracingQuotesLeft"/><xsl:value-of select="marc:subfield[@code='a']"/><xsl:value-of select="$TracingQuotesRight"/></xsl:attribute>
             </xsl:otherwise>
             </xsl:choose>
             <xsl:call-template name="chopPunctuation">
index da5b9c9..80fb6ac 100644 (file)
     <xsl:variable name="UseAuthoritiesForTracings" select="marc:sysprefs/marc:syspref[@name='UseAuthoritiesForTracings']"/>
     <xsl:variable name="TraceSubjectSubdivisions" select="marc:sysprefs/marc:syspref[@name='TraceSubjectSubdivisions']"/>
     <xsl:variable name="Show856uAsImage" select="marc:sysprefs/marc:syspref[@name='OPACDisplay856uAsImage']"/>
+    <xsl:variable name="TracingQuotesLeft">
+      <xsl:choose>
+        <xsl:when test="marc:sysprefs/marc:syspref[@name='UseICU']='1'">{</xsl:when>
+        <xsl:otherwise>"</xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <xsl:variable name="TracingQuotesRight">
+      <xsl:choose>
+        <xsl:when test="marc:sysprefs/marc:syspref[@name='UseICU']='1'">}</xsl:when>
+        <xsl:otherwise>"</xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
         <xsl:variable name="leader" select="marc:leader"/>
         <xsl:variable name="leader6" select="substring($leader,7,1)"/>
         <xsl:variable name="leader7" select="substring($leader,8,1)"/>
                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:call-template name="subfieldSelect">
                         <xsl:with-param name="codes">abcdfgklmnopqrstvxyz</xsl:with-param>
                         <xsl:with-param name="delimeter"> and </xsl:with-param>
-                        <xsl:with-param name="prefix">(su<xsl:value-of select="$SubjectModifier"/>:{</xsl:with-param>
-                        <xsl:with-param name="suffix">})</xsl:with-param>
+                        <xsl:with-param name="prefix">(su<xsl:value-of select="$SubjectModifier"/>:<xsl:value-of select="$TracingQuotesLeft"/></xsl:with-param>
+                        <xsl:with-param name="suffix"><xsl:value-of select="$TracingQuotesRight"/>)</xsl:with-param>
                     </xsl:call-template>
                 </xsl:attribute>
             </xsl:when>
             <xsl:otherwise>
-                <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=su<xsl:value-of select="$SubjectModifier"/>:{<xsl:value-of select="marc:subfield[@code='a']"/>}</xsl:attribute>
+                <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=su<xsl:value-of select="$SubjectModifier"/>:<xsl:value-of select="$TracingQuotesLeft"/><xsl:value-of select="marc:subfield[@code='a']"/><xsl:value-of select="$TracingQuotesRight"/></xsl:attribute>
             </xsl:otherwise>
             </xsl:choose>
             <xsl:call-template name="chopPunctuation">