]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 22 Jul 2013 10:06:16 +0000 (10:06 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 22 Jul 2013 10:06:16 +0000 (10:06 +0000)
inc/commons/class.common.tools.php
inc/ws/Controlleur/class.ws.services.php
inc/ws/Util/class.ws.exporter.php

index daebf438cf7baa93e7d4c722a60cdfaca329c5a9..c4474dea1d39aaf3cc1d57ec4b5b34b8e90546b4 100644 (file)
@@ -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);
index 2658b5fe0c20f5e540413f50e466cb3babf9dcf6..be3181b3acdbd58442a32a680d0209fb76efd069 100644 (file)
@@ -553,13 +553,19 @@ class wsServices extends cubeFlashGateway {
        public function collection() {\r
                global $core;\r
                $id = $this->callArgs[0];\r
-               $local = (isset($this->callArgs[1])) ? $this->callArgs[1] : null;\r
+               $os = $this->callArgs[1];\r
+               $local = (isset($this->callArgs[2])) ? $this->callArgs[2] : null;\r
+\r
 \r
                $this->outputXML = false;\r
                header('Content-type: application/json');\r
 \r
-               $cache = WS_COLLECTIONS . '/ws/' . $id . '.json';\r
-               $update = WS_COLLECTIONS . '/ws/' . $id . '.update';\r
+               $cache = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.json';\r
+               $update = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.update';\r
+\r
+               if (file_exists($update) && filemtime(__FILE__) > filemtime($update)) {\r
+                       unlink($update);\r
+               }\r
 \r
                if (!is_null($local) && file_exists($update) && file_get_contents($update) == $local) {\r
                        echo 'false';\r
@@ -575,14 +581,18 @@ class wsServices extends cubeFlashGateway {
                        $composition = json_decode(file_get_contents(WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/composition.json'));\r
 \r
                        $couvertures = array();\r
+                       $vroot = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/';\r
+\r
                        foreach ($composition as $k => $g) {\r
                                foreach ($g->publications as $l => $p) {\r
-                                       $couv = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/ios/' . $p->id . '/data/background/36/t1.jpg';\r
+                                       $root = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/' . $p->id;\r
+                                       $couv = $root . '/data/background/36/t1.jpg';\r
                                        $couvertures[$p->id] = base64_encode(file_get_contents($couv));\r
+                                       $publications[] = $p->id;\r
                                }\r
                        }\r
 \r
-                       $d = array('id' => $id, 'time' => $version, 'datas' => $composition, 'couvertures' => $couvertures);\r
+                       $d = array('id' => $id, 'time' => $version, 'manifest' => $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os), 'datas' => $composition, 'couvertures' => $couvertures);\r
 \r
                        $dao = new wsDAOCollection($core->con);\r
                        $col = $dao->selectById($id);\r
@@ -598,6 +608,53 @@ class wsServices extends cubeFlashGateway {
                exit;\r
        }\r
 \r
+       protected function _getManifest($publications, $dir) {\r
+\r
+\r
+               $res = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => false);\r
+               $bundles = array();\r
+\r
+               $removeFromRelative = realpath(ROOT . '/' . $dir) . '/';\r
+\r
+               foreach ($publications as $p) {\r
+                       $c = array();\r
+                       $c1 = array();\r
+                       $r = $p . '/';\r
+                       $iterator = CubeIT_Files::getRecursiveDirectoryIterator(ROOT . $dir . '/' . $p);\r
+                       foreach ($iterator as $k => $f) {\r
+                               if ($f->isDir()) {\r
+                                       continue;\r
+                               }\r
+                               $path = str_replace($removeFromRelative, '', $k);\r
+                               $order = $this->_inFirstManifest($path, $r);\r
+                               if ($order === 0) {\r
+                                       $c1[] = $path;\r
+                               } elseif ($order === 1) {\r
+                                       $c[] = $path;\r
+                               }\r
+                       }\r
+                       //shuffle($c);\r
+\r
+                       $bundles[] = array('name' => 'p_' . $p, 'contents' => $c1);\r
+                       $bundles[] = array('name' => 'p_' . $p . '_', 'contents' => $c);\r
+               }\r
+\r
+               $res['bundles'] = $bundles;\r
+               return $res;\r
+       }\r
+\r
+       protected function _inFirstManifest($p, $r) {\r
+\r
+               $ok = array('^' . $r . 'style/(.*)$', '^' . $r . 'index.html$', '^' . $r . 'images/(.*)$', '^' . $r . 'data/images/(.*)$', '^' . $r . 'data/style/(.*)$', '^' . $r . 'data/(.*).js$');\r
+               foreach ($ok as $v) {\r
+                       if (preg_match('|' . $v . '|i', $p)) {\r
+                               fb('ok : ' . $v, $p);\r
+                               return 0;\r
+                       }\r
+               }\r
+               return 1;\r
+       }\r
+\r
        public function collectionPushRegister() {\r
                global $core;\r
 \r
index eef918287ddd06e1be5cfda4ec382cc7683cf917..a48974ec3e599cf82c83f111de31112729e4c942 100644 (file)
@@ -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);
        }