public function TemplateBase::columns in Forena Reports 8
Extract a list of columns from the data context.
Parameters
\SimpleXMLElement $xml The xml data:
string $path: Xpath used to determine the columns
Return value
array Data columns or fields found in data.
4 calls to TemplateBase::columns()
- FrxCrosstab::generate in src/
FrxPlugin/ Template/ FrxCrosstab.php - FrxFieldTable::generate in src/
FrxPlugin/ Template/ FrxFieldTable.php - FrxSVGGraph::generate in src/
FrxPlugin/ Template/ FrxSVGGraph.php - FrxTable::generate in src/
FrxPlugin/ Template/ FrxTable.php
File
- src/
FrxPlugin/ Template/ TemplateBase.php, line 57 - FrxRenderer.php Base class for FrxAPI custom Renderer @author davidmetzler
Class
Namespace
Drupal\forena\TemplateCode
public function columns(\SimpleXMLElement $xml, $path = '/*/*') {
//create an array of columns
if (!is_object($xml)) {
return array();
}
// Use xpath if possible otherwise iterate.
if (method_exists($xml, 'xpath')) {
$rows = $xml
->xpath($path);
}
else {
$rows = $xml;
}
$column_array = array();
$numeric_columns = array();
foreach ($rows as $columns) {
foreach ($columns as $name => $value) {
$label = str_replace('_', ' ', $name);
$column_array[$name] = $label;
if (is_numeric((string) $value)) {
$numeric_columns[$name] = $label;
}
else {
if (isset($numeric_columns[$name])) {
unset($numeric_columns[$name]);
}
}
}
if (is_object($xml) && method_exists($xml, 'attributes')) {
foreach ($xml
->attributes() as $name => $value) {
$column_array['@' . $name] = '@' . $name;
}
}
}
$this->columns = $column_array;
$this->numeric_columns = $numeric_columns;
return $column_array;
}