From: vincent@cubedesigners.com Date: Mon, 15 Aug 2011 01:41:45 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=c44313b937b645a67a8fe538fad29666eccf72a5;p=cubeextranet.git --- diff --git a/inc/ws/Util/packager/html5/class.ws.packager.html5.php b/inc/ws/Util/packager/html5/class.ws.packager.html5.php index 7a82629ec..bd1c2b22a 100644 --- a/inc/ws/Util/packager/html5/class.ws.packager.html5.php +++ b/inc/ws/Util/packager/html5/class.ws.packager.html5.php @@ -87,6 +87,19 @@ class wsPackagerHTML5 extends wsPackager { 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); + + // Copy style folder + $from = WS_COMPILE_ASSETS . '/_html5/style'; + $to = $this->vdir; + `cp -r $from $to`; + + // Copy images folder + $from = WS_COMPILE_ASSETS . '/_html5/images'; + `cp -r $from $to`; + + // Copy swf + copy(WS_COMPILE_ASSETS . '/_html5/swf/video.swf', $this->vdir . '/swf/video.swf'); foreach ($this->div as $n => $page) { file_put_contents($this->vdir . '/data/contents/p' . $n . '.html', $this->writePage($page)); @@ -94,10 +107,38 @@ class wsPackagerHTML5 extends wsPackager { $this->writeFonts(); $this->writeImages(); $linksCSS = $this->writeLinks(); - $this->writeCSS($this->vdir . '/data/style/style_%d.css', $linksCSS); + $numCSS = $this->writeCSS($this->vdir . '/data/style/style_%d.css', $linksCSS); $this->writeLangs(); + $this->writeJs(); + $this->writeIndex($numCSS); + } + + protected function writeIndex($numCSS) { + $html = file_get_contents(WS_COMPILE_ASSETS . '/_html5/_index.html'); - file_put_contents($this->vdir . '/data/datas.js', $this->writeConfig()); + $titre = $this->book->parametres->title; + $credits = ''; + // Google analytics + $ga = ''; + if ($this->book->parametres->googleAnalytics != '') { + $ga = cubePage::googleAnalytics($this->book->parametres->googleAnalytics); + } + // Feuilles de style + $sheets = array('style/fluidbook.css'); + for ($i = 0; $i < $numCSS; $i++) { + $sheets[] = 'data/style/style_' . $i . '.css'; + } + $style = array(); + foreach ($sheets as $sheet) { + $style[] = ''; + } + $style = implode("\n\t\t", $style); + + $vars = array('titre', 'credits', 'ga', 'style'); + foreach ($vars as $v) { + $html = str_replace('', $$v, $html); + } + file_put_contents($this->vdir . '/index.html', $html); } protected function writeLangs() { @@ -145,12 +186,68 @@ class wsPackagerHTML5 extends wsPackager { return $css; } + protected function writeJs() { + $files = array('js/libs/modernizr.js', + 'js/libs/sylvester.js', + 'js/libs/jquery/jquery.js', + 'js/libs/jquery/jquery.transform.js', + 'js/libs/jquery/jquery.mousewheel.js', + 'js/libs/swfaddress.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'; + if (file_exists($minimized)) { + $mintime = filemtime($minimized); + } + $reminimize = false; + foreach ($files as $file) { + if (filemtime(WS_COMPILE_ASSETS . '/_html5/' . $file) > $mintime) { + $reminimize = true; + break; + } + } + + if ($reminimize) { + $js = ''; + foreach ($files as $file) { + $js.=file_get_contents(WS_COMPILE_ASSETS . '/_html5/' . $file); + $js.="\n\n"; + } + $tmp = cubeFiles::tempnam(); + file_put_contents($tmp, $js); + + $compressor = new cubeCommandLine('yuicompressor'); + $compressor->setPath(CONVERTER_PATH); + $compressor->setArg('charset', 'UTF-8'); + $compressor->setArg('type', 'js'); + $compressor->setArg('line-break', 1024); + $compressor->setArg('o', $minimized); + $compressor->setArg(null, $tmp); + $compressor->execute(); + } + + $js = $this->writeConfig(); + $js.=file_get_contents($minimized); + file_put_contents($this->vdir . '/data/fluidbook.js', $js); + } + protected function writeConfig() { $config = cubeObject::merge($this->book->parametres->toStandardObject(), $this->theme->parametres->toStandardObject()); $config->numerotation = explode(',', $this->book->numerotation); $config->id = $this->book->book_id; $config->cacheDate = TIME; - return 'DATAS=' . json_encode($config) . ';'; + return 'var DATAS=' . json_encode($config) . ';' . "\n"; } protected function writeFonts() { @@ -474,6 +571,7 @@ class wsPackagerHTML5 extends wsPackager { foreach ($res as $k => $css) { file_put_contents(sprintf($file, $k), implode("\n", $css)); } + return count($res); } protected function writeCSSUA($property, $value) { @@ -532,7 +630,7 @@ class wsPackagerHTML5 extends wsPackager { $res[] = array( 'color' => $this->getCSSColor($group['color']), 'size' => $this->getCSSSize($group['size']), - 'font' => $this->getCSSFont((string)$group['font'], $document_id), + 'font' => $this->getCSSFont((string) $group['font'], $document_id), 'letterspacing' => $this->getCSSLetterSpacing($ls), 'wordspacing' => $this->getCSSLetterSpacing($ws), 'y' => 0, @@ -630,7 +728,7 @@ class wsPackagerHTML5 extends wsPackager { } protected function getCSSFont($font, $document_id) { - $font=(string) $font; + $font = (string) $font; if (!isset($this->fontDocs[$font])) { $this->fontDocs[$font] = array(); }