Diff for /loncom/interface/loncommon.pm between versions 1.556 and 1.562

version 1.556, 2007/07/30 00:31:28 version 1.562, 2007/08/14 19:32:27
Line 334  sub studentbrowser_javascript { Line 334  sub studentbrowser_javascript {
    return (<<'ENDSTDBRW');     return (<<'ENDSTDBRW');
 <script type="text/javascript" language="Javascript" >  <script type="text/javascript" language="Javascript" >
     var stdeditbrowser;      var stdeditbrowser;
     function openstdbrowser(formname,uname,udom,roleflag) {      function openstdbrowser(formname,uname,udom,roleflag,ignorefilter) {
         var url = '/adm/pickstudent?';          var url = '/adm/pickstudent?';
         var filter;          var filter;
         eval('filter=document.'+formname+'.'+uname+'.value;');   if (!ignorefilter) {
       eval('filter=document.'+formname+'.'+uname+'.value;');
    }
         if (filter != null) {          if (filter != null) {
            if (filter != '') {             if (filter != '') {
                url += 'filter='+filter+'&';                 url += 'filter='+filter+'&';
Line 365  sub selectstudent_link { Line 367  sub selectstudent_link {
    return '';     return '';
        }         }
        return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele.         return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele.
         '","'.$udomele.'");'."'>".&mt('Select User')."</a>";          '","'.$udomele.'","","1");'."'>".&mt('Select User')."</a>";
    }     }
    if ($env{'request.role'}=~/^(au|dc|su)/) {     if ($env{'request.role'}=~/^(au|dc|su)/) {
        return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele.         return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele.
Line 3395  Inputs: Line 3397  Inputs:
   
 =item * $args, optional argument valid values are  =item * $args, optional argument valid values are
             no_auto_mt_title -> prevents &mt()ing the title arg              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  =back
   
Line 3451  sub bodytag { Line 3456  sub bodytag {
   
 # construct main body tag  # construct main body tag
     my $bodytag = "<body $extra_body_attr>".      my $bodytag = "<body $extra_body_attr>".
  &Apache::lontexconvert::init_math_support();   &Apache::lontexconvert::init_math_support($args->{'inherit_jsmath'});
   
     if ($bodyonly) {      if ($bodyonly) {
         return $bodytag;          return $bodytag;
Line 4709  Inputs: $title - optional title for the Line 4714  Inputs: $title - optional title for the
   
                   no_auto_mt_title -> prevent &mt()ing the title arg                    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  =cut
   
 sub start_page {  sub start_page {
Line 5555  sub user_picker { Line 5564  sub user_picker {
         }          }
         $srchterm = $srch->{'srchterm'};          $srchterm = $srch->{'srchterm'};
     }      }
   
     my %lt=&Apache::lonlocal::texthash(      my %lt=&Apache::lonlocal::texthash(
                     'usr'  => 'Search for',                      'usr'       => 'Search for',
                     'or'   => 'or',                      'or'        => 'or',
                     'in'   => 'in',                      'doma'      => 'domain',
                     'doma' => 'domain',                      'uname'     => 'username',
                     'uname' => 'username',                      'lastname'  => 'last name',
                     'lastname' => 'last name',  
                     'lastfirst' => 'last name, first name',                      'lastfirst' => 'last name, first name',
                     'crs' => 'this course',                      'crs'       => 'in this course',
                     'dom' => 'this domain',                       'dom'       => 'in this domain', 
                     'alc' => 'all LON-CAPA',                      'alc'       => 'all LON-CAPA',
                     'instd' => 'institutional directory',                      'instd'     => 'in institutional directory',
                     'exact' => 'as exact match to',                      'exact'     => 'is',
                     'contains' => 'contained in',                      'contains'  => 'contains',
                                        );                                         );
     my $domform = &select_dom_form($currdom,'srchdomain',1);      my $domform = &select_dom_form($currdom,'srchdomain',1);
   
     my $srchinsel = ' <select name="srchin">';      my $srchin;
   
     my @srchins = ('crs','dom','alc','instd');      my @srchins = ('crs','dom','alc','instd');
   
Line 5583  sub user_picker { Line 5590  sub user_picker {
         #       has been completed.          #       has been completed.
         next if ($option eq 'alc');          next if ($option eq 'alc');
         next if ($option eq 'crs' && !$env{'request.course.id'});          next if ($option eq 'crs' && !$env{'request.course.id'});
         if ($curr_selected{'srchin'} eq $option) {          my $checked =($curr_selected{'srchin'} eq $option) ?'checked="checked"'
             $srchinsel .= '                                                      :'';
    <option value="'.$option.'" selected="selected">'.$lt{$option}.'</option>';   my $extra = ($option eq 'dom') ? $domform
         } else {                                 : '';
             $srchinsel .= '   $srchin.=<<ROW
    <option value="'.$option.'">'.$lt{$option}.'</option>';   <tr>
         }     <td>
        <label><input type="radio" name="srchin" value="$option" $checked /> $lt{$option}</label> $extra
      </td>
   </tr>
   ROW
     }      }
     $srchinsel .= "\n  </select>\n";  
   
     my $srchbysel =  ' <select name="srchby">';      my $srchbysel =  ' <select name="srchby">';
     foreach my $option ('uname','lastname','lastfirst') {      foreach my $option ('uname','lastname','lastfirst') {
Line 5617  sub user_picker { Line 5627  sub user_picker {
     }      }
     $srchtypesel .= "\n  </select>\n";      $srchtypesel .= "\n  </select>\n";
   
     my ($newuserscript,$newuservalidate);      my ($newuserscript,$new_user_create);
   
     if ($forcenewuser) {      if ($forcenewuser) {
    $new_user_create = '<p> <input type="submit" name="forcenew" value="'.&HTML::Entities::encode(&mt('Make new user "[_1]"',$srchterm),'<>&"').'" onclick="javascript:setSearch(\'1\');" /> </p>';
         $newuserscript = <<"ENDSCRIPT";          $newuserscript = <<"ENDSCRIPT";
   
 function setSearch() {  function setSearch(createnew) {
     var createnew = 0;  
     for (var i=0; i<document.crtuser.forcenew.length; i++) {  
         if (document.crtuser.forcenew[i].checked) {  
             if (document.crtuser.forcenew[i].value == 1) {  
                 createnew = 1;  
             }  
         }  
     }  
     if (createnew == 1) {      if (createnew == 1) {
         for (var i=0; i<document.crtuser.srchby.length; i++) {          for (var i=0; i<document.crtuser.srchby.length; i++) {
             if (document.crtuser.srchby.options[i].value == 'uname') {              if (document.crtuser.srchby.options[i].value == 'uname') {
Line 5638  function setSearch() { Line 5641  function setSearch() {
             }              }
         }          }
         for (var i=0; i<document.crtuser.srchin.length; i++) {          for (var i=0; i<document.crtuser.srchin.length; i++) {
             if (document.crtuser.srchin.options[i].value == 'dom') {              if ( document.crtuser.srchin[i].value == 'dom') {
                 document.crtuser.srchin.selectedIndex = i;   document.crtuser.srchin[i].checked = 1;
             }              }
         }          }
         for (var i=0; i<document.crtuser.srchtype.length; i++) {          for (var i=0; i<document.crtuser.srchtype.length; i++) {
Line 5655  function setSearch() { Line 5658  function setSearch() {
     }      }
 }  }
 ENDSCRIPT  ENDSCRIPT
         $newuservalidate = <<"ENDBLOCK";  
 setSearch();  
 ENDBLOCK  
     }      }
   
     my $output = <<"END_BLOCK";      my $output = <<"END_BLOCK";
 <script type="text/javascript">  <script type="text/javascript">
 function validateEntry() {  function validateEntry() {
     $newuservalidate  
     var checkok = 1;      var checkok = 1;
     var srchin = document.crtuser.srchin.options[document.crtuser.srchin.selectedIndex].value;      var srchin;
       for (var i=0; i<document.crtuser.srchin.length; i++) {
    if ( document.crtuser.srchin[i].checked ) {
       srchin = document.crtuser.srchin[i].value;
    }
       }
   
     var srchtype = document.crtuser.srchtype.options[document.crtuser.srchtype.selectedIndex].value;      var srchtype = document.crtuser.srchtype.options[document.crtuser.srchtype.selectedIndex].value;
     var srchby = document.crtuser.srchby.options[document.crtuser.srchby.selectedIndex].value;      var srchby = document.crtuser.srchby.options[document.crtuser.srchby.selectedIndex].value;
     var srchdomain = document.crtuser.srchdomain.options[document.crtuser.srchdomain.selectedIndex].value;      var srchdomain = document.crtuser.srchdomain.options[document.crtuser.srchdomain.selectedIndex].value;
Line 5717  function validateEntry() { Line 5724  function validateEntry() {
 $newuserscript  $newuserscript
   
 </script>  </script>
   
   $new_user_create
   
 <table>  <table>
 <tr>   <tr>
  <td align="right">$lt{'usr'}:</td><td><input type="text" size="15" name="srchterm" value="$srchterm" /></td>    <td> $srchbysel
  <td>         $srchtypesel 
 $srchtypesel         <input type="text" size="15" name="srchterm" value="$srchterm" />
  </td>    </td>
  <td>   </tr>
 $srchbysel  $srchin
  </td>  
 </tr>  
 <tr>  
  <td align="right">$lt{'in'}:</td>  
  <td colspan="2">  
 $srchinsel  
  </td>  
 </tr>  
 <tr>  
  <td align="right">$lt{'doma'}:</td><td colspan="2">$domform</td>  
 </tr>  
 </table>  </table>
 <br />  <br />
 END_BLOCK  END_BLOCK
     if ($forcenewuser) {  
         $output .= '<span class="LC_nobreak">'.&mt('Make new user if no match found: ').'<input type="radio" name="forcenew" value="1" onclick="javascript:setSearch()" />'.&mt('Yes').'&nbsp;&nbsp;<input type="radio" name="forcenew" value="0" checked="checked" />'.&mt('No').'</span><br />';  
     }  
     return $output;      return $output;
 }  }
   
Line 6004  sub record_sep { Line 6001  sub record_sep {
             $i++;              $i++;
         }          }
     } else {      } else {
         my @allfields;          my $separator=',';
         if ($env{'form.upfiletype'} eq 'semisv') {          if ($env{'form.upfiletype'} eq 'semisv') {
             @allfields=split(/;/,$record,-1);              $separator=';';
         } else {  
             @allfields=split(/\,/,$record,-1);  
         }          }
         my $i=0;          my $i=0;
         my $j;  # the character we are looking for to indicate the end of a quote or a record 
         for ($j=0;$j<=$#allfields;$j++) {          my $looking_for=$separator;
             my $field=$allfields[$j];  # do not add the characters to the fields
             if ($field=~/^\s*(\"|\')/) {          my $ignore=0;
  my $delimiter=$1;  # we just encountered a separator (or the beginning of the record)
                 while (($field!~/$delimiter$/) && ($j<$#allfields)) {          my $just_found_separator=1;
     $j++;  # store the field we are working on here
     $field.=','.$allfields[$j];          my $field='';
  }  # work our way through all characters in record
                 $field=~s/^\s*$delimiter//;          foreach my $character ($record=~/(.)/g) {
                 $field=~s/$delimiter\s*$//;              if ($character eq $looking_for) {
             }                 if ($character ne $separator) {
             $components{&takeleft($i)}=$field;  # Found the end of a quote, again looking for separator
     $i++;                    $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;      return %components;
 }  }

Removed from v.1.556  
changed lines
  Added in v.1.562


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>