tripal_views_setup.module 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. require_once 'includes/tripal_views_setup.admin.inc';
  3. function tripal_views_setup_menu(){
  4. $items = array();
  5. //parents admin page TODO: figure out what to do here: add / remove searches
  6. $items['admin/tripal/tripal_views_setup'] = array(
  7. 'title' => t('Tripal Views Setups'),
  8. 'description' => t('Tripal Views Setups settings page, allows you to select and create materialized views and chado tables to use for searches.'),
  9. 'page callback' => 'drupal_get_form',
  10. 'page arguments' => array('tripal_views_setup_admin_form'),
  11. 'access arguments' => array('access administration pages'),
  12. 'type' => MENU_NORMAL_ITEM,
  13. );
  14. //page to actually create searche->mview->chado table relationships
  15. $items['admin/tripal/tripal_views_setup_new'] = array(
  16. 'title' => 'Create New Views Setup',
  17. 'page callback' => 'drupal_get_form',
  18. 'page arguments' => array('tripal_views_setup_new_search_form'),
  19. 'access arguments' => array('access administration pages'), //TODO: figure out the proper permissions arguments
  20. 'type' => MENU_NORMAL_ITEM,
  21. );
  22. return $items;
  23. }
  24. function tripal_views_setup_theme(){
  25. $theme = array();
  26. $theme['tripal_views_setup_form'] = array(
  27. 'arguments' => array('form' => NULL,),
  28. );
  29. $theme['tripal_views_setup_admin_form'] = array(
  30. 'arguments' => array(),
  31. );
  32. return $theme;
  33. }
  34. function theme_tripal_views_setup_admin_form($form){
  35. $header = array(
  36. theme('table_select_header_cell'),//using previously empty field
  37. array('data' => t('Setup ID'), 'field' => 'setup_id', 'sort' => 'asc'),
  38. array('data' => t('MView ID'), 'field' => 'mview_id'),
  39. array('data' => t('Base Table Name'), 'field' => 'base_table_name'),
  40. );
  41. if(!empty($form['checkboses']['#options'])) {
  42. foreach (element_children($form['uid']) as $key) {
  43. $rows[] = array(
  44. drupal_render($form['checkboxes'][$key]),
  45. drupal_render($form['setup_id'][$key]),
  46. drupal_render($form['mview_id'][$key]),
  47. drupal_render($form['base_table_name'][$key]),
  48. );
  49. }
  50. }
  51. else {
  52. $row[] = array(array('data' => '<div class="error">click link above to add entries</div>', 'colspan' => 4));
  53. }
  54. $output .= theme('table', $header, $rows);
  55. $output .= drupal_render($form);
  56. return $output;
  57. }