Exemplo n.º 1
0
 /**
  * create the file
  * @var $data Book the title of the main page of the book in Wikisource
  * @return string
  */
 public function create(Book $book)
 {
     $outputFileName = buildTemporaryFileName($book->title, $this->getExtension());
     $epubFileName = $this->createEpub($book);
     $this->convert($epubFileName, $outputFileName);
     unlink($epubFileName);
     return $outputFileName;
 }
Exemplo n.º 2
0
 /**
  * create the file
  * @var $data Book the title of the main page of the book in Wikisource
  * @return string
  */
 public function create(Book $book)
 {
     $dom = new DOMDocument("1.0", "UTF-8");
     $entry = $this->buildEntry($book, $dom);
     $this->appendNamespaces($entry);
     $dom->appendChild($entry);
     $fileName = buildTemporaryFileName($book->title, 'atom');
     $dom->save($fileName);
     return $fileName;
 }
Exemplo n.º 3
0
 /**
  * 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;
 }