]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sat, 17 Mar 2012 23:50:06 +0000 (23:50 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sat, 17 Mar 2012 23:50:06 +0000 (23:50 +0000)
inc/extranet/Controlleur/class.extranet.url.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/Util/html5/class.ws.html5.compiler.php
inc/ws/Util/packager/class.ws.packager.html.php

index 0cd27a2189650f6b06f92fc2d2878e912c860fd6..4301d05d6d0fa8ba94264b64fb653d67e121a2b7 100644 (file)
@@ -620,13 +620,12 @@ class extranetUrl {
                global $core;\r
                commonDroits::min(1);\r
                $settings = $core->user->getSettings('timereport');\r
+               $res = '';\r
                if (!isset($_GET['light'])) {\r
                        $filtres = array();\r
                        $filtres[] = new commonFiltre(__('Participants'), 'equipier_participe', $settings['filtres']);\r
-                       $res = commonPage::barre($filtres, 'filtreTimereport', 'timereport', null);\r
-\r
+                       $res .= commonPage::barre($filtres, 'filtreTimereport', 'timereport', null);\r
                        $res .= commonPage::tMain();\r
-\r
                        $res .= commonPage::bh();\r
                }\r
                $res .= '<div id="listeTimereport">';\r
index 5a97c0e3306d7289136c6ad6802cd82c970d231d..5ad564c335341f0ddad77acc734fc2f4cef4ec72 100644 (file)
@@ -627,12 +627,36 @@ html{height:100%}' . "\n";
        }\r
 \r
        public static function viewerh($args) {\r
+               global $core;\r
+       \r
                $args = cubePage::getArgs($args);\r
 \r
                $e = explode('_', $args[0]);\r
-               if (count($e) == 2 || $e[2] < TIME - 10) {\r
-                       $e[2] = TIME;\r
-                       http::redirect(SITE_PATH . 'viewerh/' . implode('_', $e) . '/');\r
+\r
+               $book_id = $e[0];\r
+               $hash = $e[1];\r
+\r
+               $dao = new wsDAOBook($core->con);\r
+\r
+               $book = $dao->selectById($book_id);\r
+               if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) {\r
+                       commonDroits::error();\r
+               }\r
+\r
+               if (!$dao->isUpToDate($book_id)) {\r
+                       if ($version == 'u' || $version == 't') {\r
+                               $dao->compileHTML5($book_id);\r
+                       } else {\r
+                               $dao->compile($book_id);\r
+                               $dao->touchCompile($book_id);\r
+                       }\r
+               }\r
+\r
+               $time = self::getHTML5CacheTime($book_id);\r
+\r
+               if (count($e) == 2 || $e[2] != $time) {\r
+                       $e[2] = $time;\r
+                       http::redirect(SITE_PATH . 'viewerh/' . implode('_', $e) . '/index.html');\r
                        exit;\r
                }\r
 \r
@@ -641,13 +665,23 @@ html{height:100%}' . "\n";
                self::commonHTML5Viewer($book_id, $hash);\r
        }\r
 \r
+       public static function getHTML5CacheTime($book_id) {\r
+               $cacheFile = WS_BOOKS . '/html5/' . $book_id . '/cache.appcache';\r
+               if (file_exists($cacheFile)) {\r
+                       return filemtime($cacheFile);\r
+               }\r
+               return TIME;\r
+       }\r
+\r
        public static function viewerhu($args) {\r
                commonDroits::min(5);\r
                $args = cubePage::getArgs($args);\r
 \r
                $e = explode('_', $args[0]);\r
-               if (count($e) == 2 || $e[2] < TIME - 10) {\r
-                       $e[2] = TIME;\r
+               $time = self::getHTML5CacheTime($e[0]);\r
+\r
+               if (count($e) == 2 || $e[2] != $time) {\r
+                       $e[2] = $time;\r
                        http::redirect(SITE_PATH . 'viewerhu/' . implode('_', $e) . '/');\r
                        exit;\r
                }\r
@@ -662,8 +696,10 @@ html{height:100%}' . "\n";
                $args = cubePage::getArgs($args);\r
 \r
                $e = explode('_', $args[0]);\r
-               if (count($e) == 2 || $e[2] < TIME - 10) {\r
-                       $e[2] = TIME;\r
+               $time = self::getHTML5CacheTime($e[0]);\r
+\r
+               if (count($e) == 2 || $e[2] != $time) {\r
+                       $e[2] = $time;\r
                        http::redirect(SITE_PATH . 'viewerht/' . implode('_', $e) . '/');\r
                        exit;\r
                }\r
@@ -770,14 +806,14 @@ html{height:100%}' . "\n";
                $dao = new wsDAOBook($core->con);\r
                $book = $dao->selectById($book_id);\r
 \r
-               if(!wsDroits::admin()){\r
-               if ($book->parametres->redirectDemo != '') {\r
-                       http::redirect($book->parametres->redirectDemo);\r
-                       exit; \r
-               }\r
-               if ($book->parametres->disableDemo) {\r
-                       commonDroits::error();\r
-               }\r
+               if (!wsDroits::admin()) {\r
+                       if ($book->parametres->redirectDemo != '') {\r
+                               http::redirect($book->parametres->redirectDemo);\r
+                               exit;\r
+                       }\r
+                       if ($book->parametres->disableDemo) {\r
+                               commonDroits::error();\r
+                       }\r
                }\r
 \r
                if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) {\r
index ddb1fa39be84882cbe0d6f568596141525fb14d9..951f1596d4cc75ed4634b458439b222c7dc8085e 100644 (file)
@@ -62,6 +62,7 @@ class wsHTML5Compiler {
        protected $additionalConfig = array();
        protected $fontScale = 1;
        protected $cache = array();
+       protected $backgroundsPrefix = 'p';
 
        function __construct($book_id) {
                global $core;
@@ -85,6 +86,10 @@ class wsHTML5Compiler {
                $this->book = $this->daoBook->selectById($book_id);
                $this->pages = $this->daoBook->getPagesOfBook($book_id);
 
+               if ($this->book->parametres->mobileVersion == 'html5-images') {
+                       $this->backgroundsPrefix = 't';
+               }
+
                $daoTheme = new wsDAOTheme($core->con);
                $this->theme = $daoTheme->getThemeOfBook($book_id, true);
                $this->themeRoot = WS_THEMES . '/' . $this->theme->theme_id . '/';
@@ -98,7 +103,7 @@ class wsHTML5Compiler {
 
 
                $imagesize = getimagesize(WS_DOCS . '/' . $this->pages[1]['document_id'] . '/html/h150-' . $this->pages[1]['document_page'] . '.jpg');
-               $this->pdf2htmlRatio = round(($imagesize[0]*0.48) / $this->width, 2);
+               $this->pdf2htmlRatio = round(($imagesize[0] * 0.48) / $this->width, 2);
 
                $this->cssScale = min($this->optimalWidth / $this->width, $this->optimalHeight / $this->height);
                $this->cssOneScale = min(($this->optimalWidth * 2) / $this->width, $this->optimalHeight / $this->height);
@@ -131,15 +136,6 @@ class wsHTML5Compiler {
        }
 
        public function compile() {
-               foreach ($this->layouts as $page => $layout) {
-                       $lines = $this->sortPage($layout);
-                       $document_id = $this->pages[$page]['document_id'];
-                       $this->div[$page] = array();
-                       foreach ($lines as $line) {
-                               $this->div[$page][] = $this->addLine($line, $document_id);
-                       }
-               }
-
                $dirsToCreate = array('data/images', 'data/contents', 'data/background', 'data/thumbnails', 'data/style', 'data/links/pages', 'data/l10n', 'swf');
 
                foreach ($dirsToCreate as $dir) {
@@ -167,6 +163,77 @@ class wsHTML5Compiler {
                $this->writeLangs();
                $this->writeIndex($numCSS);
                $this->writeJs();
+               $this->writeCache();
+       }
+
+       protected function writeCache() {
+               $ignore = array('data/l10n/([a-z-]{2,5}).json', '(.*).ogv', '(.*).flv', '(.*).mp4', '(.*).webm');
+
+               $cacheFile = $this->vdir . '/cache.appcache';
+
+               if (file_exists($cacheFile)) {
+                       unlink($cacheFile);
+               }
+
+               $dest = realpath($this->vdir);
+               $lines = array();
+
+               $network = array('NETWORK:','*');
+
+               $lines[] = 'CACHE MANIFEST';
+               $lines[] = '# ' . date('Y-m-d H:i:s');
+               $lines[] = '';
+               $lines[] = 'index.html';
+               $lines[] = '';
+               $lines[] = 'FALLBACK:';
+               $lines[] = '/ index.html';
+               $lines[] = 'index.html* index.html';
+               $lines[] = '';
+               $lines[] = 'CACHE:';
+               //$lines[] = 'index.html';
+               $assets = array('images', 'style', 'swf', 'data/l10n', 'data/style', 'data/images', 'data/fluidbook.js');
+
+               $pages = $this->book->parametres->pages + 1;
+
+               for ($i = 0; $i <= $pages; $i++) {
+
+                       $assets[] = 'data/background/150/' . $this->backgroundsPrefix . $i . '.jpg';
+                       $assets[] = 'data/links/pages/p' . $i . '.html';
+                       $assets[] = 'data/contents/p' . $i . '.svg';
+               }
+               $assets[] = 'data/thumbnails';
+               $assets[] = 'data/links';
+
+               foreach ($assets as $a) {
+                       $ap = $dest . '/' . $a;
+
+                       if (!file_exists($ap)) {
+                               continue;
+                       }
+                       if (is_file($ap)) {
+                               $lines[] = str_replace($dest . '/', '', $ap);
+                       } else if (is_dir($ap)) {
+                               $iterator = new RecursiveDirectoryIterator($ap);
+                               foreach ($iterator as $path) {
+                                       if (!$path->isFile()) {
+                                               continue;
+                                       }
+                                       $p = str_replace($dest . '/', '', $path);
+                                       foreach ($ignore as $i) {
+                                               if (preg_match('|' . $i . '|i', $p, $matches)) {
+                                                       $network[] = $p;
+                                                       continue 2;
+                                               }
+                                       }
+                                       $lines[] = $p;
+                               }
+                       }
+               }
+
+               $lines[] = '';
+               $lines = array_merge($lines, $network);
+
+               file_put_contents($cacheFile, implode("\n", $lines));
        }
 
        protected function writeIndex($numCSS) {
@@ -191,9 +258,11 @@ class wsHTML5Compiler {
                }
                $style = implode("\n\t\t", $style);
 
+               $pagesContents = '';
+
                $script = '<script type="text/javascript" src="data/fluidbook.js"></script>';
 
-               $vars = array('titre', 'credits', 'ga', 'style', 'script');
+               $vars = array('titre', 'credits', 'ga', 'style', 'script', 'pagesContents');
                foreach ($vars as $v) {
                        $html = str_replace('<!-- $' . $v . ' -->', $$v, $html);
                }
@@ -214,7 +283,7 @@ class wsHTML5Compiler {
 
                $thtml = $uhtml;
 
-               $vars = array('titre', 'credits', 'ga', 'style', 'script');
+               $vars = array('titre', 'credits', 'ga', 'style', 'script', 'pagesContents');
                foreach ($vars as $v) {
                        $uhtml = str_replace('<!-- $' . $v . ' -->', $$v, $uhtml);
                }
@@ -358,22 +427,21 @@ class wsHTML5Compiler {
                }
                foreach ($this->pages as $page => $infos) {
                        foreach (self::$resolutions as $r) {
-                               $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/h' . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/p' . $page . '.jpg');
-                               $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/t' . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/t' . $page . '.jpg');
+                               $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/' . $this->backgroundsPrefix . $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');
                }
        }
-       
-       protected function copy($s,$t){
-               if(!file_exists($s)){
+
+       protected function copy($s, $t) {
+               if (!file_exists($s)) {
                        return;
                }
-               if(file_exists($t) && filemtime($t)>=filemtime($s) && filesize($s)==filesize($t)){
+               if (file_exists($t) && filemtime($t) >= filemtime($s) && filesize($s) == filesize($t)) {
                        return;
                }
-               
-               copy($s,$t);
+
+               copy($s, $t);
        }
 
        protected function writeCSS($file, $links) {
@@ -572,6 +640,7 @@ class wsHTML5Compiler {
                } while ($val > 0);
                return $str;
        }
+
        public function copyLinkFile($source, $dest, $video = false) {
                $origDir = WS_BOOKS . '/working/' . $this->book_id . '/';
                $types = array('flv', 'mp4', 'ogv', 'webm', 'jpg');
@@ -597,7 +666,7 @@ class wsHTML5Compiler {
                                if (!file_exists(dirname($d))) {
                                        mkdir(dirname($d), 0777, true);
                                }
-                               if(file_exists($d) && filemtime($d)>=filemtime($s) && filesize($d)==filesize($s)){
+                               if (file_exists($d) && filemtime($d) >= filemtime($s) && filesize($d) == filesize($s)) {
                                        continue;
                                }
                                copy($s, $d);
index f2f6614d7d8e26130d03cc226506be9d55b7061b..1548366bad352459dce1e8c27e10fe0d42992760 100644 (file)
@@ -190,39 +190,6 @@ class wsPackagerHTML extends wsPackager {
                        $rm->setArg(null, $dest . '/' . $f);\r
                }\r
                $rm->execute();\r
-\r
-               $this->writeHTML5Cache($dest);\r
-       }\r
-\r
-       public function writeHTML5Cache($dest) {\r
-               $ignore = array('data/l10n/([a-z-]{2,5}).json');\r
-\r
-               $dest = realpath($dest);\r
-               $lines = array();\r
-               $lines[] = 'CACHE MANIFEST';\r
-               $lines[] = '# ' . date('Y-m-d H:i:s');\r
-               $lines[] = '';\r
-               $lines[] = 'CACHE:';\r
-               $lines[] = 'index.html';\r
-               $dir = array('images', 'data', 'style');\r
-               foreach ($dir as $d) {\r
-                       $directory = $dest . '/' . $d;\r
-\r
-                       $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST);\r
-                       foreach ($iterator as $path) {\r
-                               if (!$path->isFile()) {\r
-                                       continue;\r
-                               }\r
-                               $p = str_replace($dest . '/', '', $path);\r
-                               foreach ($ignore as $i) {\r
-                                       if (preg_match('|' . $i . '|i', $p, $matches)) {\r
-                                               continue 2;\r
-                                       }\r
-                               }\r
-                               $lines[] = $p;\r
-                       }\r
-               }\r
-               file_put_contents($dest . '/cache.appcache', implode("\n", $lines));\r
        }\r
 \r
        public function makePackage($zip) {\r