tripal_views_search.module 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. function tripal_views_search_menu(){
  3. $items = array();
  4. $items['admin/settings/tripal_views_search'] = array(
  5. 'title' => t('Tripal Views Search settings'),
  6. 'description' => t('Tripal Views Search settings page, allows you to select which materialized views and chado tables to use for searches.'),
  7. 'page callback' => 'drupal_get_form',
  8. 'page arguments' => array('tripal_views_search_admin'),
  9. 'access arguments' => array('access administration pages'),
  10. 'type' => MENU_NORMAL_ITEM,
  11. );
  12. return $items;
  13. }
  14. function tripal_views_search_admin(){
  15. $form = array();
  16. $form['tripal_views_search_config_mview'] = array(
  17. '#type' => 'select',
  18. '#title' => t('Materialized View'),
  19. '#options' => tripal_views_search_mview_list(),
  20. '#description' => t('Select which materialized view needs to be used for this search'),
  21. '#required' => TRUE,
  22. );
  23. $form['tripal_views_search_config_btable'] = array(
  24. '#type' => 'select',
  25. '#title' => t('Chado base table'),
  26. '#options' => tripal_views_search_btable_list(),
  27. '#description' => t('Select which chado table needs to be used for this earch'),
  28. '#required' => TRUE,
  29. );
  30. return system_settings_form($form);
  31. }
  32. /* this needs to go into the function tripal_views_search_block()
  33. $limitnum = variable_get("onthisdate_maxdisp", 3);
  34. $query = "SELECT nid, title, created FROM " .
  35. "{node} WHERE created >= %d " .
  36. "AND created <= %d";
  37. $query_result = db_query_range($query, $start_time, $end_time, 0, $limitnum);
  38. */
  39. //TODO: validation for the admin pages
  40. function tripal_views_search_mview_list(){
  41. //must return an array of strings ie:
  42. $options = array(
  43. 'dummyoption' => t('dummyoptiontext'),
  44. );
  45. return $options;
  46. }
  47. function tripal_views_search_btable_list(){
  48. //must return an array of strings ie:
  49. $options = array(
  50. 'dummyoption2' => t('dummyoptiontext2'),
  51. );
  52. return $options;
  53. }
  54. /**
  55. *
  56. * Use this hook for the admin form page,
  57. * once changes are saved, use this to update
  58. * the tripal_views_search related tables.
  59. *
  60. * @param array $form
  61. * @param array $form_state
  62. * @param int $form_id
  63. */
  64. function tripal_views_search_form_alter(&$form, &$form_state, $form_id){
  65. if(strstr('tripal-views-search-admin', $form['#id'] != FALSE)){
  66. $form['#submit']['tripal_views_search_admin_submit'] = array();
  67. }
  68. }
  69. /**
  70. *
  71. * the actual submit callback function
  72. * @param int $form_id
  73. * @param array $form_values
  74. */
  75. function tripal_views_search_admin_submit($form_id, &$form_values){
  76. //populate db tables based on settings
  77. }