--- loncom/interface/lonindexer.pm 2004/01/26 19:55:44 1.87 +++ loncom/interface/lonindexer.pm 2004/03/28 21:01:06 1.95 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.87 2004/01/26 19:55:44 www Exp $ +# $Id: lonindexer.pm,v 1.95 2004/03/28 21:01:06 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -47,6 +47,7 @@ use strict; use Apache::lonnet(); use Apache::loncommon(); use Apache::lonhtmlcommon(); +use Apache::lonsequence(); use Apache::Constants qw(:common); use Apache::lonmeta; use Apache::File; @@ -164,7 +165,7 @@ END # selection is made. # $element is the name of the element in $formname which receives # the URL. - # &Apache::lonxml::debug('Checking mode, form, element'); + #&Apache::lonxml::debug('Checking mode, form, element'); &setvalues(\%hash,'form.mode' ,\%ENV,'form.mode' ); &setvalues(\%hash,'form.form' ,\%ENV,'form.form' ); &setvalues(\%hash,'form.element' ,\%ENV,'form.element'); @@ -187,8 +188,7 @@ END $element = $ENV{'form.element'}; $titleelement = $ENV{'form.titleelement'}; } - &Apache::lonxml::debug("mode=$mode form=$form element=$element - titleelement=$titleelement"); + #&Apache::lonxml::debug("mode=$mode form=$form element=$element titleelement=$titleelement"); # ------ set catalogmodefunctions to have extra needed javascript functionality my $catalogmodefunctions=''; if ($ENV{'form.catalogmode'} eq 'interactive' or @@ -511,9 +511,12 @@ END my $indent = 0; $uri = $uri.'/' if $uri !~ /.*\/$/; - - $hash{'top.level'} = $uri; - $toplevel = $uri; + if ($ENV{'form.dirPointer'} ne 'on') { + $hash{'top.level'} = $uri; + $toplevel = $uri; + } else { + $toplevel = $hash{'top.level'}; + } # -------------------------------- if not at top level, provide an uplink arrow if ($toplevel ne '/res/'){ @@ -559,16 +562,18 @@ sub scanDir { my $c = $r->connection(); my ($compuri,$curdir); my $dirptr=16384; + my $obs; $indent++; - my %dupdirs = %dirs; my @list=&get_list($r,$startdir); foreach my $line (@list) { return if ($c->aborted()); - my ($strip,$dom,undef,$testdir,undef)=split(/\&/,$line,5); - next if $strip =~ /.*\.meta$/; + #This is a kludge, sorry aboot this + my ($strip,$dom,undef,$testdir,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); + next if($strip =~ /.*\.meta$/ | $obs eq '1'); my (@fileparts) = split(/\./,$strip); if ($hash{'display_attrs_9'} != 1) { +# if not all versions to be shown if (scalar(@fileparts) >= 3) { my $fext = pop @fileparts; my $ov = pop @fileparts; @@ -587,7 +592,7 @@ sub scanDir { $curdir = $startdir; } my $diropen = 'closed'; - if (($dirptr&$testdir) or ($dom =~ /^(domain|user)$/)) { + if (($dirptr&$testdir) or ($dom =~ /^(domain|user)$/) || ($compuri=~/\.(sequence|page)$/)) { while (my ($key,$val)= each %dupdirs) { if ($key eq $compuri and $val eq "open") { $diropen = "opened"; @@ -615,7 +620,12 @@ sub get_list { if ($hash{'dirlist_files_'.$luri}) { @list = split(/\n/,$hash{'dirlist_files_'.$luri}); + } elsif ($uri=~/\.(page|sequence)$/) { +# is a page or a sequence + @list= &Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$uri)); + $hash{'dirlist_files_'.$luri} = join("\n",@list); } else { +# is really a directory @list = &Apache::lonnet::dirlist($uri); $hash{'dirlist_files_'.$luri} = join("\n",@list); } @@ -691,7 +701,6 @@ sub display_line { my $tabtag=''; my $i=0; - while ($i<=8) { $tabtag=join('',$tabtag," ") if $hash{'display_attrs_'.$i} == 1; @@ -719,12 +728,13 @@ sub display_line { $r->print(&mt("Up")." $tabtag\n"); return OK; } -# Do we have permission to look at this? - - return OK if (!&Apache::lonnet::allowed('bre',$startdir.$filecom[0])); +# Do we have permission to look at this? + if($filecom[15] ne '1') { return OK if (!&Apache::lonnet::allowed('bre',$startdir.$filecom[0])); } # display domain if ($filecom[1] eq 'domain') { + $r->print (''."\n") + if ($ENV{'form.dirPointer'} eq "on"); $r->print("$extrafield"); $r->print(""); &begin_form ($r,$filecom[0]); @@ -777,7 +787,6 @@ sub display_line { # display file if ($fnptr == 0 and $filecom[3] ne '') { my $filelink = $startdir.$filecom[0]; - next if &Apache::lonnet::metadata($filelink,'obsolete'); my @file_ext = split (/\./,$listname); my $curfext = $file_ext[-1]; if (@Omit) { @@ -805,11 +814,10 @@ sub display_line { $r->print("". "\n"); $r->print(""); - } - elsif ($ENV{'form.catalogmode'} eq 'groupimport') { + } elsif ($ENV{'form.catalogmode'} eq 'groupimport') { $title=$listname; - $title = &Apache::lonnet::metadata($filelink,'title') - if ($metafile == 1); + #$title = &Apache::lonnet::metadata($filelink,'title') + #if ($metafile == 1); $title=$listname unless $title; my $titleesc=&HTML::Entities::encode($title); $r->print("
\n"); @@ -828,7 +836,15 @@ sub display_line { $hash{"pre_${fnum}_title"}=$titleesc; $fnum++; } - +# Form to open or close sequences + if ($filelink=~/\.(page|sequence)$/) { + my $curdir = $startdir.$filecom[0].'/'; + my $anchor = $curdir; + $anchor =~ s/\///g; + &begin_form($r,$curdir); + $indent--; + } +# General indentation if ($indent > 0 and $indent < 11) { $r->print("\n"); @@ -844,8 +860,23 @@ sub display_line { $r->print("\n") if $rem > 0; } - +# Sequence open/close icon + if ($filelink=~/\.(page|sequence)$/) { + my $curdir = $startdir.$filecom[0].'/'; + my $anchor = $curdir; + $anchor =~ s/\///g; + $r->print (''); + $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0">'. + "\n"); + } +# Filetype icons $r->print("\n"); +# Close form to open/close sequence + if ($filelink=~/\.(page|sequence)$/) { + $r->print(''); + } $r->print ("
$listname "); @@ -895,8 +926,20 @@ sub display_line { my $output=''; my $embstyle=&Apache::loncommon::fileembstyle($curfext); if ($embstyle eq 'ssi') { - $output=&Apache::lonnet::ssi_body($filelink); - $output=''.$output.''; + my $cache=$Apache::lonnet::perlvar{'lonDocRoot'}.$filelink. + '.tmp'; + if ((!$ENV{'form.updatedisplay'}) && + (-e $cache)) { + open(FH,$cache); + $output=join("\n",); + close(FH); + } else { + $output=&Apache::lonnet::ssi_body($filelink); + open(FH,">$cache"); + print FH $output; + close(FH); + } + $output=''.$output.''; } elsif ($embstyle eq 'img') { $output=''; } elsif ($filelink=~/^\/res\/(\w+)\/(\w+)\//) { @@ -1009,6 +1052,7 @@ sub begin_form { 'enctype="application/x-www-form-urlencoded">'."\n"); $r->print (''. "\n"); + $r->print (''."\n"); $dnum++; }