tripal_views.views.inc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. <?php
  2. include('views/handlers/views_handler_join_chado_through_linking.inc');
  3. include('views/handlers/views_handler_join_chado_aggregator.inc');
  4. include('api/tripal_views.api.inc');
  5. // TEMPORARY
  6. include('views/chado_linking.TMP.inc');
  7. /**
  8. * @file
  9. * Tripal Views Integration
  10. *
  11. * @defgroup views Views Integration
  12. * @{
  13. * Provide rules for formatting and composition of fields
  14. * @}
  15. *
  16. * @defgroup views_handlers Views Integration Handlers
  17. * @ingroup views
  18. * @{
  19. * Provide rules for formatting and composition of fields
  20. * @}
  21. *
  22. * @defgroup views_field_handlers Views Field Handlers
  23. * @ingroup views_handlers
  24. * @{
  25. * Provide rules for formatting and composition of fields
  26. * @}
  27. *
  28. *
  29. * @defgroup views_filter_handlers Views Filter Handlers
  30. * @ingroup views_handlers
  31. * @{
  32. * Provide the ability to filter based on specified data
  33. * @}
  34. *
  35. * @defgroup views_sort_handlers Views Sort Handlers
  36. * @ingroup views_handlers
  37. * @{
  38. * Provide methods describing how specific data should be sorted
  39. * @}
  40. *
  41. * @defgroup views_argument_handlers Views Arguement Handlers
  42. * @ingroup views_handlers
  43. * @{
  44. * Provide the ability to filter pased on arguments in the path of the view
  45. * @}
  46. */
  47. /**
  48. * Implements hook_views_handlers()
  49. *
  50. * Purpose: Register all custom handlers with views
  51. * where a handler describes either "the type of field",
  52. * "how a field should be filtered", "how a field should be sorted"
  53. *
  54. * @return
  55. * An array of handler definitions
  56. *
  57. * @ingroup tripal_views
  58. */
  59. function tripal_views_views_handlers() {
  60. return array(
  61. 'info' => array(
  62. 'path' => drupal_get_path('module', 'tripal_views') . '/views/handlers',
  63. ),
  64. 'handlers' => array(
  65. // Custom Tripal Filter Handlers
  66. 'tripal_views_handler_filter_file_upload' => array(
  67. 'parent' => 'views_handler_filter',
  68. ),
  69. 'tripal_views_handler_filter_textarea' => array(
  70. 'parent' => 'views_handler_filter',
  71. ),
  72. 'tripal_views_handler_filter_no_results' => array(
  73. 'parent' => 'views_handler_filter'
  74. ),
  75. 'tripal_views_handler_filter_select_cvterm' => array(
  76. 'parent' => 'views_handler_filter_string',
  77. ),
  78. 'tripal_views_handler_filter_select_string' => array(
  79. 'parent' => 'chado_views_handler_filter_string',
  80. ),
  81. 'tripal_views_handler_filter_sequence' => array(
  82. 'parent' => 'chado_views_handler_filter_string',
  83. ),
  84. // Custom Tripal Field Handlers
  85. 'tripal_views_handler_field_aggregate' => array(
  86. 'parent' => 'chado_views_handler_field',
  87. ),
  88. 'tripal_views_handler_field_sequence' => array(
  89. 'parent' => 'chado_views_handler_field',
  90. ),
  91. // Join Handlers
  92. 'views_handler_join_chado_aggregator' => array(
  93. 'parent' => 'views_join',
  94. ),
  95. 'views_handler_join_chado_through_linking' => array(
  96. 'parent' => 'views_join',
  97. ),
  98. // Relationship Handlers
  99. 'chado_views_handler_relationship' => array(
  100. 'parent' => 'views_handler_relationship'
  101. ),
  102. 'chado_views_handler_relationship_to_node' => array(
  103. 'parent' => 'views_handler_relationship'
  104. ),
  105. // Wrappers for Default Views Handlers-----
  106. // Field Handlers
  107. 'chado_views_handler_field' => array(
  108. 'parent' => 'views_handler_field'
  109. ),
  110. 'chado_views_handler_field_boolean' => array(
  111. 'parent' => 'views_handler_field_boolean'
  112. ),
  113. 'chado_views_handler_field_counter' => array(
  114. 'parent' => 'views_handler_field_counter'
  115. ),
  116. 'chado_views_handler_field_custom' => array(
  117. 'parent' => 'views_handler_field_custom'
  118. ),
  119. 'chado_views_handler_field_date' => array(
  120. 'parent' => 'views_handler_field_date'
  121. ),
  122. 'chado_views_handler_field_markup' => array(
  123. 'parent' => 'views_handler_field_markup'
  124. ),
  125. 'chado_views_handler_field_math' => array(
  126. 'parent' => 'views_handler_field_math'
  127. ),
  128. 'chado_views_handler_field_numeric' => array(
  129. 'parent' => 'views_handler_field_numeric'
  130. ),
  131. // Filter Handlers
  132. 'chado_views_handler_filter_string' => array(
  133. 'parent' => 'views_handler_filter_string',
  134. ),
  135. 'chado_views_handler_filter_boolean_operator_string' => array(
  136. 'parent' => 'views_handler_filter_boolean_operator_string',
  137. ),
  138. 'chado_views_handler_filter_boolean_operator' => array(
  139. 'parent' => 'views_handler_filter_boolean_operator',
  140. ),
  141. 'chado_views_handler_filter_date' => array(
  142. 'parent' => 'views_handler_filter_date',
  143. ),
  144. 'chado_views_handler_filter_equality' => array(
  145. 'parent' => 'views_handler_filter_equality',
  146. ),
  147. 'chado_views_handler_filter_float' => array(
  148. 'parent' => 'views_handler_filter_float',
  149. ),
  150. 'chado_views_handler_filter_numeric' => array(
  151. 'parent' => 'views_handler_filter_numeric',
  152. ),
  153. // Sort Handlers
  154. 'chado_views_handler_sort' => array(
  155. 'parent' => 'views_handler_sort'
  156. ),
  157. 'chado_views_handler_sort_date' => array(
  158. 'parent' => 'views_handler_sort_date'
  159. ),
  160. 'chado_views_handler_sort_formula' => array(
  161. 'parent' => 'views_handler_sort_formula'
  162. ),
  163. 'chado_views_handler_sort_menu_hierarchy' => array(
  164. 'parent' => 'views_handler_sort_menu_hierarchy'
  165. ),
  166. 'chado_views_handler_sort_random' => array(
  167. 'parent' => 'views_handler_sort_random'
  168. ),
  169. ),
  170. );
  171. }
  172. /**
  173. * Implements hook_views_pre_render
  174. *
  175. * Purpose: Intercepts the view after the query has been executed
  176. * All the results are stored in $view->result
  177. * Looking up the NID here ensures the query is only executed once
  178. * for all stocks in the table.
  179. *
  180. * @todo add if !<chado/drupal same db> around NID portion
  181. *
  182. * @ingroup tripal_views
  183. */
  184. function tripal_views_views_pre_render(&$view) {
  185. // We need to unset the exposed_input for the view so we can repopulate that
  186. // variable. This is necessary if we're using the file_upload_combo
  187. // custom form element which adds the file_path variable to the $_GET after the
  188. // view has populated the $view->exposed_input variable
  189. unset($view->exposed_input);
  190. // we want to add to the bottom of the views the form for downloading
  191. // results in other formats (e.g. Excel, FASTA, CSV, etc.). The Views Data
  192. // Export module provides small images at the bottom, but we want to provide
  193. // a more intutitive interface for getting different file formats
  194. $form = drupal_get_form('tripal_views_data_export_download_form', $view, $display_id, $args);
  195. $view->attachment_after = $form;
  196. }
  197. /**
  198. * Generates a dynamic data array for Views
  199. *
  200. * Purpose: This function is a hook used by the Views module. It populates and
  201. * returns a data array that specifies for the Views module the base table,
  202. * the tables it joins with and handlers. The data array is populated
  203. * using the data stored in the tripal_views tables.
  204. *
  205. * @return a data array formatted for the Views module
  206. *
  207. * @ingroup tripal_views
  208. */
  209. function tripal_views_views_data() {
  210. // Make sure all chado tables are integrated
  211. tripal_views_integrate_all_chado_tables();
  212. // Define Global Fields
  213. // Filter handler that lets the admin say:
  214. // "Show no results until they enter search parameters"
  215. $data['views']['search_results'] = array(
  216. 'title' => t('Search Results'),
  217. 'help' => t('Delay results until Apply/Search is clicked by the user.'),
  218. 'filter' => array(
  219. 'handler' => 'tripal_views_handler_filter_no_results',
  220. ),
  221. );
  222. $tvi_query = db_query('SELECT * FROM {tripal_views}');
  223. while ($tvi_row = db_fetch_object($tvi_query)) {
  224. // check to see if this is the lightest (drupal-style) priority setup for this table
  225. // if not then don't use this definition
  226. $lightest_priority_setup = tripal_views_is_lightest_priority_setup($tvi_row->setup_id, $tvi_row->table_name);
  227. if (!$lightest_priority_setup) {
  228. continue;
  229. }
  230. // ids we'll use for queries
  231. $setup_id = $tvi_row->setup_id;
  232. $mview_id = $tvi_row->mview_id;
  233. // holds the base table name and fields
  234. $base_table = '';
  235. $base_fields = array();
  236. // indicated whether the current table is a base table or not
  237. $is_base_table = $tvi_row->base_table;
  238. // populate the base table name and fields. If an $mview_id is given
  239. // then get the materialized view info, otherwise get the Chado table info
  240. if ($mview_id) {
  241. // get the base table name from the materialized view
  242. $sql = "SELECT name, mv_specs FROM {tripal_mviews} WHERE mview_id = %d";
  243. $mview_table = db_fetch_object(db_query($sql, $mview_id));
  244. $base_table = $mview_table->name;
  245. // get the columns in this materialized view. They are separated by commas
  246. // where the first word is the column name and the rest is the type
  247. $columns = explode(",", $mview_table->mv_specs);
  248. foreach ($columns as $column) {
  249. $column = trim($column); // trim trailing and leading spaces
  250. preg_match("/^(.*?)\ (.*?)$/", $column, $matches);
  251. $column_name = $matches[1];
  252. $column_type = $matches[2];
  253. $base_fields[$column_name] = array(
  254. 'column_name' => $column_name,
  255. 'type' => $column_type,
  256. );
  257. }
  258. // get the field name and descriptions
  259. $sql = "SELECT * FROM {tripal_views_field} WHERE setup_id=%d";
  260. $query = db_query($sql, $setup_id);
  261. while ($field = db_fetch_object($query)) {
  262. $base_fields[$field->column_name]['name'] = $field->name;
  263. $base_fields[$field->column_name]['help'] = $field->description;
  264. }
  265. }
  266. // if this is not a legacy materialized view
  267. else {
  268. $base_table = $tvi_row->table_name;
  269. // Check if we are trying to integrate the node table
  270. // if we are we want to add to a current integration
  271. // as compared to create a whole new one
  272. if ($base_table == 'node') {
  273. // Add any joins between the node table and other tables
  274. $sql = "SELECT * FROM {tripal_views_join} WHERE setup_id = %d";
  275. $joins = db_query($sql, $setup_id);
  276. while ($join = db_fetch_object($joins)) {
  277. $left_table = $join->left_table;
  278. $left_field = $join->left_field;
  279. $base_field = $join->base_field;
  280. $handler = $join->handler;
  281. // add join entry
  282. $data[$base_table]['table']['join'][$left_table] = array(
  283. 'left_field' => $left_field,
  284. 'field' => $base_field,
  285. );
  286. if ($handler) {
  287. $data[$base_table]['table']['join'][$left_table]['handler'] = $handler;
  288. }
  289. }
  290. // Add in any handlers for node fields
  291. $sql = "SELECT * FROM {tripal_views_handlers} WHERE setup_id=%d";
  292. $query = db_query($sql, $setup_id);
  293. while ($handler = db_fetch_object($query)) {
  294. $data[$base_table][$handler->column_name][$handler->handler_type]['handler'] = $handler->handler_name;
  295. // Add in any additional arguments
  296. // This should be a serialized array including (at a minimum) name => <handler name>
  297. if ($handler->arguments) {
  298. $data[$base_table][$handler->column_name][$handler->handler_type] = array_merge($data[$base_table][$handler->column_name][$handler->handler_type], unserialize($handler->arguments));
  299. }
  300. }
  301. continue;
  302. }
  303. // get the table description
  304. $table_desc = tripal_core_get_chado_table_schema($base_table);
  305. $fields = $table_desc['fields'];
  306. if (!is_array($fields)) {
  307. $fields = array();
  308. }
  309. foreach ($fields as $column => $attrs) {
  310. $base_fields[$column] = array(
  311. 'column_name' => $column,
  312. 'type' => $attrs['type'],
  313. );
  314. }
  315. // get the field name and descriptions
  316. $sql = "SELECT * FROM {tripal_views_field} WHERE setup_id=%d";
  317. $query = db_query($sql, $setup_id);
  318. while ($field = db_fetch_object($query)) {
  319. $base_fields[$field->column_name]['name'] = $field->name;
  320. $base_fields[$field->column_name]['help'] = $field->description;
  321. }
  322. }
  323. // Setup the base table info in the data array
  324. $data[$base_table]['table']['group'] = t("$tvi_row->name");
  325. if ($is_base_table) {
  326. $data[$base_table]['table']['base'] = array(
  327. 'group' => "$tvi_row->name",
  328. 'title' => "$tvi_row->name",
  329. 'help' => $tvi_row->comment,
  330. );
  331. }
  332. else {
  333. $data[$base_table]['table'] = array(
  334. 'group' => "$tvi_row->name",
  335. 'title' => "$tvi_row->name",
  336. 'help' => $tvi_row->comment,
  337. );
  338. }
  339. // first add the fields
  340. foreach ($base_fields as $column_name => $base_field) {
  341. $data[$base_table][$column_name] = array(
  342. 'title' => t($base_field['name']),
  343. 'help' => t($base_field['help']),
  344. 'field' => array(
  345. 'click sortable' => TRUE,
  346. ),
  347. );
  348. // now add the handlers
  349. $sql = "SELECT * FROM {tripal_views_handlers} WHERE setup_id = %d AND column_name = '%s'";
  350. $handlers = db_query($sql, $setup_id, $column_name);
  351. while ($handler = db_fetch_object($handlers)) {
  352. $data[$base_table][$column_name][$handler->handler_type]['handler'] = $handler->handler_name;
  353. // Add in any additional arguments
  354. // This should be a serialized array including (at a minimum) name => <handler name>
  355. if ($handler->arguments) {
  356. $data[$base_table][$column_name][$handler->handler_type] = array_merge($data[$base_table][$column_name][$handler->handler_type], unserialize($handler->arguments));
  357. }
  358. };
  359. }
  360. // now add the joins
  361. $sql = "SELECT * FROM {tripal_views_join} WHERE setup_id = %d";
  362. $joins = db_query($sql, $setup_id);
  363. if (!isset($joins)) {
  364. $joins = array();
  365. }
  366. while ($join = db_fetch_object($joins)) {
  367. $left_table = $join->left_table;
  368. $left_field = $join->left_field;
  369. $base_field = $join->base_field;
  370. $handler = $join->handler;
  371. // add join entry
  372. $data[$base_table]['table']['join'][$left_table] = array(
  373. 'left_field' => $left_field,
  374. 'field' => $base_field,
  375. );
  376. if ($handler) {
  377. $data[$base_table]['table']['join'][$left_table]['handler'] = $handler;
  378. }
  379. }
  380. }
  381. // TEMPORARY: needed to join chado base tables to node linking tables
  382. // currently done using old-style data arrays
  383. //$data = tripal_views_TEMPORARY_chado_linking_data($data);
  384. return $data;
  385. }
  386. /**
  387. *
  388. * @ingroup tripal_views
  389. */
  390. function tripal_views_views_data_alter(&$data) {
  391. $tvi_query = db_query('SELECT * FROM {tripal_views}');
  392. // iterate through the views that we manage
  393. while ($tvi_row = db_fetch_object($tvi_query)) {
  394. //ids we'll use for queries
  395. $mview_id = $tvi_row->mview_id;
  396. $setup_id = $tvi_row->setup_id;
  397. // iterate through the columns and alter the existing data array for
  398. // joins to other tables
  399. $sql = "SELECT * FROM {tripal_views_join} WHERE setup_id = %d";
  400. $joins = db_query($sql, $setup_id);
  401. while ($join = db_fetch_object($joins)) {
  402. $left_table = $join->left_table;
  403. $left_field = $join->left_field;
  404. $base_field = $join->base_field;
  405. $base_table = $join->base_table;
  406. // add the recipricol join entries for each column
  407. if (array_key_exists($left_table, $data)) {
  408. $data[$left_table]['table']['join'][$base_table] = array(
  409. 'left_field' => $base_field,
  410. 'field' => $left_field,
  411. );
  412. }
  413. }
  414. }
  415. return $data;
  416. }
  417. /**
  418. * Implementation of hook_views_plugins().
  419. */
  420. function tripal_views_views_plugins() {
  421. $tc_path = drupal_get_path('module', 'tripal_views');
  422. $style_defaults = array(
  423. 'path' => $tc_path . '/views_data_export/plugins',
  424. 'parent' => 'views_data_export',
  425. 'theme' => 'views_data_export',
  426. 'theme path' => $tc_path . '/views_data_export/theme',
  427. 'theme file' => 'tripal_views_data_export.theme.inc',
  428. 'uses row plugin' => FALSE,
  429. 'uses fields' => TRUE,
  430. 'uses options' => TRUE,
  431. 'type' => 'data_export',
  432. );
  433. // add FASTA format as a new style for the existing views_export_data Display
  434. return array(
  435. 'style' => array(
  436. 'views_data_export_fasta' => array(
  437. 'title' => t('FASTA file'),
  438. 'help' => t('Display results in FASTA format. All fields in results are on the definition line while the feature.residues field must be present .'),
  439. 'handler' => 'tripal_views_plugin_style_export_fasta',
  440. // Views Data Export element that will be used to set additional headers when serving the feed.
  441. 'export headers' => array('Content-type: text/plain; charset=utf-8'),
  442. // Views Data Export element mostly used for creating some additional classes and template names.
  443. 'export feed type' => 'fasta',
  444. 'export feed text' => 'FASTA',
  445. 'export feed file' => '%view.fna',
  446. 'export feed icon' => $tc_path . '/views_data_export/images/fasta.png',
  447. 'additional themes' => array(
  448. 'views_data_export_fasta_header' => 'style',
  449. 'views_data_export_fasta_body' => 'style',
  450. 'views_data_export_fasta_footer' => 'style',
  451. ),
  452. 'additional themes base' => 'views_data_export_fasta',
  453. ) + $style_defaults,
  454. ),
  455. );
  456. }
  457. /**
  458. * Implementation of hook_views_pre_view().
  459. */
  460. function tripal_views_views_pre_view(&$view, &$display_id, &$args) {
  461. // merge the $_GET and $_POST into the $_GET. This is because
  462. // Views and Views Data Export modules only uses the $_GET variable but
  463. // file uploads require $_POST. We need to make sure these two modules
  464. // have access to everything needed for this view to work properlys
  465. $_GET = array_merge($_GET, $_POST);
  466. }
  467. /**
  468. * Implementation of hook_views_pre_build().
  469. */
  470. /* function tripal_views_views_pre_render(&$view, &$display_id, &$args){
  471. // we want to add to the bottom of the views the form for downloading
  472. // results in other formats (e.g. Excel, FASTA, CSV, etc.). The Views Data
  473. // Export module provides small images at the bottom, but we want to provide
  474. // a more intutitive interface for getting different file formats
  475. $form = drupal_get_form('tripal_views_data_export_download_form',$view,$display_id,$args);
  476. $view->attachment_after = $form;
  477. }*/
  478. /*
  479. *
  480. function tripal_views_views_query_alter(&$view, &$query){
  481. // iterate through the tables and see if they are chado tables.
  482. // if they are then prefix them with a "chado." prefix
  483. dpm($query);
  484. $tables = $query->tables;
  485. foreach ($tables as $base => $subtables) {
  486. $desc = tripal_core_get_chado_table_schema($base);
  487. if ($desc) {
  488. $query->tables["chado." . $base] = $subtables;
  489. unset($query->tables[$base]);
  490. $base = "chado." . $base;
  491. }
  492. foreach ($subtables as $subtable => $values) {
  493. $desc = tripal_core_get_chado_table_schema($subtable);
  494. if ($desc) {
  495. $query->tables[$base]["chado." . $subtable] = $values;
  496. unset($query->tables[$base][$subtable]);
  497. }
  498. }
  499. }
  500. dpm($query);
  501. } */
  502. /**
  503. * Implementation of hook_views_pre_execute().
  504. */
  505. function tripal_views_views_pre_execute(&$view) {
  506. // if the base table is a chado table then we want to set the
  507. // search path so it can find all of the tables.
  508. // this will break views that use tables that have the same name
  509. // as chado tables (e.g. contact).
  510. $desc = tripal_core_get_chado_table_schema($view->base_table);
  511. if ($desc) {
  512. tripal_db_set_chado_search_path('chado');
  513. }
  514. }
  515. /**
  516. * Implementation of hook_views_post_render().
  517. */
  518. function tripal_views_views_post_render(&$view, &$output, &$cache) {
  519. // if the base table and the query is completed we want to set
  520. // the search path back to the default.
  521. $desc = tripal_core_get_chado_table_schema($view->base_table);
  522. if ($desc) {
  523. tripal_db_set_default_search_path();
  524. }
  525. }
  526. /**
  527. * the Download Views data export form
  528. */
  529. function tripal_views_data_export_download_form(&$form_state, $view, $display_id, $args) {
  530. $form = array();
  531. $urls = array();
  532. // get any export_data_export displays
  533. $displays = $view->display;
  534. $options = array();
  535. $default = '';
  536. $current_display = $view->current_display;
  537. foreach ($displays as $name => $display) {
  538. if (preg_match("/^views_data_export/", $name)) {
  539. // only add this display to the form if it is attached
  540. $display_options = $display->display_options;
  541. if (strcmp($display_options['displays'][$current_display], $current_display) != 0) {
  542. continue;
  543. }
  544. // set the first item as default
  545. if (!$default) {
  546. $default = $display->id;
  547. }
  548. $path = $display->display_options['path'];
  549. $query = $view->get_exposed_input(); // retrieves elements in $_GET array
  550. $urls[$display->id]['path'] = $path;
  551. $urls[$display->id]['query'] = $query;
  552. // add the new item to the options array
  553. $options[$display->id] = $display->display_title;
  554. }
  555. }
  556. // only generate the form if we have views_data_export displays attached
  557. // to this view
  558. if (count($options) > 0) {
  559. $form_state['storage']['urls'] = $urls;
  560. $form['#cache'] = TRUE;
  561. // we want the form to redirect to a new window
  562. $form['#attributes']['target'] = "_blank";
  563. // now build the form elements
  564. $form['downloads'] = array(
  565. '#type' => 'fieldset',
  566. '#title' => 'Download Results',
  567. '#collapsible' => TRUE,
  568. '#collapsed' => FALSE
  569. );
  570. $form['downloads']['file_type'] = array(
  571. '#title' => t('File format'),
  572. '#type' => 'radios',
  573. '#options' => $options,
  574. '#required' => TRUE,
  575. '#default_value' => $default,
  576. '#description' => t('Please select a file format to download'),
  577. );
  578. $form['downloads']['submit'] = array(
  579. '#value' => t('Download Results'),
  580. '#type' => 'submit',
  581. );
  582. }
  583. return $form;
  584. }
  585. /**
  586. * Submit for the Download Views data export form
  587. */
  588. function tripal_views_data_export_download_form_submit($form, &$form_state) {
  589. $urls = $form_state['storage']['urls'];
  590. $display_id = $form_state['values']['file_type'];
  591. drupal_goto($urls[$display_id]['path'], $urls[$display_id]['query']);
  592. }