--- loncom/interface/lonindexer.pm 2001/06/26 21:11:18 1.12 +++ loncom/interface/lonindexer.pm 2001/08/08 03:00:11 1.16 @@ -1,6 +1,8 @@ # The LearningOnline Network with CAPA +# # Directory Indexer # (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 @@ -13,6 +15,8 @@ # 06/02/2001 Scott Harrison # 06/15/2001 Scott Harrison # 06/26/2001 H. K. Ng +# 07/08/2001 H. K. Ng +# 8/6,8/7 Scott Harrison package Apache::lonindexer; @@ -28,8 +32,10 @@ my %language; my $hidden; my $extrafield; my $fnum; +my $dnum; sub BEGIN { - my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/language.tab'); + my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}. + '/language.tab'); map { $_=~/(\w+)\s+([\w\s\-]+)/; $language{$1}=$2; @@ -42,6 +48,7 @@ sub handler { $r->send_http_header; return OK if $r->header_only; $fnum=0; + $dnum=0; my $iconpath= $r->dir_config('lonIconsURL') . "/"; my $domain = $r->dir_config('lonDefDomain'); my $role = $r->dir_config('lonRole'); @@ -52,51 +59,90 @@ sub handler { my $tabdir = $r->dir_config('lonTabDir'); my $fileclr='#ffffe6'; + my $line; + my (@attrchk,@openpath); + my $uri=$r->uri; + # -------------------------------------- see if called from an interactive mode +# foreach my $key (sort(keys(%ENV))) { +# $r->print("$key is $ENV{$key}
"); +# } +# $r->print("END ENV"); map { my ($name, $value) = split(/=/,$_); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; if ($name eq 'catalogmode') { $ENV{'form.'.$name}=$value; - } + } + if ($name eq 'launch') { + $ENV{'form.'.$name}=$value; + } + if ($name eq 'acts') { + $ENV{'form.'.$name}=$value; + } } (split(/&/,$ENV{'QUERY_STRING'})); $hidden=''; my $closebutton=''; my $groupimportbutton=''; my $colspan=''; - if ($ENV{'form.catalogmode'} eq 'interactive') { - $extrafield=''. - ''; - $colspan=" colspan='2' "; - $hidden=<'. + ''; + $colspan=" colspan='2' "; + $hidden=< END - $closebutton=< END - } - elsif ($ENV{'form.catalogmode'} eq 'groupimport') { - $extrafield=''. - ''; - $colspan=" colspan='2' "; - $hidden=<'. + ''; + $colspan=" colspan='2' "; + $hidden=< END - $closebutton=< END - $groupimportbutton=< END - } + } - my $catalogmodefunctions=''; - if ($ENV{'form.catalogmode'} eq 'interactive' or - $ENV{'form.catalogmode'} eq 'groupimport') { - $catalogmodefunctions=<print(<print(< The LearningOnline Network With CAPA Directory Browser - +function gothere(val) { + window.location=val+'?acts='+document.forms.fileattr.acts.value; +} + ENDHEADER - - my $line; - my (@attrchk,@openpath); - my $uri=$r->uri; - - $r->print('

The LearningOnline With CAPA Network Directory Browser

