[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm londependencies.pm londocs.pm
raeburn
raeburn at source.lon-capa.org
Mon Jan 26 12:34:25 EST 2026
raeburn Mon Jan 26 17:34:25 2026 EDT
Modified files:
/loncom/interface londependencies.pm londocs.pm loncommon.pm
Log:
- WCAG 2 compliance
- Include landmark for page's main content to support "Skip to main content"
- Sequential headings
- Include labels for form elements
- Group form elements in fieldset with legend for screenreaders
- Include empty alt tag for icons
- Satisfy w3c validation: balance opening <p> with </p>, remove duplicate "
-------------- next part --------------
Index: loncom/interface/londependencies.pm
diff -u loncom/interface/londependencies.pm:1.5 loncom/interface/londependencies.pm:1.6
--- loncom/interface/londependencies.pm:1.5 Sun Aug 13 20:52:59 2017
+++ loncom/interface/londependencies.pm Mon Jan 26 17:34:25 2026
@@ -2,7 +2,7 @@
# Handler to manage dependencies for HTML files uploaded directly
# to a course.
#
-# $Id: londependencies.pm,v 1.5 2017/08/13 20:52:59 raeburn Exp $
+# $Id: londependencies.pm,v 1.6 2026/01/26 17:34:25 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -132,10 +132,11 @@
}
my $js = &Apache::loncommon::ask_embedded_js();
my $output = &Apache::loncommon::start_page($title,$js,
- {'only_body' => 1});
+ {'only_body' => 1}).
+ '<div class="LC_landmark" role="main" id="LC_main_content">';
if ($earlyout) {
$r->print($output.&mt('Cannot display dependency information - invalid file: [_1].',$url).
- &Apache::loncommon::end_page());
+ '</div>'.&Apache::loncommon::end_page());
return OK;
}
if ($action eq 'modifyhrefs') {
@@ -156,13 +157,13 @@
} else {
$output .= &mt('Cannot display dependency information - invalid file: [_1].',$url);
}
- $output .= '<p><a href="javascript:window.close()">'.&mt('Close window').'</a>';
+ $output .= '<p><a href="javascript:window.close()">'.&mt('Close window').'</a></p>';
}
if (($action eq 'modifyhrefs') && ($numrefchanges > 0)) {
$output .= '<p><a href="javascript:window.opener.location.reload(true);javascript:window.close();">'.
- &mt('Close pop-up window and reload page').'</a>';
+ &mt('Close pop-up window and reload page').'</a></p>';
}
- $output .= &Apache::loncommon::end_page();
+ $output .= '</div>'.&Apache::loncommon::end_page();
$r->print($output);
return OK;
}
@@ -209,11 +210,11 @@
}
}
if ($outcome ne '') {
- $output .= '<h4>'.&mt('Deleted unused files').'</h4>'.
+ $output .= '<h2 class="LC_heading_3">'.&mt('Deleted unused files').'</h2>'.
'<ul>'.$outcome.'</ul>';
}
if ($error ne '') {
- $output .= '<h4>'.&mt('Error(s) deleting unused files').'</h4>'.
+ $output .= '<h2 class="LC_heading_3">'.&mt('Error(s) deleting unused files').'</h2>'.
'<p class="LC_warning">'.$error.'</p>';
}
}
@@ -222,7 +223,7 @@
&Apache::loncommon::upload_embedded($context,$destination,$cnum,$cdom,
$dir_root,$url_root,undef,undef,undef,
$state,'/adm/dependencies');
- $output .= '<h4>'.&mt('Uploaded files').'</h4>'.
+ $output .= '<h2 class="LC_heading_3">'.&mt('Uploaded files').'</h2>'.
$result;
unless ($numpathchgs) {
if ($context eq 'syllabus') {
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.736 loncom/interface/londocs.pm:1.737
--- loncom/interface/londocs.pm:1.736 Tue Jan 13 03:18:22 2026
+++ loncom/interface/londocs.pm Mon Jan 26 17:34:25 2026
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.736 2026/01/13 03:18:22 raeburn Exp $
+# $Id: londocs.pm,v 1.737 2026/01/26 17:34:25 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -7517,6 +7517,9 @@
&Apache::lonnet::update_supp_caches($coursedom,$coursenum);
undef($suppchanges);
}
+ if ($uploadphase) {
+ $r->print('<div class="LC_landmark" role="main" id="LC_main_content">');
+ }
$r->print($upload_output);
} elsif ($env{'form.phase'} eq 'upload_embedded') {
# Process file upload - phase two - upload embedded objects
@@ -7533,7 +7536,8 @@
&Apache::loncommon::upload_embedded('coursedoc',$destination,
$docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
$actionurl);
- $r->print($result.&return_to_editor());
+ $r->print('<div class="LC_landmark" role="main" id="LC_main_content">'.
+ $result.&return_to_editor());
} elsif ($env{'form.phase'} eq 'check_embedded') {
# Process file upload - phase three - modify references in HTML file
$uploadphase = 'modified_orightml';
@@ -7544,14 +7548,17 @@
&Apache::loncommon::modify_html_refs('coursedoc',$destination,
$docuname,$docudom,undef,
$dir_root);
- $r->print($result.&return_to_editor());
+ $r->print('<div class="LC_landmark" role="main" id="LC_main_content">'.
+ $result.&return_to_editor());
} elsif ($env{'form.phase'} eq 'decompress_uploaded') {
$uploadphase = 'decompress_phase_one';
- $r->print(&decompression_phase_one().
+ $r->print('<div class="LC_landmark" role="main" id="LC_main_content">'.
+ &decompression_phase_one().
&return_to_editor());
} elsif ($env{'form.phase'} eq 'decompress_cleanup') {
$uploadphase = 'decompress_phase_two';
- $r->print(&decompression_phase_two().
+ $r->print('<div class="LC_landmark" role="main" id="LC_main_content">'.
+ &decompression_phase_two().
&return_to_editor());
}
}
@@ -8494,6 +8501,8 @@
&Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
&entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
+ } elsif ($uploadphase) {
+ $r->print('</div>');
}
}
unless ($noendpage) {
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1503 loncom/interface/loncommon.pm:1.1504
--- loncom/interface/loncommon.pm:1.1503 Sat Jan 24 02:20:56 2026
+++ loncom/interface/loncommon.pm Mon Jan 26 17:34:25 2026
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1503 2026/01/24 02:20:56 raeburn Exp $
+# $Id: loncommon.pm,v 1.1504 2026/01/26 17:34:25 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -13571,7 +13571,7 @@
next if ($embed_file =~ m{^\w+://});
}
$upload_output .= &start_data_table_row().
- '<td valign="top"><img src="'.&icon($embed_file).'" /> '.
+ '<td valign="top"><img src="'.&icon($embed_file).'" alt="" /> '.
'<span class="LC_filename">'.$embed_file.'</span>';
unless ($mapping{$embed_file} eq $embed_file) {
$upload_output .= '<br /><span class="LC_info" style="font-size:smaller;">'.
@@ -13603,7 +13603,7 @@
my ($size,$mtime) = &get_dependency_details(\%currfile,\%currsubfile,$embed_file);
$modify_output .= &start_data_table_row().
'<td><a href="'.$path.'/'.$embed_file.'" style="text-decoration:none;">'.
- '<img src="'.&icon($embed_file).'" border="0" />'.
+ '<img src="'.&icon($embed_file).'" border="0" alt="" />'.
' <span class="LC_filename">'.$embed_file.'</span></a></td>'.
'<td>'.$size.'</td>'.
'<td>'.$mtime.'</td>'.
@@ -13619,7 +13619,7 @@
$counter ++;
} else {
$upload_output .= &start_data_table_row().
- '<td valign="top"><img src="'.&icon($embed_file).'" /> '.
+ '<td valign="top"><img src="'.&icon($embed_file).'" alt="" /> '.
'<span class="LC_filename">'.$embed_file.'</span></td>'.
'<td align="right"><span class="LC_info LC_fontsize_medium">'.&mt('Already exists').'</span></td>'.
&Apache::loncommon::end_data_table_row()."\n";
@@ -13629,7 +13629,7 @@
foreach my $oldfile (sort {lc($a) cmp lc($b)} keys(%unused)) {
my ($size,$mtime) = &get_dependency_details(\%currfile,\%currsubfile,$oldfile);
$delete_output .= &start_data_table_row().
- '<td><img src="'.&icon($oldfile).'" />'.
+ '<td><img src="'.&icon($oldfile).'" alt="" />'.
' <span class="LC_filename">'.$oldfile.'</span></td>'.
'<td>'.$size.'</td>'.
'<td>'.$mtime.'</td>'.
@@ -13643,12 +13643,21 @@
$delidx ++;
}
if ($upload_output) {
- $upload_output = &start_data_table().
+ $upload_output = '<fieldset class="LC_borderless">'.
+ '<legend class="LC_visually_hidden">'.&mt('Upload files').'</legend>'."\n".
+ &start_data_table().
+ &start_data_table_header_row().
+ '<th>'.&mt('File').'</th>'.
+ '<th>'.&mt('Upload?').'</th>'.
+ &end_data_table_header_row().
$upload_output.
- &end_data_table()."\n";
+ &end_data_table()."\n".
+ '</fieldset><br />'."\n";
}
if ($modify_output) {
- $modify_output = &start_data_table().
+ $modify_output = '<fieldset class="LC_borderless">'.
+ '<legend class="LC_visually_hidden">'.&mt('Modify files').'</legend>'."\n".
+ &start_data_table().
&start_data_table_header_row().
'<th>'.&mt('File').'</th>'.
'<th>'.&mt('Size (KB)').'</th>'.
@@ -13656,10 +13665,13 @@
'<th>'.&mt('Upload replacement?').'</th>'.
&end_data_table_header_row().
$modify_output.
- &end_data_table()."\n";
+ &end_data_table()."\n".
+ '</fieldset><br />'."\n";
}
if ($delete_output) {
- $delete_output = &start_data_table().
+ $delete_output = '<fieldset class="LC_borderless">'.
+ '<legend class="LC_visually_hidden">'.&mt('Delete files').'</legend>'."\n".
+ &start_data_table().
&start_data_table_header_row().
'<th>'.&mt('File').'</th>'.
'<th>'.&mt('Size (KB)').'</th>'.
@@ -13667,7 +13679,8 @@
'<th>'.&mt('Delete?').'</th>'.
&end_data_table_header_row().
$delete_output.
- &end_data_table()."\n";
+ &end_data_table()."\n".
+ '</fieldset><br />'."\n";
}
my $applies = 0;
if ($numremref) {
@@ -13681,28 +13694,29 @@
}
if ($counter || $numunused) {
$output = '<form name="upload_embedded" action="'.$actionurl.'"'.
- ' method="post" enctype="multipart/form-data">'."\n".
- $state.'<h3>'.$heading.'</h3>';
+ ' method="post" enctype="multipart/form-data">'."\n".$state;
if ($actionurl eq '/adm/dependencies') {
+ $output .= '<h1 class="LC_heading_2">'.$heading.'</h1>';
if ($numnew) {
- $output .= '<h4>'.&mt('Missing dependencies').'</h4>'.
+ $output .= '<h2 class="LC_heading_3">'.&mt('Missing dependencies').'</h2>'.
'<p>'.&mt('The following files need to be uploaded.').'</p>'."\n".
$upload_output.'<br />'."\n";
}
if ($numexisting) {
- $output .= '<h4>'.&mt('Uploaded dependencies (in use)').'</h4>'.
+ $output .= '<h2 class="LC_heading_3">'.&mt('Uploaded dependencies (in use)').'</h2>'.
'<p>'.&mt('Upload a new file to replace the one currently in use.').'</p>'."\n".
$modify_output.'<br />'."\n";
$buttontext = &mt('Save changes');
}
if ($numunused) {
- $output .= '<h4>'.&mt('Unused files').'</h4>'.
+ $output .= '<h2 class="LC_heading_3">'.&mt('Unused files').'</h2>'.
'<p>'.&mt('The following uploaded files are no longer used.').'</p>'."\n".
$delete_output.'<br />'."\n";
$buttontext = &mt('Save changes');
}
} else {
- $output .= $upload_output.'<br />'."\n";
+ $output .= '<h2 class="LC_heading_2">'.$heading.'</h2>'."\n".
+ $upload_output.'<br />'."\n";
}
$output .= '<input type ="hidden" name="number_embedded_items" value="'.
$counter.'" />'."\n";
@@ -13829,7 +13843,9 @@
(ref($codebase) eq 'HASH'));
my $output;
if (($context eq 'upload_embedded') && ($type ne 'delete')) {
- $output = '<input name="embedded_item_'.$num.'" type="file" value="" />'."\n";
+ my $labeltext = &mt('Choose file for embedded item [_1]',
+ &HTML::Entities::encode($embed_file,'"&<>'));
+ $output = '<input name="embedded_item_'.$num.'" type="file" value="" aria-label="'.$labeltext.'" />'."\n";
}
$output .= '<input name="embedded_orig_'.$num.'" type="hidden" value="'.
&escape($embed_file).'" />';
@@ -13880,7 +13896,7 @@
sub ask_embedded_js {
return <<"END";
-<script type="text/javascript"">
+<script type="text/javascript">
// <![CDATA[
function toggleBrowse(counter) {
var chkboxid = document.getElementById('mod_upload_dep_'+counter);
More information about the LON-CAPA-cvs
mailing list