echo ' selected="selected"'; } echo '>' . $label . '</option>'; } ?> </select> <span class="help-inline"></span> </div> </div> <div class="form-group"> <label for="fonts" class="col-lg-2 control-label">Include fonts</label> <div class="col-lg-10"> <select id="fonts" name="fonts" class="form-control"> <option value="">None</option><?php $list = FontProvider::getList(); foreach ($list as $key => $label) { echo '<option value="' . $key . '"'; if ($options['fonts'] == $key) { echo ' selected="selected"'; } echo '>' . $label . '</option>' . "\n"; } ?> </select> </div> </div> <div class="form-group"> <label class="col-lg-2 control-label">Options</label> <div class="col-lg-10">
protected function getOpfContent(Book $book, $wsUrl) { $content = '<?xml version="1.0" encoding="UTF-8" ?> <package xmlns="http://www.idpf.org/2007/opf" unique-identifier="uid" version="2.0"> <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dcterms="http://purl.org/dc/terms/"> <dc:identifier id="uid" opf:scheme="URI">' . $wsUrl . '</dc:identifier> <dc:language xsi:type="dcterms:RFC4646">' . $book->lang . '</dc:language> <dc:title>' . htmlspecialchars($book->name, ENT_QUOTES) . '</dc:title> <dc:source>' . $wsUrl . '</dc:source> <dc:date opf:event="ops-publication" xsi:type="dcterms:W3CDTF">' . date(DATE_W3C) . '</dc:date> <dc:rights>http://creativecommons.org/licenses/by-sa/3.0/</dc:rights> <dc:rights>http://www.gnu.org/copyleft/fdl.html</dc:rights> <dc:contributor opf:role="bkp">Wikisource</dc:contributor>'; if ($book->author != '') { $content .= '<dc:creator opf:role="aut">' . htmlspecialchars($book->author, ENT_QUOTES) . '</dc:creator>'; } if ($book->translator != '') { $content .= '<dc:contributor opf:role="trl">' . htmlspecialchars($book->translator, ENT_QUOTES) . '</dc:contributor>'; } if ($book->illustrator != '') { $content .= '<dc:contributor opf:role="ill">' . htmlspecialchars($book->illustrator, ENT_QUOTES) . '</dc:contributor>'; } if ($book->publisher != '') { $content .= '<dc:publisher>' . htmlspecialchars($book->publisher, ENT_QUOTES) . '</dc:publisher>'; } if ($book->year != '') { $content .= '<dc:date opf:event="original-publication">' . htmlspecialchars($book->year, ENT_QUOTES) . '</dc:date>'; } if ($book->cover != '') { $content .= '<meta name="cover" content="cover" />'; } else { $content .= '<meta name="cover" content="title" />'; } $content .= '</metadata> <manifest> <item href="toc.ncx" id="ncx" media-type="application/x-dtbncx+xml"/>'; if ($book->cover != '') { $content .= '<item id="cover" href="cover.xhtml" media-type="application/xhtml+xml" />'; } $content .= '<item id="title" href="title.xhtml" media-type="application/xhtml+xml" /> <item id="mainCss" href="main.css" media-type="text/css" /> <item id="Accueil_scribe.png" href="images/Accueil_scribe.png" media-type="image/png" />'; $font = FontProvider::getData($book->options['fonts']); if ($font !== null) { foreach ($font['otf'] as $name => $path) { $content .= '<item id="' . $font['name'] . $name . '" href="fonts/' . $font['name'] . $name . '.otf" media-type="font/opentype" />' . "\n"; } } if ($book->content) { $content .= '<item id="' . $book->title . '" href="' . $book->title . '.xhtml" media-type="application/xhtml+xml" />' . "\n"; } foreach ($book->chapters as $chapter) { $content .= '<item id="' . $chapter->title . '" href="' . $chapter->title . '.xhtml" media-type="application/xhtml+xml" />' . "\n"; foreach ($chapter->chapters as $subpage) { $content .= '<item id="' . $subpage->title . '" href="' . $subpage->title . '.xhtml" media-type="application/xhtml+xml" />' . "\n"; } } foreach ($book->pictures as $picture) { $content .= '<item id="' . $picture->title . '" href="images/' . $picture->title . '" media-type="' . $picture->mimetype . '" />' . "\n"; } $content .= '<item id="about" href="about.xhtml" media-type="application/xhtml+xml" /> </manifest> <spine toc="ncx">'; if ($book->cover != '') { $content .= '<itemref idref="cover" linear="no" />'; } $content .= '<itemref idref="title" linear="yes" />'; if ($book->content) { $content .= '<itemref idref="' . $book->title . '" linear="yes" />'; } if (!empty($book->chapters)) { foreach ($book->chapters as $chapter) { $content .= '<itemref idref="' . $chapter->title . '" linear="yes" />'; foreach ($chapter->chapters as $subpage) { $content .= '<itemref idref="' . $subpage->title . '" linear="yes" />'; } } } $content .= '<itemref idref="about" linear="yes" /> </spine> <guide>'; if ($book->cover != '') { $content .= '<reference type="cover" title="' . htmlspecialchars($this->i18n['cover'], ENT_QUOTES) . '" href="cover.xhtml" />'; } else { $content .= '<reference type="cover" title="' . htmlspecialchars($this->i18n['cover'], ENT_QUOTES) . '" href="title.xhtml" />'; } $content .= '<reference type="title-page" title="' . htmlspecialchars($this->i18n['title_page'], ENT_QUOTES) . '" href="title.xhtml" />'; if ($book->content) { $content .= '<reference type="text" title="' . htmlspecialchars($book->name, ENT_QUOTES) . '" href="' . $book->title . '.xhtml" />'; } $content .= '<reference type="copyright-page" title="' . htmlspecialchars($this->i18n['about'], ENT_QUOTES) . '" href="about.xhtml" /> </guide> </package>'; return $content; }
protected function getOpfContent(Book $book, $wsUrl) { $content = '<?xml version="1.0" encoding="UTF-8" ?> <package xmlns="http://www.idpf.org/2007/opf" unique-identifier="uid" version="3.0" xml:lang="' . $book->lang . '" prefix="cc: http://creativecommons.org/ns#"> <metadata xmlns:dc="http://purl.org/dc/elements/1.1/"> <dc:identifier id="uid">' . $wsUrl . '</dc:identifier> <meta property="dcterms:modified">' . date('Y-m-d\\TH:i:s') . 'Z</meta> <dc:language>' . $book->lang . '</dc:language> <dc:title id="meta-title">' . htmlspecialchars($book->name, ENT_QUOTES) . '</dc:title> <meta refines="#meta-title" property="title-type">main</meta> <dc:source>' . $wsUrl . '</dc:source> <dc:rights xml:lang="en">Creative Commons BY-SA 3.0</dc:rights> <link rel="cc:license" href="http://creativecommons.org/licenses/by-sa/3.0/" /> <dc:rights xml:lang="en">GNU Free Documentation License</dc:rights> <link rel="cc:license" href="http://www.gnu.org/copyleft/fdl.html" /> <dc:contributor id="meta-bkp">Wikisource</dc:contributor> <meta refines="#meta-bkp" property="role" scheme="marc:relators">bkp</meta>'; if ($book->author != '') { $content .= '<dc:creator id="meta-aut">' . htmlspecialchars($book->author, ENT_QUOTES) . '</dc:creator> <meta refines="#meta-aut" property="role" scheme="marc:relators">aut</meta>'; } if ($book->translator != '') { $content .= '<dc:contributor id="meta-trl">' . htmlspecialchars($book->translator, ENT_QUOTES) . '</dc:contributor> <meta refines="#meta-trl" property="role" scheme="marc:relators">trl</meta>'; } if ($book->illustrator != '') { $content .= '<dc:contributor id="meta-ill">' . htmlspecialchars($book->illustrator, ENT_QUOTES) . '</dc:contributor> <meta refines="#meta-ill" property="role" scheme="marc:relators">ill</meta>'; } if ($book->publisher != '') { $content .= '<dc:publisher>' . htmlspecialchars($book->publisher, ENT_QUOTES) . '</dc:publisher>'; } if ($book->year != '') { $content .= '<dc:date>' . htmlspecialchars($book->year, ENT_QUOTES) . '</dc:date>'; } if ($book->cover != '') { $content .= '<meta name="cover" content="cover" />'; } else { $content .= '<meta name="cover" content="title" />'; } $content .= '</metadata> <manifest> <item href="nav.xhtml" id="nav" media-type="application/xhtml+xml" properties="nav" /> <item href="toc.ncx" id="ncx" media-type="application/x-dtbncx+xml"/>'; // deprecated if ($book->cover != '') { // TODO use image ? $content .= '<item id="cover" href="cover.xhtml" media-type="application/xhtml+xml" />'; } $content .= '<item id="title" href="title.xhtml" media-type="application/xhtml+xml" /> <item id="mainCss" href="main.css" media-type="text/css" /> <item id="Accueil_scribe.png" href="images/Accueil_scribe.png" media-type="image/png" />'; $font = FontProvider::getData($book->options['fonts']); if ($font !== null) { foreach ($font['otf'] as $name => $path) { $content .= '<item id="' . $font['name'] . $name . '" href="fonts/' . $font['name'] . $name . '.otf" media-type="font/opentype" />' . "\n"; } } if ($book->content) { $content .= '<item id="' . $book->title . '" href="' . $book->title . '.xhtml" media-type="application/xhtml+xml" />' . "\n"; } foreach ($book->chapters as $chapter) { $content .= '<item id="' . $chapter->title . '" href="' . $chapter->title . '.xhtml" media-type="application/xhtml+xml" />' . "\n"; foreach ($chapter->chapters as $subpage) { $content .= '<item id="' . $subpage->title . '" href="' . $subpage->title . '.xhtml" media-type="application/xhtml+xml" />' . "\n"; } } foreach ($book->pictures as $pictureId => $picture) { $content .= '<item id="' . $picture->title . '" href="images/' . $picture->title . '" media-type="' . $picture->mimetype . '"'; if ($book->cover === $pictureId) { $content .= ' properties="cover-image"'; } $content .= ' />' . "\n"; } $content .= '<item id="about" href="about.xhtml" media-type="application/xhtml+xml" /> </manifest> <spine toc="ncx">'; if ($book->cover != '') { $content .= '<itemref idref="cover" linear="no" />'; } $content .= '<itemref idref="title" linear="yes" />'; if ($book->content) { $content .= '<itemref idref="' . $book->title . '" linear="yes" />'; } if (!empty($book->chapters)) { foreach ($book->chapters as $chapter) { $content .= '<itemref idref="' . $chapter->title . '" linear="yes" />'; foreach ($chapter->chapters as $subpage) { $content .= '<itemref idref="' . $subpage->title . '" linear="yes" />'; } } } $content .= '<itemref idref="about" linear="yes" /> </spine> </package>'; return $content; }
protected function getCss(Book $book) { $css = FontProvider::getCss($book->options['fonts'], 'fonts/'); $css .= getTempFile($book->lang, 'epub.css'); return $css; }