Diff for /loncom/interface/lonsearchcat.pm between versions 1.179 and 1.180

version 1.179, 2003/06/16 19:42:02 version 1.180, 2003/06/16 20:54:39
Line 382  END Line 382  END
             (undef,undef,undef,undef);              (undef,undef,undef,undef);
         my $pretty_string;          my $pretty_string;
         if ($ENV{'form.phase'} eq 'basic_search') {          if ($ENV{'form.phase'} eq 'basic_search') {
             ($query,$pretty_string) = &parse_basic_search($r,$closebutton);              ($query,$pretty_string,$libraries) = 
                   &parse_basic_search($r,$closebutton);
         } else {                      # Advanced search          } else {                      # Advanced search
             ($query,$customquery,$customshow,$libraries,$pretty_string)               ($query,$customquery,$customshow,$libraries,$pretty_string) 
                 = &parse_advanced_search($r,$closebutton);                  = &parse_advanced_search($r,$closebutton);
Line 554  then press SEARCH below. Line 555  then press SEARCH below.
 ENDDOCUMENT  ENDDOCUMENT
     $scrout.=' '.&simpletextfield('basicexp',$ENV{'form.basicexp'},40).      $scrout.=' '.&simpletextfield('basicexp',$ENV{'form.basicexp'},40).
         ' ';          ' ';
     my $checkbox = &simplecheckbox('related',$ENV{'form.related'});      my $relatedcheckbox = &simplecheckbox('related',$ENV{'form.related'});
       my $domain = $r->dir_config('lonDefDomain');
       my $domaincheckbox = &simplecheckbox('domains',$domain,'checked');
     $scrout.=<<END;      $scrout.=<<END;
 </td><td><a  </td><td><a
 href="/adm/searchcat?phase=disp_adv&catalogmode=$ENV{'form.catalogmode'}&launch=$ENV{'form.launch'}"  href="/adm/searchcat?phase=disp_adv&catalogmode=$ENV{'form.catalogmode'}&launch=$ENV{'form.launch'}"
 >Advanced Search</a></td></tr>  >Advanced Search</a></td></tr>
 <tr><td>$checkbox use related words</td><td></td></tr>  <tr><td>$relatedcheckbox use related words</td>
       <td>$domaincheckbox only search domain <b>$domain</b></td></tr>
 </table>  </table>
 </p>  </p>
 <p>  <p>
Line 579  per page. Line 583  per page.
 </p>  </p>
 </form>  </form>
 ENDDOCUMENT  ENDDOCUMENT
     if ($ENV{'request.course.id'}) { $scrout.='<hr />'; }      }
 }      if ($ENV{'request.course.id'}) {
 if ($ENV{'request.course.id'}) {          $scrout.=(<<ENDCOURSESEARCH);
     $scrout.=(<<ENDCOURSESEARCH);  <hr />
 <h1>Course Search</h1>      <h1>Course Search</h1>    
 <form method="post" action="/adm/searchcat">  <form method="post" action="/adm/searchcat">
 <input type="hidden" name="phase" value="course_search" />  <input type="hidden" name="phase" value="course_search" />
Line 594  Enter terms or phrases, then press SEARC Line 598  Enter terms or phrases, then press SEARC
 <table>  <table>
 <tr><td>  <tr><td>
 ENDCOURSESEARCH  ENDCOURSESEARCH
     $scrout.='&nbsp;'.&simpletextfield('courseexp',$ENV{'form.courseexp'},40);          $scrout.='&nbsp;'.
     my $crscheckbox = &simplecheckbox('crsfulltext',$ENV{'form.crsfulltext'});              &simpletextfield('courseexp',$ENV{'form.courseexp'},40);
     my $relcheckbox = &simplecheckbox('crsrelated',$ENV{'form.crsrelated'});          my $crscheckbox = 
 $scrout.=(<<ENDENDCOURSE);              &simplecheckbox('crsfulltext',$ENV{'form.crsfulltext'});
           my $relcheckbox = 
               &simplecheckbox('crsrelated',$ENV{'form.crsrelated'});
           $scrout.=(<<ENDENDCOURSE);
 </td></tr>  </td></tr>
 <tr><td>$relcheckbox use related words</td><td></td></tr>  <tr><td>$relcheckbox use related words</td><td></td></tr>
 <tr><td>$crscheckbox fulltext search (time consuming)</td><td></td></tr>  <tr><td>$crscheckbox fulltext search (time consuming)</td><td></td></tr>
Line 605  $scrout.=(<<ENDENDCOURSE); Line 612  $scrout.=(<<ENDENDCOURSE);
 &nbsp;<input type="submit" name="coursesubmit" value='SEARCH' />  &nbsp;<input type="submit" name="coursesubmit" value='SEARCH' />
 </p>  </p>
 ENDENDCOURSE  ENDENDCOURSE
 }      }
     $scrout.=(<<ENDDOCUMENT);      $scrout.=(<<ENDDOCUMENT);
 </body>  </body>
 </html>  </html>
