You are here

public function RendererBase::setAttributes in Forena Reports 7.5

Set FRX attributes.

Parameters

DOMNode $node:

unknown $attributes:

unknown $frxattributes:

3 calls to RendererBase::setAttributes()
RendererBase::addNode in src/Renderer/RendererBase.php
Add a node to the existing dom element with attributes
RendererBase::blockDiv in src/Renderer/RendererBase.php
Generate generic div tag.
RendererBase::setFirstNode in src/Renderer/RendererBase.php
Sets the first child element to a node and returns it. IF the node

File

src/Renderer/RendererBase.php, line 424
FrxRenderer.php Base class for Frx custom Renderer @author davidmetzler

Class

RendererBase

Namespace

Drupal\forena\Renderer

Code

public function setAttributes(DOMElement $node, $attributes, $frx_attributes) {
  if ($attributes) {
    foreach ($attributes as $key => $value) {
      $node
        ->setAttribute($key, $value);
    }
  }

  // Iterate the value
  if ($frx_attributes) {
    foreach ($frx_attributes as $key => $value) {

      // If the value is an array create multiple attributes
      // that are of the form key_1, key_2 .... etc.
      if (is_array($value)) {
        $i = 0;
        $done = FALSE;
        while (!$done) {
          $v = '';
          if ($value) {
            $v = array_shift($value);
          }
          $i++;
          $k = $key . '_' . trim((string) $i);
          $node
            ->setAttribute($k, $v);
          if (!$v) {
            $done = TRUE;
          }
        }
      }
      else {
        if ($value) {
          $node
            ->setAttributeNS($this->xmlns, $key, $value);
        }
      }
    }
  }
}