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