[LON-CAPA-cvs] cvs: loncom /interface lonindexer.pm

www lon-capa-cvs@mail.lon-capa.org
Tue, 22 Jun 2004 13:27:52 -0000


www		Tue Jun 22 09:27:52 2004 EDT

  Modified files:              
    /loncom/interface	lonindexer.pm 
  Log:
  Also read dynamic metadata for resources inside sequences and pages.
  
  
Index: loncom/interface/lonindexer.pm
diff -u loncom/interface/lonindexer.pm:1.116 loncom/interface/lonindexer.pm:1.117
--- loncom/interface/lonindexer.pm:1.116	Thu Jun 17 21:27:04 2004
+++ loncom/interface/lonindexer.pm	Tue Jun 22 09:27:51 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Directory Indexer
 #
-# $Id: lonindexer.pm,v 1.116 2004/06/18 01:27:04 www Exp $
+# $Id: lonindexer.pm,v 1.117 2004/06/22 13:27:51 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -60,6 +60,7 @@
 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.
@@ -679,7 +680,6 @@
 # is really a directory
 	@list = &Apache::lonnet::dirlist($uri);
 	$hash{'dirlist_files_'.$luri} = join("\n",@list);
-	&dynmetaread($uri);
     }
     return @list=&match_ext($r,@list);
 }
@@ -687,8 +687,21 @@
 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;
     } 
 }
 
@@ -985,6 +998,7 @@
 	}
 	if ($hash{'display_attrs_8'} == 1) {
 # statistics
+	    &dynmetaread($filelink);
 	    $r->print("<td>");
 	    &dynmetaprint($r,$filelink,'count');
 	    &dynmetaprint($r,$filelink,'course');
@@ -1013,6 +1027,7 @@
 	}
 	if ($hash{'display_attrs_11'} == 1) {
 # links
+	   &dynmetaread($filelink);
 	   $r->print('<td>');
 	   &dynmetaprint($r,$filelink,'goto_list');
 	   &dynmetaprint($r,$filelink,'comefrom_list');