'."\n"); - - my $diropendb = "/home/httpd/perl/tmp/$domain\_$ENV{'user.name'}_indexer.db"; - + if ($ENV{'form.catalogmode'} eq 'groupimport') { +# $r->print($ENV{'form.acts'}."
"); + my $acts=$ENV{'form.acts'}; + my @Acts=split(/b/,$acts); + my %ahash; + my %achash; + my $ac=0; + map { + my ($state,$ref)=split(/a/); + $ahash{$ref}=$state; + $achash{$ref}=$ac; + $ac++; + } (@Acts); + map { + my $key=$_; + if ($ahash{$key} eq '1') { +# $r->print("NEW: "); +# $r->print($hash{'pre_'.$key.'_title'}); +# $r->print(" : "); +# $r->print($hash{'pre_'.$key.'_link'}); +# $r->print("
"); + $hash{'store_'.$hash{'pre_'.$key.'_link'}}= + $hash{'pre_'.$key.'_title'}; + $hash{'storectr_'.$hash{'pre_'.$key.'_link'}}= + $hash{'storectr'}+0; + $hash{'storectr'}++; + } + if ($ahash{$key} eq '0') { + if ($hash{'store_'.$hash{'pre_'.$key.'_link'}}) { + delete $hash{'store_'.$hash{'pre_'.$key.'_link'}}; + } + } + } sort {$achash{$a}<=>$achash{$b}} (keys %ahash); + map { + if ($_ =~ /^store_/) { + my $key=$_; + $key=~s/^store_//; +# $r->print("STORE: "); +# $r->print($hash{'storectr_'.$key}); +# $r->print(':'); +# $r->print($hash{'store_'.$key}); +# $r->print(':'); +# $r->print($key); +# $r->print("
"); + } + } keys %hash; + map { + if ($_ =~ /^pre_/ && $_ =~/link$/) { + my $key = $_; + $key =~ s/^pre_//; + $key =~ s/_[^_]*$//; +# $r->print($key); +# $r->print(':'); +# $r->print($hash{'pre_'.$key.'_title'}); +# $r->print(':'); +# $r->print($hash{'pre_'.$key.'_link'}); +# $r->print('
'); + delete $hash{'pre_'.$key.'_title'}; + delete $hash{'pre_'.$key.'_link'}; + } + } keys %hash; + } + + $r->print('

The LearningOnline With CAPA Network Directory Browser

