Annotation of loncom/interface/lonindexer.pm, revision 1.141

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

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