function tripal_views_data_export_download_form
1.x tripal_views.views.inc | tripal_views_data_export_download_form(&$form_state, $view, $display_id, $args) |
the Download Views data export form
2 string references to 'tripal_views_data_export_download_form'
- tripal_views_theme in tripal_views/
tripal_views.module - Implements hook_theme()
- tripal_views_views_pre_render in tripal_views/
tripal_views.views.inc - Implements hook_views_pre_render
File
- tripal_views/
tripal_views.views.inc, line 724 - Tripal Views Integration
Code
function tripal_views_data_export_download_form(&$form_state, $view, $display_id, $args) {
$form = array();
$urls = array();
// get any export_data_export displays
$displays = $view->display;
$options = array();
$default = '';
$current_display = $view->current_display;
foreach ($displays as $name => $display) {
if (preg_match("/^views_data_export/", $name)) {
// only add this display to the form if it is attached
$display_options = $display->display_options;
if (strcmp($display_options['displays'][$current_display], $current_display) != 0) {
continue;
}
// set the first item as default
if (!$default) {
$default = $display->id;
}
$path = $display->display_options['path'];
$query = $view->get_exposed_input(); // retrieves elements in $_GET array
$urls[$display->id]['path'] = $path;
$urls[$display->id]['query'] = $query;
// add the new item to the options array
$options[$display->id] = $display->display_title;
}
}
// only generate the form if we have views_data_export displays attached
// to this view
if (count($options) > 0) {
$form_state['storage']['urls'] = $urls;
$form['#cache'] = TRUE;
// we want the form to redirect to a new window
$form['#attributes']['target'] = "_blank";
// now build the form elements
$form['downloads'] = array(
'#type' => 'fieldset',
'#title' => 'Download Results',
'#collapsible' => TRUE,
'#collapsed' => FALSE
);
$form['downloads']['file_type'] = array(
'#title' => t('File format'),
'#type' => 'radios',
'#options' => $options,
'#required' => TRUE,
'#default_value' => $default,
'#description' => t('Please select a file format to download'),
);
$form['downloads']['submit'] = array(
'#value' => t('Download Results'),
'#type' => 'submit',
);
}
return $form;
}