소스 검색

In progress cleaning up Tripal Views codeing style

Lacey Sanderson 13 년 전
부모
커밋
ab0d75f8e0
30개의 변경된 파일617개의 추가작업 그리고 773개의 파일을 삭제
  1. 21 21
      tripal_stock/tripal_stock.views.inc
  2. 66 63
      tripal_views/tripal_views.module
  3. 57 53
      tripal_views/tripal_views.views.inc
  4. 0 45
      tripal_views/views/README
  5. 19 11
      tripal_views/views/handlers/chado_views_handler_field.inc
  6. 27 19
      tripal_views/views/handlers/chado_views_handler_field_aggregate.inc
  7. 19 11
      tripal_views/views/handlers/chado_views_handler_field_boolean.inc
  8. 19 11
      tripal_views/views/handlers/chado_views_handler_field_counter.inc
  9. 19 11
      tripal_views/views/handlers/chado_views_handler_field_custom.inc
  10. 23 15
      tripal_views/views/handlers/chado_views_handler_field_date.inc
  11. 19 11
      tripal_views/views/handlers/chado_views_handler_field_markup.inc
  12. 19 11
      tripal_views/views/handlers/chado_views_handler_field_math.inc
  13. 19 11
      tripal_views/views/handlers/chado_views_handler_field_numeric.inc
  14. 30 20
      tripal_views/views/handlers/chado_views_handler_filter_boolean_operator.inc
  15. 21 13
      tripal_views/views/handlers/chado_views_handler_filter_boolean_operator_string.inc
  16. 23 15
      tripal_views/views/handlers/chado_views_handler_filter_date.inc
  17. 23 15
      tripal_views/views/handlers/chado_views_handler_filter_equality.inc
  18. 23 15
      tripal_views/views/handlers/chado_views_handler_filter_float.inc
  19. 30 20
      tripal_views/views/handlers/chado_views_handler_filter_numeric.inc
  20. 23 15
      tripal_views/views/handlers/chado_views_handler_filter_string.inc
  21. 16 8
      tripal_views/views/handlers/chado_views_handler_sort.inc
  22. 16 8
      tripal_views/views/handlers/chado_views_handler_sort_date.inc
  23. 16 8
      tripal_views/views/handlers/chado_views_handler_sort_formula.inc
  24. 16 8
      tripal_views/views/handlers/chado_views_handler_sort_menu_hierarchy.inc
  25. 16 8
      tripal_views/views/handlers/chado_views_handler_sort_random.inc
  26. 17 12
      tripal_views/views/handlers/chado_wrapper_functions.inc
  27. 13 13
      tripal_views/views/handlers/views_handler_field_chado_count.inc
  28. 7 7
      tripal_views/views/handlers/views_handler_filter_file_upload.inc
  29. 0 84
      tripal_views/views/template.node_join.views.inc
  30. 0 211
      tripal_views/views/template.table_defn.views.inc

+ 21 - 21
tripal_stock/tripal_stock.views.inc

@@ -6,7 +6,7 @@
  *  chado/tripal stock tables. Supplementary functions can be found in
  *  ./views/
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
@@ -16,28 +16,28 @@
  * @ingroup tripal_stock
  */
 
-require_once('views/stock.views.inc');
-require_once('views/chado_stock.views.inc');
-require_once('views/misc_tables.views.inc'); 
 /**
  * Implements hook_views_data(): Describe chado/tripal tables & fields to views
  *
  * @return array
  *   A data array which follows the structure outlined in the
  *   views2 documentation for this hook. Essentially, it's an array of table
- *   definitions keyed by chado/tripal table name. Each table definition 
+ *   definitions keyed by chado/tripal table name. Each table definition
  *   includes basic details about the table, fields in that table and
  *   relationships between that table and others (joins)
  *
  * @ingroup tripal_stock_views
  */
+require_once('views/stock.views.inc');
+require_once('views/chado_stock.views.inc');
+require_once('views/misc_tables.views.inc');
 function tripal_stock_views_data()  {
   $data = array();
 
   $data = array_merge($data, retrieve_stock_views_data());
   $data = array_merge($data, retrieve_chado_stock_views_data());
   $data = array_merge($data, retrieve_stock_misc_tables_views_data());
-  
+
   return $data;
 }
 
@@ -45,7 +45,7 @@ function tripal_stock_views_data()  {
  * Implements hook_views_handlers()
  *
  * Purpose: Register all custom handlers with views
- *   where a handler describes either "the type of field", 
+ *   where a handler describes either "the type of field",
  *   "how a field should be filtered", "how a field should be sorted"
  *
  * @return array
@@ -119,7 +119,7 @@ function tripal_stock_views_data_alter(&$data) {
       ),
     );
   }
