--- loncom/interface/lonhtmlcommon.pm 2004/06/12 01:09:31 1.77 +++ loncom/interface/lonhtmlcommon.pm 2006/07/03 20:00:20 1.140 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.77 2004/06/12 01:09:31 www Exp $ +# $Id: lonhtmlcommon.pm,v 1.140 2006/07/03 20:00:20 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -55,10 +55,13 @@ html. package Apache::lonhtmlcommon; +use strict; use Time::Local; use Time::HiRes; use Apache::lonlocal; -use strict; +use Apache::lonnet; +use lib '/home/httpd/lib/perl/'; +use LONCAPA; ############################################## ############################################## @@ -80,7 +83,7 @@ sub authorbombs { foreach (keys %bombs) { if ($_=~/^$udom\/$uname\//) { return ''. + '">'. &Apache::loncommon::help_open_topic('About_Bombs'); } } @@ -92,41 +95,54 @@ sub authorbombs { sub recent_filename { my $area=shift; - return 'nohist_recent_'.&Apache::lonnet::escape($area); + return 'nohist_recent_'.&escape($area); } sub store_recent { - my ($area,$name,$value)=@_; + my ($area,$name,$value,$freeze)=@_; 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 $oldest=time(); my $delkey=''; - foreach (keys %recent) { - my $thistime=(split(/\&/,$recent{$_}))[0]; - if ($thistime<$oldest) { + foreach my $item (keys(%recent)) { + my $thistime=(split(/\&/,$recent{$item}))[0]; + if (($thistime ne "always_include") && ($thistime<$oldest)) { $oldest=$thistime; - $delkey=$_; + $delkey=$item; } } &Apache::lonnet::del($file,[$delkey]); } # store new value + my $timestamp; + if ($freeze) { + $timestamp = "always_include"; + } else { + $timestamp = time(); + } &Apache::lonnet::put($file,{ $name => - time.'&'.&Apache::lonnet::escape($value) }); + $timestamp.'&'.&escape($value) }); +} + +sub remove_recent { + my ($area,$names)=@_; + my $file=&recent_filename($area); + return &Apache::lonnet::del($file,$names); } sub select_recent { my ($area,$fieldname,$event)=@_; my %recent=&Apache::lonnet::dump(&recent_filename($area)); my $return="\n'; return $Str; @@ -175,6 +237,28 @@ sub checkbox { return $Str; } + +=pod + +=item radiobutton + +=cut + +############################################## +############################################## +sub radio { + my ($name,$checked,$value) = @_; + my $Str = ' + ENDJS - $result .= " }; # Month my @Months = qw/January February March April May June July August September October November December/; # Pad @Months with a bogus value to make indexing easier unshift(@Months,'If you can read this an error occurred'); - if ($includeempty) { $result.=""; } + if ($includeempty) { $monthselector.=""; } for(my $m = 1;$m <=$#Months;$m++) { - $result .= "