]> _ Git - cubeextranet.git/commitdiff
wip #1701
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 31 Oct 2017 10:20:15 +0000 (10:20 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 31 Oct 2017 10:20:15 +0000 (10:20 +0000)
inc/ws/Controlleur/class.ws.ajax.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php
inc/ws/Util/packager/class.ws.packager.phonegap.php

index 2aaff30a9f5696f1d22d24e5bfea91bcaae75bf7..f78906d51e48dec75b8411ee303de95b82323d2b 100644 (file)
@@ -1161,6 +1161,11 @@ class wsAjax extends cubeAjax {
 
                self::cleanCachesCollection($id);
 
+               if ($_GET['ctrl']) {
+                       $_GET['ctrl'] = false;
+                       self::exportCollection(array('exportCollection', $id, 'ios'), $x);
+               }
+
                $x->addReload();
        }
 
index 34d01e0b28e9323d8f008fd2432b3f84783eaaf3..06e317ad1f98b66ca61ee5651203771634d8999c 100644 (file)
@@ -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);
        }
index 70b85618ca1a9959b7692bfea57ad4f768715191..7c6c4f59e0c1f4081f3dc2dde953b964a7932a8a 100644 (file)
@@ -32,7 +32,11 @@ class wsPackagerPhonegap extends wsPackager {
                        }
 
                        $compiler = wsHTML5::compilerFactory($this->book_id, null, $os, 'latest', $vdir, false, !$this->ignoreCache, $this->home);
-                       $compiler->compile();
+                       $compiler->book->parametres->mobileVersion = 'html5-images';
+                       $compiler->book->parametres->menuBreakpoint = '900px';
+                       $compiler->maxRes = 150;
+                       $compiler->initConfig();
+                       $compiler->compile(false);
 
                        unlink($vdir . '/indext.html');
                        unlink($vdir . '/indexu.html');