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

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
1.9       harris41   12: # 06/01/2001 Scott Harrison
                     13: # 06/02/2001 Scott Harrison
1.10      harris41   14: # 06/15/2001 Scott Harrison
1.12    ! ng         15: # 06/26/2001 H. K. Ng
1.7       harris41   16: 
1.1       www        17: package Apache::lonindexer;
                     18: 
                     19: use strict;
                     20: use Apache::lonnet();
                     21: use Apache::Constants qw(:common);
1.2       harris41   22: use Apache::File;
                     23: use GDBM_File;
                     24: 
1.4       harris41   25: my %hash;
1.2       harris41   26: my %dirs;
                     27: my %language;
1.7       harris41   28: my $hidden;
                     29: my $extrafield;
1.9       harris41   30: my $fnum;
1.2       harris41   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: }
1.1       www        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;
1.9       harris41   44:     $fnum=0;
1.10      harris41   45:     my $iconpath= $r->dir_config('lonIconsURL') . "/";
1.1       www        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: 
1.7       harris41   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') {
1.8       harris41   81: 	$extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
                     82: 	    '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.
                     83: 	    ' border="0"></td>';
1.7       harris41   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;
1.8       harris41   92: <input type="button" name="groupimport" value='GROUP IMPORT' onClick="javascript:select_group()">
1.7       harris41   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);
1.8       harris41  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() {
1.9       harris41  114:     var linkflag=false;
1.8       harris41  115:     for (var num=0; num<document.forms.fnum.fnum.value; num++) {
                    116: 	if (eval("document.forms.form"+num+".filelink.checked")) {
1.9       harris41  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;
1.8       harris41  126: 	}
                    127:     }
1.9       harris41  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;
1.7       harris41  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: 
1.1       www       160: # ---------------------------------------------------------------- Print Header
                    161:     $r->print(<<ENDHEADER);
                    162: <html>
                    163: <head>
1.2       harris41  164: <title>The LearningOnline Network With CAPA Directory Browser</title>
1.3       harris41  165: 
1.2       harris41  166: <SCRIPT language="javascript">
1.7       harris41  167: $catalogmodefunctions
1.2       harris41  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>
1.3       harris41  176: 
1.1       www       177: </head>
                    178: <body bgcolor="#FFFFFF">
                    179: ENDHEADER
                    180: 
                    181:     my $line;
                    182:     my (@attrchk,@openpath);
                    183:     my $uri=$r->uri;
                    184: 
1.12    ! ng        185:     $r->print('<h2><font color="#888888">The LearningOnline With CAPA Network Directory Browser</font></h2>'."\n");
1.1       www       186: 
1.11      ng        187:     my $diropendb = "/home/httpd/perl/tmp/$domain\_$ENV{'user.name'}_indexer.db";
1.6       harris41  188: 
1.11      ng        189:     if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) {
1.6       harris41  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: 	}
1.1       www       204:     $r->print(<<END);
1.2       harris41  205: <b><font color="#666666">Display file attributes</font></b><br>
1.1       www       206: <form method="post" name="fileattr" action="$uri" enctype="application/x-www-form-urlencoded">
                    207: <table border=0><tr>
1.2       harris41  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>
1.1       www       211: </tr><tr>
1.2       harris41  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>
1.1       www       215: </tr></table>
1.6       harris41  216: <input type="submit" name="attrs" value="Review">&nbsp;
                    217: <input type="submit" name="attrs" value="Refresh">
1.7       harris41  218: $hidden
                    219: $closebutton
                    220: $groupimportbutton
1.1       www       221: </form>
                    222: END
                    223: 
1.5       harris41  224:     my $titleclr="#ddffff";
                    225:     $r->print("<table border=0><tr><td bgcolor=#eeeeee>\n");
                    226:     $r->print("<table border=0><tr>\n");
1.7       harris41  227:     $r->print("<td $colspan bgcolor=$titleclr><b>Name</b></td>\n");
1.6       harris41  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);
1.5       harris41  234:     $r->print("</tr>");
                    235: 
1.4       harris41  236: 	map {
                    237: 	    if ($_ =~ /^diropen_status_/) {
                    238: 		my $key = $_;
                    239: 		$key =~ s/^diropen_status_//;
                    240: 		$dirs{$key} = $hash{$_};
                    241: 	    }
                    242: 	} keys %hash;
                    243: 
