--- loncom/interface/lonindexer.pm 2004/02/05 03:42:52 1.90 +++ loncom/interface/lonindexer.pm 2004/03/29 21:18:00 1.96 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.90 2004/02/05 03:42:52 taceyjo1 Exp $ +# $Id: lonindexer.pm,v 1.96 2004/03/29 21:18:00 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'); @@ -568,10 +569,11 @@ sub scanDir { foreach my $line (@list) { return if ($c->aborted()); #This is a kludge, sorry aboot this - my ($strip,$dom,undef,$testdir,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$obs)=split(/\&/,$line,15); + 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; @@ -590,7 +592,7 @@ sub scanDir { $curdir = $startdir; } my $diropen = 'closed'; - if (($dirptr&$testdir) or ($dom =~ /^(domain|user)$/)) { + if (($dirptr&$testdir) or ($dom =~ /^(domain|user)$/) or ($compuri=~/\.(sequence|page)\/$/)) { while (my ($key,$val)= each %dupdirs) { if ($key eq $compuri and $val eq "open") { $diropen = "opened"; @@ -618,12 +620,16 @@ 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); } - @list=&match_ext($r,@list); - return @list; + return @list=&match_ext($r,@list); } sub initdebug { @@ -665,7 +671,7 @@ sub match_ext { next if ($unpackline[0] eq '..'); my @filecom = split (/\./,$unpackline[0]); my $fext = pop(@filecom); - my $fnptr = $unpackline[3]&$dirptr; + my $fnptr = ($unpackline[3]&$dirptr) || ($fext=~/\.(page|sequence)$/); if ($fnptr == 0 and $unpackline[3] ne "") { my $embstyle = &Apache::loncommon::fileembstyle($fext); push @trimlist,$line if (defined($embstyle) && @@ -722,9 +728,8 @@ 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') { @@ -809,8 +814,7 @@ 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); @@ -832,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"); @@ -848,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 ");