File:  [LON-CAPA] / loncom / interface / lonindexer.pm
Revision 1.14: download - view: text, annotated - select for diffs
Tue Aug 7 14:02:27 2001 UTC (22 years, 11 months ago) by harris41
Branches: MAIN
CVS tags: HEAD
causing display of extrafield to be conditional for interactive

    1: # The LearningOnline Network with CAPA
    2: #
    3: # Directory Indexer
    4: # (Login Screen
    5: #
    6: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14 Gerd Kortemeyer)
    7: # 11/23 Gerd Kortemeyer
    8: # 07/20-08/04 H.K. Ng
    9: #
   10: # 05/9-05/19/2001 H. K. Ng
   11: # 05/21/2001 H. K. Ng
   12: # 05/23/2001 H. K. Ng
   13: # 05/31/2001 Scott Harrison
   14: # 06/01/2001 Scott Harrison
   15: # 06/02/2001 Scott Harrison
   16: # 06/15/2001 Scott Harrison
   17: # 06/26/2001 H. K. Ng
   18: # 07/08/2001 H. K. Ng
   19: 
   20: package Apache::lonindexer;
   21: 
   22: use strict;
   23: use Apache::lonnet();
   24: use Apache::Constants qw(:common);
   25: use Apache::File;
   26: use GDBM_File;
   27: 
   28: my %hash;
   29: my %dirs;
   30: my %language;
   31: my $hidden;
   32: my $extrafield;
   33: my $fnum;
   34: sub BEGIN {
   35:     my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
   36: 			     '/language.tab');
   37:     map {
   38: 	$_=~/(\w+)\s+([\w\s\-]+)/;
   39: 	$language{$1}=$2;
   40:     } <$fh>;
   41: }
   42: 
   43: sub handler {
   44:     my $r = shift;
   45:     $r->content_type('text/html');
   46:     $r->send_http_header;
   47:     return OK if $r->header_only;
   48:     $fnum=0;
   49:     my $iconpath= $r->dir_config('lonIconsURL') . "/";
   50:     my $domain  = $r->dir_config('lonDefDomain');
   51:     my $role    = $r->dir_config('lonRole');
   52:     my $loadlim = $r->dir_config('lonLoadLim');
   53:     my $servadm = $r->dir_config('lonAdmEMail');
   54:     my $sysadm  = $r->dir_config('lonSysEMail');
   55:     my $lonhost = $r->dir_config('lonHostID');
   56:     my $tabdir  = $r->dir_config('lonTabDir');
   57: 
   58:     my $fileclr='#ffffe6';
   59: # -------------------------------------- see if called from an interactive mode
   60:     map {
   61:        my ($name, $value) = split(/=/,$_);
   62:        $value =~ tr/+/ /;
   63:        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
   64:        if ($name eq 'catalogmode') {
   65:            $ENV{'form.'.$name}=$value;
   66: 	   }
   67:     } (split(/&/,$ENV{'QUERY_STRING'}));
   68: 
   69:     $hidden=''; my $closebutton='';
   70:     my $groupimportbutton='';
   71:     my $colspan=''; 
   72: 
   73:     $extrafield='';
   74:     if ($ENV{'form.catalogmode'} eq 'interactive') {
   75: 	$extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
   76: 	    '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.
   77: 	    ' border="0"></td>';
   78: 	$colspan=" colspan='2' ";
   79: 	$hidden=<<END;
   80: <input type='hidden' name='catalogmode' value='interactive'>
   81: END
   82:         $closebutton=<<END;
   83: <input type="button" name="close" value='CLOSE' onClick="self.close()">
   84: END
   85:     }
   86:     elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
   87: 	$extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
   88: 	    '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.
   89: 	    ' border="0"></td>';
   90: 	$colspan=" colspan='2' ";
   91: 	$hidden=<<END;
   92: <input type='hidden' name='catalogmode' value='groupimport'>
   93: END
   94:         $closebutton=<<END;
   95: <input type="button" name="close" value='CLOSE' onClick="self.close()">
   96: END
   97:         $groupimportbutton=<<END;
   98: <input type="button" name="groupimport" value='GROUP IMPORT' onClick="javascript:select_group()">
   99: END
  100:     }
  101: 
  102:     my $catalogmodefunctions='';
  103:     if ($ENV{'form.catalogmode'} eq 'interactive' or
  104: 	$ENV{'form.catalogmode'} eq 'groupimport') {
  105: 	$catalogmodefunctions=<<END;
  106: function select_data(title,url) {
  107:     changeTitle(title);
  108:     changeURL(url);
  109:     self.close();
  110: }
  111: function save_group() {
  112:     for (var num=0; num<document.forms.fnum.fnum.value; num++) {
  113: 	if (eval("document.forms.form"+num+".filelink.checked")) {
  114: 	    alert(eval("document.forms.form"+num+".title.value")+
  115: 		       eval("document.forms.form"+num+".filelink.value"));
  116: 	}
  117:     }
  118: }
  119: function select_group() {
  120:     var linkflag=false;
  121:     for (var num=0; num<document.forms.fnum.fnum.value; num++) {
  122: 	if (eval("document.forms.form"+num+".filelink.checked")) {
  123: //	    alert(eval("document.forms.form"+num+".title.value")+
  124: //		       eval("document.forms.form"+num+".filelink.value"));
  125: 	    insertRowInLastRow();
  126: 	    placeResourceInLastRow(
  127: 		   eval("document.forms.form"+num+".title.value"),
  128: 		   eval("document.forms.form"+num+".filelink.value"),
  129: 		   linkflag
  130: 				   );
  131: 	    linkflag=true;
  132: 	}
  133:     }
  134:     opener.editmode=0;
  135:     opener.notclear=0;
  136:     opener.linkmode=0;
  137:     opener.infoclear();
  138:     opener.draw();
  139: }
  140: function insertRowInLastRow() {
  141:     opener.insertrow(opener.maxrow);
  142:     opener.addobj(opener.maxrow,'e&2');
  143: }
  144: function placeResourceInLastRow (title,url,linkflag) {
  145:     opener.newresource(opener.maxrow,2,opener.escape(title),opener.escape(url),'false','normal');
  146:     opener.save();
  147:     opener.mostrecent=opener.obj.length-1;
  148:     if (linkflag) {
  149: 	opener.joinres(opener.linkmode,opener.mostrecent,0);
  150:     }
  151:     opener.linkmode=opener.mostrecent;
  152: }
  153: function changeTitle(val) {
  154:     if (opener.inf.document.forms.resinfo.elements.t) {
  155:         opener.inf.document.forms.resinfo.elements.t.value=val;
  156:     }
  157: }
  158: function changeURL(val) {
  159:     if (opener.inf.document.forms.resinfo.elements.u) {
  160: 	opener.inf.document.forms.resinfo.elements.u.value=val;
  161:     }
  162: }
  163: END
  164:     }
  165: 
  166: # ---------------------------------------------------------------- Print Header
  167:     $r->print(<<ENDHEADER);
  168: <html>
  169: <head>
  170: <title>The LearningOnline Network With CAPA Directory Browser</title>
  171: 
  172: <script language="javascript">
  173: $catalogmodefunctions
  174: function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
  175:     var options = "width=" + w + ",height=" + h + ",";
  176:     options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
  177:     options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
  178:     var newWin = window.open(url, wdwName, options);
  179:     newWin.focus();
  180: }
  181: </script>
  182: 
  183: </head>
  184: <body bgcolor="#FFFFFF">
  185: ENDHEADER
  186: 
  187:     my $line;
  188:     my (@attrchk,@openpath);
  189:     my $uri=$r->uri;
  190: 
  191:     $r->print('<h2><font color="#888888">The LearningOnline With CAPA Network Directory Browser</font></h2>'."\n");
  192: 
  193:     my $diropendb = "/home/httpd/perl/tmp/$domain\_$ENV{'user.name'}_indexer.db";
  194: 
  195:     if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) {
  196: 
  197: 	if ($ENV{'form.attrs'} ne "") {
  198: 	    for (my $i=0; $i<=5; $i++) {
  199: 		delete $hash{'display_attrs_'.$i};
  200: 		if ($ENV{'form.attr'.$i} == 1) {
  201: 		    $attrchk[$i] = "checked";
  202: 		    $hash{'display_attrs_'.$i} = 1;
  203: 		}
  204: 	    }
  205: 	} else {
  206: 	    for (my $i=0; $i<=5; $i++) {
  207: 		$attrchk[$i] = "checked" if $hash{'display_attrs_'.$i} == 1;
  208: 	    }
  209: 	}
  210:     $r->print(<<END);
  211: <b><font color="#666666">Display file attributes</font></b><br>
  212: <form method="post" name="fileattr" action="$uri" enctype="application/x-www-form-urlencoded">
  213: <table border=0><tr>
  214: <td><input type=checkbox name=attr0 value="1" $attrchk[0]> Size</td>
  215: <td><input type=checkbox name=attr1 value="1" $attrchk[1]> Last access</td>
  216: <td><input type=checkbox name=attr2 value="1" $attrchk[2]> Last modified</td>
  217: </tr><tr>
  218: <td><input type=checkbox name=attr3 value="1" $attrchk[3]> Author</td>
  219: <td><input type=checkbox name=attr4 value="1" $attrchk[4]> Keywords</td>
  220: <td><input type=checkbox name=attr5 value="1" $attrchk[5]> Language</td>
  221: </tr></table>
  222: <input type=hidden name=dirPointer value="on">
  223: <input type="submit" name="attrs" value="Review">&nbsp;
  224: <input type="submit" name="attrs" value="Refresh">
  225: $hidden
  226: $closebutton
  227: $groupimportbutton
  228: </form>
  229: END
  230: 
  231:     my $titleclr="#ddffff";
  232:     $r->print("<table border=0><tr><td bgcolor=#eeeeee>\n");
  233:     $r->print("<table border=0><tr>\n");
  234:     $r->print("<td $colspan bgcolor=$titleclr><b>Name</b></td>\n");
  235:     $r->print("<td bgcolor=$titleclr align=right><b>Size (bytes) </b></td>\n") if ($hash{'display_attrs_0'} == 1);
  236:     $r->print("<td bgcolor=$titleclr><b>Last accessed</b></td>\n") if ($hash{'display_attrs_1'} == 1);
  237:     $r->print("<td bgcolor=$titleclr><b>Last modified</b></td>\n") if ($hash{'display_attrs_2'} == 1);
  238:     $r->print("<td bgcolor=$titleclr><b>Author(s)</b></td>\n") if ($hash{'display_attrs_3'} == 1);
  239:     $r->print("<td bgcolor=$titleclr><b>Keywords</b></td>\n") if ($hash{'display_attrs_4'} == 1);
  240:     $r->print("<td bgcolor=$titleclr><b>Language</b></td>\n") if ($hash{'display_attrs_5'} == 1);
  241:     $r->print("</tr>");
  242: 
  243: 	map {
  244: 	    if ($_ =~ /^diropen_status_/) {
  245: 		my $key = $_;
  246: 		$key =~ s/^diropen_status_//;
  247: 		$dirs{$key} = $hash{$_};
  248: 	    }
  249: 	} keys %hash;
  250: 
  251: 	if ($ENV{'form.openuri'}) {  # take care of review and refresh options
  252: 	    my $uri=$ENV{'form.openuri'};
  253: 	    if (exists($hash{'diropen_status_'.$uri})) {
  254: 		my $cursta = $hash{'diropen_status_'.$uri};
  255: 		$dirs{$uri} = 'open';
  256: 		$hash{'diropen_status_'.$uri} = 'open';
  257: 		if ($cursta eq 'open') {
  258: 		    $dirs{$uri} = 'closed';
  259: 		    $hash{'diropen_status_'.$uri} = 'closed';
  260: 		}
  261: 	    } else {
  262: 		$hash{'diropen_status_'.$uri} = 'open';
  263: 		$dirs{$uri} = 'open';
  264: 	    }
  265: 	}
  266: 	
  267: 	my $bredir = $ENV{'form.dirPointer'};
  268: 	my $toplevel;
  269: 	my $indent = 0;
  270: 	$uri = $uri.'/' if $uri !~ /.*\/$/;
  271: 	if ($bredir ne "on") {
  272: 	    $hash{'top.level'} = $uri;
  273: 	    $toplevel = $uri;
  274: 
  275: 	} else {
  276: 	    $toplevel = $hash{'top.level'};
  277: 	}
  278: 	if ($toplevel ne "/res/"){
  279: 	    my (@uri_com) = split(/\//,$uri);
  280: 	    pop @uri_com;
  281: 	    my $upone = join('/',@uri_com);
  282: 	    my @list = qw (0);
  283: 	    &display_line ($r,'opened',$upone.'&viewOneUp',0,$upone,@list);
  284: 	    $indent = 1;
  285: 	}
  286: 	&scanDir ($r,$toplevel,$indent);
  287: 	
  288: 	$r->print("<form name='fnum'>");
  289: 	$r->print("<input type='hidden' name='fnum' value='$fnum'></form>");
  290: 	$r->print("</table>");
  291: 	$r->print("</td></tr></table>");
  292: 	$r->print("</body></html>\n");
  293: 	untie(%hash);
  294:     } else {
  295: 	$r->print("Unable to tie hash to db file");
  296:     }
  297:     return OK;
  298: }
  299: 
  300: 
  301: # --------------------recursive scan of a directory
  302: sub scanDir {
  303:     my ($r,$startdir,$indent)=@_;
  304:     my ($compuri,$curdir);
  305:     my $dirptr=16384;
  306:     $indent++;
  307: 
  308:     my %dupdirs = %dirs;
  309:     my @list=&get_list($r,$startdir);
  310:     foreach my $line (@list) {
  311: 	my ($strip,$dom,$foo,$testdir,$foo)=split(/\&/,$line,5); 
  312: 	next if $strip =~ /.*\.meta$/;
  313: 	if ($dom eq "domain") {
  314: 	    $compuri = join('',$strip,"/");  # domain list has /res/<domain name>
  315: 	    $curdir = $compuri;
  316: 	} else {
  317: 	    $compuri = join('',$startdir,$strip,"/"); # user, dir & file have name only, i.e., w/o path
  318: 	    $curdir = $startdir;
  319: 	}
  320: 	my $diropen = "closed";
  321: 	if (($dirptr&$testdir) or ($dom =~ /^(domain|user)$/)) {
  322: 	    while (my ($key,$val)= each %dupdirs) {
  323: 		if ($key eq $compuri and $val eq "open") {
  324: 		    $diropen = "opened";
  325: 		    delete $dupdirs{key},$dirs{$key};
  326: 		}
  327: 	    }
  328: 	}
  329: 	&display_line($r,$diropen,$line,$indent,$curdir,@list);
  330: 	&scanDir ($r,$compuri,$indent) if $diropen eq "opened";
  331:     }
  332:     $indent--;
  333: }
  334: 
  335: # ----------------- get complete matched list based on the uri ------
  336: sub get_list {
  337:     my ($r,$uri)=@_;
  338:     my @list;
  339:     my $luri = $uri;
  340:     $luri =~ s/\//_/g;
  341: 
  342:     if ($ENV{'form.attrs'} eq "Refresh") {
  343: 	map {
  344: 	    delete $hash{$_} if ($_ =~ /^dirlist_files_/);
  345: 	    } keys %hash;
  346:     }
  347: 
  348:     if ($hash{'dirlist_files'.$luri}) {
  349: 	@list = split(/\n/,$hash{'dirlist_files_'.$luri});
  350:     } else {
  351: 	@list = &Apache::lonnet::dirlist($uri);
  352: 	$hash{'dirlist_files_'.$luri} = join('\n',@list);
  353:     }
  354:     return @list=&match_ext($r,@list);
  355: }
  356: 
  357: #-------------------------- filters out files based on extensions
  358: sub match_ext {
  359:     my ($r,@packlist)=@_;
  360:     my @trimlist;
  361:     my $nextline;
  362:     my @fileext;
  363:     my $dirptr=16384;
  364: 
  365:     my $tabdir  = $r->dir_config('lonTabDir');
  366:     my $fn = $tabdir.'/filetypes.tab';
  367:     if (-e $fn) {
  368: 	my $FH=Apache::File->new($fn);
  369: 	my @content=<$FH>;
  370: 	foreach my $line (@content) {
  371: 	    (my $ext,my $foo) = split /\s+/,$line;
  372: 	    push @fileext,$ext;
  373: 	}
  374:     }
  375:     foreach my $line (@packlist) {
  376: 	chomp $line;
  377: 	$line =~ s/^\/home\/httpd\/html//;
  378: 	my @unpackline = split (/\&/,$line);
  379: 	next if ($unpackline[0] eq ".");
  380: 	next if ($unpackline[0] eq "..");
  381: 	my @filecom = split (/\./,$unpackline[0]);
  382: 	my $fext = pop(@filecom);
  383: 	my $fnptr = $unpackline[3]&$dirptr;
  384:  	if ($fnptr == 0 and $unpackline[3] ne "") {
  385: 	    foreach my $nextline (@fileext) {
  386: 		push @trimlist,$line if $nextline eq $fext;
  387: 	    }
  388: 	} else {
  389: 	    push @trimlist,$line;
  390: 	}
  391:     }
  392:     @trimlist = sort (@trimlist);
  393:     return @trimlist;
  394: }
  395: 
  396: #------------------- displays one line in appropriate table format
  397: sub display_line{
  398:     my ($r,$diropen,$line,$indent,$startdir,@list)=@_;
  399:     my (@pathfn, $fndir, $fnptr);
  400:     my $dirptr=16384;
  401:     my $fileclr="#ffffe6";
  402:     my $iconpath= $r->dir_config('lonIconsURL') . "/";
  403: 
  404:     my @filecom = split (/\&/,$line);
  405:     my @pathcom = split (/\//,$filecom[0]);
  406:     my $listname = $pathcom[scalar(@pathcom)-1];
  407:     my $fnptr = $filecom[3]&$dirptr;
  408:     my $msg = 'View '.$filecom[0].' resources';
  409:     $msg = 'Close '.$filecom[0].' directory' if $diropen eq "opened";
  410: 
  411:     my $tabtag="</td>";
  412:     my $i=0;
  413: 
  414:     while ($i<=5) {
  415: 	$tabtag=join('',$tabtag,"<td bgcolor=",$fileclr,">&nbsp;</td>") if $hash{'display_attrs_'.$i} == 1;
  416: 	$i++;
  417:     }
  418:     if ($filecom[1] eq "viewOneUp") {
  419: 	$r->print("<tr>$extrafield");
  420: 	$r->print("<td bgcolor=$fileclr valign=bottom>\n");
  421: 	$r->print ('<form method="post" name="dirpath" action="'.$startdir.
  422: 		   '" enctype="application/x-www-form-urlencoded">'."\n");
  423: 	$r->print ($hidden.'<input type=hidden name=openuri value="'.$startdir.'">'."\n");
  424: 	$r->print ('<input src="'.$iconpath.'arrow_up.gif"');
  425: 	$r->print (' name="'.$msg.'" height="22" type="image" border="0">'."\n");
  426: 	$r->print("Up $tabtag</tr></form>\n");
  427: 	return OK;
  428:     }
  429:     if ($filecom[1] eq "domain") {
  430: 	$r->print ('<input type=hidden name=dirPointer value="on">'."\n") if ($ENV{'form.dirPointer'} eq "on");
  431: 	$r->print("<tr>$extrafield");
  432: 	$r->print("<td bgcolor=$fileclr valign=bottom>");
  433: 	&begin_form ($r,$filecom[0].'/');
  434: 	my $anchor = $filecom[0].'/';
  435: 	$anchor =~ s/\///g;
  436: 	$r->print ('<a name="'.$anchor.'">');
  437: 	$r->print ('<input src="'.$iconpath.'folder_pointer_'.$diropen.'.gif"'); 
  438: 	$r->print (' name="'.$msg.'" height="22" type="image" border="0">'."\n");
  439: 	$r->print ('<a href="'.$filecom[0].'"><img src="'.$iconpath.'server.gif"');
  440: 	$r->print (' border="0"></a>'."\n");
  441: 	$r->print("Domain - $listname $tabtag</tr></form>\n");
  442: 	return OK;
  443:     }
  444:     if ($filecom[1] eq "user") {
  445: 	$r->print("<tr>$extrafield");
  446: 	$r->print("<td bgcolor=$fileclr valign=bottom nowrap>\n");
  447: 	my $curdir = $startdir.$filecom[0].'/';
  448: 	my $anchor = $curdir;
  449: 	$anchor =~ s/\///g;
  450: 	&begin_form ($r,$curdir);
  451: 	$r->print ('<a name="'.$anchor.'"><img src="'.$iconpath.'whitespace1.gif" border=0>'."\n");
  452: 	$r->print ('<input src="'.$iconpath.'folder_pointer_'.$diropen.'.gif"'); 
  453: 	$r->print (' name="'.$msg.'" height="22" type="image" border="0">'."\n");
  454: 	$r->print ('<a href="'.$curdir.'"><img src='.$iconpath.'quill.gif border=0 name="'.$msg.'" height="22"></a>');
  455: 	$r->print ($listname.$tabtag.'</tr></form>'."\n");
  456: 	return OK;
  457:     }
  458: # display file
  459:     if ($fnptr == 0 and $filecom[3] ne "") {
  460: 	my @file_ext = split (/\./,$listname);
  461: 	my $curfext = $file_ext[scalar(@file_ext)-1];
  462: 	my $filelink = $startdir.$filecom[0];
  463: 	$r->print("<tr><td nowrap valign='bottom' bgcolor=$fileclr>");
  464: 	my $metafile = grep /^$filecom[0]\.meta\&/, @list;
  465: 	my $title;
  466:         if ($ENV{'form.catalogmode'} eq 'interactive') {
  467: 	    $title=$listname;
  468: 	    $title = &Apache::lonnet::metadata($filelink,'title')
  469: 		if ($metafile == 1);
  470: 	    $title=$listname unless $title;
  471: 	    $r->print("<a href='javascript:select_data(\"",
  472: 	              $title,'","',$filelink,"\")'>");
  473: 	    $r->print("<img src='",$iconpath,"select.gif' border=0></a>\n");
  474: 	    $r->print("</td><td valign='bottom' nowrap bgcolor=$fileclr>");
  475: 	}
  476:         elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
  477: 	    $title=$listname;
  478: 	    $title = &Apache::lonnet::metadata($filelink,'title')
  479: 		if ($metafile == 1);
  480: 	    $title=$listname unless $title;
  481: 	    $r->print("<form name='form$fnum'>\n");
  482: 	    $r->print("<input type='checkbox' name='filelink"."' ".
  483: 		      "value='$filelink'>\n");
  484: 	    $r->print("<input type='hidden' name='title"."' ".
  485: 		      "value='$title'>\n");
  486: 	    $r->print("</form>\n");
  487: 	    $r->print("</td><td valign='bottom' nowrap bgcolor=$fileclr>");
  488:   	    $fnum++;
  489: 	}
  490: 
  491: 	if ($indent > 0 and $indent < 11) {
  492: 	    $r->print("<img src=",$iconpath,"whitespace",$indent,".gif border=0>\n");
  493: 	} elsif ($indent >0) {
  494: 	    my $ten = int($indent/10.);
  495: 	    my $rem = $indent%10.0;
  496: 	    my $count = 0;
  497: 	    while ($count < $ten) {
  498: 		$r->print("<img src=",$iconpath,"whitespace10.gif border=0>\n");
  499: 	    $count++;
  500: 	    }
  501: 	    $r->print("<img src=",$iconpath,"whitespace",$rem,".gif border=0>\n") if $rem > 0;
  502: 	}
  503: 
  504: 	$r->print("<img src=$iconpath$curfext.gif border=0>\n");
  505: 	$r->print (" <a href=\"javascript:openWindow('".$filelink."', 'metadatafile', '450', '500', 'no', 'yes')\"; TARGET=_self>$listname</a> ");
  506: 
  507: 	$r->print (" (<a href=\"javascript:openWindow('".$filelink.".meta', 'metadatafile', '400', '450', 'no', 'yes')\"; TARGET=_self>metadata</a>) ") if ($metafile == 1);
  508: 
  509: 	$r->print("</td>\n");
  510: 	$r->print("<td bgcolor=$fileclr align=right valign=bottom> ",$filecom[8]," </td>\n") 
  511: 	    if $hash{'display_attrs_0'} == 1;
  512: 	$r->print("<td bgcolor=$fileclr valign=bottom> ".(localtime($filecom[9]))." </td>\n") 
  513: 	    if $hash{'display_attrs_1'} == 1;
  514: 	$r->print("<td bgcolor=$fileclr valign=bottom> ".(localtime($filecom[10]))." </td>\n") 
  515: 	    if $hash{'display_attrs_2'} == 1;
  516: 
  517: 	if ($hash{'display_attrs_3'} == 1) {
  518: 	    my $author = &Apache::lonnet::metadata($filelink,'author') if ($metafile == 1);
  519: 	    $author = '&nbsp;' if (!$author);
  520: 	    $r->print("<td bgcolor=$fileclr valign=bottom> ".$author." </td>\n");
  521: 	}
  522: 	if ($hash{'display_attrs_4'} == 1) {
  523: 	    my $keywords = &Apache::lonnet::metadata($filelink,'keywords') if ($metafile == 1);
  524: 	    $keywords = '&nbsp;' if (!$keywords);
  525: 	    $r->print("<td bgcolor=$fileclr valign=bottom> ".$keywords." </td>\n");
  526: 	}
  527: 	if ($hash{'display_attrs_5'} == 1) {
  528: 	    my $lang = &Apache::lonnet::metadata($filelink,'language') if ($metafile == 1);
  529: 	    $lang = $language{$lang};
  530: 	    $lang = '&nbsp;' if (!$lang);
  531: 	    $r->print("<td bgcolor=$fileclr valign=bottom> ".$lang." </td>\n");
  532: 	}
  533: 	$r->print("</tr>\n");
  534:     }
  535: # -- display directory
  536:     if ($fnptr == $dirptr) {
  537: 	my @file_ext = split (/\./,$listname);
  538: 	my $curfext = $file_ext[scalar(@file_ext)-1];
  539: 	my $curdir = $startdir.$filecom[0].'/';
  540: 	my $anchor = $curdir;
  541: 	$anchor =~ s/\///g;
  542: 	$r->print("<tr>$extrafield<td bgcolor=$fileclr valign=bottom>");
  543: 	&begin_form ($r,$curdir);
  544: 	my $indentm1 = $indent-1;
  545: 	if ($indentm1 < 11 and $indentm1 > 0) {
  546: 	    $r->print("<img src=",$iconpath,"whitespace",$indentm1,".gif border=0>\n");
  547: 	} else {
  548: 	    my $ten = int($indentm1/10.);
  549: 	    my $rem = $indentm1%10.0;
  550: 	    my $count = 0;
  551: 	    while ($count < $ten) {
  552: 		$r->print ("<img src=",$iconpath,"whitespace10.gif border=0>\n");
  553: 		$count++;
  554: 	    }
  555: 	    $r->print ("<img src=",$iconpath,"whitespace",$rem,".gif border=0>\n") if $rem > 0;
  556: 	}
  557: 	$r->print ('<a name="'.$anchor.'"><input src="'.$iconpath.'folder_pointer_'.$diropen.'.gif"');
  558: 	$r->print (' name="'.$msg.'" height="22" type="image" border="0">'."\n");
  559: 	$r->print ('<a href="'.$curdir.'"><img src="'.$iconpath.'folder_'.$diropen.'.gif" border=0></a>'."\n");
  560: 	$r->print ("$listname$tabtag</tr></form>\n");
  561:     }
  562: 
  563: }
  564: 
  565: # ------------------- prints the beginning of a form for directory or file link
  566: sub begin_form {
  567:     my ($r,$uri) = @_;
  568:     my $anchor = $uri;
  569:     $anchor =~ s/\///g;
  570:     $r->print ('<form method="post" name="dirpath" action="'.$uri.'#'.$anchor.
  571: 	       '" enctype="application/x-www-form-urlencoded">'."\n");
  572:     $r->print ($hidden.'<input type=hidden name=openuri value="'.$uri.'">'."\n");
  573:     $r->print ('<input type=hidden name=dirPointer value="on">'."\n");
  574: }
  575: 
  576: 1;
  577: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>