Bug 3098, Bug 3108, Bug 3545 -- Make MARC21 XSLT obey sysprefs in OPAC

The MARC21slim2OPACDetail.xsl and MARC21slim2OPACResults.xsl XSLT
stylesheets do not obey any of the OPAC sysprefs, OPACURLOpenInNewWindow,
URLLinkText, or a new one added for Bug 3545, DisplayOPACiconsXSLT.
Modified C4/XSLT.pm based on code written by Fréric Demians (thanks!) to
pass the values of the sysprefs to the .xsl files.  Modified the .xsl
files to implement them.  If the respective sysprefs are set, the OPAC
results and display pages will/will not display the format/material
type/audience icons, will/will not open URLs in new browser windows,
and will/will not use the text entered in URLLinkText as generic link
text when there is no value in the 856 subfield y, 3, or z.  (Note that
if subfields y, 3, or z do contain text, the first match is what will be displayed.)

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
This commit is contained in:
Jane Wagner 2009-08-23 15:58:55 -04:00 committed by Galen Charlton
parent f6aaac4119
commit 486a9496de
8 changed files with 113 additions and 27 deletions

View file

@ -125,6 +125,15 @@ sub XSLTParse4Display {
my $itemsxml = buildKohaItemsNamespace($biblionumber);
my $xmlrecord = $record->as_xml();
$xmlrecord =~ s/\<\/record\>/$itemsxml\<\/record\>/;
my $sysxml = "<sysprefs>\n";
foreach my $syspref ( qw/OPACURLOpenInNewWindow DisplayOPACiconsXSLT URLLinkText/ ) {
$sysxml .= "<syspref name=\"$syspref\">" .
C4::Context->preference( $syspref ) .
"</syspref>\n";
}
$sysxml .= "</sysprefs>\n";
$xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/;
my $parser = XML::LibXML->new();
# don't die when you find &, >, etc
$parser->recover_silently(1);

View file

@ -320,6 +320,7 @@ $tabsysprefs{OPACDisplayRequestPriority} = "OPAC";
$tabsysprefs{OPACAllowHoldDateInFuture} = "OPAC";
$tabsysprefs{OPACPatronDetails} = "OPAC";
$tabsysprefs{OPACFinesTab} = "OPAC";
$tabsysprefs{DisplayOPACiconsXSLT} = "OPAC";
# OPAC
$tabsysprefs{SearchMyLibraryFirst} = "OPAC";

View file

@ -258,4 +258,5 @@ INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanatio
INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('HidePatronName', '0', '', 'If this is switched on, patron''s cardnumber will be shown instead of their name on the holds and catalog screens', 'YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACSearchForTitleIn','<li><a href="http://worldcat.org/search?q={TITLE}" target="_blank">Other Libraries (WorldCat)</a></li>\n<li><a href="http://www.scholar.google.com/scholar?q={TITLE}" target="_blank">Other Databases (Google Scholar)</a></li>\n<li><a href="http://www.bookfinder.com/search/?author={AUTHOR}&amp;title={TITLE}&amp;st=xl&amp;ac=qr" target="_blank">Online Stores (Bookfinder.com)</a></li>','Enter the HTML that will appear in the \'Search for this title in\' box on the detail page in the OPAC. Enter {TITLE}, {AUTHOR}, or {ISBN} in place of their respective variables in the URL. Leave blank to disable \'More Searches\' menu.','70|10','Textarea');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACPatronDetails','1','If OFF the patron details tab in the OPAC is disabled.','','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACFinesTab','1','If OFF the patron fines tab in the OPAC is disabled.','','YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACFinesTab','1','If OFF the patron fines tab in the OPAC is disabled.','','YesNo');
INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', '', 'If ON, displays the format, audience, type icons in XSLT MARC21 results and display pages.', 'YesNo');

View file

@ -258,3 +258,4 @@ INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanatio
INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ( 'ReturnToShelvingCart', '0', '', 'Si défini, quand un exemplaire est renvoyé son code sera modifié pour CART.' 'YesNo');
INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ('DisplayClearScreenButton', '0', '', 'Cette option ajoute un bouton à la page de circulation pour effacer l\'écran', 'YesNo');
INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('HidePatronName', '0', '', 'Active l''affichage du numéro des adhérents à la place de leur nom dans les pages de réservation et du catalogue.', 'YesNo');
INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', '', 'Si activé, affiche le format, le type de public et les icônes de type en XSLT (MARC21)).', 'YesNo');

View file

@ -237,3 +237,4 @@ INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES
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,explanation,options,type) VALUES('MergeAuthoritiesOnUpdate', '1', 'if ON, Updating authorities will automatically updates biblios',NULL,'YesNo');
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowNotForLoanOverride', '0', 'if ON, enables the librarian to choose when they want to check out a notForLoan regular item',NULL,'YesNo');
INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', '', 'If ON, displays the format, audience, type icons in XSLT MARC21 results and display pages.', 'YesNo');

View file

@ -2644,6 +2644,14 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
print "Upgrade to $DBversion done (Added primary keys to language tables)\n";
}
$DBversion = '3.01.00.042';
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
$dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('DisplayOPACiconsXSLT', '1', '', 'If ON, displays the format, audience, type icons in XSLT MARC21 results and display pages.', 'YesNo')");
SetVersion ($DBversion);
print "Upgrade to $DBversion done (added DisplayOPACiconsXSLT sysprefs)\n";
}
=item DropAllForeignKeys($table)
Drop all foreign keys of the table $table