'."\n"); + } else { + $r->print('Unable to tie hash to db file'); + return OK; + } + untie %hash; if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) { if ($ENV{'form.attrs'} ne "") { @@ -201,37 +342,39 @@ ENDHEADER $attrchk[$i] = "checked" if $hash{'display_attrs_'.$i} == 1; } } - $r->print(<print(<Display file attributes
- - - + + + - - - + + +
Size Last access Last modified Size Last access Last modified
Author Keywords Language Author Keywords Language
-  - + + +  + $hidden $closebutton $groupimportbutton
END - my $titleclr="#ddffff"; - $r->print("
\n"); - $r->print("\n"); - $r->print("\n"); - $r->print("\n") if ($hash{'display_attrs_0'} == 1); - $r->print("\n") if ($hash{'display_attrs_1'} == 1); - $r->print("\n") if ($hash{'display_attrs_2'} == 1); - $r->print("\n") if ($hash{'display_attrs_3'} == 1); - $r->print("\n") if ($hash{'display_attrs_4'} == 1); - $r->print("\n") if ($hash{'display_attrs_5'} == 1); - $r->print(""); + my $titleclr="#ddffff"; + $r->print("
NameSize (bytes) Last accessedLast modifiedAuthor(s)KeywordsLanguage
\n"); + $r->print("\n"); + $r->print("\n"); + $r->print("\n") if ($hash{'display_attrs_0'} == 1); + $r->print("\n") if ($hash{'display_attrs_1'} == 1); + $r->print("\n") if ($hash{'display_attrs_2'} == 1); + $r->print("\n") if ($hash{'display_attrs_3'} == 1); + $r->print("\n") if ($hash{'display_attrs_4'} == 1); + $r->print("\n") if ($hash{'display_attrs_5'} == 1); + $r->print(""); map { if ($_ =~ /^diropen_status_/) { @@ -259,19 +402,24 @@ END my $bredir = $ENV{'form.dirPointer'}; my $toplevel; + my $indent = 0; $uri = $uri.'/' if $uri !~ /.*\/$/; - if ($uri eq "/res/" or $bredir ne "on") { + if ($bredir ne "on") { $hash{'top.level'} = $uri; $toplevel = $uri; - } elsif ($bredir eq "on") { - if ($hash{'top.level'} eq "/res/") { - $toplevel = "/res/"; - } else { - $toplevel = $uri; - } + + } else { + $toplevel = $hash{'top.level'}; } - my $indent = 0; - &scanDir ($r,$toplevel,$indent); + if ($toplevel ne "/res/"){ + my (@uri_com) = split(/\//,$uri); + pop @uri_com; + my $upone = join('/',@uri_com); + my @list = qw (0); + &display_line ($r,'opened',$upone.'&viewOneUp',0,$upone,@list); + $indent = 1; + } + &scanDir ($r,$toplevel,$indent,\%hash); $r->print(""); $r->print(""); @@ -288,7 +436,7 @@ END # --------------------recursive scan of a directory sub scanDir { - my ($r,$startdir,$indent)=@_; + my ($r,$startdir,$indent,$hashref)=@_; my ($compuri,$curdir); my $dirptr=16384; $indent++; @@ -314,7 +462,7 @@ sub scanDir { } } } - &display_line($r,$diropen,$line,$indent,$curdir,@list); + &display_line($r,$diropen,$line,$indent,$curdir,$hashref,@list); &scanDir ($r,$compuri,$indent) if $diropen eq "opened"; } $indent--; @@ -383,7 +531,7 @@ sub match_ext { #------------------- displays one line in appropriate table format sub display_line{ - my ($r,$diropen,$line,$indent,$startdir,@list)=@_; + my ($r,$diropen,$line,$indent,$startdir,$hashref,@list)=@_; my (@pathfn, $fndir, $fnptr); my $dirptr=16384; my $fileclr="#ffffe6"; @@ -403,28 +551,50 @@ sub display_line{ $tabtag=join('',$tabtag,"") if $hash{'display_attrs_'.$i} == 1; $i++; } + if ($filecom[1] eq "viewOneUp") { + $r->print("$extrafield"); + $r->print("\n"); + return OK; + } if ($filecom[1] eq "domain") { + $r->print (''."\n") if ($ENV{'form.dirPointer'} eq "on"); $r->print("$extrafield"); $r->print("\n"); return OK; } if ($filecom[1] eq "user") { $r->print("$extrafield"); - $r->print("'."\n"); + $r->print (''); + $r->print ($listname.$tabtag.''."\n"); return OK; } # display file @@ -452,11 +622,18 @@ sub display_line{ $title=$listname unless $title; $r->print("\n"); $r->print("\n"); + "value='$filelink' onClick='". + "javascript:queue(\"form$fnum\")' "); + if ($hash{'store_'.$filelink}) { + $r->print("checked"); + } + $r->print(">\n"); $r->print("\n"); $r->print("\n"); $r->print("\n"); + $r->print (''."\n"); + $r->print ("$listname$tabtag\n"); } } -#---------------------prints the beginning of a form for directory or file link +# ------------------- prints the beginning of a form for directory or file link sub begin_form { my ($r,$uri) = @_; my $anchor = $uri; $anchor =~ s/\///g; - $r->print (''."\n"); + $r->print (''."\n"); $r->print ($hidden.''."\n"); $r->print (''."\n"); - + $dnum++; } 1; __END__ - - -
NameSize (bytes) Last accessedLast modifiedAuthor(s)KeywordsLanguage
 
\n"); + $r->print ('
'."\n"); + $r->print ($hidden.''."\n"); + $r->print (''."\n"); + $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0">'."\n"); + $r->print("Up $tabtag
"); &begin_form ($r,$filecom[0].'/'); my $anchor = $filecom[0].'/'; $anchor =~ s/\///g; - $r->print ('print (''); + $r->print (''); + $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0">'."\n"); + $r->print ('print (' border="0">'."\n"); $r->print("Domain - $listname $tabtag
\n"); + $r->print("\n"); my $curdir = $startdir.$filecom[0].'/'; - &begin_form ($r,$curdir); my $anchor = $curdir; $anchor =~ s/\///g; + &begin_form ($r,$curdir); $r->print (''."\n"); + $r->print (''); $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0">'."\n"); - $r->print (''.$listname.$tabtag.'
"); + $hash{"pre_${fnum}_link"}=$filelink; + $hash{"pre_${fnum}_title"}=$title; $fnum++; } @@ -521,32 +698,32 @@ sub display_line{ my $rem = $indentm1%10.0; my $count = 0; while ($count < $ten) { - $r->print("\n"); + $r->print ("\n"); $count++; } - $r->print("\n") if $rem > 0; + $r->print ("\n") if $rem > 0; } + $r->print (''); $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0">'."\n"); - $r->print("\n"); - $r->print("$listname $tabtag