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");
$this->extractIdAttributes("ref_" . $reference, $pageData);
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;
}