You are here

public function ReportEditor::verifyHeaderElements in Forena Reports 7.5

Same name and namespace in other branches
  1. 8 src/Editor/ReportEditor.php \Drupal\forena\Editor\ReportEditor::verifyHeaderElements()

Makes sure that the normal header elements for a report are there. Enter description here ...

13 calls to ReportEditor::verifyHeaderElements()
ReportEditor::getCache in src/Editor/ReportEditor.php
ReportEditor::getCategory in src/Editor/ReportEditor.php
ReportEditor::getMenu in src/Editor/ReportEditor.php
ReportEditor::getOptions in src/Editor/ReportEditor.php
Retrieve options element in array form
ReportEditor::load in src/Editor/ReportEditor.php
Load report from file system

... See full list

File

src/Editor/ReportEditor.php, line 295
ReportEditor.inc Wrapper XML class for working with DOM object. It provides helper Enter description here ... @author metzlerd

Class

ReportEditor

Namespace

Drupal\forena\Editor

Code

public function verifyHeaderElements($required_elements = array()) {
  if (!$required_elements) {
    $required_elements = array(
      'category',
      'options',
      'fields',
      'parameters',
      'docgen',
    );
  }
  $dom = $this->dom;
  if (!$this->dom->documentElement) {
    drupal_set_message('error', 'error');
    return;
  }
  $head = $dom
    ->getElementsByTagName('head')
    ->item(0);
  if (!$head) {
    $head = $dom
      ->createElement('head');
    $dom->documentElement
      ->appendChild($head);
  }

  // Make sure the report title exists.
  if ($dom
    ->getElementsByTagName('title')->length == 0) {
    $n = $dom
      ->createElement('title');
    $head
      ->appendChild($n);
  }

  // Make sure each of these exists in the header
  foreach ($required_elements as $tag) {
    if ($dom
      ->getElementsByTagNameNS($this->xmlns, $tag)->length == 0) {
      $n = $dom
        ->createElementNS($this->xmlns, $tag);
      $head
        ->appendChild($n);
    }
  }
}