You are here

public function FrxEditor::applyTemplate in Forena Reports 7.4

Apply a template based on the block id.

Parameters

unknown $id:

unknown $class:

unknown $config:

File

./FrxEditor.inc, line 796
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 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 = Frx::BlockEditor($block_name)
    ->data($this->parms);
  $c = Frx::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' => $templateClass,
    )), 'error');
  }
}