diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index e553946..c476df3 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -1136,36 +1136,52 @@ class Poche * handle epub */ public function createEpub() { - - if (isset($_GET['epub']) && isset($_GET['id'])) { - if ($_GET['id'] == "all") { // we put all entries in the file - $entries = $this->store->retrieveAll($this->user->getId()); - } - else { // we put only one entry in the file + + switch ($_GET['method']) { + case 'id': $entryID = filter_var($_GET['id'],FILTER_SANITIZE_NUMBER_INT); $entry = $this->store->retrieveOneById($entryID, $this->user->getId()); $entries = array($entry); - } + break; + case 'all': + $entries = $this->store->retrieveAll($this->user->getId()); + break; + case 'tag': + $tag = filter_var($_GET['tag'],FILTER_SANITIZE_STRING); + $tags_id = $this->store->retrieveAllTags($this->user->getId(),$tag); + $tag_id = $tags_id[0]["id"]; // we take the first result, which is supposed to match perfectly. There must be a workaround. + $entries = $this->store->retrieveEntriesByTag($tag_id,$this->user->getId()); + break; + case 'category': + $category = filter_var($_GET['category'],FILTER_SANITIZE_STRING); + $entries = $this->store->getEntriesByView($category,$this->user->getId()); + break; + case 'search': + $search = filter_var($_GET['search'],FILTER_SANITIZE_STRING); + $entries = $this->store->search($search,$this->user->getId()); + break; + case 'default': + die(_('Uh, there is a problem while generating epub.')); + } + $content_start = "\n" - . "\n" - . "\n" - . "" - . "\n" + . "\n" + . "\n" + . "\n" . "\n" - . "Test Book\n" + . "wallabag article\n" . "\n" . "\n"; $bookEnd = "\n\n"; - $log = new Logger($entryID, TRUE); + $log = new Logger("wallabag", TRUE); $fileDir = CACHE; - $book = new EPub(); + $book = new EPub(EPub::BOOK_VERSION_EPUB3); $log->logLine("new EPub()"); $log->logLine("EPub class version: " . EPub::VERSION); $log->logLine("EPub Req. Zip version: " . EPub::REQ_ZIP_VERSION); @@ -1186,6 +1202,10 @@ class Poche $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, "PHP"); $cssData = "body {\n margin-left: .5em;\n margin-right: .5em;\n text-align: justify;\n}\n\np {\n font-family: serif;\n font-size: 10pt;\n text-align: justify;\n text-indent: 1em;\n margin-top: 0px;\n margin-bottom: 1ex;\n}\n\nh1, h2 {\n font-family: sans-serif;\n font-style: italic;\n text-align: center;\n background-color: #6b879c;\n color: white;\n width: 100%;\n}\n\nh1 {\n margin-bottom: 2px;\n}\n\nh2 {\n margin-top: -2px;\n margin-bottom: 2px;\n}\n"; + + $log->logLine("Add Cover Image"); + $book->setCoverImage("Cover.png", file_get_contents("themes/baggy/img/apple-touch-icon-152.png"), "image/png"); + $cover = $content_start . "

My articles on wallabag

\n

As seen on : http://$_SERVER[HTTP_HOST]

\n" . $bookEnd; $book->addChapter("Notices", "Cover.html", $cover); $book->buildTOC(NULL, "toc", "Table of Contents", TRUE, TRUE); @@ -1193,7 +1213,7 @@ class Poche foreach ($entries as $entry) { $tags = $this->store->retrieveTagsByEntry($entry['id']); foreach ($tags as $tag) { - $book->setSubject($tag); + $book->setSubject($tag['value']); } $log->logLine("Set up parameters"); @@ -1201,11 +1221,11 @@ class Poche $chapter = $content_start . $entry['content'] . $bookEnd; - $book->addChapter("Chapter " . $entry['id'] . ": " . $entry['title'], htmlspecialchars($entry['title']) . ".html", $chapter, true, EPub::EXTERNAL_REF_ADD); + $book->addChapter($entry['title'], htmlspecialchars($entry['title']) . ".html", $chapter, true, EPub::EXTERNAL_REF_ADD); } - if (true) { + if (DEBUG_POCHE) { $epuplog = $book->getLog(); $book->addChapter("Log", "Log.html", $content_start . $log->getLog() . "\n" . $bookEnd); // generation log // Only used in case we need to debug EPub.php. diff --git a/themes/baggy/config.twig b/themes/baggy/config.twig index f43f6d0..1b8b864 100755 --- a/themes/baggy/config.twig +++ b/themes/baggy/config.twig @@ -126,7 +126,7 @@

{% trans "Click here" %} {% trans "to export your wallabag data." %}

Fancy a ebook ?

- Click on this link to get all your articles in one ebook (ePub). + Click on this link to get all your articles in one ebook (ePub).

{% trans "Cache" %}

{% trans "Click here" %} {% trans "to delete cache." %}

diff --git a/themes/baggy/home.twig b/themes/baggy/home.twig index 5dd9130..301f353 100755 --- a/themes/baggy/home.twig +++ b/themes/baggy/home.twig @@ -57,6 +57,11 @@ {% endfor %} {% if view == 'home' %}{% if nb_results > 1 %}{{ "Mark all the entries as read" }}{% endif %}{% endif %} + + {% if tag %}{% trans "Download the articles from this tag in an epub" %} + {% elseif search_term is defined %}{% trans "Download the articles from this search in an epub" %} + {% else %}{% trans "Download the articles from this category in an epub" %}{% endif %} + {% endif %} {{ block('pager') }} {% endblock %} diff --git a/themes/baggy/view.twig b/themes/baggy/view.twig index 0dff4e2..af97407 100755 --- a/themes/baggy/view.twig +++ b/themes/baggy/view.twig @@ -16,7 +16,7 @@ {% if constant('SHARE_SHAARLI') == 1 %}
  • {% trans "shaarli" %}
  • {% endif %} {% if constant('FLATTR') == 1 %}{% if flattr.status == constant('FLATTRABLE') %}
  • {% trans "flattr" %}
  • {% elseif flattr.status == constant('FLATTRED') %}
  • {% trans "flattr" %} ({{ flattr.numflattrs }})
  • {% endif %}{% endif %} {% if constant('SHOW_PRINTLINK') == 1 %}
  • {% trans "Print" %}
  • {% endif %} -
  • EPUB
  • +
  • EPUB
  • {% trans "Does this article appear wrong?" %}