From 8c670838daf688d743b399275dad93add76bc190 Mon Sep 17 00:00:00 2001 From: mytory Date: Wed, 19 Sep 2018 19:19:28 +0900 Subject: [PATCH] php72, download utf8 filename --- src/PHPePub/Core/EPub.php | 19 +++++++++++++++---- src/PHPePub/Core/Structure/Ncx.php | 6 ++++-- src/PHPePub/Core/Structure/OPF/MetaValue.php | 3 ++- src/PHPePub/Core/Structure/OPF/Metadata.php | 10 ++++++++-- 4 files changed, 29 insertions(+), 9 deletions(-) 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
    \n"; $li = ""; - while (list($item, $descriptive) = each($this->referencesOrder)) { + foreach ($this->referencesOrder as $item => $descriptive) { + // while (list($item, $descriptive) = each($this->referencesOrder)) { if (array_key_exists($item, $this->referencesList)) { $li .= "\t\t\t\t\t
  1. tagName; if (sizeof($this->attr) > 0) { - while (list($name, $content) = each($this->attr)) { + // while (list($name, $content) = each($this->attr)) { + foreach ($this->attr as $name => $content) { $dc .= " " . $name . "=\"" . $content . "\""; } } diff --git a/src/PHPePub/Core/Structure/OPF/Metadata.php b/src/PHPePub/Core/Structure/OPF/Metadata.php index d182563..90f16ea 100644 --- a/src/PHPePub/Core/Structure/OPF/Metadata.php +++ b/src/PHPePub/Core/Structure/OPF/Metadata.php @@ -123,12 +123,18 @@ function finalize($bookVersion = EPub::BOOK_VERSION_EPUB2, $date = null) { } foreach ($this->metaProperties as $data) { - list($name, $content) = each($data); + // list($name, $content) = each($data); + foreach ($data as $name => $content) { + break; + } $metadata .= "\t\t" . $content . "\n"; } foreach ($this->meta as $data) { - list($name, $content) = each($data); + // list($name, $content) = each($data); + foreach ($data as $name => $content) { + break; + } $metadata .= "\t\t\n"; }