--- loncom/interface/lonindexer.pm 2004/05/18 15:53:58 1.108
+++ loncom/interface/lonindexer.pm 2004/06/17 01:44:34 1.112
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Directory Indexer
#
-# $Id: lonindexer.pm,v 1.108 2004/05/18 15:53:58 albertel Exp $
+# $Id: lonindexer.pm,v 1.112 2004/06/17 01:44:34 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -52,12 +52,14 @@ use Apache::Constants qw(:common);
use Apache::lonmeta;
use Apache::File;
use Apache::lonlocal;
+use Apache::lonsource();
use GDBM_File;
# ---------------------------------------- variables used throughout the module
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
# ----- Values which are set by the handler subroutine and are accessible to
# ----- other methods.
@@ -406,7 +408,7 @@ $r->print(&Apache::loncommon::bodytag('B
# ---------------------------------- get state of file attributes to be showing
if ($ENV{'form.attrs'}) {
- for (my $i=0; $i<=9; $i++) {
+ for (my $i=0; $i<=11; $i++) {
delete $hash{'display_attrs_'.$i};
if ($ENV{'form.attr'.$i} == 1) {
$attrchk[$i] = 'checked';
@@ -414,7 +416,7 @@ $r->print(&Apache::loncommon::bodytag('B
}
}
} else {
- for (my $i=0; $i<=9; $i++) {
+ for (my $i=0; $i<=11; $i++) {
$attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1;
}
}
@@ -431,7 +433,9 @@ $r->print(&Apache::loncommon::bodytag('B
'au' => 'Author',
'kw' => 'Keywords',
'ln' => 'Language',
+ 'sa' => 'Source Available',
'sr' => 'Show resource',
+ 'li' => 'Linked/Related Resources',
'av' => 'All versions',
'ud' => 'Update Display'
);
@@ -446,13 +450,14 @@ $r->print(&Apache::loncommon::bodytag('B
$lt{'la'} |
$lt{'lm'} |
$lt{'st'} |
+ $lt{'sa'} |
$lt{'au'} |
$lt{'kw'} |
$lt{'ln'} |
$lt{'sr'} |
$lt{'av'} |
- |
+ $lt{'li'} |
@@ -511,6 +516,10 @@ END
$r->print("".&mt("Usage Statistics")." (".
&mt("Courses/Network Hits").") | \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('');
# ----------------- read in what directories have previously been set to "open"
@@ -665,10 +674,20 @@ 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));
+ &Apache::lonnet::logthis('Found: '.$uri." : ".join(',',keys %dynhash));
+ }
+}
+
sub initdebug {
return <
@@ -749,12 +768,11 @@ sub display_line {
my $tabtag='';
my $i=0;
- while ($i<=8) {
+ while ($i<=11) {
$tabtag=join('',$tabtag," | ")
if $hash{'display_attrs_'.$i} == 1;
$i++;
}
-
my $valign = ($hash{'display_attrs_7'} == 1 ? 'top' : 'bottom');
# display uplink arrow
@@ -786,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') {
@@ -960,6 +978,8 @@ sub display_line {
$r->print(' '.($keywords eq '' ? ' ' : $keywords).
" | \n");
}
+#'
+
if ($hash{'display_attrs_6'} == 1) {
my $lang = &Apache::lonnet::metadata($filelink,'language');
$lang = &Apache::loncommon::languagedescription($lang);
@@ -995,14 +1015,39 @@ 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');
+ 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("$filelink");
+ if ($dynhash{$filelink}->{'goto_list'}) {
+ $r->print(&mt('Number of students: ').
+ $dynhash{$filelink}->{'goto_list'}.' ');
+ }
+ if ($dynhash{$filelink}->{'comefrom_list'}) {
+ $r->print(&mt('Number of students: ').
+ $dynhash{$filelink}->{'comefrom_list'}.' ');
+ }
+ $r->print(" | \n");
+ }
$r->print("\n");
}
@@ -1079,6 +1124,12 @@ sub display_line {
if ($hash{'display_attrs_8'} == 1) {
$r->print(' | ');
}
+ if ($hash{'display_attrs_10'} == 1) {
+ $r->print(' | ');
+ }
+ if ($hash{'display_attrs_11'} == 1) {
+ $r->print(' | ');
+ }
$r->print('');
}