public function FrxReportEditor::__construct in Forena Reports 7
Same name and namespace in other branches
- 6.2 FrxReportEditor.inc \FrxReportEditor::__construct()
- 6 FrxReportEditor.inc \FrxReportEditor::__construct()
- 7.2 FrxReportEditor.inc \FrxReportEditor::__construct()
Create initial FRX report Enter description here ...
Parameters
unknown_type $xml_string:
File
- ./
FrxReportEditor.inc, line 26
Class
- FrxReportEditor
- Wrapper XML class for working with DOM object. It provides helper Enter description here ... @author metzlerd
Code
public function __construct($xml_string = '') {
$this->dom = new DOMDocument('1.0', 'UTF-8');
$dom = $this->dom;
// Load a new one or build the empty XML Document
if ($xml_string) {
// Eliminate the xml headers that don't have encoding info
$xml_string = str_ireplace('<?xml version="1.0"?>', '', $xml_string);
// If the <?xml code is missing assume UTF-8
if (strpos($xml_string, '<?xml') === FALSE) {
$xml_string = $this->doc_prefix . "\n" . $xml_string;
}
}
else {
$xml_string = $this->doc_prefix . '<html xmlns:frx="urn:FrxReports"><head/><body/></html>';
}
libxml_use_internal_errors();
try {
$dom
->loadXML($xml_string);
} catch (Exception $e) {
forena_error('Invalid or malformed report document', '<pre>' . $e
->getMessage() . $e
->getTraceAsString() . '</pre>');
}
$this
->verifyHeaderElements();
$tnodes = $dom
->getElementsByTagName('title');
if ($tnodes->length) {
$this->title = $tnodes
->item(0)->textContent;
}
$this->document_root = $dom->documentElement;
$this->simplexml = simplexml_import_dom($dom);
$dom->formatOutput = TRUE;
$this->xpq = new DOMXPath($dom);
$this->xpq
->registerNamespace('frx', $this->xmlns);
}