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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 09 Sep 2005 19:12:31 -0000


albertel		Fri Sep  9 15:12:31 2005 EDT

  Modified files:              
    /loncom/interface	portfolio.pm 
  Log:
  - hide the 'files from other dirs' message unless there are othe files.
  - add some text to the upload/create dir fileds to make them more obvious
  
  
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.87 loncom/interface/portfolio.pm:1.88
--- loncom/interface/portfolio.pm:1.87	Fri Aug 26 17:47:25 2005
+++ loncom/interface/portfolio.pm	Fri Sep  9 15:12:29 2005
@@ -43,28 +43,46 @@
 sub display_common {
     my ($r,$current_path,$is_empty,$dir_list)=@_;
     my $iconpath= $r->dir_config('lonIconsURL') . "/";
-    $r->print('<table border="0" cellspacing="2" cellpadding="2"><tr valign="middle">');
-    $r->print('<td bgcolor="#ccddaa" align="center">');
-    my $displayOut = '<form method="post" enctype="multipart/form-data">';
-    $displayOut .= '<input name="uploaddoc" type="file" />'.
-        '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
-        '<input type="hidden" name="action" value="'.$env{"form.action"}.'" />'.
-        '<input type="hidden" name="fieldname" value="'.$env{"form.fieldname"}.'" />'.
-        '<input type="hidden" name="mode" value="'.$env{"form.mode"}.'" />'. 
-        '<input type="submit" name="storeupl" value="Upload" />'.
-        '</form>';
-    $r->print($displayOut);
-    $r->print('</td></tr><tr><td bgcolor="#ccddaa" align="center">');
-    $displayOut = '<form method="post">';
-    $displayOut .= '<input name="newdir" type="input" />'.
-        '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
-        '<input type="hidden" name="action" value="'.$env{"form.action"}.'" />'.
-        '<input type="hidden" name="fieldname" value="'.$env{"form.fieldname"}.'" />'.
-        '<input type="hidden" name="mode" value="'.$env{"form.mode"}.'" />'. 
-        '<input type="submit" name="createdir" value="'.&mt("Create Directory").'" />'.
-        '</form>';
-    $r->print($displayOut);
-    $r->print('</td></tr></table>');
+    my %text=&Apache::lonlocal::texthash('upload' => 'Upload',
+					 'upload_label' =>  
+					 'Upload file to current directory:',
+					 'createdir' => 'Create Subdirectory',
+					 'createdir_label' => 
+					 'Create subdirectory in current directory:');
+    $r->print(<<"TABLE"); 
+<table border="0" cellspacing="2" cellpadding="2">
+  <form method="post" enctype="multipart/form-data">
+    <tr valign="middle">
+      <td bgcolor="#ccddaa" align="right">
+        $text{'upload_label'}
+      </td>
+      <td bgcolor="#ccddaa" align="left">
+        <input name="uploaddoc" type="file" />
+	<input type="hidden" name="currentpath" value="$current_path" />
+	<input type="hidden" name="action" value="$env{"form.action"}" />
+	<input type="hidden" name="fieldname" value="$env{"form.fieldname"}" />
+	<input type="hidden" name="mode" value="$env{"form.mode"}" />
+	<input type="submit" name="storeupl" value="$text{'upload'}" />
+      </td>
+    </tr>
+  </form>
+  <form method="post">
+    <tr>
+      <td bgcolor="#ccddaa" align="right">
+        $text{'createdir_label'}
+      </td>
+      <td bgcolor="#ccddaa" align="left">
+        <input name="newdir" type="input" />
+        <input type="hidden" name="currentpath" value="$current_path" />
+        <input type="hidden" name="action" value="$env{"form.action"}" />
+        <input type="hidden" name="fieldname" value="$env{"form.fieldname"}" />
+        <input type="hidden" name="mode" value="$env{"form.mode"}" />
+        <input type="submit" name="createdir" value="$text{'createdir'}" />
+      </td>
+    </tr>
+  </form>
+</table>
+TABLE
     my @tree = split (/\//,$current_path);
     $r->print('<font size="+2">'.&make_anchor('portfolio','/',$env{"form.mode"},$env{"form.fieldname"},$env{"form.continue"}).'/');
     if (@tree > 1){
@@ -387,10 +405,13 @@
 ENDSMP
     $r->print($javascript);
     $r->print("<h1>Select portfolio files</h1>
-                Check as many as you wish in response to the essay problem.<br />");
-    $r->print("<strong>Files selected from other directories:</strong><br />");
-    foreach (&Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'})) {
-        $r->print($_."<br />");
+                Check as many as you wish in response to the problem.<br />");
+    my @otherfiles=&Apache::lonnet::files_not_in_path($env{'user.name'}, $env{'form.currentpath'});
+    if (@otherfiles) {
+	$r->print("<strong>Files selected from other directories:</strong><br />");
+	foreach my $file (@otherfiles) {
+	    $r->print($file."<br />");
+	}
     }
 }
 sub upload {
@@ -529,7 +550,7 @@
         $r->print(&Apache::loncommon::bodytag('Portfolio Manager'));
     }
     $r->rflush();
-	if (($env{'form.storeupl'} eq 'Upload') & (!$env{'form.uploaddoc.filename'})){
+	if (($env{'form.storeupl'}) & (!$env{'form.uploaddoc.filename'})){
    	    $r->print('<font color="red"> No file was selected to upload.'.
    	            'To upload a file, click <strong>Browse...</strong>'.
    	            ', select a file, then click <strong>Upload</strong>,</font>');