You are here

public function Report::save_attributes_by_id in Forena Reports 7.5

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

src/Report.php, line 544
Basic report provider. Controls the rendering of the report.

Class

Report

Namespace

Drupal\forena

Code

public function save_attributes_by_id() {
  $attributes = $this->frx_attributes;
  $rpt_xml = $this->rpt_xml;
  if ($attributes) {
    foreach ($attributes as $id => $att_list) {
      $id_search_path = 'body//*[@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;
          }
        }
      }
    }
  }
}