Allow metadata updating for epub. Disabled by default for now.

fix #18
This commit is contained in:
Sébastien Lucas 2013-01-02 21:50:44 +01:00
parent 11f4efb51d
commit 60df6f1c18
9 changed files with 1560 additions and 2 deletions

View file

@ -11,6 +11,7 @@ require_once('serie.php');
require_once('author.php');
require_once('tag.php');
require_once('data.php');
require_once('php-epub-meta/epub.php');
// Silly thing because PHP forbid string concatenation in class const
define ('SQL_BOOKS_LEFT_JOIN', "left outer join comments on comments.book = books.id
@ -259,6 +260,36 @@ class Book extends Base {
}
}
public function getUpdatedEpub ($idData)
{
$data = $this->getDataById ($idData);
try
{
$epub = new EPub ($data->getLocalPath ());
$epub->Title ($this->title);
$authorArray = array ();
foreach ($this->getAuthors() as $author) {
$authorArray [$author->sort] = $author->name;
}
$epub->Authors ($authorArray);
$epub->Language ($this->getLanguages ());
$epub->Description ($this->getComment (false));
$epub->Subjects ($this->getTagsName ());
$se = $this->getSerie ();
if (!is_null ($se)) {
$epub->Serie ($se->name);
$epub->SerieIndex ($this->seriesIndex);
}
$epub->download ($data->getFilename ());
}
catch (Exception $e)
{
echo "Exception : " . $e->getMessage();
}
}
public function getLinkArray ()
{
global $config;