diff --git a/book.php b/book.php index 06fe5d0..dcfb1c9 100644 --- a/book.php +++ b/book.php @@ -140,14 +140,20 @@ class Book extends Base { } public function getFullContentArray () { + global $config; $out = $this->getContentArray (); $out ["coverurl"] = Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)->hrefXhtml (); $out ["thumbnailurl"] = Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL, NULL, 150)->hrefXhtml (); $out ["content"] = $this->getComment (false); $out ["datas"] = array (); + $dataKindle = $this->GetMostInterestingDataToSendToKindle (); foreach ($this->getDatas() as $data) { - array_push ($out ["datas"], array ("format" => $data->format, "url" => $data->getHtmlLink ())); + $tab = array ("id" => $data->id, "format" => $data->format, "url" => $data->getHtmlLink (), "mail" => 0); + if (!empty ($config['cops_mail_configuration']) && !is_null ($dataKindle) && $data->id == $dataKindle->id) { + $tab ["mail"] = 1; + } + array_push ($out ["datas"], $tab); } $out ["authors"] = array (); foreach ($this->getAuthors () as $author) { @@ -264,7 +270,7 @@ class Book extends Base { public function GetMostInterestingDataToSendToKindle () { - $bestFormatForKindle = array ("PDF", "MOBI"); + $bestFormatForKindle = array ("EPUB", "PDF", "MOBI"); $bestRank = -1; $bestData = NULL; foreach ($this->getDatas () as $data) { diff --git a/images/mail-send.png b/images/mail-send.png new file mode 100644 index 0000000..1dbcb98 Binary files /dev/null and b/images/mail-send.png differ diff --git a/styles/style-default.css b/styles/style-default.css index 2f910db..1fe2da5 100644 --- a/styles/style-default.css +++ b/styles/style-default.css @@ -156,8 +156,12 @@ max-width:800px; text-decoration : none; font-weight: bold; padding: 5px 10px 5px 10px; + text-align: center; } +.download img { + vertical-align:middle; +} .books h4{ display: inline; diff --git a/templates/default/bookdetail.html b/templates/default/bookdetail.html index 9d58fa6..e5b5662 100644 --- a/templates/default/bookdetail.html +++ b/templates/default/bookdetail.html @@ -8,7 +8,11 @@

{{~it.book.datas:data:i}} - {{=data.format}}
+ {{=data.format}} + {{? data.mail == 1}} + Mail + {{?}} +
{{~}}

{{=it.const.i18n.permalinkAlt}}{{=htmlEscape (it.title)}}

diff --git a/util.js b/util.js index 7437ec3..79302af 100644 --- a/util.js +++ b/util.js @@ -19,6 +19,23 @@ function elapsed () { return "Elapsed : " + elapsed; } +function retourMail(data, textStatus, jqXHR ) { + alert (data); +} + +function sendToMailAddress (component, dataid) { + $toto = $.cookie ('email'); + if (!$.cookie ('email')) { + var email = window.prompt ("Please enter your email : ", ""); + $.cookie ('email', email); + } + email = $.cookie ('email'); + var url = 'sendtomail.php'; + if (currentData.databaseId) url = url + '?db=' + currentData.databaseId; + $.ajax ({url: url, type: 'post', data: { data: dataid, email: email }, success: retourMail}); +} + + function fancyBoxObject (title, type) { var out = { prevEffect : 'none', nextEffect : 'none' }; if (isEink) {