Browse Source

Fixed coding standards problems as found by the coder module

spficklin 12 years ago
parent
commit
3efbf1ed79

+ 1 - 1
tripal_bulk_loader/tripal_bulk_loader.admin.templates.inc

@@ -2147,4 +2147,4 @@ function tripal_bulk_loader_edit_field_ahah() {
   print drupal_json(array('status' => TRUE, 'data' => $output));
   exit();
 
-}
+}

+ 1 - 1
tripal_bulk_loader/tripal_bulk_loader.constants.inc

@@ -367,7 +367,7 @@ function theme_tripal_bulk_loader_set_constants_form($form) {
     // @coder-ignore: no user input thus don't need to filter
     $form['exposed_fields']['existing'] = array(
       '#type' => 'markup',
-      '#value' => theme('table', $header, $rows, array('id' => 'mytable')) . '<br />'
+      '#value' => filter_xss(theme('table', $header, $rows, array('id' => 'mytable')) . '<br />'),
     );
   }
 

+ 6 - 5
tripal_bulk_loader/tripal_bulk_loader.drush.inc

@@ -1,7 +1,8 @@
 <?php
 
 /**
- * Implements drush integration for this module
+ *  @file
+ *  Implements drush integration for this module
  */
 
 /**
@@ -20,10 +21,10 @@ function tripal_bulk_loader_drush_command() {
  * Code ran for the tripal-loader-progress drush command
  * Display the progress of any running tripal bulk loading job.
  */
-function drush_tripal_bulk_loader_tripal_loader_progress () {
+function drush_tripal_bulk_loader_tripal_loader_progress() {
 
   // determine the progress of any loading jobs
-  $sql = "SELECT t.loader_name, t.file, t.job_id FROM tripal_bulk_loader t WHERE job_status='Loading...'";
+  $sql = "SELECT t.loader_name, t.file, t.job_id FROM {tripal_bulk_loader} t WHERE job_status='Loading...'";
   $resource = db_query($sql);
 
   while ($r = db_fetch_object($resource)) {
@@ -36,7 +37,7 @@ function drush_tripal_bulk_loader_tripal_loader_progress () {
           . "File:" . $r->file . "\n"
           . "Current Constant Set:\n"
           . "\tLines processed: " . $progress->num_lines . "\n"
-          . "\tRecord Inserted: " .$progress->num_records . "\n"
+          . "\tRecord Inserted: " . $progress->num_records . "\n"
           . "\tPercent Complete: " . $progress->percent_file . "\n"
           . "Number of Constant Sets fully loaded: " . $progress->num_constant_sets_loaded . "\n"
           . "Job Percent Complete: " . $progress->total_percent . "\n"
@@ -44,4 +45,4 @@ function drush_tripal_bulk_loader_tripal_loader_progress () {
       }
     }
   }
-}
+}

+ 18 - 18
tripal_bulk_loader/tripal_bulk_loader.loader.inc

@@ -295,7 +295,7 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
       chado_query("LOCK TABLE %s IN %s MODE", $table, $lockmode);
     }
 
-    tripal_bulk_loader_progress_bar(0,$total_lines);
+    tripal_bulk_loader_progress_bar(0, $total_lines);
     while (!feof($file_handle)) {
 
       // Clear variables
@@ -317,7 +317,7 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
       if ($node->job_id and $num_lines % $interval == 0) {
         // percentage of lines processed for the current group
         $group_progress = round(($num_lines/$total_lines)*100);
-        tripal_bulk_loader_progress_bar($num_lines,$total_lines);
+        tripal_bulk_loader_progress_bar($num_lines, $total_lines);
         // percentage of lines processed for all groups
         // <previous group index> * 100 + <current group progress>
         // --------------------------------------------------------
@@ -386,7 +386,7 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
       break;
     }
 
-    tripal_bulk_loader_progress_bar($total_lines,$total_lines);
+    tripal_bulk_loader_progress_bar($total_lines, $total_lines);
     tripal_bulk_loader_progress_file_track_job($job_id, FALSE, FALSE, TRUE);
   } //end of foreach constant set
 
