فهرست منبع

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