View | Details | Raw Unified | Return to bug 28247
Collapse All | Expand All

(-)a/authorities/showmarc.pl (+77 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Koha library project  www.koha-community.org
4
5
# Copyright 2007 Liblime
6
# Parts copyright 2010 BibLibre
7
#
8
# This file is part of Koha.
9
#
10
# Koha is free software; you can redistribute it and/or modify it
11
# under the terms of the GNU General Public License as published by
12
# the Free Software Foundation; either version 3 of the License, or
13
# (at your option) any later version.
14
#
15
# Koha is distributed in the hope that it will be useful, but
16
# WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
# GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License
21
# along with Koha; if not, see <http://www.gnu.org/licenses>.
22
23
use Modern::Perl;
24
25
# standard or CPAN modules used
26
use CGI qw(:standard -utf8);
27
use DBI;
28
use Encode;
29
30
# Koha modules used
31
use C4::Context;
32
use C4::Output;
33
use C4::Auth;
34
use C4::AuthoritiesMarc;
35
use C4::XSLT ();
36
37
my $input= CGI->new;
38
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
39
  {
40
    template_name   => "authorities/showmarc.tt",
41
    query           => $input,
42
    type            => "intranet",
43
    flagsrequired   => { authorities => 1  },
44
    debug           => 1,
45
  }
46
);
47
48
my $authid = $input->param('id');
49
my $view = $input->param('viewas')||'';
50
51
my $record = GetAuthority($authid);
52
53
if(!ref $record) {
54
    print $input->redirect("/cgi-bin/koha/errors/404.pl");
55
    exit;
56
}
57
58
if($view eq 'card' || $view eq 'html') {
59
    my $xml = GetAuthorityXML($authid);
60
    my $xsl;
61
    if ( $view eq 'card' ){
62
        $xsl = C4::Context->preference('marcflavour') eq 'UNIMARC'
63
              ? 'UNIMARC_compact.xsl' : 'compact.xsl';
64
    }
65
    else {
66
        $xsl = 'plainMARC.xsl';
67
    }
68
    my $htdocs = C4::Context->config('intrahtdocs');
69
    my ($theme, $lang) = C4::Templates::themelanguage($htdocs, $xsl, 'intranet', $input);
70
    $xsl = "$htdocs/$theme/$lang/xslt/$xsl";
71
    print $input->header(-charset => 'UTF-8'),
72
        Encode::encode_utf8(C4::XSLT::engine->transform($xml, $xsl));
73
}
74
else {
75
    $template->param( MARC_FORMATTED => $record->as_formatted );
76
    output_html_with_http_headers $input, $cookie, $template->output;
77
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt (+31 lines)
Lines 45-50 Link Here
45
  <table>
45
  <table>
46
      <tr>
46
      <tr>
47
        <th>Summary</th>
47
        <th>Summary</th>
48
        <th>MARC preview</th>
48
        <th>Heading type</th>
49
        <th>Heading type</th>
49
        [% UNLESS ( isEDITORS ) %]
50
        [% UNLESS ( isEDITORS ) %]
50
          <th>Used in</th>
51
          <th>Used in</th>
Lines 57-62 Link Here
57
    <tr data-authid="[% resul.authid | html %]">
58
    <tr data-authid="[% resul.authid | html %]">
58
      <td>[% PROCESS authresult summary=resul.summary authid=resul.authid %]</td>
59
      <td>[% PROCESS authresult summary=resul.summary authid=resul.authid %]</td>
59
      <td>[% resul.authtype | html %]</td>
60
      <td>[% resul.authtype | html %]</td>
61
      <td><a class="previewMARC btn btn-default btn-xs" href="showmarc.pl?id=[% resul.authid | uri %]&viewas=html"  title="MARC">Show</a></td>
60
    [% UNLESS ( resul.isEDITORS ) %]
62
    [% UNLESS ( resul.isEDITORS ) %]
61
      <td>
63
      <td>
62
      [% IF resul.used > 0 %]
64
      [% IF resul.used > 0 %]
Lines 94-101 Link Here
94
</div>
96
</div>
95
</div>
97
</div>
96
98
99
<div id="marcPreview" class="modal" tabindex="-1" role="dialog" aria-labelledby="marcPreviewLabel" aria-hidden="true">
100
    <div class="modal-dialog modal-lg">
101
        <div class="modal-content">
102
            <div class="modal-header">
103
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
104
                <h3 id="marcPreviewLabel">MARC preview</h3>
105
            </div>
106
            <div class="modal-body">
107
                <div id="loading"> <img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" alt="" /> Loading </div>
108
            </div>
109
            <div class="modal-footer">
110
                <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
111
            </div>
112
        </div>
113
    </div>
114
</div>
115
97
[% MACRO jsinclude BLOCK %]
116
[% MACRO jsinclude BLOCK %]
98
    [% INCLUDE 'authorities_js.inc' %]
117
    [% INCLUDE 'authorities_js.inc' %]
99
[% END %]
118
[% END %]
100
119
101
[% INCLUDE 'intranet-bottom.inc' %]
120
[% INCLUDE 'intranet-bottom.inc' %]
121
122
<script>
123
  $("body").on("click",".previewMARC", function(e){
124
      e.preventDefault();
125
      var page = $(this).attr("href");
126
      $("#marcPreview .modal-body").load(page + " table");
127
      $('#marcPreview').modal({show:true});
128
  });
129
  $("#marcPreview").on("hidden.bs.modal", function(){
130
      $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
131
  });
132
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/showmarc.tt (-1 / +10 lines)
Line 0 Link Here
0
- 
1
        [% INCLUDE 'doc-head-open.inc' %]
2
        <title>Koha &rsaquo; Authorities &rsaquo; MARC preview</title>
3
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4
    </head>
5
    <body id="authorities_showmarc" class="authority">
6
        <div id="main" style="direction: ltr;">
7
            <pre>[% MARC_FORMATTED | html %]</pre>
8
        </div>
9
    </body>
10
</html>

Return to bug 28247