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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 24 Aug 2004 05:01:42 -0000


This is a MIME encoded message

--albertel1093323702
Content-Type: text/plain

albertel		Tue Aug 24 01:01:42 2004 EDT

  Modified files:              
    /loncom/interface	portfolio.pm 
  Log:
  - some style police management
  
  
  
--albertel1093323702
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20040824010142.txt"

Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.22 loncom/interface/portfolio.pm:1.23
--- loncom/interface/portfolio.pm:1.22	Tue Aug 24 00:55:49 2004
+++ loncom/interface/portfolio.pm	Tue Aug 24 01:01:42 2004
@@ -32,27 +32,27 @@
 
 # receives a file name and path stub from username/userfiles/portfolio/
 # returns an anchor tag consisting encoding filename and currentpath
-sub makeAnchor{
-    my ($fileName, $currentPath) = @_;
-    my $anchor = '<a href="/adm/portfolio?selectfile='.$fileName.'&currentpath='.$currentPath.'">'.$fileName.'</a>';
+sub make_anchor {
+    my ($filename, $current_path) = @_;
+    my $anchor = '<a href="/adm/portfolio?selectfile='.$filename.'&currentpath='.$current_path.'">'.$filename.'</a>';
     return $anchor;
 }
 
 # returns html with <br /> separated contents of the directory
 # returns a <strong>currentFile</strong> (bolds the selected file/dir)
-sub displayDirectory {
+sub display_directory {
     my ($currentPath, $currentFile, @dirList,) = @_;
     my $displayOut='';  
-    my $fileName;
+    my $filename;
     my $upPath;
-    if ($currentPath ne '/'){
-        $displayOut = 'Listing of '.$currentPath.'<br /><hr />'.
+    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 '/'){
+        if ($1 ne '/') {
             $upPath = $1.'/';
-        }else{
+        } else {
             $upPath = $1;
         }
         
@@ -63,20 +63,22 @@
     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:){
+    	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>'.(makeAnchor($fileName.'/', $fileName.'/').'</strong><br />'."\n");
-                }else{
-                    $displayOut.= (makeAnchor($fileName.'/', $fileName.'/').'<br />'."\n");
+                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>'.(makeAnchor($fileName, $currentPath).'</strong><br />'."\n");
-                }else{
-                    $displayOut.=(makeAnchor($fileName, $currentPath).'<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");
                 }
             }
             
@@ -85,12 +87,13 @@
     }
     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 ($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 '/')) {
@@ -117,7 +120,7 @@
             value="Rename '.$currentFile.'" />
             </form>';
         }
-    }else{  #action options offered for files
+    } else {  #action options offered for files
         $displayOut = $displayOut.'<form method="POST">';
         $displayOut = $displayOut.'<input type="hidden" name="selectfile"';
         $displayOut = $displayOut.'value="'.$currentFile;
@@ -155,6 +158,7 @@
             ';
     return $displayOut;
 }
