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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 11 May 2004 05:19:30 -0000


albertel		Tue May 11 01:19:30 2004 EDT

  Modified files:              
    /loncom/interface	lonindexer.pm 
  Log:
  - this properly handles the metadata avoidance to speed things up
   it now
      1) checks if the metadata file already exists, if it does, it always loads the metadata up for that file
      2) if the user is browsing with a metadata field display turned on (stats/title) it always replicates/loads up the metadata for that file
      3) it always provides the link to the metadata
  
  - this means in the simplest case (no metadata display turned on) (just wandering around)
     no data is replicated, but in all cases where metadata is desired to be shown it is shown and is replicated.
  
  
  
Index: loncom/interface/lonindexer.pm
diff -u loncom/interface/lonindexer.pm:1.103 loncom/interface/lonindexer.pm:1.104
--- loncom/interface/lonindexer.pm:1.103	Mon May 10 04:34:50 2004
+++ loncom/interface/lonindexer.pm	Tue May 11 01:19:30 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Directory Indexer
 #
-# $Id: lonindexer.pm,v 1.103 2004/05/10 08:34:50 taceyjo1 Exp $
+# $Id: lonindexer.pm,v 1.104 2004/05/11 05:19:30 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -841,8 +841,14 @@
 	# Set the icon for the file
 	my $iconname = &Apache::loncommon::icon($listname);
 	$r->print("<tr valign='$valign' bgcolor=$fileclr><td nowrap>");
-	my $metafile = grep /^\Q$filecom[0]\E\.meta\&/, @list;
-#	my $metafile=1;
+	
+	my $metafile = $Apache::lonnet::perlvar{'lonDocRoot'}.$pathprefix.
+	    $filecom[0].'.meta';
+	if (-e $metafile) {
+	    $metafile=1;
+	} else {
+	    $metafile=0;
+	}
 	my $title;
         if ($ENV{'form.catalogmode'} eq 'interactive') {
 	    $title=$listname;
@@ -860,7 +866,7 @@
 	    $title=$listname;
 	    $title = &Apache::lonnet::metadata($filelink,'title')
 		if ($metafile == 1);
-		$title=$listname unless $title;
+	    $title=$listname unless $title;
 	    my $titleesc=&HTML::Entities::encode($title,'<>&"');
 	    $r->print("<form name='form$fnum'>\n");
 	    $r->print("<input type='checkbox' name='filelink"."' ".
@@ -925,12 +931,10 @@
 
 	$r->print (" (<a href=\"javascript:openWindow('".$filelink.
 		   ".meta', 'metadatafile', '500', '550', 'no', 'yes','no')\"; ".
-		   "TARGET=_self>metadata</a>) ") if ($metafile == 1);
-
+		   "TARGET=_self>metadata</a>) ");
 	$r->print("</td>\n");
 	if ($hash{'display_attrs_0'} == 1) {
-	    my $title = &Apache::lonnet::gettitle($filelink,'title')
-		if ($metafile == 1);
+	    my $title = &Apache::lonnet::gettitle($filelink,'title');
 	    $r->print('<td> '.($title eq '' ? '&nbsp;' : $title).
 		      ' </td>'."\n");
 	}
@@ -945,21 +949,18 @@
 	    if $hash{'display_attrs_3'} == 1;
 
 	if ($hash{'display_attrs_4'} == 1) {
-	    my $author = &Apache::lonnet::metadata($filelink,'author')
-		if ($metafile == 1);
+	    my $author = &Apache::lonnet::metadata($filelink,'author');
 	    $r->print('<td> '.($author eq '' ? '&nbsp;' : $author).
 		      " </td>\n");
 	}
 	if ($hash{'display_attrs_5'} == 1) {
-	    my $keywords = &Apache::lonnet::metadata($filelink,'keywords')
-		if ($metafile == 1);
+	    my $keywords = &Apache::lonnet::metadata($filelink,'keywords');
 	    # $keywords = '&nbsp;' if (!$keywords);
 	    $r->print('<td> '.($keywords eq '' ? '&nbsp;' : $keywords).
 		      " </td>\n");
 	}
 	if ($hash{'display_attrs_6'} == 1) {
-	    my $lang = &Apache::lonnet::metadata($filelink,'language')
-		if ($metafile == 1);
+	    my $lang = &Apache::lonnet::metadata($filelink,'language');
 	    $lang = &Apache::loncommon::languagedescription($lang);
 	    $r->print('<td> '.($lang eq '' ? '&nbsp;' : $lang).
 		      " </td>\n");
@@ -993,7 +994,7 @@
 		      " </td>\n");
         }
 	if ($hash{'display_attrs_8'} == 1) {
-	    my (%stat) = &Apache::lonmeta::dynamicmeta($filelink) if ($metafile == 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'} : '');