$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'];
$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) {
$inner .= '<h3> </h3>';
}
}
- $inner .= $this->_articleToHTML($child, $title, $lead, $image);
+ $inner .= $this->_articleToHTML($child, $title, $lead, $image, $dir);
}
$inner .= '</div></article>';
* @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',
$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') {
} 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) {
$m = $markupMap[$tag] ?? $tag;
$e = explode('.', $m);
$markup = $e[0];
- $attrs = '';
+ $attrs = $dirattr;
if (count($e) === 2) {
$attrs .= ' class="' . $e[1] . '"';
}