Browse Source

Tripal Natural Diversity aheres to Drupal coding standards

Pubudu Basnayaka 13 years ago
parent
commit
c522f5d8d7

+ 64 - 64
tripal_natural_diversity/tripal_natural_diversity.api.inc

@@ -1,8 +1,8 @@
 <?php
 
-function tripal_natural_diversity_chado_nd_experiment_schema () {
+function tripal_natural_diversity_chado_nd_experiment_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment',
     'fields' => array(
@@ -48,13 +48,13 @@ function tripal_natural_diversity_chado_nd_experiment_schema () {
       'nd_experimentprop'
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_contact_schema () {
+function tripal_natural_diversity_chado_nd_experiment_contact_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_contact',
     'fields' => array(
@@ -92,13 +92,13 @@ function tripal_natural_diversity_chado_nd_experiment_contact_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_dbxref_schema () {
+function tripal_natural_diversity_chado_nd_experiment_dbxref_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_dbxref',
     'fields' => array(
@@ -136,13 +136,13 @@ function tripal_natural_diversity_chado_nd_experiment_dbxref_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_genotype_schema () {
+function tripal_natural_diversity_chado_nd_experiment_genotype_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_genotype',
     'fields' => array(
@@ -180,13 +180,13 @@ function tripal_natural_diversity_chado_nd_experiment_genotype_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_phenotype_schema () {
+function tripal_natural_diversity_chado_nd_experiment_phenotype_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_phenotype',
     'fields' => array(
@@ -224,13 +224,13 @@ function tripal_natural_diversity_chado_nd_experiment_phenotype_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_project_schema () {
+function tripal_natural_diversity_chado_nd_experiment_project_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_project',
     'fields' => array(
@@ -268,13 +268,13 @@ function tripal_natural_diversity_chado_nd_experiment_project_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_protocol_schema () {
+function tripal_natural_diversity_chado_nd_experiment_protocol_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_protocol',
     'fields' => array(
@@ -312,13 +312,13 @@ function tripal_natural_diversity_chado_nd_experiment_protocol_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_pub_schema () {
+function tripal_natural_diversity_chado_nd_experiment_pub_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_pub',
     'fields' => array(
@@ -356,13 +356,13 @@ function tripal_natural_diversity_chado_nd_experiment_pub_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_stock_schema () {
+function tripal_natural_diversity_chado_nd_experiment_stock_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_stock',
     'fields' => array(
@@ -411,13 +411,13 @@ function tripal_natural_diversity_chado_nd_experiment_stock_schema () {
       'nd_experiment_stockprop',
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_stockprop_schema () {
+function tripal_natural_diversity_chado_nd_experiment_stockprop_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_stockprop',
     'fields' => array(
@@ -462,13 +462,13 @@ function tripal_natural_diversity_chado_nd_experiment_stockprop_schema () {
     'referring_tables' => array(
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_stock_dbxref_schema () {
+function tripal_natural_diversity_chado_nd_experiment_stock_dbxref_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_stock_dbxref',
     'fields' => array(
@@ -506,13 +506,13 @@ function tripal_natural_diversity_chado_nd_experiment_stock_dbxref_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experimentprop_schema () {
+function tripal_natural_diversity_chado_nd_experimentprop_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experimentprop',
     'fields' => array(
@@ -557,13 +557,13 @@ function tripal_natural_diversity_chado_nd_experimentprop_schema () {
     'referring_tables' => array(
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_geolocation_schema () {
+function tripal_natural_diversity_chado_nd_geolocation_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_reagent',
     'fields' => array(
@@ -595,13 +595,13 @@ function tripal_natural_diversity_chado_nd_geolocation_schema () {
       'nd_geolocationprop'
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_geolocationprop_schema () {
+function tripal_natural_diversity_chado_nd_geolocationprop_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_geolocationprop',
     'fields' => array(
@@ -646,13 +646,13 @@ function tripal_natural_diversity_chado_nd_geolocationprop_schema () {
     'referring_tables' => array(
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_protocol_schema () {
+function tripal_natural_diversity_chado_nd_protocol_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_protocol',
     'fields' => array(
@@ -671,23 +671,23 @@ function tripal_natural_diversity_chado_nd_protocol_schema () {
     'referring_tables' => array(
       'nd_experiment_protocol',
       'nd_protocol_reagent',
-      'nd_protocolprop'  
+      'nd_protocolprop'
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_protocol_reagent_schema () {
+function tripal_natural_diversity_chado_nd_protocol_reagent_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_protocol_reagent',
     'fields' => array(
       'nd_protocol_reagent_id' => array(
         'type' => 'serial',
         'not null' => 1,
-      ),    
+      ),
       'nd_protocol_id' => array(
         'type' => 'int',
         'not null' => 1,
@@ -702,7 +702,7 @@ function tripal_natural_diversity_chado_nd_protocol_reagent_schema () {
       ),
     ),
     'primary key' => array(
-      '0' => 'nd_protocol_reagent_id',   
+      '0' => 'nd_protocol_reagent_id',
     ),
     'foreign keys' => array(
       'nd_protocol' => array(
@@ -725,16 +725,16 @@ function tripal_natural_diversity_chado_nd_protocol_reagent_schema () {
       ),
     ),
     'referring_tables' => array(
-    
+
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_protocolprop_schema () {
+function tripal_natural_diversity_chado_nd_protocolprop_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_protocolprop',
     'fields' => array(
@@ -779,13 +779,13 @@ function tripal_natural_diversity_chado_nd_protocolprop_schema () {
     'referring_tables' => array(
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_reagent_schema () {
+function tripal_natural_diversity_chado_nd_reagent_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_reagent',
     'fields' => array(
@@ -819,13 +819,13 @@ function tripal_natural_diversity_chado_nd_reagent_schema () {
       ),
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_reagent_relationship_schema () {
+function tripal_natural_diversity_chado_nd_reagent_relationship_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_reagent_relationship',
     'fields' => array(
@@ -865,13 +865,13 @@ function tripal_natural_diversity_chado_nd_reagent_relationship_schema () {
       ),
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_reagentprop_schema () {
+function tripal_natural_diversity_chado_nd_reagentprop_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_reagentprop',
     'fields' => array(
@@ -916,6 +916,6 @@ function tripal_natural_diversity_chado_nd_reagentprop_schema () {
     'referring_tables' => array(
     ),
   );
-  
+
   return $description;
 }

+ 11 - 10
tripal_natural_diversity/tripal_natural_diversity.module

@@ -5,9 +5,9 @@ require_once('tripal_natural_diversity.api.inc');
 /**
  *  @file
  * This file contains the basic functions needed for this drupal module.
- * The drupal tripal_natural_diversity module maps directly to the chado X module. 
+ * The drupal tripal_natural_diversity module maps directly to the chado X module.
  *
- * For documentation regarding the Chado X module: 
+ * For documentation regarding the Chado X module:
  * @see http://gmod.org/wiki/Chado_General_Module
  */
 
@@ -16,7 +16,7 @@ require_once('tripal_natural_diversity.api.inc');
  * Purpose: Essentially this hook tells drupal that there is views support for
  *  for this module which then includes tripal_natural_diversity.views.inc where all the
  *  views integration code is
- */ 
+ */
 function tripal_natural_diversity_views_api() {
    return array(
       'api' => 2.0,
@@ -30,11 +30,11 @@ function tripal_natural_diversity_theme() {
   return array(
     'tripal_feature_genotype_experiments' => array(
       'arguments' => array('node' => NULL),
-      'template' => 'tripal_feature-genotype_experiments',      
+      'template' => 'tripal_feature-genotype_experiments',
     ),
     'tripal_stock_genotype_experiments' => array(
       'arguments' => array('node' => NULL),
-      'template' => 'tripal_feature-stock_experiments',      
+      'template' => 'tripal_feature-stock_experiments',
     ),
   );
 }
@@ -42,17 +42,18 @@ function tripal_natural_diversity_theme() {
 /**
  *
  */
-function tripal_natural_diversity_nodeapi (&$node, $op, $teaser, $page) {
+function tripal_natural_diversity_nodeapi(&$node, $op, $teaser, $page) {
   switch ($op) {
     case 'view':
       if ($node->type == 'chado_feature') {
         $node->content['tripal_feature_genotype_experiments'] = array(
            '#value' => theme('tripal_feature_genotype_experiments', $node),
-        );      
-      } elseif ($node->type == 'chado_stock') {
+        );
+      }
+      elseif ($node->type == 'chado_stock') {
         $node->content['tripal_stock_genotype_experiments'] = array(
            '#value' => theme('tripal_stock_genotype_experiments', $node),
-        );      
+        );
       }
   }
-}
+}

+ 11 - 11
tripal_natural_diversity/tripal_natural_diversity.views.inc

@@ -6,17 +6,17 @@
  *  chado/tripal_natural_diversity 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.
  */
- 
+
 /*************************************************************************
  * Implements hook_views_data()
  * Purpose: Describe chado/tripal tables & fields to views
  *
  * @return: 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)
  */
@@ -28,26 +28,26 @@ require_once('views/nd_reagent.views.inc');
 require_once('views/nd_reagentprop.views.inc');
 function tripal_natural_diversity_views_data()  {
   $data = array();
-  
+
   //EXPERIMENT
   $data = array_merge($data, retrieve_nd_experiment_views_data());
   $data = array_merge($data, retrieve_nd_experimentprop_views_data());
-  
+
   // GEOLOCATION
   $data = array_merge($data, retrieve_nd_geolocation_views_data());
   $data = array_merge($data, retrieve_nd_geolocationprop_views_data());
-  
+
   // REAGENTS
   $data = array_merge($data, retrieve_nd_reagent_views_data());
   $data = array_merge($data, retrieve_nd_reagentprop_views_data());
-  
+
   return $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: An array of handler definitions
@@ -58,12 +58,12 @@ function tripal_natural_diversity_views_handlers() {
      'path' => drupal_get_path('module', 'tripal_natural_diversity') . '/views/handlers',
    ),
    'handlers' => array(
-		'views_handler_field_chado_relationship_all' => array(
+  'views_handler_field_chado_relationship_all' => array(
        'parent' => 'views_handler_field_prerender_list',
      ),
-		'views_handler_field_chado_relationship_by_type' => array(
+  'views_handler_field_chado_relationship_by_type' => array(
        'parent' => 'views_handler_field_prerender_list',
      ),
    ),
  );
-}
+}

+ 72 - 70
tripal_natural_diversity/views/handlers/views_handler_field_chado_relationship_all.inc

@@ -14,87 +14,89 @@ class views_handler_field_chado_relationship_all extends views_handler_field_pre
     $this->add_additional_fields();
   }
 
-	function pre_render($values) {
-		$this->aliases['relationships'] = 'relationships';
-		$this->aliases['primary_id'] = $this->view->base_table.'_id';
-		$this->field_alias = $this->aliases['primary_id'];
-		$relationship_tablename = $this->view->base_table.'_relationship';
-		$this->aliases['relationship_primary_id'] = $relationship_tablename . '_id';
-		$table_desc = module_invoke_all('chado_'.$relationship_tablename.'_schema');
-		foreach($table_desc['foreign keys'][$this->view->base_table]['columns'] as $k => $v) {
-		  if (preg_match('/subject/',$k)) { $subject_id = $k; }
-		  if (preg_match('/object/', $k)) { $object_id = $k; }
-		}
-		$this->aliases['subject_id'] = $subject_id;
-		$this->aliases['object_id'] = $object_id;
-		  
+  function pre_render($values) {
+    $this->aliases['relationships'] = 'relationships';
+    $this->aliases['primary_id'] = $this->view->base_table . '_id';
+    $this->field_alias = $this->aliases['primary_id'];
+    $relationship_tablename = $this->view->base_table . '_relationship';
+    $this->aliases['relationship_primary_id'] = $relationship_tablename . '_id';
+    $table_desc = module_invoke_all('chado_' . $relationship_tablename . '_schema');
+    foreach ($table_desc['foreign keys'][$this->view->base_table]['columns'] as $k => $v) {
+      if (preg_match('/subject/', $k)) {
+      $subject_id = $k;}
+      if (preg_match('/object/', $k)) {
+      $object_id = $k;}
+    }
+    $this->aliases['subject_id'] = $subject_id;
+    $this->aliases['object_id'] = $object_id;
+
     //Add values for all if possible
     if (!$this->view->result[0]->relationships) {
       //get base table primary keys
       $primary_ids = array();
-		  foreach ($this->view->result as $row_num => $row) {
-			  $primary_ids[$row_num] = $row->{$this->aliases['primary_id']};
-		  }
-		
-		  //generate results from db
-      $sql = "SELECT ".$relationship_tablename.".*, cvterm.name as type_name, "
-					."subject_parent.name as subject_name, object_parent.name as object_name "
-					."FROM ".$relationship_tablename." "
-					."LEFT JOIN ".$this->view->base_table." subject_parent ON "
-					  .$relationship_tablename.".".$subject_id."=subject_parent.".$this->aliases['primary_id']." "
-					."LEFT JOIN ".$this->view->base_table." object_parent ON "
-					  .$relationship_tablename.".".$object_id."=object_parent.".$this->aliases['primary_id']." "
-					."LEFT JOIN cvterm cvterm ON "
-					  .$relationship_tablename.".type_id = cvterm.cvterm_id "
-					."WHERE ".$relationship_tablename.".".$subject_id." IN (".implode(',',$primary_ids).") "
-					."OR ".$relationship_tablename.".".$object_id." IN (".implode(',',$primary_ids).") ";
-			$previous_db = tripal_db_set_active('chado');
-			$resource = db_query($sql);
-			tripal_db_set_active($previous_db);
-			
-			//add results to views results
-			while ($r = db_fetch_object($resource)) {
-				if (in_array($r->{$subject_id}, $primary_ids)) {
-					$key = array_search($r->{$subject_id}, $primary_ids);
-					$r->{$this->aliases['primary_id']} = $r->{$subject_id};
-					$this->view->result[$key]->relationships[] = clone $r;
-				}
-				if (in_array($r->{$object_id}, $primary_ids)) {
-					$key = array_search($r->{$object_id}, $primary_ids);
-					$r->{$this->aliases['primary_id']} = $r->{$object_id};
-					$this->view->result[$key]->relationships[] = clone $r;
-				}
-			} //end of while
+      foreach ($this->view->result as $row_num => $row) {
+        $primary_ids[$row_num] = $row->{$this->aliases['primary_id']};
+      }
+
+      //generate results from db
+      $sql = "SELECT " . $relationship_tablename . ".*, cvterm.name as type_name, "
+          ."subject_parent.name as subject_name, object_parent.name as object_name "
+          ."FROM " . $relationship_tablename . " "
+          ."LEFT JOIN " . $this->view->base_table . " subject_parent ON "
+            . $relationship_tablename . "." . $subject_id . "=subject_parent." . $this->aliases['primary_id'] . " "
+          ."LEFT JOIN " . $this->view->base_table . " object_parent ON "
+            . $relationship_tablename . "." . $object_id . "=object_parent." . $this->aliases['primary_id'] . " "
+          ."LEFT JOIN cvterm cvterm ON "
+            . $relationship_tablename . ".type_id = cvterm.cvterm_id "
+          . "WHERE " . $relationship_tablename . "." . $subject_id . " IN (" . implode(',', $primary_ids) . ") "
+          . "OR " . $relationship_tablename . "." . $object_id . " IN (" . implode(',', $primary_ids) . ") ";
+      $previous_db = tripal_db_set_active('chado');
+      $resource = db_query($sql);
+      tripal_db_set_active($previous_db);
+
+      //add results to views results
+      while ($r = db_fetch_object($resource)) {
+        if (in_array($r->{$subject_id}, $primary_ids)) {
+          $key = array_search($r->{$subject_id}, $primary_ids);
+          $r->{$this->aliases['primary_id']} = $r->{$subject_id};
+          $this->view->result[$key]->relationships[] = clone $r;
+        }
+        if (in_array($r->{$object_id}, $primary_ids)) {
+          $key = array_search($r->{$object_id}, $primary_ids);
+          $r->{$this->aliases['primary_id']} = $r->{$object_id};
+          $this->view->result[$key]->relationships[] = clone $r;
+        }
+      } //end of while
     }// end of if add values
 
-		//for each stock in this view page, add the values
-		foreach ($values as $result) {
-			if (!empty($result->{$this->aliases['relationships']})) {
-				
-				// all relationships including the current stock
-				$relationships = $result->{$this->aliases['relationships']};
-				foreach ($relationships as $relationship) {			
-					// Add relationship to the list of items to be rendered
-					// Note: $this->aliases['primary_id'] = base table primary key
-					
-					$elements = array(
-					  $this->aliases['primary_id'] => $relationship->{$this->aliases['primary_id']},
-					  $this->aliases['relationship_primary_id'] => $relationship->{$this->aliases['relationship_primary_id']},
-					  'subject_id' => $relationship->{$this->aliases['subject_id']},
-					  'subject_name' => $relationship->subject_name,
-					  'object_id' => $relationship->{$this->aliases['object_id']},
+    //for each stock in this view page, add the values
+    foreach ($values as $result) {
+      if (!empty($result->{$this->aliases['relationships']})) {
+
+        // all relationships including the current stock
+        $relationships = $result->{$this->aliases['relationships']};
+        foreach ($relationships as $relationship) {
+          // Add relationship to the list of items to be rendered
+          // Note: $this->aliases['primary_id'] = base table primary key
+
+          $elements = array(
+            $this->aliases['primary_id'] => $relationship->{$this->aliases['primary_id']},
+            $this->aliases['relationship_primary_id'] => $relationship->{$this->aliases['relationship_primary_id']},
+            'subject_id' => $relationship->{$this->aliases['subject_id']},
+            'subject_name' => $relationship->subject_name,
+            'object_id' => $relationship->{$this->aliases['object_id']},
             'object_name' => $relationship->object_name,
             'type_id' => $relationship->type_id,
             'type_name' => $relationship->type_name,
-					);
-					$this->items[$relationship->{$this->aliases['primary_id']}][$relationship->{$this->aliases['relationship_primary_id']}] = $elements;
-				}
-			}
-		}
-	}
+          );
+          $this->items[$relationship->{$this->aliases['primary_id']}][$relationship->{$this->aliases['relationship_primary_id']}] = $elements;
+        }
+      }
+    }
+  }
 
   function render_item($count, $item) {
-		return $item['subject_name'].' '.$item['type_name'].' '.$item['object_name'];
+    return $item['subject_name'] . ' ' . $item['type_name'] . ' ' . $item['object_name'];
   }
 
 }

+ 14 - 13
tripal_natural_diversity/views/handlers/views_handler_field_chado_relationship_by_type.inc

@@ -10,7 +10,7 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
 
     // Boolean to determine whether
     //    TRUE =>  value (property type)      -more than one property type displayed
-    //    FALSE => or just value is rendered  -only 1 porperty type is displayed    
+    //    FALSE => or just value is rendered  -only 1 porperty type is displayed
     $this->display_type = TRUE;
 
   }
@@ -18,7 +18,7 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
   function option_definition() {
     $options = parent::option_definition();
     $options['stockrel_type_ids'] = array('default' => array());
-    $options['stockrel_display_options'] = array('default' => array('subject','type','object'));
+    $options['stockrel_display_options'] = array('default' => array('subject', 'type', 'object'));
     return $options;
   }
 
@@ -42,7 +42,7 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
       ),
       '#default_value' => array($this->options['stockrel_display_parts']['subject'], $this->options['stockrel_display_parts']['type'], $this->options['stockrel_display_parts']['object']),
     );
-    
+
     $form['stockrel_display_rels'] = array(
       '#type' => 'radios',
       '#title' => t('Display Relationships Where'),
@@ -59,7 +59,7 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
       ),
       '#default_value' => $this->options['stockrel_display_rels'],
     );
-    
+
     $options = tripal_cv_get_cvterm_options( variable_get('chado_stock_relationship_cv', 'null') );
     $form['stockrel_type_ids'] = array(
       '#type' => 'checkboxes',
@@ -80,14 +80,14 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
     $this->aliases['relationships'] = 'relationships';
     $this->aliases['stock_id'] = 'stock_id';
     $this->field_alias = $this->aliases['stock_id'];
-    
+
     //for each stock in this view page
     foreach ($values as $result) {
       if (!empty($result->{$this->aliases['relationships']})) {
-          
+
         // all relationships including the current stock
         $relationships = $result->{$this->aliases['relationships']};
-        foreach ($relationships as $relationship) {      
+        foreach ($relationships as $relationship) {
           // perform filtering------
           //type
           if (!empty($this->options['stockrel_type_ids'])) {
@@ -96,18 +96,19 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
               continue;
             }
           }
-          
+
           //"Display Relationships Where" criteria
           if (preg_match('/subject/', $this->options['stockrel_display_rels'])) {
             if ($relationship->stock_id != $relationship->subject_id) {
               continue;
-            }      
-          } elseif (preg_match('/object/', $this->options['stockrel_display_rels'])) {
+            }
+          }
+          elseif (preg_match('/object/', $this->options['stockrel_display_rels'])) {
             if ($relationship->stock_id != $relationship->object_id) {
               continue;
             }
           }
-          
+
           // Add relationship to the list of items to be rendered
           $this->items[$relationship->stock_id][$relationship->stock_relationship_id]['stock_id'] = $relationship->stock_id;
           $this->items[$relationship->stock_id][$relationship->stock_relationship_id]['stock_relationship_id'] = $relationship->stock_relationship_id;
@@ -124,7 +125,7 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
 
   function render_item($count, $item) {
     $text = array();
-    
+
     // Render Parts
     if ($this->options['stockrel_display_parts']['subject']) {
       $text[] = $item['subject_name'];
@@ -135,7 +136,7 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
     if ($this->options['stockrel_display_parts']['object']) {
       $text[] = $item['object_name'];
     }
-    
+
     return implode(' ', $text);
   }
 

+ 25 - 25
tripal_natural_diversity/views/nd_experiment.views.inc

@@ -1,5 +1,5 @@
 <?php
- 
+
 /**
  *  @file
  *  This file defines the data array for a given chado table. This array
@@ -7,12 +7,12 @@
  *  with this module in:
  *  @see tripal_natural_diversity.views.inc --in tripal_natural_diversity_views_data()
  *
- *  Documentation on views integration can be found at 
+ *  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 
+ * Purpose: this function returns the portion of the data array
  *   which describes the nd_experiment table, it's fields and any joins between it and other tables
  * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  *
@@ -23,7 +23,7 @@
   CREATE TABLE nd_experiment (
     nd_experiment_id serial PRIMARY KEY NOT NULL,
     nd_geolocation_id integer NOT NULL references nd_geolocation (nd_geolocation_id) on delete cascade INITIALLY DEFERRED,
-    type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED 
+    type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED
   );
  * @endcode
  */
@@ -34,32 +34,32 @@
   // 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)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
     $database = 'chado';
   }
-   
+
   //Basic table definition-----------------------------------
   $data['nd_experiment']['table']['group'] = t('Chado ND Experiment');
-  
+
   $data['nd_experiment']['table']['base'] = array(
     'field' => 'nd_experiment_id',
     'title' => t('Chado Natural Diversity Experiment'),
     'help' => t('Represents one data point in a natural diversity project.'),
   );
-  if($database){
+  if ($database) {
      $data['nd_experiment']['table']['database'] = $database;
   }
 
-  
+
   //Relationship Definitions---------------------------------
   //Join: nd_experiment => nd_geolocation
   // In nd_experiment.views.inc
-  
+
   //Join: nd_experiment => nd_experiment_contact => contact
   $data['nd_experiment']['table']['join']['nd_experiment_contact'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
-  );  
+  );
   $data['nd_experiment']['table']['join']['contact'] = array(
     'left_table' => 'nd_experiment_contact',
     'left_field' => 'nd_experiment_id',
@@ -69,12 +69,12 @@
     'left_field' => 'contact_id',
     'field' => 'contact_id',
   );
-  
+
   //Join: nd_experiment => nd_experiment_dbxref => dbxref
   $data['nd_experiment']['table']['join']['nd_experiment_dbxref'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
-  );  
+  );
   $data['nd_experiment']['table']['join']['dbxref'] = array(
     'left_table' => 'nd_experiment_dbxref',
     'left_field' => 'nd_experiment_id',
@@ -84,12 +84,12 @@
     'left_field' => 'dbxref_id',
     'field' => 'dbxref_id',
   );
-  
+
   //Join: nd_experiment => nd_experiment_genotype => genotype
   $data['nd_experiment']['table']['join']['nd_experiment_genotype'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
-  );  
+  );
   $data['nd_experiment']['table']['join']['genotype'] = array(
     'left_table' => 'nd_experiment_genotype',
     'left_field' => 'nd_experiment_id',
@@ -99,12 +99,12 @@
     'left_field' => 'genotype_id',
     'field' => 'genotype_id',
   );
-  
+
   //Join: nd_experiment => nd_experiment_phenotype => phenotype
   $data['nd_experiment']['table']['join']['nd_experiment_phenotype'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
-  );  
+  );
   $data['nd_experiment']['table']['join']['phenotype'] = array(
     'left_table' => 'nd_experiment_phenotype',
     'left_field' => 'nd_experiment_id',
@@ -114,12 +114,12 @@
     'left_field' => 'phenotype_id',
     'field' => 'phenotype_id',
   );
-  
+
   //Join: nd_experiment => nd_experiment_project => project
   $data['nd_experiment']['table']['join']['nd_experiment_project'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
-  );  
+  );
   $data['nd_experiment']['table']['join']['project'] = array(
     'left_table' => 'nd_experiment_project',
     'left_field' => 'nd_experiment_id',
@@ -129,12 +129,12 @@
     'left_field' => 'project_id',
     'field' => 'project_id',
   );
-  
+
   //Join: nd_experiment => nd_experiment_pub => pub
   $data['nd_experiment']['table']['join']['nd_experiment_pub'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
-  );  
+  );
   $data['nd_experiment']['table']['join']['pub'] = array(
     'left_table' => 'nd_experiment_pub',
     'left_field' => 'nd_experiment_id',
@@ -149,7 +149,7 @@
   $data['nd_experiment']['table']['join']['nd_experiment_stock'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
-  );  
+  );
   $data['nd_experiment']['table']['join']['stock'] = array(
     'left_table' => 'nd_experiment_stock',
     'left_field' => 'nd_experiment_id',
@@ -161,7 +161,7 @@
   );
 
   //Table Field Definitions----------------------------------
-      
+
   //Field: nd_experiment_id (primary key)
   $data['nd_experiment']['nd_experiment_id'] = array(
     'title' => t('ND Experiment Primary Key'),
@@ -177,6 +177,6 @@
       'handler' => 'views_handler_filter_numeric',
     ),
   );
-    
+
   return $data;
-}
+}

+ 15 - 15
tripal_natural_diversity/views/nd_experimentprop.views.inc

@@ -1,5 +1,5 @@
 <?php
- 
+
 /**
  *  @file
  *  This file defines the data array for a given chado table. This array
@@ -7,12 +7,12 @@
  *  with this module in:
  *  @see tripal_natural_diversity.views.inc --in tripal_natural_diversity_views_data()
  *
- *  Documentation on views integration can be found at 
+ *  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 
+ * Purpose: this function returns the portion of the data array
  *   which describes the nd_experimentprop table, it's fields and any joins between it and other tables
  * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  *
@@ -28,10 +28,10 @@
   // 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)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
     $database = 'chado';
   }
-   
+
   //Basic table definition-----------------------------------
   $data['nd_experimentprop']['table'] = array(
     'group' => t('Chado ND Experiment Properties'),
@@ -39,20 +39,20 @@
     'title' => t('Chado ND Experiment Property'),
     'help' => t('Properties of a given Natural Diversity Experiment.'),
   );
-  if($database){
+  if ($database) {
      $data['nd_experimentprop']['table']['database'] = $database;
   }
 
-  
+
   //Relationship Definitions---------------------------------
   //Join: nd_experimentprop => nd_experiment
   $data['nd_experimentprop']['table']['join']['nd_experiment'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
   );
-  
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: nd_experimentprop_id (primary key)
   $data['nd_experimentprop']['nd_experimentprop_id'] = array(
     'title' => t('ND Experiment Property Primary Key'),
@@ -69,7 +69,7 @@
     ),
   );
 
-  //Field: value (varchar 255)   
+  //Field: value (varchar 255)
   $data['nd_experimentprop']['value'] = array(
     'title' => t('Property Value'),
     'help' => t('The value of a given property.'),
@@ -88,7 +88,7 @@
     ),
   );
 
-  //Field: rank (int)   
+  //Field: rank (int)
   $data['nd_experimentprop']['rank'] = array(
     'title' => t('Property Rank'),
     'help' => t('The rank of a given propery.'),
@@ -104,7 +104,7 @@
     ),
   );
 
-  //Calculated Field: type/cvterm name (varchar 255)   
+  //Calculated Field: type/cvterm name (varchar 255)
   $data['nd_experimentprop']['nd_experimentprop_cvterm_name'] = array(
     'title' => t('Property Type'),
     'help' => t('The type of property.'),
@@ -121,7 +121,7 @@
     'argument' => array(
       'handler' => 'views_handler_argument_string',
     ),
-  );  
-  
+  );
+
   return $data;
-}
+}

+ 19 - 19
tripal_natural_diversity/views/nd_geolocation.views.inc

@@ -1,5 +1,5 @@
 <?php
- 
+
 /**
  *  @file
  *  This file defines the data array for a given chado table. This array
@@ -7,12 +7,12 @@
  *  with this module in:
  *  @see tripal_natural_diversity.views.inc --in tripal_natural_diversity_views_data()
  *
- *  Documentation on views integration can be found at 
+ *  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 
+ * Purpose: this function returns the portion of the data array
  *   which describes the nd_geolocation table, it's fields and any joins between it and other tables
  * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  *
@@ -28,32 +28,32 @@
   // 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)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
     $database = 'chado';
   }
-   
+
   //Basic table definition-----------------------------------
   $data['nd_geolocation']['table']['group'] = t('Chado ND geolocation');
-  
+
   $data['nd_geolocation']['table']['base'] = array(
     'field' => 'nd_geolocation_id',
     'title' => t('Chado Natural Diversity Geolocation'),
     'help' => t('A listing of locations where Natural Diversity Experiments can be performed.'),
   );
-  if($database){
+  if ($database) {
      $data['nd_geolocation']['table']['database'] = $database;
   }
 
-  
+
   //Relationship Definitions---------------------------------
   //Join: nd_geolocation => nd_experiment
   $data['nd_geolocation']['table']['join']['nd_experiment'] = array(
     'left_field' => 'nd_geolocation_id',
     'field' => 'nd_geolocation_id',
-  );  
-  
+  );
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: nd_geolocation_id (primary key)
   $data['nd_geolocation']['nd_geolocation_id'] = array(
     'title' => t('ND Geolocation Primary Key'),
@@ -70,7 +70,7 @@
     ),
   );
 
-  //Field: description (varchar 255)   
+  //Field: description (varchar 255)
   $data['nd_geolocation']['description'] = array(
     'title' => t('Description'),
     'help' => t('A short description of a given geolocation.'),
@@ -89,7 +89,7 @@
     ),
   );
 
-  //Field: latitude (real)   
+  //Field: latitude (real)
   $data['nd_geolocation']['latitude'] = array(
     'title' => t('Latitude'),
     'help' => t('The decimal latitude coordinate of the georeference, using positive and negative sign to indicate N and S, respectively.'),
@@ -105,7 +105,7 @@
     ),
   );
 
-  //Field: longitude (real)   
+  //Field: longitude (real)
   $data['nd_geolocation']['longitude'] = array(
     'title' => t('Longitude'),
     'help' => t('The decimal longitude coordinate of the georeference, using positive and negative sign to indicate E and W, respectively.'),
@@ -121,7 +121,7 @@
     ),
   );
 
-  //Field: altitude (real)   
+  //Field: altitude (real)
   $data['nd_geolocation']['altitude'] = array(
     'title' => t('Altitude'),
     'help' => t('The altitude (elevation) of the location in meters. If the altitude is only known as a range, this is the average, and altitude_dev will hold half of the width of the range.'),
@@ -137,7 +137,7 @@
     ),
   );
 
-  //Field: geodetic_datum (varchar 255)   
+  //Field: geodetic_datum (varchar 255)
   $data['nd_geolocation']['geodetic_datum'] = array(
     'title' => t('Deodetic Datum'),
     'help' => t('The geodetic system on which the geo-reference coordinates are based. For geo-references measured between 1984 and 2010, this will typically be WGS84.'),
@@ -155,7 +155,7 @@
       'handler' => 'views_handler_argument_string',
     ),
   );
-  
-    
+
+
   return $data;
-}
+}

+ 16 - 16
tripal_natural_diversity/views/nd_geolocationprop.views.inc

@@ -1,5 +1,5 @@
 <?php
- 
+
 /**
  *  @file
  *  This file defines the data array for a given chado table. This array
@@ -7,12 +7,12 @@
  *  with this module in:
  *  @see tripal_natural_diversity.views.inc --in tripal_natural_diversity_views_data()
  *
- *  Documentation on views integration can be found at 
+ *  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 
+ * Purpose: this function returns the portion of the data array
  *   which describes the nd_geolocationprop table, it's fields and any joins between it and other tables
  * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  *
@@ -28,10 +28,10 @@
   // 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)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
     $database = 'chado';
   }
-   
+
   //Basic table definition-----------------------------------
   $data['nd_geolocationprop']['table'] = array(
     'field' => 'nd_geolocationprop_id',
@@ -39,20 +39,20 @@
     'help' => t('Properties of Natural Diversity Geolocations.'),
     'group' => t('Chado ND Geolocation Properties'),
   );
-  if($database){
+  if ($database) {
      $data['nd_geolocationprop']['table']['database'] = $database;
   }
 
-  
+
   //Relationship Definitions---------------------------------
   //Join: nd_geolocation => nd_geolocationprop
   $data['nd_geolocationprop']['table']['join']['nd_geolocation'] = array(
     'left_field' => 'nd_geolocation_id',
     'field' => 'nd_geolocation_id',
   );
-  
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: nd_geolocationprop_id (primary key)
   $data['nd_geolocationprop']['field_name'] = array(
     'title' => t('ND Geolocation Property Primary Key'),
@@ -68,8 +68,8 @@
       'handler' => 'views_handler_filter_numeric',
     ),
   );
-  
-  //Field: value (varchar 255)   
+
+  //Field: value (varchar 255)
   $data['nd_geolocationprop']['value'] = array(
     'title' => t('Property Value'),
     'help' => t('The value of a given property.'),
@@ -88,7 +88,7 @@
     ),
   );
 
-  //Field: rank (int)   
+  //Field: rank (int)
   $data['nd_geolocationprop']['rank'] = array(
     'title' => t('Property Rank'),
     'help' => t('The rank of a given propery.'),
@@ -104,7 +104,7 @@
     ),
   );
 
-  //Calculated Field: type/cvterm name (varchar 255)   
+  //Calculated Field: type/cvterm name (varchar 255)
   $data['nd_geolocationprop']['nd_geolocationprop_cvterm_name'] = array(
     'title' => t('Property Type'),
     'help' => t('The type of property.'),
@@ -121,7 +121,7 @@
     'argument' => array(
       'handler' => 'views_handler_argument_string',
     ),
-  );  
-    
+  );
+
   return $data;
-}
+}

+ 29 - 29
tripal_natural_diversity/views/nd_reagent.views.inc

@@ -1,5 +1,5 @@
 <?php
- 
+
 /**
  *  @file
  *  This file defines the data array for a given chado table. This array
@@ -7,12 +7,12 @@
  *  with this module in:
  *  @see tripal_natural_diversity.views.inc --in tripal_natural_diversity_views_data()
  *
- *  Documentation on views integration can be found at 
+ *  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 
+ * Purpose: this function returns the portion of the data array
  *   which describes the nd_reagent table, it's fields and any joins between it and other tables
  * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  *
@@ -33,24 +33,24 @@
   // 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)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
     $database = 'chado';
   }
-   
+
   //Basic table definition-----------------------------------
   $data['nd_reagent']['table']['group'] = t('Chado ND Reagent');
-  
+
   $data['nd_reagent']['table']['base'] = array(
     'field' => 'nd_reagent_id',
     'title' => t('Chado Natural Diversity Reagent'),
     'help' => t('Reagents used in Natural Diversity Experiments.'),
   );
-  if($database){
+  if ($database) {
      $data['nd_reagent']['table']['base']['database'] = $database;
   }
-   
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: nd_reagent_id (primary key)
   $data['nd_reagent']['nd_reagent_id'] = array(
     'title' => t('ND Reagent Primary Key'),
@@ -67,7 +67,7 @@
     ),
   );
 
-  //Field: name (varchar 255)   
+  //Field: name (varchar 255)
   $data['nd_reagent']['name'] = array(
     'title' => t('Name'),
     'help' => t('The name of the reagent.'),
@@ -88,27 +88,27 @@
 
   //Field: type_id (foreign key)
   // Join described in cvterm.views.inc
-  
+
   //Field: feature_id (foreign key)
   // Join described in feature.views.inc
- 
- 	//Calculated Field: stock relationships (ALL)
-	// uses a custom field handler which pulls results from the view
-	// actual query performed in chado_stock_views_views_pre_render	(&$view) -file:tripal_stock.views.inc
-	$data['nd_reagent']['all_relationships'] = array(
-  	'title' => t('All Reagent Relationships'),
-  	'help' => t('Relationships including the current reagent.'),
-  	'field' => array(
-    	'title' => t('All Relationships'),
-    	'help' => t('Display all relationships including the current reagent.'),
-    	'handler' => 'views_handler_field_chado_relationship_all',
-  	),
-	);
 
-	//Calculated Field: stock relationships
-	// uses a custom field handler which pulls results from the view
-	// actual query performed in chado_stock_views_views_pre_render	(&$view) -file:tripal_stock.views.inc
-	$data['nd_reagent']['relationships'] = array(
+   //Calculated Field: stock relationships (ALL)
+  // uses a custom field handler which pulls results from the view
+  // actual query performed in chado_stock_views_views_pre_render  (&$view) -file:tripal_stock.views.inc
+  $data['nd_reagent']['all_relationships'] = array(
+    'title' => t('All Reagent Relationships'),
+    'help' => t('Relationships including the current reagent.'),
+    'field' => array(
+      'title' => t('All Relationships'),
+      'help' => t('Display all relationships including the current reagent.'),
+      'handler' => 'views_handler_field_chado_relationship_all',
+    ),
+  );
+
+  //Calculated Field: stock relationships
+  // uses a custom field handler which pulls results from the view
+  // actual query performed in chado_stock_views_views_pre_render  (&$view) -file:tripal_stock.views.inc
+  $data['nd_reagent']['relationships'] = array(
     'title' => t('ND Reagent Relationships'),
     'help' => t('Relationships including the current reagent.'),
     'field' => array(
@@ -118,4 +118,4 @@
     ),
   );
   return $data;
-}
+}

+ 15 - 15
tripal_natural_diversity/views/nd_reagentprop.views.inc

@@ -1,5 +1,5 @@
 <?php
- 
+
 /**
  *  @file
  *  This file defines the data array for a given chado table. This array
@@ -7,12 +7,12 @@
  *  with this module in:
  *  @see tripal_natural_diversity.views.inc --in tripal_natural_diversity_views_data()
  *
- *  Documentation on views integration can be found at 
+ *  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 
+ * Purpose: this function returns the portion of the data array
  *   which describes the nd_reagentprop table, it's fields and any joins between it and other tables
  * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  *
@@ -28,18 +28,18 @@
   // 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)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
     $database = 'chado';
   }
-   
-  //Basic table definition-----------------------------------  
+
+  //Basic table definition-----------------------------------
   $data['nd_reagentprop']['table'] = array(
     'field' => 'primary_id',
     'title' => t('Chado ND Reagent Property'),
     'help' => t('Properties of Natural Diversity Reagents.'),
     'group' => t('Chado ND Reagent Property'),
   );
-  if($database){
+  if ($database) {
      $data['nd_reagentprop']['table']['database'] = $database;
   }
 
@@ -49,9 +49,9 @@
     'left_field' => 'nd_reagent_id',
     'field' => 'nd_reagent_id',
   );
-   
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: nd_reagentprop_id (primary key)
   $data['nd_reagentprop']['nd_reagentprop_id'] = array(
     'title' => t('ND Reagent Propery Primary Key'),
@@ -67,7 +67,7 @@
       'handler' => 'views_handler_filter_numeric',
     ),
   );
-  //Field: value (varchar 255)   
+  //Field: value (varchar 255)
   $data['nd_reagentprop']['value'] = array(
     'title' => t('Property Value'),
     'help' => t('The value of a given property.'),
@@ -86,7 +86,7 @@
     ),
   );
 
-  //Field: rank (int)   
+  //Field: rank (int)
   $data['nd_reagentprop']['rank'] = array(
     'title' => t('Property Rank'),
     'help' => t('The rank of a given propery.'),
@@ -102,7 +102,7 @@
     ),
   );
 
-  //Calculated Field: type/cvterm name (varchar 255)   
+  //Calculated Field: type/cvterm name (varchar 255)
   $data['nd_reagentprop']['nd_reagentprop_cvterm_name'] = array(
     'title' => t('Property Type'),
     'help' => t('The type of property.'),
@@ -119,7 +119,7 @@
     'argument' => array(
       'handler' => 'views_handler_argument_string',
     ),
-  );  
-    
+  );
+
   return $data;
-}
+}

+ 28 - 28
tripal_natural_diversity/views/template.node_join.views.inc

@@ -5,18 +5,18 @@
  *
  *  - 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 
+ *
+ *  NOTE: Creating the table definition file is not enough. You also need to call the
  *        retrieve_XXX_views_data() function from ../tripal_natural_diversity.views.inc:tripal_natural_diversity_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 
+ *        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
@@ -24,31 +24,31 @@
  *  with this module in:
  *  @see tripal_natural_diversity.views.inc --in tripal_natural_diversity_views_data()
  *
- *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *  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 
+ *  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 
+ * 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_natural_diversity_views_data() --in tripal_natural_diversity.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;
+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)){
+  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;
   }
@@ -57,28 +57,28 @@ function retrieve_chado_XXX_views_data () {
   $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',
+    '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',
+    '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',
-  );  
+    'left_table' => 'chado_XXX',
+    'left_field' => 'nid',
+    'field' => 'nid',
+  );
 
-	return $data;
-}
+  return $data;
+}

+ 27 - 27
tripal_natural_diversity/views/template.table_defn.views.inc

@@ -5,7 +5,7 @@
  *
  *   - 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'] 
+ *     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
@@ -15,18 +15,18 @@
  *   - 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 
+ *
+ *  NOTE: Creating the table definition file is not enough. You also need to call the
  *        retrieve_XXX_views_data() function from ../tripal_natural_diversity.views.inc:tripal_natural_diversity_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 
+ *        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
@@ -34,12 +34,12 @@
  *  with this module in:
  *  @see tripal_natural_diversity.views.inc --in tripal_natural_diversity_views_data()
  *
- *  Documentation on views integration can be found at 
+ *  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 
+ * 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_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  *
@@ -55,23 +55,23 @@
   // 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)){
+  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){
+  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
@@ -80,16 +80,16 @@
   $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 
+  // 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',
@@ -99,9 +99,9 @@
     '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'),
@@ -123,7 +123,7 @@
    * Remove this section when done
    */
 
-  //Field: plain_text_field (chado datatype)   
+  //Field: plain_text_field (chado datatype)
   $data['XXX']['plain_text_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -142,7 +142,7 @@
     ),
   );
 
-  //Field: numeric_field (chado datatype)   
+  //Field: numeric_field (chado datatype)
   $data['XXX']['numeric_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -158,7 +158,7 @@
     ),
   );
 
-  //Field: boolean_field (chado datatype)   
+  //Field: boolean_field (chado datatype)
   $data['XXX']['boolean_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -174,7 +174,7 @@
     ),
   );
 
-  //Field: unix_timestamp (chado datatype)   
+  //Field: unix_timestamp (chado datatype)
   $data['XXX']['unix_timestamp'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -190,7 +190,7 @@
     ),
   );
 
-  //Field: human_readable_date (chado datatype)   
+  //Field: human_readable_date (chado datatype)
   $data['XXX']['human_readable_date'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -202,10 +202,10 @@
       'handler' => 'views_handler_sort_date',
     ),
   );
-   
+
    /*
     * End of Example Field definitions
     */
-    
+
   return $data;
-}
+}