-  
+
 }
 
 /**
@@ -136,18 +136,18 @@ function tripal_stock_views_data_alter(&$data) {
  */
 function tripal_stock_views_pre_render	(&$view) {
 	if (preg_match('/stock/', $view->base_table)) {
-		
+
 		//-----Node IDs---------------------------------------------
 		// @see file: tripal_core.views.inc function: tripal_core_add_node_ids_to_view (&$view);
-		
+
 		// retrieve the stock_id for each record in the views current page
 		$stock_ids = array();
 		foreach ($view->result as $row_num => $row) {
 			$stock_ids[$row_num] = $row->stock_id;
 		}
-		
+
 		if (sizeof($stock_ids)) {
-		
+
 			//-----Properties------------------------------------------
 			$field_names = array_keys($view->field);
 			//if any property fields are in the current view
@@ -159,14 +159,14 @@ function tripal_stock_views_pre_render	(&$view) {
 				$previous_db = tripal_db_set_active('chado');
 				$resource = db_query($sql);
 			 tripal_db_set_active($previous_db);
-		
+
 				$view->result[$key]->properties = array();
 				while ($r = db_fetch_object($resource)) {
 					$key = array_search($r->stock_id, $stock_ids);
 					$view->result[$key]->properties[] = $r;
 				}
 			}
-		
+
 			//-----Relationships----------------------------------------
 			//if any relationship fields are in the current view
 			$relationship_field_names = preg_grep('/relationships/', $field_names);
@@ -182,7 +182,7 @@ function tripal_stock_views_pre_render	(&$view) {
 				$previous_db = tripal_db_set_active('chado');
 				$resource = db_query($sql);
 			 tripal_db_set_active($previous_db);
-			
+
 				while ($r = db_fetch_object($resource)) {
 					if (in_array($r->subject_id, $stock_ids)) {
 						$key = array_search($r->subject_id, $stock_ids);
@@ -196,7 +196,7 @@ function tripal_stock_views_pre_render	(&$view) {
 					}
 				}
 			}
-		
+
 			//-----DB References--------------------------------------------
 			//if any dbxref fields are in the current view
 			$dbxref_field_names = preg_grep('/dbxref/',$field_names);
@@ -210,14 +210,14 @@ function tripal_stock_views_pre_render	(&$view) {
 				$previous_db = tripal_db_set_active('chado');
 				$resource = db_query($sql);
 			 tripal_db_set_active($previous_db);
-		
+
 				$view->result[$key]->dbxref = array();
 				while ($r = db_fetch_object($resource)) {
 					$key = array_search($r->stock_id, $stock_ids);
 					$view->result[$key]->dbxref[] = $r;
 				}
 			}
-			
+
 		} //if there are stocks
 	} //if we're dealing with a stock view
 }
@@ -228,7 +228,7 @@ function tripal_stock_views_pre_render	(&$view) {
  */
 function tripal_stock_views_default_views() {
   $views = array();
-  
+
   $view = new view;
   $view->name = 'all_stocks';
   $view->description = 'This view lists all stocks by default. There are exposed filters available but no arguments are used.';
@@ -581,7 +581,7 @@ function tripal_stock_views_default_views() {
     'weight' => 0,
     'name' => 'navigation',
   ));
-  $views[$view->name] = $view;  
-  
+  $views[$view->name] = $view;
+
   return $views;
 }

+ 66 - 63
tripal_views/tripal_views.module

@@ -12,63 +12,65 @@ require_once "tripal_views_form_elements.inc";
  * @ingroup tripal_views
  */
 function tripal_views_menu() {
-   $items = array();
-   
-   $items['admin/tripal/views'] = array(
-     'title' => t('Views Integration'),
-     'description' => 'Integration with Drupal Views',
-     'page callback' => 'tripal_views_description_page',
-     'access arguments' => array('administer site configuration'),
-     'type' => MENU_NORMAL_ITEM,
-   );
+  $items = array();
 
- 	$items['admin/tripal/views/integration'] = array(
-     'title' => t('Integrated Tables'),
-     'description' => t('Provide a list of all integrated tables and allows for adding new tables or editing already integrated tables.'),
-     'page callback' => 'tripal_views_integration_setup_list',
-     'access arguments' => array('manage tripal_views_integration'),
-     'type' => MENU_NORMAL_ITEM,
- 	);
+/**
+  $items['admin/tripal/views'] = array(
+    'title' => 'Views Integration',
+    'description' => 'Integration with Drupal Views',
+    'page callback' => 'tripal_views_description_page',
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM,
+  );
 
+  $items['admin/tripal/views/integration'] = array(
+    'title' => 'Integrated Tables',
+    'description' => 'Provide a list of all integrated tables and allows for adding new tables or editing already integrated tables.',
+    'page callback' => 'tripal_views_integration_setup_list',
+    'access arguments' => array('manage tripal_views_integration'),
+    'type' => MENU_NORMAL_ITEM,
+  );
 
-	$items['admin/tripal/views/integration/new'] = array(
-     'title' => 'Integrate Views',
-     'page callback' => 'drupal_get_form',
-     'page arguments' => array('tripal_views_integration_form'),
-     'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
-     'type' => MENU_CALLBACK,
-	);
-	
-	$items['admin/tripal/views/integration/edit/%'] = array(
-     'title' => 'Edit Views Integration',
-     'page callback' => 'drupal_get_form',
-     'page arguments' => array('tripal_views_integration_form',5),
-     'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
-     'type' => MENU_CALLBACK,
-	);
+  $items['admin/tripal/views/integration/new'] = array(
+    'title' => 'Integrate Views',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_views_integration_form'),
+    'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
+    'type' => MENU_CALLBACK,
+  );
 
-	$items['admin/tripal/views/integration/delete/%'] = array(
-     'title' => 'Delete Views Integration',
-     'page callback' => 'tripal_views_integration_delete',
-     'page arguments' => array(5),
-     'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
-     'type' => MENU_CALLBACK,
-	);
+  $items['admin/tripal/views/integration/edit/%'] = array(
+    'title' => 'Edit Views Integration',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_views_integration_form', 5),
+    'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
+    'type' => MENU_CALLBACK,
+  );
 
-   return $items;
+  $items['admin/tripal/views/integration/delete/%'] = array(
+    'title' => 'Delete Views Integration',
+    'page callback' => 'tripal_views_integration_delete',
+    'page arguments' => array(5),
+    'access arguments' => array('manage tripal_views_integration'), //TODO: figure out the proper permissions arguments
+    'type' => MENU_CALLBACK,
+  );
+*/
+  return $items;
 }
+
 /**
  * Implements hook_views_api()
- * 
- * Purpose: Set the permission types that the chado module uses.  
+ *
+ * Purpose: Set the permission types that the chado module uses.
  *
  * @ingroup tripal_views
  */
-function tripal_views_perm(){
-   return array(
-      'manage tripal_views_integration',
-   );
+function tripal_views_perm() {
+  return array(
+    'manage tripal_views_integration',
+  );
 }
+
 /**
  * Implements hook_views_api()
  *
@@ -79,30 +81,31 @@ function tripal_views_perm(){
  * @ingroup tripal_views
  */
 function tripal_views_views_api() {
-   return array(
-      'api' => 2.0,
-   );
+  return array(
+    'api' => 2.0,
+  );
 }
+
 /**
  * Implements hook_theme()
  *
- * Purpose: this hook provides details about themable objects added by 
+ * Purpose: this hook provides details about themable objects added by
  *   this module
  *
  * @ingroup tripal_views
  */
-function tripal_views_theme () {
-   return array(
-	   'tripal_views_integration_form' => array(
-         'arguments' => array('form' => NULL),
-         'template'  => 'tripal_views_integration_fields_form',
-	   ),
-	   'tripal_views_data_export_download_form' => array(
-         'arguments' => array('form' => NULL),
-         'template'  => 'tripal_views_data_export_download_form',
-	   ),
-      'file_upload_combo' => array(
-        'arguments' => array('element' => NULL)
-      ),
-   );
+function tripal_views_theme() {
+  return array(
+    'tripal_views_integration_form' => array(
+      'arguments' => array('form' => NULL),
+      'template'  => 'tripal_views_integration_fields_form',
+    ),
+    'tripal_views_data_export_download_form' => array(
+      'arguments' => array('form' => NULL),
+      'template'  => 'tripal_views_data_export_download_form',
+    ),
+    'file_upload_combo' => array(
+      'arguments' => array('element' => NULL)
+    ),
+  );
 }

+ 57 - 53
tripal_views/tripal_views.views.inc

@@ -10,7 +10,7 @@ include('tripal_views.api.inc');
  * Provide rules for formatting and composition of fields
  * @}
  */
- 
+
 /**
  * @defgroup views_field_handlers Views Field Handlers
  * @{
@@ -42,12 +42,12 @@ include('tripal_views.api.inc');
  * @}
  * @ingroup views
  */
- 
+
 /**
  * Implements hook_views_handlers()
  *
  * Purpose: Register all custom handlers with views
- *   where a handler describes either "the type of field", 
+ *   where a handler describes either "the type of field",
  *   "how a field should be filtered", "how a field should be sorted"
  *
  * @return
@@ -62,7 +62,7 @@ function tripal_views_views_handlers() {
      'path' => drupal_get_path('module', 'tripal_views') . '/views/handlers',
    ),
    'handlers' => array(
-   
+
      // Custom Chado Handlers
      'chado_views_handler_field_aggregate' => array(
       'parent' => 'chado_views_handler_field',
@@ -73,7 +73,7 @@ function tripal_views_views_handlers() {
      'views_handler_filter_chado_select_cvterm_name' => array(
       'parent' => 'views_handler_filter_string',
      ),
-     
+
      // Join Handlers
      'views_handler_join_chado_aggregator' => array(
       'parent' => 'views_join',
@@ -81,12 +81,12 @@ function tripal_views_views_handlers() {
      'views_handler_join_chado_through_linking' => array(
       'parent' => 'views_join',
      ),
-     
+
      // Other Custom Handlers
      'views_handler_filter_no_results' => array(
       'parent' => 'views_handler_filter'
      ),
-     
+
      // Old Handlers
      'views_handler_field_node_optional' => array(
        'parent' => 'views_handler_field_node',
@@ -113,7 +113,7 @@ function tripal_views_views_handlers() {
        'parent' => 'views_handler_field',
      ),
 
-     
+
      // Wrappers for Default Views Handlers-----
      // Field Handlers
      'chado_views_handler_field' => array(
@@ -143,7 +143,7 @@ function tripal_views_views_handlers() {
      // Filter Handlers
      'chado_views_handler_filter_string' => array(
       'parent' => 'views_handler_filter_string',
-     ), 
+     ),
      'chado_views_handler_filter_boolean_operator_string' => array(
       'parent' => 'views_handler_filter_boolean_operator_string',
      ),
@@ -168,19 +168,19 @@ function tripal_views_views_handlers() {
      // Sort Handlers
      'chado_views_handler_sort' => array(
       'parent' => 'views_handler_sort'
-     ),     
+     ),
      'chado_views_handler_sort_date' => array(
       'parent' => 'views_handler_sort_date'
-     ), 
+     ),
      'chado_views_handler_sort_formula' => array(
       'parent' => 'views_handler_sort_formula'
-     ), 
+     ),
      'chado_views_handler_sort_menu_hierarchy' => array(
       'parent' => 'views_handler_sort_menu_hierarchy'
-     ), 
+     ),
      'chado_views_handler_sort_random' => array(
       'parent' => 'views_handler_sort_random'
-     ), 
+     ),
    ),
  );
 }
@@ -203,14 +203,14 @@ function tripal_views_views_pre_render	(&$view) {
 	// @see file: tripal_views.views.inc
 	tripal_views_add_node_ids_to_view ($view);
 
-   // We need to unset the exposed_input for the view so we can repopulate that 
-   // variable. This is necessary if we're using the file_upload_combo 
+   // We need to unset the exposed_input for the view so we can repopulate that
+   // variable. This is necessary if we're using the file_upload_combo
    // custom form element which adds the file_path variable to the $_GET after the
-   // view has populated the $view->exposed_input variable 
+   // view has populated the $view->exposed_input variable
    unset($view->exposed_input);
    $query = $view->get_exposed_input();  // retrieves elements in $_GET array
-		
-   // we want to add to the bottom of the views the form for downloading 
+
+   // we want to add to the bottom of the views the form for downloading
    // results in other formats (e.g. Excel, FASTA, CSV, etc.).  The Views Data
    // Export module provides small images at the bottom, but we want to provide
    // a more intutitive interface for getting different file formats
@@ -223,7 +223,7 @@ function tripal_views_views_pre_render	(&$view) {
  *
  * Purpose: To add basetable_nid fields to all result arrays of a view
  *   only if the basetable_nid field is added. This function will only be
- *   called if chado/drupal are not in the same database (ie: only if 
+ *   called if chado/drupal are not in the same database (ie: only if
  *   a join between the base and node table isn't possible.
  *
  * Note: Supports adding Node IDs to analysis, feature, library, organism, stock
@@ -236,7 +236,7 @@ function tripal_views_views_pre_render	(&$view) {
  * @ingroup tripal_views
  */
 function tripal_views_add_node_ids_to_view (&$view) {
-	
+
 	//-----Analysis----------------------------------------------
 	if (!empty($view->field['analysis_nid'])) {
 		// retrieve the analysis_id for each record in the views current page
@@ -267,7 +267,7 @@ function tripal_views_add_node_ids_to_view (&$view) {
 			}
 		} // if there are any analysis'
 	} //end of case for analysis NID
-	
+
 	//-----Feature-----------------------------------------------
 	if (!empty($view->field['feature_nid'])) {
 		// retrieve the feature_id for each record in the views current page
@@ -298,7 +298,7 @@ function tripal_views_add_node_ids_to_view (&$view) {
 			}
 		} // if there are any features
 	} //end of case for feature NID
-	
+
 	//-----Library-----------------------------------------------
 	if (!empty($view->field['library_nid'])) {
 		// retrieve the library_id for each record in the views current page
@@ -329,7 +329,7 @@ function tripal_views_add_node_ids_to_view (&$view) {
 			}
 		} // if there are libraries
 	} //end of case for library NID
-	
+
 	//-----Organism----------------------------------------------
 	if (!empty($view->field['organism_nid'])) {
 		// retrieve the organism_id for each record in the views current page
@@ -360,7 +360,7 @@ function tripal_views_add_node_ids_to_view (&$view) {
 			}
 		} // if there are organisms
 	} //end of case for organism NID
-	
+
 	//-----Stock-------------------------------------------------
 	if (!empty($view->field['stock_nid'])) {
 		// retrieve the stock_id for each record in the views current page
@@ -391,7 +391,7 @@ function tripal_views_add_node_ids_to_view (&$view) {
 			}
 		} //if there are stocks
 	} //end of case for stock NID
-		
+
 	return $view;
 }
 /**
@@ -407,10 +407,10 @@ function tripal_views_add_node_ids_to_view (&$view) {
  * @ingroup tripal_views
  */
 
