Bug 7470: Babeltheque integration
authorJonathan Druart <jonathan.druart@biblibre.com>
Fri, 2 Mar 2012 12:59:44 +0000 (13:59 +0100)
committerPaul Poulain <paul.poulain@biblibre.com>
Mon, 26 Mar 2012 12:24:04 +0000 (14:24 +0200)
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.)

26 files changed:
C4/SocialData.pm [new file with mode: 0644]
installer/data/mysql/kohastructure.sql
installer/data/mysql/sysprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref
koha-tmpl/opac-tmpl/prog/en/css/opac.css
koha-tmpl/opac-tmpl/prog/en/includes/opac-bottom.inc
koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt
koha-tmpl/opac-tmpl/prog/images/Star0.gif [new file with mode: 0644]
koha-tmpl/opac-tmpl/prog/images/Star1.gif [new file with mode: 0644]
koha-tmpl/opac-tmpl/prog/images/Star2.gif [new file with mode: 0644]
koha-tmpl/opac-tmpl/prog/images/Star3.gif [new file with mode: 0644]
koha-tmpl/opac-tmpl/prog/images/Star4.gif [new file with mode: 0644]
koha-tmpl/opac-tmpl/prog/images/Star5.gif [new file with mode: 0644]
koha-tmpl/opac-tmpl/prog/images/bonus.png [new file with mode: 0644]
koha-tmpl/opac-tmpl/prog/images/socnet/delicious16.gif [new file with mode: 0644]
koha-tmpl/opac-tmpl/prog/images/socnet/facebook16.png [new file with mode: 0644]
koha-tmpl/opac-tmpl/prog/images/socnet/linkedin16.png [new file with mode: 0644]
koha-tmpl/opac-tmpl/prog/images/socnet/mailto16.png [new file with mode: 0644]
koha-tmpl/opac-tmpl/prog/images/socnet/twitter16.png [new file with mode: 0644]
misc/cronjobs/social_data/get_report_social_data.pl [new file with mode: 0644]
misc/cronjobs/social_data/update_social_data.pl [new file with mode: 0644]
opac/opac-detail.pl
opac/opac-search.pl

diff --git a/C4/SocialData.pm b/C4/SocialData.pm
new file mode 100644 (file)
index 0000000..9e97115
--- /dev/null
@@ -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;
index a353576..26689c6 100644 (file)
@@ -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 */;
index 3e850b3..b9f6bf1 100644 (file)
@@ -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');
index 020cd0a..e158f1a 100755 (executable)
@@ -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)
index f5828ae..bb3bc2d 100644 (file)
@@ -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
index 3d7dd64..7b5993d 100644 (file)
@@ -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
index 3011e58..c10e08d 100644 (file)
@@ -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;
+}
+
+*/
index 46e195d..66e26c1 100644 (file)
@@ -55,9 +55,5 @@
 
 [% END %]
 
-[% IF ( Babeltheque ) %]
-<script type="text/javascript" src="http://www.babeltheque.com/bw_30.js"></script>
-[% END %]
-
 </body>
 </html>
index 5c5b885..33ddae8 100644 (file)
@@ -2,6 +2,9 @@
 [% INCLUDE 'doc-head-close.inc' %]
 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tools.min.js"></script>
+<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
+  {lang: '[% lang %]'}
+</script>
 <script type="text/JavaScript" language="JavaScript">
 //<![CDATA[
     [% IF ( busc ) %]
@@ -496,6 +499,15 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
        [% END %]
     [% END %]
 
+    [% IF ( Babeltheque ) %]
+        <input type="hidden" name="BW_id_isbn" id="BW_id_isbn" value="[% normalized_isbn %]"/>
+
+        <div id="BW_notes"></div>
+        <div id="BW_critiques"></div>
+        <div id="BW_critiques_pro"></div>
+        <div id="BW_citations"></div>
+    [% END %]
+
 </div>
 
 <div id="bibliodescriptions" class="toptabs">
@@ -550,7 +562,6 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
     [% IF ( OPACFRBRizeEditions ) %][% IF ( XISBNS ) %]<li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#editions">Editions</a></li>[% END %][% END %]
     
     [% IF ( OPACAmazonEnabled ) %][% IF ( OPACAmazonReviews ) %]<li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#amazonreviews">Amazon Reviews</a></li>[% END %][% END %]
-    [% IF ( Babeltheque ) %]<li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#babeltheque">Babelthèque</a></li>[% END %]
 
     [% IF ( serialcollection ) %]
                [% IF ( defaulttab == 'serialcollection' ) %]<li class="ui-tabs-selected">
@@ -937,15 +948,6 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
 </div>
 [% END %]
 
-[% IF ( Babeltheque ) %]
-<div id="babeltheque">
-  <div id="BW_notes"></div>
-  <div id="BW_critiques"></div>
-  <div id="BW_citations"></div>
-  <div id="BW_etiquettes"></div>
-</div>
-[% END %]
-
 [% IF ( OPACFRBRizeEditions ) %][% IF ( XISBNS ) %]
 <div id="editions">
 
@@ -1039,6 +1041,16 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
 </div>
 [% END %][% END %]
 </div>
+
+[% IF ( Babeltheque ) %]
+    <div>
+        <div id="BW_etiquettes"></div>
+        <div id="BW_suggestions"></div>
+    </div>
+    <div class="clearfix"></div>
+    <div id="BW_videos"></div>
+[% END %]
+
 </div>
 
 
