buildAttributes() public static method

Returns a string by key="value" pair.
public static buildAttributes ( array $attributes ) : string
$attributes array
return string
Beispiel #1
0
    }
    $icon = '';
    if (isset($item['icon']) && $item['icon'] != '') {
        if (isset($item['itemAttr']['class'])) {
            if (is_array($item['itemAttr']['class'])) {
                $item['itemAttr']['class'] = array_merge($item['itemAttr']['class'], ['rex-has-icon']);
            } else {
                $item['itemAttr']['class'] = [$item['itemAttr']['class'], 'rex-has-icon'];
            }
        } else {
            $item['itemAttr']['class'] = ['rex-has-icon'];
        }
        $icon = '<i class="' . trim($item['icon']) . '"></i> ';
    }
    $itemAttr = isset($item['itemAttr']) ? rex_string::buildAttributes($item['itemAttr']) : '';
    $linkAttr = isset($item['linkAttr']) ? rex_string::buildAttributes($item['linkAttr']) : '';
    ?>

        <li<?php 
    echo $itemAttr;
    ?>
><a href="<?php 
    echo $item['href'];
    ?>
"<?php 
    echo $linkAttr;
    ?>
><?php 
    echo $icon . $item['title'];
    ?>
</a></li>
Beispiel #2
0
        }
        $li_a .= '<li' . rex_string::buildAttributes($attributes) . '>';
        if (isset($navi['href']) && $navi['href'] != '') {
            $attributes = [];
            $attributes['href'] = $navi['href'];
            if (isset($navi['linkClasses']) && is_array($navi['linkClasses']) && count($navi['linkClasses']) > 0 && isset($navi['linkClasses'][0]) && $navi['linkClasses'][0] != '') {
                $attributes['class'] = implode(' ', $navi['linkClasses']);
            }
            if (isset($navi['linkAttr']) && is_array($navi['linkAttr']) && count($navi['linkAttr']) > 0) {
                foreach ($navi['linkAttr'] as $key => $value) {
                    if ($value != '') {
                        $attributes[$key] = $value;
                    }
                }
            }
            $li_a .= '<a' . rex_string::buildAttributes($attributes) . '>';
        }
        if (isset($navi['icon']) && $navi['icon'] != '') {
            $li_a .= '<i class="' . $navi['icon'] . '"></i> ';
        }
        $li_a .= $navi['title'];
        if (isset($navi['href']) && $navi['href'] != '') {
            $li_a .= '</a>';
        }
        $li_a .= '</li>';
        $li[] = $li_a;
    }
    $navigations[$nav_key] = implode($li);
}
$out = '';
$tabs = '';
Beispiel #3
0
<?php

if (!isset($this->buttons)) {
    $this->buttons['button'] = $this->button;
}
foreach ($this->buttons as $button) {
    if (!isset($button['attributes'])) {
        $button['attributes'] = [];
    }
    if (!isset($button['attributes']['class'])) {
        $button['attributes']['class'] = [];
    }
    if (!in_array('btn', $button['attributes']['class'])) {
        $button['attributes']['class'] = array_merge(['btn'], $button['attributes']['class']);
    }
    if (!isset($button['label'])) {
        $button['label'] = '';
    }
    if (isset($button['hidden_label'])) {
        $button['label'] = '<span class="sr-only">' . $button['hidden_label'] . '</span>';
    }
    $icon = isset($button['icon']) ? '<i class="rex-icon rex-icon-' . $button['icon'] . '"></i>' : '';
    $tag = 'button';
    $href = '';
    if (isset($button['url'])) {
        $tag = 'a';
        $href = ' href="' . $button['url'] . '"';
    }
    echo '<' . $tag . $href . rex_string::buildAttributes($button['attributes']) . '>' . $icon . $button['label'] . '</' . $tag . '>';
}
Beispiel #4
0
<?php

