public function ReportEditor::prependBlock in Forena Reports 7.5
Same name and namespace in other branches
- 8 src/Editor/ReportEditor.php \Drupal\forena\Editor\ReportEditor::prependBlock()
Insert a data block before a node.
Parameters
unknown $block:
unknown $class:
unknown $id:
Return value
File
- src/
Editor/ ReportEditor.php, line 938 - ReportEditor.inc Wrapper XML class for working with DOM object. It provides helper Enter description here ... @author metzlerd
Class
Namespace
Drupal\forena\EditorCode
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;
}