Эх сурвалжийг харах

Fixed bug allowing file uploads in views to split values by commas and by newlines. Previously it would only work with newlines

spficklin 13 жил өмнө
parent
commit
35df0e66e1

+ 10 - 2
base/tripal_views/views/handlers/views_handler_filter_file_upload.inc

@@ -91,8 +91,16 @@ class views_handler_filter_file_upload extends views_handler_filter {
      if($file_path){
         $fh = fopen($file_path,'r');
         while($line = fgets($fh)){
-          $line = trim($line);
-          $values[] = $line;
+           $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