version 1.134, 2006/06/16 22:37:10
|
version 1.136, 2006/06/22 23:22:41
|
Line 99 sub recent_filename {
|
Line 99 sub recent_filename {
|
} |
} |
|
|
sub store_recent { |
sub store_recent { |
my ($area,$name,$value)=@_; |
my ($area,$name,$value,$freeze)=@_; |
my $file=&recent_filename($area); |
my $file=&recent_filename($area); |
my %recent=&Apache::lonnet::dump($file); |
my %recent=&Apache::lonnet::dump($file); |
if (scalar(keys(%recent))>20) { |
if (scalar(keys(%recent))>20) { |
# remove oldest value |
# remove oldest value |
my $oldest=time; |
my $oldest=time(); |
my $delkey=''; |
my $delkey=''; |
foreach (keys %recent) { |
foreach my $item (keys(%recent)) { |
my $thistime=(split(/\&/,$recent{$_}))[0]; |
my $thistime=(split(/\&/,$recent{$item}))[0]; |
if ($thistime<$oldest) { |
if (($thistime ne "always_include") && ($thistime<$oldest)) { |
$oldest=$thistime; |
$oldest=$thistime; |
$delkey=$_; |
$delkey=$item; |
} |
} |
} |
} |
&Apache::lonnet::del($file,[$delkey]); |
&Apache::lonnet::del($file,[$delkey]); |
} |
} |
# store new value |
# store new value |
|
my $timestamp; |
|
if ($freeze) { |
|
$timestamp = "always_include"; |
|
} else { |
|
$timestamp = time(); |
|
} |
&Apache::lonnet::put($file,{ $name => |
&Apache::lonnet::put($file,{ $name => |
time.'&'.&escape($value) }); |
$timestamp.'&'.&escape($value) }); |
} |
} |
|
|
sub remove_recent { |
sub remove_recent { |
Line 132 sub select_recent {
|
Line 138 sub select_recent {
|
my $return="\n<select name='$fieldname'". |
my $return="\n<select name='$fieldname'". |
($event?" onchange='$event'":''). |
($event?" onchange='$event'":''). |
">\n<option value=''>--- ".&mt('Recent')." ---</option>"; |
">\n<option value=''>--- ".&mt('Recent')." ---</option>"; |
foreach (sort keys %recent) { |
foreach my $value (sort(keys(%recent))) { |
unless ($_=~/^error\:/) { |
unless ($value =~/^error\:/) { |
my $escaped = &Apache::loncommon::escape_url($_); |
my $escaped = &Apache::loncommon::escape_url($value); |
$return.="\n<option value='$escaped'>". |
$return.="\n<option value='$escaped'>". |
&unescape((split(/\&/,$recent{$_}))[1]). |
&unescape((split(/\&/,$recent{$value}))[1]). |
'</option>'; |
'</option>'; |
} |
} |
} |
} |
Line 149 sub get_recent {
|
Line 155 sub get_recent {
|
my %recent=&Apache::lonnet::dump(&recent_filename($area)); |
my %recent=&Apache::lonnet::dump(&recent_filename($area)); |
|
|
# Create hash with key as time and recent as value |
# Create hash with key as time and recent as value |
|
# Begin filling return_hash with any 'always_include' option |
my %time_hash = (); |
my %time_hash = (); |
my $nfrozen = 0; |
my %return_hash = (); |
foreach (keys %recent) { |
foreach my $item (keys %recent) { |
my ($thistime,$thisvalue)=(split(/\&/,$recent{$_})); |
my ($thistime,$thisvalue)=(split(/\&/,$recent{$item})); |
if (($thisvalue eq 'role_frozen') && ($area='roles')) { |
if ($thistime eq 'always_include') { |
$thistime=time+$nfrozen; |
$return_hash{$item} = &unescape($thisvalue); |
$nfrozen++; |
$n--; |
|
} else { |
|
$time_hash{$thistime} = $item; |
} |
} |
$time_hash{$thistime} = $_; |
|
} |
} |
|
|
# Sort by decreasing time and return key value pairs |
# Sort by decreasing time and return key value pairs |
my %return_hash = (); |
|
my $idx = 1; |
my $idx = 1; |
foreach (reverse sort keys %time_hash) { |
foreach my $item (reverse(sort(keys(%time_hash)))) { |
$return_hash{$time_hash{$_}} = |
$return_hash{$time_hash{$item}} = |
&unescape((split(/\&/,$recent{$time_hash{$_}}))[1]); |
&unescape((split(/\&/,$recent{$time_hash{$item}}))[1]); |
if ($n && ($idx++ >= $n)) {last;} |
if ($n && ($idx++ >= $n)) {last;} |
} |
} |
|
|
return %return_hash; |
return %return_hash; |
} |
} |
|
|
|
sub get_recent_frozen { |
|
my ($area) = @_; |
|
my %recent=&Apache::lonnet::dump(&recent_filename($area)); |
|
|
|
# Create hash with all 'frozen' items |
|
my %return_hash = (); |
|
foreach my $item (keys(%recent)) { |
|
my ($thistime,$thisvalue)=(split(/\&/,$recent{$item})); |
|
if ($thistime eq 'always_include') { |
|
$return_hash{$item} = &unescape($thisvalue); |
|
} |
|
} |
|
return %return_hash; |
|
} |
|
|
|
|
|
|
=pod |
=pod |
Line 330 sub date_setter {
|
Line 352 sub date_setter {
|
} |
} |
my $result = "\n<!-- $dname date setting form -->\n"; |
my $result = "\n<!-- $dname date setting form -->\n"; |
$result .= <<ENDJS; |
$result .= <<ENDJS; |
<script language="Javascript"> |
<script type="text/javascript"> |
function $dname\_checkday() { |
function $dname\_checkday() { |
var day = document.$formname.$dname\_day.value; |
var day = document.$formname.$dname\_day.value; |
var month = document.$formname.$dname\_month.value; |
var month = document.$formname.$dname\_month.value; |
Line 393 document.$formname.$dname\_year.value,
|
Line 415 document.$formname.$dname\_year.value,
|
} |
} |
</script> |
</script> |
ENDJS |
ENDJS |
$result .= ' <nobr>'; |
$result .= ' <span style="white-space: nowrap;">'; |
my $monthselector = qq{<select name="$dname\_month" $special $state onchange="javascript:$dname\_checkday()" >}; |
my $monthselector = qq{<select name="$dname\_month" $special $state onchange="javascript:$dname\_checkday()" >}; |
# Month |
# Month |
my @Months = qw/January February March April May June |
my @Months = qw/January February March April May June |
Line 455 ENDJS
|
Line 477 ENDJS
|
$result .= &mt('[_7]Select Date[_8]',$cal_link,'</a>'); |
$result .= &mt('[_7]Select Date[_8]',$cal_link,'</a>'); |
} |
} |
} |
} |
$result .= "</nobr>\n<!-- end $dname date setting form -->\n"; |
$result .= "</span>\n<!-- end $dname date setting form -->\n"; |
return $result; |
return $result; |
} |
} |
|
|