You are here

function forena_report_page_callback in Forena Reports 7.4

Parameters

string $report_name:

string $com:

1 string reference to 'forena_report_page_callback'
forena_menu in ./forena.module
Implementation of hook_menu.

File

./forena.module, line 1021

Code

function forena_report_page_callback($report_name, $js_mode, $id = '', $command = '') {
  $commands = array();
  if ($js_mode != 'ajax') {
    return forena_report($report_name);
  }
  else {
    $content = forena_report($report_name);
    $report =& $content['content']['#markup'];
    if (!empty($content['content']['#ajax_commands']['pre'])) {
      $commands = array_merge($commands, $content['content']['#ajax_commands']['pre']);
    }
    if (!$command) {
      $command = 'modal';
    }
    switch ($command) {
      case 'after':
        $commands[] = ajax_command_after("#{$id}", $report);
        break;
      case 'append':
        $commands[] = ajax_command_append("#{$id}", $report);
        break;
      case 'before':
        $commands[] = ajax_command_before("#{$id}", $report);
        break;
      case 'modal':
        $title = Frx::Editor()->frxReport->title;
        if (is_callable('ctools_include')) {
          ctools_include('modal');
          ctools_modal_render($title, $report);
          return NULL;
        }
        else {
          drupal_set_title($title);
          return $content;
        }
        break;
      case 'html':
        $commands[] = ajax_command_html("#{$id}", $report);
        break;
      case 'replace':
        $commands[] = ajax_command_replace("#{$id}", $report);
        break;
    }
    if (!empty($content['content']['#ajax_commands']['post'])) {
      $commands = array_merge($commands, $content['content']['#ajax_commands']['post']);
    }
    ajax_deliver(array(
      '#type' => 'ajax',
      '#commands' => $commands,
    ));
  }
}