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

ng lon-capa-cvs@mail.lon-capa.org
Sat, 29 Jun 2002 19:55:19 -0000


This is a MIME encoded message

--ng1025380519
Content-Type: text/plain

ng		Sat Jun 29 15:55:19 2002 EDT

  Modified files:              
    /loncom/interface	lonindexer.pm 
  Log:
  Add the option to display the title. 
  
  
--ng1025380519
Content-Type: text/plain
Content-Disposition: attachment; filename="ng-20020629155519.txt"

Index: loncom/interface/lonindexer.pm
diff -u loncom/interface/lonindexer.pm:1.44 loncom/interface/lonindexer.pm:1.45
--- loncom/interface/lonindexer.pm:1.44	Thu Jun 20 17:22:20 2002
+++ loncom/interface/lonindexer.pm	Sat Jun 29 15:55:19 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Directory Indexer
 #
-# $Id: lonindexer.pm,v 1.44 2002/06/20 21:22:20 ng Exp $
+# $Id: lonindexer.pm,v 1.45 2002/06/29 19:55:19 ng Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -43,6 +43,7 @@
 # 12/11,12/13 Scott Harrison
 # YEAR=2002
 # 1/17 Scott Harrison
+# 6/29/2002 H. K. Ng
 #
 ###
 
@@ -382,34 +383,34 @@
 '<h2><font color="#339933">The Learning<i>Online</i> Network with CAPA '.
 		  'Network Directory Browser</font></h2>'."\n");
 # ---------------------------------- get state of file attributes to be showing
