--- loncom/interface/lonhtmlcommon.pm 2005/06/14 02:33:18 1.108 +++ loncom/interface/lonhtmlcommon.pm 2005/10/13 22:37:40 1.114 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.108 2005/06/14 02:33:18 www Exp $ +# $Id: lonhtmlcommon.pm,v 1.114 2005/10/13 22:37:40 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -100,7 +100,7 @@ sub store_recent { my ($area,$name,$value)=@_; my $file=&recent_filename($area); my %recent=&Apache::lonnet::dump($file); - if (scalar(keys(%recent))>10) { + if (scalar(keys(%recent))>20) { # remove oldest value my $oldest=time; my $delkey=''; @@ -266,12 +266,15 @@ sub date_setter { if (! defined($no_hh_mm_ss)) { $no_hh_mm_ss = 0; } - if (! defined($currentvalue) || $currentvalue eq 'now') { - unless ($includeempty) { - $currentvalue = time; - $wasdefined=0; - } else { + if ($currentvalue eq 'now') { + $currentvalue=time; + } + if ((!defined($currentvalue)) || ($currentvalue eq '')) { + $wasdefined=0; + if ($includeempty) { $currentvalue = 0; + } else { + $currentvalue = time; } } # other potentially useful values: wkday,yrday,is_daylight_savings @@ -282,9 +285,18 @@ sub date_setter { $year += 1900; } unless ($wasdefined) { - $sec=($defsec?$defsec:0); - $min=($defmin?$defmin:0); - $hour=($defhour?$defhour:0); + if (($defhour) || ($defmin) || ($defsec)) { + ($sec,$min,$hour,$mday,$month,$year,undef,undef,undef) = + localtime(time); + $year += 1900; + $sec=($defsec?$defsec:0); + $min=($defmin?$defmin:0); + $hour=($defhour?$defhour:0); + } elsif (!$includeempty) { + $sec=0; + $min=0; + $hour=0; + } } my $result = "\n\n"; $result .= < + + + + + + +
+ +END + return $output; +} + +sub end_pick_box { + my $output = <<"END"; +
+
+ + + +END + return $output; +} + +sub row_title { + my ($col_width,$tablecolor,$title) = @_; + my $output = <<"ENDONE"; + + + + + + +
$title: +
+ + + + +ENDONE + return $output; +} + +sub row_closure { + my $output = <<"ENDTWO"; + +
+ + + + +
+ + +ENDTWO + return $output; +} + +sub role_select_row { + my ($roles,$col_width,$tablecolor,$title) = @_; + my $output = &row_title($col_width,$tablecolor,$title); + $output .= qq| + + \n|; + $output .= &row_closure(); + return $output; +} + +sub course_select_row { + my ($col_width,$tablecolor,$title,$formname,$totcodes,$codetitles,$idlist,$idlist_titles) = @_; + my $output = &row_title($col_width,$tablecolor,$title); + $output .= " \n"; + $output .= qq| + + |; + my $courseform=''.&Apache::loncommon::selectcourse_link + ($formname,'pickcourse','pickdomain','coursedesc').''; + if ($totcodes > 0) { + $output .= ''.&mt('All courses'); + my $numtitles = @$codetitles; + if ($numtitles > 0) { + $output .= '
'.&mt('Pick courses by category:').'
'; + $output .= ''; + for (my $i=1; $i<$numtitles; $i++) { + $output .= ''; + } + $output .= '
'.$$codetitles[0].'
'."\n". + '
'.$$codetitles[$i].'
'."\n". + ''."\n". + '

'; + } + } + $output .= ''.&mt('Pick specific course(s):').' '.$courseform.'  selected.
'."\n"; + $output .= &row_closure(); + return $output; +} + +sub status_select_row { + my ($types,$col_width,$tablecolor,$title) = @_; + my $output = &row_title($col_width,$tablecolor,$title); + $output .= qq| + + \n|; + $output .= &row_closure(); + return $output; +} + +sub email_default_row { + my ($authtypes,$col_width,$tablecolor,$title,$descrip) = @_; + my $output = &row_title($col_width,$tablecolor,$title); + my @rowcols = ('#eeeeee','#dddddd'); + $output .= ' '.$descrip; + $output .= &start_pick_box('50%'); + $output .= ' + '.&mt('Authentication Method').''.&mt('Username -> e-mail conversion').' + '."\n"; + my $rownum = 0; + foreach my $auth (sort(keys(%{$authtypes}))) { + my ($userentry,$size); + my $rowiter = $rownum%2; + if ($auth =~ /^krb/) { + $userentry = ''; + $size = 25; + } else { + $userentry = 'username@'; + $size = 15; + } + $output .= ' '.$$authtypes{$auth}.''.$userentry.''; + $rownum ++; + } + $output .= &end_pick_box(); + $output .= "
\n"; + $output .= &row_closure(); + return $output; +} + + +sub submit_row { + my ($col_width,$tablecolor,$title,$cmd,$submit_text) = @_; + my $output = &row_title($col_width,$tablecolor,$title); + $output .= qq| + +
+ +   +

+ \n|; + return $output; +} 1;