File:  [LON-CAPA] / loncom / interface / lonsearchcat.pm
Revision 1.110: download - view: text, annotated - select for diffs
Tue Dec 11 03:18:39 2001 UTC (22 years, 6 months ago) by harris41
Branches: MAIN
CVS tags: HEAD
causing language to default to 'any'; and temp fix for reading
in filetypes.tab -Scott Harrison

    1: # The LearningOnline Network with CAPA
    2: # Search Catalog
    3: #
    4: # $Id: lonsearchcat.pm,v 1.110 2001/12/11 03:18:39 harris41 Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # YEAR=2001
   29: # 3/8, 3/12, 3/13, 3/14, 3/15, 3/19 Scott Harrison
   30: # 3/20, 3/21, 3/22, 3/26, 3/27, 4/2, 8/15, 8/24, 8/25 Scott Harrison
   31: # 10/12,10/14,10/15,10/16,11/28,11/29,12/10 Scott Harrison
   32: #
   33: ###
   34: 
   35: ###############################################################################
   36: ##                                                                           ##
   37: ## ORGANIZATION OF THIS PERL MODULE                                          ##
   38: ##                                                                           ##
   39: ## 1. Modules used by this module                                            ##
   40: ## 2. Choices for different output views (detailed, summary, xml, etc)       ##
   41: ## 3. BEGIN block (to be run once after compilation)                         ##
   42: ## 4. Handling routine called via Apache and mod_perl                        ##
   43: ## 5. Other subroutines                                                      ##
   44: ##                                                                           ##
   45: ###############################################################################
   46: 
   47: package Apache::lonsearchcat;
   48: 
   49: # ------------------------------------------------- modules used by this module
   50: use strict;
   51: use Apache::Constants qw(:common);
   52: use Apache::lonnet();
   53: use Apache::File();
   54: use CGI qw(:standard);
   55: use Text::Query;
   56: use GDBM_File;
   57: 
   58: # ---------------------------------------- variables used throughout the module
   59: 
   60: # -- information holders
   61: my %language; # holds contents of language.tab
   62: my %cprtag; # holds contents of copyright.tab
   63: my %mimetag; # holds contents of filetypes.tab
   64: my %hostdomains; # matches host name to host domain
   65: my %hostips; # matches host name to host ip
   66: my %hitcount; # stores number of hits per host
   67: 
   68: # -- dynamically rendered interface components
   69: my $closebutton; # button that closes the search window
   70: my $importbutton; # button to take the selected results and go to group sorting
   71: 
   72: # -- miscellaneous variables
   73: my $scrout; # string that holds portions of the screen output
   74: my $yourself; # allows for quickly limiting to oneself
   75: my %hash;
   76: 
   77: # ------------------------------------------ choices for different output views
   78: # Detailed Citation View ---> sub detailed_citation_view
   79: # Summary View ---> sub summary_view
   80: # Fielded Format ---> sub fielded_format_view
   81: # XML/SGML ---> sub xml_sgml_view
   82: my $basicviewselect=<<END;
   83: <select name='basicviewselect'>
   84: <option value='Detailed Citation View'>Detailed Citation View</option>
   85: <option value='Summary View'>Summary View</option>
   86: <option value='Fielded Format'>Fielded Format</option>
   87: <option value='XML/SGML'>XML/SGML</option>
   88: </select>
   89: END
   90: my $advancedviewselect=<<END;
   91: <select name='advancedviewselect'>
   92: <option value='Detailed Citation View'>Detailed Citation View</option>
   93: <option value='Summary View'>Summary View</option>
   94: <option value='Fielded Format'>Fielded Format</option>
   95: <option value='XML/SGML'>XML/SGML</option>
   96: </select>
   97: END
   98: 
   99: # ----------------------------------------------------------------------- BEGIN
  100: sub BEGIN {
  101: # --------------------------------- Compute various listings of metadata values
  102:     $language{'any'}='Any language';
  103:     {
  104: 	my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
  105: 				 '/language.tab');
  106: 	while (<$fh>) {
  107: 	    $_=~/(\w+)\s+([\w\s\-]+)/; chomp;
  108: 	    $language{$1}=$2;
  109: 	}
  110:     }
  111:     $cprtag{'any'}='Any copyright/distribution';
  112:     {
  113: 	my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonIncludes'}.
  114: 				 '/copyright.tab');
  115: 	while (<$fh>) {
  116: 	    $_=~/(\w+)\s+([\w\s\-]+)/; chomp;
  117: 	    $cprtag{$1}=$2;
  118: 	}
  119:     }
  120:     $mimetag{'any'}='Any type';
  121:     {
  122: 	my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
  123: 				 '/filetypes.tab');
  124: 	while (<$fh>) {
  125: 	    if (/^\S/ and !/^\#/) {
  126: 		$_=~/(\S+)\s+(\S+)\s+([\S\s\-]+)/; chomp;
  127: 		$mimetag{$1}=".$1 $3";
  128: 	    }
  129: 	}
  130:     }
  131:     {
  132: 	my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
  133: 				 '/hosts.tab');
  134: 	while (<$fh>) {
  135: 	    $_=~/(\w+?)\:(\w+?)\:(\w+?)\:(.*)/; chomp;
  136: 	    if ($3 eq 'library') {
  137: 		$hostdomains{$1}=$2;
  138: 		$hostips{$1}=$4;
  139: 	    }
  140: 	}
  141:     }
  142: }
  143: 
  144: my $diropendb = "";
  145: my $domain = "";
  146: 
  147: # ----------------------------- Handling routine called via Apache and mod_perl
  148: sub handler {
  149:     my $r = shift;
  150:     untie %hash;
  151:     &get_unprocessed_cgi();
  152: 
  153:     $r->content_type('text/html');
  154:     $r->send_http_header;
  155:     return OK if $r->header_only;
  156: 
  157:     $domain  = $r->dir_config('lonDefDomain');
  158: 
  159:     $diropendb= "/home/httpd/perl/tmp/$domain\_$ENV{'user.name'}_searchcat.db";
  160: 
  161:     if ($ENV{'form.launch'} eq '1') {
  162: 	if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) {
  163: 	    &start_fresh_session();
  164: 	    untie %hash;
  165: 	}
  166: 	else {
  167: 	    $r->print('<html><head></head><body>Unable to tie hash to db '.
  168: 		      'file</body></html>');
  169: 	    return OK;
  170: 	}
  171:     }
  172: 
  173: # ----------------------------------- configure dynamic components of interface
  174:     my $hidden='';
  175:     if ($ENV{'form.catalogmode'} eq 'interactive') {
  176: 	$hidden="<input type='hidden' name='catalogmode' value='interactive'>".
  177: 	    "\n";
  178:         $closebutton="<input type='button' name='close' value='CLOSE' ".
  179: 	    "onClick='self.close()'>"."\n";
  180:     }
  181:     elsif ($ENV{'form.catalogmode'} eq 'groupsearch') {
  182: 	$hidden=<<END;
  183: <input type='hidden' name='catalogmode' value='groupsearch'>
  184: END
  185:         $closebutton=<<END;
  186: <input type='button' name='close' value='CLOSE' onClick='self.close()'>
  187: END
  188:         $importbutton=<<END;
  189: <input type='button' name='import' value='IMPORT'
  190: onClick='javascript:select_group()'>
  191: END
  192:     }
  193: 
  194: # ------------------------------------------------------ Determine current user
  195:     $yourself=$ENV{'user.name'}.'@'.$ENV{'user.domain'};
  196: 
  197: # --- Now, depending on the interface actions, do one of three things here:
  198: # --- 1. a basic search
  199: # --- 2. an advanced search
  200: # --- 3. output a search interface
  201: 
  202: # ----------------------------------- See if a search invocation should be done
  203:     if ($ENV{'form.basicsubmit'} eq 'SEARCH') {
  204: 	untie %hash; return &basicsearch($r,\%ENV);
  205:     }
  206:     elsif ($ENV{'form.advancedsubmit'} eq 'SEARCH') {
  207: 	untie %hash; return &advancedsearch($r,\%ENV);
  208:     }
  209: 
  210: # ----------------------------- Else, begin building search interface to output
  211:     $scrout=''; # building a part of screen output
  212:     $scrout.=&searchphrasefield('Limit by title','title',
  213: 			$ENV{'form.title'});
  214: 
  215:     $scrout.=&searchphrasefield('Limit by author','author',
  216: 			$ENV{'form.author'});
  217: 
  218:     $scrout.=&searchphrasefield('Limit by subject','subject',
  219: 			$ENV{'form.subject'});
  220: 
  221:     $scrout.=&searchphrasefield('Limit by keywords','keywords',
  222: 			$ENV{'form.keywords'});
  223: 
  224:     $scrout.=&searchphrasefield('Limit by URL','url',
  225: 			$ENV{'form.url'});
  226: 
  227: #    $scrout.=&searchphrasefield('Limit by version','version',
  228: #			$ENV{'form.version'});
  229: 
  230:     $scrout.=&searchphrasefield('Limit by notes','notes',
  231: 			$ENV{'form.notes'});
  232: 
  233:     $scrout.=&searchphrasefield('Limit by abstract','abstract',
  234: 			$ENV{'form.abstract'});
  235: 
  236:     $ENV{'form.mime'}='any' unless length($ENV{'form.mime'});
  237:     $scrout.=&selectbox('Limit by MIME type','mime',
  238: 			$ENV{'form.mime'},%mimetag);
  239: 
  240:     $ENV{'form.language'}='any' unless length($ENV{'form.language'});
  241: 
  242:     $scrout.=&selectbox('Limit by language','language',
  243: 			$ENV{'form.language'},%language);
  244:     
  245: 
  246: # ------------------------------------------------ Compute date selection boxes
  247:     $scrout.=<<CREATIONDATESTART;
  248: <p>
  249: <font color="#800000" face="helvetica"><b>LIMIT BY CREATION DATE RANGE:</b>
  250: </font>
  251: <br />
  252: between:
  253: CREATIONDATESTART
  254:     $scrout.=&dateboxes('creationdatestart',1,1,1976,
  255: 			$ENV{'form.creationdatestart_month'},
  256: 			$ENV{'form.creationdatestart_day'},
  257: 			$ENV{'form.creationdatestart_year'},
  258: 			);
  259:     $scrout.=<<CREATIONDATEEND;
  260: and:
  261: CREATIONDATEEND
  262:     $scrout.=&dateboxes('creationdateend',12,31,2051,
  263: 			$ENV{'form.creationdateend_month'},
  264: 			$ENV{'form.creationdateend_day'},
  265: 			$ENV{'form.creationdateend_year'},
  266: 			);
  267:     $scrout.="</p>";
  268: 
  269:     $scrout.=<<LASTREVISIONDATESTART;
  270: <p>
  271: <font color="#800000" face="helvetica"><b>LIMIT BY LAST REVISION DATE RANGE:
  272: </b></font>
  273: <br />between:
  274: LASTREVISIONDATESTART
  275:     $scrout.=&dateboxes('lastrevisiondatestart',1,1,1976,
  276: 			$ENV{'form.lastrevisiondatestart_month'},
  277: 			$ENV{'form.lastrevisiondatestart_day'},
  278: 			$ENV{'form.lastrevisiondatestart_year'},
  279: 			);
  280:     $scrout.=<<LASTREVISIONDATEEND;
  281: and:
  282: LASTREVISIONDATEEND
  283:     $scrout.=&dateboxes('lastrevisiondateend',12,31,2051,
  284: 			$ENV{'form.lastrevisiondateend_month'},
  285: 			$ENV{'form.lastrevisiondateend_day'},
  286: 			$ENV{'form.lastrevisiondateend_year'},
  287: 			);
  288:     $scrout.='</p>';
  289: 
  290:     $scrout.=&searchphrasefield('Limit by publisher/owner','owner',
  291: 				$ENV{'form.owner'});
  292: 
  293:     $ENV{'form.copyright'}='any' unless length($ENV{'form.copyright'});
  294:     $scrout.=&selectbox('Limit by copyright/distribution','copyright',
  295: 			$ENV{'form.copyright'},%cprtag);
  296: 
  297: # ------------------------------------------- Compute customized metadata field
  298:     $scrout.=<<CUSTOMMETADATA;
  299: <p>
  300: <font color="#800000" face="helvetica"><b>LIMIT BY SPECIAL METADATA FIELDS:</b>
  301: </font>
  302: For resource-specific metadata, enter in an expression in the form of 
  303: <i>key</i>=<i>value</i> separated by operators such as AND, OR or NOT.<br />
  304: <b>Example:</b> grandmother=75 OR grandfather=85
  305: <br />
  306: CUSTOMMETADATA
  307: $scrout.=&simpletextfield('custommetadata',$ENV{'form.custommetadata'});
  308: $scrout.=' <i>initial users of this system do not need to worry about this option</i>';
  309: 
  310:     $scrout.=<<CUSTOMSHOW;
  311: <p>
  312: <font color="#800000" face="helvetica"><b>SHOW SPECIAL METADATA FIELDS:</b>
  313: </font>
  314: Enter in a space-separated list of special metadata fields to show
  315: in a fielded listing for each record result.
  316: <br />
  317: CUSTOMSHOW
  318: $scrout.=&simpletextfield('customshow',$ENV{'form.customshow'});
  319: $scrout.=' <i>initial users of this system do not need to worry about this option</i>';
  320: 
  321: # ---------------------------------------------------------------- Print screen
  322:     $r->print(<<ENDDOCUMENT);
  323: <html>
  324: <head>
  325: <title>The LearningOnline Network with CAPA</title>
  326: <script type="text/javascript">
  327:     function openhelp(val) {
  328: 	openhelpwin=open('/adm/help/searchcat.html','helpscreen',
  329: 	     'scrollbars=1,width=400,height=300');
  330: 	openhelpwin.focus();
  331:     }
  332: </script>
  333: </head>
  334: <body bgcolor="#FFFFFF">
  335: <img align='right' src='/adm/lonIcons/lonlogos.gif' />
  336: <h1>Search Catalog</h1>
  337: <form method="post" action="/adm/searchcat">
  338: $hidden
  339: <hr />
  340: <h3>Basic Search</h3>
  341: <p>
  342: Enter terms or phrases separated by search operators
  343: such as AND, OR, or NOT then press SEARCH below.  Terms should be specific
  344: to the title, author, subject, notes, or abstract information associated
  345: with a resource.
  346: <br />
  347: ENDDOCUMENT
  348:     $r->print(&simpletextfield('basicexp',$ENV{'form.basicexp'}));
  349:     $r->print(' ');
  350:     $r->print(&simplecheckbox('titleonly',$ENV{'form.titleonly'}));
  351:     $r->print('<font color="#800000">Title only</font> ');
  352: #    $r->print(&simplecheckbox('allversions',$ENV{'form.allversions'}));
  353: # <font color="#800000">Search historic archives</font>
  354:     $r->print(<<ENDDOCUMENT);
  355: <br />
  356: <input type="submit" name="basicsubmit" value='SEARCH' />
  357: <input type="reset" name="reset" value='RESET' />
  358: $closebutton
  359: $basicviewselect
  360: <input type="button" value="HELP" onClick="openhelp()" />
  361: </p>
  362: <hr />
  363: <h3>Advanced Search</h3>
  364: $scrout
  365: <p>
  366: <input type="submit" name="advancedsubmit" value='SEARCH' />
  367: <input type="reset" name="reset" value='RESET' />
  368: $closebutton
  369: $advancedviewselect
  370: <input type="button" value="HELP" onClick="openhelp()" />
  371: </p>
  372: </form>
  373: </body>
  374: </html>
  375: ENDDOCUMENT
  376:     return OK;
  377: } 
  378: 
  379: # ----------- grab unprocessed CGI variables that may have been appended to URL
  380: sub get_unprocessed_cgi {
  381:     foreach (split(/&/,$ENV{'QUERY_STRING'})) {
  382:        my ($name, $value) = split(/=/,$_);
  383:        $value =~ tr/+/ /;
  384:        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
  385:        if ($name eq 'catalogmode' or $name eq 'launch' or $name eq 'acts') {
  386: 	   $ENV{'form.'.$name}=$value;
  387:        }
  388:     }
  389: }
  390: 
  391: # ------------------------------------------------------------- make persistent
  392: sub make_persistent {
  393:     my $persistent='';
  394:     
  395:     foreach (keys %ENV) {
  396: 	if (/^form\./ && !/submit/) {
  397: 	    my $name=$_;
  398: 	    my $key=$name;
  399: 	    $ENV{$key}=~s/\'//g; # do not mess with html field syntax
  400: 	    $name=~s/^form\.//;
  401: 	    $persistent.=<<END;
  402: <input type='hidden' name='$name' value='$ENV{$key}' />
  403: END
  404:         }
  405:     }
  406:     return $persistent;
  407: }
  408: 
  409: # --------------------------------------------------------- Various form fields
  410: 
  411: sub simpletextfield {
  412:     my ($name,$value)=@_;
  413:     return '<input type=text name=\''.$name.
  414: 	   '\' size=20 value=\''.$value.'\' />';
  415: }
  416: 
  417: sub simplecheckbox {
  418:     my ($name,$value)=@_;
  419:     my $checked='';
  420:     $checked="CHECKED" if $value eq 'on';
  421:     return '<input type=checkbox name=\''.$name.'\' '. $checked . '>';
  422: }
  423: 
  424: sub searchphrasefield {
  425:     my ($title,$name,$value)=@_;
  426:     my $instruction=<<END;
  427: Enter terms or phrases separated by search operators such
  428: as AND, OR, or NOT.
  429: END
  430:     my $uctitle=uc($title);
  431:     return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:</b>".
  432: 	   "</FONT> $instruction<br />".
  433:            '<input type=text name="'.$name.'" size=80 value=\''.$value.'\'>';
  434: }
  435: 
  436: sub dateboxes {
  437:     my ($name,$defaultmonth,$defaultday,$defaultyear,
  438: 	$currentmonth,$currentday,$currentyear)=@_;
  439:     ($defaultmonth,$defaultday,$defaultyear)=('','','');
  440:     my $month=<<END;
  441: <select name="${name}_month">
  442: <option value='$defaultmonth'> </option>
  443: <option value="1">January</option>
  444: <option value="2">February</option>
  445: <option value="3">March</option>
  446: <option value="4">April</option>
  447: <option value="5">May</option>
  448: <option value="6">June</option>
  449: <option value="7">July</option>
  450: <option value="8">August</option>
  451: <option value="9">September</option>
  452: <option value="10">October</option>
  453: <option value="11">November</option>
  454: <option value="12">December</option>
  455: </select>
  456: END
  457:     $month=~s/(\"$currentmonth\")/$1 SELECTED/ if length($currentmonth);
  458:     my $day=<<END;
  459: <select name="${name}_day">
  460: <option value='$defaultday'> </option>
  461: <option value="1">1</option>
  462: <option value="2">2</option>
  463: <option value="3">3</option>
  464: <option value="4">4</option>
  465: <option value="5">5</option>
  466: <option value="6">6</option>
  467: <option value="7">7</option>
  468: <option value="8">8</option>
  469: <option value="9">9</option>
  470: <option value="10">10</option>
  471: <option value="11">11</option>
  472: <option value="12">12</option>
  473: <option value="13">13</option>
  474: <option value="14">14</option>
  475: <option value="15">15</option>
  476: <option value="16">16</option>
  477: <option value="17">17</option>
  478: <option value="18">18</option>
  479: <option value="19">19</option>
  480: <option value="20">20</option>
  481: <option value="21">21</option>
  482: <option value="22">22</option>
  483: <option value="23">23</option>
  484: <option value="24">24</option>
  485: <option value="25">25</option>
  486: <option value="26">26</option>
  487: <option value="27">27</option>
  488: <option value="28">28</option>
  489: <option value="29">29</option>
  490: <option value="30">30</option>
  491: <option value="31">31</option>
  492: </select>
  493: END
  494:     $day=~s/(\"$currentday\")/$1 SELECTED/ if length($currentday);
  495:     my $year=<<END;
  496: <select name="${name}_year">
  497: <option value='$defaultyear'> </option>
  498: <option value="1976">1976</option>
  499: <option value="1977">1977</option>
  500: <option value="1978">1978</option>
  501: <option value="1979">1979</option>
  502: <option value="1980">1980</option>
  503: <option value="1981">1981</option>
  504: <option value="1982">1982</option>
  505: <option value="1983">1983</option>
  506: <option value="1984">1984</option>
  507: <option value="1985">1985</option>
  508: <option value="1986">1986</option>
  509: <option value="1987">1987</option>
  510: <option value="1988">1988</option>
  511: <option value="1989">1989</option>
  512: <option value="1990">1990</option>
  513: <option value="1991">1991</option>
  514: <option value="1992">1992</option>
  515: <option value="1993">1993</option>
  516: <option value="1994">1994</option>
  517: <option value="1995">1995</option>
  518: <option value="1996">1996</option>
  519: <option value="1997">1997</option>
  520: <option value="1998">1998</option>
  521: <option value="1999">1999</option>
  522: <option value="2000">2000</option>
  523: <option value="2001">2001</option>
  524: <option value="2002">2002</option>
  525: <option value="2003">2003</option>
  526: <option value="2004">2004</option>
  527: <option value="2005">2005</option>
  528: <option value="2006">2006</option>
  529: <option value="2007">2007</option>
  530: <option value="2008">2008</option>
  531: <option value="2009">2009</option>
  532: <option value="2010">2010</option>
  533: <option value="2011">2011</option>
  534: <option value="2012">2012</option>
  535: <option value="2013">2013</option>
  536: <option value="2014">2014</option>
  537: <option value="2015">2015</option>
  538: <option value="2016">2016</option>
  539: <option value="2017">2017</option>
  540: <option value="2018">2018</option>
  541: <option value="2019">2019</option>
  542: <option value="2020">2020</option>
  543: <option value="2021">2021</option>
  544: <option value="2022">2022</option>
  545: <option value="2023">2023</option>
  546: <option value="2024">2024</option>
  547: <option value="2025">2025</option>
  548: <option value="2026">2026</option>
  549: <option value="2027">2027</option>
  550: <option value="2028">2028</option>
  551: <option value="2029">2029</option>
  552: <option value="2030">2030</option>
  553: <option value="2031">2031</option>
  554: <option value="2032">2032</option>
  555: <option value="2033">2033</option>
  556: <option value="2034">2034</option>
  557: <option value="2035">2035</option>
  558: <option value="2036">2036</option>
  559: <option value="2037">2037</option>
  560: <option value="2038">2038</option>
  561: <option value="2039">2039</option>
  562: <option value="2040">2040</option>
  563: <option value="2041">2041</option>
  564: <option value="2042">2042</option>
  565: <option value="2043">2043</option>
  566: <option value="2044">2044</option>
  567: <option value="2045">2045</option>
  568: <option value="2046">2046</option>
  569: <option value="2047">2047</option>
  570: <option value="2048">2048</option>
  571: <option value="2049">2049</option>
  572: <option value="2050">2050</option>
  573: <option value="2051">2051</option>
  574: </select>
  575: END
  576:     $year=~s/(\"$currentyear\")/$1 SELECTED/ if length($currentyear);
  577:     return "$month$day$year";
  578: }
  579: 
  580: sub selectbox {
  581:     my ($title,$name,$value,%options)=@_;
  582:     my $uctitle=uc($title);
  583:     my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".
  584: 	"</b></font><br />".'<select name="'.$name.'">';
  585:     foreach (sort keys %options) {
  586:         $selout.='<option value=\''.$_.'\'';
  587:         if ($_ eq $value) { $selout.=' selected'; }
  588:         $selout.='>'.$options{$_}.'</option>';
  589:     }
  590:     return $selout.'</select>';
  591: }
  592: 
  593: # ----------------------------------------------- Performing an advanced search
  594: sub advancedsearch {
  595:     my ($r,$envhash)=@_;
  596:     my %ENV=%{$envhash};
  597: 
  598:     my $fillflag=0;
  599:     # Clean up fields for safety
  600:     for my $field ('title','author','subject','keywords','url','version',
  601: 		   'creationdatestart_month','creationdatestart_day',
  602: 		   'creationdatestart_year','creationdateend_month',
  603: 		   'creationdateend_day','creationdateend_year',
  604: 		   'lastrevisiondatestart_month','lastrevisiondatestart_day',
  605: 		   'lastrevisiondatestart_year','lastrevisiondateend_month',
  606: 		   'lastrevisiondateend_day','lastrevisiondateend_year',
  607: 		   'notes','abstract','mime','language','owner',
  608: 		   'custommetadata','customshow') {
  609: 	$ENV{"form.$field"}=~s/[^\w\/\s\(\)\=\-\"\']//g;
  610:     }
  611: 
  612:     # Check to see if enough information was filled in
  613:     for my $field ('title','author','subject','keywords','url','version',
  614: 		   'notes','abstract','mime','language','owner',
  615: 		   'custommetadata') {
  616: 	if (&filled($ENV{"form.$field"})) {
  617: 	    $fillflag++;
  618: 	}
  619:     }
  620:     unless ($fillflag) {
  621: 	&output_blank_field_error($r);
  622: 	return OK;
  623:     }
  624: 
  625: 
  626:     # Turn the form input into a SQL-based query
  627:     my $query='';
  628: 
  629:     my @queries;
  630:     # Evaluate logical expression AND/OR/NOT phrase fields.
  631:     foreach my $field ('title','author','subject','notes','abstract','url',
  632: 		       'keywords','version','owner') {
  633: 	if ($ENV{'form.'.$field}) {
  634: 	    push @queries,&build_SQL_query($field,$ENV{'form.'.$field});
  635: 	}
  636:     }
  637:     # Evaluate option lists
  638:     if ($ENV{'form.language'} and $ENV{'form.language'} ne 'any') {
  639: 	push @queries,"(language like \"$ENV{'form.language'}\")";
  640:     }
  641:     if ($ENV{'form.mime'} and $ENV{'form.mime'} ne 'any') {
  642: 	push @queries,"(mime like \"$ENV{'form.mime'}\")";
  643:     }
  644:     if ($ENV{'form.copyright'} and $ENV{'form.copyright'} ne 'any') {
  645: 	push @queries,"(copyright like \"$ENV{'form.copyright'}\")";
  646:     }
  647:     # Evaluate date windows
  648:     my $datequery=&build_date_queries(
  649: 			$ENV{'form.creationdatestart_month'},
  650: 			$ENV{'form.creationdatestart_day'},
  651: 			$ENV{'form.creationdatestart_year'},
  652: 			$ENV{'form.creationdateend_month'},
  653: 			$ENV{'form.creationdateend_day'},
  654: 			$ENV{'form.creationdateend_year'},
  655: 			$ENV{'form.lastrevisiondatestart_month'},
  656: 			$ENV{'form.lastrevisiondatestart_day'},
  657: 			$ENV{'form.lastrevisiondatestart_year'},
  658: 			$ENV{'form.lastrevisiondateend_month'},
  659: 			$ENV{'form.lastrevisiondateend_day'},
  660: 			$ENV{'form.lastrevisiondateend_year'},
  661: 			);
  662:     # Test to see if date windows are legitimate
  663:     if ($datequery=~/^Incorrect/) {
  664: 	&output_date_error($r,$datequery);
  665: 	return OK;
  666:     }
  667:     elsif ($datequery) {
  668: 	push @queries,$datequery;
  669:     }
  670: 
  671:     # Process form information for custom metadata querying
  672:     my $customquery='';
  673:     if ($ENV{'form.custommetadata'}) {
  674: 	$customquery=&build_custommetadata_query('custommetadata',
  675: 				      $ENV{'form.custommetadata'});
  676:     }
  677:     my $customshow='';
  678:     if ($ENV{'form.customshow'}) {
  679: 	$customshow=$ENV{'form.customshow'};
  680: 	$customshow=~s/[^\w\s]//g;
  681: 	my @fields=split(/\s+/,$customshow);
  682: 	$customshow=join(" ",@fields);
  683:     }
  684:     # Send query statements over the network to be processed by either the SQL
  685:     # database or a recursive scheme of 'grep'-like actions (for custom
  686:     # metadata).
  687:     if (@queries) {
  688: 	$query=join(" AND ",@queries);
  689: 	$query="select * from metadata where $query";
  690: 	my $reply; # reply hash reference
  691: 	unless ($customquery or $customshow) {
  692: 	    $reply=&Apache::lonnet::metadata_query($query);
  693: 	}
  694: 	else {
  695: 	    $reply=&Apache::lonnet::metadata_query($query,
  696: 						   $customquery,$customshow);
  697: 	}
  698: 	&output_results('Advanced',$r,$envhash,$customquery,$reply);
  699:     }
  700:     elsif ($customquery) {
  701: 	my $reply; # reply hash reference
  702: 	$reply=&Apache::lonnet::metadata_query('',
  703: 					       $customquery,$customshow);
  704: 	&output_results('Advanced',$r,$envhash,$customquery,$reply);
  705:     }
  706:     # should not get to this point
  707:     return 'Error.  Should not have gone to this point.';
  708: }
  709: 
  710: # --------------------------------------------------- Performing a basic search
  711: sub basicsearch {
  712:     my ($r,$envhash)=@_;
  713:     my %ENV=%{$envhash};
  714:     # Clean up fields for safety
  715:     for my $field ('basicexp') {
  716: 	$ENV{"form.$field"}=~s/[^\w\s\(\)\-]//g;
  717:     }
  718: 
  719:     # Check to see if enough is filled in
  720:     unless (&filled($ENV{'form.basicexp'})) {
  721: 	&output_blank_field_error($r);
  722: 	return OK;
  723:     }
  724: 
  725:     # Build SQL query string based on form page
  726:     my $query='';
  727:     my $concatarg=join(',"    ",',
  728: 		       ('title', 'author', 'subject', 'notes', 'abstract'));
  729:     $concatarg='title' if $ENV{'form.titleonly'};
  730: 
  731:     $query=&build_SQL_query('concat('.$concatarg.')',$ENV{'form.'.'basicexp'});
  732: 
  733:     # Get reply (either a hash reference to filehandles or bad connection)
  734:     my $reply=&Apache::lonnet::metadata_query('select * from metadata where '.$query);
  735: 
  736:     # Output search results
  737: 
  738:     &output_results('Basic',$r,$envhash,$query,$reply);
  739: 
  740:     return OK;
  741: }
  742: 
  743: # ------------------------------------------------------------- build_SQL_query
  744: sub build_SQL_query {
  745:     my ($field_name,$logic_statement)=@_;
  746:     my $q=new Text::Query('abc',
  747: 			  -parse => 'Text::Query::ParseAdvanced',
  748: 			  -build => 'Text::Query::Build');
  749:     $q->prepare($logic_statement);
  750:     my $matchexp=${$q}{'matchexp'}; chomp $matchexp;
  751:     my $sql_query=&recursive_SQL_query_build($field_name,$matchexp);
  752:     return $sql_query;
  753: }
  754: 
  755: # ------------------------------------------------- build custom metadata query
  756: sub build_custommetadata_query {
  757:     my ($field_name,$logic_statement)=@_;
  758:     my $q=new Text::Query('abc',
  759: 			  -parse => 'Text::Query::ParseAdvanced',
  760: 			  -build => 'Text::Query::BuildAdvancedString');
  761:     $q->prepare($logic_statement);
  762:     my $matchexp=${$q}{'-parse'}{'-build'}{'matchstring'};
  763:     # quick fix to change literal into xml tag-matching
  764:     # will eventually have to write a separate builder module
  765:     my $oldmatchexp=$matchexp;
  766:     $matchexp=~s/(\w+)\\\=([\w\\\+]+)/\\\<$1\\\>\[\^\\\<\]\*$2\[\^\\\<\]\*\\\<\\\/$1\\\>/g;
  767:     return $matchexp;
  768: }
  769: 
  770: # - Recursively parse a reverse notation expression into a SQL query expression
  771: sub recursive_SQL_query_build {
  772:     my ($dkey,$pattern)=@_;
  773:     my @matches=($pattern=~/(\[[^\]|\[]*\])/g);
  774:     return $pattern unless @matches;
  775:     foreach my $match (@matches) {
  776: 	$match=~/\[ (\w+)\s(.*) \]/;
  777: 	my ($key,$value)=($1,$2);
  778: 	my $replacement='';
  779: 	if ($key eq 'literal') {
  780: 	    $replacement="($dkey like \"\%$value\%\")";
  781: 	}
  782: 	elsif ($key eq 'not') {
  783: 	    $value=~s/like/not like/;
  784: #	    $replacement="($dkey not like $value)";
  785: 	    $replacement="$value";
  786: 	}
  787: 	elsif ($key eq 'and') {
  788: 	    $value=~/(.*[\"|\)]) ([|\(|\^].*)/;
  789: 	    $replacement="($1 AND $2)";
  790: 	}
  791: 	elsif ($key eq 'or') {
  792: 	    $value=~/(.*[\"|\)]) ([|\(|\^].*)/;
  793: 	    $replacement="($1 OR $2)";
  794: 	}
  795: 	substr($pattern,
  796: 	       index($pattern,$match),
  797: 	       length($match),
  798: 	       $replacement
  799: 	       );
  800:     }
  801:     &recursive_SQL_query_build($dkey,$pattern);
  802: }
  803: 
  804: # ------------------------------------------------------------ Build date query
  805: sub build_date_queries {
  806:     my ($cmonth1,$cday1,$cyear1,$cmonth2,$cday2,$cyear2,
  807: 	$lmonth1,$lday1,$lyear1,$lmonth2,$lday2,$lyear2)=@_;
  808:     my @queries;
  809:     if ($cmonth1 or $cday1 or $cyear1 or $cmonth2 or $cday2 or $cyear2) {
  810: 	unless ($cmonth1 and $cday1 and $cyear1 and
  811: 		$cmonth2 and $cday2 and $cyear2) {
  812: 	    return "Incorrect entry for the creation date.  You must specify ".
  813: 		   "a starting month, day, and year and an ending month, ".
  814: 		   "day, and year.";
  815: 	}
  816: 	my $cnumeric1=sprintf("%d%2d%2d",$cyear1,$cmonth1,$cday1);
  817: 	$cnumeric1+=0;
  818: 	my $cnumeric2=sprintf("%d%2d%2d",$cyear2,$cmonth2,$cday2);
  819: 	$cnumeric2+=0;
  820: 	if ($cnumeric1>$cnumeric2) {
  821: 	    return "Incorrect entry for the creation date.  The starting ".
  822: 		   "date must occur before the ending date.";
  823: 	}
  824: 	my $cquery="(creationdate BETWEEN '$cyear1-$cmonth1-$cday1' AND '".
  825: 	           "$cyear2-$cmonth2-$cday2 23:59:59')";
  826: 	push @queries,$cquery;
  827:     }
  828:     if ($lmonth1 or $lday1 or $lyear1 or $lmonth2 or $lday2 or $lyear2) {
  829: 	unless ($lmonth1 and $lday1 and $lyear1 and
  830: 		$lmonth2 and $lday2 and $lyear2) {
  831: 	    return "Incorrect entry for the last revision date.  You must ".
  832: 		   "specify a starting month, day, and year and an ending ".
  833: 		   "month, day, and year.";
  834: 	}
  835: 	my $lnumeric1=sprintf("%d%2d%2d",$lyear1,$lmonth1,$lday1);
  836: 	$lnumeric1+=0;
  837: 	my $lnumeric2=sprintf("%d%2d%2d",$lyear2,$lmonth2,$lday2);
  838: 	$lnumeric2+=0;
  839: 	if ($lnumeric1>$lnumeric2) {
  840: 	    return "Incorrect entry for the last revision date.  The ".
  841: 		   "starting date must occur before the ending date.";
  842: 	}
  843: 	my $lquery="(lastrevisiondate BETWEEN '$lyear1-$lmonth1-$lday1' AND '".
  844: 	           "$lyear2-$lmonth2-$lday2 23:59:59')";
  845: 	push @queries,$lquery;
  846:     }
  847:     if (@queries) {
  848: 	return join(" AND ",@queries);
  849:     }
  850:     return '';
  851: }
  852: 
  853: # ----------------------------- format and output results based on a reply list
  854: # There are two windows that this function writes to.  The main search
  855: # window ("srch") has a listing of the results.  A secondary window ("popwin")
  856: # gives the status of the network search (time elapsed, number of machines
  857: # contacted, etc.)
  858: sub output_results {
  859:     my $fnum; # search result counter
  860:     my ($mode,$r,$envhash,$query,$replyref)=@_;
  861:     my %ENV=%{$envhash};
  862:     my %rhash=%{$replyref};
  863:     my $compiledresult='';
  864:     my $timeremain=300;
  865:     my $elapsetime=0;
  866:     my $resultflag=0;
  867:     my $tflag=1;
  868: 
  869:     # make query information persistent to allow for subsequent revision
  870:     my $persistent=&make_persistent();
  871: 
  872:     # output beginning of search page
  873: 	$r->print(<<BEGINNING);
  874: <html>
  875: <head>
  876: <title>The LearningOnline Network with CAPA</title>
  877: BEGINNING
  878: 
  879:     # conditional output of script functions dependent on the mode in
  880:     # which the search was invoked
  881:         $r->print(<<SCRIPT) if $ENV{'form.catalogmode'} eq 'interactive';
  882: <script type="text/javascript">
  883:     function select_data(title,url) {
  884: 	changeTitle(title);
  885: 	changeURL(url);
  886: 	self.close();
  887:     }
  888:     function changeTitle(val) {
  889: 	if (opener.inf.document.forms.resinfo.elements.t) {
  890: 	    opener.inf.document.forms.resinfo.elements.t.value=val;
  891: 	}
  892:     }
  893:     function changeURL(val) {
  894: 	if (opener.inf.document.forms.resinfo.elements.u) {
  895: 	    opener.inf.document.forms.resinfo.elements.u.value=val;
  896: 	}
  897:     }
  898: </script>
  899: SCRIPT
  900:         $r->print(<<SCRIPT) if $ENV{'form.catalogmode'} eq 'groupsearch';
  901: <script type="text/javascript">
  902:     function select_data(title,url) {
  903: //	alert('DEBUG: Should be storing '+title+' and '+url);
  904:     }
  905:     function queue(val) {
  906: 	if (eval("document.forms.results.returnvalues["+val+"].checked")) {
  907: 	    document.forms.results.acts.value+='1a'+val+'b';
  908: 	}
  909: 	else {
  910: 	    document.forms.results.acts.value+='0a'+val+'b';
  911: 	}
  912:     }
  913:     function select_group() {
  914: 	window.location="/adm/groupsort?catalogmode=groupsearch&acts="+
  915: 	    document.forms.results.acts.value;
  916:     }
  917: </script>
  918: SCRIPT
  919:         $r->print(<<SCRIPT);
  920: <script type="text/javascript">
  921:     function displayinfo(val) {
  922: 	popwin.document.forms.popremain.sdetails.value=val;
  923:     }
  924:     function openhelp(val) {
  925: 	openhelpwin=open('/adm/help/searchcat.html','helpscreen',
  926: 	     'scrollbars=1,width=400,height=300');
  927: 	openhelpwin.focus();
  928:     }
  929:     function abortsearch(val) {
  930: 	openhelpwin=open('/adm/help/searchcat.html','helpscreen',
  931: 	     'scrollbars=1,width=400,height=300');
  932: 	openhelpwin.focus();
  933:     }
  934: </script>
  935: SCRIPT
  936:     $r->rflush();
  937: 
  938:     # begin showing the cataloged results
  939:     $r->print(<<CATALOGBEGIN);
  940: </head>
  941: <body bgcolor="#ffffff">
  942: <img align=right src=/adm/lonIcons/lonlogos.gif>
  943: <h1>Search Catalog</h1>
  944: CATALOGBEGIN
  945:         $r->print(<<CATALOGCONTROLS);
  946: <form name='results' method="post" action="/adm/searchcat">
  947: <input type='hidden' name='acts' value='' />
  948: <input type='button' value='Revise search request'
  949: onClick='this.form.submit();' />
  950: $importbutton
  951: $closebutton
  952: $persistent
  953: <hr />
  954: <h3>Search Query</h3>
  955: CATALOGCONTROLS
  956:     if ($mode eq 'Basic') {
  957: 	$r->print(<<RESULTS);
  958: <p>
  959: <b>Basic search:</b> $ENV{'form.basicexp'}
  960: </p>
  961: RESULTS
  962:     }
  963:     elsif ($mode eq 'Advanced') {
  964: 	$r->print(<<RESULTS);
  965: <p>
  966: <b>Advanced search</b>
  967: $query
  968: </p>
  969: RESULTS
  970:     }
  971:     $r->print('<h3>Search Results</h3>');
  972:     $r->rflush();
  973:     my $servernum=(keys %rhash)+0;
  974: 
  975:     # define server grid (shows status of multiple machines)
  976:     my $hcinit;
  977:     my $grid="'<br />'+";
  978:     $grid.="\n";
  979:     my $sn=1;
  980:     for my $sk (sort keys %rhash) {
  981: 	# '<a href="
  982: 	$grid.="'<a href=\"";
  983: 	# javascript:displayinfo('+
  984: 	$grid.="javascript:opener.displayinfo('+";
  985: 	# "'"+'key
  986: 	$grid.="\"'\"+'";
  987: 	$grid.=$sk;
  988: 	my $hc;
  989: 	if ($rhash{$sk} eq 'con_lost') {
  990: 	    $hc="!!!BAD CONNECTION, CONTACT SYSTEM ADMINISTRATOR!!!";
  991: 	}
  992: 	else {
  993: 	    $hc="'+\"'\"+\"+hc['$sk']+\"+\"'\"+'";
  994: 	    $hcinit.="hc[\"$sk\"]=\"not yet connected...\";";
  995: 	}
  996: 	$grid.=" hitcount=".$hc;
  997: 	$grid.=" domain=".$hostdomains{$sk};
  998: 	$grid.=" IP=".$hostips{$sk};
  999: 	# '+"'"+'">'+
 1000: 	$grid.="'+\"'\"+')\">'+";
 1001: 	$grid.="\n";
 1002: 	$grid.="'<img border=\"0\" name=\"img".$sn."\"".
 1003: 	    " src=\"/adm/lonIcons/srvnull.gif\" alt=\"".$sk."\" /></a>'+\n";
 1004: 	$grid.="'<br />'+\n" unless $sn%10;
 1005:         $sn++;
 1006:     }
 1007: 	    $r->print(<<ENDPOP);
 1008: <script type="text/javascript">
 1009:     popwin=open('','popwin','scrollbars=1,width=400,height=200');
 1010:     popwin.focus();
 1011:     popwin.document.writeln('<'+'html>');
 1012:     popwin.document.writeln('<'+'head>');
 1013:     popwin.document.writeln('<'+'script>');
 1014:     popwin.document.writeln('hc=new Array();$hcinit');
 1015:     popwin.document.writeln('<'+'/script>');
 1016:     popwin.document.writeln('<'+'/head>'+
 1017:         '<'+'body bgcolor="#FFFFFF">'+
 1018: 	'<'+'image name="whirly" align="right" src="/adm/lonIcons/'+
 1019: 	'lonanim.gif" '+
 1020: 	'alt="animated logo" />'+
 1021: 	'<'+'h3>Search Results Progress<'+'/h3>'+
 1022:         '<'+'form name="popremain">'+
 1023:         '<'+'tt>'+
 1024: 	'<'+'br clear="all"/><i>PLEASE BE PATIENT</i>'+
 1025: 	'<'+'br />SCANNING $servernum SERVERS'+
 1026: 	'<'+'br clear="all" />Number of record hits found '+
 1027: 	'<'+'input type="text" size="10" name="numhits"'+
 1028: 	' value="0" />'+
 1029: 	'<'+'br clear="all" />Time elapsed '+
 1030: 	'<'+'input type="text" size="10" name="elapsetime"'+
 1031: 	' value="0" />'+
 1032: 	'<'+'br />'+
 1033: 	'SERVER GRID (click on any cell for details)'+
 1034:         $grid
 1035:         '<'+'br />'+
 1036: 	'Server details '+
 1037: 	'<'+'input type="text" size="25" name="sdetails"'+
 1038: 	' value="" />'+
 1039: 	'<'+'br />'+
 1040: 	' <'+'input type="button" name="button"'+
 1041: 	' value="abort search and view current results" '+
 1042: 	' onClick="javascript:opener.abortsearch()" />'+
 1043: 	' <'+'input type="button" name="button"'+
 1044: 	' value="help" onClick="javascript:opener.openhelp()" />'+
 1045: 	'<'+'/tt>'+
 1046:         '<'+'/form>'+
 1047:         '<'+'/body><'+'/html>');
 1048:     popwin.document.close();
 1049: </script>
 1050: ENDPOP
 1051:     $r->rflush();
 1052: 
 1053:     my $servercount=0;
 1054:     my $hitcountsum=0;
 1055:     my $bloop=$servernum;
 1056:     my %orkey;
 1057:   BLOOP: while(1) {
 1058:       my $sn=0;
 1059:       last BLOOP unless $bloop;
 1060:       last BLOOP unless $timeremain;
 1061:     RLOOP: foreach my $rkey (sort keys %rhash) {
 1062: 	$sn++;
 1063: 	next RLOOP if $orkey{$rkey};
 1064: 	$servercount++;
 1065: 	$tflag=1;
 1066: 	$compiledresult='';
 1067: 	my $hostname=$rkey;
 1068: 	my $reply=$rhash{$rkey};
 1069: 	my @results;
 1070: 	
 1071: 	my $replyfile='';
 1072: 
 1073: 	if ($reply eq 'con_lost') {
 1074: 	    $r->print('<script type="text/javascript">popwin.document.img'.
 1075: 		      $sn.'.'.
 1076: 		      'src="/adm/lonIcons/srvbad.gif";</script>'.
 1077: 		      "\n");
 1078: 	    $r->rflush();
 1079: 	    $bloop--;
 1080: 	    $orkey{$rkey}=1;
 1081: 	}
 1082: 	else {
 1083: 	    $reply=~/^([\.\w]+)$/; # must do since 'use strict' checks for tainting
 1084: 	    $replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1;
 1085: 	    $reply=~/(.*?)\_/;
 1086: 	    {
 1087: 		my $temp=0;
 1088: 	      WLOOP: while (1) {
 1089: 		  if (-e $replyfile && $tflag) {
 1090: 		      $r->print('<script type="text/javascript">'.
 1091: 				'popwin.document.img'.$sn.'.'.
 1092: 				'src="/adm/lonIcons/srvhalf.gif";</script>'.
 1093: 				"\n");
 1094: 		      $r->rflush();
 1095: 		      $r->print('<script type="text/javascript">'.
 1096: 				'popwin.hc["'.$rkey.'"]='.
 1097: 				'"still transferring..."'.';</script>'.
 1098: 				"\n");
 1099: 		      $r->rflush();
 1100: 		      $tflag=0;
 1101: 		  }
 1102: 		  if (-e "$replyfile.end") {
 1103: 		      $bloop--;
 1104: 		      $orkey{$rkey}=1;
 1105: 		      if (-s $replyfile) {
 1106: 			  $r->print('<script type="text/javascript">'.
 1107: 				    'popwin.document.img'.$sn.'.'.
 1108: 				    'src="/adm/lonIcons/srvgood.gif";'.
 1109: 				    '</script>'."\n");
 1110: 			  $r->rflush();
 1111: 			  my $fh=Apache::File->new($replyfile) or 
 1112: 			      ($r->print('ERROR: file '.
 1113: 					 $replyfile.' cannot be opened') and
 1114: 			       return OK);
 1115: 			  @results=<$fh> if $fh;
 1116: 			  $hitcount{$rkey}=@results+0;
 1117: 			  $r->print('<script type="text/javascript">'.
 1118: 				    'popwin.hc["'.$rkey.'"]='.
 1119: 				    $hitcount{$rkey}.';</script>'.
 1120: 				    "\n");
 1121: 			  $r->rflush();
 1122: 			  $hitcountsum+=$hitcount{$rkey};
 1123: 			  $r->print('<script type="text/javascript">'.
 1124: 				    'popwin.document.forms.popremain.'.
 1125: 				    'numhits.value='.$hitcountsum.
 1126: 				    ';</script>'.
 1127: 				    "\n");
 1128: 			  $r->rflush();
 1129: 		      }
 1130: 		      else {
 1131: 			  $r->print('<script type="text/javascript">'.
 1132: 				    'popwin.document.img'.$sn.'.'.
 1133: 				    'src="/adm/lonIcons/srvempty.gif";'.
 1134: 				    '</script>'.
 1135: 				    "\n");
 1136: 			  $r->rflush();
 1137: 			  $r->print('<script type="text/javascript">'.
 1138: 				    'popwin.hc["'.$rkey.'"]=0'.
 1139: 				    ';</script>'.
 1140: 				    "\n");
 1141: 			  $r->rflush();
 1142: 		      }
 1143: 		      last WLOOP;
 1144: 		  }
 1145: 		  if ($temp>1) {
 1146: 		      sleep 1;
 1147: 		      $timeremain--;
 1148: 		      $elapsetime++;
 1149: 		      last WLOOP;
 1150: 		  }
 1151: 		  last WLOOP unless $timeremain;
 1152: 		  sleep 1;
 1153: 		  $timeremain--;
 1154: 		  $elapsetime++;
 1155: 		  $r->print('<script type="text/javascript">'.
 1156: 			    'popwin.document.popremain.elapsetime.'.
 1157: 			    'value="'.$elapsetime.'";</script>'."\n");
 1158: 		  $r->rflush();
 1159: 		  $temp++;
 1160: 	      }
 1161: 	    }
 1162: 	    $r->print('<script type="text/javascript">'.
 1163: 		      'popwin.document.whirly.'.
 1164: 		      'src="'.'/adm/lonIcons/lonanimend.gif'.
 1165: 		      '";</script>'."\n");
 1166: 	    $r->rflush();
 1167: 	}
 1168: 	my $customshow='';
 1169: 	my $extrashow='';
 1170: 	my @customfields;
 1171: 	if ($ENV{'form.customshow'}) {
 1172: 	    $customshow=$ENV{'form.customshow'};
 1173: 	    $customshow=~s/[^\w\s]//g;
 1174: 	    my @fields=map {"<font color=\"#008000\">$_:</font><!-- $_ -->"} 
 1175: 	    split(/\s+/,$customshow);
 1176: 	    @customfields=split(/\s+/,$customshow);
 1177: 	    if ($customshow) {
 1178: 		$extrashow="<ul><li>".join("</li><li>",@fields)."</li></ul>\n";
 1179: 	    }
 1180: 	}
 1181: 	my $customdata='';
 1182: 	my %customhash;
 1183: 	foreach my $result (@results) {
 1184: 	    if ($result=~/^(custom\=.*)$/) { # grab all custom metadata
 1185: 		my $tmp=$result;
 1186: 		$tmp=~s/^custom\=//;
 1187: 		my ($k,$v)=map {&Apache::lonnet::unescape($_);
 1188: 			    } split(/\,/,$tmp);
 1189: 		$customhash{$k}=$v;
 1190: 	    }
 1191: 	}
 1192: 	if (keys %hash) {
 1193: 	    untie %hash;
 1194: 	}
 1195: 	if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) {
 1196: 	    if ($ENV{'form.launch'} eq '1') {
 1197: 		&start_fresh_session();
 1198: 	    }
 1199: 	    foreach my $result (@results) {
 1200: 		next if $result=~/^custom\=/;
 1201: 		chomp $result;
 1202: 		next unless $result;
 1203: 		my @fields=map
 1204: 		{&Apache::lonnet::unescape($_)}
 1205: 		(split(/\,/,$result));
 1206: 		my ($title,$author,$subject,$url,$keywords,$version,
 1207: 		    $notes,$abstract,$mime,$lang,
 1208: 		    $creationdate,$lastrevisiondate,$owner,$copyright)=@fields;
 1209: 
 1210: 		unless ($ENV{'user.adv'}) {
 1211: 		    $keywords='<i>- not displayed -</i>';
 1212: 		    $fields[4]=$keywords;
 1213: 		    $notes='<i>- not displayed -</i>';
 1214: 		    $fields[6]=$notes;
 1215: 		    $abstract='<i>- not displayed -</i>';
 1216: 		    $fields[7]=$abstract;
 1217: 		    $subject='<i>- not displayed -</i>';
 1218: 		    $fields[2]=$subject;
 1219: 		}
 1220: 
 1221: 		my $shortabstract=$abstract;
 1222: 		$shortabstract=substr($abstract,0,200).'...' if length($abstract)>200;
 1223: 		$fields[7]=$shortabstract;
 1224: 		my $shortkeywords=$keywords;
 1225: 		$shortkeywords=substr($keywords,0,200).'...' if length($keywords)>200;
 1226: 		$fields[4]=$shortkeywords;
 1227: 
 1228: 		my $extrashow2=$extrashow;
 1229: 		if ($extrashow) {
 1230: 		    foreach my $field (@customfields) {
 1231: 			my $value='';
 1232: 			if ($customhash{$url}=~/\<${field}[^\>]*\>(.*?)\<\/${field}[^\>]*\>/s) {
 1233: 		            $value=$1;
 1234: 			}
 1235: 		        $extrashow2=~s/\<\!\-\- $field \-\-\>/ $value/g;
 1236: 	            }
 1237:                 }
 1238: 	
 1239: 	        $compiledresult.=<<END if $compiledresult or $servercount!=$servernum;
 1240: <hr align='left' width='200' noshade />
 1241: END
 1242:                 $compiledresult.=<<END;
 1243: <p>
 1244: END
 1245:                 $compiledresult.=<<END if $ENV{'form.catalogmode'} eq 'interactive';
 1246: <font size='-1'><INPUT TYPE="button" NAME="returnvalues" VALUE="SELECT"
 1247: onClick="javascript:select_data('$title','$url')">
 1248: </font>
 1249: <br />
 1250: END
 1251:                 if ($ENV{'form.catalogmode'} eq 'groupsearch') {
 1252: 		    $fnum+=0;
 1253: 		    $hash{"pre_${fnum}_link"}=$url;
 1254: 		    $hash{"pre_${fnum}_title"}=$title;
 1255: 		    $compiledresult.=<<END;
 1256: <font size='-1'><input type="checkbox" name="returnvalues" value="SELECT"
 1257: onClick="javascript:queue($fnum)" />
 1258: </font>
 1259: <br />
 1260: END
 1261: # <input type="hidden" name="title$fnum" value="$title" />
 1262: # <input type="hidden" name="url$fnum" value="$url" />
 1263:                     $fnum++;
 1264: 		}
 1265: 	        my $httphost=$ENV{'HTTP_HOST'};
 1266: 
 1267: 	        my $viewselect;
 1268: 	        if ($mode eq 'Basic') {
 1269: 		    $viewselect=$ENV{'form.basicviewselect'};
 1270: 		}
 1271: 	        elsif ($mode eq 'Advanced') {
 1272: 		    $viewselect=$ENV{'form.advancedviewselect'};
 1273: 		}
 1274: 
 1275: 	        if ($viewselect eq 'Detailed Citation View') {
 1276: 		    $compiledresult.=&detailed_citation_view(@fields,
 1277: 						 $hostname,$httphost,
 1278: 						 $extrashow2);
 1279: 		}
 1280:                 elsif ($viewselect eq 'Summary View') {
 1281: 		    $compiledresult.=&summary_view(@fields,$hostname,$httphost,
 1282: 				       $extrashow2);
 1283: 	        }
 1284:                 elsif ($viewselect eq 'Fielded Format') {
 1285: 		    $compiledresult.=&fielded_format_view(@fields,$hostname,
 1286: 					      $httphost,$extrashow2);
 1287: 	        }
 1288:                 elsif ($viewselect eq 'XML/SGML') {
 1289: 		    $compiledresult.=&xml_sgml_view(@fields,$hostname,$httphost,
 1290: 					$extrashow2);
 1291: 		}
 1292:     
 1293:             }
 1294: 
 1295:             untie %hash;
 1296:         }
 1297:         else {
 1298: 	    $r->print('<html><head></head><body>Unable to tie hash to db '.
 1299: 		  'file</body></html>');
 1300: 	}
 1301: 	if ($compiledresult) {
 1302: 	    $resultflag=1;
 1303: 	}
 1304: 
 1305: 	$r->print(<<RESULTS);
 1306: $compiledresult
 1307: RESULTS
 1308:         my $percent=sprintf('%3.0f',($servercount/$servernum*100));
 1309:     }
 1310:   }
 1311:     unless ($resultflag) {
 1312:         $r->print("\nThere were no results that matched your query\n");
 1313:     }
 1314: #    $r->print('<script type="text/javascript">'.'popwin.close()</script>'."\n"); $r->rflush(); 
 1315:     $r->print(<<RESULTS);
 1316: </body>
 1317: </html>
 1318: RESULTS
 1319: }
 1320: 
 1321: # ------------------------------------------------------ Detailed Citation View
 1322: sub detailed_citation_view {
 1323:     my ($title,$author,$subject,$url,$keywords,$version,
 1324: 	$notes,$shortabstract,$mime,$lang,
 1325: 	$creationdate,$lastrevisiondate,$owner,$copyright,
 1326: 	$hostname,$httphost,$extrashow)=@_;
 1327:     my $result=<<END;
 1328: <i>$owner</i>, last revised $lastrevisiondate
 1329: <h3><A HREF="http://$httphost$url" TARGET='search_preview'>$title</A></h3>
 1330: <h3>$author</h3>
 1331: </p>
 1332: <p>
 1333: <b>Subject:</b> $subject<br />
 1334: <b>Keyword(s):</b> $keywords<br />
 1335: <b>Notes:</b> $notes<br />
 1336: <b>MIME Type:</b> $mimetag{$mime}<br />
 1337: <b>Language:</b> $language{$lang}<br />
 1338: <b>Copyright/Distribution:</b> $cprtag{$copyright}<br />
 1339: </p>
 1340: $extrashow
 1341: <p>
 1342: $shortabstract
 1343: </p>
 1344: END
 1345:     return $result;
 1346: }
 1347: 
 1348: # ---------------------------------------------------------------- Summary View
 1349: sub summary_view {
 1350:     my ($title,$author,$subject,$url,$keywords,$version,
 1351: 	$notes,$shortabstract,$mime,$lang,
 1352: 	$creationdate,$lastrevisiondate,$owner,$copyright,
 1353: 	$hostname,$httphost,$extrashow)=@_;
 1354:     my $result=<<END;
 1355: <a href="http://$httphost$url" TARGET='search_preview'>$author</a><br />
 1356: $title<br />
 1357: $owner -- $lastrevisiondate<br />
 1358: $cprtag{$copyright}<br />
 1359: $extrashow
 1360: </p>
 1361: END
 1362:     return $result;
 1363: }
 1364: 
 1365: # -------------------------------------------------------------- Fielded Format
 1366: sub fielded_format_view {
 1367:     my ($title,$author,$subject,$url,$keywords,$version,
 1368: 	$notes,$shortabstract,$mime,$lang,
 1369: 	$creationdate,$lastrevisiondate,$owner,$copyright,
 1370: 	$hostname,$httphost,$extrashow)=@_;
 1371:     my $result=<<END;
 1372: <b>URL: </b> <A HREF="http://$httphost$url" TARGET='search_preview'>$url</A>
 1373: <br />
 1374: <b>Title:</b> $title<br />
 1375: <b>Author(s):</b> $author<br />
 1376: <b>Subject:</b> $subject<br />
 1377: <b>Keyword(s):</b> $keywords<br />
 1378: <b>Notes:</b> $notes<br />
 1379: <b>MIME Type:</b> $mimetag{$mime}<br />
 1380: <b>Language:</b> $language{$lang}<br />
 1381: <b>Creation Date:</b> $creationdate<br />
 1382: <b>Last Revision Date:</b> $lastrevisiondate<br />
 1383: <b>Publisher/Owner:</b> $owner<br />
 1384: <b>Copyright/Distribution:</b> $cprtag{$copyright}<br />
 1385: <b>Repository Location:</b> $hostname<br />
 1386: <b>Abstract:</b> $shortabstract<br />
 1387: $extrashow
 1388: </p>
 1389: END
 1390:     return $result;
 1391: }
 1392: 
 1393: # -------------------------------------------------------------------- XML/SGML
 1394: sub xml_sgml_view {
 1395:     my ($title,$author,$subject,$url,$keywords,$version,
 1396: 	$notes,$shortabstract,$mime,$lang,
 1397: 	$creationdate,$lastrevisiondate,$owner,$copyright,
 1398: 	$hostname,$httphost,$extrashow)=@_;
 1399:     my $result=<<END;
 1400: <pre>
 1401: &lt;LonCapaResource&gt;
 1402: &lt;url&gt;$url&lt;/url&gt;
 1403: &lt;title&gt;$title&lt;/title&gt;
 1404: &lt;author&gt;$author&lt;/author&gt;
 1405: &lt;subject&gt;$subject&lt;/subject&gt;
 1406: &lt;keywords&gt;$keywords&lt;/keywords&gt;
 1407: &lt;notes&gt;$notes&lt;/notes&gt;
 1408: &lt;mimeInfo&gt;
 1409: &lt;mime&gt;$mime&lt;/mime&gt;
 1410: &lt;mimetag&gt;$mimetag{$mime}&lt;/mimetag&gt;
 1411: &lt;/mimeInfo&gt;
 1412: &lt;languageInfo&gt;
 1413: &lt;language&gt;$lang&lt;/language&gt;
 1414: &lt;languagetag&gt;$language{$lang}&lt;/languagetag&gt;
 1415: &lt;/languageInfo&gt;
 1416: &lt;creationdate&gt;$creationdate&lt;/creationdate&gt;
 1417: &lt;lastrevisiondate&gt;$lastrevisiondate&lt;/lastrevisiondate&gt;
 1418: &lt;owner&gt;$owner&lt;/owner&gt;
 1419: &lt;copyrightInfo&gt;
 1420: &lt;copyright&gt;$copyright&lt;/copyright&gt;
 1421: &lt;copyrighttag&gt;$cprtag{$copyright}&lt;/copyrighttag&gt;
 1422: &lt;/copyrightInfo&gt;
 1423: &lt;repositoryLocation&gt;$hostname&lt;/repositoryLocation&gt;
 1424: &lt;shortabstract&gt;$shortabstract&lt;/shortabstract&gt;
 1425: &lt;/LonCapaResource&gt;
 1426: </pre>
 1427: $extrashow
 1428: END
 1429:     return $result;
 1430: }
 1431: 
 1432: # ---------------------------------------------------- see if a field is filled
 1433: sub filled {
 1434:     my ($field)=@_;
 1435:     if ($field=~/\S/ && $field ne 'any') {
 1436: 	return 1;
 1437:     }
 1438:     else {
 1439: 	return 0;
 1440:     }
 1441: }
 1442: 
 1443: # ---------------- Message to output when there are not enough fields filled in
 1444: sub output_blank_field_error {
 1445:     my ($r)=@_;
 1446:     # make query information persistent to allow for subsequent revision
 1447:     my $persistent=&make_persistent();
 1448: 
 1449:     $r->print(<<BEGINNING);
 1450: <html>
 1451: <head>
 1452: <title>The LearningOnline Network with CAPA</title>
 1453: BEGINNING
 1454:     $r->print(<<RESULTS);
 1455: </head>
 1456: <body bgcolor="#ffffff">
 1457: <img align='right' src='/adm/lonIcons/lonlogos.gif' />
 1458: <h1>Search Catalog</h1>
 1459: <form method="post" action="/adm/searchcat">
 1460: $persistent
 1461: <input type='button' value='Revise search request'
 1462: onClick='this.form.submit();' />
 1463: $closebutton
 1464: <hr />
 1465: <h3>Helpful Message</h3>
 1466: <p>
 1467: Incorrect search query due to blank entry fields.
 1468: You need to fill in the relevant
 1469: fields on the search page in order for a query to be
 1470: processed.
 1471: </p>
 1472: </body>
 1473: </html>
 1474: RESULTS
 1475: }
 1476: 
 1477: # ----------------------------------------------------------- Output date error
 1478: sub output_date_error {
 1479:     my ($r,$message)=@_;
 1480:     # make query information persistent to allow for subsequent revision
 1481:     my $persistent=&make_persistent();
 1482: 
 1483:     $r->print(<<BEGINNING);
 1484: <html>
 1485: <head>
 1486: <title>The LearningOnline Network with CAPA</title>
 1487: BEGINNING
 1488:     $r->print(<<RESULTS);
 1489: </head>
 1490: <body bgcolor="#ffffff">
 1491: <img align='right' src='/adm/lonIcons/lonlogos.gif' />
 1492: <h1>Search Catalog</h1>
 1493: <form method="post" action="/adm/searchcat">
 1494: $persistent
 1495: <input type='button' value='Revise search request'
 1496: onClick='this.form.submit();' />
 1497: $closebutton
 1498: <hr />
 1499: <h3>Helpful Message</h3>
 1500: <p>
 1501: $message
 1502: </p>
 1503: </body>
 1504: </html>
 1505: RESULTS
 1506: }
 1507: 
 1508: # --------- settings whenever the user causes the search window to be launched
 1509: sub start_fresh_session {
 1510:     delete $hash{'mode_catalog'};
 1511:     foreach (keys %hash) {
 1512:         if ($_ =~ /^pre_/) {
 1513:             delete $hash{$_};
 1514:         }
 1515:         if ($_ =~ /^store/) {
 1516: 	    delete $hash{$_};
 1517: 	}
 1518:     }
 1519: }
 1520: 
 1521: 1;
 1522: 
 1523: __END__
 1524: 
 1525: =head1 NAME
 1526: 
 1527: Apache::lonsearchcat - mod_perl module for handling a searchable catalog
 1528: 
 1529: =head1 SYNOPSIS
 1530: 
 1531: Invoked by /etc/httpd/conf/srm.conf:
 1532: 
 1533:  <Location /adm/searchcat>
 1534:  PerlAccessHandler       Apache::lonacc
 1535:  SetHandler perl-script
 1536:  PerlHandler Apache::lonsearchcat
 1537:  ErrorDocument     403 /adm/login
 1538:  ErrorDocument	  500 /adm/errorhandler
 1539:  </Location>
 1540: 
 1541: =head1 INTRODUCTION
 1542: 
 1543: This module enables searching for a distributed browseable catalog.
 1544: 
 1545: This is part of the LearningOnline Network with CAPA project
 1546: described at http://www.lon-capa.org.
 1547: 
 1548: =head1 BEGIN SUBROUTINE
 1549: 
 1550: This routine is only run once after compilation.
 1551: 
 1552: =over 4
 1553: 
 1554: =item *
 1555: 
 1556: Initializes %language hash table.
 1557: 
 1558: =item *
 1559: 
 1560: Initializes %cprtag hash table (for copyright.tab).
 1561: 
 1562: =item *
 1563: 
 1564: Initializes %mimetag hash table (for filetypes.tab).
 1565: 
 1566: =item *
 1567: 
 1568: Initializes %hostdomains and hostips hash table (for hosts.tab).
 1569: 
 1570: =back
 1571: 
 1572: =head1 HANDLER SUBROUTINE
 1573: 
 1574: This routine is called by Apache and mod_perl.
 1575: 
 1576: =over 4
 1577: 
 1578: =item *
 1579: 
 1580: configure dynamic components of interface
 1581: 
 1582: =item *
 1583: 
 1584: determine current user
 1585: 
 1586: =item *
 1587: 
 1588: see if a search invocation should be done
 1589: 
 1590: =item *
 1591: 
 1592: else, begin building search interface to output
 1593: 
 1594: =item *
 1595: 
 1596: compute date selection boxes
 1597: 
 1598: =item *
 1599: 
 1600: compute customized metadata field
 1601: 
 1602: =item *
 1603: 
 1604: print screen
 1605: 
 1606: =back
 1607: 
 1608: =head1 OTHER SUBROUTINES
 1609: 
 1610: =over 4
 1611: 
 1612: =item *
 1613: 
 1614: get_unprocessed_cgi() : reads in critical name/value pairs that may have not
 1615: been processed and passed into %ENV by the web server
 1616: 
 1617: =item *
 1618: 
 1619: make_persistent() : makes a set of hidden HTML fields to make
 1620: SQL search interface information to be persistent
 1621: 
 1622: =back
 1623: 
 1624: WEB INTERFACE COMPONENT FUNCTIONS
 1625: 
 1626: =over 4
 1627: 
 1628: =item *
 1629: 
 1630: simpletextfield(name,value) : returns HTML formatted string for simple text
 1631: field
 1632: 
 1633: =item *
 1634: 
 1635: simplecheckbox(name,value) : returns HTML formatted string for simple
 1636: checkbox
 1637: 
 1638: =item *
 1639: 
 1640: searchphrasefield(title,name,value) : returns HTML formatted string for
 1641: a search expression phrase field
 1642: 
 1643: =item *
 1644: 
 1645: dateboxes(name, defaultmonth, defaultday, defaultyear) : returns HTML
 1646: formatted string for a calendar date
 1647: 
 1648: =item *
 1649: 
 1650: selectbox(title,name,value,%HASH=options) : returns HTML formatted string for
 1651: a selection box field
 1652: 
 1653: =back
 1654: 
 1655: SEARCH FUNCTIONS
 1656: 
 1657: =over 4
 1658: 
 1659: =item *
 1660: 
 1661: advancedsearch(server reference, environment reference) : perform a complex
 1662: multi-field logical query
 1663: 
 1664: =item *
 1665: 
 1666: basicsearch(server reference, environment reference) : perform a simple
 1667: single-field logical query
 1668: 
 1669: =item *
 1670: 
 1671: build_SQL_query(field name, logic) : builds a SQL query string from a
 1672: logical expression with AND/OR keywords
 1673: 
 1674: =item *
 1675: 
 1676: build_custommetadata_query(field_name, logic_statement) : builds a perl
 1677: regular expression from a logical expression with AND/OR keywords
 1678: 
 1679: =item *
 1680: 
 1681: recursive_SQL_query_build(field name, reverse notation expression) : 
 1682: builds a SQL query string from a reverse notation expression
 1683: logical expression with AND/OR keywords
 1684: 
 1685: =item *
 1686: 
 1687: build_date_queries(cmonth1, cday1, cyear1, cmonth2, cday2, cyear2,
 1688: lmonth1, lday1, lyear1, lmonth2, lday2, lyear2) :
 1689: Builds a SQL logic query to check time/date entries.
 1690: 
 1691: =back
 1692: 
 1693: OUTPUTTING RESULTS FUNCTION
 1694: 
 1695: =over 4
 1696: 
 1697: =item *
 1698: 
 1699: output_results(output mode, server reference, environment reference,
 1700: reply list reference) : outputs results from search
 1701: 
 1702: =back
 1703: 
 1704: DIFFERENT WAYS TO VIEW METADATA RECORDS
 1705: 
 1706: =over 4
 1707: 
 1708: =item *
 1709: 
 1710: detailed_citation_view(ORDERED METADATA LIST FOR A RESULT OBJECT INSTANCE) :
 1711: see metadata viewing notes below 
 1712: 
 1713: =item *
 1714: 
 1715: summary_view(ORDERED METADATA LIST FOR A RESULT OBJECT INSTANCE) :
 1716: see metadata viewing notes below 
 1717: 
 1718: =item *
 1719: 
 1720: fielded_format_view(ORDERED METADATA LIST FOR A RESULT OBJECT INSTANCE) :
 1721: see metadata viewing notes below 
 1722: 
 1723: =item *
 1724: 
 1725: xml_sgml_view(ORDERED METADATA LIST FOR A RESULT OBJECT INSTANCE) :
 1726: see metadata viewing notes below 
 1727: 
 1728: =back
 1729: 
 1730:   _____________________________________________________________________
 1731:  | * Metadata viewing notes                                            |
 1732:  | Output is a HTML-ified string.                                      |
 1733:  | Input arguments are title, author, subject, url, keywords, version, |
 1734:  | notes, short abstract, mime, language, creation date,               |
 1735:  | last revision date, owner, copyright, hostname, httphost, and       |
 1736:  | extra custom metadata to show.                                      |
 1737:   ---------------------------------------------------------------------
 1738: 
 1739: TEST CONDITIONAL FUNCTIONS
 1740: 
 1741: =over 4
 1742: 
 1743: =item *
 1744: 
 1745: filled(field) : determines whether a given field has been filled
 1746: 
 1747: =back
 1748: 
 1749: ERROR FUNCTIONS
 1750: 
 1751: =over 4
 1752: 
 1753: =item *
 1754: 
 1755: output_blank_field_error(server reference) : outputs a message saying that
 1756: more fields need to be filled in
 1757: 
 1758: =item *
 1759: 
 1760: output_date_error(server reference, error message) : outputs
 1761: an error message specific to bad date format.
 1762: 
 1763: =back
 1764: 
 1765: =cut

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