You are here

function FrxRepoMan::dataBlockParams in Forena Reports 7.3

Same name and namespace in other branches
  1. 7.4 FrxRepoMan.inc \FrxRepoMan::dataBlockParams()

File

./FrxRepoMan.inc, line 361
FrxRepoMan.inc Enter description here ... @author davidmetzler

Class

FrxRepoMan
@file FrxRepoMan.inc Enter description here ... @author davidmetzler

Code

function dataBlockParams($data_block, $field, $label) {
  $xml = Frx::RepoMan()
    ->data($data_block);
  $list = array();
  if ($xml) {
    $path = $field ? $field : '*[1]';
    $label_path = $label ? $label : '*[2]';

    //walk through the $xml.
    $rows = $xml
      ->xpath('*');
    if ($rows) {
      foreach ($rows as $row) {
        $value = $row
          ->xpath($path);
        $label_field = $row
          ->xpath($label_path);
        $label_value = $label_field ? (string) $label_field[0] : (string) $value[0];
        $list[(string) $value[0]] = (string) $label_value;
      }
    }
  }
  return $list;
}