View file

@ -16,6 +16,9 @@
<!-- Option: Display Alternate Graphic Representation (MARC 880) -->
<xsl:variable name="display880" select="boolean(marc:datafield[@tag=880])"/>
<xsl:variable name="DisplayOPACiconsXSLT" select="marc:sysprefs/marc:syspref[@name='DisplayOPACiconsXSLT']"/>
<xsl:variable name="OPACURLOpenInNewWindow" select="marc:sysprefs/marc:syspref[@name='OPACURLOpenInNewWindow']"/>
<xsl:variable name="URLLinkText" select="marc:sysprefs/marc:syspref[@name='URLLinkText']"/>
<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)"/>
@ -157,13 +160,14 @@
<span class="view"><a id="ISBDview" href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber={marc:datafield[@tag=999]/marc:subfield[@code='c']}">Card View (ISBD)</a></span>
</div>
<xsl:if test="$DisplayOPACiconsXSLT!='0'">
<xsl:if test="$materialTypeCode!=''">
<span class="results_summary"><span class="label">Type: </span>
<xsl:element name="img"><xsl:attribute name="src">/opac-tmpl/prog/famfamfam/<xsl:value-of select="$materialTypeCode"/>.png</xsl:attribute><xsl:attribute name="alt"></xsl:attribute></xsl:element>
<xsl:value-of select="$materialTypeLabel"/>
</span>
</xsl:if>
</xsl:if>
<!--Series: Alternate Graphic Representation (MARC 880) -->
<xsl:if test="$display880">
@ -395,23 +399,53 @@
<xsl:if test="marc:datafield[@tag=856]">
<span class="results_summary"><span class="label">Online Resources: </span>
<xsl:for-each select="marc:datafield[@tag=856]">
<a><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
<xsl:choose>
<xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">y3z</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
Click here to access online
</xsl:when>
</xsl:choose>
</a>
<xsl:choose>
<xsl:when test="position()=last()"></xsl:when>
<xsl:otherwise> | </xsl:otherwise>
</xsl:choose>
<xsl:if test="$OPACURLOpenInNewWindow='0'">
<a><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
<xsl:choose>
<xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">y3z</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
<xsl:choose>
<xsl:when test="$URLLinkText!=''">
<xsl:value-of select="$URLLinkText"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>Click here to access online</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</a>
</xsl:if>
<xsl:if test="$OPACURLOpenInNewWindow='1'">
<a target='_blank'><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
<xsl:choose>
<xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">y3z</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
<xsl:choose>
<xsl:when test="$URLLinkText!=''">
<xsl:value-of select="$URLLinkText"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>Click here to access online</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</a>
</xsl:if>
<xsl:choose>
<xsl:when test="position()=last()"><xsl:text> </xsl:text></xsl:when>
<xsl:otherwise> | </xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</span>
</xsl:if>

View file

@ -18,6 +18,9 @@
<!-- Option: Display Alternate Graphic Representation (MARC 880) -->
<xsl:variable name="display880" select="boolean(marc:datafield[@tag=880])"/>
<xsl:variable name="DisplayOPACiconsXSLT" select="marc:sysprefs/marc:syspref[@name='DisplayOPACiconsXSLT']"/>
<xsl:variable name="OPACURLOpenInNewWindow" select="marc:sysprefs/marc:syspref[@name='OPACURLOpenInNewWindow']"/>
<xsl:variable name="URLLinkText" select="marc:sysprefs/marc:syspref[@name='URLLinkText']"/>
<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)"/>
@ -483,6 +486,7 @@
</span>
</xsl:if>
<xsl:if test="$DisplayOPACiconsXSLT!='0'">
<span class="results_summary">
<xsl:if test="$typeOf008!=''">
<span class="label">Type: </span>
@ -819,6 +823,7 @@
</xsl:choose>
</xsl:if>
</span>
</xsl:if>
<!-- Publisher Statement: Alternate Graphic Representation (MARC 880) -->
<xsl:if test="$display880">
@ -860,7 +865,6 @@
</xsl:call-template>
</xsl:for-each>
</span>
</xsl:if>
<span class="results_summary">
@ -868,9 +872,8 @@
<xsl:choose>
<xsl:when test="marc:datafield[@tag=856]">
<xsl:for-each select="marc:datafield[@tag=856]">
<xsl:choose>
<xsl:when test="@ind2=0">
<a><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
<xsl:if test="$OPACURLOpenInNewWindow='0'">
<a><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
<xsl:choose>
<xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
<xsl:call-template name="subfieldSelect">
@ -878,19 +881,47 @@
</xsl:call-template>
</xsl:when>
<xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
Click here to access online
<xsl:choose>
<xsl:when test="$URLLinkText!=''">
<xsl:value-of select="$URLLinkText"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>Click here to access online</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</a>
</xsl:if>
<xsl:if test="$OPACURLOpenInNewWindow='1'">
<a target='_blank'><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
<xsl:choose>
<xsl:when test="position()=last()"></xsl:when>
<xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">y3z</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
<xsl:choose>
<xsl:when test="$URLLinkText!=''">
<xsl:value-of select="$URLLinkText"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>Click here to access online</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</a>
</xsl:if>
<xsl:choose>
<xsl:when test="position()=last()"><xsl:text> </xsl:text></xsl:when>
<xsl:otherwise> | </xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:when test="count(key('item-by-status', 'available'))=0 and count(key('item-by-status', 'reference'))=0">No copies available
</xsl:when>
<xsl:when test="count(key('item-by-status', 'available'))>0">