+
 sub handler {
     # this handles file management
     my $r = shift;
@@ -190,7 +194,7 @@
     }
     if ($ENV{'form.selectfile'}) {
         # have to check if the selected file is a subdirectory
-        if ($ENV{'form.selectfile'} =~ /-\(Dir\)/){
+        if ($ENV{'form.selectfile'} =~ /-\(Dir\)/) {
             # $currentPath =~ /\-\(Dir\)/;
             $currentPath = $`.'/';
             $r->print('<br />'.$currentPath.'<br />');
@@ -205,7 +209,7 @@
         $r->print(&Apache::lonnet::userfileupload('uploaddoc','','portfolio'.$currentPath).'<br />');  
     }
     # similarly, we need to delete or rename files before getting directory list
-    if ($ENV{'form.selectfile'}){
+    if ($ENV{'form.selectfile'}) {
         if ($ENV{'form.fileaction'} eq 'delete') {
             $r->print('<br />trying to delete '.$currentPath.$ENV{'form.selectfile'}.'<br />');
             $r->print(&Apache::lonnet::removeuserfile($ENV{'user.name'}, $ENV{'user.domain'},'portfolio'.$currentPath.$ENV{'form.selectfile'}));
@@ -236,11 +240,11 @@
         } elsif ($ENV{'form.fileaction'} eq 'rename') {
             &Apache::lonnet::portfoliomanage($ENV{'form.selectfile'}, 'rename', $ENV{'form.filenewname'});
         } else {
-        # Remember user's file selection for later
-        $ENV{'portfolio.file'} = $ENV{'form.selectfile'};
-        # offer things user can do with selected file
+	    # Remember user's file selection for later
+	    $ENV{'portfolio.file'} = $ENV{'form.selectfile'};
+	    # offer things user can do with selected file
         }
-    }else{
+    } else {
         unless ($ENV{'portfolio.file'}){
             $ENV{'portfolio.file'} = 'No File Selected';
         }
@@ -267,12 +271,12 @@
     $r->print($displayOut);
     $r->print('</td></tr></table>');
     my @tree = split (/\//,$currentPath);
-    $r->print('<font size="+2">'.makeAnchor('/','/'));
+    $r->print('<font size="+2">'.&make_anchor('/','/'));
     if (@tree > 1){
         my $newCurrentPath = '';
         for (my $i = 1; $i< @tree; $i++){
             $newCurrentPath .= $tree[$i].'/';
-            $r->print(makeAnchor($tree[$i],'/'.$newCurrentPath).'/');
+            $r->print(&make_anchor($tree[$i],'/'.$newCurrentPath).'/');
         }
     }
     $r->print('</font>');
@@ -287,14 +291,14 @@
     foreach my $line (@dirList) {
     	#$strip holds directory/file name
     	#$dom 
-    	my ($fileName,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); 
-    	if (($fileName ne '.') && ($fileName ne '..')){
-            if ($dirptr&$testdir){
+    	my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); 
+    	if (($filename ne '.') && ($filename ne '..')) {
+            if ($dirptr&$testdir) {
                 $r->print('<tr bgcolor="#FFAA99"><td><img src="'.$iconpath.'folder_closed.gif"></td>');
                 $r->print('<td>Go to ...</td>');
-                $r->print('<td>'.makeAnchor($fileName.'/',$currentPath.$fileName.'/').'</td>'); 
+                $r->print('<td>'.&make_anchor($filename.'/',$currentPath.$filename.'/').'</td>'); 
                 $r->print('</tr>'); 
-            }else{
+            } else {
                 $r->print('<tr bgcolor="#CCCCFF">');
                 $r->print('<td>
 <select name="action">
@@ -305,8 +309,8 @@
 <input type="submit" name="doit" value="Go" />
 </td>');
                 $r->print('<td><img src="'.$iconpath.'unknown.gif"></td>');
-                $r->print('<td><a href="'.$href_location.$fileName.'">'.
-			  $fileName.'</a></td>'); 
+                $r->print('<td><a href="'.$href_location.$filename.'">'.
+			  $filename.'</a></td>'); 
                 $r->print('<td>'.$size.'</td>');
                 $r->print('<td>'.&Apache::lonlocal::locallocaltime($mtime).'</td>');
                 $r->print('</tr>'); 
@@ -315,9 +319,9 @@
     }
 #   <tr bgcolor="#FFAA99"> pink bg 
 #   <tr bgcolor="#CCCCFF"> blue bg            
-#   $r->print(displayDirectory($currentPath, $currentFile, @dirList));
+#   $r->print(&display_directory($currentPath, $currentFile, @dirList));
 #    $r->print('</td>><td>');
-#   $r->print(displayActions($currentPath, $currentFile, $isEmpty));
+#   $r->print(&display_actions($currentPath, $currentFile, $isEmpty));
     $r->print('</table></form>');
     $r->print('</blockquote>');
     $r->print("</body>\n</html>\n");

--albertel1093323702--