[LON-CAPA-cvs] cvs: loncom /imspackages imsimportdocs.pm

bisitz bisitz@source.lon-capa.org
Fri, 20 Nov 2009 14:39:32 -0000


This is a MIME encoded message

--bisitz1258727972
Content-Type: text/plain

bisitz		Fri Nov 20 14:39:32 2009 EDT

  Modified files:              
    /loncom/imspackages	imsimportdocs.pm 
  Log:
  Layout, localization and code style for import phase 2 (display_two, step 3 and 4):
  - Replaced hardcoded styles by standard styles (topic_bar, data_table)
  - Removed unnecessary HTML tables
  - Got rid of deprecated tags and outdated/unecessary styles
  - Code style: Directly go on with next item in area loop when no content exists for current area
  - XHTML: attributes in lower case
  - Close <form>, close all data_table rows
  - Split message text about what to do at the bottom in two texts and display the approriate part in each step where needed
  - Localization: Added missing &mt() calls, use quant for item counter
  - Consistent wording: "Finish Import"
  - Added some code comments
  
  
--bisitz1258727972
Content-Type: text/plain
Content-Disposition: attachment; filename="bisitz-20091120143932.txt"

Index: loncom/imspackages/imsimportdocs.pm
diff -u loncom/imspackages/imsimportdocs.pm:1.25 loncom/imspackages/imsimportdocs.pm:1.26
--- loncom/imspackages/imsimportdocs.pm:1.25	Fri Nov 20 11:16:59 2009
+++ loncom/imspackages/imsimportdocs.pm	Fri Nov 20 14:39:32 2009
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: imsimportdocs.pm,v 1.25 2009/11/20 11:16:59 bisitz Exp $
+# $Id: imsimportdocs.pm,v 1.26 2009/11/20 14:39:32 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -269,10 +269,7 @@
     my %hrefs = ();
     my %resinfo = ();
     my %count = ();
-    my @bgcolors = ("#eeeeee","#dddddd");
-
     my $counter = 0;
-    my $iter = 0;
     my %count = (
                 announce => 0,
                 board => 0,
@@ -337,143 +334,119 @@
         }
     }
 
