You are here

public function Report::setReport in Forena Reports 7.5

Same name and namespace in other branches
  1. 8 src/Report.php \Drupal\forena\Report::setReport()

Sets the report.

Parameters

DOMDocument $dom:

1 call to Report::setReport()
Report::__construct in src/Report.php

File

src/Report.php, line 95
Basic report provider. Controls the rendering of the report.

Class

Report

Namespace

Drupal\forena

Code

public function setReport(DOMDocument $dom, DOMXPath $xpq, $edit = FALSE) {
  $this->dom = $dom;
  $dom->formatOutput = TRUE;
  $this->xpathQuery = $xpq;
  $rpt_xml = $this->rpt_xml = simplexml_import_dom($this->dom->documentElement);
  $this->missing_parms = FALSE;

  // Load header data
  $this->body = $rpt_xml->body;
  if ($rpt_xml->head) {
    $this->title = (string) $rpt_xml->head->title;
    $nodes = $rpt_xml
      ->xpath('//frx:docgen/frx:doc');
    $this->formats = array();
    if ($nodes) {
      foreach ($nodes as $value) {
        $arr = $value
          ->attributes();
        $this->formats[] = (string) $arr['type'];
      }
    }
    foreach ($rpt_xml->head
      ->children(FRX_NS) as $name => $node) {
      switch ($name) {
        case 'fields':
          $this->fields = $node;
          break;
        case 'category':
          $this->category = (string) $node;
          break;
        case 'descriptor':
          $this->descriptor = (string) $node;
          break;
        case 'options':
          foreach ($node
            ->attributes() as $key => $value) {
            $this->options[$key] = (string) $value;
          }
          break;
        case 'cache':
          foreach ($node
            ->attributes() as $key => $value) {
            $this->cache[$key] = (string) $value;
          }
        case 'title':
          $this->frx_title = (string) $node;
          break;
        case 'form':
          $this->form = (string) $value;
          break;
        case 'parameters':
          foreach ($node
            ->children(FRX_NS) as $key => $node) {
            $parm = array();
            foreach ($node
              ->attributes() as $akey => $attr) {
              $parm[$akey] = (string) $attr;
            }
            $id = $parm['id'];
            $val = isset($parm['value']) ? $parm['value'] : '';
            $parm['value'] = (string) $node ? (string) $node : $val;
            $this->parameters[$id] = $parm;
          }
          break;
        case 'data':
          $data = array();
          foreach ($node
            ->attributes() as $key => $value) {
            $data[$key] = (string) $value;
          }
          $data['data'] = $node;
          $this->data[] = $data;
          break;
        case 'doctypes':
          $this->doctypes = $value;
          break;
      }
    }
    if ($edit) {
      $this
        ->get_attributes_by_id();
    }
    $this->skin = isset($this->options['skin']) ? $this->options['skin'] : @$this->options['form'];
  }
}