adding three new variables for installation:
[koha.git] / opac / unapi
1 #!/usr/bin/perl
2 use CGI;
3 use strict;
4 use warnings;
5 use C4::Context;
6 use XML::Simple;
7 use LWP::Simple;
8
9 use LWP::UserAgent;
10 use HTTP::Request::Common;
11
12 my $cgi = new CGI;
13 binmode(STDOUT, "utf8"); #output as utf8
14 my $baseurl = C4::Context->preference('OPACBaseURL');
15 warn "Warning: OPACBaseURL not set in system preferences" unless $baseurl;
16
17 my $id = $cgi->param('id');
18 my $format = $cgi->param('format');
19 if ($id && $format) {
20     # koha:isbn:0152018484
21     if ($id =~ /isbn/) {
22         $id =~ s/koha:isbn://;
23         my $url = "http://$baseurl:9998/biblios?version=1.1&operation=searchRetrieve&query=$id&startRecord=1&maximumRecords=20&recordSchema=$format";
24         my $content = get($url);
25         print $cgi->header( -type =>'application/xml' );
26         print $content;
27     }
28 }
29
30 else {
31
32 print $cgi->header( -type =>'application/xml' );
33
34 print "<?xml version='1.0' encoding='utf-8'  ?>
35 <formats>
36 <!-- <format name=\"opac\" type=\"text/html\"/> -->
37 <!-- <format name=\"html\" type=\"text/html\"/> -->
38 <!-- <format name=\"htmlholdings\" type=\"text/html\"/> -->
39 <!-- <format name=\"html-full\" type=\"text/html\"/> -->
40 <!-- <format name=\"htmlholdings-full\" type=\"text/html\"/> -->
41 <!-- <format name=\"atom\" type=\"application/xml\" namespace_uri=\"http://www.w3.org/2005/Atom\" docs=\"http://www.ietf.org/rfc/rfc4287.txt\"/> -->
42 <!-- <format name=\"atom-full\" type=\"application/xml\" namespace_uri=\"http://www.w3.org/2005/Atom\" docs=\"http://www.ietf.org/rfc/rfc4287.txt\"/> -->
43 <format name=\"marcxml\" type=\"application/xml\" namespace_uri=\"http://www.loc.gov/MARC21/slim\" docs=\"http://www.loc.gov/marcxml/\" schema_location=\"http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\"/>
44 <format name=\"marcxml-full\" type=\"application/xml\" namespace_uri=\"http://www.loc.gov/MARC21/slim\" docs=\"http://www.loc.gov/marcxml/\" schema_location=\"http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\"/>
45 <format name=\"mods\" type=\"application/xml\" namespace_uri=\"http://www.loc.gov/mods/\" docs=\"http://www.loc.gov/mods/\" schema_location=\"http://www.loc.gov/standards/mods/mods.xsd\"/>
46 <format name=\"mods-full\" type=\"application/xml\" namespace_uri=\"http://www.loc.gov/mods/\" docs=\"http://www.loc.gov/mods/\" schema_location=\"http://www.loc.gov/standards/mods/mods.xsd\"/>
47 <format name=\"mods3\" type=\"application/xml\" namespace_uri=\"http://www.loc.gov/mods/v3\" docs=\"http://www.loc.gov/mods/\" schema_location=\"http://www.loc.gov/standards/mods/v3/mods-3-1.xsd\"/>
48 <format name=\"mods3-full\" type=\"application/xml\" namespace_uri=\"http://www.loc.gov/mods/v3\" docs=\"http://www.loc.gov/mods/\" schema_location=\"http://www.loc.gov/standards/mods/v3/mods-3-1.xsd\"/>
49 <format name=\"oai_dc\" type=\"application/xml\" namespace_uri=\"http://www.openarchives.org/OAI/2.0/oai_dc/\" schema_location=\"http://www.openarchives.org/OAI/2.0/oai_dc.xsd\"/>
50 <format name=\"rdfdc\" type=\"application/xml\" namespace_uri=\"http://purl.org/dc/elements/1.1/\" schema_location=\"http://purl.org/dc/elements/1.1/\"/>
51 <format name=\"rss2\" type=\"application/xml\"/>
52 <format name=\"rss2-full\" type=\"application/xml\"/>
53 <format name=\"srw_dc\" type=\"application/xml\" namespace_uri=\"info:srw/schema/1/dc-schema\" schema_location=\"http://www.loc.gov/z3950/agency/zing/srw/dc-schema.xsd\"/>
54 </formats>
55 ";
56 }