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

(-)a/C4/Installer/PerlDependencies.pm (+15 lines)
Lines 737-742 our $PERL_DEPS = { Link Here
737
        'required' => '0',
737
        'required' => '0',
738
        'min_ver'  => '5.61',
738
        'min_ver'  => '5.61',
739
    },
739
    },
740
    'HTML::Entities' => {
741
        'usage'    => 'Core',
742
        'required' => '1',
743
        'min_ver'  => '3.69',
744
    },
745
    'HTML::Entities::Numbered' => {
746
        'usage'    => 'Core',
747
        'required' => '1',
748
        'min_ver'  => '0.04',
749
    },
750
    'RDF::Trine' => {
751
        'usage'    => 'Core',
752
        'required' => '1',
753
        'min_ver'  => '1.000',
754
    },
740
};
755
};
741
756
742
1;
757
1;
(-)a/C4/Record.pm (-22 / +87 lines)
Lines 25-31 use strict; Link Here
25
# please specify in which methods a given module is used
25
# please specify in which methods a given module is used
26
use MARC::Record; # marc2marcxml, marcxml2marc, changeEncoding
26
use MARC::Record; # marc2marcxml, marcxml2marc, changeEncoding
27
use MARC::File::XML; # marc2marcxml, marcxml2marc, changeEncoding
27
use MARC::File::XML; # marc2marcxml, marcxml2marc, changeEncoding
28
use MARC::Crosswalk::DublinCore; # marc2dcxml
28
use Koha::DublinCoreTransformer; # marc2dcxml
29
use Biblio::EndnoteStyle;
29
use Biblio::EndnoteStyle;
30
use Unicode::Normalize; # _entity_encode
30
use Unicode::Normalize; # _entity_encode
31
use C4::Biblio; #marc2bibtex
31
use C4::Biblio; #marc2bibtex
Lines 218-237 sub marcxml2marc { Link Here
218
218
219
=head2 marc2dcxml - Convert from ISO-2709 to Dublin Core
219
=head2 marc2dcxml - Convert from ISO-2709 to Dublin Core
220
220
221
  my ($error,$dcxml) = marc2dcxml($marc,$qualified);
221
  my ( $type, $marc, $qualified, $entities, $root, $xsi_schemaLocation, $rdf_subject,
222
        $rdf_format ) = @_;
222
223
223
Returns a DublinCore::Record object, will eventually return a Dublin Core scalar
224
Returns a DublinCore::Record object, will eventually return a Dublin Core scalar
224
225
225
FIXME: should return actual XML, not just an object
226
FIXME: should return actual XML, not just an object (Koha::DublinCoreTransformer return an XML)
227
228
C<$type> - the recommendation ( simple-dc-rdf, dc-rdf, dc-xml, oai-dc )
226
229
227
C<$marc> - an ISO-2709 scalar or MARC::Record object
230
C<$marc> - an ISO-2709 scalar or MARC::Record object
228
231
229
C<$qualified> - specify whether qualified Dublin Core should be used in the input or output [0]
232
C<$qualified> - specify whether simple or qualified Dublin Core should be used in output [0 or 1]
233
234
C<$entities> placing entities to 0 will codify only the five basic entities e.g., &lt, &gt, &quot, &amp, and &apos. Conversely if it is encoded to 1, all entities will coded into decimal
235
236
C<$root> root element for XML files
237
238
C<$xsi_schemaLocation> the xsischemaLocation for XML files.
239
240
C<$rdf_subject> Represent the main subject of RDF triples (for Koha the URI of the resource)
241
242
C<$rdf_format> Imply multiple formats for RDF (ntriples, nquads, rdfxml, rdfjson, ntriples-canonical, turtle)
230
243
231
=cut
244
=cut
232
245
233
sub marc2dcxml {
246
sub marc2dcxml {
234
	my ($marc,$qualified) = @_;
247
    my ( $type, $marc, $qualified, $entities, $root, $xsi_schemaLocation, $rdf_subject,
248
        $rdf_format ) = @_;
235
	my $error;
249
	my $error;
236
    # test if it's already a MARC::Record object, if not, make it one
250
    # test if it's already a MARC::Record object, if not, make it one
237
    my $marc_record_obj;
251
    my $marc_record_obj;
Lines 245-268 sub marc2dcxml { Link Here
245
			$error .="\nCreation of MARC::Record object failed: ".$MARC::File::ERROR;
259
			$error .="\nCreation of MARC::Record object failed: ".$MARC::File::ERROR;
246
		}
260
		}
247
	}
261
	}
248
	my $crosswalk = MARC::Crosswalk::DublinCore->new;
262
    my $dcxml;
249
	if ($qualified) {
263
250
		$crosswalk = MARC::Crosswalk::DublinCore->new( qualified => 1 );
264
    SWITCH:
251
	}
265
    for ($type) {
252
	my $dcxml = $crosswalk->as_dublincore($marc_record_obj);
266
        if (/^simple-dc-rdf/) {
253
	my $dcxmlfinal = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
267
            my $objectDC = Koha::DublinCoreTransformer->new({
254
	$dcxmlfinal .= "<metadata
268
                type            => 'rdf',
255
  xmlns=\"http://example.org/myapp/\"
269
                qualified       => 0,
256
  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
270
                get_marc_record => $marc,
257
  xsi:schemaLocation=\"http://example.org/myapp/ http://example.org/myapp/schema.xsd\"
271
            });
258
  xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
272
259
  xmlns:dcterms=\"http://purl.org/dc/terms/\">";
273
            $objectDC->get_rdf_data({
260
274
                rdf_subject => $rdf_subject,
261
	foreach my $element ( $dcxml->elements() ) {
275
                rdf_format  => $rdf_format,
262
                $dcxmlfinal.="<"."dc:".$element->name().">".$element->content()."</"."dc:".$element->name().">\n";
276
                entities    => 1,
277
            });
278
            $dcxml = $objectDC->write_rdf();
279
            last SWITCH;
280
        }
281
        if (/^dc-rdf/) {
282
            my $objectDC = Koha::DublinCoreTransformer->new({
283
                type            => 'rdf',
284
                qualified       => 1,
285
                get_marc_record => $marc,
286
            });
287
288
            $objectDC->get_rdf_data({
289
                rdf_subject => $rdf_subject,
290
                rdf_format  => $rdf_format,
291
                entities    => 1,
292
            });
293
            $dcxml = $objectDC->write_rdf();
294
            last SWITCH;
295
        }
296
        if (/^dc-xml/) {
297
            my $objectDC = Koha::DublinCoreTransformer->new({
298
                type            => 'xml',
299
                qualified       => $qualified,
300
                get_marc_record => $marc,
301
            });
302
303
            $objectDC->get_xml_data({
304
                root               => $root,
305
                xsi_schemaLocation => $xsi_schemaLocation,
306
                entities           => 1,
307
            });
308
            $dcxml = $objectDC->write_xml();
309
            last SWITCH;
310
        }
311
        if (/^oai-dc/) {
312
            my $objectDC = Koha::DublinCoreTransformer->new({
313
                type            => 'xml',
314
                qualified       => 0,
315
                get_marc_record => $marc,
316
            });
317
318
            $objectDC->get_xml_data({
319
                root               => 'oai_dc:dc',
320
                xsi_schemaLocation => 'http://www.openarchives.org/OAI/2.0/oai_dc/' .
321
                                      ' http://www.openarchives.org/OAI/2.0/oai_dc.xsd',
322
                entities           => 0,
323
                optional_namespace => 'oai_dc',
324
                namespace_url      => 'http://www.openarchives.org/OAI/2.0/oai_dc/',
325
            });
326
            $dcxml = $objectDC->write_xml();
327
            last SWITCH;
328
        }
263
    }
329
    }
264
	$dcxmlfinal .= "\n</metadata>";
330
    return ( $error, $dcxml );
265
	return ($error,$dcxmlfinal);
