You are here

public function Report::processParameters in Forena Reports 7.5

Same name and namespace in other branches
  1. 8 src/Report.php \Drupal\forena\Report::processParameters()

Default the parameters ba

Parameters

$parms Array of parameters.:

Return value

boolean indicating whether the required parameters are present.

File

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

Class

Report

Namespace

Drupal\forena

Code

public function processParameters($parms = NULL) {
  if ($parms == NULL) {
    $parms = $this->parms;
  }
  else {
    $this->parms = $parms;
  }
  $missing_parms = FALSE;
  foreach ($this->parameters as $key => $parm) {
    if ((@$parms[$key] === '' || @$parms[$key] === array() || @$parms[$key] === NULL) && @$parm['value']) {
      $value = $parm['value'];
      $options = array();
      if (@$parm['options']) {
        parse_str($parm['options'], $options);
      }
      switch ((string) @$parm['type']) {
        case 'date_text':
        case 'date_popup':
        case 'date_select':
          if ($value) {
            $date_format = @$options['date_format'] ? $options['date_format'] : 'Y-m-d';
            $datetime = @strtotime($value);
            if ($datetime) {
              $value = date($date_format, $datetime);
            }
          }
          break;
        default:
          if (strpos($value, '|') !== FALSE) {
            $value = explode('|', $value);
          }
      }
      $parms[$key] = $value;
      $reload_params = TRUE;
    }

    //do not show report if a required parameter does not have a value

    //force the user to input a parameter
    if (@(!$parms[$key]) && @strcmp($parm['require'], "1") == 0) {
      $missing_parms = TRUE;
    }
  }
  $this->parms = $parms;
  return $missing_parms;
}