class wsHTML5Compiler {
protected static $resolutions = array(150, 300);
- protected $maxRes = 300;
+ public $maxRes = 300;
public $jsFiles = array(
'js/libs/modernizr/modernizr.min.js',
'js/libs/cube/fb.js',
'js/libs/modernizr/modernizr.min.js',
'js/libs/modernizr/tests.js',
- 'js/libs/jquery/jquery.js',
+ 'js/libs/jquery/jquery.min.js',
'js/libs/jquery/jquery.transit.js',
'js/widget.js'
);
function __construct($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false) {
global $core;
-
$this->phonegapVersion = wsHTML5::getPhonegapVersion($phonegapVersion);
$this->appcache = $appcache;
$this->multiApp = $this->home = $home;
$this->book = $this->daoBook->selectById($book_id);
$this->pages = $this->daoBook->getPagesOfBook($book_id);
- switch ($this->book->parametres->mobileVersion) {
- case 'html5-desktop':
- $this->backgroundsPrefix = array('t', 'p');
- $this->svg = true;
- break;
- case 'html5-images':
- $this->backgroundsPrefix = array('t');
- $this->svg = false;
- break;
- default:
- $this->backgroundsPrefix = array('p');
- $this->svg = true;
- break;
- }
$daoTheme = new wsDAOTheme($core->con);
$this->theme = $daoTheme->getThemeOfBook($book_id, true);
}
$this->numerotation = explode(',', $this->book->numerotation);
- $this->config = cubeObject::merge($this->book->parametres->toStandardObject(), $this->theme->parametres->toStandardObject());
-
+ $this->initConfig();
$this->log('Defined dimensions');
}
+ public function initConfig() {
+ $this->config = cubeObject::merge($this->book->parametres->toStandardObject(), $this->theme->parametres->toStandardObject());
+ }
+
public function log($step) {
$currenttime = microtime(true);
if (null === $this->logfp) {
}
public function getResolutions() {
- $res = self::$resolutions;
+ $res = [];
+ foreach (self::$resolutions as $r) {
+ if ($r > $this->maxRes) {
+ continue;
+ }
+ $res[] = $r;
+ }
if ($this->widget) {
$res = array_merge(array(36), $res);
}
return $p + 1;
}
- public function compile() {
+ public function compile($delete = true) {
$this->log('Start compile process');
$this->log('Extras written');
$this->writeJs();
$this->log('Js written');
- $this->vdir->sync(true);
+ $this->vdir->sync($delete);
$this->log('Files Synced');
}
$tmp = cubeFiles::tempnam();
file_put_contents($tmp, $js);
+ unlink($minimized);
+
$uglify = new CubeIT_CommandLine('/usr/local/bin/uglifyjs');
$uglify->setArg('o', $minimized);
$uglify->setArg(null, $tmp);
$uglify->execute();
$uglify->debug();
+
+ if (!file_exists($minimized)) {
+ die('An error occured while uglifying : ' . $uglify->output);
+ }
}
$dest = 'data/' . $jsfinal . '.js';
$this->vdir->copy($minimized, $dest);
protected function writeImages() {
global $core;
+ switch ($this->book->parametres->mobileVersion) {
+ case 'html5-desktop':
+ $this->backgroundsPrefix = array('t', 'p');
+ $this->svg = true;
+ break;
+ case 'html5-images':
+ $this->backgroundsPrefix = array('t');
+ $this->svg = false;
+ break;
+ default:
+ $this->backgroundsPrefix = array('p');
+ $this->svg = true;
+ break;
+ }
+
$thumbs = array();
foreach ($this->pages as $page => $infos) {
$docdir = wsDocument::getDir($infos['document_id']);
foreach ($res as $k => $css) {
$this->stylesheets[] = 'data/style/style_' . $k . '.css';
$this->vdir->file_put_contents(sprintf($file, $k), implode("\n", $css));
+ $this->log('Write CSS ' . sprintf($file, $k));
}
return count($res);
}