--- loncom/interface/portfolio.pm 2004/08/24 04:55:49 1.22 +++ loncom/interface/portfolio.pm 2004/08/24 05:01:42 1.23 @@ -32,27 +32,27 @@ use Apache::lonlocal; # 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 = ''.$fileName.''; +sub make_anchor { + my ($filename, $current_path) = @_; + my $anchor = ''.$filename.''; return $anchor; } # returns html with
separated contents of the directory # returns a currentFile (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.'

'. + if ($currentPath ne '/') { + $displayOut = 'Listing of '.$currentPath.'

'; # 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 @@ sub displayDirectory { 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.= ''.(makeAnchor($fileName.'/', $fileName.'/').'
'."\n"); - }else{ - $displayOut.= (makeAnchor($fileName.'/', $fileName.'/').'
'."\n"); + if ($filename eq $currentFile) { + #checks to bold the selected file + $displayOut.= ''.(&make_anchor($filename.'/', $filename.'/').'
'."\n"); + } else { + $displayOut.= (&make_anchor($filename.'/', $filename.'/').'
'."\n"); } - }else{ - if ($fileName eq $currentFile){ #checks to bold the selected file - $displayOut.=''.(makeAnchor($fileName, $currentPath).'
'."\n"); - }else{ - $displayOut.=(makeAnchor($fileName, $currentPath).'
'."\n"); + } else { + if ($filename eq $currentFile) { + #checks to bold the selected file + $displayOut.=''.(&make_anchor($filename, $currentPath).'
'."\n"); + } else { + $displayOut.=(&make_anchor($filename, $currentPath).'
'."\n"); } } @@ -85,12 +87,13 @@ sub displayDirectory { } 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 @@ sub displayActions { value="Rename '.$currentFile.'" /> '; } - }else{ #action options offered for files + } else { #action options offered for files $displayOut = $displayOut.'
'; $displayOut = $displayOut.'print('
'.$currentPath.'
'); @@ -205,7 +209,7 @@ sub handler { $r->print(&Apache::lonnet::userfileupload('uploaddoc','','portfolio'.$currentPath).'
'); } # 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('
trying to delete '.$currentPath.$ENV{'form.selectfile'}.'
'); $r->print(&Apache::lonnet::removeuserfile($ENV{'user.name'}, $ENV{'user.domain'},'portfolio'.$currentPath.$ENV{'form.selectfile'})); @@ -236,11 +240,11 @@ sub handler { } 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 @@ sub handler { $r->print($displayOut); $r->print(''); my @tree = split (/\//,$currentPath); - $r->print(''.makeAnchor('/','/')); + $r->print(''.&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(''); @@ -287,14 +291,14 @@ sub handler { 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(''); $r->print('Go to ...'); - $r->print(''.makeAnchor($fileName.'/',$currentPath.$fileName.'/').''); + $r->print(''.&make_anchor($filename.'/',$currentPath.$filename.'/').''); $r->print(''); - }else{ + } else { $r->print(''); $r->print(' '); $r->print(''); - $r->print(''. - $fileName.''); + $r->print(''. + $filename.''); $r->print(''.$size.''); $r->print(''.&Apache::lonlocal::locallocaltime($mtime).''); $r->print(''); @@ -315,9 +319,9 @@ sub handler { } # pink bg # blue bg -# $r->print(displayDirectory($currentPath, $currentFile, @dirList)); +# $r->print(&display_directory($currentPath, $currentFile, @dirList)); # $r->print('>'); -# $r->print(displayActions($currentPath, $currentFile, $isEmpty)); +# $r->print(&display_actions($currentPath, $currentFile, $isEmpty)); $r->print(''); $r->print(''); $r->print("\n\n");