]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 17 Feb 2012 17:58:44 +0000 (17:58 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 17 Feb 2012 17:58:44 +0000 (17:58 +0000)
inc/extranet/Controlleur/class.extranet.tools.php
inc/ws/Util/html5/class.ws.html5.compiler.php
inc/ws/Util/packager/class.ws.packager.html.php
inc/ws/Util/packager/class.ws.packager.v1.php

index 6edacc5d9db19c3d5269a18707f9fd0902b0b675..66d1cad09b07cab93c93cacdbcf7fa52b6bef569 100644 (file)
@@ -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');
        }
 
index d8ab1e35f241f6a911119195d7efde7d46fdd474..ca72b3a70a145053b546116750244b9bf7b8adcd 100644 (file)
@@ -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[] = '<link type="text/css" rel="stylesheet" href="' . $sheet . '?junk=' . TIME . '" />';
+                       $style[] = '<link type="text/css" rel="stylesheet" href="' . $sheet . '" />';
                }
                $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('&thinsp;', '', $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;
index d6ab6ec88d0ce9aee77274e56500d7068f42e9e7..2ec53956795edb897a4f8e3d4942e5079543fb2d 100644 (file)
@@ -4,7 +4,7 @@ class wsPackagerHTML extends wsPackager {
 \r
        protected $origHTML;\r
 \r
-       public function __construct($book_id, $vdir=null, $whole=true) {\r
+       public function __construct($book_id, $vdir = null, $whole = true) {\r
                parent::__construct($book_id, $vdir, $whole);\r
                $this->version = 'html';\r
        }\r
@@ -182,6 +182,38 @@ class wsPackagerHTML extends wsPackager {
                        $rm->setArg(null, $dest . '/' . $f);\r
                }\r
                $rm->execute();\r
+\r
+               $this->writeHTML5Cache($dest);\r
+       }\r
+\r
+       public function writeHTML5Cache($dest) {\r
+               $ignore = array('data/l10n/([a-z-]{2,5}).json');\r
+\r
+               $dest = realpath($dest);\r
+               $lines = array();\r
+               $lines[] = 'CACHE MANIFEST';\r
+               $lines[] = '#';\r
+               $lines[] = '';\r
+               $lines[] = 'CACHE:';\r
+               $dir = array('images', 'data', 'style');\r
+               foreach ($dir as $d) {\r
+                       $directory = $dest . '/' . $d;\r
+\r
+                       $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST);\r
+                       foreach ($iterator as $path) {\r
+                               if (!$path->isFile()) {\r
+                                       continue;\r
+                               }\r
+                               $p = str_replace($dest . '/', '', $path);\r
+                               foreach ($ignore as $i) {\r
+                                       if (preg_match('|' . $i . '|i', $p, $matches)) {\r
+                                               continue 2;\r
+                                       }\r
+                               }\r
+                               $lines[] = $p;\r
+                       }\r
+               }\r
+               file_put_contents($dest . '/cache.appcache', implode("\n", $lines));\r
        }\r
 \r
        public function makePackage($zip) {\r
index 39a3e3d2fa7a01bf4ecc756eb3933fe7a3ed1384..ac5f5b483429aa41f827787cd880bf8dcd710eff 100644 (file)
@@ -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 = '') {