[LON-CAPA-cvs] cvs: loncom /interface londocs.pm

bisitz bisitz@source.lon-capa.org
Fri, 05 Jun 2009 10:51:14 -0000


This is a MIME encoded message

--bisitz1244199074
Content-Type: text/plain

bisitz		Fri Jun  5 10:51:14 2009 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  IMS Export:
  - Simplified and LON-CAPA standard HTML structure for "(un)check all" area
  - Replaced hardcoded table by standard data_table
      - Removed now unneeded special styles
      - Manual backgroundcolor switch not needed anymore
      - Corrected missing table row closure
      - Moved table closure right next to table creation
      - Removed unused dummy column in the middle
  - Localization: Added missing &mt() calls
  - Optimized &mt() call for choose text and download link
  - Added error style to error message
  - Wrapped download and error message in paragraph
  
  XHTML:
      - Properly exclude javascript code from being interpreted as HTML code
      - Added type to script
      - Added dummy action to forms without action
      - lower case attributes (onclick)
      - Added alt attribute to all images
  
  
--bisitz1244199074
Content-Type: text/plain
Content-Disposition: attachment; filename="bisitz-20090605105114.txt"

Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.368 loncom/interface/londocs.pm:1.369
--- loncom/interface/londocs.pm:1.368	Sat May 23 20:43:24 2009
+++ loncom/interface/londocs.pm	Fri Jun  5 10:51:13 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.368 2009/05/23 20:43:24 truskell Exp $
+# $Id: londocs.pm,v 1.369 2009/06/05 10:51:13 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -142,7 +142,7 @@
     my ($r) = @_;
     my $type = &Apache::loncommon::course_type();
     $r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space').
-	      '<form name="dumpdoc" method="post">');
+	      '<form name="dumpdoc" action="" method="post">');
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$type.' DOCS to Construction Space'));
     my ($home,$other,%outhash)=&authorhosts();
     unless ($home) { return ''; }
@@ -321,9 +321,15 @@
                 open(OUTPUT, "zip -r $imszip *  2> /dev/null |");
                 close(OUTPUT);
                 chdir $cwd;
