From 7266c0a016fefb51834e7242b8c38969c9ef9709 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Sun, 18 Mar 2012 17:57:12 +0000 Subject: [PATCH] --- inc/ws/Controlleur/class.ws.url.php | 4 +- inc/ws/DAO/class.ws.dao.book.php | 1 - inc/ws/Util/html5/class.ws.html5.compiler.php | 36 ++++++- inc/ws/Util/html5/class.ws.html5.links.php | 97 ++++++++++--------- 4 files changed, 86 insertions(+), 52 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index d0fbd18bb..f945ca7b6 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -628,7 +628,7 @@ html{height:100%}' . "\n"; public static function viewerh($args) { global $core; - + $args = cubePage::getArgs($args); $e = explode('_', $args[0]); @@ -644,7 +644,7 @@ html{height:100%}' . "\n"; } if (!$dao->isUpToDate($book_id)) { - if ($version == 'u' || $version == 't') { + if (isset($version) && ($version == 'u' || $version == 't')) { $dao->compileHTML5($book_id); } else { $dao->compile($book_id); diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index b6d3fa1a5..7cab8b482 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -247,7 +247,6 @@ class wsDAOBook extends commonDAO { public function getPagesOfBook($book_id) { $pages = array(); $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'); - $update = $r->composition_update; while ($r->fetch()) { $n = explode(',', $r->num); if ($r->conversion != '') { diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index c07596947..a23cab957 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -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 = ''; + 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) { diff --git a/inc/ws/Util/html5/class.ws.html5.links.php b/inc/ws/Util/html5/class.ws.html5.links.php index 4abb2296c..89164d9c2 100644 --- a/inc/ws/Util/html5/class.ws.html5.links.php +++ b/inc/ws/Util/html5/class.ws.html5.links.php @@ -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 ''; + return 'getAdditionnalContent() . '>'; } 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 = '
'; - $res.='