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

banghart lon-capa-cvs@mail.lon-capa.org
Tue, 12 Oct 2004 00:44:06 -0000


banghart		Mon Oct 11 20:44:06 2004 EDT

  Modified files:              
    /loncom/interface	portfolio.pm 
  Log:
  	Added beginning of javascript sending selected files
  	back to opener.
  
  	Still not working.
  
  
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.47 loncom/interface/portfolio.pm:1.48
--- loncom/interface/portfolio.pm:1.47	Mon Oct 11 18:52:20 2004
+++ loncom/interface/portfolio.pm	Mon Oct 11 20:44:05 2004
@@ -38,7 +38,7 @@
     return $anchor;
 }
 my $dirptr=16384;
-sub display_directory {
+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">');
@@ -73,15 +73,20 @@
 	      &Apache::lonhtmlcommon::select_recent('portfolio','currentpath',
 						    'this.form.submit();'));
     $r->print("</form>");
+}
+sub display_directory {
+    my ($r,$current_path,$is_empty,$dir_list)=@_;
+    my $iconpath= $r->dir_config('lonIconsURL') . "/";
+    my $display_out;
     if ($is_empty && ($current_path ne '/')) {
-        $displayOut = '<form method="post" action="/adm/portfolio">'.
+        $display_out = '<form method="post" action="/adm/portfolio">'.
         '<input type="hidden" name="action" value="deletedir" />'.
         '<input type="submit" name="deletedir" value="'.&mt("Delete Directory").'" />'.
         '<input type="hidden" name="selectfile" value="" />'.
         '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
         '</form>';
         
-        $r->print($displayOut);
+        $r->print($display_out);
 	return;
     }
     $r->print('<table border="0" cellspacing="2" cellpadding="2">'.
@@ -135,53 +140,23 @@
 sub display_file_select {
     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 = $displayOut.'<input name="uploaddoc" type="file" />'.
-        '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
-        '<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="submit" name="createdir" value="'.&mt("Create Directory").'" />'.
-        '</form>';
-    $r->print($displayOut);
-    $r->print('</td></tr></table>');
-    my @tree = split (/\//,$current_path);
-    $r->print('<font size="+2">'.&make_anchor('portfolio','/').'/');
-    if (@tree > 1){
-        my $newCurrentPath = '';
-        for (my $i = 1; $i< @tree; $i++){
-            $newCurrentPath .= $tree[$i].'/';
-            $r->print(&make_anchor($tree[$i],'/'.$newCurrentPath).'/');
-        }
-    }
-    $r->print('</font>');
-    &Apache::lonhtmlcommon::store_recent('portfolio',$current_path,$current_path);
-    #Fixme -- remove from recent those paths that are deleted
-    $r->print('<br /><form method=post action="/adm/portfolio">'.
-	      &Apache::lonhtmlcommon::select_recent('portfolio','currentpath',
-						    'this.form.submit();'));
-    $r->print("</form>");
+    my $display_out;
     if ($is_empty && ($current_path ne '/')) {
-        $displayOut = '<form method="post" action="/adm/portfolio">'.
+        $display_out = '<form method="post" action="/adm/portfolio">'.
         '<input type="hidden" name="action" value="deletedir" />'.
         '<input type="submit" name="deletedir" value="'.&mt("Delete Directory").'" />'.
         '<input type="hidden" name="selectfile" value="" />'.
         '<input type="hidden" name="currentpath" value="'.$current_path.'" />'.
+
         '</form>';
         
-        $r->print($displayOut);
+        $r->print($display_out);
 	return;
     }
     $r->print('<table border="0" cellspacing="2" cellpadding="2">'.
             '<tr><th>Select</th><th>&nbsp;</th><th>Name</th><th>Size</th><th>Last Modified</th></tr>');
     my $href_location="/uploaded/$ENV{'user.domain'}/$ENV{'user.name'}/portfolio$current_path";
-    $r->print('<form method="post" action="/adm/portfolio">');
+    $r->print('<form method="post" name="checkselect" action="/adm/portfolio">');
     foreach my $line (sort 
 		      { 
 			  my ($afile)=split('&',$a,2);
@@ -211,16 +186,10 @@
             }
         }
     }
-    $r->print('<input type="submit" name="doit" value="Go" />
-                
-                <input type="hidden" name="currentpath" value="'.$current_path.'" />');
-
-#   <tr bgcolor="#FFAA99"> pink bg 
-#   <tr bgcolor="#CCCCFF"> blue bg            
-#   $r->print(&display_directory($current_path, $currentFile, @dir_list));
-#    $r->print('</td>><td>');
-#   $r->print(&display_actions($current_path, $currentFile, $isEmpty));
-    $r->print('</table></form>');
+    $r->print('</table>
+            <input type="button" name="doit" onClick= "finishSelect();" value="Select checked files, and close window" />
+            <input type="hidden" name="currentpath" value="'.$current_path.'" />
+    </form>');
 }
 
 sub open_form {
@@ -346,6 +315,16 @@
 }
 sub select_files {
     my ($r)=@_;
+    my $java_script =(<<ENDSMP);
+        <script language='javascript'>
+        function finishSelect() {
+            opener.document.forms.lonhomework.selectedfiles.value='files were selected';
+            
+            self.close();
+        }
+        </script>
+ENDSMP
+    $r->print($java_script);
     $r->print("<h1>Select portfolio files</h1>
                 Check as many as you wish in response to the essay problem.<br />");
     my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
@@ -379,6 +358,7 @@
     }
     # need to know if directory is empty so it can be removed if desired
     my $is_empty=(@dir_list == 2);
+    &display_common($r,$current_path,$is_empty,\@dir_list);
     &display_file_select($r,$current_path,$is_empty,\@dir_list);
     $r->print("</body>\n</html>\n");
     return OK;
@@ -529,6 +509,7 @@
         }
 	# need to know if directory is empty so it can be removed if desired
 	my $is_empty=(@dir_list == 2);
+	&display_common($r,$current_path,$is_empty,\@dir_list);
 	&display_directory($r,$current_path,$is_empty,\@dir_list);
 	$r->print("</body>\n</html>\n");
 	return OK;