-	if ($ENV{'form.attrs'} ne "") {
-	    for (my $i=0; $i<=6; $i++) {
+	if ($ENV{'form.attrs'} ne '') {
+	    for (my $i=0; $i<=7; $i++) {
 		delete $hash{'display_attrs_'.$i};
 		if ($ENV{'form.attr'.$i} == 1) {
-		    $attrchk[$i] = "checked";
+		    $attrchk[$i] = 'checked';
 		    $hash{'display_attrs_'.$i} = 1;
 		}
 	    }
 	} else {
-	    for (my $i=0; $i<=6; $i++) {
-		$attrchk[$i] = "checked" if $hash{'display_attrs_'.$i} == 1;
+	    for (my $i=0; $i<=7; $i++) {
+		$attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1;
 	    }
 	}
 # ------------------------------- output state of file attributes to be showing
 	$r->print(<<END);
-<b><font color="#666666">Display file attributes</font></b><br />
 <form method="post" name="fileattr" action="$uri"
  enctype="application/x-www-form-urlencoded">
+<b><font color="#666666">Display file attributes</font></b><br />
 <table border=0><tr>
-<td><input type="checkbox" name="attr0" value="1" $attrchk[0] /> Size</td>
-<td><input type="checkbox" name="attr1" value="1" $attrchk[1] /> Last access</td>
-<td><input type="checkbox" name="attr2" value="1" $attrchk[2] /> Last modified</td>
-<td><input type="checkbox" name="attr6" value="1" $attrchk[6] /> All versions</td>
+<td><input type="checkbox" name="attr0" value="1" $attrchk[0] /> Title</td>
+<td><input type="checkbox" name="attr1" value="1" $attrchk[1] /> Size</td>
+<td><input type="checkbox" name="attr2" value="1" $attrchk[2] /> Last access</td>
+<td><input type="checkbox" name="attr3" value="1" $attrchk[3] /> Last modified</td>
 </tr><tr>
-<td><input type="checkbox" name="attr3" value="1" $attrchk[3] /> Author</td>
-<td><input type="checkbox" name="attr4" value="1" $attrchk[4] /> Keywords</td>
-<td><input type="checkbox" name="attr5" value="1" $attrchk[5] /> Language</td>
-<td>&nbsp;</td>
+<td><input type="checkbox" name="attr4" value="1" $attrchk[4] /> Author</td>
+<td><input type="checkbox" name="attr5" value="1" $attrchk[5] /> Keywords</td>
+<td><input type="checkbox" name="attr6" value="1" $attrchk[6] /> Language</td>
+<td><input type="checkbox" name="attr7" value="1" $attrchk[7] /> All versions</td>
 </tr></table>
 <input type="hidden" name="dirPointer" value="on" />
 <input type="hidden" name="acts" value="" />
@@ -426,21 +427,23 @@
 #        $r->print(&writedebug("Omit:@Omit")) if (@Omit);
 #        $r->print(&writedebug("Only:@Only")) if (@Only);
         $r->print("<table width='100\%' border=0><tr><td bgcolor=#990404>\n");
-	$r->print("<table width='100\%' border=0><tr>\n");
-	$r->print("<td $colspan bgcolor=$titleclr><b>Name</b></td>\n");
-	$r->print("<td bgcolor=$titleclr align=right><b>Size (bytes) ".
-		  "</b></td>\n") if ($hash{'display_attrs_0'} == 1);
-	$r->print("<td bgcolor=$titleclr><b>Last accessed</b></td>\n") 
-	    if ($hash{'display_attrs_1'} == 1);
-	$r->print("<td bgcolor=$titleclr><b>Last modified</b></td>\n")
+	$r->print("<table width='100\%' border=0><tr bgcolor=$titleclr>\n");
+	$r->print("<td $colspan><b>Name</b></td>\n");
+	$r->print("<td><b>Title</b></td>\n") 
+	    if ($hash{'display_attrs_0'} == 1);
+	$r->print("<td align=right><b>Size (bytes) ".
+		  "</b></td>\n") if ($hash{'display_attrs_1'} == 1);
+	$r->print("<td><b>Last accessed</b></td>\n") 
 	    if ($hash{'display_attrs_2'} == 1);
-	$r->print("<td bgcolor=$titleclr><b>Author(s)</b></td>\n")
+	$r->print("<td><b>Last modified</b></td>\n")
 	    if ($hash{'display_attrs_3'} == 1);
-	$r->print("<td bgcolor=$titleclr><b>Keywords</b></td>\n")
+	$r->print("<td><b>Author(s)</b></td>\n")
 	    if ($hash{'display_attrs_4'} == 1);
-	$r->print("<td bgcolor=$titleclr><b>Language</b></td>\n")
+	$r->print("<td><b>Keywords</b></td>\n")
 	    if ($hash{'display_attrs_5'} == 1);
-	$r->print("</tr>");
+	$r->print("<td><b>Language</b></td>\n")
+	    if ($hash{'display_attrs_6'} == 1);
+	$r->print('</tr>');
 
 # ----------------- read in what directories have previously been set to "open"
 	foreach (keys %hash) {
@@ -472,7 +475,7 @@
 	my $indent = 0;
 	$uri = $uri.'/' if $uri !~ /.*\/$/;
 
-	if ($bredir ne "on") {
+	if ($bredir ne 'on') {
 	    $hash{'top.level'} = $uri;
 	    $toplevel = $uri;
 
@@ -481,7 +484,7 @@
 	}
 
 # -------------------------------- if not at top level, provide an uplink arrow
-	if ($toplevel ne "/res/"){
+	if ($toplevel ne '/res/'){
 	    my (@uri_com) = split(/\//,$uri);
 	    pop @uri_com;
 	    my $upone = join('/',@uri_com);
@@ -498,11 +501,11 @@
 	$r->print("<input type='hidden' name='fnum' value='$fnum'></form>");
 
 # -------------------------------------------------------------- end the tables
-	$r->print("</table>");
-	$r->print("</td></tr></table>");
+	$r->print('</table>');
+	$r->print('</td></tr></table>');
 
 # --------------------------------------------------- end the output and return
-	$r->print("</body></html>\n");
+	$r->print('</body></html>'."\n");
 	untie(%hash);
     } else {
 	$r->print('<html><head></head><body>Unable to tie hash to db '.
@@ -525,7 +528,7 @@
 	my ($strip,$dom,$foo,$testdir,$foo)=split(/\&/,$line,5); 
 	next if $strip =~ /.*\.meta$/;
 	my (@fileparts) = split(/\./,$strip);
-	if ($hash{'display_attrs_6'} != 1) {
+	if ($hash{'display_attrs_7'} != 1) {
 	    if (scalar(@fileparts) >= 3) {
 		my $fext = pop @fileparts;
 		my $ov = pop @fileparts;
@@ -534,15 +537,15 @@
 	    }
 	}
 
-	if ($dom eq "domain") {
-	    $compuri = join('',$strip,"/");  # dom list has /res/<domain name>
+	if ($dom eq 'domain') {
+	    $compuri = join('',$strip,'/');  # dom list has /res/<domain name>
 	    $curdir = $compuri;
 	} else {
 	    # user, dir & file have name only, i.e., w/o path
-	    $compuri = join('',$startdir,$strip,"/");
+	    $compuri = join('',$startdir,$strip,'/');
 	    $curdir = $startdir;
 	}
-	my $diropen = "closed";
+	my $diropen = 'closed';
 	if (($dirptr&$testdir) or ($dom =~ /^(domain|user)$/)) {
 	    while (my ($key,$val)= each %dupdirs) {
 		if ($key eq $compuri and $val eq "open") {
@@ -552,7 +555,7 @@
 	    }
 	}
 	&display_line($r,$diropen,$line,$indent,$curdir,$hashref,@list);
-	&scanDir ($r,$compuri,$indent) if $diropen eq "opened";
+	&scanDir ($r,$compuri,$indent) if $diropen eq 'opened';
     }
     $indent--;
 }
@@ -561,10 +564,9 @@
 sub get_list {
     my ($r,$uri)=@_;
     my @list;
-    my $luri = $uri;
-    $luri =~ s/\//_/g;
+    (my $luri = $uri) =~ s/\//_/g;
 
-    if ($ENV{'form.attrs'} eq "Refresh") {
+    if ($ENV{'form.attrs'} eq 'Refresh') {
 	foreach (keys %hash) {
 	    delete $hash{$_} if ($_ =~ /^dirlist_files_/);
 	    }
@@ -614,8 +616,8 @@
 	chomp $line;
 	$line =~ s/^\/home\/httpd\/html//;
 	my @unpackline = split (/\&/,$line);
-	next if ($unpackline[0] eq ".");
-	next if ($unpackline[0] eq "..");
+	next if ($unpackline[0] eq '.');
+	next if ($unpackline[0] eq '..');
 	my @filecom = split (/\./,$unpackline[0]);
 	my $fext = pop(@filecom);
 	my $fnptr = $unpackline[3]&$dirptr;
@@ -637,28 +639,28 @@
     my (@pathfn, $fndir, $fnptr);
     my $dirptr=16384;
     my $fileclr="#ffffe6";
-    my $iconpath= $r->dir_config('lonIconsURL') . "/";
+    my $iconpath= $r->dir_config('lonIconsURL') . '/';
 
     my @filecom = split (/\&/,$line);
     my @pathcom = split (/\//,$filecom[0]);
     my $listname = $pathcom[scalar(@pathcom)-1];
     my $fnptr = $filecom[3]&$dirptr;
     my $msg = 'View '.$filecom[0].' resources';
-    $msg = 'Close '.$filecom[0].' directory' if $diropen eq "opened";
+    $msg = 'Close '.$filecom[0].' directory' if $diropen eq 'opened';
 
-    my $tabtag="</td>";
+    my $tabtag='</td>';
     my $i=0;
 
-    while ($i<=5) {
-	$tabtag=join('',$tabtag,"<td bgcolor=",$fileclr,">&nbsp;</td>")
+    while ($i<=6) {
+	$tabtag=join('',$tabtag,"<td>&nbsp;</td>")
 	    if $hash{'display_attrs_'.$i} == 1;
 	$i++;
     }
 
 # display uplink arrow
-    if ($filecom[1] eq "viewOneUp") {
-	$r->print("<tr>$extrafield");
-	$r->print("<td bgcolor=$fileclr valign=bottom>\n");
+    if ($filecom[1] eq 'viewOneUp') {
+	$r->print("<tr bgcolor=$fileclr>$extrafield");
+	$r->print("<td valign=bottom>\n");
 	$r->print ('<form method="post" name="dirpathUP" action="'.$startdir.
 		   '/" '.
 		   'onSubmit="return rep_dirpath(\'UP\','.
@@ -676,11 +678,11 @@
     }
 
 # display domain
-    if ($filecom[1] eq "domain") {
+    if ($filecom[1] eq 'domain') {
 	$r->print ('<input type="hidden" name="dirPointer" value="on">'."\n")
 	    if ($ENV{'form.dirPointer'} eq "on");
-	$r->print("<tr>$extrafield");
-	$r->print("<td bgcolor=$fileclr valign=bottom>");
+	$r->print("<tr bgcolor=$fileclr>$extrafield");
+	$r->print("<td valign=bottom>");
 	&begin_form ($r,$filecom[0].'/');
 	my $anchor = $filecom[0].'/';
 	$anchor =~ s/\///g;
@@ -698,9 +700,9 @@
 
 # display user directory
     }
-    if ($filecom[1] eq "user") {
-	$r->print("<tr>$extrafield");
-	$r->print("<td bgcolor=$fileclr valign=bottom nowrap>\n");
+    if ($filecom[1] eq 'user') {
+	$r->print("<tr bgcolor=$fileclr>$extrafield");
+	$r->print("<td valign=bottom nowrap>\n");
 	my $curdir = $startdir.$filecom[0].'/';
 	my $anchor = $curdir;
 	$anchor =~ s/\///g;
@@ -720,7 +722,7 @@
     }
 
 # display file
-    if ($fnptr == 0 and $filecom[3] ne "") {
+    if ($fnptr == 0 and $filecom[3] ne '') {
 	my @file_ext = split (/\./,$listname);
 	my $curfext = $file_ext[-1];
         if (@Omit) {
@@ -739,7 +741,7 @@
 	    (!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn');
 	#
 	my $filelink = $startdir.$filecom[0];
-	$r->print("<tr><td nowrap valign='bottom' bgcolor=$fileclr>");
+	$r->print("<tr bgcolor=$fileclr><td nowrap valign='bottom'>");
 	my $metafile = grep /^$filecom[0]\.meta\&/, @list;
 	my $title;
         if ($ENV{'form.catalogmode'} eq 'interactive') {
@@ -753,7 +755,7 @@
                       $titleesc,"','",$filelink,"')\">");
 	    $r->print("<img src='",$iconpath,"select.gif' border='0' /></a>".
 		      "\n");
-	    $r->print("</td><td valign='bottom' nowrap bgcolor=$fileclr>");
+	    $r->print("</td><td valign='bottom' nowrap>");
 	}
         elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
 	    $title=$listname;
@@ -772,7 +774,7 @@
 	    $r->print("<input type='hidden' name='title"."' ".
 		      "value='$titleesc'>\n");
 	    $r->print("</form>\n");
-	    $r->print("</td><td valign='bottom' nowrap bgcolor=$fileclr>");
+	    $r->print("</td><td valign='bottom' nowrap>");
 	    $hash{"pre_${fnum}_link"}=$filelink;
 	    $hash{"pre_${fnum}_title"}=$titleesc;
   	    $fnum++;
@@ -804,36 +806,40 @@
 		   "TARGET=_self>metadata</a>) ") if ($metafile == 1);
 
 	$r->print("</td>\n");
-	$r->print("<td bgcolor=$fileclr align=right valign=bottom> ",
+	if ($hash{'display_attrs_0'} == 1) {
+	    my $title = &Apache::lonnet::metadata($filelink,'title')
+		if ($metafile == 1);
+	    $r->print('<td valign=bottom> '.($title eq '' ? '&nbsp;' : $title).
+		      ' </td>'."\n");
+	}
+	$r->print('<td align=right valign=bottom> ',
 		  $filecom[8]," </td>\n") 
-	    if $hash{'display_attrs_0'} == 1;
-	$r->print("<td bgcolor=$fileclr valign=bottom> ".
-		  (localtime($filecom[9]))." </td>\n") 
 	    if $hash{'display_attrs_1'} == 1;
-	$r->print("<td bgcolor=$fileclr valign=bottom> ".
-		  (localtime($filecom[10]))." </td>\n") 
+	$r->print('<td valign=bottom> '.
+		  (localtime($filecom[9]))." </td>\n") 
 	    if $hash{'display_attrs_2'} == 1;
+	$r->print('<td valign=bottom> '.
+		  (localtime($filecom[10]))." </td>\n") 
+	    if $hash{'display_attrs_3'} == 1;
 
-	if ($hash{'display_attrs_3'} == 1) {
+	if ($hash{'display_attrs_4'} == 1) {
 	    my $author = &Apache::lonnet::metadata($filelink,'author')
 		if ($metafile == 1);
-	    $author = '&nbsp;' if (!$author);
-	    $r->print("<td bgcolor=$fileclr valign=bottom> ".$author.
+	    $r->print('<td valign=bottom> '.($author eq '' ? '&nbsp;' : $author).
 		      " </td>\n");
 	}
-	if ($hash{'display_attrs_4'} == 1) {
+	if ($hash{'display_attrs_5'} == 1) {
 	    my $keywords = &Apache::lonnet::metadata($filelink,'keywords')
 		if ($metafile == 1);
-	    $keywords = '&nbsp;' if (!$keywords);
-	    $r->print("<td bgcolor=$fileclr valign=bottom> ".$keywords.
+	    # $keywords = '&nbsp;' if (!$keywords);
+	    $r->print('<td valign=bottom> '.($keywords eq '' ? '&nbsp;' : $keywords).
 		      " </td>\n");
 	}
-	if ($hash{'display_attrs_5'} == 1) {
+	if ($hash{'display_attrs_6'} == 1) {
 	    my $lang = &Apache::lonnet::metadata($filelink,'language')
 		if ($metafile == 1);
 	    $lang = &Apache::loncommon::languagedescription($lang);
-	    $lang = '&nbsp;' if (!$lang);
-	    $r->print("<td bgcolor=$fileclr valign=bottom> ".$lang.
+	    $r->print('<td valign=bottom> '.($lang eq '' ? '&nbsp;' : $lang).
 		      " </td>\n");
 	}
 	$r->print("</tr>\n");
@@ -846,7 +852,7 @@
 	my $curdir = $startdir.$filecom[0].'/';
 	my $anchor = $curdir;
 	$anchor =~ s/\///g;
-	$r->print("<tr>$extrafield<td bgcolor=$fileclr valign=bottom>");
+	$r->print("<tr bgcolor=$fileclr>$extrafield<td valign=bottom>");
 	&begin_form ($r,$curdir);
 	my $indentm1 = $indent-1;
 	if ($indentm1 < 11 and $indentm1 > 0) {

--ng1025380519--