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

bisitz bisitz at source.lon-capa.org
Fri Nov 30 06:36:14 EST 2012


bisitz		Fri Nov 30 11:36:14 2012 EDT

  Modified files:              
    /loncom/publisher	loncfile.pm 
  Log:
  - Consistent and improved page layout:
      - confirm_success
      - actionbox
      - removed impropriate headline usage
  - form.action: Improved code readability
  - Typos
  
  
  
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.116 loncom/publisher/loncfile.pm:1.117
--- loncom/publisher/loncfile.pm:1.116	Mon Oct 29 17:38:55 2012
+++ loncom/publisher/loncfile.pm	Fri Nov 30 11:36:14 2012
@@ -9,7 +9,7 @@
 #  and displays a page showing the results of the action.
 #
 #
-# $Id: loncfile.pm,v 1.116 2012/10/29 17:38:55 raeburn Exp $
+# $Id: loncfile.pm,v 1.117 2012/11/30 11:36:14 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -101,7 +101,7 @@
 =cut
 
 sub Debug {
-    # Put out the indicated message butonly if DEBUG is true.
+    # Put out the indicated message but only if DEBUG is true.
     if ($DEBUG) {
 	my ($r,$message) = @_;
 	$r->log_reason($message);
@@ -109,14 +109,15 @@
 }
 
 sub done {
-   my ($url)=@_;
-   my $done=&mt("Done");
-   return(<<ENDDONE);
-<a href="$url">$done</a>
-<script type="text/javascript">
-location.href="$url";
-</script>
-ENDDONE
+    my ($url) = @_;
+    return
+       '<p>'
+      .&Apache::lonhtmlcommon::confirm_success(&mt("Done"))
+      .'<br /><a href="'.$url.'">'.&mt("Continue").'</a>'
+      .'<script type="text/javascript">'
+      .'location.href="'.$url.'";'
+      .'</script>'
+      .'</p>';
 }
 
 =pod
@@ -436,9 +437,9 @@
 
 sub CloseForm1 {
     my ($request,  $fn) = @_;
-    $request->print('<p><input type="submit" value="'.&mt('Continue').'" /></p></form>');
-    $request->print('<form action="'.&url($fn).
-		    '" method="post"><p><input type="submit" value="'.&mt('Cancel').'" /></p></form>');
+    $request->print('<input type="submit" value="'.&mt('Continue').'" /></form>');
+    $request->print(' <form action="'.&url($fn).'" method="post">'.
+                    '<input type="submit" value="'.&mt('Cancel').'" /></form>');
 }
 
 
@@ -837,7 +838,7 @@
 =item 2 new forms are displayed.  Clicking on the confirmation button
 causes the browser to attempt to load the specfied URL, allowing the
 proper handler to take care of file creation. There is also a Cancel
-button which returns you to the driectory listing you came from
+button which returns you to the directory listing you came from
 
 =back
 
@@ -961,8 +962,8 @@
             $dirlist=$fn; 
         }
         $r->print('<div class="LC_error">'.$error.'</div>'.
-                  '<h3><a href="'.&url($dirlist).'">'.&mt('Return to Directory').
-                  '</a></h3>');
+                  '<p><a href="'.&url($dirlist).'">'.&mt('Return to Directory').
+                  '</a></p>');
         return;
     }
     $r->print('<form action="/adm/cfile" method="post">'.
@@ -1098,7 +1099,7 @@
 	}
     } else {
         $request->print(
-            '<p>'
+            '<p class="LC_error">'
            .&mt('No such file: [_1]',
                 &display($oldfile))
            .'</p></form>'
@@ -1386,11 +1387,19 @@
 	$dest = $newdir."/";
     }
     if ( ($env{'form.action'} eq 'newdir') && ($env{'form.phase'} eq 'two') && ( ($env{'form.callingmode'} eq 'testbank') || ($env{'form.callingmode'} eq 'imsimport') ) ) {
-	$r->print('<h3><a href="javascript:self.close()">'.&mt('Done').'</a></h3>');
+        $r->print(
+            '<p>'
+           .&Apache::lonhtmlcommon::confirm_success(&mt('Done'))
+           .'<br /><a href="javascript:self.close()">'.&mt('Continue').'</a>'
+           .'</p>'
+        );
     } else {
         if ($env{'form.action'} eq 'rename') {
-            $r->print('<h3><a href="'.&url($dest).'">'.&mt('Return to Directory').'</a></h3>');
-            $r->print('<h3><a href="'.&url($dest_newname).'">'.$disp_newname.'</a></h3>');
+            $r->print(
+                 '<p>'.&Apache::lonhtmlcommon::confirm_success(&mt('Done')).'</p>'
+                .&Apache::lonhtmlcommon::actionbox(
+                     ['<a href="'.&url($dest).'">'.&mt('Return to Directory').'</a>',
+                      '<a href="'.&url($dest_newname).'">'.$disp_newname.'</a>']));
         } else {
 	    $r->print(&done(&url($dest)));
 	}
@@ -1496,7 +1505,7 @@
                   &Apache::loncommon::CSTR_pageheader($trailfile))
     );
   
