adding a holdings-specific stylesheet
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 11 Jun 2006 15:50:05 +0000 (15:50 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 11 Jun 2006 15:50:05 +0000 (15:50 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@4569 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm
Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm
Open-ILS/xsl/MARC21slim2HTMLCard-holdings.xsl [new file with mode: 0755]
Open-ILS/xsl/MARC21slim2HTMLCard.xsl

index 5feca73..72afa11 100644 (file)
@@ -2023,13 +2023,12 @@ sub biblio_search_multi_class_fts {
                SELECT  b.id,
                        $relevance AS rel,
                        $rank AS rank,
-                       src.transcendant
+                       b.source
                FROM    $search_table_list
                        $metabib_record_descriptor rd,
                        $source_table src,
                        $br_table b
                WHERE   rd.record = b.id
-                       AND src.id = b.source
                        AND b.active IS TRUE
                        AND b.deleted IS FALSE
                        $fts_list
@@ -2039,7 +2038,7 @@ sub biblio_search_multi_class_fts {
                        $a_filter
                        $l_filter
                        $lf_filter
-               GROUP BY b.id, src.transcendant
+               GROUP BY b.id, b.source
                ORDER BY 3 $sort_dir
                LIMIT $visiblity_limit
        SQL
@@ -2049,6 +2048,7 @@ sub biblio_search_multi_class_fts {
 
                        SELECT  s.*
                          FROM  ($select) s
+                               LEFT OUTER JOIN $source_table src ON (s.source = src.id)
                          WHERE EXISTS (
                                SELECT  1
                                  FROM  $asset_call_number_table cn,
@@ -2068,7 +2068,7 @@ sub biblio_search_multi_class_fts {
                                        AND cn.deleted IS FALSE
                                  LIMIT 1
                                )
-                               OR transcendant IS TRUE
+                               OR src.transcendant IS TRUE
                          ORDER BY 3 $sort_dir
                SQL
        } else {
@@ -2076,6 +2076,7 @@ sub biblio_search_multi_class_fts {
 
                        SELECT  s.*
                          FROM  ($select) s
+                               LEFT OUTER JOIN $source_table src ON (s.source = src.id)
                          WHERE EXISTS (
                                SELECT  1
                                  FROM  $asset_call_number_table cn,
@@ -2091,7 +2092,7 @@ sub biblio_search_multi_class_fts {
                                  WHERE cn.record = s.id
                                  LIMIT 1
                                )
-                               OR transcendant IS TRUE
+                               OR src.transcendant IS TRUE
                          ORDER BY 3 $sort_dir
                SQL
        }
index 82840ea..07efd90 100644 (file)
@@ -761,7 +761,7 @@ sub create_record_feed {
        $feed->unapi($unapi);
 
        $type = 'atom' if ($type eq 'html');
-       $type = 'marcxml' if ($type eq 'htmlcard');
+       $type = 'marcxml' if ($type eq 'htmlcard' or $type eq 'htmlholdings');
 
        for my $rec (@$records) {
                next unless($rec);
@@ -782,7 +782,7 @@ sub create_record_feed {
                }
 
                $node->id($item_tag);
-               $node->link(alternate => $feed->unapi . "?id=$item_tag&format=htmlcard" => 'text/html');
+               $node->link(alternate => $feed->unapi . "?id=$item_tag&format=htmlholdings" => 'text/html');
                $node->link(opac => $feed->unapi . "?id=$item_tag&format=opac");
                $node->link(unapi => $feed->unapi . "?id=$item_tag");
                $node->link('unapi-id' => $item_tag);
index ffd86db..255ee11 100644 (file)
@@ -475,6 +475,7 @@ sub new {
        my $class = shift;
        my $self = $class->SUPER::new;
        $self->type('text/html');
+       $self->{xsl} = "/MARC21slim2HTMLCard.xsl";
        return $self;
 }
 
@@ -495,8 +496,7 @@ sub toString {
        $xslt_file ||=
                 OpenSRF::Utils::SettingsClient
                                ->new
-                               ->config_value( dirs => 'xsl' ).
-                "/MARC21slim2HTMLCard.xsl";
+                               ->config_value( dirs => 'xsl' ).$self->{xsl};
 
         # parse the MODS xslt ...
         my $atom2html_xslt = $_xslt->parse_stylesheet( $_parser->parse_file($xslt_file) );
@@ -511,8 +511,20 @@ sub toString {
        return $new_doc->toString(1); 
 }
 
+package OpenILS::WWW::SuperCat::Feed::htmlholdings;
+use base 'OpenILS::WWW::SuperCat::Feed::htmlcard';
+
+sub new {
+       my $class = shift;
+       my $self = $class->SUPER::new;
+       $self->{xsl} = "/MARC21slim2HTMLCard-holdings.xsl";
+       return $self;
+}
 
 package OpenILS::WWW::SuperCat::Feed::htmlcard::item;
 use base 'OpenILS::WWW::SuperCat::Feed::marcxml::item';
 
+package OpenILS::WWW::SuperCat::Feed::htmlholdings::item;
+use base 'OpenILS::WWW::SuperCat::Feed::htmlcard::item';
+
 1;
diff --git a/Open-ILS/xsl/MARC21slim2HTMLCard-holdings.xsl b/Open-ILS/xsl/MARC21slim2HTMLCard-holdings.xsl
new file mode 100755 (executable)
index 0000000..ed6c41e
--- /dev/null
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+  
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:marc="http://www.loc.gov/MARC21/slim"
+  xmlns:hold="http://open-ils.org/spec/holdings/v1"
+  version="1.0">
+  <xsl:output method="html" doctype-public="-//W3C/DTD HTML 4.01 Transitional//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd" />    
+  <xsl:template match="/">
+     <html>
+       <head>
+         <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
+         <link href="{$base_dir}/htmlcard.css" rel="stylesheet" type="text/css" />
+       </head>
+       <body>
+        <xsl:apply-templates select="//marc:record"/>
+       </body>
+     </html>
+  </xsl:template>
+      
+  <xsl:template match="marc:record">
+    <div class="cardimage">
+     <xsl:apply-templates select="marc:datafield[@tag!='082' and @tag!='092' and @tag!='010']"/>
+     <span class="bottom">
+      <xsl:apply-templates select="marc:controlfield[@tag='001']"/>
+      <xsl:apply-templates select="marc:datafield[@tag='082' or @tag='092' or @tag='010']"/>
+     </span>
+    </div>
+    <br/>
+    <xsl:apply-templates select="hold:volumes"/>
+    <br/>
+  </xsl:template>
+
+  <xsl:template match="hold:volumes">
+    <xsl:if test="count(hold:volume) &gt; 0">
+       <u>Holdings</u>
+    </xsl:if>
+    <ul>
+    <xsl:apply-templates select="hold:volume">
+      <xsl:sort select="@lib"/>
+    </xsl:apply-templates>
+    </ul>
+  </xsl:template>
+
+  <xsl:template match="hold:volume">
+      <li> <b><xsl:value-of select="./@label"/></b>
+        <xsl:apply-templates select="hold:copies"/>
+      </li>
+  </xsl:template>
+
+  <xsl:template match="hold:copies">
+    <ul>
+    <xsl:apply-templates select="hold:copy">
+      <xsl:sort select="hold:location"/>
+    </xsl:apply-templates>
+    </ul>
+  </xsl:template>
+
+  <xsl:template match="hold:copy">
+      <li> <xsl:value-of select="./@barcode"/>
+        <ul>
+         <li>Circulating from <b><xsl:value-of select="hold:circlib"/></b></li>
+         <li>Located at <b><xsl:value-of select="hold:location"/></b></li>
+         <li>Status is <b><xsl:value-of select="hold:status"/></b></li>
+       </ul>
+      </li>
+  </xsl:template>
+
+  <xsl:template match="marc:controlfield">
+      <span class="oclc">#<xsl:value-of select="substring(.,4)"/></span>
+  </xsl:template>
+      
+  <xsl:template match="marc:datafield">
+    <xsl:if test="starts-with(@tag, '1')">
+      <p class="mainheading"><xsl:value-of select="."/></p>
+    </xsl:if>
+
+    <xsl:if test="starts-with(@tag, '24') and /marc:record/marc:datafield[@tag='100']">
+      <span class="title"><xsl:value-of select="."/></span>
+    </xsl:if>
+
+    <xsl:if test="starts-with(@tag, '24') and not(/marc:record/marc:datafield[@tag='100'])">
+      <span class="titlemain"><xsl:value-of select="."/></span><br/>
+    </xsl:if>
+
+    <xsl:if test="@tag='260'">
+      <xsl:value-of select="."/>
+    </xsl:if>
+
+    <xsl:if test="@tag='300'">
+      <p class="extent"><xsl:value-of select="."/></p>
+     </xsl:if>
+
+    <xsl:if test="starts-with(@tag, '5')">
+      <p class="note"><xsl:value-of select="."/></p>
+    </xsl:if>
+
+    <xsl:if test="@tag='650'">
+      <span class='counter'><xsl:number count="marc:datafield[@tag='650']"/>.</span> <xsl:apply-templates select="marc:subfield"/>
+    </xsl:if>
+
+    <xsl:if test="@tag='653'">
+      <span class="counter"><xsl:number format="i" count="marc:datafield[@tag='653']"/>.</span> <xsl:apply-templates select="marc:subfield"/>
+    </xsl:if>
+
+    <xsl:if test="@tag='010'">
+      <xsl:variable name="LCCN.nospace" select="translate(., ' ', '')"/>
+      <xsl:variable name="LCCN.length" select="string-length($LCCN.nospace)"/>
+      <xsl:variable name="LCCN.display" select="concat(substring($LCCN.nospace, 1, $LCCN.length - 6), '-', format-number(substring($LCCN.nospace, $LCCN.length - 5),'#'))"/>
+      <span class="LCCN">LCCN:<xsl:value-of select="$LCCN.display"/></span>
+    </xsl:if>
+
+    <xsl:if test="@tag='082' or @tag='092'">
+      <span class="DDC"><xsl:value-of select="marc:subfield[@code='a']"/></span>
+    </xsl:if>
+
+    <xsl:if test="@tag='856'">
+     <br/><xsl:apply-templates mode="link" select="marc:subfield" />
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="marc:subfield" mode="link">
+    <xsl:if test="@code='u'">
+      <span class="link">
+        <a class="url" href="{.}">
+                <xsl:choose>
+                        <xsl:when test="../marc:subfield[@code='y']">
+                                <xsl:value-of select="../marc:subfield[@code='y']"/>
+                        </xsl:when>
+                        <xsl:when test="../marc:subfield[@code='3']">
+                                <xsl:value-of select="../marc:subfield[@code='3']"/>
+                        </xsl:when>
+                        <xsl:otherwise>
+                                <xsl:value-of select="."/>
+                        </xsl:otherwise>
+                </xsl:choose>
+        </a>
+      </span>
+    </xsl:if>
+  </xsl:template>
+  
+  <xsl:template match="marc:subfield">
+    <xsl:if test="@code!='2'">    
+     <xsl:if test="@code!='a'">--</xsl:if>
+     <xsl:value-of select="."/>
+    </xsl:if>
+  </xsl:template>
+
+</xsl:stylesheet>
index 5ac8c4c..dcfe004 100755 (executable)
       <xsl:apply-templates select="marc:datafield[@tag='082' or @tag='092' or @tag='010']"/>
      </span>
     </div>
-    <br/>
-    <u>Holdings</u>
-    <xsl:apply-templates select="hold:volumes"/>
-    <br/>
-  </xsl:template>
-
-  <xsl:template match="hold:volumes">
-    <ul>
-    <xsl:apply-templates select="hold:volume">
-      <xsl:sort select="@lib"/>
-    </xsl:apply-templates>
-    </ul>
-  </xsl:template>
-
-  <xsl:template match="hold:volume">
-      <li> <b><xsl:value-of select="./@label"/></b>
-        <xsl:apply-templates select="hold:copies"/>
-      </li>
-  </xsl:template>
-
-  <xsl:template match="hold:copies">
-    <ul>
-    <xsl:apply-templates select="hold:copy">
-      <xsl:sort select="hold:location"/>
-    </xsl:apply-templates>
-    </ul>
-  </xsl:template>
-
-  <xsl:template match="hold:copy">
-      <li> <xsl:value-of select="./@barcode"/>
-        <ul>
-         <li>Circulating from <b><xsl:value-of select="hold:circlib"/></b></li>
-         <li>Located at <b><xsl:value-of select="hold:location"/></b></li>
-         <li>Status is <b><xsl:value-of select="hold:status"/></b></li>
-       </ul>
-      </li>
   </xsl:template>
 
   <xsl:template match="marc:controlfield">
   <xsl:template match="marc:subfield" mode="link">
     <xsl:if test="@code='u'">
       <span class="link">
-        <a class="url" href="{.}"><xsl:value-of select="../marc:subfield[@code='y']"/></a>
+        <a class="url" href="{.}">
+               <xsl:choose>
+                       <xsl:when test="../marc:subfield[@code='y']">
+                               <xsl:value-of select="../marc:subfield[@code='y']"/>
+                       </xsl:when>
+                       <xsl:when test="../marc:subfield[@code='3']">
+                               <xsl:value-of select="../marc:subfield[@code='3']"/>
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <xsl:value-of select="."/>
+                       </xsl:otherwise>
+               </xsl:choose>
+       </a>
       </span>
     </xsl:if>
   </xsl:template>