--- loncom/interface/loncommon.pm 2007/07/02 03:36:28 1.541
+++ loncom/interface/loncommon.pm 2007/08/15 18:03:22 1.564
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.541 2007/07/02 03:36:28 raeburn Exp $
+# $Id: loncommon.pm,v 1.564 2007/08/15 18:03:22 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -240,7 +240,7 @@ Inputs: formname, elementname
formname and elementname specify the name of the html form and the name
of the element the selection from the search results will be placed in.
-=back
+
=cut
sub browser_and_searcher_javascript {
@@ -334,10 +334,12 @@ sub studentbrowser_javascript {
return (<<'ENDSTDBRW');
+
+$new_user_create
+
+
+
+END_BLOCK
+
+ return $output;
+}
+
+
+
=pod
+=back
+
+=head1 HTTP Helpers
+
+=over 4
+
=item * get_unprocessed_cgi($query,$possible_names)
Modify the %env hash to contain unprocessed CGI form parameters held in
@@ -5664,28 +6010,50 @@ sub record_sep {
$i++;
}
} else {
- my @allfields;
+ my $separator=',';
if ($env{'form.upfiletype'} eq 'semisv') {
- @allfields=split(/;/,$record,-1);
- } else {
- @allfields=split(/\,/,$record,-1);
+ $separator=';';
}
my $i=0;
- my $j;
- for ($j=0;$j<=$#allfields;$j++) {
- my $field=$allfields[$j];
- if ($field=~/^\s*(\"|\')/) {
- my $delimiter=$1;
- while (($field!~/$delimiter$/) && ($j<$#allfields)) {
- $j++;
- $field.=','.$allfields[$j];
- }
- $field=~s/^\s*$delimiter//;
- $field=~s/$delimiter\s*$//;
- }
- $components{&takeleft($i)}=$field;
- $i++;
+# the character we are looking for to indicate the end of a quote or a record
+ my $looking_for=$separator;
+# do not add the characters to the fields
+ my $ignore=0;
+# we just encountered a separator (or the beginning of the record)
+ my $just_found_separator=1;
+# store the field we are working on here
+ my $field='';
+# work our way through all characters in record
+ foreach my $character ($record=~/(.)/g) {
+ if ($character eq $looking_for) {
+ if ($character ne $separator) {
+# Found the end of a quote, again looking for separator
+ $looking_for=$separator;
+ $ignore=1;
+ } else {
+# Found a separator, store away what we got
+ $components{&takeleft($i)}=$field;
+ $i++;
+ $just_found_separator=1;
+ $ignore=0;
+ $field='';
+ }
+ next;
+ }
+# single or double quotation marks after a separator indicate beginning of a quote
+# we are now looking for the end of the quote and need to ignore separators
+ if ((($character eq '"') || ($character eq "'")) && ($just_found_separator)) {
+ $looking_for=$character;
+ next;
+ }
+# ignore would be true after we reached the end of a quote
+ if ($ignore) { next; }
+ if (($just_found_separator) && ($character=~/\s/)) { next; }
+ $field.=$character;
+ $just_found_separator=0;
}
+# catch the very last entry, since we never encountered the separator
+ $components{&takeleft($i)}=$field;
}
return %components;
}