[LON-CAPA-cvs] cvs: loncom /publisher loncleanup.pm

bisitz bisitz at source.lon-capa.org
Wed Dec 5 13:19:45 EST 2012


bisitz		Wed Dec  5 18:19:45 2012 EDT

  Modified files:              
    /loncom/publisher	loncleanup.pm 
  Log:
  - Improved user guidance and layout:
      - Show warning and allow to go back if no selection was made
      - Added confirm_success
      - Consistent layout: use actionbox
  - Added missing labels to cleanup options
  - Added warning style to warning message
  - XHTML - URL for "Diffs": encoding
  
  
Index: loncom/publisher/loncleanup.pm
diff -u loncom/publisher/loncleanup.pm:1.17 loncom/publisher/loncleanup.pm:1.18
--- loncom/publisher/loncleanup.pm:1.17	Mon Oct 29 17:38:55 2012
+++ loncom/publisher/loncleanup.pm	Wed Dec  5 18:19:45 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to cleanup XML files
 #
-# $Id: loncleanup.pm,v 1.17 2012/10/29 17:38:55 raeburn Exp $
+# $Id: loncleanup.pm,v 1.18 2012/12/05 18:19:45 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -251,17 +251,22 @@
     $r->print(
         &Apache::lonhtmlcommon::start_pick_box()
        .&Apache::lonhtmlcommon::row_title(&mt('Select actions to attempt'))
+       .'<label>'
        .'<input type="checkbox" name="linefeed" checked="checked" /> '
        .&mt('Linefeeds, formfeeds, and carriage returns')
-       .'<br />'
+       .'</label><br />'
+       .'<label>'
        .'<input type="checkbox" name="empty" checked="checked" /> '
        .&mt('Empty tags')
-       .'<br />'
+       .'</label><br />'
+       .'<label>'
        .'<input type="checkbox" name="lower" checked="checked" /> '
        .&mt('Lower casing')
-       .'<br />'
+       .'</label><br />'
+       .'<label>'
        .'<input type="checkbox" name="symbol" checked="checked" /> '
        .&mt('Symbol font')
+       .'</label>'
        .&Apache::lonhtmlcommon::row_closure(1)
        .&Apache::lonhtmlcommon::end_pick_box()
     );
@@ -285,6 +290,20 @@
         }
         close(IN);
     }
+    # Check if any selection was made
+    if ($env{'form.linefeed'} ne 'on' &&
+        $env{'form.empty'} ne 'on' &&
+        $env{'form.lower'} ne 'on' &&
+        $env{'form.symbol'} ne 'on') {
+        $r->print(
+            '<p class="LC_warning">'
+           .&mt('Please select at least one option.')
+           .'</p>'
+           .'<p><a href="javascript:history.back();">'.&mt('Back').'</p>'
+        );
+        return;
+    }
+
     my $uri="/priv/$udom/$uname".$fn;
     my $result=&Apache::lonnet::ssi_body($uri,
 					 ('grade_target'=>'web',
@@ -339,8 +358,11 @@
        .'<li><a href="'.$newuri.'" target="prev">'
        .&mt('Open (and edit) cleaned up file in new window')
        .'</a></li>'
-       .'<li><a href="/adm/diff?filename='.&escape($uri)
-       .'&versionone=priv&filetwo='.&escape($newuri).'" target="prev">'
+       .'<li><a href="'
+       .&HTML::Entities::encode(
+            '/adm/diff?filename='.&escape($uri)
+           .'&versionone=priv&filetwo='.&escape($newuri))
+       .'" target="prev">'
        .&mt('Show diffs in new window')
        .'</a></li>'
        .'</ul>'
@@ -363,20 +385,24 @@
     my $newfn=$main.'_Auto_Cleaned_Up.'.$ext;
     my $new=$r->dir_config('lonDocRoot')."/priv/$udom/$uname".$newfn;
     if ($env{'form.accept'}) {
-	$r->print(
+        $r->print(
         '<p class="LC_info">'
-       .&mt('Accepting changes')
+       .&mt('Accepting changes...')
        .'</p>'
     );
         move($new,$old);
     } else {
-	$r->print(
+        $r->print(
         '<p class="LC_info">'
-       .&mt('Rejecting changes')
+       .&mt('Rejecting changes...')
        .'</p>'
-    );
+        );
         unlink($new);
     }
+    $r->print(
+        '<p>'
+       .&Apache::lonhtmlcommon::confirm_success(&mt('Done')));
+        '</p>'
 }
 
 # ---------------------------------------------------------------- Main Handler
@@ -436,7 +462,7 @@
               '<form action="/adm/cleanup" method="post">'.
               '<input type="hidden" name="filename" value="'.$env{'form.filename'}.'" />');
     unless ($fn=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm|sty)$/) {
-	$r->print(&mt('Cannot cleanup this filetype'));
+	$r->print('<p class="LC_warning">'.&mt('Cannot cleanup this filetype').'</p>');
     } else {
 	if ($env{'form.phase'} eq 'three') {
 	    &phasethree($r,$fn,$uname,$udom);
@@ -450,12 +476,11 @@
     $dir=~s{[^/]+$}{};
     $r->print(
         '</form>'
-       .&Apache::lonhtmlcommon::start_funclist()
-       .&Apache::lonhtmlcommon::add_item_funclist(
-            '<a href="/priv/'.$udom.'/'.$uname.$fn.'">'.&mt('Back to Source File').'</a>')
-       .&Apache::lonhtmlcommon::add_item_funclist(
-            '<a href="/priv/'.$udom.'/'.$uname.$dir.'">'.&mt('Back to Source Directory').'</a>')
-       .&Apache::lonhtmlcommon::end_funclist()
+       .&Apache::lonhtmlcommon::actionbox(
+            ['<a href="/priv/'.$udom.'/'.$uname.$fn.'">'.
+                 &mt('Back to Source File').'</a>',
+            '<a href="/priv/'.$udom.'/'.$uname.$dir.'">'.
+                &mt('Back to Source Directory').'</a>'])
        .&Apache::loncommon::end_page()
     );
 




More information about the LON-CAPA-cvs mailing list