You are here

function forena_add_report_form in Forena Reports 7.3

Same name and namespace in other branches
  1. 8 forena.report.inc \forena_add_report_form()
  2. 6.2 forena.admin.inc \forena_add_report_form()
  3. 7.5 forena.report.inc \forena_add_report_form()
  4. 7.2 forena.admin.inc \forena_add_report_form()
  5. 7.4 forena.report.inc \forena_add_report_form()
1 string reference to 'forena_add_report_form'
forena_menu in ./forena.module
Implementation of hook_menu.

File

./forena.admin.inc, line 612

Code

function forena_add_report_form($formid, $form_state, $report_name = '') {
  $name = '';
  $filename = '';
  $format = '';
  if ($report_name) {
    $desc = Frx::Menu()
      ->parseURL($report_name);
    $name = $desc['name'];
    $filename = $desc['filename'];
    $format = @$desc['format'];
  }
  $form = array();
  global $language;

  //determine if this is an add new report request
  $r = forena_get_report_editor($name);
  $title = (string) $r->title;
  if (module_exists('locale')) {
    @(list($tlang, $tsave_name) = explode('/', $name, 2));

    // FInd out if the starting name of the report is an installed language.
    if (array_key_exists($tlang, language_list())) {
      $lang = $tlang;
      $save_name = $tsave_name;
    }
    else {
      $lang = 'en';
    }
  }

  // Need to get all option attributes
  $frx_options = $r
    ->getOptions();
  $hidden = @$frx_options['hidden'] == '1' ? 1 : 0;
  $report_form = @$frx_options['form'];
  $attributes = $r
    ->get_attributes_by_id();
  $category = $r
    ->getCategory();
  $body = $r->simplexml->body
    ->asXML();

  //array of xml attributes that are required to have a value
  $required = array(
    'id' => TRUE,
    'label' => TRUE,
  );

  //list of supported document formats
  $doclist = variable_get('forena_doc_formats', array());
  $form['save_report_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Report Name'),
    '#description' => t('Enter only letters, numbers, and special characters:  - _ /
                         <br/>White space is not permitted.
                         Create a directory using the format: (directory name) / (report name). Save multiple reports to the same directory
                         by referencing the same name.'),
    '#required' => TRUE,
  );
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => $title,
    '#required' => TRUE,
  );
  $form['category'] = array(
    '#type' => 'textfield',
    '#title' => t('Category'),
    '#default_value' => $category,
    '#autocomplete_path' => 'forena/categories/autocomplete',
    '#description' => t('The heading your report will be grouped under on the report list.'),
  );
  $form['hidden'] = array(
    '#type' => 'checkbox',
    '#title' => t('Hidden'),
    '#default_value' => $hidden,
    '#description' => t('Hide your report from showing up on the report list.'),
  );
  $form['report_name'] = array(
    '#title' => t('Create from report'),
    '#type' => 'textfield',
    '#autocomplete_path' => 'forena/reports/autocomplete',
    '#default_value' => $name,
  );
  $form['save'] = array(
    '#type' => 'submit',
    '#value' => 'Create',
  );
  return $form;
}