@@ -732,22 +732,22 @@ function tripal_bulk_loader_flatten_array($values) {
 function tripal_bulk_loader_progress_bar($current=0, $total=100, $size=50) {
 
   // First iteration
-  if($current == 0) {
+  if ($current == 0) {
     $new_bar = TRUE;
-    fputs(STDOUT,"Progress:\n");
+    fputs(STDOUT, "Progress:\n");
   }
 
   //Percentage round off for a more clean, consistent look
-  $perc = round(($current/$total)*100,2);
+  $perc = round(($current/$total)*100, 2);
   // percent indicator must be four characters, if shorter, add some spaces
-  for($i=strlen($perc); $i<=4; $i++) {
-    $perc = ' '.$perc;
+  for ($i = strlen($perc); $i <= 4; $i++) {
+    $perc = ' ' . $perc;
   }
 
   $total_size = $size + $i + 3 + 2;
   // if it's not first go, remove the previous bar
-  if(!$new_bar) {
-    for($place = $total_size; $place > 0; $place--) {
+  if (!$new_bar) {
+    for ($place = $total_size; $place > 0; $place--) {
       // echo a backspace (hex:08) to remove the previous character
       echo "\x08";
     }
@@ -756,9 +756,9 @@ function tripal_bulk_loader_progress_bar($current=0, $total=100, $size=50) {
   // output the progess bar as it should be
   // Start with a border
   echo '[';
-  for($place = 0; $place <= $size; $place++) {
+  for ($place = 0; $place <= $size; $place++) {
     // output "full" spaces if this portion is completed
-    if($place <= ($current / $total * $size)) {
+    if ($place <= ($current / $total * $size)) {
       echo '|';
     }
     else {
@@ -773,7 +773,7 @@ function tripal_bulk_loader_progress_bar($current=0, $total=100, $size=50) {
   echo " $perc%";
 
   // if it's the end, add a new line
-  if($current == $total) {
+  if ($current == $total) {
     echo "\n";
   }
 
@@ -801,20 +801,20 @@ function tripal_bulk_loader_progress_bar($current=0, $total=100, $size=50) {
  */
 function tripal_bulk_loader_progress_file_track_job($job_id, $record_added, $line_complete = FALSE, $close = FALSE) {
   // retrieve the file handle
-  $file_handle = variable_get('tripal_bulk_loader_progress_file_handle',NULL);
+  $file_handle = variable_get('tripal_bulk_loader_progress_file_handle', NULL);
 
   // open file for reading if not already
   if (!$file_handle) {
-    $file_handle = fopen('/tmp/tripal_bulk_loader_progress-'.$job_id.'.out', 'w');
+    $file_handle = fopen('/tmp/tripal_bulk_loader_progress-'. $job_id . '.out', 'w');
     variable_set('tripal_bulk_loader_progress_file_handle', $file_handle);
   }
 
   if ($record_added) {
-    fwrite($file_handle,'.');
+    fwrite($file_handle, '.');
   }
 
   if ($line_complete) {
-    fwrite($file_handle,"\n");
+    fwrite($file_handle, "\n");
   }
 
   // close the file if finished
@@ -822,4 +822,4 @@ function tripal_bulk_loader_progress_file_track_job($job_id, $record_added, $lin
     fclose($file_handle);
     variable_set('tripal_bulk_loader_progress_file_handle', NULL);
   }
-}
+}

+ 2 - 3
tripal_core/tripal_core.api.inc

@@ -1057,8 +1057,7 @@ function tripal_core_generate_chado_var($table, $values, $base_options = array()
       if (db_table_exists('chado_' . $table)) {
         // that has a foreign key to this one ($table_desc['primary key'][0]
         // and to the node table (nid)
-        // @coder-ignore: acting on chado schema rather then drupal schema therefore, table prefixing does not apply
-        $sql = "SELECT %s, nid FROM chado_%s WHERE %s=%d";
+        $sql = "SELECT %s, nid FROM {chado_%s} WHERE %s=%d";
         $mapping = db_fetch_object(db_query(
           $sql,
           $table_primary_key,
@@ -1264,7 +1263,7 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
             // than once with the same table we want to alter the
             // array structure
             if (count($foreign_table_desc['foreign keys'][$base_table]['columns']) > 1) {
-              if(!is_object($object->{$foreign_table})){
+              if (!is_object($object->{$foreign_table})) {
                  $object->{$foreign_table} = new stdClass();
               }
               $object->{$foreign_table}->{$left} = $foreign_object;

+ 1 - 1
tripal_core/tripal_core.module

@@ -249,7 +249,7 @@ function tripal_core_job_describe_args($callback, $args) {
     $mview = db_fetch_object(db_query($sql, $args[0]));
     $new_args['View Name'] = $mview->name;
   }
-  elseif($callback == 'tripal_core_install_chado'){
+  elseif ($callback == 'tripal_core_install_chado') {
      $new_args['Action'] = $args[0];
   }
   return $new_args;

+ 2 - 2
tripal_cv/tripal_cv.views.inc

@@ -42,7 +42,7 @@ function tripal_cv_views_data() {
     foreach ($tables as $tablename) {
       if (!tripal_views_is_integrated($tablename, 10)) {
         // get default integration array
-        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename,TRUE);
+        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE);
 
         // add specialty handlers
         if ($tablename == 'cvterm') {
@@ -396,4 +396,4 @@ function tripal_cv_views_default_views() {
   $views[$view->name] = $view;
 
   return $views;
-}
+}

+ 13 - 11
tripal_feature/tripal_feature.module

@@ -1346,7 +1346,7 @@ function tripal_feature_load_featureloc_sequences($feature_id, $featurelocs) {
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_get_matched_alignments($feature){
+function tripal_feature_get_matched_alignments($feature) {
   // This function is for features that align through an intermediate such
   // as 'EST_match' or 'match'.  This occurs in the case where two sequences
   // align but where one does not align perfectly.  Some ESTs may be in a contig
@@ -1399,11 +1399,11 @@ function tripal_feature_get_matched_alignments($feature){
           "  AND (CVT2.name = 'match' or CVT2.name like '%_match') ".
           "ORDER BY FL1.fmin";
 
-   $results = db_query($sql,$feature->feature_id,$feature->feature_id);
+   $results = db_query($sql, $feature->feature_id, $feature->feature_id);
    
    // iterate through the results and add them to our featurelocs array
    $featurelocs = array();
-   while($fl = db_fetch_object($results)){
+   while ($fl = db_fetch_object($results)) {
       $featurelocs[] = $fl ;
    }   
    return $featurelocs;
@@ -1918,14 +1918,16 @@ function tripal_feature_preprocess_tripal_feature_alignments(&$variables) {
   $cfeaturelocs = $feature->featureloc->feature_id;
   if (!$cfeaturelocs) {
      $cfeaturelocs = array();
-  } elseif (!is_array($cfeaturelocs)) { 
+  } 
+  elseif (!is_array($cfeaturelocs)) { 
      $cfeaturelocs = array($cfeaturelocs); 
   }
   // get alignment as parent
   $pfeaturelocs = $feature->featureloc->srcfeature_id;
   if (!$pfeaturelocs) {
      $pfeaturelocs = array();
-  } elseif (!is_array($pfeaturelocs)) { 
+  } 
+  elseif (!is_array($pfeaturelocs)) { 
      $pfeaturelocs = array($pfeaturelocs); 
   }
 
@@ -1936,9 +1938,9 @@ function tripal_feature_preprocess_tripal_feature_alignments(&$variables) {
   // combine all three alignments into a single array for printing together in
   // a single list
   $alignments = array();
-  foreach ($pfeaturelocs as $featureloc){
+  foreach ($pfeaturelocs as $featureloc) {
      // if type is a 'match' then ignore it. We will handle those below
-     if(preg_match('/(^match$|^.*?_match)$/',$featureloc->feature_id->type_id->name)){
+     if (preg_match('/(^match$|^.*?_match)$/', $featureloc->feature_id->type_id->name)) {
         continue;
      }
      $alignment = new stdClass();
@@ -1952,9 +1954,9 @@ function tripal_feature_preprocess_tripal_feature_alignments(&$variables) {
      $alignment->strand = $featureloc->strand;
      $alignments[] = $alignment;
   }
-  foreach ($cfeaturelocs as $featureloc){
+  foreach ($cfeaturelocs as $featureloc) {
      // if type is a 'match' then ignore it. We will handle those below
-     if(preg_match('/(^match$|^.*?_match)$/',$featureloc->feature_id->type_id->name)){
+     if (preg_match('/(^match$|^.*?_match)$/', $featureloc->feature_id->type_id->name)) {
         continue;
      }
      $alignment = new stdClass();
@@ -1972,10 +1974,10 @@ function tripal_feature_preprocess_tripal_feature_alignments(&$variables) {
   }
   // in matching features, the left feature is always the feature
   // provided to this function. 
-  foreach ($mfeaturelocs as $featureloc){
+  foreach ($mfeaturelocs as $featureloc) {
      // get more information about the right feature
      $select = array('feature_id' => $featureloc->right_srcfeature_id);
-     $rfeature = tripal_core_generate_chado_var('feature',$select);
+     $rfeature = tripal_core_generate_chado_var('feature', $select);
      // now add to the list
      $alignment = new stdClass();
      $alignment->record = $featureloc;

+ 1 - 1
tripal_stock/tripal_stock.module

@@ -325,7 +325,7 @@ function tripal_stock_show_stocks() {
 function theme_tripal_stock_stock_table(&$stocks) {
 
   // cycle through the stocks and build the stocks page
-  $header = array('Name', 'Type','Organism','Description');
+  $header = array('Name', 'Type', 'Organism', 'Description');
   $rows = array();
   foreach ($stocks as $node) {
     $output .= "<tr>";

+ 1 - 1
tripal_views/tripal_views.views.inc

@@ -710,7 +710,7 @@ function tripal_views_data_export_download_form(&$form_state, $view, $display_id
 
       // only add this display to the form if it is attached
       $display_options = $display->display_options;
-      if(strcmp($display_options['displays'][$current_display],$current_display)!=0){
+      if (strcmp($display_options['displays'][$current_display], $current_display) != 0) {
          continue;
       }
 

+ 11 - 7
tripal_views/tripal_views_integration.inc

@@ -433,9 +433,9 @@ function tripal_views_integration_form(&$form_state, $setup_id = NULL) {
     $i=1;
     $form['view_setup_table']["instructions"] = array(
          '#type' => 'markup',
-         '#value' => "Select an optional table to which the fields of the ".
+         '#value' => filter_xss("Select an optional table to which the fields of the ".
                      "materialized view can join.  If a field does not need to ".
-                     "join you may leave the selection blank.",
+                     "join you may leave the selection blank."),
     );
     $data['field_types'] = array();
 
@@ -492,7 +492,8 @@ function tripal_views_integration_form(&$form_state, $setup_id = NULL) {
       $form['view_setup_table']["$table_id-$i"] = array(
            '#type' => 'markup',
            '#prefix' => "<div class=\"fields-new-row\">",
-           '#suffix' => "</div>"
+           '#suffix' => "</div>",
+           '#value' => filter_xss('')
       );
 
       // COLUMN I
@@ -501,7 +502,7 @@ function tripal_views_integration_form(&$form_state, $setup_id = NULL) {
         '#prefix' => "<div class=\"column-one\">",
         '#value' => "<span class=\"column-name\">" . filter_xss($column_name) . "</span>".
                     "<br /><span class=\"column-type\">" . filter_xss($column_type) . "</span>",
-        '#suffix' => "</div>",
+        '#suffix' => "</div>",        
       );
       $data['field_types'][$column_name] = $column_type;
 
@@ -509,7 +510,8 @@ function tripal_views_integration_form(&$form_state, $setup_id = NULL) {
       $form['view_setup_table']["$table_id-$i"]['column-2'] = array(
            '#type' => 'markup',
            '#prefix' => "<div class=\"column-two\">",
-           '#suffix' => "</div>"
+           '#suffix' => "</div>",
+           '#value' => filter_xss('')
       );
 
       // set the default values for the human-readable name and description
@@ -546,7 +548,8 @@ function tripal_views_integration_form(&$form_state, $setup_id = NULL) {
       $form['view_setup_table']["$table_id-$i"]['column-3'] = array(
            '#type' => 'markup',
            '#prefix' => "<div class=\"column-three\">",
-           '#suffix' => "</div>"
+           '#suffix' => "</div>",
+           '#value' => filter_xss('')
       );
 
       // set the default values for the join table and columns
@@ -624,7 +627,8 @@ function tripal_views_integration_form(&$form_state, $setup_id = NULL) {
       $form['view_setup_table']["$table_id-$i"]['column-4'] = array(
         '#type' => 'markup',
         '#prefix' => "<div class=\"column-four\">",
-        '#suffix' => "</div>"
+        '#suffix' => "</div>",
+        '#value' => filter_xss('')
       );
 
       // create the handler fields

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

@@ -89,22 +89,22 @@ class chado_views_handler_field_boolean extends views_handler_field_boolean {
     // check to see if this is a t/f boolean field or a 1/0 boolean field
     // parent render expects 1/0 so need to translate to that form before rendering
     if (!is_array($values->{$this->field_alias})) {
-      if (!preg_match('/[01]/',$values->{$this->field_alias})) {
-        if (preg_match('/^[tT]/',$values->{$this->field_alias})) {
+      if (!preg_match('/[01]/', $values->{$this->field_alias})) {
+        if (preg_match('/^[tT]/', $values->{$this->field_alias})) {
           $values->{$this->field_alias} = 1;
         }
-        elseif (preg_match('/^[fF]/',$values->{$this->field_alias})) {
+        elseif (preg_match('/^[fF]/', $values->{$this->field_alias})) {
           $values->{$this->field_alias} = 0;
         }
       }
     }
     else {
-      if (!preg_match('/[01]/',$values->{$this->field_alias}[0])) {
+      if (!preg_match('/[01]/', $values->{$this->field_alias}[0])) {
         foreach ($values->{$this->field_alias} as $k => $v) {
-          if (preg_match('/^[tT]/',$v)) {
+          if (preg_match('/^[tT]/', $v)) {
             $values->{$this->field_alias}[$k] = 1;
           }
-          elseif (preg_match('/^[fF]/',$v)) {
+          elseif (preg_match('/^[fF]/', $v)) {
             $values->{$this->field_alias}[$k] = 0;
           }
         }
@@ -118,4 +118,4 @@ class chado_views_handler_field_boolean extends views_handler_field_boolean {
     return parent::render($val);
   }
 
-}
+}

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

@@ -10,7 +10,7 @@
  */
 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);
   }

+ 3 - 3
tripal_views/views/handlers/chado_views_handler_field_date.inc

@@ -88,12 +88,12 @@ class chado_views_handler_field_date extends views_handler_field_date {
 
     // Check the format of the date is a UNIX timestamp and otherwise convert
     if (!is_array($values->{$this->field_alias})) {
-      if (!preg_match('/^\d+$/',$values->{$this->field_alias})) {
+      if (!preg_match('/^\d+$/', $values->{$this->field_alias})) {
          $values->{$this->field_alias} = strtotime($values->{$this->field_alias});
       }
     }
     else {
-      if (!preg_match('/^\d+$/',$values->{$this->field_alias}[0])) {
+      if (!preg_match('/^\d+$/', $values->{$this->field_alias}[0])) {
         foreach ($values->{$this->field_alias} as $k => $v) {
          $values->{$this->field_alias}[$k] = strtotime($v);
         }
@@ -108,4 +108,4 @@ class chado_views_handler_field_date extends views_handler_field_date {
     return parent::render($val);
   }
 
-}
+}

+ 5 - 5
tripal_views/views/handlers/chado_views_handler_filter_boolean_operator.inc

@@ -67,7 +67,7 @@ class chado_views_handler_filter_boolean_operator extends views_handler_filter_b
 
     // check if its a t/f or 1/0 boolean
     $check = db_fetch_object(db_query("SELECT %s as val FROM %s LIMIT 1", $this->real_field, $this->table));
-    if (preg_match('/^[tTfF]/',$check->val)) {
+    if (preg_match('/^[tTfF]/', $check->val)) {
       $true = 't';
       $false = 'f';
     }
@@ -83,17 +83,17 @@ class chado_views_handler_filter_boolean_operator extends views_handler_filter_b
       if ($this->options['agg']['records_with']) {
         $where = "$this->table_alias.$this->real_field ";
         if (empty($this->value)) {
-          $where .= "= '".$false."'";
+          $where .= "= '" . $false . "'";
           if ($this->accept_null) {
             $where = '(' . $where . " OR $this->table_alias.$this->real_field IS NULL)";
           }
         }
         else {
           if (!empty($this->definition['use equal'])) {
-            $where .= "= '".$true."'";
+            $where .= "= '" . $true . "'";
           }
           else {
-            $where .= "<> '".$false."'";
+            $where .= "<> '" . $false . "'";
           }
         }
         $this->query->add_where($this->options['group'], $where);
@@ -137,4 +137,4 @@ class chado_views_handler_filter_boolean_operator extends views_handler_filter_b
 
   }
 
-}
+}

+ 3 - 3
tripal_views/views/handlers/chado_views_handler_filter_date.inc

@@ -51,7 +51,7 @@ class chado_views_handler_filter_date extends views_handler_filter_date {
 
     // Check whether we have a UNIX timestamp or an ISO Timestamp
     $check = db_fetch_object(db_query("SELECT $this->real_field as val FROM $this->table WHERE $this->real_field IS NOT NULL LIMIT 1"));
-    if (preg_match('/^\d+$/',$check->val)) {
+    if (preg_match('/^\d+$/', $check->val)) {
       // this is a unix timestamp
       $is_unix = TRUE;
     }
@@ -103,7 +103,7 @@ class chado_views_handler_filter_date extends views_handler_filter_date {
 
     // Check whether we have a UNIX timestamp or an ISO Timestamp
     $check = db_fetch_object(db_query("SELECT $this->real_field as val FROM $this->table WHERE $this->real_field IS NOT NULL LIMIT 1"));
-    if (preg_match('/^\d+$/',$check->val)) {
+    if (preg_match('/^\d+$/', $check->val)) {
       // this is a unix timestamp
       $is_unix = TRUE;
     }
@@ -156,4 +156,4 @@ class chado_views_handler_filter_date extends views_handler_filter_date {
     }
   }
 
-}
+}

+ 6 - 6
tripal_views/views/handlers/chado_views_handler_filter_select_string.inc

@@ -77,19 +77,19 @@ class chado_views_handler_filter_select_string extends chado_views_handler_filte
       // available to the user to edit--their fixed.
       $where = '';
       $filters = ($this->view->filter) ? $this->view->filter : array();
-      foreach($filters as $filter_name => $details){
+      foreach ($filters as $filter_name => $details) {
          // we only want to inclue non-exposed filters
-         if($details->options['exposed'] == FALSE){
+         if ($details->options['exposed'] == FALSE) {
             // we only want to filter on the table we're getting the list from
-            if(strcmp($details->table,$this->table)==0){
-              $where .= "$details->field $details->operator ". $details->value['value'];
+            if (strcmp($details->table, $this->table)==0) {
+              $where .= "$details->field $details->operator " . $details->value['value'];
               $where .= ' AND ';
             }
          }
       }
-      if($where){
+      if ($where) {
          $where = "WHERE $where";
-         $where = substr($where,0,-5); # remove the final ' AND '
+         $where = substr($where, 0, -5); # remove the final ' AND '
       }
 
       // get the values from the table

+ 5 - 5
tripal_views/views/handlers/views_handler_filter_chado_select_string.inc

@@ -77,19 +77,19 @@ class views_handler_filter_chado_select_string extends views_handler_filter_stri
       // available to the user to edit--their fixed.
       $where = '';
       $filters = $this->view->filter;
-      foreach($filters as $filter_name => $details){
+      foreach ($filters as $filter_name => $details) {
          // we only want to inclue non-exposed filters 
-         if($details->options['exposed'] == FALSE){
+         if ($details->options['exposed'] == FALSE) {
             // we only want to filter on the table we're getting the list from
-            if(strcmp($details->table,$this->table)==0){
+            if (strcmp($details->table, $this->table)==0) {
               $where .= "$details->field $details->operator ". $details->value['value'];
               $where .= ' AND ';
             }
          }
       } 
-      if($where){
+      if ($where) {
          $where = "WHERE $where";
-         $where = substr($where,0,-5); # remove the final ' AND '
+         $where = substr($where, 0, -5); # remove the final ' AND '
       }
 
       // get the values from the table