--- loncom/interface/loncommon.pm 2007/07/28 21:38:29 1.555 +++ loncom/interface/loncommon.pm 2007/08/18 00:01:37 1.565 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.555 2007/07/28 21:38:29 raeburn Exp $ +# $Id: loncommon.pm,v 1.565 2007/08/18 00:01:37 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -334,10 +334,12 @@ sub studentbrowser_javascript { return (<<'ENDSTDBRW'); +RESIZE + +} + +=pod + =back =head1 Excel and CSV file utility routines @@ -1422,7 +1481,7 @@ sub select_level_form { =pod -=item * select_dom_form($defdom,$name,$includeempty) +=item * select_dom_form($defdom,$name,$includeempty,$showdomdesc) Returns a string containing a \n"; foreach my $dom (@domains) { $selectdomain.="\n"; + ($dom eq $defdom ? 'selected="selected" ' : '').'>'.$dom; + if ($showdomdesc) { + if ($dom ne '') { + my $domdesc = &Apache::lonnet::domain($dom,'description'); + if ($domdesc ne '') { + $selectdomain .= ' ('.$domdesc.')'; + } + } + } + $selectdomain .= "\n"; } $selectdomain.=""; return $selectdomain; @@ -3395,6 +3464,9 @@ Inputs: =item * $args, optional argument valid values are no_auto_mt_title -> prevents &mt()ing the title arg + inherit_jsmath -> when creating popup window in a page, + should it have jsmath forced on by the + current page =back @@ -3451,7 +3523,7 @@ sub bodytag { # construct main body tag my $bodytag = "". - &Apache::lontexconvert::init_math_support(); + &Apache::lontexconvert::init_math_support($args->{'inherit_jsmath'}); if ($bodyonly) { return $bodytag; @@ -4709,6 +4781,10 @@ Inputs: $title - optional title for the no_auto_mt_title -> prevent &mt()ing the title arg + inherit_jsmath -> when creating popup window in a page, + should it have jsmath forced on by the + current page + =cut sub start_page { @@ -5555,24 +5631,19 @@ sub user_picker { } $srchterm = $srch->{'srchterm'}; } - my %lt=&Apache::lonlocal::texthash( - 'usr' => 'Search for', - 'or' => 'or', - 'in' => 'in', - 'doma' => 'domain', - 'uname' => 'username', - 'lastname' => 'last name', + 'doma' => 'Domain/institution to search', + 'uname' => 'username', + 'lastname' => 'last name', 'lastfirst' => 'last name, first name', - 'crs' => 'this course', - 'dom' => 'this domain', - 'alc' => 'all LON-CAPA', - 'instd' => 'institutional directory', - 'exact' => 'as exact match to', - 'contains' => 'contained in', + 'crs' => 'in this course', + 'dom' => 'in this domain', + 'alc' => 'all LON-CAPA', + 'instd' => 'in institutional directory', + 'exact' => 'is', + 'contains' => 'contains', ); - my $domform = &select_dom_form($currdom,'srchdomain',1); - + my $domform = &select_dom_form($currdom,'srchdomain',1,1); my $srchinsel = ' \n"; + my ($newuserscript,$new_user_create); + + if ($forcenewuser) { + $new_user_create = '

&"').'" onclick="javascript:setSearch(\'1\');" />

'; + $newuserscript = <<"ENDSCRIPT"; + +function setSearch(createnew) { + if (createnew == 1) { + for (var i=0; i +function validateEntry() { + + var checkok = 1; + var srchin; + for (var i=0; i + +$new_user_create + - - - - - - - - - - - - + + + + + + +
$lt{'usr'}: -$srchtypesel - -$srchbysel -
$lt{'in'}: -$srchinsel -
$lt{'doma'}:$domform
$srchbysel + $srchtypesel + + $srchinsel +
$lt{'doma'}: $domform

END_BLOCK - if ($forcenewuser) { - $output .= ''.&mt('Make new user if no match found: ').''.&mt('Yes').'  '.&mt('No').'
'; - } + return $output; } + + =pod =back @@ -5903,28 +6067,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; }