]> _ Git - cubeextranet.git/commitdiff
wip #4857 @0.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 3 Nov 2021 14:29:15 +0000 (14:29 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 3 Nov 2021 14:29:15 +0000 (14:29 +0000)
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index 7b60c4cfd130970fd00af22f61fd5a634139e189..be5675122d3f77539b0dde6098c43f51176dc8cd 100644 (file)
@@ -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"></iframe></noscript>
             }
 
             $print = $this->writePrint();
-            $message = sprintf($this->__('Your browser is not up to date and is not able to run this publication. %sLearn more%s'), '<br /><a href="http://www.whatbrowser.org/intl/' . $this->config->defaultLang . '/" target="_blank">', '</a>');
+            $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"></iframe></noscript>
                     $splash .= '<div class="logo"><img src="data/images/' . $this->theme->parametres->logoLoader . '" width="' . $dim[0] . '" height="' . $dim[1] . '" alt="" /></div>';
                 }
             }
-
-
-            $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 .= '<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">' . implode('', $this->_svgSymbols) . '</svg>' . "\n";
-            }
+            $svg = $this->_mergeSVG();
 
             if ($this->phonegap) {
                 $csp = "<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'self' data: gap: 'unsafe-inline' *; style-src 'self' 'unsafe-inline'; font-src 'self' data:; script-src 'self' 'unsafe-inline' 'unsafe-eval' " . implode(' ', array_unique($this->securityPolicyWhitelist)) . "; img-src * data:\">";
@@ -1415,6 +1403,32 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
         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 '<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">' . str_replace('> <', '><', CubeIT_Util_Text::removeNewLines(implode('', $symbols))) . '</svg>';
+    }
+
+    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"></iframe></noscript>
         $xml = simplexml_load_string(file_get_contents($svg));
         $viewBox = (string)$xml['viewBox'];
 
-        $this->_svgSymbols[] = '<symbol id="' . $symbolName . '" viewBox="' . $viewBox . '">' . $this->SimpleXMLElement_innerXML($xml) . '</symbol>';
+        $this->_svgSymbols[$symbolName] = '<symbol id="' . $symbolName . '" viewBox="' . $viewBox . '">' . $this->SimpleXMLElement_innerXML($xml) . '</symbol>';
     }
 
     protected function writeLinks()