[LON-CAPA-cvs] cvs: loncom /interface portfolio.pm
banghart
lon-capa-cvs@mail.lon-capa.org
Wed, 08 Sep 2004 20:34:28 -0000
This is a MIME encoded message
--banghart1094675668
Content-Type: text/plain
banghart Wed Sep 8 16:34:28 2004 EDT
Modified files:
/loncom/interface portfolio.pm
Log:
Some formatting changes, hoping style police approve.
Removed superfluous '/' added to $href_location owing to leading and trailing '/' in
$current_path
Added additional Fixme comment to remove dead directories from recent pulldown.
Removed unused routines.
Corrected error in earlier submit. Removed " character I had erroneously inserted in
make_anchor routine.
--banghart1094675668
Content-Type: text/plain
Content-Disposition: attachment; filename="banghart-20040908163428.txt"
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.38 loncom/interface/portfolio.pm:1.39
--- loncom/interface/portfolio.pm:1.38 Wed Sep 8 13:53:37 2004
+++ loncom/interface/portfolio.pm Wed Sep 8 16:34:28 2004
@@ -38,127 +38,6 @@
return $anchor;
}
-# returns html with <br /> separated contents of the directory
-# returns a <strong>currentFile</strong> (bolds the selected file/dir)
-sub display_directory_old {
- my ($currentPath, $currentFile, @dirList,) = @_;
- my $displayOut='';
- my $filename;
- my $upPath;
- if ($currentPath ne '/') {
- $displayOut = 'Listing of '.$currentPath.'<br /><hr />';
- # provides the "up one directory level" function
- # it means shortening the currentpath to the parent directory
- $currentPath =~ m:(^/.*)(/.*/$):;
- if ($1 ne '/') {
- $upPath = $1.'/';
- } else {
- $upPath = $1;
- }
-
- # $displayOut = $displayOut.'<a href="/adm/portfolio?selectfile='.$upPath.'¤tpath='.$upPath.'">..</a><br />';
- } else {
- # $displayOut = $displayOut.'at root '.$currentPath.'<br />';
- }
- foreach my $line (@dirList) {
- #$strip holds directory/file name
- #$dom
- my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$obs,undef)=split(/\&/,$line,16);
- if (($filename ne '.') && ($filename ne '..')) {
- if ($testdir =~ m:^1:) {
- # handle directories different from files
- if ($filename eq $currentFile) {
- #checks to bold the selected file
- $displayOut.= '<strong>'.(&make_anchor($filename.'/', $filename.'/').'</strong><br />'."\n");
- } else {
- $displayOut.= (&make_anchor($filename.'/', $filename.'/').'<br />'."\n");
- }
- } else {
- if ($filename eq $currentFile) {
- #checks to bold the selected file
- $displayOut.='<strong>'.(&make_anchor($filename, $currentPath).'</strong><br />'."\n");
- } else {
- $displayOut.=(&make_anchor($filename, $currentPath).'<br />'."\n");
- }
- }
-
- }
-
- }
- return $displayOut;
-}
-
-sub displayActions {
- # returns html to offer user appropriate actions depending on selected file/directory
- my $displayOut;
- my ($currentPath, $currentFile, $isEmpty) = @_;
-# $displayOut = 'here are actions for '.$currentFile;
- if ($currentFile =~ m:/$:) {
- # if the selected file is a directory, these are the options
- # offer the chance to delete the directory only if it is empty
- if ($isEmpty && ($currentPath ne '/')) {
- $displayOut = $displayOut.'<form method="POST">
- <input type="hidden" name="selectfile"
- value="'.$currentFile.'" />
- <input type="hidden" name="fileaction" value="delete" />
- <input type="hidden" name="currentpath" value="'.$currentPath.'" />
- <center>
- <input type="submit"
- value="Delete '.$currentFile.'" />
- </center>
- </form>';
- }
- if ($currentPath ne '/') {
- $displayOut = $displayOut.'<hr />
- <form method="POST">
- <input type="hidden" name="selectfile"
- value="'.$currentFile.'" />
- <input type="hidden" name="fileaction" value="rename" />
- <input type="hidden" name="currentpath" value="'.$currentPath.'" />
- <input type="input" name="filenewname" value="Type new name here" />
- <input type="submit"
- value="Rename '.$currentFile.'" />
- </form>';
- }
- } else { #action options offered for files
- $displayOut = $displayOut.'<form method="POST">';
- $displayOut = $displayOut.'<input type="hidden" name="selectfile"';
- $displayOut = $displayOut.'value="'.$currentFile;
- $displayOut = $displayOut.'" /><input type="hidden" name="fileaction" value="delete" />
- <input type="hidden" name="currentpath" value="'.$currentPath.'" />
- <center>
- <input type="submit"
- value="Delete '.$currentFile.'" />
- </center>
- </form>';
-
- $displayOut = $displayOut.'<hr />
- <form method="POST">
- <input type="hidden" name="selectfile"
- value="'.$currentFile.'" />
- <input type="hidden" name="fileaction" value="rename" />
- <input type="hidden" name="currentpath" value="'.$currentPath.'" />
- <input type="input" name="filenewname" value="Type new name here" />
- <input type="submit"
- value="Rename '.$currentFile.'" />
- </form>
- <hr />';
- }
- $displayOut = $displayOut.'<hr />Add a file to '.$currentPath;
- # file upload form
- $displayOut = $displayOut.'<form method="post" enctype="multipart/form-data">';
- $displayOut = $displayOut.'<input name="uploaddoc" type="file" />'.
- '<input type="hidden" name="currentpath" value="'.$currentPath.'" />'.
- '<input type="submit" name="storeupl" value="Upload" />'.
- '</form><hr />';
- $displayOut = $displayOut.'<form method="POST">
- <input name="subdir" type="text" />
- <input type="submit" value="Create Subdirectory" />
- </form>
- ';
- return $displayOut;
-}
-
my $dirptr=16384;
sub display_directory {
my ($r,$current_path,$is_empty,$dir_list)=@_;
@@ -190,6 +69,7 @@
}
$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();'));
@@ -207,7 +87,7 @@
}
$r->print('<table border="0" cellspacing="2" cellpadding="2">'.
'<tr><th>Actions</th><th> </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/";
+ my $href_location="/uploaded/$ENV{'user.domain'}/$ENV{'user.name'}/portfolio$current_path";
foreach my $line (sort
{
my ($afile)=split('&',$a,2);
@@ -226,20 +106,20 @@
} else {
$r->print('<tr bgcolor="#CCCCFF">');
$r->print('<td>
-<form method="post" action="/adm/portfolio">
-<select name="action">
- <option value=""></option>
- <option value="delete">'.&mt("Delete").'</option>
- <option value="rename">'.&mt("Rename").'</option>
-</select>
-<input type="submit" name="doit" value="Go" />
-<input type="hidden" name="selectfile" value="'.$filename.'" />
-<input type="hidden" name="currentpath" value="'.$current_path.'" />
-</form>
-</td>');
+ <form method="post" action="/adm/portfolio">
+ <select name="action">
+ <option value=""></option>
+ <option value="delete">'.&mt("Delete").'</option>
+ <option value="rename">'.&mt("Rename").'</option>
+ </select>
+ <input type="submit" name="doit" value="Go" />
+ <input type="hidden" name="selectfile" value="'.$filename.'" />
+ <input type="hidden" name="currentpath" value="'.$current_path.'" />
+ </form>
+ </td>');
$r->print('<td><img src="'.$iconpath.'unknown.gif"></td>');
$r->print('<td><a href="'.$href_location.$filename.'">'.
- $filename.'</a></td>');
+ $filename.'</a></td>');
$r->print('<td>'.$size.'</td>');
$r->print('<td>'.&Apache::lonlocal::locallocaltime($mtime).'</td>');
$r->print('</tr>');
--banghart1094675668--