--- /dev/null
+<?php
+
+namespace App\Console\Commands;
+
+use App\Fluidbook\Packager\Base;
+use Cubist\Backpack\Console\Commands\CubistCommand;
+
+class FluidbookPackage extends CubistCommand
+{
+ protected $signature = 'fluidbook:package {id} {type} {--zip}';
+ protected $description = 'Compile a fluidbook';
+
+ /**
+ * @throws \Exception
+ */
+ public function handle()
+ {
+ $packager = Base::package($this->argument('id'), $this->argument('type'), $this->option('zip', false));
+ $packager->handle();
+ }
+}
use App\Models\User;
use App\Util\wsDAOBook;
use App\Util\wsDocument;
+use Cubist\Util\ArrayUtil;
use Cubist\Util\Files\Files;
use Cubist\Util\Str;
use Fluidbook\Tools\Links\Link;
}
$r = json_decode(gzdecode(file_get_contents($file)), true);
+
$links = self::_UID($r['links']);
$rulers = self::_UID($r['rulers']);
+
if (can('fluidbook-publication:links:edit-animations')) {
$links = Link::decryptLinks($links);
- }else{
+ } else {
$links = Link::encryptLinks($links);
}
+
self::_correctImageSpecialLinks($links);
}
namespace App\Fluidbook\Packager;
+use App\Jobs\FluidbookCompiler;
+use App\Models\FluidbookPublication;
+use App\Models\FluidbookTheme;
use Cubist\Util\CommandLine;
+use Cubist\Util\Files\Files;
use Cubist\Util\PHP;
use Cubist\Util\Text;
protected $dir;
protected $vdir;
+
+ /**
+ * @var FluidbookPublication
+ */
public $book;
- protected $pages;
+ /** @var FluidbookTheme */
protected $theme;
- protected $version;
+ protected $scormVariant = false;
protected $book_id;
protected $themeRoot;
- protected $daoBook;
protected $zip;
protected $workingDir;
- protected $whole = true;
protected $_clean = true;
protected $_compileOnConstruct = false;
public $cleanOnDestruct = true;
- const COMPILE_ASSETS = '/application/resources/fluidbookpublication/packager/';
-
- public static function package($book_id, $version, $zip = true, $cleanOnDestruct = true, $options = [])
- {
- global $packager;
-
- PHP::neverStop();
-
- if ($version === 'html') {
- $packager = new Online($book_id, null, true, $options);
- } else if ($version === 'scorm') {
- $packager = new SCORM($book_id, null, true, $options);
- } else if ($version === 'sharepoint') {
- $packager = new Sharepoint($book_id, null, true, $options);
- } elseif ($version === 'win_html') {
- $packager = new OfflineHTML($book_id, null, true, $options);
- } else if ($version === 'win_exe_html') {
- $packager = new WindowsZIP($book_id, $options);
- } else if ($version === 'mac_exe_html') {
- $packager = new MacOS($book_id, $options);
- } else if ($version === 'win_ins_html') {
- $packager = new WindowsInstaller($book_id, $options);
- } else if ($version === 'win_inss_html') {
- $packager = new WindowsEXE($book_id, $options);
- } else if ($version === 'win_cd_html') {
- $packager = new USBKey($book_id, $options);
- } else if ($version === 'precompiled') {
- $packager = new Precompiled($book_id, null, true, $options);
- } else if ($version === 'chromeos') {
- $packager = new ChromeOS($book_id, null, true, $options);
+ public $zipPackage = true;
+
+ public $type = 'base';
+
+
+ public static function package($book_id, $type, $zipPackage = true, $cleanOnDestruct = true, $options = [])
+ {
+ if ($type === 'html') {
+ $packager = new Online($book_id, null, $options);
+ } else if ($type === 'scorm') {
+ $packager = new SCORM($book_id, null, $options);
+ } else if ($type === 'sharepoint') {
+ $packager = new Sharepoint($book_id, null, $options);
+ } elseif ($type === 'win_html') {
+ $packager = new OfflineHTML($book_id, null, $options);
+ } else if ($type === 'win_exe_html') {
+ $packager = new WindowsZIP($book_id, null, $options);
+ } else if ($type === 'mac_exe_html') {
+ $packager = new MacOS($book_id, null, $options);
+ } else if ($type === 'win_ins_html') {
+ $packager = new WindowsInstaller($book_id, null, $options);
+ } else if ($type === 'win_inss_html') {
+ $packager = new WindowsEXE($book_id, null, $options);
+ } else if ($type === 'win_cd_html') {
+ $packager = new USBKey($book_id, null, $options);
+ } else if ($type === 'precompiled') {
+ $packager = new Precompiled($book_id, null, $options);
+ } else if ($type === 'chromeos') {
+ $packager = new ChromeOS($book_id, null, $options);
}
$packager->cleanOnDestruct = $packager->cleanOnDestruct && $cleanOnDestruct;
+ $packager->zipPackage = $zipPackage;
- return $packager->makePackage($zip);
+ return $packager;
}
- public function __construct($book_id, $vdir = null, $whole = true, $options = [])
+
+ public function __construct($book_id, $vdir = null, $options = [])
{
$this->_clean = (null === $vdir);
$this->book_id = $book_id;
$this->vdir = $vdir;
- $this->dir = ROOT . '/fluidbook/packager/' . $book_id . '/';
- $this->whole = $whole;
+ $this->dir = Files::mkdir($this->packager_path('/' . $book_id));
- if (!file_exists($this->dir)) {
- mkdir($this->dir, 0777, true);
- }
-
- $this->book = $this->daoBook->selectById($book_id);
+ $this->book = FluidbookPublication::find($book_id);
$forceCompile = false;
if (count($options)) {
$options['forceCompileOnDownload'] = true;
}
foreach ($options as $k => $v) {
- $this->book->parametres->$k = $v;
+ $this->book->getSettings()->set($k, $v);
}
- $this->pages = $this->daoBook->getPagesOfBook($book_id, false);
-
- $daoTheme = new wsDAOTheme($core->con);
- $this->theme = $daoTheme->getThemeOfBook($book_id, true);
- $this->themeRoot = WS_THEMES . '/' . $this->theme->theme_id . '/';
+ $this->theme = $this->book->getTheme();
$this->workingDir = $this->book->getAssetDir();
}
}
+ public function handle()
+ {
+ PHP::neverStop();
+ $this->makePackage($this->zipPackage);
+ }
+
+ protected function packager_path($path = '')
+ {
+ return protected_path('/fluidbookpublication/packager/' . ltrim($path, '/'));
+ }
+
+
+ protected function resource_path($path)
+ {
+ return resource_path('/fluidbookpublication/packager/' . ltrim($path, '/'));
+ }
protected function compile($forceCompile = false)
{
- $this->daoBook->compile($this->book_id, '2', false, $this->book->parametres->forceCompileOnDownload || $forceCompile, false, $this->book);
+ $compiler = new FluidbookCompiler($this->book, $this->scormVariant);
+ $compiler->handle();
}
protected function preparePackage()
return $res;
}
- protected function copyFluidbookFiles()
- {
- // Copie du FB vers un répertoire temporaire
- $cp = new CommandLine('cp');
- $cp->setArg('R');
- $cp->setArg('p');
- $cp->setArg(null, WS_BOOKS . '/final/' . $this->book->book_id . '/*');
- $cp->setArg(null, $this->vdir);
- $cp->execute();
- }
-
- protected function copyOtherFiles($files)
- {
- foreach ($files as $source => $dest) {
- if (is_int($source)) {
- $source = $dest;
- }
-
- $s = WS_COMPILE_ASSETS . '/' . $source;
- if (is_file($s) && !file_exists($this->vdir . $dest)) {
- $this->copy($s, $this->vdir . $dest);
- } else if (is_dir($s)) {
- $cp = new CommandLine('cp');
- $cp->setArg('R');
- $cp->setArg('p');
- $cp->setArg(null, $s);
- $cp->setArg(null, $this->vdir);
- $cp->execute();
-
- $mv = new CommandLine('mv');
- $mv->setArg($this->vdir . '/' . $source);
- $mv->setArg($this->vdir . '/' . $dest);
- $mv->execute();
- }
- }
- }
protected function getBaseFile()
{
- return $this->version . '-' . date('Ymdhis') . '-' . $this->escapeTitle();
+ return $this->type . '-' . date('Ymdhis') . '-' . $this->escapeTitle();
}
protected function escapeTitle()
{
- $res = Text::str2URL($this->book->parametres->title);
+ $res = Text::str2URL($this->book->title);
if ($res == '') {
$res = 'fluidbook';
}
return $res;
}
- protected function getRelativeBase()
- {
- return '/packager/download/' . $this->getBaseFile();
- }
-
- protected function getURLBase($ext = '')
- {
- $res = '/fluidbook' . $this->getRelativeBase();
- if ($ext != '') {
- $res .= '.' . $ext;
- }
- return $res;
- }
protected function getPathBase($ext = '')
{
- $res = WS_FILES . $this->getRelativeBase();
+ $res = '/download/' . $this->getBaseFile();
if ($ext != '') {
$res .= '.' . $ext;
}
- return $res;
+ return $this->packager_path($res);
}
protected function zip($zipfile = null)
{
- if (!$this->whole) {
- return;
- }
- $url = $this->getURLBase('zip');
+ Files::mkdir($this->packager_path('download'));
$final = $this->getPathBase('zip');
$rename = false;
if (is_null($zipfile)) {
$zip->setArg(null, '.');
$zip->setManualArg('-x "*/\.*"');
$zip->execute();
- $zip->debug();
- }
-
- if (!file_exists(WS_FILES . '/packager/download')) {
- mkdir(WS_FILES . '/packager/download', 0777, true);
}
if ($rename) {
rename($zipfile, $final);
}
- return $url;
+ return $final;
}
public function getFinalPackageDir()
{
- $dir = $this->vdir;
- $dir .= '/m/';
- return $dir;
+ return $this->vdir;
}
protected function initTempDir()
{
if (is_null($this->vdir)) {
- $this->vdir = $this->dir . $this->version . '/';
- }
- $this->cleanVdir();
- if (!file_exists($this->vdir . '/data')) {
- mkdir($this->vdir . '/data', 0777, true);
+ $this->vdir = $this->dir . $this->type . '/';
}
}
- protected function cleanVdir()
- {
- if (!$this->_clean) {
- return;
- }
- if (file_exists($this->vdir)) {
- // Suppression du répertoire si il existe
- $rm = new CommandLine('rm');
- $rm->setArg('r');
- $rm->setArg('f');
- $rm->setArg(null, $this->vdir);
- $rm->execute();
- }
- }
protected function postPackage()
{
}
- public function __destruct()
- {
- if ($this->whole && $this->cleanOnDestruct) {
- $this->cleanVdir();
- }
- }
-
public function copy($source, $dest)
{
if (!file_exists($source)) {
class ChromeOS extends Online
{
- public function __construct($book_id, $vdir = null, $whole = true, $options = [])
- {
- parent::__construct($book_id, $vdir, $whole, $options);
- $this->version = 'chromeos';
- $this->cleanOnDestruct = true;
- }
+
+ public $type='chormeos';
+ public $cleanOnDestruct=true;
protected function preparePackage()
{
<?php
+
namespace App\Fluidbook\Packager;
+
use Cubist\Util\CommandLine;
class MacOS extends OfflineHTML
protected $nwversion = '0.49.2';
protected $node_platform = 'mac';
protected $exenameMaxlength = 28;
-
- public function __construct($book_id, $options = [])
- {
- parent::__construct($book_id, $options);
- $this->version = 'mac_exe_html';
- }
+ public $type = 'mac_exe_html';
public function makePackage($zip)
{
$cl->debug();
$this->replaceFFMpeg();
- if(!file_exists($this->getAppPath())){
- die('Error while building mac app : '.$cl->commande.' // '.$cl->output);
+ if (!file_exists($this->getAppPath())) {
+ die('Error while building mac app : ' . $cl->commande . ' // ' . $cl->output);
}
$this->signApp();
namespace App\Fluidbook\Packager;
-class OfflineHTML extends Online {
- protected $_allowNetworking = 'internal';
+class OfflineHTML extends Online
+{
+ protected $_allowNetworking = 'internal';
+ public $type = 'win_html';
- protected function copyFluidbookFiles() {
- parent::copyFluidbookFiles();
- unlink($this->vdir . '/index.swf');
- unlink($this->vdir . '/player.swf');
- copy(WS_COMPILE_ASSETS . '/offline.swf', $this->vdir . '/index.swf');
- }
+ protected function copyFluidbookFiles()
+ {
+ parent::copyFluidbookFiles();
+ unlink($this->vdir . '/index.swf');
+ unlink($this->vdir . '/player.swf');
+ copy(WS_COMPILE_ASSETS . '/offline.swf', $this->vdir . '/index.swf');
+ }
}
namespace App\Fluidbook\Packager;
+use App\Jobs\FluidbookCompiler;
+use App\Models\FluidbookPublication;
use Cubist\Util\CommandLine;
class Online extends Base
-{ protected $origHTML;
+{
+ protected $origHTML;
protected $_labels = array();
protected $_allowNeworking = 'all';
protected $_ext = 'html';
- protected $_disableScorm = true;
+ public $type = 'html';
+
protected $_compileOnConstruct = false;
- public function __construct($book_id, $vdir = null, $whole = true, $options = [])
- {
- parent::__construct($book_id, $vdir, $whole, $options);
- $this->version = 'html';
- }
protected function preparePackage()
{
parent::preparePackage();
- if ($this->_disableScorm) {
- $this->book->parametres->scorm_enable = false;
- }
-
- $this->_ext = $this->book->parametres->htmlExtension;
- $this->book->parametres->actualHtmlExtension = $this->_ext;
-
- $this->copyFluidbookFiles();
- $this->mergeJavascript();
+ $this->book->getSettings()->set('scorm_enable', $this->scormVariant);
-// $others = array('fluidbook.js', 'getflash.gif', 'index.html', 'style.css');
-// $others = array_merge($others, $this->getSWFFiles());
-//
-// $this->copyOtherFiles($others);
-
- if (!file_exists($this->vdir . '/pages')) {
- mkdir($this->vdir . '/pages/', 0777, true);
- }
+ $this->_ext = $this->book->getSettings()->get('htmlExtension');
+ $this->book->getSettings()->set('actualHtmlExtension', $this->_ext);
- $ga = '';
- if ($this->book->parametres->googleAnalyticsCustom) {
- $ga = $this->book->parametres->googleAnalyticsCustom;
- } elseif ($this->book->parametres->googleAnalytics != '') {
- $variables = array('Language' => array('value' => 'getLang()', 'valueAsJS' => true, 'scope' => 2));
- $ga = cubePage::googleAnalytics(explode(',', $this->book->parametres->googleAnalytics), true, $variables);
- }
-
- $statsfooter = '';
- if ($this->book->parametres->statsCustom != '') {
- $statsfooter = $this->book->parametres->statsCustom;
- }
-
- $facebook = '';
- if ($this->book->parametres->facebook) {
- if ($this->book->parametres->facebook_title != '') {
- $facebook .= '<meta property="og:title" content="' . self::escape($this->book->parametres->facebook_title) . '" />';
- } else {
- $facebook .= '<meta property="og:title" content="' . self::escape($this->book->parametres->title) . '" />';
- }
- if ($this->book->parametres->facebook_description != '') {
- $facebook .= '<meta property="og:description" content="' . self::escape($this->book->parametres->facebook_description) . '" />';
- }
- $t = 'https://workshop.fluidbook.com/services/facebook_thumbnail?cid=' . $this->book->cid . '&j=' . time();
- $dim = getimagesize($t);
- $facebook .= '<meta property="og:image" content="' . $t . '" />';
- $facebook .= '<meta property="og:image:width" content="' . $dim[0] . '" />';
- $facebook .= '<meta property="og:image:height" content="' . $dim[1] . '" />';
- }
-
- $favicon = '';
-
- if ($this->theme->parametres->favicon != '') {
- $favicon = '<link rel="shortcut icon" href="data/fluidbook.ico">';
- }
-
- $redirectPDF = 'redirectPDF();';
- if ($this->book->parametres->mobileVersion == 'pdf') {
- $redirectMobile = $redirectPDF;
- } else {
- $redirectMobile = 'redirectMobile();';
- $this->prepareHTML5();
- }
-
- $seoVersion = true;
- if (isset($this->book->parametres->seoVersion)) {
- $seoVersion = $this->book->parametres->seoVersion;
- }
-
- $seoRobot = true;
- if (isset($this->book->parametres->seoRobots)) {
- $seoRobot = $this->book->parametres->seoRobots;
- }
-
- $robots = '';
- if (!$seoRobot) {
- $robots = '<meta name="robots" content="noindex, nofollow">';
- }
-
- $keywords = '';
- if ($this->book->parametres->seoKeywords) {
- $keywords = '<meta name="keywords" content="' . self::escape($this->book->parametres->seoKeywords) . '">';
- }
-
- $alwaysHTML5 = true;
- $html5priority = true;
-
-
- // Stuffs to replace in html
- $toReplace = array('lang' => strtolower($this->book->lang),
- 'ga' => $ga,
- 'statsfooter' => $statsfooter,
- 'facebook' => $facebook,
- 'bgcolor' => $this->theme->parametres->loadingBackColor,
- 'junk' => TIME,
- 'robots' => $robots,
- 'favicon' => $favicon,
- 'alwaysHTML5' => $alwaysHTML5,
- 'keywords' => $keywords,
- );
-
- $this->origHTML = $this->book->parametres->htmlPrepend;
- $h = $this->vdir . '/index.html';
- if (file_exists($h)) {
- $this->origHTML .= file_get_contents($h);
- unlink($h);
- }
- $this->origHTML = $this->replaceHTML($toReplace);
-
- $nav1 = $this->makeHTMLNav(true);
- $nav = $this->makeHTMLNav(false);
- $footer = $this->makeHTMLFooter();
-
-
- foreach ($this->pages as $page => $infos) {
- $pathToIndex = 'index.swf';
- $pathToGetflash = 'getflash.gif';
- $redirectScript = '';
- if ($page == 1) {
- $dest = 'index.' . $this->_ext;
- $title = $this->book->parametres->title;
- $sp = '';
- } else {
- $label = $this->_getLabelOfPage($page);
- $title = $label . ' - ' . $this->book->parametres->title;
- $dest = 'pages/' . $page . '-' . mb_strtolower(cubeText::str2URL($label)) . '.' . $this->_ext;
- $pathToIndex = '../index.swf';
- $pathToGetflash = '../getflash.gif';
- $sp = '../';
- $redirectScript = '<script type="text/javascript">window.location=\'../index.' . $this->_ext . '#/' . $page . '\';</script>';
- }
- $alt = '';
-
-// if ($seoVersion && CubeIT_Util_Gzip::file_exists($htmlfile)) {
-// $html = CubeIT_Util_Gzip::file_get_contents($htmlfile);
-// $alt .= "\n" . $html . "\n";
-//
-// if ($page == 1) {
-// $alt .= $nav1;
-// } else {
-// $alt .= $nav;
-// }
-// }
-
- $alt .= $footer;
-
- $base = '';
- if ($this->book->parametres->baseUrl) {
- $base = '<base href="' . $this->book->parametres->baseUrl . '" />';
- }
-
- if ($page == 1 && $this->book->parametres->seoDescription) {
- $description = $this->book->parametres->seoDescription;
- } else {
- $textfile = wsDocument::getDir($infos['document_id']) . 'ph' . $infos['document_page'] . '.txt';
- if (file_exists($textfile)) {
- $description = mb_substr(file_get_contents($textfile), 0, 150);
- } else {
- $description = '';
- }
- }
-
- $data = str_replace('$alt', $alt, $this->origHTML);
- $data = str_replace('$base', $base, $data);
- $data = str_replace('$pathToIndex', $pathToIndex, $data);
- $data = str_replace('$title', $this->escape($title), $data);
- $data = str_replace('$pathToGetflash', $pathToGetflash, $data);
- $data = str_replace('$redirectScript', $redirectScript, $data);
- $data = str_replace('$sp', $sp, $data);
- $data = str_replace('$index_ext', $this->_ext, $data);
- $data = str_replace('$description', '<meta name="description" content="' . self::escape($description, true) . '">', $data);
-
- file_put_contents($this->vdir . $dest, $data);
-
- if (!$seoVersion) {
- break;
- }
- }
+ $this->prepareHTML5();
}
- protected function getFlashvars()
- {
- return array();
- }
public function prepareHTML5()
{
- if (!$this->whole) {
- return;
- }
- $dest = $this->vdir . 'm';
+ $dest = $this->vdir;
- $mfid = $this->book->parametres->mobilefirstFluidbookId;
+ $mfid = $this->book->getSettings()->get('mobilefirstFluidbookId', '');
if ($mfid != '' && (int)$mfid > 0) {
- $mfbook = $this->daoBook->selectById($mfid);
+ $mfbook = FluidbookPublication::find($mfid);
$this->_compileHTML5($this->book_id, $this->book, $dest . '/d', true);
$vars = wsDAOBook::$lastHTML5Compiler->getIndexVars();
$this->_compileHTML5($mfid, $mfbook, $dest . '/mf', true);
- $hybrid = file_get_contents(WS_COMPILE_ASSETS . '/hybrid/index.html');
+ $hybrid = file_get_contents($this->resource_path('hybrid.html'));
$replace = [
'titre' => $vars['<!-- $titre -->'],
'breakpoint' => $this->book->parametres->mobilefirstBreakpoint . 'px',
protected function _compileHTML5($bookId, $book, $dest, $hybrid = false)
{
+ $compiler = new FluidbookCompiler($book, $this->scormVariant, false, "latest", null, false, false, false, null, $hybrid);
+ $compiler->handle();
- $this->daoBook->compile($bookId, 'html5', false, $book->parametres->forceCompileOnDownload, false, $book, true, false, $hybrid);
-
- if (!file_exists($dest)) {
- mkdir($dest, 0777, true);
- }
-
- $cp = new CommandLine('cp');
- $cp->setPath(CONVERTER_PATH);
- $cp->setArg('r');
- $cp->setArg('p');
- $cp->setArg(null, WS_BOOKS . '/html5/' . $bookId . '/*');
- $cp->setArg(null, $dest);
- $cp->execute();
-
- $filesToAdd = array();
- foreach ($filesToAdd as $f) {
- $this->copy(WS_COMPILE_ASSETS . '/_html5/' . $f, $dest . '/' . $f);
- }
-
- $filesToDelete = array('indext.html', 'indexu.html');
+ $rsync = new CommandLine\Rsync(rtrim($compiler->getFinalPath(),'/'), $dest, true);
+ $rsync->execute();
$htmlFiles = array('index');
+ $filesToDelete = [];
foreach ($htmlFiles as $name) {
- $html = $book->parametres->htmlPrepend . file_get_contents($dest . '/' . $name . '.html');
+ $html = $book->getSettings()->get('htmlPrepend') . file_get_contents($dest . $name . '.html');
file_put_contents($dest . '/' . $name . '.' . $this->_ext, $html);
if ($this->_ext != 'html') {
$filesToDelete[] = $name . '.html';
}
$rm = new CommandLine('rm');
- $rm->setPath(CONVERTER_PATH);
foreach ($filesToDelete as $f) {
$rm->setArg(null, $dest . '/' . $f);
}
if ($this->_ext !== 'html') {
$e = $this->_ext;
`find $dest -type f -name "*.html" -exec rename 's/\.html$/.$e/' '{}' \;`;
-
}
}
return $this->getFinalPackageDir();
}
- protected function makeHTMLNav($root)
- {
- $res = '<nav>';
- foreach ($this->pages as $page => $infos) {
- $label = $this->_getLabelOfPage($page);
- if ($page == 1) {
- if ($root) {
- $url = 'index.' . $this->_ext;
- } else {
- $url = '../index.' . $this->_ext;
- }
- } else {
- if ($root) {
- $url = 'pages/' . $page . '-' . mb_strtolower(cubeText::str2URL($label)) . '.' . $this->_ext;
- } else {
- $url = $page . '-' . mb_strtolower(cubeText::str2URL($label)) . '.' . $this->_ext;
- }
- }
- $res .= '<a href="' . $url . '">' . $label . '</a>';
- }
- $res .= '</nav>';
- return $res;
- }
-
- protected function _getLabelOfPage($page)
- {
- if (!isset($this->_chapters)) {
- $this->_chapters = $this->book->chapters;
- }
-
-
- if (isset($this->_labels[$page])) {
- return $this->_labels[$page];
- }
-
-
- if ($page == 1) {
- $this->_labels[1] = $this->book->parametres->title;
-
- return $this->_labels[1];
- }
-
-
- $virtual = $this->_getVirtualPage($page);
-
- $candidates = array();
- foreach ($this->_chapters as $c) {
- if ($c->page == $virtual) {
- $candidates[] = $c;
- }
- }
- if (!count($candidates)) {
- $this->_labels[$page] = $this->_getLabelOfPage($page - 1);
- return $this->_labels[$page];
- }
-
- usort($candidates, array($this, '_sortCandidates'));
- $c = array_shift($candidates);
-
- $this->_labels[$page] = $c->label;
- return $this->_labels[$page];
- }
-
- protected function _sortCandidates($a, $b)
- {
- if ($a->level > $b->level) {
- return 1;
- } else if ($a->level < $b->level) {
- return -1;
- } else {
- return 0;
- }
- }
-
- protected function _getVirtualPage($page)
- {
- $num = explode(',', $this->book->numerotation);
- if (isset($num[$page - 1])) {
- return $num[$page - 1];
- }
- return 1;
- }
-
- protected function escape($txt, $replaceNewLines = false)
- {
- $res = htmlentities($txt, ENT_COMPAT, 'UTF-8');
- if ($replaceNewLines) {
- $res = str_replace("\n", ' ', $res);
- $res = str_replace("\r", '', $res);
- }
- return $res;
- }
-
- protected function makeHTMLFooter()
- {
- $res = '<footer>';
- $res .= '<h2><a href="https://www.fluidbook.com">Fluidbook : Solution de catalogues interactifs et brochures en ligne</a></h2>';
- $res .= '</footer>';
- return $res;
- }
-
- protected function replaceHTML($toReplace)
- {
- return $this->replaceContents($this->origHTML, $toReplace);
- }
-
- protected function mergeJavascript()
- {
- $dest = WS_COMPILE_ASSETS . '/fluidbook.js';
- $orig = WS_COMPILE_ASSETS . '/_js/';
- $files = array('log4js.js' => false, 'esapi.js' => false, 'resources/i18n/ESAPI_Standard_en_US.properties.js' => false, 'resources/Base.esapi.properties.js' => false, 'swfobject.js' => false, 'swfaddress.js' => true, 'fluidbook.js' => true);
-
- $refresh = false;
- if (file_exists($dest)) {
- $mtime = filemtime($dest);
- foreach ($files as $file => $min) {
- if (filemtime($orig . $file) > $mtime) {
- $refresh = true;
- break;
- }
- }
- } else {
- $refresh = true;
- }
- if (!$refresh) {
- return;
- }
-
- $minjs = "\n\n";
- foreach ($files as $file => $min) {
- $c = file_get_contents($orig . $file);
- if ($min) {
- $c = JSMin::minify($c);
- }
-
- $minjs .= $c . "\n\n";
- }
- file_put_contents($dest, $minjs);
- }
-
}
class Precompiled extends Online
{
- public function __construct($book_id, $vdir = null, $whole = true,$options=[])
+ public $type = 'precompiled';
+
+ public function __construct($book_id, $vdir = null, $options = [])
{
- parent::__construct($book_id, $vdir, $whole,$options);
- $this->version = 'precompiled';
+ parent::__construct($book_id, $vdir, $options);
$this->book->parametres->embedAllLibraries = true;
}
<?php
+
namespace App\Fluidbook\Packager;
class Scorm extends Online
{
- public function __construct($book_id, $vdir = null, $whole = true, $options = [])
- {
- parent::__construct($book_id, $vdir, $whole, $options);
- $this->version = 'scorm';
- $this->_disableScorm = false;
- }
+ protected $scormVariant = true;
+
+ public $type = 'scorm';
protected function preparePackage()
{
class Sharepoint extends Online
{
- public function __construct($book_id, $vdir = null, $whole = true, $options = [])
+ public $type = 'sharepoint';
+
+ public function __construct($book_id, $vdir = null, $options = [])
{
- parent::__construct($book_id, $vdir, $whole, $options);
- $this->version = 'sharepoint';
- $this->book->parametres->seoVersion = false;
- $this->book->parametres->maxResolution = 150;
- $this->book->parametres->htmlExtension = 'aspx';
+ parent::__construct($book_id, $vdir, $options);
+ $this->book->getSettings()->set('seoVersion', false);
+ $this->book->getSettings()->set('maxResolution', 150);
+ $this->book->getSettings()->set('htmlExtension', 'aspx');
}
}
namespace App\Fluidbook\Packager;
class USBKey extends MacOS
{
-
- public function __construct($book_id,$options=[])
- {
- parent::__construct($book_id,$options);
- $this->version = 'win_cd_html';
- }
+ public $type='win_cd_html';
protected function preparePackage()
{
<?php
+
namespace App\Fluidbook\Packager;
class WindowsEXE extends WindowsInstaller
{
protected $nsifile = 'html-silent';
+ public $type = 'win_inss_html';
- public function __construct($book_id, $options = [])
- {
- parent::__construct($book_id, $options);
- $this->version = 'win_inss_html';
- }
}
protected $nsi;
protected $nsifile = 'html';
- public function __construct($book_id, $options = [])
- {
- parent::__construct($book_id, $options);
- $this->version = 'win_ins_html';
- }
+ public $type='win_ins_html';
+
protected function preparePackage()
{
use Cubist\Net\SSH2;
use Cubist\Util\CommandLine;
+use Cubist\Util\Text;
class WindowsZIP extends Base
{
protected $exenameMaxlength = 30;
protected $_compileOnConstruct = true;
- public function __construct($book_id, $options = [])
+ public $type = 'win_exe_html';
+
+ public function __construct($book_id, $vdir = null, $options = [])
{
- parent::__construct($book_id, null, true, $options);
- $this->version = 'win_exe_html';
+ parent::__construct($book_id, $vdir, $options);
$this->appName = '';
$this->appversion = '1.0.' . time();
$this->_clean = false;
$this->exeName = $this->book->book_id . '-' . trim(cubeText::str2URL(mb_substr($this->book->parametres->title, 0, $this->exenameMaxlength - 6)), '-');
$this->appName = $this->book->parametres->title;
} else {
- $this->exeName = trim(cubeText::str2URL(mb_substr($this->book->parametres->offlineTitle, 0, $this->exenameMaxlength)), '-');
+ $this->exeName = trim(Text::str2URL(mb_substr($this->book->parametres->offlineTitle, 0, $this->exenameMaxlength)), '-');
$this->appName = $this->book->parametres->offlineTitle;
}
public $dir;
public $z = 3;
protected $_lottieIDByHash = [];
+
+ /**
+ * @var FluidbookPublication
+ */
public $book;
public $pages;
public $theme;
/**
* @param FluidbookPublication $book
- * @param $version null|string
+ * @param bool $scormVariant
* @param $phonegap
* @param $phonegapVersion
* @param $dir
* @throws \Exception
*/
- function __construct(FluidbookPublication $book, $version = 'online', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, FluidbookTheme $theme = null, $hybrid = false, Command $command = null)
+ function __construct(FluidbookPublication $book, $scormVariant = false, $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, FluidbookTheme $theme = null, $hybrid = false, Command $command = null)
{
parent::__construct();
$this->appcache = $appcache;
$this->multiApp = $this->home = $home;
$this->devversion = $this->getFluidbook()->mobileLVersion;
- $this->version = $version;
+ $this->scormVariant = $scormVariant;
$this->hybrid = $hybrid;
$this->book_id = $this->getFluidbook()->id;
$this->log('Start compilation');
- $this->dir = $this->getFluidbook()->getFinalPath($theme, $version);
+ $this->dir = $this->getFluidbook()->getFinalPath($theme, $scormVariant);
$this->vdir = new VirtualDirectory($this->dir);
$this->wdir = $this->getFluidbook()->getAssetDir();
$this->imageFormat = $this->fluidbookSettings->imageFormat;
-
$p1 = $this->getFluidbook()->getFile(1, $this->imageFormat, 150);
$imagesize = Image::getimagesize($p1);
$this->pdf2htmlRatio = round(($imagesize[0] * 0.48) / $this->width, 12);
$this->log('Defined dimensions');
}
+ public function getFinalPath()
+ {
+ return $this->dir;
+ }
+
public function getSetting($key, $default = null)
{
public function initConfig()
{
- if ($this->version !== 'scorm') {
+ if (!$this->scormVariant) {
$this->fluidbookSettings->scorm_enable = false;
}
{
parent::setFields();
-// $this->addField([
-// 'name' => 'name',
-// 'type' => FluidbookTitle::class,
-// 'label' => __('Titre de la publication'),
-// 'default' => '',
-// 'column' => true,
-// 'translatable' => false,
-// 'non_default_tracking' => false,
-// ]);
$this->addOwnerField();
return (float)$this->getDocumentSize($page)[1];
}
- public function getFinalPath($theme = null, $version = 'online')
+ public function getFinalPath($theme = null, $scormVariant = false)
{
$dir = $this->id;
- if (null === $theme || ($theme instanceof FluidbookTheme && $theme->id != $this->theme)) {
+ if (null !== $theme || ($theme instanceof FluidbookTheme && $theme->id != $this->theme)) {
$dir .= '-';
if (is_string($theme) || is_numeric($theme)) {
$dir .= $theme;
$dir .= $theme->id;
}
}
- return protected_path('fluidbookpublication/final/' . $dir . '/' . $version);
+ return protected_path('fluidbookpublication/final/' . $dir . '/' . ($scormVariant ? 'scorm' : 'online'));
}
public function getAssetDir()
--- /dev/null
+[autorun]
+label=$title
+icon=$exe
+open=$exe
+action=$title
\ No newline at end of file
--- /dev/null
+[autorun]
+label=$title
+icon=data\fluidbook.ico
+open=$exe
+action=$title
\ No newline at end of file
--- /dev/null
+; Fluidbook
+;--------------------------------
+
+!define FLUIDBOOKNAME "$name"
+!define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\$fname"
+
+Unicode true
+
+; The name of the installer
+Name "${FLUIDBOOKNAME}"
+
+; The file to write
+OutFile "$output"
+
+; The default installation directory
+InstallDir $LOCALAPPDATA\$fname
+
+; Request application privileges for Windows Vista
+RequestExecutionLevel user
+
+; Style
+XPStyle on
+
+Icon "$favicon"
+
+; not released
+;TargetMinimalOS 5.0
+
+; Langues
+LoadLanguageFile "$nsisdir/Contrib/Language files/$lang.nlf"
+
+; Pages
+
+Page directory
+Page instfiles
+
+; Compression
+SetCompress off
+
+;--------------------------------
+
+Function .onInit
+ SetSilent silent
+FunctionEnd
+
+; The stuff to install
+Section "" ;No components page, name is not important
+ ; Set output path to the installation directory.
+ SetOutPath $INSTDIR
+
+ ; Put file there
+ SetOverwrite ifnewer
+ File /r "$fdir\*"
+
+ ; Create shortcut
+ CreateShortCut "$SMPROGRAMS\${FLUIDBOOKNAME}.lnk" "$INSTDIR\$fname.exe" "--disable-crash-handler=true" "$INSTDIR\package.nw\icon.ico"
+ CreateShortCut "$DESKTOP\${FLUIDBOOKNAME}.lnk" "$INSTDIR\$fname.exe" "--disable-crash-handler=true" "$INSTDIR\package.nw\icon.ico"
+
+ WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayName" "${FLUIDBOOKNAME}"
+ WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayIcon" "$\"$INSTDIR\package.nw\icon.ico$\""
+ WriteRegStr HKCU "${REG_UNINSTALL}" "InstallLocation" "$\"$INSTDIR$\""
+ WriteRegDWord HKCU "${REG_UNINSTALL}" "NoModify" 1
+ WriteRegDWord HKCU "${REG_UNINSTALL}" "NoRepair" 1
+ WriteRegStr HKCU "${REG_UNINSTALL}" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
+
+ WriteUninstaller "$INSTDIR\Uninstall.exe"
+
+ ExecShell "" "$INSTDIR\$fname.exe" "--disable-crash-handler=true"
+SectionEnd
+
+Section "Uninstall"
+ DeleteRegKey HKCU "${REG_UNINSTALL}"
+ Delete "$SMPROGRAMS\${FLUIDBOOKNAME}.lnk"
+ Delete "$DESKTOP\${FLUIDBOOKNAME}.lnk"
+ Delete "$INSTDIR\Uninstall.exe"
+ RMDIR /r /REBOOTOK $INSTDIR
+ SetRebootFlag false
+SectionEnd
+
+
--- /dev/null
+[autorun]
+label=$title
+icon=$nwplatform\package.nw\icon.ico
+open=$exe
+action=$title
\ No newline at end of file
--- /dev/null
+; Fluidbook
+;--------------------------------
+
+!define FLUIDBOOKNAME "$name"
+!define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\$fname"
+
+Unicode true
+
+; The name of the installer
+Name "${FLUIDBOOKNAME}"
+
+; The file to write
+OutFile "$output"
+
+; The default installation directory
+InstallDir $LOCALAPPDATA\$fname
+
+; Request application privileges for Windows Vista
+RequestExecutionLevel user
+
+; Style
+XPStyle on
+
+Icon "$favicon"
+
+; not released
+;TargetMinimalOS 5.0
+
+; Langues
+LoadLanguageFile "$nsisdir/Contrib/Language files/$lang.nlf"
+
+; Pages
+
+Page directory
+Page instfiles
+
+; Compression
+SetCompress off
+
+; The stuff to install
+Section "" ;No components page, name is not important
+ ; Set output path to the installation directory.
+ SetOutPath $INSTDIR
+
+ ; Put file there
+ SetOverwrite ifnewer
+ File /r "$fdir\*"
+
+ ; Create shortcut
+ CreateShortCut "$SMPROGRAMS\${FLUIDBOOKNAME}.lnk" "$INSTDIR\$fname.exe" "--disable-crash-handler=true" "$INSTDIR\package.nw\icon.ico"
+ CreateShortCut "$DESKTOP\${FLUIDBOOKNAME}.lnk" "$INSTDIR\$fname.exe" "--disable-crash-handler=true" "$INSTDIR\package.nw\icon.ico"
+
+ WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayName" "${FLUIDBOOKNAME}"
+ WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayIcon" "$\"$INSTDIR\package.nw\icon.ico$\""
+ WriteRegStr HKCU "${REG_UNINSTALL}" "InstallLocation" "$\"$INSTDIR$\""
+ WriteRegDWord HKCU "${REG_UNINSTALL}" "NoModify" 1
+ WriteRegDWord HKCU "${REG_UNINSTALL}" "NoRepair" 1
+ WriteRegStr HKCU "${REG_UNINSTALL}" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
+
+ WriteUninstaller "$INSTDIR\Uninstall.exe"
+
+ ExecShell "" "$INSTDIR\$fname.exe" "--disable-crash-handler=true"
+SectionEnd
+
+Section "Uninstall"
+ DeleteRegKey HKCU "${REG_UNINSTALL}"
+ Delete "$SMPROGRAMS\${FLUIDBOOKNAME}.lnk"
+ Delete "$DESKTOP\${FLUIDBOOKNAME}.lnk"
+ Delete "$INSTDIR\Uninstall.exe"
+ RMDIR /r /REBOOTOK $INSTDIR
+ SetRebootFlag false
+SectionEnd
+
+
--- /dev/null
+<!doctype html>
+<html>
+<head>
+ <title>$titre</title>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width">
+ $description
+ $opengraph
+ $twittercard
+ <style type="text/css">
+ * {
+ padding: 0;
+ margin: 0;
+ }
+
+ body, html {
+ background-color: #$bgcolor;
+ width: 100%;
+ height: 100%;
+ }
+
+ footer {
+ visibility: hidden;
+ }
+ </style>
+ <script>
+ var redirect;
+ var locationWithoutHash = window.location.href.split('#')[0];
+ var e = locationWithoutHash.split('?', 2);
+ var params = '';
+ if (e.length === 2 && e[1]!=='') {
+ params = e[1] + '&';
+ }
+ var hash = window.location.hash;
+ if (window.matchMedia('(min-device-width: $breakpoint) and (min-device-height: $breakpoint)').matches) {
+ redirect = 'd';
+ } else {
+ redirect = 'mf';
+ }
+ window.location = './' + redirect + '/index.html?' + params + 'hybrid=1&from=' + encodeURIComponent(locationWithoutHash) + hash;
+ </script>
+</head>
+<body>
+<footer id="credits">$credits</footer>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+; Fluidbook
+;--------------------------------
+
+!define FLUIDBOOKNAME "$name"
+!define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\$fname"
+
+; The name of the installer
+Name "${FLUIDBOOKNAME}"
+
+; The file to write
+OutFile "$output"
+
+; The default installation directory
+InstallDir $LOCALAPPDATA\$fname
+
+; Request application privileges for Windows Vista
+RequestExecutionLevel user
+
+; Style
+XPStyle on
+
+Icon "$favicon"
+
+; not released
+;TargetMinimalOS 5.0
+
+; Langues
+LoadLanguageFile "$nsisdir/Contrib/Language files/$lang.nlf"
+
+; Pages
+
+Page directory
+Page instfiles
+
+; Compression
+SetCompress off
+
+;--------------------------------
+
+; The stuff to install
+Section "" ;No components page, name is not important
+
+ ; Set output path to the installation directory.
+ SetOutPath $INSTDIR
+
+ ; Put file there
+ File /r "$fdir\*"
+
+ ; Create shortcut
+ CreateShortCut "$SMPROGRAMS\${FLUIDBOOKNAME}.lnk" "$INSTDIR\$fname.exe" "" "$INSTDIR\data\fluidbook.ico"
+ CreateShortCut "$DESKTOP\${FLUIDBOOKNAME}.lnk" "$INSTDIR\$fname.exe" "" "$INSTDIR\data\fluidbook.ico"
+
+ WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayName" "${FLUIDBOOKNAME}"
+ WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayIcon" "$\"$INSTDIR\data\fluidbook.ico$\""
+ WriteRegStr HKCU "${REG_UNINSTALL}" "InstallLocation" "$\"$INSTDIR$\""
+ WriteRegDWord HKCU "${REG_UNINSTALL}" "NoModify" 1
+ WriteRegDWord HKCU "${REG_UNINSTALL}" "NoRepair" 1
+ WriteRegStr HKCU "${REG_UNINSTALL}" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
+
+ WriteUninstaller "$INSTDIR\Uninstall.exe"
+
+ ExecShell "" "$INSTDIR\$fname.exe"
+SectionEnd
+
+Section "Uninstall"
+DeleteRegKey HKCU "${REG_UNINSTALL}"
+Delete "$SMPROGRAMS\${FLUIDBOOKNAME}.lnk"
+Delete "$DESKTOP\${FLUIDBOOKNAME}.lnk"
+Delete "$INSTDIR\Uninstall.exe"
+RMDIR /r /REBOOTOK $INSTDIR
+SetRebootFlag false
+SectionEnd
+
+