$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;
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;
public $display_area;
public $infobulle;
public $id;
+
+ /**
+ *
+ * @var wsHTML5Compiler
+ */
public $compiler;
/**
$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);
$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);
}
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;