瀏覽代碼

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

spficklin 13 年之前
父節點
當前提交
35df0e66e1
共有 1 個文件被更改,包括 10 次插入2 次删除
  1. 10 2
      base/tripal_views/views/handlers/views_handler_filter_file_upload.inc

+ 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