--- loncom/interface/lonhtmlcommon.pm 2009/08/10 16:27:39 1.230
+++ loncom/interface/lonhtmlcommon.pm 2009/10/30 05:10:03 1.236
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.230 2009/08/10 16:27:39 bisitz Exp $
+# $Id: lonhtmlcommon.pm,v 1.236 2009/10/30 05:10:03 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -82,7 +82,7 @@ sub confirm_success {
.''."\n";
} else {
return ''."\n"
- .'
'."\n"
+ .'
'."\n"
.$message."\n"
.''."\n";
}
@@ -160,8 +160,8 @@ sub authorbombs {
$url=&Apache::lonnet::declutter($url);
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\//) {
+ foreach my $bomb (keys(%bombs)) {
+ if ($bomb =~ /^$udom\/$uname\//) {
return '
'.
&Apache::loncommon::help_open_topic('About_Bombs');
@@ -239,7 +239,7 @@ sub get_recent {
# Begin filling return_hash with any 'always_include' option
my %time_hash = ();
my %return_hash = ();
- foreach my $item (keys %recent) {
+ foreach my $item (keys(%recent)) {
my ($thistime,$thisvalue)=(split(/\&/,$recent{$item}));
if ($thistime eq 'always_include') {
$return_hash{$item} = &unescape($thisvalue);
@@ -1453,7 +1453,7 @@ returns: nothing
}
sub add_breadcrumb {
- push (@Crumbs,@_);
+ push(@Crumbs,@_);
}
} # End of scope for @Crumbs
@@ -1590,6 +1590,10 @@ ENDTWO
sub role_select_row {
my ($roles,$title,$css_class,$show_separate_custom,$cdom,$cnum) = @_;
+ my $crstype = 'Course';
+ if ($cdom ne '' && $cnum ne '') {
+ $crstype = &Apache::loncommon::course_type($cdom.'_'.$cnum);
+ }
my $output;
if (defined($title)) {
$output = &row_title($title,$css_class);
@@ -1614,7 +1618,7 @@ sub role_select_row {
$plrole = &mt('Custom Role');
}
} else {
- $plrole=&Apache::lonnet::plaintext($role);
+ $plrole=&Apache::lonnet::plaintext($role,$crstype);
}
if (($role ne 'cr') || (!$show_separate_custom)) {
$output .= ' ';
@@ -1945,7 +1949,7 @@ sub set_form_elements {
$values{$name}[$i] =~ s/([\r\n\f]+)/\\n/g;
$values{$name}[$i] =~ s/"/\\"/g;
}
- if ($$elements{$name} eq 'text') {
+ if (($$elements{$name} eq 'text') || ($$elements{$name} eq 'hidden')) {
my $numvalues = @{$values{$name}};
if ($numvalues > 1) {
my $valuestring = join('","',@{$values{$name}});
@@ -1980,6 +1984,8 @@ sub set_form_elements {
$output .= qq|
if (courseForm.elements['$name'].value == "$value") {
courseForm.elements['$name'].checked = true;
+ } else {
+ courseForm.elements['$name'].checked = false;
}|;
}
}
@@ -2021,6 +2027,7 @@ sub set_form_elements {
}
}
$output .= "
+ return;
}\n";
return $output;
}
@@ -2109,22 +2116,38 @@ sub inittags {
}
-# USAGE: scripttag(scriptcode, true/false);
+# USAGE: scripttag(scriptcode, [start|end|both]);
#
# EXAMPLES:
-# - scripttag("alert('Hello World!')")
+# - scripttag("alert('Hello World!')", 'both')
+# returns:
+#
#
# NOTES:
# - works currently only for javascripts
#
-# OUTPUT: Scriptcode properly enclosed in