/** * @param int $startPage * @param int $endPage * @param int $progressUpdaterWeighting multiplier for the amount to increment the progress indicator each time a thumbnail is complete */ public function generateThumbnails($startPage, $endPage, $progressUpdaterWeighting = ProgressUpdater::WEIGHTING_TYPICAL) { $pages = $this->epub->pageList(); // Generate Thumbnails and update progress. for ($pageNum = $startPage; $pageNum <= $endPage; $pageNum++) { CakeLog::debug("[CommonProcessor::process] Generating thumbnail for page {$pageNum} in Book ID {$this->bookId}"); $this->requestThumbnail($pages[$pageNum - 1]->relativePath); $this->progress->incrementStep($progressUpdaterWeighting); } CakeLog::debug("[CommonProcessor::process] Thumbnail generation complete"); }
/** * Hyperlink href attributes must be set before all the pages are named. * Go through the pages and replace the page UIDs in all hrefs with the actual page name. * Use Ganon to target only hyperlink href attributes * @param EpubManager $epubManager */ public function fixHyperlinkPageNames(EpubManager $epubManager) { $pages = $epubManager->pageList(); foreach ($pages as $pageFile) { $content = $epubManager->getPageContent($pageFile->relativePath); $dom = new HTML_Parser($content); $hyperlinks = $dom('a'); if (count($hyperlinks) > 0) { foreach ($hyperlinks as $hyperlink) { $href = $hyperlink->getAttribute('href'); $correctedHref = str_replace(array_keys($this->pageNameXref), array_values($this->pageNameXref), $href); $hyperlink->setAttribute('href', $correctedHref); } $epubManager->updatePageContent($pageFile->relativePath, (string) $dom); } unset($dom); } }