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

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.24      harris41  427:     $r->print(<<END);
1.22      harris41  428: Advanced searching is not yet implemented.
                    429: END
1.24      harris41  430:     return OK;
1.18      harris41  431: }
                    432: 
1.26      harris41  433: # ---------------------------------------------------- see if a field is filled
                    434: sub filled {
1.27    ! harris41  435:     return ($_=~/\S/);
1.26      harris41  436: }
                    437: 
1.6       harris41  438: # --------------------------------------------------- Performing a basic search
                    439: sub basicsearch {
1.19      harris41  440:     my ($r,$envhash)=@_;
                    441:     my %ENV=%{$envhash};
1.6       harris41  442: 
1.26      harris41  443:     unless (&filled($ENV{'form.basicexp'})) {
1.24      harris41  444: 	&output_blank_field_error($r);
                    445: 	return OK;
                    446:     }
1.22      harris41  447: 
1.19      harris41  448:     my $query=$ENV{'form.basicexp'};
                    449:     $query="select * from metadata where concat(title,\"    \",author) like '\%$ENV{'form.basicexp'}\%'";
1.13      harris41  450:     my $reply=&Apache::lonnet::metadata_query($query);
1.19      harris41  451:     &output_results($r,$envhash,$reply);
1.18      harris41  452:     return OK;
1.22      harris41  453: }
                    454: 
                    455: sub output_blank_field_error {
                    456:     my ($r)=@_;
                    457:     # make query information persistent to allow for subsequent revision
                    458:     my $persistent='';
                    459:     map {
                    460: 	if (/^form\./ && !/submit/) {
                    461: 	    my $name=$_;
                    462: 	    my $key=$name;
                    463: 	    $name=~s/^form\.//;
                    464: 	    $persistent.=<<END;
                    465: <INPUT TYPE='hidden' NAME='$name' VALUE='$ENV{$key}'>
                    466: END
                    467:         }
                    468:     } (keys %ENV);
                    469: 
                    470:     $r->print(<<BEGINNING);
                    471: <html>
                    472: <head>
                    473: <title>The LearningOnline Network with CAPA</title>
                    474: BEGINNING
                    475:     $r->print(<<RESULTS);
                    476: </head>
                    477: <body bgcolor="#ffffff">
                    478: <img align=right src=/adm/lonIcons/lonlogos.gif>
                    479: <h1>Search Catalog</h1>
                    480: <form method="post" action="/adm/searchcat">
                    481: $persistent
                    482: <input type='button' value='Revise search request'
                    483: onClick='this.form.submit();'>
                    484: <input type='button' value='CLOSE'
                    485: onClick='self.close();'>
                    486: <hr>
                    487: <h3>Helpful Message</h3>
                    488: <p>
                    489: Incorrect search query due to blank entry fields.
                    490: You need to fill in the relevant
                    491: fields on the search page in order for a query to be
                    492: processed.
                    493: </p>
                    494: </body>
                    495: </html>
                    496: RESULTS
1.18      harris41  497: }
1.6       harris41  498: 
1.18      harris41  499: # ----------------------------- format and output results based on a reply list
                    500: sub output_results {
1.19      harris41  501:     my ($r,$envhash,@replylist)=@_;
                    502:     my %ENV=%{$envhash};
1.18      harris41  503:     foreach my $reply (@replylist) {
                    504: 
                    505: 	my @results;
                    506: 
                    507: 	my $replyfile='';
                    508: 	$reply=~/^([\.\w]+)$/; # must do since 'use strict' checks for tainting
                    509: 	$replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1;
                    510: 	$reply=~/(.*?)\_/;
                    511: 	my $hostname=$1;
                    512: 
                    513: 	{
                    514: 	    while (1) {
                    515: 		last if -e $replyfile;
                    516: 		sleep 1;
                    517: 	    }
                    518: 	    # QUESTION: how should I handle this error condition..
                    519: 	    # I'm sure there is syntax elsewhere I can use..
                    520: 	    my $fh=Apache::File->new($replyfile) or
                    521: 		($r->print('file cannot be opened') and return OK);
                    522: 	    @results=<$fh>;
1.6       harris41  523: 	}
                    524: 
1.18      harris41  525: 	my $compiledresult='';
1.6       harris41  526: 
1.18      harris41  527: 	foreach my $result (@results) {
                    528: 	    my ($title,$author,$subject,$url,$keywords,$version,
                    529: 		$notes,$abstract,$mime,$lang,
                    530: 		$creationdate,$lastrevisiondate,$owner,$copyright
                    531: 		)=map {&Apache::lonnet::unescape($_)} (split(/\,/,$result));
                    532: 	    my $shortabstract=$abstract;
                    533: 	    $shortabstract=substr($abstract,0,200) if length($abstract)>200;
                    534: 	    $compiledresult.=<<END;
1.6       harris41  535: <p>
1.8       harris41  536: END
1.18      harris41  537:             $compiledresult.=<<END if $ENV{'form.catalogmode'} eq 'interactive';
1.8       harris41  538: <font size='-1'><INPUT TYPE="button" NAME="returnvalues" VALUE="SELECT"
1.10      harris41  539: onClick="javascript:select_data('$title','$url')">
1.8       harris41  540: </font>
                    541: <br>
                    542: END
1.18      harris41  543:             $compiledresult.=<<END;
1.21      harris41  544: <b>URL: </b> <A HREF="http://$ENV{'HTTP_HOST'}$url" TARGET='search_preview'>$url</A>
1.17      harris41  545: <br>
1.6       harris41  546: <b>Title:</b> $title<br>
                    547: <b>Author(s):</b> $author<br>
                    548: <b>Subject:</b> $subject<br>
1.9       harris41  549: <b>Keyword(s):</b> $keywords<br>
1.6       harris41  550: <b>Notes:</b> $notes<br>
                    551: <b>Abstract:</b> $shortabstract<br>
                    552: <b>MIME Type:</b> $mimetag{$mime}<br>
                    553: <b>Language:</b> $language{$lang}<br>
                    554: <b>Creation Date:</b> $creationdate<br>
                    555: <b>Last Revision Date:</b> $lastrevisiondate<br>
                    556: <b>Publisher/Owner:</b> $owner<br>
                    557: <b>Copyright/Distribution:</b> $copyright<br>
                    558: <b>Repository Location:</b> $hostname
                    559: </p>
                    560: END
1.18      harris41  561:         }
1.6       harris41  562: 
1.18      harris41  563: 	unless ($compiledresult) {
                    564: 	    $compiledresult="There were no results that matched your query";
                    565: 	}
1.6       harris41  566: 
1.18      harris41  567: 	# make query information persistent to allow for subsequent revision
                    568: 	my $persistent='';
                    569: 	map {
                    570: 	    if (/^form\./ && !/submit/) {
                    571: 		my $name=$_;
                    572: 		my $key=$name;
                    573: 		$name=~s/^form\.//;
                    574: 		$persistent.=<<END;
1.9       harris41  575: <INPUT TYPE='hidden' NAME='$name' VALUE='$ENV{$key}'>
                    576: END
1.18      harris41  577:             }
                    578: 	} (keys %ENV);
1.9       harris41  579: 
1.18      harris41  580: 	$r->print(<<BEGINNING);
1.6       harris41  581: <html>
                    582: <head>
                    583: <title>The LearningOnline Network with CAPA</title>
1.8       harris41  584: BEGINNING
1.18      harris41  585:         $r->print(<<SCRIPT) if $ENV{'form.catalogmode'} eq 'interactive';
1.8       harris41  586: <script>
                    587:     function select_data(title,url) {
                    588: 	changeTitle(title);
                    589: 	changeURL(url);
                    590:     }
                    591:     function changeTitle(val) {
                    592: 	if (opener.inf.document.forms.resinfo.elements.t) {
                    593: 	    opener.inf.document.forms.resinfo.elements.t.value=val;
                    594: 	}
                    595:     }
                    596:     function changeURL(val) {
                    597: 	if (opener.inf.document.forms.resinfo.elements.u) {
                    598: 	    opener.inf.document.forms.resinfo.elements.u.value=val;
                    599: 	}
                    600:     }
                    601: </script>
                    602: SCRIPT
1.18      harris41  603:         $r->print(<<RESULTS);
1.6       harris41  604: </head>
                    605: <body bgcolor="#ffffff">
                    606: <img align=right src=/adm/lonIcons/lonlogos.gif>
                    607: <h1>Search Catalog</h1>
                    608: <form method="post" action="/adm/searchcat">
1.9       harris41  609: <input type='button' value='Revise search request'
                    610: onClick='this.form.submit();'>
1.11      harris41  611: <input type='button' value='CLOSE'
                    612: onClick='self.close();'>
1.9       harris41  613: $persistent
1.6       harris41  614: <hr>
                    615: <h3>Search Query</h3>
                    616: <p>
1.19      harris41  617: <b>Basic search:</b> $ENV{'form.basicexp'}
1.6       harris41  618: </p>
                    619: <h3>Search Results</h3>
                    620: $compiledresult
                    621: </body>
                    622: </html>
                    623: RESULTS
1.18      harris41  624:     }
1.3       harris41  625: }
1.1       www       626: 
                    627: 1;
                    628: __END__

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