From: Jonathan Druart Date: Fri, 2 Mar 2012 12:59:44 +0000 (+0100) Subject: Bug 7470: Babeltheque integration X-Git-Tag: v3.08.00~207 X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=commitdiff_plain;h=f35a1cce68f055b15afca2ab4006508d863dc08c;p=koha_gimpoz Bug 7470: Babeltheque integration 3 features: - adds social network information in search results - adds babeltheque data in opac-detail - adds social network links in opac-detail too (google+, twitter, mail and co.) --- diff --git a/C4/SocialData.pm b/C4/SocialData.pm new file mode 100644 index 0000000000..9e9711560d --- /dev/null +++ b/C4/SocialData.pm @@ -0,0 +1,129 @@ +package C4::SocialData; + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use Modern::Perl; + +use C4::Context; +use Business::ISBN; +use C4::Koha; + +=head2 get_data + +Get social data from a biblio + +params: + $isbn = isbn of the biblio (it must be the same in your database, isbn given to babelio) + +returns: + this function returns an hashref with keys + + isbn = isbn + num_critics = number of critics + num_critics_pro = number of profesionnal critics + num_quotations = number of quotations + num_videos = number of videos + score_avg = average score + num_scores = number of score +=cut +sub get_data { + my ( $isbn ) = @_; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare( qq{SELECT * FROM social_data WHERE isbn = ? LIMIT 1} ); + $sth->execute( $isbn ); + my $results = $sth->fetchrow_hashref; + + return $results; +} + +=head 2 + +Update Social data + +params: + $url = url containing csv file with data + +data separator : ; (semicolon) +data order : isbn ; active ; critics number , critics pro number ; quotations number ; videos number ; average score ; scores number + +=cut +sub update_data { + my ( $output_filepath ) = @_; + + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare( qq{INSERT INTO social_data ( + `isbn`, `num_critics`, `num_critics_pro`, `num_quotations`, `num_videos`, `score_avg`, `num_scores` + ) VALUES ( ?, ?, ?, ?, ?, ?, ? ) + ON DUPLICATE KEY UPDATE `num_critics`=?, `num_critics_pro`=?, `num_quotations`=?, `num_videos`=?, `score_avg`=?, `num_scores`=? + } ); + + open my $file, '<', $output_filepath or die "File $output_filepath can not be read"; + my $sep = qq{;}; + my $i = 0; + my $unknown = 0; + while ( my $line = <$file> ) { + my ( $isbn, $active, $num_critics, $num_critics_pro, $num_quotations, $num_videos, $score_avg, $num_scores ) = split $sep, $line; + next if not $active; + eval { + $sth->execute( $isbn, $num_critics, $num_critics_pro, $num_quotations, $num_videos, $score_avg, $num_scores, + $num_critics, $num_critics_pro, $num_quotations, $num_videos, $score_avg, $num_scores + ); + }; + if ( $@ ) { + warn "Can't insert $isbn ($@)"; + } else { + $i++; + } + } + say "$i data insered or updated"; +} + +=head 2 + +Get social data report + +=cut +sub get_report { + my $dbh = C4::Context->dbh; + + my $sth = $dbh->prepare( qq{ + SELECT biblionumber, isbn FROM biblioitems + } ); + $sth->execute; + my %results; + while ( my ( $biblionumber, $isbn ) = $sth->fetchrow() ) { + push @{ $results{no_isbn} }, { biblionumber => $biblionumber } and next if not $isbn; + my $original_isbn = $isbn; + $isbn =~ s/^\s*(\S*)\s*$/$1/; + $isbn = GetNormalizedISBN( $isbn, undef, undef ); + $isbn = Business::ISBN->new( $isbn ); + next if not $isbn; + eval{ + $isbn = $isbn->as_isbn13->as_string; + }; + next if $@; + $isbn =~ s/-//g; + my $social_datas = C4::SocialData::get_data( $isbn ); + if ( $social_datas ) { + push @{ $results{with} }, { biblionumber => $biblionumber, isbn => $isbn, original => $original_isbn }; + } else { + push @{ $results{without} }, { biblionumber => $biblionumber, isbn => $isbn, original => $original_isbn }; + } + } + return \%results; +} + +1; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index a3535766b4..26689c68fc 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2789,6 +2789,22 @@ CREATE TABLE `biblioimages` ( CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- Table structure for table `social_data` +-- + +DROP TABLE IF EXISTS `social_data`; +CREATE TABLE IF NOT EXISTS `social_data` ( + `isbn` VARCHAR(30), + `num_critics` INT, + `num_critics_pro` INT, + `num_quotations` INT, + `num_videos` INT, + `score_avg` DECIMAL(5,2), + `num_scores` INT, + PRIMARY KEY (`isbn`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 3e850b3706..b9f6bf1acb 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -355,3 +355,6 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OAI-PMH:AutoUpdateSets','0','Automatically update OAI sets when a bibliographic record is created or updated','','YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAllowPublicListCreation',1,'If set, allows opac users to create public lists',NULL,'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAllowSharingPrivateLists',0,'If set, allows opac users to share private lists with other patrons',NULL,'YesNo'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('Babeltheque_url_js','','Url for Babeltheque javascript (e.g. http://www.babeltheque.com/bw_XX.js)','','Free'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('Babeltheque_url_update', '', 'Url for Babeltheque update (E.G. http://www.babeltheque.com/.../file.csv.bz2)', '', 'Free'); +INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('SocialNetworks','1','Enable/Disable social networks links in opac detail pages','','YesNo'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 020cd0a7b7..e158f1adba 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5000,9 +5000,6 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion($DBversion); } - - - $DBversion = "3.07.00.034"; if (C4::Context->preference("Version") < TransformToNum($DBversion)) { $dbh->do("ALTER TABLE borrower_attribute_types ADD COLUMN category_code VARCHAR(10) NULL DEFAULT NULL AFTER `display_checkout`"); @@ -5063,6 +5060,32 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.07.00.039"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do( qq{INSERT IGNORE INTO `systempreferences` (variable,value,explanation,options,type) VALUES('Babeltheque_url_js','','Url for Babeltheque javascript (e.g. http://www.babeltheque.com/bw_XX.js','','Free')} ); + $dbh->do( qq{CREATE TABLE IF NOT EXISTS `social_data` + ( `isbn` VARCHAR(30), + `num_critics` INT, + `num_critics_pro` INT, + `num_quotations` INT, + `num_videos` INT, + `score_avg` DECIMAL(5,2), + `num_scores` INT, + PRIMARY KEY (`isbn`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 + } ); + $dbh->do( qq{INSERT IGNORE INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('Babeltheque_url_update', '', 'Url for Babeltheque update (E.G. http://www.babeltheque.com/.../file.csv.bz2)', '', 'Free')} ); + print "Upgrade to $DBversion done (added syspref and table for babeltheque (Babeltheque_url_js, babeltheque))\n"; + SetVersion($DBversion); +} + +$DBversion = "3.07.00.040"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do( qq{INSERT IGNORE INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SocialNetworks','1','Enable/Disable social networks links in opac detail','','YesNo')} ); + print "Upgrade to $DBversion done (added syspref Social_networks)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 DropAllForeignKeys($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref index f5828aeaf5..bb3bc2d89e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref @@ -103,6 +103,12 @@ Enhanced Content: yes: Do no: "Don't" - include information (such as reviews and citations) from Babelthèque in item detail pages on the OPAC. + - + - pref: Babeltheque_url_js + - Defined the url for the Babeltheque javascript file (eg. http://www.babeltheque.com/bw_XX.js) + - + - pref: Babeltheque_url_update + - Defined the url for the Babeltheque update periodically (eq. http://www.babeltheque.com/.../file.csv.bz2). Baker and Taylor: - - pref: BakerTaylorEnabled diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref index 3d7dd6454b..7b5993d6b7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -76,6 +76,13 @@ Searching: yes: Using no: "Not using" - 'ICU Zebra indexing. Please note: This setting will not affect Zebra indexing, it should only be used to tell Koha that you have activated ICU indexing if you have actually done so, since there is no way for Koha to figure this out on its own.' + - + - pref: SocialNetworks + default: 0 + choices: + yes: Enable + no: Disable + - Enable/Disable social network links in opac detail pages Search Form: - - Show tabs in OPAC and staff-side advanced search for limiting searches on the diff --git a/koha-tmpl/opac-tmpl/prog/en/css/opac.css b/koha-tmpl/opac-tmpl/prog/en/css/opac.css index 3011e58be7..c10e08d826 100644 --- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css +++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css @@ -2365,3 +2365,153 @@ span.sep { padding: 0 .2em; text-shadow: 1px 1px 0 #FFF; } + +/* ## BABELTHEQUE ## */ +/* Uncomment if babeltheque configuration no contains these lines */ +/* +#BW_etiquettes { + clear :left; + border: 1px solid #E8E8E8; + margin-top: 10px; + width: 49%; + float: left; + visibility: hidden; + visibility: visible\9; +} +#BW_etiquettes:not(:empty) { + visibility: visible; +} + +#BW_etiquettes h2 { + clear:left; + background-color: #E8E8E8; + margin: 5px 10px; + padding: 0 5px; +} + +#BW_ulEti {max-width:100%;} + +#BW_ulEti ul { + margin:0; + padding:0 15px; + list-style-type: none; +} + +#BW_ulEti a { + text-decoration: none; +} + +#BW_ulEti a.tag_s0 {font-weight: 120;font-size:0.8em;} +#BW_ulEti a.tag_s1 {font-weight: 150;font-size:0.9em;} +#BW_ulEti a.tag_s2 {font-weight: 180;font-size:1.0em;} +#BW_ulEti a.tag_s3 {font-weight: 200;font-size:1.2em;} +#BW_ulEti a.tag_s4 {font-weight: 220;font-size:1.4em;} +#BW_ulEti a.tag_s5 {font-weight: 230;font-size:1.5em;} +#BW_ulEti a.tag_s6 {font-weight: 320;font-size:1.6em;} +#BW_ulEti a.tag_s7 {font-weight: 350;font-size:1.7em;} +#BW_ulEti a.tag_s8 {font-weight: 400;font-size:1.8em;} +#BW_ulEti { padding: 0px; line-height: 2em; text-align: center;} +#BW_ulEti a { padding: 2px; } +#BW_ulEti { margin: 0px; } + +#BW_ulEti ol { + float:left; + display: inline; + margin: 0 10px; +} + +#BW_suggestions { + border: 1px solid #E8E8E8; + margin-top: 10px; + float: right; + width: 49%; + visibility: hidden; + visibility: visible\9; +} +#BW_suggestions:not(:empty) { + visibility: visible; +} +#BW_suggestions h2 { + background-color: #E8E8E8; + margin: 5px 10px; + padding: 0 5px; +} +#BW_suggestions .BW_livres_tag_page { + padding: 0 15px; +} +#BW_suggestions .BW_livres_tag_page:before { + content : '> '; +} +#BW_droite .BW_livres_tag:before { + content : '> '; +} + +#BW_videos { + clear : both; + border: 1px solid #E8E8E8; + padding-bottom: 140px; + margin-top: 10px; + max-width: 100%; + visibility: hidden; + visibility: visible\9; +} + +#BW_videos:not(:empty) { + visibility: visible; +} + +#BW_videos h2 { + background-color: #E8E8E8; + margin: 5px 10px; + padding: 0 5px; +} +#BW_videos .BW_bloc_vid { + clear: both; + padding: 0 15px; +} +.BW_vignette_vid { + border: 1px solid #DFD9CE; + float: left; + height: 141px; + margin: 5px; + min-height: 141px; + padding: 5px; + white-space: nowrap; +} + +#BW_notes {clear :left;} +#BW_notes h2 {font-size:85%;} + +#BW_citations {} +#BW_citations h2 {font-size:85%;} + +#BW_critiques {} +#BW_critiques h2 {font-size:85%;} + +#BW_critiques_pro {} +#BW_critiques_pro h2 {font-size:85%;} + +#BW_citations,#BW_critiques,#BW_critiques_pro { + background: -moz-linear-gradient(center top , #3399FF, #3333FF) repeat scroll 0 0 transparent; + background: -webkit-gradient(linear, center top, center bottom, from(#3399FF), to(#3333FF)); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#3399FF', endColorstr='#3333FF'); + border: 1px solid #B7B7B7; + border-radius: 5px 5px 5px 5px; + color: #FFFFCC; + display: inline-block; + float: left; + font-weight: bold; + margin: 15px 20px 15px 0; + min-width: 150px; + padding: 0 15px 8px; + position: relative; + text-align: center; + text-shadow: 1px 1px 1px #777777; + white-space: nowrap; +} + +#BW_citations a,#BW_critiques a,#BW_critiques_pro a { + color: #FFFFCC; +} + +*/ diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/prog/en/includes/opac-bottom.inc index 46e195dac6..66e26c13cf 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/opac-bottom.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/opac-bottom.inc @@ -55,9 +55,5 @@ [% END %] -[% IF ( Babeltheque ) %] - -[% END %] - diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt index 5c5b8859df..33ddae8269 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt @@ -2,6 +2,9 @@ [% INCLUDE 'doc-head-close.inc' %] + [% END %] + +[% IF ( Babeltheque ) %] + +[% END %] + [% INCLUDE 'opac-bottom.inc' %] diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt index c8a39261e8..eda2015077 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt @@ -392,6 +392,9 @@ $(document).ready(function(){ [% IF ( SEARCH_RESULT.imageurl ) %] [% SEARCH_RESULT.description %] [% END %] + [% IF ( SEARCH_RESULT.score_avg ) %] + + [% END %] [% END %] [% END %] @@ -480,6 +483,23 @@ $(document).ready(function(){ [% END %] + [% IF ( SEARCH_RESULT.score_avg ) %] + + [% SEARCH_RESULT.score_avg %] / 5 (on [% SEARCH_RESULT.num_scores %] rates) + [% IF ( SEARCH_RESULT.num_critics ) %] + + [% END %] + [% IF ( SEARCH_RESULT.num_critics_pro ) %] + + [% END %] + [% IF ( SEARCH_RESULT.num_videos ) %] + + [% END %] + [% IF ( SEARCH_RESULT.num_quotations ) %] + + [% END %] + + [% END %] [% IF ( LibraryThingForLibrariesID ) %]
[% END %] [% IF ( opacuserlogin ) %][% IF ( TagsEnabled ) %] [% IF ( TagsShowOnList ) %] diff --git a/koha-tmpl/opac-tmpl/prog/images/Star0.gif b/koha-tmpl/opac-tmpl/prog/images/Star0.gif new file mode 100644 index 0000000000..44ffdf4885 Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/Star0.gif differ diff --git a/koha-tmpl/opac-tmpl/prog/images/Star1.gif b/koha-tmpl/opac-tmpl/prog/images/Star1.gif new file mode 100644 index 0000000000..203863874d Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/Star1.gif differ diff --git a/koha-tmpl/opac-tmpl/prog/images/Star2.gif b/koha-tmpl/opac-tmpl/prog/images/Star2.gif new file mode 100644 index 0000000000..2b60940ffc Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/Star2.gif differ diff --git a/koha-tmpl/opac-tmpl/prog/images/Star3.gif b/koha-tmpl/opac-tmpl/prog/images/Star3.gif new file mode 100644 index 0000000000..3ff6739cd1 Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/Star3.gif differ diff --git a/koha-tmpl/opac-tmpl/prog/images/Star4.gif b/koha-tmpl/opac-tmpl/prog/images/Star4.gif new file mode 100644 index 0000000000..473cb32087 Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/Star4.gif differ diff --git a/koha-tmpl/opac-tmpl/prog/images/Star5.gif b/koha-tmpl/opac-tmpl/prog/images/Star5.gif new file mode 100644 index 0000000000..0a61173924 Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/Star5.gif differ diff --git a/koha-tmpl/opac-tmpl/prog/images/bonus.png b/koha-tmpl/opac-tmpl/prog/images/bonus.png new file mode 100644 index 0000000000..663a31d660 Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/bonus.png differ diff --git a/koha-tmpl/opac-tmpl/prog/images/socnet/delicious16.gif b/koha-tmpl/opac-tmpl/prog/images/socnet/delicious16.gif new file mode 100644 index 0000000000..11682e826f Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/socnet/delicious16.gif differ diff --git a/koha-tmpl/opac-tmpl/prog/images/socnet/facebook16.png b/koha-tmpl/opac-tmpl/prog/images/socnet/facebook16.png new file mode 100644 index 0000000000..1176590b3e Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/socnet/facebook16.png differ diff --git a/koha-tmpl/opac-tmpl/prog/images/socnet/linkedin16.png b/koha-tmpl/opac-tmpl/prog/images/socnet/linkedin16.png new file mode 100644 index 0000000000..2a195c2b76 Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/socnet/linkedin16.png differ diff --git a/koha-tmpl/opac-tmpl/prog/images/socnet/mailto16.png b/koha-tmpl/opac-tmpl/prog/images/socnet/mailto16.png new file mode 100644 index 0000000000..d8e4a5ad20 Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/socnet/mailto16.png differ diff --git a/koha-tmpl/opac-tmpl/prog/images/socnet/twitter16.png b/koha-tmpl/opac-tmpl/prog/images/socnet/twitter16.png new file mode 100644 index 0000000000..ccb1b61896 Binary files /dev/null and b/koha-tmpl/opac-tmpl/prog/images/socnet/twitter16.png differ diff --git a/misc/cronjobs/social_data/get_report_social_data.pl b/misc/cronjobs/social_data/get_report_social_data.pl new file mode 100644 index 0000000000..7069e24662 --- /dev/null +++ b/misc/cronjobs/social_data/get_report_social_data.pl @@ -0,0 +1,16 @@ +#!/bin/perl + +use Modern::Perl; +use C4::SocialData; + +my $results = C4::SocialData::get_report; + +say "==== Social Data report ===="; +say "Matched : (" . scalar( @{ $results->{with} } ) . ")"; +say "biblionumber = $_->{biblionumber},\toriginal = $_->{original},\tisbn = $_->{isbn}" for @{ $results->{with} }; + +say "No Match : (" . scalar( @{ $results->{without} } ) . ")"; +say "biblionumber = $_->{biblionumber},\toriginal = $_->{original},\tisbn = $_->{isbn}" for @{ $results->{without} }; + +say "Without ISBN : (" . scalar( @{ $results->{no_isbn} } ) . ")"; +say "biblionumber = $_->{biblionumber}" for @{ $results->{no_isbn} }; diff --git a/misc/cronjobs/social_data/update_social_data.pl b/misc/cronjobs/social_data/update_social_data.pl new file mode 100644 index 0000000000..53058a75b2 --- /dev/null +++ b/misc/cronjobs/social_data/update_social_data.pl @@ -0,0 +1,16 @@ +#!/usr/bin/perl + +use Modern::Perl; +use C4::Context; +use C4::SocialData; + +my $url = C4::Context->preference( "Babeltheque_url_update" ); +my $output_dir = qq{/tmp}; +my $output_filepath = qq{$output_dir/social_data.csv}; +system( qq{/bin/rm -f $output_filepath} ); +system( qq{/bin/rm -f $output_dir/social_data.csv.bz2} ); +system( qq{/usr/bin/wget $url -O $output_dir/social_data.csv.bz2 } ) == 0 or die "Can't get bz2 file from url $url ($?)"; +system( qq{/bin/bunzip2 $output_dir/social_data.csv.bz2 } ) == 0 or die "Can't extract bz2 file ($?)"; + + +C4::SocialData::update_data $output_filepath; diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index b45250dc37..aed7dd7428 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -837,9 +837,16 @@ $template->param(NovelistSelectView => C4::Context->preference('NovelistSelectVi if ( C4::Context->preference("Babeltheque") ) { $template->param( Babeltheque => 1, + Babeltheque_url_js => C4::Context->preference("Babeltheque_url_js"), ); } +# Social Networks +if ( C4::Context->preference( "SocialNetworks" ) ) { + $template->param( current_url => C4::Context->preference('OPACBaseURL') . "/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber" ); + $template->param( SocialNetworks => 1 ); +} + # Shelf Browser Stuff if (C4::Context->preference("OPACShelfBrowser")) { # pick the first itemnumber unless one was selected by the user diff --git a/opac/opac-search.pl b/opac/opac-search.pl index d846e55281..ea0cb98ca4 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -36,10 +36,11 @@ use C4::Biblio; # GetBiblioData use C4::Koha; use C4::Tags qw(get_tags); use C4::Branch; # GetBranches +use C4::SocialData; use POSIX qw(ceil floor strftime); use URI::Escape; use Storable qw(thaw freeze); - +use Business::ISBN; my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold"); @@ -533,9 +534,23 @@ for (my $i=0;$i<@servers;$i++) { foreach (@newresults) { my $record = GetMarcBiblio($_->{'biblionumber'}); $_->{coins} = GetCOinSBiblio($record); + if ( C4::Context->preference( "Babeltheque" ) and $_->{normalized_isbn} ) { + my $isbn = Business::ISBN->new( $_->{normalized_isbn} ); + next if not $isbn; + $isbn = $isbn->as_isbn13->as_string; + $isbn =~ s/-//g; + my $social_datas = C4::SocialData::get_data( $isbn ); + next if not $social_datas; + for my $key ( keys %$social_datas ) { + $_->{$key} = $$social_datas{$key}; + if ( $key eq 'score_avg' ){ + $_->{score_int} = sprintf("%.0f", $$social_datas{score_avg} ); + } + } + } } } - + if ($results_hashref->{$server}->{"hits"}){ $total = $total + $results_hashref->{$server}->{"hits"}; }