tripal_views_setup.admin.inc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. }
  42. function tripal_views_setup_new_search_form(){
  43. $form = array();
  44. $form['row_name'] = array(
  45. '#title' => t('Name'),
  46. '#type' => 'textfield',
  47. '#size' => 60,
  48. '#maxlength' => 60,
  49. '#description' => 'Name of the Views Setup',
  50. '#required' => TRUE,
  51. );
  52. $form['submit'] = array(
  53. '#type' => 'submit',
  54. '#value' => 'Create',
  55. );
  56. return $form;
  57. }
  58. function tripal_views_setup_new_search_form_submit($form, &$form_state){
  59. }