function forena_report_general_form in Forena Reports 7.5
Same name and namespace in other branches
- 8 forena.report.inc \forena_report_general_form()
- 7.4 forena.report.inc \forena_report_general_form()
1 string reference to 'forena_report_general_form'
- forena_menu in ./
forena.module - Implementation of hook_menu.
File
- ./
forena.report.inc, line 261
Code
function forena_report_general_form($form, &$form_state, $report_name) {
if (!$report_name) {
$report_name = $form_state['storage']['report_name'];
}
else {
$form_state['storage']['report_name'] = $report_name;
}
//set the name to empty string for new reports
$r = Frx::Editor($report_name);
$title = (string) $r->title;
drupal_set_title(filter_xss($r->title));
$frx_options = $r
->getOptions();
$hidden = @$frx_options['hidden'] == '1' ? 1 : 0;
$report_form = @$frx_options['form'];
$category = $r
->getCategory();
if (isset($form_state['values']['menu'])) {
$menu = $form_state['values']['menu'];
}
else {
$menu = $r
->getMenu();
$menu['enabled'] = @$menu['path'] ? 1 : 0;
if (!isset($menu['type'])) {
$menu['type'] = 'callback';
}
}
$cache = $r
->getCache();
$form['report_name'] = array(
'#type' => 'value',
'#value' => $report_name,
);
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $title,
);
$form['visibility'] = array(
'#type' => 'fieldset',
'#title' => t('Visibility'),
);
$form['visibility']['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['visibility']['hidden'] = array(
'#type' => 'checkbox',
'#title' => t('Hidden'),
'#default_value' => $hidden,
'#description' => t('Hide your report from showing up on the report list.'),
);
$form['menu'] = array(
'#type' => 'fieldset',
'#title' => t('Menu'),
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => empty($menu),
'#prefix' => '<div id="forena-menu-wrapper">',
'#suffix' => '</div>',
);
$form['menu']['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Provide a menu link'),
'#default_value' => @$menu['enabled'],
'#ajax' => array(
'callback' => 'forena_report_general_menu_ajax',
'wrapper' => 'forena-menu-wrapper',
),
);
$form['menu']['path'] = array(
'#type' => 'textfield',
'#title' => t('Menu Path'),
'#access' => $menu['enabled'],
'#description' => t('Indicate site relative path to menu. Parameters may be embedded in the url using a :parm syntax (e.g. states/:state)'),
'#default_value' => @$menu['path'],
);
$form['menu']['args'] = array(
'#type' => 'textfield',
'#title' => t('Additional Arguments'),
'#description' => t('Indicate additonal parameters that should be extracted after the menu path using a :parm syntax (e.g. :parma/:parmb)'),
'#access' => $menu['enabled'],
'#default_value' => @$menu['args'],
);
$menu_options = array(
'normal-item' => t('Normal'),
'local-task' => t('Tab'),
'default-local-task' => t('Default Tab'),
'callback' => t('Callback'),
);
$form['menu']['type'] = array(
'#type' => 'select',
'#title' => 'Type of menu to create',
'#options' => $menu_options,
'#access' => $menu['enabled'],
'#default_value' => @$menu['type'],
'#ajax' => array(
'callback' => 'forena_report_general_menu_ajax',
'wrapper' => 'forena-menu-wrapper',
),
);
$form['menu']['title'] = array(
'#type' => 'textfield',
'#title' => t('Menu Title'),
'#description' => t('Title of menu item. Leave blank to use the report title as the menu title.'),
'#access' => $menu['enabled'] && $menu['type'] != 'callback',
'#default_value' => @$menu['title'],
);
$options = menu_parent_options(menu_get_menus(), 0);
$default = @$menu['menu_name'];
if ($default && @$menu['plid']) {
$default .= ':' . $menu['plid'];
}
$form['menu']['parent'] = array(
'#type' => 'select',
'#title' => t('Parent item'),
'#default_value' => $default,
'#options' => $options,
'#empty_option' => t('Not Specified'),
'#empty_value' => '',
'#access' => $menu['enabled'] && $menu['type'] == 'normal-item',
'#attributes' => array(
'class' => array(
'menu-parent-select',
),
),
);
$form['menu']['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
'#delta' => 50,
'#access' => $menu['enabled'] && $menu['type'] != 'callback',
'#default_value' => @$menu['weight'],
'#description' => t('Menu links with smaller weights are displayed before links with larger weights.'),
);
$form['cache'] = array(
'#type' => 'fieldset',
'#title' => t('Cache'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => TRUE,
);
$form['cache']['duration'] = array(
'#type' => 'textfield',
'#title' => t('Duration'),
'#description' => t('Specify a php strtotime relative date duration, (e.g. +1 hour, +2 days)'),
'#default_value' => @$cache['duration'],
);
$form['cache']['per_user'] = array(
'#type' => 'checkbox',
'#title' => t('Per User'),
'#default_value' => @$cache['per_user'],
);
$form['cache']['per_doctype'] = array(
'#type' => 'checkbox',
'#title' => t('Per Document Type'),
'#default_value' => @$cache['per_doctype'],
);
$form['update'] = array(
'#type' => 'submit',
'#value' => t('Update'),
'#submit' => array(
'forena_report_general_form_submit',
),
);
$form['cancel'] = array(
'#type' => 'submit',
'#value' => 'Cancel',
'#submit' => array(
'forena_update_cancel',
),
);
return $form;
}