From: vincent@cubedesigners.com Date: Fri, 19 Jun 2020 17:17:40 +0000 (+0000) Subject: fix #3722 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=d3cb3ab24c9e13dcc53302bed8e06871702ea755;p=cubeextranet.git fix #3722 @1.5 --- diff --git a/inc/ws/Util/html5/class.ws.html5.php b/inc/ws/Util/html5/class.ws.html5.php index cd935441a..b8ded0a56 100644 --- a/inc/ws/Util/html5/class.ws.html5.php +++ b/inc/ws/Util/html5/class.ws.html5.php @@ -2,111 +2,111 @@ class wsHTML5 { - protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', ''); - - /** - * @param $book_id - * @param string $version - * @param bool $phonegap - * @param string $phonegapVersion - * @param null $dir - * @param bool $standalone - * @param bool $appcache - * @param bool $home - * @param null $book - * @return wsHTML5Compiler - */ - public static function compilerFactory($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, $book = null) - { - if (is_null($version)) { - global $core; - $dao = new wsDAOBook($core->con); - $book = $dao->selectById($book_id); - $version = $book->parametres->mobileLVersion; - } - - if ($version == 'stable' || $version == 'dev') { - $branch = 'master'; - } else { - list($branch, $w) = explode('|', $version); - } - - - $branchDir = __DIR__ . '/' . $branch . '/'; - $masterDir = __DIR__ . '/master/'; - $files = array('class.ws.html5.compiler.php', 'class.ws.html5.links.php', 'class.ws.html5.seo.php'); - - if (!class_exists('wsHTML5Compiler', false)) { - foreach ($files as $file) { - if (file_exists($branchDir . $file)) { - require_once $branchDir . $file; - } else if (file_exists($masterDir . $file)) { - require_once $masterDir . $file; - } - } - } - - return new wsHTML5Compiler($book_id, $version, $phonegap, $phonegapVersion, $dir, $standalone, $appcache, $home, $book); - } - - public static function getPhonegapVersion($v = 'latest') - { - if ($v != 'latest') { - return $v; - } - - $versions = self::getPhonegapVersions(); - return array_pop($versions); - } - - public static function getPhonegapVersions() - { - $versions = array(); - $phonegap_dir = WS_COMPILE_ASSETS . '/_html5/js/libs/phonegap'; - - if (is_dir($phonegap_dir)) { - $dr = opendir($phonegap_dir); - while ($file = readdir($dr)) { - if ($file == '.' || $file == '..' || $file == 'plugins') { - continue; - } - $versions[] = $file; - } - usort($versions, 'version_compare'); - } - - return $versions; - } - - public static function writeCSSUA($property, $value) - { - $res = array(); - foreach (self::$uaPrefixes as $prefix) { - $res[] = $prefix . $property . ':' . $value; - } - return implode(';', $res); - } - - public static function colorToArray($color, $forceAlpha = null) - { - $color = ltrim($color, '#'); - if (strlen($color) == 6) { - $hex = $color; - $alpha = 1; - } else { - $alpha = hexdec(substr($color, 0, 2)) / 255; - $hex = substr($color, 2, 6); - } - - if (!is_null($forceAlpha)) { - $alpha = $forceAlpha; - } - - return array('hex' => strtoupper($hex), 'opacity' => number_format($alpha, 3, '.', '')); - } - - public static function colorToCSS($color, $forceAlpha = null) - { - return CubeIT_Graphics_Color::colorToCSS($color, $forceAlpha); - } + protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', ''); + + /** + * @param $book_id + * @param string $version + * @param bool $phonegap + * @param string $phonegapVersion + * @param null $dir + * @param bool $standalone + * @param bool $appcache + * @param bool $home + * @param null $book + * @return wsHTML5Compiler + */ + public static function compilerFactory($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, $book = null) + { + if (is_null($version)) { + global $core; + $dao = new wsDAOBook($core->con); + $book = $dao->selectById($book_id); + $version = $book->parametres->mobileLVersion; + } + + if ($version == 'stable' || $version == 'dev') { + $branch = 'master'; + } else { + list($branch, $w) = explode('|', $version); + } + + + $branchDir = __DIR__ . '/' . $branch . '/'; + $masterDir = __DIR__ . '/master/'; + $files = array('class.ws.html5.compiler.php', 'class.ws.html5.links.php', 'class.ws.html5.seo.php'); + + if (!class_exists('wsHTML5Compiler', false)) { + foreach ($files as $file) { + if (file_exists($branchDir . $file)) { + require_once $branchDir . $file; + } else if (file_exists($masterDir . $file)) { + require_once $masterDir . $file; + } + } + } + + return new wsHTML5Compiler($book_id, $version, $phonegap, $phonegapVersion, $dir, $standalone, $appcache, $home, $book); + } + + public static function getPhonegapVersion($v = 'latest') + { + if ($v != 'latest') { + return $v; + } + + $versions = self::getPhonegapVersions(); + return array_pop($versions); + } + + public static function getPhonegapVersions() + { + $versions = array(); + $phonegap_dir = WS_COMPILE_ASSETS . '/_html5/js/libs/phonegap'; + + if (is_dir($phonegap_dir)) { + $dr = opendir($phonegap_dir); + while ($file = readdir($dr)) { + if ($file == '.' || $file == '..' || $file == 'plugins') { + continue; + } + $versions[] = $file; + } + usort($versions, 'version_compare'); + } + + return $versions; + } + + public static function writeCSSUA($property, $value) + { + $res = array(); + foreach (self::$uaPrefixes as $prefix) { + $res[] = $prefix . $property . ':' . $value; + } + return implode(';', $res) . ';'; + } + + public static function colorToArray($color, $forceAlpha = null) + { + $color = ltrim($color, '#'); + if (strlen($color) == 6) { + $hex = $color; + $alpha = 1; + } else { + $alpha = hexdec(substr($color, 0, 2)) / 255; + $hex = substr($color, 2, 6); + } + + if (!is_null($forceAlpha)) { + $alpha = $forceAlpha; + } + + return array('hex' => strtoupper($hex), 'opacity' => number_format($alpha, 3, '.', '')); + } + + public static function colorToCSS($color, $forceAlpha = null) + { + return CubeIT_Graphics_Color::colorToCSS($color, $forceAlpha); + } } \ No newline at end of file diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index 2c1881e33..1f998b908 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -2349,7 +2349,7 @@ class wsHTML5Compiler public function getConfigZIP($d) { - $res = array('width' => 0, 'height' => 0); + $res = array('type'=>'zip','width' => 0, 'height' => 0); if (file_exists($d . '/index.html')) { $doc = new DOMDocument(); @$doc->loadHTMLFile($d . '/index.html'); diff --git a/inc/ws/Util/html5/master/class.ws.html5.links.php b/inc/ws/Util/html5/master/class.ws.html5.links.php index 593c2d12f..5665199c9 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -436,7 +436,7 @@ class wsHTML5Link public function getConfigHTML($d, $html) { $res = array('width' => $this->video_width, 'height' => $this->video_height); - $r = array('html' => $html, 'inject' => array(), 'injectcss' => array(), 'injectjs' => array()); + $r = array('type' => 'html', 'html' => $html, 'inject' => array(), 'injectcss' => array(), 'injectjs' => array()); return array_merge($res, $r); } @@ -452,7 +452,7 @@ class wsHTML5Link $props = array('default-width' => 'width', 'default-height' => 'height', 'html-page' => 'html'); - $res = array('inject' => array(), 'injectcss' => array(), 'injectjs' => array(), 'content' => trim($c->content), 'name' => $c->_name, 'assets' => array()); + $res = array('type' => 'oam', 'inject' => array(), 'injectcss' => array(), 'injectjs' => 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; @@ -1330,7 +1330,7 @@ class htmlMultimediaLink extends wsHTML5Link $this->_config['lowDef'] = 'index_ld.html'; $this->compiler->vdir->file_put_contents($d['fdir'] . '/' . $this->_config['lowDef'], $html); } - } elseif ($ext == 'html') { + } elseif ($ext === 'html') { $fdir = 'data/links'; $dir = $fdir; @@ -1440,6 +1440,26 @@ class htmlMultimediaLink extends wsHTML5Link if ($this->_externalIframe !== false && $this->in_popup) { $css .= '#l_' . $this->id . '>iframe{' . wsHTML5::writeCSSUA('transform', 'scale(' . $this->getCssScale() . ')') . '}'; } + + if ($this->_config['type'] === 'oam') { + $sx = ($this->width / ($this->_config['width'])) * $this->getCssScale(); + $sy = ($this->height / ($this->_config['height'])) * $this->getCssScale(); + if ($this->compiler->book->parametres->OAMChromeFactor != 1) { + $css .= '.chrome #l_' . $this->id . '{'; + $css .= 'width:' . ($this->_config['width'] * $this->compiler->book->parametres->OAMChromeFactor) . 'px;height:' . ($this->_config['height'] * $this->compiler->book->parametres->OAMChromeFactor) . 'px;'; + $css .= wsHTML5::writeCSSUA('transform', 'scale(' . ($sx / $this->compiler->book->parametres->OAMChromeFactor) . ',' . ($sy / $this->compiler->book->parametres->OAMChromeFactor) . ')'); + $css .= '}'; + } + if ($this->compiler->book->parametres->OAMIEFactor != 1) { + $css .= '.msie #l_' . $this->id . '{'; + $css .= 'width:' . ($this->_config['width'] * $this->compiler->book->parametres->OAMIEFactor) . 'px;height:' . ($this->_config['height'] * $this->compiler->book->parametres->OAMIEFactor) . 'px;'; + $css .= wsHTML5::writeCSSUA('transform', 'scale(' . ($sx / $this->compiler->book->parametres->OAMIEFactor) . ',' . ($sy / $this->compiler->book->parametres->OAMIEFactor) . ')'); + $css .= '}'; + } + + } + + return $css; } @@ -1865,8 +1885,8 @@ class zoomLink extends normalLink $maxzoom = $this->getZoomAttributes()['maxzoom']; // Max zoom level might not always be set in the link editor $maxzoom = max(2, min($maxzoom, 4.166666667)); - if(!$maxzoom){ - $maxzoom=2; + if (!$maxzoom) { + $maxzoom = 2; } // TODO: Consider generating higher-res images (eg. 2x) for HiDPI screens. Maybe some extra optimisations can be done on the larger images...