Add emailing. re #53

This commit is contained in:
Sébastien Lucas 2013-06-21 21:31:49 +02:00
parent 6b8846e02b
commit e833172e99
5 changed files with 34 additions and 3 deletions

View file

@ -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) {

BIN
images/mail-send.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

@ -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;

View file

@ -8,7 +8,11 @@
</span>
<h2 class="download">
{{~it.book.datas:data:i}}
<a href="{{=data.url}}">{{=data.format}}</a><br />
<a href="{{=data.url}}">{{=data.format}}</a>
{{? data.mail == 1}}
<a href="customize.php" onclick="sendToMailAddress (this, {{=data.id}}); return false;"><img src="images/mail-send.png?v={{=it.const.version}}" alt="Mail" /></a>
{{?}}
<br />
{{~}}
</h2>
<h1><a rel="bookmark" href="{{=strformat (it.const.url.detailUrl, it.book.id, it.databaseId)}}"><img src="images/Link.png?v={{=it.const.version}}" alt="{{=it.const.i18n.permalinkAlt}}" /></a>{{=htmlEscape (it.title)}}</h1>

17
util.js
View file

@ -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) {