]> _ Git - cubeextranet.git/commitdiff
wip #4188 @0.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 14 Jan 2021 17:18:05 +0000 (17:18 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 14 Jan 2021 17:18:05 +0000 (17:18 +0000)
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index 9ccc1159ab6290a8eec0de2a6c9addab2c157f52..1dbf7266d2b0d12e57b100b46a9b556f77f17d21 100644 (file)
@@ -2705,6 +2705,7 @@ class wsHTML5Compiler
         $x = simplexml_load_string(file_get_contents($f));
         $prevurl = '';
         foreach ($x->xpath('/articles/article') as $k => $a) {
+            $dir = isset($a['dir']) ? (string)$a['dir'] : null;
             $url = (string)$a['url'];
             $id = (string)$a['id'];
             $color = (string)$a['color'];
@@ -2715,7 +2716,11 @@ class wsHTML5Compiler
             $specificStyles = '## h3, ## figure figcaption{background-color:' . $color . '}';
             $specificStyles .= '## .chapo, ## blockquote, ## a{color:' . $color . ';}';
 
-            $inner = '<article data-id="$id" class="menu-article" id="article_$id">';
+            $inner = '<article data-id="$id" class="menu-article" id="article_$id"';
+            if (null !== $dir) {
+                $inner .= ' dir="' . $dir . '"';
+            }
+            $inner .= '>';
             $inner .= '<style type="text/css">' . str_replace('##', '#article_$id', $specificStyles) . '</style>';
             $inner .= '<div class="actions">';
             if ($this->book->parametres->articlesShare && $this->book->parametres->share) {
@@ -2739,7 +2744,7 @@ class wsHTML5Compiler
                         $inner .= '<h3>&nbsp;</h3>';
                     }
                 }
-                $inner .= $this->_articleToHTML($child, $title, $lead, $image);
+                $inner .= $this->_articleToHTML($child, $title, $lead, $image, $dir);
             }
             $inner .= '</div></article>';
 
@@ -2807,7 +2812,7 @@ class wsHTML5Compiler
      * @return string|void
      * @throws Zend_Filter_Exception
      */
-    protected function _articleToHTML($child, &$title, &$lead, &$image)
+    protected function _articleToHTML($child, &$title, &$lead, &$image, $dir = null)
     {
         $markupMap = ['category' => 'h3',
             'subtitle' => 'h2',
@@ -2825,12 +2830,21 @@ class wsHTML5Compiler
 
         $attrsmap = ['a' => ['link' => 'href']];
 
+        $dirattr = '';
+        if (isset($child['dir'])) {
+            $d = (string)$child['dir'];
+            if ($d !== $dir) {
+                $dirattr = ' dir="' . $d . '"';
+                $dir = $d;
+            }
+        }
+
         $res = '';
         $tag = $child->getName();
         if ($tag === 'encadre') {
-            $res .= '<aside>';
+            $res .= '<aside' . $dirattr . '>';
             foreach ($child->children() as $sub) {
-                $res .= $this->_articleToHTML($sub, $a1, $a2, $a3);
+                $res .= $this->_articleToHTML($sub, $a1, $a2, $a3, $dir);
             }
             $res .= '</aside>';
         } else if ($tag === 'youtube') {
@@ -2858,7 +2872,7 @@ class wsHTML5Compiler
             } else {
                 $dim = [0 => 1024, 1 => 10];
             }
-            $res .= '<figure><img src="data/articles/' . $file . '" alt="' . $legend . '" width="' . $dim[0] . '" height="' . $dim[1] . '">' . $caption . '</figure>';
+            $res .= '<figure'.$dirattr.'><img src="data/articles/' . $file . '" alt="' . $legend . '" width="' . $dim[0] . '" height="' . $dim[1] . '">' . $caption . '</figure>';
         } else {
             $c = trim($this->SimpleXMLElement_innerXML($child));
             if (!$c) {
@@ -2873,7 +2887,7 @@ class wsHTML5Compiler
             $m = $markupMap[$tag] ?? $tag;
             $e = explode('.', $m);
             $markup = $e[0];
-            $attrs = '';
+            $attrs = $dirattr;
             if (count($e) === 2) {
                 $attrs .= ' class="' . $e[1] . '"';
             }