Diff for /loncom/interface/lonsearchcat.pm between versions 1.206 and 1.209

version 1.206, 2004/04/14 18:29:32 version 1.209, 2004/04/19 16:53:27
Line 164  sub handler { Line 164  sub handler {
             '_'.&Apache::lonnet::escape($ENV{'user.name'}).              '_'.&Apache::lonnet::escape($ENV{'user.name'}).
                 '_'.$ENV{'form.persistent_db_id'}.'_persistent_search.db';                  '_'.$ENV{'form.persistent_db_id'}.'_persistent_search.db';
     ##      ##
       &Apache::lonhtmlcommon::clear_breadcrumbs();
       if (exists($ENV{'request.course.id'}) && $ENV{'request.course.id'} ne '') {
           &Apache::lonhtmlcommon::add_breadcrumb
                ({href=>'/adm/searchcat?'.
                      'catalogmode='.$ENV{'form.catalogmode'}.
                      '&launch='.$ENV{'form.launch'}.
                      '&mode='.$ENV{'form.mode'},
                 text=>"Course and Catalog Search",
                 bug=>'Searching',});
       } else {
           &Apache::lonhtmlcommon::add_breadcrumb
                ({href=>'/adm/searchcat?'.
                      'catalogmode='.$ENV{'form.catalogmode'}.
                      '&launch='.$ENV{'form.launch'}.
                      '&mode='.$ENV{'form.mode'},
                 text=>"Catalog Search",
                 bug=>'Searching',});
       }
       #
     if (! &get_persistent_form_data($persistent_db_file)) {      if (! &get_persistent_form_data($persistent_db_file)) {
         if ($ENV{'form.phase'} =~ /(run_search|results)/) {          if ($ENV{'form.phase'} =~ /(run_search|results)/) {
             &Apache::lonnet::logthis("lonsearchcat:Unable to recover data ".              &Apache::lonnet::logthis("lonsearchcat:Unable to recover data ".
Line 264  END Line 283  END
     }      }
     $ENV{'form.phase'} = 'disp_basic' if (! exists($ENV{'form.phase'}));      $ENV{'form.phase'} = 'disp_basic' if (! exists($ENV{'form.phase'}));
     $ENV{'form.show'} = 20 if (! exists($ENV{'form.show'}));      $ENV{'form.show'} = 20 if (! exists($ENV{'form.show'}));
       #
       $ENV{'form.searchmode'} = 'basic';
       if ($ENV{'form.phase'} eq 'adv_search' ||
           $ENV{'form.phase'} eq 'disp_adv') {
           $ENV{'form.searchmode'} = 'advanced';
       } elsif ($ENV{'form.phase'} eq 'course_search') {
           $ENV{'form.searchmode'} = 'course_search';
       }
       #
       if ($ENV{'form.searchmode'} eq 'advanced') {
           &Apache::lonhtmlcommon::add_breadcrumb
               ({href=>'/adm/searchcat?phase=disp_adv&'.
                     'catalogmode='.$ENV{'form.catalogmode'}.
                     '&launch='.$ENV{'form.launch'}.
                     '&mode='.$ENV{'form.mode'},
                     text=>"Advanced Search",
                     bug=>'Searching',});
       } elsif ($ENV{'form.searchmode'} eq 'course search') {
           &Apache::lonhtmlcommon::add_breadcrumb
               ({href=>'/adm/searchcat?phase=disp_adv&'.
                     'catalogmode='.$ENV{'form.catalogmode'}.
                     '&launch='.$ENV{'form.launch'}.
                     '&mode='.$ENV{'form.mode'},
                     text=>"Course Search",
                     bug=>'Searching',});
       }
     ##      ##
     ## Switch on the phase      ## Switch on the phase
     ##      ##
Line 288  END Line 333  END
         &course_search($r);          &course_search($r);
     } elsif(($ENV{'form.phase'} eq 'basic_search') ||      } elsif(($ENV{'form.phase'} eq 'basic_search') ||
             ($ENV{'form.phase'} eq 'adv_search')) {              ($ENV{'form.phase'} eq 'adv_search')) {
         $ENV{'form.searchmode'} = 'basic';  
         if ($ENV{'form.phase'} eq 'adv_search') {  
             $ENV{'form.searchmode'} = 'advanced';  
         }  
         # Set up table          # Set up table
         if (! defined(&create_results_table())) {          if (! defined(&create_results_table())) {
     my $errorstring=&Apache::lonmysql::get_error();      my $errorstring=&Apache::lonmysql::get_error();
Line 454  sub untiehash { Line 495  sub untiehash {
   
 } # End of course search scoping  } # End of course search scoping
   
   sub search_html_header {
       my $Str = <<ENDHEADER;
   <html>
   <head>
   <title>The LearningOnline Network with CAPA</title>
   <script type="text/javascript">
       function openhelp(val) {
    openhelpwin=open('/adm/help/searchcat.html','helpscreen',
        'scrollbars=1,width=600,height=300');
    openhelpwin.focus();
       }
   </script>
   </head>
   ENDHEADER
       return $Str;
   }
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
Line 470  Prints the form for the basic search.  S Line 528  Prints the form for the basic search.  S
 sub print_basic_search_form {  sub print_basic_search_form {
     my ($r,$closebutton,$hidden_fields) = @_;      my ($r,$closebutton,$hidden_fields) = @_;
     my $bodytag=&Apache::loncommon::bodytag('Search').      my $bodytag=&Apache::loncommon::bodytag('Search').
  &Apache::loncommon::help_open_topic('Finding_Resources').          &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Finding_Resources',
  &Apache::loncommon::help_open_bug('Searching');                                              undef,undef,! $ENV{'form.launch'});
     my $scrout=<<"ENDDOCUMENT";      my $scrout = &search_html_header().$bodytag;
 <html>      if (&Apache::lonnet::allowed('bre',$ENV{'request.role.domain'})) {
 <head>          my $Statement=&searchhelp();
 <title>The LearningOnline Network with CAPA</title>          $scrout.=(<<ENDDOCUMENT);
 <script type="text/javascript">  
     function openhelp(val) {  
  openhelpwin=open('/adm/help/searchcat.html','helpscreen',  
      'scrollbars=1,width=600,height=300');  
  openhelpwin.focus();  
     }  
 </script>  
 </head>  
 $bodytag  
 ENDDOCUMENT  
 if (&Apache::lonnet::allowed('bre',$ENV{'request.role.domain'})) {  
     my $CatalogSearch=&mt('Catalog Search');  
     my $Statement=&searchhelp();  
     $scrout.=(<<ENDDOCUMENT);  
 <h1>$CatalogSearch</h1>  
 <form name="loncapa_search" method="post" action="/adm/searchcat">  <form name="loncapa_search" method="post" action="/adm/searchcat">
 <input type="hidden" name="phase" value="basic_search" />  <input type="hidden" name="phase" value="basic_search" />
 $hidden_fields  $hidden_fields
Line 501  $Statement. Line 544  $Statement.
 <table>  <table>
 <tr><td>  <tr><td>
 ENDDOCUMENT  ENDDOCUMENT
     $scrout.='&nbsp;'.&Apache::lonhtmlcommon::textbox('basicexp',          $scrout.='&nbsp;'.
                                             $ENV{'form.basicexp'},40).              &Apache::lonhtmlcommon::textbox('basicexp',
         '&nbsp;';                                          $ENV{'form.basicexp'},40).
     my $relatedcheckbox = &Apache::lonhtmlcommon::checkbox('related',                                          '&nbsp;';
  $ENV{'form.related'});          my $relatedcheckbox = 
     my $domain = $r->dir_config('lonDefDomain');              &Apache::lonhtmlcommon::checkbox('related',
     my $domaincheckbox = &Apache::lonhtmlcommon::checkbox('domains',                                               $ENV{'form.related'});
  $ENV{'form.domains'});          my $domain = $r->dir_config('lonDefDomain');
     my $srch=&mt('Search');          my $domaincheckbox = 
     my $header=&mt('Advanced Search');              &Apache::lonhtmlcommon::checkbox('domains',
     my $userelatedwords=&mt('use related words');                                               $ENV{'form.domains'});
     my $onlysearchdomain=&mt('only search domain');          my $srch=&mt('Search');
     my $view=&viewoptions();          my $header=&mt('Advanced Search');
     $scrout.=<<END;          my $userelatedwords=&mt('use related words');
           my $onlysearchdomain=&mt('only search domain');
           my $view=&viewoptions();
           $scrout.=<<END;
 </td><td><a  </td><td><a
 href="/adm/searchcat?phase=disp_adv&catalogmode=$ENV{'form.catalogmode'}&launch=$ENV{'form.launch'}&mode=$ENV{'form.mode'}"  href="/adm/searchcat?phase=disp_adv&catalogmode=$ENV{'form.catalogmode'}&launch=$ENV{'form.launch'}&mode=$ENV{'form.mode'}"
 >$header</a></td></tr>  >$header</a></td></tr>
Line 602  sub print_advanced_search_form{ Line 648  sub print_advanced_search_form{
 <input type="reset" name="reset" value='$lt{"reset"}' />  <input type="reset" name="reset" value='$lt{"reset"}' />
 $closebutton  $closebutton
 <input type="button" value="$lt{'help'}" onClick="openhelp()" />  <input type="button" value="$lt{'help'}" onClick="openhelp()" />
 </p>  
 END  END
     my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search');      my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search').
           &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching',
                                               'Finding_Resources',
                                               undef,undef,
                                               ! $ENV{'form.launch'});
     my $searchhelp=&searchhelp();      my $searchhelp=&searchhelp();
     my $scrout=<<"ENDHEADER";      my $scrout=&search_html_header();
 <html>      $scrout .= <<"ENDHEADER";
 <head>  
 <title>The LearningOnline Network with CAPA</title>  
 <script type="text/javascript">  
     function openhelp(val) {  
  openhelpwin=open('/adm/help/searchcat.html','helpscreen',  
      'scrollbars=1,width=600,height=300');  
  openhelpwin.focus();  
     }  
 </script>  
 </head>  
 $bodytag  $bodytag
 $searchhelp  
 <form method="post" action="/adm/searchcat" name="advsearch">  <form method="post" action="/adm/searchcat" name="advsearch">
 $advanced_buttons  $advanced_buttons
 $hidden_fields  
 <input type="hidden" name="phase" value="adv_search" />  
 ENDHEADER  ENDHEADER
     $scrout.=&viewoptions();      $scrout.=('&nbsp;'x2).&viewoptions().'</p>'.$hidden_fields. 
           '<input type="hidden" name="phase" value="adv_search" />';
     my %fields=&Apache::lonmeta::fieldnames();      my %fields=&Apache::lonmeta::fieldnames();
       #
     $scrout.='<table>';      $scrout.= '<p>'.$searchhelp.'</p>'.
     $scrout.="<tr><th>".&mt('Field').'</th><th>'.&mt('Value').'</th><th>'          "<table>\n";
  .&mt('Related').'<br />'.&mt('Words')."</td></tr>\n";      my %related_word_search = 
     foreach ('title','author','owner','authorspace','modifyinguser',          ('title'=>1,
      'keywords','notes','abstract','standards',           'author'=>0,
      'lowestgradelevel','highestgradelevel','mime') {           'owner'=>0,
  $scrout.='<tr bgcolor="#FFFFBB"><td>'.&titlefield($fields{$_}).'</td><td>'.           'authorspace'=>0,
     &Apache::lonmeta::prettyinput($_,$ENV{'form.'.$_},$_,'advsearch',           'modifyinguser'=>0,
   1,'</td><td>',$ENV{'form.'.$_.'_related'}).           'keywords'=>1,
     '</td></tr>';           'notes'=>1,
            'abstract'=>1,
            'standards'=>1,
            'mime'=>1,
            );
       #
       foreach my $field ('title','author','owner','authorspace','modifyinguser',
        'keywords','notes','abstract','standards','mime') {
    $scrout.='<tr><td align="right">'.&titlefield($fields{$field}).'</td><td>'.
       &Apache::lonmeta::prettyinput($field,
                                             $ENV{'form.'.$field},
                                             $field,
                                             'advsearch',
     $related_word_search{$field},
                                             '</td><td align="left">',
                                             $ENV{'form.'.$field.'_related'},
                                             50);
           if ($related_word_search{$field}) {
               $scrout .= 'related words';
           } else {
               $scrout .= '</td><td>&nbsp;';
           }
           $scrout .= '</td></tr>'.$/;
     }      }
     $scrout.='<tr bgcolor="#FFFFBB"><td>'.      foreach my $field ('lowestgradelevel','highestgradelevel') {
  &titlefield(&mt('MIME Type Category')).'</td><td>'.    $scrout.='<tr>'.
               '<td align="right">'.&titlefield($fields{$field}).'</td>'.
               '<td colspan="2">'.
       &Apache::lonmeta::prettyinput($field,
                                             $ENV{'form.'.$field},
                                             $field,
                                             'advsearch',
     0).
                                             '</td></tr>'.$/;
       }
       $scrout.='<tr><td align="right">'.
    &titlefield(&mt('MIME Type Category')).'</td><td colspan="2">'. 
     &Apache::loncommon::filecategoryselect('category',      &Apache::loncommon::filecategoryselect('category',
    $ENV{'form.category'}).     $ENV{'form.category'}).
     '</td><td>&nbsp;</td></td></tr>';      '</td></tr>'.$/;
     $scrout.='<tr bgcolor="#FFFFBB"><td>'.      $scrout.='<tr><td align="right" valign="top">'.
  &titlefield(&mt('Limit Search to Domains')).'</td><td>'.    &titlefield(&mt('Domains')).'</td><td colspan="2">'. 
     &Apache::loncommon::domain_select('domains',      &Apache::loncommon::domain_select('domains',
    $ENV{'form.domains'},1).     $ENV{'form.domains'},1).
     '</td><td>&nbsp;</td></td></tr>';      '</td></tr>'.$/;
       $scrout .= "</table>\n<br />\n<table>\n";
     my %dates=&Apache::lonlocal::texthash      my %dates=&Apache::lonlocal::texthash
         ('creationdatestart'     => 'Creation Date After',          ('creationdatestart'     => 'Creation Date After',
          'creationdateend'       => 'Creation Date Before',           'creationdateend'       => 'Creation Date Before',
          'lastrevisiondatestart' => 'Last Revision Date After',           'lastrevisiondatestart' => 'Last Revision Date After',
          'lastrevisiondateend'   => 'Last Revision Date Before');           'lastrevisiondateend'   => 'Last Revision Date Before');
     foreach (sort keys %dates) {      foreach my $field (sort keys %dates) {
  $scrout.='<tr bgcolor="#FFFFBB">'.   $scrout.='<tr>'.
             '<td>'.&titlefield($dates{$_}).'</td><td>'.               '<td align="right">'.&titlefield($dates{$field}).'</td><td>'. 
     &Apache::lonhtmlcommon::date_setter('advsearch',$_,0,'',1).      &Apache::lonhtmlcommon::date_setter('advsearch',$field,0,'',1).
     '</td><td>&nbsp;</td></td>'.      '</td></tr>'.$/;
             '</tr>';  
     }      }
   
     $scrout.="</table>\n";      $scrout.="</table>\n";
     $scrout.=<<ENDDOCUMENT;      $scrout.=<<ENDDOCUMENT;
 $advanced_buttons  $advanced_buttons
Line 690  Outputs: titletext with font wrapper Line 759  Outputs: titletext with font wrapper
 ######################################################################  ######################################################################
 sub titlefield {  sub titlefield {
     my $title=shift;      my $title=shift;
     return '<font face="arial" color="#800000">'.$title.'</font>';      return $title;
 }  }
   
 ######################################################################  ######################################################################
Line 735  Outputs: text for box with view options Line 804  Outputs: text for box with view options
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
 sub viewoptions {  sub viewoptions {
     my $scrout="\n\n".'<table bgcolor="#FFFFBB">'.      my $scrout="\n".'<nobr>';
         '<tr><th>'.&mt('View Options').'</th><th>'.      if (! defined($ENV{'form.viewselect'})) { 
  &mt('Records per Page').'</th></tr><tr><td>';          $ENV{'form.viewselect'}='detailed'; 
     unless ($ENV{'form.viewselect'}) { $ENV{'form.viewselect'}='detailed'; }      }
     $scrout.=&Apache::lonmeta::selectbox('viewselect',      $scrout.=&Apache::lonmeta::selectbox('viewselect',
  $ENV{'form.viewselect'},   $ENV{'form.viewselect'},
  \&viewoptiontext,   \&viewoptiontext,
  sort(keys(%Views)));   sort(keys(%Views)));
     $scrout.='</td><td>';      $scrout.= '&nbsp;&nbsp;';
     $scrout.=&Apache::lonmeta::selectbox('show',      $scrout.=&Apache::lonmeta::selectbox('show',
  $ENV{'form.show'},   $ENV{'form.show'},
  undef,   undef,
  (10,20,50,100,1000,10000));   (10,20,50,100,1000,10000));
     $scrout.="</td></tr></table>\n\n";      $scrout .= ('&nbsp;'x2).&mt('Records per Page').'</nobr>'.$/;
     return $scrout;      return $scrout;
 }  }
   

Removed from v.1.206  
changed lines
  Added in v.1.209


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