From 4bbb2fab8c68d63b1a9f93c93244cdcdb9feb40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Wed, 15 May 2013 19:32:18 +0200 Subject: [PATCH] Prepare a feature to send the book by email (Send to Kindle). re #53 --- book.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/book.php b/book.php index a7d434c..0098439 100644 --- a/book.php +++ b/book.php @@ -199,6 +199,21 @@ class Book extends Base { } return $this->datas; } + + public function GetMostInterestingDataToSendToKindle () + { + $bestFormatForKindle = array ("PDF", "MOBI"); + $bestRank = -1; + $bestData = NULL; + foreach ($this->getDatas () as $data) { + $key = array_search ($data->format, $bestFormatForKindle); + if ($key !== false && $key > $bestRank) { + $bestRank = $key; + $bestData = $data; + } + } + return $bestData; + } public function getDataById ($idData) {