1: # The LearningOnline Network with CAPA
2: # Directory Indexer
3: #
4: # $Id: lonindexer.pm,v 1.111 2004/06/16 23:39:01 www Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28: ###
29:
30: ###############################################################################
31: ## ##
32: ## ORGANIZATION OF THIS PERL MODULE ##
33: ## ##
34: ## 1. Description of functions ##
35: ## 2. Modules used by this module ##
36: ## 3. Choices for different output views (detailed, summary, xml, etc) ##
37: ## 4. BEGIN block (to be run once after compilation) ##
38: ## 5. Handling routine called via Apache and mod_perl ##
39: ## 6. Other subroutines ##
40: ## ##
41: ###############################################################################
42:
43: package Apache::lonindexer;
44:
45: # ------------------------------------------------- modules used by this module
46: use strict;
47: use Apache::lonnet();
48: use Apache::loncommon();
49: use Apache::lonhtmlcommon();
50: use Apache::lonsequence();
51: use Apache::Constants qw(:common);
52: use Apache::lonmeta;
53: use Apache::File;
54: use Apache::lonlocal;
55: use Apache::lonsource();
56: use LONCAPA::lonmetadata();
57: use GDBM_File;
58:
59: # ---------------------------------------- variables used throughout the module
60: my %hash; # global user-specific gdbm file
61: my %dirs; # keys are directories, values are the open/close status
62: my %language; # has the reference information present in language.tab
63: my %dynhash; # hash of hashes for dynamic metadata
64:
65: # ----- Values which are set by the handler subroutine and are accessible to
66: # ----- other methods.
67: my $extrafield; # default extra table cell
68: my $fnum; # file counter
69: my $dnum; # directory counter
70:
71: # ----- Used to include or exclude files with certain extensions.
72: my @Only = ();
73: my @Omit = ();
74:
75:
76: # ----------------------------- Handling routine called via Apache and mod_perl
77: sub handler {
78: my $r = shift;
79: my $c = $r->connection();
80: &Apache::loncommon::content_type($r,'text/html');
81: &Apache::loncommon::no_cache($r);
82: $r->send_http_header;
83: return OK if $r->header_only;
84: $fnum=0;
85: $dnum=0;
86:
87: # Deal with stupid global variables (is there a way around making
88: # these global to this package? It is just so wrong....)
89: undef (@Only);
90: undef (@Omit);
91:
92: # ------------------------------------- read in machine configuration variables
93: my $iconpath= $r->dir_config('lonIconsURL') . "/";
94: my $domain = $r->dir_config('lonDefDomain');
95: my $role = $r->dir_config('lonRole');
96: my $loadlim = $r->dir_config('lonLoadLim');
97: my $servadm = $r->dir_config('lonAdmEMail');
98: my $sysadm = $r->dir_config('lonSysEMail');
99: my $lonhost = $r->dir_config('lonHostID');
100: my $tabdir = $r->dir_config('lonTabDir');
101:
102: my $fileclr='#ffffe6';
103: my $line;
104: my (@attrchk,@openpath);
105: my $uri=$r->uri;
106:
107: # -------------------------------------- see if called from an interactive mode
108: # Get the parameters from the query string
109: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
110: ['catalogmode','launch','acts','mode','form','element',
111: 'only','omit','titleelement']);
112: #-------------------------------------------------------------------
113: my $closebutton='';
114: my $groupimportbutton='';
115: my $colspan='';
116:
117: $extrafield='';
118: my $diropendb =
119: "/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_indexer.db";
120: %hash = ();
121: {
122: my %dbfile;
123: if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_READER(),0640)) {
124: while(my($key,$value)=each(%dbfile)) {
125: $hash{$key}=$value;
126: }
127: untie(%dbfile);
128: }
129: }
130: {
131: if ($ENV{'form.launch'} eq '1') {
132: &start_fresh_session();
133: }
134: #Hijack lonindexer to verify a title and be close down.
135: if ($ENV{'form.launch'} eq '2') {
136: $r->content_type('text/html');
137: my $extra='';
138: if (defined($ENV{'form.titleelement'})) {
139: my $verify_title = &Apache::lonnet::gettitle($ENV{'form.acts'});
140: &Apache::lonnet::logthis("Hrrm $ENV{'form.acts'} -- $verify_title");
141: $verify_title=~s/'/\\'/g;
142: $extra='window.opener.document.forms["'.$ENV{'form.form'}.'"].elements["'.$ENV{'form.titleelement'}.'"].value=\''.$verify_title.'\';';
143: }
144: $r->print(<<ENDSUBM);
145: <html>
146: <script type="text/javascript">
147: function load() {
148: window.opener.document.forms["$ENV{'form.form'}"].elements["$ENV{'form.element'}"].value='$ENV{'form.acts'}';
149: $extra
150: window.close();
151: }
152: </script>
153: <body onLoad=load();>
154: </body>
155: </html>
156: ENDSUBM
157: return OK;
158: }
159:
160: # -------------------- refresh environment with user database values (in %hash)
161: &setvalues(\%hash,'form.catalogmode',\%ENV,'form.catalogmode' );
162:
163: # --------------------- define extra fields and buttons in case of special mode
164: if ($ENV{'form.catalogmode'} eq 'interactive') {
165: $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
166: '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.
167: ' border="0" /></td>';
168: $colspan=" colspan='2' ";
169: my $cl=&mt('Close');
170: $closebutton=<<END;
171: <input type="button" name="close" value='$cl' onClick="self.close()">
172: END
173: }
174: elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
175: $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
176: '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.
177: ' border="0" /></td>';
178: $colspan=" colspan='2' ";
179: my $cl=&mt('Close');
180: my $gi=&mt('Group Import');
181: $closebutton=<<END;
182: <input type="button" name="close" value='$cl' onClick="self.close()">
183: END
184: $groupimportbutton=<<END;
185: <input type="button" name="groupimport" value='$gi'
186: onClick="javascript:select_group()">
187: END
188: }
189: # Additions made by Matthew to make the browser a little easier to deal
190: # with in the future.
191: #
192: # $mode (at this time) indicates if we are in edit mode.
193: # $form is the name of the form that the URL is placed when the
194: # selection is made.
195: # $element is the name of the element in $formname which receives
196: # the URL.
197: #&Apache::lonxml::debug('Checking mode, form, element');
198: &setvalues(\%hash,'form.mode' ,\%ENV,'form.mode' );
199: &setvalues(\%hash,'form.form' ,\%ENV,'form.form' );
200: &setvalues(\%hash,'form.element' ,\%ENV,'form.element');
201: &setvalues(\%hash,'form.titleelement',\%ENV,'form.titleelement');
202: &setvalues(\%hash,'form.only' ,\%ENV,'form.only' );
203: &setvalues(\%hash,'form.omit' ,\%ENV,'form.omit' );
204:
205: # Deal with 'omit' and 'only'
206: if (exists $ENV{'form.omit'}) {
207: @Omit = split(',',$ENV{'form.omit'});
208: }
209: if (exists $ENV{'form.only'}) {
210: @Only = split(',',$ENV{'form.only'});
211: }
212:
213: my $mode = $ENV{'form.mode'};
214: my ($form,$element,$titleelement);
215: if ($mode eq 'edit' || $mode eq 'parmset') {
216: $form = $ENV{'form.form'};
217: $element = $ENV{'form.element'};
218: $titleelement = $ENV{'form.titleelement'};
219: }
220: #&Apache::lonxml::debug("mode=$mode form=$form element=$element titleelement=$titleelement");
221: # ------ set catalogmodefunctions to have extra needed javascript functionality
222: my $catalogmodefunctions='';
223: if ($ENV{'form.catalogmode'} eq 'interactive' or
224: $ENV{'form.catalogmode'} eq 'groupimport') {
225: # The if statement below sets us up to use the old version
226: # by default (ie. if $mode is undefined). This is the easy
227: # way out. Hopefully in the future I'll find a way to get
228: # the calls dealt with in a more comprehensive manner.
229:
230: #
231: # There is now also mode "simple", which is for the simple version of the rat
232: #
233: #
234: if (!defined($mode) || ($mode ne 'edit' && $mode ne 'parmset')) {
235: my $location = "/adm/groupsort?catalogmode=groupimport&";
236: $location .= "mode=".$mode."&";
237: $location .= "acts=";
238: $catalogmodefunctions=<<"END";
239: function select_data(url) {
240: changeURL(url);
241: self.close();
242: }
243: function select_group() {
244: window.location="$location"+document.forms.fileattr.acts.value;
245: }
246: function changeURL(val) {
247: if (opener.inf) {
248: if (opener.inf.document.forms.resinfo.elements.u) {
249: opener.inf.document.forms.resinfo.elements.u.value=val;
250: }
251: }
252: }
253: END
254: } elsif ($mode eq 'edit') { # we are in 'edit' mode
255: my $location = "/adm/groupsort?catalogmode=interactive&";
256: $location .= "form=$form&element=$element&mode=edit&acts=";
257: $catalogmodefunctions=<<END;
258: // mode = $mode
259: function select_data(url) {
260: var location = "/res/?launch=2&form=$form&element=$element&titleelement=$titleelement&acts=" + url;
261: window.location=location;
262: }
263: function select_group() {
264: window.location="$location"+document.forms.fileattr.acts.value;
265: }
266:
267: function changeURL(val) {
268: if (window.opener.document) {
269: window.opener.document.forms["$form"].elements["$element"].value=val;
270: } else {
271: alert("The file you selected is: "+val);
272: }
273: }
274: END
275: if (!$titleelement) {
276: $catalogmodefunctions.='function changeTitle(val) {}';
277: } else {
278: $catalogmodefunctions.=<<END;
279: function changeTitle(val) {
280: if (window.opener.document) {
281: window.opener.document.forms["$form"].elements["$titleelement"].value=val;
282: } else {
283: alert("The title of the file you selected is: "+val);
284: }
285: }
286: END
287: }
288: } elsif ($mode eq 'parmset') {
289: my $location = "/adm/groupsort?catalogmode=interactive&";
290: $location .= "form=$form&element=$element&mode=parmset&acts=";
291: $catalogmodefunctions=<<END;
292: // mode = $mode
293: function select_data(url) {
294: changeURL(url);
295: self.close();
296: }
297:
298: function select_group() {
299: window.location="$location"+document.forms.fileattr.acts.value;
300: }
301:
302: function changeURL(val) {
303: if (window.opener.document) {
304: var elementname = "$element"+"_value";
305: var checkboxname = "$element"+"_setparmval";
306: window.opener.document.forms["$form"].elements[elementname].value=val;
307: window.opener.document.forms["$form"].elements[checkboxname].checked=true;
308: } else {
309: alert("The file you selected is: "+val);
310: }
311: }
312:
313: END
314: }
315: }
316: $catalogmodefunctions.=<<END;
317: var acts='';
318: function rep_dirpath(suffix,val) {
319: eval("document.forms.dirpath"+suffix+".acts.value=val");
320: }
321: END
322: if ($ENV{'form.catalogmode'} eq 'groupimport') {
323: $catalogmodefunctions.=<<END;
324: function queue(val) {
325: if (eval("document.forms."+val+".filelink.checked")) {
326: var l=val.length;
327: var v=val.substring(4,l);
328: document.forms.fileattr.acts.value+='1a'+v+'b';
329: }
330: else {
331: var l=val.length;
332: var v=val.substring(4,l);
333: document.forms.fileattr.acts.value+='0a'+v+'b';
334: }
335: }
336: END
337: }
338:
339: # ---------------------------------------------------------------- Print Header
340: $r->print(<<ENDHEADER);
341: <html>
342: <head>
343: <title>The LearningOnline Network With CAPA Directory Browser</title>
344:
345: <script type="text/javascript">
346: $catalogmodefunctions
347: function openWindow(url, wdwName, w, h, toolbar,scrollbar,locationbar) {
348: var xpos = (screen.width-w)/2;
349: xpos = (xpos < 0) ? '0' : xpos;
350: var ypos = (screen.height-h)/2-30;
351: ypos = (ypos < 0) ? '0' : ypos;
352: var options = "width=" + w + ",height=" + h + ",screenx="+xpos+",screeny="+ypos+",";
353: options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
354: options += "menubar=no,toolbar="+toolbar+",location="+locationbar+",directories=no";
355: var newWin = window.open(url, wdwName, options);
356: newWin.focus();
357: }
358: function gothere(val) {
359: window.location=val+'?acts='+document.forms.fileattr.acts.value;
360: }
361: </script>
362:
363: </head>
364: ENDHEADER
365: my ($headerdom)=($uri=~/^\/res\/(\w+)\//);
366: $r->print(&Apache::loncommon::bodytag('Browse Resources',undef,undef,undef,
367: $headerdom));
368: # - Evaluate actions from previous page (both cumulatively and chronologically)
369: if ($ENV{'form.catalogmode'} eq 'groupimport') {
370: my $acts=$ENV{'form.acts'};
371: my @Acts=split(/b/,$acts);
372: my %ahash;
373: my %achash;
374: my $ac=0;
375: # some initial hashes for working with data
376: foreach (@Acts) {
377: my ($state,$ref)=split(/a/);
378: $ahash{$ref}=$state;
379: $achash{$ref}=$ac;
380: $ac++;
381: }
382: # sorting through the actions and changing the global database hash
383: foreach (sort {$achash{$a}<=>$achash{$b}} (keys %ahash)) {
384: my $key=$_;
385: if ($ahash{$key} eq '1') {
386: $hash{'store_'.$hash{'pre_'.$key.'_link'}}=
387: $hash{'pre_'.$key.'_title'};
388: $hash{'storectr_'.$hash{'pre_'.$key.'_link'}}=
389: $hash{'storectr'}+0;
390: $hash{'storectr'}++;
391: }
392: if ($ahash{$key} eq '0') {
393: if ($hash{'store_'.$hash{'pre_'.$key.'_link'}}) {
394: delete $hash{'store_'.$hash{'pre_'.$key.'_link'}};
395: }
396: }
397: }
398: # deleting the previously cached listing
399: foreach (keys %hash) {
400: if ($_ =~ /^pre_/ && $_ =~/link$/) {
401: my $key = $_;
402: $key =~ s/^pre_//;
403: $key =~ s/_[^_]*$//;
404: delete $hash{'pre_'.$key.'_title'};
405: delete $hash{'pre_'.$key.'_link'};
406: }
407: }
408: }
409:
410: # ---------------------------------- get state of file attributes to be showing
411: if ($ENV{'form.attrs'}) {
412: for (my $i=0; $i<=11; $i++) {
413: delete $hash{'display_attrs_'.$i};
414: if ($ENV{'form.attr'.$i} == 1) {
415: $attrchk[$i] = 'checked';
416: $hash{'display_attrs_'.$i} = 1;
417: }
418: }
419: } else {
420: for (my $i=0; $i<=11; $i++) {
421: $attrchk[$i] = 'checked' if $hash{'display_attrs_'.$i} == 1;
422: }
423: }
424:
425: # ------------------------------- output state of file attributes to be showing
426: # All versions has to the last item
427: # since it does not take an extra col
428: my %lt=&Apache::lonlocal::texthash(
429: 'ti' => 'Title',
430: 'si' => 'Size',
431: 'la' => 'Last access',
432: 'lm' => 'Last modified',
433: 'st' => 'Statistics',
434: 'au' => 'Author',
435: 'kw' => 'Keywords',
436: 'ln' => 'Language',
437: 'sa' => 'Source Available',
438: 'sr' => 'Show resource',
439: 'li' => 'Linked/Related Resources',
440: 'av' => 'All versions',
441: 'ud' => 'Update Display'
442: );
443: my $Displayfileattributes=&mt('Display file attributes');
444: $r->print(<<END);
445: <form method="post" name="fileattr" action="$uri"
446: enctype="application/x-www-form-urlencoded">
447: <b><font color="#666666">$Displayfileattributes</font></b><br />
448: <table border=0><tr>
449: <td><input type="checkbox" name="attr0" value="1" $attrchk[0] onClick="this.form.submit();" /> $lt{'ti'}</td>
450: <td><input type="checkbox" name="attr1" value="1" $attrchk[1] onClick="this.form.submit();" /> $lt{'si'}</td>
451: <td><input type="checkbox" name="attr2" value="1" $attrchk[2] onClick="this.form.submit();" /> $lt{'la'}</td>
452: <td><input type="checkbox" name="attr3" value="1" $attrchk[3] onClick="this.form.submit();" /> $lt{'lm'}</td>
453: <td><input type="checkbox" name="attr8" value="1" $attrchk[8] onClick="this.form.submit();" /> $lt{'st'}</td>
454: <td><input type="checkbox" name="attr10" value="1" $attrchk[10] onClick="this.form.submit();" /> $lt{'sa'}</td>
455: </tr><tr>
456: <td><input type="checkbox" name="attr4" value="1" $attrchk[4] onClick="this.form.submit();" /> $lt{'au'}</td>
457: <td><input type="checkbox" name="attr5" value="1" $attrchk[5] onClick="this.form.submit();" /> $lt{'kw'}</td>
458: <td><input type="checkbox" name="attr6" value="1" $attrchk[6] onClick="this.form.submit();" /> $lt{'ln'}</td>
459: <td><input type="checkbox" name="attr7" value="1" $attrchk[7] onClick="this.form.submit();" /> $lt{'sr'}</td>
460: <td><input type="checkbox" name="attr9" value="1" $attrchk[9] onClick="this.form.submit();" /> $lt{'av'}</td>
461: <td><input type="checkbox" name="attr11" value="1" $attrchk[11] onClick="this.form.submit();" /> $lt{'li'}</td>
462: </tr></table>
463: <input type="hidden" name="attrs" value="1" />
464: <input type="submit" name="updatedisplay" value="$lt{'ud'}" />
465: <input type="hidden" name="acts" value="" />
466: $closebutton $groupimportbutton
467: END
468: # -------------- Filter out sequence containment in crumbs and "recent folders"
469: my $storeuri=$uri;
470: $storeuri='/'.(split(/\.(page|sequence)\/\//,$uri))[-1];
471: $storeuri=~s/\/+/\//g;
472: # ---------------------------------------------------------------- Bread crumbs
473: $r->print(&Apache::lonhtmlcommon::crumbs($storeuri,'','',
474: (($ENV{'form.catalogmode'} eq 'groupimport')?
475: 'document.forms.fileattr':'')).
476: &Apache::lonhtmlcommon::select_recent('residx','resrecent',
477: 'this.form.action=this.form.resrecent.options[this.form.resrecent.selectedIndex].value;this.form.submit();'));
478: # -------------------------------------------------------- Resource Home Button
479: my $reshome=$ENV{'course.'.$ENV{'request.course.id'}.'.reshome'};
480: if ($reshome) {
481: $r->print("<font size='+2'><a href='");
482: if ($ENV{'form.catalogmode'} eq 'groupimport') {
483: $r->print('javascript:document.forms.fileattr.action="'.$reshome.'";document.forms.fileattr.submit();');
484: } else {
485: $r->print($reshome);
486: }
487: $r->print("'>".&mt('Home').'</a></font>');
488: }
489: $r->print('</form>');
490: # ------------------------------------------------------ Remember where we were
491: &Apache::loncommon::storeresurl($storeuri);
492: &Apache::lonhtmlcommon::store_recent('residx',$storeuri,$storeuri);
493: # ----------------- output starting row to the indexed file/directory hierarchy
494: my $titleclr="#ddffff";
495: # $r->print(&initdebug());
496: # $r->print(&writedebug("Omit:@Omit")) if (@Omit);
497: # $r->print(&writedebug("Only:@Only")) if (@Only);
498: $r->print("<table width='100\%' border=0><tr><td bgcolor=#777777>\n");
499: $r->print("<table width='100\%' border=0><tr bgcolor=$titleclr>\n");
500: $r->print("<td $colspan><b>".&mt('Name')."</b></td>\n");
501: $r->print("<td><b>".&mt('Title')."</b></td>\n")
502: if ($hash{'display_attrs_0'} == 1);
503: $r->print("<td align=right><b>".&mt("Size")." (".&mt("bytes").") ".
504: "</b></td>\n") if ($hash{'display_attrs_1'} == 1);
505: $r->print("<td><b>".&mt("Last accessed")."</b></td>\n")
506: if ($hash{'display_attrs_2'} == 1);
507: $r->print("<td><b>".&mt("Last modified")."</b></td>\n")
508: if ($hash{'display_attrs_3'} == 1);
509: $r->print("<td><b>".&mt("Author(s)")."</b></td>\n")
510: if ($hash{'display_attrs_4'} == 1);
511: $r->print("<td><b>".&mt("Keywords")."</b></td>\n")
512: if ($hash{'display_attrs_5'} == 1);
513: $r->print("<td><b>".&mt("Language")."</b></td>\n")
514: if ($hash{'display_attrs_6'} == 1);
515: $r->print("<td><b>".&mt("Resource")."</b></td>\n")
516: if ($hash{'display_attrs_7'} == 1);
517: $r->print("<td><b>".&mt("Usage Statistics")." <br />(".
518: &mt("Courses/Network Hits").")</b></td>\n")
519: if ($hash{'display_attrs_8'} == 1);
520: $r->print("<td><b>".&mt("Source Available")."</b></td>\n")
521: if ($hash{'display_attrs_10'} == 1);
522: $r->print("<td><b>".&mt("Linked/Related Resources")."</b></td>\n")
523: if ($hash{'display_attrs_11'} == 1);
524: $r->print('</tr>');
525:
526: # ----------------- read in what directories have previously been set to "open"
527: foreach (keys %hash) {
528: if ($_ =~ /^diropen_status_/) {
529: my $key = $_;
530: $key =~ s/^diropen_status_//;
531: $dirs{$key} = $hash{$_};
532: }
533: }
534:
535: if ($ENV{'form.openuri'}) { # take care of review and refresh options
536: my $uri=$ENV{'form.openuri'};
537: if (exists($hash{'diropen_status_'.$uri})) {
538: my $cursta = $hash{'diropen_status_'.$uri};
539: $dirs{$uri} = 'open';
540: $hash{'diropen_status_'.$uri} = 'open';
541: if ($cursta eq 'open') {
542: $dirs{$uri} = 'closed';
543: $hash{'diropen_status_'.$uri} = 'closed';
544: }
545: } else {
546: $hash{'diropen_status_'.$uri} = 'open';
547: $dirs{$uri} = 'open';
548: }
549: }
550:
551: my $toplevel;
552: my $indent = 0;
553: $uri = $uri.'/' if $uri !~ /.*\/$/;
554:
555: if ($ENV{'form.dirPointer'} ne 'on') {
556: $hash{'top.level'} = $uri;
557: $toplevel = $uri;
558: } else {
559: $toplevel = $hash{'top.level'};
560: }
561:
562: # -------------------------------- if not at top level, provide an uplink arrow
563: if ($toplevel ne '/res/'){
564: my (@uri_com) = split(/\//,$uri);
565: pop @uri_com;
566: my $upone = join('/',@uri_com);
567: my @list = qw (0);
568: &display_line ($r,'opened',$upone.'&viewOneUp',0,$upone,@list);
569: $indent = 1;
570: }
571:
572: # -------- recursively go through all the directories and output as appropriate
573: &scanDir ($r,$toplevel,$indent,\%hash);
574:
575: # ---------------------------- embed hidden information useful for group import
576: $r->print("<form name='fnum'>");
577: $r->print("<input type='hidden' name='fnum' value='$fnum'></form>");
578:
579: # -------------------------------------------------------------- end the tables
580: $r->print('</table>');
581: $r->print('</td></tr></table>');
582:
583: # --------------------------------------------------- end the output and return
584: $r->print('</body></html>'."\n");
585: }
586: if(! $c->aborted()) {
587: # write back into the temporary file
588: my %dbfile;
589: if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_NEWDB(),0640)) {
590: while (my($key,$value) = each(%hash)) {
591: $dbfile{$key}=$value;
592: }
593: untie(%dbfile);
594: }
595: }
596:
597: return OK;
598: }
599:
600: # ----------------------------------------------- recursive scan of a directory
601: sub scanDir {
602: my ($r,$startdir,$indent,$hashref)=@_;
603: my $c = $r->connection();
604: my ($compuri,$curdir);
605: my $dirptr=16384;
606: my $obs;
607: $indent++;
608: my %dupdirs = %dirs;
609: my @list=&get_list($r,$startdir);
610: foreach my $line (@list) {
611: return if ($c->aborted());
612: #This is a kludge, sorry aboot this
613: my ($strip,$dom,undef,$testdir,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$obs,undef)=split(/\&/,$line,16);
614: next if($strip =~ /.*\.meta$/ | $obs eq '1');
615: my (@fileparts) = split(/\./,$strip);
616: if ($hash{'display_attrs_9'} != 1) {
617: # if not all versions to be shown
618: if (scalar(@fileparts) >= 3) {
619: my $fext = pop @fileparts;
620: my $ov = pop @fileparts;
621: my $fname = join ('.',@fileparts,$fext);
622: next if (grep /\Q$fname\E/,@list and $ov =~ /^\d+$/);
623: }
624: }
625:
626: if ($dom eq 'domain') {
627: # dom list has full path /res/<domain name>/ already
628: $curdir='';
629: $compuri = (split(/\&/,$line))[0];
630: } else {
631: # user, dir & file have name only, i.e., w/o path
632: $compuri = join('',$startdir,$strip,'/');
633: $curdir = $startdir;
634: }
635: my $diropen = 'closed';
636: if (($dirptr&$testdir) or ($dom =~ /^(domain|user)$/) or ($compuri=~/\.(sequence|page)\/$/)) {
637: while (my ($key,$val)= each %dupdirs) {
638: if ($key eq $compuri and $val eq "open") {
639: $diropen = "opened";
640: delete($dupdirs{$key});
641: delete($dirs{$key});
642: }
643: }
644: }
645: &display_line($r,$diropen,$line,$indent,$curdir,$hashref,@list);
646: &scanDir ($r,$compuri,$indent) if $diropen eq 'opened';
647: }
648: $indent--;
649: }
650:
651: # --------------- get complete matched list based on the uri (returns an array)
652: sub get_list {
653: my ($r,$uri)=@_;
654: my @list=();
655: (my $luri = $uri) =~ s/\//_/g;
656: if ($ENV{'form.updatedisplay'}) {
657: foreach (keys %hash) {
658: delete $hash{$_} if ($_ =~ /^dirlist_files_/);
659: }
660: }
661:
662: if ($hash{'dirlist_files_'.$luri}) {
663: @list = split(/\n/,$hash{'dirlist_files_'.$luri});
664: } elsif ($uri=~/\.(page|sequence)\/$/) {
665: # is a page or a sequence
666: $uri=~s/\/$//;
667: $uri='/'.(split(/\.(page|sequence)\/\//,$uri))[-1];
668: $uri=~s/\/+/\//g;
669: foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$uri))) {
670: my @ratpart=split(/\:/,$_);
671: push @list,$ratpart[1];
672: }
673: $hash{'dirlist_files_'.$luri} = join("\n",@list);
674: } else {
675: # is really a directory
676: @list = &Apache::lonnet::dirlist($uri);
677: $hash{'dirlist_files_'.$luri} = join("\n",@list);
678: }
679: return @list=&match_ext($r,@list);
680: }
681:
682: sub initdebug {
683: return <<ENDJS;
684: <script>
685: var debugging = true;
686: if (debugging) {
687: var debuggingWindow = window.open('','Debug','width=400,height=300',true);
688: }
689:
690: function output(text) {
691: if (debugging) {
692: debuggingWindow.document.writeln(text);
693: }
694: }
695: output("<html><head><title>Debugging Window</title></head><body><pre>");
696: </script>
697: ENDJS
698: }
699:
700: sub writedebug {
701: my $text = shift;
702: return "<script>output('$text');</script>";
703: }
704:
705: # -------------------- filters out files based on extensions (returns an array)
706: sub match_ext {
707: my ($r,@packlist)=@_;
708: my @trimlist;
709: my $nextline;
710: my @fileext;
711: my $dirptr=16384;
712:
713: foreach my $line (@packlist) {
714: chomp $line;
715: $line =~ s/^\/home\/httpd\/html//;
716: my @unpackline = split (/\&/,$line);
717: next if ($unpackline[0] eq '.');
718: next if ($unpackline[0] eq '..');
719: my @filecom = split (/\./,$unpackline[0]);
720: my $fext = pop(@filecom);
721: my $fnptr = ($unpackline[3]&$dirptr) || ($fext=~/\.(page|sequence)$/);
722: if ($fnptr == 0 and $unpackline[3] ne "") {
723: my $embstyle = &Apache::loncommon::fileembstyle($fext);
724: push @trimlist,$line if (defined($embstyle) &&
725: ($embstyle ne 'hdn' or $fext eq 'meta'));
726: } else {
727: push @trimlist,$line;
728: }
729: }
730: @trimlist = sort {uc($a) cmp uc($b)} (@trimlist);
731: return @trimlist;
732: }
733:
734: # ------------------------------- displays one line in appropriate table format
735: sub display_line {
736: my ($r,$diropen,$line,$indent,$startdir,$hashref,@list)=@_;
737: my (@pathfn, $fndir);
738: # there could be relative paths (files actually belonging into this directory)
739: # or absolute paths (for example, from sequences)
740: my $absolute;
741: my $pathprefix;
742: if ($line=~m|^/res/| && $startdir ne '') {
743: $absolute=1;
744: $pathprefix='';
745: } else {
746: $absolute=0;
747: $pathprefix=$startdir;
748: }
749: my $dirptr=16384;
750: my $fileclr="#ffffe6";
751: my $iconpath= $r->dir_config('lonIconsURL') . '/';
752:
753: my @filecom = split (/\&/,$line);
754: my @pathcom = split (/\//,$filecom[0]);
755: my $listname = $pathcom[scalar(@pathcom)-1];
756: my $fnptr = $filecom[3]&$dirptr;
757: my $msg = &mt('View').' '.$filecom[0].' '.&mt('resources');
758: $msg = &mt('Close').' '.$filecom[0].' '.&mt('directory') if $diropen eq 'opened';
759:
760: my $tabtag='</td>';
761: my $i=0;
762: while ($i<=11) {
763: $tabtag=join('',$tabtag,"<td> </td>")
764: if $hash{'display_attrs_'.$i} == 1;
765: $i++;
766: }
767: my $valign = ($hash{'display_attrs_7'} == 1 ? 'top' : 'bottom');
768:
769: # display uplink arrow
770: if ($filecom[1] eq 'viewOneUp') {
771: my $updir=$startdir;
772: # -------------- Filter out sequence containment in crumbs and "recent folders"
773: $updir='/'.(split(/\.(page|sequence)\/\//,$startdir))[-1];
774: $updir=~s/\/+/\//g;
775:
776: $r->print("<tr valign='$valign' bgcolor=$fileclr>$extrafield");
777: $r->print("<td>\n");
778: $r->print ('<form method="post" name="dirpathUP" action="'.$updir.
779: '/" '.
780: 'onSubmit="return rep_dirpath(\'UP\','.
781: 'document.forms.fileattr.acts.value)" '.
782: 'enctype="application/x-www-form-urlencoded"'.
783: '>'."\n");
784: $r->print ('<input type=hidden name=openuri value="'.
785: $startdir.'">'."\n");
786: $r->print ('<input type="hidden" name="acts" value="">'."\n");
787: $r->print ('<input src="'.$iconpath.'arrow_up.gif"');
788: $r->print (' name="'.$msg.'" height="22" type="image" border="0">'.
789: "\n");
790: $r->print(&mt("Up")." $tabtag</tr></form>\n");
791: return OK;
792: }
793: # Do we have permission to look at this?
794:
795: if($filecom[15] ne '1') { return OK if (!&Apache::lonnet::allowed('bre',$pathprefix.$filecom[0])); }
796:
797: # make absolute links appear on different background
798: if ($absolute) { $fileclr='#aaaa88'; }
799:
800: # display domain
801: if ($filecom[1] eq 'domain') {
802: $r->print ('<input type="hidden" name="dirPointer" value="on">'."\n")
803: if ($ENV{'form.dirPointer'} eq "on");
804: $r->print("<tr valign='$valign' bgcolor=$fileclr>$extrafield");
805: $r->print("<td>");
806: &begin_form ($r,$filecom[0]);
807: my $anchor = $filecom[0];
808: $anchor =~ s/\///g;
809: $r->print ('<a name="'.$anchor.'">');
810: $r->print ('<input type="hidden" name="acts" value="">');
811: $r->print ('<input src="'.$iconpath.'folder_pointer_'.
812: $diropen.'.gif"');
813: $r->print (' name="'.$msg.'" height="22" type="image" border="0">'.
814: "\n");
815: $r->print ('<a href="javascript:gothere(\''.$filecom[0].
816: '\')"><img src="'.$iconpath.'server.gif"');
817: $r->print (' border="0" /></a>'."\n");
818: $r->print (&mt("Domain")." - $listname ");
819: if ($Apache::lonnet::domaindescription{$listname}) {
820: $r->print("(".$Apache::lonnet::domaindescription{$listname}.
821: ")");
822: }
823: $r->print (" $tabtag</tr></form>\n");
824: return OK;
825:
826: # display user directory
827: }
828: if ($filecom[1] eq 'user') {
829: $r->print("<tr valign=$valign bgcolor=$fileclr>$extrafield");
830: $r->print("<td nowrap>\n");
831: my $curdir = $startdir.$filecom[0].'/';
832: my $anchor = $curdir;
833: $anchor =~ s/\///g;
834: &begin_form ($r,$curdir);
835: $r->print ('<a name="'.$anchor.'"><img src="'.$iconpath.
836: 'whitespace1.gif" border="0" />'."\n");
837: $r->print ('<input type="hidden" name="acts" value="">');
838: $r->print ('<input src="'.$iconpath.'folder_pointer_'.$diropen.
839: '.gif"');
840: $r->print (' name="'.$msg.'" height="22" type="image" border="0">'.
841: "\n");
842: $r->print ('<a href="javascript:gothere(\''.$curdir.'\')"><img src='.
843: $iconpath.'quill.gif border="0" name="'.$msg.
844: '" height="22" /></a>');
845: my $domain=(split(m|/|,$startdir))[2];
846: my $plainname=&Apache::loncommon::plainname($listname,$domain);
847: $r->print ($listname);
848: if (defined($plainname) && $plainname) { $r->print(" ($plainname) "); }
849: $r->print ($tabtag.'</tr></form>'."\n");
850: return OK;
851: }
852:
853: # display file
854: if (($fnptr == 0 and $filecom[3] ne '') or $absolute) {
855: my $filelink = $pathprefix.$filecom[0];
856: my @file_ext = split (/\./,$listname);
857: my $curfext = $file_ext[-1];
858: if (@Omit) {
859: foreach (@Omit) { return OK if ($curfext eq $_); }
860: }
861: if (@Only) {
862: my $skip = 1;
863: foreach (@Only) { $skip = 0 if ($curfext eq $_); }
864: return OK if ($skip > 0);
865: }
866: # Set the icon for the file
867: my $iconname = &Apache::loncommon::icon($listname);
868: $r->print("<tr valign='$valign' bgcolor=$fileclr><td nowrap>");
869:
870: my $metafile = $Apache::lonnet::perlvar{'lonDocRoot'}.$pathprefix.
871: $filecom[0].'.meta';
872: if (-e $metafile) {
873: $metafile=1;
874: } else {
875: $metafile=0;
876: }
877: if ($ENV{'form.catalogmode'} eq 'interactive') {
878: $r->print("<a href=\"javascript:select_data(\'",
879: $filelink,"')\">");
880: $r->print("<img src='",$iconpath,"select.gif' border='0' /></a>".
881: "\n");
882: $r->print("</td><td nowrap>");
883: } elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
884: $r->print("<form name='form$fnum'>\n");
885: $r->print("<input type='checkbox' name='filelink"."' ".
886: "value='$filelink' onClick='".
887: "javascript:queue(\"form$fnum\")' ");
888: if ($hash{'store_'.$filelink}) {
889: $r->print("checked");
890: }
891: $r->print(">\n");
892: $r->print("</form>\n");
893: $r->print("</td><td nowrap>");
894: $hash{"pre_${fnum}_link"}=$filelink;
895: $fnum++;
896: }
897: # Form to open or close sequences
898: if ($filelink=~/\.(page|sequence)$/) {
899: my $curdir = $startdir.$filecom[0].'/';
900: my $anchor = $curdir;
901: $anchor =~ s/\///g;
902: &begin_form($r,$curdir);
903: $indent--;
904: }
905: # General indentation
906: if ($indent > 0 and $indent < 11) {
907: $r->print("<img src=",$iconpath,"whitespace",$indent,
908: ".gif border='0' />\n");
909: } elsif ($indent >0) {
910: my $ten = int($indent/10.);
911: my $rem = $indent%10.0;
912: my $count = 0;
913: while ($count < $ten) {
914: $r->print("<img src=",$iconpath,
915: "whitespace10.gif border='0' />\n");
916: $count++;
917: }
918: $r->print("<img src=",$iconpath,"whitespace",$rem,
919: ".gif border='0' />\n") if $rem > 0;
920: }
921: # Sequence open/close icon
922: if ($filelink=~/\.(page|sequence)$/) {
923: my $curdir = $startdir.$filecom[0].'/';
924: my $anchor = $curdir;
925: $anchor =~ s/\///g;
926: $r->print ('<input type="hidden" name="acts" value="">');
927: $r->print ('<a name="'.$anchor.'"><input src="'.$iconpath.
928: 'folder_pointer_'.$diropen.'.gif"');
929: $r->print (' name="'.$msg.'" height="22" type="image" border="0">'.
930: "\n");
931: }
932: # Filetype icons
933: $r->print("<img src='$iconname' border='0' />\n");
934: # Close form to open/close sequence
935: if ($filelink=~/\.(page|sequence)$/) {
936: $r->print('</form>');
937: }
938: $r->print (" <a href=\"javascript:openWindow('".$filelink.
939: "', 'previewfile', '450', '500', 'no', 'yes','yes')\";".
940: " TARGET=_self>$listname</a> ");
941:
942: $r->print (" (<a href=\"javascript:openWindow('".$filelink.
943: ".meta', 'metadatafile', '500', '550', 'no', 'yes','no')\"; ".
944: "TARGET=_self>metadata</a>) ");
945: $r->print("</td>\n");
946: if ($hash{'display_attrs_0'} == 1) {
947: my $title = &Apache::lonnet::gettitle($filelink,'title');
948: $r->print('<td> '.($title eq '' ? ' ' : $title).
949: ' </td>'."\n");
950: }
951: $r->print('<td align=right> ',
952: $filecom[8]," </td>\n")
953: if $hash{'display_attrs_1'} == 1;
954: $r->print('<td> '.
955: (localtime($filecom[9]))." </td>\n")
956: if $hash{'display_attrs_2'} == 1;
957: $r->print('<td> '.
958: (localtime($filecom[10]))." </td>\n")
959: if $hash{'display_attrs_3'} == 1;
960:
961: if ($hash{'display_attrs_4'} == 1) {
962: my $author = &Apache::lonnet::metadata($filelink,'author');
963: $r->print('<td> '.($author eq '' ? ' ' : $author).
964: " </td>\n");
965: }
966: if ($hash{'display_attrs_5'} == 1) {
967: my $keywords = &Apache::lonnet::metadata($filelink,'keywords');
968: # $keywords = ' ' if (!$keywords);
969: $r->print('<td> '.($keywords eq '' ? ' ' : $keywords).
970: " </td>\n");
971: }
972: #'
973:
974: if ($hash{'display_attrs_6'} == 1) {
975: my $lang = &Apache::lonnet::metadata($filelink,'language');
976: $lang = &Apache::loncommon::languagedescription($lang);
977: $r->print('<td> '.($lang eq '' ? ' ' : $lang).
978: " </td>\n");
979: }
980: if ($hash{'display_attrs_7'} == 1) {
981: my $output='';
982: my $embstyle=&Apache::loncommon::fileembstyle($curfext);
983: if ($embstyle eq 'ssi') {
984: my $cache=$Apache::lonnet::perlvar{'lonDocRoot'}.$filelink.
985: '.tmp';
986: if ((!$ENV{'form.updatedisplay'}) &&
987: (-e $cache)) {
988: open(FH,$cache);
989: $output=join("\n",<FH>);
990: close(FH);
991: } else {
992: $output=&Apache::lonnet::ssi_body($filelink);
993: open(FH,">$cache");
994: print FH $output;
995: close(FH);
996: }
997: $output='<font size="-2">'.$output.'</font>';
998: } elsif ($embstyle eq 'img') {
999: $output='<img src="'.$filelink.'" />';
1000: } elsif ($filelink=~/^\/res\/(\w+)\/(\w+)\//) {
1001: $output='<img src="http://'.
1002: $Apache::lonnet::hostname{&Apache::lonnet::homeserver($2,$1)}.
1003: '/cgi-bin/thumbnail.gif?url='.$filelink.'" />';
1004: }
1005: $r->print('<td> '.($output eq '' ? ' ':$output).
1006: " </td>\n");
1007: }
1008: if ($hash{'display_attrs_8'} == 1) {
1009: # statistics
1010: $r->print("<td> </td>\n");
1011:
1012: }
1013: if ($hash{'display_attrs_10'} == 1) {
1014: my $source = &Apache::lonnet::metadata($filelink,'sourceavail');
1015: if($source eq 'open') {
1016: my $sourcelink = &Apache::lonsource::make_link($filelink);
1017: $r->print('<td>'."<a href=\"javascript:openWindow('".$sourcelink.
1018: "', 'previewsource', '700', '700', 'no', 'yes','yes')\";".
1019: " TARGET=_self>Yes</a> "."</td>\n");
1020: } else { #A cuddled else. :P
1021: $r->print("<td> </td>\n");
1022: }
1023: }
1024: if ($hash{'display_attrs_11'} == 1) {
1025: # links
1026: $r->print("<td> </td>\n");
1027: }
1028: $r->print("</tr>\n");
1029: }
1030:
1031: # -- display directory
1032: if ($fnptr == $dirptr) {
1033: my $curdir = $startdir.$filecom[0].'/';
1034: my $anchor = $curdir;
1035: $anchor =~ s/\///g;
1036: $r->print("<tr bgcolor=$fileclr>$extrafield<td valign=$valign>");
1037: &begin_form ($r,$curdir);
1038: my $indentm1 = $indent-1;
1039: if ($indentm1 < 11 and $indentm1 > 0) {
1040: $r->print("<img src=",$iconpath,"whitespace",$indentm1,
1041: ".gif border='0' />\n");
1042: } else {
1043: my $ten = int($indentm1/10.);
1044: my $rem = $indentm1%10.0;
1045: my $count = 0;
1046: while ($count < $ten) {
1047: $r->print ("<img src=",$iconpath
1048: ,"whitespace10.gif border='0' />\n");
1049: $count++;
1050: }
1051: $r->print ("<img src=",$iconpath,"whitespace",$rem,
1052: ".gif border='0' />\n") if $rem > 0;
1053: }
1054: $r->print ('<input type="hidden" name="acts" value="">');
1055: $r->print ('<a name="'.$anchor.'"><input src="'.$iconpath.
1056: 'folder_pointer_'.$diropen.'.gif"');
1057: $r->print (' name="'.$msg.'" height="22" type="image" border="0">'.
1058: "\n");
1059: $r->print ('<a href="javascript:gothere(\''.$curdir.'\')"><img src="'.
1060: $iconpath.'folder_'.$diropen.'.gif" border="0" /></a>'.
1061: "\n");
1062: $r->print ("$listname</td>\n");
1063: # Attributes
1064: my $filelink = $startdir.$filecom[0].'/default';
1065:
1066: if ($hash{'display_attrs_0'} == 1) {
1067: my $title = &Apache::lonnet::gettitle($filelink,'title');
1068: $r->print('<td> '.($title eq '' ? ' ' : $title).
1069: ' </td>'."\n");
1070: }
1071: $r->print('<td align=right> ',
1072: $filecom[8]," </td>\n")
1073: if $hash{'display_attrs_1'} == 1;
1074: $r->print('<td> '.
1075: (localtime($filecom[9]))." </td>\n")
1076: if $hash{'display_attrs_2'} == 1;
1077: $r->print('<td> '.
1078: (localtime($filecom[10]))." </td>\n")
1079: if $hash{'display_attrs_3'} == 1;
1080:
1081: if ($hash{'display_attrs_4'} == 1) {
1082: my $author = &Apache::lonnet::metadata($filelink,'author');
1083: $r->print('<td> '.($author eq '' ? ' ' : $author).
1084: " </td>\n");
1085: }
1086: if ($hash{'display_attrs_5'} == 1) {
1087: my $keywords = &Apache::lonnet::metadata($filelink,'keywords');
1088: # $keywords = ' ' if (!$keywords);
1089: $r->print('<td> '.($keywords eq '' ? ' ' : $keywords).
1090: " </td>\n");
1091: }
1092: if ($hash{'display_attrs_6'} == 1) {
1093: my $lang = &Apache::lonnet::metadata($filelink,'language');
1094: $lang = &Apache::loncommon::languagedescription($lang);
1095: $r->print('<td> '.($lang eq '' ? ' ' : $lang).
1096: " </td>\n");
1097: }
1098: if ($hash{'display_attrs_7'} == 1) {
1099: $r->print('<td> </td>');
1100: }
1101: if ($hash{'display_attrs_8'} == 1) {
1102: $r->print('<td> </td>');
1103: }
1104: if ($hash{'display_attrs_10'} == 1) {
1105: $r->print('<td> </td>');
1106: }
1107: if ($hash{'display_attrs_11'} == 1) {
1108: $r->print('<td> </td>');
1109: }
1110: $r->print('</form></tr>');
1111: }
1112:
1113: }
1114:
1115: # ------------------- prints the beginning of a form for directory or file link
1116: sub begin_form {
1117: my ($r,$uri) = @_;
1118: my $anchor = $uri;
1119: $anchor =~ s/\///g;
1120: $r->print ('<form method="post" name="dirpath'.$dnum.'" action="'.$uri.
1121: '#'.$anchor.
1122: '" onSubmit="return rep_dirpath(\''.$dnum.'\''.
1123: ',document.forms.fileattr.acts.value)" '.
1124: 'enctype="application/x-www-form-urlencoded">'."\n");
1125: $r->print ('<input type="hidden" name="openuri" value="'.$uri.'">'.
1126: "\n");
1127: $r->print ('<input type="hidden" name="dirPointer" value="on">'."\n");
1128: $dnum++;
1129: }
1130:
1131: # --------- settings whenever the user causes the indexer window to be launched
1132: sub start_fresh_session {
1133: delete $hash{'form.catalogmode'};
1134: delete $hash{'form.mode'};
1135: delete $hash{'form.form'};
1136: delete $hash{'form.element'};
1137: delete $hash{'form.omit'};
1138: delete $hash{'form.only'};
1139: foreach (keys %hash) {
1140: delete $hash{$_} if (/^(pre_|store)/);
1141: }
1142: }
1143:
1144: # ------------------------------------------------------------------- setvalues
1145: sub setvalues {
1146: # setvalues is used in registerurl to synchronize the database
1147: # hash and environment hashes
1148: my ($H1,$h1key,$H2,$h2key) =@_;
1149: #
1150: if (exists $H2->{$h2key}) {
1151: $H1->{$h1key} = $H2->{$h2key};
1152: } elsif (exists $H1->{$h1key}) {
1153: $H2->{$h2key} = $H1->{$h1key};
1154: }
1155: }
1156:
1157: 1;
1158:
1159: sub cleanup {
1160: if (tied(%hash)){
1161: &Apache::lonnet::logthis('Cleanup indexer: hash');
1162: }
1163: }
1164:
1165: =head1 NAME
1166:
1167: Apache::lonindexer - mod_perl module for cross server filesystem browsing
1168:
1169: =head1 SYNOPSIS
1170:
1171: Invoked by /etc/httpd/conf/srm.conf:
1172:
1173: <LocationMatch "^/res.*/$">
1174: SetHandler perl-script
1175: PerlHandler Apache::lonindexer
1176: </LocationMatch>
1177:
1178: =head1 INTRODUCTION
1179:
1180: This module enables a scheme of browsing across a cross server.
1181:
1182: This is part of the LearningOnline Network with CAPA project
1183: described at http://www.lon-capa.org.
1184:
1185: =head1 BEGIN SUBROUTINE
1186:
1187: This routine is only run once after compilation.
1188:
1189: =over 4
1190:
1191: =item *
1192:
1193: Initializes %language hash table.
1194:
1195: =back
1196:
1197: =head1 HANDLER SUBROUTINE
1198:
1199: This routine is called by Apache and mod_perl.
1200:
1201: =over 4
1202:
1203: =item *
1204:
1205: read in machine configuration variables
1206:
1207: =item *
1208:
1209: see if called from an interactive mode
1210:
1211: =item *
1212:
1213: refresh environment with user database values (in %hash)
1214:
1215: =item *
1216:
1217: define extra fields and buttons in case of special mode
1218:
1219: =item *
1220:
1221: set catalogmodefunctions to have extra needed javascript functionality
1222:
1223: =item *
1224:
1225: print header
1226:
1227: =item *
1228:
1229: evaluate actions from previous page (both cumulatively and chronologically)
1230:
1231: =item *
1232:
1233: output title
1234:
1235: =item *
1236:
1237: get state of file attributes to be showing
1238:
1239: =item *
1240:
1241: output state of file attributes to be showing
1242:
1243: =item *
1244:
1245: output starting row to the indexed file/directory hierarchy
1246:
1247: =item *
1248:
1249: read in what directories have previously been set to "open"
1250:
1251: =item *
1252:
1253: if not at top level, provide an uplink arrow
1254:
1255: =item *
1256:
1257: recursively go through all the directories and output as appropriate
1258:
1259: =item *
1260:
1261: information useful for group import
1262:
1263: =item *
1264:
1265: end the tables
1266:
1267: =item *
1268:
1269: end the output and return
1270:
1271: =back
1272:
1273: =head1 OTHER SUBROUTINES
1274:
1275: =over 4
1276:
1277: =item *
1278:
1279: scanDir - recursive scan of a directory
1280:
1281: =item *
1282:
1283: get_list - get complete matched list based on the uri (returns an array)
1284:
1285: =item *
1286:
1287: match_ext - filters out files based on extensions (returns an array)
1288:
1289: =item *
1290:
1291: display_line - displays one line in appropriate table format
1292:
1293: =item *
1294:
1295: begin_form - prints the beginning of a form for directory or file link
1296:
1297: =item *
1298:
1299: start_fresh_session - settings whenever the user causes the indexer window
1300: to be launched
1301:
1302: =back
1303:
1304: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>