-            $r->print(<<ENDBLOCK);
-<form name="pickoptions" method="post">
-  <table border='0' bgcolor='#F6F6F6'' cellspacing='0' cellpadding ='0' width='100%'>
-   <tr>
-    <td colspan='2'>
-     <table border='0' cellspacing='0' cellpadding='0'>
-      <tr>
-       <td colspan='2'  align='left'>&nbsp;
-       </td>
-      </tr>
-      <tr bgcolor='#CCCCFF'>
-       <td valign="middle"><img src="/res/adm/pages/bl_step3.gif" alt="3" />
-       </td>
-       <td width='100%' align='left'>&nbsp;&nbsp;
-        <font face='arial,helvetica,sans-serif'><b>Choose which content types you wish to import</b></font>
-       </td>
-      </tr>
-      <tr>
-       <td colspan='2'>&nbsp;</td>
-      </tr>
-      <tr>
-       <td>&nbsp;</td>
-       <td>
-        <table border='0' cellspacing='0' cellpadding='1' bgcolor='#000000'>
-         <tr>
-          <td>
-           <table border='0' cellspacing='0' cellpadding='0' bgcolor='#ffffff' width='100%'>
-            <tr>
-             <td>
-              <table border='0' cellspacing='1' cellpadding='1' bgcolor='#ffffff' width='100%'>
-               <tr bgcolor='#CCCCFF'>
-                <td align='center'><font face='arial,helvetica,sans-serif'><b>Import?</b></font></td>           
-                <td align='center'><font face='arial,helvetica,sans-serif'><b>Content type</b></font></td>
-                <td align='center'><font face='arial,helvetica,sans-serif'><b>Additional options</b></font></td>
-               </tr>
-ENDBLOCK
-            foreach my $area (@{$areasref}) {
-                if ($count{$area} > 0) {
-                    my $count_tag = 'flag_'.$counter;
-                    $r->print("               <tr bgcolor='@bgcolors[$iter]'>
-                <td align='left'><font face='arial,helvetica,sans-serif'><input name='$area' type='checkbox' ");
-                    if ($area eq 'board' || $area eq 'users') {
-                        $r->print(qq|onClick='javascript:setOptions("$area","$counter")'|);
-                    }
-                    $r->print("/></font></td>
-                <td align='left'><font face='arial,helvetica,sans-serif'>&nbsp;&nbsp;$$areaname{$area}&nbsp;&nbsp; - $count{$area} item(s)</font></td>");
-                    if ($area eq 'board') {
-                        $r->print("            <td align='left'><font face='arial,helvetica,sans-serif'>&nbsp;&nbsp;
-                 <select name='db_handling'>
-                  <option value='-2'>&lt;-- Check Import first</option>
-                 </select></font>
-                </td>");
-                    } elsif ($area eq 'users') {
-                        $r->print("            <td align='left'><font face='arial,helvetica,sans-serif'>&nbsp;&nbsp;
-                 <select name='user_handling'>
-                  <option value='-2'>&lt;-- Check Import first</option>
-                 </select>
-                 </font>        
-                </td>");
-                    } else {
-                        $r->print("            <td align='left'><font face='arial,helvetica,sans-serif'>&nbsp;&nbsp;None<input type='hidden' name='$count_tag' /></font></td>");
-                    }
-                    $counter ++;
-                    $iter = $counter%2;
-                }
-            }
-            $r->print(<<ENDDOCUMENT);
-               </tr>
-              </table>
-             </td>
-            </tr>
-           </table>
-          </td>
-         </tr>
-        </table>
-       </td>
-      </tr>
-      <tr>
-       <td colspan='2'>&nbsp;<br /><br /></td>
-      </tr>
-      <tr bgcolor='#CCCCFF'>
-       <td valign="middle"><img src="/res/adm/pages/bl_step4.gif" alt="4" />
-       </td>
-       <td width='100%' align='left'>&nbsp;&nbsp;
-        <font face='arial,helvetica,sans-serif'><b>Choose display options for listing of contents of top level of package</b></font>
-       </td>
-      </tr>
-      <tr>
-       <td colspan='2'>&nbsp;</td>
-      </tr>
-      <tr>
-       <td>&nbsp;</td>
-       <td>
-        <table border='0'>
-         <tr>
-          <td><font face='arial,helvetica,sans-serif'><label><input type="radio" name="toplevel" value="newfolder" />Display listing of contents in a new folder, with folder name:</label>&nbsp;&nbsp;&nbsp;<input type="text" name="foldername" size="15" value="Type Name Here" /></font></td>
-         </tr>
-         <tr>
-          <td><font face='arial,helvetica,sans-serif'><label><input type="radio" name="toplevel" value="oldfolder" />Append listing of contents of top level of package to contents list for the current folder.</label></font></td>
-         </tr>
-        </table>
-       </td>
-      </tr>
-      <tr>
-       <td colspan='2'>&nbsp;</td>
-      </tr>
-      <tr>
-       <td>&nbsp;</td>
-       <td><font face='arial,helvetica,sans-serif'>Once you have checked the checkboxes for all areas you wish to import from the IMS package, selected options (if available), and selected a display option for the package contents you should click the 'Complete Import' button.</font></td>
-      </tr>
-      <tr>
-       <td colspan='2'>&nbsp;
-          <input type="hidden" name="folder" value="$env{'form.folder'}" />
-          <input type="hidden" name="source" value="$cms" />
-          <input type="hidden" name="tempdir" value="$tempdir" />
-          <input type="hidden" name="phase" value="three" />
-       </td>
-      </tr>
-      <tr>
-       <td colspan='2'>
-        <table border='0' cellspacing='0' cellpadding='0' width="100%">
-         <tr>
-          <td align='left'>
-           <input type='button' name='exitpage' value='Cancel' onClick="javascript:self.close()" />
-          </td>
-          <td align='right'>
-           <input type="button" name="nextpage" value="Complete Import" onClick="javascript:nextPage($counter)" />
-          </td>
-         </tr>
-        </table>
-       </td>
-      </tr>
-     </table>
-    </td>
-   </tr>
-  </table>
-ENDDOCUMENT
+
+    # Start output: Step 3 and step 4
+
+    $r->print(
+        '<form name="pickoptions" method="post">'
+       .&Apache::lonhtmlcommon::topic_bar(
+            3,&mt('Choose which content types you wish to import'))
+       .'<p>'
+       .&mt('Check the checkboxes for all areas you wish to import from the IMS package:')
+       .'</p>'
+    );
+
+    $r->print(
+        &Apache::loncommon::start_data_table()
+       .&Apache::loncommon::start_data_table_header_row()
+       .'<th>'.&mt('Import?').'</th>'
+       .'<th>'.&mt('Content type').'</th>'
+       .'<th>'.&mt('Additional options').'</th>'
+       .&Apache::loncommon::end_data_table_header_row()
+    );
+
+    # Display import row for each area/content type
+    foreach my $area (@{$areasref}) {
+        unless ($count{$area} > 0) { next };
+
+        my $count_tag = 'flag_'.$counter;
+
+        # Checkbox: Import?
+        $r->print(
+            &Apache::loncommon::start_data_table_row()
+           .'<td><input name="'.$area.'" type="checkbox"'
+        );
+        if ($area eq 'board' || $area eq 'users') {
+            $r->print(qq| onclick='javascript:setOptions("$area","$counter")'|);
+        }
+
+        $r->print(' /></td>');
+
+        # Content Type
+        $r->print(
+            '<td>'
+           .$$areaname{$area}.'&nbsp;&nbsp; - '
+           .&mt('[quant,_1,item]',$count{$area})
+           .'</td>'
+        );
+
+        # Additional Options
+        $r->print('<td>');
+        if ($area eq 'board') {
+            $r->print(
+                '<select name="db_handling">'
+               .'<option value="-2">&lt;-- '.&mt('Check Import first').'</option>'
+               .'</select>'
+            );
+        } elsif ($area eq 'users') {
+            $r->print(
+                '<select name="user_handling">'
+               .'<option value="-2">&lt;-- '.&mt('Check Import first').'</option>'
+               .'</select>'
+            );
+        } else {
+            $r->print(
+                &mt('None')
+               .'<input type="hidden" name="'.$count_tag.'" />'
+            );
+        }
+        $r->print('</td>');
+
+        $r->print(&Apache::loncommon::end_data_table_row());
+        $counter ++;
+    }
+
+    $r->print(&Apache::loncommon::end_data_table());
+
+    $r->print(
+        &Apache::lonhtmlcommon::topic_bar(
+            4,&mt('Choose display options for listing of contents of top level of package'))
+       .'<p>'
+       .&mt('Select a display option for the package content:')
+       .'</p>'
+    );
+    $r->print(
+        '<label>'
+       .'<input type="radio" name="toplevel" value="newfolder" />'
+       .&mt('Display listing of contents in a new folder, with folder name:')
+       .'</label>'
+       .' <input type="text" name="foldername" size="15" value="'.&mt('Type Name Here').'" />'
+       .'<br />'
+       .'<label>'
+       .'<input type="radio" name="toplevel" value="oldfolder" />'
+       .&mt('Append listing of contents of top level of package to contents list for the current folder.')
+       .'</label>'
+    );
+
+    # Buttons
+    $r->print(
+        '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'
+       .'<input type="hidden" name="source" value="'.$cms.'" />'
+       .'<input type="hidden" name="tempdir" value="'.$tempdir.'" />'
+       .'<input type="hidden" name="phase" value="three" />'
+    );
+    $r->print(
+        '<hr />'
+       .'<p>'
+       .'<input type="button" name="exitpage" value="'.&mt('Cancel').'"'
+       .' onclick="javascript:self.close()" />'
+       .' '
+       .'<input type="button" name="nextpage" value="'.&mt('Finish Import').'"'
+       .' onclick="javascript:nextPage('.$counter.')" />'
+       .'</p>'
+    );
+
+   $r->print('</form>');
 }
 
 

--bisitz1258727972--