File:  [LON-CAPA] / loncom / interface / lonindexer.pm
Revision 1.9: download - view: text, annotated - select for diffs
Sat Jun 2 16:57:35 2001 UTC (23 years, 1 month ago) by harris41
Branches: MAIN
CVS tags: HEAD
group import now creates a long linked list on the RAT user
interface (still in a meaningless order though) -Scott

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

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