You are here

function forena_report in Forena Reports 8

Same name and namespace in other branches
  1. 6.2 forena.module \forena_report()
  2. 6 forena.module \forena_report()
  3. 7.5 forena.module \forena_report()
  4. 7 forena.module \forena_report()
  5. 7.2 forena.module \forena_report()
  6. 7.3 forena.module \forena_report()
  7. 7.4 forena.module \forena_report()

Load and render a report based on a drupal path. In this function the arglist is used to get the full path to the report.

Return value

array|string Report contents.

2 calls to forena_report()
forena_report_menu_callback in ./forena.module
Menu callback for rendering the forena report.
_forena_filter_process in ./forena.module
Process tag replacement for xml filters

File

./forena.module, line 135

Code

function forena_report($name_in, $parms = NULL, $print = TRUE, $filename = '') {
  require_once 'forena.common.inc';
  $desc = FrxAPI::Menu()
    ->parseURL($name_in);
  $time = @new DateTime($value);
  $desc['time'] = date_format($time, 'Y-m-d H:i:s');
  $desc['basepath'] = base_path();
  $desc['path'] = $desc['basepath'] . FrxAPI::File()
    ->directory(FrxAPI::File()
    ->path($desc['filename'], TRUE));
  $desc['theme'] = $desc['basepath'] . drupal_get_path('theme', \Drupal::theme()
    ->getActiveTheme()
    ->getName());
  $format = $desc['format'];
  if (!$desc['exists']) {
    \Drupal::logger('error')
      ->error('Report %s not found', array(
      '%s' => $name_in,
    ));
    if ($print) {
      throw new NotFoundHttpException();
    }
    return '';
  }
  FrxData::instance()
    ->setContext('cookie', $_COOKIE);
  FrxData::instance()
    ->setContext('report', $desc);
  $report_name = $desc['name'];

  // Load dataTable plugin if possible.

  //forena_include_data_tables();
  $content = FrxAPI::Editor($name_in, FALSE)
    ->report($parms, $print, FALSE, $filename);
  if ($format == 'web' && $print) {
    $content['#attached']['css'][] = drupal_get_path('module', 'forena') . '/forena.css';
  }
  $m_path = drupal_get_path('module', 'forena');
  if ($content) {

    // This has been deprecated, but we'll eave it in for now.
    $content['#attached']['js'][] = $m_path . '/forena.js';
  }
  if (!$print && is_array($content)) {
    return drupal_render($content['content']);
  }
  return $content;
}