Line 1017  If $value eq 'on' the box is checked. Line 1024  If $value eq 'on' the box is checked.
 ###############################################  ###############################################
 ###############################################  ###############################################
   
 sub simplecheckbox {  sub simplecheckbox{
     my ($name,$value)=@_;      my ($name,$value,$checked)=@_;
     my $checked='';      $checked="checked" if ($value eq 'on');
     $checked="checked" if $value eq 'on';      return '<input type="checkbox" name="'.$name.'" value="'.$value.'" '.
     return '<input type="checkbox" name="'.$name.'" '. $checked . ' />';          $checked.' />';
 }  }
   
 ###############################################  ###############################################
Line 1415  sub parse_advanced_search { Line 1422  sub parse_advanced_search {
     ## ---------------------------------------------------------------      ## ---------------------------------------------------------------
     ## Deal with restrictions to given domains      ## Deal with restrictions to given domains
     ##       ## 
       my ($libraries_to_query,$pretty_domains_string) = 
           &parse_domain_restrictions();
       $pretty_search_string .= $pretty_domains_string."<br />\n";
       #
       if (@queries) {
    $query=join(" AND ",@queries);
    $query="select * from metadata where $query";
       } elsif ($customquery) {
           $query = '';
       }
       return ($query,$customquery,$customshow,$libraries_to_query,
               $pretty_search_string);
   }
   
   sub parse_domain_restrictions {
     my $libraries_to_query = undef;      my $libraries_to_query = undef;
     # $ENV{'form.domains'} can be either a scalar or an array reference.      # $ENV{'form.domains'} can be either a scalar or an array reference.
     # We need an array.      # We need an array.
     my @allowed_domains = (ref($ENV{'form.domains'}) ? @{$ENV{'form.domains'}}       if (! exists($ENV{'form.domains'})) {
                            :  ($ENV{'form.domains'}) );          return (undef,'');
       }
       my @allowed_domains;
       if (ref($ENV{'form.domains'})) {
           @allowed_domains =  @{$ENV{'form.domains'}};
       } else {
           @allowed_domains = ($ENV{'form.domains'});
       }
     my %domain_hash = ();      my %domain_hash = ();
     my $pretty_domains_string;      my $pretty_domains_string;
     foreach (@allowed_domains) {      foreach (@allowed_domains) {
Line 1442  sub parse_advanced_search { Line 1471  sub parse_advanced_search {
             }              }
         }          }
     }      }
     $pretty_search_string .= $pretty_domains_string."<br />\n";      return ($libraries_to_query,$pretty_domains_string);
     #  
     if (@queries) {  
  $query=join(" AND ",@queries);  
  $query="select * from metadata where $query";  
     } elsif ($customquery) {  
         $query = '';  
     }  
     return ($query,$customquery,$customshow,$libraries_to_query,  
             $pretty_search_string);  
 }  }
   
 ######################################################################  ######################################################################
Line 1479  sub parse_basic_search { Line 1499  sub parse_basic_search {
  $ENV{"form.$_"}=&Apache::lonnet::unescape($ENV{"form.$_"});   $ENV{"form.$_"}=&Apache::lonnet::unescape($ENV{"form.$_"});
  $ENV{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g;   $ENV{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g;
     }      }
       my ($libraries_to_query,$pretty_domains_string) = 
           &parse_domain_restrictions();
     # Check to see if enough is filled in      # Check to see if enough is filled in
     unless (&filled($ENV{'form.basicexp'})) {      unless (&filled($ENV{'form.basicexp'})) {
  &output_blank_field_error($r,$closebutton,'phase=disp_basic');   &output_blank_field_error($r,$closebutton,'phase=disp_basic');
Line 1503  sub parse_basic_search { Line 1524  sub parse_basic_search {
                         'keywords'));                          'keywords'));
     $concatarg='title' if $ENV{'form.titleonly'};      $concatarg='title' if $ENV{'form.titleonly'};
     $query=&build_SQL_query('concat_ws(" ",'.$concatarg.')',$search_string);      $query=&build_SQL_query('concat_ws(" ",'.$concatarg.')',$search_string);
       if (defined($pretty_domains_string) && $pretty_domains_string ne '') {
           $pretty_search_string .= ' '.$pretty_domains_string;
       }
     $pretty_search_string .= "<br />\n";      $pretty_search_string .= "<br />\n";
     return 'SELECT * FROM metadata WHERE '.$query,$pretty_search_string;      return ('SELECT * FROM metadata WHERE '.$query,$pretty_search_string,
               $libraries_to_query);
 }  }
   
   

Removed from v.1.179  
changed lines
  Added in v.1.180


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