From 04e9ffe3831d8da324ae9d9aa8c7ac97cdad33ef Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Thu, 25 Jul 2013 14:02:59 +0000 Subject: [PATCH] --- inc/ws/Controlleur/class.ws.ajax.php | 23 ++++++++++++++----- inc/ws/Controlleur/class.ws.services.php | 19 ++++++++++++--- inc/ws/Controlleur/class.ws.url.php | 4 ++++ inc/ws/Metier/class.ws.document.php | 15 ++++++++++++ .../html5/app/class.ws.html5.app.compiler.php | 3 +++ 5 files changed, 55 insertions(+), 9 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index 67cf9bbec..b0a7dca79 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -1091,6 +1091,8 @@ class wsAjax extends cubeAjax { self::collectionVersionPublish(array('collectionVersionPublish', $id, $time), new cubeAjax()); } + self::cleanCachesCollection($id); + $x->addReload(); } @@ -1108,17 +1110,26 @@ class wsAjax extends cubeAjax { $c->online = 1; $c->update('WHERE collection_id=\'' . $core->con->escape($id) . '\' AND compile_date=\'' . $core->con->escape($date) . '\''); - $caches = array(WS_COLLECTIONS . '/ws/' . $id . '.ios.json', WS_COLLECTIONS . '/ws/' . $id . '.android.json'); - foreach ($caches as $cache) { - if (file_exists($cache)) { - unlink($cache); - } - } + self::cleanCachesCollection($id); $x->addReload(); } + protected static function cleanCachesCollection($id) { + $os = array('ios', 'android'); + $files = array('json', 'update'); + + foreach ($os as $_os) { + foreach ($files as $f) { + $ff = WS_COLLECTIONS . '/ws/' . $id . '.' . $_os . '.' . $f; + if (file_exists($ff)) { + unlink($ff); + } + } + } + } + public static function collectionVersionDelete($args, &$x) { global $core; diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index 1341f638f..cf923b5d5 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -572,13 +572,16 @@ class wsServices extends cubeFlashGateway { exit; } + + $limit = TIME - 72000; if (!file_exists($cache) || !file_exists($update) || filemtime($cache) < $limit) { $r = $core->con->select('SELECT * FROM book_collection_compile WHERE online=1 AND collection_id=\'' . $core->con->escape($id) . '\''); $r->fetch(); $version = $r->compile_date; - $composition = json_decode(file_get_contents(WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/composition.json')); + $vcompo = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/composition.json'; + $composition = json_decode(file_get_contents($vcompo)); $couvertures = array(); $vroot = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/'; @@ -600,12 +603,22 @@ class wsServices extends cubeFlashGateway { $json = json_encode($d); file_put_contents($cache, $json); - echo $json; + file_put_contents($update, $version); } else { - echo file_get_contents($cache); + $d = json_decode(file_get_contents($cache), true); + } + + $force = false; + if (!is_null($local)) { + $lcompo = WS_COLLECTIONS . '/versions/' . $id . '/' . $local . '/composition.json'; + if (!file_exists($lcompo)) { + $force = true; + } } + $d['forceUpdate'] = $force; + echo json_encode($d); exit; } diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 63faf1ae2..165478a92 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -305,6 +305,10 @@ class wsUrl { foreach ($images as $i => $label) { $res.='' . $label . '' . form::hidden(array('theme[' . $i . ']', 'theme_' . $i), $collection->theme[$i]) . ''; } + $res.='' . __('Couleur principale') . '#' . form::field(array('settings[couleurA]', 'couleurA'), 6, 6, $collection->settings['couleurA']) . ''; + $res.='' . __('Couleur secondaire') . '#' . form::field(array('settings[couleurB]', 'couleurB'), 6, 6, $collection->settings['couleurB']) . ''; + $res.='' . __('Couleur des textes') . '#' . form::field(array('settings[couleurC]', 'couleurC'), 6, 6, $collection->settings['couleurC']) . ''; + $res.=''; $res.='' . $core->typo->Ajouter(__('Enregistrer')) . ''; diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index 21d439a4f..d24dff580 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -573,6 +573,7 @@ class wsDocument extends cubeMetier { } public function makeSVGFile($page) { + $testFile = $this->out . '/html/s' . $page . '.svg'; $svgFile = $this->out . '/html/p' . $page . '.svg'; //$svgSimplified = $this->out . '/html/s' . $page . '.svg'; $svgOpt = $this->out . '/html/o' . $page . '.svg'; @@ -588,6 +589,20 @@ class wsDocument extends cubeMetier { $pdftocairo->execute(); $this->addToLog($pdftocairo, true, $page); + /*$pdf2svg = new cubeCommandLine('pdf2svg'); + $pdf2svg->setPath(CONVERTER_PATH); + $pdf2svg->setArg(null, $this->cropped); + $pdf2svg->setArg(null, $testFile); + $pdf2svg->setArg(null, $page); + $pdf2svg->execute(); + $this->addToLog($pdf2svg, true, $page); + $this->_cleanSVG($testFile);*/ + + $this->_cleanSVG($svgFile); + + } + + protected function _cleanSVG($svgFile) { $svg = new DOMDocument(); $svg->preserveWhiteSpace = false; $svg->load($svgFile); diff --git a/inc/ws/Util/html5/app/class.ws.html5.app.compiler.php b/inc/ws/Util/html5/app/class.ws.html5.app.compiler.php index 2e930b949..364f389c7 100644 --- a/inc/ws/Util/html5/app/class.ws.html5.app.compiler.php +++ b/inc/ws/Util/html5/app/class.ws.html5.app.compiler.php @@ -106,6 +106,9 @@ class wsHTML5AppCompiler { function writeScript() { $config = array(); $config['id'] = $this->collectionId; + $config['couleurA']=$this->collection->settings['couleurA']; + $config['couleurB']=$this->collection->settings['couleurB']; + $config['couleurC']=$this->collection->settings['couleurC']; $this->copy(WS_COMPILE_ASSETS . '/_html5/js/libs/phonegap/' . $this->phonegapVersion . '/cordova-' . $this->os . '.js', $this->vdir . '/js/cordova.js'); file_put_contents($this->vdir . '/data/app.js', 'DATAS = ' . CubeIT_Util_Json::encode($config) . ';'); -- 2.39.5