$this->version = 'html';\r
}\r
\r
+ protected function getMinFlashVersion() {\r
+ return '10.0.22';\r
+ }\r
+\r
+ protected function getSWFFiles() {\r
+ return array('index.swf', 'player.swf');\r
+ }\r
+\r
protected function preparePackage() {\r
parent::preparePackage();\r
\r
$this->copyFluidbookFiles();\r
$this->mergeJavascript();\r
\r
- $this->copyOtherFiles(array('fluidbook.js', 'getflash.gif', 'index.html', 'index.swf', 'player.swf', 'style.css'));\r
+ $others = array('fluidbook.js', 'getflash.gif', 'index.html', 'style.css');\r
+ $others = array_merge($others, $this->getSWFFiles());\r
+\r
+ $this->copyOtherFiles($others);\r
\r
mkdir($this->vdir . '/pages/', 0777, true);\r
\r
'redirectPDF' => $redirectPDF,\r
'junk' => TIME,\r
'robots' => $robots,\r
- 'favicon' => $favicon);\r
+ 'favicon' => $favicon,\r
+ 'flashversion' => $this->getMinFlashVersion());\r
\r
$this->origHTML = file_get_contents($this->vdir . '/index.html');\r
$this->origHTML = $this->replaceHTML($toReplace);\r
--- /dev/null
+<?php
+
+class wsPackagerV1 extends wsPackagerHTML {
+
+ public function __construct($book_id) {
+ parent::__construct($book_id);
+ $this->version = 'v1';
+ }
+
+ protected function getMinFlashVersion() {
+ return '8';
+ }
+
+ protected function getSWFFiles() {
+ return array('_v1/index.swf' => 'index.swf');
+ }
+
+ protected function copyFluidbookFiles() {
+ parent::copyFluidbookFiles();
+ unlink($this->vdir . '/data/fd.swf');
+ unlink($this->vdir . '/data/fdl.swf');
+
+ $this->copyThumbnails();
+ $this->copyTexts();
+ $this->copyLinks();
+ $this->copyConfig();
+ $this->copyTheme();
+ }
+
+ protected function copyThumbnails() {
+ foreach ($this->pages as $book_page => $infos) {
+ copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/p' . $book_page . '.jpg');
+ }
+ }
+
+ protected function copyTexts() {
+ $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8" ?><movie />');
+
+ foreach ($this->pages as $book_page => $infos) {
+ $ftext = WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.txt';
+ if (file_exists($ftext)) {
+ $xml->addChild('pageText', htmlspecialchars(file_get_contents($ftext)));
+ } else {
+ $xml->addChild('pageText', ' ');
+ }
+ }
+
+ file_put_contents($this->vdir . '/data/texts.xml', $xml->asXML());
+ }
+
+ protected function copyLinks() {
+ global $core;
+
+ /* <oneLink>
+ <page>0</page>
+ <linkType>0</linkType>
+ <linkTo>0</linkTo>
+ <startX>0</startX>
+ <endX>0</endX>
+ <startY>0</startY>
+ <endY>0</endY>
+ </oneLink> */
+
+ $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8" ?><links><oneLink /></links>');
+ $daoDoc = new wsDAODocument($core->con);
+ $daoDoc->getLinksAndRulers($this->book_id, $links, $rulers);
+
+ foreach ($links as $link) {
+ $one = $xml->addChild('oneLink');
+
+ if ($link['page'] % 2 == 1) {
+ $link['page']--;
+ $link['left']-=$this->book->parametres['width'];
+ }
+
+ if ($link['type'] > 6) {
+ if ($link['type'] == 15) {
+ $link['type'] = 6;
+ } else {
+ $link['type'] = 1;
+ }
+ }
+
+ if ($link['type'] == 5 && $link['numerotation'] == 'virtual') {
+ $link['to'] = $this->__virtualToPhysical($link['to']);
+ }
+
+ $one->addChild('page', $link['page']);
+ $one->addChild('linkTo', $link['to']);
+ $one->addChild('linkType', $link['type']);
+ $one->addChild('startX', $link['left']);
+ $one->addChild('endX', $link['left'] + $link['width']);
+ $one->addChild('startY', $link['top']);
+ $one->addChild('endY', $link['top'] + $link['height']);
+
+ $this->_copyWorkingFile($link['to']);
+ }
+
+ // Chapters
+ /*
+ * <chapters>
+ <page>3</page>
+ <level>0</level>
+ <txt>c</txt>
+ </chapters>
+ *
+ */
+
+ foreach ($this->book->chapters as $c) {
+ $chap = $xml->addChild('chapters');
+ $chap->addChild('page', $this->__virtualToPhysical($c['page']));
+ $chap->addChild('level', $c['level']);
+ $chap->addChild('txt', htmlspecialchars($c['label']));
+ }
+
+ file_put_contents($this->vdir . '/data/links.xml', $xml->asXML());
+ }
+
+ protected function copyConfig() {
+ global $core;
+
+ $mapping = array('width' => 'sizeX'
+ , 'height' => 'sizeY',
+ 'repeat' => 'patternFlag',
+ 'zoom' => 'maxZoom',
+ 'zoomw' => 'maxZoomScroll',
+ 'url_link' => 'logoLink',
+ 'pdf' => 'pdfFlag',
+ 'search' => 'searchFlag',
+ 'friend' => 'sendfriendFlag',
+ 'print' => 'printFlag',
+ 'bookmark' => 'bookmarkFlag',
+ 'email_title' => 'emailTitle',
+ 'email_body' => 'emailBody',
+ 'email_editable' => 'emailEditable',
+ );
+
+ $more = array('id' => $this->book_id,
+ 'pagesSplit' => 1,
+ 'pdfName' => 'document.pdf',
+ 'readingDir' => 'ltr');
+
+ $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8" ?><movie />');
+ $extras = $xml->addChild('extras');
+ $allParams = $more;
+ foreach ($this->book->parametres as $k => $v) {
+ $allParams[$k] = $v;
+ }
+ foreach ($this->theme->parametres as $k => $v) {
+ $allParams[$k] = $v;
+ }
+
+ $daoDoc = new wsDAODocument($core->con);
+ $firstDoc = $daoDoc->selectById($this->pages[1]['document_id']);
+ $size = $firstDoc->generalInfos['size'];
+
+ $allParams['width'] = round($size[0], 2);
+ $allParams['height'] = round($size[1], 2);
+
+
+ $daoSignature = new wsDAOSignature($core->con);
+ $s = $daoSignature->selectById($this->book->parametres->signature);
+ $signature = array('fbCredit' => $s->main,
+ 'fbLink' => $s->mainLink,
+ 'partnerCredit' => $s->partner,
+ 'partnerLink' => $s->partnerLink);
+
+
+ $allParams = array_merge($allParams, $signature);
+ $allParams['firstPageNr'] = $this->__virtualToPhysical('1');
+
+ foreach ($allParams as $k => $v) {
+ if ((stristr($k, 'color') || stristr($k, 'couleur')) && strlen($v) == 8) {
+ $v = substr($v, 2);
+ }
+ $allParams[$k] = $v;
+
+
+ if (isset($mapping[$k])) {
+ $k = $mapping[$k];
+ }
+
+ $this->_copyWorkingFile($v);
+
+ $xml->addChild($k, $v);
+ $extras->addChild($k, $v);
+ }
+
+ $colors = $xml->addChild('colors');
+ $colors->addChild('color', '0x' . $allParams['couleurA']);
+ $colors->addChild('color', '0x' . $allParams['couleurB']);
+ $colors->addChild('color', '0x' . $allParams['couleurS']);
+
+ file_put_contents($this->vdir . '/data/data.xml', $xml->asXML());
+ }
+
+ public function copyTheme() {
+
+ }
+
+ protected function _copyWorkingFile($file) {
+ $src = $this->workingDir . '/' . $file;
+ if (file_exists($src) && is_file($src)) {
+ copy($src, $this->vdir . '/data/' . $file);
+ }
+ }
+
+ protected function __virtualToPhysical($page, $default = '') {
+ $n = explode(',', $this->book->numerotation);
+ $keys = array_keys($n, $page);
+ if (count($keys)) {
+ return $keys[0];
+ }
+ return $default;
+ }
+
+}
+
+?>