You are here

public function Report::preloadData in Forena Reports 7.5

Same name and namespace in other branches
  1. 8 src/Report.php \Drupal\forena\Report::preloadData()
1 call to Report::preloadData()
Report::render in src/Report.php
Render the report

File

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

Class

Report

Namespace

Drupal\forena

Code

public function preloadData() {
  $blocks_loaded = $this->blocks_loaded;
  $jsonData = array();
  if ($this->data) {
    foreach ($this->data as $d) {
      if (!empty($d['block'])) {
        $id = @$d['id'];
        $block = $d['block'];
        $parms = @$d['parameters'];
        $raw = !empty($d['json']) || !empty($d['raw_mode']);
        $data = $this
          ->getData($block, $id, $parms, $raw);
        if (@$d['path'] && !$raw && $data) {
          $data = $data
            ->xpath((string) $d['path']);
          if ($data) {
            $data = $data[0];
          }
        }
        Frx::Data()
          ->setContext($id, $data);
        if (!empty($d['json']) && $this->format == 'web') {
          $ret = array();
          if ($data) {
            foreach ($data as $row) {
              $ret[] = $row;
            }
          }
          $jsonData[$d['json']] = $ret;
        }
      }
      else {
        $id = @$d['id'];
        if ($id) {
          Frx::Data()
            ->setContext($id, $d['data']);
        }
      }
    }
  }
  if ($jsonData) {
    drupal_add_js(array(
      'forenaData' => $jsonData,
    ), 'setting');
  }
  $this->blocks_loaded = $blocks_loaded;
}