version 1.147, 2006/07/29 00:31:58
|
version 1.163, 2007/09/26 12:42:32
|
Line 60 use Time::Local;
|
Line 60 use Time::Local;
|
use Time::HiRes; |
use Time::HiRes; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonnet; |
use Apache::lonnet; |
use lib '/home/httpd/lib/perl/'; |
|
use LONCAPA; |
use LONCAPA; |
|
|
############################################## |
############################################## |
Line 78 use LONCAPA;
|
Line 77 use LONCAPA;
|
sub authorbombs { |
sub authorbombs { |
my $url=shift; |
my $url=shift; |
$url=&Apache::lonnet::declutter($url); |
$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); |
my %bombs=&Apache::lonmsg::all_url_author_res_msg($uname,$udom); |
foreach (keys %bombs) { |
foreach (keys %bombs) { |
if ($_=~/^$udom\/$uname\//) { |
if ($_=~/^$udom\/$uname\//) { |
Line 141 sub select_recent {
|
Line 140 sub select_recent {
|
foreach my $value (sort(keys(%recent))) { |
foreach my $value (sort(keys(%recent))) { |
unless ($value =~/^error\:/) { |
unless ($value =~/^error\:/) { |
my $escaped = &Apache::loncommon::escape_url($value); |
my $escaped = &Apache::loncommon::escape_url($value); |
|
&Apache::loncommon::inhibit_menu_check(\$escaped); |
$return.="\n<option value='$escaped'>". |
$return.="\n<option value='$escaped'>". |
&unescape((split(/\&/,$recent{$value}))[1]). |
&unescape((split(/\&/,$recent{$value}))[1]). |
'</option>'; |
'</option>'; |
Line 689 sub StatusOptions {
|
Line 689 sub StatusOptions {
|
$status = $env{'form.Status'} if (exists($env{'form.Status'})); |
$status = $env{'form.Status'} if (exists($env{'form.Status'})); |
} |
} |
|
|
my $OpSel1 = ''; |
|
my $OpSel2 = ''; |
|
my $OpSel3 = ''; |
|
|
|
if($status eq 'Any') { $OpSel3 = ' selected'; } |
|
elsif($status eq 'Expired' ) { $OpSel2 = ' selected'; } |
|
else { $OpSel1 = ' selected'; } |
|
|
|
my $Str = ''; |
my $Str = ''; |
$Str .= '<select name="Status"'; |
$Str .= '<select name="Status"'; |
if(defined($formName) && $formName ne '' && ! defined($onchange)) { |
if(defined($formName) && $formName ne '' && ! defined($onchange)) { |
Line 707 sub StatusOptions {
|
Line 699 sub StatusOptions {
|
} |
} |
$Str .= ' size="'.$size.'" '; |
$Str .= ' size="'.$size.'" '; |
$Str .= '>'."\n"; |
$Str .= '>'."\n"; |
$Str .= '<option value="Active" '.$OpSel1.'>'. |
foreach my $type (['Active', &mt('Currently Has Access')], |
&mt('Currently Enrolled').'</option>'."\n"; |
['Future', &mt('Will Have Future Access')], |
$Str .= '<option value="Expired" '.$OpSel2.'>'. |
['Expired', &mt('Previously Had Access')], |
&mt('Previously Enrolled').'</option>'."\n"; |
['Any', &mt('Any Access Status')]) { |
$Str .= '<option value="Any" '.$OpSel3.'>'. |
my ($name,$label) = @$type; |
&mt('Any Enrollment Status').'</option>'."\n"; |
$Str .= '<option value="'.$name.'" '; |
|
if ($status eq $name) { |
|
$Str .= 'selected="selected" '; |
|
} |
|
$Str .= '>'.$label.'</option>'."\n"; |
|
} |
|
|
$Str .= '</select>'."\n"; |
$Str .= '</select>'."\n"; |
} |
} |
|
|
Line 855 sub Create_PrgWin {
|
Line 853 sub Create_PrgWin {
|
popwin=open(\'\',\'popwin\',\'width=400,height=100\');". |
popwin=open(\'\',\'popwin\',\'width=400,height=100\');". |
"popwin.document.writeln(\'".$start_page. |
"popwin.document.writeln(\'".$start_page. |
"<h4>$heading<\/h4>". |
"<h4>$heading<\/h4>". |
"<form name=\"popremain\" method=\"post\">". |
"<form action= \"\" name=\"popremain\" method=\"post\">". |
'<input type="text" size="'.$width.'" name="remaining" value="'. |
'<input type="text" size="'.$width.'" name="remaining" value="'. |
&mt('Starting').'" /><\\/form>'.$end_page. |
&mt('Starting').'" /><\\/form>'.$end_page. |
"\');". |
"\');". |
Line 867 sub Create_PrgWin {
|
Line 865 sub Create_PrgWin {
|
$prog_state{'window'}='window'; |
$prog_state{'window'}='window'; |
if (!$formname) { |
if (!$formname) { |
$prog_state{'formname'}=&get_uniq_name(); |
$prog_state{'formname'}=&get_uniq_name(); |
&r_print($r,'<form name="'.$prog_state{'formname'}.'">'); |
&r_print($r,'<form action="" name="'.$prog_state{'formname'}.'">'); |
} else { |
} else { |
$prog_state{'formname'}=$formname; |
$prog_state{'formname'}=$formname; |
} |
} |
Line 894 sub Create_PrgWin {
|
Line 892 sub Create_PrgWin {
|
# update progress |
# update progress |
sub Update_PrgWin { |
sub Update_PrgWin { |
my ($r,$prog_state,$displayString)=@_; |
my ($r,$prog_state,$displayString)=@_; |
&r_print($r,'<script>'.$$prog_state{'window'}.'.document.'. |
&r_print($r,'<script type="text/javascript">'.$$prog_state{'window'}.'.document.'. |
$$prog_state{'formname'}.'.'. |
$$prog_state{'formname'}.'.'. |
$$prog_state{'inputname'}.'.value="'. |
$$prog_state{'inputname'}.'.value="'. |
$displayString.'";</script>'); |
$displayString.'";</script>'); |
Line 1005 sub crumbs {
|
Line 1003 sub crumbs {
|
} |
} |
} else { |
} else { |
$path.='/'; |
$path.='/'; |
|
} |
|
my $href_path = &HTML::Entities::encode($path,'<>&"'); |
|
&Apache::loncommon::inhibit_menu_check(\$href_path); |
|
if ($form) { |
|
my $href = 'javascript:'.$form.".action='".$href_path."';".$form.'.submit();'; |
|
$output.=qq{<a href="$href" $target>$dir</a>/}; |
|
} else { |
|
$output.=qq{<a href="$href_path" $target>$dir</a>/}; |
} |
} |
my $linkpath = &Apache::loncommon::escape_single($path); |
|
if ($form) { |
|
$linkpath= |
|
qq{javascript:$form.action='$linkpath';$form.submit();}; |
|
} |
|
$output.=qq{<a href="$linkpath" $target>$dir</a>/}; |
|
} |
} |
} else { |
} else { |
$output.=$uri; |
foreach my $dir (split('/',$uri)) { |
|
if (! $dir) { next; } |
|
$output.=$dir.'/'; |
|
} |
} |
} |
unless ($uri=~/\/$/) { $output=~s/\/$//; } |
if ($uri !~ m|/$|) { $output=~s|/$||; } |
return $output.'</font>'.($noformat?'':'</b></tt><br />'); |
return $output.'</font>'.($noformat?'':'</b></tt><br />'); |
} |
} |
|
|
Line 1045 var checkwin;
|
Line 1048 var checkwin;
|
function spellcheckerwindow(string) { |
function spellcheckerwindow(string) { |
var esc_string = string.replace(/\"/g,'"'); |
var esc_string = string.replace(/\"/g,'"'); |
checkwin=window.open($nothing,'spellcheckwin','height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no'); |
checkwin=window.open($nothing,'spellcheckwin','height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no'); |
checkwin.document.writeln('$start_page<form name="spellcheckform" action="/adm/spellcheck" method="post"><input type="hidden" name="text" value="'+esc_string+'" /><\/form>$end_page'); |
checkwin.document.writeln('$start_page<form name="spellcheckform" action="/adm/spellcheck" method="post"><input type="hidden" name="text" value="'+esc_string+'" /><\\/form>$end_page'); |
checkwin.document.close(); |
checkwin.document.close(); |
} |
} |
// END LON-CAPA Internal --> |
// END LON-CAPA Internal --> |
Line 1202 Pushes a breadcrumb on the stack of crum
|
Line 1205 Pushes a breadcrumb on the stack of crum
|
|
|
input: $breadcrumb, a hash reference. The keys 'href','title', and 'text' |
input: $breadcrumb, a hash reference. The keys 'href','title', and 'text' |
are required. If present the keys 'faq' and 'bug' will be used to provide |
are required. If present the keys 'faq' and 'bug' will be used to provide |
links to the FAQ and bug sites. |
links to the FAQ and bug sites. If the key 'no_mt' is present the 'title' |
|
and 'text' values won't be sent through &mt() |
|
|
returns: nothing |
returns: nothing |
|
|
Line 1252 returns: nothing
|
Line 1256 returns: nothing
|
if (defined($_->{'target'}) && $_->{'target'} ne '') { |
if (defined($_->{'target'}) && $_->{'target'} ne '') { |
$result .= 'target="'.$_->{'target'}.'" '; |
$result .= 'target="'.$_->{'target'}.'" '; |
} |
} |
$result .='title="'.&mt($_->{'title'}).'">'. |
if ($_->{'no_mt'}) { |
&mt($_->{'text'}).'</a>'; |
$result .='title="'.$_->{'title'}.'">'. |
|
$_->{'text'}.'</a>'; |
|
} else { |
|
$result .='title="'.&mt($_->{'title'}).'">'. |
|
&mt($_->{'text'}).'</a>'; |
|
} |
$result; |
$result; |
} @Crumbs |
} @Crumbs |
); |
); |
$links .= '->' if ($links ne ''); |
$links .= '->' if ($links ne ''); |
$links .= '<b>'.&mt($last->{'text'}).'</b>'; |
if ($last->{'no_mt'}) { |
|
$links .= '<b>'.$last->{'text'}.'</b>'; |
|
} else { |
|
$links .= '<b>'.&mt($last->{'text'}).'</b>'; |
|
} |
# |
# |
my $icons = ''; |
my $icons = ''; |
$faq = $last->{'faq'} if (exists($last->{'faq'})); |
$faq = $last->{'faq'} if (exists($last->{'faq'})); |
Line 1321 returns: nothing
|
Line 1334 returns: nothing
|
# row2 |
# row2 |
# row3 ... etc. |
# row3 ... etc. |
# &submit_row(0 |
# &submit_row(0 |
# &end_pickbox() |
# &end_pick_box() |
# |
# |
# where row1, row 2 etc. are chosen from &role_select_row,&course_select_row, |
# where row1, row 2 etc. are chosen from &role_select_row,&course_select_row, |
# &status_select_row and &email_default_row |
# &status_select_row and &email_default_row |
Line 1559 sub status_select_row {
|
Line 1572 sub status_select_row {
|
sub email_default_row { |
sub email_default_row { |
my ($authtypes,$title,$descrip,$css_class) = @_; |
my ($authtypes,$title,$descrip,$css_class) = @_; |
my $output = &row_title($title,$css_class); |
my $output = &row_title($title,$css_class); |
my @rowcols = ('#eeeeee','#dddddd'); |
|
$output .= $descrip. |
$output .= $descrip. |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(). |
&Apache::loncommon::start_data_table_header_row(). |
Line 1784 sub set_form_elements {
|
Line 1796 sub set_form_elements {
|
($$elements{$name} eq 'checkbox')) { |
($$elements{$name} eq 'checkbox')) { |
$output .= qq| |
$output .= qq| |
if (courseForm.elements['$name'].value == "$value") { |
if (courseForm.elements['$name'].value == "$value") { |
courseForm.elemenst['$name'].checked = true; |
courseForm.elements['$name'].checked = true; |
}|; |
}|; |
} |
} |
} |
} |
Line 1830 sub set_form_elements {
|
Line 1842 sub set_form_elements {
|
return $output; |
return $output; |
} |
} |
|
|
|
############################################## |
|
############################################## |
|
|
|
# javascript_valid_email |
|
# |
|
# Generates javascript to validate an e-mail address. |
|
# Returns a javascript function which accetps a form field as argumnent, and |
|
# returns false if field.value does not satisfy two regular expression matches |
|
# for a valid e-mail address. Backwards compatible with old browsers without |
|
# support for javascript RegExp (just checks for @ in field.value in this case). |
|
|
|
sub javascript_valid_email { |
|
my $scripttag .= <<'END'; |
|
function validmail(field) { |
|
var str = field.value; |
|
if (window.RegExp) { |
|
var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)"; |
|
var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; //" |
|
var reg1 = new RegExp(reg1str); |
|
var reg2 = new RegExp(reg2str); |
|
if (!reg1.test(str) && reg2.test(str)) { |
|
return true; |
|
} |
|
return false; |
|
} |
|
else |
|
{ |
|
if(str.indexOf("@") >= 0) { |
|
return true; |
|
} |
|
return false; |
|
} |
|
} |
|
END |
|
return $scripttag; |
|
} |
|
|
|
############################################## |
|
############################################## |
|
|
|
# javascript_window_dims |
|
# |
|
# Generates javascript to get the dimensions of the user's browser window. |
|
|
|
sub javascript_window_dims { |
|
my $scripttag .= <<'END'; |
|
function getDimensions(width,height) { |
|
width.value = getWindowWidth(); |
|
height.value = getWindowHeight(); |
|
return; |
|
} |
|
|
|
function getWindowWidth() { |
|
var width = 0; |
|
if( document.documentElement && document.documentElement.clientWidth ) { |
|
width = document.documentElement.clientWidth; |
|
} |
|
else if( document.body && document.body.clientWidth ) { |
|
width = document.body.clientWidth; |
|
} |
|
else if( window.innerWidth ) { |
|
width = window.innerWidth - 18; |
|
} |
|
return width; |
|
} |
|
|
|
function getWindowHeight() { |
|
var height = 0; |
|
if( document.documentElement && document.documentElement.clientHeight ) { |
|
height = document.documentElement.clientHeight; |
|
} |
|
else if( document.body && document.body.clientHeight ) { |
|
height = document.body.clientHeight; |
|
} |
|
else if( window.innerHeight ) { |
|
height = window.innerHeight - 18; |
|
} |
|
return height; |
|
} |
|
|
|
END |
|
return $scripttag; |
|
} |
1; |
1; |
|
|
__END__ |
__END__ |