/**
* Reference pages is usually one or two pages for items such as Table of Contents, reference lists, Author notes or Acknowledgements.
* These do not show up in the regular navigation list.
*
* As they are supposed to be short.
*
* @param string $pageName Name of the chapter, will be use din the TOC
* @param string $fileName Filename to use for the chapter, must be unique for the book.
* @param string $pageData Page content in XHTML. File should NOT exceed 250kB.
* @param string $reference Reference key
* @param int $externalReferences How to handle external references. See documentation for <code>processChapterExternalReferences</code> for explanation. Default is EPub::EXTERNAL_REF_IGNORE.
* @param string $baseDir Default is "", meaning it is pointing to the document root. NOT used if $externalReferences is set to EPub::EXTERNAL_REF_IGNORE.
*
* @return bool $success
*/
function addReferencePage($pageName, $fileName, $pageData, $reference, $externalReferences = EPub::EXTERNAL_REF_IGNORE, $baseDir = "")
{
if ($this->isFinalized) {
return false;
}
$fileName = RelativePath::getRelativePath($fileName);
$fileName = preg_replace('#^[/\\.]+#i', "", $fileName);
if (!empty($pageData) && is_string($pageData)) {
if ($this->encodeHTML === true) {
$pageData = StringHelper::encodeHtml($pageData);
}
$this->wrapChapter($pageData);
if ($externalReferences !== EPub::EXTERNAL_REF_IGNORE) {
$htmlDirInfo = pathinfo($fileName);
$htmlDir = preg_replace('#^[/\\.]+#i', "", $htmlDirInfo["dirname"] . "/");
$this->processChapterExternalReferences($pageData, $externalReferences, $baseDir, $htmlDir);
}
$this->addFile($fileName, "ref_" . $reference, $pageData, "application/xhtml+xml");
if ($reference !== Reference::TABLE_OF_CONTENTS || !isset($this->ncx->referencesList[$reference])) {
$this->opf->addItemRef("ref_" . $reference, false);
$this->opf->addReference($reference, $pageName, $fileName);
$this->ncx->referencesList[$reference] = $fileName;
$this->ncx->referencesName[$reference] = $pageName;
}
return true;
}
return true;
}