-function tripal_views_views_data(){   
-  
-   // Define Global Fields 
-   // Filter handler that lets the admin say: 
+function tripal_views_views_data(){
+
+   // Define Global Fields
+   // Filter handler that lets the admin say:
    // "Show no results until they enter search parameters"
    $data['views']['search_results'] = array(
       'title' => t('Search Results'),
@@ -419,19 +419,19 @@ function tripal_views_views_data(){
          'handler' => 'views_handler_filter_no_results',
       ),
    );
-  
- 
+
+
     $tvi_query = db_query('SELECT * FROM {tripal_views}');
 
     while($tvi_row = db_fetch_object($tvi_query)){
-      
+
       // check to see if this is the lightest (drupal-style) priority setup for this table
       // if not then don't use this definition
       $lightest_priority_setup = tripal_views_is_lightest_priority_setup($tvi_row->setup_id, $tvi_row->table_name);
       if (!$lightest_priority_setup) {
         continue;
       }
-      
+
       // ids we'll use for queries
       $setup_id = $tvi_row->setup_id;
       $mview_id = $tvi_row->mview_id;
@@ -463,7 +463,7 @@ function tripal_views_views_data(){
               'type' => $column_type,
             );
          }
-         
+
          // get the field name and descriptions
          $sql = "SELECT * FROM {tripal_views_field} WHERE setup_id=%d";
          $query = db_query($sql, $setup_id);
@@ -478,10 +478,14 @@ function tripal_views_views_data(){
          // The chado table could be a regular Chado table or a custom table
          // in the chado database.  Therefore we'll check both
          $table_desc = module_invoke_all('chado_'.$base_table.'_schema');
-         if(!$table_desc){            
+         if(!$table_desc){
             $table_desc = tripal_get_chado_custom_schema($base_table);
          }
          $fields = $table_desc['fields'];
+         if (!is_array($fields)) {
+           $fields = array();
+           drupal_set_message('No Fields for '.$base_table, 'error');
+         }
          foreach($fields as $column => $attrs){
             $base_fields[$column] = array(
               'column_name' => $column,
@@ -513,8 +517,8 @@ function tripal_views_views_data(){
               'click sortable' => TRUE,
            ),
         );
-        
-        
+
+
         // now add the handlers
         $sql = "SELECT * FROM {tripal_views_handlers} WHERE setup_id = %d AND column_name = '%s'";
         $handlers = db_query($sql,$setup_id,$column_name);
@@ -526,11 +530,11 @@ function tripal_views_views_data(){
      // now add the joins
      $sql = "SELECT * FROM {tripal_views_join} WHERE setup_id = %d";
      $joins = db_query($sql,$setup_id);
-     while($join = db_fetch_object($joins)){               
+     while($join = db_fetch_object($joins)){
         $left_table = $join->left_table;
         $left_field = $join->left_field;
-        $base_field = $join->base_field;  
-      
+        $base_field = $join->base_field;
+
         // add join entry
         $data[$base_table]['table']['join'][$left_table] = array(
           'left_field' => $left_field,
@@ -569,11 +573,11 @@ function tripal_views_views_data_alter(&$data) {
       // joins to other tables
       $sql = "SELECT * FROM {tripal_views_join} WHERE setup_id = %d";
       $joins = db_query($sql,$setup_id);
-      while($join = db_fetch_object($joins)){                       
+      while($join = db_fetch_object($joins)){
         $left_table = $join->left_table;
         $left_field = $join->left_field;
-        $base_field = $join->base_field;  
-        $base_table = $join->base_table;    
+        $base_field = $join->base_field;
+        $base_table = $join->base_table;
 
         // add the recipricol join entries for each column
         if(array_key_exists($left_table,$data)){
@@ -586,7 +590,7 @@ function tripal_views_views_data_alter(&$data) {
         // check to see if this table is one that correlates with Drupal nodes
         // if so, there will be a chado_<table_name> table in the Drupal database
         // if there is, then we need to add the linking join information.  We did
-        // this step in the hook_views_data function above, but now we need 
+        // this step in the hook_views_data function above, but now we need
         // to add the reciprical joins
         if(db_table_exists("chado_$left_table")){
 
@@ -602,7 +606,7 @@ function tripal_views_views_data_alter(&$data) {
               	'left_table' => "chado_$left_table",
               	'left_field' => 'nid',
               	'field' => 'nid',
-              );           
+              );
            }
         }
       }
@@ -628,8 +632,8 @@ function tripal_views_views_plugins() {
   );
 
   // add FASTA format as a new style for the existing views_export_data Display
-  return array( 
-    'style' => array(   
+  return array(
+    'style' => array(
       'views_data_export_fasta' => array(
         'title' => t('FASTA file'),
         'help' => t('Display results in FASTA format. All fields in results are on the definition line while the feature.residues field must be present .'),
@@ -647,7 +651,7 @@ function tripal_views_views_plugins() {
           'views_data_export_fasta_footer' => 'style',
         ),
         'additional themes base' => 'views_data_export_fasta',
-      ) + $style_defaults,      
+      ) + $style_defaults,
     ),
   );
 }
@@ -666,7 +670,7 @@ function tripal_views_views_pre_view(&$view,&$display_id,&$args){
  * Implementation of hook_views_pre_build().
  */
 /*function tripal_views_views_pre_render(&$view, &$display_id, &$args){
-   // we want to add to the bottom of the views the form for downloading 
+   // we want to add to the bottom of the views the form for downloading
    // results in other formats (e.g. Excel, FASTA, CSV, etc.).  The Views Data
    // Export module provides small images at the bottom, but we want to provide
    // a more intutitive interface for getting different file formats
@@ -674,7 +678,7 @@ function tripal_views_views_pre_view(&$view,&$display_id,&$args){
    $view->attachment_after = $form;
 }*/
 /**
- * 
+ *
  */
 function tripal_views_data_export_download_form(&$form_state, $view,$display_id,$args){
    $form = array();
@@ -728,11 +732,11 @@ function tripal_views_data_export_download_form(&$form_state, $view,$display_id,
          '#type' => 'submit',
       );
    }
-   
+
    return $form;
 }
 /**
- * 
+ *
  */
 function tripal_views_data_export_download_form_submit($form, &$form_state){
    $urls = $form_state['storage']['urls'];

+ 0 - 45
tripal_views/views/README

@@ -1,45 +0,0 @@
-
-This directory contains all additional views code needed to integrate this module with views2.
-
-FILE/FOLDER DESCRIPTIONS
----------------------------
-<chado table name>.views.inc:
-	contains a single function retrieve_<chado table name>_views_data()
-	which describes that table to views. This function is called by
-	tripal_core_views_data() in ../tripal_core.views.inc.
-	For more information on the form of this data array look up the
-	views2 documentation for hook_views_data() 
-	-http://views2.logrus.com/doc/html/index.html
-	
-handlers/
-	Each file contained within this folder defines a views handler. Only custom
-	handlers are included in this folder and each must be described in 
-	hook_views_handlers() in ../tripal_core.views.inc.
-	A views handler does one of the following:
-		1) describe the type of a field and how it should be displayed
-		2) describe a method to sort this field
-		3) describe a method to filter this field
-
-
-STANDARDS TO FOLLOW
----------------------------
-
-1. All table definition files should be named tablename.views.inc
-2. All handlers should be in a handlers sub-directory and follow the naming convention of
-   views handlers (ie: views_handler_field/filter/sort_handlername.inc )
-
-Views Table Definitions:
-- Please use the template files provided whenever you are describing a new table to views.
-   For any table in chado simply copy template.table_defn.views.inc to tablename.views.inc and 
-   follow the instructions listed at the top of the template file.
-- ONLY ONE TABLE DEFINITION PER FILE
-- To join a chado table to it's drupal node simply copy template.node_join.views.inc to 
-   basetablename.views.inc and replace all XXX with basetablename.
-   
-   NOTE: Creating the table definition file is not enough. You also need to call the 
-         retrieve_XXX_views_data() function from ../tripal_core.views.inc:tripal_core_views_data()
-         by adding the following line:
-            $data = array_merge($data, retrieve_XXX_views_data());
-         to the function and including the file directly above the function (blow the function 
-         header by adding:
-            require_once('views/XXX.views.inc');

+ 19 - 11
tripal_views/views/handlers/chado_views_handler_field.inc

@@ -1,12 +1,20 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_field.
+ *
+ * Handles fields which may be aggregated during the chado join process. This field
+ * will render an aggregated field as a pre_rendered list and will dynamically detect
+ * whether the field is aggregated or not.
+ */
 class chado_views_handler_field extends views_handler_field {
 
   function init (&$view, $options) {
     include_once('chado_wrapper_functions.inc');
     parent::init($view,$options);
   }
-  
+
   /**
    * Defines the defaults for the options form
    */
@@ -18,13 +26,13 @@ class chado_views_handler_field extends views_handler_field {
 
     return $options;
   }
-  
+
   /**
    * Defines the options form (form available to admin when they add a field to a view)
    */
   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
-    
+
     $form['type'] = array(
       '#type' => 'radios',
       '#title' => t('Display type'),
@@ -44,7 +52,7 @@ class chado_views_handler_field extends views_handler_field {
       '#dependency' => array('radio:options[type]' => array('separator')),
     );
   }
-  
+
   /**
    * Determines whether the current field is aggregated or not
    * Note: The parent::query() takes care of adding the field to the query, etc.
@@ -53,20 +61,20 @@ class chado_views_handler_field extends views_handler_field {
     parent::query();
     $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
   }
-  
+
   /**
    * Splits the aggregated values up for use in rendering
    */
   function pre_render (&$values) {
-    
+
     // further check the results to see if this field is a postgresql array
     $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-    
+
     // Split Aggregated Results
     chado_wrapper_split_array_agg_results($this, $values);
-    
+
   }
-  
+
   /**
    * Render the field.
    *
@@ -79,9 +87,9 @@ class chado_views_handler_field extends views_handler_field {
   function render($values) {
     return chado_wrapper_render_items($this, $values);
   }
-  
+
   function parent_render($val) {
     return parent::render($val);
   }
-  
+
 }

+ 27 - 19
tripal_views/views/handlers/chado_views_handler_field_aggregate.inc

@@ -1,22 +1,30 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_field.
+ *
+ * Handles fields which may be aggregated during the chado join process. This field
+ * will render an aggregated field as a pre_rendered list and will dynamically detect
+ * whether the field is aggregated or not.
+ */
 class chado_views_handler_field_aggregate extends chado_views_handler_field {
-  
+
   function init(&$view, $options) {
     parent::init($view, $options);
-    
+
     if (!isset($this->chado_table_description)) {
-      $this->chado_table_description = module_invoke_all('chado_'.$this->table.'_schema');
+      $this->chado_table_description = module_invoke_all('chado_' . $this->table . '_schema');
       foreach($this->chado_table_description['foreign keys'] as $defn) {
         if ($defn['table'] != $this->view->base_table) {
-          $join_table = module_invoke_all('chado_'.$defn['table'].'_schema');
+          $join_table = module_invoke_all('chado_' . $defn['table'] . '_schema');
           foreach ($join_table['fields'] as $fname => $f) {
-            $this->chado_table_description['fields'][$defn['table'] .'_'. $fname] = $f;
+            $this->chado_table_description['fields'][$defn['table'] . '_' . $fname] = $f;
           }
         }
       }
     }
-    
+
   }
 
   /**
@@ -28,7 +36,7 @@ class chado_views_handler_field_aggregate extends chado_views_handler_field {
     $form['format'] = array(
       '#type' => 'fieldset',
       '#title' => 'Format Output',
-      '#description' => t('The following fields specify how a single result of this field will be 
+      '#description' => t('The following fields specify how a single result of this field will be
         displayed. When there are multiple results of this field due to aggregation, each result
         will be rendered according to the following rules and then all results will be joined
         together based on the "Display Type" indicated.')
@@ -41,37 +49,37 @@ class chado_views_handler_field_aggregate extends chado_views_handler_field {
       $this->tokens[$t] = t($field);
       $value[] = $t . ' == ' . $field;
     }
-    
+
     $form['format']['format_string'] = array(
       '#type' => 'textfield',
       '#title' => t('Format String'),
       '#description' => 'Use any of the format tokens below to indicate what fields you want displayed.',
       '#default_value' => ($this->options['format']['format_string']) ? $this->options['format']['format_string'] : implode(', ', array_keys($this->tokens)),
     );
-    
+
     $form['format']['tokens'] = array(
       '#type' => 'item',
       '#title' => 'Format Tokens',
       '#value' => implode("<br />",$value),
     );
-    
+
   }
-  
+
   function query() {
     parent::query();
-    
+
     $this->table_definition = $this->query->get_table_info($this->table);
   }
 
 
   function pre_render (&$values) {
-    
+
     if ($this->aggregated) {
       foreach($values as $k => $v) {
         $values[$k]->{$this->field_alias} = $this->split_array_agg_results($v->{$this->field_alias});
-        
+
         foreach($values[$k]->{$this->field_alias} as &$val) {
-          
+
           // First, get the token values
           $subparts = explode(',',$val);
           $token_values = array();
@@ -80,15 +88,15 @@ class chado_views_handler_field_aggregate extends chado_views_handler_field {
               $token_values[ '[all-'.$matches[1].']' ] = $matches[2];
             }
           }
-          
+
           // Now manually sub them in
           $val = str_replace(array_keys($token_values),$token_values,$this->options['format']['format_string']);
-          
+
         }
       }
 
     }
-    
+
   }
-	
+
 }

+ 19 - 11
tripal_views/views/handlers/chado_views_handler_field_boolean.inc

@@ -1,12 +1,20 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_field_boolean.
+ *
+ * Handles fields which may be aggregated during the chado join process. This field
+ * will render an aggregated field as a pre_rendered list and will dynamically detect
+ * whether the field is aggregated or not.
+ */
 class chado_views_handler_field_boolean extends views_handler_field_boolean {
 
   function init (&$view, $options) {
     include_once('chado_wrapper_functions.inc');
     parent::init($view,$options);
   }
-  
+
   /**
    * Defines the defaults for the options form
    */
@@ -18,13 +26,13 @@ class chado_views_handler_field_boolean extends views_handler_field_boolean {
 
     return $options;
   }
-  
+
   /**
    * Defines the options form (form available to admin when they add a field to a view)
    */
   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
-    
+
     $form['type'] = array(
       '#type' => 'radios',
       '#title' => t('Display type'),
@@ -44,7 +52,7 @@ class chado_views_handler_field_boolean extends views_handler_field_boolean {
       '#dependency' => array('radio:options[type]' => array('separator')),
     );
   }
-  
+
   /**
    * Determines whether the current field is aggregated or not
    * Note: The parent::query() takes care of adding the field to the query, etc.
@@ -53,20 +61,20 @@ class chado_views_handler_field_boolean extends views_handler_field_boolean {
     parent::query();
     $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
   }
-  
+
   /**
    * Splits the aggregated values up for use in rendering
    */
   function pre_render (&$values) {
-    
+
     // further check the results to see if this field is a postgresql array
     $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-    
+
     // Split Aggregated Results
     chado_wrapper_split_array_agg_results($this, $values);
-    
+
   }
-  
+
   /**
    * Render the field.
    *
@@ -79,9 +87,9 @@ class chado_views_handler_field_boolean extends views_handler_field_boolean {
   function render($values) {
     return chado_wrapper_render_items($this, $values);
   }
-  
+
   function parent_render($val) {
     return parent::render($val);
   }
-  
+
 }

+ 19 - 11
tripal_views/views/handlers/chado_views_handler_field_counter.inc

@@ -1,12 +1,20 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_field_counter.
+ *
+ * Handles fields which may be aggregated during the chado join process. This field
+ * will render an aggregated field as a pre_rendered list and will dynamically detect
+ * whether the field is aggregated or not.
+ */
 class chado_views_handler_field_counter extends views_handler_field_counter {
 
   function init (&$view, $options) {
     include_once('chado_wrapper_functions.inc');
     parent::init($view,$options);
   }
-  
+
   /**
    * Defines the defaults for the options form
    */
@@ -18,13 +26,13 @@ class chado_views_handler_field_counter extends views_handler_field_counter {
 
     return $options;
   }
-  
+
   /**
    * Defines the options form (form available to admin when they add a field to a view)
    */
   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
-    
+
     $form['type'] = array(
       '#type' => 'radios',
       '#title' => t('Display type'),
@@ -44,7 +52,7 @@ class chado_views_handler_field_counter extends views_handler_field_counter {
       '#dependency' => array('radio:options[type]' => array('separator')),
     );
   }
-  
+
   /**
    * Determines whether the current field is aggregated or not
    * Note: The parent::query() takes care of adding the field to the query, etc.
@@ -53,20 +61,20 @@ class chado_views_handler_field_counter extends views_handler_field_counter {
     parent::query();
     $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
   }
-  
+
   /**
    * Splits the aggregated values up for use in rendering
    */
   function pre_render (&$values) {
-    
+
     // further check the results to see if this field is a postgresql array
     $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-    
+
     // Split Aggregated Results
     chado_wrapper_split_array_agg_results($this, $values);
-    
+
   }
-  
+
   /**
    * Render the field.
    *
@@ -79,9 +87,9 @@ class chado_views_handler_field_counter extends views_handler_field_counter {
   function render($values) {
     return chado_wrapper_render_items($this, $values);
   }
-  
+
   function parent_render($val) {
     return parent::render($val);
   }
-  
+
 }

+ 19 - 11
tripal_views/views/handlers/chado_views_handler_field_custom.inc

@@ -1,12 +1,20 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_field_custom.
+ *
+ * Handles fields which may be aggregated during the chado join process. This field
+ * will render an aggregated field as a pre_rendered list and will dynamically detect
+ * whether the field is aggregated or not.
+ */
 class chado_views_handler_field_custom extends views_handler_field_custom {
 
   function init (&$view, $options) {
     include_once('chado_wrapper_functions.inc');
     parent::init($view,$options);
   }
-  
+
   /**
    * Defines the defaults for the options form
    */
@@ -18,13 +26,13 @@ class chado_views_handler_field_custom extends views_handler_field_custom {
 
     return $options;
   }
-  
+
   /**
    * Defines the options form (form available to admin when they add a field to a view)
    */
   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
-    
+
     $form['type'] = array(
       '#type' => 'radios',
       '#title' => t('Display type'),
@@ -44,7 +52,7 @@ class chado_views_handler_field_custom extends views_handler_field_custom {
       '#dependency' => array('radio:options[type]' => array('separator')),
     );
   }
-  
+
   /**
    * Determines whether the current field is aggregated or not
    * Note: The parent::query() takes care of adding the field to the query, etc.
@@ -53,20 +61,20 @@ class chado_views_handler_field_custom extends views_handler_field_custom {
     parent::query();
     $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
   }
-  
+
   /**
    * Splits the aggregated values up for use in rendering
    */
   function pre_render (&$values) {
-    
+
     // further check the results to see if this field is a postgresql array
     $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-    
+
     // Split Aggregated Results
     chado_wrapper_split_array_agg_results($this, $values);
-    
+
   }
-  
+
   /**
    * Render the field.
    *
@@ -79,9 +87,9 @@ class chado_views_handler_field_custom extends views_handler_field_custom {
   function render($values) {
     return chado_wrapper_render_items($this, $values);
   }
-  
+
   function parent_render($val) {
     return parent::render($val);
   }
-  
+
 }

+ 23 - 15
tripal_views/views/handlers/chado_views_handler_field_date.inc

@@ -1,12 +1,20 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_field_date.
+ *
+ * Handles fields which may be aggregated during the chado join process. This field
+ * will render an aggregated field as a pre_rendered list and will dynamically detect
+ * whether the field is aggregated or not.
+ */
 class chado_views_handler_field_date extends views_handler_field_date {
 
-  function init (&$view, $options) {
+  function init(&$view, $options) {
     include_once('chado_wrapper_functions.inc');
-    parent::init($view,$options);
+    parent::init($view, $options);
   }
-  
+
   /**
    * Defines the defaults for the options form
    */
@@ -18,13 +26,13 @@ class chado_views_handler_field_date extends views_handler_field_date {
 
     return $options;
   }
-  
+
   /**
    * Defines the options form (form available to admin when they add a field to a view)
    */
   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
-    
+
     $form['type'] = array(
       '#type' => 'radios',
       '#title' => t('Display type'),
@@ -44,29 +52,29 @@ class chado_views_handler_field_date extends views_handler_field_date {
       '#dependency' => array('radio:options[type]' => array('separator')),
     );
   }
-  
+
   /**
    * Determines whether the current field is aggregated or not
    * Note: The parent::query() takes care of adding the field to the query, etc.
    */
-  function query () {
+  function query() {
     parent::query();
     $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
   }
-  
+
   /**
    * Splits the aggregated values up for use in rendering
    */
-  function pre_render (&$values) {
-    
+  function pre_render(&$values) {
+
     // further check the results to see if this field is a postgresql array
     $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-    
+
     // Split Aggregated Results
     chado_wrapper_split_array_agg_results($this, $values);
-    
+
   }
-  
+
   /**
    * Render the field.
    *
@@ -79,9 +87,9 @@ class chado_views_handler_field_date extends views_handler_field_date {
   function render($values) {
     return chado_wrapper_render_items($this, $values);
   }
-  
+
   function parent_render($val) {
     return parent::render($val);
   }
-  
+
 }

+ 19 - 11
tripal_views/views/handlers/chado_views_handler_field_markup.inc

@@ -1,12 +1,20 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_field_markup.
+ *
+ * Handles fields which may be aggregated during the chado join process. This field
+ * will render an aggregated field as a pre_rendered list and will dynamically detect
+ * whether the field is aggregated or not.
+ */
 class chado_views_handler_field_markup extends views_handler_field_markup {
 
   function init (&$view, $options) {
     include_once('chado_wrapper_functions.inc');
     parent::init($view,$options);
   }
-  
+
   /**
    * Defines the defaults for the options form
    */
@@ -18,13 +26,13 @@ class chado_views_handler_field_markup extends views_handler_field_markup {
 
     return $options;
   }
-  
+
   /**
    * Defines the options form (form available to admin when they add a field to a view)
    */
   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
-    
+
     $form['type'] = array(
       '#type' => 'radios',
       '#title' => t('Display type'),
@@ -44,7 +52,7 @@ class chado_views_handler_field_markup extends views_handler_field_markup {
       '#dependency' => array('radio:options[type]' => array('separator')),
     );
   }
-  
+
   /**
    * Determines whether the current field is aggregated or not
    * Note: The parent::query() takes care of adding the field to the query, etc.
@@ -53,20 +61,20 @@ class chado_views_handler_field_markup extends views_handler_field_markup {
     parent::query();
     $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
   }
-  
+
   /**
    * Splits the aggregated values up for use in rendering
    */
   function pre_render (&$values) {
-    
+
     // further check the results to see if this field is a postgresql array
     $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-    
+
     // Split Aggregated Results
     chado_wrapper_split_array_agg_results($this, $values);
-    
+
   }
-  
+
   /**
    * Render the field.
    *
@@ -79,9 +87,9 @@ class chado_views_handler_field_markup extends views_handler_field_markup {
   function render($values) {
     return chado_wrapper_render_items($this, $values);
   }
-  
+
   function parent_render($val) {
     return parent::render($val);
   }
-  
+
 }

+ 19 - 11
tripal_views/views/handlers/chado_views_handler_field_math.inc

@@ -1,12 +1,20 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_field_math.
+ *
+ * Handles fields which may be aggregated during the chado join process. This field
+ * will render an aggregated field as a pre_rendered list and will dynamically detect
+ * whether the field is aggregated or not.
+ */
 class chado_views_handler_field_math extends views_handler_field_math {
 
   function init (&$view, $options) {
     include_once('chado_wrapper_functions.inc');
     parent::init($view,$options);
   }
-  
+
   /**
    * Defines the defaults for the options form
    */
@@ -18,13 +26,13 @@ class chado_views_handler_field_math extends views_handler_field_math {
 
     return $options;
   }
-  
+
   /**
    * Defines the options form (form available to admin when they add a field to a view)
    */
   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
-    
+
     $form['type'] = array(
       '#type' => 'radios',
       '#title' => t('Display type'),
@@ -44,7 +52,7 @@ class chado_views_handler_field_math extends views_handler_field_math {
       '#dependency' => array('radio:options[type]' => array('separator')),
     );
   }
-  
+
   /**
    * Determines whether the current field is aggregated or not
    * Note: The parent::query() takes care of adding the field to the query, etc.
@@ -53,20 +61,20 @@ class chado_views_handler_field_math extends views_handler_field_math {
     parent::query();
     $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
   }
-  
+
   /**
    * Splits the aggregated values up for use in rendering
    */
   function pre_render (&$values) {
-    
+
     // further check the results to see if this field is a postgresql array
     $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-    
+
     // Split Aggregated Results
     chado_wrapper_split_array_agg_results($this, $values);
-    
+
   }
-  
+
   /**
    * Render the field.
    *
@@ -79,9 +87,9 @@ class chado_views_handler_field_math extends views_handler_field_math {
   function render($values) {
     return chado_wrapper_render_items($this, $values);
   }
-  
+
   function parent_render($val) {
     return parent::render($val);
   }
-  
+
 }

+ 19 - 11
tripal_views/views/handlers/chado_views_handler_field_numeric.inc

@@ -1,12 +1,20 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_field_numeric.
+ *
+ * Handles fields which may be aggregated during the chado join process. This field
+ * will render an aggregated field as a pre_rendered list and will dynamically detect
+ * whether the field is aggregated or not.
+ */
 class chado_views_handler_field_numeric extends views_handler_field_numeric {
 
   function init (&$view, $options) {
     include_once('chado_wrapper_functions.inc');
     parent::init($view,$options);
   }
-  
+
   /**
    * Defines the defaults for the options form
    */
@@ -18,13 +26,13 @@ class chado_views_handler_field_numeric extends views_handler_field_numeric {
 
     return $options;
   }
-  
+
   /**
    * Defines the options form (form available to admin when they add a field to a view)
    */
   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
-    
+
     $form['type'] = array(
       '#type' => 'radios',
       '#title' => t('Display type'),
@@ -44,7 +52,7 @@ class chado_views_handler_field_numeric extends views_handler_field_numeric {
       '#dependency' => array('radio:options[type]' => array('separator')),
     );
   }
-  
+
   /**
    * Determines whether the current field is aggregated or not
    * Note: The parent::query() takes care of adding the field to the query, etc.
@@ -53,20 +61,20 @@ class chado_views_handler_field_numeric extends views_handler_field_numeric {
     parent::query();
     $this->aggregated = chado_wrapper_is_aggregated_by_join($this);
   }
-  
+
   /**
    * Splits the aggregated values up for use in rendering
    */
   function pre_render (&$values) {
-    
+
     // further check the results to see if this field is a postgresql array
     $this->aggregated = chado_wrapper_is_aggregated_by_result($this, $values);
-    
+
     // Split Aggregated Results
     chado_wrapper_split_array_agg_results($this, $values);
-    
+
   }
-  
+
   /**
    * Render the field.
    *
@@ -79,9 +87,9 @@ class chado_views_handler_field_numeric extends views_handler_field_numeric {
   function render($values) {
     return chado_wrapper_render_items($this, $values);
   }
-  
+
   function parent_render($val) {
     return parent::render($val);
   }
-  
+
 }

+ 30 - 20
tripal_views/views/handlers/chado_views_handler_filter_boolean_operator.inc

@@ -1,5 +1,13 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_filter_boolean_operator.
+ *
+ * Handles fields which may be aggregated during the chado join process. There are options
+ * to filter the base table based on an aggregated table or just filter the aggregated
+ * table (showing blank for that field if there are no records in the aggregated table).
+ */
 class chado_views_handler_filter_boolean_operator extends views_handler_filter_boolean_operator {
 
   /**
@@ -10,48 +18,50 @@ class chado_views_handler_filter_boolean_operator extends views_handler_filter_b
       '#type' => 'item',
       '#value' => '<b>If this filter applies to a table that is aggregated, additionally options may be ignored.</b>'
     );
-    
+
     parent::options_form($form, $form_state);
-    
+
     $form['agg'] = array(
       '#type' => 'fieldset',
       '#title' => 'Apply to fields that are aggregated'
     );
-    
+
     $form['agg']['records_with'] = array(
       '#type' => 'checkbox',
       '#title' => t('Filter base table records'),
-      '#description' => t('Filters '.$this->view->base_table.' to only those with the value in the aggregate array.'),
+      '#description' => t('Filters %base_table to only those with the value in the aggregate array.', array('%base_table' => $this->view->base_table)),
       '#default_value' => (isset($this->options['records_with'])) ? $this->options['records_with'] : TRUE,
     );
-    
+
     $form['agg']['aggregates_with'] = array(
       '#type' => 'checkbox',
       '#title' => t('Filter aggregates displayed'),
-      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of '.$this->view->base_table.' records.'),
-      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,    
+      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of %base_table records.', array('%base_table' => $this->view->base_table)),
+      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,
     );
-    
+
   }
-  
+
   /**
    * If the table to be filtered is not aggregated uses the parent::query()
    * However, if it is uses postgresql any() function to compare
    */
-  function query () {
+  function query() {
     $this->ensure_my_table();
-    
-    
+
+
     $table = $this->query->get_table_info($this->table);
-    if (preg_match('/aggregator/',$table['join']->definition['handler'])) {
+    if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
       $this->aggregated = TRUE;
-    } else {
+    }
+    else {
       $this->aggregated = FALSE;
     }
 
     if (!$this->aggregated) {
       parent::query();
-    } else {
+    }
+    else {
 
       // Only base records with value in the aggregated field
       // This doesn't restrict the items in the aggregate field
@@ -63,13 +73,13 @@ class chado_views_handler_filter_boolean_operator extends views_handler_filter_b
       }
 
       // To restrict the items in the aggregate...
-      // Tell the join handler about the filter 
+      // Tell the join handler about the filter
       // so it can be done in the join query
       if ($this->options['agg']['aggregates_with']) {
-        $table['join']->filter[] = $field ." = '". $this->value."'";
-      }    
+        $table['join']->filter[] = $field . " = '" . $this->value . "'";
+      }
     }
-    
+
   }
-  
+
 }

+ 21 - 13
tripal_views/views/handlers/chado_views_handler_filter_boolean_operator_string.inc

@@ -1,5 +1,13 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_filter_boolean_operator_string.
+ *
+ * Handles fields which may be aggregated during the chado join process. There are options
+ * to filter the base table based on an aggregated table or just filter the aggregated
+ * table (showing blank for that field if there are no records in the aggregated table).
+ */
 class chado_views_handler_filter_boolean_operator_string extends views_handler_filter_boolean_operator_string {
 
   /**
@@ -10,38 +18,38 @@ class chado_views_handler_filter_boolean_operator_string extends views_handler_f
       '#type' => 'item',
       '#value' => '<b>If this filter applies to a table that is aggregated, additionally options may be ignored.</b>'
     );
-    
+
     parent::options_form($form, $form_state);
-    
+
     $form['agg'] = array(
       '#type' => 'fieldset',
       '#title' => 'Apply to fields that are aggregated'
     );
-    
+
     $form['agg']['records_with'] = array(
       '#type' => 'checkbox',
       '#title' => t('Filter base table records'),
       '#description' => t('Filters '.$this->view->base_table.' to only those with the value in the aggregate array.'),
       '#default_value' => (isset($this->options['records_with'])) ? $this->options['records_with'] : TRUE,
     );
-    
+
     $form['agg']['aggregates_with'] = array(
       '#type' => 'checkbox',
       '#title' => t('Filter aggregates displayed'),
       '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of '.$this->view->base_table.' records.'),
-      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,    
+      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,
     );
-    
+
   }
-  
+
   /**
    * If the table to be filtered is not aggregated uses the parent::query()
    * However, if it is uses postgresql any() function to compare
    */
   function query () {
     $this->ensure_my_table();
-    
-    
+
+
     $table = $this->query->get_table_info($this->table);
     if (preg_match('/aggregator/',$table['join']->definition['handler'])) {
       $this->aggregated = TRUE;
@@ -63,13 +71,13 @@ class chado_views_handler_filter_boolean_operator_string extends views_handler_f
       }
 
       // To restrict the items in the aggregate...
-      // Tell the join handler about the filter 
+      // Tell the join handler about the filter
       // so it can be done in the join query
       if ($this->options['agg']['aggregates_with']) {
         $table['join']->filter[] = $field ." = '". $this->value."'";
-      }    
+      }
     }
-    
+
   }
-  
+
 }

+ 23 - 15
tripal_views/views/handlers/chado_views_handler_filter_date.inc

@@ -1,5 +1,13 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_filter_date.
+ *
+ * Handles fields which may be aggregated during the chado join process. There are options
+ * to filter the base table based on an aggregated table or just filter the aggregated
+ * table (showing blank for that field if there are no records in the aggregated table).
+ */
 class chado_views_handler_filter_date extends views_handler_filter_date {
 
   /**
@@ -10,38 +18,38 @@ class chado_views_handler_filter_date extends views_handler_filter_date {
       '#type' => 'item',
       '#value' => '<b>If this filter applies to a table that is aggregated, additionally options may be ignored.</b>'
     );
-    
+
     parent::options_form($form, $form_state);
-    
+
     $form['agg'] = array(
       '#type' => 'fieldset',
       '#title' => 'Apply to fields that are aggregated'
     );
-    
+
     $form['agg']['records_with'] = array(
       '#type' => 'checkbox',
       '#title' => t('Filter base table records'),
-      '#description' => t('Filters '.$this->view->base_table.' to only those with the value in the aggregate array.'),
+      '#description' => t('Filters %base_table to only those with the value in the aggregate array.', array('%base_table' => $this->view->base_table)),
       '#default_value' => (isset($this->options['records_with'])) ? $this->options['records_with'] : TRUE,
     );
-    
+
     $form['agg']['aggregates_with'] = array(
       '#type' => 'checkbox',
       '#title' => t('Filter aggregates displayed'),
-      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of '.$this->view->base_table.' records.'),
-      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,    
+      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of %base_table records.', array('%base_table' => $this->view->base_table)),
+      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,
     );
-    
+
   }
-  
+
   /**
    * If the table to be filtered is not aggregated uses the parent::query()
    * However, if it is uses postgresql any() function to compare
    */
   function query () {
     $this->ensure_my_table();
-    
-    
+
+
     $table = $this->query->get_table_info($this->table);
     if (preg_match('/aggregator/',$table['join']->definition['handler'])) {
       $this->aggregated = TRUE;
@@ -63,13 +71,13 @@ class chado_views_handler_filter_date extends views_handler_filter_date {
       }
 
       // To restrict the items in the aggregate...
-      // Tell the join handler about the filter 
+      // Tell the join handler about the filter
       // so it can be done in the join query
       if ($this->options['agg']['aggregates_with']) {
         $table['join']->filter[] = $field ." = '". $this->value."'";
-      }    
+      }
     }
-    
+
   }
-  
+
 }

+ 23 - 15
tripal_views/views/handlers/chado_views_handler_filter_equality.inc

@@ -1,5 +1,13 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_filter_equality.
+ *
+ * Handles fields which may be aggregated during the chado join process. There are options
+ * to filter the base table based on an aggregated table or just filter the aggregated
+ * table (showing blank for that field if there are no records in the aggregated table).
+ */
 class chado_views_handler_filter_equality extends views_handler_filter_equality {
 
   /**
@@ -10,38 +18,38 @@ class chado_views_handler_filter_equality extends views_handler_filter_equality
       '#type' => 'item',
       '#value' => '<b>If this filter applies to a table that is aggregated, additionally options may be ignored.</b>'
     );
-    
+
     parent::options_form($form, $form_state);
-    
+
     $form['agg'] = array(
       '#type' => 'fieldset',
       '#title' => 'Apply to fields that are aggregated'
     );
-    
+
     $form['agg']['records_with'] = array(
       '#type' => 'checkbox',
       '#title' => t('Filter base table records'),
-      '#description' => t('Filters '.$this->view->base_table.' to only those with the value in the aggregate array.'),
+      '#description' => t('Filters %base_table to only those with the value in the aggregate array.', array('%base_table' => $this->view->base_table)),
       '#default_value' => (isset($this->options['records_with'])) ? $this->options['records_with'] : TRUE,
     );
-    
+
     $form['agg']['aggregates_with'] = array(
       '#type' => 'checkbox',
       '#title' => t('Filter aggregates displayed'),
-      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of '.$this->view->base_table.' records.'),
-      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,    
+      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of %base_table records.', array('%base_table' => $this->view->base_table)),
+      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,
     );
-    
+
   }
-  
+
   /**
    * If the table to be filtered is not aggregated uses the parent::query()
    * However, if it is uses postgresql any() function to compare
    */
   function query () {
     $this->ensure_my_table();
-    
-    
+
+
     $table = $this->query->get_table_info($this->table);
     if (preg_match('/aggregator/',$table['join']->definition['handler'])) {
       $this->aggregated = TRUE;
@@ -63,13 +71,13 @@ class chado_views_handler_filter_equality extends views_handler_filter_equality
       }
 
       // To restrict the items in the aggregate...
-      // Tell the join handler about the filter 
+      // Tell the join handler about the filter
       // so it can be done in the join query
       if ($this->options['agg']['aggregates_with']) {
         $table['join']->filter[] = $field ." = '". $this->value."'";
-      }    
+      }
     }
-    
+
   }
-  
+
 }

+ 23 - 15
tripal_views/views/handlers/chado_views_handler_filter_float.inc

@@ -1,5 +1,13 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_filter_float.
+ *
+ * Handles fields which may be aggregated during the chado join process. There are options
+ * to filter the base table based on an aggregated table or just filter the aggregated
+ * table (showing blank for that field if there are no records in the aggregated table).
+ */
 class chado_views_handler_filter_float extends views_handler_filter_float {
 
   /**
@@ -10,38 +18,38 @@ class chado_views_handler_filter_float extends views_handler_filter_float {
       '#type' => 'item',
       '#value' => '<b>If this filter applies to a table that is aggregated, additionally options may be ignored.</b>'
     );
-    
+
     parent::options_form($form, $form_state);
-    
+
     $form['agg'] = array(
       '#type' => 'fieldset',
       '#title' => 'Apply to fields that are aggregated'
     );
-    
+
     $form['agg']['records_with'] = array(
       '#type' => 'checkbox',
       '#title' => t('Filter base table records'),
-      '#description' => t('Filters '.$this->view->base_table.' to only those with the value in the aggregate array.'),
+      '#description' => t('Filters %base_table to only those with the value in the aggregate array.', array('%base_table' => $this->view->base_table)),
       '#default_value' => (isset($this->options['records_with'])) ? $this->options['records_with'] : TRUE,
     );
-    
+
     $form['agg']['aggregates_with'] = array(
       '#type' => 'checkbox',
       '#title' => t('Filter aggregates displayed'),
-      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of '.$this->view->base_table.' records.'),
-      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,    
+      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of %base_table records.', array('%base_table' => $this->view->base_table)),
+      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,
     );
-    
+
   }
-  
+
   /**
    * If the table to be filtered is not aggregated uses the parent::query()
    * However, if it is uses postgresql any() function to compare
    */
   function query () {
     $this->ensure_my_table();
-    
-    
+
+
     $table = $this->query->get_table_info($this->table);
     if (preg_match('/aggregator/',$table['join']->definition['handler'])) {
       $this->aggregated = TRUE;
@@ -63,13 +71,13 @@ class chado_views_handler_filter_float extends views_handler_filter_float {
       }
 
       // To restrict the items in the aggregate...
-      // Tell the join handler about the filter 
+      // Tell the join handler about the filter
       // so it can be done in the join query
       if ($this->options['agg']['aggregates_with']) {
         $table['join']->filter[] = $field ." = '". $this->value."'";
-      }    
+      }
     }
-    
+
   }
-  
+
 }

+ 30 - 20
tripal_views/views/handlers/chado_views_handler_filter_numeric.inc

@@ -1,5 +1,13 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_filter_numeric.
+ *
+ * Handles fields which may be aggregated during the chado join process. There are options
+ * to filter the base table based on an aggregated table or just filter the aggregated
+ * table (showing blank for that field if there are no records in the aggregated table).
+ */
 class chado_views_handler_filter_numeric extends views_handler_filter_numeric {
 
   /**
@@ -10,48 +18,50 @@ class chado_views_handler_filter_numeric extends views_handler_filter_numeric {
       '#type' => 'item',
       '#value' => '<b>If this filter applies to a table that is aggregated, additionally options may be ignored.</b>'
     );
-    
+
     parent::options_form($form, $form_state);
-    
+
     $form['agg'] = array(
       '#type' => 'fieldset',
       '#title' => 'Apply to fields that are aggregated'
     );
-    
+
     $form['agg']['records_with'] = array(
       '#type' => 'checkbox',
       '#title' => t('Filter base table records'),
-      '#description' => t('Filters '.$this->view->base_table.' to only those with the value in the aggregate array.'),
+      '#description' => t('Filters %base_table to only those with the value in the aggregate array.', array('%base_table' => $this->view->base_table)),
       '#default_value' => (isset($this->options['records_with'])) ? $this->options['records_with'] : TRUE,
     );
-    
+
     $form['agg']['aggregates_with'] = array(
       '#type' => 'checkbox',
       '#title' => t('Filter aggregates displayed'),
-      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of '.$this->view->base_table.' records.'),
-      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,    
+      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of %base_table records.', array('%base_table' => $this->view->base_table)),
+      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,
     );
-    
+
   }
-  
+
   /**
    * If the table to be filtered is not aggregated uses the parent::query()
    * However, if it is uses postgresql any() function to compare
    */
-  function query () {
+  function query() {
     $this->ensure_my_table();
-    
-    
+
+
     $table = $this->query->get_table_info($this->table);
-    if (preg_match('/aggregator/',$table['join']->definition['handler'])) {
+    if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
       $this->aggregated = TRUE;
-    } else {
+    }
+    else {
       $this->aggregated = FALSE;
     }
 
     if (!$this->aggregated) {
       parent::query();
-    } else {
+    }
+    else {
 
       // Only base records with value in the aggregated field
       // This doesn't restrict the items in the aggregate field
@@ -63,13 +73,13 @@ class chado_views_handler_filter_numeric extends views_handler_filter_numeric {
       }
 
       // To restrict the items in the aggregate...
-      // Tell the join handler about the filter 
+      // Tell the join handler about the filter
       // so it can be done in the join query
       if ($this->options['agg']['aggregates_with']) {
-        $table['join']->filter[] = $field ." = '". $this->value."'";
-      }    
+        $table['join']->filter[] = $field . " = '" . $this->value . "'";
+      }
     }
-    
+
   }
-  
+
 }

+ 23 - 15
tripal_views/views/handlers/chado_views_handler_filter_string.inc

@@ -1,5 +1,13 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_filter_string.
+ *
+ * Handles fields which may be aggregated during the chado join process. There are options
+ * to filter the base table based on an aggregated table or just filter the aggregated
+ * table (showing blank for that field if there are no records in the aggregated table).
+ */
 class chado_views_handler_filter_string extends views_handler_filter_string {
 
   /**
@@ -10,38 +18,38 @@ class chado_views_handler_filter_string extends views_handler_filter_string {
       '#type' => 'item',
       '#value' => '<b>If this filter applies to a table that is aggregated, additionally options may be ignored.</b>'
     );
-    
+
     parent::options_form($form, $form_state);
-    
+
     $form['agg'] = array(
       '#type' => 'fieldset',
       '#title' => 'Apply to fields that are aggregated'
     );
-    
+
     $form['agg']['records_with'] = array(
       '#type' => 'checkbox',
       '#title' => t('Filter base table records'),
-      '#description' => t('Filters '.$this->view->base_table.' to only those with the value in the aggregate array.'),
+      '#description' => t('Filters %base_table to only those with the value in the aggregate array.', array('%base_table' => $this->view->base_table)),
       '#default_value' => (isset($this->options['records_with'])) ? $this->options['records_with'] : TRUE,
     );
-    
+
     $form['agg']['aggregates_with'] = array(
       '#type' => 'checkbox',
       '#title' => t('Filter aggregates displayed'),
-      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of '.$this->view->base_table.' records.'),
-      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,    
+      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of %base_table records.', array('%base_table' => $this->view->base_table)),
+      '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,
     );
-    
+
   }
-  
+
   /**
    * If the table to be filtered is not aggregated uses the parent::query()
    * However, if it is uses postgresql any() function to compare
    */
   function query () {
     $this->ensure_my_table();
-    
-    
+
+
     $table = $this->query->get_table_info($this->table);
     if (preg_match('/aggregator/',$table['join']->definition['handler'])) {
       $this->aggregated = TRUE;
@@ -63,13 +71,13 @@ class chado_views_handler_filter_string extends views_handler_filter_string {
       }
 
       // To restrict the items in the aggregate...
-      // Tell the join handler about the filter 
+      // Tell the join handler about the filter
       // so it can be done in the join query
       if ($this->options['agg']['aggregates_with']) {
         $table['join']->filter[] = $field ." = '". $this->value."'";
-      }    
+      }
     }
-    
+
   }
-  
+
 }

+ 16 - 8
tripal_views/views/handlers/chado_views_handler_sort.inc

@@ -1,12 +1,20 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_sort.
+ *
+ * Handles fields which may be aggregated during the chado join process. Sorting of
+ * aggregated fields required PostgreSQL 9.0 due to postgresql limitations. Sorting of
+ * non-aggregated fields works for all PostgreSQL versions.
+ */
 class chado_views_handler_sort extends views_handler_sort {
 
   /**
    * Defines the options form (form available to admin when they add a field to a view)
    */
   function options_form(&$form, &$form_state) {
-    
+
     $form['msg'] = array(
       '#type' => 'item',
       '#value' => '<b>Sorting of aggregated fields only works for PostgreSQL 9.0+. This is due to lack of support at the database level. With lower postgreSQL versions, no sorting is applied.</b>'
@@ -14,13 +22,13 @@ class chado_views_handler_sort extends views_handler_sort {
 
     parent::options_form($form, $form_state);
   }
-  
+
   /**
    * Adds the sort to the query only if the field isn't aggregated
    * If the field is aggregated then the sort has to be applied at the join handler level
    */
   function query () {
-    
+
     // Determine if the current field is part of an aggregated table
     $table = $this->query->get_table_info($this->table);
     if (preg_match('/aggregator/',$table['join']->definition['handler'])) {
@@ -28,7 +36,7 @@ class chado_views_handler_sort extends views_handler_sort {
     } else {
       $this->aggregated = FALSE;
     }
-    
+
     // One day when the aggregated sort will work (ie: Postgresql 9.0+)
     // it will need to be applied in join handler
     // thus tell join handler about the sort
@@ -37,13 +45,13 @@ class chado_views_handler_sort extends views_handler_sort {
       'field' => $this->options['field'],
       'order' => $this->options['order']
     );
-    
-    
+
+
     // if not then add the sort
     if (!$this->aggregated) {
       parent::query();
     }
-    
+
   }
-  
+
 }

+ 16 - 8
tripal_views/views/handlers/chado_views_handler_sort_date.inc

@@ -1,12 +1,20 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_sort_date.
+ *
+ * Handles fields which may be aggregated during the chado join process. Sorting of
+ * aggregated fields required PostgreSQL 9.0 due to postgresql limitations. Sorting of
+ * non-aggregated fields works for all PostgreSQL versions.
+ */
 class chado_views_handler_sort extends views_handler_sort_date {
 
   /**
    * Defines the options form (form available to admin when they add a field to a view)
    */
   function options_form(&$form, &$form_state) {
-    
+
     $form['msg'] = array(
       '#type' => 'item',
       '#value' => '<b>Sorting of aggregated fields only works for PostgreSQL 9.0+. This is due to lack of support at the database level. With lower postgreSQL versions, no sorting is applied.</b>'
@@ -14,13 +22,13 @@ class chado_views_handler_sort extends views_handler_sort_date {
 
     parent::options_form($form, $form_state);
   }
-  
+
   /**
    * Adds the sort to the query only if the field isn't aggregated
    * If the field is aggregated then the sort has to be applied at the join handler level
    */
   function query () {
-    
+
     // Determine if the current field is part of an aggregated table
     $table = $this->query->get_table_info($this->table);
     if (preg_match('/aggregator/',$table['join']->definition['handler'])) {
@@ -28,7 +36,7 @@ class chado_views_handler_sort extends views_handler_sort_date {
     } else {
       $this->aggregated = FALSE;
     }
-    
+
     // One day when the aggregated sort will work (ie: Postgresql 9.0+)
     // it will need to be applied in join handler
     // thus tell join handler about the sort
@@ -37,13 +45,13 @@ class chado_views_handler_sort extends views_handler_sort_date {
       'field' => $this->options['field'],
       'order' => $this->options['order']
     );
-    
-    
+
+
     // if not then add the sort
     if (!$this->aggregated) {
       parent::query();
     }
-    
+
   }
-  
+
 }

+ 16 - 8
tripal_views/views/handlers/chado_views_handler_sort_formula.inc

@@ -1,12 +1,20 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_sort_formula.
+ *
+ * Handles fields which may be aggregated during the chado join process. Sorting of
+ * aggregated fields required PostgreSQL 9.0 due to postgresql limitations. Sorting of
+ * non-aggregated fields works for all PostgreSQL versions.
+ */
 class chado_views_handler_sort extends views_handler_sort_formula {
 
   /**
    * Defines the options form (form available to admin when they add a field to a view)
    */
   function options_form(&$form, &$form_state) {
-    
+
     $form['msg'] = array(
       '#type' => 'item',
       '#value' => '<b>Sorting of aggregated fields only works for PostgreSQL 9.0+. This is due to lack of support at the database level. With lower postgreSQL versions, no sorting is applied.</b>'
@@ -14,13 +22,13 @@ class chado_views_handler_sort extends views_handler_sort_formula {
 
     parent::options_form($form, $form_state);
   }
-  
+
   /**
    * Adds the sort to the query only if the field isn't aggregated
    * If the field is aggregated then the sort has to be applied at the join handler level
    */
   function query () {
-    
+
     // Determine if the current field is part of an aggregated table
     $table = $this->query->get_table_info($this->table);
     if (preg_match('/aggregator/',$table['join']->definition['handler'])) {
@@ -28,7 +36,7 @@ class chado_views_handler_sort extends views_handler_sort_formula {
     } else {
       $this->aggregated = FALSE;
     }
-    
+
     // One day when the aggregated sort will work (ie: Postgresql 9.0+)
     // it will need to be applied in join handler
     // thus tell join handler about the sort
@@ -37,13 +45,13 @@ class chado_views_handler_sort extends views_handler_sort_formula {
       'field' => $this->options['field'],
       'order' => $this->options['order']
     );
-    
-    
+
+
     // if not then add the sort
     if (!$this->aggregated) {
       parent::query();
     }
-    
+
   }
-  
+
 }

+ 16 - 8
tripal_views/views/handlers/chado_views_handler_sort_menu_hierarchy.inc

@@ -1,12 +1,20 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_sort_menu_hierarchy.
+ *
+ * Handles fields which may be aggregated during the chado join process. Sorting of
+ * aggregated fields required PostgreSQL 9.0 due to postgresql limitations. Sorting of
+ * non-aggregated fields works for all PostgreSQL versions.
+ */
 class chado_views_handler_sort extends views_handler_sort_menu_hierarchy {
 
   /**
    * Defines the options form (form available to admin when they add a field to a view)
    */
   function options_form(&$form, &$form_state) {
-    
+
     $form['msg'] = array(
       '#type' => 'item',
       '#value' => '<b>Sorting of aggregated fields only works for PostgreSQL 9.0+. This is due to lack of support at the database level. With lower postgreSQL versions, no sorting is applied.</b>'
@@ -14,13 +22,13 @@ class chado_views_handler_sort extends views_handler_sort_menu_hierarchy {
 
     parent::options_form($form, $form_state);
   }
-  
+
   /**
    * Adds the sort to the query only if the field isn't aggregated
    * If the field is aggregated then the sort has to be applied at the join handler level
    */
   function query () {
-    
+
     // Determine if the current field is part of an aggregated table
     $table = $this->query->get_table_info($this->table);
     if (preg_match('/aggregator/',$table['join']->definition['handler'])) {
@@ -28,7 +36,7 @@ class chado_views_handler_sort extends views_handler_sort_menu_hierarchy {
     } else {
       $this->aggregated = FALSE;
     }
-    
+
     // One day when the aggregated sort will work (ie: Postgresql 9.0+)
     // it will need to be applied in join handler
     // thus tell join handler about the sort
@@ -37,13 +45,13 @@ class chado_views_handler_sort extends views_handler_sort_menu_hierarchy {
       'field' => $this->options['field'],
       'order' => $this->options['order']
     );
-    
-    
+
+
     // if not then add the sort
     if (!$this->aggregated) {
       parent::query();
     }
-    
+
   }
-  
+
 }

+ 16 - 8
tripal_views/views/handlers/chado_views_handler_sort_random.inc

@@ -1,12 +1,20 @@
 <?php
 
+/**
+ * @file
+ * A chado wrapper for the views_handler_sort_random.
+ *
+ * Handles fields which may be aggregated during the chado join process. Sorting of
+ * aggregated fields required PostgreSQL 9.0 due to postgresql limitations. Sorting of
+ * non-aggregated fields works for all PostgreSQL versions.
+ */
 class chado_views_handler_sort extends views_handler_sort_random {
 
   /**
    * Defines the options form (form available to admin when they add a field to a view)
    */
   function options_form(&$form, &$form_state) {
-    
+
     $form['msg'] = array(
       '#type' => 'item',
       '#value' => '<b>Sorting of aggregated fields only works for PostgreSQL 9.0+. This is due to lack of support at the database level. With lower postgreSQL versions, no sorting is applied.</b>'
@@ -14,13 +22,13 @@ class chado_views_handler_sort extends views_handler_sort_random {
 
     parent::options_form($form, $form_state);
   }
-  
+
   /**
    * Adds the sort to the query only if the field isn't aggregated
    * If the field is aggregated then the sort has to be applied at the join handler level
    */
   function query () {
-    
+
     // Determine if the current field is part of an aggregated table
     $table = $this->query->get_table_info($this->table);
     if (preg_match('/aggregator/',$table['join']->definition['handler'])) {
@@ -28,7 +36,7 @@ class chado_views_handler_sort extends views_handler_sort_random {
     } else {
       $this->aggregated = FALSE;
     }
-    
+
     // One day when the aggregated sort will work (ie: Postgresql 9.0+)
     // it will need to be applied in join handler
     // thus tell join handler about the sort
@@ -37,13 +45,13 @@ class chado_views_handler_sort extends views_handler_sort_random {
       'field' => $this->options['field'],
       'order' => $this->options['order']
     );
-    
-    
+
+
     // if not then add the sort
     if (!$this->aggregated) {
       parent::query();
     }
-    
+
   }
-  
+
 }

+ 17 - 12
tripal_views/views/handlers/chado_wrapper_functions.inc

@@ -1,5 +1,10 @@
 <?php
 
+/**
+ * @file
+ * A collection of functions used for the chado wrapper views handlers
+ */
+
 /**
  * Splits an SQL array of results in a single field
  * into a php array
@@ -13,7 +18,7 @@ function chado_wrapper_split_array_agg_results($handler, &$values) {
 
   if ($handler->aggregated) {
     foreach($values as $k => $v) {
-      
+
       if(preg_match('/^{(.*)}$/',$v->{$handler->field_alias}, $matches)) {
         $values[$k]->{$handler->field_alias} = str_getcsv($matches[1]);
       } else {
@@ -21,7 +26,7 @@ function chado_wrapper_split_array_agg_results($handler, &$values) {
       }
     }
   }
-  
+
   return $values;
 }
 
@@ -36,12 +41,12 @@ function chado_wrapper_split_array_agg_results($handler, &$values) {
  */
 function chado_wrapper_is_aggregated_by_join ($handler) {
   $aggregated = FALSE;
-  
+
   $table = $handler->query->get_table_info($handler->table);
   if (preg_match('/aggregator/',$table['join']->definition['handler'])) {
     $aggregated = TRUE;
   }
-  
+
   return $aggregated;
 }
 
@@ -58,22 +63,22 @@ function chado_wrapper_is_aggregated_by_join ($handler) {
  */
 function chado_wrapper_is_aggregated_by_result ($handler, $values) {
   $aggregated = FALSE;
-  
+
   if (preg_match('/^{.*}$/',$values[0]->{$handler->field_alias})) {
     $aggregated = TRUE;
   }
-  
+
   return $aggregated;
 }
 
 function chado_wrapper_render_items($handler, $values) {
 
-  // If it's aggregated (an array), then render each part 
+  // If it's aggregated (an array), then render each part
   // using the parent render functionality
   if ($handler->aggregated) {
-    
+
     $items = array();
-    
+
     $parts = $values->{$handler->field_alias};
     foreach ($parts as $p) {
       $v[ $handler->field_alias ] = $p;
@@ -81,17 +86,17 @@ function chado_wrapper_render_items($handler, $values) {
       $items[] = $handler->parent_render($val);
       unset($v, $val);
     }
-    
+
     if ($handler->options['type'] == 'separator') {
       return implode(check_plain($handler->options['separator']), $items);
     }
     else {
       return theme('item_list', $items, NULL, $handler->options['type']);
     }
-    
+
   // Otherwise it is not aggragated
   // Just render like the default handler would
   } else {
     return $handler->parent_render($values);
-  }      
+  }
 }

+ 13 - 13
tripal_views/views/handlers/views_handler_field_chado_count.inc

@@ -1,10 +1,10 @@
 <?php
- 
+
 /**
  * Purpose: Provide a field that counts the number of records in the current table
  *   are connected to the base table. For example, this field could be used to count
- *   the number of features connected to a given organism -base table=organism, 
- *   current table=feature: for each record in the organism view count feature records where 
+ *   the number of features connected to a given organism -base table=organism,
+ *   current table=feature: for each record in the organism view count feature records where
  *   feature.organism_id=organism_id of current organism record
  *
  * @ingroup views_field_handlers
@@ -14,25 +14,25 @@ class views_handler_field_chado_count extends views_handler_field {
 
   function init(&$view, $options) {
     parent::init($view, $options);
-    
+
     // the table to query is required
     // check that it was provided in the field definition and if not warn
     if ($this->definition['table_to_query']) {
       $this->aliases['current_table'] = $this->definition['table_to_query'];
     } else {
-      drupal_set_message("The field definition ( in hook_views_data() ) needs to specify the 'table_to_query' in order for this fields to work. Field:".$this->field." in the ".$this->table." table definition", 'error');
+      drupal_set_message(t("The field definition ( in hook_views_data() ) needs to specify the 'table_to_query' in order for this fields to work. Field:%field in the %table table definition"), array('%field' => $this->field, '%table' => $this->table), 'error');
     }
-    
+
     // set aliases
     $this->aliases['primary_id'] = $this->table . '_id';
     $this->aliases['foreign_key'] = $this->table . '_id';
   }
-  
+
   //Needed to ensure that the name of this field is not added to the query
   function query() {
     $this->add_additional_fields();
   }
-  
+
   function pre_render(&$values) {
     // Render nothing if the current table wasn't set in the field definition
     if(!$this->aliases['current_table']) {
@@ -41,23 +41,23 @@ class views_handler_field_chado_count extends views_handler_field {
 
     foreach ($values as $key => $record) {
       $primary_id = $record->{$this->aliases['primary_id']};
-      
+
       //Select count from database
       $sql = 'SELECT count(*) as count FROM %s WHERE %s=%d';
       $previous_db = tripal_db_set_active('chado');
       $result = db_fetch_object(db_query(
-        $sql, 
-        $this->aliases['current_table'], 
+        $sql,
+        $this->aliases['current_table'],
         $this->aliases['foreign_key'],
         $primary_id
       ));
       tripal_db_set_active($previous_db);
-      
+
       //Add to view results
       $this->view->result[$key]->{$this->field} = $result->count;
     }
   }
-  
+
   function render($values) {
     return $values->{$this->field};
   }

+ 7 - 7
tripal_views/views/handlers/views_handler_filter_file_upload.inc

@@ -17,21 +17,21 @@ class views_handler_filter_file_upload extends views_handler_filter {
     parent::options_form($form, $form_state);
 
   }
-  
+
   /**
   * Defines the value field in both the views filter options form
   *   and the exposed form
   */
   function value_form(&$form, &$form_state) {
     parent::value_form($form, $form_state);
-    
+
     $this->value_form = array(
        '#type' => 'file_upload_combo',
        '#title' => $this->options['expose']['label'],
        '#default_value' => $this->value,
        '#multiple' => FALSE,
-       '#description' => t('Provide search values for ' . $this->options['expose']['label'] . 
-         '. Please place each search item on a separate line or separated by commas.'),
+       '#description' => t('Provide search values for %label. Please place each search
+        item on a separate line or separated by commas.', array('%label' => $this->options['expose']['label'])),
     );
     $form['value'] = &$this->value_form;
   }
@@ -46,7 +46,7 @@ class views_handler_filter_file_upload extends views_handler_filter {
     if (empty($this->options['exposed'])) {
       return;
     }
-    // rebuild the form elements 
+    // rebuild the form elements
     $value = $this->options['expose']['identifier'];
     $this->value_form($form, $form_state);
 
@@ -64,7 +64,7 @@ class views_handler_filter_file_upload extends views_handler_filter {
     }
 
   }
-  /** 
+  /**
    *  Validates the input form
    */
   function exposed_validate(&$form, &$form_state) {
@@ -102,7 +102,7 @@ class views_handler_filter_file_upload extends views_handler_filter {
            $vals = preg_split("/[\n,]+/",$items);
            $values = array_merge($values,$vals);
         }
-     } 
+     }
      // if a file upload has not been provided then use the value in the textarea
      if($items){
 

+ 0 - 84
tripal_views/views/template.node_join.views.inc

@@ -1,84 +0,0 @@
-<?php
-
-/*************************************************************************
- * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
- *
- *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
- *    (ie: If you want to join features to their drupal nodes then XXX=feature)
- * 
- *  NOTE: Creating the table definition file is not enough. You also need to call the 
- *        retrieve_XXX_views_data() function from ../tripal_core.views.inc:tripal_core_views_data()
- *        by adding the following line:
- *           $data = array_merge($data, retrieve_XXX_views_data());
- *        to the function and including the file directly above the function (blow the function 
- *        header by adding:
- *           require_once('views/XXX.views.inc');
- *
- *  REMOVE THIS COMMENT IN THE COPY!
- */ 
- 
-/**
- *  @file
- *  This file defines the data array for a given chado table. This array
- *  is merged into a larger array containing definitions of all tables associated
- *  with this module in:
- *  @see tripal_core.views.inc --in tripal_core_views_data()
- *
- *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
- *        This file simply defines this linking table and joins the three tables together.
- *        No modification of XXX.views.inc is needed.
- *
- *  Documentation on views integration can be found at 
- *  http://views2.logrus.com/doc/html/index.html.
- */
- 
-/**
- * Purpose: this function returns the portion of the data array 
- *   which describes the chado_XXX drupal table, it's fields and any joins between it 
- *   and other tables
- * @see tripal_core_views_data() --in tripal_core.views.inc
- *
- * The main need for description of this table to views is to join chado data with drupal nodes
- *
- */
-function retrieve_chado_XXX_views_data () {
-	global $db_url;
-  $data = array();
-  
-  // if the chado database is not local to the drupal database
-  // then we need to set the database name.  This should always
-  // be 'chado'.
-  if(is_array($db_url) and array_key_exists('chado',$db_url)){
-     // return empty data array b/c if chado is external then no join to the nodetable can be made
-     return $data;
-  }
-
-  //Basic table definition-----------------------------------
-  $data['chado_XXX']['table'] = array(
-    'field' => 'nid',
-  );
-  
-  //Relationship Definitions---------------------------------
-  // Note: No joins need to be made from $data['XXX']['table']
-  
-  // Join the chado_XXX table to XXX
-  $data['chado_XXX']['table']['join']['XXX'] = array(
-  	'left_field' => 'XXX_id',
-  	'field' => 'XXX_id',
-  );
-  
-  // Join the node table to chado_XXX
-  $data['node']['table']['join']['chado_XXX'] = array(
-  	'left_field' => 'nid',
-  	'field' => 'nid',
-  );
-  
-  // Join the node table to XXX
-  $data['node']['table']['join']['XXX'] = array(
-  	'left_table' => 'chado_XXX',
-  	'left_field' => 'nid',
-  	'field' => 'nid',
-  );  
-
-	return $data;
-}

+ 0 - 211
tripal_views/views/template.table_defn.views.inc

@@ -1,211 +0,0 @@
-<?php
-
-/*************************************************************************
- * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE
- *
- *   - Every instance of XXX should be replaced with the name of your table
- *   - If this is a base table (you want a view where every row is a row from this table)
- *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
- *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
- *   - Relationships between this table and others: YYY is the table you are trying to join to this
- *     one. You want to join a table to this one if this table contains a foreign key to the other
- *     table. If the join between this table and another is through a linking table
- *     (ie: library-XXX/YYY => library_feature-XY => feature-XXX/YYY) then make the join in both
- *     directions (ie: in the file XXX.views.inc and the file YYY.views.inc
- *   - Create a field definition for each field in this table using the example fields already
- *     listed. Match the type of the database field to the field definition listed below.
- *     (ie: for a text/varchar field from the database use plain_text_field below)
- * 
- *  NOTE: Creating the table definition file is not enough. You also need to call the 
- *        retrieve_XXX_views_data() function from ../tripal_core.views.inc:tripal_core_views_data()
- *        by adding the following line:
- *           $data = array_merge($data, retrieve_XXX_views_data());
- *        to the function and including the file directly above the function (blow the function 
- *        header by adding:
- *           require_once('views/XXX.views.inc');
- *
- *  REMOVE THIS COMMENT IN THE COPY!
- */ 
- 
-/**
- *  @file
- *  This file defines the data array for a given chado table. This array
- *  is merged into a larger array containing definitions of all tables associated
- *  with this module in:
- *  @see tripal_core.views.inc --in tripal_core_views_data()
- *
- *  Documentation on views integration can be found at 
- *  http://views2.logrus.com/doc/html/index.html.
- */
-
-/*************************************************************************
- * Purpose: this function returns the portion of the data array 
- *   which describes the XXX table, it's fields and any joins between it and other tables
- * @see tripal_core_views_data() --in tripal_core.views.inc
- *
- * Table: XXX
- * @code
- * XXX-Copy/Paste Table SQL code here-XXX
- * @endcode
- */
- function retrieve_XXX_views_data() {
-  global $db_url;
-  $data = array();
-
-  // if the chado database is not local to the drupal database
-  // then we need to set the database name.  This should always
-  // be 'chado'.
-  if(is_array($db_url) and array_key_exists('chado',$db_url)){
-    $database = 'chado';
-  }
-   
-  //Basic table definition-----------------------------------
-  $data['XXX']['table']['group'] = t('Chado XXX');
-  
-  $data['XXX']['table'] = array(
-    'field' => 'primary_id',
-    'title' => t('Chado XXX'),
-    'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
-  );
-  if($database){
-     $data['XXX']['table']['database'] = $database;
-  }
-
-  
-  //Relationship Definitions---------------------------------
-  //Join: YYY => XXX
-  // Notice that this relationship tells the primary table to show it's fields to the
-  // table referencing it by a foreign key and thus the relationship is from
-  // primary table to table referenceing it (ie: cvterm => feature)
-  $data['XXX']['table']['join']['YYY'] = array(
-    'left_field' => 'foreign key in YYY table',
-    'field' => 'primary key in XXX table',
-  );  
-  
-  //Join: XXX => XY => YYY
-  // This relationship should be described in both directions
-  // in the appropriate files (ie: for feature => library 
-  // describe in both feature.views.inc and library.views.inc)
-  $data['XXX']['table']['join']['XY'] = array(
-    'left_field' => 'matching XXX key in the XY table',
-    'field' => 'primary key in XXX table',
-  );  
-  $data['XXX']['table']['join']['YYY'] = array(
-    'left_table' => 'XY',
-    'left_field' => 'matching XXX key in the XY table',
-    'field' => 'primary key in XXX table',
-  );
-  $data['XY']['table']['join']['YYY'] = array(
-    'left_field' => 'primary key in YYY table',
-    'field' => 'matching YYY key in the XY table',
-  );
-   
-  //Table Field Definitions----------------------------------
-      
-  //Field: XXX_id (primary key)
-  $data['XXX']['field_name'] = array(
-    'title' => t('XXX Primary Key'),
-    'help' => t('A unique index for every XXX.'),
-    'field' => array(
-      'handler' => 'views_handler_field_numeric',
-      'click sortable' => TRUE,
-     ),
-    'sort' => array(
-      'handler' => 'views_handler_sort',
-    ),
-    'filter' => array(
-      'handler' => 'views_handler_filter_numeric',
-    ),
-  );
-
-  /*.......................................................
-   * Beginning of Example Field definitions
-   * Remove this section when done
-   */
-
-  //Field: plain_text_field (chado datatype)   
-  $data['XXX']['plain_text_field'] = array(
-    'title' => t('Human-Readable Name'),
-    'help' => t('Description of this field.'),
-    'field' => array(
-      'handler' => 'views_handler_field',
-      'click sortable' => TRUE,
-     ),
-    'sort' => array(
-      'handler' => 'views_handler_sort',
-    ),
-    'filter' => array(
-      'handler' => 'views_handler_filter_string',
-    ),
-    'argument' => array(
-      'handler' => 'views_handler_argument_string',
-    ),
-  );
-
-  //Field: numeric_field (chado datatype)   
-  $data['XXX']['numeric_field'] = array(
-    'title' => t('Human-Readable Name'),
-    'help' => t('Description of this field.'),
-    'field' => array(
-      'handler' => 'views_handler_field_numeric',
-      'click sortable' => TRUE,
-     ),
-    'sort' => array(
-      'handler' => 'views_handler_sort',
-    ),
-    'filter' => array(
-      'handler' => 'views_handler_filter_numeric',
-    ),
-  );
-
-  //Field: boolean_field (chado datatype)   
-  $data['XXX']['boolean_field'] = array(
-    'title' => t('Human-Readable Name'),
-    'help' => t('Description of this field.'),
-    'field' => array(
-      'handler' => 'views_handler_field_boolean',
-      'click sortable' => TRUE,
-     ),
-    'sort' => array(
-      'handler' => 'views_handler_sort',
-    ),
-    'filter' => array(
-      'handler' => 'views_handler_filter_boolean_operator',
-    ),
-  );
-
-  //Field: unix_timestamp (chado datatype)   
-  $data['XXX']['unix_timestamp'] = array(
-    'title' => t('Human-Readable Name'),
-    'help' => t('Description of this field.'),
-    'field' => array(
-      'handler' => 'views_handler_field_date',
-      'click sortable' => TRUE,
-     ),
-    'sort' => array(
-      'handler' => 'views_handler_sort_date',
-    ),
-    'filter' => array(
-      'handler' => 'views_handler_filter_date',
-    ),
-  );
-
-  //Field: human_readable_date (chado datatype)   
-  $data['XXX']['human_readable_date'] = array(
-    'title' => t('Human-Readable Name'),
-    'help' => t('Description of this field.'),
-    'field' => array(
-      'handler' => 'views_handler_field_readble_date',
-      'click sortable' => TRUE,
-     ),
-    'sort' => array(
-      'handler' => 'views_handler_sort_date',
-    ),
-  );
-   
-   /*
-    * End of Example Field definitions
-    */
-    
-  return $data;
-}