Browse Source

Fixed issues with views integration and fixed form hooks

Stephen Ficklin 10 years ago
parent
commit
9cc848902c

+ 3 - 3
tripal_bulk_loader/includes/tripal_bulk_loader.constants.inc

@@ -123,7 +123,7 @@ function tripal_bulk_loader_has_exposed_fields($node) {
  *
  * @ingroup tripal_bulk_loader
  */
-function tripal_bulk_loader_set_constants_form($form, $form_state, $node) {
+function tripal_bulk_loader_set_constants_form($form, &$form_state, $node) {
   $form = array();
 
   $form['nid'] = array(
@@ -410,7 +410,7 @@ function tripal_bulk_loader_set_constants_form_submit($form, $form_state) {
  *
  * @ingroup tripal_bulk_loader
  */
-function tripal_bulk_loader_edit_constant_set_form($form, $form_state, $node, $group_id) {
+function tripal_bulk_loader_edit_constant_set_form($form, &$form_state, $node, $group_id) {
   $form = array();
 
   $form['nid'] = array(
@@ -554,7 +554,7 @@ function tripal_bulk_loader_edit_constant_set_form_submit($form, &$form_state) {
  *
  * @ingroup tripal_bulk_loader
  */
-function tripal_bulk_loader_delete_constant_set_form($form, $form_state, $node, $group_id) {
+function tripal_bulk_loader_delete_constant_set_form($form, &$form_state, $node, $group_id) {
   $form = array();
 
   $form['nid'] = array(

+ 1 - 1
tripal_bulk_loader/includes/tripal_bulk_loader.loader.inc

@@ -15,7 +15,7 @@
  *
  * @ingroup tripal_bulk_loader
  */
-function tripal_bulk_loader_add_loader_job_form($form, $form_state, $node) {
+function tripal_bulk_loader_add_loader_job_form($form, &$form_state, $node) {
   $form = array();
 
   // --notify--

+ 1 - 1
tripal_core/api/tripal_core.DEPRECATED.inc

@@ -149,7 +149,7 @@ function chado_node_additional_dbxrefs_form_update_dbxrefs($node, $details, $ret
  *
  * @see chado_add_node_form_properties().
  */
-function chado_node_properties_form($form, $form_state, $details) {
+function chado_node_properties_form($form, &$form_state, $details) {
 
   tripal_report_error(
     'tripal_deprecated',

+ 1 - 1
tripal_core/api/tripal_core.chado_nodes.api.inc

@@ -791,7 +791,7 @@ function hook_chado_node_sync_create_new_node($new_node, $record) {
  *
  * @ingroup tripal_chado_node_api
  */
-function hook_chado_node_sync_form($form, $form_state) {
+function hook_chado_node_sync_form($form, &$form_state) {
 
   // Change or add to the form array as needed
   // Any changes should be made in accordance with the Drupal Form API

+ 1 - 1
tripal_core/api/tripal_core.chado_nodes.dbxrefs.api.inc

@@ -7,7 +7,7 @@
  * How To Use:
  * @code
 
-  function chado_example_form($form, $form_state) {
+  function chado_example_form($form, &$form_state) {
 
     // Default values for form elements can come in the following ways:
     //

+ 1 - 1
tripal_core/api/tripal_core.chado_nodes.properties.api.inc

@@ -7,7 +7,7 @@
  * How To Use:
  * @code
 
-  function chado_example_form($form, $form_state) {
+  function chado_example_form($form, &$form_state) {
 
     // Default values for form elements can come in the following ways:
     //

+ 1 - 1
tripal_core/api/tripal_core.chado_nodes.relationships.api.inc

@@ -7,7 +7,7 @@
  * How To Use:
  * @code
 
-  function chado_example_form($form, $form_state) {
+  function chado_example_form($form, &$form_state) {
 
     // Default values for form elements can come in the following ways:
     //

+ 1 - 1
tripal_cv/includes/tripal_cv.admin.inc

@@ -48,7 +48,7 @@ function tripal_cv_admin_cv_listing() {
 /**
  *
  */
-function tripal_cv_admin_set_defaults_form($form, $form_state) {
+function tripal_cv_admin_set_defaults_form($form, &$form_state) {
 
   $form['instructions'] = array(
     '#markup' => t('Much of the data housed in Chado is typed, meaning that a ' .

+ 1 - 1
tripal_cv/includes/tripal_cv.cv_form.inc

@@ -79,7 +79,7 @@ function tripal_cv_cv_edit_form($form, &$form_state) {
  *
  * @ingroup tripal_cv
  */
-function tripal_cv_cv_add_form($form, $form_state) {
+function tripal_cv_cv_add_form($form, &$form_state) {
 
   // add in the form fields to this form
   tripal_cv_add_cv_form_fields($form, $form_state);

+ 1 - 1
tripal_cv/includes/tripal_cv.trees.inc

@@ -432,7 +432,7 @@ function tripal_cv_cvterm_info($cvterm_id) {
  *
  * @ingroup tripal_cv
  */
-function tripal_cv_list_form($form_state) {
+function tripal_cv_list_form($form, &$form_state) {
 
   // get a list of db from chado for user to choose
   $sql = "

+ 1 - 1
tripal_db/includes/tripal_db.admin.inc

@@ -120,7 +120,7 @@ function tripal_db_db_edit_form($form, &$form_state) {
  *
  * @ingroup tripal_db
  */
-function tripal_db_db_add_form($form, $form_state) {
+function tripal_db_db_add_form($form, &$form_state) {
 
   // add in the form fields to this form
   tripal_db_add_db_form_fields($form, $form_state);

+ 1 - 1
tripal_feature/includes/tripal_feature.seq_extract.inc

@@ -73,7 +73,7 @@ function tripal_feature_seq_extract_page() {
  *
  * @ingroup tripal_feature
  */
-function theme_tripal_feature_seq_extract_form($form) {
+function theme_tripal_feature_seq_extract_form($form, &$form_state) {
   $rows = array(
     0 => array(
       array('data' => drupal_render($form['description']), 'colspan' => 3),

+ 1 - 0
tripal_feature/tripal_feature.module

@@ -302,6 +302,7 @@ function tripal_feature_theme($existing, $type, $theme, $path) {
       'template' => 'tripal_feature_relationships',
       'path' => "$path/theme/templates",
     ),
+    // help template
     'tripal_feature_help' => array(
       'template' => 'tripal_feature_help',
       'variables' =>  array(NULL),

+ 1 - 1
tripal_pub/includes/tripal_pub.pub_citation.inc

@@ -11,7 +11,7 @@
  *
  * @ingroup tripal_pub
  */
-function tripal_pub_citation_form($form_state) {
+function tripal_pub_citation_form($form, &$form_state) {
 
   $form['instructions'] = array(
     '#markup' => '<p>Use this form to unify publication citations. Citations are created automtically when

+ 6 - 0
tripal_stock/tripal_stock.module

@@ -319,6 +319,12 @@ function tripal_stock_theme($existing, $type, $theme, $path) {
       'variables' =>  array(NULL),
       'path' => "$path/theme/templates",
     ),
+    // themed teaser
+    'tripal_stock_teaser' => array(
+      'variables' => array('node' => NULL),
+      'template' => 'tripal_stock_teaser',
+      'path' => "$path/theme/templates",
+    ),
   );
   return $items;
 }

+ 47 - 43
tripal_views/includes/tripal_views_integration_UI.inc

@@ -17,6 +17,7 @@
 function tripal_views_integration_setup_list() {
   $output = '';
 
+  // TODO: change the following to use theme_item_list()
   $output .= '<ul class="action-links">';
   $output .=  '<li>' . l(t('Add a New Entry'), "admin/tripal/views-integration/new") . '</li>';
   $output .=  '<li style="float: right;">' . l(t('Delete ALL Entries'), "admin/tripal/views-integration/delete-all/confirm") . '</li>';
@@ -143,7 +144,7 @@ function tripal_views_integration_delete($setup_id) {
  *
  * @ingroup tripal_views
  */
-function tripal_views_integration_delete_all_form ($form, $form_state) {
+function tripal_views_integration_delete_all_form($form, &$form_state) {
 
   $form['extra'] = array(
     '#type' => 'item',
@@ -185,7 +186,7 @@ function tripal_views_integration_delete_all_form ($form, $form_state) {
  *
  * @ingroup tripal_views
  */
-function tripal_views_integration_delete_all_form_submit ($form, &$form_state) {
+function tripal_views_integration_delete_all_form_submit($form, &$form_state) {
 
   tripal_views_rebuild_views_integrations(TRUE);
 
@@ -197,14 +198,13 @@ function tripal_views_integration_delete_all_form_submit ($form, &$form_state) {
  * Purpose: defines the web form used for specifing the base table, joins and
  *   handlers when integrating a table with views.  This form is used for both
  *   creating a new record and editing an existing record.
+ *   
+ * @param $form
+ *    The form array which is passed automatically by drupal
  *
  * @param $form_state
  *    The form state which is passed automatically by drupal
  *
- * @param $setup_id
- *    The unique setup for an integrated table.  This value is only set when
- *    the form is used for updating an existing record.
- *
  * @return
  *    A proper Drupal form associative array.
  *
@@ -213,7 +213,7 @@ function tripal_views_integration_delete_all_form_submit ($form, &$form_state) {
  *
  * @ingroup tripal_views
  */
-function tripal_views_integration_form($form, $form_state, $arg) {
+function tripal_views_integration_form($form, &$form_state) {
 
   $data = array();
   $form['#cache'] = TRUE;
@@ -289,7 +289,7 @@ function tripal_views_integration_form($form, $form_state, $arg) {
        '#value' => $setup_id,
     );
 
-  }
+  } // end if (isset($setup_id)) {
 
   // add a fieldset for the MView & Chado table selectors
   $form['base_table_type'] = array(
@@ -317,7 +317,7 @@ function tripal_views_integration_form($form, $form_state, $arg) {
     '#ajax' => array(
        //D6: 'path' => 'tripal/views-integration/ajax/view_setup_table',
        'callback' => 'tripal_views_integration_ajax_view_setup_table',
-       'wrapper' => 'fieldset-table-rows-wrapper',
+       'wrapper' => 'tripal-views-integration-form',
        'effect' => 'fade',
        'event' => 'change',
        'method' => 'replace',
@@ -346,7 +346,7 @@ function tripal_views_integration_form($form, $form_state, $arg) {
     '#ajax' => array(
        //D6: 'path' => 'tripal/views-integration/ajax/view_setup_table',
        'callback' => 'tripal_views_integration_ajax_view_setup_table',
-       'wrapper' => 'fieldset-table-rows-wrapper',
+       'wrapper' => 'tripal-views-integration-form',
        'effect' => 'fade',
        'event' => 'change',
        'method' => 'replace',
@@ -661,26 +661,26 @@ function tripal_views_integration_form($form, $form_state, $arg) {
       // create the handler fields
       $default_field_handler = 0;
       if (isset($setup_id) && !isset($form_state['values']["fields_field_handler_$table_id-$i"])) {
-        $default_field_handler = $default_handlers[$column_name]['field']['handler_name'];
+        $default_field_handler = array_key_exists('field', $default_handlers[$column_name]) ? $default_handlers[$column_name]['field']['handler_name'] : "";
         $form_state['values']["fields_field_handler_$table_id-$i"] = $default_field_handler;
       }
       else {
-        $default_field_handler = $form_state['values']["fields_field_handler_$table_id-$i"];
+        $default_field_handler = array_key_exists("fields_field_handler_$table_id-$i", $form_state['values']) ? $form_state['values']["fields_field_handler_$table_id-$i"] : '';
         if (!$default_field_handler) {
           if ($column_type == 'integer' or $column_type == 'int' or $column_type == 'serial') {
-            $default_field_handler = 'chado_views_handler_field_numeric';
+            $default_field_handler = 'views_handler_field_numeric';
           }
           elseif (preg_match("/character varying/", $column_type) or $column_type == 'char' or $column_type == 'text' or $column_type == 'varchar') {
-            $default_field_handler = 'chado_views_handler_field';
+            $default_field_handler = 'views_handler_field';
           }
           elseif ($column_type == 'boolean') {
-            $default_field_handler = 'chado_views_handler_field_boolean';
+            $default_field_handler = 'views_handler_field_boolean';
           }
           elseif ($column_type == 'float') {
-            $default_field_handler = 'chado_views_handler_field_numeric';
+            $default_field_handler = 'views_handler_field_numeric';
           }
           elseif ($column_type == 'datetime') {
-            $default_field_handler = 'chado_views_handler_field_date';
+            $default_field_handler = 'views_handler_field_date';
           }
         }
       }
@@ -696,26 +696,26 @@ function tripal_views_integration_form($form, $form_state, $arg) {
 
       $default_filter_handler = 0;
       if (isset($setup_id) && !isset($form_state['values']["fields_filter_handler_$table_id-$i"])) {
-        $default_filter_handler = $default_handlers[$column_name]['filter']['handler_name'];
+        $default_filter_handler = array_key_exists('filter', $default_handlers[$column_name]) ? $default_handlers[$column_name]['filter']['handler_name'] : "";
         $form_state['values']["fields_filter_handler_$table_id-$i"]= $default_filter_handler;
       }
       else {
-        $default_filter_handler = $form_state['values']["fields_filter_handler_$table_id-$i"];
+        $default_filter_handler = array_key_exists("fields_filter_handler_$table_id-$i", $form_state['values']) ? $form_state['values']["fields_filter_handler_$table_id-$i"] : "";
         if (!$default_filter_handler) {
           if ($column_type == 'integer' or $column_type == 'int' or $column_type == 'serial') {
-            $default_filter_handler = 'chado_views_handler_filter_numeric';
+            $default_filter_handler = 'views_handler_filter_numeric';
           }
           elseif (preg_match("/^character varying/", $column_type) or $column_type == 'char' or $column_type == 'text' or $column_type == 'varchar') {
-            $default_filter_handler = 'chado_views_handler_filter_string';
+            $default_filter_handler = 'views_handler_filter_string';
           }
           elseif ($column_type == 'boolean') {
-            $default_filter_handler = 'chado_views_handler_filter_boolean';
+            $default_filter_handler = 'views_handler_filter_boolean';
           }
           elseif ($column_type == 'float') {
-            $default_filter_handler = 'chado_views_handler_filter_float';
+            $default_filter_handler = 'views_handler_filter_float';
           }
           elseif ($column_type == 'datetime') {
-            $default_filter_handler = 'chado_views_handler_filter_date';
+            $default_filter_handler = 'views_handler_filter_date';
           }
         }
       }
@@ -730,26 +730,26 @@ function tripal_views_integration_form($form, $form_state, $arg) {
 
       $default_sort_handler = 0;
       if (isset($setup_id) && !isset($form_state['values']["fields_sort_handler_$table_id-$i"])) {
-        $default_sort_handler = $default_handlers[$column_name]['sort']['handler_name'];
+        $default_sort_handler = array_key_exists('sort', $default_handlers[$column_name]) ? $default_handlers[$column_name]['sort']['handler_name'] : "";
         $form_state['values']["fields_sort_handler_$table_id-$i"] = $default_sort_handler;
       }
       else {
-        $default_sort_handler = $form_state['values']["fields_sort_handler_$table_id-$i"];
+        $default_sort_handler = array_key_exists("fields_sort_handler_$table_id-$i", $form_state['values']) ? $form_state['values']["fields_sort_handler_$table_id-$i"] : "";
         if (!$default_sort_handler) {
           if ($column_type == 'integer' or $column_type == 'int' or $column_type == 'serial') {
-            $default_sort_handler = 'chado_views_handler_sort';
+            $default_sort_handler = 'views_handler_sort';
           }
           elseif (preg_match("/character varying/", $column_type) or $column_type == 'char' or $column_type == 'text' or $column_type == 'varchar') {
-            $default_sort_handler = 'chado_views_handler_sort';
+            $default_sort_handler = 'views_handler_sort';
           }
           elseif ($column_type == 'boolean') {
-            $default_sort_handler = 'chado_views_handler_sort';
+            $default_sort_handler = 'views_handler_sort';
           }
           elseif ($column_type == 'float') {
-            $default_sort_handler = 'chado_views_handler_sort';
+            $default_sort_handler = 'views_handler_sort';
           }
           elseif ($column_type == 'datetime') {
-            $default_sort_handler = 'chado_views_handler_sort_date';
+            $default_sort_handler = 'views_handler_sort_date';
           }
         }
       }
@@ -768,7 +768,7 @@ function tripal_views_integration_form($form, $form_state, $arg) {
         && isset($default_handlers[$column_name]['argument']))
       {
         $default_argument_handler = $default_handlers[$column_name]['argument']['handler_name'];
-        $form_state['values']["fields_argument_handler_$table_id-$i"]=$default_argument_handler ;
+        $form_state['values']["fields_argument_handler_$table_id-$i"] = $default_argument_handler ;
       }
       else {
         if (isset($form_state['values']["fields_argument_handler_$table_id-$i"])) {
@@ -802,7 +802,7 @@ function tripal_views_integration_form($form, $form_state, $arg) {
       );
 
       $i++;
-    }
+    } // end foreach ($columns as $column) {
 
     $form['view_setup_join'] = array(
       '#type' => 'fieldset',
@@ -857,6 +857,7 @@ function tripal_views_integration_form($form, $form_state, $arg) {
       ->orderBy('tvj.relationship_only','ASC')
       ->orderBy('tvj.base_field', 'ASC')
       ->orderBy('tvj.left_table', 'ASC');
+    
     foreach ($query->execute() as $i => $result) {
       $form['view_setup_join']["$table_id-$i"] = array(
            '#type' => 'markup',
@@ -954,7 +955,7 @@ function tripal_views_integration_form($form, $form_state, $arg) {
         '#required' => FALSE,
         '#default_value' => $result->left_field
       );
-    }
+    } // end foreach ($query->execute() as $i => $result) {
 
     $form['num_joins'] = array(
       '#type' => 'hidden',
@@ -1070,9 +1071,9 @@ function tripal_views_integration_form($form, $form_state, $arg) {
     );
 
     $data['row_count'] = $i - 1;
-  } //end of if table/mview
+  } // end of if table/mview
 
-  //use this to put values into $form_state['values']
+  // use this to put values into $form_state['values']
   $form['data'] = array();
 
   // Ensure that we don't store an array
@@ -1091,9 +1092,11 @@ function tripal_views_integration_form($form, $form_state, $arg) {
       );
     }
   }
+  
+  $form['#prefix'] = '<div id="tripal-views-integration-form">';
+  $form['#suffix'] = '</div>';
 
   $form['#redirect'] = 'admin/tripal/views-integration/list';
-
   return $form;
 }
 
@@ -1155,12 +1158,12 @@ function tripal_views_integration_form_validate($form, &$form_state) {
  * @ingroup tripal_views
  */
 function tripal_views_integration_form_submit($form, &$form_state) {
-  $name = $form_state['values']['row_name'];
-  $mview_id = $form_state['values']['mview_id'];
+  $name       = trim($form_state['values']['row_name']);
+  $mview_id   = $form_state['values']['mview_id'];
   $table_name = $form_state['values']['table_name'];
-  $setup_id = $form_state['values']['setup_id'];
-  $priority = $form_state['values']['row_priority'];
-  $comment = $form_state['values']['row_description'];
+  $setup_id   = array_key_exists('setup_id', $form_state['values']) ? $form_state['values']['setup_id'] : "";
+  $priority   = $form_state['values']['row_priority'];
+  $comment    = $form_state['values']['row_description'];
 
   // get details about this mview
   if ($mview_id) {
@@ -1415,7 +1418,8 @@ function tripal_views_integration_discover_handlers() {
  * @ingroup tripal_views
  */
 function tripal_views_integration_ajax_view_setup_table($form, $form_state) {
-  return $form['view_setup_table'];
+  //return $form['view_setup_table'];
+  return $form;
 }
 
 /*

+ 1 - 1
tripal_views/includes/tripal_views_integration_port.inc

@@ -18,7 +18,7 @@
  *
  * @ingroup tripal_views
  */
-function tripal_views_integration_export_form($form, $form_state, $setup_id) {
+function tripal_views_integration_export_form($form, &$form_state, $setup_id) {
   $form = array();
 
   $defn_array = tripal_views_integration_export_entry($setup_id);