You are here

public function FrxFieldTable::scrapeConfig in Forena Reports 8

Extract table configuration from the HTML

Overrides TemplateInterface::scrapeConfig

See also

FrxRenderer::scrapeConfig()

File

src/FrxPlugin/Template/FrxFieldTable.php, line 21
FrxFieldTable Template that displays a table of column/value vertically.

Class

FrxFieldTable
Field Table Template

Namespace

Drupal\forena\Template

Code

public function scrapeConfig(\SimpleXMLElement $xml) {
  $config = array();
  $this
    ->extractTemplateHTML($this->reportDocDomNode, $config, array(
    'table',
  ));
  $tds = $this
    ->extractXPathInnerHTML('*//td', $this->reportDocDomNode, FALSE);
  $ths = $this
    ->extractXPathInnerHTML('*//th', $this->reportDocDomNode, FALSE);
  $columns = array_combine($ths, $tds);
  $i = 0;
  foreach ($columns as $label => $token) {
    $i++;
    $key = trim($token, '{}');
    $config['columns'][$key] = array(
      'contents' => $token,
      'label' => $label,
      'include' => 1,
      'weight' => $i,
    );
  }
  return $config;
}