]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 15 Aug 2011 20:48:48 +0000 (20:48 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 15 Aug 2011 20:48:48 +0000 (20:48 +0000)
.htaccess
images/ws/html5bug.png [new file with mode: 0644]
inc/ws/Controlleur/class.ws.url.php
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Util/html5/class.ws.html5.compiler.php
inc/ws/Util/html5/class.ws.html5.links.php
inc/ws/Util/packager/class.ws.packager.php
inc/ws/_common.php

index b74df29d9bb27806244288a24c9d9ab5156d36a1..2f639c659148e89076f5c7dbc91506ff330d9e24 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -50,4 +50,10 @@ AddCharset UTF-8 log
        RewriteRule ^viewerp/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/index.swf$ fluidbook/compile/_standalone/player.swf [L]\r
        RewriteRule ^viewerp/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/fluidbook.js$ fluidbook/compile/fluidbook.js [L]\r
        RewriteRule ^viewerp/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/final/$1/$4 [L]\r
+\r
+       RewriteRule ^viewerh/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L]\r
+\r
+       RewriteRule ^viewerhu/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/js/(.+)$ fluidbook/compile/_html5/js/$4 [L]      \r
+       RewriteRule ^viewerhu/([0-9]+)_([0-9a-fA-F]+)_([0-9]+)/(.+)$ fluidbook/books/html5/$1/$4 [L]\r
+       \r
 </IfModule>
