public function ReportEditor::applyTemplate in Forena Reports 8
Same name and namespace in other branches
- 7.5 src/Editor/ReportEditor.php \Drupal\forena\Editor\ReportEditor::applyTemplate()
Apply a template based on the block id.
Parameters
string $id:
string $class:
array $config:
File
- src/
Editor/ ReportEditor.php, line 884 - 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 applyTemplate($id, $template_class, $config = array()) {
$path = "body//*[@id='{$id}']";
$nodes = $this->simplexml
->xpath($path);
if ($nodes) {
$node = dom_import_simplexml($nodes[0]);
}
else {
drupal_set_message(t('Could not find %s in report', array(
'%s' => $id,
)), 'error');
return;
}
$block_name = $node
->getAttributeNS($this->xmlns, 'block');
$class = $node
->getAttribute("class");
$config['block'] = $block_name;
$data = FrxAPI::BlockEditor($block_name)
->data($this->parms);
$c = FrxAPI::Template($template_class);
if ($c) {
$c
->initReportNode($node, $this->frxReport);
if (strpos($class, $template_class) === FALSE) {
$c
->resetTemplate();
}
$c
->generate($data, $config);
}
else {
drupal_set_message(t('Could not find template %s', array(
'%s' => $template_class,
)), 'error');
}
}