if (!isset($this->buttons)) {
    $this->buttons['button'] = $this->button;
}
foreach ($this->buttons as $button) {
    if (!isset($button['attributes'])) {
        $button['attributes'] = [];
    }
    if (!isset($button['attributes']['class'])) {
        $button['attributes']['class'] = [];
    }
    if (!in_array('btn', $button['attributes']['class'])) {
        $button['attributes']['class'] = array_merge(['btn'], $button['attributes']['class']);
    }
    if (!isset($button['label'])) {
        $button['label'] = '';
    }
    if (isset($button['hidden_label'])) {
        $button['label'] = '<span class="sr-only">' . $button['hidden_label'] . '</span>';
    }
    $icon = isset($button['icon']) ? '<i class="rex-icon rex-icon-' . $button['icon'] . '"></i>' : '';
    echo '<a href="' . $button['url'] . '"' . rex_string::buildAttributes($button['attributes']) . '>' . $icon . $button['label'] . '</a>';
}
Beispiel #5
0
 public function testBuildAttributes()
 {
     $this->assertEquals(' id="rex-test" class="a b" alt="" checked', rex_string::buildAttributes(['id' => 'rex-test', 'class' => ['a', 'b'], 'alt' => '', 'checked']));
 }
Beispiel #6
0
    $header .= '<div class="rex-panel-options">' . $this->options . '</div>';
}
if (isset($this->title) && $this->title != '') {
    $header .= '<div class="panel-title">' . $this->title . '</div>';
}
if (isset($this->heading) && $this->heading != '') {
    $header .= $this->heading;
}
if (isset($this->collapse) && $this->collapse) {
    if ($collapsed) {
        $attributes['class'][] = 'collapsed';
    }
    $attributes['data-toggle'] = 'collapse';
    $attributes['data-target'] = '#' . $collapse_id;
}
echo $header != '' ? '<header' . rex_string::buildAttributes($attributes) . '>' . $header . '</header>' : '';
?>

        <?php 
if (isset($this->collapse) && $this->collapse) {
    ?>
            <div id="<?php 
    echo $collapse_id;
    ?>
" class="panel-collapse collapse<?php 
    echo $collapsed ? '' : ' in';
    ?>
">
        <?php 
}
?>
Beispiel #7
0
 if (isset($navi['href']) && $navi['href'] != '') {
     $attributes = [];
     $attributes['href'] = $navi['href'];
     if (isset($navi['linkClasses']) && is_array($navi['linkClasses']) && count($navi['linkClasses']) > 0 && isset($navi['itemClasses'][0]) && $navi['itemClasses'][0] != '') {
         $attributes['class'] = implode(' ', $navi['linkClasses']);
     }
     if (isset($navi['linkAttr']) && is_array($navi['linkAttr']) && count($navi['linkAttr']) > 0) {
         foreach ($navi['linkAttr'] as $n => $v) {
             if ($n == 'class' && $v != '' && isset($attributes['class'])) {
                 $attributes['class'] = $attributes['class'] . ' ' . $v;
             } elseif ($v != '') {
                 $attributes[$n] = $v;
             }
         }
     }
     echo '<a' . rex_string::buildAttributes($attributes) . '>';
     unset($attributes);
 }
 echo $navi['title'];
 if (isset($navi['href']) && $navi['href'] != '') {
     echo '</a>';
 }
 if (isset($navi['children']) && count($navi['children']) > 0) {
     echo '<ul>';
     foreach ($navi['children'] as $subnavi) {
         echo '<li ';
         if (isset($subnavi['itemClasses']) && is_array($subnavi['itemClasses']) && count($subnavi['itemClasses']) > 0) {
             echo ' class="' . implode(' ', $subnavi['itemClasses']) . '"';
         }
         if (isset($subnavi['itemAttr']) && is_array($subnavi['itemAttr']) && count($subnavi['itemAttr']) > 0) {
             foreach ($subnavi['itemAttr'] as $n => $v) {