[Koha-patches] [PATCH 1/2] Fix Amazon cover for UNIMARC

2009-03-30 Thread Frédéric Demians
In UNIMARC, 010 tag contains ISBN. In UNIMARC, ISBN with '-'
are valid. This patch modify ISBN normalization in order to
automaticaly suppress '-' before sending ISBN to Amazon
to get book cover.
---
 C4/Koha.pm |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/C4/Koha.pm b/C4/Koha.pm
index 290ef40..9c37020 100644
--- a/C4/Koha.pm
+++ b/C4/Koha.pm
@@ -1249,6 +1249,7 @@ sub _normalize_match_point {
 
 sub _isbn_cleanup ($) {
 my $normalized_isbn = shift;
+$normalized_isbn =~ s/-//g;
 $normalized_isbn =~/([0-9]{1,})/;
 $normalized_isbn = $1;
 if (
-- 
1.5.6.5

___
Koha-patches mailing list
Koha-patches@lists.koha.org
http://lists.koha.org/mailman/listinfo/koha-patches


[Koha-patches] [PATCH 2/2] Internationalize Amazon support

2009-03-30 Thread Frédéric Demians
Without this patch:

  * On OPAC detail page, Amazon book cover has a banner
'Search Inside' which in untranslatable.
  * Link on book cover search inside book content in
Amazon.com--.com not .fr or .co.uk depending on
AmazonLocale syspref.

With this patch:

  * Modfiy book cover image in order not get anymore
'search inside' text.
  * Link the image to local Amazon web site.
---
 C4/External/Amazon.pm  |   30 ---
 .../opac-tmpl/prog/en/modules/opac-detail.tmpl |8 -
 opac/opac-detail.pl|3 ++
 3 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/C4/External/Amazon.pm b/C4/External/Amazon.pm
index 7d0c1b5..a0c922f 100644
--- a/C4/External/Amazon.pm
+++ b/C4/External/Amazon.pm
@@ -35,9 +35,27 @@ BEGIN {
 @EXPORT = qw(
 get_amazon_details
 check_search_inside
+get_amazon_tld
 );
 }
 
+
+sub get_amazon_tld {
+my %tld = (
+CA = '.ca',
+DE = '.de',
+FR = '.fr',
+JP = '.jp',
+UK = '.co.uk',
+US = '.com',
+);
+
+my $locale = C4::Context-preference('AmazonLocale');
+my $tld = $tld{ $locale } || '.com'; # default top level domain is .com
+return $tld;
+}
+
+
 =head1 NAME
 
 C4::External::Amazon - Functions for retrieving Amazon.com content in Koha
@@ -100,17 +118,7 @@ sub get_amazon_details {
 # Determine which content to grab in the request
 
 # Determine correct locale
-my $locale_hashref = {
-CA = '.ca',
-DE = '.de',
-FR = '.fr',
-JP = '.jp',
-UK = '.co.uk',
-US = '.com',
-};
-
-my $amazon_locale_syspref = C4::Context-preference('AmazonLocale');
-my $tld = $locale_hashref-{$amazon_locale_syspref} || '.com'; # default 
top level domain is .com
+my $tld = get_amazon_tld();
 
 # grab the AWSAccessKeyId: mine is '0V5JZ3HR2RQFNHR2'
 my $aws_access_key_id = C4::Context-preference('AWSAccessKeyID');
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl 
b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
index 7ca4739..7c6ae69 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
@@ -52,7 +52,13 @@
 div id=catalogue_detail_biblio
 
 div id=bookcover
-!-- TMPL_IF NAME=OPACAmazonEnabled --!-- TMPL_IF 
NAME=OPACAmazonCoverImages --!-- TMPL_IF NAME=OPACURLOpenInNewWindow 
--a href=http://www.amazon.com/gp/reader/!-- TMPL_VAR 
NAME=normalized_isbn --/ref=sib_dp_pt/002-7879865-0184864#reader-link 
target=_blankimg border=0 src=http://images.amazon.com/images/P/!-- 
TMPL_VAR NAME=normalized_isbn 
--.01._PIdp-schmooS,TopRight,7,-26_SCMZZZ_.jpg alt=Cover Image 
//a!-- TMPL_ELSE --a href=http://www.amazon.com/gp/reader/!-- TMPL_VAR 
NAME=normalized_isbn --/ref=sib_dp_pt/002-7879865-0184864#reader-linkimg 
border=0 src=http://images.amazon.com/images/P/!-- TMPL_VAR 
NAME=normalized_isbn --.01._PIdp-schmooS,TopRight,7,-26_SCMZZZ_.jpg 
alt=Cover Image //a!-- /TMPL_IF --!-- /TMPL_IF --!-- /TMPL_IF --
+!-- TMPL_IF NAME=OPACAmazonEnabled --
+!-- TMPL_IF NAME=OPACAmazonCoverImages --
+a href=http://www.amazon!-- TMPL_VAR NAME=AmazonTld --/gp/reader/!-- 
TMPL_VAR NAME=normalized_isbn 
--/ref=sib_dp_pt/002-7879865-0184864#reader-link
+!-- TMPL_IF NAME=OPACURLOpenInNewWindow --target=_blank!-- /TMPL_IF --
+img border=0 src=http://images.amazon.com/images/P/!-- TMPL_VAR 
NAME=normalized_isbn --.01.MZZZ.jpg alt=Cover Image /
+/a
+!-- /TMPL_IF --
 !-- TMPL_IF NAME=SyndeticsEnabled --!-- TMPL_IF 
NAME=SyndeticsCoverImages --!-- TMPL_IF NAME=content_identifier_exists 
--img src=http://www.syndetics.com/index.aspx?isbn=!-- TMPL_VAR 
NAME=normalized_isbn --/!-- TMPL_VAR NAME=SyndeticsCoverImageSize 
--.GIFamp;client=!-- TMPL_VAR NAME=SyndeticsClientCode 
--amp;type=xw10!-- TMPL_IF NAME=normalized_upc --amp;upc=!-- TMPL_VAR 
NAME=normalized_upc --!-- /TMPL_IF --!-- TMPL_IF NAME=normalized_oclc 
--amp;oclc=!-- TMPL_VAR NAME=normalized_oclc --!-- /TMPL_IF -- alt= 
class=thumbnail /!-- TMPL_ELSE --span class=no-imageNo cover image 
available/span!-- /TMPL_IF --!-- /TMPL_IF --!-- /TMPL_IF --
 !-- TMPL_IF NAME=GoogleJackets --div style=block title=!-- 
TMPL_VAR NAME=biblionumber ESCAPE=URL -- class=!-- TMPL_VAR 
NAME=normalized_isbn -- id=gbs-thumbnail/div!-- /TMPL_IF --
 !-- TMPL_IF NAME=BakerTaylorEnabled --!-- TMPL_IF 
NAME=normalized_isbn --!-- TMPL_IF NAME=OPACURLOpenInNewWindow --a 
href=https://!-- TMPL_VAR NAME=BakerTaylorBookstoreURL ESCAPE=HTML 
--!-- TMPL_VAR NAME=normalized_isbn -- target=_blankimg alt=See 
Baker amp; Taylor src=!-- TMPL_VAR NAME=BakerTaylorImageURL ESCAPE=HTML 
--!-- TMPL_VAR NAME=normalized_isbn -- //a!-- TMPL_ELSE --a 
href=https://!-- TMPL_VAR NAME=BakerTaylorBookstoreURL ESCAPE=HTML 
--!-- TMPL_VAR NAME=normalized_isbn --img alt=See Baker amp; Taylor 
src=!-- TMPL_VAR NAME=BakerTaylorImageURL 

[Koha-patches] [PATCH] Working on filters for output

2009-03-30 Thread Chris Cormack
From: Chris Cormack chr...@catalyst.net.nz

---
 C4/Output.pm |   21 +
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/C4/Output.pm b/C4/Output.pm
index fd32541..443383c 100644
--- a/C4/Output.pm
+++ b/C4/Output.pm
@@ -364,6 +364,15 @@ sub output_html_with_http_headers ($$$;$) {
 my $query = shift;
 my $cookie = shift;
 my $html = shift;
+
+# strip new lines or whitespace
+if (C4::Context-preference('FilterWhiteSpace') eq 'stripwhitespace'){
+   $html = remove_white_space($html);
+}
+elsif (C4::Context-preference('FilterWhiteSpace') eq 'stripnewlines'){
+   $html = remove_newline($html);
+}
+
 my $content_type = @_ ? shift : text/html;
 $content_type = text/html unless $content_type =~ m!/!; # very basic 
sanity check
 print $query-header(
@@ -391,6 +400,18 @@ sub is_ajax () {
return ($x_req and $x_req =~ /XMLHttpRequest/i) ? 1 : 0;
 }
 
+sub remove_white_space {
+$_[0] =~ s/^\s+$//mgo;
+return $_[0];
+}
+
+sub remove_newline {
+$_[0] =~ s/\s*\n\s*//go;
+return $_[0];
+}
+
+
+
 END { }# module clean-up code here (global destructor)
 
 1;
-- 
1.5.6.3

___
Koha-patches mailing list
Koha-patches@lists.koha.org
http://lists.koha.org/mailman/listinfo/koha-patches