]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 17 Jul 2013 08:49:50 +0000 (08:49 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 17 Jul 2013 08:49:50 +0000 (08:49 +0000)
inc/ws/Util/html5/class.ws.html5.compiler.php
inc/ws/Util/html5/class.ws.html5.links.php

index 5355fd0839d9ba1d1672c3e0c94d74ccbc896a20..6244f5c878dc9790e9830a18d419bf2599335399 100644 (file)
@@ -383,14 +383,14 @@ class wsHTML5Compiler {
                $lines[] = 'CACHE:';
 
                $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dest), RecursiveIteratorIterator::SELF_FIRST);
-               
-               $exclude=array('index.html','indexu.html','widget.html','indext.html');
-               
+
+               $exclude = array('index.html', 'indexu.html', 'widget.html', 'indext.html');
+
                foreach ($iterator as $path) {
                        if (!$path->isFile()) {
                                continue;
                        }
-                       
+
                        $p = str_replace($dest . '/', '', $path);
                        if (in_array($p, $exclude)) {
                                continue;
@@ -1206,6 +1206,10 @@ class wsHTML5Compiler {
                return $str;
        }
 
+       public function copyLinkDir($source, $dest) {
+               `cp -a $source $this->vdir/$dest`;
+       }
+
        public function copyLinkFile($source, $dest, $video = false) {
                if ($video && $this->book->parametres->mobileVideosPath != '') {
                        return;
index 8bad840b2e03d29ea61b23f82f66a7687c5257e9..c665440030651c2d33f487c0f1441b1ddd01acac 100644 (file)
@@ -23,6 +23,11 @@ class wsHTML5Link {
        public $display_area;
        public $infobulle;
        public $id;
+
+       /**
+        *
+        * @var wsHTML5Compiler 
+        */
        public $compiler;
 
        /**
@@ -127,8 +132,12 @@ class wsHTML5Link {
                $this->compiler->copyLinkFile($file, 'data/links/', $video);
        }
 
-       public function unzipFile($file) {
-               $fdir = 'data/links/' . $this->id;
+       public function copyExternalDir($dir) {
+               $this->compiler->copyLinkDir($dir, 'data/links');
+       }
+
+       public function unzipFile($file, $moveAssets = false) {
+               $fdir = 'data/links/' . $file;
                $dir = $this->compiler->vdir . '/' . $fdir;
                if (!file_exists($dir)) {
                        mkdir($dir, 0777, true);
@@ -137,6 +146,12 @@ class wsHTML5Link {
                $unzip->setArg(null, $this->compiler->wdir . '/' . $file);
                $unzip->setArg('d', $dir);
                $unzip->execute();
+
+               if ($moveAssets) {
+                       `mv $dir/Assets/* $dir`;
+                       rmdir($dir . '/Assets');
+               }
+
                return array('dir' => $dir, 'fdir' => $fdir);
        }
 
@@ -426,31 +441,65 @@ class multimediaLink extends wsHTML5Link {
 
 class htmlMultimediaLink extends wsHTML5Link {
 
+       protected $_config = null;
+       protected $_content = '';
+
        public function getHTMLContent() {
-               $d = $this->unzipFile($this->to);
-               $w = $this->width * $this->getCssScale();
-               $h = $this->height * $this->getCssScale();
+               if ($this->_content == '') {
+                       $d = $this->unzipFile($this->to, true);
 
-               $dr = opendir($d['dir']);
-               while ($file = readdir($dr)) {
-                       if ($file == '.' || $file == '..') {
-                               continue;
-                       }
+                       $this->_config = $this->getConfig($d['dir']);
+
+
+                       $this->_correctFiles($d['dir']);
+
+                       $w = $this->width * $this->getCssScale();
+                       $h = $this->height * $this->getCssScale();
 
-                       $ext = files::getExtension($file);
-
-                       if ($ext == 'js') {
-                               $this->compiler->pluginJs[] = $d['fdir'] . '/' . $file;
-                               $e = explode('.', $file);
-                               $name = $e[0];
-                               $code = '$("#l_' . $this->id . '").' . $name . '();';
-                               $this->compiler->htmlmultimedia[] = $code;
-                       } else if ($ext == 'css') {
-                               $this->compiler->pluginCSS[] = $d['fdir'] . '/' . $file;
-                       } else if ($ext == 'html') {
-                               $res = file_get_contents($d['dir'] . '/' . $file);
-                               unlink($d['dir'] . '/' . $file);
+                       $res = '<script type="text/javascript" src="' . $d['fdir'] . '/' . $this->_config['name'] . '_edgePreload.js"></script>';
+                       $res.=$this->_config['content'];
+
+                       $this->copyExternalDir($d['dir']);
+                       $this->_content = $res;
+               }
+               return $this->_content;
+       }
+
+       protected function _correctFiles($dir) {
+
+               $preloadFile = $d['dir'] . '/' . $this->_config['name'] . '_edgePreload.js';
+               $preload = file_get_contents($preloadFile);
+               $preload = str_replace('load:"', 'load:"data/links/' . $this->to . '/', $preload);
+               file_put_contents($preloadFile, $preload);
+       }
+
+       protected function _correctFile($file) {
+               $content = file_get_contents($file);
+
+               file_put_contents($file, $content);
+       }
+
+       public function getConfig($d) {
+               $x = simplexml_load_file($d . '/config.xml');
+               $config = (string) $x->oamfile['src'];
+               $config = str_replace('/Assets', '', $d . '/' . $config);
+               $x = simplexml_load_file($config, 'SimpleXMLElement', LIBXML_NOCDATA);
+               $c = CubeIT_Util_Xml::toObject($x);
+
+               $props = array('default-width' => 'width', 'default-height' => 'height');
+
+
+               $res = array('content' => trim($c->content), 'name' => $c->_name, 'assets' => array());
+               foreach ($c->properties->property as $p) {
+                       if (isset($props[$p->_name])) {
+                               $res[$props[$p->_name]] = $p->_defaultValue;
+                       }
+               }
+               foreach ($c->require as $r) {
+                       if ($r->_type == 'folder') {
+                               continue;
                        }
+                       $res['assets'][] = $r->_src;
                }
 
                return $res;