You are here

function forena_format_form in Forena Reports 7.3

Same name and namespace in other branches
  1. 6.2 forena.admin.inc \forena_format_form()
  2. 7.2 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 245

Code

function forena_format_form($formid, $form_state, $report_name) {
  $desc = Frx::Menu()
    ->parseURL($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'];
    $doclist = Frx::Menu()->doc_formats;
    $skins[''] = t('Use Default');
    $skins = array_merge(variable_get('forena_skins', array()), $skins);
    $form['report_name'] = array(
      '#type' => 'value',
      '#value' => $name,
    );
    $form['form'] = array(
      '#type' => 'select',
      '#title' => t('Skin'),
      '#options' => $skins,
      '#default_value' => $report_form,
      '#description' => t('The page style of your report.  The {skin}.skinfo file specifies css and js file in your report.'),
    );

    //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 $value) {
        $options[$value] = strtoupper($value);
        $doc = isset($r) ? $r->simplexml->head
          ->xpath('frx:docgen/frx:doc[@type="' . $value . '"]') : '';
        if ($doc && array_search($value, $doclist) !== FALSE) {
          $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;
}