Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/PHPePub/Core/EPub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 4 additions & 2 deletions src/PHPePub/Core/Structure/Ncx.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++);
Expand All @@ -380,7 +381,8 @@ function finalizeEPub3Landmarks() {
. "\t\t\t\t<ol>\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<li><a epub:type=\""
. $item
Expand Down
3 changes: 2 additions & 1 deletion src/PHPePub/Core/Structure/OPF/MetaValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ function finalize($bookVersion = EPub::BOOK_VERSION_EPUB2) {
$dc = "\t\t<" . $this->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 . "\"";
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/PHPePub/Core/Structure/OPF/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<meta property=\"" . $name . "\">" . $content . "</meta>\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<meta name=\"" . $name . "\" content=\"" . $content . "\" />\n";
}

Expand Down