diff --git a/EPub.php b/EPub.php index c43bb90..7c263d1 100644 --- a/EPub.php +++ b/EPub.php @@ -77,6 +77,9 @@ class EPub { private $EPubMark = TRUE; private $generator = ""; + private $contentHeader = ""; + private $contentFooter = ""; + /** * Class constructor. * @@ -106,6 +109,20 @@ function __construct() { $this->chapterCount = 0; $this->isGdInstalled = extension_loaded('gd') && function_exists('gd_info'); + + // introduced variable {{BOOKTITLE}} for str_replace the BookTitle in all head sections + $this->contentHeader = "\n" + . "\n" + . "\n" + . "" + . "\n" + . "\n" + . "{{BOOKTITLE}}\n" + . "\n" + . "\n"; + + $this->contentFooter = "\n\n"; } /** @@ -210,7 +227,8 @@ function addChapter($chapterName, $fileName, $chapterData, $autoSplit = FALSE, $ $htmlDir = pathinfo($fileName); $htmlDir = preg_replace('#^[/\.]+#i', "", $htmlDir["dirname"] . "/"); - $chapter = $chapterData; + // Add Header and Footer to Chapter HTML Data + $chapter = $this->wrapChapter($chapterData); if ($autoSplit && is_string($chapterData) && mb_strlen($chapterData) > $this->splitDefaultSize) { $splitter = new EPubChapterSplitter(); @@ -262,6 +280,16 @@ function addChapter($chapterName, $fileName, $chapterData, $autoSplit = FALSE, $ return TRUE; } + /** + * Wrap ChapterContent with Head and Footer + * + * @param $content + * @return string $content + */ + private function wrapChapter($content) { + return $this->contentHeader . "\n" . $content . "\n" . $this->contentFooter; + } + /** * Process external references from a HTML to the book. The chapter itself is not stored. * the HTML is scanned for ,