]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 24 Jul 2013 09:08:44 +0000 (09:08 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 24 Jul 2013 09:08:44 +0000 (09:08 +0000)
inc/commons/class.common.tools.php
inc/ws/Controlleur/class.ws.ajax.php
inc/ws/Controlleur/class.ws.services.php
inc/ws/Util/class.ws.tools.php
inc/ws/Util/html5/class.ws.html5.compiler.php

index c4474dea1d39aaf3cc1d57ec4b5b34b8e90546b4..d73854e671bc380deff2b9d65388d46daa4e726c 100644 (file)
@@ -553,9 +553,6 @@ class commonTools {
                $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 bc5a7354fff04e25b26b0fa0dbc1555c5975f72d..67cf9bbec09e831463d384216ea4968d28b72e59 100644 (file)
@@ -1081,8 +1081,6 @@ class wsAjax extends cubeAjax {
 \r
                file_put_contents(WS_COLLECTIONS . '/versions/' . $id . '/' . $time . '/composition.json', json_encode($compiler->collection->datas));\r
 \r
-\r
-\r
                $c = $core->con->openCursor('book_collection_compile');\r
                $c->collection_id = $id;\r
                $c->compile_date = $time;\r
@@ -1110,9 +1108,12 @@ class wsAjax extends cubeAjax {
                $c->online = 1;\r
                $c->update('WHERE collection_id=\'' . $core->con->escape($id) . '\' AND compile_date=\'' . $core->con->escape($date) . '\'');\r
 \r
-               $cache = WS_COLLECTIONS . '/ws/' . $id . '.json';\r
-               if (file_exists($cache)) {\r
-                       unlink($cache);\r
+               $caches = array(WS_COLLECTIONS . '/ws/' . $id . '.ios.json', WS_COLLECTIONS . '/ws/' . $id . '.android.json');\r
+\r
+               foreach ($caches as $cache) {\r
+                       if (file_exists($cache)) {\r
+                               unlink($cache);\r
+                       }\r
                }\r
 \r
                $x->addReload();\r
index be3181b3acdbd58442a32a680d0209fb76efd069..1341f638fb538481dec5919541834e3319dd122b 100644 (file)
@@ -586,13 +586,14 @@ class wsServices extends cubeFlashGateway {
                        foreach ($composition as $k => $g) {\r
                                foreach ($g->publications as $l => $p) {\r
                                        $root = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/' . $p->id;\r
-                                       $couv = $root . '/data/background/36/t1.jpg';\r
+                                       $couv = $root . '/cover.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, 'manifest' => $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os), 'datas' => $composition, 'couvertures' => $couvertures);\r
+                       $d = array('id' => $id, 'time' => $version, 'datas' => $composition, 'couvertures' => $couvertures);\r
+                       $d = array_merge($d, $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os));\r
 \r
                        $dao = new wsDAOCollection($core->con);\r
                        $col = $dao->selectById($id);\r
@@ -609,50 +610,104 @@ class wsServices extends cubeFlashGateway {
        }\r
 \r
        protected function _getManifest($publications, $dir) {\r
+               global $core;\r
+               $res = array();\r
+               $res['manifest'] = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => true);\r
+               $res['manifestPub'] = array();\r
 \r
-\r
-               $res = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => false);\r
                $bundles = array();\r
 \r
                $removeFromRelative = realpath(ROOT . '/' . $dir) . '/';\r
 \r
+\r
                foreach ($publications as $p) {\r
-                       $c = array();\r
-                       $c1 = array();\r
+                       $res['manifestPub'][$p] = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => true);\r
+\r
                        $r = $p . '/';\r
                        $iterator = CubeIT_Files::getRecursiveDirectoryIterator(ROOT . $dir . '/' . $p);\r
+\r
+                       $daoBook = new wsDAOBook($core->con);\r
+                       $book = $daoBook->selectById($p);\r
+                       $daoTheme = new wsDAOTheme($core->con);\r
+                       $theme = $daoTheme->selectById($book->theme);\r
+                       $orders = $this->_getBundles($book);\r
+                       $reg = $this->_getRegExpManifest($r, $book, $theme);\r
+\r
+                       $b = array();\r
+\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
+                               $order = $this->_inFirstManifest($path, $orders, $reg);\r
+\r
+                               if (!isset($b[$order])) {\r
+                                       $b[$order] = array();\r
                                }\r
+\r
+                               $b[$order][] = $path;\r
                        }\r
-                       //shuffle($c);\r
 \r
-                       $bundles[] = array('name' => 'p_' . $p, 'contents' => $c1);\r
-                       $bundles[] = array('name' => 'p_' . $p . '_', 'contents' => $c);\r
+\r
+\r
+                       $bundles[] = array('name' => 'p_' . $p, 'contents' => $b['loading']);\r
+\r
+                       $res['manifestPub'][$p]['bundles'] = array();\r
+\r
+                       foreach ($b as $name => $contents) {\r
+                               if ($name == 'loading') {\r
+                                       continue;\r
+                               }\r
+                               $k = array_search($name, $orders);\r
+                               $res['manifestPub'][$p]['bundles'][$k] = array('name' => $name, 'contents' => $contents);\r
+                       }\r
+                       ksort($res['manifestPub'][$p]['bundles']);\r
+                       $res['manifestPub'][$p]['bundles'] = array_values($res['manifestPub'][$p]['bundles']);\r
                }\r
 \r
-               $res['bundles'] = $bundles;\r
+               $res['manifest']['bundles'] = $bundles;\r
                return $res;\r
        }\r
 \r
-       protected function _inFirstManifest($p, $r) {\r
+       protected function _getRegExpManifest($r, $book, $theme) {\r
+               $reg = array();\r
+               $reg['loading'] = array('^' . $r . 'style/(.*).css$', '^' . $r . 'index.html$', '^' . $r . 'data/style/(.*)$', '^' . $r . 'data/(.*).js$', '^' . $r . 'data/images/' . $theme->parametres->logoLoader . '$');\r
+               $reg['extras'] = array('^' . $r . 'data/links/(.*)$', '^' . $r . 'data/(.*).pdf$', '^' . $r . 'cover.jpg$');\r
+               $reg['thumbnails'] = array('^' . $r . 'data/thumbnails/p(\d+).jpg$');\r
+               for ($i = 1; $i <= $book->parametres->pages; $i++) {\r
+                       $var = 'content_' . $i;\r
+                       $reg[$var] = array('^' . $r . 'data/background/150/t' . $i . '.jpg$', '^' . $r . 'data/contents/p' . $i . '.svg$');\r
+               }\r
+               $reg['urgents'] = array('^' . $r . 'images/(.*)$', '^' . $r . 'data/images/(.*)$', '^' . $r . 'style/fonts/(.*).ttf$');\r
+               return $reg;\r
+       }\r
+\r
+       protected function _inFirstManifest($p, $orders, $reg) {\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
+               foreach ($orders as $list) {\r
+                       foreach ($reg[$list] as $v) {\r
+                               if (preg_match('|' . $v . '|', $p)) {\r
+                                       fb($p);\r
+                                       if ($p == '11461/data/background/150/t25.jpg') {\r
+                                               fb($reg[$list]);\r
+                                               fb($v);\r
+                                       }\r
+                                       return $list;\r
+                               }\r
                        }\r
                }\r
-               return 1;\r
+               return $list;\r
+       }\r
+\r
+       protected function _getBundles($book) {\r
+               $res = array(0 => 'loading', 200001 => 'extras', 20000 => 'thumbnails', 1 => 'urgents');\r
+               for ($i = 1; $i <= $book->parametres->pages; $i++) {\r
+                       $k = 2 + $i;\r
+                       $res[$k] = 'content_' . $i;\r
+               }\r
+               return $res;\r
        }\r
 \r
        public function collectionPushRegister() {\r
index c5260e483a471b916d11b8d679556fe6d0d48459..5f3b94ed3baab5560ae989ab5afba95030c3e195 100644 (file)
@@ -22,7 +22,7 @@ class wsTools {
                $webvideo->execute();
        }
 
-       public static function colorizeAndRasterizeIcon($iconSet, $icon, $colors, $dest, $scale, &$w, &$h) {
+       public static function colorizeAndRasterizeIcon($iconSet, $icon, $colors, $dest, $scale, &$w, &$h, $makepng = true) {
                // Init directory
                if (is_string($colors)) {
                        $colors = array('colorize' => $colors);
@@ -102,7 +102,9 @@ class wsTools {
                $w = $dim[0] / $scale;
                $h = $dim[1] / $scale;
 
-               self::copy($png, $dest . '/' . $icon . '.png');
+               if ($makepng) {
+                       self::copy($png, $dest . '/' . $icon . '.png');
+               }
        }
 
        public static function copy($source, $dest) {
index 9c9176c9b8ce24f1935dd64606ee9ae118f4c4b4..997287f68f649b3673813e176f202ccd88069f45 100644 (file)
@@ -17,7 +17,7 @@ class wsHTML5Compiler {
                }
        }
 
-       protected static $resolutions = array(150, 36);
+       protected static $resolutions = array(150);
        protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', '');
        public $jsFiles = array(
                'js/libs/fix/ios-orientation.js',
@@ -37,6 +37,8 @@ class wsHTML5Compiler {
                'js/libs/jquery/jquery.localscroll.js',
                'js/libs/gsap/TweenMax.js',
                'js/libs/gsap/jquery.gsap.js',
+               'js/libs/gal/gal.js',
+               'js/libs/gal/gal.filesystem.js',
                'js/libs/fluidbook/fluidbook.utils.js',
                'js/libs/fluidbook/fluidbook.support.js',
                'js/libs/fluidbook/fluidbook.video.js',
@@ -789,6 +791,16 @@ class wsHTML5Compiler {
                file_put_contents($this->vdir . '/data/search.js', $js);
        }
 
+       public function supportSVG() {
+               if (!$this->phonegap) {
+                       return false;
+               } else if ($this->phonegap == 'ios') {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
        protected function writeConfig() {
                $this->config->numerotation = explode(',', $this->book->numerotation);
                $this->config->id = $this->book->book_id;
@@ -826,9 +838,16 @@ class wsHTML5Compiler {
                $this->config->navOrder = $navOrder;
 
                $this->config->standalone = $this->standalone;
+               if ($this->config->phonegap) {
+                       $this->config->manifest = $this->writeManifest();
+               }
                return 'var DATAS=' . json_encode($this->config) . ';' . "\n";
        }
 
+       protected function writeManifest() {
+               $res=array();
+       }
+
        protected function writeIcons() {
                $res = array();
                // Get the colors used to colorize graphics
@@ -857,8 +876,9 @@ class wsHTML5Compiler {
                );
 
                $this->config->iconsDimensions = array();
+               $makepng = !$this->supportSVG();
                foreach ($icons as $icon => $color) {
-                       wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $this->vdir . '/data/images/', 4, $w, $h);
+                       wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $this->vdir . '/data/images/', 4, $w, $h, $makepng);
                        $this->config->iconsDimensions[$icon] = array($w, $h);
                }
                return $res;
@@ -888,6 +908,10 @@ class wsHTML5Compiler {
                                $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/' . $this->backgroundsPrefix . $page . '.jpg');
                        }
                        $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/thumbnails/p' . $page . '.jpg');
+
+                       if ($page == 1) {
+                               $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/t36-' . $infos['document_page'] . '.jpg', $this->vdir . '/cover.jpg');
+                       }
                }
        }