1.2       harris41  244: 	if ($ENV{'form.openuri'}) {  # take care of review and refresh options
                    245: 	    my $uri=$ENV{'form.openuri'};
1.4       harris41  246: 	    if (exists($hash{'diropen_status_'.$uri})) {
                    247: 		my $cursta = $hash{'diropen_status_'.$uri};
1.2       harris41  248: 		$dirs{$uri} = 'open';
1.4       harris41  249: 		$hash{'diropen_status_'.$uri} = 'open';
                    250: 		if ($cursta eq 'open') {
                    251: 		    $dirs{$uri} = 'closed';
                    252: 		    $hash{'diropen_status_'.$uri} = 'closed';
                    253: 		}
1.2       harris41  254: 	    } else {
1.4       harris41  255: 		$hash{'diropen_status_'.$uri} = 'open';
1.2       harris41  256: 		$dirs{$uri} = 'open';
                    257: 	    }
                    258: 	}
1.12    ! ng        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: 	}
1.4       harris41  273: 	my $indent = 0;
1.2       harris41  274: 	&scanDir ($r,$toplevel,$indent);
1.12    ! ng        275: 	
1.8       harris41  276: 	$r->print("<form name='fnum'>");
                    277: 	$r->print("<input type='hidden' name='fnum' value='$fnum'></form>");
1.2       harris41  278: 	$r->print("</table>");
                    279: 	$r->print("</td></tr></table>");
                    280: 	$r->print("</body></html>\n");
1.4       harris41  281: 	untie(%hash);
1.2       harris41  282:     } else {
                    283: 	$r->print("Unable to tie hash to db file");
                    284:     }
1.1       www       285:     return OK;
                    286: }
1.2       harris41  287: 
1.6       harris41  288: 
1.2       harris41  289: # --------------------recursive scan of a directory
                    290: sub scanDir {
                    291:     my ($r,$startdir,$indent)=@_;
1.3       harris41  292:     my ($compuri,$curdir);
                    293:     my $dirptr=16384;
1.1       www       294:     $indent++;
                    295: 
1.2       harris41  296:     my %dupdirs = %dirs;
                    297:     my @list=&get_list($r,$startdir);
                    298:     foreach my $line (@list) {
1.5       harris41  299: 	my ($strip,$dom,$foo,$testdir,$foo)=split(/\&/,$line,5); 
1.4       harris41  300: 	next if $strip =~ /.*\.meta$/;
1.5       harris41  301: 	if ($dom eq "domain") {
1.3       harris41  302: 	    $compuri = join('',$strip,"/");  # domain list has /res/<domain name>
                    303: 	    $curdir = $compuri;
1.2       harris41  304: 	} else {
1.12    ! ng        305: 	    $compuri = join('',$startdir,$strip,"/"); # user, dir & file have name only, i.e., w/o path
1.3       harris41  306: 	    $curdir = $startdir;
1.2       harris41  307: 	}
1.11      ng        308: 	my $diropen = "closed";
1.5       harris41  309: 	if (($dirptr&$testdir) or ($dom =~ /^(domain|user)$/)) {
1.3       harris41  310: 	    while (my ($key,$val)= each %dupdirs) {
1.5       harris41  311: 		if ($key eq $compuri and $val eq "open") {
1.11      ng        312: 		    $diropen = "opened";
1.5       harris41  313: 		    delete $dupdirs{key},$dirs{$key};
                    314: 		}
1.3       harris41  315: 	    }
1.1       www       316: 	}
1.4       harris41  317: 	&display_line($r,$diropen,$line,$indent,$curdir,@list);
1.11      ng        318: 	&scanDir ($r,$compuri,$indent) if $diropen eq "opened";
1.1       www       319:     }
                    320:     $indent--;
                    321: }
                    322: 
1.2       harris41  323: # ----------------- get complete matched list based on the uri ------
1.1       www       324: sub get_list {
                    325:     my ($r,$uri)=@_;
                    326:     my @list;
1.2       harris41  327:     my $luri = $uri;
                    328:     $luri =~ s/\//_/g;
                    329: 
1.6       harris41  330:     if ($ENV{'form.attrs'} eq "Refresh") {
1.4       harris41  331: 	map {
                    332: 	    delete $hash{$_} if ($_ =~ /^dirlist_files_/);
                    333: 	    } keys %hash;
1.2       harris41  334:     }
                    335: 
1.4       harris41  336:     if ($hash{'dirlist_files'.$luri}) {
                    337: 	@list = split(/\n/,$hash{'dirlist_files_'.$luri});
1.1       www       338:     } else {
1.4       harris41  339: 	@list = &Apache::lonnet::dirlist($uri);
                    340: 	$hash{'dirlist_files_'.$luri} = join('\n',@list);
1.1       www       341:     }
                    342:     return @list=&match_ext($r,@list);
                    343: }
                    344: 
