function forena_data_block_form in Forena Reports 6.2
Same name and namespace in other branches
- 6 forena.admin.inc \forena_data_block_form()
- 7 forena.admin.inc \forena_data_block_form()
- 7.2 forena.admin.inc \forena_data_block_form()
- 7.3 forena.admin.inc \forena_data_block_form()
A form to preview and add data blocks to an existing report
Parameters
unknown_type $form_state:
Return value
unknown_type
2 string references to 'forena_data_block_form'
- forena_data_block in ./
forena.module - Add, preview, or delete data blocks from your report
- forena_menu in ./
forena.module - Implementation of hook_menu.
File
- ./
forena.admin.inc, line 1942
Code
function forena_data_block_form(&$form_state, $report_name) {
$desc = forena_report_desc($report_name);
if (!$desc['exists']) {
drupal_not_found();
exit;
}
$name = $desc['name'];
$filename = $desc['filename'];
$format = isset($desc['format']) ? $desc['format'] : '';
$r = forena_get_report_editor($name);
drupal_set_title($r->title);
$form = array();
$title = (string) $r->title;
$template_array = FrxReportGenerator::instance()
->supported_templates();
@($default_template = $form_state['storage']['template']);
@($params = $form_state['storage']['parameters']);
@($param_values = $form_state['storage']['param_values']);
$form = array();
$form['report_name'] = array(
'#type' => 'value',
'#value' => $name,
);
$links = array();
$links[] = array(
'href' => $desc['link'] . '/edit/data/add',
'title' => 'Add Data',
);
$form['add_link'] = array(
'#type' => 'markup',
'#value' => theme_links($links, array(
'class' => 'action-links',
)),
);
//The default submit handler
//If someone presses enter, this handler will execute
$form['default_submit'] = array(
'#type' => 'submit',
'#submit' => array(
'forena_data_block_form_submit',
),
'#prefix' => '<div style="visibility:hidden;float:right">',
'#suffix' => '</div>',
);
//find the datablocks in the existing report
$data_block_array = array();
if ($r) {
$r
->get_attributes_by_id();
}
$body = $r->simplexml->body;
$path = '//*[@frx:block]';
$form['blocks'] = array(
'#tree' => TRUE,
);
if ($body) {
foreach ($body
->xpath($path) as $node) {
$attrs = $node
->attributes(FRX_NS);
$id = (string) $node['id'];
$block = (string) $attrs['block'];
$parameters = (string) $attrs['parameters'];
$clause = $attrs['clause'] ? "(" . (string) $attrs['clause'] . ")" : '';
$block_info = FrxReportGenerator::instance()
->load_block($block, $clause);
$access = $block_info['access'];
$data_block_array[$id] = $block . ": <i>" . $clause . ' security "' . $access . '"</i>';
$ctl = array(
'#type' => 'fieldset',
'#title' => $id,
'#collapsible' => true,
);
$ctl['id'] = array(
'#type' => 'value',
'#value' => $id,
);
$ctl['block'] = array(
'#type' => 'textfield',
'#autocomplete_path' => 'forena/data_block/autocomplete',
'#title' => 'Data Block',
'#default_value' => $block,
'#description' => t('The data block to be used as the source for the data in the report.'),
);
$ctl['access'] = array(
'#type' => 'item',
'#value' => $access,
'#title' => t('Security'),
);
$ctl['parameters'] = array(
'#type' => 'textfield',
'#title' => t('Parameters'),
'#default_value' => $parameters,
'#description' => t('Leave blank to use the current data context as parameters. In a simple report this will be the parameters of the report.
In master detail reports, this will be the report of the containing data block. Parameters should be specified in the form of a url string.'),
);
$ctl['delete'] = array(
'#type' => 'checkbox',
'#title' => 'Confirm delete',
'#description' => t('Check this box to remove this data from the report.'),
);
$ctl['delete_submit'] = array(
'#type' => 'submit',
'#value' => 'Delete',
'#submit' => array(
'forena_data_block_delete',
),
);
$form['blocks'][] = $ctl;
}
}
$form['save'] = array(
'#type' => 'submit',
'#value' => 'Save',
);
return $form;
}