Proposed fix for Bug 5106 - Simplify MARC view choices in the OPAC (Conflict marker...
authorOwen Leonard <oleonard@myacpl.org>
Mon, 20 Dec 2010 19:11:26 +0000 (20:11 +0100)
committerChris Cormack <chrisc@catalyst.net.nz>
Tue, 21 Dec 2010 04:01:33 +0000 (17:01 +1300)
- Eliminates the "Extended MARC View" tab
- Points the "MARC View" tab to opac-MARCDetail.pl as it is when XSLT is off
- Offers a "view plain" link on opac-MARCDetail.pl. Clicking this link
  replaces the standard labeled MARC view with an unformatted view similar to the
  one displayed in the pop-up modal MARC view.
- When viewing the "plain view," clicking the "view labeled" link will return
  you to the standard labeled MARC view.
- Adds a new XSL file for displaying MARC data in a slightly-more-formatted
  manner (compared to one big <pre></pre> block).

Removed a conflict marker line from Owen's patch (Marcel).

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
koha-tmpl/opac-tmpl/prog/en/css/opac.css
koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tmpl
koha-tmpl/opac-tmpl/prog/en/modules/opac-MARCdetail.tmpl
koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl
koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACMARCdetail.xsl [new file with mode: 0644]
koha-tmpl/opac-tmpl/prog/images/loading.gif [new file with mode: 0644]
opac/opac-showmarc.pl

index bfff594..68cc572 100644 (file)
@@ -2000,3 +2000,8 @@ div.ft {
        background-color : rgb(239, 254, 213);
        background-color : rgba(239, 254, 213, 0.4);
 }
+
+#plainmarc table { border: 0; margin: .7em 0 0 0; font-family: monospace; font-size: 95%; }
+#plainmarc th { background-color : #FFF; border: 0; white-space: nowrap; text-align:left; vertical-align: top; padding: 2px; }
+#plainmarc td { border: 0; padding : 2px; vertical-align: top; }
+
index 475d681..305dfce 100644 (file)
      });
 //]]>
 </script>
-<!-- TMPL_IF NAME="OPACXSLTDetailsDisplay" --><script type="text/javascript">
-    var GB_ROOT_DIR = "/opac-tmpl/prog/en/lib/greybox/";
-</script>
-<script type="text/javascript" src="/opac-tmpl/prog/en/lib/greybox/AJS.js"></script>
-<script type="text/javascript" src="/opac-tmpl/prog/en/lib/greybox/AJS_fx.js"></script>
-<script type="text/javascript" src="/opac-tmpl/prog/en/lib/greybox/gb_scripts.js"></script>
-<link href="/opac-tmpl/prog/en/lib/greybox/gb_styles.css" rel="stylesheet" type="text/css" />
-<!-- /TMPL_IF -->
 </head>
 <body id="opac-isbddetail">
 
 
 
     <div id="yui-main">
-    <div class="yui-b"><div id="opac-detail" class="yui-ge">
+    <div class="yui-b">
+    <div id="opac-detail" class="yui-ge">
     <div class="yui-u first">
     <div class="container">
     <div id="catalogue_detail_biblio">
        
      <h1 style="float:left;margin:0 1em 1em 0;">ISBD View</h1> <div id="views">
-        <span class="view"><a id="Normalview" href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->">Normal View</a></span> <!-- TMPL_IF NAME="OPACXSLTDetailsDisplay" -->
-<span class="view"><a id="MARCviewPop" href="/cgi-bin/koha/opac-showmarc.pl?id=<!-- TMPL_VAR NAME="biblionumber" -->" title="MARC" rel="gb_page_center[600,500]">MARC View</a></span>
-       <span class="view"><a id="MARCview" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->">Expanded MARC View</a></span>
-<!-- TMPL_ELSE -->
-<span class="view"><a id="MARCview" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">MARC View</a></span>
-<!-- /TMPL_IF --> <span class="view"><span id="ISBDview">ISBD View</span></span>
-</div>
+        <span class="view"><a id="Normalview" href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->">Normal View</a></span> <span class="view"><a id="MARCview" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">MARC View</a></span> <span class="view"><span id="ISBDview">ISBD View</span></span></div>
+
     <div id="isbdcontents"><!-- TMPL_VAR name="ISBD" --></div>
-       
+
        </div>
        </div>
        </div>
index 8f5182e..fba0c08 100644 (file)
             YAHOO.widget.Overlay.windowResizeEvent.subscribe(positionfurthersearchesMenu);
      });
 <!-- TMPL_IF NAME="OPACXSLTDetailsDisplay" -->
