You are here

public function ReportEditor::setStyle in Forena Reports 8

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

File

src/Editor/ReportEditor.php, line 670
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 setStyle($css) {
  $dom = $this->dom;

  //$this->verifyHeaderElements(array('menu'));
  $head = $dom
    ->getElementsByTagName('head')
    ->item(0);
  $nodes = $dom
    ->getElementsByTagName('style');
  $style = $dom
    ->createElement('style');
  $style
    ->appendChild(new \DOMText($css));
  if ($nodes->length == 0) {
    $head
      ->appendChild($style);
  }
  else {
    $head
      ->replaceChild($style, $nodes
      ->item(0));
  }
}