function forena_layout_form_submit in Forena Reports 6
Same name and namespace in other branches
- 6.2 forena.admin.inc \forena_layout_form_submit()
- 7 forena.admin.inc \forena_layout_form_submit()
- 7.2 forena.admin.inc \forena_layout_form_submit()
- 7.3 forena.admin.inc \forena_layout_form_submit()
builds a string of the xml document, submits it to forena_save_report.
1 string reference to 'forena_layout_form_submit'
- forena_layout_form in ./
forena.admin.inc - Form function for the edit report form
File
- ./
forena.admin.inc, line 557
Code
function forena_layout_form_submit($form, &$form_state) {
$values = $form_state['values'];
$report_name = $values['save_report_name'];
$r = forena_get_report_editor($values['report_name']);
// Title and category
$r
->setTitle($values['title']);
$r
->setCategory($values['category']);
// Form options
$options = array(
'hidden' => $values['hidden'],
'form' => $values['form'],
);
$r
->setOptions($options);
// Doc gen settings.
$docgen = array();
if ($selected = array_filter($values['docgen']['docs'])) {
foreach ($selected as $key => $value) {
if ($value) {
$docgen[] = array(
'type' => $key,
);
}
}
}
$r
->setDocgen($docgen);
// Body
$r
->setBody($values['body']);
// If there are no frx attributes in the body then replace them with the old values.
$frx_nodes = $r->simplexml
->xpath('body//*[@frx:block]');
if (!$frx_nodes) {
$r
->save_attributes_by_id($values['attributes']);
}
//determine redirection.
$report_path = forena_report_path();
$filename = $report_path . '/' . $report_name . '.frx';
if (!file_exists($filename)) {
$new_rpt = TRUE;
}
else {
$new_rpt = FALSE;
}
if (forena_save_report($report_name, $r
->asXML(), TRUE) == 1) {
drupal_set_message('Your report, "' . $report_name . '" has been saved.');
//if this is a new report then redirect to data blocks
if ($new_rpt) {
$form_state['redirect'] = 'reports/' . str_replace('/', '.', $report_name) . '/data';
}
else {
$form_state['redirect'] = 'reports/' . str_replace('/', '.', $report_name) . '/layout';
}
}
}