tripal_views_setup.admin.inc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. function tripal_views_setup_admin_form(){
  3. $form = array();
  4. $form['#theme'] = 'tripal';
  5. $query_results = db_query('SELECT * FROM public.tripal_views_setup;');
  6. $header = array('Setup ID', 'Name', 'Materialized View ID', 'Base Table Name', 'Description');
  7. $rows = array();
  8. $results = array();
  9. while($result = db_fetch_object($query_results)){
  10. $rows[] = array($result->setup_id, $result->name, $result->mview_id, $result->base_table_name, $result->description,);
  11. $results[] = $result;
  12. }
  13. $options = array();
  14. foreach ($results as $key => $value) {
  15. if(!empty($value))
  16. $options[] = $value->setup_id;// . ' | ' . $value->name . ' | ' . $value->mview_id . ' | ' . $value->base_table_name;
  17. }
  18. $form['existing_rows'] = array(
  19. '#type' => 'select',
  20. '#options' => $options,
  21. '#description' => '<strong>Select a View Setup to delete from the database.</strong>',
  22. '#prefix' => theme('table', $header, $rows),
  23. );
  24. $form['submit'] = array(
  25. '#type' => 'submit',
  26. '#value' => t('Remove'),
  27. );
  28. $form['cancel'] = array(
  29. '#type' => 'markup',
  30. '#value' => l(t('Cancel '), 'admin/tripal/'),
  31. );
  32. $form['new'] = array(
  33. '#type' => 'markup',
  34. '#value' => l(t(' New'), 'admin/tripal/tripal_views_setup_new'),
  35. );
  36. return $form;
  37. }
  38. function tripal_views_setup_admin_form_submit($form, &$form_state){
  39. $value = $form['existing_rows']['#options'][$form_state['values']['existing_rows']];
  40. db_query("DELETE FROM public.tripal_views_setup WHERE setup_id = $value;");
  41. db_query("DELETE FROM public.tripal_views_handlers WHERE setup_id = $value;");
  42. db_query("DELETE FROM public.tripal_mviews_join WHERE setup_id = $value;");
  43. }
  44. function tripal_views_setup_new_search_form(){
  45. $form = array();
  46. $form['row_name'] = array(
  47. '#title' => t('Name'),
  48. '#type' => 'textfield',
  49. '#size' => 60,
  50. '#maxlength' => 128,
  51. '#description' => 'Name of the Views Setup',
  52. '#required' => TRUE,
  53. );
  54. $form['row_description'] = array(
  55. '#title' => t('Description'),
  56. '#type' => 'textfield',
  57. '#size' => 60,
  58. '#maxlength' => 255,
  59. '#description' => 'Briefly describe in which view this will be used',
  60. '#required' => TRUE,
  61. );
  62. $form['row_mview'] = array(
  63. '#title' => t('Materialized View'),
  64. '#type' => 'select',
  65. '#options' => array('stub'),
  66. '#maxlength' => 128,
  67. '#description' => 'Which materialized view to use.',
  68. '#required' => TRUE,
  69. );
  70. $form['row_base_table_name'] = array(
  71. '#title' => t('Base Table Name'),
  72. '#type' => 'select',
  73. '#options' => array('stub'),
  74. '#maxlength' => 128,
  75. '#description' => 'Select which chado table to use for this view.',
  76. '#required' => TRUE,
  77. );
  78. //--tripal_mviews_join
  79. $form['row_view_column'] = array(
  80. '#title' => t('View Column'),
  81. '#type' => 'select',
  82. '#options' => array('stub'),
  83. '#maxlength' => 128,
  84. '#description' => 'Which materialized view column to use.',
  85. '#required' => TRUE,
  86. );
  87. $form['row_chado_column'] = array(
  88. '#title' => t('Chado Column'),
  89. '#type' => 'select',
  90. '#options' => array('stub'),
  91. '#maxlength' => 128,
  92. '#description' => 'Which Chado table column to use.',
  93. '#required' => TRUE,
  94. );
  95. $form['submit'] = array(
  96. '#type' => 'submit',
  97. '#value' => 'Create',
  98. );
  99. return $form;
  100. }
  101. function tripal_views_setup_new_search_form_submit($form, &$form_state){
  102. }