You are here

private function FrxCrosstab::defaultHeaders in Forena Reports 8

Generate default headers from Embedded xml.

1 call to FrxCrosstab::defaultHeaders()
FrxCrosstab::render in src/FrxPlugin/Renderer/FrxCrosstab.php
Render the crosstab

File

src/FrxPlugin/Renderer/FrxCrosstab.php, line 24

Class

FrxCrosstab
Crosstab Renderer

Namespace

Drupal\forena\FrxPlugin\Renderer

Code

private function defaultHeaders() {
  $node = $this->reportNode;
  if ($node->thead && $node->thead->tr) {

    /** @var \SimpleXMLElement $cell */
    foreach ($node->thead->tr
      ->children() as $name => $cell) {
      $hcol = array();
      $hcol['data'] = $this
        ->innerXML($cell);
      $hcol['depth'] = 1;
      foreach ($cell
        ->attributes() as $k => $v) {
        $hcol[$k] = (string) $v;
      }
      if ($name == 'th') {
        $this->group_headers[] = $hcol;
      }
      else {
        $this->dim_headers[] = $hcol;
      }
    }
  }
  if ($node->tbody && $node->tbody->tr) {
    foreach ($node->tbody->tr
      ->children() as $name => $cell) {
      $col = array();
      $col['data'] = $this
        ->innerXML($cell);
      foreach ($cell
        ->attributes() as $k => $v) {
        $col[$k] = (string) $v;
      }
      if ($name == 'th') {
        $this->group_columns[] = $col;
      }
      else {
        $this->dim_columns[] = $col;
      }
    }
  }
}