--- loncom/interface/lonindexer.pm 2004/06/17 18:22:13 1.113 +++ loncom/interface/lonindexer.pm 2004/09/07 20:38:20 1.123 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.113 2004/06/17 18:22:13 www Exp $ +# $Id: lonindexer.pm,v 1.123 2004/09/07 20:38:20 matthew 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; @@ -177,7 +179,7 @@ END ' border="0" />'; $colspan=" colspan='2' "; my $cl=&mt('Close'); - my $gi=&mt('Group Import'); + my $gi=&mt('Import'); $closebutton=< END @@ -440,26 +442,30 @@ $r->print(&Apache::loncommon::bodytag('B 'av' => 'All versions', 'ud' => 'Update Display' ); - my $Displayfileattributes=&mt('Display file attributes'); $r->print(< -$Displayfileattributes
- + $lt{'av'} +
+ + + + + + - - - - - - - + + + -
$lt{'ti'} $lt{'au'} $lt{'kw'} $lt{'ln'}
$lt{'si'} $lt{'la'} $lt{'lm'} $lt{'st'} $lt{'sa'}
$lt{'au'} $lt{'kw'} $lt{'ln'} $lt{'sr'} $lt{'av'}
$lt{'st'} $lt{'li'}
+ $lt{'sr'} +  + + @@ -512,15 +518,15 @@ END if ($hash{'display_attrs_5'} == 1); $r->print("".&mt("Language")."\n") if ($hash{'display_attrs_6'} == 1); - $r->print("".&mt("Resource")."\n") - if ($hash{'display_attrs_7'} == 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); $r->print("".&mt("Linked/Related Resources")."\n") if ($hash{'display_attrs_11'} == 1); + $r->print("".&mt("Resource")."\n") + if ($hash{'display_attrs_7'} == 1); $r->print(''); # ----------------- read in what directories have previously been set to "open" @@ -656,10 +662,12 @@ 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)) { @list = split(/\n/,$hash{'dirlist_files_'.$luri}); } elsif ($uri=~/\.(page|sequence)\/$/) { # is a page or a sequence @@ -675,7 +683,7 @@ sub get_list { # is really a directory @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); } @@ -683,8 +691,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; } } @@ -874,15 +895,8 @@ sub display_line { } # Set the icon for the file my $iconname = &Apache::loncommon::icon($listname); - $r->print(""); + $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(""); @@ -986,7 +1000,47 @@ sub display_line { $r->print(' '.($lang eq '' ? ' ' : $lang). " \n"); } + if ($hash{'display_attrs_8'} == 1) { +# statistics + &dynmetaread($filelink); + $r->print(""); + &dynmetaprint($r,$filelink,'count'); + &dynmetaprint($r,$filelink,'course'); + &dynmetaprint($r,$filelink,'stdno'); + &dynmetaprint($r,$filelink,'avetries'); + &dynmetaprint($r,$filelink,'difficulty'); + &dynmetaprint($r,$filelink,'disc'); + &dynmetaprint($r,$filelink,'clear'); + &dynmetaprint($r,$filelink,'technical'); + &dynmetaprint($r,$filelink,'correct'); + &dynmetaprint($r,$filelink,'helpful'); + &dynmetaprint($r,$filelink,'depth'); + $r->print(" \n"); + + } + if ($hash{'display_attrs_10'} == 1) { + my $source = &Apache::lonnet::metadata($filelink,'sourceavail'); + if($source eq 'open') { + my $sourcelink = &Apache::lonsource::make_link($filelink,$listname); + $r->print(''."Yes "."\n"); + } else { #A cuddled else. :P + $r->print(" \n"); + } + } + if ($hash{'display_attrs_11'} == 1) { +# links + &dynmetaread($filelink); + $r->print(''); + &dynmetaprint($r,$filelink,'goto_list'); + &dynmetaprint($r,$filelink,'comefrom_list'); + &dynmetaprint($r,$filelink,'sequsage_list'); + &dynmetaprint($r,$filelink,'dependencies'); + $r->print(''); + } if ($hash{'display_attrs_7'} == 1) { +# Show resource my $output=''; my $embstyle=&Apache::loncommon::fileembstyle($curfext); if ($embstyle eq 'ssi') { @@ -1014,43 +1068,6 @@ sub display_line { $r->print(' '.($output eq '' ? ' ':$output). " \n"); } - if ($hash{'display_attrs_8'} == 1) { -# statistics - $r->print(""); - if ($dynhash{$filelink}->{'stdno'}) { - $r->print(&mt('Number of students: '). - $dynhash{$filelink}->{'stdno'}.'
'); - } - $r->print(" \n"); - - } - if ($hash{'display_attrs_10'} == 1) { - my $source = &Apache::lonnet::metadata($filelink,'sourceavail'); - if($source eq 'open') { - my $sourcelink = &Apache::lonsource::make_link($filelink); - $r->print(''."Yes "."\n"); - } else { #A cuddled else. :P - $r->print(" \n"); - } - } - if ($hash{'display_attrs_11'} == 1) { -# links - $r->print(''); - &dynmetaprint($r,$filelink,'goto_list'); - &dynmetaprint($r,$filelink,'comefrom_list'); - &dynmetaprint($r,$filelink,'sequsage_list'); - my $dependencies=&Apache::lonnet::metadata($filelink,'dependencies'); - if ($dependencies=~/\w/) { - $r->print(&mt('Links to:'). - &Apache::lonmeta::prettyprint('linkto_list',&Apache::lonnet::metadata($filelink,'dependencies'), - (($ENV{'form.catalogmode'} ne 'groupimport')?'preview':''), - '', - (($ENV{'form.catalogmode'} eq 'groupimport')?'document.forms.fileattr':''),1)); - } - $r->print(''); - } $r->print("\n"); } @@ -1121,18 +1138,18 @@ sub display_line { $r->print(' '.($lang eq '' ? ' ' : $lang). " \n"); } - if ($hash{'display_attrs_7'} == 1) { - $r->print(' '); - } if ($hash{'display_attrs_8'} == 1) { $r->print(' '); } - if ($hash{'display_attrs_10'} == 1) { + if ($hash{'display_attrs_10'} == 1) { $r->print(' '); } if ($hash{'display_attrs_11'} == 1) { $r->print(' '); } + if ($hash{'display_attrs_7'} == 1) { + $r->print(' '); + } $r->print(''); } @@ -1141,7 +1158,7 @@ sub display_line { sub dynmetaprint { my ($r,$filelink,$item)=@_; if ($dynhash{$filelink}->{$item}) { - $r->print($fieldnames{$item}.': '. + $r->print("\n
".$fieldnames{$item}.': '. &Apache::lonmeta::prettyprint($item, $dynhash{$filelink}->{$item}, (($ENV{'form.catalogmode'} ne 'groupimport')?'preview':''),