--- loncom/interface/lonindexer.pm 2004/06/18 01:09:24 1.115 +++ loncom/interface/lonindexer.pm 2004/07/26 22:38:16 1.121 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.115 2004/06/18 01:09:24 www Exp $ +# $Id: lonindexer.pm,v 1.121 2004/07/26 22:38:16 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -60,6 +60,7 @@ my %hash; # global user-specific gdbm fi my %dirs; # keys are directories, values are the open/close status my %language; # has the reference information present in language.tab my %dynhash; # hash of hashes for dynamic metadata +my %dynread; # hash of directories already read for dynamic metadata my %fieldnames; # Metadata fieldnames # ----- Values which are set by the handler subroutine and are accessible to # ----- other methods. @@ -135,7 +136,8 @@ sub handler { if ($ENV{'form.launch'} eq '2') { $r->content_type('text/html'); my $extra=''; - if (defined($ENV{'form.titleelement'})) { + if (defined($ENV{'form.titleelement'}) && + $ENV{'form.titleelement'} ne '') { my $verify_title = &Apache::lonnet::gettitle($ENV{'form.acts'}); # &Apache::lonnet::logthis("Hrrm $ENV{'form.acts'} -- $verify_title"); $verify_title=~s/'/\\'/g; @@ -517,7 +519,7 @@ END $r->print("".&mt("Language")."\n") if ($hash{'display_attrs_6'} == 1); $r->print("".&mt("Usage Statistics")."
(". - &mt("Courses/Network Hits").")
\n") + &mt("Courses/Network Hits").") ".&mt('updated periodically')."\n") if ($hash{'display_attrs_8'} == 1); $r->print("".&mt("Source Available")."\n") if ($hash{'display_attrs_10'} == 1); @@ -660,10 +662,13 @@ sub get_list { if ($ENV{'form.updatedisplay'}) { foreach (keys %hash) { delete $hash{$_} if ($_ =~ /^dirlist_files_/); + delete $hash{$_} if ($_ =~ /^dirlist_timestamp_files_/); } } - if ($hash{'dirlist_files_'.$luri}) { + if (defined($hash{'dirlist_files_'.$luri}) && + $hash{'dirlist_timestamp_files_'.$luri}+600 > (time)) { + &Apache::lonnet::logthis("using old n:".time." s:".$hash{'dirlist_timestamp_files_'.$luri}); @list = split(/\n/,$hash{'dirlist_files_'.$luri}); } elsif ($uri=~/\.(page|sequence)\/$/) { # is a page or a sequence @@ -677,9 +682,10 @@ sub get_list { $hash{'dirlist_files_'.$luri} = join("\n",@list); } else { # is really a directory + &Apache::lonnet::logthis("getting fresh n:".time." s:".$hash{'dirlist_timestamp_files_'.$luri}); @list = &Apache::lonnet::dirlist($uri); $hash{'dirlist_files_'.$luri} = join("\n",@list); - &dynmetaread($uri); + $hash{'dirlist_timestamp_files_'.$luri} = time; } return @list=&match_ext($r,@list); } @@ -687,8 +693,21 @@ sub get_list { sub dynmetaread { my $uri=shift; if (($hash{'display_attrs_8'}==1) || ($hash{'display_attrs_11'}==1)) { +# We don't want the filename + $uri=~s/\/[^\/]+$//; +# Did we already see this? + my $builddir=$uri; + while ($builddir) { + if ($dynread{$builddir}) { + return 0; + } + $builddir=~s/\/[^\/]+$//; + } +# Actually get the data %dynhash= (%dynhash,&Apache::lonmeta::get_dynamic_metadata_from_sql($uri)); +# Remember that we got it + $dynread{$uri}=1; } } @@ -880,13 +899,6 @@ sub display_line { my $iconname = &Apache::loncommon::icon($listname); $r->print(""); - my $metafile = $Apache::lonnet::perlvar{'lonDocRoot'}.$pathprefix. - $filecom[0].'.meta'; - if (-e $metafile) { - $metafile=1; - } else { - $metafile=0; - } if ($ENV{'form.catalogmode'} eq 'interactive') { $r->print(""); @@ -992,6 +1004,7 @@ sub display_line { } if ($hash{'display_attrs_8'} == 1) { # statistics + &dynmetaread($filelink); $r->print(""); &dynmetaprint($r,$filelink,'count'); &dynmetaprint($r,$filelink,'course'); @@ -1010,7 +1023,7 @@ sub display_line { if ($hash{'display_attrs_10'} == 1) { my $source = &Apache::lonnet::metadata($filelink,'sourceavail'); if($source eq 'open') { - my $sourcelink = &Apache::lonsource::make_link($filelink); + my $sourcelink = &Apache::lonsource::make_link($filelink,$listname); $r->print(''."Yes "."\n"); @@ -1020,6 +1033,7 @@ sub display_line { } if ($hash{'display_attrs_11'} == 1) { # links + &dynmetaread($filelink); $r->print(''); &dynmetaprint($r,$filelink,'goto_list'); &dynmetaprint($r,$filelink,'comefrom_list');