--- loncom/homework/Attic/lonindexer.pm 2000/08/03 21:19:44 1.3
+++ 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;
@@ -40,7 +41,6 @@ ENDHEADER
my $iconpath="/res/adm/pages/indexericons/";
$r->print("
The LearningOnline Network Directory Browser
\n");
-# $r->print("
Current uri=$uri
called uri=$ENV{'form.openuri'}
domain=$domain
");
for (my $i=0; $i<=5; $i++) {
$attrchk[$i] = "checked" if $ENV{'form.attr'.$i} == 1;
@@ -59,6 +59,7 @@ ENDHEADER
+
END
my $titleclr="#ddffff";
@@ -72,22 +73,29 @@ END
$r->print("Last modified | \n") if ($ENV{'form.attr2'} == 1);
$r->print("");
- if ($ENV{'dirlist.level'} eq "") {
- my %dirlevel;
- $dirlevel{'dirlist.level'}='-2';
- &Apache::lonnet::appenv(%dirlevel);
- } else {
- $ENV{'dirlist.level'}='-2';
- }
if ($ENV{'form.openuri'} =~ /$uri\&/) {
my @pathcom = split(/\//,$uri);
pop @pathcom;
my $splituri = join ('/',@pathcom);
$uri = join ('',$splituri,"/");
}
+
+
+ my $openuri = $ENV{'form.openuri'};
+# $r->print ("
openuri=$openuri
");
+ $openuri =~ s/$uri(.*)\&//g;
+# $r->print ("
parsed openuri=$openuri
");
+ @openpath = split(/\&/,$openuri);
+# $r->print ("
open path=@openpath
");
+ push @openpath, $uri;
+# $r->print ("
append current uri to open path=@openpath
");
+ @openpath = sort @openpath;
+# $r->print ("
sorted open path=@openpath
");
+
+
+ my $indent = -1;
&display_line ($r,1,"/res/".$domain."&domain");
-# $domain="/res/".$domain."/";
- &branch($r,"/res/".$domain."/",$uri);
+ &branch ($r,"/res/".$domain."/",$indent,@openpath);
$r->print("");
$r->print("");
@@ -101,30 +109,34 @@ END
# print "Dir list
".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;
- $ENV{'dirlist.level'}++;
+ $indent++;
- @list=&get_list($r,$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.level'}--;
+ $indent--;
}
# ------ get complete list based on the uri ------
@@ -133,6 +145,7 @@ sub get_list {
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);
@@ -214,7 +227,7 @@ sub match_ext {
}
sub display_line{
- my ($r,$diropen,$line)=@_;
+ my ($r,$diropen,$line,$indent)=@_;
my (@pathfn, $fndir, $fnptr);
my $dirptr=16384;
my $fileclr="#ffffe6";
@@ -224,7 +237,6 @@ sub display_line{
my @pathcom = split (/\//,$filecom[0]);
my $listname = $pathcom[scalar(@pathcom)-1];
my $fnptr = $filecom[3]&$dirptr;
- my $indent = $ENV{'dirlist.level'};
my $tabtag="";
my $nextline;
@@ -252,13 +264,13 @@ sub display_line{
$r->print("\n");
&begin_form ($r,$filecom[0]);
my $count = 0;
- while ($count <= $ENV{'dirlist.level'}) {
+ while ($count <= $indent) {
$r->print(" \n");
$count++;
}
$r->print ("print ("right.gif\"") if $diropen == 0;
- $r->print ("down.gif\"") if $diropen == 1;
+ $r->print ("folder_pointer_closed.gif\"") if $diropen == 0;
+ $r->print ("folder_pointer_opened.gif\"") if $diropen == 1;
$r->print (" name=\"submit\" height=\"22\" type=\"image\" border=\"0\">\n");
$r->print(" \n");
$r->print("$listname $tabtag\n");
@@ -271,7 +283,7 @@ sub display_line{
my $curfext = $file_ext[scalar(@file_ext)-1];
my $count = 0;
$r->print(" | ");
- while ($count <= $ENV{'dirlist.level'}) {
+ while ($count <= $indent) {
$r->print(" \n");
$count++;
}
@@ -292,17 +304,17 @@ sub display_line{
&begin_form ($r,$filecom[0]);
my $count = 0;
- while ($count <= $ENV{'dirlist.level'}) {
+ while ($count <= $indent) {
$r->print(" \n");
$count++;
}
$r->print ("print ("right.gif\"") if $diropen == 0;
- $r->print ("down.gif\"") if $diropen == 1;
+ $r->print ("folder_pointer_closed.gif\"") if $diropen == 0;
+ $r->print ("folder_pointer_opened.gif\"") if $diropen == 1;
$r->print (" name=\"submit\" height=\"22\" type=\"image\" border=\"0\">\n");
- $r->print(" \n") if $diropen == 0;
- $r->print(" \n") if $diropen == 1;
+ $r->print(" \n") if $diropen == 0;
+ $r->print(" \n") if $diropen == 1;
$r->print("$listname $tabtag |
\n");
}
}
@@ -311,8 +323,8 @@ sub begin_form {
my ($r,$uri) = @_;
my $currenturi = $r->uri;
my $openuri = $ENV{'form.openuri'};
- if ($ENV{'form.openuri'} =~ /$currenturi\&/) {
- $openuri =~ s/$currenturi\&//;
+ if ($ENV{'form.openuri'} =~ /$currenturi(.*)\&/) {
+ $openuri =~ s/$currenturi(.*)\&//g;
} else {
$currenturi = join ('',$currenturi,"&");
$openuri = join ('&',$ENV{'form.openuri'},$currenturi);
@@ -342,7 +354,3 @@ sub display_env {
1;
__END__
-
-
-
-