Diff for /loncom/interface/lonsearchcat.pm between versions 1.92 and 1.93

version 1.92, 2001/04/02 16:57:38 version 1.93, 2001/04/02 21:18:35
Line 711  sub output_results { Line 711  sub output_results {
     my %rhash=%{$replyref};      my %rhash=%{$replyref};
     my $compiledresult='';      my $compiledresult='';
     my $timeremain=30;      my $timeremain=30;
       my $resultflag=0;
       my $tflag=1;
   
       # make query information persistent to allow for subsequent revision
       my $persistent=&make_persistent();
   
       # output beginning of search page
  $r->print(<<BEGINNING);   $r->print(<<BEGINNING);
 <html>  <html>
 <head>  <head>
Line 740  SCRIPT Line 747  SCRIPT
 <img align=right src=/adm/lonIcons/lonlogos.gif>  <img align=right src=/adm/lonIcons/lonlogos.gif>
 <h1>Search Catalog</h1>  <h1>Search Catalog</h1>
 CATALOGBEGIN  CATALOGBEGIN
           $r->print(<<RESULTS);
   <form method="post" action="/adm/searchcat">
   <input type='button' value='Revise search request'
   onClick='this.form.submit();'>
   $closebutton
   $persistent
   <hr>
   <h3>Search Query</h3>
   RESULTS
       if ($mode eq 'Basic') {
    $r->print(<<RESULTS);
   <p>
   <b>Basic search:</b> $ENV{'form.basicexp'}
   </p>
   RESULTS
       }
       elsif ($mode eq 'Advanced') {
    $r->print(<<RESULTS);
   <p>
   <b>Advanced search</b>
   $query
   </p>
   RESULTS
       }
       $r->print('<h3>Search Results</h3>');
     $r->rflush();      $r->rflush();
     $r->print(<<ENDPOP);      $r->print(<<ENDPOP);
 <script>  <script>
Line 759  ENDPOP Line 791  ENDPOP
   
     my $servernum=(keys %rhash)+0;      my $servernum=(keys %rhash)+0;
     $r->print('<script>popwin.document.popremain.space.value="'.      $r->print('<script>popwin.document.popremain.space.value="'.
       $servernum.', 0%, count=0/1";</script>');        $servernum.', 0%, count=0/'.$servernum.'";</script>');
     $r->rflush();       $r->rflush(); 
       my $servercount=0;
     foreach my $rkey (keys %rhash) {      foreach my $rkey (keys %rhash) {
    $servercount++;
    $tflag=1;
    $compiledresult='';
    my $hostname=$rkey;
  $r->print('<script>popwin.document.popremain.status.value="'.   $r->print('<script>popwin.document.popremain.status.value="'.
   $rkey.', trying contact";</script>');    $rkey.', trying contact";</script>');
  $r->rflush();   $r->rflush();
Line 769  ENDPOP Line 806  ENDPOP
  my @results;   my @results;
   
  my $replyfile='';   my $replyfile='';
  $reply=~/^([\.\w]+)$/; # must do since 'use strict' checks for tainting  
  $replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1;  
  $reply=~/(.*?)\_/;  
  my $hostname=$1;  
  {  
     while (1) {  
  $r->print('<script>popwin.document.popremain.status.value="'.  
   $rkey.', contacted";</script>') if -e $replyfile;  
  $r->rflush();  
  last if -e "$replyfile.end";  
  last unless $timeremain;  
  sleep 1;  
  $timeremain--;  
  $r->print('<script>popwin.document.popremain.timeout.value="'.  
   $timeremain.'";</script>');  
  $r->rflush();  
     }  
     # 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>;  
  }  
   
    if ($reply eq 'con_lost') {
       my $percent=sprintf('%3.0f',($servercount/$servernum*100));
       $r->print('<script>popwin.document.popremain.space.value="'.
         $servernum.', '.$percent.'%, count='.$servercount.
         '/'.$servernum.'";</script>');
    }
    else {
       $reply=~/^([\.\w]+)$/; # must do since 'use strict' checks for tainting
       $replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1;
       $reply=~/(.*?)\_/;
       {
    while (1) {
       if (-e $replyfile && $tflag) {
    $r->print('<script>popwin.document.popremain.status.'.
     'value="'.$rkey.', transmitting";</script>');
    $r->rflush();
    $tflag=0;
        }
       last if -e "$replyfile.end";
       last unless $timeremain;
       sleep 1;
       $timeremain--;
       $r->print('<script>popwin.document.popremain.timeout.value="'.
         $timeremain.'";</script>');
       $r->rflush();
    }
    # 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('ERROR: file cannot be opened') and return OK);
    @results=<$fh>;
       }
    }
  my $customshow='';   my $customshow='';
  my $extrashow='';   my $extrashow='';
  my @customfields;   my @customfields;
Line 800  ENDPOP Line 847  ENDPOP
     $customshow=$ENV{'form.customshow'};      $customshow=$ENV{'form.customshow'};
     $customshow=~s/[^\w\s]//g;      $customshow=~s/[^\w\s]//g;
     my @fields=map {"<font color=\"#008000\">$_:</font><!-- $_ -->"}       my @fields=map {"<font color=\"#008000\">$_:</font><!-- $_ -->"} 
                    split(/\s+/,$customshow);      split(/\s+/,$customshow);
     @customfields=split(/\s+/,$customshow);      @customfields=split(/\s+/,$customshow);
     if ($customshow) {      if ($customshow) {
  $extrashow="<ul><li>".join("</li><li>",@fields)."</li></ul>\n";   $extrashow="<ul><li>".join("</li><li>",@fields)."</li></ul>\n";
Line 822  ENDPOP Line 869  ENDPOP
     chomp $result;      chomp $result;
     next unless $result;      next unless $result;
     my @fields=map      my @fields=map
                    {&Apache::lonnet::unescape($_)}      {&Apache::lonnet::unescape($_)}
                    (split(/\,/,$result));      (split(/\,/,$result));
     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)=@fields;   $creationdate,$lastrevisiondate,$owner,$copyright)=@fields;
Line 835  ENDPOP Line 882  ENDPOP
  foreach my $field (@customfields) {   foreach my $field (@customfields) {
     my $value='';      my $value='';
     if ($customhash{$url}=~/\<${field}[^\>]*\>(.*?)\<\/${field}[^\>]*\>/s) {      if ($customhash{$url}=~/\<${field}[^\>]*\>(.*?)\<\/${field}[^\>]*\>/s) {
          $value=$1;          $value=$1;
     }      }
     $extrashow2=~s/\<\!\-\- $field \-\-\>/ $value/g;              $extrashow2=~s/\<\!\-\- $field \-\-\>/ $value/g;
  }          }
     }              }
   
     $compiledresult.=<<END if $compiledresult;              $compiledresult.=<<END if $compiledresult;
 <hr align='left' width='200' noshade />  <hr align='left' width='200' noshade />
 END  END
     $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>
Line 855  onClick="javascript:select_data('$title' Line 902  onClick="javascript:select_data('$title'
 END  END
             my $httphost=$ENV{'HTTP_HOST'};              my $httphost=$ENV{'HTTP_HOST'};
   
     my $viewselect;              my $viewselect;
     if ($mode eq 'Basic') {              if ($mode eq 'Basic') {
  $viewselect=$ENV{'form.basicviewselect'};   $viewselect=$ENV{'form.basicviewselect'};
     }      }
     elsif ($mode eq 'Advanced') {              elsif ($mode eq 'Advanced') {
  $viewselect=$ENV{'form.advancedviewselect'};          $viewselect=$ENV{'form.advancedviewselect'};
     }              }
   
             if ($viewselect eq 'Detailed Citation View') {              if ($viewselect eq 'Detailed Citation View') {
  $compiledresult.=&detailed_citation_view(@fields,          $compiledresult.=&detailed_citation_view(@fields,
  $hostname,$httphost,   $hostname,$httphost,
  $extrashow2);   $extrashow2);
     }      }
             elsif ($viewselect eq 'Summary View') {              elsif ($viewselect eq 'Summary View') {
  $compiledresult.=&summary_view(@fields,$hostname,$httphost,   $compiledresult.=&summary_view(@fields,$hostname,$httphost,
        $extrashow2);         $extrashow2);
     }      }
             elsif ($viewselect eq 'Fielded Format') {              elsif ($viewselect eq 'Fielded Format') {
  $compiledresult.=&fielded_format_view(@fields,$hostname,   $compiledresult.=&fielded_format_view(@fields,$hostname,
       $httphost,$extrashow2);        $httphost,$extrashow2);
     }      }
             elsif ($viewselect eq 'XML/SGML') {              elsif ($viewselect eq 'XML/SGML') {
  $compiledresult.=&xml_sgml_view(@fields,$hostname,$httphost,   $compiledresult.=&xml_sgml_view(@fields,$hostname,$httphost,
  $extrashow2);   $extrashow2);
     }      }
       
         }          }
   
  unless ($compiledresult) {   if ($compiledresult) {
     $compiledresult="There were no results that matched your query";      $resultflag=1;
  }   }
   
  # make query information persistent to allow for subsequent revision  
  my $persistent=&make_persistent();  
   
         $r->print(<<RESULTS);  
 <form method="post" action="/adm/searchcat">  
 $customdata  
 <input type='button' value='Revise search request'  
 onClick='this.form.submit();'>  
 $closebutton  
 $persistent  
 <hr>  
 <h3>Search Query</h3>  
 RESULTS  
     if ($mode eq 'Basic') {  
  $r->print(<<RESULTS);   $r->print(<<RESULTS);
 <p>  $compiledresult
 <b>Basic search:</b> $ENV{'form.basicexp'}  
 </p>  
 RESULTS  RESULTS
           my $percent=sprintf('%3.0f',($servercount/$servernum*100));
    $r->print('<script>popwin.document.popremain.space.value="'.
             $servernum.', '.$percent.'%, count='.$servercount.
     '/'.$servernum.'";</script>');
     }      }
     elsif ($mode eq 'Advanced') {      unless ($resultflag) {
  $r->print(<<RESULTS);          $r->print("\nThere were no results that matched your query\n");
 <p>  
 <b>Advanced search</b>  
 $query  
 </p>  
 RESULTS  
     }      }
  $r->print(<<RESULTS);      $r->print('<script>popwin.close()</script>'); $r->rflush(); 
 <h3>Search Results</h3>      $r->print(<<RESULTS);
 $compiledresult  
 </body>  </body>
 </html>  </html>
 RESULTS  RESULTS
     }  
     $r->print('<script>popwin.close()</script>'); $r->rflush();   
 }  }
   
 # ------------------------------------------------------------- build_SQL_query  # ------------------------------------------------------------- build_SQL_query

Removed from v.1.92  
changed lines
  Added in v.1.93


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