You are here

public function FrxReport::save_attributes_by_id in Forena Reports 7.3

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

Save attributes based on id match

Parameters

array $attributes:

The attributes array should be of the form array( element_id => array( key1 => value1, key2 => value2) The function restores the attributes based on the element id.

File

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

Class

FrxReport

Code

public function save_attributes_by_id($attributes) {
  $rpt_xml = $this->rpt_xml;
  if ($attributes) {
    foreach ($attributes as $id => $att_list) {
      $id_search_path = '//*[@id="' . $id . '"]';
      $fnd = $rpt_xml
        ->xpath($id_search_path);
      if ($fnd) {
        $node = $fnd[0];

        // Start attribute replacement
        $frx_attributes = $node
          ->Attributes(FRX_NS);
        foreach ($att_list as $key => $value) {
          if (!$frx_attributes[$key]) {
            $node['frx:' . $key] = $value;
          }
          else {
            unset($frx_attributes[$key]);
            $node['frx:' . $key] = $value;
          }
        }
      }
    }
  }
}