@@ -1067,7 +1079,6 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
 [% END %]
 
 [% INCLUDE 'opac-detail-sidebar.inc' %]
-
         [% IF ( NovelistSelectProfile ) %] [% IF ( NovelistSelectView == 'right') %]
          <div id="NovelistSelect">
             <h4>Novelist Select</h4>
@@ -1075,6 +1086,25 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
          </div>
         [% END %] [% END %]
 
+[% IF ( Babeltheque ) %]
+    <div class="babeltheque_adds">
+        <div id="BW_critiques_aj"></div>
+        <div id="BW_citations_aj"></div>
+    </div>
+[% END %]
+
+[% IF ( SocialNetworks ) %]
+    <div class="social_networks">
+        <span>Share</span>
+        <a href="http://www.facebook.com/sharer.php?u=[% current_url |url %]&t=[% title |url %]" title="Share on Facebook"><img alt="Share on Facebook" src="/opac-tmpl/prog/images/socnet/facebook16.png" /></a>
+        <a href="http://twitter.com/share" title="Share on Twitter"><img alt="Share on Twitter" src="/opac-tmpl/prog/images/socnet/twitter16.png" /></a>
+        <a href="http://www.linkedin.com/shareArticle?mini=true&url=[% current_url |url %]&title=[% title |url %]" title="Share on LinkedIn"><img alt="Share on LinkedIn" src="/opac-tmpl/prog/images/socnet/linkedin16.png" /></a>
+        <a href="http://www.delicious.com/save?url=[% current_url |url %]&title=[% title |url %]" title="Share on Delicious"><img alt="Share on Delicious" src="/opac-tmpl/prog/images/socnet/delicious16.gif" /></a>
+        <g:plusone size="small"></g:plusone>
+        <a href="mailto:ADRESSE?subject=TO READ : [% title %]>&body=[% title %]> [% current_url |url %]" title="Share by email"><img alt="Share by email" src="/opac-tmpl/prog/images/socnet/mailto16.png" /></a>
+    </div>
+[% END %]
+
 </div>
 </div>
 </div>
@@ -1098,4 +1128,9 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
 [% IF ( NovelistSelectProfile ) %]
 <script type="text/javascript" src="http://imageserver.ebscohost.com/novelistselect/ns2init.js"></script>
 [% END %]
+
+[% IF ( Babeltheque ) %]
+    <script type="text/javascript" src="[% Babeltheque_url_js %]"></script>
+[% END %]
+
 [% INCLUDE 'opac-bottom.inc' %]
index c8a3926..eda2015 100644 (file)
@@ -392,6 +392,9 @@ $(document).ready(function(){
                 [% IF ( SEARCH_RESULT.imageurl ) %]
                 <img src="[% SEARCH_RESULT.imageurl %]" title="[% SEARCH_RESULT.description %]" alt="[% SEARCH_RESULT.description %]" />
                 [% END %]
+                [% IF ( SEARCH_RESULT.score_avg ) %]
+                    <img src="[% themelang %]/../images/bonus.png" title="bonus" style="max-height: 35px;"/>
+                [% END %]
                 </td>
                 [% END %]
                 [% END %]
@@ -480,6 +483,23 @@ $(document).ready(function(){
                 </span>
 
                 [% END %]
+                [% IF ( SEARCH_RESULT.score_avg ) %]
+                    <span class="result_summary">
+                        <img src="[% themelang %]/../images/Star[% SEARCH_RESULT.score_int %].gif" title="" style="max-height: 15px;"/> <span style="font-size: 85%;">[% SEARCH_RESULT.score_avg %] / 5 (on [% SEARCH_RESULT.num_scores %] rates)</span>
+                        [% IF ( SEARCH_RESULT.num_critics ) %]
+                            <span class="social_data">[% SEARCH_RESULT.num_critics %] Internet user critics</span>
+                        [% END %]
+                        [% IF ( SEARCH_RESULT.num_critics_pro ) %]
+                            <span class="social_data">[% SEARCH_RESULT.num_critics_pro %] Professional critics</span>
+                        [% END %]
+                        [% IF ( SEARCH_RESULT.num_videos ) %]
+                            <span class="social_data">[% SEARCH_RESULT.num_videos %] Video extracts</span>
+                        [% END %]
+                        [% IF ( SEARCH_RESULT.num_quotations ) %]
+                            <span class="social_data">[% SEARCH_RESULT.num_quotations %] Quotations</span>
+                        [% END %]
+                    </span>
+                [% END %]
                 [% IF ( LibraryThingForLibrariesID ) %]<div class="ltfl_reviews"></div>[% 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 (file)
index 0000000..44ffdf4
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 (file)
index 0000000..2038638
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 (file)
index 0000000..2b60940
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 (file)
index 0000000..3ff6739
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 (file)
index 0000000..473cb32
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 (file)
index 0000000..0a61173
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 (file)
index 0000000..663a31d
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 (file)
index 0000000..11682e8
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 (file)
index 0000000..1176590
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 (file)
index 0000000..2a195c2
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 (file)
index 0000000..d8e4a5a
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 (file)
index 0000000..ccb1b61
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 (file)
index 0000000..7069e24
--- /dev/null
@@ -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 (file)
index 0000000..53058a7
--- /dev/null
@@ -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;
index b45250d..aed7dd7 100755 (executable)
@@ -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
index d846e55..ea0cb98 100755 (executable)
@@ -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"};
         }