From: vincent@cubedesigners.com Date: Wed, 3 Nov 2021 14:29:15 +0000 (+0000) Subject: wip #4857 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=18b163981be28610b182e8a1138493e7e214468c;p=cubeextranet.git wip #4857 @0.5 --- 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 7b60c4cfd..be5675122 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -336,11 +336,11 @@ class wsHTML5Compiler } - if ((int)$this->theme->parametres->iconSet < 15) { - $this->theme->parametres->iconSet = 15; + $this->svgfiles = array_unique([$this->assets . '/images/symbols/interface.svg', + WS_ICONS . '/15/interface.svg']); + if ($this->theme->parametres->iconSet > 15) { + $this->svgfiles[] = WS_ICONS . '/' . $this->theme->parametres->iconSet . '/interface.svg'; } - $this->svgfiles = array($this->assets . '/images/symbols/interface.svg', - WS_ICONS . '/' . $this->theme->parametres->iconSet . '/interface.svg'); if ($this->book->parametres->zoomMode == 1 || $this->isMobileFirst()) { $this->multiply = $this->pdf2htmlRatio * $this->scale * $this->cssOneScale; @@ -1364,7 +1364,7 @@ height="0" width="0" style="display:none;visibility:hidden"> } $print = $this->writePrint(); - $message = sprintf($this->__('Your browser is not up to date and is not able to run this publication. %sLearn more%s'), '
', ''); + $message = sprintf($this->__('Your browser is not up to date and is not able to run this publication. %sLearn more%s'), ''); $splash = ''; $splashstyles = ''; @@ -1382,19 +1382,7 @@ height="0" width="0" style="display:none;visibility:hidden"> $splash .= ''; } } - - - $svg = ''; - foreach ($this->svgfiles as $svgfile) { - if (file_exists($svgfile)) { - $svg .= str_replace('$bookmark-color', wsHTML5::colorToCSS($this->theme->parametres->bookmarkBackgroundColor), file_get_contents($svgfile)); - } else { - die($svgfile . ' does not exist'); - } - } - if (count($this->_svgSymbols)) { - $svg .= '' . implode('', $this->_svgSymbols) . '' . "\n"; - } + $svg = $this->_mergeSVG(); if ($this->phonegap) { $csp = "securityPolicyWhitelist)) . "; img-src * data:\">"; @@ -1415,6 +1403,32 @@ height="0" width="0" style="display:none;visibility:hidden"> return $this->_indexVars; } + protected function _mergeSVG() + { + $symbols = []; + foreach ($this->svgfiles as $svgfile) { + $symbols = array_merge($symbols, $this->_getSVGSymbols($svgfile)); + } + $symbols = array_merge($symbols, $this->_svgSymbols); + return '' . str_replace('> <', '><', CubeIT_Util_Text::removeNewLines(implode('', $symbols))) . ''; + } + + protected function _getSVGSymbols($svg) + { + if (file_exists($svg)) { + $svg = file_get_contents($svg); + } + $svg = str_replace('$bookmark-color', wsHTML5::colorToCSS($this->theme->parametres->bookmarkBackgroundColor), $svg); + $res = []; + $xml = simplexml_load_string($svg); + $xml->registerXPathNamespace('svg', 'http://www.w3.org/2000/svg'); + foreach ($xml->xpath('//svg:symbol') as $item) { + $res[(string)$item['id']] = $item->asXML(); + } + + return $res; + } + protected function writeIndex() { @@ -1673,7 +1687,7 @@ height="0" width="0" style="display:none;visibility:hidden"> $xml = simplexml_load_string(file_get_contents($svg)); $viewBox = (string)$xml['viewBox']; - $this->_svgSymbols[] = '' . $this->SimpleXMLElement_innerXML($xml) . ''; + $this->_svgSymbols[$symbolName] = '' . $this->SimpleXMLElement_innerXML($xml) . ''; } protected function writeLinks()