--- loncom/interface/lonhtmlcommon.pm 2006/03/21 18:39:02 1.122
+++ loncom/interface/lonhtmlcommon.pm 2006/06/22 15:53:48 1.135
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.122 2006/03/21 18:39:02 albertel Exp $
+# $Id: lonhtmlcommon.pm,v 1.135 2006/06/22 15:53:48 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -60,6 +60,8 @@ use Time::Local;
use Time::HiRes;
use Apache::lonlocal;
use Apache::lonnet;
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
##############################################
##############################################
@@ -93,7 +95,7 @@ sub authorbombs {
sub recent_filename {
my $area=shift;
- return 'nohist_recent_'.&Apache::lonnet::escape($area);
+ return 'nohist_recent_'.&escape($area);
}
sub store_recent {
@@ -115,7 +117,7 @@ sub store_recent {
}
# store new value
&Apache::lonnet::put($file,{ $name =>
- time.'&'.&Apache::lonnet::escape($value) });
+ time.'&'.&escape($value) });
}
sub remove_recent {
@@ -134,7 +136,7 @@ sub select_recent {
unless ($_=~/^error\:/) {
my $escaped = &Apache::loncommon::escape_url($_);
$return.="\n';
}
}
@@ -148,8 +150,13 @@ sub get_recent {
# Create hash with key as time and recent as value
my %time_hash = ();
+ my $nfrozen = 0;
foreach (keys %recent) {
- my $thistime=(split(/\&/,$recent{$_}))[0];
+ my ($thistime,$thisvalue)=(split(/\&/,$recent{$_}));
+ if (($thisvalue eq 'role_frozen') && ($area='roles')) {
+ $thistime=time+$nfrozen;
+ $nfrozen++;
+ }
$time_hash{$thistime} = $_;
}
@@ -158,7 +165,7 @@ sub get_recent {
my $idx = 1;
foreach (reverse sort keys %time_hash) {
$return_hash{$time_hash{$_}} =
- &Apache::lonnet::unescape((split(/\&/,$recent{$_}))[1]);
+ &unescape((split(/\&/,$recent{$time_hash{$_}}))[1]);
if ($n && ($idx++ >= $n)) {last;}
}
@@ -178,6 +185,7 @@ sub get_recent {
sub textbox {
my ($name,$value,$size,$special) = @_;
$size = 40 if (! defined($size));
+ $value = &HTML::Entities::encode($value,'<>&"');
my $Str = '';
return $Str;
@@ -280,7 +288,7 @@ The method used to restrict user input w
##############################################
sub date_setter {
my ($formname,$dname,$currentvalue,$special,$includeempty,$state,
- $no_hh_mm_ss,$defhour,$defmin,$defsec) = @_;
+ $no_hh_mm_ss,$defhour,$defmin,$defsec,$nolink) = @_;
my $wasdefined=1;
if (! defined($state) || $state ne 'disabled') {
$state = '';
@@ -322,7 +330,7 @@ sub date_setter {
}
my $result = "\n\n";
$result .= <
+
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('[_4]Select Date[_5]',$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('[_7]Select Date[_8]',$cal_link,'');
+ }
}
- $result .= "\n\n";
+ $result .= "\n\n";
return $result;
}
@@ -524,7 +539,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;
@@ -817,10 +832,10 @@ sub Create_PrgWin {
function openpopwin () {
popwin=open(\'\',\'popwin\',\'width=400,height=100\');".
"popwin.document.writeln(\'".$start_page.
- "$heading
".
- "'.$end_page.
+ &mt('Starting').'" /><\\/form>'.$end_page.
"\');".
"popwin.document.close();}".
"\nwindow.setTimeout(openpopwin,0)");
@@ -945,7 +960,7 @@ sub r_print {
# ------------------------------------------------------- Puts directory header
sub crumbs {
- my ($uri,$target,$prefix,$form,$size,$noformat)=@_;
+ my ($uri,$target,$prefix,$form,$size,$noformat,$skiplast)=@_;
if (! defined($size)) {
$size = '+2';
}
@@ -961,7 +976,14 @@ sub crumbs {
foreach my $dir (split('/',$uri)) {
if (! $dir) { next; }
$path .= $dir;
- unless ($path eq $uri) { $path.='/'; }
+ if ($path eq $uri) {
+ if ($skiplast) {
+ $output.=$dir;
+ last;
+ }
+ } else {
+ $path.='/';
+ }
my $linkpath = &Apache::loncommon::escape_single($path);
if ($form) {
$linkpath=
@@ -979,7 +1001,14 @@ sub crumbs {
# --------------------- A function that generates a window for the spellchecker
sub spellheader {
- my $html=&Apache::lonxml::xmlbegin();
+ my $start_page=
+ &Apache::loncommon::start_page('Speller Suggestions',undef,
+ {'only_body' => 1,
+ 'js_ready' => 1,
+ 'bgcolor' => '#DDDDDD',});
+ my $end_page=
+ &Apache::loncommon::end_page({'js_ready' => 1});
+
my $nothing=&javascript_nothing();
return (<
@@ -988,7 +1017,7 @@ var checkwin;
function spellcheckerwindow() {
checkwin=window.open($nothing,'spellcheckwin','height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
- checkwin.document.writeln('$html