File:  [LON-CAPA] / loncom / interface / lonindexer.pm
Revision 1.215: download - view: text, annotated - select for diffs
Wed Jul 11 12:51:36 2012 UTC (12 years ago) by www
Branches: MAIN
CVS tags: HEAD
FIXME entered

    1: # The LearningOnline Network with CAPA
    2: # Directory Indexer
    3: #
    4: # $Id: lonindexer.pm,v 1.215 2012/07/11 12:51:36 www Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: ###
   29: 
   30: ###############################################################################
   31: ##                                                                           ##
   32: ## ORGANIZATION OF THIS PERL MODULE                                          ##
   33: ##                                                                           ##
   34: ## 1. Description of functions                                               ##
   35: ## 2. Modules used by this module                                            ##
   36: ## 3. Choices for different output views (detailed, summary, xml, etc)       ##
   37: ## 4. BEGIN block (to be run once after compilation)                         ##
   38: ## 5. Handling routine called via Apache and mod_perl                        ##
   39: ## 6. Other subroutines                                                      ##
   40: ##                                                                           ##
   41: ###############################################################################
   42: 
   43: package Apache::lonindexer;
   44: 
   45: # ------------------------------------------------- modules used by this module
   46: use strict;
   47: use Apache::lonnet;
   48: use Apache::loncommon();
   49: use Apache::lonhtmlcommon();
   50: use Apache::lonsequence();
   51: use Apache::Constants qw(:common);
   52: use Apache::lonmeta;
   53: use Apache::File;
   54: use Apache::lonlocal;
   55: use Apache::lonsource();
   56: use Apache::groupsort();
   57: use GDBM_File;
   58: use LONCAPA qw(:match);
   59: 
   60: # ---------------------------------------- variables used throughout the module
   61: my %hash; # global user-specific gdbm file
   62: my %dirs; # keys are directories, values are the open/close status
   63: my %language; # has the reference information present in language.tab
   64: my %dynhash; # hash of hashes for dynamic metadata
   65: my %dynread; # hash of directories already read for dynamic metadata
   66: my %fieldnames; # Metadata fieldnames
   67: # ----- Values which are set by the handler subroutine and are accessible to
   68: # -----     other methods.
   69: my $extrafield; # default extra table cell
   70: my $fnum; # file counter
   71: my $dnum; # directory counter
   72: 
   73: # ----- Used to include or exclude files with certain extensions.
   74: my @Only = ();
   75: my @Omit = ();
   76: 
   77: 
   78: 
   79: 
   80: # ----------------------------- Handling routine called via Apache and mod_perl
   81: sub handler {
   82:     my $r = shift;
   83:     my $c = $r->connection();
   84:     &Apache::loncommon::content_type($r,'text/html');
   85:     &Apache::loncommon::no_cache($r);
   86:     $r->send_http_header;
   87:     return OK if $r->header_only;
   88:     $fnum=0;
   89:     $dnum=0;
   90: 
   91:     # Deal with stupid global variables (is there a way around making
   92:     # these global to this package?  It is just so wrong....)
   93:     undef (@Only);
   94:     undef (@Omit);
   95:     %fieldnames=&Apache::lonmeta::fieldnames();
   96: 
   97: # ------------------------------------- read in machine configuration variables
   98:     my $iconpath= $r->dir_config('lonIconsURL') . "/";
   99:     my $domain  = $r->dir_config('lonDefDomain');
  100:     my $role    = $r->dir_config('lonRole');
  101:     my $loadlim = $r->dir_config('lonLoadLim');
  102:     my $servadm = $r->dir_config('lonAdmEMail');
  103:     my $sysadm  = $r->dir_config('lonSysEMail');
  104:     my $lonhost = $r->dir_config('lonHostID');
  105:     my $tabdir  = $r->dir_config('lonTabDir');
  106: 
  107: #SB my $fileclr='#ffffe6';
  108:     my $line;
  109:     my (@attrchk,@openpath,$typeselect);
  110:     my $uri=$r->uri;
  111: 
  112: # -------------------------------------- see if called from an interactive mode
  113:     # Get the parameters from the query string
  114:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
  115: 	     ['catalogmode','launch','acts','mode','form','element',
  116:               'only','omit','titleelement']);
  117:     #-------------------------------------------------------------------
  118:     my $closebutton='';
  119:     my $groupimportbutton='';
  120:     my $colspan=''; 
  121:     
  122:     $extrafield='';
  123:     my $diropendb = LONCAPA::tempdir() .
  124: 	"$env{'user.domain'}_$env{'user.name'}_sel_res.db";
  125:     %hash = ();
  126:     {
  127: 	my %dbfile;
  128: 	if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_WRITER(),0640)) {
  129: 	    if ($env{'form.launch'} eq '1') {
  130: 		&start_fresh_session(\%dbfile);
  131: 	    }
  132: 	    while(my($key,$value)=each(%dbfile)) {
  133: 		$hash{$key}=$value;
  134: 	    }
  135: 	    untie(%dbfile);
  136: 	}
  137:     }
  138: # - Evaluate actions from previous page (both cumulatively and chronologically)
  139:         if ($env{'form.catalogmode'} eq 'import' || $hash{'form.catalogmode'} eq 'import') {
  140: 	    &Apache::groupsort::update_actions_hash(\%hash);
  141: 	}
  142:     
  143:     {
  144:   #Hijack lonindexer to verify a title and be close down.
  145:    if ($env{'form.launch'} eq '2') {
  146:        &Apache::loncommon::content_type($r,'text/html');
  147:        my $extra='';
  148:        if (defined($env{'form.titleelement'}) && 
  149: 	   $env{'form.titleelement'} ne '') {
  150: 	   my $verify_title = &Apache::lonnet::gettitle($env{'form.acts'});
  151: #	   &Apache::lonnet::logthis("Hrrm $env{'form.acts'} -- $verify_title");
  152: 	   $verify_title=~s/'/\\'/g;
  153: 	   $extra='window.opener.document.forms["'.$env{'form.form'}.'"].elements["'.$env{'form.titleelement'}.'"].value=\''.$verify_title.'\';';
  154:        }
  155:        my $js = <<ENDSUBM;
  156: 	       <script type="text/javascript">
  157: 		function load() {
  158: 			window.opener.document.forms["$env{'form.form'}"]
  159: 			    .elements["$env{'form.element'}"]
  160: 			    .value='$env{'form.acts'}';
  161: 			$extra
  162: 			window.close();
  163: 		}
  164:    	       </script>
  165: ENDSUBM
  166:        $r->print(&Apache::loncommon::start_page(undef,$js,
  167: 						{'only_body'   =>1,
  168:                                                  'add_modal' => 1,
  169:                                                  'add_wishlist' => 1,
  170: 						 'add_entries' =>
  171: 						     {'onload' => "load();"},}
  172: 						).
  173: 		 &Apache::loncommon::end_page());
  174:        return OK;
  175:    }
  176:     
  177: # -------------------- refresh environment with user database values (in %hash)
  178: 	&setvalues(\%hash,'form.catalogmode',\%env,'form.catalogmode'   );
  179: 
  180: # --------------------- define extra fields and buttons in case of special mode
  181: 	if ($env{'form.catalogmode'} eq 'interactive') {
  182: #SB	    $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
  183:             $extrafield='<td class="LC_bottom">'.
  184: 		'<img alt="" src="'.$iconpath.'whitespace1.gif"'.
  185: 		' class="LC_icon" /></td>';
  186: 	    $colspan=" colspan='2' ";
  187:             my $cl=&mt('Close');
  188:             $closebutton=<<END;
  189: <input type="button" name="close" value='$cl' onclick="self.close()" />
  190: END
  191:         }
  192: 	elsif ($env{'form.catalogmode'} eq 'import') {
  193: #SB	    $extrafield='<td bgcolor="'.$fileclr.'" valign="bottom">'.
  194:             $extrafield='<td class="LC_bottom">'.
  195: 		'<img alt="" src="'.$iconpath.'whitespace1.gif"'.
  196: 		' class="LC_icon" /></td>';
  197: 	    $colspan=" colspan='2' ";
  198: 	    my $cl=&mt('Close');
  199:             my $gi=&mt('Import');
  200:             $closebutton=<<END;
  201: <input type="button" name="close" value='$cl' onclick="self.close()" />
  202: END
  203:             $groupimportbutton=<<END;
  204: <input type="button" name="groupimport" value='$gi'
  205: onclick="javascript:select_group()" />
  206: END
  207:         }
  208: 	# Additions made by Matthew to make the browser a little easier to deal
  209: 	# with in the future.
  210: 	#
  211: 	# $mode (at this time) indicates if we are in edit mode.
  212: 	# $form is the name of the form that the URL is placed when the
  213: 	#       selection is made.
  214: 	# $element is the name of the element in $formname which receives
  215: 	#       the URL.
  216: 	#&Apache::lonxml::debug('Checking mode, form, element');
  217: 	&setvalues(\%hash,'form.mode'        ,\%env,'form.mode'   );
  218: 	&setvalues(\%hash,'form.form'        ,\%env,'form.form'   );
  219: 	&setvalues(\%hash,'form.element'     ,\%env,'form.element');
  220: 	&setvalues(\%hash,'form.titleelement',\%env,'form.titleelement');
  221: 	&setvalues(\%hash,'form.only'        ,\%env,'form.only'   );
  222: 	&setvalues(\%hash,'form.omit'        ,\%env,'form.omit'   );
  223: 
  224:         # Deal with 'omit' and 'only' 
  225:         if (exists $env{'form.omit'}) {
  226:             @Omit = split(',',$env{'form.omit'});
  227:         }
  228:         if (exists $env{'form.only'}) {
  229:             @Only = split(',',$env{'form.only'});
  230:         }
  231:         
  232: 	my $mode = $env{'form.mode'};
  233: 	my ($form,$element,$titleelement);
  234: 	if ($mode eq 'edit' || $mode eq 'parmset') {
  235: 	    $form         = $env{'form.form'};
  236: 	    $element      = $env{'form.element'};
  237: 	    $titleelement = $env{'form.titleelement'};
  238: 	}
  239: 	#&Apache::lonxml::debug("mode=$mode form=$form element=$element titleelement=$titleelement");
  240: # ------ set catalogmodefunctions to have extra needed javascript functionality
  241: 	my $catalogmodefunctions='';
  242: 	if ($env{'form.catalogmode'} eq 'interactive' or
  243: 	    $env{'form.catalogmode'} eq 'import') {
  244: 	    # The if statement below sets us up to use the old version
  245: 	    # by default (ie. if $mode is undefined).  This is the easy
  246: 	    # way out.  Hopefully in the future I'll find a way to get 
  247: 	    # the calls dealt with in a more comprehensive manner.
  248: 
  249: #
  250: # There is now also mode "simple", which is for the simple version of the rat
  251: #
  252: #
  253: 	    if (!defined($mode) || ($mode ne 'edit' && $mode ne 'parmset')) {
  254:                 my $location = "/adm/groupsort?&inhibitmenu=yes&catalogmode=import&";
  255:                 $location .= "mode=".$mode."&";
  256:                 $location .= "acts=";
  257: 		$catalogmodefunctions=<<"END";
  258: function select_data(url) {
  259:     changeURL(url);
  260:     self.close();
  261: }
  262: function select_group() {
  263:     window.location="$location"+document.forms.fileattr.acts.value;
  264: }
  265: function changeURL(val) {
  266:     if (opener.inf) {
  267:         if (opener.inf.document.forms.resinfo.elements.u) {
  268: 	    opener.inf.document.forms.resinfo.elements.u.value=val;
  269:         }
  270:     }
  271: }
  272: END
  273:             } elsif ($mode eq 'edit') { # we are in 'edit' mode
  274:                 my $location = "/adm/groupsort?catalogmode=interactive&";
  275:                 $location .= "form=$form&element=$element&mode=edit&acts=";
  276: 		$catalogmodefunctions=<<END;
  277: // mode = $mode
  278: function select_data(url) {
  279:    var location = "/res/?launch=2&form=$form&element=$element&titleelement=$titleelement&acts=" + url;
  280:    window.location=location;
  281:    if (window.opener.document.forms["$form"].elements["$element"].value != url) {
  282:        window.opener.unClean();
  283:    }
  284: }
  285: function select_group() {
  286:     window.location="$location"+document.forms.fileattr.acts.value;
  287: }
  288: 
  289: function changeURL(val) {
  290:     if (window.opener.document) {
  291: 	window.opener.document.forms["$form"].elements["$element"].value=val;
  292:     } else {
  293: 	    alert("The file you selected is: "+val);
  294:     }
  295: }
  296: END
  297:                 if (!$titleelement) {
  298: 		    $catalogmodefunctions.='function changeTitle(val) {}';
  299: 		} else {
  300: 		    $catalogmodefunctions.=<<END;
  301: function changeTitle(val) {
  302:     if (window.opener.document) {
  303: 	    window.opener.document.forms["$form"].elements["$titleelement"].value=val;
  304:     } else {
  305: 	    alert("The title of the file you selected is: "+val);
  306:     }
  307: }
  308: END
  309:                 }
  310:             } elsif ($mode eq 'parmset') {
  311:                 my $location = "/adm/groupsort?catalogmode=interactive&";
  312:                 $location .= "form=$form&element=$element&mode=parmset&acts=";
  313: 		$catalogmodefunctions=<<END;
  314: // mode = $mode
  315: function select_data(url) {
  316:     changeURL(url);
  317:     self.close();
  318: }
  319: 
  320: function select_group() {
  321:     window.location="$location"+document.forms.fileattr.acts.value;
  322: }
  323: 
  324: function changeURL(val) {
  325:     if (window.opener.document) {
  326:         var elementname  = "$element";
  327: 	window.opener.document.forms["$form"].elements[elementname].value=val;
  328:     } else {
  329: 	    alert("The file you selected is: "+val);
  330:     }
  331: }
  332: 
  333: END
  334:             }
  335:         }
  336:         $catalogmodefunctions.=<<END;
  337: var acts='';
  338: function rep_dirpath(suffix,val) {
  339:     eval("document.forms.dirpath"+suffix+".acts.value=val");
  340: }
  341: END
  342: 	if ($env{'form.catalogmode'} eq 'import') {
  343:             $catalogmodefunctions.=<<END;
  344: function queue(val) {
  345:     if (eval("document.forms."+val+".filelink.checked")) {
  346: 	var l=val.length;
  347: 	var v=val.substring(4,l);
  348: 	document.forms.fileattr.acts.value+='1a'+v+'b';
  349:     }
  350:     else {
  351: 	var l=val.length;
  352: 	var v=val.substring(4,l);
  353: 	document.forms.fileattr.acts.value+='0a'+v+'b';
  354:     }
  355: }
  356: END
  357: 	}
  358: 
  359:         my $inhibit_menu = "+'&".&Apache::loncommon::inhibit_menu_check()."'";
  360: # ---------------------------------------------------------------- Print Header
  361:         
  362: 	my $js = <<"ENDHEADER";
  363: <script type="text/javascript">
  364: // <![CDATA[
  365: $catalogmodefunctions;
  366: function update_only(field) {
  367:     alert(field.name);
  368: }
  369: function checkAll() {
  370:     var numForms = document.forms.length;
  371:     for (i=0;i<numForms;i++) {
  372:         var numElements = document.forms[i].elements.length;
  373:         for (j=0;j<numElements;j++){
  374:             var fieldName = document.forms[i].elements[j].name;
  375:             if (fieldName == 'filelink') {
  376:                 document.forms[i].elements[j].checked = true;
  377:                 queue(document.forms[i].name);
  378:             }
  379:         }
  380:     }
  381: }
  382: function uncheckAll() {
  383:     var numForms = document.forms.length;
  384:     for (i=0;i<numForms;i++) {
  385:         var numElements = document.forms[i].elements.length;
  386:         for (j=0;j<numElements;j++){
  387:             var fieldName = document.forms[i].elements[j].name;
  388:             if (fieldName == 'filelink') {
  389:                 document.forms[i].elements[j].checked = false;
  390:                 queue(document.forms[i].name);
  391:             }
  392:         }
  393:     }
  394: }
  395: 
  396: function openWindow(url, wdwName, w, h, toolbar,scrollbar,locationbar) {
  397:     var xpos = (screen.width-w)/2;
  398:     xpos = (xpos < 0) ? '0' : xpos;
  399:     var ypos = (screen.height-h)/2-30;
  400:     ypos = (ypos < 0) ? '0' : ypos;
  401:     var options = "width=" + w + ",height=" + h + ",screenx="+xpos+",screeny="+ypos+",";
  402:     options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
  403:     options += "menubar=no,toolbar="+toolbar+",location="+locationbar+",directories=no";
  404:     var newWin = window.open(url, wdwName, options);
  405:     newWin.focus();
  406: }
  407: 
  408: function gothere(val) {
  409:     window.location=val+'?acts='+document.forms.fileattr.acts.value$inhibit_menu;
  410: }
  411: // ]]>
  412: </script>
  413: ENDHEADER
  414: 
  415:         my ($headerdom)=($uri=~m{^/res/($match_domain)/});
  416: 
  417:         if ($env{'form.catalogmode'}) {
  418:             # "Popup mode"
  419:             $r->print(&Apache::loncommon::start_page('Browse published resources',$js,
  420:                                                      {'only_body' => 1, 'add_wishlist'=>1, 'add_modal' =>1, 
  421:                                                       'domain' => $headerdom,}));
  422:         } else {
  423:             # Only display page header and breadcrumbs in non-popup mode
  424:             &Apache::lonhtmlcommon::clear_breadcrumbs();
  425: #
  426: # FIXME: hard link to fhwfdev?
  427: #
  428: #
  429: 
  430:             &Apache::lonhtmlcommon::add_breadcrumb({
  431:                 'text'  => 'Browse published resources',
  432:                 'href'  => '/res/fhwfdev/?launch=1',
  433:             });
  434:             $r->print(&Apache::loncommon::start_page('Browse published resources',$js,
  435:                                                      {'domain' => $headerdom,})
  436:                      .&Apache::lonhtmlcommon::breadcrumbs()
  437:             );
  438:         }
  439: 
  440: # ---------------------------------- get state of file types to be showing
  441: 	if ($env{'form.only'}) {
  442: 	    $typeselect = $env{'form.only'};
  443: 	} else {
  444: 	    $typeselect = '';
  445: 	}
  446: 
  447: # ---------------------------------- get state of file attributes to be showing
  448: 	if ($env{'form.attrs'}) {
  449: 	    for (my $i=0; $i<=16; $i++) {
  450: 		delete $hash{'display_attrs_'.$i};
  451: 		if ($env{'form.attr'.$i} == 1) {
  452: 		    $attrchk[$i] = 'checked';
  453: 		    $hash{'display_attrs_'.$i} = 1;
  454: 		}
  455: 	    }
  456: 	} else {
  457: 	    for (my $i=0; $i<=16; $i++) {
  458: 		$attrchk[$i] = 'checked="checked"' if $hash{'display_attrs_'.$i} == 1;
  459: 	    }
  460: 	}
  461: 
  462:         my @file_categories = &Apache::loncommon::filecategories();
  463:         my %select_file_categories;
  464:         my @select_form_order = ('');
  465:         $select_file_categories{''} = &mt('All file types');
  466:         foreach my $cat (@file_categories) {
  467:             my $types = join(",",&Apache::loncommon::filecategorytypes($cat));
  468:             $select_file_categories{$types} = &mt($cat);
  469:             push(@select_form_order,$types);
  470:         }
  471:         $select_file_categories{'select_form_order'} = \@select_form_order;
  472:         my $onchange = 'this.form.submit();';
  473:         my $type_element=
  474:             &Apache::loncommon::select_form(
  475:                 $typeselect,
  476:                 'only',
  477:                 \%select_file_categories,$onchange);
  478:         my $type_selector = '<label>'.&mt('File Type Displayed: [_1]',
  479:                                           $type_element).'</label>';
  480: 
  481: # ------------------------------- output state of file attributes to be showing
  482: #                                 All versions has to the last item
  483: #                                 since it does not take an extra col
  484: 	my %lt=&Apache::lonlocal::texthash(
  485: 					   'av' => 'All versions',
  486: 					   'ud' => 'Update Display',
  487: 					   'pr' => 'Problems',
  488: 					   'gr' => 'Graphics',
  489: 					   'at' => 'All types',
  490: 					   'hd' => 'Display Options'
  491: 					   );
  492:         my @disp_order = ('0','4','5','6','13','1','2','3','10','14','8','11','7','12','15','16');
  493:         my %disp_options = &Apache::lonlocal::texthash (
  494:                               0  => 'Title',
  495:                               4  => 'Author',
  496:                               5  => 'Keywords',
  497:                               6  => 'Language',
  498:                               13 => 'Notes',
  499:                               1  => 'Size',
  500:                               2  => 'Last access',
  501:                               3  => 'Last modified',
  502:                               10 => 'Source Available',
  503:                               14 => 'Abstract',
  504:                               8  => 'Statistics',
  505:                               11 => 'Linked/Related Resources',
  506:                               7  => 'Show resource',
  507:                               12 => 'Subject',
  508:                               15 => 'Grade Level',
  509:                               16 => 'Standards',
  510:                            );
  511:         my $cell = 0;
  512:         my $numinrow = 4;
  513: 	$r->print('
  514: <form method="post" name="fileattr" action="'.$uri.'" enctype="application/x-www-form-urlencoded">
  515: <fieldset>
  516: <legend>'.$lt{'hd'}.'</legend>
  517: <table style=" border-collapse: collapse; border-style: none;">'."\n");
  518:         foreach my $item (@disp_order) {
  519:             my $style = 'padding-left: 12px; padding-right: 8px;';
  520:             if ($cell%$numinrow == 0) {
  521:                 $r->print('<tr>');
  522:             }
  523:             $cell ++;
  524:             if ($cell > 3 * $numinrow) {
  525:                 $style .= ' padding-bottom: 6px;'; 
  526:             }
  527:             if (defined($disp_options{$item})) {
  528:                 $r->print('<td style="'.$style.'"><span class="LC_nobreak">'.
  529:                           '<label><input type="checkbox" name="attr'.$item.'" value="1" '.
  530:                           $attrchk[$item].' onclick="this.form.submit();" /> '.$disp_options{$item}.
  531:                           '</label></span></td>'."\n");
  532:             }
  533:             if ($cell > 1 && $cell%$numinrow == 0) {
  534:                 $r->print('</tr>');
  535:             }
  536:         }
  537:         $r->print(<<END);
  538: <tr>
  539: <td style="font-style: italic; border-top: 1px solid black; padding-top: 6px"> 
  540: <label><input type="checkbox" name="attr9" value="1" $attrchk[9] onclick="this.form.submit();" /> $lt{'av'}</label>
  541: </td>
  542: <td colspan="3" style="padding-left:8px; padding-top: 4px; font-style: italic; border-top: 1px solid black; padding-top: 8px">$type_selector</td>
  543: </tr>
  544: </table>
  545: <input type="hidden" name="attrs" value="1" />
  546: </fieldset>
  547: <input type="submit" name="updatedisplay" value="$lt{'ud'}" />
  548: <input type="hidden" name="acts" value="" />
  549: $closebutton $groupimportbutton
  550: END
  551:         $r->print(&Apache::loncommon::inhibit_menu_check('input'));
  552:    
  553: # -------------- Filter out sequence containment in crumbs and "recent folders"
  554: 	my $storeuri=$uri;
  555: 	$storeuri='/'.(split(/\.(page|sequence)\/\//,$uri))[-1];
  556: 	$storeuri=~s/\/+/\//g;
  557: # ---------------------------------------------------------------- Bread crumbs
  558:         $r->print(
  559:             '<p>'
  560:            .&Apache::lonhtmlcommon::crumbs(
  561:                 $storeuri,
  562:                 '',
  563:                 '',
  564:                 (($env{'form.catalogmode'} eq 'import')?
  565:                                  'document.forms.fileattr':''))
  566:            .'<br />'
  567:            .&Apache::lonhtmlcommon::select_recent(
  568:                 'residx',
  569:                 'resrecent',
  570:                 '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();')
  571:            .'</p>'
  572:         );
  573: # -------------------------------------------------------- Resource Home Button
  574: 	my $reshome=$env{'course.'.$env{'request.course.id'}.'.reshome'};
  575: 	if ($reshome) {
  576: 	    $r->print("<span class=\"LC_fontsize_large\"><a href='");
  577: 	    if ($env{'form.catalogmode'} eq 'import') {
  578: 		$r->print('javascript:document.forms.fileattr.action="'.&Apache::loncommon::inhibit_menu_check($reshome).'";document.forms.fileattr.submit();');
  579: 	    } else {
  580: 		$r->print($reshome);
  581: 	    }
  582: 	    $r->print("'>".&mt('Home').'</a></span>');
  583: 	}
  584: 	$r->print('</form>');
  585: # ------------------------------------------------------ Remember where we were
  586: 	&Apache::loncommon::storeresurl($storeuri);
  587: 	&Apache::lonhtmlcommon::store_recent('residx',$storeuri,$storeuri);
  588: # -------------------------------------------------- Check All and Uncheck all
  589: 	if ($env{'form.catalogmode'} eq 'import') {
  590: 	    $r->print('<p><input type="button" value="'.&mt("Check All").'" id="checkallbutton" onclick="javascript:checkAll()" />');
  591: 	    $r->print('<input type="button" value="'.&mt("Uncheck All").'" id="uncheckallbutton" onclick="javascript:uncheckAll()" /></p>');
  592: 	}
  593: # ----------------- output starting row to the indexed file/directory hierarchy
  594:         #$r->print(&initdebug());
  595:         #$r->print(&writedebug("Omit:@Omit")) if (@Omit);
  596:         #$r->print(&writedebug("Only:@Only")) if (@Only);
  597:         $r->print(&Apache::loncommon::start_data_table("LC_tableBrowseRes")
  598:                  .&Apache::loncommon::start_data_table_header_row());
  599: 	$r->print("<th $colspan>".&mt('Name')."</th>\n");
  600: 	$r->print("<th></th>\n");
  601: 	$r->print("<th>".&mt('Title')."</th>\n") 
  602: 	    if ($hash{'display_attrs_0'} == 1);
  603: 	$r->print('<th class="LC_right">'.&mt("Size")." (".&mt("bytes").") ".
  604: 		  "</th>\n") if ($hash{'display_attrs_1'} == 1);
  605: 	$r->print("<th>".&mt("Last accessed")."</th>\n") 
  606: 	    if ($hash{'display_attrs_2'} == 1);
  607: 	$r->print("<th>".&mt("Last modified")."</th>\n")
  608: 	    if ($hash{'display_attrs_3'} == 1);
  609: 	$r->print("<th>".&mt("Author(s)")."</th>\n")
  610: 	    if ($hash{'display_attrs_4'} == 1);
  611: 	$r->print("<th>".&mt("Keywords")."</th>\n")
  612: 	    if ($hash{'display_attrs_5'} == 1);
  613: 	$r->print("<th>".&mt("Language")."</th>\n")
  614: 	    if ($hash{'display_attrs_6'} == 1);
  615: 	$r->print("<th>".&mt("Usage Statistics")." <br />(".
  616: 		  &mt("Courses/Network Hits").") ".&mt('updated periodically')."</th>\n")
  617: 	    if ($hash{'display_attrs_8'} == 1);
  618: 	$r->print("<th>".&mt("Source Available")."</th>\n")
  619: 	    if ($hash{'display_attrs_10'} == 1);
  620: 	$r->print("<th>".&mt("Linked/Related Resources")."</th>\n")
  621: 	    if ($hash{'display_attrs_11'} == 1);
  622: 	$r->print("<th>".&mt("Resource")."</th>\n")
  623: 	    if ($hash{'display_attrs_7'} == 1);
  624: 	$r->print("<th>".&mt("Subject")."</th>\n")
  625: 	    if ($hash{'display_attrs_12'} == 1);
  626: 	$r->print("<th>".&mt("Notes")."</th>\n")
  627: 	    if ($hash{'display_attrs_13'} == 1);
  628: 	$r->print("<th>".&mt("Abstract")."</th>\n")
  629: 	    if ($hash{'display_attrs_14'} == 1);
  630: 	$r->print("<th>".&mt("Grade Level")."</th>\n")
  631: 	    if ($hash{'display_attrs_15'} == 1);
  632: 	$r->print("<th>".&mt("Standards")."</th>\n")
  633: 	    if ($hash{'display_attrs_16'} == 1);
  634: 	    
  635:     $r->print(&Apache::loncommon::end_data_table_header_row());
  636:     
  637:     	
  638: 
  639: # ----------------- read in what directories have previously been set to "open"
  640: 	foreach (keys %hash) {
  641: 	    if ($_ =~ /^diropen_status_/) {
  642: 		my $key = $_;
  643: 		$key =~ s/^diropen_status_//;
  644: 		$dirs{$key} = $hash{$_};
  645: 	    }
  646: 	}
  647: 
  648: 	if ($env{'form.openuri'}) {  # take care of review and refresh options
  649: 	    my $uri=$env{'form.openuri'};
  650: 	    if (exists($hash{'diropen_status_'.$uri})) {
  651: 		my $cursta = $hash{'diropen_status_'.$uri};
  652: 		$dirs{$uri} = 'open';
  653: 		$hash{'diropen_status_'.$uri} = 'open';
  654: 		if ($cursta eq 'open') {
  655: 		    $dirs{$uri} = 'closed';
  656: 		    $hash{'diropen_status_'.$uri} = 'closed';
  657: 		}
  658: 	    } else {
  659: 		$hash{'diropen_status_'.$uri} = 'open';
  660: 		$dirs{$uri} = 'open';
  661: 	    }
  662: 	}
  663: 	
  664: 	my $toplevel;
  665: 	my $indent = 0;
  666: 	$uri = $uri.'/' if $uri !~ /.*\/$/;
  667: 
  668:  	if ($env{'form.dirPointer'} ne 'on') {
  669:  	    $hash{'top.level'} = $uri;
  670:  	    $toplevel = $uri;
  671:  	} else {
  672:  	    $toplevel = $hash{'top.level'};
  673:  	}
  674: 
  675: # -------------------------------- if not at top level, provide an uplink arrow
  676: 	if ($toplevel ne '/res/'){
  677: 	    my (@uri_com) = split(/\//,$uri);
  678: 	    pop @uri_com;
  679: 	    my $upone = join('/',@uri_com);
  680: 	    my @list = qw (0);
  681: 	    &display_line ($r,'opened',$upone.'&viewOneUp',0,$upone,@list);
  682: 	    $indent = 1;
  683: 	}
  684: 
  685: # -------- recursively go through all the directories and output as appropriate
  686: 	&scanDir ($r,$toplevel,$indent,\%hash);
  687: 
  688: # -------------------------------------------------------------- end the tables
  689:         $r->print(&Apache::loncommon::end_data_table());
  690: 
  691: # ---------------------------- embed hidden information useful for group import
  692: 	$r->print("<form name='fnum' action=''>");
  693: 	$r->print("<input type='hidden' name='fnum' value='$fnum' /></form>");
  694: 
  695: # --------------------------------------------------- end the output and return
  696: 	$r->print(&Apache::loncommon::end_page()."\n");
  697:     }
  698:     if(! $c->aborted()) {
  699: # write back into the temporary file
  700: 	my %dbfile;
  701:         if (tie(%dbfile,'GDBM_File',$diropendb,&GDBM_NEWDB(),0640)) {
  702:             while (my($key,$value) = each(%hash)) {
  703:                 $dbfile{$key}=$value;
  704:             }
  705:             untie(%dbfile);
  706:         }
  707:     }
  708: 
  709:     return OK;
  710: }
  711: 
  712: # ----------------------------------------------- recursive scan of a directory
  713: sub scanDir {
  714:     my ($r,$startdir,$indent,$hashref)=@_;
  715:     my $c = $r->connection();
  716:     my ($compuri,$curdir);
  717:     my $dirptr=16384;
  718:     my $obs;
  719:     $indent++;
  720:     my %dupdirs = %dirs;
  721:     my @list=&get_list($r,$startdir);
  722:     foreach my $line (@list) {
  723:         return if ($c->aborted());
  724: 	#This is a kludge, sorry aboot this
  725: 	my ($strip,$dom,undef,$testdir,undef,undef,undef,undef,undef,undef,undef,undef,undef,undef,$obs,undef)=split(/\&/,$line,16); 
  726: 	next if($strip =~ /.*\.meta$/ | $obs eq '1');
  727: 	my (@fileparts) = split(/\./,$strip);
  728: 	if ($hash{'display_attrs_9'} != 1) {
  729:             # if not all versions to be shown
  730: 	    if (scalar(@fileparts) >= 3) {
  731: 		my $fext = pop @fileparts;
  732: 		my $ov = pop @fileparts;
  733: 		my $fname = join ('.',@fileparts,$fext);
  734: 		next if (grep /\Q$fname\E/,@list and $ov =~ /^\d+$/);
  735: 	    }
  736: 	}
  737: 
  738: 	if ($dom eq 'domain') {
  739: 	    # dom list has full path /res/<domain name>/ already
  740: 	    $curdir='';
  741: 	    $compuri = (split(/\&/,$line))[0];
  742: 	} else {
  743: 	    # user, dir & file have name only, i.e., w/o path
  744: 	    $compuri = join('',$startdir,$strip,'/');
  745: 	    $curdir = $startdir;
  746: 	}
  747: 	my $diropen = 'closed';
  748: 	if (($dirptr&$testdir) or ($dom =~ /^(domain|user)$/) or ($compuri=~/\.(sequence|page)\/$/)) {
  749: 	    while (my ($key,$val)= each %dupdirs) {
  750: 		if ($key eq $compuri and $val eq "open") {
  751: 		    $diropen = "opened";
  752: 		    delete($dupdirs{$key});
  753: 		    delete($dirs{$key});
  754: 		}
  755: 	    }
  756: 	}
  757: 	&display_line($r,$diropen,$line,$indent,$curdir,$hashref,@list);
  758: 	&scanDir ($r,$compuri,$indent) if $diropen eq 'opened';
  759:     }
  760:     $indent--;
  761: }
  762: 
  763: # --------------- get complete matched list based on the uri (returns an array)
  764: sub get_list {
  765:     my ($r,$uri)=@_;
  766:     my @list=();
  767:     my $listerror;
  768:     
  769:     (my $luri = $uri) =~ s/\//_/g;
  770:     if ($env{'form.updatedisplay'}) {
  771: 	foreach (keys %hash) {
  772: 	    delete $hash{$_} if ($_ =~ /^dirlist_files_/);
  773: 	    delete $hash{$_} if ($_ =~ /^dirlist_timestamp_files_/);
  774: 	}
  775:     }
  776: 
  777:     if (defined($hash{'dirlist_files_'.$luri}) &&
  778: 	$hash{'dirlist_timestamp_files_'.$luri}+600 > (time)) {
  779: 	@list = split(/\n/,$hash{'dirlist_files_'.$luri});
  780:     } elsif ($uri=~/\.(page|sequence)\/$/) {
  781: # is a page or a sequence
  782: 	$uri=~s/\/$//;
  783: 	$uri='/'.(split(/\.(page|sequence)\/\//,$uri))[-1];
  784: 	$uri=~s/\/+/\//g;
  785: 	foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$uri))) {
  786: 	    my @ratpart=split(/\:/,$_);
  787: 	    push(@list,&LONCAPA::map::qtescape($ratpart[1]));
  788: 	} 
  789: 	$hash{'dirlist_files_'.$luri} = join("\n",@list);
  790:     } else {
  791: # is really a directory
  792: 	(my $listref,$listerror) = &Apache::lonnet::dirlist($uri);
  793:         if (ref($listref) eq 'ARRAY') {
  794:             @list = @{$listref};
  795:         }
  796: 	$hash{'dirlist_files_'.$luri} = join("\n",@list);
  797: 	$hash{'dirlist_timestamp_files_'.$luri} = time;
  798:     }
  799: #Checking for error messages associated with empty directories or inaccessible servers (See Bug 4984)
  800:     if (($listerror eq 'no_such_dir') || ($listerror eq 'no_such_host') || ($listerror eq 'no_host')) { 
  801:         $r->print("<p class='LC_info'>" . &mt("Directory does not exist."). "</p>");
  802:     } elsif ($listerror eq 'con_lost') {
  803:         $r->print("<p class='LC_info'>" . &mt("Directory temporarily not accessible."). "</p>");
  804:     }
  805: 
  806:     return @list=&match_ext($r,@list);    
  807: }
  808: 
  809: sub dynmetaread {
  810:     my $uri=shift;
  811:     if (($hash{'display_attrs_8'}==1) || ($hash{'display_attrs_11'}==1)) {
  812: # We don't want the filename
  813: 	$uri=~s/\/[^\/]+$//;
  814: # Did we already see this?
  815: 	my $builddir=$uri;
  816: 	while ($builddir) {
  817: 	    if ($dynread{$builddir}) {
  818: 		return 0;
  819: 	    }
  820: 	    $builddir=~s/\/[^\/]+$//;
  821: 	}
  822: # Actually get the data
  823: 	%dynhash=
  824: 	    (%dynhash,&Apache::lonmeta::get_dynamic_metadata_from_sql($uri.'/'));
  825: # Remember that we got it
  826: 	$dynread{$uri}=1;
  827:     } 
  828: }
  829: 
  830: sub initdebug {
  831:     my $start_page=
  832: 	&Apache::loncommon::start_page('Debug',undef,
  833: 				       {'only_body' => 1,});
  834:     $start_page =~ s/\n/ /g;
  835:     return <<ENDJS;
  836: <script type="text/javascript">
  837: var debugging = true;
  838: if (debugging) {
  839:     var debuggingWindow = window.open('','Debug','width=400,height=300',true);
  840: } 
  841: 
  842: function output(text) {
  843:     if (debugging) {
  844:         debuggingWindow.document.writeln(text);
  845:     }
  846: }
  847: output('$start_page<pre>');   
  848: </script>
  849: ENDJS
  850: }
  851: 
  852: sub writedebug {
  853:     my ($text) = @_;
  854:     return "<script type=\"text/javascript\">output('$text');</script>";
  855: }
  856: 
  857: # -------------------- filters out files based on extensions (returns an array)
  858: sub match_ext {
  859:     my ($r,@packlist)=@_;
  860:     my @trimlist;
  861:     my $nextline;
  862:     my @fileext;
  863:     my $dirptr=16384;
  864: 
  865:     foreach my $line (@packlist) {
  866: 	chomp $line;
  867: 	$line =~ s/^\/home\/httpd\/html//;
  868: 	my @unpackline = split (/\&/,$line);
  869: 	next if ($unpackline[0] eq '.');
  870: 	next if ($unpackline[0] eq '..');
  871: 	my @filecom = split (/\./,$unpackline[0]);
  872: 	my $fext = pop(@filecom);
  873: 	my $fnptr = ($unpackline[3]&$dirptr) || ($fext=~/\.(page|sequence)$/);
  874:  	if ($fnptr == 0 and $unpackline[3] ne "") {
  875: 	    my $embstyle = &Apache::loncommon::fileembstyle($fext);
  876:             push @trimlist,$line if (defined($embstyle) && 
  877: 				     ($embstyle ne 'hdn' or $fext eq 'meta'));
  878: 	} else {
  879: 	    push @trimlist,$line;
  880: 	}
  881:     }
  882:     @trimlist = sort {uc($a) cmp uc($b)} (@trimlist);
  883:     return @trimlist;
  884: }
  885: 
  886: # ------------------------------- displays one line in appropriate table format
  887: sub display_line {
  888:     my ($r,$diropen,$line,$indent,$startdir,$hashref,@list)=@_;
  889:     my (@pathfn, $fndir);
  890: # there could be relative paths (files actually belonging into this directory)
  891: # or absolute paths (for example, from sequences)
  892:     my $absolute;
  893:     my $pathprefix;
  894:     if ($line=~m|^/res/| && $startdir ne '') {
  895: 	$absolute=1;
  896: 	$pathprefix='';
  897:     } else {
  898: 	$absolute=0;
  899: 	$pathprefix=$startdir;
  900:     }
  901:     my $dirptr=16384;
  902: #SB my $fileclr="#ffffe6";
  903:     my $iconpath= $r->dir_config('lonIconsURL') . '/';
  904: 
  905:     my @filecom = split (/\&/,$line);
  906:     my @pathcom = split (/\//,$filecom[0]);
  907:     my $listname = $pathcom[scalar(@pathcom)-1];
  908:     my $fnptr = $filecom[3]&$dirptr;
  909:     my $msg = &mt('View').' '.$filecom[0].' '.&mt('resources');
  910:     $msg = &mt('Close').' '.$filecom[0].' '.&mt('directory') if $diropen eq 'opened';
  911:     my $nowOpen = ($diropen eq 'opened' ? 1 : 0);
  912: 
  913:     my $tabtag='</td>';
  914:     my $i=0;
  915:     while ($i<=16) {
  916: 	$tabtag=join('',$tabtag,"<td>&nbsp;</td>")
  917: 	    if ($i != 9 &&
  918: 		$hash{'display_attrs_'.$i} == 1);
  919: 	$i++;
  920:     }
  921:     my $valign = ($hash{'display_attrs_7'} == 1 ? 'top' : 'bottom');
  922: 
  923: # display uplink arrow
  924:     if ($filecom[1] eq 'viewOneUp') {
  925: 	my $updir=$startdir;
  926: # -------------- Filter out sequence containment in crumbs and "recent folders"
  927: 	$updir='/'.(split(/\.(page|sequence)\/\//,$startdir))[-1];
  928: 	$updir=~s/\/+/\//g;
  929: 
  930: #SB	$r->print("<tr valign='$valign' bgcolor=\"$fileclr\">$extrafield");
  931:         $r->print(&Apache::loncommon::start_data_table_row()); # valign="$valign" ?!?
  932:         $r->print($extrafield);
  933: 	$r->print("<td>\n");
  934: 	$r->print ('<form method="post" name="dirpathUP" action="'.$updir.
  935: 		   '/" '.
  936: 		   'onsubmit="return rep_dirpath(\'UP\','.
  937: 		   'document.forms.fileattr.acts.value)" '.
  938: 		   'enctype="application/x-www-form-urlencoded"'.
  939:                    '>'."\n");
  940: 	$r->print(&Apache::loncommon::inhibit_menu_check('input'));
  941: 	$r->print ('<input type="hidden" name="openuri" value="'.
  942: 		   $startdir.'" />'."\n");
  943:         $r->print ('<input type="hidden" name="acts" value="" />'."\n");
  944: 	$r->print ('<a href="#" onclick="document.dirpathUP.submit()"><img src="'.$iconpath.'arrow.up.gif"');
  945: 	$r->print (' alt="'.$msg.'" class="LC_fileicon" />'.
  946: 		   "\n");
  947: 	$r->print(&mt("Up")."</a></form></td><td>$tabtag");
  948:         $r->print(&Apache::loncommon::end_data_table_row());
  949: 	return OK;
  950:     }
  951: # Do we have permission to look at this?
  952:     if($filecom[15] ne '1') { return OK if ((!&Apache::lonnet::allowed('bre',$pathprefix.$filecom[0])) && (!&Apache::lonnet::allowed('bro',$pathprefix.$filecom[0]))); }
  953: 
  954: # make absolute links appear on different background
  955: #SB    if ($absolute) { $fileclr='#ccdd99'; }
  956: 
  957: # display domain
  958:     if ($filecom[1] eq 'domain') {
  959:  	$r->print ('<input type="hidden" name="dirPointer" value="on" />'."\n")
  960:  	    if ($env{'form.dirPointer'} eq "on");
  961: #SB	$r->print("<tr valign='$valign' bgcolor=\"$fileclr\">$extrafield");
  962: 	$r->print(&Apache::loncommon::start_data_table_row()); # valign="$valign" ?!?"
  963:         $r->print($extrafield);
  964: 	$r->print("<td>");
  965: 	&begin_form ($r,$filecom[0]);
  966: 	my $anchor = $filecom[0];
  967: 	$anchor =~ s/\W//g;
  968: 	$r->print ('<a name="'.$anchor.'"></a>');
  969: $r->print ('<input type="hidden" name="acts" value="" />');
  970: 	$r->print ('<a href="#" onclick="document.dirpath'.($dnum-1).'.submit()"><img src="'.$iconpath.'arrow.'.($nowOpen ? "open" : "closed" ).'.gif"'); 
  971: 	$r->print (' alt="'.$msg.'" class="LC_fileicon" /></a>'.
  972: 		   "\n");
  973: 	my $quotable_filecom = &Apache::loncommon::escape_single($filecom[0]);
  974: 	$r->print ('<a href="javascript:gothere(\''.$quotable_filecom.
  975: 		   '\')"><img alt="" src="'.$iconpath.'server.gif"');
  976: 	$r->print (' class="LC_fileicon" />'."\n");
  977: 	$r->print (&mt("Domain")." - $listname </a>");
  978: 	if (&Apache::lonnet::domain($listname,'description')) {
  979: 	    $r->print("<br />(".&Apache::lonnet::domain($listname,'description').
  980: 		      ")");
  981: 	}
  982: 	$r->print("</form></td><td>$tabtag");
  983:          $r->print(&Apache::loncommon::end_data_table_row());
  984: 	return OK;
  985: 
  986: # display user directory
  987:     }
  988:     if ($filecom[1] eq 'user') {
  989: 	# $r->print("<tr valign=$valign bgcolor=\"$fileclr\">$extrafield");
  990: 	my $curdir = $startdir.$filecom[0].'/';
  991: 	my $anchor = $curdir;
  992: 	$anchor =~ s/\W//g;
  993: #SB	$r->print("<tr bgcolor=\"$fileclr\">$extrafield<td valign=$valign>");
  994:         $r->print(&Apache::loncommon::start_data_table_row()
  995:                  .$extrafield.'<td class="LC_'.$valign.'">');
  996: 	&begin_form ($r,$curdir);
  997: 	$r->print ('<a name="'.$anchor.'"></a><img alt="" src="'.$iconpath.
  998: 		   'whitespace_21.gif" class="LC_icon" />'."\n");
  999: 	$r->print ('<input type="hidden" name="acts" value="" />');
 1000: 	$r->print ('<a href="#" onclick="document.dirpath'.($dnum-1).'.submit()">');
 1001:         $r->print ('<img src="'.$iconpath.'arrow.'.($nowOpen ? "open" : "closed" ).
 1002: 		   '.gif" class="LC_fileicon"'); 
 1003: 	$r->print (' alt="'.$msg.'"/></a>'.
 1004: 		   "\n");
 1005: 	my $quotable_curdir = &Apache::loncommon::escape_single($curdir);
 1006: 	$r->print ('<a href="javascript:gothere(\''.$quotable_curdir
 1007: 		   .'\')"><img alt="'.$msg.'" src="'.
 1008: 		   $iconpath.'quill.gif" class="LC_fileicon" />');
 1009: 	my $domain=(split(m|/|,$startdir))[2];
 1010: 	my $plainname=&Apache::loncommon::plainname($listname,$domain);
 1011:         $r->print ($listname.'</a>');
 1012: 
 1013:         if (defined($plainname) && $plainname) { $r->print(" ($plainname) "); }
 1014: # Wishlistlink
 1015:         $r->print('</form></td><td><a href="javascript:;" '.
 1016:                   'title="'.&mt('Save a link for this folder in your personal Stored Links repository').'" '.
 1017:                   'onclick="set_wishlistlink('."'$plainname','$startdir$listname'".')">'.
 1018:                   '<img class="LC_icon" src="/res/adm/pages/wishlist.png" '.
 1019:                   'alt="'.&mt('save in Stored Links').'" style="width:22px;"/></a>'.$tabtag);
 1020:         $r->print(&Apache::loncommon::end_data_table_row());
 1021:         return OK;
 1022:     }
 1023: 
 1024: # display file
 1025:         if (($fnptr == 0 and $filecom[3] ne '') or $absolute) {
 1026:             my $title;
 1027:             my $filelink = $pathprefix.$filecom[0];
 1028:             if ($hash{'display_attrs_0'} == 1) {
 1029:                 $title = &Apache::lonnet::gettitle($filelink);
 1030:             }
 1031:             my @file_ext = split (/\./,$listname);
 1032:             my $curfext = $file_ext[-1];
 1033:             if (@Omit) {
 1034:                 foreach (@Omit) { return OK if (lc($curfext) eq $_); }
 1035:             }
 1036:             if (@Only) {
 1037:                 my $skip = 1;
 1038:                 foreach (@Only) { $skip = 0 if (lc($curfext) eq $_); }
 1039:                 return OK if ($skip > 0);
 1040:             }
 1041:             # Set the icon for the file
 1042:             my $iconname = &Apache::loncommon::icon($listname);
 1043: #SB	$r->print("<tr valign='$valign' bgcolor=\"$fileclr\">);
 1044:         $r->print(&Apache::loncommon::start_data_table_row()); #SB valign="$valign" ?!?
 1045:         $r->print('<td class="LC_middle LC_nobreak">');
 1046: 	
 1047:         if ($env{'form.catalogmode'} eq 'interactive') {
 1048: 	    my $quotable_filelink = &Apache::loncommon::escape_single($filelink);
 1049:             $r->print("<a href=\"javascript:select_data(\'",
 1050:                       $quotable_filelink,"')\">");
 1051: 	    $r->print("<img alt=\"\" src='",$iconpath,"select.gif' class='LC_icon' /></a>".
 1052: 		      "\n");
 1053: 	    $r->print('</td><td class="LC_middle">');
 1054: 	} elsif ($env{'form.catalogmode'} eq 'import') {
 1055: 	    $r->print("<form name='form$fnum' action=''>\n");
 1056: 	    $r->print("<input type='checkbox' name='filelink"."' ".
 1057: 		      "value='$filelink' onclick='".
 1058: 		      "javascript:queue(\"form$fnum\")' ");
 1059: 	    if ($hash{'store_'.$filelink}) {
 1060: 		$r->print("checked");
 1061: 	    }
 1062: 	    $r->print(" />\n");
 1063: 	    $r->print('</form></td><td class="LC_middle">');
 1064: 	    $hash{"pre_${fnum}_link"}=$filelink;
 1065: 	    $hash{"pre_${fnum}_title"}=$title;
 1066: 	    if (!$hash{"pre_${fnum}_title"}) {
 1067: 	        $hash{"pre_${fnum}_title"} = 'Not_retrieved';
 1068: 	    }
 1069:   	    $fnum++;
 1070: 	}
 1071: # Form to open or close sequences
 1072: 	if ($filelink=~/\.(page|sequence)$/) {
 1073: 	    my $curdir = $startdir.$filecom[0].'/';
 1074: 	    &begin_form($r,$curdir);
 1075: 	    $indent--;
 1076: 	}
 1077: # General indentation
 1078: 	    my $count = 0;
 1079: 	    while ($count < $indent) {
 1080:             $r->print('<img alt="" src="'.$iconpath.'whitespace_21.gif" 
 1081:                 class="LC_icon" />');
 1082: 	        $count++;
 1083: 	    }
 1084: # Sequence open/close icon
 1085: 	if ($filelink=~/\.(page|sequence)$/) {
 1086: 	    my $curdir = $startdir.$filecom[0].'/';
 1087: 	    my $anchor = $curdir;
 1088: 	    $anchor =~ s/\W//g;
 1089: 	    $r->print ('<input type="hidden" name="acts" value="" />');
 1090: 	    $r->print ('<a name="'.$anchor.'"></a>');
 1091:             $r->print ('<a href="#" onclick="document.dirpath'.($dnum-1).'.submit()">');
 1092:             $r->print ('<img src="'.$iconpath.'arrow.'.($nowOpen ? "open" : "closed" ).
 1093:                        '.gif" class="LC_fileicon"');
 1094: 	    $r->print (' alt="'.$msg.'" /></a>'.
 1095: 		       "\n");
 1096: 	}
 1097: # Filetype icons
 1098: 	$r->print("<img alt=\"\" src='$iconname' class='LC_fileicon' />\n");
 1099: 	my $quotable_filelink = &Apache::loncommon::escape_single($filelink);
 1100: 
 1101: 	$r->print (" <a href=\"javascript:openMyModal('".$quotable_filelink."?inhibitmenu=yes',500,500,'yes');\">$listname</a> ");
 1102: 	$quotable_filelink = &Apache::loncommon::escape_single($filelink.'.meta');
 1103: 	&Apache::loncommon::inhibit_menu_check(\$quotable_filelink);
 1104: 	$r->print (" (<a href=\"javascript:openMyModal('".$quotable_filelink."?inhibitmenu=yes',500,500,'yes');\">".&mt('metadata')."</a>) ");
 1105: # Close form to open/close sequence
 1106: 	if ($filelink=~/\.(page|sequence)$/) {
 1107: 	    $r->print('</form>');
 1108: 	}
 1109: 	$r->print("</td>\n");
 1110: # Wishlistlink
 1111:         $r->print('<td><a href="javascript:;" title="'.&mt('Save a link for this resource in your personal Stored Links repository').'" '.
 1112:                   'onclick="set_wishlistlink('."'".&Apache::lonnet::gettitle($filelink).
 1113:                   "','$startdir$listname'".')">'.
 1114:                   '<img class="LC_icon" src="/res/adm/pages/wishlist.png" '.
 1115:                   'alt="'.&mt('save in Stored Links').'" style="width:22px;"/></a></td>');
 1116: 	if ($hash{'display_attrs_0'} == 1) {
 1117: 	    $r->print('<td> '.($title eq '' ? '&nbsp;' : $title).
 1118: 		      ' </td>'."\n");
 1119: 	}
 1120: 	$r->print('<td class="LC_right"> ',
 1121: 		  $filecom[8]," </td>\n") 
 1122: 	    if $hash{'display_attrs_1'} == 1;
 1123: 	$r->print('<td class="LC_nobreak"> '.
 1124:                   (&Apache::lonlocal::locallocaltime($filecom[9]))." </td>\n")
 1125: 	    if $hash{'display_attrs_2'} == 1;
 1126: 	$r->print('<td class="LC_nobreak"> '.
 1127:                   (&Apache::lonlocal::locallocaltime($filecom[10]))." </td>\n")
 1128: 	    if $hash{'display_attrs_3'} == 1;
 1129: 
 1130: 	if ($hash{'display_attrs_4'} == 1) {
 1131: 	    my $author = &Apache::lonnet::metadata($filelink,'author');
 1132: 	    $r->print('<td class="LC_nobreak"> '.($author eq '' ? '&nbsp;' : $author).
 1133: 		      " </td>\n");
 1134: 	}
 1135: 	if ($hash{'display_attrs_5'} == 1) {
 1136: 	    my $keywords = &Apache::lonnet::metadata($filelink,'keywords');
 1137: 	    # $keywords = '&nbsp;' if (!$keywords);
 1138: 	    $r->print('<td> '.($keywords eq '' ? '&nbsp;' : $keywords).
 1139: 		      " </td>\n");
 1140: 	}
 1141: 
 1142: 	if ($hash{'display_attrs_6'} == 1) {
 1143: 	    my $lang = &Apache::lonnet::metadata($filelink,'language');
 1144: 	    $lang = &Apache::loncommon::languagedescription($lang);
 1145: 	    $r->print('<td> '.($lang eq '' ? '&nbsp;' : $lang).
 1146: 		      " </td>\n");
 1147: 	}
 1148: 	if ($hash{'display_attrs_8'} == 1) {
 1149: # statistics
 1150: 	    &dynmetaread($filelink);
 1151: 	    $r->print("<td>");
 1152: 
 1153:         for (qw(count course stdno avetries difficulty disc clear technical
 1154:             correct helpful depth)) {
 1155: 
 1156:             dynmetaprint($r,$filelink,$_);
 1157:         }
 1158: 
 1159: 	    $r->print("&nbsp;</td>\n");
 1160: 
 1161: 	}
 1162: 	if ($hash{'display_attrs_10'} == 1) {
 1163: 	    my $source = &Apache::lonnet::metadata($filelink,'sourceavail');
 1164: 	    if($source eq 'open') {
 1165: 		my $sourcelink = &Apache::lonsource::make_link($filelink,$listname);
 1166: 		my $quotable_sourcelink = &Apache::loncommon::escape_single($sourcelink);
 1167: 		&Apache::loncommon::inhibit_menu_check(\$quotable_sourcelink);
 1168: 		$r->print('<td>'."<a href=\"javascript:openWindow('"
 1169: 			  .$quotable_sourcelink.
 1170: 			  "', 'previewsource', '700', '700', 'no', 'yes','yes');\"".
 1171: 			  " target=\"_self\">".&mt('Source Code')."</a> "."</td>\n");
 1172: 	    } else { #A cuddled else. :P
 1173: 		$r->print("<td>&nbsp;</td>\n");
 1174: 	    }
 1175: 	}
 1176: 	if ($hash{'display_attrs_11'} == 1) {
 1177: # links
 1178: 	   &dynmetaread($filelink);
 1179: 	   $r->print('<td>');
 1180: 	   &coursecontext($r,$filelink);
 1181:        for (qw(goto_list comefrom_list sequsage_list dependencies course_list)) {
 1182:              dynmetaprint($r,$filelink,$_);
 1183:        }
 1184: 	   $r->print('</td>');
 1185:         }
 1186:         
 1187:    
 1188: 	
 1189: 	if ($hash{'display_attrs_7'} == 1) {
 1190: # Show resource
 1191: 	   my $output=&showpreview($filelink);
 1192:            $r->print('<td class="LC_fontsize_medium">'.($output eq '' ? '&nbsp;':$output).
 1193: 		      " </td>\n");
 1194:     }
 1195:     
 1196:     if ($hash{'display_attrs_12'} == 1) {
 1197: 	    my $subject = &Apache::lonnet::metadata($filelink,'subject');
 1198: 	    $r->print('<td> '.($subject eq '' ? '&nbsp;' : $subject).
 1199: 		      " </td>\n");
 1200: 	}
 1201: 	
 1202: 	if ($hash{'display_attrs_13'} == 1) {
 1203: 	    my $notes = &Apache::lonnet::metadata($filelink,'notes');
 1204: 	    $r->print('<td> '.($notes eq '' ? '&nbsp;' : $notes).
 1205: 		      " </td>\n");
 1206: 	}
 1207: 	
 1208: 	if ($hash{'display_attrs_14'} == 1) {
 1209: 	    my $abstract = &Apache::lonnet::metadata($filelink,'abstract');
 1210: 	    $r->print('<td> '.($abstract eq '' ? '&nbsp;' : $abstract).
 1211: 		      " </td>\n");
 1212: 	}
 1213: 	
 1214: 	if ($hash{'display_attrs_15'} == 1) {
 1215: 	    my $gradelevel = &Apache::lonnet::metadata($filelink,'gradelevel');
 1216: 	    $r->print('<td> '.($gradelevel eq '' ? '&nbsp;' : $gradelevel).
 1217: 		      " </td>\n");
 1218: 	}
 1219: 	
 1220: 	if ($hash{'display_attrs_16'} == 1) {
 1221: 	    my $standards = &Apache::lonnet::metadata($filelink,'standards');
 1222: 	    $r->print('<td> '.($standards eq '' ? '&nbsp;' : $standards).
 1223: 		      " </td>\n");
 1224: 	}
 1225: 	
 1226: 	$r->print(&Apache::loncommon::end_data_table_row());
 1227: }
 1228:     
 1229:     
 1230: 
 1231: # -- display directory
 1232:     if ($fnptr == $dirptr) {
 1233: 	my $curdir = $startdir.$filecom[0].'/';
 1234: 	my $anchor = $curdir;
 1235: 	$anchor =~ s/\W//g;
 1236: #SB	$r->print("<tr bgcolor=\"$fileclr\">$extrafield<td valign=$valign>");
 1237:         $r->print(&Apache::loncommon::start_data_table_row()); # SB: bgcolor suggestion: darkgrey ("LC_info_row"?!?)
 1238: #	$r->print('<tr class="LC_info_row">');
 1239:         $r->print($extrafield.'<td class="LC_middle LC_nobreak">');
 1240: 	&begin_form ($r,$curdir);
 1241: 	my $indentm1 = $indent-1;
 1242: 	my $count = 0;
 1243: 	while ($count < $indentm1) {
 1244: 	    $r->print ('<img alt="" src="',$iconpath
 1245: 	               ,'whitespace_21.gif" class="LC_icon" />');
 1246:             $count++;
 1247: 	}
 1248: 	$r->print ('<input type="hidden" name="acts" value="" />');
 1249: 	$r->print ('<a name="'.$anchor.'"></a>');
 1250:         $r->print ('<a href="#" onclick="document.dirpath'.($dnum-1).'.submit()"><img src="'.$iconpath.
 1251: 		   'arrow.'.($nowOpen ? "open" : "closed" ).'.gif"');
 1252: 	$r->print (' alt="'.$msg.'" class="LC_fileicon" /></a>'.
 1253: 		   "\n");
 1254: 	my $quotable_curdir = &Apache::loncommon::escape_single($curdir);
 1255:         
 1256:         my $location = &Apache::loncommon::lonhttpdurl("/adm/lonIcons");
 1257: 	my $icon = "navmap.folder.".($nowOpen ? "open":"closed").'.gif';
 1258:         $r->print ('<a href="javascript:gothere('
 1259:                   ."'$quotable_curdir'".');">'
 1260:                   .'<img class="LC_fileicon" alt="'.&mt('Open Folder').'" src="'
 1261:                   .$location.'/'.$icon.'" />'
 1262:                   ."\n");
 1263: 	$r->print ("$listname</a></form>");
 1264: # Wishlistlink
 1265:         $r->print('</td><td><a href="javascript:;" '.
 1266:                   'title="'.&mt('Save a link for this folder in Stored Links').'" '.
 1267:                   'onclick="set_wishlistlink('."'$listname','$startdir$listname'".')">'.
 1268:                   '<img class="LC_icon" src="/res/adm/pages/wishlist.png" '.
 1269:                   'alt="'.&mt('save in Stored Links').'" style="width:22px;"/></a></td>');
 1270: # Attributes
 1271: 	my $filelink = $startdir.$filecom[0].'/default';
 1272: 
 1273: 	if ($hash{'display_attrs_0'} == 1) {
 1274: 	    my $title = &Apache::lonnet::gettitle($filelink);
 1275: 	    $r->print('<td> '.($title eq '' ? '&nbsp;' : $title).
 1276: 		      ' </td>'."\n");
 1277: 	}
 1278: 	$r->print('<td class="LC_right"> ',
 1279: 		  $filecom[8]," </td>\n") 
 1280: 	    if $hash{'display_attrs_1'} == 1;
 1281: 	$r->print('<td class="LC_break"> '.
 1282:                   (&Apache::lonlocal::locallocaltime($filecom[9]))." </td>\n")
 1283: 	    if $hash{'display_attrs_2'} == 1;
 1284: 	$r->print('<td class="LC_break"> '.
 1285:                   (&Apache::lonlocal::locallocaltime($filecom[10]))." </td>\n")
 1286: 	    if $hash{'display_attrs_3'} == 1;
 1287: 
 1288: 	if ($hash{'display_attrs_4'} == 1) {
 1289: 	    my $author = &Apache::lonnet::metadata($filelink,'author');
 1290: 	    $r->print('<td> '.($author eq '' ? '&nbsp;' : $author).
 1291: 		      " </td>\n");
 1292: 	}
 1293: 	if ($hash{'display_attrs_5'} == 1) {
 1294: 	    my $keywords = &Apache::lonnet::metadata($filelink,'keywords');
 1295: 	    # $keywords = '&nbsp;' if (!$keywords);
 1296: 	    $r->print('<td> '.($keywords eq '' ? '&nbsp;' : $keywords).
 1297: 		      " </td>\n");
 1298: 	}
 1299: 	if ($hash{'display_attrs_6'} == 1) {
 1300: 	    my $lang = &Apache::lonnet::metadata($filelink,'language');
 1301: 	    $lang = &Apache::loncommon::languagedescription($lang);
 1302: 	    $r->print('<td> '.($lang eq '' ? '&nbsp;' : $lang).
 1303: 		      " </td>\n");
 1304: 	}
 1305: 	
 1306: 	if ($hash{'display_attrs_8'} == 1) {
 1307: 	   $r->print('<td>&nbsp;</td>');
 1308: 	}
 1309:  	if ($hash{'display_attrs_10'} == 1) {
 1310: 	   $r->print('<td>&nbsp;</td>');
 1311: 	}
 1312: 	if ($hash{'display_attrs_7'} == 1) {
 1313: 	   $r->print('<td>&nbsp;</td>');
 1314:     }     
 1315:     if ($hash{'display_attrs_11'} == 1) {
 1316: 	   $r->print('<td>&nbsp;</td>');
 1317: 	}
 1318: 	if ($hash{'display_attrs_12'} == 1) {
 1319: 	    my $subject = &Apache::lonnet::metadata($filelink,'subject');
 1320: 	    $r->print('<td> '.($subject eq '' ? '&nbsp;' : $subject).
 1321: 		      " </td>\n");
 1322: 	}
 1323: 	if ($hash{'display_attrs_13'} == 1) {
 1324: 	    my $notes = &Apache::lonnet::metadata($filelink,'notes');
 1325: 	    $r->print('<td> '.($notes eq '' ? '&nbsp;' : $notes).
 1326: 		      " </td>\n");
 1327: 	}
 1328: 	
 1329: 	if ($hash{'display_attrs_14'} == 1) {
 1330: 	    my $abstract = &Apache::lonnet::metadata($filelink,'abstract');
 1331: 	    $r->print('<td> '.($abstract eq '' ? '&nbsp;' : $abstract).
 1332: 		      " </td>\n");
 1333: 	}
 1334: 	
 1335: 	if ($hash{'display_attrs_15'} == 1) {
 1336: 	    my $gradelevel = &Apache::lonnet::metadata($filelink,'gradelevel');
 1337: 	    $r->print('<td> '.($gradelevel eq '' ? '&nbsp;' : $gradelevel).
 1338: 		      " </td>\n");
 1339: 	}
 1340: 	
 1341: 	if ($hash{'display_attrs_16'} == 1) {
 1342: 	    my $standards = &Apache::lonnet::metadata($filelink,'standards');
 1343: 	    $r->print('<td> '.($standards eq '' ? '&nbsp;' : $standards).
 1344: 		      " </td>\n");
 1345: 	}
 1346: 	
 1347: 	
 1348: 	$r->print(&Apache::loncommon::end_data_table_row());
 1349:     }
 1350: 
 1351: }
 1352: 
 1353: sub coursecontext {
 1354:     my ($r,$filelink)=@_;
 1355:     my $filesymb=&Apache::lonnet::symbread($filelink);
 1356:     if ($filesymb) {
 1357: 	my ($map,$index,$resource)=&Apache::lonnet::decode_symb($filesymb);
 1358: 	$r->print(&mt('Already in this course:<br />[_1] in folder/map [_2].<br />',
 1359: 	      &Apache::lonnet::gettitle($resource),
 1360: 	      &Apache::lonnet::gettitle($map)));
 1361:     }
 1362: }
 1363: 
 1364: sub showpreview {
 1365:     my ($filelink)=@_;
 1366:     if ($filelink=~m-^(/ext/|http://)-) {
 1367: 	return &mt('External Resource, preview not enabled');
 1368:     }
 1369:     my ($curfext)=($filelink=~/\.(\w+)$/);
 1370:     my $output='';
 1371:     my $embstyle=&Apache::loncommon::fileembstyle($curfext);
 1372:     if ($embstyle eq 'ssi') {
 1373:        my $cache=$Apache::lonnet::perlvar{'lonDocRoot'}.$filelink.
 1374:                     '.tmp';
 1375:        if ((!$env{'form.updatedisplay'}) &&
 1376:                     (-e $cache)) {
 1377:           open(FH,$cache);
 1378:           $output=join("\n",<FH>);
 1379:           close(FH);
 1380:        } else {
 1381: # In update display mode, remove old cache. This is done to retroactively
 1382: # clean up course context renderings.
 1383: 	  if (-e $cache) {
 1384: 	       unlink($cache);
 1385: 	  }
 1386:           $output=&Apache::lonnet::ssi_body($filelink);
 1387: # Is access denied? Don't render, don't store
 1388:           if ($output=~/LONCAPAACCESSCONTROLERRORSCREEN/s) {
 1389:              $output='';
 1390: # Was this rendered in course content? Don't store
 1391:           } elsif (!&Apache::lonnet::symbread($filelink)) {
 1392:              open(FH,">$cache");
 1393:              print FH $output;
 1394:              close(FH);
 1395:           }
 1396:        }
 1397:     } elsif ($embstyle eq 'img') {
 1398:        $output='<img alt="'.&mt('Preview').'" src="'.$filelink.'" />';
 1399:     } elsif ($filelink=~m{^/res/($match_domain)/($match_username)/}) {
 1400:        $output='<img  alt="'.&mt('Preview').'" src="http://'.
 1401:                  &Apache::lonnet::hostname(&Apache::lonnet::homeserver($2,$1)).
 1402:                  '/cgi-bin/thumbnail.gif?url='.$filelink.'" />';
 1403:     }
 1404:     return $output;
 1405: }
 1406: 
 1407: sub dynmetaprint {
 1408:     my ($r,$filelink,$item)=@_;
 1409:     if ($dynhash{$filelink}->{$item}) {
 1410: 	$r->print("\n<br />".$fieldnames{$item}.': '.
 1411: 		  &Apache::lonmeta::prettyprint($item,
 1412: 						$dynhash{$filelink}->{$item},
 1413: 		  (($env{'form.catalogmode'} ne 'import')?'preview':''),
 1414: 		  '',
 1415: 		  (($env{'form.catalogmode'} eq 'import')?'document.forms.fileattr':''),1));
 1416:     }
 1417: }
 1418: 
 1419: # ------------------- prints the beginning of a form for directory or file link
 1420: sub begin_form {
 1421:     my ($r,$uri) = @_;
 1422:     my $anchor = $uri;
 1423:     $anchor =~ s/\W//g;
 1424:     $uri=&Apache::loncommon::escape_single($uri);
 1425:     $r->print ('<form method="post" name="dirpath'.$dnum.'" action="'.$uri.
 1426: 	       '#'.$anchor.
 1427: 	       '" onsubmit="return rep_dirpath(\''.$dnum.'\''.
 1428: 	       ',document.forms.fileattr.acts.value)" '.
 1429: 	       'enctype="application/x-www-form-urlencoded">'."\n");
 1430:     $r->print ('<input type="hidden" name="openuri" value="'.$uri.'" />'.
 1431: 	       "\n");
 1432:     $r->print ('<input type="hidden" name="dirPointer" value="on" />'."\n");
 1433:     $r->print(&Apache::loncommon::inhibit_menu_check('input'));
 1434:     $dnum++;
 1435: }
 1436: 
 1437: # --------- settings whenever the user causes the indexer window to be launched
 1438: sub start_fresh_session {
 1439:     my ($hash) = @_;
 1440:     delete $hash->{'form.catalogmode'};
 1441:     delete $hash->{'form.mode'};
 1442:     delete $hash->{'form.form'};
 1443:     delete $hash->{'form.element'};
 1444:     delete $hash->{'form.omit'};
 1445:     delete $hash->{'form.only'};
 1446:     foreach (keys %{$hash}) {
 1447:         delete $hash->{$_} if (/^(pre_|store)/);
 1448:     }
 1449: }
 1450: 
 1451: # ------------------------------------------------------------------- setvalues
 1452: sub setvalues {
 1453:     # setvalues is used in registerurl to synchronize the database
 1454:     # hash and environment hashes
 1455:     my ($H1,$h1key,$H2,$h2key) =@_;
 1456:     #
 1457:     if (exists $H2->{$h2key}) {
 1458: 	$H1->{$h1key} = $H2->{$h2key};
 1459:     } elsif (exists $H1->{$h1key}) {
 1460: 	$H2->{$h2key} = $H1->{$h1key};
 1461:     } 
 1462: }
 1463: 
 1464: 1;
 1465: 
 1466: sub cleanup {
 1467:     if (tied(%hash)){
 1468: 	&Apache::lonnet::logthis('Cleanup indexer: hash');
 1469:     }
 1470:     return OK;
 1471: }
 1472: 
 1473: 
 1474: 
 1475: 
 1476: 
 1477: =head1 NAME
 1478: 
 1479: Apache::lonindexer - mod_perl module for cross server filesystem browsing
 1480: 
 1481: =head1 SYNOPSIS
 1482: 
 1483: Invoked by /etc/httpd/conf/srm.conf:
 1484: 
 1485:  <LocationMatch "^/res.*/$">
 1486:  SetHandler perl-script
 1487:  PerlHandler Apache::lonindexer
 1488:  </LocationMatch>
 1489: 
 1490: =head1 INTRODUCTION
 1491: 
 1492: This module enables a scheme of browsing across a cross server.
 1493: 
 1494: This is part of the LearningOnline Network with CAPA project
 1495: described at http://www.lon-capa.org.
 1496: 
 1497: =head1 BEGIN SUBROUTINE
 1498: 
 1499: This routine is only run once after compilation.
 1500: 
 1501: =over 4
 1502: 
 1503: =item *
 1504: 
 1505: Initializes %language hash table.
 1506: 
 1507: =back
 1508: 
 1509: =head1 HANDLER SUBROUTINE
 1510: 
 1511: This routine is called by Apache and mod_perl.
 1512: 
 1513: =over 4
 1514: 
 1515: =item *
 1516: 
 1517: read in machine configuration variables
 1518: 
 1519: =item *
 1520: 
 1521: see if called from an interactive mode
 1522: 
 1523: =item *
 1524: 
 1525: refresh environment with user database values (in %hash)
 1526: 
 1527: =item *
 1528: 
 1529: define extra fields and buttons in case of special mode
 1530: 
 1531: =item *
 1532: 
 1533: set catalogmodefunctions to have extra needed javascript functionality
 1534: 
 1535: =item *
 1536: 
 1537: print header
 1538: 
 1539: =item *
 1540: 
 1541: evaluate actions from previous page (both cumulatively and chronologically)
 1542: 
 1543: =item *
 1544: 
 1545: output title
 1546: 
 1547: =item *
 1548: 
 1549: get state of file attributes to be showing
 1550: 
 1551: =item *
 1552: 
 1553: output state of file attributes to be showing
 1554: 
 1555: =item *
 1556: 
 1557: output starting row to the indexed file/directory hierarchy
 1558: 
 1559: =item *
 1560: 
 1561: read in what directories have previously been set to "open"
 1562: 
 1563: =item *
 1564: 
 1565: if not at top level, provide an uplink arrow
 1566: 
 1567: =item *
 1568: 
 1569: recursively go through all the directories and output as appropriate
 1570: 
 1571: =item *
 1572: 
 1573: information useful for group import
 1574: 
 1575: =item *
 1576: 
 1577: end the tables
 1578: 
 1579: =item *
 1580: 
 1581: end the output and return
 1582: 
 1583: =back
 1584: 
 1585: =head1 OTHER SUBROUTINES
 1586: 
 1587: =over 4
 1588: 
 1589: =item *
 1590: 
 1591: scanDir - recursive scan of a directory
 1592: 
 1593: =item *
 1594: 
 1595: get_list - get complete matched list based on the uri (returns an array)
 1596: 
 1597: =item *
 1598: 
 1599: match_ext - filters out files based on extensions (returns an array)
 1600: 
 1601: =item *
 1602: 
 1603: display_line - displays one line in appropriate table format
 1604: 
 1605: =item *
 1606: 
 1607: begin_form - prints the beginning of a form for directory or file link
 1608: 
 1609: =item *
 1610: 
 1611: start_fresh_session - settings whenever the user causes the indexer window
 1612: to be launched
 1613: 
 1614: =back
 1615: 
 1616: =cut

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