You are here

public function FrxEditor::addBlock in Forena Reports 7.4

Add a data blcok

Parameters

unknown $block:

unknown $class:

unknown $id:

Return value

FrxEditor

File

./FrxEditor.inc, line 836
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 addBlock($block_name, $template_class, &$config, $id = '') {
  if (!$template_class) {
    $template_class = 'FrxTable';
  }
  $block_name = str_replace('.', '/', $block_name);
  if ($id) {
    $path = "body//*[@id='{$id}']";
    $nodes = $this->simplexml
      ->xpath($path);
    if ($nodes) {
      $pnode = dom_import_simplexml($nodes[0]);
      $node = $this->dom
        ->createElement('div');
      $pnode
        ->appendChild($node);
    }
    else {
      drupal_set_message(t('Could not find %s in report', array(
        '%s' => $id,
      )), 'error');
      return;
    }
  }
  else {
    $nodes = $this->dom
      ->getElementsByTagName('body');
    $pnode = $nodes
      ->item(0);
    $node = $this->dom
      ->createElement('div');
    $pnode
      ->appendChild($node);
  }
  $this->frxReport
    ->setReport($this->dom, $this->xpq, $this->edit);
  $config['block'] = $block_name;
  $b = Frx::BlockEditor($block_name, $this->frxReport->block_edit_mode);
  $data = $b
    ->data($this->parms);
  $this
    ->addParameters($b
    ->tokens());
  $c = Frx::Template($template_class);
  if ($c) {
    $c
      ->initReportNode($node, $this->frxReport);
    $c
      ->generate($data, $config);
  }
  else {
    drupal_set_message(t('Could not find template %s', array(
      '%s' => $template_class,
    )), 'error');
  }
  return $this;
}