From e833172e9981472d9f6cdcc1be307d7013eb38eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Fri, 21 Jun 2013 21:31:49 +0200 Subject: [PATCH] Add emailing. re #53 --- book.php | 10 ++++++++-- images/mail-send.png | Bin 0 -> 3585 bytes styles/style-default.css | 4 ++++ templates/default/bookdetail.html | 6 +++++- util.js | 17 +++++++++++++++++ 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 images/mail-send.png 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 0000000000000000000000000000000000000000..1dbcb984beb68467ddbc5b9da97f153a33a7f90f GIT binary patch liter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007bV*G`2igS(4J{(q)T(#@000_v zMObuGZ)S9NVRB^vP+@6qbS_RsR3LUUE;TMOFfjCTp#T5_3rR#lR5(wqlwC-ZQ5eS$ zED)wR5fniMy(pzN%8QYV98nA}q=8{d^9xO7AF_8Xhcf)ijcLxg;a7gl`8A!oId60q z6?7Lt&}A3VjTn&zk>R^g)3^T_zBOe+UoZSP=RD_m{^vQ*`@ApVAF)_0@cDewm6etH zKp@cYr_i{ir6pNmVd1%B$zM-mVq$!6Z?Ac6ZS7kq6gpU6UynfNXTk3u`|b@64nE4v z%oH6<64Kn<9JjErAZc%J&rL{3$gi%h_DoMte_CB#<$}Q=M@JsI=55h)uh;vfv9Zyg zl$3NGdY4dv%dM@gaiqV$UxsVF1W(OobCFOeyrEPoof8uiTYkU)2yi^h%gZO`6eO~v zQmNb!E;5-+O6WWTub_L4Kv0d7cNZ5IY0$RI<Bu0zH@_K%L{yQ?^PJ`PX z_4W0=Ehs2>n30hox7+Pn9JWPupvShfwCISzU|^=Err6opS#EA_js|Xzj*i;W($eyB za&j8r^aA_)bf0HtX6DdpwZ4%`rKaTMmhlh7{I$bCwB}G+ST&#f22f+i6$MZ8Dwy;*K zH4=?R!{B5V*>cgi-R^xjKCi8gtRH znK5`7ti$2pV&QZ;Ih5i9df496({l&GR%Et8?XmnR&_E|#R7Was;Vj@si>%6y1KepynXI}0lhGqz(~r<%Jle}b~`#cI10Yh$jHx6 zuVdMx_b6>`ZER_2sezyi?lv_wy~hFE?|{HFZTv{}psOMRf#AGMCbOb1H_`Yz;OpO_ z*XwuC+M84lx)mP7X9q3&lgb05CCZQ)vIl#*g00000NkvXX Hu0mjf|4GKS literal 0 HcmV?d00001 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) {