--- loncom/interface/lonhtmlcommon.pm 2005/06/03 15:47:29 1.106 +++ loncom/interface/lonhtmlcommon.pm 2007/10/10 00:02:19 1.167 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.106 2005/06/03 15:47:29 www Exp $ +# $Id: lonhtmlcommon.pm,v 1.167 2007/10/10 00:02:19 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -60,6 +60,7 @@ use Time::Local; use Time::HiRes; use Apache::lonlocal; use Apache::lonnet; +use LONCAPA; ############################################## ############################################## @@ -76,7 +77,7 @@ use Apache::lonnet; sub authorbombs { my $url=shift; $url=&Apache::lonnet::declutter($url); - my ($udom,$uname)=($url=~/^(\w+)\/(\w+)\//); + my ($udom,$uname)=($url=~m{^($LONCAPA::domain_re)/($LONCAPA::username_re)/}); my %bombs=&Apache::lonmsg::all_url_author_res_msg($uname,$udom); foreach (keys %bombs) { if ($_=~/^$udom\/$uname\//) { @@ -93,29 +94,35 @@ 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 { @@ -130,11 +137,12 @@ sub select_recent { my $return="\n'; return $Str; @@ -207,6 +237,28 @@ sub checkbox { return $Str; } + +=pod + +=item radiobutton + +=cut + +############################################## +############################################## +sub radio { + my ($name,$checked,$value) = @_; + my $Str = ' + ENDJS - $result .= ' '; + $result .= ' '; my $monthselector = qq{\n"; my $minuteselector = qq{}; my $secondselector= qq{}; - my $cal_link = qq{}; + my $cal_link; + if (!$nolink) { + $cal_link = qq{}; + } # if ($no_hh_mm_ss) { - $result .= &mt('[_1] [_2] [_3] [_4]Select Date[_5]', - $monthselector,$dayselector,$yearselector, - $cal_link,''); + $result .= &mt('[_1] [_2] [_3] ', + $monthselector,$dayselector,$yearselector); + if (!$nolink) { + $result .= &mt('[_1]Select Date[_2]',$cal_link,''); + } } else { - $result .= &mt('[_1] [_2] [_3] [_4] [_5]m [_6]s [_7]Select Date[_8]', - $monthselector,$dayselector,$yearselector, - $hourselector,$minuteselector,$secondselector, - $cal_link,''); + $result .= &mt('[_1] [_2] [_3] [_4] [_5]m [_6]s ', + $monthselector,$dayselector,$yearselector, + $hourselector,$minuteselector,$secondselector); + if (!$nolink) { + $result .= &mt('[_1]Select Date[_2]',$cal_link,''); + } } - $result .= "\n\n"; + $result .= "\n\n"; return $result; } + +sub build_url { + my ($base, $fields)=@_; + my $url; + $url = $base.'?'; + foreach my $key(keys(%$fields)) { + $url.=$key.'='.$$fields{$key}.'&'; + } + $url =~ s/&$//; + return $url; +} + + ############################################## ############################################## @@ -483,7 +574,7 @@ sub get_date_from_form { if (($year<70) || ($year>137)) { return undef; } if (defined($sec) && defined($min) && defined($hour) && defined($day) && defined($month) && defined($year) && - eval(&timelocal($sec,$min,$hour,$day,$month,$year))) { + eval('&timelocal($sec,$min,$hour,$day,$month,$year)')) { return &timelocal($sec,$min,$hour,$day,$month,$year); } else { return undef; @@ -506,11 +597,13 @@ parameter setting wizard. ############################################## sub pjump_javascript_definition { my $Str = <'. - &mt('Currently Enrolled').''."\n"; - $Str .= ''."\n"; - $Str .= ''."\n"; + foreach my $type (['Active', &mt('Currently Has Access')], + ['Future', &mt('Will Have Future Access')], + ['Expired', &mt('Previously Had Access')], + ['Any', &mt('Any Access Status')]) { + my ($name,$label) = @$type; + $Str .= '