--- loncom/interface/lonindexer.pm 2002/06/20 21:22:20 1.44 +++ loncom/interface/lonindexer.pm 2002/06/29 19:55:19 1.45 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.44 2002/06/20 21:22:20 ng Exp $ +# $Id: lonindexer.pm,v 1.45 2002/06/29 19:55:19 ng Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,6 +43,7 @@ # 12/11,12/13 Scott Harrison # YEAR=2002 # 1/17 Scott Harrison +# 6/29/2002 H. K. Ng # ### @@ -382,34 +383,34 @@ ENDHEADER '

The LearningOnline Network with CAPA '. 'Network Directory Browser

'."\n"); # ---------------------------------- get state of file attributes to be showing - if ($ENV{'form.attrs'} ne "") { - for (my $i=0; $i<=6; $i++) { + if ($ENV{'form.attrs'} ne '') { + for (my $i=0; $i<=7; $i++) { delete $hash{'display_attrs_'.$i}; if ($ENV{'form.attr'.$i} == 1) { - $attrchk[$i] = "checked"; + $attrchk[$i] = 'checked'; $hash{'display_attrs_'.$i} = 1; } } } else { - for (my $i=0; $i<=6; $i++) { - $attrchk[$i] = "checked" if $hash{'display_attrs_'.$i} == 1; + for (my $i=0; $i<=7; $i++) { + $attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1; } } # ------------------------------- output state of file attributes to be showing $r->print(<Display file attributes
+Display file attributes
- - - - + + + + - - - - + + + +
Size Last access Last modified All versions Title Size Last access Last modified
Author Keywords Language  Author Keywords Language All versions
@@ -426,21 +427,23 @@ END # $r->print(&writedebug("Omit:@Omit")) if (@Omit); # $r->print(&writedebug("Only:@Only")) if (@Only); $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") + $r->print("
NameSize (bytes) ". - "Last accessedLast modified
\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") + $r->print("\n") if ($hash{'display_attrs_3'} == 1); - $r->print("\n") + $r->print("\n") if ($hash{'display_attrs_4'} == 1); - $r->print("\n") + $r->print("\n") if ($hash{'display_attrs_5'} == 1); - $r->print(""); + $r->print("\n") + if ($hash{'display_attrs_6'} == 1); + $r->print(''); # ----------------- read in what directories have previously been set to "open" foreach (keys %hash) { @@ -472,7 +475,7 @@ END my $indent = 0; $uri = $uri.'/' if $uri !~ /.*\/$/; - if ($bredir ne "on") { + if ($bredir ne 'on') { $hash{'top.level'} = $uri; $toplevel = $uri; @@ -481,7 +484,7 @@ END } # -------------------------------- if not at top level, provide an uplink arrow - if ($toplevel ne "/res/"){ + if ($toplevel ne '/res/'){ my (@uri_com) = split(/\//,$uri); pop @uri_com; my $upone = join('/',@uri_com); @@ -498,11 +501,11 @@ END $r->print(""); # -------------------------------------------------------------- end the tables - $r->print("
NameTitleSize (bytes) ". + "Last accessedAuthor(s)Last modifiedKeywordsAuthor(s)LanguageKeywords
Language
"); - $r->print("
"); + $r->print(''); + $r->print(''); # --------------------------------------------------- end the output and return - $r->print("\n"); + $r->print(''."\n"); untie(%hash); } else { $r->print('Unable to tie hash to db '. @@ -525,7 +528,7 @@ sub scanDir { my ($strip,$dom,$foo,$testdir,$foo)=split(/\&/,$line,5); next if $strip =~ /.*\.meta$/; my (@fileparts) = split(/\./,$strip); - if ($hash{'display_attrs_6'} != 1) { + if ($hash{'display_attrs_7'} != 1) { if (scalar(@fileparts) >= 3) { my $fext = pop @fileparts; my $ov = pop @fileparts; @@ -534,15 +537,15 @@ sub scanDir { } } - if ($dom eq "domain") { - $compuri = join('',$strip,"/"); # dom list has /res/ + if ($dom eq 'domain') { + $compuri = join('',$strip,'/'); # dom list has /res/ $curdir = $compuri; } else { # user, dir & file have name only, i.e., w/o path - $compuri = join('',$startdir,$strip,"/"); + $compuri = join('',$startdir,$strip,'/'); $curdir = $startdir; } - my $diropen = "closed"; + my $diropen = 'closed'; if (($dirptr&$testdir) or ($dom =~ /^(domain|user)$/)) { while (my ($key,$val)= each %dupdirs) { if ($key eq $compuri and $val eq "open") { @@ -552,7 +555,7 @@ sub scanDir { } } &display_line($r,$diropen,$line,$indent,$curdir,$hashref,@list); - &scanDir ($r,$compuri,$indent) if $diropen eq "opened"; + &scanDir ($r,$compuri,$indent) if $diropen eq 'opened'; } $indent--; } @@ -561,10 +564,9 @@ sub scanDir { sub get_list { my ($r,$uri)=@_; my @list; - my $luri = $uri; - $luri =~ s/\//_/g; + (my $luri = $uri) =~ s/\//_/g; - if ($ENV{'form.attrs'} eq "Refresh") { + if ($ENV{'form.attrs'} eq 'Refresh') { foreach (keys %hash) { delete $hash{$_} if ($_ =~ /^dirlist_files_/); } @@ -614,8 +616,8 @@ sub match_ext { chomp $line; $line =~ s/^\/home\/httpd\/html//; my @unpackline = split (/\&/,$line); - next if ($unpackline[0] eq "."); - next if ($unpackline[0] eq ".."); + next if ($unpackline[0] eq '.'); + next if ($unpackline[0] eq '..'); my @filecom = split (/\./,$unpackline[0]); my $fext = pop(@filecom); my $fnptr = $unpackline[3]&$dirptr; @@ -637,28 +639,28 @@ sub display_line { my (@pathfn, $fndir, $fnptr); my $dirptr=16384; my $fileclr="#ffffe6"; - my $iconpath= $r->dir_config('lonIconsURL') . "/"; + my $iconpath= $r->dir_config('lonIconsURL') . '/'; my @filecom = split (/\&/,$line); my @pathcom = split (/\//,$filecom[0]); my $listname = $pathcom[scalar(@pathcom)-1]; my $fnptr = $filecom[3]&$dirptr; my $msg = 'View '.$filecom[0].' resources'; - $msg = 'Close '.$filecom[0].' directory' if $diropen eq "opened"; + $msg = 'Close '.$filecom[0].' directory' if $diropen eq 'opened'; - my $tabtag=""; + my $tabtag=''; my $i=0; - while ($i<=5) { - $tabtag=join('',$tabtag," ") + while ($i<=6) { + $tabtag=join('',$tabtag," ") if $hash{'display_attrs_'.$i} == 1; $i++; } # display uplink arrow - if ($filecom[1] eq "viewOneUp") { - $r->print("$extrafield"); - $r->print("\n"); + if ($filecom[1] eq 'viewOneUp') { + $r->print("$extrafield"); + $r->print("\n"); $r->print ('
print (''."\n") if ($ENV{'form.dirPointer'} eq "on"); - $r->print("$extrafield"); - $r->print(""); + $r->print("$extrafield"); + $r->print(""); &begin_form ($r,$filecom[0].'/'); my $anchor = $filecom[0].'/'; $anchor =~ s/\///g; @@ -698,9 +700,9 @@ sub display_line { # display user directory } - if ($filecom[1] eq "user") { - $r->print("$extrafield"); - $r->print("\n"); + if ($filecom[1] eq 'user') { + $r->print("$extrafield"); + $r->print("\n"); my $curdir = $startdir.$filecom[0].'/'; my $anchor = $curdir; $anchor =~ s/\///g; @@ -720,7 +722,7 @@ sub display_line { } # display file - if ($fnptr == 0 and $filecom[3] ne "") { + if ($fnptr == 0 and $filecom[3] ne '') { my @file_ext = split (/\./,$listname); my $curfext = $file_ext[-1]; if (@Omit) { @@ -739,7 +741,7 @@ sub display_line { (!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn'); # my $filelink = $startdir.$filecom[0]; - $r->print(""); + $r->print(""); my $metafile = grep /^$filecom[0]\.meta\&/, @list; my $title; if ($ENV{'form.catalogmode'} eq 'interactive') { @@ -753,7 +755,7 @@ sub display_line { $titleesc,"','",$filelink,"')\">"); $r->print("". "\n"); - $r->print(""); + $r->print(""); } elsif ($ENV{'form.catalogmode'} eq 'groupimport') { $title=$listname; @@ -772,7 +774,7 @@ sub display_line { $r->print("\n"); $r->print("
\n"); - $r->print(""); + $r->print(""); $hash{"pre_${fnum}_link"}=$filelink; $hash{"pre_${fnum}_title"}=$titleesc; $fnum++; @@ -804,36 +806,40 @@ sub display_line { "TARGET=_self>metadata) ") if ($metafile == 1); $r->print("\n"); - $r->print(" ", + if ($hash{'display_attrs_0'} == 1) { + my $title = &Apache::lonnet::metadata($filelink,'title') + if ($metafile == 1); + $r->print(' '.($title eq '' ? ' ' : $title). + ' '."\n"); + } + $r->print(' ', $filecom[8]," \n") - if $hash{'display_attrs_0'} == 1; - $r->print(" ". - (localtime($filecom[9]))." \n") if $hash{'display_attrs_1'} == 1; - $r->print(" ". - (localtime($filecom[10]))." \n") + $r->print(' '. + (localtime($filecom[9]))." \n") if $hash{'display_attrs_2'} == 1; + $r->print(' '. + (localtime($filecom[10]))." \n") + if $hash{'display_attrs_3'} == 1; - if ($hash{'display_attrs_3'} == 1) { + if ($hash{'display_attrs_4'} == 1) { my $author = &Apache::lonnet::metadata($filelink,'author') if ($metafile == 1); - $author = ' ' if (!$author); - $r->print(" ".$author. + $r->print(' '.($author eq '' ? ' ' : $author). " \n"); } - if ($hash{'display_attrs_4'} == 1) { + if ($hash{'display_attrs_5'} == 1) { my $keywords = &Apache::lonnet::metadata($filelink,'keywords') if ($metafile == 1); - $keywords = ' ' if (!$keywords); - $r->print(" ".$keywords. + # $keywords = ' ' if (!$keywords); + $r->print(' '.($keywords eq '' ? ' ' : $keywords). " \n"); } - if ($hash{'display_attrs_5'} == 1) { + if ($hash{'display_attrs_6'} == 1) { my $lang = &Apache::lonnet::metadata($filelink,'language') if ($metafile == 1); $lang = &Apache::loncommon::languagedescription($lang); - $lang = ' ' if (!$lang); - $r->print(" ".$lang. + $r->print(' '.($lang eq '' ? ' ' : $lang). " \n"); } $r->print("\n"); @@ -846,7 +852,7 @@ sub display_line { my $curdir = $startdir.$filecom[0].'/'; my $anchor = $curdir; $anchor =~ s/\///g; - $r->print("$extrafield"); + $r->print("$extrafield"); &begin_form ($r,$curdir); my $indentm1 = $indent-1; if ($indentm1 < 11 and $indentm1 > 0) {