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

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

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