-    $r->print('<h3>'.&mt('Location').': '.&display($fn).'</h3>');
+    $r->print('<p>'.&mt('Location').': '.&display($fn).'</p>');
   
     if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
         $r->print('<p class="LC_info">'
@@ -1507,37 +1516,35 @@
 
 
     &Debug($r, "loncfile::handler Form action is $env{'form.action'} ");
-    if ($env{'form.action'} eq 'delete') {
-      	$r->print('<h3>'.&mt('Delete').'</h3>');
-    } elsif ($env{'form.action'} eq 'rename') {
-	$r->print('<h3>'.&mt('Rename').'</h3>');
-    } elsif ($env{'form.action'} eq 'move') {
-	$r->print('<h3>'.&mt('Move').'</h3>');
-    } elsif ($env{'form.action'} eq 'newdir') {
-	$r->print('<h3>'.&mt('New Directory').'</h3>');
-    } elsif ($env{'form.action'} eq 'decompress') {
-	$r->print('<h3>'.&mt('Decompress').'</h3>');
-    } elsif ($env{'form.action'} eq 'copy') {
-	$r->print('<h3>'.&mt('Copy').'</h3>');
-    } elsif ($env{'form.action'} eq 'newfile' ||
-	     $env{'form.action'} eq 'newhtmlfile' ||
-	     $env{'form.action'} eq 'newproblemfile' ||
-	     $env{'form.action'} eq 'newpagefile' ||
-	     $env{'form.action'} eq 'newsequencefile' ||
-	     $env{'form.action'} eq 'newrightsfile' ||
-	     $env{'form.action'} eq 'newstyfile' ||
-	     $env{'form.action'} eq 'newtaskfile' ||
-             $env{'form.action'} eq 'newlibraryfile' ||
-	     $env{'form.action'} eq 'Select Action' ) {
-	$r->print('<h3>'.&mt('New Resource').'</h3>');
+    my %action = &Apache::lonlocal::texthash(
+        'delete'          => 'Delete',
+        'rename'          => 'Rename',
+        'move'            => 'Move',
+        'newdir'          => 'New Directory',
+        'decompress'      => 'Decompress',
+        'copy'            => 'Copy',
+        'newfile'         => 'New Resource',
+	'newhtmlfile'     => 'New Resource',
+	'newproblemfile'  => 'New Resource',
+	'newpagefile'     => 'New Resource',
+	'newsequencefile' => 'New Resource',
+	'newrightsfile'   => 'New Resource',
+	'newstyfile'      => 'New Resource',
+	'newtaskfile'     => 'New Resource',
+        'newlibraryfile'  => 'New Resource',
+	'Select Action'   => 'New Resource',
+    );
+    if ($action{$env{'form.action'}}) {
+        $r->print('<h2>'.$action{$env{'form.action'}}.'</h2>');
     } else {
         $r->print('<p class="LC_error">'
-                 .&mt('Unknown Action').' '.$env{'form.action'}
+                 .&mt('Unknown Action: [_1]',$env{'form.action'})
                  .'</p>'
                  .&Apache::loncommon::end_page()
         );
-	return OK;  
+        return OK;
     }
+
     if ($env{'form.phase'} eq 'two') {
 	&Debug($r, "loncfile::handler  entering phase2");
 	&phasetwo($r,$fn,$uname,$udom);




More information about the LON-CAPA-cvs mailing list