266
}
331
}
267
332
268
=head2 marc2modsxml - Convert from ISO-2709 to MODS
333
=head2 marc2modsxml - Convert from ISO-2709 to MODS
(-)a/Koha/DublinCoreTransformer.pm (+1017 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
package Koha::DublinCoreTransformer;
3
4
#
5
# This file is part of Koha.
6
#
7
# Copyright (C) 2014 Universidad de El Salvador,
8
# Facultad Multidisciplinaria Oriental
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
24
use Modern::Perl;
25
use strict;
26
use warnings::register;
27
use utf8;
28
use version;
29
use v5.10.1;
30
31
BEGIN {
32
    require Exporter;
33
34
    # set the version for version checking
35
    our $VERSION = version->declare("v0.01");
36
37
    # Inherit from Exporter to export functions and variables
38
    our @ISA = qw(Exporter);
39
40
    # Functions and variables which are exported by default
41
    our @EXPORT = qw(new get_xml_data get_rdf_data write_xml write_rdf);
42
43
    # Functions and variables which can be optionally exported
44
    our @EXPORT_OK =
45
      qw(type qualified get_marc_record root xsi_schemaLocation rdf_subject rdf_format entities optional_namespace namespace_url);
46
47
}
48
49
use MARC::File::USMARC;
50
use MARC::Crosswalk::DublinCore;
51
use XML::LibXML;
52
use HTML::Entities;
53
use HTML::Entities::Numbered;
54
use RDF::Trine;
55
use base qw(Class::Accessor);
56
__PACKAGE__->mk_accessors(
57
    qw(type qualified get_marc_record root xsi_schemaLocation rdf_subject rdf_format entities optional_namespace namespace_url)
58
);
59
60
# Defining some constants
61
my $xsi_schema  = qq(http://www.w3.org/2001/XMLSchema-instance);
62
my $unqualified = qq(http://purl.org/dc/elements/1.1/);
63
my $qualified   = qq(http://purl.org/dc/terms/);
64
my $dcam        = qq(http://purl.org/dc/dcam/);
65
my $rdfNS       = qq(http://www.w3.org/1999/02/22-rdf-syntax-ns#);
66
my @elementupcase =
67
  qw/tableOfContents dateAccepted dateCopyrighted dateSubmitted isVersionOf hasVersion isReplacedBy isRequiredBy isPartOf hasPart isReferencedBy isFormatOf hasFormat conformsTo accrualMethod accrualPeriodicity accrualPolicy instructionalMethod rightsHolder educationLevel accessRights bibliographicCitation/;
68
my $map;
69
70
#USAGE: Koha::DublinCoreTransformer->new({
71
#    type => 'xml|rdf',
72
#    qualified => 0|1,
73
#    get_marc_record => $record
74
#});
75
76
sub new {
77
    my ( $class, $args ) = @_;
78
    $args = {} unless defined $args;
79
    return bless( $args, $class );
80
}
81
82
sub get_xml_data {
83
84
#USAGE: oop->get_xml_data({
85
#        root => 'root',
86
#        xsi_schemaLocation => 'http://example.org/myapp/ http://example.org/myapp/schema.xsd',
87
#        entities => 0|1,
88
#        optional_namespace => 'oai_dc'
89
#        namespace_url => 'http://www.openarchives.org/OAI/2.0/oai_dc/'
90
#});
91
    my $self = shift;
92
    my ($args) = @_;
93
94
    if (@_) {
95
        $self->root( $args->{root} );
96
        $self->xsi_schemaLocation( $args->{xsi_schemaLocation} );
97
        $self->entities( $args->{entities} );
98
        $self->optional_namespace( $args->{optional_namespace} );
99
        $self->namespace_url( $args->{namespace_url} );
100
    }
101
102
    #if data not filled
103
    $self->{root}     = "metadata" unless ( defined $self->{root} );
104
    $self->{entities} = 0          unless ( defined $self->{entities} );
105
    my %dataxml = (
106
        xmlroot            => $self->{root},
107
        entities           => $self->{entities},
108
        optional_namespace => $self->{optional_namespace},
109
        namespace_url      => $self->{namespace_url},
110
    );
111
112
    if ( exists $self->{xsi_schemaLocation} ) {
113
        $dataxml{'xsi_schemaLocation'} = $self->{xsi_schemaLocation};
114
    }
115
    if ( exists $self->{xsi_schemaLocation} ) {
116
        $dataxml{'optional_namespace'} = $self->{optional_namespace};
117
    }
118
    if ( exists $self->{xsi_schemaLocation} ) {
119
        $dataxml{'namespace_url'} = $self->{namespace_url};
120
    }
121
    return \%dataxml;
122
}
123
124
sub get_rdf_data {
125
126
#USAGE: oop->get_rdf_data({
127
#        rdf_subject => 'http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=17589',
128
#        rdf_format => 'ntriples | nquads| rdfxml | rdfjson | ntriples-canonical | turtle',
129
#        entities => 0|1,
130
#})
131
132
    my $self = shift;
133
    my ($args) = @_;
134
135
    if (@_) {
136
        $self->rdf_subject( $args->{rdf_subject} );
137
        $self->rdf_format( $args->{rdf_format} );
138
        $self->entities( $args->{entities} );
139
    }
140
141
    #if data not filled
142
    $self->{rdf_subject} = "http://koha-community.org/"
143
      unless ( defined $self->{rdf_subject} );
144
    $self->{rdf_format} = "rdfxml" unless ( defined $self->{rdf_format} );
145
    $self->{entities}   = 0        unless ( defined $self->{entities} );
146
    my %rdfdescription = (
147
        rdf_subject => $self->{rdf_subject},
148
        rdf_format  => $self->{rdf_format},
149
        entities    => $self->{entities},
150
    );
151
152
    return \%rdfdescription;
153
}
154
155
sub conversion_to_dc {
156
157
#Get the MARC record and return a Dublin Core elements, passed as argument in dc_order_execution method.
158
#USAGE:
159
#my dc = $self->conversion_to_dc();
160
#$self->dc_order_execution ($dc, $dcxml, $root);
161
    my $self            = shift;
162
    my $marc_record_obj = $self->get_marc_record();
163
    my $crosswalk;
164
    my $dc;
165
166
    #if data not filled
167
    $self->qualified(0) unless ( exists $self->{qualified} );
168
    if ( ( $self->qualified() != 0 and $self->qualified() != 1 )
169
        && warnings::enabled($self) )
170
    {
171
        warnings::warn( $self, "Only the 0 or 1 values are accepted" );
172
        die "Set qualified => " . $self->qualified() . " is no good, stopped";
173
    }
174
    if ( $self->qualified() == 1 ) {
175
        $crosswalk = MARC::Crosswalk::DublinCore->new( qualified => 1 );
176
    }
177
    elsif ( $self->qualified() == 0 ) {
178
        $crosswalk = MARC::Crosswalk::DublinCore->new( qualified => 0 );
179
    }
180
    if ( $marc_record_obj =~ /^MARC::Record/ ) {
181
        $dc = $crosswalk->as_dublincore($marc_record_obj);
182
    }
183
    else {
184
        warnings::warn( $self,
185
            "MARC::Record object failed or not a MARC::Record" );
186
        die "Stopped due get_marc_record => is not a MARC::Record";
187
    }
188
189
    return $dc;
190
191
}
192
193
sub write_xml {
194
    my $self    = shift;
195
    my $dataxml = $self->get_xml_data();
196
    my $dc      = $self->conversion_to_dc();
197
198
    #Looking for bad data
199
    if ( ( $self->type() ne 'xml' and $self->type() ne 'rdf' )
200
        && warnings::enabled($self) )
201
    {
202
        warnings::warn( $self, "Only the xml or rdf values are accepted" );
203
        die "Set type => " . $self->type() . " is no good, stopped";
204
    }
205
    elsif ( $self->type() eq 'rdf' && warnings::enabled($self) ) {
206
        warnings::warn( $self, "The constructor specified rdf" );
207
        die "Cannot use this method with rdf. This is no good, stopped";
208
    }
209
210
    if ( ( $self->entities() != 0 and $self->entities() != 1 )
211
        && warnings::enabled($self) )
212
    {
213
        warnings::warn( $self, "Only the 0 or 1 values are accepted" );
214
        die "Set entities => " . $self->entities() . " is no good, stopped";
215
    }
216
217
    #Creating XML object
218
    my $doc = XML::LibXML::Document->new( '1.0', 'utf-8' );
219
    my $root = $doc->createElement( $dataxml->{'xmlroot'} );
220
    $root->setNamespace( $xsi_schema, 'xsi', 0 );
221
222
    if ( defined $dataxml->{'optional_namespace'} ) {
223
        $root->setNamespace( $dataxml->{'namespace_url'},
224
            $dataxml->{'optional_namespace'}, 0 );
225
    }
226
227
    if ( $self->type() eq 'xml' ) {
228
        if ( $self->qualified() == 0 ) {
229
            if ( defined $dataxml->{'xsi_schemaLocation'} ) {
230
                $root->setAttribute(
231
                    'xsi:schemaLocation' => $dataxml->{'xsi_schemaLocation'} );
232
                $root->setNamespace( $unqualified, 'dc', 0 );
233
                $self->dc_order_execution( $dc, $doc, $root );
234
            }
235
            else {
236
                $root->setNamespace( $unqualified, 'dc', 0 );
237
                $self->dc_order_execution( $dc, $doc, $root );
238
            }
239
        }
240
        elsif ( $self->qualified() == 1 ) {
241
            if ( defined $dataxml->{'xsi_schemaLocation'} ) {
242
                $root->setAttribute(
243
                    'xsi:schemaLocation' => $dataxml->{'xsi_schemaLocation'} );
244
                $root->setNamespace( $unqualified, 'dc',      0 );
245
                $root->setNamespace( $qualified,   'dcterms', 0 );
246
                $self->dc_order_execution( $dc, $doc, $root );
247
            }
248
            else {
249
                $root->setNamespace( $unqualified, 'dc',      0 );
250
                $root->setNamespace( $qualified,   'dcterms', 0 );
251
                $self->dc_order_execution( $dc, $doc, $root );
252
            }
253
        }
254
    }
255
256
    $doc->setDocumentElement($root);
257
258
    #Enabling or desabling entities and print the xml
259
    if ( $dataxml->{'entities'} == 1 ) {
260
        my $serialized_data = $doc->toString(1);
261
        my ($dcxml_entity_encoded) = XML_entity_encode($serialized_data);
262
        $serialized_data = $dcxml_entity_encoded;
263
        return $serialized_data;
264
    }
265
    else {
266
        return $doc->toString(1);
267
    }
268
}
269
270
sub write_rdf {
271
    my $self           = shift;
272
    my $rdfdescription = $self->get_rdf_data();
273
    my $dc             = $self->conversion_to_dc();
274
    my $serializer;
275
    my %namespaces;
276
277
    #Looking for bad data
278
    if ( ( $self->type() ne 'xml' and $self->type() ne 'rdf' )
279
        && warnings::enabled($self) )
280
    {
281
        warnings::warn( $self, "Only the xml or rdf values are accepted" );
282
        die "Set type => " . $self->type() . " is no good, stopped";
283
    }
284
    elsif ( $self->type() eq 'xml' && warnings::enabled($self) ) {
285
        warnings::warn( $self, "The constructor specified xml" );
286
        die "Cannot use this method with xml. This is no good, stopped";
287
    }
288
289
    if ( ( $self->entities() != 0 and $self->entities() != 1 )
290
        && warnings::enabled($self) )
291
    {
292
        warnings::warn( $self, "Only the 0 or 1 values are accepted" );
293
        die "Set entities => " . $self->entities() . " is no good, stopped";
294
    }
295
296
    # Creating the triple store in temporary data
297
    my $store = RDF::Trine::Store::Memory->new();
298
299
    # Creating the model
300
    my $rdf = RDF::Trine::Model->new($store);
301
302
    # Creating the subject
303
    my $subject =
304
      RDF::Trine::Node::Resource->new( $rdfdescription->{'rdf_subject'} );
305
306
    $namespaces{'rdf'} = $rdfNS;
307
308
    if ( $self->qualified() == 0 ) {
309
310
        # Declaring all namespaces in a hash
311
        $namespaces{'dc'} = $unqualified;
312
    }
313
    else {
314
315
        # Declaring all namespaces in a hash
316
        $namespaces{'dcterms'} = $qualified;
317
        $namespaces{'dcam'}    = $dcam;
318
    }
319
320
    # Creating namespaces
321
    $map = RDF::Trine::NamespaceMap->new( \%namespaces );
322
323
    if ( $self->type() eq 'rdf' ) {
324
        $self->dc_order_execution( $dc, $rdf, $subject );
325
    }
326
327
   #Enabling or desabling entities and print the xml, fixing encode with rdfjson
328
    if ( $rdfdescription->{'rdf_format'} eq 'rdfxml' ) {
329
        if ( $rdfdescription->{'entities'} == 1 ) {
330
            $serializer =
331
              RDF::Trine::Serializer::RDFXML->new(
332
                namespaces => {%namespaces} );
333
            my $serialized_data = $serializer->serialize_model_to_string($rdf);
334
            my ($dcxml_entity_encoded) = XML_entity_encode($serialized_data);
335
            return $serialized_data = $dcxml_entity_encoded;
336
        }
337
        else {
338
            $serializer =
339
              RDF::Trine::Serializer::RDFXML->new(
340
                namespaces => {%namespaces} );
341
            return $serializer->serialize_model_to_string($rdf);
342
        }
343
    }
344
    elsif ( $rdfdescription->{'rdf_format'} eq 'turtle' ) {
345
        $serializer =
346
          RDF::Trine::Serializer::Turtle->new( namespaces => {%namespaces} );
347
        return $serializer->serialize_model_to_string($rdf);
348
    }
349
    else {
350
        $serializer =
351
          RDF::Trine::Serializer->new( $rdfdescription->{'rdf_format'} );
352
        return $serializer->serialize_model_to_string($rdf);
353
    }
354
}
355
356
sub upper_or_lowercase {
357
358
#This subroutine define if is necessary to convert lowercase some qualifiers or let them as crosswalk method basis
359
#USAGE: upper_or_lowercase (element->qualifier())
360
    my $dcelement = $_[0];
361
    my $count     = 0;
362
    my $result;
363
    while ( $count <= $#elementupcase ) {
364
        if ( $elementupcase[$count] eq $dcelement ) {
365
            $result = $dcelement;
366
            last;
367
        }
368
        elsif ( $dcelement ne $elementupcase[$count] ) {
369
            $result = lc($dcelement);
370
            $count++;
371
            next;
372
        }
373
    }
374
375
    return $result;
376
377
}
378
379
sub XML_entity_encode {
380
381
#This subroutine change characteres to XML entities. Since XML::LibXML only encode the five basics
382
#USAGE: This subroutine is called when get_xml_data is populated with entities => 1
383
    my @strings = @_;
384
    my @strings_entity_encoded;
385
    foreach my $string (@strings) {
386
        utf8::decode($string);
387
        my $html_entities =
388
          HTML::Entities::encode_entities( $string, '^\n\t\x20-\x7e' );
389
        my $xml_entities =
390
          HTML::Entities::Numbered::name2hex_xml($html_entities);
391
        push @strings_entity_encoded, $xml_entities;
392
    }
393
    return @strings_entity_encoded;
394
}
395
396
sub xml_constructor {
397
398
#xml_constructor ( doc, root, namespace, attr, element_name, element_content, element_qualifier, element_scheme )
399
#USAGE: define all posible elements (name, content, qualifier, scheme) as neccesary
400
#doc: the XML object
401
#root: append root to doc
402
#namespace: defined as "dc" or "dcterms"
403
#attr: a boolean value to determinate xsi:type xml namespace for dcterms
404
#examples:
405
#xml_constructor ( $dcxml, $root, "dc", 0, element->name(), element->content() );
406
#xml_constructor ( $dcxml, $root, "dcterms", 1, element->name(), element->content(), $element->qualifier() );
407
408
    my ( $doc, $root, $namespace, $attr, $element_name, $element_content,
409
        $element_qualifier, $element_scheme )
410
      = @_;
411
412
    # This scalar is used for deleting spaces in scheme elements
413
    my $deletespaces;
414
415
    # This scalar is used for making upper or lowercase the qualifier elements
416
    my $lowercase;
417
    my $tagxml;
418
419
    given ($namespace) {
420
        when ( $namespace eq "dc" ) {
421
            $lowercase = lc($element_name);
422
        }
423
        when ( $namespace eq "dcterms" ) {
424
            $lowercase = upper_or_lowercase($element_qualifier);
425
426
            #replacing spacial to spatial, bug from dublin or crosswalk.
427
            $lowercase =~ s/spacial/spatial/;
428
        }
429
    }
430
431
    if ( ( $namespace eq "dc" or "dcterms" ) and $attr == 0 ) {
432
433
        # This will do something like: <dc:title>Title</dc:title>
434
        $tagxml = XML::LibXML::Element->new($lowercase);
435
        $tagxml->setNamespace( undef, $namespace, 1 );
436
        $tagxml->appendTextNode($element_content);
437
        $root->appendChild($tagxml);
438
    }
439
    elsif ( ( $namespace eq "dcterms" ) and $attr == 1 ) {
440
441
# This will do something like: <dcterms:spatial xsi:type="dcterms:ISO3166">us</dcterms:spatial>
442
        $deletespaces = $element_scheme;
443
        $deletespaces =~ s/\s//;
444
        $tagxml = XML::LibXML::Element->new($lowercase);
445
        $tagxml->setNamespace( undef, $namespace, 1 );
446
        my $attribute = $namespace . ':' . $deletespaces;
447
        $tagxml->setAttribute( 'xsi:type', $attribute );
448
        $tagxml->appendTextNode($element_content);
449
        $root->appendChild($tagxml);
450
    }
451
    elsif ( ( $namespace eq "dc" ) and $attr == 1 ) {
452
        given ($element_scheme) {
453
454
# This will do something like: <dc:subject xsi:type="dcterms:LCSH">Water supply.</dc:subject>
455
            when ( $element_scheme ne "DCMI Type Vocabulary" )
456
            {    #Dublin core returns DCMI Type Vocabulary
457
                $deletespaces = $element_scheme;
458
                $deletespaces =~ s/\s//;
459
                $tagxml = XML::LibXML::Element->new($lowercase);
460
                $tagxml->setNamespace( undef, $namespace, 1 );
461
                my $attribute = 'dcterms:' . $deletespaces;
462
                $tagxml->setAttribute( 'xsi:type', $attribute );
463
                $tagxml->appendTextNode($element_content);
464
                $root->appendChild($tagxml);
465
            }
466
            when ( $element_scheme eq "DCMI Type Vocabulary" )
467
            {    #Changing for DCMIType
468
                 # This will do something like: <dc:type xsi:type="dcterms:DCMIType">Text</dc:type>
469
                $tagxml = XML::LibXML::Element->new($lowercase);
470
                $tagxml->setNamespace( undef, $namespace, 1 );
471
                $tagxml->setAttribute( 'xsi:type', 'dcterms:DCMIType' );
472
                $tagxml->appendTextNode($element_content);
473
                $root->appendChild($tagxml);
474
            }
475
        }
476
    }    #if...elsif
477
478
    return $tagxml;
479
480
}    #subroutine
481
482
sub rdf_constructor {
483
484
#xml_constructor ( rdf, subject, namespace, attr, element_name, element_content, element_qualifier, element_scheme )
485
#USAGE: define all posible elements (name, content, qualifier, scheme) as neccesary
486
#rdf: the RDF object
487
#subject: the subject for the triples
488
#namespace: defined as "dc" or "dcterms". This is for Simple DC or DC-RDF recommendations.
489
#attr: a boolean value to determine the nodeID attribute for dcterms
490
491
    my ( $rdf, $subject, $namespace, $attr, $element_name, $element_content,
492
        $element_qualifier, $element_scheme )
493
      = @_;
494
495
    #This scalar is used for deleting spaces in scheme elements
496
    my $deletespaces;
497
498
    #This scalar is used for making upper or lowercase the qualifier elements
499
    my $lowercase;
500
501
    given ($namespace) {
502
        when ( $namespace eq "dc" ) {
503
            $lowercase = lc($element_name);
504
        }
505
        when ( $namespace eq "dcterms" ) {
506
            $lowercase = upper_or_lowercase($element_qualifier);
507
508
            #replacing spacial to spatial, bug from dublin or crosswalk.
509
            $lowercase =~ s/spacial/spatial/;
510
        }
511
    }
512
513
    if ( ( $namespace eq "dc" or "dcterms" ) and $attr == 0 ) {
514
515
        # This will do something like: <dc:title>Title</dc:title>
516
        my $predicate = undef;
517
        if ( $namespace eq "dc" ) {
518
            $predicate = $map->dc($lowercase);
519
        }
520
        else {
521
            $predicate = $map->dcterms($lowercase);
522
        }
523
        my $object = RDF::Trine::Node::Literal->new($element_content);
524
        my $statement =
525
          RDF::Trine::Statement->new( $subject, $predicate, $object );
526
        $rdf->add_statement($statement);
527
    }
528
    elsif ( ( $namespace eq "dc" ) and $attr == 2 ) {
529
530
        # This will do something like: <dcterms:title>Title</dcterms:title>
531
        my $predicate = $map->dcterms($lowercase);
532
        my $object    = RDF::Trine::Node::Literal->new($element_content);
533
        my $statement =
534
          RDF::Trine::Statement->new( $subject, $predicate, $object );
535
        $rdf->add_statement($statement);
536
    }
537
    elsif ( ( $namespace eq "dc" ) and $attr == 1 ) {
538
        $deletespaces = $element_scheme;
539
        $deletespaces =~ s/\s//;
540
      SWITCH:
541
        for ($element_scheme) {
542
            if (/^ISO 3166/) {
543
544
       #  Dublin core returns DCMI Type Vocabulary
545
       #  This will do something like:
546
       #    <rdf:Description rdf:nodeID="country">
547
       #        <dcam:memberOf rdf:resource="http://purl.org/dc/terms/ISO3166"/>
548
       #        <rdf:value>us</rdf:value>
549
       #    </rdf:Description>
550
       #    <dcterms:spatial rdf:nodeID="country"/>
551
                my $objectbnode = RDF::Trine::Node::Blank->new('country');
552
                my $predicate   = $map->dcterms($lowercase);
553
                my $object = RDF::Trine::Node::Literal->new($element_content);
554
                my $dcam_member_of  = $map->dcam('memberOf');
555
                my $resource_schema = $map->dcterms($deletespaces);
556
                my $rdf_value       = $map->rdf('value');
557
                my $statement1 =
558
                  RDF::Trine::Statement->new( $subject, $predicate,
559
                    $objectbnode );
560
                my $statement2 =
561
                  RDF::Trine::Statement->new( $objectbnode, $dcam_member_of,
562
                    $resource_schema );
563
                my $statement3 =
564
                  RDF::Trine::Statement->new( $objectbnode, $rdf_value,
565
                    $object );
566
                $rdf->add_statement($statement1);
567
                $rdf->add_statement($statement2);
568
                $rdf->add_statement($statement3);
569
                last SWITCH;
570
            }
571
            if (/^DCMI Type Vocabulary/) {    #Changing for DCMIType
572
                my $objectbnode = RDF::Trine::Node::Blank->new('DCMIType');
573
                my $predicate   = $map->dcterms($lowercase);
574
                my $object = RDF::Trine::Node::Literal->new($element_content);
575
                my $dcam_member_of  = $map->dcam('memberOf');
576
                my $resource_schema = $map->dcterms('DCMIType');
577
                my $rdf_value       = $map->rdf('value');
578
                my $statement1 =
579
                  RDF::Trine::Statement->new( $subject, $predicate,
580
                    $objectbnode );
581
                my $statement2 =
582
                  RDF::Trine::Statement->new( $objectbnode, $dcam_member_of,
583
                    $resource_schema );
584
                my $statement3 =
585
                  RDF::Trine::Statement->new( $objectbnode, $rdf_value,
586
                    $object );
587
                $rdf->add_statement($statement1);
588
                $rdf->add_statement($statement2);
589
                $rdf->add_statement($statement3);
590
                last SWITCH;
591
            }
592
            if (/^ISO 639-2/) {    #Changing bnodeId ISO639-2 for language
593
                my $objectbnode = RDF::Trine::Node::Blank->new('language');
594
                my $predicate   = $map->dcterms($lowercase);
595
                my $object = RDF::Trine::Node::Literal->new($element_content);
596
                my $dcam_member_of  = $map->dcam('memberOf');
597
                my $resource_schema = $map->dcterms($deletespaces);
598
                my $rdf_value       = $map->rdf('value');
599
                my $statement1 =
600
                  RDF::Trine::Statement->new( $subject, $predicate,
601
                    $objectbnode );
602
                my $statement2 =
603
                  RDF::Trine::Statement->new( $objectbnode, $dcam_member_of,
604
                    $resource_schema );
605
                my $statement3 =
606
                  RDF::Trine::Statement->new( $objectbnode, $rdf_value,
607
                    $object );
608
                $rdf->add_statement($statement1);
609
                $rdf->add_statement($statement2);
610
                $rdf->add_statement($statement3);
611
                last SWITCH;
612
            }
613
            if (/^RFC 1766/) {    #Changing bnodeId RFC1766 for languagetag
614
                my $objectbnode = RDF::Trine::Node::Blank->new('languagetag');
615
                my $predicate   = $map->dcterms($lowercase);
616
                my $object = RDF::Trine::Node::Literal->new($element_content);
617
                my $dcam_member_of  = $map->dcam('memberOf');
618
                my $resource_schema = $map->dcterms($deletespaces);
619
                my $rdf_value       = $map->rdf('value');
620
                my $statement1 =
621
                  RDF::Trine::Statement->new( $subject, $predicate,
622
                    $objectbnode );
623
                my $statement2 =
624
                  RDF::Trine::Statement->new( $objectbnode, $dcam_member_of,
625
                    $resource_schema );
626
                my $statement3 =
627
                  RDF::Trine::Statement->new( $objectbnode, $rdf_value,
628
                    $object );
629
                $rdf->add_statement($statement1);
630
                $rdf->add_statement($statement2);
631
                $rdf->add_statement($statement3);
632
                last SWITCH;
633
            }
634
            if ( /^LCSH/ || /^MeSH/ || /^LCC/ || /^DDC/ ||
635
                 /^UDC/ || /^IMT/ || /^URI/ || /^TGN/ )
636
            {    #Scheme sharing common elements
637
                my $objectbnode = RDF::Trine::Node::Blank->new($deletespaces);
638
                my $predicate   = $map->dcterms($lowercase);
639
                my $object = RDF::Trine::Node::Literal->new($element_content);
640
                my $dcam_member_of  = $map->dcam('memberOf');
641
                my $resource_schema = $map->dcterms($deletespaces);
642
                my $rdf_value       = $map->rdf('value');
643
                my $statement1 =
644
                  RDF::Trine::Statement->new( $subject, $predicate,
645
                    $objectbnode );
646
                my $statement2 =
647
                  RDF::Trine::Statement->new( $objectbnode, $dcam_member_of,
648
                    $resource_schema );
649
                my $statement3 =
650
                  RDF::Trine::Statement->new( $objectbnode, $rdf_value,
651
                    $object );
652
                $rdf->add_statement($statement1);
653
                $rdf->add_statement($statement2);
654
                $rdf->add_statement($statement3);
655
                last SWITCH;
656
            }
657
        }
658
    }    #if-elsif
659
    return $rdf;
660
}    #subroutine
661
662
sub dc_order_execution {
663
664
    #USAGE: USAGE: Get the parameters for xml or rdf and execute in order.
665
    my $self = shift;
666
667
    if ( $self->type() eq 'xml' ) {    #Order for xml
668
        my ( $dc, $dcxml, $root ) = @_;
669
        foreach my $element ( $dc->elements() ) {
670
          SWITCH: {
671
                if (    $element->name()
672
                    and not defined $element->scheme()
673
                    and not defined $element->qualifier() )
674
                {
675
                    $dcxml =
676
                      xml_constructor( $dcxml, $root, "dc", 0, $element->name(),
677
                        $element->content() );
678
                    last SWITCH;
679
                }
680
681
                if (    $element->name()
682
                    and not defined $element->scheme()
683
                    and not defined $element->qualifier() )
684
                {
685
                    $dcxml =
686
                      xml_constructor( $dcxml, $root, "dcterms", 0,
687
                        $element->name(), $element->content() );
688
                    last SWITCH;
689
                }
690
691
                if (    $element->name()
692
                    and $element->scheme()
693
                    and $element->qualifier() )
694
                {
695
                    $dcxml = xml_constructor(
696
                        $dcxml,                $root,
697
                        "dcterms",             1,
698
                        $element->name(),      $element->content(),
699
                        $element->qualifier(), $element->scheme()
700
                    );
701
                    last SWITCH;
702
                }
703
704
                if (    $element->name()
705
                    and $element->scheme()
706
                    and ( $element->scheme ne "DCMI Type Vocabulary" ) )
707
                {
708
                    $dcxml =
709
                      xml_constructor( $dcxml, $root, "dc", 1, $element->name(),
710
                        $element->content(), $element->qualifier(),
711
                        $element->scheme() );
712
                    last SWITCH;
713
                }
714
715
                if (    $element->name()
716
                    and $element->scheme()
717
                    and ( $element->scheme() eq "DCMI Type Vocabulary" ) )
718
                {
719
                    $dcxml =
720
                      xml_constructor( $dcxml, $root, "dc", 1, $element->name(),
721
                        $element->content(), $element->qualifier(),
722
                        $element->scheme() );
723
                    last SWITCH;
724
                }
725
726
                if ( $element->name() and $element->qualifier() ) {
727
                    $dcxml = xml_constructor(
728
                        $dcxml,                $root,
729
                        "dcterms",             0,
730
                        $element->name(),      $element->content(),
731
                        $element->qualifier(), $element->scheme()
732
                    );
733
                    last SWITCH;
734
                }    #if
735
            }    #SWITCH
736
        }    #foreach 1
737
    }
738
    elsif ( $self->type() eq 'rdf' ) {    #Order for rdf/xml
739
        my ( $dc, $rdf, $subject ) = @_;
740
        foreach my $element ( $dc->elements() ) {
741
          SWITCH: {
742
                if (    $element->name()
743
                    and not defined $element->scheme()
744
                    and not defined $element->qualifier() )
745
                {
746
                    rdf_constructor( $rdf, $subject, "dc", 0, $element->name(),
747
                        $element->content() )
748
                      unless $self->qualified() == 1;
749
                    rdf_constructor( $rdf, $subject, "dc", 2, $element->name(),
750
                        $element->content() )
751
                      unless $self->qualified() == 0;
752
                    last SWITCH;
753
                }
754
755
                if (    $element->name()
756
                    and $element->scheme()
757
                    and ( $element->scheme ne "DCMI Type Vocabulary" ) )
758
                {
759
                    rdf_constructor( $rdf, $subject, "dc", 1, $element->name(),
760
                        $element->content(), $element->qualifier(),
761
                        $element->scheme() );
762
                    last SWITCH;
763
                }
764
765
                if (    $element->name()
766
                    and $element->scheme()
767
                    and ( $element->scheme() eq "DCMI Type Vocabulary" ) )
768
                {
769
                    rdf_constructor( $rdf, $subject, "dc", 1, $element->name(),
770
                        $element->content(), $element->qualifier(),
771
                        $element->scheme() );
772
                    last SWITCH;
773
                }
774
775
                if ( $element->name() and $element->qualifier() ) {
776
                    rdf_constructor(
777
                        $rdf,                  $subject,
778
                        "dcterms",             0,
779
                        $element->name(),      $element->content(),
780
                        $element->qualifier(), $element->scheme()
781
                    );
782
                    last SWITCH;
783
                }    #if
784
            }    #SWITCH
785
        }    #foreach 2
786
    }
787
    return;
788
}
789
790
END {
791
792
    #When opened with MARC::File::USMARC, close marc record if not closed
793
    sub DESTROY {
794
        my $self = shift;
795
        if ( $self->{get_marc_record} =~ /^MARC:File::USMARC/ ) {
796
            $self->{get_marc_record}->close();
797
            undef $self->{get_marc_record};
798
        }
799
    }
800
}
801
1;
802
__END__
803
804
=pod
805
806
=encoding UTF-8
807
808
=head1 NAME
809
810
Koha::DublinCoreTransformer - transform the values of MARC::Crosswalk::DublinCore
811
into metadata in XML or RDF format.
812
813
=head1 SYNOPSIS
814
815
=head2 XML-DC
816
817
  use Koha::DublinCoreTransformer;
818
  use MARC::File::USMARC;
819
  my $batch = MARC::File::USMARC->in('in.mrc');
820
821
  ## the $record will be a MARC::Record object.
822
  my $record = $batch->next();
823
824
  #For Simple DC-XML
825
  my $objectDC = DublinCoreTransformer->new({
826
        type => 'xml',
827
        qualified => 0,
828
        get_marc_record => $record});
829
830
  #For Qualified DC-XML
831
  my $objectDC = DublinCoreTransformer->new({
832
        type => 'xml',
833
        qualified => 1,
834
        get_marc_record => $record});
835
836
  #After call constructor you need to pass the root element and
837
  #the schema in .xsd format. If you prefer or you don't know nothing
838
  #about it pass the method in blank, i.e., without arguments.
839
  #Also you can determine if you want to encode with xml entities or
840
  #just with the five basics entities.
841
  #Set entities to 0 for the five basics or 1 to encode with the
842
  #complete xml entities.
843
  $objectDC->get_xml_data({
844
        root => 'metadata',
845
        xsi_schemaLocation => 'http://example.org/myapp/ http://example.org/myapp/schema.xsd',
846
  });
847
  #This print your xml file in STDOUT
848
  my $XML-DC = $objectDC->write_xml();
849
  print $XML-DC;
850
851
  #Close the file according to MARC::File::USMARC
852
  $batch->close();
853
  undef $batch;
854
855
  #Or if you want to generate a file
856
  open (OUTPUT, '> dc2xml.xml') or die $!;
857
  print OUTPUT $XML-DC;
858
  close(OUTPUT);
859
860
=head2 DC-RDF
861
862
  use Koha::DublinCoreTransformer;
863
  use MARC::File::USMARC;
864
  my $marc = MARC::File::USMARC->in('in.mrc');
865
  my $record = $marc->next();
866
867
  #Simple DC-RDF is not used but not deprecated, DublinCoreTransformer
868
  #can generate it as follow:
869
  my $objectDC = DublinCoreTransformer->new({
870
        type => 'rdf',
871
        qualified => 0,
872
        get_marc_record => $record});
873
874
  #DC-RDF
875
  my $objectDC = DublinCoreTransformer->new({
876
        type => 'rdf',
877
        qualified => 1,
878
        get_marc_record => $record});
879
880
  #The get_rdf_data method for RDF does not need to use the root element
881
  #and the schema, but you need to declare the resource being described,
882
  #i.e., the record.
883
  #Note: For Koha is the IRI identifier of the record
884
  $objectDC->get_rdf_data({
885
        rdf_subject => 'http://opac.mydomain.edu/cgi-bin/koha/opac-detail.pl?biblionumber=17589',
886
  });
887
888
  my $XML-RDF = $objectDC->write_rdf();
889
  print $XML-RDF;
890
  #Close the file according to MARC::File::USMARC
891
  $batch->close();
892
  undef $marc;
893
894
=head1 DESCRIPTION
895
896
The Koha::DublinCoreTransformer defines the interface to transform
897
and manipulate MARC records into DC-XML or DC-RDF recommendation.
898
This package transform MARC records to XML or RDF/XML Dublin Core
899
and follows the recommendations listed below:
900
901
L<DC-XML-GUIDELINES [DCMI Recommendation]|http://dublincore.org/documents/dc-xml-guidelines/>
902
903
L<Expressing Simple Dublin Core in RDF-XML|http://dublincore.org/documents/dcmes-xml/>
904
This recommendation is superseded by DC-RDFrecommendation but not obsoleted at all.
905
906
L<DC-RDF [DCMI Recommendation]|http://dublincore.org/documents/dc-rdf/>
907
908
=head2 Methods
909
910
=over 12
911
912
=item C<new>
913
914
Return a new Koha::DublinCoreTransformer object.
915
This constructor sets the output type (RDF or XML), the level of the standard (Simple DC or Qualified DC) and the MARC record to be transformed to DC.
916
917
  my $objectDC = DublinCoreTransformer->new({
918
        type => 'rdf',
919
        qualified => 0,
920
        get_marc_record => $record});
921
922
=item C<get_xml_data>
923
924
This method is just for DC-XML: Fetch the xml root element and the schema in .xsd format.
925
926
  $objectDC->get_xml_data({
927
        root => 'metadata',
928
        xsi_schemaLocation => 'http://example.org/myapp/ http://example.org/myapp/schema.xsd',
929
        entities => 1,
930
  });
931
932
The entities argument is for extended xml entities, i.e., placing entities to zero will codify only the five basic entities e.g., &lt, &gt, &quot, &amp, and &apos. Conversely if it is encoded to one, all entities will coded into decimal.
933
934
Additionally, has been included the optional_namespace and namespace_url arguments to include another XML name space.
935
936
NOTE: This method is only for use of the DC-XML recommendation, i.e., type => 'xml'.
937
See C<new> method or the section SYNOPSIS.
938
939
=item C<get_rdf_data>
940
941
This method is only for DC-RDF: Fetch the IRI identifier of the resource being described. As well, you can pass the format you want to generate with the rdf, by default the DC-RDF specify RDF/XML but RDF can represent in other formats listed below:
942
943
. ntriples
944
945
. nquads
946
947
. rdfxml
948
949
. rdfjson
950
951
. ntriples-canonical
952
953
. turtle
954
955
    $objectDC->get_rdf_data({
956
        rdf_subject => 'http://opac.fmoues.edu.sv/cgi-bin/koha/opac-detail.pl?biblionumber=17589',
957
        rdf_format => 'rdfxml',
958
        entities => 0|1,
959
    });
960
961
NOTE: The entities is needed only for rdfxml value and is used like C<get_xml_data> method.
962
963
=item C<write_xml>
964
965
Return the xml object as string.
966
967
NOTE: This method is only for use of the DC-XML recommendation, i.e., type => 'xml'.
968
See C<new> and C<get_xml_data> methods or the section SYNOPSIS.
969
970
=item C<write_rdf>
971
972
Return the rdf object as string.
973
974
NOTE: This method is only for use of the DC-RDF recommendation, i.e., type => 'rdf'.
975
See C<new> and C<get_rdf_data> methods or the section SYNOPSIS.
976
977
=back
978
979
=head1 VERSION
980
981
version 0.01
982
983
=head1 RELATES MODULES
984
985
This package requires the following modules:
986
987
L<DublinCore::Record>
988
989
L<MARC::Record>
990
991
L<MARC::File::USMARC>
992
993
L<MARC::Crosswalk::DublinCore>
994
995
L<HTML::Entities>
996
997
L<HTML::Entities::Numbered>
998
999
L<XML::LibXML>
1000
1001
L<RDF::Trine>
1002
1003
=head2 SEE ALSO
1004
1005
Dublin Core Web Page L<http://dublincore.org>.
1006
1007
=head1 LICENSE
1008
1009
Copyright (c) 2014 Koha Community. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1010
1011
=head1 AUTHOR
1012
1013
Hector Eduardo Catro Avalos E<lt> hector.hecaxmmx at gmail dot com E<gt>
1014
and the Koha Development Team.
1015
1016
=cut
1017
(-)a/catalogue/export.pl (-2 / +28 lines)
Lines 26-31 my $format=$query->param("format"); Link Here
26
my $error = '';
26
my $error = '';
27
if ($op eq "export") {
27
if ($op eq "export") {
28
    my $biblionumber = $query->param("bib");
28
    my $biblionumber = $query->param("bib");
29
    my $recommendation = $query->param("recommendation");
30
    my $formats = $query->param("formats");
31
    my $qualifier = $query->param("qualifier");
32
    my $root_element = $query->param("root_element");
33
    my $xsischemalocation = $query->param("xsischemalocation");
34
    my $resource_url = $query->url(-base => 1) . '/cgi-bin/koha/catalogue/detail.pl?biblionumber=' . $biblionumber;
29
        if ($biblionumber){
35
        if ($biblionumber){
30
36
31
            my $marc = GetMarcBiblio($biblionumber, 1);
37
            my $marc = GetMarcBiblio($biblionumber, 1);
Lines 51-58 if ($op eq "export") { Link Here
51
                $format = "bibtex";
57
                $format = "bibtex";
52
            }
58
            }
53
            elsif ($format =~ /dc/) {
59
            elsif ($format =~ /dc/) {
54
                ($error,$marc) = marc2dcxml($marc,1);
60
                SWITCH:
55
                $format = "dublin-core.xml";
61
                    for ($recommendation) {
62
                        if (/^simple-dc-rdf/) {
63
                            ($error,$marc) = marc2dcxml($recommendation, $marc, 0,
64
                            1, undef, undef, $resource_url , $formats);
65
                            $format = "dublin-core." . $formats;
66
                            last SWITCH; }
67
                        if (/^dc-rdf/) {
68
                            ($error,$marc) = marc2dcxml($recommendation, $marc, 1,
69
                            1, undef, undef, $resource_url, $formats);
70
                            $format = "dublin-core." . $formats;
71
                            last SWITCH; }
72
                        if (/^dc-xml/) {
73
                            ($error,$marc) = marc2dcxml($recommendation, $marc, $qualifier,
74
                            1, $root_element, $xsischemalocation, undef, undef);
75
                            $format = "dublin-core.xml";
76
                            last SWITCH; }
77
                        if (/^oai-dc/) {
78
                            ($error,$marc) = marc2dcxml($recommendation, $marc);
79
                            $format = "dublin-core.xml";
80
                            last SWITCH; }
81
                    }
56
            }
82
            }
57
            elsif ($format =~ /marc8/) {
83
            elsif ($format =~ /marc8/) {
58
                $marc = changeEncoding($marc,"MARC","MARC21","MARC-8");
84
                $marc = changeEncoding($marc,"MARC","MARC21","MARC-8");
(-)a/debian/control (-2 / +12 lines)
Lines 46-60 Build-Depends: libalgorithm-checkdigits-perl, Link Here
46
 libdigest-sha-perl | perl,
46
 libdigest-sha-perl | perl,
47
 libemail-date-perl,
47
 libemail-date-perl,
48
 libemail-valid-perl,
48
 libemail-valid-perl,
49
 libfile-path-perl | perl-modules,
50
 libfile-slurp-perl,
49
 libfile-slurp-perl,
51
 libfont-ttf-perl,
50
 libfont-ttf-perl,
52
 libgd-barcode-perl,
51
 libgd-barcode-perl,
53
 libgd-gd2-noxpm-perl | libgd-gd2-perl,
52
 libgd-gd2-noxpm-perl | libgd-gd2-perl,
54
 libgraphics-magick-perl,
53
 libgraphics-magick-perl,
55
 libgravatar-url-perl,
54
 libgravatar-url-perl,
55
 libhtml-entities-numbered-perl,
56
 libhtml-format-perl,
56
 libhtml-format-perl,
57
 libhtml-parser-perl,
57
 libhtml-scrubber-perl,
58
 libhtml-scrubber-perl,
59
 libhttp-cookies-perl,
60
 libhttp-message-perl,
58
 libhttp-oai-perl,
61
 libhttp-oai-perl,
59
 libjson-perl,
62
 libjson-perl,
60
 liblibrary-callnumber-lc-perl,
63
 liblibrary-callnumber-lc-perl,
Lines 85-90 Build-Depends: libalgorithm-checkdigits-perl, Link Here
85
 libpdf-reuse-barcode-perl,
88
 libpdf-reuse-barcode-perl,
86
 libpdf-reuse-perl,
89
 libpdf-reuse-perl,
87
 libpdf-table-perl,
90
 libpdf-table-perl,
91
 librdf-trine-perl,
88
 libreadonly-perl,
92
 libreadonly-perl,
89
 libreadonly-xs-perl,
93
 libreadonly-xs-perl,
90
 libscalar-list-utils-perl,
94
 libscalar-list-utils-perl,
Lines 96-101 Build-Depends: libalgorithm-checkdigits-perl, Link Here
96
 libtemplate-plugin-htmltotext-perl,
100
 libtemplate-plugin-htmltotext-perl,
97
 libtemplate-plugin-json-escape-perl,
101
 libtemplate-plugin-json-escape-perl,
98
 libtest-deep-perl,
102
 libtest-deep-perl,
103
 libtest-harness-perl | perl-modules,
99
 libtest-mockmodule-perl,
104
 libtest-mockmodule-perl,
100
 libtest-mockobject-perl,
105
 libtest-mockobject-perl,
101
 libtest-simple-perl | perl-modules,
106
 libtest-simple-perl | perl-modules,
Lines 243-257 Depends: libalgorithm-checkdigits-perl, Link Here
243
 libdigest-sha-perl | perl,
248
 libdigest-sha-perl | perl,
244
 libemail-date-perl,
249
 libemail-date-perl,
245
 libemail-valid-perl,
250
 libemail-valid-perl,
246
 libfile-path-perl | perl-modules,
247
 libfile-slurp-perl,
251
 libfile-slurp-perl,
248
 libfont-ttf-perl,
252
 libfont-ttf-perl,
249
 libgd-barcode-perl,
253
 libgd-barcode-perl,
250
 libgd-gd2-noxpm-perl | libgd-gd2-perl,
254
 libgd-gd2-noxpm-perl | libgd-gd2-perl,
251
 libgraphics-magick-perl,
255
 libgraphics-magick-perl,
252
 libgravatar-url-perl,
256
 libgravatar-url-perl,
257
 libhtml-entities-numbered-perl,
253
 libhtml-format-perl,
258
 libhtml-format-perl,
259
 libhtml-parser-perl,
254
 libhtml-scrubber-perl,
260
 libhtml-scrubber-perl,
261
 libhttp-cookies-perl,
262
 libhttp-message-perl,
255
 libhttp-oai-perl,
263
 libhttp-oai-perl,
256
 libjson-perl,
264
 libjson-perl,
257
 liblibrary-callnumber-lc-perl,
265
 liblibrary-callnumber-lc-perl,
Lines 282-287 Depends: libalgorithm-checkdigits-perl, Link Here
282
 libpdf-reuse-barcode-perl,
290
 libpdf-reuse-barcode-perl,
283
 libpdf-reuse-perl,
291
 libpdf-reuse-perl,
284
 libpdf-table-perl,
292
 libpdf-table-perl,
293
 librdf-trine-perl,
285
 libreadonly-perl,
294
 libreadonly-perl,
286
 libreadonly-xs-perl,
295
 libreadonly-xs-perl,
287
 libscalar-list-utils-perl,
296
 libscalar-list-utils-perl,
Lines 293-298 Depends: libalgorithm-checkdigits-perl, Link Here
293
 libtemplate-plugin-htmltotext-perl,
302
 libtemplate-plugin-htmltotext-perl,
294
 libtemplate-plugin-json-escape-perl,
303
 libtemplate-plugin-json-escape-perl,
295
 libtest-deep-perl,
304
 libtest-deep-perl,
305
 libtest-harness-perl | perl-modules,
296
 libtest-mockmodule-perl,
306
 libtest-mockmodule-perl,
297
 libtest-mockobject-perl,
307
 libtest-mockobject-perl,
298
 libtest-simple-perl | perl-modules,
308
 libtest-simple-perl | perl-modules,
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc (-1 / +1 lines)
Lines 219-225 CAN_user_serials_create_subscription ) %] Link Here
219
    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-download-alt"></i> Save <span class="caret"></span></button>
219
    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-download-alt"></i> Save <span class="caret"></span></button>
220
    <ul class="dropdown-menu">
220
    <ul class="dropdown-menu">
221
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=bibtex&amp;op=export&amp;bib=[% biblionumber %]">BIBTEX</a></li>
221
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=bibtex&amp;op=export&amp;bib=[% biblionumber %]">BIBTEX</a></li>
222
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=dc&amp;op=export&amp;bib=[% biblionumber %]">Dublin Core (XML)</a></li>
222
        <li><a href="#" data-toggle="modal" data-target="#exportModal_">Dublin Core</a></li>
223
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marcxml&amp;op=export&amp;bib=[% biblionumber %]">MARCXML</a></li>
223
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marcxml&amp;op=export&amp;bib=[% biblionumber %]">MARCXML</a></li>
224
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marc8&amp;op=export&amp;bib=[% biblionumber %]">MARC (non-Unicode/MARC-8)</a></li>
224
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=marc8&amp;op=export&amp;bib=[% biblionumber %]">MARC (non-Unicode/MARC-8)</a></li>
225
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=utf8&amp;op=export&amp;bib=[% biblionumber %]">MARC (Unicode/UTF-8)</a></li>
225
        <li><a href="/cgi-bin/koha/catalogue/export.pl?format=utf8&amp;op=export&amp;bib=[% biblionumber %]">MARC (Unicode/UTF-8)</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +129 lines)
Lines 297-302 function verify_images() { Link Here
297
297
298
        [% END %]
298
        [% END %]
299
    });
299
    });
300
301
    //JQuery for Dublin Core Modal
302
    $(document).ready(function(){
303
        $("#input-simple").click(function(){
304
            $(".rdfoptions").removeAttr("disabled");
305
            $(".xmloptions").attr("disabled","disabled");
306
            $("#dc-rdf").toggle();
307
            $("#dc-xml").hide();
308
        });
309
    });
310
311
    $(document).ready(function(){
312
        $("#input-rdf").click(function(){
313
            $(".rdfoptions").removeAttr("disabled");
314
            $(".xmloptions").attr("disabled","disabled");
315
            $("#dc-rdf").toggle();
316
            $("#dc-xml").hide();
317
        });
318
    });
319
320
    $(document).ready(function(){
321
        $("#input-xml").click(function(){
322
            $(".xmloptions").removeAttr("disabled");
323
            $(".rdfoptions").attr("disabled","disabled");
324
                if($("#root_checked").is(':checked')){
325
                    $("#root_value").removeAttr("disabled");
326
                } else {
327
                    $("#root_value").attr("disabled","disabled");
328
                }
329
                if($("#schema_checked").is(':checked')){
330
                    $("#schema_value").removeAttr("disabled");
331
                } else {
332
                    $("#schema_value").attr("disabled","disabled");
333
                }
334
                $("#dc-xml").toggle();
335
                $("#dc-rdf").hide();
336
        });
337
    });
338
339
    $(document).ready(function(){
340
        $("#root_checked").click(function(){
341
            if($("#root_checked").is(':checked')){
342
                $("#root_value").removeAttr("disabled");
343
            } else {
344
                $("#root_value").attr("disabled","disabled");
345
            }
346
        });
347
    });
348
349
    $(document).ready(function(){
350
        $("#schema_checked").click(function(){
351
            if($("#schema_checked").is(':checked')){
352
                $("#schema_value").removeAttr("disabled");
353
            } else {
354
                $("#schema_value").attr("disabled","disabled");
355
            }
356
        });
357
    });
358
359
    $(document).ready(function(){
360
        $("#input-oai").click(function(){
361
            $(".rdfoptions").attr("disabled","disabled");
362
            $(".xmloptions").attr("disabled","disabled");
363
            $("#dc-rdf").hide();
364
            $("#dc-xml").hide();
365
        });
366
    });
367
300
//]]>
368
//]]>
301
</script>
369
</script>
302
</head>
370
</head>
Lines 1003-1009 function verify_images() { Link Here
1003
      <th>Save Record</th>   </tr>
1071
      <th>Save Record</th>   </tr>
1004
    <tr><td> Select download format:    <select name="format">
1072
    <tr><td> Select download format:    <select name="format">
1005
        <option value="mods">MODS (XML)</option>
1073
        <option value="mods">MODS (XML)</option>
1006
        <option value="dc">Dublin Core (XML)</option>
1074
        <option data-toggle="modal" data-target="#exportModal_">Dublin Core</option> <!-- trigger modal -->
1007
        <option value="marcxml">MARCXML</option>
1075
        <option value="marcxml">MARCXML</option>
1008
        <option value="marc8">MARC (non-Unicode/MARC-8)</option>
1076
        <option value="marc8">MARC (non-Unicode/MARC-8)</option>
1009
        <option value="utf8">MARC (Unicode/UTF-8)</option>    </select>
1077
        <option value="utf8">MARC (Unicode/UTF-8)</option>    </select>
Lines 1036-1039 function verify_images() { Link Here
1036
</div>
1104
</div>
1037
[% END %]
1105
[% END %]
1038
</div>
1106
</div>
1107
    <!-- Modal for Dublin Core-->
1108
    <div class="modal hide" id="exportModal_" tabindex="-1" role="dialog" aria-labelledby="exportLabelexportModal_" aria-hidden="true">
1109
        <div class="modal-header">
1110
            <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">&times;</button>
1111
            <h3 id="exportLabelexportModal_">Exporting to Dublin Core...</h3>
1112
        </div>
1113
        <!-- Form to recolect data for Dublin Core-->
1114
        <form method="get" action="/cgi-bin/koha/catalogue/export.pl">
1115
        <div class="modal-body">
1116
            <fieldset>
1117
                <input id="input-simple" type="radio" name="recommendation" value="simple-dc-rdf">Simple DC-RDF
1118
                <br>
1119
                <input id="input-rdf" type="radio" name="recommendation" value="dc-rdf" checked>DC-RDF (Recommended)
1120
                <div id="dc-rdf" style="display:none;">
1121
                    <br>DC-RDF is downloadable in &quot;rdfxml&quot; by default (this is according with the
1122
                    <br>recommendation),  but you can download the file in other formats:
1123
                    <br>
1124
                    <input class="rdfoptions" type="radio" name="formats" value="rdfxml" checked>rdfxml
1125
                    <input class="rdfoptions" type="radio" name="formats" value="rdfjson">rdfjson
1126
                    <input class="rdfoptions" type="radio" name="formats" value="ntriples">ntriples
1127
                    <input class="rdfoptions" type="radio" name="formats" value="nquads">nquads
1128
                    <input class="rdfoptions" type="radio" name="formats" value="ntriples-canonical">ntriples-canonical
1129
                    <input class="rdfoptions" type="radio" name="formats" value="turtle">turtle
1130
                </div>
1131
                <br>
1132
                <input id="input-xml" type="radio" name="recommendation" value="dc-xml">DC-XML
1133
                <div id="dc-xml" style="display:none;">
1134
                    <p><b>Output options for DC-XML</b>
1135
                    <br>
1136
                    <b>Dublin Core level</b></p>
1137
                    <p><input class="xmloptions" type="radio" name="qualifier" value="0" checked disabled>Simple Dublin Core
1138
                    <input class="xmloptions" type="radio" name="qualifier" value="1" disabled>Qualified Dublin Core</p>
1139
                    <b>Other data (Optional)</b>
1140
                    <br>
1141
                    <input id="root_checked" class="xmloptions" type="checkbox" value="root">
1142
                    Root element: <input id="root_value" class="xmloptions" type="text" name="root_element" value="metadata" disabled>
1143
                    <br>The xsischemaLocation should be filled like:
1144
                    <br>http://example.org/myapp/ http://example.org/myapp/schema.xsd
1145
                    <br>
1146
                    <input id="schema_checked" class="xmloptions" type="checkbox" value="schema" disabled>
1147
                    xsischemaLocation: <input id="schema_value" class="xmloptions" type="url" name="xsischemalocation" disabled><br>
1148
                </div>
1149
                <br>
1150
                <input id="input-oai" type="radio" name="recommendation" value="oai-dc">OAI-DC
1151
                <br>
1152
                <div>
1153
                <br>Learn more about DCMI Specifications at: <a href="http://dublincore.org/specifications/">http://dublincore.org/specifications/</a>
1154
                <br>
1155
                </div>
1156
            </fieldset>
1157
        </div>
1158
        <div class="modal-footer">
1159
            <button type="submit" class="btn">Export</button>
1160
            <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1161
        </div>
1162
        <input type="hidden" name="op" value="export" />
1163
        <input type="hidden" name="format" value="dc" />
1164
        <input type="hidden" name="bib" value="[% biblionumber %]" />
1165
        </form>
1166
    </div>
1039
[% INCLUDE 'intranet-bottom.inc' %]
1167
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc (+64 lines)
Lines 316-318 Link Here
316
            </div>
316
            </div>
317
        </form> <!-- /#auth -->
317
        </form> <!-- /#auth -->
318
    </div>  <!-- /#modalAuth  -->
318
    </div>  <!-- /#modalAuth  -->
319
320
    <!-- Dublin Core Exporter modal form -->
321
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
322
        <div class="modal-dialog">
323
            <div class="modal-content">
324
                <div class="modal-header">
325
                    <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">&times;</button>
326
                    <h4 class="modal-title" id="myModalLabel">Exporting to Dublin Core...</h4>
327
                </div>
328
                <form method="get" action="/cgi-bin/koha/opac-export.pl">
329
                    <div class="modal-body">
330
                        <fieldset>
331
                            <input id="input-simple" type="radio" name="recommendation" value="simple-dc-rdf">Simple DC-RDF
332
                            <br>
333
                            <input id="input-rdf" type="radio" name="recommendation" value="dc-rdf" checked>DC-RDF (Recommended)
334
                            <div id="dc-rdf" style="display:none;">
335
                                <br>DC-RDF is downloadable in &quot;rdfxml&quot; by default (this is according with the
336
                                <br>recommendation),  but you can download the file in other formats:
337
                                <br>
338
                                <input class="rdfoptions" type="radio" name="formats" value="rdfxml" checked>rdfxml
339
                                <input class="rdfoptions" type="radio" name="formats" value="rdfjson">rdfjson
340
                                <input class="rdfoptions" type="radio" name="formats" value="ntriples">ntriples
341
                                <input class="rdfoptions" type="radio" name="formats" value="nquads">nquads
342
                                <input class="rdfoptions" type="radio" name="formats" value="ntriples-canonical">ntriples-canonical
343
                                <input class="rdfoptions" type="radio" name="formats" value="turtle">turtle
344
                            </div>
345
                            <br>
346
                            <input id="input-xml" type="radio" name="recommendation" value="dc-xml">DC-XML
347
                            <div id="dc-xml" style="display:none;">
348
                                <p><b>Output options for DC-XML</b>
349
                                <br>
350
                                <b>Dublin Core level</b></p>
351
                                <p><input class="xmloptions" type="radio" name="qualifier" value="0" checked disabled>Simple Dublin Core
352
                                <input class="xmloptions" type="radio" name="qualifier" value="1" disabled>Qualified Dublin Core</p>
353
                                <b>Other data (Optional)</b>
354
                                <br>
355
                                <input id="root_checked" class="xmloptions" type="checkbox" value="root">
356
                                Root element: <input id="root_value" class="xmloptions" type="text" name="root_element" value="metadata" disabled>
357
                                <br>The xsischemaLocation should be filled like:
358
                                <br>http://example.org/myapp/ http://example.org/myapp/schema.xsd
359
                                <br>
360
                                <input id="schema_checked" class="xmloptions" type="checkbox" value="schema" disabled>
361
                                xsischemaLocation: <input id="schema_value" class="xmloptions" type="url" name="xsischemalocation" disabled><br>
362
                            </div>
363
                            <br>
364
                            <input id="input-oai" type="radio" name="recommendation" value="oai-dc">OAI-DC
365
                            <br>
366
                            <div>
367
                                <br>Learn more about DCMI Specifications at: <a href="http://dublincore.org/specifications/">http://dublincore.org/specifications/</a>
368
                                <br>
369
                            </div>
370
                        </fieldset>
371
                    </div>
372
                    <div class="modal-footer">
373
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
374
                        <button type="submit" class="btn btn-primary">Export</button>
375
                    </div>
376
                    <input type="hidden" name="op" value="export" />
377
                    <input type="hidden" name="format" value="dc" />
378
                    <input type="hidden" name="bib" value="[% biblionumber %]" />
379
                </form>
380
            </div>
381
        </div>
382
    </div><!-- End modal form -->
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc (-15 / +18 lines)
Lines 42-62 Link Here
42
                    <a id="format" class="dropdown-toggle" data-toggle="dropdown" href="#">Save record <b class="caret"></b></a>
42
                    <a id="format" class="dropdown-toggle" data-toggle="dropdown" href="#">Save record <b class="caret"></b></a>
43
                        <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="format">
43
                        <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="format">
44
                            [% FOREACH option IN export_options %]
44
                            [% FOREACH option IN export_options %]
45
                                <li>
45
                                [% IF option == 'dc' %]
46
                                    <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblionumber %]&amp;format=[% option %]">
46
                                    <li><a role="menuitem" href="#" data-toggle="modal" data-target="#myModal">Dublin Core</a></li>
47
                                        [% SWITCH option %]
47
                                [% ELSE %]
48
                                            [% CASE 'bibtex' %]BIBTEX
48
                                    <li>
49
                                            [% CASE 'dc' %]Dublin Core (XML)
49
                                        <a role="menuitem" href="/cgi-bin/koha/opac-export.pl?op=export&amp;bib=[% biblionumber %]&amp;format=[% option %]">
50
                                            [% CASE 'endnote' %]EndNote
50
                                            [% SWITCH option %]
51
                                            [% CASE 'marcxml' %]MARCXML
51
                                                [% CASE 'bibtex' %]BIBTEX
52
                                            [% CASE 'marc8' %]MARC (non-Unicode/MARC-8)
52
                                                [% CASE 'endnote' %]EndNote
53
                                            [% CASE 'utf8' %]MARC (Unicode/UTF-8)
53
                                                [% CASE 'marcxml' %]MARCXML
54
                                            [% CASE 'marcstd' %]MARC (Unicode/UTF-8, Standard)
54
                                                [% CASE 'marc8' %]MARC (non-Unicode/MARC-8)
55
                                            [% CASE 'mods' %]MODS (XML)
55
                                                [% CASE 'utf8' %]MARC (Unicode/UTF-8)
56
                                            [% CASE 'ris' %]RIS
56
                                                [% CASE 'marcstd' %]MARC (Unicode/UTF-8, Standard)
57
                                        [% END %]
57
                                                [% CASE 'mods' %]MODS (XML)
58
                                    </a>
58
                                                [% CASE 'ris' %]RIS
59
                                </li>
59
                                            [% END %]
60
                                        </a>
61
                                    </li>
62
                                [% END %]
60
                            [% END %]
63
                            [% END %]
61
                        </ul>
64
                        </ul>
62
                </div>
65
                </div>
(-)a/koha-tmpl/opac-tmpl/bootstrap/js/script.js (-1 / +68 lines)
Lines 63-66 $(document).ready(function(){ Link Here
63
            $("#members").removeAttr("style");
63
            $("#members").removeAttr("style");
64
        }
64
        }
65
    });
65
    });
66
});
66
});
67
68
    //JQuery for Dublin Core Modal
