File:  [LON-CAPA] / loncom / interface / lonindexer.pm
Revision 1.12: download - view: text, annotated - select for diffs
Tue Jun 26 21:11:18 2001 UTC (22 years, 11 months ago) by ng
Branches: MAIN
CVS tags: HEAD
allow browsing by providing the uri at location. If /res/ is provided, it allows
browsing thru the whole network. Anything else will show only that directory.

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

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