-                $outcome .= &mt('Download the zip file from <a href="[_1]">IMS '.lc($type).' archive</a><br />',$imszipfile,);
+                $outcome .= '<p>'
+                           .&mt('Download the zip file from [_1]IMS '.lc($type).' archive[_2]'
+                               ,'<a href="'.$imszipfile.'">','</a>')
+                           .'</p>';
                 if ($copyresult) {
-                    $outcome .= &mt('The following errors occurred during export - [_1]',$copyresult);
+                    $outcome .= '<p class="LC_error">'
+                               .&mt('The following errors occurred during export - [_1]'
+                                   ,$copyresult)
+                               .'</p>';
                 }
             } else {
                 $outcome = '<br />'.&mt('Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.').'<br />';
@@ -335,21 +341,23 @@
         $r->print(&Apache::loncommon::end_page());
     } else {
         my $display;
-        $display = '<form name="exportdoc" method="post">'."\n";
-        $display .= &mt('Choose which items you wish to export from your '.$type.'.<br /><br />');
-        $display .= '<table border="0" cellspacing="0" cellpadding="3">'.
-                    '<tr><td><fieldset><legend>&nbsp;<b>Content items</b></legend>'.
-                    '<input type="button" value="check all" '.
+        $display = '<form name="exportdoc" action="" method="post">'."\n";
+        $display .= '<p>'
+                   .&mt('Choose which items you wish to export from your '.$type.'.')
+                   .'</p>';
+        $display .= '<div class="LC_columnSection"><fieldset>'.
+                    '<legend>'.&mt('Content items').'</legend>'.
+                    '<input type="button" value="'.&mt('check all').'" '.
                     'onclick="javascript:checkAll(document.exportdoc.archive)" />'.
-                    '&nbsp;&nbsp;<input type="button" value="uncheck all"'.
-                    ' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset></td>'.
-                    '<td>&nbsp;</td><td>&nbsp;</td>'.
-                    '<td align="right"><fieldset><legend>&nbsp;<b>Discussion posts'.
-                    '</b></legend><input type="button" value="check all"'.
+                    '&nbsp;&nbsp;<input type="button" value="'.&mt('uncheck all').'"'.
+                    ' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset>'.
+                    '<fieldset>'.
+                    '<legend>'.&mt('Discussion posts').'</legend>'.
+                    '<input type="button" value="'.&mt('check all').'"'.
                     ' onclick="javascript:checkAll(document.exportdoc.discussion)" />'.
-                    '&nbsp;&nbsp;<input type="button" value="uncheck all"'.
-                    ' onclick="javascript:uncheckAll(document.exportdoc.discussion)" /></fieldset></td>'.
-                    '</tr></table>';
+                    '&nbsp;&nbsp;<input type="button" value="'.&mt('uncheck all').'"'.
+                    ' onclick="javascript:uncheckAll(document.exportdoc.discussion)" />'.
+                    '</fieldset></div>';
         my $curRes;
         my $depth = 0;
         my $count = 0;
@@ -358,13 +366,17 @@
         my %parent = ();
         my %children = ();
         my $lastcontainer = $startcount;
-        my @bgcolors = ('#F6F6F6','#FFFFFF');
-        $display .= '<table cellspacing="0"><tr>'.
-            '<td><b>Export content item?<br /></b></td><td>&nbsp;</td><td align="right">'."\n";
+        $display .= &Apache::loncommon::start_data_table()
+                   .&Apache::loncommon::start_data_table_header_row()
+                   .'<th>'.&mt('Export content item?').'</th>'
+                   .'<th>';
         if ($numdisc > 0) {
-            $display.='<b>Export&nbsp;discussion posts?</b>'."\n";
+            $display .= &mt('Export discussion posts?');
+        } else {
+             $display .= '&nbsp;';
         }
-        $display.='&nbsp;</td></tr>';
+        $display .= '</th>'
+                   .&Apache::loncommon::end_data_table_header_row();
         while ($curRes = $it->next()) {
             if (ref($curRes)) {
                 $count ++;
@@ -385,16 +397,17 @@
                         $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
                     }
                 }
-                my $color = $count%2;
-                $display .='<tr bgcolor='.$bgcolors[$color].'><td>'."\n".
-                    '<input type="checkbox" name="archive" value="'.$count.'" ';
+                $display .= &Apache::loncommon::start_data_table_row()
+                           .'<td>'."\n"
+                           .'<input type="checkbox" name="archive" value="'.$count.'" ';
                 if (($curRes->is_sequence()) || ($curRes->is_page())) {
                     my $checkitem = $count + $boards + $startcount;
-                    $display .= 'onClick="javascript:propagateCheck('."'$checkitem'".')"';
+                    $display .= 'onclick="javascript:propagateCheck('."'$checkitem'".')"';
                 }
                 $display .= ' />'."\n";
                 for (my $i=0; $i<$depth; $i++) {
-                    $display .= '<img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" /><img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" />'."\n";
+                    $display .= '<img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" alt="" />'
+                               .'<img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" alt="" />'."\n";
                 }
                 if ($curRes->is_sequence()) {
                     $display .= '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" />&nbsp;'."\n";
@@ -405,19 +418,25 @@
                 }
                 my $currelem = $count+$boards+$startcount;
                 $children{$parent{$depth}} .= $currelem.':';
-                $display .= '&nbsp;'.$curRes->title().'</td>';
+                $display .= '&nbsp;'.$curRes->title().'</td>'."\n";
+
+                # Existing discussion posts?
                 if ($discussiontime{$ressymb} > 0) {
                     $boards ++;
                     $currelem = $count+$boards+$startcount;
-                    $display .= '<td>&nbsp;</td><td align="right"><input type="checkbox" name="discussion" value="'.$count.'" />&nbsp;</td>'."\n";
+                    $display .= '<td align="right">'
+                               .'<input type="checkbox" name="discussion" value="'.$count.'" />'
+                               .'</td>'."\n";
                 } else {
-                    $display .= '<td colspan="2">&nbsp;</td>'."\n";
+                    $display .= '<td>&nbsp;</td>'."\n";
                 }
+                $display .= &Apache::loncommon::end_data_table_row();
             }
         }
+        $display .= &Apache::loncommon::end_data_table();
         my $scripttag = qq|
-<script>
-
+<script type="text/javascript">
+// <![CDATA[
 function checkAll(field) {
     if (field.length > 0) {
         for (i = 0; i < field.length; i++) {
@@ -467,13 +486,13 @@
         }
      }
 }
-
+// ]]>
 </script>
         |;
 	$r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package',
 						 $scripttag));
 	$r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