-    var GB_ROOT_DIR = "/opac-tmpl/prog/en/lib/greybox/";
+$(document).ready(function(){
+    $.ajaxSetup({
+        error:function(x,e){
+            switch (x.status) {
+                case 200: break;
+                default:
+                $('#switchview').parent().html("<div class=\"dialog alert\">"+_("Sorry, plain view is temporarily unavailable")+".</div>");
+                $("#plainmarc").hide();
+                $("#labeledmarc").show();
+                break;
+            }
+        }
+    });
+
+    var loaded = 0;
+    $("#switchview").toggle(
+      function () {
+        $(this).text(_("view labeled"));
+        $("#labeledmarc").hide();
+        if(!loaded){
+            $("#plainmarc").show().html("<div style=\"margin:1em;padding:1em;border:1px solid #EEE;font-size:150%;\"><img src=\"/opac-tmpl/prog/images/loading.gif\" /> "+_("Loading")+"...</div>").load("/cgi-bin/koha/opac-showmarc.pl","id=<!-- TMPL_VAR name="biblionumber" -->&viewas=html");
+            loaded = 1;
+        } else {
+            $("#plainmarc").show();
+        }
+      },
+      function () {
+        $(this).text(_("view plain"));
+        $("#labeledmarc").show();
+        $("#plainmarc").hide();
+      }
+    );
+});
 <!-- /TMPL_IF -->
 //]]>
 </script>
-<!-- TMPL_IF NAME="OPACXSLTDetailsDisplay" -->
-<script type="text/javascript" src="/opac-tmpl/prog/en/lib/greybox/AJS.js"></script>
-<script type="text/javascript" src="/opac-tmpl/prog/en/lib/greybox/AJS_fx.js"></script>
-<script type="text/javascript" src="/opac-tmpl/prog/en/lib/greybox/gb_scripts.js"></script>
-<link href="/opac-tmpl/prog/en/lib/greybox/gb_styles.css" rel="stylesheet" type="text/css" />
-<!-- /TMPL_IF -->
 </head>
 <body id="opac-marcdetail">
 
    <div id="bd">
 <!--TMPL_INCLUDE NAME="masthead.inc" -->
 
-
     <div id="yui-main">
     <div class="yui-b"><div id="opac-detail" class="yui-ge">
     <div class="yui-u first">
     <div class="container">
     <div id="catalogue_detail_biblio">
 
-       <h1 style="float:left;margin: 0 1em 1em 0;">MARC View</h1>
-       <div id="views">
-       <span class="view"><a id="Normalview" href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->">Normal View</a></span> 
-
-<!-- TMPL_IF NAME="OPACXSLTDetailsDisplay" -->
-<span class="view"><a id="MARCviewPop" href="/cgi-bin/koha/opac-showmarc.pl?id=<!-- TMPL_VAR NAME="biblionumber" -->" title="MARC" rel="gb_page_center[600,500]">MARC View</a></span>
-        <span class="view"><span id="MARCview">Expanded MARC View</span></span>
-<!-- TMPL_ELSE -->
-<span class="view"><span id="MARCview">MARC View</span>
-<!-- /TMPL_IF -->
+    <h2 style="float:left;margin: 0 1em 1em 0;">MARC View</h2>
+    <div id="views">
+    <span class="view"><a id="Normalview" href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->">Normal View</a></span>
 
- <!-- TMPL_IF NAME="ISBD" --><span class="view"><a id="ISBDview"  href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->">ISBD View</a></span><!-- /TMPL_IF -->
+<span class="view"><span id="MARCview">MARC View</span></span>
+<!-- TMPL_IF NAME="ISBD" --><span class="view"><a id="ISBDview"  href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->">ISBD View</a></span><!-- /TMPL_IF -->
 </div>
-    <h1 style="clear:both;"><!-- TMPL_VAR NAME="bibliotitle" --> (Record no. <!-- TMPL_VAR NAME="biblionumber" -->)</h1>
-       <table id="marc">
+    <h3 style="clear:both;"><!-- TMPL_VAR NAME="bibliotitle" --> (Record no. <!-- TMPL_VAR NAME="biblionumber" -->)</h3>
+    <!-- TMPL_IF NAME="OPACXSLTDetailsDisplay" -->
+    <div>[ <a id="switchview" href="/cgi-bin/koha/opac-showmarc.pl?id=<!-- TMPL_VAR NAME="biblionumber" -->&amp;viewas=html">view plain</a> ]</div>
+    <div id="plainmarc"></div><!-- /TMPL_IF -->
+    <div id="labeledmarc">
+    <table id="marc">
         <!-- TMPL_LOOP name="0XX" -->
         <tr><th colspan="2"><!-- TMPL_VAR name="tag" --></th></tr>
         <!-- TMPL_LOOP name="subfield" -->
             <!-- /TMPL_LOOP -->
         <!-- /TMPL_LOOP -->
     </table>
