You are here

public function FrxEditor::verifyHeaderElements in Forena Reports 7.4

Same name and namespace in other branches
  1. 7.3 FrxEditor.inc \FrxEditor::verifyHeaderElements()

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

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

... See full list

File

./FrxEditor.inc, line 239
FrxEditor.inc Wrapper XML class for working with DOM object. It provides helper Enter description here ... @author metzlerd

Class

FrxEditor
@file FrxEditor.inc Wrapper XML class for working with DOM object. It provides helper Enter description here ... @author metzlerd

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);
    }
  }
}