示例#1
0
        $cssData .= file_get_contents($value);
    }
    $book->addCSSFile("styles.css", "css1", $cssData);
    // This test requires you have an image, change "demo/cover-image.jpg" to match your location.
    $book->setCoverImage("Cover.jpg", file_get_contents($metadatas["ebook-cover-image"]), "image/jpeg");
    // Titre et courte description de l'ouvrage
    $cover = $content_start . '<h1>' . $metadatas["ebook-title"] . '</h1>' . "\n" . '<h2>' . _t('TAGS_BY') . ': ' . $metadatas["ebook-author"] . '</h2>' . "\n" . $metadatas["ebook-description"] . $bookEnd;
    $book->addChapter(_t('TAGS_ABOUT_THIS_EBOOK'), "Cover.html", $cover);
    // on recupere les include pour faire les chapitres
    preg_match_all("/{{include.*page=\"(.*)\".*class=\"(.*)\".*}}/U", $this->page["body"], $matches);
    foreach ($matches[1] as $nb => $pageWiki) {
        $page = $this->LoadPage($pageWiki);
        $url = explode('wakka.php', $this->config['base_url']);
        if (TEMPLATES_DEFAULT_CHARSET != 'UTF-8') {
            $contentpage = utf8_encode($content_start . str_replace('<img src="' . $url[0], '<img src="', $this->Format('{{include page="' . $pageWiki . '" class="' . $matches[2][$nb] . '"}}')) . $bookEnd);
        } else {
            $contentpage = $content_start . str_replace('<img src="' . $url[0], '<img src="', $this->Format('{{include page="' . $pageWiki . '" class="' . $matches[2][$nb] . '"}}')) . $bookEnd;
        }
        $book->addChapter(get_title_from_body($page), $pageWiki . ".html", $contentpage, false, EPub::EXTERNAL_REF_ADD);
    }
    $book->finalize();
    // Finalize the book, and build the archive.
    // Save book as a file relative to your script (for local ePub generation)
    // Notice that the extions .epub will be added by the script.
    // The second parameter is a directory name which is '.' by default. Don't use trailing slash!
    $book->saveBook($this->getPageTag(), 'cache');
    // Send the book to the client. ".epub" will be appended if missing.
    $zipData = $book->sendBook($this->getPageTag());
} else {
    echo $this->Header() . '<div class="alert alert-danger">' . _t('TAGS_NO_EBOOK_METADATAS') . '</div>' . $this->Footer();
}
示例#2
0
     //$book->setCoverImage("Cover.jpg", getImagePath($story_id), "image/jpeg");
     $cover = $content_start . "<div class='coverPage'><h1>{$story["title"]}</h1>\n<h2>by: {$story["author"]}</h2></div>" . $bookEnd;
     $book->addChapter($story["title"], "Cover.html", $cover);
     $book->buildTOC();
     for ($i = 0; $i < $numChapter; $i++) {
         $title = isset($story["chapters"]["title"][$i]) ? $story["chapters"]["title"][$i] : "";
         $content = isset($story["chapters"]["content"][$i]) ? $story["chapters"]["content"][$i] : "";
         if (!empty($content) && !empty($title)) {
             $title = formatTitle($title, $i);
             $filename = "Chapter" . ($i + 1) . ".html";
             $book->addChapter($title, $filename, $content_start . "<h2>{$title}</h2>" . $content . $bookEnd, true, EPub::EXTERNAL_REF_ADD);
         }
     }
     $book->finalize();
     $filename = $uniqid . "_" . $story["title"] . " - " . $story["author"] . ".epub";
     $book->saveBook($filename, "./tmp");
     if (!empty($email)) {
         mailAttachment($filename, "./tmp/", $email, $uniqid);
     }
 } else {
     if ($format == "mobi") {
         include_once "mobi/MOBI.php";
         $mobi = new MOBI();
         $mobiContent = new MOBIFile();
         $mobiContent->set("title", $story["title"]);
         $mobiContent->set("author", $story["author"]);
         $mobiContent->set("toc", true);
         $mobiContent->appendChapterTitle($story["title"]);
         $mobiContent->appendParagraph("by: " . $story["author"]);
         $mobiContent->appendPageBreak();
         for ($i = 0; $i < $numChapter; $i++) {