]> _ Git - cubeextranet.git/commitdiff
wip #3826 @0.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 24 Aug 2020 16:06:05 +0000 (16:06 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 24 Aug 2020 16:06:05 +0000 (16:06 +0000)
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index 4a902a009045e794d89e98637e391b99b8706597..f80a20f37a5db69c69e4ae2cc4a7cfc267d64ef0 100644 (file)
@@ -216,6 +216,7 @@ class wsHTML5Compiler
     public $lessVariables = [];
     protected $_indexVars = null;
     public $accessibleTexts = [];
+    protected $_svgSymbols = [];
 
     public $_signature;
     /**
@@ -1040,6 +1041,10 @@ class wsHTML5Compiler
                     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";
+
+            }
 
             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:\">";
@@ -1295,11 +1300,26 @@ class wsHTML5Compiler
         for ($i = 1; $i <= 5; $i++) {
             $ic = $this->book->parametres->{'navExtraIcon' . $i};
             if ($ic != '') {
-                $this->vdir->copy($this->wdir . '/' . $ic, 'data/images/' . $ic);
+                if (stristr($ic, '.svg')) {
+                    $e = explode('.', $ic);
+                    $sname = 'external-' . $e[0];
+                    $this->addSVGSymbolFromFile($this->wdir . '/' . $ic, $sname);
+                    $this->config->{'navExtraIcon' . $i} = $sname;
+                } else {
+                    $this->vdir->copy($this->wdir . '/' . $ic, 'data/images/' . $ic);
+                }
             }
         }
     }
 
+    protected function addSVGSymbolFromFile($svg, $symbolName)
+    {
+        $xml = simplexml_load_string(file_get_contents($svg));
+        $viewBox = (string)$xml['viewBox'];
+
+        $this->_svgSymbols[] = '<symbol id="' . $symbolName . '" viewBox="' . $viewBox . '">' . $this->SimpleXMLElement_innerXML($xml) . '</symbol>';
+    }
+
     protected function writeLinks()
     {
         global $core;