--- loncom/homework/Attic/lonindexer.pm 2000/08/02 12:20:28 1.2 +++ loncom/homework/Attic/lonindexer.pm 2000/08/04 19:24:12 1.4 @@ -3,6 +3,7 @@ # (Login Screen # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14 Gerd Kortemeyer) # 11/23 Gerd Kortemeyer +# 07/20-08/04 H.K. Ng # package Apache::lonindexer; @@ -56,33 +57,45 @@ ENDHEADER
");
- $r->print("
".join(' ',@packlist)." "; sub branch { - my ($r,$uri,$calluri)=@_; - my ($line,@list); + my ($r,$uri,$indent,@openuri)=@_; + my ($calluri,$line,@list); my ($domusr,$foo,$strip,$testdir,$compuri,$chkdir,$diropen); my $dirptr=16384; -# my $calluri=$r->uri; - $ENV{'dirlist.lvl'}++; + $indent++; - @list=&get_list($uri); - foreach $line (@list) { - chomp $line; - - ($strip,$domusr,$foo,$testdir,$foo)=split(/\&/,$line,5); - $compuri=join("",$strip,"/"); - - $chkdir=$testdir&$dirptr; - if ($domusr eq "domain" or $domusr eq "user") { - $chkdir = $dirptr; - $testdir = $dirptr; - } - $diropen = 0; - $diropen = 1 if ($compuri eq $calluri); - &display_line($r,$diropen,$line); + foreach $calluri (@openuri) { + @list=&get_list($r,$uri); + foreach $line (@list) { + chomp $line; - &branch($r,$compuri,$calluri) if ($calluri =~ $compuri and $calluri=~/^$uri/ and $chkdir == $dirptr and $testdir ne ""); + ($strip,$domusr,$foo,$testdir,$foo)=split(/\&/,$line,5); + $compuri=join("",$strip,"/"); + $chkdir=$testdir&$dirptr; + if ($domusr eq "domain" or $domusr eq "user") { + $chkdir = $dirptr; + $testdir = $dirptr; + } + $diropen = 0; + $diropen = 1 if ($compuri eq $calluri); + &display_line($r,$diropen,$line,$indent); + + my @securi; + push @securi,$calluri; + &branch($r,$compuri,$indent,@securi) if ($calluri =~ $compuri and $calluri=~/^$uri/ and $chkdir == $dirptr and $testdir ne ""); + } } - $ENV{'dirlist.lvl'}--; + $indent--; } # ------ get complete list based on the uri ------ sub get_list { - my $uri=shift; + my ($r,$uri)=@_; my @list; my $luri=$uri; $luri=~s/\//_/g; + unlink "/home/httpd/perl/tmp/$ENV{'user.name'}_dirlist*.tmp" if ($ENV{'form.dirlistattr'} eq "Refresh"); my $dirlist = "/home/httpd/perl/tmp/$ENV{'user.name'}_dirlist$luri.tmp"; if (-e $dirlist) { my $FH = Apache::File->new($dirlist); @@ -139,7 +155,7 @@ sub get_list { my $FH = Apache::File->new(">$dirlist"); print $FH join("\n",@list); } - return @list=&match_ext(@list); + return @list=&match_ext($r,@list); } # ------ get previously opened path, if any ------ @@ -173,14 +189,15 @@ sub get_openpath { } sub match_ext { - my @packlist=@_; + my ($r,@packlist)=@_; my $line; my @trimlist; my $nextline; my @fileext; my $dirptr=16384; - my $fn="/home/httpd/lonTabs/filetypes.tab"; + my $tabdir = $r->dir_config('lonTabDir'); + my $fn = $tabdir."/filetypes.tab"; if (-e $fn) { my $FH=Apache::File->new($fn); my @content=<$FH>; @@ -210,17 +227,16 @@ sub match_ext { } sub display_line{ - my ($r,$diropen,$line)=@_; - my (@pathfn, $fndir, $fnptr, $disattr); + my ($r,$diropen,$line,$indent)=@_; + my (@pathfn, $fndir, $fnptr); my $dirptr=16384; - my $fileclr="#ffffdd"; + my $fileclr="#ffffe6"; my $iconpath="/res/adm/pages/indexericons/"; my @filecom = split (/\&/,$line); my @pathcom = split (/\//,$filecom[0]); my $listname = $pathcom[scalar(@pathcom)-1]; my $fnptr = $filecom[3]&$dirptr; - my $indent = $ENV{'dirlist.lvl'}; my $tabtag=""; my $nextline; @@ -228,30 +244,36 @@ sub display_line{ while ($i<=5) { my $key="form.attr".$i; - $i++; $tabtag=join('',$tabtag," | ") if $ENV{$key} == 1;
+ $i++;
}
if ($filecom[1] eq "domain") {
$r->print("![]() ");
+ &begin_form ($r,$filecom[0]);
+ $r->print ("print ("comp.blue.gif\"");
+ $r->print (" name=\"submit\" height=\"22\" type=\"image\" border=\"0\">\n");
+ $r->print("Domain - $listname $tabtag\n");
return OK;
}
if ($filecom[1] eq "user") {
$r->print(" | \n");
+ &begin_form ($r,$filecom[0]);
my $count = 0;
- while ($count <= $ENV{'dirlist.lvl'}) {
+ while ($count <= $indent) {
$r->print(" | ");
- while ($count <= $ENV{'dirlist.lvl'}) {
+ while ($count <= $indent) {
$r->print(" | ");
- $r->print("![]() ",$filecom[8]," | ") if $ENV{'form.attr0'} == 1;
- $r->print(" ".(localtime($filecom[9]))." | ") if $ENV{'form.attr1'} == 1;
- $r->print(" ".(localtime($filecom[10]))." | ") if $ENV{'form.attr2'} == 1;
- $r->print(" ",$filecom[8]," | \n") if $ENV{'form.attr0'} == 1;
+ $r->print(" ".(localtime($filecom[9]))." | \n") if $ENV{'form.attr1'} == 1;
+ $r->print(" ".(localtime($filecom[10]))." | \n") if $ENV{'form.attr2'} == 1;
+ $r->print("\n");
}
# display directory
if ($fnptr == $dirptr) {
my @file_ext = split (/\./,$listname);
my $curfext = $file_ext[scalar(@file_ext)-1];
-
$r->print("");
+ &begin_form ($r,$filecom[0]);
+
my $count = 0;
- while ($count <= $ENV{'dirlist.lvl'}) {
+ while ($count <= $indent) {
$r->print(" | |