}
$res = '';
- if ($v1) {
- fb(time(), 'Compile V1');
- $res .= $this->compile1($book_id, $book, $pages);
- $this->touchCompile($book_id, '1');
- }
- if ($v2) {
- fb(time(), 'Compile V2');
- $res .= $this->compile3($book_id, $complete, $book, $pages);
- $this->touchCompile($book_id, '2');
- }
if ($html5) {
fb(time(), 'Compile HTML5');
+ $this->compilePDF($book, $pages);
$res .= $this->compileHTML5($book_id, $book, $dev, $delete);
$this->touchCompile($book_id, 'html5');
}
- if ($v1 || $v2) {
- fb(time(), 'Compile PDF & Widget');
- $this->compilePDF($book, $pages);
- $this->compileWidget($book, $pages);
- }
fb(time(), 'End Compile');
return $res;
}
- public function compile1($book_id, $book, $pages)
- {
- $finalDir = WS_BOOKS . '/finalv1/' . $book_id . '/';
- $packager = new wsPackagerV1($book_id, $finalDir, false);
- $packager->makePackage(false);
- }
-
- public function compile3($book_id, $complete, $book, $pages)
- {
- $res = '';
-
- $compilerDir = WS_BOOKS . '/datasCompiler/' . $book_id . '/';
- $finalDir = WS_BOOKS . '/final/' . $book_id . '/';
-
- $vdir = new CubeIT_Files_VirtualDirectory($finalDir);
-
- $debug = false;
-
- $flex = new cubeFlexCompiler('FluidbookDatas', $compilerDir, 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH, 10, 30, 800, 600, $debug);
- $flexLight = new cubeFlexCompiler('FluidbookDatasLight', $compilerDir, 'flash.display.Sprite', explode(';', AS3_SOURCES), MXMLC_PATH, 10, 30, 800, 600, $debug);
-
- $filesToCopy = array();
- $this->compileFlex($book_id, $complete, $compilerDir, $vdir, $filesToCopy, $book, $pages, $flex, $flexLight, $finalDir);
-
- $res .= $flex->compile() . "\n\n-------------------\n\n";
- $flexLight->addVariable('datasSize', filesize($compilerDir . '/FluidbookDatas.swf'));
- $res .= $flexLight->compile();
-
- $filesToCopy['data/fd.swf'] = $compilerDir . '/FluidbookDatas.swf';
- $filesToCopy['data/fdl.swf'] = $compilerDir . '/FluidbookDatasLight.swf';
-
- // Copy of files
- // Check if dest dir exists
-
- foreach ($filesToCopy as $local => $source) {
- $localPath = $local;
- $vdir->copy($source, $localPath);
- }
-
- $workingDir = WS_BOOKS . '/working/' . $book_id . '/';
- $vdir->copyDirectory($workingDir . 'media', 'data');
- $vdir->sync(true);
-
- return $res;
- }
-
public function copy($source, $dest)
{
if (!file_exists($source)) {
return $pages[$book_page];
}
- public function compileAir($book_id)
- {
- $compilerDir = WS_BOOKS . '/air/' . $book_id . '/compiler';
- $finalDir = WS_BOOKS . '/air/' . $book_id . '/';
-
- $book = $this->selectById($book_id);
- $pages = $this->getPagesOfBook($book_id);
-
- $src = AS3_FLUIDBOOK_SOURCES . '/_src/';
- $lib10 = AS3_FLUIDBOOK_SOURCES . '/lib10/';
- $libs = array(
- $src,
- $lib10,
- AS3_SOURCES,
- $src . 'lib/fluidbook3dLibrary.swc',
- $src . 'lib/mdm.swc',
- $lib10 . 'flash.swc',
- $lib10 . 'flex.swc',
- $lib10 . 'framework.swc',
- );
-
- wsSVN::updateToLastRevision();
-
- $swf = 'FluidbookAirProjector' . $book_id;
- $flex = new cubeFlexCompiler($swf, $compilerDir, 'com.fluidbook.player.AIRMain', $libs, '/usr/local/flex/bin/mxmlc', 'air', 45, 800, 600, true);
-
- $this->compileFlex($book_id, true, $compilerDir, $finalDir, $filesToCopy, $book, $pages, $flex, $flex);
- $res = $flex->compile();
-
- $air = new cubeAIRCompiler($swf . '.swf', '/usr/local/flex/bin', $compilerDir, '2.0');
- $air->setApplicationDatas('com.fluidbook' . $book_id, $book->parametres->title, $book->parametres->title, cubeText::str2URL($book->parametres->title), $book->lang);
- $air->setInitialWindow($book->parametres->title);
- $res .= $air->compile();
-
- return $res;
- }
-
- public function compileFlex($book_id, $complete, $compilerDir, $vdir, &$filesToCopy, $book, $pages, $flex, $flexLight)
- {
- /* @var $vdir CubeIT_Files_VirtualDirectory */
-
- cubePHP::neverStop();
- /* @var $flex cubeFlexCompiler */
-
- $workingDir = WS_BOOKS . '/working/' . $book_id . '/';
-
- $res = '';
-
- $daoDoc = new wsDAODocument($this->con);
- $firstDoc = $daoDoc->selectById($pages[1]['document_id']);
- $size = $firstDoc->generalInfos['size'];
-
- $daoLang = new wsDAOLang($this->con);
- $lang = $daoLang->selectById($book->lang);
-
- $langs = $daoLang->selectAll();
-
- $daoTheme = new wsDAOTheme($this->con);
- $theme = $daoTheme->getThemeOfBook($book_id, true);
-
- $index = '';
- $textes = '';
- $pageLabels = array();
-
- $hash = $book_id;
- $hash .= 'kjgl!az4.';
- $hash .= count($pages);
- $hash .= round($size[0], 3);
-
- $hash = sha1($hash);
-
- $this->makeTextsIndexes($book, $pages, $index, $textes);
-
- wsLinks::getLinksAndRulersFromFile($book_id, $links, $rulers);
-
- $audiodescription = array();
-
- $imagesassets = array();
- $id = 1;
- $ignoreLinks = array();
- foreach ($links as $id => $link) {
- $links[$id]['id'] = $id;
- $skipCopyAsset = false;
-
- if (isset($link['image']) && $link['image']) {
- $workingFile = $workingDir . '/' . $link['image'];
- $assetId = 'link_datas_i_' . md5($link['image']);
-
- if (isset($imagesassets[$assetId])) {
-
- } else {
- if (file_exists($workingFile)) {
- if ($link['page'] <= 1) {
- $flexLight->addBitmap($workingFile, $assetId);
- } else {
- $flex->addBitmap($workingFile, $assetId);
- }
- }
- $imagesassets[$assetId] = true;
- }
- }
-
- if ($link['type'] == 16 && $book->parametres->linkFilePrefix) {
- if (!CubeIT_Util_Url::isDistant($link['to'])) {
- $skipCopyAsset = true;
- $links[$id]['to'] = $book->parametres->linkFilePrefix . $link['to'];
- }
- }
-
- if ($link['type'] == 15) {
- if (isset($imagesassets[$id])) {
- continue;
- }
- if ($link['page'] <= 1) {
- $flexLight->addBitmap($workingDir . '/' . $link['to'], 'link_datas_' . $id);
- } else {
- $flex->addBitmap($workingDir . '/' . $link['to'], 'link_datas_' . $id);
- }
- $imagesassets[$id] = true;
- } else if (in_array($link['type'], array(4, 6, 7, 9, 16, 17, 25))) {
- if (!$skipCopyAsset) {
- $workingFile = $workingDir . '/' . $link['to'];
- if (file_exists($workingFile)) {
- $filesToCopy['data/' . $link['to']] = $workingFile;
- }
-
- if ($link['type'] == 4) {
- $poster = $link['to'];
- $e = explode('.', $poster);
- array_pop($e);
- array_push($e, 'jpg');
- $poster = implode('.', $e);
-
- $workingFile = $workingDir . '/' . $poster;
- if (file_exists($workingFile)) {
- $filesToCopy['data/' . $poster] = $workingFile;
- }
- }
- }
- }
-
- if ($link['type'] == 25) {
- $audiodescription[$link['page']] = $link['to'];
- $ignoreLinks[] = $id;
- }
- if ($link['type'] == 26) {
- $pageLabels[$link['to']] = $link['page'];
- $ignoreLinks[] = $id;
- }
- }
-
- foreach ($ignoreLinks as $ignoreLink) {
- unset($links[$ignoreLink]);
- }
- $links = array_values($links);
-
- $externalsOptions = array('ongletsSWF', 'tabs2DSWF', 'externalChapters', 'externalArchives', 'ambientSound');
- foreach ($externalsOptions as $e) {
- if (isset($book->parametres->$e) && $book->parametres->$e != '') {
- $f = $workingDir . '/' . $book->parametres->$e;
- if (file_exists($f)) {
- $filesToCopy['data/' . $book->parametres->$e] = $f;
- }
- }
- }
-
- $flex->addVariable('audiodescription', $audiodescription, false, true, "JSONObject");
- $flex->addVariable('pagelabels', $pageLabels, false, true, 'JSONObject');
- $flex->addVariable('links', $links, false, true, 'JSONObject');
- $flexLight->addVariable('datas', $book->parametres->toStandardObject(), false, true, 'JSONObject');
- $flexLight->addVariable('id', $book_id, false, true, 'uint');
- $flexLight->addVariable('cid', $book->cid, false, true, 'String');
-
- $traductions = (!count($book->traductions)) ? $lang->traductions : $book->traductions;
- $allTraductions = array();
- foreach ($langs as $l) {
- $allTraductions[$l->lang_id] = $l->traductions;
- }
-
- $flex->addVariable('traductions', $traductions, false, true, 'JSONObject', false);
- $flex->addVariable('allTraductions', $allTraductions, false, true, 'JSONObject');
- $flex->addVariable('chapters', $book->chapters, false, true, 'JSONObject');
- $flex->addVariable('extras', '<extras>' . $book->extras . '</extras>', false, true, 'XML');
- $flex->addVariable('numerotation', $book->numerotation, false, true, 'String');
- $flexLight->addVariable('theme', $theme->parametres->toStandardObject(), false, true, 'JSONObject');
- $flexLight->addVariable('pages', $book->parametres->pages);
- $flexLight->addVariable('fwidth', round($size[0], 4), false, true, 'Number');
- $flexLight->addVariable('fheight', round($size[1], 4), false, true, 'Number');
- $flexLight->addVariable('pagesInDatas', $complete, false, true, 'Boolean');
- $flex->addVariable('index', $index, false, true, 'JSONObject', false, false);
- $flex->addVariable('textes', $textes, false, true, 'JSONObject', false, false);
-
- $rasterized = array();
- $sizes = array();
-
- foreach ($pages as $i => $infos) {
- $base = wsDocument::getDir($infos['document_id']) . 'p' . $infos['document_page'];
- $baset = wsDocument::getDir($infos['document_id']) . 't' . $infos['document_page'];
- $swffile = $base . '.swf';
- if (file_exists($swffile)) {
- clearstatcache(true, $swffile);
- $fsize = filesize($swffile);
- } else {
- $fsize = 0;
- }
-
- if ($complete) {
- $flex->addSWF($swffile, 'page' . $i);
- } else {
- $filesToCopy['data/p' . $i . '.swf'] = $swffile;
- if ($infos['method'] >= wsDocument::BARBARE_PNM) {
- $rasterized[$i] = true;
- $filesToCopy['data/t' . $i . '.swf'] = $baset . '.swf';
- } else {
- $rasterized[$i] = false;
- }
- }
-
- $thumb = false;
- if ($book->parametres->pdfThumbnails) {
- $thumb = wsPDFConvert::getThumbFromPDF($workingDir . '/' . $book->parametres->pdfThumbnails, $i);
- }
- if (!$thumb) {
- $thumb = $base . '.jpg';
- }
-
- if ($i == 1) {
- $flexLight->addBitmap($thumb, 'thumb1');
- } else {
- $flex->addBitmap($thumb, 'thumb' . $i);
- }
- $sizes[$i] = $fsize;
- }
-
- $flexLight->addVariable('rasterized', $rasterized, false, true, 'JSONObject');
- $flexLight->addVariable('sizes', $sizes, false, true, 'JSONObject');
-
- if ($book->parametres->soundTheme != '') {
- $flex->addSound(WS_SOUNDS . '/' . $book->parametres->soundTheme . '/corner-drag.mp3', 'soundDragCorner');
- $flex->addSound(WS_SOUNDS . '/' . $book->parametres->soundTheme . '/corner-release.mp3', 'soundReleaseCorner');
- $flex->addSound(WS_SOUNDS . '/' . $book->parametres->soundTheme . '/page-flip-1.mp3', 'soundPage0');
- $flex->addSound(WS_SOUNDS . '/' . $book->parametres->soundTheme . '/page-flip-2.mp3', 'soundPage1');
- $flex->addSound(WS_SOUNDS . '/' . $book->parametres->soundTheme . '/cover-flip.mp3', 'soundCover0');
- }
- // Theme assets
- $themeRoot = WS_THEMES . '/' . $theme->theme_id . '/';
-
- if ($theme->parametres->backgroundImage != '') {
- $flexLight->addBitmap($themeRoot . $theme->parametres->backgroundImage, 'background');
- }
- if ($theme->parametres->menuImage != '') {
- $flex->addBitmap($themeRoot . $theme->parametres->menuImage, 'menu');
- }
- if ($theme->parametres->logoLoader != '') {
- $flexLight->addBitmap($themeRoot . $theme->parametres->logoLoader, 'logoLoader');
- }
- if ($theme->parametres->topBar != '') {
- $flexLight->addBitmap($themeRoot . $theme->parametres->topBar, 'topBar');
- }
- if ($theme->parametres->logo != '') {
- $flex->addBitmap($themeRoot . $theme->parametres->logo, 'logo');
- }
- if ($theme->parametres->afterSearch != '') {
- $flex->addBitmap($themeRoot . $theme->parametres->afterSearch, 'aftersearch');
- }
- if ($theme->parametres->favicon != '') {
- $filesToCopy['data/fluidbook.ico'] = $themeRoot . 'fluidbook.ico';
- }
-
- // Icons assets
- $iconsRoot = WS_ICONS . '/' . $theme->parametres->iconSet . '/';
- foreach (wsIcone::$files as $file) {
- $flex->addBitmap($iconsRoot . 'nav-' . $file . '.png', 'nav_' . $file);
- }
- // Share icons
- $iconsRoot = WS_ICONS . '/share/';
- foreach (wsIcone::$share as $file) {
- $flex->addBitmap($iconsRoot . 'share-' . $file . '.png', 'share_' . $file);
- }
-
- // Multilang
- if (trim($book->parametres->multilang) != '') {
- $m = str_replace("\r", "\n", trim($book->parametres->multilang));
- $langs = explode("\n", $m);
- $langNames = array();
- $countryNames = array();
- $iso = l10n::getISOcodes();
- $chars = '()';
- $vuFlags = array();
- foreach ($langs as $l) {
- list($mlang, $flag, $url) = explode(',', trim($l), 3);
- if (!isset($vuFlags[$flag])) {
- $flex->addBitmap(cubeMedia::getFlagFile($flag), 'flag_' . $flag);
- $vuFlags[$flag] = true;
- }
- $ll = explode('-', $mlang);
- $n = cubeText::ucfirst($iso[$ll[0]]);
- $langNames[$mlang] = $n;
- $cn = cubeCountry::getCountryName($flag, $mlang);
- $countryNames[$mlang . '_' . $flag] = $cn;
- $chars .= $n . $cn;
- }
-
- $chars = preg_split('/(?<!^)(?!$)/u', $chars);
- $chars = array_unique($chars);
-
- $flex->addFont(WS_FILES . '/fonts/FluidbookMultilang.ttf', 'MultilangFont', $chars);
- $flex->addVariable('langNames', $langNames, false, true, 'JSONObject');
- $flex->addVariable('countryNames', $countryNames, false, true, 'JSONObject');
- }
- $flexLight->addVariable('lang', $book->lang);
-
- // Basket
- if ($book->parametres->basket) {
- $formats = array('jpg', 'png', 'jpeg');
- $referencesFile = self::getWorkingFile($book->parametres->basketReferences, $book_id, 'commerce');
-
- if (file_exists($referencesFile) || CubeIT_Util_Url::isDistant($referencesFile)) {
- $ext = CubeIT_Files::getExtension($referencesFile);
- if ($ext == 'xml') {
- $xml = simplexml_load_file($referencesFile);
- $i = 0;
- $allref = array();
- foreach ($xml->item as $item) {
- $ref = (string)$item['reference'];
- if (isset($allref[$ref])) {
- continue;
- }
- $allref[$ref] = true;
- foreach ($formats as $f) {
- $refimage = $workingDir . 'commerce/' . $ref . '.' . $f;
- if (file_exists($refimage)) {
- $flex->addBitmap($refimage, "basket_image_" . $ref);
- break;
- }
- }
- $i++;
- }
- } elseif ($ext == 'xlsx') {
- $references = wsUtil::excelToArray($referencesFile);
- if ($book->parametres->customLinkClass == 'AtlanticDownloadLink') {
- $references = wsUtil::atlanticReferences($references, 'local/', null, array($vdir, 'copy'));
- }
- $flex->addVariable('basketReferences', $references, false, true, "OrderedObject");
- }
- }
- if (isset($xml)) {
- $flex->addVariable('basketReferences', cubeXML::condense($xml->asXML()), false, true, "String");
- }
- if ($book->parametres->basketPDFBackground != '') {
- $flex->addByteArray($workingDir . 'commerce/' . $book->parametres->basketPDFBackground, 'basket_pdf_background');
- }
- }
- // Fonts
- if ($theme->parametres->fontKit == 'auto') {
- if ($lang->font != 'system') {
- $font = FONT_PATH . '/' . $lang->font;
- $bfont = FONT_PATH . '/B' . $lang->font;
- if (!file_exists($bfont)) {
- $bfont = $font;
- }
-
- $flex->addFont($bfont, 'BoldFont', $lang->charset);
- $flex->addFont($font, 'GeneralFont', $lang->charset);
- }
- $flex->addFont(FONT_PATH . '/FluidbookCredits.ttf', 'CreditsFont', 'ASCII');
- $flexLight->addFont(FONT_PATH . '/FluidbookLoader.ttf', 'LoaderFont', 'Numerals');
- } else if ($theme->parametres->fontKit == 'vagrounded') {
- $flex->addFont(FONT_PATH . '/vagrounded/VAGRoundedStd-Bold.otf', 'BoldFont', $lang->charset);
- $flex->addFont(FONT_PATH . '/vagrounded/VAGRoundedStd-Light.otf', 'GeneralFont', $lang->charset);
- $flex->addFont(FONT_PATH . '/FluidbookCredits.ttf', 'CreditsFont', 'ASCII');
- $flexLight->addFont(FONT_PATH . '/vagrounded/VAGRoundedStd-Bold.otf', 'LoaderFont', 'Numerals');
- } else if ($theme->parametres->fontKit == 'gill') {
- $flex->addFont(FONT_PATH . '/gill/gill.ttf', 'BoldFont', $lang->charset);
- $flex->addFont(FONT_PATH . '/gill/gill.ttf', 'GeneralFont', $lang->charset);
- $flex->addFont(FONT_PATH . '/FluidbookCredits.ttf', 'CreditsFont', 'ASCII');
- $flexLight->addFont(FONT_PATH . '/gill/gill.ttf', 'LoaderFont', 'Numerals');
- }
-
- $flexLight->addVariable('checksum', $hash, false, true, 'String');
- }
-
-
public static function getWorkingFile($path, $book_id, $dir = "")
{
if (CubeIT_Util_Url::isDistant($path) || (substr($path, 0, 1) == '/' && file_exists($path))) {
return $workingDir . trim($dir, '/') . '/' . $path;
}
- public function compileWidget($book, $pages)
- {
- if (!$book->parametres->widget) {
- return;
- }
-
- global $core;
-
- $finalDir = WS_BOOKS . '/final/' . $book->book_id . '/widget/';
- $finalWidget = $finalDir . 'miniFluidbook.swf';
-
- if (!file_exists($finalDir)) {
- mkdir($finalDir, 0777, true);
- }
-
- if ($book->parametres->widgetCover) {
- $file = 'miniFluidbookCouv.swf';
- } else {
- $file = 'miniFluidbook.swf';
- }
- $mini = WS_COMPILE_ASSETS . '/_widget/' . $file;
-
- $from = max(1, $book->parametres->widgetStart);
- $to = min($book->parametres->widgetEnd, count($pages));
-
- $swfcombine = new cubeCommandLine('swfcombine');
- $swfcombine->setPath(CONVERTER_PATH);
- $swfcombine->setArg('merge');
- $swfcombine->setArg('stack1');
- $swfcombine->setArg('z');
- $swfcombine->setArg('o', $finalWidget);
- $swfcombine->setArg(null, $mini);
-
- $tempimage = array();
- $tempswf = array();
- $timg = array();
-
- for ($i = $from; $i <= $to; $i++) {
- $page = $pages[$i];
-
- $timg[$i] = $tempimage[$i] = cubeFiles::tempnam();
- $tempswf[$i] = cubeFiles::tempnam();
-
- $it = new imageTools();
- $image = wsDocument::getDir($page['document_id']) . '/html/t150-' . $page['document_page'] . '.jpg';
-
- try {
- $it->loadImage($image);
- $it->resize($book->parametres->widgetSize, 10000);
- $it->output('jpeg', $tempimage[$i], 100);
- } catch (Exception $e) {
- $tempimage[$i] = $image;
- }
- $jpg2swf = new cubeCommandLine('jpeg2swf');
- $jpg2swf->setEnv('PATH', '/bin:/usr/bin:/usr/local/bin');
- $jpg2swf->setArg('q', $book->parametres->widgetQuality);
- $jpg2swf->setArg('o', $tempswf[$i]);
- $jpg2swf->setArg(null, $tempimage[$i]);
- $jpg2swf->execute();
-
- $swfcombine->setArg(null, $tempswf[$i]);
- }
- $swfcombine->execute();
-
- foreach ($timg as $t) {
- if (file_exists($t)) {
- unlink($t);
- }
- }
- foreach ($tempswf as $t) {
- unlink($t);
- }
- }
-
public function compileHTML5($book_id, $book, $dev = false, $delete = true)
{
$version = $book->parametres->mobileLVersion;
+++ /dev/null
-<?php
-
-class wsPackagerV1 extends wsPackagerHTML {
-
- protected $size;
-
- public function __construct($book_id, $vdir = null, $whole = true) {
- global $core;
-
- parent::__construct($book_id, $vdir, $whole);
- $this->version = 'v1';
-
- $daoDoc = new wsDAODocument($core->con);
- $firstDoc = $daoDoc->selectById($this->pages[1]['document_id']);
- $this->size = $firstDoc->generalInfos['size'];
- }
-
- protected function getMinFlashVersion() {
- return '8';
- }
-
- protected function getSWFFiles() {
- return array('_v1/index.swf' => 'index.swf');
- }
-
- protected function compile() {
-
- }
-
- 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();
- $this->copyLang();
- }
-
- protected function copyThumbnails() {
- foreach ($this->pages as $book_page => $infos) {
- $this->copy(wsDocument::getDir($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 = wsDocument::getDir($infos['document_id']) . 'p' . $infos['document_page'] . '.txt';
- if (file_exists($ftext)) {
- $xml->addChild('pageText', htmlspecialchars(CubeIT_Util_Gzip::file_get_contents($ftext)));
- } else {
- $xml->addChild('pageText', ' ');
- }
- }
-
- file_put_contents($this->vdir . '/data/texts.xml', $xml->asXML());
- }
-
- protected function getFlashvars() {
- return array('id' => $this->book_id,
- 'mail' => '0',
- 'onlineFlag' => '1',
- 'loaderColor' => $this->theme->parametres->loadingBackColor);
- }
-
- 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>');
- wsLinks::getLinksAndRulersFromFile($this->book_id, $links, $rulers);
-
- foreach ($links as $link) {
- $one = $xml->addChild('oneLink');
- $link['type'] = intval($link['type']);
-
- if ($link['page'] % 2 == 1) {
- $link['page']--;
- $link['left'] = $link['left'] + $this->size[0];
- }
-
- if ($link['type'] == 4 && !$link['inline']) {
- $link['type'] = 1;
- $link['to'] .= '$' . $link['video_width'] . '$' . $link['video_height'];
- }
-
- 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']);
- }
-
- if ($this->_copyWorkingFile($link['to']) && !in_array($link['type'], array(4, 6))) {
- $link['to'] = 'data/' . $link['to'];
- }
-
- $one->addChild('page', $link['page']);
- $one->addChild('linkType', $link['type']);
- $one->addChild('linkTo', htmlspecialchars($link['to']));
- $one->addChild('startX', $link['left']);
- $one->addChild('endX', $link['left'] + $link['width']);
- $one->addChild('startY', $link['top']);
- $one->addChild('endY', $link['top'] + $link['height']);
- $one->addChild('tooltip', $link['infobulle']);
- if ($link['type'] == 4) {
- $one->addChild('soundOn', $link['video_sound_on']);
- $one->addChild('loopFlag', $link['video_loop']);
- $one->addChild('playerActive', $link['video_auto_start']);
- }
- }
-
- 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,
- 'readingDir' => 'ltr',
- 'ws' => '2');
-
- $booleans = array('pdfFlag', 'printFlag', 'searchFlag', 'sendfriendFlag', 'bookmarkFlag', 'emailEditable');
-
- $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($this->size[0], 2);
- $allParams['height'] = round($this->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') - 1;
-
- $xtra = simplexml_load_string('<?xml version="1.0" encoding="UTF-8" ?><extras>' . $this->book->parametres->extras . '</extras>');
- foreach ($xtra as $xt) {
- $k = $xt->getName();
- $v = (string)$xt;
- $allParams[$k] = $v;
- }
-
- 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];
- }
-
- if (in_array($k, $booleans)) {
- $v = $v ? 'true' : 'false';
- }
-
- $this->_copyWorkingFile($v);
-
- if ($k != 'extras') {
- $xml->addChild($k, html::escapeHTML($v));
- }
- $extras->addChild($k, html::escapeHTML($v));
- }
-
- $colors = $xml->addChild('colors');
- $colors->addChild('color', '0x' . $allParams['couleurA']);
- $colors->addChild('color', '0x' . $allParams['couleurB']);
- $colors->addChild('color', '0x' . $allParams['couleurS']);
-
- if ($this->book->parametres->v1SWF != '') {
- $this->_copyWorkingFile($this->book->parametres->v1SWF, $this->vdir);
- }
-
- if (!file_exists($this->vdir . '/index.swf')) {
- $this->_copyWorkingFile(WS_COMPILE_ASSETS . '/_v1/index.swf', $this->vdir);
- }
- file_put_contents($this->vdir . '/data/data.xml', $xml->asXML());
- }
-
- public function copyTheme() {
- $files = array('logoLoader' => 'logoLoader.png',
- 'backgroundImage' => 'backgroundImg.jpg',
- 'logo' => 'menu_clientLogo.png',
- 'menuImage' => 'menu_back.png');
-
- $images = $this->vdir . '/images';
- if (!file_exists($images)) {
- mkdir($images, 0777, true);
- }
-
- foreach ($files as $param => $file) {
- $src = $this->themeRoot . '/' . $this->theme->parametres->$param;
- if (!file_exists($src) || !is_file($src)) {
- $src = WS_THEMES . '/spacer.png';
- }
- $this->copy($src, $images . '/' . $file);
- }
-
- $cp = new cubeCommandLine('cp');
- $cp->setArg(null, WS_ICONS . '/' . $this->theme->parametres->iconSet . '/v1/*');
- $cp->setArg(null, $this->vdir . '/images');
- $cp->execute();
- }
-
- protected function copyLang() {
- global $core;
- $mapping = wsLang::$idtonew;
-
- $daoLang = new wsDAOLang($core->con);
- $lang = $daoLang->selectById($this->book->lang);
-
- $xml = $lang->getV1XML();
- file_put_contents($this->vdir . '/data/lang.xml', $xml->asXML());
- }
-
- protected function _copyWorkingFile($file, $dir = null) {
-
- $e = explode("$", $file);
- $file = array_shift($e);
- if (is_null($dir)) {
- $dir = $this->vdir . '/data/';
- }
-
- $src = $this->workingDir . '/' . $file;
- if (file_exists($src) && is_file($src)) {
- $res = $this->copy($src, $dir . $file);
- return $res;
- }
- return false;
- }
-
- protected function __virtualToPhysical($page, $default = '') {
- $n = explode(',', $this->book->numerotation);
- $keys = array_keys($n, $page);
- if (count($keys)) {
- return $keys[0] + 1;
- }
- return $default;
- }
-
-}
-
-?>