-	$r->print($display.'</table>'.
+	$r->print($display.
                   '<p><input type="hidden" name="finishexport" value="1" />'.
                   '<input type="submit" name="exportcourse" value="'.
                   &mt('Export '.$type.' DOCS').'" /></p></form>');
@@ -1961,7 +1980,7 @@
     	my $ro_set=
 	    ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
 	$rand_order_text ='
-<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onClick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></span>';
+<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onclick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></span>';
     }
     if ($ispage) {
         my $pagename=&escape($pagetitle);
@@ -2005,12 +2024,12 @@
 	$line.=(<<ENDPARMS);
   <td class="LC_docs_entry_parameter">
     $form_start
-    <label><input type="checkbox" name="hiddenresource_$orderidx" onClick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
+    <label><input type="checkbox" name="hiddenresource_$orderidx" onclick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
     $form_end
   </td>
   <td class="LC_docs_entry_parameter">
     $form_start
-    <label><input type="checkbox" name="encrypturl_$orderidx" onClick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
+    <label><input type="checkbox" name="encrypturl_$orderidx" onclick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
     $form_end
   </td>
   <td class="LC_docs_entry_parameter">$form_start $rand_order_text $form_end</td>
@@ -2093,7 +2112,7 @@
                  if (($errorcount) ||
                      ($warningcount)) {
 		     if ($errorcount) {
-                        $r->print('<img src="/adm/lonMisc/bomb.gif" alt="" /><span class="LC_error">'.
+                        $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
                           &mt('[quant,_1,error]',$errorcount).'</span>');
                      }
 		     if ($warningcount) {
@@ -2483,13 +2502,17 @@
 	$message='Changes will become active for your current session after [_1], or the next time you log in.';
     }
     $r->print("\n\n".
-'<script type="text/javascript">function reinit(tf) { tf.submit();'.$postexec.' }</script>'."\n".
+'<script type="text/javascript">'.
+'// <![CDATA['.
+'function reinit(tf) { tf.submit();'.$postexec.' }'.
+'// ]]>'.
+'</script>'."\n".
 '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
 '<input type="hidden" name="orgurl" value="'.$url.
 '" /><input type="hidden" name="selectrole" value="1" /><h3><span class="LC_warning">'.
 &mt($message,' <input type="hidden" name="'.
     $env{'request.role'}.'" value="1" /><input type="button" value="'.
-    &mt('re-initializing '.$course_type).'" onClick="reinit(this.form)" />').
+    &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
 $help{'Caching'}.'</span></h3></form>'."\n\n");
 }
 
@@ -2646,7 +2669,11 @@
 	$script .= &editing_js($udom,$uname);
     }
 # -------------------------------------------------------------------- Body tag
