From: vincent@cubedesigners.com Date: Mon, 22 Jul 2013 10:06:16 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=f9c3fe6d464a7ab060d101ad0b7b03b34468847b;p=cubeextranet.git --- diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index daebf438c..c4474dea1 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -536,6 +536,7 @@ class commonTools { $js = $_GET['js']; } + if ($js == '') { ob_end_clean(); exit; @@ -545,14 +546,16 @@ class commonTools { file_put_contents($tmp, $js); $uglify = new cubeCommandLine('uglifyjs'); $uglify->setPath(CONVERTER_PATH); - $uglify->setArg('o', $res); - $uglify->setArg('mangle-toplevel'); - $uglify->setArg('no-copyright'); - $uglify->setArg('unsafe'); $uglify->setArg(null, $tmp); + $uglify->setArg('o', $res); + $uglify->setArg('c'); + $uglify->setArg('m'); $uglify->execute(); ob_end_clean(); + fb($uglify->commande); + fb($uglify->output); + header('Content-type: text/javascript'); if (file_exists($res)) { echo file_get_contents($res); diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index 2658b5fe0..be3181b3a 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -553,13 +553,19 @@ class wsServices extends cubeFlashGateway { public function collection() { global $core; $id = $this->callArgs[0]; - $local = (isset($this->callArgs[1])) ? $this->callArgs[1] : null; + $os = $this->callArgs[1]; + $local = (isset($this->callArgs[2])) ? $this->callArgs[2] : null; + $this->outputXML = false; header('Content-type: application/json'); - $cache = WS_COLLECTIONS . '/ws/' . $id . '.json'; - $update = WS_COLLECTIONS . '/ws/' . $id . '.update'; + $cache = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.json'; + $update = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.update'; + + if (file_exists($update) && filemtime(__FILE__) > filemtime($update)) { + unlink($update); + } if (!is_null($local) && file_exists($update) && file_get_contents($update) == $local) { echo 'false'; @@ -575,14 +581,18 @@ class wsServices extends cubeFlashGateway { $composition = json_decode(file_get_contents(WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/composition.json')); $couvertures = array(); + $vroot = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/'; + foreach ($composition as $k => $g) { foreach ($g->publications as $l => $p) { - $couv = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/ios/' . $p->id . '/data/background/36/t1.jpg'; + $root = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/' . $p->id; + $couv = $root . '/data/background/36/t1.jpg'; $couvertures[$p->id] = base64_encode(file_get_contents($couv)); + $publications[] = $p->id; } } - $d = array('id' => $id, 'time' => $version, 'datas' => $composition, 'couvertures' => $couvertures); + $d = array('id' => $id, 'time' => $version, 'manifest' => $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os), 'datas' => $composition, 'couvertures' => $couvertures); $dao = new wsDAOCollection($core->con); $col = $dao->selectById($id); @@ -598,6 +608,53 @@ class wsServices extends cubeFlashGateway { exit; } + protected function _getManifest($publications, $dir) { + + + $res = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => false); + $bundles = array(); + + $removeFromRelative = realpath(ROOT . '/' . $dir) . '/'; + + foreach ($publications as $p) { + $c = array(); + $c1 = array(); + $r = $p . '/'; + $iterator = CubeIT_Files::getRecursiveDirectoryIterator(ROOT . $dir . '/' . $p); + foreach ($iterator as $k => $f) { + if ($f->isDir()) { + continue; + } + $path = str_replace($removeFromRelative, '', $k); + $order = $this->_inFirstManifest($path, $r); + if ($order === 0) { + $c1[] = $path; + } elseif ($order === 1) { + $c[] = $path; + } + } + //shuffle($c); + + $bundles[] = array('name' => 'p_' . $p, 'contents' => $c1); + $bundles[] = array('name' => 'p_' . $p . '_', 'contents' => $c); + } + + $res['bundles'] = $bundles; + return $res; + } + + protected function _inFirstManifest($p, $r) { + + $ok = array('^' . $r . 'style/(.*)$', '^' . $r . 'index.html$', '^' . $r . 'images/(.*)$', '^' . $r . 'data/images/(.*)$', '^' . $r . 'data/style/(.*)$', '^' . $r . 'data/(.*).js$'); + foreach ($ok as $v) { + if (preg_match('|' . $v . '|i', $p)) { + fb('ok : ' . $v, $p); + return 0; + } + } + return 1; + } + public function collectionPushRegister() { global $core; diff --git a/inc/ws/Util/class.ws.exporter.php b/inc/ws/Util/class.ws.exporter.php index eef918287..a48974ec3 100644 --- a/inc/ws/Util/class.ws.exporter.php +++ b/inc/ws/Util/class.ws.exporter.php @@ -178,7 +178,6 @@ class wsExporter { $d = '/' . $this->destinationDir; $packager = new wsPackagerPhonegap($this->book_id, $d, true, false, $this->version); - $packager->ignoreCache = false; $packager->home=true; return $packager->makePackage(false); }