From: stephen@cubedesigners.com Date: Tue, 31 Oct 2017 13:10:06 +0000 (+0000) Subject: Merge master changes to burgermenu branch. X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ba1e1c0634c6a6a78fd1773031c3e20ee2d8903d;p=cubeextranet.git Merge master changes to burgermenu branch. --- diff --git a/inc/ws/Util/html5/burgermenu/class.ws.html5.compiler.php b/inc/ws/Util/html5/burgermenu/class.ws.html5.compiler.php index 6dff4f655..8b99eaecf 100644 --- a/inc/ws/Util/html5/burgermenu/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/burgermenu/class.ws.html5.compiler.php @@ -2,7 +2,7 @@ class wsHTML5Compiler { protected static $resolutions = array(150, 300); - protected $maxRes = 300; + public $maxRes = 300; public $jsFiles = array( 'js/libs/modernizr/modernizr.min.js', @@ -80,7 +80,7 @@ class wsHTML5Compiler { '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' ); @@ -161,7 +161,6 @@ class wsHTML5Compiler { 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; @@ -201,20 +200,6 @@ class wsHTML5Compiler { $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); @@ -251,11 +236,14 @@ class wsHTML5Compiler { } $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) { @@ -276,7 +264,13 @@ class wsHTML5Compiler { } 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); } @@ -298,7 +292,7 @@ class wsHTML5Compiler { return $p + 1; } - public function compile() { + public function compile($delete = true) { $this->log('Start compile process'); @@ -338,7 +332,7 @@ class wsHTML5Compiler { $this->log('Extras written'); $this->writeJs(); $this->log('Js written'); - $this->vdir->sync(true); + $this->vdir->sync($delete); $this->log('Files Synced'); } @@ -919,11 +913,17 @@ class wsHTML5Compiler { $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); @@ -1062,6 +1062,21 @@ class wsHTML5Compiler { 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']); @@ -1370,6 +1385,7 @@ class wsHTML5Compiler { 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); }