Browse Source

Tripal views adheres to Drupal coding standards

Lacey Sanderson 13 năm trước cách đây
mục cha
commit
65488ce420
42 tập tin đã thay đổi với 617 bổ sung499 xóa
  1. 11 1
      tripal_views/tripal_views.coder_ignores.txt
  2. 1 0
      tripal_views/tripal_views_data_export_download_form.tpl.php
  3. 2 0
      tripal_views/tripal_views_integration_fields_form.tpl.php
  4. 4 4
      tripal_views/views/handlers/chado_views_handler_field.inc
  5. 11 11
      tripal_views/views/handlers/chado_views_handler_field_aggregate.inc
  6. 4 4
      tripal_views/views/handlers/chado_views_handler_field_boolean.inc
  7. 4 4
      tripal_views/views/handlers/chado_views_handler_field_counter.inc
  8. 4 4
      tripal_views/views/handlers/chado_views_handler_field_custom.inc
  9. 4 4
      tripal_views/views/handlers/chado_views_handler_field_markup.inc
  10. 4 4
      tripal_views/views/handlers/chado_views_handler_field_math.inc
  11. 4 4
      tripal_views/views/handlers/chado_views_handler_field_numeric.inc
  12. 9 8
      tripal_views/views/handlers/chado_views_handler_filter_boolean_operator_string.inc
  13. 7 5
      tripal_views/views/handlers/chado_views_handler_filter_date.inc
  14. 7 5
      tripal_views/views/handlers/chado_views_handler_filter_equality.inc
  15. 7 5
      tripal_views/views/handlers/chado_views_handler_filter_float.inc
  16. 7 5
      tripal_views/views/handlers/chado_views_handler_filter_string.inc
  17. 4 3
      tripal_views/views/handlers/chado_views_handler_sort.inc
  18. 4 3
      tripal_views/views/handlers/chado_views_handler_sort_date.inc
  19. 4 3
      tripal_views/views/handlers/chado_views_handler_sort_formula.inc
  20. 4 3
      tripal_views/views/handlers/chado_views_handler_sort_menu_hierarchy.inc
  21. 4 3
      tripal_views/views/handlers/chado_views_handler_sort_random.inc
  22. 10 8
      tripal_views/views/handlers/chado_wrapper_functions.inc
  23. 4 2
      tripal_views/views/handlers/views_handler_field_chado_count.inc
  24. 41 38
      tripal_views/views/handlers/views_handler_field_chado_rel_by_type.inc
  25. 3 2
      tripal_views/views/handlers/views_handler_field_chado_tf_boolean.inc
  26. 19 20
      tripal_views/views/handlers/views_handler_field_cvterm_name.inc
  27. 39 34
      tripal_views/views/handlers/views_handler_field_dbxref_accession_link.inc
  28. 17 14
      tripal_views/views/handlers/views_handler_field_node_optional.inc
  29. 2 1
      tripal_views/views/handlers/views_handler_field_readable_date.inc
  30. 8 8
      tripal_views/views/handlers/views_handler_field_type_name.inc
  31. 16 14
      tripal_views/views/handlers/views_handler_filter_chado_boolean.inc
  32. 81 68
      tripal_views/views/handlers/views_handler_filter_chado_select_cvterm_name.inc
  33. 37 29
      tripal_views/views/handlers/views_handler_filter_chado_select_string.inc
  34. 65 69
      tripal_views/views/handlers/views_handler_filter_file_upload.inc
  35. 21 15
      tripal_views/views/handlers/views_handler_filter_no_results.inc
  36. 59 49
      tripal_views/views/handlers/views_handler_join_chado_aggregator.inc
  37. 27 20
      tripal_views/views/handlers/views_handler_join_chado_through_linking.inc
  38. 1 1
      tripal_views/views_data_export/plugins/tripal_views_plugin_style_export_fasta.inc
  39. 24 12
      tripal_views/views_data_export/theme/tripal_views_data_export.theme.inc
  40. 29 12
      tripal_views/views_data_export/theme/views-data-export-fasta-body.tpl.php
  41. 2 0
      tripal_views/views_data_export/theme/views-data-export-fasta-footer.tpl.php
  42. 2 0
      tripal_views/views_data_export/theme/views-data-export-fasta-header.tpl.php

+ 11 - 1
tripal_views/tripal_views.coder_ignores.txt

@@ -7,4 +7,14 @@ tripal_views_integration_fields_form.tpl.php:48:style
 tripal_views_data_export_download_form.tpl.php:8:style
 
 ; All variables are set through the code and thus don't need to be filtered
-tripal_views_integration.inc:734:security
+tripal_views_integration.inc:734:security
+
+; SQL queries the chado database which does not use the drupal prefixing functionality
+; therefore, curly brackets ({}) are not appropriate.
+views/handlers/views_handler_filter_chado_select_cvterm_name.inc:53:sql
+views/handlers/views_handler_filter_chado_select_cvterm_name.inc:61:sql
+views/handlers/views_handler_field_dbxref_accession_link.inc:31:sql
+
+; SQL queries the pg_tables table to check if a table exists in chado; drupal
+; prefixing is not appropriate
+views/handlers/views_handler_field_chado_rel_by_type.inc:22:sql

+ 1 - 0
tripal_views/tripal_views_data_export_download_form.tpl.php

@@ -9,3 +9,4 @@ print drupal_render($form);
 
 ?>
 
+<!-- END -->

+ 2 - 0
tripal_views/tripal_views_integration_fields_form.tpl.php

@@ -51,3 +51,5 @@
 
 <?php print drupal_render($form); ?>
 
+<!-- END -->
+

+ 4 - 4
tripal_views/views/handlers/chado_views_handler_field.inc