1.2       harris41  345: #-------------------------- filters out files based on extensions
1.1       www       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');
1.12    ! ng        354:     my $fn = $tabdir.'/filetypes.tab';
1.1       www       355:     if (-e $fn) {
                    356: 	my $FH=Apache::File->new($fn);
                    357: 	my @content=<$FH>;
1.2       harris41  358: 	foreach my $line (@content) {
1.1       www       359: 	    (my $ext,my $foo) = split /\s+/,$line;
                    360: 	    push @fileext,$ext;
                    361: 	}
                    362:     }
1.2       harris41  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;
1.1       www       375: 	    }
                    376: 	} else {
1.2       harris41  377: 	    push @trimlist,$line;
1.1       www       378: 	}
                    379:     }
1.4       harris41  380:     @trimlist = sort (@trimlist);
1.1       www       381:     return @trimlist;
                    382: }
                    383: 
1.2       harris41  384: #------------------- displays one line in appropriate table format
1.1       www       385: sub display_line{
1.4       harris41  386:     my ($r,$diropen,$line,$indent,$startdir,@list)=@_;
1.1       www       387:     my (@pathfn, $fndir, $fnptr);
                    388:     my $dirptr=16384;
                    389:     my $fileclr="#ffffe6";
1.10      harris41  390:     my $iconpath= $r->dir_config('lonIconsURL') . "/";
1.1       www       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;
1.4       harris41  396:     my $msg = 'View '.$filecom[0].' resources';
1.11      ng        397:     $msg = 'Close '.$filecom[0].' directory' if $diropen eq "opened";
1.1       www       398: 
                    399:     my $tabtag="</td>";
                    400:     my $i=0;
                    401: 
                    402:     while ($i<=5) {
1.6       harris41  403: 	$tabtag=join('',$tabtag,"<td bgcolor=",$fileclr,">&nbsp;</td>") if $hash{'display_attrs_'.$i} == 1;
1.1       www       404: 	$i++;
                    405:     }
                    406:     if ($filecom[1] eq "domain") {
1.7       harris41  407: 	$r->print("<tr>$extrafield");
1.1       www       408: 	$r->print("<td bgcolor=$fileclr valign=bottom>");
1.2       harris41  409: 	&begin_form ($r,$filecom[0].'/');
1.3       harris41  410: 	my $anchor = $filecom[0].'/';
                    411: 	$anchor =~ s/\///g;
1.11      ng        412: 	$r->print ('<a name="'.$anchor.'"><input src="'.$iconpath.'server.gif"');
                    413: 	$r->print (' name="'.$msg.'" height="22" type="image" border="0">'."\n");
1.1       www       414: 	$r->print("Domain - $listname $tabtag</tr></form>\n");
                    415: 	return OK;
                    416:     }
                    417:     if ($filecom[1] eq "user") {
1.7       harris41  418: 	$r->print("<tr>$extrafield");
1.1       www       419: 	$r->print("<td bgcolor=$fileclr valign=bottom>\n");
1.2       harris41  420: 	my $curdir = $startdir.$filecom[0].'/';
                    421: 	&begin_form ($r,$curdir);
1.3       harris41  422: 	my $anchor = $curdir;
                    423: 	$anchor =~ s/\///g;
1.11      ng        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");
1.12    ! ng        427: 	$r->print ('<img src='.$iconpath.'quill.gif border=0>'.$listname.$tabtag.'</tr></form>'."\n");
1.1       www       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];
1.2       harris41  434: 	my $filelink = $startdir.$filecom[0];
1.8       harris41  435: 	$r->print("<tr><td nowrap valign='bottom' bgcolor=$fileclr>");
1.7       harris41  436: 	my $metafile = grep /^$filecom[0]\.meta\&/, @list;
                    437: 	my $title;
                    438:         if ($ENV{'form.catalogmode'} eq 'interactive') {
                    439: 	    $title=$listname;
1.8       harris41  440: 	    $title = &Apache::lonnet::metadata($filelink,'title')
                    441: 		if ($metafile == 1);
1.7       harris41  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");
1.8       harris41  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++;
1.7       harris41  461: 	}
1.4       harris41  462: 
1.12    ! ng        463: 	if ($indent > 0 and $indent < 11) {
1.4       harris41  464: 	    $r->print("<img src=",$iconpath,"whitespace",$indent,".gif border=0>\n");
1.11      ng        465: 	} elsif ($indent >0) {
1.4       harris41  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");
1.1       www       471: 	    $count++;
1.4       harris41  472: 	    }
                    473: 	    $r->print("<img src=",$iconpath,"whitespace",$rem,".gif border=0>\n") if $rem > 0;
1.1       www       474: 	}
1.4       harris41  475: 
1.1       www       476: 	$r->print("<img src=$iconpath$curfext.gif border=0>\n");
1.12    ! ng        477: 	$r->print (" <a href=\"javascript:openWindow('".$filelink."', 'metadatafile', '450', '500', 'no', 'yes')\"; TARGET=_self>$listname</a> ");
1.2       harris41  478: 
1.4       harris41  479: 	$r->print (" (<a href=\"javascript:openWindow('".$filelink.".meta', 'metadatafile', '400', '450', 'no', 'yes')\"; TARGET=_self>metadata</a>) ") if ($metafile == 1);
1.2       harris41  480: 
1.7       harris41  481: 	$r->print("</td>\n");
1.11      ng        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;
1.2       harris41  488: 
1.6       harris41  489: 	if ($hash{'display_attrs_3'} == 1) {
1.4       harris41  490: 	    my $author = &Apache::lonnet::metadata($filelink,'author') if ($metafile == 1);
1.2       harris41  491: 	    $author = '&nbsp;' if (!$author);
                    492: 	    $r->print("<td bgcolor=$fileclr valign=bottom> ".$author." </td>\n");
                    493: 	}