+    </div>
 <!-- TMPL_IF NAME="item_header_loop" -->
         <table id="items">
-                       <caption>Copies</caption>
+            <caption>Copies</caption>
                 <tr>
                     <!-- TMPL_LOOP name="item_header_loop" -->
                         <th>
     </div>
     </div>
     </div>
-       <div class="yui-u">
-       <div class="container">
+    <div class="yui-u">
+    <div class="container">
 <ul id="action">
 
 <!-- TMPL_UNLESS NAME="norequests" -->
         <!-- TMPL_IF NAME="opacuserlogin" -->
-               <!-- TMPL_IF NAME="RequestOnOpac" -->
-                       <!-- TMPL_IF NAME="AllowOnShelfHolds" -->
-                               <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Place Hold</a></li>
-                       <!-- TMPL_ELSE -->
-                               <!-- TMPL_IF NAME="ItemsIssued" -->
-                                       <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Place Hold</a></li>
-                               <!-- /TMPL_IF -->
-                       <!-- /TMPL_IF -->
-
-               <!-- /TMPL_IF -->
-       <!-- /TMPL_IF -->
+        <!-- TMPL_IF NAME="RequestOnOpac" -->
+            <!-- TMPL_IF NAME="AllowOnShelfHolds" -->
+                <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Place Hold</a></li>
+            <!-- TMPL_ELSE -->
+                <!-- TMPL_IF NAME="ItemsIssued" -->
+                    <li><a class="reserve" href="/cgi-bin/koha/opac-reserve.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Place Hold</a></li>
+                <!-- /TMPL_IF -->
+            <!-- /TMPL_IF -->
+
+            <!-- /TMPL_IF -->
+    <!-- /TMPL_IF -->
 <!-- /TMPL_UNLESS -->
         <li><a class="print" href="/cgi-bin/koha/opac-detailprint.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" onclick="Dopop('opac-detailprint.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->'); return false;">
             Print
 </div>
 <!-- /TMPL_IF -->
 
-               <div id="export">
-               <form method="get" action="/cgi-bin/koha/opac-export.pl">
-               <label for="format">Save Record:</label>
-           <select name="format" id="format">
-               <option value="">-- Choose Format --</option>
+        <div id="export">
+        <form method="get" action="/cgi-bin/koha/opac-export.pl">
+        <label for="format">Save Record:</label>
+        <select name="format" id="format">
+        <option value="">-- Choose Format --</option>
         <option value="mods">MODS (XML)</option>
         <option value="dc">Dublin Core (XML)</option>
         <option value="marcxml">MARCXML</option>
index e83ea3a..931153b 100644 (file)
@@ -47,14 +47,6 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
 <style type="text/css">
     #addtagl { display: none; }
 </style>
-<!-- TMPL_IF NAME="OPACXSLTDetailsDisplay" --><script type="text/javascript">
-    var GB_ROOT_DIR = "/opac-tmpl/prog/en/lib/greybox/";                               
-</script>
-<script type="text/javascript" src="/opac-tmpl/prog/en/lib/greybox/AJS.js"></script>
-<script type="text/javascript" src="/opac-tmpl/prog/en/lib/greybox/AJS_fx.js"></script>
-<script type="text/javascript" src="/opac-tmpl/prog/en/lib/greybox/gb_scripts.js"></script>
-<link href="/opac-tmpl/prog/en/lib/greybox/gb_styles.css" rel="stylesheet" type="text/css" />
-<!-- /TMPL_IF -->
 
 </head>
 <body id="opac-detail">
index 24326f2..5703059 100755 (executable)
         </xsl:choose>
         <div id="views">
         <span class="view"><span id="Normalview">Normal View</span> </span>
-        <span class="view"><a id="MARCviewPop" href="/cgi-bin/koha/opac-showmarc.pl?id={marc:datafield[@tag=999]/marc:subfield[@code='c']}" title="MARC" rel="gb_page_center[600,500]">MARC View</a></span>
-        <span class="view"><a id="MARCview" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber={marc:datafield[@tag=999]/marc:subfield[@code='c']}" title="MARC">Expanded MARC View</a></span>
+        <span class="view"><a id="MARCview" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber={marc:datafield[@tag=999]/marc:subfield[@code='c']}" title="MARC">MARC View</a></span>
 <xsl:if test="$ShowISBD!='0'">
