public function FrxControls::csvdocument in Forena Reports 6
Same name and namespace in other branches
- 6.2 plugins/FrxControls.inc \FrxControls::csvDocument()
- 7 plugins/FrxControls.inc \FrxControls::csvdocument()
- 7.2 plugins/FrxControls.inc \FrxControls::csvDocument()
File
- plugins/
FrxControls.inc, line 137 - contains various methods for extending report formating, layout, transformation and design.
Class
- FrxControls
- @file contains various methods for extending report formating, layout, transformation and design.
Code
public function csvdocument($body, $options) {
$doc = new DOMDocument();
$doc->strictErrorChecking = FALSE;
$xmlBody = '<?xml version="1.0" encoding="UTF-8"?>' . $body;
$doc
->loadHTML($xmlBody);
$xml = simplexml_import_dom($doc);
$rows = $xml
->xpath('//tr');
if ($rows) {
foreach ($rows as $row) {
foreach ($row as $column) {
$value = $column
->asXML();
$value = strip_tags($value);
$value = str_replace('"', '""', $value);
$value = str_replace(array(
"\n",
), '', $value);
$value = '"' . $value . '",';
$output .= $value;
}
$output .= "\n";
}
}
return $output;
}