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