69
    $(document).ready(function(){
70
        $("#input-simple").click(function(){
71
            $(".rdfoptions").removeAttr("disabled");
72
            $(".xmloptions").attr("disabled","disabled");
73
            $("#dc-rdf").toggle();
74
            $("#dc-xml").hide();
75
        });
76
    });
77
78
    $(document).ready(function(){
79
        $("#input-rdf").click(function(){
80
            $(".rdfoptions").removeAttr("disabled");
81
            $(".xmloptions").attr("disabled","disabled");
82
            $("#dc-rdf").toggle();
83
            $("#dc-xml").hide();
84
        });
85
    });
86
87
    $(document).ready(function(){
88
        $("#input-xml").click(function(){
89
            $(".xmloptions").removeAttr("disabled");
90
            $(".rdfoptions").attr("disabled","disabled");
91
                if($("#root_checked").is(':checked')){
92
                    $("#root_value").removeAttr("disabled");
93
                } else {
94
                    $("#root_value").attr("disabled","disabled");
95
                }
96
                if($("#schema_checked").is(':checked')){
97
                    $("#schema_value").removeAttr("disabled");
98
                } else {
99
                    $("#schema_value").attr("disabled","disabled");
100
                }
101
                $("#dc-xml").toggle();
102
                $("#dc-rdf").hide();
103
        });
104
    });
