File:  [LON-CAPA] / loncom / interface / lonindexer.pm
Revision 1.83: download - view: text, annotated - select for diffs
Mon Dec 22 19:30:25 2003 UTC (20 years, 6 months ago) by www
Branches: MAIN
CVS tags: HEAD
Crumbs on both /priv and /res

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

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