You are here

function forena_get_data_block_params in Forena Reports 6

Same name and namespace in other branches
  1. 7 forena.common.inc \forena_get_data_block_params()
1 call to forena_get_data_block_params()
forena_parameters_form in ./forena.common.inc
Form to edit parameters Extra features: In the parameters section of the report are new attributes frx:parm: @data_source = data block for the parameter to values from @data_field = specific field of the data block to recieve values from. if no field…

File

./forena.common.inc, line 607
Common functions used throughout the project but loaded in this file to keep the module file lean.

Code

function forena_get_data_block_params($data_block, $field, $label, $params = array(), $clause = '') {
  $xml = forena_invoke_data_provider($data_block, $params, $clause);
  $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;
}