/** * create the file * @var $data Book the content of the book * @return string */ public function create(Book $book) { $oldBookTitle = $book->title; $css = $this->getCss($book); $this->i18n = getI18n($book->lang); setlocale(LC_TIME, $book->lang . '_' . strtoupper($book->lang) . '.utf8'); $wsUrl = wikisourceUrl($book->lang, $book->title); $cleaner = new BookCleanerEpub($this->getVersion()); $cleaner->clean($book, wikisourceUrl($book->lang)); $fileName = buildTemporaryFileName($book->title, 'epub'); $zip = $this->createZipFile($fileName); $zip->addFromString('META-INF/container.xml', $this->getXmlContainer()); $zip->addFromString('OPS/content.opf', $this->getOpfContent($book, $wsUrl)); $zip->addFromString('OPS/toc.ncx', $this->getNcxToc($book, $wsUrl)); if ($book->cover != '') { $zip->addFromString('OPS/cover.xhtml', $this->getXhtmlCover($book)); } $zip->addFromString('OPS/title.xhtml', $this->getXhtmlTitle($book)); $zip->addFromString('OPS/about.xhtml', $this->getXhtmlAbout($book, $wsUrl)); $dir = __DIR__; $zip->addFile($dir . '/images/Accueil_scribe.png', 'OPS/images/Accueil_scribe.png'); $font = FontProvider::getData($book->options['fonts']); if ($font !== null) { foreach ($font['otf'] as $name => $path) { $zip->addFile($dir . '/fonts/' . $font['name'] . '/' . $path, 'OPS/fonts/' . $font['name'] . $name . '.otf'); } } if ($book->content) { $zip->addFromString('OPS/' . $book->title . '.xhtml', $book->content->saveXML()); } if (!empty($book->chapters)) { foreach ($book->chapters as $chapter) { $zip->addFromString('OPS/' . $chapter->title . '.xhtml', $chapter->content->saveXML()); foreach ($chapter->chapters as $subpage) { $zip->addFromString('OPS/' . $subpage->title . '.xhtml', $subpage->content->saveXML()); } } } foreach ($book->pictures as $picture) { $zip->addFromString('OPS/images/' . $picture->title, $picture->content); } $zip->addFromString('OPS/main.css', $css); $this->addContent($book, $zip); $book->title = $oldBookTitle; $zip->close(); return $fileName; }
protected function translateI18n($v341be97d9aff90c9978347f66f945b77, $v240bf022e685b0ee30ad9fe9e1fb5d5b = "") { $vd304ba20e96d87411588eeabac850e34 = getI18n($v341be97d9aff90c9978347f66f945b77, $v240bf022e685b0ee30ad9fe9e1fb5d5b); return is_null($vd304ba20e96d87411588eeabac850e34) ? $v341be97d9aff90c9978347f66f945b77 : $vd304ba20e96d87411588eeabac850e34; }