Diff for /loncom/interface/lonsearchcat.pm between versions 1.21 and 1.39

version 1.21, 2001/03/15 18:52:17 version 1.39, 2001/03/15 21:42:05
Line 424  sub advancedsearch { Line 424  sub advancedsearch {
     my ($r,$envhash)=@_;      my ($r,$envhash)=@_;
     my %ENV=%{$envhash};      my %ENV=%{$envhash};
   
       my $fillflag=0;
       for my $field ('title','author','subject','keywords','url','version',
      'notes','abstract','mime','language','owner',
      'custommetadata') {
    if (&filled($ENV{'form.basicexp'})) {
       $fillflag++;
    }
       }
   
       unless ($fillflag) {
    &output_blank_field_error($r);
    return OK;
       }
   
       my $query='';
   #    my $concatarg=join(',"    ",',
   #       ('title', 'author', 'subject', 'notes', 'abstract'));
   
       $query="select * from metadata where concat(title) like '\%$ENV{'form.title'}\%'";
       my $reply=&Apache::lonnet::metadata_query($query);
   
       &output_results($r,$envhash,$reply);
       return OK;
   }
   
   # ---------------------------------------------------- see if a field is filled
   sub filled {
       my ($field)=@_;
       if ($field=~/\S/) {
    return 1;
       }
       else {
    return 0;
       }
 }  }
   
 # --------------------------------------------------- Performing a basic search  # --------------------------------------------------- Performing a basic search
Line 431  sub basicsearch { Line 465  sub basicsearch {
     my ($r,$envhash)=@_;      my ($r,$envhash)=@_;
     my %ENV=%{$envhash};      my %ENV=%{$envhash};
   
     my $query=$ENV{'form.basicexp'};      unless (&filled($ENV{'form.basicexp'})) {
     $query="select * from metadata where concat(title,\"    \",author) like '\%$ENV{'form.basicexp'}\%'";   &output_blank_field_error($r);
    return OK;
       }
   
       my $query='';
       my $concatarg=join(',"    ",',
          ('title', 'author', 'subject', 'notes', 'abstract'));
   
       $query="select * from metadata where concat($concatarg) like '\%$ENV{'form.basicexp'}\%'";
     my $reply=&Apache::lonnet::metadata_query($query);      my $reply=&Apache::lonnet::metadata_query($query);
     &output_results($r,$envhash,$reply);      &output_results($r,$envhash,$reply);
     return OK;      return OK;
 }  }
   
   sub output_blank_field_error {
       my ($r)=@_;
       # make query information persistent to allow for subsequent revision
       my $persistent='';
       map {
    if (/^form\./ && !/submit/) {
       my $name=$_;
       my $key=$name;
       $name=~s/^form\.//;
       $persistent.=<<END;
   <INPUT TYPE='hidden' NAME='$name' VALUE='$ENV{$key}'>
   END
           }
       } (keys %ENV);
   
       $r->print(<<BEGINNING);
   <html>
   <head>
   <title>The LearningOnline Network with CAPA</title>
   BEGINNING
       $r->print(<<RESULTS);
   </head>
   <body bgcolor="#ffffff">
   <img align=right src=/adm/lonIcons/lonlogos.gif>
   <h1>Search Catalog</h1>
   <form method="post" action="/adm/searchcat">
   $persistent
   <input type='button' value='Revise search request'
   onClick='this.form.submit();'>
   <input type='button' value='CLOSE'
   onClick='self.close();'>
   <hr>
   <h3>Helpful Message</h3>
   <p>
   Incorrect search query due to blank entry fields.
   You need to fill in the relevant
   fields on the search page in order for a query to be
   processed.
   </p>
   </body>
   </html>
   RESULTS
   }
   
 # ----------------------------- format and output results based on a reply list  # ----------------------------- format and output results based on a reply list
 sub output_results {  sub output_results {
     my ($r,$envhash,@replylist)=@_;      my ($r,$envhash,@replylist)=@_;

Removed from v.1.21  
changed lines
  Added in v.1.39


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