version 1.37, 2003/12/29 21:17:00
|
version 1.45, 2004/02/03 21:52:22
|
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 .= " "; |
$result .= " "; |
$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 744 Returns: none
|
Line 826 Returns: none
|
# Create progress |
# Create progress |
sub Create_PrgWin { |
sub Create_PrgWin { |
my ($r, $title, $heading, $number_to_do)=@_; |
my ($r, $title, $heading, $number_to_do)=@_; |
|
#the whole function called through timeout is due to issues |
|
#in mozilla Read BUG #2665 if you want to know the whole story |
$r->print('<script>'. |
$r->print('<script>'. |
"popwin=open(\'\',\'popwin\',\'width=400,height=100\');". |
"var popwin; |
|
function openpopwin () { |
|
popwin=open(\'\',\'popwin\',\'width=400,height=100\');". |
"popwin.document.writeln(\'<html><head><title>$title</title></head>". |
"popwin.document.writeln(\'<html><head><title>$title</title></head>". |
"<body bgcolor=\"#88DDFF\">". |
"<body bgcolor=\"#88DDFF\">". |
"<h4>$heading</h4>". |
"<h4>$heading</h4>". |
Line 753 sub Create_PrgWin {
|
Line 839 sub Create_PrgWin {
|
'<input type="text" size="55" name="remaining" value="'. |
'<input type="text" size="55" name="remaining" value="'. |
&mt('Starting').'"></form>'. |
&mt('Starting').'"></form>'. |
"</body></html>\');". |
"</body></html>\');". |
"popwin.document.close();". |
"popwin.document.close();}". |
"</script>"); |
"\nwindow.setTimeout(openpopwin,0)</script>"); |
|
|
my %prog_state; |
my %prog_state; |
$prog_state{'done'}=0; |
$prog_state{'done'}=0; |
Line 839 sub Close_PrgWin {
|
Line 925 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>/'; |
unless ($path eq $uri) { $path.='/'; } |
|
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; |