\ No newline at end of file
diff --git a/images/ws/html5bug.png b/images/ws/html5bug.png
new file mode 100644 (file)
index 0000000..5a8ba35
Binary files /dev/null and b/images/ws/html5bug.png differ
index 9771d7719428bda06269f424db18f38de378aefd..4bdcc0a72fcd55b8727c60b01c4783bfebccf5f4 100644 (file)
@@ -167,9 +167,6 @@ class wsUrl {
                $versions['win-ins'] = array('title' => __('Version offline') . ' - ' . __('Installeur Auto-executable Windows'), 'icon' => cubeMedia::silk('application_view_tile.png'));\r
                $versions['mac-exe'] = array('title' => __('Version offline') . ' - ' . __('ExĂ©cutable Mac OS X'), 'icon' => cubeMedia::image(IMG . '/macos.png'));\r
                $versions['win-cd'] = array('title' => __('Version offline') . ' - ' . __('CD-ROM') . ' / ' . __('ClĂ© USB'), 'icon' => cubeMedia::silk('cd.png'));\r
-               if (wsDroits::admin()) {\r
-                       $versions['html5'] = array('title' => __('Version HTML5 (&alpha;)'), 'icon' => cubeMedia::image(IMG . '/html5.png'));\r
-               }\r
 \r
                $res = '<div class="contextMenu downbookContextMenu" id="' . $id . '">';\r
                $res .= '<ul>';\r
@@ -208,8 +205,9 @@ class wsUrl {
 \r
                if (wsDroits::admin()) {\r
                        $viewers = array('viewer' => array('title' => __('Version Flash'), 'icon' => cubeMedia::image(IMG . '/flash.png')),\r
+                               'viewerh' => array('title' => __('Version HTML5'), 'icon' => cubeMedia::image(IMG . '/html5.png')),\r
                                'vieweru' => array('title' => __('Version Flash') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/flashbug.png')),\r
-                               'viewerh' => array('title' => __('Version HTML5'), 'icon' => cubeMedia::image(IMG . '/html5.png')));\r
+                               'viewerhu' => array('title' => __('Version HTML5') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/html5bug.png')));\r
                }\r
 \r
                $res = '<div class="contextMenu viewbookContextMenu" id="' . $id . '">';\r
@@ -592,6 +590,56 @@ html{height:100%}' . "\n";
                echo self::commonViewer($book_id, $e[1], false, 'default', true);\r
        }\r
 \r
+       public static function viewerh($args) {\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
+                       exit;\r
+               }\r
+\r
+               $book_id = $e[0];\r
+               $hash = $e[1];\r
+               self::commonHTML5Viewer($book_id, $hash);\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
+                       http::redirect(SITE_PATH . 'viewerhu/' . implode('_', $e) . '/');\r
+                       exit;\r
+               }\r
+\r
+               $book_id = $e[0];\r
+               $hash = $e[1];\r
+               self::commonHTML5Viewer($book_id, $hash, 'u');\r
+       }\r
+\r
+       public static function commonHTML5Viewer($book_id, $hash, $version='') {\r
+               global $core;\r
+               self::checkDocumentVersionOfBook($book_id);\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
+                       $dao->compile($book_id);\r
+                       $dao->touchCompile($book_id);\r
+               }\r
+               echo file_get_contents(WS_BOOKS . '/html5/' . $book_id . '/index' . $version . '.html');\r
+               exit;\r
+       }\r
+\r
        public static function viewer($args) {\r
                $args = cubePage::getArgs($args);\r
 \r
index b23d97023e1a0fcebb709b2a2fe736163a1fa80e..bd80334f7a6ca1a5a9ea18d35ae60fe616f484b3 100644 (file)
@@ -530,9 +530,25 @@ class wsDAOBook extends commonDAO {
                $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
        }\r
 \r
-       public function isUpToDate($book_id) {\r
+       public function isUpToDate($book_id, $html=false) {\r
                $r = $this->con->select('SELECT changedate,compiledate FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
-               return $r->compiledate > $r->changedate;\r
+               if ($r->compiledate < $r->changedate) {\r
+                       return false;\r
+               }\r
+\r
+               $checks = array($r->changedate, filemtime(WS_COMPILE_ASSETS . '/_html5'));\r
+               $reffile = WS_BOOKS . '/html5/' . $book_id;\r
+\r
+               if (!file_exists($reffile)) {\r
+                       return false;\r
+               }\r
+               $reftime = filemtime($reffile);\r
+               foreach ($checks as $check) {\r
+                       if ($check > $reftime) {\r
+                               return false;\r
+                       }\r
+               }\r
+               return true;\r
        }\r
 \r
        public function setComposition($book_id, $pages) {\r
@@ -880,10 +896,16 @@ class wsDAOBook extends commonDAO {
                $this->compilePDF($book, $pages);\r
                $this->indexPDF($book, $pages);\r
                $this->touchCompile($book_id);\r
+               $this->compileHTML5($book_id);\r
 \r
                return $res;\r
        }\r
 \r
+       protected function compileHTML5($book_id) {\r
+               $htmlCompiler = new wsHTML5Compiler($book_id);\r
+               $htmlCompiler->compile();\r
+       }\r
+\r
        public function indexPDF($book, $pages) {\r
                $indexPath = WS_BOOKS . '/search/' . $book->book_id;\r
 \r
index 44ef1616771fffefeb5ebef1c13475cb44078189..abed44590af68f598ef30e3967c94e604e57fc90 100644 (file)
@@ -2,6 +2,24 @@
 
 class wsHTML5Compiler {
 
+       protected static $resolutions = array(36, 72, 150);
+       protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', '');
+       protected static $jsFiles = array('js/libs/modernizr.js',
+               'js/libs/jquery/jquery.js',
+               'js/libs/jquery/jquery.transform.js',
+               'js/libs/jquery/jquery.mousewheel.js',
+               'js/libs/jquery/jquery.hashchange.js',
+               'js/libs/fluidbook/fluidbook.utils.js',
+               'js/libs/fluidbook/fluidbook.cache.js',
+               'js/libs/fluidbook/fluidbook.support.js',
+               'js/libs/fluidbook/fluidbook.viewport.js',
+               'js/libs/fluidbook/fluidbook.desktop.js',
+               'js/libs/fluidbook/fluidbook.service.js',
+               'js/libs/fluidbook/fluidbook.loader.js',
+               'js/libs/fluidbook/fluidbook.l10n.js',
+               'js/libs/fluidbook/fluidbook.nav.js',
+               'js/libs/fluidbook/fluidbook.js',
+               'js/main.js');
        protected $layouts = array();
        protected $cssSize = array();
        protected $cssColor = array();
@@ -17,8 +35,6 @@ class wsHTML5Compiler {
        protected $multiply;
        protected $div = array();
        protected $numerotation;
-       protected static $resolutions = array(36, 72, 150);
-       protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', '');
        protected $fontDocs = array();
        protected $dir;
        protected $vdir;
@@ -29,12 +45,21 @@ class wsHTML5Compiler {
        protected $book_id;
        protected $themeRoot;
        protected $daoBook;
+       protected $needToRecompileContents = true;
+       protected $needToRecompileSettings = true;
 
        function __construct($book_id) {
+               global $core;
+
+               if (trim($book_id) == '') {
+                       return;
+               }
                $this->book_id = $book_id;
 
                $this->vdir = $this->dir = WS_BOOKS . '/html5/' . $book_id . '/';
 
+               // Clean the folder
+               `rm -rf $this->vdir`;
                if (!file_exists($this->dir)) {
                        mkdir($this->dir, 0777, true);
                }
@@ -59,8 +84,6 @@ class wsHTML5Compiler {
                $this->scale = 4;
                $this->multiply = $this->pdf2htmlRatio * $this->scale;
                $this->numerotation = explode(',', $this->book->numerotation);
-
-               $this->createHTML();
        }
 
        public function virtualToPhysical($virtual) {
@@ -79,7 +102,7 @@ class wsHTML5Compiler {
                }
        }
 
-       protected function createHTML() {
+       public function compile() {
                foreach ($this->layouts as $page => $layout) {
                        $this->div[$page] = array();
                        $document_id = $this->pages[$page]['document_id'];
@@ -93,14 +116,15 @@ class wsHTML5Compiler {
                                $this->div[$page][] = $this->addLine($line, $document_id);
                        }
                }
-               mkdir($this->vdir . '/data/images', 0777, true);
-               mkdir($this->vdir . '/data/contents', 0777, true);
-               mkdir($this->vdir . '/data/background', 0777, true);
-               mkdir($this->vdir . '/data/thumbnails', 0777, true);
-               mkdir($this->vdir . '/data/style', 0777, true);
-               mkdir($this->vdir . '/data/links/pages', 0777, true);
-               mkdir($this->vdir . '/data/l10n/', 0777, true);
-               mkdir($this->vdir . '/swf', 0777, true);
+
+               $dirsToCreate = array('data/images', 'data/contents', 'data/background', 'data/thumbnails', 'data/style', 'data/links/pages', 'data/l10n', 'swf');
+
+               foreach ($dirsToCreate as $dir) {
+                       $d = $this->vdir . '/' . $dir;
+                       if (!file_exists($d)) {
+                               mkdir($d, 0777, true);
+                       }
+               }
 
                // Copy style folder
                $from = WS_COMPILE_ASSETS . '/_html5/style';
@@ -128,6 +152,7 @@ class wsHTML5Compiler {
 
        protected function writeIndex($numCSS) {
                $html = file_get_contents(WS_COMPILE_ASSETS . '/_html5/_index.html');
+               $uhtml = $html;
 
                $titre = $this->book->parametres->title;
                $credits = '';
@@ -147,11 +172,27 @@ class wsHTML5Compiler {
                }
                $style = implode("\n\t\t", $style);
 
-               $vars = array('titre', 'credits', 'ga', 'style');
+               $script = '<script type="text/javascript" src="data/fluidbook.js"></script>';
+
+               $vars = array('titre', 'credits', 'ga', 'style', 'script');
                foreach ($vars as $v) {
                        $html = str_replace('<!-- $' . $v . ' -->', $$v, $html);
                }
+
+               $scripts = array();
+               foreach (self::$jsFiles as $js) {
+                       $scripts[] = '<script type="text/javascript" src="' . $js . '"></script>';
+               }
+               $scripts[] = '<script type="text/javascript" src="data/datas.js"></script>';
+               $script = implode("\n\t\t", $scripts);
+
+               $vars = array('titre', 'credits', 'ga', 'style', 'script');
+               foreach ($vars as $v) {
+                       $uhtml = str_replace('<!-- $' . $v . ' -->', $$v, $uhtml);
+               }
+
                file_put_contents($this->vdir . '/index.html', $html);
+               file_put_contents($this->vdir . '/indexu.html', $uhtml);
        }
 
        protected function writeLangs() {
@@ -200,22 +241,7 @@ class wsHTML5Compiler {
        }
 
        protected function writeJs() {
-               $files = array('js/libs/modernizr.js',
-                       'js/libs/jquery/jquery.js',
-                       'js/libs/jquery/jquery.transform.js',
-                       'js/libs/jquery/jquery.mousewheel.js',
-                       'js/libs/jquery/jquery.hashchange.js',
-                       'js/libs/fluidbook/fluidbook.utils.js',
-                       'js/libs/fluidbook/fluidbook.cache.js',
-                       'js/libs/fluidbook/fluidbook.support.js',
-                       'js/libs/fluidbook/fluidbook.viewport.js',
-                       'js/libs/fluidbook/fluidbook.desktop.js',
-                       'js/libs/fluidbook/fluidbook.service.js',
-                       'js/libs/fluidbook/fluidbook.loader.js',
-                       'js/libs/fluidbook/fluidbook.l10n.js',
-                       'js/libs/fluidbook/fluidbook.nav.js',
-                       'js/libs/fluidbook/fluidbook.js',
-                       'js/main.js');
+
 
                $mintime = 0;
                $minimized = WS_COMPILE_ASSETS . '/_html5/js/min.js';
@@ -223,7 +249,7 @@ class wsHTML5Compiler {
                        $mintime = filemtime($minimized);
                }
                $reminimize = false;
-               foreach ($files as $file) {
+               foreach (self::$jsFiles as $file) {
                        if (filemtime(WS_COMPILE_ASSETS . '/_html5/' . $file) > $mintime) {
                                $reminimize = true;
                                break;
@@ -232,7 +258,7 @@ class wsHTML5Compiler {
 
                if ($reminimize) {
                        $js = '';
-                       foreach ($files as $file) {
+                       foreach (self::$jsFiles as $file) {
                                $js.=file_get_contents(WS_COMPILE_ASSETS . '/_html5/' . $file);
                                $js.="\n\n";
                        }
@@ -249,8 +275,9 @@ class wsHTML5Compiler {
                        $compressor->execute();
                }
 
-               $js = $this->writeConfig();
-               $js.=file_get_contents($minimized);
+               $config = $this->writeConfig();
+               $js=$config.file_get_contents($minimized);
+               file_put_contents($this->vdir.'/data/datas.js',$config);
                file_put_contents($this->vdir . '/data/fluidbook.js', $js);
        }
 
@@ -302,7 +329,7 @@ class wsHTML5Compiler {
        protected function writeImages() {
 
                foreach (self::$resolutions as $r) {
-                       mkdir($this->vdir . '/data/background/' . $r, 0777);
+                       mkdir($this->vdir . '/data/background/' . $r, 0777, true);
                }
                foreach ($this->pages as $page => $infos) {
                        foreach (self::$resolutions as $r) {
@@ -838,7 +865,6 @@ class wsHTML5Compiler {
                $origDir = WS_BOOKS . '/working/' . $this->book_id . '/';
                $types = array('mp4', 'ogv', 'webm', 'jpg');
                if ($video) {
-                       return;
                        wsTools::encodeWebVideos($origDir . $source, null, false);
                        $e = explode('.', $source);
                        array_pop($e);
@@ -912,4 +938,5 @@ class wsHTML5Compiler {
        }
 
 }
+
 ?>
\ No newline at end of file
index b0bf8cb3be5eb9eb740a8ce9f8677d69e82680ca..d2eee02ab2dc0e28a6b5f10664303ca377c4bc22 100644 (file)
@@ -149,7 +149,7 @@ class contentLink extends wsHTML5Link {
 class webLink extends normalLink {
 
        public function getURL() {
-               return wsPackagerHTML5Link::getUniversalLocation($this->to);
+               return wsHTML5Link::getUniversalLocation($this->to);
        }
 
        public function getTarget() {
@@ -224,10 +224,10 @@ class videoLink extends wsHTML5Link {
                        if ($type != '') {
                                $type = " type='" . $type . "'";
                        }
-                       $res.='<source src="' . wsPackagerHTML5Link::getUniversalLocation($basename . '.' . $ext) . '"' . $type . ' />';
+                       $res.='<source src="' . wsHTML5Link::getUniversalLocation($basename . '.' . $ext) . '"' . $type . ' />';
                }
-               $flashvars = array('video' => wsPackagerHTML5Link::getUniversalLocation($basename . '.mp4'),
-                       'poster' => wsPackagerHTML5Link::getUniversalLocation($basename . '.jpg'),
+               $flashvars = array('video' => wsHTML5Link::getUniversalLocation($basename . '.mp4'),
+                       'poster' => wsHTML5Link::getUniversalLocation($basename . '.jpg'),
                        'controls' => $this->video_controls == '1',
                        'autoPlay' => $this->video_auto_start == '1',
                        'loop' => $this->video_loop);
@@ -274,7 +274,7 @@ class basketLink extends wsHTML5Link {
 class colorLink extends contentLink {
 
        public function getCSS() {
-               return 'background-color:' . wsPackagerHTML5::colorToCSS($this->to) . ';';
+               return 'background-color:' . wsHTML5Compiler::colorToCSS($this->to) . ';';
        }
 
 }
@@ -283,7 +283,7 @@ class imageLink extends contentLink {
 
        public function getCSS() {
                $this->copyExternalFile($this->to);
-               return 'background-image:url(' . wsPackagerHTML5Link::getUniversalLocation($this->to, true) . ');background-size:100% 100%;background-repeat:no-repeat;';
+               return 'background-image:url(' . wsHTML5Link::getUniversalLocation($this->to, true) . ');background-size:100% 100%;background-repeat:no-repeat;';
        }
 
 }
@@ -292,7 +292,7 @@ class fileLink extends normalLink {
 
        public function getURL() {
                $this->copyExternalFile($this->to);
-               return wsPackagerHTML5Link::getUniversalLocation($this->to);
+               return wsHTML5Link::getUniversalLocation($this->to);
        }
 
        public function getTarget() {
@@ -304,7 +304,7 @@ class fileLink extends normalLink {
 class multimediaLink extends wsHTML5Link {
 
        public function getHTMLContent() {
-               return cubeMedia::flashObject(wsPackagerHTML5Link::getUniversalLocation($this->to), $this->width, $this->height, array(), '', '', 9, '#ffffff', '', 'true', 'noscale', 'transparent');
+               return cubeMedia::flashObject(wsHTML5Link::getUniversalLocation($this->to), $this->width, $this->height, array(), '', '', 9, '#ffffff', '', 'true', 'noscale', 'transparent');
        }
 
 }
index 78702703e1227390621ac3a3dab710ff071d3298..564e37987be82c8292b7a1ef00c553a6598a4a02 100644 (file)
@@ -24,8 +24,6 @@ class wsPackager {
                        $packager = new wsPackagerWinINST($book_id);\r
                } elseif ($version == 'mac-exe') {\r
                        $packager = new wsPackagerMacEXE($book_id);\r
-               } elseif ($version == 'html5') {\r
-                       $packager = new wsPackagerHTML5($book_id);\r
                }\r
 \r
                return $packager->makePackage();\r
index e803a91278ba6c5927f0017ea98b9f9db0d15b97..18585940b86e3e6d9c100fd66f89708696842419 100644 (file)
@@ -1,4 +1,5 @@
 <?php\r
+\r
 // Inclusion des classes propres au Fluidbook Workshop\r
 require_once(dirname(__FILE__) . '/Metier/_common.php');\r
 require_once(dirname(__FILE__) . '/Controlleur/_common.php');\r
@@ -15,6 +16,8 @@ $core->url->register('restoreLinks', 'restoreLinks', '^restoreLinks/(.*)$', arra
 $core->url->register('viewer', 'viewer', '^viewer/(.*)$', array('wsUrl', 'viewer'));\r
 $core->url->register('vieweru', 'vieweru', '^vieweru/(.*)$', array('wsUrl', 'vieweru'));\r
 $core->url->register('viewerp', 'viewerp', '^viewerp/(.*)$', array('wsUrl', 'viewerp'));\r
+$core->url->register('viewerh', 'viewerh', '^viewerh/(.*)$', array('wsUrl', 'viewerh'));\r
+$core->url->register('viewerhu', 'viewerhu', '^viewerhu/(.*)$', array('wsUrl', 'viewerhu'));\r
 \r
 if (DEV) {\r
        $tools = ROOT . '/../inc/tools/';\r
@@ -23,5 +26,4 @@ if (DEV) {
        cubePHP::appendEnv('PATH', $tools . 'gs8.70/lib/');\r
        cubePHP::setEnv('GS_FONTPATH', FONT_PATH);\r
 }\r
-\r
 ?>
\ No newline at end of file