function forena_layout_form in Forena Reports 7.3
Same name and namespace in other branches
- 6.2 forena.admin.inc \forena_layout_form()
- 6 forena.admin.inc \forena_layout_form()
- 7 forena.admin.inc \forena_layout_form()
- 7.2 forena.admin.inc \forena_layout_form()
Form function for the edit report form
Parameters
$form_state:
Return value
the form
1 string reference to 'forena_layout_form'
- forena_menu in ./
forena.module - Implementation of hook_menu.
File
- ./
forena.admin.inc, line 352
Code
function forena_layout_form($form, $form_state, $report_name) {
$name_in = $report_name;
$desc = Frx::Menu()
->parseURL($report_name);
$name = $desc['name'];
global $language;
//determine if this is an add new report request
$filename = $desc['filename'];
$format = @$desc['format'];
if ($name) {
if (isset($desc['exists']) && $desc['exists']) {
$save_name = $name;
//set the name to empty string for new reports
$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';
}
}
drupal_set_title(filter_xss($r->title));
// 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();
$menu = $r
->getMenu();
$body = $r->simplexml->body
->asXML();
$css = @(string) $r->simplexml->head->style;
$form = array();
//array of xml attributes that are required to have a value
$required = array(
'id' => TRUE,
'label' => TRUE,
);
$form['report_name'] = array(
'#type' => 'value',
'#value' => $name,
);
$form['name_in'] = array(
'#type' => 'value',
'#value' => $name_in,
);
$form['attributes'] = array(
'#type' => 'value',
'#value' => $attributes,
);
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $title,
);
$form['body'] = array(
'#type' => 'text_format',
'#title' => t('Body'),
'#default_value' => $body,
'#rows' => 25,
'#format' => variable_get('forena_input_format', filter_default_format()),
);
$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),
);
$form['menu']['path'] = array(
'#type' => 'textfield',
'#title' => t('Menu Path'),
'#description' => t('Indicate site reletive 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)'),
'#default_value' => @$menu['args'],
);
$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.'),
'#default_value' => @$menu['title'],
);
$menu_options = array(
'normal-item' => t('Normal'),
'local-task' => t('Tab'),
'default-local-taks' => t('Default Tab'),
'callback' => t('Callback'),
);
$form['menu']['type'] = array(
'#type' => 'select',
'#title' => 'Type of menu to create',
'#options' => $menu_options,
'#default_value' => @$menu['type'],
);
$form['style'] = array(
'#type' => 'fieldset',
'#title' => t('CSS Styles'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['style']['css'] = array(
'#type' => 'textarea',
'#default_value' => $css,
'#description' => t('Specify small css snipets that can be used in the reports.'),
'#rows' => 10,
'#cols' => 80,
);
$form['buttons']['save'] = array(
'#type' => 'submit',
'#value' => 'Save',
'#submit' => array(
'forena_layout_form_submit',
),
);
if (user_access('delete report')) {
$form['buttons']['delete'] = array(
'#type' => 'submit',
'#value' => 'Delete',
'#submit' => array(
'forena_edit_delete_submit',
),
);
}
return $form;
}
else {
drupal_not_found();
exit;
}
}
else {
drupal_not_found();
exit;
}
}