]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sun, 18 Mar 2012 17:57:12 +0000 (17:57 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sun, 18 Mar 2012 17:57:12 +0000 (17:57 +0000)
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

index d0fbd18bb08f6f25519e9d8af1bb7b4b814e209b..f945ca7b660bde657f33b3be2134d0f40c5f466c 100644 (file)
@@ -628,7 +628,7 @@ html{height:100%}' . "\n";
 \r
        public static function viewerh($args) {\r
                global $core;\r
-       \r
+\r
                $args = cubePage::getArgs($args);\r
 \r
                $e = explode('_', $args[0]);\r
@@ -644,7 +644,7 @@ html{height:100%}' . "\n";
                }\r
 \r
                if (!$dao->isUpToDate($book_id)) {\r
-                       if ($version == 'u' || $version == 't') {\r
+                       if (isset($version) && ($version == 'u' || $version == 't')) {\r
                                $dao->compileHTML5($book_id);\r
                        } else {\r
                                $dao->compile($book_id);\r
index b6d3fa1a53d4c1452bf79ce833a854ceacd313d7..7cab8b482c97604d1c2fb59d549606d78d32969e 100644 (file)
@@ -247,7 +247,6 @@ class wsDAOBook extends commonDAO {
        public function getPagesOfBook($book_id) {\r
                $pages = array();\r
                $r = $this->con->select('SELECT b.*,d.numberSections AS num,d.conversionInfos AS conversion,d.pages AS doc_pages,d.version AS version FROM book_pages b JOIN documents d ON d.document_id=b.document_id WHERE b.book_id=\'' . $this->con->escape($book_id) . '\' ORDER BY book_page');\r
-               $update = $r->composition_update;\r
                while ($r->fetch()) {\r
                        $n = explode(',', $r->num);\r
                        if ($r->conversion != '') {\r
index c075969478b03e7483f7330a8359427b61d2acc5..a23cab9570d27761b57941f27889d81e2219a54b 100644 (file)
@@ -14,6 +14,7 @@ class wsHTML5Compiler {
                'js/libs/jquery/jquery.hashchange.js',
                'js/libs/fluidbook/fluidbook.utils.js',
                'js/libs/fluidbook/fluidbook.support.js',
+               'js/libs/fluidbook/fluidbook.video.js',
                'js/libs/fluidbook/fluidbook.viewport.js',
                'js/libs/fluidbook/fluidbook.desktop.js',
                'js/libs/fluidbook/fluidbook.service.js',
@@ -167,7 +168,9 @@ class wsHTML5Compiler {
        }
 
        protected function writeCache() {
-               $ignore = array('data/l10n/([a-z-]{2,5}).json', '(.*).ogv', '(.*).flv', '(.*).mp4', '(.*).webm');
+               $videosExtensions = array('flv', 'ogv', 'webm', 'mp4');
+               $videos = array('flv' => array(), 'ogv' => array(), 'webm' => array(), 'mp4' => array());
+               $ignore = array('data/l10n/([a-z-]{2,5}).json');
 
                $cacheFile = $this->vdir . '/cache.appcache';
 
@@ -178,7 +181,7 @@ class wsHTML5Compiler {
                $dest = realpath($this->vdir);
                $lines = array();
 
-               $network = array('NETWORK:','*');
+               $network = array('NETWORK:', '*');
 
                $lines[] = 'CACHE MANIFEST';
                $lines[] = '# ' . date('Y-m-d H:i:s');
@@ -190,13 +193,11 @@ class wsHTML5Compiler {
                $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';
@@ -222,6 +223,12 @@ class wsHTML5Compiler {
                                        foreach ($ignore as $i) {
                                                if (preg_match('|' . $i . '|i', $p, $matches)) {
                                                        continue 2;
+                                               } else {
+                                                       $ext = strtolower(files::getExtension($p));
+                                                       if (in_array($ext, $videosExtensions)) {
+                                                               $videos[$ext][] = $path->getFilename();
+                                                               continue 2;
+                                                       }
                                                }
                                        }
                                        $lines[] = $p;
@@ -233,6 +240,27 @@ class wsHTML5Compiler {
                $lines = array_merge($lines, $network);
 
                file_put_contents($cacheFile, implode("\n", $lines));
+
+               foreach ($videos as $format => $v) {
+                       if (!count($v)) {
+                               continue;
+                       }
+                       $cacheFile = $dest . '/data/links/video.' . $format . '.appcache';
+                       $htmlFile = $dest . '/data/links/video.' . $format . '.html';
+
+                       $html = '<!DOCTYPE html><html manifest="video.' . $format . '.appcache"><head></head><body></body></html>';
+                       file_put_contents($htmlFile, $html);
+
+                       $lines = array();
+                       $lines[] = 'CACHE MANIFEST';
+                       $lines[] = '# ' . date('Y-m-d H:i:s');
+                       $lines[] = '';
+                       $lines[] = 'CACHE:';
+                       foreach ($v as $video) {
+                               $lines[] = $video;
+                       }
+                       file_put_contents($cacheFile, implode("\n", $lines));
+               }
        }
 
        protected function writeIndex($numCSS) {
index 4abb2296cd4561426e95fb76f144e9fc8f237b16..89164d9c211b15905deff6cf27a938679d4128b5 100644 (file)
@@ -85,6 +85,14 @@ class wsHTML5Link {
                return '';
        }
 
+       public function getAdditionnalContent() {
+               
+       }
+       
+       public function getClasses(){
+               return array();
+       }
+
        public function copyExternalFile($file, $video = false) {
                $this->compiler->copyLinkFile($file, 'data/links/', $video);
        }
@@ -121,7 +129,7 @@ class wsHTML5Link {
 class normalLink extends wsHTML5Link {
 
        public function getHTMLContent() {
-               $class = array();
+               $class =$this->getClasses();
                if ($this->display_area) {
                        $class[] = 'displayArea';
                }
@@ -129,7 +137,7 @@ class normalLink extends wsHTML5Link {
                if (count($class)) {
                        $c = ' class="' . implode(' ', $class) . '"';
                }
-               return '<a href="' . $this->getURL() . '" target="' . $this->getTarget() . '"' . $c . '></a>';
+               return '<a href="' . $this->getURL() . '" target="' . $this->getTarget() . '"' . $c . $this->getAdditionnalContent() . '></a>';
        }
 
        public function getURL() {
@@ -193,50 +201,58 @@ class internalLink extends normalLink {
 class videoLink extends wsHTML5Link {
 
        public function getHTMLContent() {
-               $file = $this->to;
+               $this->copyExternalFile($this->to, true);
+
+               $w = round($this->width * $this->compiler->getCssScale());
+               $h = round($this->height * $this->compiler->getCssScale());
+
+               return self::makeVideoTag($this, $w, $h);
+       }
+
+       public static function makeVideoTag($linkDatas, $w = null, $h = null) {
+               $file = $linkDatas->to;
                $e = explode('.', $file);
                $ext = array_pop($e);
                $basename = implode('.', $e);
-               $w = round($this->width * $this->compiler->getCssScale());
-               $h = round($this->height * $this->compiler->getCssScale());
 
-               $res = '<div class="videoContainer">';
-               $res.='<video width="' . $w . '" height="' . $h . '"';
-               if ($this->video_auto_start) {
-                       $res.=' autoplay="autoplay"';
-               }
-               $res.=' controls="controls"';
-               if (!$this->video_controls) {
-                       $res.=' onplay="hideControls(this)"';
-               }
-               if ($this->video_loop) {
-                       $res.=' onended="this.play();"';
-               }
-               if (!$this->video_sound_on) {
-                       $res.=' audio="muted"';
-               }
-               $res.=' poster="data/links/' . $basename . '.jpg"';
-               $res.='>';
-               $this->copyExternalFile($this->to, true);
-               $types = array('webm' => 'video/webm; codecs="vp8, vorbis"', 'ogv' => 'video/ogg; codecs="theora, vorbis"', 'mp4' => '');
-               foreach ($types as $ext => $type) {
-                       if ($type != '') {
-                               $type = " type='" . $type . "'";
-                       }
-                       $res.='<source src="' . wsHTML5Link::getUniversalLocation($basename . '.' . $ext) . '"' . $type . ' />';
+               $autoplay = ($linkDatas->video_auto_start ? '1' : '0');
+               $controls = ($linkDatas->video_controls ? '1' : '0');
+               $loop = ($linkDatas->video_loop ? '1' : '0');
+               $sound = ($linkDatas->video_sound_on ? '1' : '0');
+
+               $res = '<div class="videoContainer" ';
+               if (!is_null($w) && !is_null($h)) {
+                       $res.='data-width="' . $w . '" data-height="' . $h . '" ';
                }
-               $flashvars = array('video' => '../'.wsHTML5Link::getUniversalLocation($file),
-                       'poster' => wsHTML5Link::getUniversalLocation($basename . '.jpg'),
-                       'controls' => $this->video_controls == '1',
-                       'autoPlay' => $this->video_auto_start == '1',
-                       'loop' => $this->video_loop);
-               $res.='</video>';
-               $res.=cubeMedia::flashObject('swf/video.swf', $w, $h, $flashvars, 'swfplayer-' . $basename, '', 9, '#ffffff', '', 'true', 'noscale', 'normal');
+               $res.=' data-autoplay="' . $autoplay . '"';
+               $res.=' data-controls="' . $controls . '"';
+               $res.=' data-loop="' . $loop . '"';
+               $res.=' data-sound="' . $sound . '"';
+               $res.=' data-name="' . $basename . '"';
+               $res.='></div>';
                return $res;
        }
 
 }
 
+class videoPopupLink extends normalLink {
+
+       public function getURL() {
+               $this->copyExternalFile($this->to, true);
+               $file = $this->to;
+               $e = explode('.', $file);
+               $ext = array_pop($e);
+               $basename = implode('.', $e);
+
+               return '#/video/' . $basename;
+       }
+       
+       public function getAdditionnalContent() {
+               return ' data-video="'.rawurlencode(videoLink::makeVideoTag($this)).'" ';
+       }
+
+}
+
 class webVideoLink extends videoLink {
 
        public function getHTMLContent() {
@@ -308,15 +324,6 @@ class multimediaLink extends wsHTML5Link {
 
 }
 
-class videoPopupLink extends normalLink {
-
-       public function getURL() {
-               $this->copyExternalFile($this->to, true);
-               return '#/video/' . $this->to;
-       }
-
-}
-
 class webVideoPopupLink extends videoPopupLink {
 
        public function getURL() {