--- loncom/interface/lonindexer.pm 2004/06/12 04:44:31 1.110 +++ loncom/interface/lonindexer.pm 2004/06/17 18:22:13 1.113 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.110 2004/06/12 04:44:31 albertel Exp $ +# $Id: lonindexer.pm,v 1.113 2004/06/17 18:22:13 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -59,7 +59,8 @@ use GDBM_File; my %hash; # global user-specific gdbm file 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 %fieldnames; # Metadata fieldnames # ----- Values which are set by the handler subroutine and are accessible to # ----- other methods. my $extrafield; # default extra table cell @@ -86,6 +87,7 @@ sub handler { # these global to this package? It is just so wrong....) undef (@Only); undef (@Omit); + %fieldnames=&Apache::lonmeta::fieldnames(); # ------------------------------------- read in machine configuration variables my $iconpath= $r->dir_config('lonIconsURL') . "/"; @@ -135,7 +137,7 @@ sub handler { my $extra=''; if (defined($ENV{'form.titleelement'})) { my $verify_title = &Apache::lonnet::gettitle($ENV{'form.acts'}); - &Apache::lonnet::logthis("Hrrm $ENV{'form.acts'} -- $verify_title"); +# &Apache::lonnet::logthis("Hrrm $ENV{'form.acts'} -- $verify_title"); $verify_title=~s/'/\\'/g; $extra='window.opener.document.forms["'.$ENV{'form.form'}.'"].elements["'.$ENV{'form.titleelement'}.'"].value=\''.$verify_title.'\';'; } @@ -407,7 +409,7 @@ $r->print(&Apache::loncommon::bodytag('B # ---------------------------------- get state of file attributes to be showing if ($ENV{'form.attrs'}) { - for (my $i=0; $i<=10; $i++) { + for (my $i=0; $i<=11; $i++) { delete $hash{'display_attrs_'.$i}; if ($ENV{'form.attr'.$i} == 1) { $attrchk[$i] = 'checked'; @@ -415,7 +417,7 @@ $r->print(&Apache::loncommon::bodytag('B } } } else { - for (my $i=0; $i<=10; $i++) { + for (my $i=0; $i<=11; $i++) { $attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1; } } @@ -434,6 +436,7 @@ $r->print(&Apache::loncommon::bodytag('B 'ln' => 'Language', 'sa' => 'Source Available', 'sr' => 'Show resource', + 'li' => 'Linked/Related Resources', 'av' => 'All versions', 'ud' => 'Update Display' ); @@ -455,7 +458,7 @@ $r->print(&Apache::loncommon::bodytag('B $lt{'ln'} $lt{'sr'} $lt{'av'} -  + $lt{'li'} @@ -516,6 +519,8 @@ END 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(''); # ----------------- read in what directories have previously been set to "open" @@ -670,10 +675,19 @@ sub get_list { # is really a directory @list = &Apache::lonnet::dirlist($uri); $hash{'dirlist_files_'.$luri} = join("\n",@list); + &dynmetaread($uri); } return @list=&match_ext($r,@list); } +sub dynmetaread { + my $uri=shift; + if (($hash{'display_attrs_8'}==1) || ($hash{'display_attrs_11'}==1)) { + %dynhash= + (%dynhash,&Apache::lonmeta::get_dynamic_metadata_from_sql($uri)); + } +} + sub initdebug { return < @@ -790,7 +804,7 @@ sub display_line { if($filecom[15] ne '1') { return OK if (!&Apache::lonnet::allowed('bre',$pathprefix.$filecom[0])); } # make absolute links appear on different background - if ($absolute) { $fileclr='#aaaa88'; } + if ($absolute) { $fileclr='#ccdd99'; } # display domain if ($filecom[1] eq 'domain') { @@ -1001,12 +1015,14 @@ sub display_line { " \n"); } if ($hash{'display_attrs_8'} == 1) { - my (%stat) = &Apache::lonmeta::dynamicmeta($filelink); - my $stat = (exists($stat{'course'}) ? $stat{'course'} : ''). - ((exists($stat{'course'}) || exists($stat{'count'})) ? '/' : ''). - (exists($stat{'count'}) ? $stat{'count'} : ''); - $r->print(' '.($stat eq '' ? ' ' : $stat). - ' '."\n"); +# 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'); @@ -1016,9 +1032,25 @@ sub display_line { "', 'previewsource', '700', '700', 'no', 'yes','yes')\";". " TARGET=_self>Yes "."\n"); } else { #A cuddled else. :P - $r->print(''."\n"); + $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"); } @@ -1098,11 +1130,26 @@ sub display_line { if ($hash{'display_attrs_10'} == 1) { $r->print(' '); } + if ($hash{'display_attrs_11'} == 1) { + $r->print(' '); + } $r->print(''); } } +sub dynmetaprint { + my ($r,$filelink,$item)=@_; + if ($dynhash{$filelink}->{$item}) { + $r->print($fieldnames{$item}.': '. + &Apache::lonmeta::prettyprint($item, + $dynhash{$filelink}->{$item}, + (($ENV{'form.catalogmode'} ne 'groupimport')?'preview':''), + '', + (($ENV{'form.catalogmode'} eq 'groupimport')?'document.forms.fileattr':''),1)); + } +} + # ------------------- prints the beginning of a form for directory or file link sub begin_form { my ($r,$uri) = @_;