Diff for /loncom/interface/lonhtmlcommon.pm between versions 1.36 and 1.42

version 1.36, 2003/12/29 19:01:27 version 1.42, 2004/01/27 16:35:37
Line 65  use strict; Line 65  use strict;
   
 =pod  =pod
   
   =item authorbombs
   
   =cut
   
   ##############################################
   ##############################################
   
   sub authorbombs {
       my $url=shift;
       $url=&Apache::lonnet::declutter($url);
       my ($udom,$uname)=($url=~/^(\w+)\/(\w+)\//);
       my %bombs=&Apache::lonmsg::all_url_author_res_msg($uname,$udom);
       foreach (keys %bombs) {
    if ($_=~/^$udom\/$uname\//) {
       return '<a href="/adm/bombs/'.$url.
    '"><img src="/adm/lonMisc/bomb.gif" border="0" /></a>'.
    &Apache::loncommon::help_open_topic('About_Bombs');
    }
       }
       return '';
   }
   
   ##############################################
   ##############################################
   
   sub recent_filename {
       my $area=shift;
       return 'nohist_recent_'.&Apache::lonnet::escape($area);
   }
   
   sub store_recent {
       my ($area,$name,$value)=@_;
       my $file=&recent_filename($area);
       my %recent=&Apache::lonnet::dump($file);
       if (scalar(keys(%recent))>10) {
   # remove oldest value
    my $oldest=time;
    my $delkey='';
    foreach (keys %recent) {
       my $thistime=(split(/\&/,$recent{$_}))[0];
       if ($thistime<$oldest) {
    $oldest=$thistime;
    $delkey=$_;
       }
    }
    &Apache::lonnet::del($file,[$delkey]);
       }
   # store new value
       &Apache::lonnet::put($file,{ $name => 
    time.'&'.&Apache::lonnet::escape($value) });
   }
   
   sub select_recent {
       my ($area,$fieldname,$event)=@_;
       my %recent=&Apache::lonnet::dump(&recent_filename($area));
       my $return="\n<select name='$fieldname'".
    ($event?" onChange='$event'":'').
    ">\n<option value=''>--- ".&mt('Recent')." ---</option>";
       foreach (sort keys %recent) {
    unless ($_=~/^error\:/) {
       $return.="\n<option value='$_'>".
    &Apache::lonnet::unescape((split(/\&/,$recent{$_}))[1]).
    '</option>';
    }
       }
       $return.="\n</select>\n";
       return $return;
   }
   
   
   =pod
   
 =item textbox  =item textbox
   
 =cut  =cut
Line 91  sub textbox { Line 163  sub textbox {
 ##############################################  ##############################################
 ##############################################  ##############################################
 sub checkbox {  sub checkbox {
     my ($name) = @_;      my ($name,$value) = @_;
     my $Str = '<input type="checkbox" name="'.$name.'" />';      my $Str = '<input type="checkbox" name="'.$name.'"'.
    ($value?' checked="1"':'').' />';
     return $Str;      return $Str;
 }  }
   
Line 141  The method used to restrict user input w Line 214  The method used to restrict user input w
 ##############################################  ##############################################
 ##############################################  ##############################################
 sub date_setter {  sub date_setter {
     my ($formname,$dname,$currentvalue,$special) = @_;      my ($formname,$dname,$currentvalue,$special,$includeempty) = @_;
     if (! defined($currentvalue) || $currentvalue eq 'now') {      if (! defined($currentvalue) || $currentvalue eq 'now') {
         $currentvalue = time;   unless ($includeempty) {
       $currentvalue = time;
    } else {
       $currentvalue = 0;
    }
     }      }
     # other potentially useful values:     wkday,yrday,is_daylight_savings      # other potentially useful values:     wkday,yrday,is_daylight_savings
     my ($sec,$min,$hour,$mday,$month,$year,undef,undef,undef) =       my ($sec,$min,$hour,$mday,$month,$year)=('','','','','','');
         localtime($currentvalue);      if ($currentvalue) {
     $year += 1900;   ($sec,$min,$hour,$mday,$month,$year,undef,undef,undef) = 
       localtime($currentvalue);
    $year += 1900;
       }
     my $result = "\n<!-- $dname date setting form -->\n";      my $result = "\n<!-- $dname date setting form -->\n";
     $result .= <<ENDJS;      $result .= <<ENDJS;
 <script language="Javascript">  <script language="Javascript">
Line 200  ENDJS Line 280  ENDJS
                     July    August    September October November December/;                      July    August    September October November December/;
     # Pad @Months with a bogus value to make indexing easier      # Pad @Months with a bogus value to make indexing easier
     unshift(@Months,'If you can read this an error occurred');      unshift(@Months,'If you can read this an error occurred');
       if ($includeempty) { $result.="<option value=''></option>"; }
     for(my $m = 1;$m <=$#Months;$m++) {      for(my $m = 1;$m <=$#Months;$m++) {
         $result .= "      <option value=\"$m\" ";          $result .= "      <option value=\"$m\" ";
         $result .= "selected " if ($m-1 == $month);          $result .= "selected " if ($m-1 eq $month);
         $result .= "> ".&mt($Months[$m])." </option>\n";          $result .= "> ".&mt($Months[$m])." </option>\n";
     }      }
     $result .= "  </select>\n";      $result .= "  </select>\n";
Line 214  ENDJS Line 295  ENDJS
             "onChange=\"javascript:$dname\_checkday()\" />\n";              "onChange=\"javascript:$dname\_checkday()\" />\n";
     $result .= "&nbsp;&nbsp;";      $result .= "&nbsp;&nbsp;";
     $result .= "  <select name=\"$dname\_hour\" ".$special." >\n";      $result .= "  <select name=\"$dname\_hour\" ".$special." >\n";
       if ($includeempty) { $result.="<option value=''></option>"; }
     for (my $h = 0;$h<24;$h++) {      for (my $h = 0;$h<24;$h++) {
         $result .= "      <option value=\"$h\" ";          $result .= "      <option value=\"$h\" ";
         $result .= "selected " if ($hour == $h);          $result .= "selected " if ($hour == $h);
Line 437  sub StatusOptions { Line 519  sub StatusOptions {
     $Str .= ' size="'.$size.'" ';      $Str .= ' size="'.$size.'" ';
     $Str .= '>'."\n";      $Str .= '>'."\n";
     $Str .= '<option value="Active" '.$OpSel1.'>'.      $Str .= '<option value="Active" '.$OpSel1.'>'.
         'Currently Enrolled</option>'."\n";          &mt('Currently Enrolled').'</option>'."\n";
     $Str .= '<option value="Expired" '.$OpSel2.'>'.      $Str .= '<option value="Expired" '.$OpSel2.'>'.
         'Previously Enrolled</option>'."\n";          &mt('Previously Enrolled').'</option>'."\n";
     $Str .= '<option value="Any" '.$OpSel3.'>'.      $Str .= '<option value="Any" '.$OpSel3.'>'.
         'Any Enrollment Status</option>'."\n";          &mt('Any Enrollment Status').'</option>'."\n";
     $Str .= '</select>'."\n";      $Str .= '</select>'."\n";
 }  }
   
Line 839  sub Close_PrgWin { Line 921  sub Close_PrgWin {
 # ------------------------------------------------------- Puts directory header  # ------------------------------------------------------- Puts directory header
   
 sub crumbs {  sub crumbs {
     my ($uri,$target,$prefix)=@_;      my ($uri,$target,$prefix,$form)=@_;
     my $output='<br /><tt><b><font size="+2">'.$prefix.'/';      my $output='<br /><tt><b><font size="+2">'.$prefix.'/';
     if ($ENV{'user.adv'}) {      if ($ENV{'user.adv'}) {
  my $path=$prefix;   my $path=$prefix;
  foreach (split('/',$uri)) {   foreach (split('/',$uri)) {
     unless ($_) { next; }      unless ($_) { next; }
     $path.='/'.$_;      $path.='/'.$_;
     $output.='<a href="'.$path.'"'.($target?' target="'.$target.'"':'').'>'.$_.'</a>/';      my $linkpath=$path;
       if ($form) {
    $linkpath="javascript:$form.action='$path/';$form.submit();";
       }
       $output.='<a href="'.$linkpath.'"'.($target?' target="'.$target.'"':'').'>'.$_.'</a>/';
  }   }
     } else {      } else {
  $output.=$uri;   $output.=$uri;

Removed from v.1.36  
changed lines
  Added in v.1.42


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