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

www lon-capa-cvs@mail.lon-capa.org
Wed, 04 Sep 2002 13:06:20 -0000


www		Wed Sep  4 09:06:20 2002 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  Can now create new "folders" (uploaded sequences)
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.15 loncom/interface/londocs.pm:1.16
--- loncom/interface/londocs.pm:1.15	Mon Sep  2 11:27:08 2002
+++ loncom/interface/londocs.pm	Wed Sep  4 09:06:20 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.15 2002/09/02 15:27:08 www Exp $
+# $Id: londocs.pm,v 1.16 2002/09/04 13:06:20 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -68,7 +68,8 @@
 	   $r->print('<p><font color="red">'.$errtext.'</font></p>');
     } else {
 # ------------------------------------------------------------ Process commands
-	if ($allowed) {
+# ---------------- if they are for this folder and user allowed to make changes
+	if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
 # upload a file, if present
            if (($ENV{'form.uploaddoc.filename'}) &&
                ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
@@ -135,7 +136,8 @@
 # Store the changed version
 		&storemap($coursenum,$coursedom,$folder.'.sequence');
             }
-	}
+       }
+# ---------------------------------------------------------------- End commands
 # ---------------------------------------------------------------- Print screen
         my $idx=0;
         $r->print('<table>');
@@ -167,11 +169,24 @@
 <a href='/adm/coursedocs?folder=$folder&cmd=del_$index'>Remove</td>
 END
     }
-# URL
-    if ($url=~/^\/*uploaded\//) {
-	$url=&Apache::lonnet::tokenwrapper($url);
+# Figure out what kind of a resource this is
+    my ($extension)=($url=~/\.(\w+)$/);
+    my $uploaded=($url=~/^\/*uploaded\//);
+    my $icon='unknown';
+    if (-e "/home/httpd/html/adm/lonIcons/$extension.gif") {
+	$icon=$extension;
     }
-    $line.='<td><a href="'.$url.'">View</a></td>';
+    if ($uploaded) {
+       if ($extension eq 'sequence') {
+	  $icon='folder_closed';
+          $url=~/\/(\w+)\.sequence/;
+          $url='/adm/coursedocs?folder='.$1;
+       } else {
+	  $url=&Apache::lonnet::tokenwrapper($url);
+       } 
+    }
+    $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="/adm/lonIcons/'.
+        $icon.'.gif" border="0"></a></td>';
 # Title
     $title=&Apache::lonnet::unescape($title);
     if ($title=~
@@ -179,7 +194,7 @@
 	) { $title='<i>'.localtime($1).'</i> '.$2.' at '.$3.': <br>'.
 		&Apache::lontexconvert::msgtexconverted($4);
 	}
-    $line.="<td>$title</td>";
+    $line.="<td bgcolor='#FFFFBB'><a href='$url'>$title</a></td>";
     $line.='</tr>';
     return $line;
 }
@@ -240,7 +255,20 @@
 <html>
 <head>
 <title>The LearningOnline Network with CAPA</title>
-<script>$script</script>
+<script>
+$script
+
+function makenewfolder(targetform,folderseq) {
+    var foldername=prompt('Name of New Folder','New Folder');
+    if (foldername) {
+	targetform.importdetail.value=foldername+"="+folderseq;
+        targetform.submit();
+    }
+}
+
+function makenewext(targetform) {
+}
+</script>
 </head>
 ENDDOCUMENT
 $r->print(&Apache::loncommon::bodytag('Course Documents','',$events));
@@ -250,13 +278,15 @@
        my $folder=$ENV{'form.folder'};
        unless ($folder=~/^default/) { $folder='default'; }
        &editor($r,$coursenum,$coursedom,$folder,$allowed);
+       my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
+                     '.sequence';
        $r->print(<<ENDFORM);
-<table><tr>
-<th>Upload a new main course document</th>
-<th>Import a published document</th>
-<th>Special documents</th>
+<table cellspacing=2><tr>
+<th bgcolor="#DDDDDD">Upload a new main course document</th>
+<th bgcolor="#DDDDDD">Import a published document</th>
+<th bgcolor="#DDDDDD">Special documents</th>
 </tr>
-<tr><td>
+<tr><td bgcolor="#DDDDDD">
 File:<br />
 <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
 <input type="file" name="uploaddoc" size="50">
@@ -268,26 +298,31 @@
 <input type="submit" value="Upload Document">
 </form>
 </td>
-<td>
+<td bgcolor="#DDDDDD">
 <form action="/adm/coursedocs" method="post" name="simpleedit">
+<input type="hidden" name="folder" value="$folder">
 <input type=hidden name="importdetail" value="">
 <input type=button onClick=
-"javascript:groupsearch()" value="Group Search">
+"javascript:groupsearch()" value="Search">
 <input type=button onClick=
-"javascript:groupimport();" value="Group Import">
+"javascript:groupimport();" value="Import">
 </form>
-</td><td>
+</td><td bgcolor="#DDDDDD">
 <form action="/adm/coursedocs" method="post" name="newfolder">
+<input type="hidden" name="folder" value="$folder">
 <input type=hidden name="importdetail" value="">
-<input name="newfolder" type="button" onClick="javascript:newfolder();"
+<input name="newfolder" type="button"
+onClick="javascript:makenewfolder(this.form,'$folderseq');"
 value="New Folder" />
 </form>
 <form action="/adm/coursedocs" method="post" name="newext">
+<input type="hidden" name="folder" value="$folder">
 <input type=hidden name="importdetail" value="">
-<input name="newext" type="button" onClick="javascript:newext();"
+<input name="newext" type="button" onClick="javascript:makenewext(this.form);"
 value="External Resource" />
 </form>
 <form action="/adm/coursedocs" method="post" name="newsyl">
+<input type="hidden" name="folder" value="$folder">
 <input type=hidden name="importdetail" 
 value="Syllabus=/public/$coursedom/$coursenum/syllabus">
 <input name="newsyl" type="submit" value="Syllabus" />
@@ -298,10 +333,10 @@
 <input name="newsyl" type="submit" value="Navigate Content" />
 </form>
 <form action="/adm/coursedocs" method="post" name="newaboutme">
+<input type="hidden" name="folder" value="$folder">
 <input type=hidden name="importdetail" 
 value="$plainname=/adm/$udom/$uname/aboutme">
-<input name="newaboutme" type="submit" onClick="javascript:newaboutme();"
-value="My Personal Info" />
+<input name="newaboutme" type="submit" value="My Personal Info" />
 </form>
 </td></tr>
 </table>