File:  [LON-CAPA] / loncom / interface / lonsearchcat.pm
Revision 1.42: download - view: text, annotated - select for diffs
Tue Mar 20 11:45:21 2001 UTC (23 years, 2 months ago) by harris41
Branches: MAIN
CVS tags: HEAD
filled in missing portions of the beginning glossary.  beginning to
implement mode-based output of results (basic or advanced) -Scott

    1: # The LearningOnline Network
    2: # Search Catalog
    3: #
    4: # 03/08/2001 Scott Harrison
    5: # Scott Harrison: 03/12/2001, 03/13/2001, 03/14/2001, 03/15/2001, 03/19/2001
    6: # Scott Harrison: 03/20/2001
    7: #
    8: # Functions
    9: #
   10: # handler(server reference) : interacts with the Apache server layer
   11: #                             (for /adm/searchcat URLs)
   12: # simpletextfield(name,value) : returns HTML formatted string for simple text
   13: #                               field
   14: # simplecheckbox(name,value) : returns HTML formatted string for simple
   15: #                              checkbox
   16: # searchphrasefield(title,name,value) : returns HTML formatted string for
   17: #                                       a search expression phrase field
   18: # dateboxes(name, defaultmonth, defaultday, defaultyear) : returns HTML
   19: #                                                          formatted string
   20: #                                                          for a calendar date
   21: # selectbox(title,name,value,%HASH=options) : returns HTML formatted string for
   22: #                                             a selection box field
   23: # advancedsearch(server reference, environment reference) : perform a complex
   24: #                                  multi-field logical query
   25: # filled(field) : determines whether a given field has been filled
   26: # basicsearch(server reference, environment reference) : perform a simple
   27: #                               single-field logical query
   28: # output_blank_field_error(server reference) : outputs a message saying that
   29: #                                              more fields need to be filled in
   30: # output_results(output mode,
   31: #                server reference, 
   32: #                environment reference,
   33: #                reply list reference) : outputs results from search
   34: # build_SQL_query() : builds a SQL query string from a logical expression
   35: #                     with AND/OR keywords
   36: 
   37: package Apache::lonsearchcat;
   38: 
   39: use strict;
   40: use Apache::Constants qw(:common);
   41: use Apache::lonnet();
   42: use Apache::File();
   43: use CGI qw(:standard);
   44: use Text::Query;
   45: 
   46: my %language;
   47: my $scrout;
   48: my %metadatafields;
   49: my %cprtag;
   50: my %mimetag;
   51: 
   52: sub handler {
   53:     my $r = shift;
   54: 
   55: # -------------------------------------- see if called from an interactive mode
   56:     map {
   57:        my ($name, $value) = split(/=/,$_);
   58:        $value =~ tr/+/ /;
   59:        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
   60:        if ($name eq 'catalogmode') {
   61: 	   $ENV{'form.'.$name}=$value;
   62:        }
   63:     } (split(/&/,$ENV{'QUERY_STRING'}));
   64: 
   65:     $r->content_type('text/html');
   66:     $r->send_http_header;
   67:     return OK if $r->header_only;
   68: 
   69:     %metadatafields=();
   70: 
   71:     my $hidden='';
   72:     $hidden=<<END if $ENV{'form.catalogmode'} eq 'interactive';
   73: <input type='hidden' name='catalogmode' value='interactive'>
   74: END
   75: 
   76: # ------------------------------------------------ First, check out environment
   77:     $metadatafields{'owner'}=$ENV{'user.name'}.'@'.$ENV{'user.domain'};
   78: 
   79: # --------------------------------- Compute various listings of metadata values
   80:     
   81:     %language=();
   82:     $language{'any'}='Any language';
   83:     {
   84: 	my $fh=Apache::File->new($r->dir_config('lonTabDir').'/language.tab');
   85: 	map {
   86: 	    $_=~/(\w+)\s+([\w\s\-]+)/;
   87: 	    $language{$1}=$2;
   88: 	} <$fh>;
   89:     }
   90: 
   91:     %cprtag=();
   92:     $cprtag{'any'}='Any copyright/distribution';
   93:     {
   94: 	my $fh=Apache::File->new($r->dir_config('lonIncludes').'/copyright.tab');
   95: 	map {
   96: 	    $_=~/(\w+)\s+([\w\s\-]+)/;
   97: 	    $cprtag{$1}=$2;
   98: 	} <$fh>;
   99:     }
  100: 
  101:     %mimetag=();
  102:     $mimetag{'any'}='Any type';
  103:     {
  104: 	my $fh=Apache::File->new($r->dir_config('lonTabDir').'/filetypes.tab');
  105: 	map {
  106: 	    $_=~/(\w+)\s+(\w+)\s+([\w\s\-]+)/;
  107: 	    $mimetag{$1}=".$1 $3";
  108: 	} <$fh>;
  109:     }
  110: 
  111:     if ($ENV{'form.basicsubmit'} eq 'SEARCH') {
  112: 	return &basicsearch($r,\%ENV);
  113:     }
  114:     elsif ($ENV{'form.advancedsubmit'} eq 'SEARCH') {
  115: 	return &advancedsearch($r,\%ENV);
  116:     }
  117: 
  118:     $scrout=''; # building a part of screen output
  119:     $scrout.=&searchphrasefield('Limit by title','title',
  120: 			$ENV{'form.title'});
  121: 
  122:     $scrout.=&searchphrasefield('Limit by author','author',
  123: 			$ENV{'form.author'});
  124: 
  125:     $scrout.=&searchphrasefield('Limit by subject','subject',
  126: 			$ENV{'form.subject'});
  127: 
  128:     $scrout.=&searchphrasefield('Limit by keywords','keywords',
  129: 			$ENV{'form.keywords'});
  130: 
  131:     $scrout.=&searchphrasefield('Limit by URL','url',
  132: 			$ENV{'form.url'});
  133: 
  134:     $scrout.=&searchphrasefield('Limit by version','version',
  135: 			$ENV{'form.version'});
  136: 
  137:     $scrout.=&searchphrasefield('Limit by notes','notes',
  138: 			$ENV{'form.notes'});
  139: 
  140:     $scrout.=&searchphrasefield('Limit by abstract','abstract',
  141: 			$ENV{'form.abstract'});
  142: 
  143:     $ENV{'form.mime'}='notxxx' unless length($ENV{'form.mime'});
  144:     $scrout.=&selectbox('Limit by MIME type','mime',
  145: 			$ENV{'form.mime'},%mimetag);
  146: 
  147:     $ENV{'form.language'}='any' unless length($ENV{'form.language'});
  148: 
  149:     $scrout.=&selectbox('Limit by language','language',
  150: 			$ENV{'form.language'},%language);
  151:     
  152: 
  153: # ------------------------------------------------ Compute date selection boxes
  154:     $scrout.=<<CREATIONDATESTART;
  155: <p>
  156: <font color="#800000" face="helvetica"><b>LIMIT BY CREATION DATE RANGE:</b>
  157: </font>
  158: <br>
  159: between:
  160: CREATIONDATESTART
  161:     $scrout.=&dateboxes('creationdatestart',1,1,1976,
  162: 			$ENV{'form.creationdatestart_month'},
  163: 			$ENV{'form.creationdatestart_day'},
  164: 			$ENV{'form.creationdatestart_year'},
  165: 			);
  166:     $scrout.=<<CREATIONDATEEND;
  167: and:
  168: CREATIONDATEEND
  169:     $scrout.=&dateboxes('creationdateend',12,31,2051,
  170: 			$ENV{'form.creationdateend_month'},
  171: 			$ENV{'form.creationdateend_day'},
  172: 			$ENV{'form.creationdateend_year'},
  173: 			);
  174:     $scrout.="</p>";
  175: 
  176:     $scrout.=<<LASTREVISIONDATESTART;
  177: <p>
  178: <font color="#800000" face="helvetica"><b>LIMIT BY LAST REVISION DATE RANGE:
  179: </b></font>
  180: <br>between:
  181: LASTREVISIONDATESTART
  182:     $scrout.=&dateboxes('lastrevisiondatestart',1,1,1976,
  183: 			$ENV{'form.lastrevisiondatestart_month'},
  184: 			$ENV{'form.lastrevisiondatestart_day'},
  185: 			$ENV{'form.lastrevisiondatestart_year'},
  186: 			);
  187:     $scrout.=<<LASTREVISIONDATEEND;
  188: and:
  189: LASTREVISIONDATEEND
  190:     $scrout.=&dateboxes('lastrevisiondateend',12,31,2051,
  191: 			$ENV{'form.lastrevisiondateend_month'},
  192: 			$ENV{'form.lastrevisiondateend_day'},
  193: 			$ENV{'form.lastrevisiondateend_year'},
  194: 			);
  195:     $scrout.='</p>';
  196: 
  197:     $scrout.=&searchphrasefield('Limit by publisher/owner','owner',
  198: 				$ENV{'form.owner'});
  199: #			$metadatafields{'owner'});
  200: 
  201:     $ENV{'form.copyright'}='any' unless length($ENV{'form.copyright'});
  202:     $scrout.=&selectbox('Limit by copyright/distribution','copyright',
  203: 			$ENV{'form.copyright'},%cprtag);
  204: 
  205: # ------------------------------------------- Compute customized metadata field
  206:     $scrout.=<<CUSTOMMETADATA;
  207: <p>
  208: <font color="#800000" face="helvetica"><b>LIMIT BY OTHER METADATA FIELDS:</b>
  209: </font>
  210: For author-specific metadata, enter in an expression in the form of 
  211: <i>key</i>=<i>value</i> separated by operators such as AND or OR.<br>
  212: <b>Example:</b> grandmother=75 OR grandfather=85
  213: <br>
  214: CUSTOMMETADATA
  215: $scrout.=&simpletextfield('custommetadata',$ENV{'form.custommetadata'});
  216: $scrout.=' <i>initial users of this system do not need to worry about this option</i>';
  217: 
  218: # ---------------------------------------------------------------- Print screen
  219:     $r->print(<<ENDDOCUMENT);
  220: <html>
  221: <head>
  222: <title>The LearningOnline Network with CAPA</title>
  223: </head>
  224: <body bgcolor="#FFFFFF">
  225: <img align=right src=/adm/lonIcons/lonlogos.gif>
  226: <h1>Search Catalog</h1>
  227: <form method="post" action="/adm/searchcat">
  228: $hidden
  229: <hr>
  230: <h3>Basic Search</h3>
  231: <p>
  232: Enter terms or phrases separated by search operators
  233: such as AND or OR then press SEARCH below.  Terms should be specific
  234: to the title, author, subject, notes, or abstract information associated
  235: with a resource.
  236: <br>
  237: ENDDOCUMENT
  238:     $r->print(&simpletextfield('basicexp',$ENV{'form.basicexp'}));
  239:     $r->print(' ');
  240:     $r->print(&simplecheckbox('titleonly',$ENV{'form.titleonly'}));
  241:     $r->print('<font color="#800000">Title only</font> ');
  242:     $r->print(&simplecheckbox('allversions',$ENV{'form.allversions'}));
  243:     $r->print(<<ENDDOCUMENT);
  244: <font color="#800000">Search historic archives</font>
  245: <br>
  246: <input type="submit" name="basicsubmit" value="SEARCH">
  247: <input type="reset" name="reset" value="RESET">
  248: <input type="button" name="close" value="CLOSE" onClick="self.close()">
  249: </p>
  250: <hr>
  251: <h3>Advanced Search</h3>
  252: $scrout
  253: <p>
  254: <input type="submit" name="advancedsubmit" value="SEARCH">
  255: <input type="reset" name="reset" value="RESET">
  256: <input type="button" name="close" value="CLOSE" onClick="self.close()">
  257: </p>
  258: </form>
  259: </body>
  260: </html>
  261: ENDDOCUMENT
  262:     return OK;
  263: } 
  264: 
  265: # --------------------------------------------------------- Various form fields
  266: 
  267: sub simpletextfield {
  268:     my ($name,$value)=@_;
  269:     return '<input type=text name="'.$name.'" size=20 value="'.$value.'">';
  270: }
  271: 
  272: sub simplecheckbox {
  273:     my ($name,$value)=@_;
  274:     my $checked='';
  275:     $checked="CHECKED" if $value eq 'on';
  276:     return '<input type=checkbox name="'.$name.'" '. $checked . '>';
  277: }
  278: 
  279: sub searchphrasefield {
  280:     my ($title,$name,$value)=@_;
  281:     my $instruction=<<END;
  282: Enter terms or phrases separated by search operators such
  283: as AND or OR.
  284: END
  285:     my $uctitle=uc($title);
  286:     return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:</b>".
  287: 	   "</FONT> $instruction<br>".
  288:            '<input type=text name="'.$name.'" size=80 value="'.$value.'">';
  289: }
  290: 
  291: sub dateboxes {
  292:     my ($name,$defaultmonth,$defaultday,$defaultyear,
  293: 	$currentmonth,$currentday,$currentyear)=@_;
  294:     ($defaultmonth,$defaultday,$defaultyear)=('','','');
  295:     my $month=<<END;
  296: <select name="${name}_month">
  297: <option value='$defaultmonth'> </option>
  298: <option value="1">January</option>
  299: <option value="2">February</option>
  300: <option value="3">March</option>
  301: <option value="4">April</option>
  302: <option value="5">May</option>
  303: <option value="6">June</option>
  304: <option value="7">July</option>
  305: <option value="8">August</option>
  306: <option value="9">September</option>
  307: <option value="10">October</option>
  308: <option value="11">November</option>
  309: <option value="12">December</option>
  310: </select>
  311: END
  312:     $month=~s/(\"$currentmonth\")/$1 SELECTED/ if length($currentmonth);
  313:     my $day=<<END;
  314: <select name="${name}_day">
  315: <option value='$defaultday'> </option>
  316: <option value="1">1</option>
  317: <option value="2">2</option>
  318: <option value="3">3</option>
  319: <option value="4">4</option>
  320: <option value="5">5</option>
  321: <option value="6">6</option>
  322: <option value="7">7</option>
  323: <option value="8">8</option>
  324: <option value="9">9</option>
  325: <option value="10">10</option>
  326: <option value="11">11</option>
  327: <option value="12">12</option>
  328: <option value="13">13</option>
  329: <option value="14">14</option>
  330: <option value="15">15</option>
  331: <option value="16">16</option>
  332: <option value="17">17</option>
  333: <option value="18">18</option>
  334: <option value="19">19</option>
  335: <option value="20">20</option>
  336: <option value="21">21</option>
  337: <option value="22">22</option>
  338: <option value="23">23</option>
  339: <option value="24">24</option>
  340: <option value="25">25</option>
  341: <option value="26">26</option>
  342: <option value="27">27</option>
  343: <option value="28">28</option>
  344: <option value="29">29</option>
  345: <option value="30">30</option>
  346: <option value="31">31</option>
  347: </select>
  348: END
  349:     $day=~s/(\"$currentday\")/$1 SELECTED/ if length($currentday);
  350:     my $year=<<END;
  351: <select name="${name}_year">
  352: <option value='$defaultyear'> </option>
  353: <option value="1976">1976</option>
  354: <option value="1977">1977</option>
  355: <option value="1978">1978</option>
  356: <option value="1979">1979</option>
  357: <option value="1980">1980</option>
  358: <option value="1981">1981</option>
  359: <option value="1982">1982</option>
  360: <option value="1983">1983</option>
  361: <option value="1984">1984</option>
  362: <option value="1985">1985</option>
  363: <option value="1986">1986</option>
  364: <option value="1987">1987</option>
  365: <option value="1988">1988</option>
  366: <option value="1989">1989</option>
  367: <option value="1990">1990</option>
  368: <option value="1991">1991</option>
  369: <option value="1992">1992</option>
  370: <option value="1993">1993</option>
  371: <option value="1994">1994</option>
  372: <option value="1995">1995</option>
  373: <option value="1996">1996</option>
  374: <option value="1997">1997</option>
  375: <option value="1998">1998</option>
  376: <option value="1999">1999</option>
  377: <option value="2000">2000</option>
  378: <option value="2001">2001</option>
  379: <option value="2002">2002</option>
  380: <option value="2003">2003</option>
  381: <option value="2004">2004</option>
  382: <option value="2005">2005</option>
  383: <option value="2006">2006</option>
  384: <option value="2007">2007</option>
  385: <option value="2008">2008</option>
  386: <option value="2009">2009</option>
  387: <option value="2010">2010</option>
  388: <option value="2011">2011</option>
  389: <option value="2012">2012</option>
  390: <option value="2013">2013</option>
  391: <option value="2014">2014</option>
  392: <option value="2015">2015</option>
  393: <option value="2016">2016</option>
  394: <option value="2017">2017</option>
  395: <option value="2018">2018</option>
  396: <option value="2019">2019</option>
  397: <option value="2020">2020</option>
  398: <option value="2021">2021</option>
  399: <option value="2022">2022</option>
  400: <option value="2023">2023</option>
  401: <option value="2024">2024</option>
  402: <option value="2025">2025</option>
  403: <option value="2026">2026</option>
  404: <option value="2027">2027</option>
  405: <option value="2028">2028</option>
  406: <option value="2029">2029</option>
  407: <option value="2030">2030</option>
  408: <option value="2031">2031</option>
  409: <option value="2032">2032</option>
  410: <option value="2033">2033</option>
  411: <option value="2034">2034</option>
  412: <option value="2035">2035</option>
  413: <option value="2036">2036</option>
  414: <option value="2037">2037</option>
  415: <option value="2038">2038</option>
  416: <option value="2039">2039</option>
  417: <option value="2040">2040</option>
  418: <option value="2041">2041</option>
  419: <option value="2042">2042</option>
  420: <option value="2043">2043</option>
  421: <option value="2044">2044</option>
  422: <option value="2045">2045</option>
  423: <option value="2046">2046</option>
  424: <option value="2047">2047</option>
  425: <option value="2048">2048</option>
  426: <option value="2049">2049</option>
  427: <option value="2050">2050</option>
  428: <option value="2051">2051</option>
  429: </select>
  430: END
  431:     $year=~s/(\"$currentyear\")/$1 SELECTED/ if length($currentyear);
  432:     return "$month$day$year";
  433: }
  434: 
  435: sub selectbox {
  436:     my ($title,$name,$value,%options)=@_;
  437:     my $uctitle=uc($title);
  438:     my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".
  439: 	"</b></font><br>".'<select name="'.$name.'">';
  440:     map {
  441:         $selout.='<option value="'.$_.'"';
  442:         if ($_ eq $value) { $selout.=' selected'; }
  443:         $selout.='>'.$options{$_}.'</option>';
  444:     } sort keys %options;
  445:     return $selout.'</select>';
  446: }
  447: 
  448: # ------------------------------------------------ Performing a advanced search
  449: sub advancedsearch {
  450:     my ($r,$envhash)=@_;
  451:     my %ENV=%{$envhash};
  452: 
  453:     my $fillflag=0;
  454:     for my $field ('title','author','subject','keywords','url','version',
  455: 		   'notes','abstract','mime','language','owner',
  456: 		   'custommetadata') {
  457: 	if (&filled($ENV{"form.$field"})) {
  458: 	    $fillflag++;
  459: 	}
  460:     }
  461: 
  462:     unless ($fillflag) {
  463: 	&output_blank_field_error($r);
  464: 	return OK;
  465:     }
  466: 
  467:     my $query='';
  468: #    my $concatarg=join(',"    ",',
  469: #		       ('title', 'author', 'subject', 'notes', 'abstract'));
  470: 
  471:     $query="select * from metadata where concat(title) like '\%$ENV{'form.title'}\%'";
  472:     my $reply=&Apache::lonnet::metadata_query($query);
  473: 
  474:     &output_results($r,$envhash,$reply);
  475:     return OK;
  476: }
  477: 
  478: # ---------------------------------------------------- see if a field is filled
  479: sub filled {
  480:     my ($field)=@_;
  481:     if ($field=~/\S/) {
  482: 	return 1;
  483:     }
  484:     else {
  485: 	return 0;
  486:     }
  487: }
  488: 
  489: # --------------------------------------------------- Performing a basic search
  490: sub basicsearch {
  491:     my ($r,$envhash)=@_;
  492:     my %ENV=%{$envhash};
  493: 
  494:     unless (&filled($ENV{'form.basicexp'})) {
  495: 	&output_blank_field_error($r);
  496: 	return OK;
  497:     }
  498: 
  499:     my $query='';
  500:     my $concatarg=join(',"    ",',
  501: 		       ('title', 'author', 'subject', 'notes', 'abstract'));
  502: 
  503:     $query="select * from metadata where concat($concatarg) like '\%$ENV{'form.basicexp'}\%'";
  504:     my $reply=&Apache::lonnet::metadata_query($query);
  505:     &output_results($r,$envhash,$reply);
  506:     return OK;
  507: }
  508: 
  509: sub output_blank_field_error {
  510:     my ($r)=@_;
  511:     # make query information persistent to allow for subsequent revision
  512:     my $persistent='';
  513:     map {
  514: 	if (/^form\./ && !/submit/) {
  515: 	    my $name=$_;
  516: 	    my $key=$name;
  517: 	    $name=~s/^form\.//;
  518: 	    $persistent.=<<END;
  519: <INPUT TYPE='hidden' NAME='$name' VALUE='$ENV{$key}'>
  520: END
  521:         }
  522:     } (keys %ENV);
  523: 
  524:     $r->print(<<BEGINNING);
  525: <html>
  526: <head>
  527: <title>The LearningOnline Network with CAPA</title>
  528: BEGINNING
  529:     $r->print(<<RESULTS);
  530: </head>
  531: <body bgcolor="#ffffff">
  532: <img align=right src=/adm/lonIcons/lonlogos.gif>
  533: <h1>Search Catalog</h1>
  534: <form method="post" action="/adm/searchcat">
  535: $persistent
  536: <input type='button' value='Revise search request'
  537: onClick='this.form.submit();'>
  538: <input type='button' value='CLOSE'
  539: onClick='self.close();'>
  540: <hr>
  541: <h3>Helpful Message</h3>
  542: <p>
  543: Incorrect search query due to blank entry fields.
  544: You need to fill in the relevant
  545: fields on the search page in order for a query to be
  546: processed.
  547: </p>
  548: </body>
  549: </html>
  550: RESULTS
  551: }
  552: 
  553: # ----------------------------- format and output results based on a reply list
  554: sub output_results {
  555:     my ($r,$envhash,@replylist)=@_;
  556:     my %ENV=%{$envhash};
  557:     foreach my $reply (@replylist) {
  558: 
  559: 	my @results;
  560: 
  561: 	my $replyfile='';
  562: 	$reply=~/^([\.\w]+)$/; # must do since 'use strict' checks for tainting
  563: 	$replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1;
  564: 	$reply=~/(.*?)\_/;
  565: 	my $hostname=$1;
  566: 
  567: 	{
  568: 	    while (1) {
  569: 		last if -e $replyfile;
  570: 		sleep 1;
  571: 	    }
  572: 	    # QUESTION: how should I handle this error condition..
  573: 	    # I'm sure there is syntax elsewhere I can use..
  574: 	    my $fh=Apache::File->new($replyfile) or
  575: 		($r->print('file cannot be opened') and return OK);
  576: 	    @results=<$fh>;
  577: 	}
  578: 
  579: 	my $compiledresult='';
  580: 
  581: 	foreach my $result (@results) {
  582: 	    my ($title,$author,$subject,$url,$keywords,$version,
  583: 		$notes,$abstract,$mime,$lang,
  584: 		$creationdate,$lastrevisiondate,$owner,$copyright
  585: 		)=map {&Apache::lonnet::unescape($_)} (split(/\,/,$result));
  586: 	    my $shortabstract=$abstract;
  587: 	    $shortabstract=substr($abstract,0,200) if length($abstract)>200;
  588: 	    $compiledresult.=<<END;
  589: <p>
  590: END
  591:             $compiledresult.=<<END if $ENV{'form.catalogmode'} eq 'interactive';
  592: <font size='-1'><INPUT TYPE="button" NAME="returnvalues" VALUE="SELECT"
  593: onClick="javascript:select_data('$title','$url')">
  594: </font>
  595: <br>
  596: END
  597:             $compiledresult.=<<END;
  598: <b>URL: </b> <A HREF="http://$ENV{'HTTP_HOST'}$url" TARGET='search_preview'>$url</A>
  599: <br>
  600: <b>Title:</b> $title<br>
  601: <b>Author(s):</b> $author<br>
  602: <b>Subject:</b> $subject<br>
  603: <b>Keyword(s):</b> $keywords<br>
  604: <b>Notes:</b> $notes<br>
  605: <b>Abstract:</b> $shortabstract<br>
  606: <b>MIME Type:</b> $mimetag{$mime}<br>
  607: <b>Language:</b> $language{$lang}<br>
  608: <b>Creation Date:</b> $creationdate<br>
  609: <b>Last Revision Date:</b> $lastrevisiondate<br>
  610: <b>Publisher/Owner:</b> $owner<br>
  611: <b>Copyright/Distribution:</b> $copyright<br>
  612: <b>Repository Location:</b> $hostname
  613: </p>
  614: END
  615:         }
  616: 
  617: 	unless ($compiledresult) {
  618: 	    $compiledresult="There were no results that matched your query";
  619: 	}
  620: 
  621: 	# make query information persistent to allow for subsequent revision
  622: 	my $persistent='';
  623: 	map {
  624: 	    if (/^form\./ && !/submit/) {
  625: 		my $name=$_;
  626: 		my $key=$name;
  627: 		$name=~s/^form\.//;
  628: 		$persistent.=<<END;
  629: <INPUT TYPE='hidden' NAME='$name' VALUE='$ENV{$key}'>
  630: END
  631:             }
  632: 	} (keys %ENV);
  633: 
  634: 	$r->print(<<BEGINNING);
  635: <html>
  636: <head>
  637: <title>The LearningOnline Network with CAPA</title>
  638: BEGINNING
  639:         $r->print(<<SCRIPT) if $ENV{'form.catalogmode'} eq 'interactive';
  640: <script>
  641:     function select_data(title,url) {
  642: 	changeTitle(title);
  643: 	changeURL(url);
  644:     }
  645:     function changeTitle(val) {
  646: 	if (opener.inf.document.forms.resinfo.elements.t) {
  647: 	    opener.inf.document.forms.resinfo.elements.t.value=val;
  648: 	}
  649:     }
  650:     function changeURL(val) {
  651: 	if (opener.inf.document.forms.resinfo.elements.u) {
  652: 	    opener.inf.document.forms.resinfo.elements.u.value=val;
  653: 	}
  654:     }
  655: </script>
  656: SCRIPT
  657:         $r->print(<<RESULTS);
  658: </head>
  659: <body bgcolor="#ffffff">
  660: <img align=right src=/adm/lonIcons/lonlogos.gif>
  661: <h1>Search Catalog</h1>
  662: <form method="post" action="/adm/searchcat">
  663: <input type='button' value='Revise search request'
  664: onClick='this.form.submit();'>
  665: <input type='button' value='CLOSE'
  666: onClick='self.close();'>
  667: $persistent
  668: <hr>
  669: <h3>Search Query</h3>
  670: <p>
  671: <b>Basic search:</b> $ENV{'form.basicexp'}
  672: </p>
  673: <h3>Search Results</h3>
  674: $compiledresult
  675: </body>
  676: </html>
  677: RESULTS
  678:     }
  679: }
  680: 
  681: # ------------------------------------------------------------- build_SQL_query
  682: sub build_SQL_query {
  683: 
  684: }
  685: 
  686: 1;
  687: __END__

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