Annotation of loncom/interface/lonsearchcat.pm, revision 1.98

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

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