[Koha-patches] [PATCH] bug 6919 - Implementing XSLTResultsDisplay

alex.arnaud at biblibre.com alex.arnaud at biblibre.com
Mon Sep 26 16:39:31 CEST 2011


From: Alex Arnaud <alex.arnaud at biblibre.com>

---
 C4/Search.pm                                       |    7 +-
 .../prog/en/modules/catalogue/results.tt           |    6 ++-
 .../prog/en/xslt/MARC21slim2intranetResults.xsl    |   43 ++++++++++++
 .../prog/en/xslt/UNIMARCslim2intranetResults.xsl   |   69 ++++++++++++++++++++
 4 files changed, 120 insertions(+), 5 deletions(-)
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetResults.xsl

diff --git a/C4/Search.pm b/C4/Search.pm
index c3cff65..c34009f 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -1743,12 +1743,11 @@ sub searchResults {
 	use C4::Charset;
 	SetUTF8Flag($marcrecord);
 	$debug && warn $marcrecord->as_formatted;
-        if (!$scan && $search_context eq 'opac' && C4::Context->preference("OPACXSLTResultsDisplay")) {
-            # FIXME note that XSLTResultsDisplay (use of XSLT to format staff interface bib search results)
-            # is not implemented yet
+	my $interface = $search_context eq 'opac' ? 'OPAC' : '';
+        if (!$scan && C4::Context->preference($interface . "XSLTResultsDisplay")) {
             $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, 'Results', 
                                                                 $search_context, 1);
-                # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
+	    # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
 
         }
 
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt
index 7a1039d..71baeff 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt
@@ -439,8 +439,11 @@ YAHOO.util.Event.onContentReady("searchheader", function () {
                                 <input type="checkbox" class="selection" id="bib[% SEARCH_RESULT.biblionumber %]" name="biblionumber" value="[% SEARCH_RESULT.biblionumber %]" style="display:none" />
                             </td>
                             <td>
+                            [% IF ( SEARCH_RESULT.XSLTResultsRecord ) %] 
+                                [% SEARCH_RESULT.XSLTResultsRecord %] 
+                            [% ELSE %]
                                 <p>[% SEARCH_RESULT.result_number %].
-                                 [% biblionumber = SEARCH_RESULT.biblionumber %]
+                                [% biblionumber = SEARCH_RESULT.biblionumber %]
 
 				[% INCLUDE 'biblio-default-view.inc' %]
                                             <b>[% IF ( SEARCH_RESULT.title ) %][% SEARCH_RESULT.title |html %][% ELSE %]No title[% END %]</b>
@@ -495,6 +498,7 @@ YAHOO.util.Event.onContentReady("searchheader", function () {
                                 [% END %]
 
                                 [% END %]
+                                [% END %]
                                   <p class="hold">[% IF ( SEARCH_RESULT.norequests ) %]
                                   <span class="noholdstext">No holds allowed</span>
                               [% ELSE %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl
new file mode 100644
index 0000000..e71188b
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id: MARC21slim2DC.xsl,v 1.1 2003/01/06 08:20:27 adam Exp $ -->
+<xsl:stylesheet version="1.0"
+  xmlns:marc="http://www.loc.gov/MARC21/slim"
+  xmlns:items="http://www.koha.org/items"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  exclude-result-prefixes="marc items">
+<xsl:import href="UNIMARCslimUtils.xsl"/>
+<xsl:output method = "xml" indent="yes" omit-xml-declaration = "yes" />
+<xsl:key name="item-by-status" match="items:item" use="items:status"/>
+<xsl:key name="item-by-status-and-branch" match="items:item" use="concat(items:status, ' ', items:homebranch)"/>
+
+<xsl:template match="/">
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="marc:record">
+  <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:variable name="biblionumber" select="marc:controlfield[@tag=001]"/>
+  <xsl:variable name="isbn" select="marc:datafield[@tag=020]/marc:subfield[@code='a']"/>
+     	
+  <xsl:if test="marc:datafield[@tag=200]">
+    <xsl:for-each select="marc:datafield[@tag=200]">
+      	<a>
+	  <xsl:attribute name="href">/cgi-bin/koha/catalogue/detail.pl?biblionumber=<xsl:value-of select="$biblionumber"/>
+	  </xsl:attribute>
+	  <xsl:variable name="title" select="marc:subfield[@code='a']"/>
+	</a>
+      <xsl:if test="marc:subfield[@code='b']">
+        <xsl:text> : </xsl:text>
+        <xsl:value-of select="marc:subfield[@code='b']"/>
+      </xsl:if>
+      <xsl:if test="marc:subfield[@code='c']">
+        <xsl:text> : </xsl:text>
+        <xsl:value-of select="marc:subfield[@code='c']"/>
+      </xsl:if>
+      <xsl:text> </xsl:text>
+    </xsl:for-each>
+  </xsl:if>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetResults.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetResults.xsl
new file mode 100644
index 0000000..88c9026
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetResults.xsl
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- $Id: MARC21slim2DC.xsl,v 1.1 2003/01/06 08:20:27 adam Exp $ -->
+<xsl:stylesheet version="1.0"
+  xmlns:marc="http://www.loc.gov/MARC21/slim"
+  xmlns:items="http://www.koha.org/items"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  exclude-result-prefixes="marc items">
+<xsl:import href="UNIMARCslimUtils.xsl"/>
+<xsl:output method = "xml" indent="yes" omit-xml-declaration = "yes" />
+<xsl:key name="item-by-status" match="items:item" use="items:status"/>
+<xsl:key name="item-by-status-and-branch" match="items:item" use="concat(items:status, ' ', items:homebranch)"/>
+
+<xsl:template match="/">
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="marc:record">
+  <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:variable name="biblionumber" select="marc:controlfield[@tag=001]"/>
+  <xsl:variable name="isbn" select="marc:datafield[@tag=010]/marc:subfield[@code='a']"/>
+     	
+  <xsl:if test="marc:datafield[@tag=200]">
+    <xsl:for-each select="marc:datafield[@tag=200]">
+      	<a><xsl:attribute name="href">/cgi-bin/koha/catalogue/detail.pl?biblionumber=<xsl:value-of select="$biblionumber"/>
+           </xsl:attribute>
+        <xsl:variable name="title" select="marc:subfield[@code='a']"/>
+        <xsl:variable name="ntitle"
+             select="translate($title, '&#x0098;&#x009C;&#xC29C;&#xC29B;&#xC298;&#xC288;&#xC289;','')"/>
+        <xsl:value-of select="$ntitle" />
+      </a>
+      <xsl:if test="marc:subfield[@code='e']">
+        <xsl:text> : </xsl:text>
+        <xsl:value-of select="marc:subfield[@code='e']"/>
+      </xsl:if>
+      <xsl:if test="marc:subfield[@code='b']">
+        <xsl:text> [</xsl:text>
+        <xsl:value-of select="marc:subfield[@code='b']"/>
+        <xsl:text>]</xsl:text>
+      </xsl:if>
+      <xsl:if test="marc:subfield[@code='h']">
+        <xsl:text> : </xsl:text>
+        <xsl:value-of select="marc:subfield[@code='h']"/>
+      </xsl:if>
+      <xsl:if test="marc:subfield[@code='i']">
+        <xsl:text> : </xsl:text>
+        <xsl:value-of select="marc:subfield[@code='i']"/>
+      </xsl:if>
+      <xsl:if test="marc:subfield[@code='f']">
+        <xsl:text> / </xsl:text>
+        <xsl:value-of select="marc:subfield[@code='f']"/>
+      </xsl:if>
+      <xsl:if test="marc:subfield[@code='g']">
+        <xsl:text> ; </xsl:text>
+        <xsl:value-of select="marc:subfield[@code='g']"/>
+      </xsl:if>
+      <xsl:text> </xsl:text>
+    </xsl:for-each>
+  </xsl:if>
+
+  <xsl:call-template name="tag_4xx" />
+
+  <xsl:call-template name="tag_210" />
+
+  <xsl:call-template name="tag_215" />
+
+</xsl:template>
+</xsl:stylesheet>
-- 
1.7.0.4



More information about the Koha-patches mailing list