From e294525f3be97d4bf438d9fa75ca5653bd262def Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 17 Feb 2012 17:58:44 +0000 Subject: [PATCH] --- .../Controlleur/class.extranet.tools.php | 19 +++++------ inc/ws/Util/html5/class.ws.html5.compiler.php | 22 ++++++------ .../Util/packager/class.ws.packager.html.php | 34 ++++++++++++++++++- inc/ws/Util/packager/class.ws.packager.v1.php | 21 +++++++++--- 4 files changed, 68 insertions(+), 28 deletions(-) diff --git a/inc/extranet/Controlleur/class.extranet.tools.php b/inc/extranet/Controlleur/class.extranet.tools.php index 6edacc5d9..66d1cad09 100644 --- a/inc/extranet/Controlleur/class.extranet.tools.php +++ b/inc/extranet/Controlleur/class.extranet.tools.php @@ -45,16 +45,16 @@ class extranetTools { $tmp = cubeFiles::tempdir(); mkdir($tmp, 0777, true); - - - - $upload=$_FILES['file']['tmp_name']; + + + + $upload = $_FILES['file']['tmp_name']; $icotool = new cubeCommandLine('icotool'); $icotool->setArg('c'); $icotool->setArg('o', $tmp . '/favicon.ico'); - $sizes = array(256, 128, 114, 72, 64, 57, 32, 16); + $sizes = array(128, 114, 72, 64, 57, 32, 16); $apple = array(114, 72, 57); @@ -76,7 +76,7 @@ class extranetTools { $icotool->execute(); - rename($tmp . '/ico-16.png', $tmp.'/favicon.png'); + rename($tmp . '/ico-16.png', $tmp . '/favicon.png'); foreach ($sizes as $s) { if ($s == 16 || in_array($s, $apple)) { @@ -85,7 +85,7 @@ class extranetTools { unlink($tmp . '/ico-' . $s . '.png'); } - $tmpfile = cubeFiles::tempnam().'.zip'; + $tmpfile = cubeFiles::tempnam() . '.zip'; $zip = new cubeCommandLine('zip'); $zip->cd($tmp); @@ -96,10 +96,7 @@ class extranetTools { $zip->setArg('X'); $zip->setArg(null, '.'); $zip->execute(); - - fb($zip->commande); - fb($zip->output); - + cubeHTTP::downloadFile($tmpfile, 'favicon.zip'); } diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index d8ab1e35f..ca72b3a70 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -70,10 +70,11 @@ class wsHTML5Compiler { protected $optimalHeight = 709; protected $additionalConfig = array(); protected $fontScale = 1; + protected $cache = array(); function __construct($book_id) { global $core; - + cubePHP::set_memory('4G'); if (trim($book_id) == '') { @@ -164,8 +165,6 @@ class wsHTML5Compiler { } public function compile() { - - foreach ($this->layouts as $page => $layout) { $lines = $this->sortPage($layout); $document_id = $this->pages[$page]['document_id']; @@ -226,7 +225,7 @@ class wsHTML5Compiler { } $style = array(); foreach ($sheets as $sheet) { - $style[] = ''; + $style[] = ''; } $style = implode("\n\t\t", $style); @@ -387,6 +386,7 @@ class wsHTML5Compiler { } $fontforge->setArg(null, '-'); $fontforge->setArg(null, $this->vdir . '/data/style/F' . $index . '.' . $format); + $fontforge->execute(); } } @@ -916,8 +916,8 @@ class wsHTML5Compiler { } $this->fontDocs[$font][$document_id] = true; - $idx= $this->getIndex($font, $this->cssFont, array('oblique' => $oblique)); - + $idx = $this->getIndex($font, $this->cssFont, array('oblique' => $oblique)); + return $idx; } @@ -989,7 +989,7 @@ class wsHTML5Compiler { return $this->getIndex($w, $this->cssWidths); } - protected function getIndex($value, &$tab, $params=array()) { + protected function getIndex($value, &$tab, $params = array()) { $value = (string) $value; if (isset($tab[$value])) { return $tab[$value]; @@ -1003,7 +1003,7 @@ class wsHTML5Compiler { return $tab[$value]; } - protected function normalizeFloatValue($value, $round=3) { + protected function normalizeFloatValue($value, $round = 3) { $value = str_replace(',', '.', $value); $value = (float) $value; $value = round($value, $round); @@ -1022,7 +1022,7 @@ class wsHTML5Compiler { return $str; } - public function copyLinkFile($source, $dest, $video=false) { + public function copyLinkFile($source, $dest, $video = false) { $origDir = WS_BOOKS . '/working/' . $this->book_id . '/'; $types = array('mp4', 'ogv', 'webm', 'jpg'); if ($video) { @@ -1056,7 +1056,7 @@ class wsHTML5Compiler { //$in = htmlentities($in, ENT_NOQUOTES, "UTF-8"); $in = str_replace(' ', '', $in); - + return $in; } @@ -1065,7 +1065,7 @@ class wsHTML5Compiler { } - public static function colorToCSS($color, $forceAlpha=null) { + public static function colorToCSS($color, $forceAlpha = null) { if (!is_null($forceAlpha)) { $a = $forceAlpha * 255; diff --git a/inc/ws/Util/packager/class.ws.packager.html.php b/inc/ws/Util/packager/class.ws.packager.html.php index d6ab6ec88..2ec539567 100644 --- a/inc/ws/Util/packager/class.ws.packager.html.php +++ b/inc/ws/Util/packager/class.ws.packager.html.php @@ -4,7 +4,7 @@ class wsPackagerHTML extends wsPackager { protected $origHTML; - public function __construct($book_id, $vdir=null, $whole=true) { + public function __construct($book_id, $vdir = null, $whole = true) { parent::__construct($book_id, $vdir, $whole); $this->version = 'html'; } @@ -182,6 +182,38 @@ class wsPackagerHTML extends wsPackager { $rm->setArg(null, $dest . '/' . $f); } $rm->execute(); + + $this->writeHTML5Cache($dest); + } + + public function writeHTML5Cache($dest) { + $ignore = array('data/l10n/([a-z-]{2,5}).json'); + + $dest = realpath($dest); + $lines = array(); + $lines[] = 'CACHE MANIFEST'; + $lines[] = '#'; + $lines[] = ''; + $lines[] = 'CACHE:'; + $dir = array('images', 'data', 'style'); + foreach ($dir as $d) { + $directory = $dest . '/' . $d; + + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST); + foreach ($iterator as $path) { + if (!$path->isFile()) { + continue; + } + $p = str_replace($dest . '/', '', $path); + foreach ($ignore as $i) { + if (preg_match('|' . $i . '|i', $p, $matches)) { + continue 2; + } + } + $lines[] = $p; + } + } + file_put_contents($dest . '/cache.appcache', implode("\n", $lines)); } public function makePackage($zip) { diff --git a/inc/ws/Util/packager/class.ws.packager.v1.php b/inc/ws/Util/packager/class.ws.packager.v1.php index 39a3e3d2f..ac5f5b483 100644 --- a/inc/ws/Util/packager/class.ws.packager.v1.php +++ b/inc/ws/Util/packager/class.ws.packager.v1.php @@ -4,7 +4,7 @@ class wsPackagerV1 extends wsPackagerHTML { protected $size; - public function __construct($book_id, $vdir=null, $whole=true) { + public function __construct($book_id, $vdir = null, $whole = true) { global $core; parent::__construct($book_id, $vdir, $whole); @@ -94,6 +94,10 @@ class wsPackagerV1 extends wsPackagerHTML { $link['to'] = $this->__virtualToPhysical($link['to']); } + if ($this->_copyWorkingFile($link['to']) && !in_array($link->type, array(4, 6))) { + $link['to'] = 'data/' . $link['to']; + } + $one->addChild('page', $link['page']); $one->addChild('linkType', $link['type']); $one->addChild('linkTo', $link['to']); @@ -101,8 +105,12 @@ class wsPackagerV1 extends wsPackagerHTML { $one->addChild('endX', $link['left'] + $link['width']); $one->addChild('startY', $link['top']); $one->addChild('endY', $link['top'] + $link['height']); - - $this->_copyWorkingFile($link['to']); + $one->addChild('tooltip', $link['infobulle']); + if($link['type']==4){ + $one->addChild('soundOn',$link['video_sound_on']); + $one->addChild('loopFlag',$link['video_loop']); + $one->addChild('playerActive',$link['video_auto_start']); + } } foreach ($this->book->chapters as $c) { @@ -195,7 +203,9 @@ class wsPackagerV1 extends wsPackagerHTML { $this->_copyWorkingFile($v); - $xml->addChild($k, html::escapeHTML($v)); + if ($k != 'extras') { + $xml->addChild($k, html::escapeHTML($v)); + } $extras->addChild($k, html::escapeHTML($v)); } @@ -255,8 +265,9 @@ class wsPackagerV1 extends wsPackagerHTML { $src = $this->workingDir . '/' . $file; if (file_exists($src) && is_file($src)) { - copy($src, $dir . $file); + return copy($src, $dir . $file); } + return false; } protected function __virtualToPhysical($page, $default = '') { -- 2.39.5