[Koha-patches] [PATCH] [SIGNED-OFF] Proposed fix for Bug 5106 - Simplify MARC view choices in the OPAC (Conflict marker fix)

Marcel de Rooy M.de.Rooy at rijksmuseum.nl
Mon Dec 20 19:56:16 CET 2010


From: Owen Leonard <oleonard at myacpl.org>

- 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 at rijksmuseum.nl>
---
 koha-tmpl/opac-tmpl/prog/en/css/opac.css           |    5 +
 .../opac-tmpl/prog/en/modules/opac-ISBDdetail.tmpl |   22 +---
 .../opac-tmpl/prog/en/modules/opac-MARCdetail.tmpl |  104 ++++++++++++--------
 .../opac-tmpl/prog/en/modules/opac-detail.tmpl     |    8 --
 .../prog/en/xslt/MARC21slim2OPACDetail.xsl         |    5 +-
 opac/opac-showmarc.pl                              |   35 +++++--
 6 files changed, 100 insertions(+), 79 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/prog/en/css/opac.css b/koha-tmpl/opac-tmpl/prog/en/css/opac.css
index bfff594..68cc572 100644
--- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css
+++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css
@@ -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; }
+
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tmpl
index 475d681..305dfce 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-ISBDdetail.tmpl
@@ -21,14 +21,6 @@
      });
 //]]>
 </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">

@@ -38,21 +30,17 @@


     <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>
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-MARCdetail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-MARCdetail.tmpl
index 8f5182e..fba0c08 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-MARCdetail.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-MARCdetail.tmpl
@@ -17,16 +17,42 @@
             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">

@@ -34,28 +60,25 @@
    <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" -->
@@ -155,9 +178,10 @@
             <!-- /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>
@@ -176,23 +200,23 @@
     </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
@@ -223,11 +247,11 @@
 </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>
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
index e83ea3a..931153b 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
@@ -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">
diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl
index 24326f2..5703059 100755
--- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl
+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl
@@ -181,10 +181,9 @@
         </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/opac/opac-showmarc.pl b/opac/opac-showmarc.pl
index b379917..9c70d56 100755
--- a/opac/opac-showmarc.pl
+++ b/opac/opac-showmarc.pl
@@ -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;
--
1.6.0.6


More information about the Koha-patches mailing list