123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <?php
- function tripal_views_setup_admin_form(){
-
- $form = array();
-
- $form['#theme'] = 'tripal';
-
- $query_results = db_query('SELECT * FROM public.tripal_views_setup;');
-
- $header = array('Setup ID', 'Name', 'Materialized View ID', 'Base Table Name', 'Description');
- $rows = array();
-
- $results = array();
- while($result = db_fetch_object($query_results)){
- $rows[] = array($result->setup_id, $result->name, $result->mview_id, $result->base_table_name, $result->description,);
- $results[] = $result;
- }
-
- $options = array();
- foreach ($results as $key => $value) {
- if(!empty($value))
- $options[] = $value->setup_id;// . ' | ' . $value->name . ' | ' . $value->mview_id . ' | ' . $value->base_table_name;
- }
-
- $form['existing_rows'] = array(
- '#type' => 'select',
- '#options' => $options,
- '#description' => '<strong>Select a View Setup to delete from the database.</strong>',
- '#prefix' => theme('table', $header, $rows),
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Remove'),
- );
-
- $form['cancel'] = array(
- '#type' => 'markup',
- '#value' => l(t('Cancel '), 'admin/tripal/'),
- );
-
- $form['new'] = array(
- '#type' => 'markup',
- '#value' => l(t(' New'), 'admin/tripal/tripal_views_setup_new'),
- );
-
- return $form;
- }
- function tripal_views_setup_admin_form_submit($form, &$form_state){
- $value = $form['existing_rows']['#options'][$form_state['values']['existing_rows']];
- db_query("DELETE FROM public.tripal_views_setup WHERE setup_id = $value;");
- db_query("DELETE FROM public.tripal_views_handlers WHERE setup_id = $value;");
- db_query("DELETE FROM public.tripal_mviews_join WHERE setup_id = $value;");
- }
- function tripal_views_setup_new_search_form($form_state){
- $form = array();
-
- $form['#cache'] = TRUE;
-
- $form['row_name'] = array(
- '#title' => t('Name'),
- '#type' => 'textfield',
- '#size' => 60,
- '#maxlength' => 128,
- '#description' => 'Name of the Views Setup',
- '#required' => TRUE,
- );
-
- $form['row_description'] = array(
- '#title' => t('Description'),
- '#type' => 'textfield',
- '#size' => 60,
- '#maxlength' => 255,
- '#description' => 'Briefly describe in which view this will be used',
- '#required' => TRUE,
- );
-
- $mview_query = db_query("SELECT name FROM {tripal_mviews} ORDER BY name;");
- $mview_options = array();
- while ($mview_option = db_fetch_array($mview_query)){
- $mview_options[] = $mview_option['name'];
- }
-
- $form['row_mview'] = array(
- '#title' => t('Materialized View'),
- '#type' => 'select',
- '#options' => $mview_options,
- '#description' => 'Which materialized view to use.',
- '#required' => TRUE,
- // '#ahah' => array(
- // 'path' => 'rowmview/ahah',
- // 'wrapper' => 'rowmview-ahah',
- // 'effect' => 'fade',
- // 'event' => 'change',
- // 'method' => 'replace',
- // ),
- );
-
- $form['row_base_table_name'] = array(
- '#title' => t('Base Table Name'),
- '#type' => 'select',
- // '#options' => array('stub'),
- '#options' => tripal_core_get_chado_tables(),
- '#description' => 'Select which chado table to use for this view.',
- '#required' => TRUE,
- );
-
- //--tripal_mviews_join
-
- $form['row_view_column'] = array(
- '#title' => t('View Column'),
- '#type' => 'select',
- '#options' => array('stub'),
- '#description' => 'Which materialized view column to use.',
- '#required' => TRUE,
- );
-
- $form['row_chado_column'] = array(
- '#title' => t('Chado Column'),
- '#type' => 'select',
- '#options' => array('stub'),
- '#description' => 'Which Chado table column to use.',
- '#required' => TRUE,
- );
-
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => 'Create',
- );
-
- return $form;
- }
- // function rowmview_ahah(){
- // $query = "SELECT mv_specs FROM tripal_mviews;";
- // $row_options = db_fetch_array(db_query($query));
- //
- //
- // }
- // function tripal_views_setup_ajax_db_mview_columns(){
- // $mview = $_POST['row_mview'];
- // $form = drupal_get_form('tripal_views_setup_mview_column_form', $mview);
- // drupal_json(array('status' => TRUE, 'data' => $form));
- // }
- // function tripal_views_setup_mview_column_form(&$form_state = NULL, $mview = NULL){
- // if ($mview){
- // $mview_query = db_fetch_array(db_query("SELECT mv_specs FROM tripal_mviews WHERE name = $mview;"));
- //
- // $form['row_mview']
- // }
- //
- // }
- // function tripal_views_setup_ajax_db_chado_tables(){
- // }
- function tripal_views_setup_new_search_form_submit($form, &$form_state){
-
- }
|