[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm /interface loncommon.pm lonhtmlcommon.pm
bisitz
bisitz@source.lon-capa.org
Fri, 22 May 2009 17:57:19 -0000
This is a MIME encoded message
--bisitz1243015039
Content-Type: text/plain
bisitz Fri May 22 17:57:19 2009 EDT
Modified files:
/loncom/auth lonroles.pm
/loncom/interface loncommon.pm lonhtmlcommon.pm
Log:
XHTML:
- Properly exclude javascript code from being interpreted as HTML code
- Added alt attributes to <img> tags
- Lower case attributes (onclick)
- Added dummy action to <form>
- Added error style to lonroles error message
--bisitz1243015039
Content-Type: text/plain
Content-Disposition: attachment; filename="bisitz-20090522175719.txt"
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.224 loncom/auth/lonroles.pm:1.225
--- loncom/auth/lonroles.pm:1.224 Mon May 18 17:30:34 2009
+++ loncom/auth/lonroles.pm Fri May 22 17:57:03 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.224 2009/05/18 17:30:34 raeburn Exp $
+# $Id: lonroles.pm,v 1.225 2009/05/22 17:57:03 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -167,7 +167,9 @@
$r->print(<<ENDREDIR);
$start_page
<script type="text/javascript">
+// <![CDATA[
$swinfo
+// ]]>
</script>
$navwindow
<p>$msg</p>
@@ -183,9 +185,12 @@
$r->send_http_header;
return OK if $r->header_only;
$r->print(&Apache::loncommon::start_page('Problems during Course Initialization').
- '<script type="text/javascript">'.
- &Apache::lonmenu::rawconfig().'</script>'.
- '<p>'.&mt('The following problems occurred:').
+ '<script type="text/javascript">'.
+ '// <![CDATA['.
+ &Apache::lonmenu::rawconfig().
+ '// ]]>'.
+ '</script>'.
+ '<p class="LC_error">'.&mt('The following problems occurred:').
$error.
'</p><br /><a href="'.$dest.'">'.&mt('Continue').'</a>'.
&Apache::loncommon::end_page());
@@ -367,9 +372,11 @@
$r->print(<<ENDENTEREDKEY);
$start_page
<script type="text/javascript">
+// <![CDATA[
$swinfo
+// ]]>
</script>
-<form method="post">
+<form action="" method="post">
<input type="hidden" name="selectrole" value="1" />
<input type="hidden" name="$trolecode" value="1" />
<span class="LC_fontsize_large">$message</span><br />
@@ -390,9 +397,11 @@
$r->print(<<ENDENTERKEY);
$start_page
<script type="text/javascript">
+// <![CDATA[
$swinfo
+// ]]>
</script>
-<form method="post">
+<form action="" method="post">
<input type="hidden" name="selectrole" value="1" />
<input type="hidden" name="$trolecode" value="1" />
<input type="text" size="20" name="newkey" value="$env{'form.newkey'}" />
@@ -576,6 +585,7 @@
$noscript
</noscript>
<script type="text/javascript">
+// <![CDATA[
$swinfo
window.focus();
@@ -592,6 +602,7 @@
alert('$standby');
}
}
+// ]]>
</script>
ENDHEADER
@@ -971,7 +982,7 @@
.'<a href="/adm/logout">'.&mt('Logout').'</a> '
.'<a href="/adm/coursecatalog?showdom='.$esc_dom.'">'
.&mt('Course Catalog')
- .'</small></p>');
+ .'</a></small></p>');
}
$r->print(&Apache::loncommon::end_page());
return OK;
@@ -1246,31 +1257,31 @@
} elsif ($tstatus eq 'is') {
$roletext.='<td'.$rowspan.' class="'.$tbg.'">'.
'<input name="'.$buttonname.'" type="button" value="'.
- &mt('Select').'" onClick="javascript:enterrole(this.form,\''.
+ &mt('Select').'" onclick="javascript:enterrole(this.form,\''.
$trolecode."','".$buttonname.'\');" /></td>';
} elsif ($tryagain) {
$roletext.=
'<td'.$rowspan.' class="'.$tbg.'">'.
'<input name="'.$buttonname.'" type="button" value="'.
- &mt('Try Selecting Again').'" onClick="javascript:enterrole(this.form,\''.
+ &mt('Try Selecting Again').'" onclick="javascript:enterrole(this.form,\''.
$trolecode."','".$buttonname.'\');" /></td>';
} elsif ($advanced) {
$roletext.=
'<td'.$rowspan.' class="'.$tbg.'">'.
'<input name="'.$buttonname.'" type="button" value="'.
- &mt('Re-Initialize').'" onClick="javascript:enterrole(this.form,\''.
+ &mt('Re-Initialize').'" onclick="javascript:enterrole(this.form,\''.
$trolecode."','".$buttonname.'\');" /></td>';
} elsif ($reinit) {
$roletext.=
'<td'.$rowspan.' class="'.$tbg.'">'.
'<input name="'.$buttonname.'" type="button" value="'.
- &mt('Re-Select').'" onClick="javascript:enterrole(this.form,\''.
+ &mt('Re-Select').'" onclick="javascript:enterrole(this.form,\''.
$trolecode."','".$buttonname.'\');" /></td>';
} else {
$roletext.=
'<td'.$rowspan.' class="'.$tbg.'">'.
'<input name="'.$buttonname.'" type="button" value="'.
- &mt('Re-Select').'" onClick="javascript:enterrole(this.form,\''.
+ &mt('Re-Select').'" onclick="javascript:enterrole(this.form,\''.
$trolecode."','".$buttonname.'\');" /></td>';
}
}
@@ -1437,6 +1448,7 @@
);
my $verify_script = <<"END";
<script type="text/javascript">
+// <![CDATA[
function verifyCoursePick(caller) {
var numbutton = getIndex(caller)
var pickedCourse = document.rolechoice.elements[numbutton+4].value
@@ -1465,6 +1477,7 @@
}
return -1;
}
+// ]]>
</script>
END
return $verify_script;
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.823 loncom/interface/loncommon.pm:1.824
--- loncom/interface/loncommon.pm:1.823 Wed May 20 17:39:06 2009
+++ loncom/interface/loncommon.pm Fri May 22 17:57:19 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.823 2009/05/20 17:39:06 bisitz Exp $
+# $Id: loncommon.pm,v 1.824 2009/05/22 17:57:19 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -407,6 +407,7 @@
) { return ''; }
return (<<'ENDSTDBRW');
<script type="text/javascript" language="Javascript">
+// <![CDATA[
var stdeditbrowser;
function openstdbrowser(formname,uname,udom,roleflag,ignorefilter,courseadvonly) {
var url = '/adm/pickstudent?';
@@ -429,6 +430,7 @@
stdeditbrowser = open(url,title,options,'1');
stdeditbrowser.focus();
}
+// ]]>
</script>
ENDSTDBRW
}
@@ -461,6 +463,7 @@
sub authorbrowser_javascript {
return <<"ENDAUTHORBRW";
<script type="text/javascript" language="JavaScript">
+// <![CDATA[
var stdeditbrowser;
function openauthorbrowser(formname,udom) {
@@ -473,6 +476,7 @@
stdeditbrowser.focus();
}
+// ]]>
</script>
ENDAUTHORBRW
}
@@ -482,6 +486,7 @@
my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Group - for which you wish to add/modify a user role');
my $output = '
<script type="text/javascript" language="JavaScript">
+// <![CDATA[
var stdeditbrowser;'."\n";
$output .= <<"ENDSTDBRW";
function opencrsbrowser(formname,uname,udom,desc,extra_element,multflag,crstype) {
@@ -568,6 +573,7 @@
$output .= &setsec_javascript($sec_element,$formname);
}
$output .= '
+// ]]>
</script>';
return $output;
}
@@ -829,6 +835,7 @@
# output the javascript to do the changing
my $result = '';
$result.='<script type="text/javascript" language="JavaScript">'."\n";
+ $result.="// <![CDATA[\n";
$result.="var select2data = new Object();\n";
$" = '","';
my $debug = '';
@@ -874,6 +881,7 @@
}
}
}
+// ]]>
</script>
END
# output the initial values for the selection lists
@@ -1027,7 +1035,9 @@
my $banner_link = "/adm/helpmenu?page=banner&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp&stayonpage=$stayOnPage";
my $output .= <<"ENDOUTPUT";
<script type="text/javascript">
+// <![CDATA[
banner_link = '$banner_link';
+// ]]>
</script>
ENDOUTPUT
return $output;
@@ -1394,6 +1404,7 @@
my $geometry = &viewport_geometry_js();
return <<"RESIZE";
<script type="text/javascript">
+// <![CDATA[
$geometry
function getX(element) {
@@ -1432,6 +1443,7 @@
}
textarea.style.height=new_height+'px';
}
+// ]]>
</script>
RESIZE
@@ -2299,7 +2311,7 @@
$result = &mt
('[_1] Internally authenticated (with initial password [_2])',
'<label>'.$authtype,'</label>'.$autharg);
- $result.="<label><input type=\"checkbox\" name=\"visible\" onClick='if (this.checked) { this.form.intarg.type=\"text\" } else { this.form.intarg.type=\"password\" }' />".&mt('Visible input').'</label>';
+ $result.="<label><input type=\"checkbox\" name=\"visible\" onclick='if (this.checked) { this.form.intarg.type=\"text\" } else { this.form.intarg.type=\"password\" }' />".&mt('Visible input').'</label>';
return $result;
}
@@ -7617,6 +7629,7 @@
my $output = <<"END_BLOCK";
<script type="text/javascript">
+// <![CDATA[
function validateEntry(callingForm) {
var checkok = 1;
@@ -7685,6 +7698,7 @@
$newuserscript
+// ]]>
</script>
$new_user_create
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.217 loncom/interface/lonhtmlcommon.pm:1.218
--- loncom/interface/lonhtmlcommon.pm:1.217 Wed May 20 20:27:37 2009
+++ loncom/interface/lonhtmlcommon.pm Fri May 22 17:57:19 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.217 2009/05/20 20:27:37 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.218 2009/05/22 17:57:19 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -77,12 +77,12 @@
my ($message,$failure)=@_;
if ($failure) {
return '<span class="LC_error">'."\n"
- .'<img src="/adm/lonIcons/navmap.wrong.gif" /> '."\n"
+ .'<img src="/adm/lonIcons/navmap.wrong.gif" alt="'.&mt('Error').'" /> '."\n"
.$message."\n"
.'</span>'."\n";
} else {
return '<span class="LC_success">'."\n"
- .'<img src="/adm/lonIcons/navmap.correct.gif" /> '."\n"
+ .'<img src="/adm/lonIcons/navmap.correct.gif" alt="'.&mt('Ok').'" /> '."\n"
.$message."\n"
.'</span>'."\n";
}
@@ -130,11 +130,13 @@
my ($popup) = @_;
return <<ENDDRAGMATHJS;
<script type="text/javascript">
+ // <![CDATA[
function mathedit(textarea, doc) {
targetEntry = textarea;
targetDoc = doc;
newwin = window.open("/adm/dragmath/applet/$popup.html","","width=565,height=500,resizable");
}
+ // ]]>
</script>
ENDDRAGMATHJS
@@ -161,7 +163,7 @@
foreach (keys %bombs) {
if ($_=~/^$udom\/$uname\//) {
return '<a href="/adm/bombs/'.$url.
- '"><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/bomb.gif').'" border="0" /></a>'.
+ '"><img src="'.&Apache::loncommon::lonhttpdurl('/adm/lonMisc/bomb.gif').'" alt="'.&mt('Bomb').'" border="0" /></a>'.
&Apache::loncommon::help_open_topic('About_Bombs');
}
}
@@ -430,6 +432,7 @@
my $result = "\n<!-- $dname date setting form -->\n";
$result .= <<ENDJS;
<script type="text/javascript">
+// <![CDATA[
function $dname\_checkday() {
var day = document.$formname.$dname\_day.value;
var month = document.$formname.$dname\_month.value;
@@ -490,6 +493,7 @@
}
}
+// ]]>
</script>
ENDJS
$result .= ' <span class="LC_nobreak">';
@@ -975,6 +979,7 @@
#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($r,'<script type="text/javascript">'.
+ '// <![CDATA['.
"var popwin;
function openpopwin () {
popwin=open(\'\',\'popwin\',\'width=400,height=100\');".
@@ -985,7 +990,9 @@
&mt('Starting').'" /><\\/form>'.$end_page.
"\');".
"popwin.document.close();}".
- "\nwindow.setTimeout(openpopwin,0)</script>");
+ "\nwindow.setTimeout(openpopwin,0)".
+ '// ]]>'.
+ '</script>');
$prog_state{'formname'}='popremain';
$prog_state{'inputname'}="remaining";
} elsif ($type eq 'inline') {
@@ -1018,10 +1025,14 @@
# update progress
sub Update_PrgWin {
my ($r,$prog_state,$displayString)=@_;
- &r_print($r,'<script type="text/javascript">'.$$prog_state{'window'}.'.document.'.
+ &r_print($r,'<script type="text/javascript">'.
+ '// <![CDATA['.
+ $$prog_state{'window'}.'.document.'.
$$prog_state{'formname'}.'.'.
$$prog_state{'inputname'}.'.value="'.
- $displayString.'";</script>');
+ $displayString.'";'.
+ '// ]]>'.
+ '</script>');
$$prog_state{'laststart'}=&Time::HiRes::time();
}
@@ -1074,11 +1085,15 @@
if ($user_browser eq 'explorer' && $user_os =~ 'mac') {
$lasttime = '';
}
- &r_print($r,'<script>'.$$prog_state{'window'}.'.document.'.
+ &r_print($r,'<script>'.
+ '// <![CDATA['.
+ $$prog_state{'window'}.'.document.'.
$$prog_state{'formname'}.'.'.
$$prog_state{'inputname'}.'.value="'.
$$prog_state{'done'}.'/'.$$prog_state{'max'}.
- ': '.$time_est.' '.&mt('remaining').' '.$lasttime.'";'.'</script>');
+ ': '.$time_est.' '.&mt('remaining').' '.$lasttime.'";'.
+ '// ]]>'.
+ '</script>');
$$prog_state{'laststart'}=&Time::HiRes::time();
}
@@ -1086,7 +1101,11 @@
sub Close_PrgWin {
my ($r,$prog_state)=@_;
if ($$prog_state{'type'} eq 'popup') {
- &r_print($r,'<script>popwin.close()</script>'."\n");
+ &r_print($r,'<script>'.
+ '// <![CDATA['.
+ 'popwin.close()'.
+ '// ]]>'.
+ '</script>'."\n");
} elsif ($$prog_state{'type'} eq 'inline') {
&Update_PrgWin($r,$prog_state,&mt('Done'));
}
@@ -1168,6 +1187,7 @@
my $nothing=&javascript_nothing();
return (<<ENDCHECK);
<script type="text/javascript">
+// <![CDATA[
//<!-- BEGIN LON-CAPA Internal
var checkwin;
@@ -1178,6 +1198,7 @@
checkwin.document.close();
}
// END LON-CAPA Internal -->
+// ]]>
</script>
ENDCHECK
}
@@ -1251,7 +1272,8 @@
my @fields=@_;
unless (&htmlareabrowser()) { return ''; }
if (&htmlareablocked()) { return '<br />'.&enablelink(@fields); }
- my $output='<script type="text/javascript" defer="1">';
+ my $output='<script type="text/javascript" defer="1">'
+ .'// <![CDATA[';
my $lang = &htmlarea_lang();
foreach my $field (@fields) {
$output.="
@@ -1264,7 +1286,9 @@
oFCKeditor.Config['DefaultLanguage'] = '$lang';
}";
}
- $output.="\nwindow.status='Activated Editfields';\n</script><br />".
+ $output.="\nwindow.status='Activated Editfields';\n"
+ .'// ]]>'
+ .'</script><br />'.
&disablelink(@fields);
return $output;
}
@@ -1646,6 +1670,7 @@
my ($formname,$totcodes,$codetitles,$idlist,$idlist_titles) = @_;
my $output = qq|
<script type="text/javascript">
+// <![CDATA[
function coursePick (formname) {
for (var i=0; i<formname.coursepick.length; i++) {
if (formname.coursepick[i].value == 'category') {
@@ -1668,6 +1693,7 @@
formname.courselist = '';
}
}
+// ]]>
</script>
|;
my $courseform='<b>'.&Apache::loncommon::selectcourse_link
--bisitz1243015039--