adding endnote export and 'related items'
Signed-off-by: Chris Cormack <crc@liblime.com> Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
parent
a9de732ebf
commit
866c3dd616
37
C4/Record.pm
37
C4/Record.pm
|
|
@ -25,6 +25,7 @@ use strict;# use warnings; #FIXME: turn off warnings before release
|
|||
use MARC::Record; # marc2marcxml, marcxml2marc, html2marc, changeEncoding
|
||||
use MARC::File::XML; # marc2marcxml, marcxml2marc, html2marcxml, changeEncoding
|
||||
use MARC::Crosswalk::DublinCore; # marc2dcxml
|
||||
use Biblio::EndnoteStyle;
|
||||
use Unicode::Normalize; # _entity_encode
|
||||
use XML::LibXSLT;
|
||||
use XML::LibXML;
|
||||
|
|
@ -39,6 +40,7 @@ $VERSION = 3.00;
|
|||
# only export API methods
|
||||
|
||||
@EXPORT = qw(
|
||||
&marc2endnote
|
||||
&marc2marc
|
||||
&marc2marcxml
|
||||
&marcxml2marc
|
||||
|
|
@ -286,6 +288,41 @@ sub marc2modsxml {
|
|||
my $newxmlrecord = $stylesheet->output_string($results);
|
||||
return ($newxmlrecord);
|
||||
}
|
||||
|
||||
sub marc2endnote {
|
||||
my ($marc) = @_;
|
||||
my $marc_rec_obj = MARC::Record->new_from_usmarc($marc);
|
||||
my $f260 = $marc_rec_obj->field('260');
|
||||
my $f260a = $f260->subfield('a') if $f260;
|
||||
my $f710 = $marc_rec_obj->field('710');
|
||||
my $f710a = $f710->subfield('a') if $f710;
|
||||
my $f500 = $marc_rec_obj->field('500');
|
||||
my $abstract = $f500->subfield('a') if $f500;
|
||||
my $fields = {
|
||||
DB => C4::Context->preference("LibraryName"),
|
||||
Title => $marc_rec_obj->title(),
|
||||
Author => $marc_rec_obj->author(),
|
||||
Publisher => $f710a,
|
||||
City => $f260a,
|
||||
Year => $marc_rec_obj->publication_date,
|
||||
Abstract => $abstract,
|
||||
};
|
||||
my $endnote;
|
||||
my $style = new Biblio::EndnoteStyle();
|
||||
my $template;
|
||||
$template.= "DB - DB\n" if C4::Context->preference("LibraryName");
|
||||
$template.="T1 - Title\n" if $marc_rec_obj->title();
|
||||
$template.="A1 - Author\n" if $marc_rec_obj->author();
|
||||
$template.="PB - Publisher\n" if $f710a;
|
||||
$template.="CY - City\n" if $f260a;
|
||||
$template.="Y1 - Year\n" if $marc_rec_obj->publication_date;
|
||||
$template.="AB - Abstract\n" if $abstract;
|
||||
my ($text, $errmsg) = $style->format($template, $fields);
|
||||
return ($text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
=head2 html2marcxml
|
||||
|
||||
=over 4
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ This module provides facilities for retrieving XISBN, ThingISBN and XISBN conten
|
|||
);
|
||||
|
||||
sub get_biblio_from_xisbn {
|
||||
my $xisbn_data = shift;
|
||||
my $xisbn = shift;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = "SELECT biblionumber FROM biblioitems WHERE isbn=?";
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($xisbn_data->{content});
|
||||
$sth->execute($xisbn);
|
||||
my $xbib_data = $sth->fetchrow_hashref();
|
||||
my $xbiblio;
|
||||
if ($xbib_data->{biblionumber}) {
|
||||
|
|
@ -101,7 +101,7 @@ sub get_xisbns {
|
|||
for my $response_data( @{ $response->{ isbn } } ) {
|
||||
next if $unique_xisbns->{ $response_data->{content} };
|
||||
$unique_xisbns->{ $response_data->{content} }++;
|
||||
my $xbiblio= get_biblio_from_xisbn($response_data);
|
||||
my $xbiblio= get_biblio_from_xisbn($response_data->{content});
|
||||
push @xisbns, $xbiblio if $xbiblio; #response_data->{xbiblio}; #->{biblionumber}; # if $xbiblionumber;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ use C4::Serials; #uses getsubscriptionfrom biblionumber
|
|||
use C4::Output;
|
||||
use C4::Biblio;
|
||||
use C4::Serials;
|
||||
use C4::XISBN qw(get_xisbns);
|
||||
use C4::XISBN qw(get_xisbns get_biblio_from_xisbn);
|
||||
use C4::Amazon;
|
||||
|
||||
my $query = new CGI;
|
||||
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
||||
|
|
@ -103,10 +104,11 @@ $template->param(
|
|||
);
|
||||
|
||||
# XISBN Stuff
|
||||
my $xisbn=$dat->{'isbn'};
|
||||
$xisbn =~ s/(p|-| |:)//g;
|
||||
$template->param(amazonisbn => $xisbn);
|
||||
if (C4::Context->preference("FRBRizeEditions")==1) {
|
||||
eval {
|
||||
my $xisbn=$dat->{'isbn'};
|
||||
$xisbn =~ s/(p|-|:| )//g;
|
||||
$template->param(
|
||||
xisbn => $xisbn,
|
||||
XISBNS => get_xisbns($xisbn)
|
||||
|
|
@ -114,5 +116,49 @@ if (C4::Context->preference("FRBRizeEditions")==1) {
|
|||
};
|
||||
if ($@) { warn "XISBN Failed $@"; }
|
||||
}
|
||||
if ( C4::Context->preference("AmazonContent") == 1 ) {
|
||||
my $amazon_details = &get_amazon_details( $xisbn );
|
||||
foreach my $result ( @{ $amazon_details->{Details} } ) {
|
||||
$template->param( item_description => $result->{ProductDescription} );
|
||||
$template->param( image => $result->{ImageUrlMedium} );
|
||||
$template->param( list_price => $result->{ListPrice} );
|
||||
$template->param( amazon_url => $result->{url} );
|
||||
}
|
||||
|
||||
my @products;
|
||||
my @reviews;
|
||||
for my $details ( @{ $amazon_details->{Details} } ) {
|
||||
next unless $details->{SimilarProducts};
|
||||
for my $product ( @{ $details->{SimilarProducts}->{Product} } ) {
|
||||
if (C4::Context->preference("AmazonSimilarItems") ) {
|
||||
my $xbiblios;
|
||||
my @xisbns;
|
||||
|
||||
if (C4::Context->preference("XISBNAmazonSimilarItems") ) {
|
||||
my $xbiblio = get_biblio_from_xisbn($product);
|
||||
push @xisbns, $xbiblio;
|
||||
$xbiblios = \@xisbns;
|
||||
}
|
||||
else {
|
||||
$xbiblios = get_xisbns($product);
|
||||
}
|
||||
push @products, +{ product => $xbiblios };
|
||||
}
|
||||
}
|
||||
next unless $details->{Reviews};
|
||||
for my $product ( @{ $details->{Reviews}->{AvgCustomerRating} } ) {
|
||||
$template->param( rating => $product * 20 );
|
||||
}
|
||||
for my $reviews ( @{ $details->{Reviews}->{CustomerReview} } ) {
|
||||
push @reviews,
|
||||
+{
|
||||
summary => $reviews->{Summary},
|
||||
comment => $reviews->{Comment},
|
||||
};
|
||||
}
|
||||
}
|
||||
$template->param( SIMILAR_PRODUCTS => \@products );
|
||||
$template->param( AMAZONREVIEWS => \@reviews );
|
||||
}
|
||||
|
||||
output_html_with_http_headers $query, $cookie, $template->output;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,11 @@ if ($op eq "export") {
|
|||
while (my ($marc) = $sth->fetchrow) {
|
||||
if ($marc){
|
||||
|
||||
if ($format =~ /marcxml/) {
|
||||
if ($format =~ /endnote/) {
|
||||
$marc = marc2endnote($marc);
|
||||
$format = 'endnote';
|
||||
}
|
||||
elsif ($format =~ /marcxml/) {
|
||||
$marc = marc2marcxml($marc);
|
||||
}
|
||||
elsif ($format=~ /mods/) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('acquisitions','normal','Choose Normal, budget-based acquisitions, or Simple bibliographic-data acquisitions','simple|normal','Choice');
|
||||
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('advancedMARCeditor','0','If ON, the MARC editor won\'t display field/subfield descriptions','','YesNo');
|
||||
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AmazonContent','0','Turn ON Amazon Content - You MUST set AmazonDevKey and AmazonAssocTag if enabled','','YesNo');
|
||||
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AmazonSimilarItems','0','Turn ON Amazon Similar Items feature - You MUST set AmazonDevKey and AmazonAssocTag if enabled','','YesNo');
|
||||
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AmazonDevKey','','See: aws-portal.amazon.com/gp/aws/developer/registration/index.html','','free');
|
||||
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AmazonAssocTag','','See: associates.amazon.com/gp/flex/associates/apply-login.html','','free');
|
||||
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('AnonSuggestions','0','Set to anonymous borrowernumber to enable Anonymous suggestions',NULL,'free');
|
||||
|
|
|
|||
|
|
@ -68,12 +68,12 @@
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- TMPL_IF NAME="AmazonContent" -->
|
||||
<div class="yui-u">
|
||||
<a href="http://www.amazon.com/gp/reader/<!-- TMPL_VAR NAME="isbn" -->/ref=sib_dp_pt/002-7879865-0184864#reader-link"><img border="0" src="http://images.amazon.com/images/P/<!-- TMPL_VAR NAME="isbn" -->.01._PIdp-schmooS,TopRight,7,-26_SCMZZZZZZZ_.jpg" alt="Book Cover Image" /></a>
|
||||
</div>
|
||||
<!-- /TMPL_IF -->
|
||||
|
||||
<!-- TMPL_IF NAME="AmazonContent" -->
|
||||
<a href="http://www.amazon.com/gp/reader/<!-- TMPL_VAR NAME="amazonisbn" -->/ref=sib_dp_pt/002-7879865-0184864#reader-link"><img border="0" src="http://images.amazon.com/images/P/<!-- TMPL_VAR NAME="amazonisbn" -->.01._PIdp-schmooS,TopRight,7,-26_SCMZZZZZZZ_.jpg" alt="Book Cover Image" /></a>
|
||||
<!-- TMPL_ELSE -->
|
||||
<img src="http://g-images.amazon.com/images/G/01/x-site/icons/no-img-sm.gif" alt="" border="0"/>
|
||||
<!-- /TMPL_IF --></div>
|
||||
<div class="yui-u">
|
||||
<ul>
|
||||
<!-- TMPL_IF name="isbn" -->
|
||||
|
|
@ -197,11 +197,12 @@
|
|||
<!-- /TMPL_IF -->
|
||||
|
||||
<!-- TMPL_IF NAME="XISBNS" -->
|
||||
<p>Editions</p>
|
||||
<h2>Editions</h2>
|
||||
<ul>
|
||||
<!-- TMPL_LOOP NAME="XISBNS" -->
|
||||
<li><img src="/opac-tmpl/prog/itemtypeimg/<!-- TMPL_VAR NAME="itemtype" -->.gif" title="<!-- TMPL_VAR NAME="itemtype" -->" />
|
||||
<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="title" --></a> by <!-- TMPL_VAR NAME="author" --> ©<!-- TMPL_VAR NAME="copyrightdate" --></li>
|
||||
<img src="http://images.amazon.com/images/P/<!-- TMPL_VAR NAME="isbn" -->.01._THUMBZZZ_PU_PU-5_.jpg" />
|
||||
|
||||
<!-- TMPL_LOOP NAME=items -->
|
||||
<!-- TMPL_IF NAME="itype" --><img src="/opac-tmpl/prog/itemtypeimg/<!-- TMPL_VAR NAME="itype" -->.gif" title="<!-- TMPL_VAR NAME="itype" -->" /><!-- /TMPL_IF -->
|
||||
|
|
@ -212,12 +213,64 @@
|
|||
</ul>
|
||||
<!-- /TMPL_IF -->
|
||||
|
||||
<!-- TMPL_IF NAME="AmazonContent" -->
|
||||
<!-- Amazon Reviews -->
|
||||
<div id="itemReviews">
|
||||
<h2>Amazon Reader Reviews:</h2>
|
||||
<h4>
|
||||
<!-- TMPL_IF NAME="amazonisbn" -->
|
||||
<a href="http://www.amazon.com/gp/customer-reviews/write-a-review.html/002-2970817-7876066?%5Fencoding=UTF8&asin=<!-- TMPL_VAR NAME="amazonisbn" -->&store=books">Add your own review</a></h4>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="rating" -->
|
||||
<h4>Rating (from Amazon.com):</h4>
|
||||
<div id="starMT"><div id="starFull" style="width:<!-- TMPL_VAR NAME="rating" -->px"></div></div>
|
||||
<!-- TMPL_LOOP NAME="AMAZONREVIEWS" -->
|
||||
<div class="content_set">
|
||||
<!-- TMPL_IF NAME="summary" -->
|
||||
<h4 class="underline"> <!-- TMPL_VAR NAME="summary" --></h4>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_IF NAME="comment" -->
|
||||
<p><!-- TMPL_VAR NAME="comment" --></p>
|
||||
<!-- /TMPL_IF -->
|
||||
</div>
|
||||
<!-- /TMPL_LOOP -->
|
||||
<!-- TMPL_ELSE -->
|
||||
|
||||
<div class="content_set">
|
||||
<p class="error"> Sorry, there are no reviews available for this title. </p>
|
||||
</div>
|
||||
|
||||
<!-- /TMPL_IF -->
|
||||
</div> <!-- itemReviews -->
|
||||
<!-- /TMPL_IF-->
|
||||
|
||||
<!-- TMPL_IF NAME="SIMILAR_PRODUCTS" -->
|
||||
<h2>Similar Items</h2>
|
||||
|
||||
<!-- TMPL_LOOP NAME="SIMILAR_PRODUCTS" -->
|
||||
<!-- TMPL_LOOP NAME="product" -->
|
||||
|
||||
<li><img src="/opac-tmpl/prog/itemtypeimg/<!-- TMPL_VAR NAME="itemtype" -->.gif" title="<!-- TMPL_VAR NAME="itemtype" -->" />
|
||||
<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="title" --></a> by <!-- TMPL_VAR NAME="author" --> ©<!-- TMPL_VAR NAME="copyrightdate" --></li>
|
||||
<img src="http://images.amazon.com/images/P/<!-- TMPL_VAR NAME="isbn" -->.01._THUMBZZZ_PU_PU-5_.jpg" />
|
||||
<!-- TMPL_LOOP NAME=items -->
|
||||
<!-- TMPL_IF NAME="itype" --><img src="/opac-tmpl/prog/itemtypeimg/<!-- TMPL_VAR NAME="itype" -->.gif" title="<!-- TMPL_VAR NAME="itype" -->" /><!-- /TMPL_IF -->
|
||||
barcode:<!-- TMPL_VAR NAME="barcode" -->
|
||||
<!-- /TMPL_LOOP -->
|
||||
|
||||
<!-- /TMPL_LOOP -->
|
||||
<!-- /TMPL_LOOP -->
|
||||
<!-- /TMPL_IF -->
|
||||
|
||||
<div class="export">
|
||||
<form method="get" action="/cgi-bin/koha/catalogue/export.pl">
|
||||
<TABLE BORDER=1 BGCOLOR="#FFFFDD" style="width:300px; margin-right: auto; margin-left:auto;"> <TR>
|
||||
<TH>Save Record</TH> </TR>
|
||||
<TR> <TD> Select Download Format: <SELECT NAME=format> <OPTION VALUE=mods>MODS (XML)</OPTION>
|
||||
<OPTION VALUE=dc>Dublin Core (XML)</OPTION> <OPTION VALUE=marcxml>MARCXML</OPTION>
|
||||
<TR> <TD> Select Download Format: <SELECT NAME=format>
|
||||
<OPTION VALUE=endnote>Endnote</OPTION>
|
||||
<OPTION VALUE=mods>MODS (XML)</OPTION>
|
||||
<OPTION VALUE=dc>Dublin Core (XML)</OPTION>
|
||||
<OPTION VALUE=marcxml>MARCXML</OPTION>
|
||||
<OPTION VALUE=marc8>MARC (non-Unicode/MARC-8)</OPTION>
|
||||
<OPTION VALUE=utf8>MARC (Unicode/UTF-8)</OPTION> </SELECT>
|
||||
<INPUT TYPE="SUBMIT" NAME="SAVE" VALUE="Download Record"></TD>
|
||||
|
|
@ -249,7 +302,7 @@
|
|||
<tr>
|
||||
<td><!--TMPL_VAR Name="serialseq"--></td>
|
||||
<td><!--TMPL_VAR Name="planneddate"--></td>
|
||||
<td><!--TMPL_IF Name="status1"-->Waited
|
||||
<td><!--TMPL_IF Name="status1"-->Awaited
|
||||
<!--TMPL_ELSE -->
|
||||
<!-- TMPL_IF Name="status2"-->Arrived
|
||||
<!--TMPL_ELSE -->
|
||||
|
|
|
|||
Loading…
Reference in New Issue