Annotation of loncom/interface/lonindexer.pm, revision 1.7

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

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