You are here

public function FrxEditor::prependBlock in Forena Reports 7.4

Insert a data block before a node.

Parameters

unknown $block:

unknown $class:

unknown $id:

Return value

FrxEditor

File

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