diff --git a/src/PHPePub/Core/EPub.php b/src/PHPePub/Core/EPub.php index bbc6fe0..74c09b1 100644 --- a/src/PHPePub/Core/EPub.php +++ b/src/PHPePub/Core/EPub.php @@ -2058,7 +2058,14 @@ function finalize() { } reset($this->ncx->chapterList); - list($firstChapterName, $firstChapterNavPoint) = each($this->ncx->chapterList); + + + + // list($firstChapterName, $firstChapterNavPoint) = each($this->ncx->chapterList); + foreach ($this->ncx->chapterList as $firstChapterName => $firstChapterNavPoint) { + break; + } + /** @var $firstChapterNavPoint NavPoint */ $firstChapterFileName = $firstChapterNavPoint->getContentSrc(); $this->opf->addReference(Reference::TEXT, StringHelper::decodeHtmlEntities($firstChapterName), $firstChapterFileName); @@ -2156,9 +2163,13 @@ private function finalizeTOC() { } $tocData .= ">\n"; - while (list($item, $descriptive) = each($this->referencesOrder)) { + + + // while (list($item, $descriptive) = each($this->referencesOrder)) { + foreach ($this->referencesOrder as $item => $descriptive) { if ($item === "text") { - while (list($chapterName, $navPoint) = each($this->ncx->chapterList)) { + foreach ($this->ncx->chapterList as $chapterName => $navPoint) { + // while (list($chapterName, $navPoint) = each($this->ncx->chapterList)) { /** @var $navPoint NavPoint */ $fileName = $navPoint->getContentSrc(); $level = $navPoint->getLevel() - 2; @@ -2273,7 +2284,7 @@ function sendBook($fileName) { $fileName .= ".epub"; } - if (true === $this->zip->sendZip($fileName, "application/epub+zip")) { + if (true === $this->zip->sendZip($fileName, "application/epub+zip", $fileName)) { return $fileName; } diff --git a/src/PHPePub/Core/Structure/Ncx.php b/src/PHPePub/Core/Structure/Ncx.php index c410faa..ec547cb 100644 --- a/src/PHPePub/Core/Structure/Ncx.php +++ b/src/PHPePub/Core/Structure/Ncx.php @@ -355,7 +355,8 @@ function finalizeReferences() { $this->rootLevel(); $this->subLevel($this->referencesTitle, $this->referencesId, $this->referencesClass); $refId = 1; - while (list($item, $descriptive) = each($this->referencesOrder)) { + // while (list($item, $descriptive) = each($this->referencesOrder)) { + foreach ($this->referencesOrder as $item => $descriptive) { if (array_key_exists($item, $this->referencesList)) { $name = (empty($this->referencesName[$item]) ? $descriptive : $this->referencesName[$item]); $navPoint = new NavPoint($name, $this->referencesList[$item], "ref-" . $refId++); @@ -380,7 +381,8 @@ function finalizeEPub3Landmarks() { . "\t\t\t\t