@@ -10,9 +10,9 @@
  */
 class chado_views_handler_field extends views_handler_field {
 
-  function init (&$view, $options) {
+  function init(&$view, $options) {
     include_once('chado_wrapper_functions.inc');
-    parent::init($view,$options);
+    parent::init($view, $options);
   }
 
   /**
@@ -57,7 +57,7 @@ class chado_views_handler_field extends views_handler_field {
    * 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);
   }
@@ -65,7 +65,7 @@ class chado_views_handler_field extends views_handler_field {
   /**
    * 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);

+ 11 - 11
tripal_views/views/handlers/chado_views_handler_field_aggregate.inc

@@ -15,7 +15,7 @@ class chado_views_handler_field_aggregate extends chado_views_handler_field {
 
     if (!isset($this->chado_table_description)) {
       $this->chado_table_description = module_invoke_all('chado_' . $this->table . '_schema');
-      foreach($this->chado_table_description['foreign keys'] as $defn) {
+      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');
           foreach ($join_table['fields'] as $fname => $f) {
@@ -44,7 +44,7 @@ class chado_views_handler_field_aggregate extends chado_views_handler_field {
 
     $this->tokens = array();
     $value = array();
-    foreach( array_keys($this->chado_table_description['fields']) as $field ) {
+    foreach ( array_keys($this->chado_table_description['fields']) as $field ) {
       $t = '[' . $this->options['id'] . '-' . $field . ']';
       $this->tokens[$t] = t($field);
       $value[] = $t . ' == ' . $field;
@@ -60,7 +60,7 @@ class chado_views_handler_field_aggregate extends chado_views_handler_field {
     $form['format']['tokens'] = array(
       '#type' => 'item',
       '#title' => 'Format Tokens',
-      '#value' => implode("<br />",$value),
+      '#value' => implode("<br />", $value),
     );
 
   }
@@ -72,25 +72,25 @@ class chado_views_handler_field_aggregate extends chado_views_handler_field {
   }
 
 
-  function pre_render (&$values) {
+  function pre_render(&$values) {
 
     if ($this->aggregated) {
-      foreach($values as $k => $v) {
+      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) {
+        foreach ($values[$k]->{$this->field_alias} as &$val) {
 
           // First, get the token values
-          $subparts = explode(',',$val);
+          $subparts = explode(',', $val);
           $token_values = array();
-          foreach($subparts as $ssk => $ssv) {
-            if(preg_match('/(.*)::(.*)/',$ssv,$matches)) {
-              $token_values[ '[all-'.$matches[1].']' ] = $matches[2];
+          foreach ($subparts as $ssk => $ssv) {
+            if (preg_match('/(.*)::(.*)/', $ssv, $matches)) {
+              $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']);
+          $val = str_replace(array_keys($token_values), $token_values, $this->options['format']['format_string']);
 
         }
       }

+ 4 - 4
tripal_views/views/handlers/chado_views_handler_field_boolean.inc

@@ -10,9 +10,9 @@
  */
 class chado_views_handler_field_boolean extends views_handler_field_boolean {
 
-  function init (&$view, $options) {
+  function init(&$view, $options) {
     include_once('chado_wrapper_functions.inc');
-    parent::init($view,$options);
+    parent::init($view, $options);
   }
 
   /**
@@ -57,7 +57,7 @@ class chado_views_handler_field_boolean extends views_handler_field_boolean {
    * 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);
   }
@@ -65,7 +65,7 @@ class chado_views_handler_field_boolean extends views_handler_field_boolean {
   /**
    * 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);

+ 4 - 4
tripal_views/views/handlers/chado_views_handler_field_counter.inc

@@ -10,9 +10,9 @@
  */
 class chado_views_handler_field_counter extends views_handler_field_counter {
 
-  function init (&$view, $options) {
+  function init =(&$view, $options) {
     include_once('chado_wrapper_functions.inc');
-    parent::init($view,$options);
+    parent::init($view, $options);
   }
 
   /**
@@ -57,7 +57,7 @@ class chado_views_handler_field_counter extends views_handler_field_counter {
    * 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);
   }
@@ -65,7 +65,7 @@ class chado_views_handler_field_counter extends views_handler_field_counter {
   /**
    * 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);

+ 4 - 4
tripal_views/views/handlers/chado_views_handler_field_custom.inc

@@ -10,9 +10,9 @@
  */
 class chado_views_handler_field_custom extends views_handler_field_custom {
 
-  function init (&$view, $options) {
+  function init(&$view, $options) {
     include_once('chado_wrapper_functions.inc');
-    parent::init($view,$options);
+    parent::init($view, $options);
   }
 
   /**
@@ -57,7 +57,7 @@ class chado_views_handler_field_custom extends views_handler_field_custom {
    * 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);
   }
@@ -65,7 +65,7 @@ class chado_views_handler_field_custom extends views_handler_field_custom {
   /**
    * 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);

+ 4 - 4
tripal_views/views/handlers/chado_views_handler_field_markup.inc

@@ -10,9 +10,9 @@
  */
 class chado_views_handler_field_markup extends views_handler_field_markup {
 
-  function init (&$view, $options) {
+  function init(&$view, $options) {
     include_once('chado_wrapper_functions.inc');
-    parent::init($view,$options);
+    parent::init($view, $options);
   }
 
   /**
@@ -57,7 +57,7 @@ class chado_views_handler_field_markup extends views_handler_field_markup {
    * 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);
   }
@@ -65,7 +65,7 @@ class chado_views_handler_field_markup extends views_handler_field_markup {
   /**
    * 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);

+ 4 - 4
tripal_views/views/handlers/chado_views_handler_field_math.inc

@@ -10,9 +10,9 @@
  */
 class chado_views_handler_field_math extends views_handler_field_math {
 
-  function init (&$view, $options) {
+  function init(&$view, $options) {
     include_once('chado_wrapper_functions.inc');
-    parent::init($view,$options);
+    parent::init($view, $options);
   }
 
   /**
@@ -57,7 +57,7 @@ class chado_views_handler_field_math extends views_handler_field_math {
    * 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);
   }
@@ -65,7 +65,7 @@ class chado_views_handler_field_math extends views_handler_field_math {
   /**
    * 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);

+ 4 - 4
tripal_views/views/handlers/chado_views_handler_field_numeric.inc

@@ -10,9 +10,9 @@
  */
 class chado_views_handler_field_numeric extends views_handler_field_numeric {
 
-  function init (&$view, $options) {
+  function init(&$view, $options) {
     include_once('chado_wrapper_functions.inc');
-    parent::init($view,$options);
+    parent::init($view, $options);
   }
 
   /**
@@ -57,7 +57,7 @@ class chado_views_handler_field_numeric extends views_handler_field_numeric {
    * 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);
   }
@@ -65,7 +65,7 @@ class chado_views_handler_field_numeric extends views_handler_field_numeric {
   /**
    * 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);

+ 9 - 8
tripal_views/views/handlers/chado_views_handler_filter_boolean_operator_string.inc

@@ -29,14 +29,14 @@ class chado_views_handler_filter_boolean_operator_string extends views_handler_f
     $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 %table to only those with the value in the aggregate array.', array('%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.'),
+      '#description' => t('Filters the aggregates shown based on the value. Doesn\'t affect the number of %table records.', array('%table' => $this->view->base_table)),
       '#default_value' => (isset($this->options['aggregates_with'])) ? $this->options['aggregates_with'] : TRUE,
     );
 
@@ -46,20 +46,21 @@ class chado_views_handler_filter_boolean_operator_string extends views_handler_f
    * 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
@@ -74,7 +75,7 @@ class chado_views_handler_filter_boolean_operator_string extends views_handler_f
       // 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 . "'";
       }
     }
 

+ 7 - 5
tripal_views/views/handlers/chado_views_handler_filter_date.inc

@@ -46,20 +46,22 @@ class chado_views_handler_filter_date extends views_handler_filter_date {
    * 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
@@ -74,7 +76,7 @@ class chado_views_handler_filter_date extends views_handler_filter_date {
       // 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 . "'";
       }
     }
 

+ 7 - 5
tripal_views/views/handlers/chado_views_handler_filter_equality.inc

@@ -46,20 +46,22 @@ class chado_views_handler_filter_equality extends views_handler_filter_equality
    * 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
@@ -74,7 +76,7 @@ class chado_views_handler_filter_equality extends views_handler_filter_equality
       // 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 . "'";
       }
     }
 

+ 7 - 5
tripal_views/views/handlers/chado_views_handler_filter_float.inc

@@ -46,20 +46,22 @@ class chado_views_handler_filter_float extends views_handler_filter_float {
    * 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
@@ -74,7 +76,7 @@ class chado_views_handler_filter_float extends views_handler_filter_float {
       // 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 . "'";
       }
     }
 

+ 7 - 5
tripal_views/views/handlers/chado_views_handler_filter_string.inc

@@ -46,20 +46,22 @@ class chado_views_handler_filter_string extends views_handler_filter_string {
    * 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
@@ -74,7 +76,7 @@ class chado_views_handler_filter_string extends views_handler_filter_string {
       // 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 . "'";
       }
     }
 

+ 4 - 3
tripal_views/views/handlers/chado_views_handler_sort.inc

@@ -27,13 +27,14 @@ class chado_views_handler_sort extends views_handler_sort {
    * 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 () {
+  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'])) {
+    if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
       $this->aggregated = TRUE;
-    } else {
+    }
+    else {
       $this->aggregated = FALSE;
     }
 

+ 4 - 3
tripal_views/views/handlers/chado_views_handler_sort_date.inc

@@ -27,13 +27,14 @@ class chado_views_handler_sort extends views_handler_sort_date {
    * 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 () {
+  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'])) {
+    if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
       $this->aggregated = TRUE;
-    } else {
+    }
+    else {
       $this->aggregated = FALSE;
     }
 

+ 4 - 3
tripal_views/views/handlers/chado_views_handler_sort_formula.inc

@@ -27,13 +27,14 @@ class chado_views_handler_sort extends views_handler_sort_formula {
    * 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 () {
+  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'])) {
+    if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
       $this->aggregated = TRUE;
-    } else {
+    }
+    else {
       $this->aggregated = FALSE;
     }
 

+ 4 - 3
tripal_views/views/handlers/chado_views_handler_sort_menu_hierarchy.inc

@@ -27,13 +27,14 @@ class chado_views_handler_sort extends views_handler_sort_menu_hierarchy {
    * 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 () {
+  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'])) {
+    if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
       $this->aggregated = TRUE;
-    } else {
+    }
+    else {
       $this->aggregated = FALSE;
     }
 

+ 4 - 3
tripal_views/views/handlers/chado_views_handler_sort_random.inc

@@ -27,13 +27,14 @@ class chado_views_handler_sort extends views_handler_sort_random {
    * 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 () {
+  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'])) {
+    if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
       $this->aggregated = TRUE;
-    } else {
+    }
+    else {
       $this->aggregated = FALSE;
     }
 

+ 10 - 8
tripal_views/views/handlers/chado_wrapper_functions.inc

@@ -17,11 +17,12 @@
 function chado_wrapper_split_array_agg_results($handler, &$values) {
 
   if ($handler->aggregated) {
-    foreach($values as $k => $v) {
+    foreach ($values as $k => $v) {
 
-      if(preg_match('/^{(.*)}$/',$v->{$handler->field_alias}, $matches)) {
+      if (preg_match('/^{(.*)}$/', $v->{$handler->field_alias}, $matches)) {
         $values[$k]->{$handler->field_alias} = str_getcsv($matches[1]);
-      } else {
+      }
+      else {
         $values[$k]->{$handler->field_alias} = array();
       }
     }
@@ -39,11 +40,11 @@ function chado_wrapper_split_array_agg_results($handler, &$values) {
  * @return
  *   TRUE/FALSE if or if not the field has the aggregated join handler
  */
-function chado_wrapper_is_aggregated_by_join ($handler) {
+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'])) {
+  if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
     $aggregated = TRUE;
   }
 
@@ -61,10 +62,10 @@ function chado_wrapper_is_aggregated_by_join ($handler) {
  * @return
  *   TRUE/FALSE if or if not the field is aggregated
  */
-function chado_wrapper_is_aggregated_by_result ($handler, $values) {
+function chado_wrapper_is_aggregated_by_result($handler, $values) {
   $aggregated = FALSE;
 
-  if (preg_match('/^{.*}$/',$values[0]->{$handler->field_alias})) {
+  if (preg_match('/^{.*}$/', $values[0]->{$handler->field_alias})) {
     $aggregated = TRUE;
   }
 
@@ -96,7 +97,8 @@ function chado_wrapper_render_items($handler, $values) {
 
   // Otherwise it is not aggragated
   // Just render like the default handler would
-  } else {
+  }
+  else {
     return $handler->parent_render($values);
   }
 }

+ 4 - 2
tripal_views/views/handlers/views_handler_field_chado_count.inc

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @file
  * 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,
@@ -19,7 +20,8 @@ class views_handler_field_chado_count extends views_handler_field {
     // 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 {
+    }
+    else {
       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');
     }
 
@@ -35,7 +37,7 @@ class views_handler_field_chado_count extends views_handler_field {
 
   function pre_render(&$values) {
     // Render nothing if the current table wasn't set in the field definition
-    if(!$this->aliases['current_table']) {
+    if (!$this->aliases['current_table']) {
       return '';
     }
 

+ 41 - 38
tripal_views/views/handlers/views_handler_field_chado_rel_by_type.inc

@@ -1,7 +1,8 @@
 <?php
 
 /**
- * Field handler allowing all relationships of a specified type for a given chado entity to be displayed in 
+ * @file
+ * Field handler allowing all relationships of a specified type for a given chado entity to be displayed in
  * a single cell
  *
  * @ingroup views_field_handlers
@@ -12,18 +13,18 @@ class views_handler_field_chado_rel_by_type extends views_handler_field_prerende
 
     // 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;
 
     $this->chado_type = $this->table;
-    
+
     // Check that this chado type has a <chado type>_relationship table
     $sql = "SELECT true as bool FROM pg_tables WHERE tablename='%s_relationship'";
     $previous_db = tripal_db_set_active('chado');
-    $exists = db_fetch_object(db_query($sql,$this->table));
+    $exists = db_fetch_object(db_query($sql, $this->table));
     tripal_db_set_active($previous_db);
     if (!$exists->bool) {
-      drupal_set_message('The Relationship by Type handler cannot be used with this table since the '.$this->table.'_relationship table doesn\'t exist', 'error');
+      drupal_set_message(t('The Relationship by Type handler cannot be used with this table since the %table_relationship table doesn\'t exist', array('%table' => $this->table)), 'error');
       $this->broken = TRUE;
     }
   }
@@ -31,7 +32,7 @@ class views_handler_field_chado_rel_by_type extends views_handler_field_prerende
   function option_definition() {
     $options = parent::option_definition();
     $options['rel_type_ids'] = array('default' => array());
-    $options['rel_display_options'] = array('default' => array('subject','type','object'));
+    $options['rel_display_options'] = array('default' => array('subject', 'type', 'object'));
     return $options;
   }
 
@@ -45,10 +46,11 @@ class views_handler_field_chado_rel_by_type extends views_handler_field_prerende
       $form = array(
         'broken' => array(
           '#type' => 'item',
-          '#value' => 'The Relationship by Type handler cannot be used with this table since the '.$this->table.'_relationship table doesn\'t exist',
+          '#value' => 'The Relationship by Type handler cannot be used with this table since the ' . $this->table . '_relationship table doesn\'t exist',
         ),
       );
-    } else {    
+    }
+    else {
       $form['rel_display_parts'] = array(
         '#type' => 'checkboxes',
         '#title' => t('Display Relationship Parts'),
@@ -63,29 +65,29 @@ class views_handler_field_chado_rel_by_type extends views_handler_field_prerende
         ),
         '#default_value' => array($this->options['rel_display_parts']['subject'], $this->options['rel_display_parts']['type'], $this->options['rel_display_parts']['object']),
       );
-      
+
       $form['rel_display_rels'] = array(
         '#type' => 'radios',
         '#title' => t('Display Relationships Where'),
         '#description' => t('Only relationships where the selected criteria is met will be shown. '
           .'The parts of a relationship are: [Subject] [Relationship Type] [Object]. '
           .'For example, with the relationships Sarah is the maternal parent of Fred and '
-          .'Fred is the paternal_parent of Max where Fred is the current '.$this->chado_type.', '
-          .'if you selected "Current '.$this->chado_type.' is the Object" only Sarah is the maternal parent of Fred'
+          .'Fred is the paternal_parent of Max where Fred is the current ' . $this->chado_type . ', '
+          .'if you selected "Current ' . $this->chado_type . ' is the Object" only Sarah is the maternal parent of Fred'
           .' would be displayed.'),
         '#options' => array(
-          'subject' => 'Current '.$this->chado_type.' is the Subject',
-          'object' => 'Current '.$this->chado_type.' is the Object',
-          'all' => 'Current '.$this->chado_type.' is the Subject and/or Object',
+          'subject' => 'Current ' . $this->chado_type . ' is the Subject',
+          'object' => 'Current ' . $this->chado_type . ' is the Object',
+          'all' => 'Current ' . $this->chado_type . ' is the Subject and/or Object',
         ),
         '#default_value' => $this->options['rel_display_rels'],
       );
-      
+
       $options = array();
       $sql = 'SELECT rel.type_id, cvt.name FROM %s_relationship rel LEFT JOIN cvterm cvt ON cvt.cvterm_id=rel.type_id GROUP BY rel.type_id,cvt.name';
       $previous_db = tripal_db_set_active('chado');
-      $resource = db_query($sql,$this->table);
-      tripal_db_set_active($previous_db);      
+      $resource = db_query($sql, $this->table);
+      tripal_db_set_active($previous_db);
       while ($r = db_fetch_object($resource)) {
         $options[ $r->type_id ] = $r->name;
       }
@@ -104,36 +106,36 @@ class views_handler_field_chado_rel_by_type extends views_handler_field_prerende
   function query() {
     $this->add_additional_fields();
   }
-  
+
   function pre_render($values) {
     $this->aliases['relationships'] = $this->chado_type . '_relationships';
     $chado_id = $this->table . '_id';
     $chado_relationship_id = $this->table . '_relationship_id';
     $this->aliases[$chado_id] = $chado_id;
     $this->field_alias = $this->aliases[$chado_id];
-    
+
     //check if relationships added to results, if not then add
     if (empty( $this->view->result[0]->{$this->aliases['relationships']} )) {
-      
+
       // retrieve the chado_id for each record in the views current page
       $chado_ids = array();
       foreach ($this->view->result as $row_num => $row) {
         $chado_ids[$row_num] = $row->{$chado_id};
       }
-      
+
       // Add relationships to the view results
       $sql = "SELECT rel.*, cvterm.name as type_name, "
         ."subject.name as subject_name, object.name as object_name "
-        ."FROM ".$this->table."_relationship rel "
-        ."LEFT JOIN ".$this->table." subject ON rel.subject_id=subject.".$chado_id." "
-        ."LEFT JOIN ".$this->table." object ON rel.object_id=object.".$chado_id." "
+        ."FROM " . $this->table . "_relationship rel "
+        ."LEFT JOIN " . $this->table . " subject ON rel.subject_id=subject." . $chado_id . " "
+        ."LEFT JOIN " . $this->table . " object ON rel.object_id=object." . $chado_id . " "
         ."LEFT JOIN cvterm cvterm ON rel.type_id = cvterm.cvterm_id "
-        ."WHERE rel.subject_id IN (".implode(',',$chado_ids).") "
-        ."OR rel.object_id IN (".implode(',',$chado_ids).") ";
+        ."WHERE rel.subject_id IN (" . implode(',', $chado_ids) . ") "
+        ."OR rel.object_id IN (" . implode(',', $chado_ids) . ") ";
       $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, $chado_ids)) {
           $key = array_search($r->subject_id, $chado_ids);
@@ -148,14 +150,14 @@ class views_handler_field_chado_rel_by_type extends views_handler_field_prerende
       }
 
     }
-    
+
     // add relationships to this field
     foreach ($this->view->result as $result) {
       if (!empty($result->{$this->aliases['relationships']})) {
         $relationships2keep = array_filter($this->options['rel_type_ids']);
-        
+
         // all relationships including the current chado guy
-        foreach ($result->{$this->aliases['relationships']} as $relationship) {      
+        foreach ($result->{$this->aliases['relationships']} as $relationship) {
           // perform filtering------
           //type
           if (!empty($this->options['rel_type_ids'])) {
@@ -163,18 +165,19 @@ class views_handler_field_chado_rel_by_type extends views_handler_field_prerende
               continue;
             }
           }
-          
+
           //"Display Relationships Where" criteria
           if (preg_match('/subject/', $this->options['rel_display_rels'])) {
             if ($relationship->{$chado_id} != $relationship->subject_id) {
               continue;
-            }      
-          } elseif (preg_match('/object/', $this->options['rel_display_rels'])) {
+            }
+          }
+          elseif (preg_match('/object/', $this->options['rel_display_rels'])) {
             if ($relationship->{$chado_id} != $relationship->object_id) {
               continue;
             }
           }
-          
+
           // Add relationship to the list of items to be rendered
           $this->items[$relationship->{$chado_id}][$relationship->{$chado_relationship_id}][$chado_id] = $relationship->{$chado_id};
           $this->items[$relationship->{$chado_id}][$relationship->{$chado_relationship_id}][$chado_relationship_id] = $relationship->{$chado_relationship_id};
@@ -186,13 +189,13 @@ class views_handler_field_chado_rel_by_type extends views_handler_field_prerende
           $this->items[$relationship->{$chado_id}][$relationship->{$chado_relationship_id}]['type_name'] = $relationship->type_name;
         }
       }
-    } 
-    
+    }
+
   }
 
   function render_item($count, $item) {
     $text = array();
-    
+
     // Render Parts
     if ($this->options['rel_display_parts']['subject']) {
       $text[] = $item['subject_name'];
@@ -203,7 +206,7 @@ class views_handler_field_chado_rel_by_type extends views_handler_field_prerende
     if ($this->options['rel_display_parts']['object']) {
       $text[] = $item['object_name'];
     }
-    
+
     return implode(' ', $text);
   }
 }

+ 3 - 2
tripal_views/views/handlers/views_handler_field_chado_tf_boolean.inc

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @file
  * A handler to provide proper displays for booleans.
  *
  * Allows for display of true/false, yes/no, on/off.
@@ -28,11 +29,11 @@ class views_handler_field_chado_tf_boolean extends views_handler_field_boolean {
     }
 
     if (isset($this->formats[$this->options['type']])) {
-      return preg_match('/t/',$value) ? $this->formats[$this->options['type']][0] : $this->formats[$this->options['type']][1];
+      return preg_match('/t/', $value) ? $this->formats[$this->options['type']][0] : $this->formats[$this->options['type']][1];
     }
     else {
       return preg_match('/t/', $value) ? $this->formats['yes-no'][0] : $this->formats['yes-no'][1];
     }
   }
-  
+
 }

+ 19 - 20
tripal_views/views/handlers/views_handler_field_cvterm_name.inc

@@ -1,8 +1,7 @@
-<?php 
-// $Id$
+<?php
 
 /**
- *
+ * @file
  * @ingroup views_field_handlers
  * @ingroup tripal_core
  */
@@ -12,16 +11,16 @@ class views_handler_field_cvterm_name extends views_handler_field {
    * Add join to the cvterm table and cvterm.name field to the query
    */
   function query() {
-      
+
     // if this table isn't a base table
     // if it is this can be done by describing a join between base table and cvterm
-    if (!preg_match('/^'.$this->view->base_table.'$/', $this->table)) {
+    if (!preg_match('/^' . $this->view->base_table . '$/', $this->table)) {
 
       //Want to add join: LEFT JOIN cvterm nd_experimentprop_cvterm ON nd_experimentprop.type_id = nd_experimentprop_cvterm.cvterm_id
-      //===============================================================      
+      //===============================================================
 
       $this->query->ensure_table($this->table);
-      
+
       // add to table_queue--------------------------------------------
       $cvterm_join['table'] = 'cvterm';
       $cvterm_join['num'] = 1;
@@ -33,7 +32,7 @@ class views_handler_field_cvterm_name extends views_handler_field {
       $cvterm_join['join']->field = 'cvterm_id';
       $cvterm_join['join']->left_table = $this->table;
       $cvterm_join['join']->left_field = 'type_id';
-      
+
       $cvterm_join['join']->definition['table'] = 'cvterm';
       $cvterm_join['join']->definition['field'] = 'cvterm_id';
       $cvterm_join['join']->definition['left_table'] = $this->table;
@@ -42,26 +41,26 @@ class views_handler_field_cvterm_name extends views_handler_field {
       $this->query->table_queue[$cvterm_join['alias']] = $cvterm_join;
 
       // add to table--------------------------------------------------
-      $this->query->tables[$this->view->base_table][$this->table.'_cvterm'] = array(
+      $this->query->tables[$this->view->base_table][$this->table . '_cvterm'] = array(
         'count' => 1,
-        'alias' => $this->table.'_cvterm',
-      );    
+        'alias' => $this->table . '_cvterm',
+      );
 
       //Want to add field: nd_experimentprop_cvterm.name as nd_experimentprop_type
       //===============================================================
-      $field_alias = $this->table.'_cvterm_name';
-      $this->query->add_field($this->table.'_cvterm', 'name');
+      $field_alias = $this->table . '_cvterm_name';
+      $this->query->add_field($this->table . '_cvterm', 'name');
       $this->add_additional_fields();
-      $this->aliases['name'] = $field_alias;  
-      
+      $this->aliases['name'] = $field_alias;
+
     }
   }
-  
+
   /**
    * Ensure that the type/cvterm name is rendered
    */
- function render($values) { 
-   return $values->{$this->aliases['name']}; 
- }
-  
+  function render($values) {
+    return $values->{$this->aliases['name']};
+  }
+
 }

+ 39 - 34
tripal_views/views/handlers/views_handler_field_dbxref_accession_link.inc

@@ -1,42 +1,47 @@
 <?php
 
 /**
+ * @file
+ * Used for a custom field so that field can render the database reference link
  *
  * @ingroup views_field_handlers
  * @ingroup tripal_core
  */
 class views_handler_field_dbxref_accession_link extends views_handler_field {
- function construct() {
-   parent::construct();
-   $this->additional_fields['accession'] = 'accession';
-   $this->additional_fields['db_id'] = 'db_id';
-
- }
-
- function query() { 
-   $this->ensure_my_table();
-   $this->add_additional_fields(); 
- }
-
- function render($values) { 
-
-   $accession = $values->{$this->aliases['accession']}; 
-   $db_id = $values->{$this->aliases['db_id']};
-
-   if (!empty($db_id) AND !empty($accession)) {
-     $previous_db = tripal_db_set_active('chado');
-     $result = db_fetch_object(db_query('SELECT urlprefix FROM db WHERE db_id=%d', $db_id));
-     tripal_db_set_active($previous_db);   
-     $urlprefix = $result->urlprefix;
-
-     if (!empty($urlprefix)) {
-       $accession_link = $urlprefix . $accession;
-       return($accession_link); 
-     } else {
-       return $accession;
-     }
-   } else {
-     return $accession;
-   }
- } 
-} 
+  function construct() {
+    parent::construct();
+
+    $this->additional_fields['accession'] = 'accession';
+    $this->additional_fields['db_id'] = 'db_id';
+
+  }
+
+  function query() {
+    $this->ensure_my_table();
+    $this->add_additional_fields();
+  }
+
+  function render($values) {
+
+    $accession = $values->{$this->aliases['accession']};
+    $db_id = $values->{$this->aliases['db_id']};
+
+    if (!empty($db_id) AND !empty($accession)) {
+      $previous_db = tripal_db_set_active('chado');
+      $result = db_fetch_object(db_query('SELECT urlprefix FROM db WHERE db_id=%d', $db_id));
+      tripal_db_set_active($previous_db);
+      $urlprefix = $result->urlprefix;
+
+      if (!empty($urlprefix)) {
+        $accession_link = $urlprefix . $accession;
+        return $accession_link;
+      }
+      else {
+        return $accession;
+      }
+    }
+    else {
+      return $accession;
+    }
+  }
+}

+ 17 - 14
tripal_views/views/handlers/views_handler_field_node_optional.inc

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @file
  * Field handler to provide simple renderer that allows linking to a node.
  *
  * @ingroup views_field_handlers
@@ -15,12 +16,12 @@ class views_handler_field_node_optional extends views_handler_field_node {
       $this->additional_fields['language'] = array('table' => 'node', 'field' => 'language');
     }
   }
-  
+
   /**
    * Add chado_* and *_node alias'd left joins to the table
    */
   function query() {
-    
+
     // Check what we have (ie: current table? node table? )
     $chado_table = 'chado_' . $this->table;
     foreach ($this->query->table_queue as $table_def) {
@@ -28,21 +29,21 @@ class views_handler_field_node_optional extends views_handler_field_node {
       if ($table_def['table'] == $this->table) {
         $this_table_alias = $table_def['alias'];
       }
-      
+
       // check is node joined to #this->table
       if ($table_def['table'] == $chado_table) {
         $node_table_alias = $table_def['alias'];
       }
     }
-    
+
     // First: Add the main field-----------------------------------------------
     if (!$this_table_alias) {
       $this_table_alias = $this->ensure_my_table();
     }
-    $field_alias = $this->query->add_field($this_table_alias, $this->real_field); 
+    $field_alias = $this->query->add_field($this_table_alias, $this->real_field);
     $this->aliases[ $this->real_field ] = $field_alias;
     $this->field_alias = $field_alias;
-    
+
     // Second: Add nid field and Joins if necessary----------------------------
     // Add node join if needed
     if (!$node_table_alias) {
@@ -50,18 +51,18 @@ class views_handler_field_node_optional extends views_handler_field_node {
       $def['field'] = $this->table . '_id';
       $def['left_table'] = $this_table_alias;
       $def['left_field'] = $this->table . '_id';
-      
+
       $join = new views_join();
       $join->definition = $def;
       $join->construct();
       $join->adjusted = TRUE;
-    
+
       $node_table_alias = $this->query->add_relationship($def['table'], $join, $def['table']);
     }
-    
+
     // Finally Add Field
-    $field_alias = $this->query->add_field($node_table_alias, 'nid'); 
-    $this->aliases['nid'] = $field_alias;   
+    $field_alias = $this->query->add_field($node_table_alias, 'nid');
+    $this->aliases['nid'] = $field_alias;
 
   }
 
@@ -71,7 +72,7 @@ class views_handler_field_node_optional extends views_handler_field_node {
    * Data should be made XSS safe prior to calling this function.
    */
   function render_link($data, $values) {
-    if (!empty($this->options['link_to_node']) && $data !== NULL && $data !== '') {  
+    if (!empty($this->options['link_to_node']) && $data !== NULL && $data !== '') {
       if (!empty($values->{$this->aliases['nid']})) {
         $this->options['alter']['make_link'] = TRUE;
         $this->options['alter']['path'] = "node/" . $values->{$this->aliases['nid']};
@@ -84,11 +85,13 @@ class views_handler_field_node_optional extends views_handler_field_node {
             unset($this->options['alter']['language']);
           }
         }
-      } else {
+      }
+      else {
         $this->options['alter']['make_link'] = FALSE;
-        $this->options['alter']['path'] = "";        
+        $this->options['alter']['path'] = "";
       }
     }
+
     return $data;
   }
 }

+ 2 - 1
tripal_views/views/handlers/views_handler_field_readable_date.inc

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @file
  * A handler to provide proper displays for dates.
  *
  * @ingroup views_field_handlers
@@ -56,7 +57,7 @@ class views_handler_field_readable_date extends views_handler_field {
     if (in_array($format, array('custom', 'raw time ago', 'time ago', 'raw time span', 'time span'))) {
       $custom_format = $this->options['custom_date_format'];
     }
-    
+
     if (!$value) {
       return theme('views_nodate');
     }

+ 8 - 8
tripal_views/views/handlers/views_handler_field_type_name.inc

@@ -1,16 +1,16 @@
 <?php
 
 /**
- *
+ * @file
  * @ingroup views_field_handlers
  * @ingroup tripal_core
  */
 class views_handler_field_type_name extends views_handler_field {
- function construct() {
-   parent::construct();
- }
+  function construct() {
+    parent::construct();
+  }
 
- function render($values) { 
-   return $values->property_type_name;
- } 
-} 
+  function render($values) {
+    return $values->property_type_name;
+  }
+}

+ 16 - 14
tripal_views/views/handlers/views_handler_filter_chado_boolean.inc

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @file
  * Purpose: This handler provides a TRUE/FALSE or YES/NO select for chado fields
  *  of type boolean (includes both 0/1 and t/f booleans)
  *
@@ -10,17 +11,14 @@
 class views_handler_filter_chado_boolean extends views_handler_filter_boolean_operator {
  /**
   * Checks if this field uses 0/1 or t/f
+  * @todo Implement LIMIT 1 functionality for tripal_core_chado_select().
   */
   function init(&$view, $options) {
     parent::init($view, $options);
-    
-    $sql = 'SELECT '.$this->field.' FROM '.$this->table.' LIMIT 1';
-    $previous_db = tripal_db_set_active('chado');
-    $result = db_fetch_object(db_query($sql));
-    tripal_db_set_active($previous_db);
-    
+
+    $results = tripal_core_chado_select($this->table, array($this->field), array());
     $this->boolean_type_tf = FALSE;
-    if (preg_match('/[tf]/', $result->{$this->field})) {
+    if (preg_match('/[tf]/', $results[0]->{$this->field})) {
       $this->boolean_type_tf = TRUE;
     }
 
@@ -46,8 +44,9 @@ class views_handler_filter_chado_boolean extends views_handler_filter_boolean_op
       // Provide a fallback if the above didn't set anything.
       if (!isset($this->value_options)) {
         $this->value_options = array('t' => t('True'), 'f' => t('False'));
-      }    
-    } else { //end of t/f boolean
+      }
+    }
+    else { //end of t/f boolean
       if (isset($this->definition['type'])) {
         if ($this->definition['type'] == 'yes-no') {
           $this->value_options = array(1 => t('Yes'), 0 => t('No'));
@@ -70,19 +69,22 @@ class views_handler_filter_chado_boolean extends views_handler_filter_boolean_op
     $where = "$this->table_alias.$this->real_field ";
 
     if ($this->boolean_type_tf) {
-      if (preg_match('/f/',$this->value)) {
+      if (preg_match('/f/', $this->value)) {
         $where .= "= 'f'";
-      } else {
+      }
+      else {
         $where .= "= 't'";
       }
-      $this->query->add_where($this->options['group'], $where);    
-    } else {
+      $this->query->add_where($this->options['group'], $where);
+    }
+    else {
       if (empty($this->value)) {
         $where .= '= 0';
         if ($this->accept_null) {
           $where = '(' . $where . " OR $this->table_alias.$this->real_field IS NULL)";
         }
-      } else {
+      }
+      else {
         $where .= '<> 0';
       }
       $this->query->add_where($this->options['group'], $where);

+ 81 - 68
tripal_views/views/handlers/views_handler_filter_chado_select_cvterm_name.inc

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @file
  * Purpose: This Handler provides a select list for the type field
  *
  *  NOTE: This handler only works when applied to the type_id field in the base_table of
@@ -12,56 +13,63 @@
 class views_handler_filter_chado_select_cvterm_name extends views_handler_filter_string {
 
  /**
-	* Executed when the field is added
-	* Determine which cv to limit the cvterms to
-	*/
+  * Executed when the field is added
+  * Determine which cv to limit the cvterms to
+  */
   function init(&$view, $options) {
     parent::init($view, $options);
-  	
-  	if ($this->options['show_all']) {
-        $cv_id = variable_get('chado_'.$this->view->base_table.'_cv', null);
-        if ($cv_id) {
-          $results = tripal_core_chado_select('cvterm',array('cvterm_id','name'), array('cv_id'=>$cv_id));	
-          if (empty($results)) { $results = array(); }
-          foreach ($results as $c) {
-            $cvterms[$c->cvterm_id] = $c->name;
-          }    	
-        } else {
-          //get a list of cvs currently used
-          if ($this->view->base_table == 'cvterm') {
-            $sql = 'SELECT distinct(cv.cv_id) FROM '.$this->view->base_table
-              .' LEFT JOIN cv cv ON cv.cv_id=cvterm.cv_id';	
-          } else {
-            $sql = 'SELECT distinct(cv.cv_id) FROM '.$this->view->base_table
-              .' LEFT JOIN cvterm cvterm ON cvterm.cvterm_id='.$this->view->base_table.'.type_id '
-              .'LEFT JOIN cv cv ON cv.cv_id=cvterm.cv_id';
-          }
-          $previous_db = tripal_db_set_active('chado');
-          $resource = db_query($sql);
-          tripal_db_set_active($previous_db);
-          $cvterms = array();
-          while ( $r = db_fetch_object($resource) ) {
-            $results = tripal_core_chado_select('cvterm',array('cvterm_id','name'), array('cv_id'=>$r->cv_id));	
-            if (empty($results)) { $results = array(); }
-            foreach ($results as $c) {
-              $cvterms[$c->cvterm_id] = $c->name;
-            }
-          }
-        }// end of if variable not defined
-    
-    } else {
-        $sql = "SELECT cvterm_id, name FROM cvterm WHERE cvterm_id IN (SELECT distinct(type_id) FROM %s)";
+
+    if ($this->options['show_all']) {
+      $cv_id = variable_get('chado_' . $this->view->base_table . '_cv', NULL);
+      if ($cv_id) {
+        $results = tripal_core_chado_select('cvterm', array('cvterm_id', 'name'), array('cv_id' => $cv_id));
+        if (empty($results)) {
+          $results = array();
+        }
+        foreach ($results as $c) {
+          $cvterms[$c->cvterm_id] = $c->name;
+        }
+      }
+      else {
+        //get a list of cvs currently used
+        if ($this->view->base_table == 'cvterm') {
+          $sql = 'SELECT distinct(cv.cv_id) FROM ' . $this->view->base_table
+            .' LEFT JOIN cv cv ON cv.cv_id=cvterm.cv_id';
+        }
+        else {
+          $sql = 'SELECT distinct(cv.cv_id) FROM ' . $this->view->base_table
+            .' LEFT JOIN cvterm cvterm ON cvterm.cvterm_id=' . $this->view->base_table . '.type_id '
+            .'LEFT JOIN cv cv ON cv.cv_id=cvterm.cv_id';
+        }
         $previous_db = tripal_db_set_active('chado');
-        $resource = db_query($sql, $this->view->base_table);
+        $resource = db_query($sql);
         tripal_db_set_active($previous_db);
         $cvterms = array();
         while ( $r = db_fetch_object($resource) ) {
-          $cvterms[$r->cvterm_id] = $r->name;
-        }        
+          $results = tripal_core_chado_select('cvterm', array('cvterm_id', 'name'), array('cv_id' => $r->cv_id));
+          if (empty($results)) {
+            $results = array();
+          }
+          foreach ($results as $c) {
+            $cvterms[$c->cvterm_id] = $c->name;
+          }
+        }
+      }// end of if variable not defined
+
+    }
+    else {
+      $sql = "SELECT cvterm_id, name FROM cvterm WHERE cvterm_id IN (SELECT distinct(type_id) FROM %s)";
+      $previous_db = tripal_db_set_active('chado');
+      $resource = db_query($sql, $this->view->base_table);
+      tripal_db_set_active($previous_db);
+      $cvterms = array();
+      while ( $r = db_fetch_object($resource) ) {
+        $cvterms[$r->cvterm_id] = $r->name;
+      }
     }
     //sort cvterms by name (case insensitive)
     natcasesort($cvterms);
-    
+
     //add to this handler
     $this->cvterm_options = $cvterms;
   }
@@ -74,7 +82,7 @@ class views_handler_filter_chado_select_cvterm_name extends views_handler_filter
 
     $form['values_form_type'] = array(
       '#type' => 'radios',
-      '#title' => 'Filter Type',
+      '#title' => t('Filter Type'),
       '#options' => array(
         'textfield' => 'Text Field',
         'select' => 'Drop-Down Box',
@@ -95,90 +103,95 @@ class views_handler_filter_chado_select_cvterm_name extends views_handler_filter
       '#description' => t('Adds --Any-- to the available options.'),
       '#default_value' => (isset($this->options['optional'])) ? $this->options['optional'] : TRUE,
     );
-    
+
     $form['show_all'] = array(
       '#type' => 'checkbox',
-      '#title' => 'Show All Terms',
+      '#title' => t('Show All Terms'),
       '#description' => 'Otherwise only cvterms used in the base table will be used'
     );
   }
-  
+
  /**
   * Alters the query so that WHERE cvterm.cvterm_id=212 is used
   */
   function query() {
     $this->ensure_table;
-    
+
     if ($this->options['multiple']) {
       // Remove any if it's there
       unset($this->value['All']);
-      
+
       if (sizeof($this->value)) {
         $holders = array();
         foreach ($this->value as $v) {
-          if (preg_match('/^[\d\.]+$/',$v)) {
+          if (preg_match('/^[\d\.]+$/', $v)) {
             $holders[] = '%d';
-          } else {
+          }
+          else {
             $holders[] = "'%s'";
           }
         }
-        $where = "cvterm.cvterm_id IN (".implode(", ",$holders).")";
+        $where = "cvterm.cvterm_id IN (" . implode(", ", $holders) . ")";
       }
-    } else {
+    }
+    else {
       if (preg_match('/^\d+$/', $this->value)) {
         $where = 'cvterm.cvterm_id=%d';
-      } else {
+      }
+      else {
         $where = "cvterm.name" . $this->operator . "'%s'";
       }
     }
-    
+
     if ($where) {
       $this->query->add_where($this->options['group'], $where, $this->value);
     }
   }
-  
+
  /**
   * 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);
-    
+
     if (preg_match('/select/', $this->options['values_form_type'])) {
       // Get Options
       if ($this->options['optional']) {
-        $options['<select '.$this->table.'>'] = '--None--';
+        $options['<select ' . $this->table . '>'] = '--None--';
         $options['All'] = '--Any--';
       }
       $max_length = 40;
       foreach ($this->cvterm_options as $cvterm_id => $cvterm_name) {
-        if (strlen($cvterm_name) > $max_length) {
-          $options[$cvterm_id] = substr($cvterm_name,0,$max_length) . '...';
-        } else {
-          $options[$cvterm_id] = $cvterm_name;    
+        if (drupal_strlen($cvterm_name) > $max_length) {
+          $options[$cvterm_id] = drupal_substr($cvterm_name, 0, $max_length) . '...';
+        }
+        else {
+          $options[$cvterm_id] = $cvterm_name;
         }
       }
-      
+
       if (empty($options)) {
         $options[0] = '';
       }
-      
+
       //Select List
       $form['value'] = array(
           '#type' => 'select',
-          '#title' => $this->options['label'],
+          '#title' => t('%label', array('%label' => $this->options['label'])),
           '#options' => $options,
           '#default_value' => $this->value,
       );
-      
+
       if ($this->options['multiple']) {
         $form['value']['#multiple'] = TRUE;
       }
-    
-    } else {
+
+    }
+    else {
       $form['value'] = array(
         '#type' => 'textfield',
-        '#title' => $this->options['label'],
+        '#title' => t('%label', array('%label' => $this->options['label'])),
         '#default_value' => $this->value,
       );
     }
@@ -242,7 +255,7 @@ class views_handler_filter_chado_select_cvterm_name extends views_handler_filter
         'values' => 1,
       ),
     );
-    
+
     return $operators;
   }
 }

+ 37 - 29
tripal_views/views/handlers/views_handler_filter_chado_select_string.inc

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @file
  * Purpose: This Handler provides a generic select list for any chado field that is a string
  *  The select list includes all distinct values for that field.
  *
@@ -14,14 +15,14 @@ class views_handler_filter_chado_select_string extends views_handler_filter_stri
 
     $form['values_form_type'] = array(
       '#type' => 'radios',
-      '#title' => 'Filter Type',
+      '#title' => t('Filter Type'),
       '#options' => array(
         'textfield' => 'Text Field',
         'select' => 'Drop-Down Box',
       ),
       '#default_value' => ($this->options['values_form_type']) ? $this->options['values_form_type'] : 'select',
     );
-    
+
     $form['multiple'] = array(
       '#type' => 'checkbox',
       '#title' => t('Select Multiple'),
@@ -35,7 +36,7 @@ class views_handler_filter_chado_select_string extends views_handler_filter_stri
       '#description' => t('Adds --Any-- to the available options.'),
       '#default_value' => (isset($this->options['optional'])) ? $this->options['optional'] : TRUE,
     );
- 
+
     $form['max_length'] = array(
       '#type' => 'textfield',
       '#title' => t('Max Width'),
@@ -43,23 +44,26 @@ class views_handler_filter_chado_select_string extends views_handler_filter_stri
       '#default_value' => (isset($this->options['max_length'])) ? $this->options['max_length'] : 40,
 
     );
-    
+
   }
-  
+
  /**
   * 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);
-    
+
     if (preg_match('/textfield/', $this->options['values_form_type'])) {
       $form['value'] = array(
         '#type' => 'textfield',
-        '#title' => $this->options['label'],
+        '#title' => t('%label', array('%label' => $this->options['label'])),
         '#default_value' => $this->value,
-      );    
-    } else {
+      );
+
+    }
+    else {
+
       // Get Options
       if ($this->options['optional']) {
         //$options['<select '.$this->table.'>'] = '--None--';
@@ -68,27 +72,28 @@ class views_handler_filter_chado_select_string extends views_handler_filter_stri
       $sql = "SELECT $this->field FROM $this->table ORDER BY $this->field ASC";
       $previous_db = tripal_db_set_active('chado');  // use chado database
       $results = db_query($sql);
-      tripal_db_set_active($previous_db);  // now use drupal database 
+      tripal_db_set_active($previous_db);  // now use drupal database
       $max_length = $this->options['max_length'];
-      if(!$max_length){
-         $max_length = 40;
+      if (!$max_length) {
+        $max_length = 40;
       }
-      while($r = db_fetch_object($results)){
-        if (strlen($r->{$this->field}) > $max_length) {
-          $options[$r->{$this->field}] = substr($r->{$this->field},0,$max_length) . '...';
-        } else {
-          $options[$r->{$this->field}] = $r->{$this->field};    
+      while ($r = db_fetch_object($results)) {
+        if (drupal_strlen($r->{$this->field}) > $max_length) {
+          $options[$r->{$this->field}] = drupal_substr($r->{$this->field}, 0, $max_length) . '...';
+        }
+        else {
+          $options[$r->{$this->field}] = $r->{$this->field};
         }
       }
-      
+
       //Select List
       $form['value'] = array(
           '#type' => 'select',
-          '#title' => $this->options['label'],
+          '#title' => t('%label', array('%label' => $this->options['label'])),
           '#options' => $options,
           '#default_value' => $this->value,
       );
-      
+
       if ($this->options['multiple']) {
         $form['value']['#multiple'] = TRUE;
       }
@@ -131,7 +136,7 @@ class views_handler_filter_chado_select_string extends views_handler_filter_stri
   *
   */
   function query() {
-  
+
     $this->ensure_my_table();
     $field = "$this->table_alias.$this->real_field";
     $upper = $this->case_transform();
@@ -139,25 +144,28 @@ class views_handler_filter_chado_select_string extends views_handler_filter_stri
     if ($this->options['multiple']) {
       // Remove any if it's there
       unset($this->value['All']);
-      
+
       if (sizeof($this->value)) {
         $holders = array();
         foreach ($this->value as $v) {
-          if (preg_match('/^[\d\.]+$/',$v)) {
+          if (preg_match('/^[\d\.]+$/', $v)) {
             $holders[] = '%d';
-          } else {
+          }
+          else {
             $holders[] = "'%s'";
           }
         }
-        $where = "$field IN (".implode(", ",$holders).")";
+        $where = "$field IN (" . implode(", ", $holders) . ")";
         $this->query->add_where($this->options['group'], $where, $this->value);
       }
-    } else {
-  
+    }
+    else {
+
       // Deal with All/Any as value
       if (preg_match('/All/', $this->value)) {
-        // Don't do anything    
-      } else {
+        // Don't do anything
+      }
+      else {
         $info = $this->operators();
         if (!empty($info[$this->operator]['method'])) {
           $this->{$info[$this->operator]['method']}($field, $upper);

+ 65 - 69
tripal_views/views/handlers/views_handler_filter_file_upload.inc

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @file
  * Purpose: This Handler provides a file upload field by extending the
  * views_handler_filter object.
  *
@@ -8,26 +9,16 @@
  */
 class views_handler_filter_file_upload extends views_handler_filter {
 
-  function init(&$view,$options){
-     parent::init($view,$options);
-
-  }
-
-  function options_form(&$form, &$form_state) {
-    parent::options_form($form, $form_state);
-
-  }
-
   /**
-  * Defines the value field in both the views filter options form
-  *   and the exposed form
-  */
+   * 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'],
+       '#title' => t('%label', array('%label' => $this->options['expose']['label'])),
        '#default_value' => $this->value,
        '#multiple' => FALSE,
        '#description' => t('Provide search values for %label. Please place each search
@@ -37,9 +28,9 @@ class views_handler_filter_file_upload extends views_handler_filter {
   }
 
   /**
-  * Ensures the upload field gets rendered when the filter is exposed. It also
-  * changes the form type from a GET to a POST so that file uploads will work.
-  */
+   * Ensures the upload field gets rendered when the filter is exposed. It also
+   * changes the form type from a GET to a POST so that file uploads will work.
+   */
   function exposed_form(&$form, &$form_state) {
 
     // don't do anything if the form isn't exposed.
@@ -64,69 +55,74 @@ class views_handler_filter_file_upload extends views_handler_filter {
     }
 
   }
+
   /**
    *  Validates the input form
    */
   function exposed_validate(&$form, &$form_state) {
      //dpm($form_state);
   }
+
   /**
    *
    */
   function query() {
-     $this->ensure_my_table();
-     $field = "$this->table.$this->real_field";
-
-     // get the form element value
-     $value = $this->value[0];
-
-     // the form element value has sub values, so get those
-     $items =  $value['items'];
-     $file_path = $value['file_path'];
-
-     $holders = array();
-     $values = array();
-
-     // get the file upload content if one has been provided
-     if($file_path){
-        $fh = fopen($file_path,'r');
-        while($line = fgets($fh)){
-           $items = trim($line);
-
-           // remove extra spaces and new lines
-           $items = preg_replace("/\s+,/",",",$items);
-           $items = preg_replace("/\s+\n/","\n",$items);
-           $items = preg_replace("/,\n/","\n",$items);
-
-           // add the values from this line to the values[] array
-           $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){
+    $this->ensure_my_table();
+    $field = "$this->table.$this->real_field";
+
+    // get the form element value
+    $value = $this->value[0];
+
+    // the form element value has sub values, so get those
+    $items =  $value['items'];
+    $file_path = $value['file_path'];
+
+    $holders = array();
+    $values = array();
+
+    // get the file upload content if one has been provided
+    if ($file_path) {
+      $fh = fopen($file_path, 'r');
+      while ($line = fgets($fh)) {
+        $items = trim($line);
 
         // remove extra spaces and new lines
-        $items = preg_replace("/\s+,/",",",$items);
-        $items = preg_replace("/\s+\n/","\n",$items);
-        $items = preg_replace("/,\n/","\n",$items);
-
-        // in the event the user uploaded a file and provided items in the
-        // textbox then we need to merge these two lists
-        $vals = preg_split("/[\n,]+/",$items);
-        $values = array_merge($values,$vals);
-     }
-     // iterate through all of the values and generate the corresponding
-     // sprintf style holders
-     for($i = 0 ; $i < count($values); $i++){
-        $values[$i] = trim($values[$i]);
-        $holders[] = "'%s'";
-     }
-     // if we have any values supplied then update the where clause for
-     // the views query
-     if(count($holders) > 0){
-        $where = "$field IN (".implode(", ",$holders).")";
-        $this->query->add_where($this->options['group'], $where, $values);
-     }
+        $items = preg_replace("/\s+,/", ",", $items);
+        $items = preg_replace("/\s+\n/", "\n", $items);
+        $items = preg_replace("/,\n/", "\n", $items);
+
+        // add the values from this line to the values[] array
+        $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) {
+
+      // remove extra spaces and new lines
+      $items = preg_replace("/\s+,/", ",", $items);
+      $items = preg_replace("/\s+\n/", "\n", $items);
+      $items = preg_replace("/,\n/", "\n", $items);
+
+      // in the event the user uploaded a file and provided items in the
+      // textbox then we need to merge these two lists
+      $vals = preg_split("/[\n,]+/", $items);
+      $values = array_merge($values, $vals);
+    }
+
+    // iterate through all of the values and generate the corresponding
+    // sprintf style holders
+    for ($i = 0 ; $i < count($values); $i++) {
+      $values[$i] = trim($values[$i]);
+      $holders[] = "'%s'";
+    }
+
+    // if we have any values supplied then update the where clause for
+    // the views query
+    if (count($holders) > 0) {
+      $where = "$field IN (" . implode(", ", $holders) . ")";
+      $this->query->add_where($this->options['group'], $where, $values);
+    }
   }
 }

+ 21 - 15
tripal_views/views/handlers/views_handler_filter_no_results.inc

@@ -1,5 +1,11 @@
 <?php
 
+/**
+ * @file
+ * This filter ensures that when a page is first loaded, there are no results (ie: the
+ * query is not run). This imitates an advanced search form allowing users to fist
+ * enter other filter values and then retrieve results.
+ */
 class views_handler_filter_no_results extends views_handler_filter {
 
   /**
@@ -8,12 +14,12 @@ class views_handler_filter_no_results extends views_handler_filter {
   function can_expose() {
     return FALSE;
   }
-  
+
   /**
    * 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' => t('This filter ensures that when the page is first loaded, there are no results '
@@ -22,56 +28,56 @@ class views_handler_filter_no_results extends views_handler_filter {
         .'large number of results if left unfiltered since it removes the long load time before '
         .'even allowing users the ability to filter down the results.')
     );
-    
+
     $form['apply_button'] = array(
       '#type' => 'textfield',
       '#title' => 'Apply Button Text',
       '#default_value' => isset($this->options['apply_button']) ? $this->options['apply_button'] : 'Search'
     );
-    
+
     $form['no_results_text'] = array(
       '#type' => 'textarea',
       '#title' => 'Header Text before Search',
       '#description' => 'This text will replace the no results text when the view is first loaded (before the user clicks Apply/Search)',
       '#default_value' => isset($this->options['no_results_text']) ? $this->options['no_results_text'] : ''
     );
-    
+
   }
-  
+
   function query() {
     global $base_url;
-    
+
     if (empty($this->view->exposed_input)) {
       $this->view->executed = TRUE;
-      
+
       $jquery_loaded = FALSE;
-      
+
       // If set, change the no_results text
       if (!empty($this->options['apply_button'])) {
         if (!$jquery_loaded) {
-          drupal_set_html_head('<script type="text/javascript" src="'.$base_url.'/misc/jquery.js"></script>');
+          drupal_set_html_head('<script type="text/javascript" src="' . $base_url . '/misc/jquery.js"></script>');
           $jquery_loaded = TRUE;
         }
         $javascript = '<script type="text/javascript">'."\n"
           ."$(document).ready(function(){\n"
-          ."  $('div.view-empty').html('".addslashes($this->options['no_results_text'])."');\n"
+          ."  $('div.view-empty').html('" . addslashes($this->options['no_results_text']) . "');\n"
           ."});\n"
           .'</script>'."\n";
         drupal_set_html_head($javascript);
       }
     }
-    
+
     // Set the Apply button text
     if (!empty($this->options['apply_button'])) {
       if (!$jquery_loaded) {
-        drupal_set_html_head('<script type="text/javascript" src="'.$base_url.'/misc/jquery.js"></script>');
+        drupal_set_html_head('<script type="text/javascript" src="' . $base_url . '/misc/jquery.js"></script>');
         $jquery_loaded = TRUE;
       }
       $javascript = '<script type="text/javascript">'."\n"
         ."$(document).ready(function(){\n"
-        ."  $('div.views-submit-button').html(".'"'."<input type='submit' id='edit-submit-all-analysis' value='".$this->options['apply_button']."' class='form-submit'>".'"'.");\n"
+        ."  $('div.views-submit-button').html(" . '"' . "<input type='submit' id='edit-submit-all-analysis' value='" . $this->options['apply_button'] . "' class='form-submit'>" . '"' . ");\n"
         ."});\n"
-        .'</script>'."\n";
+        .'</script>' . "\n";
       drupal_set_html_head($javascript);
     }
   }

+ 59 - 49
tripal_views/views/handlers/views_handler_join_chado_aggregator.inc

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @file
  * Handler to allow joins between records via a linking table
  *
  * Example Usage:
@@ -21,7 +22,7 @@ class views_handler_join_chado_aggregator extends views_join {
   // the call to constructors upstream where appropriate.
   function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT', $added = NULL) {
     parent::construct($table, $left_table, $left_field, $field, $extra, $type);
-    
+
     // Determine the postgresql version
     $postgresql_version = pg_version();
     $this->postgresql_version = $postgresql_version['client'];
@@ -42,33 +43,33 @@ class views_handler_join_chado_aggregator extends views_join {
 
     // Create the table SQL (used in join) -------
     // query creating one-to-one table using array_agg
-    $table_desc = module_invoke_all('chado_'.$this->definition['table'].'_schema');
+    $table_desc = module_invoke_all('chado_' . $this->definition['table'] . '_schema');
     $select_fields[ $this->definition['table'] ] = $table_desc['fields'];
-    
+
     // Add joins to tables with a foreign key in this table
     // (ie: add join to cvterm if this table has a type_id
     $joins = array();
-    foreach($table_desc['foreign keys'] as $defn) {
+    foreach ($table_desc['foreign keys'] as $defn) {
       if ($defn['table'] != $this->left_table) {
-        foreach( $defn['columns'] as $left => $right) {
+        foreach ( $defn['columns'] as $left => $right) {
           $left = $this->definition['table'] .'.'. $left;
-          $right = $defn[table] .'.'. $right;
+          $right = $defn['table'] .'.'. $right;
           $joins[] = "LEFT JOIN $defn[table] $defn[table] ON $left=$right";
         }
-        
+
         // Fields to be selected from joined table
-        $join_table = module_invoke_all('chado_'.$defn['table'].'_schema');
+        $join_table = module_invoke_all('chado_' . $defn['table'] . '_schema');
         $select_fields[ $defn['table'] ] = $join_table['fields'];
-      } 
+      }
     }
-    
+
     // Determine Order BY's for aggregates
     $order_by = array();
     foreach ($this->sort as $s) {
-      $order_by[] = $s['table'].'.'.$s['field'].' '.$s['order'];
+      $order_by[] = $s['table'] . '.' . $s['field'] . ' ' . $s['order'];
     }
-    
-    
+
+
     // Fields to be selected
     foreach ($select_fields as $table => $table_fields) {
       foreach ($table_fields as $fname => $f) {
@@ -76,43 +77,46 @@ class views_handler_join_chado_aggregator extends views_join {
         if ($table != $this->definition['table']) {
           $alias = $table .'_';
         }
-        
+
         if ($fname != $this->definition['field']) {
           // Add sort to aggregate field if postgreSQL 9.0+
           if ($this->postgresql_9up && !empty($order_by)) {
-            $fields[] = 'array_agg('.$table.'.'.$fname.' ORDER BY '.implode(',',$order_by).') as '.$alias.$fname;
-          } else {
-            $fields[] = 'array_agg('.$table.'.'.$fname.') as '.$alias.$fname;
+            $fields[] = 'array_agg(' . $table . '.' . $fname . ' ORDER BY ' . implode(',', $order_by) . ') as ' . $alias . $fname;
+          }
+          else {
+            $fields[] = 'array_agg(' . $table . '.' . $fname . ') as ' . $alias . $fname;
           }
-          $composite_field_parts[] = "'".$alias.$fname."::' ||".$table.'.'.$fname;
-        } else {
+          $composite_field_parts[] = "'" . $alias . $fname . "::' ||" . $table . '.' . $fname;
+        }
+        else {
           $fields[] = $fname;
-          $composite_field_parts[] = "'".$alias.$fname."::' ||".$table.'.'.$fname;
+          $composite_field_parts[] = "'" . $alias . $fname . "::' ||" . $table . '.' . $fname;
         }
       }
     }
-    
-    // composite field 
+
+    // composite field
     // (combines all other fields before aggregating)
     // Add sort to aggregate field if postgreSQL 9.0+
     if ($this->postgresql_9up && !empty($order_by)) {
-      $composite_field = "array_agg('{'||".implode(" || ',' || ",$composite_field_parts)."||'}' ORDER BY ".implode(',',$order_by).") as all";
-    } else {
-      $composite_field = "array_agg('{'||".implode(" || ',' || ",$composite_field_parts)."||'}') as all";
+      $composite_field = "array_agg('{'||" . implode(" || ',' || ", $composite_field_parts) . "||'}' ORDER BY " . implode(',', $order_by) . ") as all";
+    }
+    else {
+      $composite_field = "array_agg('{'||" . implode(" || ',' || ", $composite_field_parts) . "||'}') as all";
     }
     $fields[] = $composite_field;
-    
+
     // SQL to use in the join
-    $sql = 'SELECT '.implode(', ',$fields)
-      .' FROM '.$this->definition['table']
-      .' '.implode(' ',$joins);
- 
+    $sql = 'SELECT ' . implode(', ', $fields)
+      .' FROM ' . $this->definition['table']
+      .' ' . implode(' ', $joins);
+
     if (!empty($this->filter)) {
-      $sql .= ' WHERE '.implode(', ', $this->filter);
+      $sql .= ' WHERE ' . implode(', ', $this->filter);
     }
-    
-    $sql .= ' GROUP BY '.$this->definition['field'];
-    
+
+    $sql .= ' GROUP BY ' . $this->definition['field'];
+
     // Create the join (full SQL) ----------------
     $output[] = $this->create_single_join(
       $query,
@@ -128,41 +132,47 @@ class views_handler_join_chado_aggregator extends views_join {
       ),
       'LEFT'
     );
-    
-    return implode("\n",$output);
+
+    return implode("\n", $output);
   }
-  
+
   /**
    * Creates SQL for a single join based on parameters
-   * Join will be: <type> JOIN (<query creating one-to-one table using array_agg>) <table alias> 
+   * Join will be: <type> JOIN (<query creating one-to-one table using array_agg>) <table alias>
    *                  ON <qualified left field>=<qualified right field>
    */
-  function create_single_join (&$query, $right_spec, $left_spec, $join_type) {
-    
+  function create_single_join(&$query, $right_spec, $left_spec, $join_type) {
+
     if ($right_spec['table']) {
       $right = $query->get_table_info($right_spec['table']);
-      if (!$right['alias']) { $right['alias'] = $right_spec['table']; }
+      if (!$right['alias']) {
+        $right['alias'] = $right_spec['table'];
+      }
       $right_field = "$right[alias].$right_spec[field]";
 
       if ($right_spec['is_drupal']) {
-        $right_table = '{'.$right_spec['table'].'}';
-      } else {
+        $right_table = '{' . $right_spec['table'] . '}';
+      }
+      else {
         $right_table = $right_spec['table'];
       }
-    }   
+    }
 
     if ($left_spec['table']) {
       $left = $query->get_table_info($left_spec['table']);
-      if (!$left['alias']) { $left['alias'] = $left_spec['table']; }
+      if (!$left['alias']) {
+        $left['alias'] = $left_spec['table'];
+      }
       $left_field = "$left[alias].$left_spec[field]";
-    } else {
+    }
+    else {
       // This can be used if left_field is a formula or something. It should be used only *very* rarely.
       $left_field = $this->left_spec['field'];
     }
-    
+
     $output = " $join_type JOIN ($right_spec[table_sql]) $right[alias] ON $left_field = $right_field";
-     
+
     return $output;
   }
- 
+
 }

+ 27 - 20
tripal_views/views/handlers/views_handler_join_chado_through_linking.inc

@@ -1,9 +1,10 @@
 <?php
 
-module_load_include('inc','views','includes/base');
-module_load_include('inc','views','includes/handlers');
+module_load_include('inc', 'views', 'includes/base');
+module_load_include('inc', 'views', 'includes/handlers');
 
 /**
+ * @file
  * Handler to allow joins between records via a linking table
  *
  * Example Usage:
@@ -20,10 +21,10 @@ module_load_include('inc','views','includes/handlers');
           'left_field' => 'feature_id',
           'field' => 'analysis_id',
           'handler' => 'views_handler_join_chado_through_linking'
-        ); 
+        );
  *   @endcode
  *
- * NOTE: If the right table is in the drupal schema rather then the chado schema 
+ * NOTE: If the right table is in the drupal schema rather then the chado schema
  *  (ie: node, chado_feature) then add the following to the above join description:
  *  @code
     'table_is_drupal' => TRUE
@@ -40,7 +41,7 @@ class views_handler_join_chado_through_linking extends views_join {
   function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT', $added = NULL) {
     parent::construct($table, $left_table, $left_field, $field, $extra, $type);
   }
-  
+
   /**
    * Creates SQL for both joins table => linking_table and linking_table => left_table
    * NOTE: Uses fields in definition as passed in from hook_views_data join definition
@@ -62,7 +63,7 @@ class views_handler_join_chado_through_linking extends views_join {
       ),
       'LEFT'
     );
-    
+
     $joins[] = $this->create_single_join(
       $query,
       array(
@@ -76,40 +77,46 @@ class views_handler_join_chado_through_linking extends views_join {
       ),
       'LEFT'
     );
-    
-    $output .= implode("\n",$joins);
+
+    $output .= implode("\n", $joins);
     return $output;
   }
-  
+
   /**
    * Creates SQL for a single join based on parameters
    */
-  function create_single_join (&$query, $right_spec, $left_spec, $join_type) {
-    
+  function create_single_join(&$query, $right_spec, $left_spec, $join_type) {
+
     if ($right_spec['table']) {
       $right = $query->get_table_info($right_spec['table']);
-      if (!$right['alias']) { $right['alias'] = $right_spec['table']; }
+      if (!$right['alias']) {
+        $right['alias'] = $right_spec['table'];
+      }
       $right_field = "$right[alias].$right_spec[field]";
 
       if ($right_spec['is_drupal']) {
-        $right_table = '{'.$right_spec['table'].'}';
-      } else {
+        $right_table = '{' . $right_spec['table'] . '}';
+      }
+      else {
         $right_table = $right_spec['table'];
       }
-    }   
+    }
 
     if ($left_spec['table']) {
       $left = $query->get_table_info($left_spec['table']);
-      if (!$left['alias']) { $left['alias'] = $left_spec['table']; }
+      if (!$left['alias']) {
+        $left['alias'] = $left_spec['table'];
+        }
       $left_field = "$left[alias].$left_spec[field]";
-    } else {
+    }
+    else {
       // This can be used if left_field is a formula or something. It should be used only *very* rarely.
       $left_field = $this->left_spec['field'];
     }
-    
+
     $output = " $join_type JOIN $right_table $right[alias] ON $left_field = $right_field";
-     
+
     return $output;
   }
- 
+
 }

+ 1 - 1
tripal_views/views_data_export/plugins/tripal_views_plugin_style_export_fasta.inc

@@ -20,7 +20,7 @@ class tripal_views_plugin_style_export_fasta extends views_data_export_plugin_st
   function option_definition() {
     $options = parent::option_definition();
 
-  
+
     return $options;
   }
 

+ 24 - 12
tripal_views/views_data_export/theme/tripal_views_data_export.theme.inc

@@ -1,17 +1,29 @@
 <?php
 
+/**
+ * @file
+ * Contains template preprocessing functions
+ */
+
+/**
+ * Preprocess the variables for the FASTA views data export -body template
+ *   - replace the field tokens in the fasta record definition lines
+ *
+ * @param $vars
+ *   The variables available to the template
+ */
 function template_preprocess_views_data_export_fasta_body(&$vars) {
-   _views_data_export_header_shared_preprocess($vars);
-   _views_data_export_body_shared_preprocess($vars);
-   $defline_tpl = $vars['options']['defline_fields'];
+  _views_data_export_header_shared_preprocess($vars);
+  _views_data_export_body_shared_preprocess($vars);
+  $defline_tpl = $vars['options']['defline_fields'];
 
-   // iterate through the rows and replace the field tokens with values
-   // to generate the definition line
-   foreach ($vars['themed_rows'] as $i => $fields) {
-      $defline = $defline_tpl;
-      foreach ($fields as $key => $value) {
-         $defline = preg_replace("/\[$key\]/",$value,$defline);
-      }
-      $vars['themed_rows'][$i]['defline'] = $defline;
-   }
+  // iterate through the rows and replace the field tokens with values
+  // to generate the definition line
+  foreach ($vars['themed_rows'] as $i => $fields) {
+    $defline = $defline_tpl;
+    foreach ($fields as $key => $value) {
+      $defline = preg_replace("/\[$key\]/", $value, $defline);
+    }
+    $vars['themed_rows'][$i]['defline'] = $defline;
+  }
 }

+ 29 - 12
tripal_views/views_data_export/theme/views-data-export-fasta-body.tpl.php

@@ -1,19 +1,36 @@
 <?php
+
+/**
+ * @file
+ * Renders the body portion of a FASTA views data export
+ */
+
 //print_r($themed_rows);
+
+// print the first FASTA record header
+// this is needed due to the order of the fields
 print $defline;
+
+// foreach row in the views table
 foreach ($themed_rows as $index => $fields) {
-   $defline = array();
-   $residues = '';
-   foreach ($fields as $key => $value) {
-     if (strcmp($key,'residues')==0)b{
-        $residues = wordwrap($value, 60, "\r\n", true);
-     }
-     if (strcmp($key,'defline')==0) {
-        $defline = $value;
-     }
-   }
-   print ">$defline\r\n";
-   print "$residues\r\n";
+  $defline = array();
+  $residues = '';
+  foreach ($fields as $key => $value) {
+
+    // wrap the sequence
+    if (strcmp($key, 'residues') == 0) {
+      $residues = wordwrap($value, 60, "\r\n", TRUE);
+    }
+
+    // set the FASTA header
+    if (strcmp($key, 'defline') == 0) {
+      $defline = $value;
+    }
+  }
+
+  // print the FASTA record
+  print ">$defline\r\n";
+  print "$residues\r\n";
 }
 
 

+ 2 - 0
tripal_views/views_data_export/theme/views-data-export-fasta-footer.tpl.php

@@ -1,5 +1,7 @@
 <?php
 
 /**
+ * @file
+ * Renders the footer of a FASTA views data export
  * FASTA files don't have a footer.
  */

+ 2 - 0
tripal_views/views_data_export/theme/views-data-export-fasta-header.tpl.php

@@ -1,5 +1,7 @@
 <?php
 
 /**
+ * @file
+ * Renders the header of a FASTA views data export
  * FASTA files don't have a header.
  */