From: vincent@cubedesigners.com Date: Fri, 9 Oct 2020 15:14:21 +0000 (+0000) Subject: wip #3931 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=d1df1e6ebb51b3c1f0bfcabf7e5c981bc3c40ac0;p=cubeextranet.git wip #3931 @1.5 --- diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 5c74941b1..5a9fffb17 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -146,21 +146,12 @@ class wsUrl $res .= '' . $book->version . ''; } if ($book->version > 1 || $droits->admin) { - $types = []; - if (!$book->parametres->alwaysHTML5) { - $types[] = 'flash'; - $defaultPlayer = 'viewer'; - } else { - $defaultPlayer = 'viewerh'; - } - if ($book->parametres->mobileVersion != 'pdf') { - $types[] = 'html5'; - } + $types = ['html5']; + $defaultPlayer = 'viewerh'; if ($book->parametres->scorm_enable) { $types[] = 'scorm'; } - $res .= '' . $btVoir . ''; $res .= '' . $btEdit . ''; } else { @@ -553,19 +544,10 @@ class wsUrl $versions = array(); $versions['online'] = array('title' => __('Version online') . $default, 'icon' => cubeMedia::silk('page_world.png')); $versions['scorm'] = array('title' => __('Version SCORM') . $default, 'icon' => cubeMedia::silk('page_world.png')); - if ($chooseVersion) { - $versions['v1'] = array('title' => __('Version online') . ' - V1', 'icon' => cubeMedia::silk('page_white_world.png')); - $versions['v2'] = array('title' => __('Version online') . ' - V2', 'icon' => cubeMedia::silk('page_white_world.png')); - } - $versions['win-exe'] = array('title' => __('Version offline') . ' - ' . __('Executable Windows') . ' (Flash)', 'icon' => cubeMedia::silk('application_view_tile.png')); - $versions['win-inss-html'] = array('title' => __('Version offline') . ' - ' . __('Executable Windows') . ' (HTML5)', 'icon' => cubeMedia::silk('application_view_tile.png')); - $versions['win-ins'] = array('title' => __('Version offline') . ' - ' . __('Installeur Auto-executable Windows') . ' (Flash)', 'icon' => cubeMedia::silk('application_view_tile.png')); - $versions['win-ins-html'] = array('title' => __('Version offline') . ' - ' . __('Installeur Auto-executable Windows') . ' (HTML5)', 'icon' => cubeMedia::silk('application_view_tile.png')); - $versions['mac-exe'] = array('title' => __('Version offline') . ' - ' . __('Exécutable Mac OS X') . ' (Flash)', 'icon' => cubeMedia::image(IMG . '/macos.png')); - $versions['mac-exe-html'] = array('title' => __('Version offline') . ' - ' . __('Exécutable Mac OS X') . ' (HTML)', 'icon' => cubeMedia::image(IMG . '/macos.png')); - $versions['win-cd'] = array('title' => __('Version offline') . ' - ' . __('CD-ROM') . ' / ' . __('Clé USB') . ' (Flash)', 'icon' => cubeMedia::silk('cd.png')); - $versions['win-cd-html'] = array('title' => __('Version offline') . ' - ' . __('CD-ROM') . ' / ' . __('Clé USB') . ' (HTML)', 'icon' => cubeMedia::silk('cd.png')); - + $versions['win-inss-html'] = array('title' => __('Version offline') . ' - ' . __('Executable Windows'), 'icon' => cubeMedia::silk('application_view_tile.png')); + $versions['win-ins-html'] = array('title' => __('Version offline') . ' - ' . __('Installeur Auto-executable Windows'), 'icon' => cubeMedia::silk('application_view_tile.png')); + $versions['mac-exe-html'] = array('title' => __('Version offline') . ' - ' . __('Exécutable Mac OS X'), 'icon' => cubeMedia::image(IMG . '/macos.png')); + $versions['win-cd-html'] = array('title' => __('Version offline') . ' - ' . __('CD-ROM') . ' / ' . __('Clé USB'), 'icon' => cubeMedia::silk('cd.png')); $versions['win-html'] = array('title' => __('Version offline') . ' - ' . __('HTML') . ' (' . __('Non adaptée à l\'installation sur un serveur web') . ')', 'icon' => cubeMedia::silk('cd.png')); if ($droits->admin) { $versions['phonegap'] = array('title' => __('Version offline') . ' - ' . __('Application mobile'), 'icon' => cubeMedia::image(IMG . '/phonegap.png')); @@ -668,7 +650,7 @@ class wsUrl { global $core; - $viewers = array(array('type' => 'flash', 'version' => 'viewer', 'title' => __('Version Flash'), 'icon' => cubeMedia::image(IMG . '/flash.png')), + $viewers = array( array('type' => 'html5', 'version' => 'viewerh', 'title' => __('Version HTML5'), 'icon' => cubeMedia::image(IMG . '/html5.png')), array('type' => 'scorm', 'version' => 'viewers', 'title' => __('Version SCORM'), 'icon' => cubeMedia::image(IMG . '/html5.png')), ); @@ -772,7 +754,7 @@ class wsUrl public static function getTranslationSources() { - return array(__('Version Flash') => PLAYER_SOURCES, __('Version HTML5') => WS_COMPILE_ASSETS . '/player/local', __('Compilateur HTML5') => ROOT . '/inc/ws/Util/html5', __('Application') => WS_COMPILE_ASSETS . '/_html5app'); + return array(__('Version HTML5') => WS_COMPILE_ASSETS . '/player/local', __('Compilateur HTML5') => ROOT . '/inc/ws/Util/html5', __('Application') => WS_COMPILE_ASSETS . '/_html5app'); } public static function exportLangAsExcel($args) diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 0f64474bc..c7f1421a2 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -1218,77 +1218,17 @@ class wsDAOBook extends commonDAO } $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)) { @@ -1306,389 +1246,6 @@ class wsDAOBook extends commonDAO 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', '' . $book->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('/(?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))) { @@ -1699,80 +1256,6 @@ class wsDAOBook extends commonDAO 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; diff --git a/inc/ws/Util/packager/class.ws.packager.air.php b/inc/ws/Util/packager/class.ws.packager.air.php deleted file mode 100644 index f0d64a8ea..000000000 --- a/inc/ws/Util/packager/class.ws.packager.air.php +++ /dev/null @@ -1,16 +0,0 @@ - diff --git a/inc/ws/Util/packager/class.ws.packager.html.php b/inc/ws/Util/packager/class.ws.packager.html.php index 81c81ac05..7d91fc377 100644 --- a/inc/ws/Util/packager/class.ws.packager.html.php +++ b/inc/ws/Util/packager/class.ws.packager.html.php @@ -7,7 +7,6 @@ class wsPackagerHTML extends wsPackager protected $_labels = array(); protected $_allowNeworking = 'all'; protected $_ext = 'html'; - protected $_forceOnlyHtml = false; protected $_disableScorm = true; public function __construct($book_id, $vdir = null, $whole = true) @@ -30,26 +29,13 @@ class wsPackagerHTML extends wsPackager { parent::preparePackage(); - if ($this->_forceOnlyHtml) { - $this->book->parametres->alwaysHTML5 = true; - } + $this->book->parametres->alwaysHTML5 = true; if ($this->_disableScorm) { $this->book->parametres->scorm_enable = false; } - if ($this->book->parametres->mobilefirstFluidbookId != '') { - $this->book->parametres->alwaysHTML5 = true; - } $this->_ext = $this->book->parametres->htmlExtension; - if ($this->book->parametres->offlineExport && $this->book->parametres->pdfComplex) { - $versions = array('win-ins' => 'exe', 'mac-exe' => 'zip'); - foreach ($versions as $v => $ext) { - $a = wsPackager::package($this->book_id, $v); - rename(ROOT . $a, $this->vdir . '/data/document.' . $ext); - } - } - $this->copyFluidbookFiles(); $this->mergeJavascript(); diff --git a/inc/ws/Util/packager/class.ws.packager.mac.exe.php b/inc/ws/Util/packager/class.ws.packager.mac.exe.php deleted file mode 100644 index 4c08e5efb..000000000 --- a/inc/ws/Util/packager/class.ws.packager.mac.exe.php +++ /dev/null @@ -1,43 +0,0 @@ -version = 'mac-exe'; - $this->book->parametres->alwaysHTML5 = false; - - $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->title, 0, 30)); - } - - protected function preparePackage() - { - parent::preparePackage(); - - $this->copyFluidbookFiles(); - $this->copyOtherFiles(array('Fluidbook.app.zip')); - - $this->signApp(); - } - - public function makePackage($zip) - { - parent::makePackage($zip); - $res = $this->zip($this->vdir . 'Fluidbook.app.zip'); - $this->postPackage(); - return $res; - } - - public function getAppPath() - { - return $this->getFinalPackageDir() . '/Fluidbook.app'; - } - - protected function signApp() - { - wsPackagerMacEXEHTML::_signApp($this->getAppPath()); - } -} diff --git a/inc/ws/Util/packager/class.ws.packager.php b/inc/ws/Util/packager/class.ws.packager.php index 20f0ef254..06fc3800f 100644 --- a/inc/ws/Util/packager/class.ws.packager.php +++ b/inc/ws/Util/packager/class.ws.packager.php @@ -27,16 +27,6 @@ class wsPackager $packager = new wsPackagerHTML($book_id); } else if ($version == 'scorm') { $packager = new wsPackagerSCORM($book_id); - } elseif ($version == 'win-exe') { - $packager = new wsPackagerWinEXE($book_id); - } elseif ($version == 'win-cd') { - $packager = new wsPackagerWinCD($book_id); - } elseif ($version == 'win-ins') { - $packager = new wsPackagerWinINST($book_id); - } elseif ($version == 'mac-exe') { - $packager = new wsPackagerMacEXE($book_id); - } elseif ($version == 'v1') { - $packager = new wsPackagerV1($book_id); } elseif ($version == 'win-html') { $packager = new wsPackagerWinHTML($book_id); } else if ($version == 'phonegap') { diff --git a/inc/ws/Util/packager/class.ws.packager.scorm.php b/inc/ws/Util/packager/class.ws.packager.scorm.php index c68b0e68d..44744e5b6 100644 --- a/inc/ws/Util/packager/class.ws.packager.scorm.php +++ b/inc/ws/Util/packager/class.ws.packager.scorm.php @@ -6,7 +6,6 @@ class wsPackagerSCORM extends wsPackagerHTML { parent::__construct($book_id, $vdir, $whole); $this->version = 'scorm'; - $this->_forceOnlyHtml = true; $this->_disableScorm = false; } diff --git a/inc/ws/Util/packager/class.ws.packager.v1.php b/inc/ws/Util/packager/class.ws.packager.v1.php deleted file mode 100644 index a0e7d7f35..000000000 --- a/inc/ws/Util/packager/class.ws.packager.v1.php +++ /dev/null @@ -1,305 +0,0 @@ -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(''); - - 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; - - /* - 0 - 0 - 0 - 0 - 0 - 0 - 0 - */ - - $xml = simplexml_load_string(''); - 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(''); - $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('' . $this->book->parametres->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; - } - -} - -?> diff --git a/inc/ws/Util/packager/class.ws.packager.win.cd.php b/inc/ws/Util/packager/class.ws.packager.win.cd.php deleted file mode 100644 index 598c04805..000000000 --- a/inc/ws/Util/packager/class.ws.packager.win.cd.php +++ /dev/null @@ -1,33 +0,0 @@ -book->parametres->alwaysHTML5=false; - $this->version = 'win-cd'; - } - - protected function preparePackage() { - parent::preparePackage(); - - $this->copyOtherFiles(array( - 'fluidbook.ico' => 'data/fluidbook.ico', - 'autorun.inf', - 'Fluidbook.exe' => 'Windows-PC-' . $this->exeName . '.exe', - 'Fluidbook.app.zip')); - $this->replaceAutorun(); - } - - public function replaceAutorun() { - $inf = file_get_contents($this->vdir . 'autorun.inf'); - $toReplace = array('title' => $this->book->parametres->title, 'exe' => 'Windows-PC-' . $this->exeName . '.exe'); - $inf = $this->replaceContents($inf, $toReplace); - file_put_contents($this->vdir . 'autorun.inf', utf8_decode($inf)); - } - - protected function postPackage() { - - } - -} \ No newline at end of file diff --git a/inc/ws/Util/packager/class.ws.packager.win.exe.php b/inc/ws/Util/packager/class.ws.packager.win.exe.php deleted file mode 100644 index 819c1a8e3..000000000 --- a/inc/ws/Util/packager/class.ws.packager.win.exe.php +++ /dev/null @@ -1,33 +0,0 @@ -version = 'win-exe'; - $this->book->parametres->alwaysHTML5=false; - - if ($this->book->parametres->offlineTitle == "") { - $this->exeName = cubeText::str2URL(mb_substr($this->book->parametres->title, 0, 30)) . '.exe'; - } else { - $this->exeName = cubeText::str2URL($this->book->parametres->offlineTitle) . '.exe'; - } - } - - protected function preparePackage() { - parent::preparePackage(); - - $this->copyFluidbookFiles(); - $this->copyOtherFiles(array('Fluidbook.exe' => $this->exeName)); - } - - public function makePackage($zip) { - parent::makePackage($zip); - $res = $this->zip(); - $this->postPackage(); - return $res; - } - -} \ No newline at end of file diff --git a/inc/ws/Util/packager/class.ws.packager.win.inst.php b/inc/ws/Util/packager/class.ws.packager.win.inst.php deleted file mode 100644 index a0ec943e9..000000000 --- a/inc/ws/Util/packager/class.ws.packager.win.inst.php +++ /dev/null @@ -1,87 +0,0 @@ -version = 'win-ins'; - $this->book->parametres->alwaysHTML5 = false; - } - - protected function preparePackage() - { - parent::preparePackage(); - - $this->copyFluidbookFiles(); - $this->copyOtherFiles(array('Fluidbook.exe' => $this->exeName)); - - $this->makeNSI(); - } - - protected function makeNSI() - { - global $core; - - $winvdir = trim($this->vdir, '/'); - $winvdir = str_replace('/', '\\', $winvdir); - $winvdir = "\\" . $winvdir; - - $daoLang = new wsDAOLang($core->con); - $lang = $daoLang->selectById($this->book->lang); - - if ($lang->nsis == 'Arabic') { - $lang->nsis = 'English'; - } - - if (!file_exists(WS_FILES . '/packager/download')) { - mkdir(WS_FILES . '/packager/download', 0777, true); - } - - - $fname = str_replace('.exe', '', $this->exeName); - $title = $this->book->parametres->offlineTitle == '' ? $this->book->parametres->title : $this->book->parametres->offlineTitle; - - $nsi = file_get_contents(WS_COMPILE_ASSETS . '/script.nsi'); - $nsi = str_replace('$name', $title, $nsi); - $nsi = str_replace('$htmldir', WS_COMPILE_ASSETS, $nsi); - $nsi = str_replace('$fname', $fname, $nsi); - $nsi = str_replace('$fdir', $winvdir, $nsi); - $nsi = str_replace('$titre', $title, $nsi); - $nsi = str_replace('$lang', $lang->nsis, $nsi); - $nsi = str_replace('$nsisdir', '/usr/share/nsis', $nsi); - $nsi = str_replace('$output', $this->getPathBase('exe'), $nsi); - $favicon = $this->vdir . '/data/fluidbook.ico'; - if ($this->theme->parametres->favicon == '') { - $this->copy(WS_COMPILE_ASSETS . '/fluidbook.ico', $favicon); - } - $nsi = str_replace('$favicon', $favicon, $nsi); - - $this->nsi = $nsi; - } - - public function makePackage($zip) - { - $this->preparePackage(); - - $tmp = cubeFiles::tempnam(); - file_put_contents($tmp, $this->nsi); - $makensis = new CubeIT_CommandLine('makensis'); - $makensis->setArg(null, $tmp); - $makensis->execute(); - $makensis->debug(); - - return $this->getURLBase('exe'); - } - - public function __destruct() - { - - } - -} - -?> \ No newline at end of file