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
$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 (α)'), 'icon' => cubeMedia::image(IMG . '/html5.png'));\r
- }\r
\r
$res = '<div class="contextMenu downbookContextMenu" id="' . $id . '">';\r
$res .= '<ul>';\r
\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
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
$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
$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
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();
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;
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);
}
$this->scale = 4;
$this->multiply = $this->pdf2htmlRatio * $this->scale;
$this->numerotation = explode(',', $this->book->numerotation);
-
- $this->createHTML();
}
public function virtualToPhysical($virtual) {
}
}
- protected function createHTML() {
+ public function compile() {
foreach ($this->layouts as $page => $layout) {
$this->div[$page] = array();
$document_id = $this->pages[$page]['document_id'];
$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';
protected function writeIndex($numCSS) {
$html = file_get_contents(WS_COMPILE_ASSETS . '/_html5/_index.html');
+ $uhtml = $html;
$titre = $this->book->parametres->title;
$credits = '';
}
$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() {
}
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';
$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;
if ($reminimize) {
$js = '';
- foreach ($files as $file) {
+ foreach (self::$jsFiles as $file) {
$js.=file_get_contents(WS_COMPILE_ASSETS . '/_html5/' . $file);
$js.="\n\n";
}
$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);
}
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) {
$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);
}
}
+
?>
\ No newline at end of file
class webLink extends normalLink {
public function getURL() {
- return wsPackagerHTML5Link::getUniversalLocation($this->to);
+ return wsHTML5Link::getUniversalLocation($this->to);
}
public function getTarget() {
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);
class colorLink extends contentLink {
public function getCSS() {
- return 'background-color:' . wsPackagerHTML5::colorToCSS($this->to) . ';';
+ return 'background-color:' . wsHTML5Compiler::colorToCSS($this->to) . ';';
}
}
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;';
}
}
public function getURL() {
$this->copyExternalFile($this->to);
- return wsPackagerHTML5Link::getUniversalLocation($this->to);
+ return wsHTML5Link::getUniversalLocation($this->to);
}
public function getTarget() {
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');
}
}
$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
<?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
$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
cubePHP::appendEnv('PATH', $tools . 'gs8.70/lib/');\r
cubePHP::setEnv('GS_FONTPATH', FONT_PATH);\r
}\r
-\r
?>
\ No newline at end of file