File:
[LON-CAPA] /
loncom /
interface /
lonindexer.pm
Revision
1.105:
download - view:
text,
annotated -
select for diffs
Tue May 11 07:35:12 2004 UTC (20 years, 3 months ago) by
taceyjo1
Branches:
MAIN
CVS tags:
HEAD
There we go, titles are nice and happy for when you do a single pick, Group import is being left alone, as it works just great for group imports. This should
work just fine, will work with all modes, however, it only seems to be useful in edit mode. If there are more modes it needs to workwith. it's just a quick
couple of lines of code in the data javascript function and everything is good.
I'm closing bug 2884 now, really, stop reopening it.... <cough> guy </cough> :P
1: # The LearningOnline Network with CAPA
2: # Directory Indexer
3: #
4: # $Id: lonindexer.pm,v 1.105 2004/05/11 07:35:12 taceyjo1 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 GDBM_File;
56:
57: # ---------------------------------------- variables used throughout the module
58: my %hash; # global user-specific gdbm file
59: my %dirs; # keys are directories, values are the open/close status
60: my %language; # has the reference information present in language.tab
61:
62: # ----- Values which are set by the handler subroutine and are accessible to
63: # ----- other methods.
64: my $extrafield; # default extra table cell
65: my $fnum; # file counter
66: my $dnum; # directory counter
67:
68: # ----- Used to include or exclude files with certain extensions.
69: my @Only = ();
70: my @Omit = ();
71:
72:
73: # ----------------------------- Handling routine called via Apache and mod_perl
74: sub handler {
75: my $r = shift;
76: my $c = $r->connection();
77: &Apache::loncommon::content_type($r,'text/html');
78: &Apache::loncommon::no_cache($r);
79: $r->send_http_header;
80: return OK if $r->header_only;
81: $fnum=0;
82: $dnum=0;
83:
84: # Deal with stupid global variables (is there a way around making
85: # these global to this package? It is just so wrong....)
86: undef (@Only);
87: undef (@Omit);
88:
89: # ------------------------------------- read in machine configuration variables
90: my $iconpath= $r->dir_config('lonIconsURL') . "/";
91: my $domain = $r->dir_config('lonDefDomain');
92: my $role = $r->dir_config('lonRole');
93: my $loadlim = $r->dir_config('lonLoadLim');
94: my $servadm = $r->dir_config('lonAdmEMail');
95: my $sysadm = $r->dir_config('lonSysEMail');
96: my $lonhost = $r->dir_config('lonHostID');
97: my $tabdir = $r->dir_config('lonTabDir');
98:
99: my $fileclr='#ffffe6';
100: my $line;
101: my (@attrchk,@openpath);
102: my $uri=$r->uri;
103:
104: # -------------------------------------- see if called from an interactive mode
105: # Get the parameters from the query string
106: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
107: ['catalogmode','launch','acts','mode','form','element',
108: 'only','omit','titleelement']);
109: #-------------------------------------------------------------------
110: my $closebutton='';
111: my $groupimportbutton='';
112: my $colspan='';
113:
114: $extrafield='';
115: my $diropendb =
116: "/home/httpd/perl/tmp/$ENV{'user.domain'}_$ENV{'user.name'}_indexer.db";
117: %hash = ();
118: {
119: my %dbfile;
120: if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_READER(),0640)) {
121: while(my($key,$value)=each(%dbfile)) {
122: $hash{$key}=$value;
123: }
124: untie(%dbfile);
125: }
126: }
127: {
128: if ($ENV{'form.launch'} eq '1') {
129: &start_fresh_session();
130: }
131: #Hijack lonindexer to verify a title and be close down.
132: if ($ENV{'form.launch'} eq '2') {
133: #$r->content_type('text/html');
134: my $verify_title = &Apache::lonnet::gettitle($ENV{'form.acts'});
135: title: $verify_title");
136: $r->print(<<ENDSUBM);
137: <html>
138: <script type="text/javascript">
139: function load() {
140: window.opener.document.forms["$ENV{'form.form'}"].elements["$ENV{'form.element'}"].value='$ENV{'form.acts'}';
141: window.opener.document.forms["$ENV{'form.form'}"].elements["$ENV{'form.titleelement'}"].value='$verify_title';
142: window.close();
143: }
144: </script>
145: <body onLoad=load();>
146: </body>
147: </html>
148: ENDSUBM
149: return OK;
150: }
151:
152: # -------------------- refresh environment with user database values (in %hash)
153: &setvalues(\%hash,'form.catalogmode',\%ENV,'form.catalogmode' );
154:
155: # --------------------- define extra fields and buttons in case of special mode
156: if ($ENV{'form.catalogmode'} eq 'interactive') {
157: $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
158: '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.
159: ' border="0" /></td>';
160: $colspan=" colspan='2' ";
161: my $cl=&mt('Close');
162: $closebutton=<<END;
163: <input type="button" name="close" value='$cl' onClick="self.close()">
164: END
165: }
166: elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
167: $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
168: '<a name="$anchor"><img src="'.$iconpath.'whitespace1.gif"'.
169: ' border="0" /></td>';
170: $colspan=" colspan='2' ";
171: my $cl=&mt('Close');
172: my $gi=&mt('Group Import');
173: $closebutton=<<END;
174: <input type="button" name="close" value='$cl' onClick="self.close()">
175: END
176: $groupimportbutton=<<END;
177: <input type="button" name="groupimport" value='$gi'
178: onClick="javascript:select_group()">
179: END
180: }
181: # Additions made by Matthew to make the browser a little easier to deal
182: # with in the future.
183: #
184: # $mode (at this time) indicates if we are in edit mode.
185: # $form is the name of the form that the URL is placed when the
186: # selection is made.
187: # $element is the name of the element in $formname which receives
188: # the URL.
189: #&Apache::lonxml::debug('Checking mode, form, element');
190: &setvalues(\%hash,'form.mode' ,\%ENV,'form.mode' );
191: &setvalues(\%hash,'form.form' ,\%ENV,'form.form' );
192: &setvalues(\%hash,'form.element' ,\%ENV,'form.element');
193: &setvalues(\%hash,'form.titleelement',\%ENV,'form.titleelement');
194: &setvalues(\%hash,'form.only' ,\%ENV,'form.only' );
195: &setvalues(\%hash,'form.omit' ,\%ENV,'form.omit' );
196:
197: # Deal with 'omit' and 'only'
198: if (exists $ENV{'form.omit'}) {
199: @Omit = split(',',$ENV{'form.omit'});
200: }
201: if (exists $ENV{'form.only'}) {
202: @Only = split(',',$ENV{'form.only'});
203: }
204:
205: my $mode = $ENV{'form.mode'};
206: my ($form,$element,$titleelement);
207: if ($mode eq 'edit' || $mode eq 'parmset') {
208: $form = $ENV{'form.form'};
209: $element = $ENV{'form.element'};
210: $titleelement = $ENV{'form.titleelement'};
211: }
212: #&Apache::lonxml::debug("mode=$mode form=$form element=$element titleelement=$titleelement");
213: # ------ set catalogmodefunctions to have extra needed javascript functionality
214: my $catalogmodefunctions='';
215: if ($ENV{'form.catalogmode'} eq 'interactive' or
216: $ENV{'form.catalogmode'} eq 'groupimport') {
217: # The if statement below sets us up to use the old version
218: # by default (ie. if $mode is undefined). This is the easy
219: # way out. Hopefully in the future I'll find a way to get
220: # the calls dealt with in a more comprehensive manner.
221:
222: #
223: # There is now also mode "simple", which is for the simple version of the rat
224: #
225: #
226: if (!defined($mode) || ($mode ne 'edit' && $mode ne 'parmset')) {
227: my $location = "/adm/groupsort?catalogmode=groupimport&";
228: $location .= "mode=".$mode."&";
229: $location .= "acts=";
230: $catalogmodefunctions=<<"END";
231: function select_data(title,url) {
232: changeTitle(title);
233: changeURL(url);
234: self.close();
235: }
236: function select_group() {
237: window.location="$location"+document.forms.fileattr.acts.value;
238: }
239: function changeTitle(val) {
240: if (opener.inf) {
241: if (opener.inf.document.forms.resinfo.elements.t) {
242: opener.inf.document.forms.resinfo.elements.t.value=val;
243: }
244: }
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(title,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(title,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<=9; $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<=9; $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: 'sr' => 'Show resource',
438: 'av' => 'All versions',
439: 'ud' => 'Update Display'
440: );
441: my $Displayfileattributes=&mt('Display file attributes');
442: $r->print(<<END);
443: <form method="post" name="fileattr" action="$uri"
444: enctype="application/x-www-form-urlencoded">
445: <b><font color="#666666">$Displayfileattributes</font></b><br />
446: <table border=0><tr>
447: <td><input type="checkbox" name="attr0" value="1" $attrchk[0] onClick="this.form.submit();" /> $lt{'ti'}</td>
448: <td><input type="checkbox" name="attr1" value="1" $attrchk[1] onClick="this.form.submit();" /> $lt{'si'}</td>
449: <td><input type="checkbox" name="attr2" value="1" $attrchk[2] onClick="this.form.submit();" /> $lt{'la'}</td>
450: <td><input type="checkbox" name="attr3" value="1" $attrchk[3] onClick="this.form.submit();" /> $lt{'lm'}</td>
451: <td><input type="checkbox" name="attr8" value="1" $attrchk[8] onClick="this.form.submit();" /> $lt{'st'}</td>
452: </tr><tr>
453: <td><input type="checkbox" name="attr4" value="1" $attrchk[4] onClick="this.form.submit();" /> $lt{'au'}</td>
454: <td><input type="checkbox" name="attr5" value="1" $attrchk[5] onClick="this.form.submit();" /> $lt{'kw'}</td>
455: <td><input type="checkbox" name="attr6" value="1" $attrchk[6] onClick="this.form.submit();" /> $lt{'ln'}</td>
456: <td><input type="checkbox" name="attr7" value="1" $attrchk[7] onClick="this.form.submit();" /> $lt{'sr'}</td>
457: <td><input type="checkbox" name="attr9" value="1" $attrchk[9] onClick="this.form.submit();" /> $lt{'av'}</td>
458: <td> </td>
459: </tr></table>
460: <input type="hidden" name="attrs" value="1" />
461: <input type="submit" name="updatedisplay" value="$lt{'ud'}" />
462: <input type="hidden" name="acts" value="" />
463: $closebutton $groupimportbutton
464: END
465: # -------------- Filter out sequence containment in crumbs and "recent folders"
466: my $storeuri=$uri;
467: $storeuri='/'.(split(/\.(page|sequence)\/\//,$uri))[-1];
468: $storeuri=~s/\/+/\//g;
469: # ---------------------------------------------------------------- Bread crumbs
470: $r->print(&Apache::lonhtmlcommon::crumbs($storeuri,'','',
471: (($ENV{'form.catalogmode'} eq 'groupimport')?
472: 'document.forms.fileattr':'')).
473: &Apache::lonhtmlcommon::select_recent('residx','resrecent',
474: 'this.form.action=this.form.resrecent.options[this.form.resrecent.selectedIndex].value;this.form.submit();'));
475: # -------------------------------------------------------- Resource Home Button
476: my $reshome=$ENV{'course.'.$ENV{'request.course.id'}.'.reshome'};
477: if ($reshome) {
478: $r->print("<font size='+2'><a href='");
479: if ($ENV{'form.catalogmode'} eq 'groupimport') {
480: $r->print('javascript:document.forms.fileattr.action="'.$reshome.'";document.forms.fileattr.submit();');
481: } else {
482: $r->print($reshome);
483: }
484: $r->print("'>".&mt('Home').'</a></font>');
485: }
486: $r->print('</form>');
487: # ------------------------------------------------------ Remember where we were
488: &Apache::loncommon::storeresurl($storeuri);
489: &Apache::lonhtmlcommon::store_recent('residx',$storeuri,$storeuri);
490: # ----------------- output starting row to the indexed file/directory hierarchy
491: my $titleclr="#ddffff";
492: # $r->print(&initdebug());
493: # $r->print(&writedebug("Omit:@Omit")) if (@Omit);
494: # $r->print(&writedebug("Only:@Only")) if (@Only);
495: $r->print("<table width='100\%' border=0><tr><td bgcolor=#777777>\n");
496: $r->print("<table width='100\%' border=0><tr bgcolor=$titleclr>\n");
497: $r->print("<td $colspan><b>".&mt('Name')."</b></td>\n");
498: $r->print("<td><b>".&mt('Title')."</b></td>\n")
499: if ($hash{'display_attrs_0'} == 1);
500: $r->print("<td align=right><b>".&mt("Size")." (".&mt("bytes").") ".
501: "</b></td>\n") if ($hash{'display_attrs_1'} == 1);
502: $r->print("<td><b>".&mt("Last accessed")."</b></td>\n")
503: if ($hash{'display_attrs_2'} == 1);
504: $r->print("<td><b>".&mt("Last modified")."</b></td>\n")
505: if ($hash{'display_attrs_3'} == 1);
506: $r->print("<td><b>".&mt("Author(s)")."</b></td>\n")
507: if ($hash{'display_attrs_4'} == 1);
508: $r->print("<td><b>".&mt("Keywords")."</b></td>\n")
509: if ($hash{'display_attrs_5'} == 1);
510: $r->print("<td><b>".&mt("Language")."</b></td>\n")
511: if ($hash{'display_attrs_6'} == 1);
512: $r->print("<td><b>".&mt("Resource")."</b></td>\n")
513: if ($hash{'display_attrs_7'} == 1);
514: $r->print("<td><b>".&mt("Usage Statistics")." <br />(".
515: &mt("Courses/Network Hits").")</b></td>\n")
516: if ($hash{'display_attrs_8'} == 1);
517: $r->print('</tr>');
518:
519: # ----------------- read in what directories have previously been set to "open"
520: foreach (keys %hash) {
521: if ($_ =~ /^diropen_status_/) {
522: my $key = $_;
523: $key =~ s/^diropen_status_//;
524: $dirs{$key} = $hash{$_};
525: }
526: }
527:
528: if ($ENV{'form.openuri'}) { # take care of review and refresh options
529: my $uri=$ENV{'form.openuri'};
530: if (exists($hash{'diropen_status_'.$uri})) {
531: my $cursta = $hash{'diropen_status_'.$uri};
532: $dirs{$uri} = 'open';
533: $hash{'diropen_status_'.$uri} = 'open';
534: if ($cursta eq 'open') {
535: $dirs{$uri} = 'closed';
536: $hash{'diropen_status_'.$uri} = 'closed';
537: }
538: } else {
539: $hash{'diropen_status_'.$uri} = 'open';
540: $dirs{$uri} = 'open';
541: }
542: }
543:
544: my $toplevel;
545: my $indent = 0;
546: $uri = $uri.'/' if $uri !~ /.*\/$/;
547:
548: if ($ENV{'form.dirPointer'} ne 'on') {
549: $hash{'top.level'} = $uri;
550: $toplevel = $uri;
551: } else {
552: $toplevel = $hash{'top.level'};
553: }
554:
555: # -------------------------------- if not at top level, provide an uplink arrow
556: if ($toplevel ne '/res/'){
557: my (@uri_com) = split(/\//,$uri);
558: pop @uri_com;
559: my $upone = join('/',@uri_com);
560: my @list = qw (0);
561: &display_line ($r,'opened',$upone.'&viewOneUp',0,$upone,@list);
562: $indent = 1;
563: }
564:
565: # -------- recursively go through all the directories and output as appropriate
566: &scanDir ($r,$toplevel,$indent,\%hash);
567:
568: # ---------------------------- embed hidden information useful for group import
569: $r->print("<form name='fnum'>");
570: $r->print("<input type='hidden' name='fnum' value='$fnum'></form>");
571:
572: # -------------------------------------------------------------- end the tables
573: $r->print('</table>');
574: $r->print('</td></tr></table>');
575:
576: # --------------------------------------------------- end the output and return
577: $r->print('</body></html>'."\n");
578: }
579: if(! $c->aborted()) {
580: # write back into the temporary file
581: my %dbfile;
582: if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_NEWDB(),0640)) {
583: while (my($key,$value) = each(%hash)) {
584: $dbfile{$key}=$value;
585: }
586: untie(%dbfile);
587: }
588: }
589:
590: return OK;
591: }
592:
593: # ----------------------------------------------- recursive scan of a directory
594: sub scanDir {
595: my ($r,$startdir,$indent,$hashref)=@_;
596: my $c = $r->connection();
597: my ($compuri,$curdir);
598: my $dirptr=16384;
599: my $obs;
600: $indent++;
601: my %dupdirs = %dirs;
602: my @list=&get_list($r,$startdir);
603: foreach my $line (@list) {
604: return if ($c->aborted());
605: #This is a kludge, sorry aboot this
606: my ($strip,$dom,undef,$testdir,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$obs,undef)=split(/\&/,$line,16);
607: next if($strip =~ /.*\.meta$/ | $obs eq '1');
608: my (@fileparts) = split(/\./,$strip);
609: if ($hash{'display_attrs_9'} != 1) {
610: # if not all versions to be shown
611: if (scalar(@fileparts) >= 3) {
612: my $fext = pop @fileparts;
613: my $ov = pop @fileparts;
614: my $fname = join ('.',@fileparts,$fext);
615: next if (grep /\Q$fname\E/,@list and $ov =~ /^\d+$/);
616: }
617: }
618:
619: if ($dom eq 'domain') {
620: # dom list has full path /res/<domain name>/ already
621: $curdir='';
622: $compuri = (split(/\&/,$line))[0];
623: } else {
624: # user, dir & file have name only, i.e., w/o path
625: $compuri = join('',$startdir,$strip,'/');
626: $curdir = $startdir;
627: }
628: my $diropen = 'closed';
629: if (($dirptr&$testdir) or ($dom =~ /^(domain|user)$/) or ($compuri=~/\.(sequence|page)\/$/)) {
630: while (my ($key,$val)= each %dupdirs) {
631: if ($key eq $compuri and $val eq "open") {
632: $diropen = "opened";
633: delete($dupdirs{$key});
634: delete($dirs{$key});
635: }
636: }
637: }
638: &display_line($r,$diropen,$line,$indent,$curdir,$hashref,@list);
639: &scanDir ($r,$compuri,$indent) if $diropen eq 'opened';
640: }
641: $indent--;
642: }
643:
644: # --------------- get complete matched list based on the uri (returns an array)
645: sub get_list {
646: my ($r,$uri)=@_;
647: my @list=();
648: (my $luri = $uri) =~ s/\//_/g;
649: if ($ENV{'form.updatedisplay'}) {
650: foreach (keys %hash) {
651: delete $hash{$_} if ($_ =~ /^dirlist_files_/);
652: }
653: }
654:
655: if ($hash{'dirlist_files_'.$luri}) {
656: @list = split(/\n/,$hash{'dirlist_files_'.$luri});
657: } elsif ($uri=~/\.(page|sequence)\/$/) {
658: # is a page or a sequence
659: $uri=~s/\/$//;
660: $uri='/'.(split(/\.(page|sequence)\/\//,$uri))[-1];
661: $uri=~s/\/+/\//g;
662: foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$uri))) {
663: my @ratpart=split(/\:/,$_);
664: push @list,$ratpart[1];
665: }
666: $hash{'dirlist_files_'.$luri} = join("\n",@list);
667: } else {
668: # is really a directory
669: @list = &Apache::lonnet::dirlist($uri);
670: $hash{'dirlist_files_'.$luri} = join("\n",@list);
671: }
672: return @list=&match_ext($r,@list);
673: }
674:
675: sub initdebug {
676: return <<ENDJS;
677: <script>
678: var debugging = true;
679: if (debugging) {
680: var debuggingWindow = window.open('','Debug','width=400,height=300',true);
681: }
682:
683: function output(text) {
684: if (debugging) {
685: debuggingWindow.document.writeln(text);
686: }
687: }
688: output("<html><head><title>Debugging Window</title></head><body><pre>");
689: </script>
690: ENDJS
691: }
692:
693: sub writedebug {
694: my $text = shift;
695: return "<script>output('$text');</script>";
696: }
697:
698: # -------------------- filters out files based on extensions (returns an array)
699: sub match_ext {
700: my ($r,@packlist)=@_;
701: my @trimlist;
702: my $nextline;
703: my @fileext;
704: my $dirptr=16384;
705:
706: foreach my $line (@packlist) {
707: chomp $line;
708: $line =~ s/^\/home\/httpd\/html//;
709: my @unpackline = split (/\&/,$line);
710: next if ($unpackline[0] eq '.');
711: next if ($unpackline[0] eq '..');
712: my @filecom = split (/\./,$unpackline[0]);
713: my $fext = pop(@filecom);
714: my $fnptr = ($unpackline[3]&$dirptr) || ($fext=~/\.(page|sequence)$/);
715: if ($fnptr == 0 and $unpackline[3] ne "") {
716: my $embstyle = &Apache::loncommon::fileembstyle($fext);
717: push @trimlist,$line if (defined($embstyle) &&
718: ($embstyle ne 'hdn' or $fext eq 'meta'));
719: } else {
720: push @trimlist,$line;
721: }
722: }
723: @trimlist = sort {uc($a) cmp uc($b)} (@trimlist);
724: return @trimlist;
725: }
726:
727: # ------------------------------- displays one line in appropriate table format
728: sub display_line {
729: my ($r,$diropen,$line,$indent,$startdir,$hashref,@list)=@_;
730: my (@pathfn, $fndir);
731: # there could be relative paths (files actually belonging into this directory)
732: # or absolute paths (for example, from sequences)
733: my $absolute;
734: my $pathprefix;
735: if ($line=~/^\/res\//) {
736: $absolute=1;
737: $pathprefix='';
738: } else {
739: $absolute=0;
740: $pathprefix=$startdir;
741: }
742: my $dirptr=16384;
743: my $fileclr="#ffffe6";
744: my $iconpath= $r->dir_config('lonIconsURL') . '/';
745:
746: my @filecom = split (/\&/,$line);
747: my @pathcom = split (/\//,$filecom[0]);
748: my $listname = $pathcom[scalar(@pathcom)-1];
749: my $fnptr = $filecom[3]&$dirptr;
750: my $msg = &mt('View').' '.$filecom[0].' '.&mt('resources');
751: $msg = &mt('Close').' '.$filecom[0].' '.&mt('directory') if $diropen eq 'opened';
752:
753: my $tabtag='</td>';
754: my $i=0;
755: while ($i<=8) {
756: $tabtag=join('',$tabtag,"<td> </td>")
757: if $hash{'display_attrs_'.$i} == 1;
758: $i++;
759: }
760:
761: my $valign = ($hash{'display_attrs_7'} == 1 ? 'top' : 'bottom');
762:
763: # display uplink arrow
764: if ($filecom[1] eq 'viewOneUp') {
765: my $updir=$startdir;
766: # -------------- Filter out sequence containment in crumbs and "recent folders"
767: $updir='/'.(split(/\.(page|sequence)\/\//,$startdir))[-1];
768: $updir=~s/\/+/\//g;
769:
770: $r->print("<tr valign='$valign' bgcolor=$fileclr>$extrafield");
771: $r->print("<td>\n");
772: $r->print ('<form method="post" name="dirpathUP" action="'.$updir.
773: '/" '.
774: 'onSubmit="return rep_dirpath(\'UP\','.
775: 'document.forms.fileattr.acts.value)" '.
776: 'enctype="application/x-www-form-urlencoded"'.
777: '>'."\n");
778: $r->print ('<input type=hidden name=openuri value="'.
779: $startdir.'">'."\n");
780: $r->print ('<input type="hidden" name="acts" value="">'."\n");
781: $r->print ('<input src="'.$iconpath.'arrow_up.gif"');
782: $r->print (' name="'.$msg.'" height="22" type="image" border="0">'.
783: "\n");
784: $r->print(&mt("Up")." $tabtag</tr></form>\n");
785: return OK;
786: }
787: # Do we have permission to look at this?
788:
789: if($filecom[15] ne '1') { return OK if (!&Apache::lonnet::allowed('bre',$pathprefix.$filecom[0])); }
790:
791: # make absolute links appear on different background
792: if ($absolute) { $fileclr='#aaaa88'; }
793:
794: # display domain
795: if ($filecom[1] eq 'domain') {
796: $r->print ('<input type="hidden" name="dirPointer" value="on">'."\n")
797: if ($ENV{'form.dirPointer'} eq "on");
798: $r->print("<tr valign='$valign' bgcolor=$fileclr>$extrafield");
799: $r->print("<td>");
800: &begin_form ($r,$filecom[0]);
801: my $anchor = $filecom[0];
802: $anchor =~ s/\///g;
803: $r->print ('<a name="'.$anchor.'">');
804: $r->print ('<input type="hidden" name="acts" value="">');
805: $r->print ('<input src="'.$iconpath.'folder_pointer_'.
806: $diropen.'.gif"');
807: $r->print (' name="'.$msg.'" height="22" type="image" border="0">'.
808: "\n");
809: $r->print ('<a href="javascript:gothere(\''.$filecom[0].
810: '\')"><img src="'.$iconpath.'server.gif"');
811: $r->print (' border="0" /></a>'."\n");
812: $r->print (&mt("Domain")." - $listname ");
813: if ($Apache::lonnet::domaindescription{$listname}) {
814: $r->print("(".$Apache::lonnet::domaindescription{$listname}.
815: ")");
816: }
817: $r->print (" $tabtag</tr></form>\n");
818: return OK;
819:
820: # display user directory
821: }
822: if ($filecom[1] eq 'user') {
823: $r->print("<tr valign=$valign bgcolor=$fileclr>$extrafield");
824: $r->print("<td nowrap>\n");
825: my $curdir = $startdir.$filecom[0].'/';
826: my $anchor = $curdir;
827: $anchor =~ s/\///g;
828: &begin_form ($r,$curdir);
829: $r->print ('<a name="'.$anchor.'"><img src="'.$iconpath.
830: 'whitespace1.gif" border="0" />'."\n");
831: $r->print ('<input type="hidden" name="acts" value="">');
832: $r->print ('<input src="'.$iconpath.'folder_pointer_'.$diropen.
833: '.gif"');
834: $r->print (' name="'.$msg.'" height="22" type="image" border="0">'.
835: "\n");
836: $r->print ('<a href="javascript:gothere(\''.$curdir.'\')"><img src='.
837: $iconpath.'quill.gif border="0" name="'.$msg.
838: '" height="22" /></a>');
839: my $domain=(split(m|/|,$startdir))[2];
840: my $plainname=&Apache::loncommon::plainname($listname,$domain);
841: $r->print ($listname);
842: if (defined($plainname) && $plainname) { $r->print(" ($plainname) "); }
843: $r->print ($tabtag.'</tr></form>'."\n");
844: return OK;
845: }
846:
847: # display file
848: if (($fnptr == 0 and $filecom[3] ne '') or $absolute) {
849: my $filelink = $pathprefix.$filecom[0];
850: my @file_ext = split (/\./,$listname);
851: my $curfext = $file_ext[-1];
852: if (@Omit) {
853: foreach (@Omit) { return OK if ($curfext eq $_); }
854: }
855: if (@Only) {
856: my $skip = 1;
857: foreach (@Only) { $skip = 0 if ($curfext eq $_); }
858: return OK if ($skip > 0);
859: }
860: # Set the icon for the file
861: my $iconname = &Apache::loncommon::icon($listname);
862: $r->print("<tr valign='$valign' bgcolor=$fileclr><td nowrap>");
863:
864: my $metafile = $Apache::lonnet::perlvar{'lonDocRoot'}.$pathprefix.
865: $filecom[0].'.meta';
866: if (-e $metafile) {
867: $metafile=1;
868: } else {
869: $metafile=0;
870: }
871: my $title;
872: if ($ENV{'form.catalogmode'} eq 'interactive') {
873: $title=$listname;
874: $title = &Apache::lonnet::metadata($filelink,'title')
875: if ($metafile == 1);
876: $title=$listname unless $title;
877: my $titleesc=HTML::Entities::encode($title,'<>&"');
878: $titleesc=~s/\'/\\'/; #' (clean up this spare quote)
879: $r->print("<a href=\"javascript:select_data(\'",
880: $titleesc,"','",$filelink,"')\">");
881: $r->print("<img src='",$iconpath,"select.gif' border='0' /></a>".
882: "\n");
883: $r->print("</td><td nowrap>");
884: } elsif ($ENV{'form.catalogmode'} eq 'groupimport') {
885: $title=$listname;
886: $title = &Apache::lonnet::metadata($filelink,'title')
887: if ($metafile == 1);
888: $title=$listname unless $title;
889: my $titleesc=&HTML::Entities::encode($title,'<>&"');
890: $r->print("<form name='form$fnum'>\n");
891: $r->print("<input type='checkbox' name='filelink"."' ".
892: "value='$filelink' onClick='".
893: "javascript:queue(\"form$fnum\")' ");
894: if ($hash{'store_'.$filelink}) {
895: $r->print("checked");
896: }
897: $r->print(">\n");
898: $r->print("<input type='hidden' name='title"."' ".
899: "value='$titleesc'>\n");
900: $r->print("</form>\n");
901: $r->print("</td><td nowrap>");
902: $hash{"pre_${fnum}_link"}=$filelink;
903: $hash{"pre_${fnum}_title"}=$titleesc;
904: $fnum++;
905: }
906: # Form to open or close sequences
907: if ($filelink=~/\.(page|sequence)$/) {
908: my $curdir = $startdir.$filecom[0].'/';
909: my $anchor = $curdir;
910: $anchor =~ s/\///g;
911: &begin_form($r,$curdir);
912: $indent--;
913: }
914: # General indentation
915: if ($indent > 0 and $indent < 11) {
916: $r->print("<img src=",$iconpath,"whitespace",$indent,
917: ".gif border='0' />\n");
918: } elsif ($indent >0) {
919: my $ten = int($indent/10.);
920: my $rem = $indent%10.0;
921: my $count = 0;
922: while ($count < $ten) {
923: $r->print("<img src=",$iconpath,
924: "whitespace10.gif border='0' />\n");
925: $count++;
926: }
927: $r->print("<img src=",$iconpath,"whitespace",$rem,
928: ".gif border='0' />\n") if $rem > 0;
929: }
930: # Sequence open/close icon
931: if ($filelink=~/\.(page|sequence)$/) {
932: my $curdir = $startdir.$filecom[0].'/';
933: my $anchor = $curdir;
934: $anchor =~ s/\///g;
935: $r->print ('<input type="hidden" name="acts" value="">');
936: $r->print ('<a name="'.$anchor.'"><input src="'.$iconpath.
937: 'folder_pointer_'.$diropen.'.gif"');
938: $r->print (' name="'.$msg.'" height="22" type="image" border="0">'.
939: "\n");
940: }
941: # Filetype icons
942: $r->print("<img src='$iconname' border='0' />\n");
943: # Close form to open/close sequence
944: if ($filelink=~/\.(page|sequence)$/) {
945: $r->print('</form>');
946: }
947: $r->print (" <a href=\"javascript:openWindow('".$filelink.
948: "', 'previewfile', '450', '500', 'no', 'yes','yes')\";".
949: " TARGET=_self>$listname</a> ");
950:
951: $r->print (" (<a href=\"javascript:openWindow('".$filelink.
952: ".meta', 'metadatafile', '500', '550', 'no', 'yes','no')\"; ".
953: "TARGET=_self>metadata</a>) ");
954: $r->print("</td>\n");
955: if ($hash{'display_attrs_0'} == 1) {
956: my $title = &Apache::lonnet::gettitle($filelink,'title');
957: $r->print('<td> '.($title eq '' ? ' ' : $title).
958: ' </td>'."\n");
959: }
960: $r->print('<td align=right> ',
961: $filecom[8]," </td>\n")
962: if $hash{'display_attrs_1'} == 1;
963: $r->print('<td> '.
964: (localtime($filecom[9]))." </td>\n")
965: if $hash{'display_attrs_2'} == 1;
966: $r->print('<td> '.
967: (localtime($filecom[10]))." </td>\n")
968: if $hash{'display_attrs_3'} == 1;
969:
970: if ($hash{'display_attrs_4'} == 1) {
971: my $author = &Apache::lonnet::metadata($filelink,'author');
972: $r->print('<td> '.($author eq '' ? ' ' : $author).
973: " </td>\n");
974: }
975: if ($hash{'display_attrs_5'} == 1) {
976: my $keywords = &Apache::lonnet::metadata($filelink,'keywords');
977: # $keywords = ' ' if (!$keywords);
978: $r->print('<td> '.($keywords eq '' ? ' ' : $keywords).
979: " </td>\n");
980: }
981: if ($hash{'display_attrs_6'} == 1) {
982: my $lang = &Apache::lonnet::metadata($filelink,'language');
983: $lang = &Apache::loncommon::languagedescription($lang);
984: $r->print('<td> '.($lang eq '' ? ' ' : $lang).
985: " </td>\n");
986: }
987: if ($hash{'display_attrs_7'} == 1) {
988: my $output='';
989: my $embstyle=&Apache::loncommon::fileembstyle($curfext);
990: if ($embstyle eq 'ssi') {
991: my $cache=$Apache::lonnet::perlvar{'lonDocRoot'}.$filelink.
992: '.tmp';
993: if ((!$ENV{'form.updatedisplay'}) &&
994: (-e $cache)) {
995: open(FH,$cache);
996: $output=join("\n",<FH>);
997: close(FH);
998: } else {
999: $output=&Apache::lonnet::ssi_body($filelink);
1000: open(FH,">$cache");
1001: print FH $output;
1002: close(FH);
1003: }
1004: $output='<font size="-2">'.$output.'</font>';
1005: } elsif ($embstyle eq 'img') {
1006: $output='<img src="'.$filelink.'" />';
1007: } elsif ($filelink=~/^\/res\/(\w+)\/(\w+)\//) {
1008: $output='<img src="http://'.
1009: $Apache::lonnet::hostname{&Apache::lonnet::homeserver($2,$1)}.
1010: '/cgi-bin/thumbnail.gif?url='.$filelink.'" />';
1011: }
1012: $r->print('<td> '.($output eq '' ? ' ':$output).
1013: " </td>\n");
1014: }
1015: if ($hash{'display_attrs_8'} == 1) {
1016: my (%stat) = &Apache::lonmeta::dynamicmeta($filelink);
1017: my $stat = (exists($stat{'course'}) ? $stat{'course'} : '').
1018: ((exists($stat{'course'}) || exists($stat{'count'})) ? '/' : '').
1019: (exists($stat{'count'}) ? $stat{'count'} : '');
1020: $r->print('<td align=center> '.($stat eq '' ? ' ' : $stat).
1021: ' </td>'."\n");
1022: }
1023:
1024: $r->print("</tr>\n");
1025: }
1026:
1027: # -- display directory
1028: if ($fnptr == $dirptr) {
1029: my $curdir = $startdir.$filecom[0].'/';
1030: my $anchor = $curdir;
1031: $anchor =~ s/\///g;
1032: $r->print("<tr bgcolor=$fileclr>$extrafield<td valign=$valign>");
1033: &begin_form ($r,$curdir);
1034: my $indentm1 = $indent-1;
1035: if ($indentm1 < 11 and $indentm1 > 0) {
1036: $r->print("<img src=",$iconpath,"whitespace",$indentm1,
1037: ".gif border='0' />\n");
1038: } else {
1039: my $ten = int($indentm1/10.);
1040: my $rem = $indentm1%10.0;
1041: my $count = 0;
1042: while ($count < $ten) {
1043: $r->print ("<img src=",$iconpath
1044: ,"whitespace10.gif border='0' />\n");
1045: $count++;
1046: }
1047: $r->print ("<img src=",$iconpath,"whitespace",$rem,
1048: ".gif border='0' />\n") if $rem > 0;
1049: }
1050: $r->print ('<input type="hidden" name="acts" value="">');
1051: $r->print ('<a name="'.$anchor.'"><input src="'.$iconpath.
1052: 'folder_pointer_'.$diropen.'.gif"');
1053: $r->print (' name="'.$msg.'" height="22" type="image" border="0">'.
1054: "\n");
1055: $r->print ('<a href="javascript:gothere(\''.$curdir.'\')"><img src="'.
1056: $iconpath.'folder_'.$diropen.'.gif" border="0" /></a>'.
1057: "\n");
1058: $r->print ("$listname</td>\n");
1059: # Attributes
1060: my $filelink = $startdir.$filecom[0].'/default';
1061:
1062: if ($hash{'display_attrs_0'} == 1) {
1063: my $title = &Apache::lonnet::gettitle($filelink,'title');
1064: $r->print('<td> '.($title eq '' ? ' ' : $title).
1065: ' </td>'."\n");
1066: }
1067: $r->print('<td align=right> ',
1068: $filecom[8]," </td>\n")
1069: if $hash{'display_attrs_1'} == 1;
1070: $r->print('<td> '.
1071: (localtime($filecom[9]))." </td>\n")
1072: if $hash{'display_attrs_2'} == 1;
1073: $r->print('<td> '.
1074: (localtime($filecom[10]))." </td>\n")
1075: if $hash{'display_attrs_3'} == 1;
1076:
1077: if ($hash{'display_attrs_4'} == 1) {
1078: my $author = &Apache::lonnet::metadata($filelink,'author');
1079: $r->print('<td> '.($author eq '' ? ' ' : $author).
1080: " </td>\n");
1081: }
1082: if ($hash{'display_attrs_5'} == 1) {
1083: my $keywords = &Apache::lonnet::metadata($filelink,'keywords');
1084: # $keywords = ' ' if (!$keywords);
1085: $r->print('<td> '.($keywords eq '' ? ' ' : $keywords).
1086: " </td>\n");
1087: }
1088: if ($hash{'display_attrs_6'} == 1) {
1089: my $lang = &Apache::lonnet::metadata($filelink,'language');
1090: $lang = &Apache::loncommon::languagedescription($lang);
1091: $r->print('<td> '.($lang eq '' ? ' ' : $lang).
1092: " </td>\n");
1093: }
1094: if ($hash{'display_attrs_7'} == 1) {
1095: $r->print('<td> </td>');
1096: }
1097: if ($hash{'display_attrs_8'} == 1) {
1098: $r->print('<td> </td>');
1099: }
1100: $r->print('</form></tr>');
1101: }
1102:
1103: }
1104:
1105: # ------------------- prints the beginning of a form for directory or file link
1106: sub begin_form {
1107: my ($r,$uri) = @_;
1108: my $anchor = $uri;
1109: $anchor =~ s/\///g;
1110: $r->print ('<form method="post" name="dirpath'.$dnum.'" action="'.$uri.
1111: '#'.$anchor.
1112: '" onSubmit="return rep_dirpath(\''.$dnum.'\''.
1113: ',document.forms.fileattr.acts.value)" '.
1114: 'enctype="application/x-www-form-urlencoded">'."\n");
1115: $r->print ('<input type="hidden" name="openuri" value="'.$uri.'">'.
1116: "\n");
1117: $r->print ('<input type="hidden" name="dirPointer" value="on">'."\n");
1118: $dnum++;
1119: }
1120:
1121: # --------- settings whenever the user causes the indexer window to be launched
1122: sub start_fresh_session {
1123: delete $hash{'form.catalogmode'};
1124: delete $hash{'form.mode'};
1125: delete $hash{'form.form'};
1126: delete $hash{'form.element'};
1127: delete $hash{'form.omit'};
1128: delete $hash{'form.only'};
1129: foreach (keys %hash) {
1130: delete $hash{$_} if (/^(pre_|store)/);
1131: }
1132: }
1133:
1134: # ------------------------------------------------------------------- setvalues
1135: sub setvalues {
1136: # setvalues is used in registerurl to synchronize the database
1137: # hash and environment hashes
1138: my ($H1,$h1key,$H2,$h2key) =@_;
1139: #
1140: if (exists $H2->{$h2key}) {
1141: $H1->{$h1key} = $H2->{$h2key};
1142: } elsif (exists $H1->{$h1key}) {
1143: $H2->{$h2key} = $H1->{$h1key};
1144: }
1145: }
1146:
1147: 1;
1148:
1149: sub cleanup {
1150: if (tied(%hash)){
1151: &Apache::lonnet::logthis('Cleanup indexer: hash');
1152: }
1153: }
1154:
1155: =head1 NAME
1156:
1157: Apache::lonindexer - mod_perl module for cross server filesystem browsing
1158:
1159: =head1 SYNOPSIS
1160:
1161: Invoked by /etc/httpd/conf/srm.conf:
1162:
1163: <LocationMatch "^/res.*/$">
1164: SetHandler perl-script
1165: PerlHandler Apache::lonindexer
1166: </LocationMatch>
1167:
1168: =head1 INTRODUCTION
1169:
1170: This module enables a scheme of browsing across a cross server.
1171:
1172: This is part of the LearningOnline Network with CAPA project
1173: described at http://www.lon-capa.org.
1174:
1175: =head1 BEGIN SUBROUTINE
1176:
1177: This routine is only run once after compilation.
1178:
1179: =over 4
1180:
1181: =item *
1182:
1183: Initializes %language hash table.
1184:
1185: =back
1186:
1187: =head1 HANDLER SUBROUTINE
1188:
1189: This routine is called by Apache and mod_perl.
1190:
1191: =over 4
1192:
1193: =item *
1194:
1195: read in machine configuration variables
1196:
1197: =item *
1198:
1199: see if called from an interactive mode
1200:
1201: =item *
1202:
1203: refresh environment with user database values (in %hash)
1204:
1205: =item *
1206:
1207: define extra fields and buttons in case of special mode
1208:
1209: =item *
1210:
1211: set catalogmodefunctions to have extra needed javascript functionality
1212:
1213: =item *
1214:
1215: print header
1216:
1217: =item *
1218:
1219: evaluate actions from previous page (both cumulatively and chronologically)
1220:
1221: =item *
1222:
1223: output title
1224:
1225: =item *
1226:
1227: get state of file attributes to be showing
1228:
1229: =item *
1230:
1231: output state of file attributes to be showing
1232:
1233: =item *
1234:
1235: output starting row to the indexed file/directory hierarchy
1236:
1237: =item *
1238:
1239: read in what directories have previously been set to "open"
1240:
1241: =item *
1242:
1243: if not at top level, provide an uplink arrow
1244:
1245: =item *
1246:
1247: recursively go through all the directories and output as appropriate
1248:
1249: =item *
1250:
1251: information useful for group import
1252:
1253: =item *
1254:
1255: end the tables
1256:
1257: =item *
1258:
1259: end the output and return
1260:
1261: =back
1262:
1263: =head1 OTHER SUBROUTINES
1264:
1265: =over 4
1266:
1267: =item *
1268:
1269: scanDir - recursive scan of a directory
1270:
1271: =item *
1272:
1273: get_list - get complete matched list based on the uri (returns an array)
1274:
1275: =item *
1276:
1277: match_ext - filters out files based on extensions (returns an array)
1278:
1279: =item *
1280:
1281: display_line - displays one line in appropriate table format
1282:
1283: =item *
1284:
1285: begin_form - prints the beginning of a form for directory or file link
1286:
1287: =item *
1288:
1289: start_fresh_session - settings whenever the user causes the indexer window
1290: to be launched
1291:
1292: =back
1293:
1294: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>