You are here

function FrxTemplate::addNode in Forena Reports 7.3

Same name and namespace in other branches
  1. 6.2 templates/FrxTemplate.inc \FrxTemplate::addNode()
  2. 7.2 templates/FrxTemplate.inc \FrxTemplate::addNode()
6 calls to FrxTemplate::addNode()
FrxEmailMerge::generate in templates/FrxEmailMerge.inc
Enter description here ...
FrxFieldTable::generate in templates/FrxFieldTable.inc
Enter description here ...
FrxGraphTemplate::generate in templates/FrxGraphTemplate.inc
Enter description here ...
FrxRptInclude::generate in templates/FrxRptInclude.inc
Enter description here ...
FrxTable::generate in templates/FrxTable.inc
Enter description here ...

... See full list

File

templates/FrxTemplate.inc, line 85
FrxTemplate Base Class for all tmeplates. By default simply renders a document with all the possible tokens in it. @author davidmetzler

Class

FrxTemplate
@file FrxTemplate Base Class for all tmeplates. By default simply renders a document with all the possible tokens in it. @author davidmetzler

Code

function addNode($cur_node, $indent = 0, $tag = 'div', $value = '', $attributes = array(), $frx_attributes = array()) {
  $dom = $this->dom;
  if (!$cur_node) {
    return;
  }
  if ($indent !== FALSE) {
    $tnode = $dom
      ->createTextNode("\n" . str_repeat(' ', $indent));
    $cur_node
      ->appendChild($tnode);
  }
  $pnode = $dom
    ->createElement($tag, $value);
  if ($attributes) {
    foreach ($attributes as $key => $value) {
      if ($value) {
        $attr = $dom
          ->createAttribute($key);
        $attr->value = $value;
        $pnode
          ->appendChild($attr);
      }
    }
  }
  if ($frx_attributes) {
    foreach ($frx_attributes as $key => $value) {
      if ($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;
          foreach ($value as $v) {
            $i++;
            $k = $key . '_' . trim((string) $i);
            $attr = $dom
              ->createAttributeNS($this->xmlns, $k);
            $attr->value = htmlentities($v);
            $pnode
              ->appendChild($attr);
          }
        }
        else {
          $attr = $dom
            ->createAttributeNS($this->xmlns, $key);
          $attr->value = htmlentities($value);
          $pnode
            ->appendChild($attr);
        }
      }
    }
  }
  $cur_node
    ->appendChild($pnode);
  return $pnode;
}