$atom->title = "Books in {$epubdir}"; // todo: replace with a $catalogname field $atom->description = "epub files on my server"; $atom->link = "http://mydomain.net/"; $atom->syndicationURL = $scripturl; // sort the files by date so the most recent is first in the feed // preg_find(pattern, starting dir, args) $files = preg_find('/\\.epub$/', $epubdir, PREG_FIND_RECURSIVE | PREG_FIND_RETURNASSOC | PREG_FIND_SORTBASENAME | PREG_FIND_SORTDESC); $files = array_keys($files); // add the files to the feed foreach ($files as $file) { if (is_file($file)) { $ebook = new ebookRead($file); // entries $item = new FeedItem(); $item->title = $ebook->getDcTitle(); $item->linktype = "application/epub+zip"; $item->link = $file; // <link rel="x-stanza-cover-image" type="image/jpeg" href="cover.php?filename=$file"/> $coverLink = new LinkItem(); $coverLink->rel = "x-stanza-cover-image"; $coverLink->type = "image/jpeg"; $coverLink->href = "cover.php?filename={$file}"; $item->addLink($coverLink); $thumbnailLink = new LinkItem(); $thumbnailLink->rel = "x-stanza-cover-image-thumbnail"; $thumbnailLink->type = "image/jpeg"; $thumbnailLink->href = "cover.php?filename={$file}&type=thumb"; $item->addLink($thumbnailLink); // <link rel="x-stanza-cover-image" type="image/jpeg" href="/get/cover/3"/> // <link rel="x-stanza-cover-image-thumbnail" type="image/jpeg" href="/get/thumb/3"/>
} function editToc($content, $ebook) { $spineInfo = $ebook->getSpine(); for ($x = 0; $x < count($spineInfo); $x += 1) { $manItem = $ebook->getManifestById($spineInfo[$x]); $tag = substr($manItem->href, 0, strrpos($manItem->href, '.')); $content = str_replace($manItem->href, "#" . $tag, $content); } return $content; } ?> <HTML> <HEAD> <TITLE>OPL's Open eBook Reader - <?php echo $ebook->getDcTitle(); ?> </TITLE> <meta name="author" content="Jacob Weigand"> </HEAD> <BODY> <?php echo "<P ALIGN=LEFT STYLE=\"margin-bottom: 0in\">\n"; echo buildToc($ebook); for ($x = 0; $x < count($spineInfo); $x += 1) { $manItem = $ebook->getManifestById($spineInfo[$x]); echo "<div id=\"section\">"; echo "<a name=" . substr($manItem->href, 0, strrpos($manItem->href, '.')) . " />\n"; echo editToc($content = $ebook->getContentById($spineInfo[$x]), $ebook); echo "</div>\n"; }