-        <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>
+        <span class="view"><a id="ISBDview" href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber={marc:datafield[@tag=999]/marc:subfield[@code='c']}">ISBD View</a></span>
 </xsl:if>
         </div>
 
diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACMARCdetail.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACMARCdetail.xsl
new file mode 100644 (file)
index 0000000..ee4058a
--- /dev/null
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+       <xsl:output method="html"/>
+
+       <xsl:template match="/">
+               <html>
+                       <xsl:apply-templates/>
+               </html>
+       </xsl:template>
+
+       <xsl:template match="marc:record">
+               <table>
+                       <tr>
+                               <th style="white-space:nowrap">
+                                       000
+                               </th>
+                               <td colspan="2"></td>
+                               <td>
+                                       <xsl:value-of select="marc:leader"/>
+                               </td>
+                       </tr>
+                       <xsl:apply-templates select="marc:datafield|marc:controlfield"/>
+               </table>
+       </xsl:template>
+
+       <xsl:template match="marc:controlfield">
+               <tr>
+                       <th style="white-space:nowrap">
+                               <xsl:value-of select="@tag"/>
+                       </th>
+                       <td colspan="2"></td>
+                       <td>
+                               <xsl:value-of select="."/>
+                       </td>
+               </tr>
+       </xsl:template>
+
+       <xsl:template match="marc:datafield">
+               <tr>
+                       <th style="white-space:nowrap">
+                               <xsl:value-of select="@tag"/>
+                       </th>
+                       <td><xsl:value-of select="@ind1"/></td>
+                       <td><xsl:value-of select="@ind2"/></td>
+                       <td><xsl:apply-templates select="marc:subfield"/></td>
+               </tr>
+       </xsl:template>
+
+       <xsl:template match="marc:subfield">
+               <strong>_<xsl:value-of select="@code"/></strong> <xsl:value-of select="."/>
+               <xsl:choose>
+               <xsl:when test="position()=last()"><xsl:text> </xsl:text></xsl:when><xsl:otherwise><br /></xsl:otherwise></xsl:choose>
+       </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
diff --git a/koha-tmpl/opac-tmpl/prog/images/loading.gif b/koha-tmpl/opac-tmpl/prog/images/loading.gif
new file mode 100644 (file)
index 0000000..3c2f7c0
Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/loading.gif differ
index b379917..9c70d56 100755 (executable)
@@ -63,17 +63,30 @@ if ($importid) {
 }
                
 if ($view eq 'card') {
-$xmlrecord = GetXmlBiblio($biblionumber) unless $xmlrecord;
-my $xslfile = C4::Context->config('opachtdocs')."/prog/en/xslt/compact.xsl";
-my $parser = XML::LibXML->new();
-my $xslt   = XML::LibXSLT->new();
-my $source = $parser->parse_string($xmlrecord);
-my $style_doc = $parser->parse_file($xslfile);
-my $stylesheet = $xslt->parse_stylesheet($style_doc);
-my $results = $stylesheet->transform($source);
-my $newxmlrecord = $stylesheet->output_string($results);
-#warn $newxmlrecord;
-print $input->header(), $newxmlrecord;
+    $xmlrecord = GetXmlBiblio($biblionumber) unless $xmlrecord;
+    my $xslfile = C4::Context->config('opachtdocs')."/prog/en/xslt/compact.xsl";
+    my $parser = XML::LibXML->new();
+    my $xslt   = XML::LibXSLT->new();
+    my $source = $parser->parse_string($xmlrecord);
+    my $style_doc = $parser->parse_file($xslfile);
+    my $stylesheet = $xslt->parse_stylesheet($style_doc);
+    my $results = $stylesheet->transform($source);
+    my $newxmlrecord = $stylesheet->output_string($results);
+    #warn $newxmlrecord;
+    print $input->header(), $newxmlrecord;
+    exit;
+} elsif ($view eq 'html'){
+    $xmlrecord = GetXmlBiblio($biblionumber) unless $xmlrecord;
+    my $xslfile = C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPACMARCdetail.xsl";
+    my $parser = XML::LibXML->new();
+    my $xslt   = XML::LibXSLT->new();
+    my $source = $parser->parse_string($xmlrecord);
+    my $style_doc = $parser->parse_file($xslfile);
+    my $stylesheet = $xslt->parse_stylesheet($style_doc);
+    my $results = $stylesheet->transform($source);
+    my $newxmlrecord = $stylesheet->output_string($results);
+    #warn $newxmlrecord;
+    print $input->header(), $newxmlrecord;
     exit;
 } else {
     $record =GetMarcBiblio($biblionumber) unless $record;