-    $script = '<script type="text/javascript">'."\n".$script."\n".'</script>';
+    $script = '<script type="text/javascript">'."\n"
+              .'// <![CDATA['
+              .$script
+              .'// ]]>'
+              ."\n".'</script>';
     my $brcrum = [{href=>"/adm/createuser",text=>"$type Documents"}];
     $r->print(&Apache::loncommon::start_page("$type Documents", $script,
 				    {'force_register' => $showdoc,
@@ -2820,20 +2847,20 @@
 	<form action="/adm/coursedocs" method="post" name="simpleeditdefault">
 	$lt{'pubd'}<br />
 	$uploadtag
-	<input type="button" onClick="javascript:groupsearch()" value="$lt{'srch'}" />
+	<input type="button" onclick="javascript:groupsearch()" value="$lt{'srch'}" />
 	<br />
 	<span class="LC_nobreak">
-	<input type="button" onClick="javascript:groupimport();" value="$lt{'impo'}" />
+	<input type="button" onclick="javascript:groupimport();" value="$lt{'impo'}" />
 	$help{'Importing_LON-CAPA_Resource'}
 	</span>
 	<br />
-	<input type="button" onClick="javascript:groupopen(0,1,1);" value="$lt{'book'}" />
+	<input type="button" onclick="javascript:groupopen(0,1,1);" value="$lt{'book'}" />
 	<hr />
 	<p>
 	$lt{'copm'}<br />
 	<input type="text" size="40" name="importmap" /><br />
 	<span class="LC_nobreak"><input type="button"
-	onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
+	onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
 	value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
 	$help{'Load_Map'}</span>
 	</p>
@@ -2845,7 +2872,7 @@
 	$uploadtag
 	<input type="hidden" name="importdetail" value="" />
 	<span class="LC_nobreak">
-	<input name="newext" type="button" onClick="javascript:makenewext('newext');"
+	<input name="newext" type="button" onclick="javascript:makenewext('newext');"
 	value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
 	</span>
 	</form>
@@ -2924,7 +2951,12 @@
        }
        my $postexec='';
        if ($folder eq 'default') {
-	   $r->print('<script type="text/javascript">this.window.name="loncapaclient";</script>');
+           $r->print('<script type="text/javascript">'
+                    .'// <![CDATA['
+                    .'this.window.name="loncapaclient";'
+                    .'// ]]>'
+                    .'</script>'
+       );
        } else {
            #$postexec='self.close();';
        }
@@ -2942,14 +2974,14 @@
 
 	my $recoverform=(<<RFORM);
 	<form action="/adm/groupsort" method="post" name="recover">
-	<input type="button" name="recovermap" onClick="javascript:groupopen('$readfile',1,0)" value="$lt{'reco'}" />
+	<input type="button" name="recovermap" onclick="javascript:groupopen('$readfile',1,0)" value="$lt{'reco'}" />
 	</form>
 RFORM
 
 	my $imspform=(<<IMSPFORM);
 	<form action="/adm/imsimportdocs" method="post" name="ims">
 	<input type="hidden" name="folder" value="$folder" />
-	<input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
+	<input name="imsimport" type="button" value="$lt{'imsf'}" onclick="javascript:makeims();" />
 	</form>
 IMSPFORM
 
@@ -2970,7 +3002,7 @@
 	<input type="hidden" name="importdetail" value="" />
 	<span class="LC_nobreak">
 	<input name="newsmppg" type="button" value="$lt{'sipa'}"
-	onClick="javascript:makesmppage();" /> $help{'Simple Page'}
+	onclick="javascript:makesmppage();" /> $help{'Simple Page'}
 	</span>
 	</form>
 NSPFORM
@@ -2981,7 +3013,7 @@
 	<input type="hidden" name="importdetail" value="" />
 	<span class="LC_nobreak">
 	<input name="newsmpproblem" type="button" value="$lt{'sipr'}"
-	onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
+	onclick="javascript:makesmpproblem();" />$help{'Simple Problem'}
 	</span>
 	</form>
 
@@ -2993,7 +3025,7 @@
 	<input type="hidden" name="importdetail" value="" />
 	<span class="LC_nobreak">
 	<input name="newdropbox" type="button" value="$lt{'drbx'}"
-	onClick="javascript:makedropbox();" />
+	onclick="javascript:makedropbox();" />
 	</span>
 	</form>
 NDBFORM
@@ -3004,7 +3036,7 @@
 	<input type="hidden" name="importdetail" value="" />
 	<span class="LC_nobreak">
 	<input name="newexamupload" type="button" value="$lt{'scuf'}"
-	onClick="javascript:makeexamupload();" />
+	onclick="javascript:makeexamupload();" />
 	$help{'Score_Upload_Form'}
 	</span>
 	</form>
@@ -3016,7 +3048,7 @@
 	<input type="hidden" name="importdetail" value="" />
 	<span class="LC_nobreak">
 	<input name="newbulletin" type="button" value="$lt{'bull'}"
-	onClick="javascript:makebulboard();" />
+	onclick="javascript:makebulboard();" />
 	$help{'Bulletin Board'}
 	</span>
 	</form>
@@ -3040,7 +3072,7 @@
 	<input type="hidden" name="importdetail" value="" />
 	<span class="LC_nobreak">
 	<input name="newaboutsomeone" type="button" value="$lt{'abou'}" 
-	onClick="javascript:makeabout();" />
+	onclick="javascript:makeabout();" />
 	</span>
 	</form>
 NASOFORM
@@ -3070,7 +3102,7 @@
 	<input type="hidden" name="importdetail" value="" />
 	<span class="LC_nobreak">
 	<input name="newpage" type="button"
-	onClick="javascript:makenewpage(this.form,'$pageseq');"
+	onclick="javascript:makenewpage(this.form,'$pageseq');"
 	value="$lt{'newp'}" />$help{'Adding_Pages'}
 	</span>
 	</form>
@@ -3082,7 +3114,7 @@
 	<input type="hidden" name="importdetail" value="" />
 	<span class="LC_nobreak">
 	<input name="newfolder" type="button"
-	onClick="javascript:makenewfolder(this.form,'$folderseq');"
+	onclick="javascript:makenewfolder(this.form,'$folderseq');"
 	value="$lt{'newf'}" />$help{'Adding_Folders'}
 	</span>
 	</form>
@@ -3199,7 +3231,7 @@
 	<input type="hidden" name="importdetail" value="" />
 	<span class="LC_nobreak">
 	<input name="newfolder" type="button"
-	onClick="javascript:makenewfolder(this.form,'$folderseq');"
+	onclick="javascript:makenewfolder(this.form,'$folderseq');"
 	value="$lt{'newf'}" /> $help{'Adding_Folders'}
 	</span>
 	</form>
@@ -3212,7 +3244,7 @@
 	<input type="hidden" name="importdetail" value="" />
 	<span class="LC_nobreak">
 	<input name="newext" type="button" 
-	onClick="javascript:makenewext('supnewext');"
+	onclick="javascript:makenewext('supnewext');"
 	value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
 	</span>
 	</form>

--bisitz1244199074--