You are here

public function FrxReport::set_value in Forena Reports 6

Same name and namespace in other branches
  1. 6.2 FrxReport.inc \FrxReport::set_value()
  2. 7 FrxReport.inc \FrxReport::set_value()
  3. 7.2 FrxReport.inc \FrxReport::set_value()
  4. 7.3 FrxReport.inc \FrxReport::set_value()
  5. 7.4 FrxReport.inc \FrxReport::set_value()

Set the value of an element within the report

Parameters

String $xpath Xpath to element being saved:

string $value Value to be saved.:

Return value

unknown_type

File

./FrxReport.inc, line 439
Basic report provider. Controls the rendering of the report.

Class

FrxReport

Code

public function set_value($xpath, $value) {
  $xml = $this->rpt_xml;
  $i = strrpos($xpath, '/');
  $path = substr($xpath, 0, $i);
  $key = substr($xpath, $i + 1);
  $nodes = $xml
    ->xpath($path);
  if ($nodes) {

    // if the last part of the xpath is a key then assume the key
    if (strpos($key, '@') === 0) {
      $key = trim($key, '@');
      if (is_null($value)) {
        unset($nodes[0][$key]);
      }
      else {
        $nodes[0][$key] = $value;
      }
    }
    else {
      if (is_null($value)) {
        unset($nodes[0]->{$key});
      }
      else {
        $nodes[0]->{$key} = $value;
      }
    }
  }
}