105
106
    $(document).ready(function(){
107
        $("#root_checked").click(function(){
108
            if($("#root_checked").is(':checked')){
109
                $("#root_value").removeAttr("disabled");
110
            } else {
111
                $("#root_value").attr("disabled","disabled");
112
            }
113
        });
114
    });
115
116
    $(document).ready(function(){
117
        $("#schema_checked").click(function(){
118
            if($("#schema_checked").is(':checked')){
119
                $("#schema_value").removeAttr("disabled");
120
            } else {
121
                $("#schema_value").attr("disabled","disabled");
122
            }
123
        });
124
    });
125
126
    $(document).ready(function(){
127
        $("#input-oai").click(function(){
128
            $(".rdfoptions").attr("disabled","disabled");
129
            $(".xmloptions").attr("disabled","disabled");
130
            $("#dc-rdf").hide();
131
            $("#dc-xml").hide();
132
        });
133
    });
(-)a/opac/opac-export.pl (-3 / +28 lines)
Lines 34-39 my $format=$query->param("format")||'utf8'; Link Here
34
my $biblionumber = $query->param("bib")||0;
34
my $biblionumber = $query->param("bib")||0;
35
$biblionumber = int($biblionumber);
35
$biblionumber = int($biblionumber);
36
my ($marc, $error)= ('','');
36
my ($marc, $error)= ('','');
37
my $recommendation = $query->param("recommendation");
38
my $formats = $query->param("formats");
39
my $qualifier = $query->param("qualifier");
40
my $root_element = $query->param("root_element");
41
my $xsischemalocation = $query->param("xsischemalocation");
42
my $resource_url = $query->url(-base => 1) . '/cgi-bin/koha/opac-detail.pl?biblionumber=' . $biblionumber;
37
43
38
$marc = GetMarcBiblio($biblionumber, 1) if $biblionumber;
44
$marc = GetMarcBiblio($biblionumber, 1) if $biblionumber;
39
if(!$marc) {
45
if(!$marc) {
Lines 61-68 elsif ($format =~ /bibtex/) { Link Here
61
    $format = 'bibtex';
67
    $format = 'bibtex';
62
}
68
}
63
elsif ($format =~ /dc/) {
69
elsif ($format =~ /dc/) {
64
    ($error,$marc) = marc2dcxml($marc,1);
70
    SWITCH:
65
    $format = "dublin-core.xml";
71
        for ($recommendation) {
72
            if (/^simple-dc-rdf/) {
73
                ($error,$marc) = marc2dcxml($recommendation, $marc, 0,
74
                1, undef, undef, $resource_url , $formats);
75
                $format = "dublin-core." . $formats;
76
                last SWITCH; }
77
            if (/^dc-rdf/) {
78
                ($error,$marc) = marc2dcxml($recommendation, $marc, 1,
79
                1, undef, undef, $resource_url, $formats);
80
                $format = "dublin-core." . $formats;
81
                last SWITCH; }
82
            if (/^dc-xml/) {
83
                ($error,$marc) = marc2dcxml($recommendation, $marc, $qualifier,
84
                1, $root_element, $xsischemalocation, undef, undef);
85
                $format = "dublin-core.xml";
86
                last SWITCH; }
87
            if (/^oai-dc/) {
88
                ($error,$marc) = marc2dcxml($recommendation, $marc);
89
                $format = "dublin-core.xml";
90
                last SWITCH; }
91
        }
66
}
92
}
67
elsif ($format =~ /marc8/) {
93
elsif ($format =~ /marc8/) {
68
    ($error,$marc) = changeEncoding($marc,"MARC","MARC21","MARC-8");
94
    ($error,$marc) = changeEncoding($marc,"MARC","MARC21","MARC-8");
69
- 

Return to bug 13642