File:  [LON-CAPA] / loncom / interface / lonindexer.pm
Revision 1.78: download - view: text, annotated - select for diffs
Sat Sep 27 13:20:46 2003 UTC (20 years, 9 months ago) by www
Branches: MAIN
CVS tags: HEAD
Internationalization, some German translations.

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

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