--- loncom/interface/lonindexer.pm 2000/08/28 21:07:32 1.1
+++ loncom/interface/lonindexer.pm 2001/08/08 03:00:11 1.16
@@ -1,23 +1,55 @@
# 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
#
+# 05/9-05/19/2001 H. K. Ng
+# 05/21/2001 H. K. Ng
+# 05/23/2001 H. K. Ng
+# 05/31/2001 Scott Harrison
+# 06/01/2001 Scott Harrison
+# 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;
use strict;
use Apache::lonnet();
use Apache::Constants qw(:common);
+use Apache::File;
+use GDBM_File;
+
+my %hash;
+my %dirs;
+my %language;
+my $hidden;
+my $extrafield;
+my $fnum;
+my $dnum;
+sub BEGIN {
+ my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
+ '/language.tab');
+ map {
+ $_=~/(\w+)\s+([\w\s\-]+)/;
+ $language{$1}=$2;
+ } <$fh>;
+}
sub handler {
my $r = shift;
$r->content_type('text/html');
$r->send_http_header;
return OK if $r->header_only;
-
- my $iconpath= $r->dir_config('lonIconsURL');
+ $fnum=0;
+ $dnum=0;
+ my $iconpath= $r->dir_config('lonIconsURL') . "/";
my $domain = $r->dir_config('lonDefDomain');
my $role = $r->dir_config('lonRole');
my $loadlim = $r->dir_config('lonLoadLim');
@@ -26,330 +58,671 @@ sub handler {
my $lonhost = $r->dir_config('lonHostID');
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='';
+
+ $extrafield='';
+ my $diropendb = "/home/httpd/perl/tmp/$domain\_$ENV{'user.name'}_indexer.db";
+
+ if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) {
+ if ($ENV{'form.launch'} eq '1') {
+ delete $hash{'mode_catalog'};
+ map {
+ if ($_ =~ /^pre_/) {
+ delete $hash{$_};
+ }
+ if ($_ =~ /^store/) {
+ delete $hash{$_};
+ }
+ } keys %hash;
+ }
+ if ($hash{'mode_catalog'} eq 'interactive') {
+ $ENV{'form.catalogmode'}='interactive';
+ }
+ if ($hash{'mode_catalog'} eq 'groupimport') {
+ $ENV{'form.catalogmode'}='groupimport';
+ }
+
+ if ($ENV{'form.catalogmode'} eq 'interactive') {
+ $hash{'mode_catalog'}='interactive';
+ $extrafield='
'.
+ ' | ';
+ $colspan=" colspan='2' ";
+ $hidden=<
+END
+ $closebutton=<
+END
+ }
+ elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
+ $hash{'mode_catalog'}='groupimport';
+ $extrafield=''.
+ ' | ';
+ $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 Directory Browser
+The LearningOnline Network With CAPA Directory Browser
+
+
+
ENDHEADER
-
- my $line;
- my (@attrchk,@openpath);
- my $uri=$r->uri;
- my $iconpath="/res/adm/pages/indexericons/";
-
- $r->print("The LearningOnline Network Directory Browser
\n");
-
- for (my $i=0; $i<=5; $i++) {
- $attrchk[$i] = "checked" if $ENV{'form.attr'.$i} == 1;
+ 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;
}
- $r->print(<Display file attributes
+ untie %hash;
+ if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) {
+
+ if ($ENV{'form.attrs'} ne "") {
+ for (my $i=0; $i<=5; $i++) {
+ delete $hash{'display_attrs_'.$i};
+ if ($ENV{'form.attr'.$i} == 1) {
+ $attrchk[$i] = "checked";
+ $hash{'display_attrs_'.$i} = 1;
+ }
+ }
+ } else {
+ for (my $i=0; $i<=5; $i++) {
+ $attrchk[$i] = "checked" if $hash{'display_attrs_'.$i} == 1;
+ }
+ }
+ $r->print(<Display file attributes
END
- my $titleclr="#ddffff";
- my $fileclr="#ffffdd";
-
- $r->print("\n");
- $r->print("\n");
- $r->print("Name | \n");
- $r->print("Size (bytes) | \n") if ($ENV{'form.attr0'} == 1);
- $r->print("Last accessed | \n") if ($ENV{'form.attr1'} == 1);
- $r->print("Last modified | \n") if ($ENV{'form.attr2'} == 1);
- $r->print(" ");
-
- if ($ENV{'form.openuri'} =~ /$uri\&/) {
- my @pathcom = split(/\//,$uri);
- pop @pathcom;
- my $splituri = join ('/',@pathcom);
- $uri = join ('',$splituri,"/");
- }
+ my $titleclr="#ddffff";
+ $r->print("\n");
+ $r->print("\n");
+ $r->print("Name | \n");
+ $r->print("Size (bytes) | \n") if ($hash{'display_attrs_0'} == 1);
+ $r->print("Last accessed | \n") if ($hash{'display_attrs_1'} == 1);
+ $r->print("Last modified | \n") if ($hash{'display_attrs_2'} == 1);
+ $r->print("Author(s) | \n") if ($hash{'display_attrs_3'} == 1);
+ $r->print("Keywords | \n") if ($hash{'display_attrs_4'} == 1);
+ $r->print("Language | \n") if ($hash{'display_attrs_5'} == 1);
+ $r->print(" ");
+
+ map {
+ if ($_ =~ /^diropen_status_/) {
+ my $key = $_;
+ $key =~ s/^diropen_status_//;
+ $dirs{$key} = $hash{$_};
+ }
+ } keys %hash;
- 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");
- &branch ($r,"/res/".$domain."/",$indent,@openpath);
-
- $r->print(" ");
- $r->print(" | ");
- $r->print("
|