1.6       harris41  494: 	if ($hash{'display_attrs_4'} == 1) {
1.4       harris41  495: 	    my $keywords = &Apache::lonnet::metadata($filelink,'keywords') if ($metafile == 1);
1.2       harris41  496: 	    $keywords = '&nbsp;' if (!$keywords);
                    497: 	    $r->print("<td bgcolor=$fileclr valign=bottom> ".$keywords." </td>\n");
                    498: 	}
1.6       harris41  499: 	if ($hash{'display_attrs_5'} == 1) {
1.4       harris41  500: 	    my $lang = &Apache::lonnet::metadata($filelink,'language') if ($metafile == 1);
1.2       harris41  501: 	    $lang = $language{$lang};
                    502: 	    $lang = '&nbsp;' if (!$lang);
                    503: 	    $r->print("<td bgcolor=$fileclr valign=bottom> ".$lang." </td>\n");
                    504: 	}
1.1       www       505: 	$r->print("</tr>\n");
                    506:     }
1.2       harris41  507: # -- display directory
1.1       www       508:     if ($fnptr == $dirptr) {
                    509: 	my @file_ext = split (/\./,$listname);
                    510: 	my $curfext = $file_ext[scalar(@file_ext)-1];
1.2       harris41  511: 	my $curdir = $startdir.$filecom[0].'/';
1.3       harris41  512: 	my $anchor = $curdir;
                    513: 	$anchor =~ s/\///g;
1.7       harris41  514: 	$r->print("<tr>$extrafield<td bgcolor=$fileclr valign=bottom>");
1.2       harris41  515: 	&begin_form ($r,$curdir);
1.4       harris41  516: 	my $indentm1 = $indent-1;
1.11      ng        517: 	if ($indentm1 < 11 and $indentm1 > 0) {
1.4       harris41  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");
1.12    ! ng        525: 		$count++;
1.4       harris41  526: 	    }
                    527: 	    $r->print("<img src=",$iconpath,"whitespace",$rem,".gif border=0>\n") if $rem > 0;
1.1       www       528: 	}
1.11      ng        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");
1.1       www       532: 	$r->print("$listname $tabtag</tr></form>\n");
                    533:     }
1.2       harris41  534: 
1.1       www       535: }
                    536: 
1.2       harris41  537: #---------------------prints the beginning of a form for directory or file link
1.1       www       538: sub begin_form {
                    539:     my ($r,$uri) = @_;
1.3       harris41  540:     my $anchor = $uri;
                    541:     $anchor =~ s/\///g;
1.12    ! ng        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");
1.1       www       545: 
                    546: }
                    547: 
                    548: 1;
                    549: __END__
1.11      ng        550: 
                    551: 
                    552: 

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