File:  [LON-CAPA] / loncom / interface / lonindexer.pm
Revision 1.13: download - view: text, annotated - select for diffs
Sun Jul 8 18:31:10 2001 UTC (23 years ago) by ng
Branches: MAIN
CVS tags: HEAD
add open just that directory if you click on folder, user or domain icon.
add ability to move up the directory when viewing sub-dir
need a new arrow_up.gif icon.

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

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