You are here

function forena_format_form in Forena Reports 6.2

Same name and namespace in other branches
  1. 7.2 forena.admin.inc \forena_format_form()
  2. 7.3 forena.admin.inc \forena_format_form()
1 string reference to 'forena_format_form'
forena_menu in ./forena.module
Implementation of hook_menu.

File

./forena.admin.inc, line 460

Code

function forena_format_form($form_state, $report_name) {
  $desc = forena_report_desc($report_name);
  $name = $desc['name'];
  if (!$desc['exists']) {
    drupal_not_found();
    exit;
  }
  $filename = $desc['filename'];
  $format = isset($desc['format']) ? $desc['format'] : '';
  if ($desc['exists']) {
    $r = forena_get_report_editor($name);
    drupal_set_title($r->title);
    $form = array();
    $r = forena_get_report_editor($name);
    $frx_options = $r
      ->getOptions();
    $report_form = @$frx_options['form'];
    $supported = FrxReportGenerator::instance()
      ->supported_doctypes();
    $doclist = variable_get('forena_doc_formats', array());
    $form['report_name'] = array(
      '#type' => 'value',
      '#value' => $name,
    );
    $form['form'] = array(
      '#type' => 'textfield',
      '#title' => t('Form'),
      '#default_value' => $report_form,
      '#description' => t('The page style of your report.  Specify the base filename of any css or js. '),
    );

    //begin checking doc generation options
    if ($r) {
      $nodes = $r->simplexml->head
        ->xpath('frx:docgen/frx:doc');
    }
    if ($doclist) {
      $form['docgen'] = array(
        '#tree' => TRUE,
        '#type' => 'fieldset',
        '#title' => t('Document Options'),
        '#description' => t('These are document transformation options. Options selected will display as links in your report view.'),
      );

      //build the options and default list
      $options = array();
      $default = array();
      foreach ($doclist as $key => $value) {
        if (is_object(FrxReportGenerator::instance()
          ->get_doctypes($value))) {
          $options[$value] = strtoupper($value);
          $doc = isset($r) ? $r->simplexml->head
            ->xpath('frx:docgen/frx:doc[@type="' . $value . '"]') : '';
          if ($doc && $doclist[$value]) {
            $default[$value] = $value;
          }
        }
      }

      //display checkboxes
      $form['docgen']['docs'] = array(
        '#type' => 'checkboxes',
        '#description' => t('If no options are selected, the system will display all of the above as available for this report.'),
        '#options' => $options,
        '#default_value' => $default,
      );
      $form['submit'] = array(
        '#type' => 'submit',
        '#value' => 'Save',
      );
    }
  }
  return $form;
}