Diff for /loncom/interface/lonsearchcat.pm between versions 1.17 and 1.18

version 1.17, 2001/03/15 18:23:54 version 1.18, 2001/03/15 18:43:30
Line 79  END Line 79  END
     if ($ENV{'form.basicsubmit'} eq 'SEARCH') {      if ($ENV{'form.basicsubmit'} eq 'SEARCH') {
  return &basicsearch($r,$ENV{'form.basicexp'});   return &basicsearch($r,$ENV{'form.basicexp'});
     }      }
       elsif ($ENV{'form.advancedsubmit'} eq 'SEARCH') {
    return &advancedsearch($r,\%ENV);
       }
   
     $scrout=''; # building a part of screen output      $scrout=''; # building a part of screen output
     $scrout.=&searchphrasefield('Limit by title','title',      $scrout.=&searchphrasefield('Limit by title','title',
Line 416  sub selectbox { Line 419  sub selectbox {
     return $selout.'</select>';      return $selout.'</select>';
 }  }
   
   # ------------------------------------------------ Performing a advanced search
   sub advancedsearch {
       my ($r,$envhash)=@_;
       my %ENV=%{$envhash};
   
   }
   
 # --------------------------------------------------- Performing a basic search  # --------------------------------------------------- Performing a basic search
 sub basicsearch {  sub basicsearch {
     my ($r,$expression)=@_;      my ($r,$expression)=@_;
   
     my $query=$expression;      my $query=$expression;
     $query="select * from metadata where concat(title,\"    \",author) like '\%$expression\%'";      $query="select * from metadata where concat(title,\"    \",author) like '\%$expression\%'";
 #    my $reply=&Apache::lonnet::reply("querysend:$query",'msul3');  
     my $reply=&Apache::lonnet::metadata_query($query);      my $reply=&Apache::lonnet::metadata_query($query);
       &output_results($reply);
       return OK;
   }
   
     my @results;  # ----------------------------- format and output results based on a reply list
   sub output_results {
     my $replyfile='';      my (@replylist)=@_;
     $reply=~/^([\.\w]+)$/; # must do since 'use strict' checks for tainting      foreach my $reply (@replylist) {
     $replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1;  
     $reply=~/(.*?)\_/;   my @results;
     my $hostname=$1;  
    my $replyfile='';
     {   $reply=~/^([\.\w]+)$/; # must do since 'use strict' checks for tainting
  while (1) {   $replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1;
     last if -e $replyfile;   $reply=~/(.*?)\_/;
     sleep 1;   my $hostname=$1;
   
    {
       while (1) {
    last if -e $replyfile;
    sleep 1;
       }
       # QUESTION: how should I handle this error condition..
       # I'm sure there is syntax elsewhere I can use..
       my $fh=Apache::File->new($replyfile) or
    ($r->print('file cannot be opened') and return OK);
       @results=<$fh>;
  }   }
  # QUESTION: how should I handle this error condition..  
  # I'm sure there is syntax elsewhere I can use..  
  my $fh=Apache::File->new($replyfile) or  
        ($r->print('file cannot be opened') and return OK);  
        @results=<$fh>;  
     }  
   
     my $compiledresult='';   my $compiledresult='';
   
     foreach my $result (@results) {   foreach my $result (@results) {
  my ($title,$author,$subject,$url,$keywords,$version,      my ($title,$author,$subject,$url,$keywords,$version,
     $notes,$abstract,$mime,$lang,   $notes,$abstract,$mime,$lang,
     $creationdate,$lastrevisiondate,$owner,$copyright   $creationdate,$lastrevisiondate,$owner,$copyright
     )=map {&Apache::lonnet::unescape($_)} (split(/\,/,$result));   )=map {&Apache::lonnet::unescape($_)} (split(/\,/,$result));
  my $shortabstract=$abstract;      my $shortabstract=$abstract;
  $shortabstract=substr($abstract,0,200) if length($abstract)>200;      $shortabstract=substr($abstract,0,200) if length($abstract)>200;
  $compiledresult.=<<END;      $compiledresult.=<<END;
 <p>  <p>
 END  END
  $compiledresult.=<<END if $ENV{'form.catalogmode'} eq 'interactive';              $compiledresult.=<<END if $ENV{'form.catalogmode'} eq 'interactive';
 <font size='-1'><INPUT TYPE="button" NAME="returnvalues" VALUE="SELECT"  <font size='-1'><INPUT TYPE="button" NAME="returnvalues" VALUE="SELECT"
 onClick="javascript:select_data('$title','$url')">  onClick="javascript:select_data('$title','$url')">
 </font>  </font>
 <br>  <br>
 END  END
         $compiledresult.=<<END;              $compiledresult.=<<END;
 <b>URL: </b> <A HREF="$ENV{'HTTP_HOST'}/$url" TARGET='search_preview'>$url</A>  <b>URL: </b> <A HREF="$ENV{'HTTP_HOST'}/$url" TARGET='search_preview'>$url</A>
 <br>  <br>
 <b>Title:</b> $title<br>  <b>Title:</b> $title<br>
Line 481  END Line 498  END
 <b>Repository Location:</b> $hostname  <b>Repository Location:</b> $hostname
 </p>  </p>
 END  END
 }          }
   
     unless ($compiledresult) {   unless ($compiledresult) {
  $compiledresult="There were no results that matched your query";      $compiledresult="There were no results that matched your query";
     }   }
   
     # make query information persistent to allow for subsequent revision   # make query information persistent to allow for subsequent revision
     my $persistent='';   my $persistent='';
     map {   map {
  if (/^form\./ && !/submit/) {      if (/^form\./ && !/submit/) {
     my $name=$_;   my $name=$_;
     my $key=$name;   my $key=$name;
     $name=~s/^form\.//;   $name=~s/^form\.//;
     $persistent.=<<END;   $persistent.=<<END;
 <INPUT TYPE='hidden' NAME='$name' VALUE='$ENV{$key}'>  <INPUT TYPE='hidden' NAME='$name' VALUE='$ENV{$key}'>
 END  END
         }              }
     } (keys %ENV);   } (keys %ENV);
   
     $r->print(<<BEGINNING);   $r->print(<<BEGINNING);
 <html>  <html>
 <head>  <head>
 <title>The LearningOnline Network with CAPA</title>  <title>The LearningOnline Network with CAPA</title>
 BEGINNING  BEGINNING
     $r->print(<<SCRIPT) if $ENV{'form.catalogmode'} eq 'interactive';          $r->print(<<SCRIPT) if $ENV{'form.catalogmode'} eq 'interactive';
 <script>  <script>
     function select_data(title,url) {      function select_data(title,url) {
  changeTitle(title);   changeTitle(title);
Line 523  BEGINNING Line 540  BEGINNING
     }      }
 </script>  </script>
 SCRIPT  SCRIPT
     $r->print(<<RESULTS);          $r->print(<<RESULTS);
 </head>  </head>
 <body bgcolor="#ffffff">  <body bgcolor="#ffffff">
 <img align=right src=/adm/lonIcons/lonlogos.gif>  <img align=right src=/adm/lonIcons/lonlogos.gif>
Line 544  $compiledresult Line 561  $compiledresult
 </body>  </body>
 </html>  </html>
 RESULTS  RESULTS
       }
     return OK;  
 }  }
   
 1;  1;

Removed from v.1.17  
changed lines
  Added in v.1.18


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