]> _ Git - cubeextranet.git/commitdiff
wip #3733 @4
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 27 Aug 2020 17:34:22 +0000 (17:34 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 27 Aug 2020 17:34:22 +0000 (17:34 +0000)
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index b237344424b32ebc116272bb91974fd3d24ce7ef..40c484c4f291abf8916b7ca0651d141de7ae5f79 100644 (file)
@@ -2524,6 +2524,50 @@ class wsHTML5Compiler
     }
 
 
+    public function parseArticlesBusinessImmo($file)
+    {
+        $zip = new ZipArchive();
+        $zip->open($file);
+        $assets = [];
+        $xmls = [];
+        for ($i = 0; $i <= $zip->numFiles; $i++) {
+            $fname = $zip->getNameIndex($i);
+            if (stristr($fname, '__MACOSX')) {
+                continue;
+            }
+            if (!preg_match('/\.xml$/', $fname)) {
+                $assets[$this->_normalizeAssetName($fname, true)] = $i;
+            } else {
+                $xmls[$fname] = $i;
+            }
+        }
+
+        foreach ($xmls as $name => $index) {
+            $e = explode('/', $name);
+            array_pop($e);
+            $dir = implode('/', $e);
+            $xmlContent = $zip->getFromIndex($index);
+            $xmlContent = preg_replace_callback('/\<\/?[A-Za-z]+\/?\>/', function($w){
+                return mb_strtolower($w[0]);
+            }, $xmlContent);
+            $sx = simplexml_load_string($xmlContent);
+        }
+
+    }
+
+    protected function _normalizeAssetName($fname, $withDir = false)
+    {
+        if (!$withDir) {
+            $e = explode('/', $fname);
+            $fname = array_pop($e);
+        }
+        $fname = rawurldecode($fname);
+        $fname = trim(mb_strtolower($fname));
+        $fname = str_replace('_opt.', '.', $fname);
+        $fname = CubeIT_Text::removeAccents($fname);
+        return $fname;
+    }
+
     public function writeArticles()
     {
         $mapFonts = ['OpenSans' => 'Open Sans'];
@@ -2532,6 +2576,7 @@ class wsHTML5Compiler
         $this->lessVariables['articles-font'] = 'OpenSans';
 
         $list = [];
+
         $f = $this->book->parametres->articlesFile;
         if ($f === '') {
             $this->config->articlesList = $list;
@@ -2543,6 +2588,10 @@ class wsHTML5Compiler
             return;
         }
 
+        if ($this->book->parametres->articlesFormat === 'business-immo') {
+            $this->parseArticlesBusinessImmo($f);
+        }
+
         $this->addLess('articles');
         if ($this->book->parametres->articlesStyle !== 'default') {
             $this->lessVariables['articles-styles'] = $this->book->parametres->articlesStyle;