You are here

function _forena_filter_process in Forena Reports 6.2

Same name and namespace in other branches
  1. 8 forena.module \_forena_filter_process()
  2. 6 forena.module \_forena_filter_process()
  3. 7.5 forena.module \_forena_filter_process()
  4. 7 forena.module \_forena_filter_process()
  5. 7.2 forena.module \_forena_filter_process()
  6. 7.3 forena.module \_forena_filter_process()
  7. 7.4 forena.module \_forena_filter_process()
1 call to _forena_filter_process()
forena_filter in ./forena.module
Implememntation of hook_filter

File

./forena.module, line 740

Code

function _forena_filter_process($text = '') {
  global $language;
  require_once 'forena.common.inc';

  // initial Parameters
  $in_parms = array();
  $in_parms = $_GET;

  // Find the instances of [xmlreport:view,
  if (preg_match_all("/\\[report?:?([^\\]]+)\\]/i", $text, $match)) {
    foreach ($match[1] as $idx => $value) {
      $parms = array();

      // Separate view from parmeters
      @(list($report_name, $parmsStr) = explode(':', $value));

      // Get any static parmeters
      $pairs = explode(',', $parmsStr);
      if ($pairs) {
        foreach ($pairs as $pair) {
          @(list($key, $value) = explode('=', $pair));
          $parms[$key] = $value;
        }
      }
      $parms = array_merge($parms, $in_parms);

      // Debug the result
      $r = FrxReportGenerator::instance()
        ->get_report($report_name, $parms);
      if ($r) {
        $output = $r
          ->render(null);
      }
      else {
        $output = '';
      }

      // Finally replace the parameters
      $find[] = $match[0][$idx];
      $replace[] = $output;
    }
    return str_replace($find, $replace, $text);
  }

  // If we didn't find anything return the text.
  return $text;
}