FrxSection.php in Forena Reports 8
File
src/FrxPlugin/Template/FrxSection.php
View source
<?php
namespace Drupal\forena\Template;
use Drupal\forena\FrxPlugin\Document\XML;
use Drupal\forena\Report;
class FrxSection extends TemplateBase {
public $templateName = 'Section';
public $lastClass = '';
private $template = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root [
<!ENTITY nbsp " ">
]>
<html xmlns:frx="urn:FrxReports">
<head>
<body>
<div class="FrxSection">
{template}
</div>
</body>
</html>
EOF;
public function scrapeConfig(\SimpleXMLElement $xml) {
$template = $this
->innerXML($xml);
$this->configuration['template'] = $template;
}
public function configForm() {
$config = $this->configuration;
$form['sections'] = array(
'#theme' => 'forena_element_draggable',
'#draggable_id' => 'FrxContainer-sections',
);
if (isset($config['sections'])) {
foreach ($config['sections'] as $id => $section) {
$ctl = array();
$ctl['id'] = array(
'#type' => 'item',
'#markup' => $id,
'#title' => 'id',
);
$ctl['markup'] = array(
'#type' => 'value',
'#value' => $section['markup'],
);
$ctl['class_label'] = array(
'#type' => 'item',
'#markup' => @$section['class'],
'#title' => t('Type'),
);
$ctl['class'] = array(
'#type' => 'value',
'#value' => @$section['class'],
);
$form['sections'][$id] = $ctl;
}
}
return $form;
}
public function configValidate(&$config) {
}
public function generate() {
$doc = new XML();
$this
->pushData($this->configuration, '_template');
$report = new Report($this->template, $doc);
$report
->render();
$text = $doc
->flush();
$xml = new \SimpleXMLElement($text);
return $this
->innerXML($xml);
}
}