Diff for /loncom/interface/lonsearchcat.pm between versions 1.186 and 1.191

version 1.186, 2003/09/22 00:48:32 version 1.191, 2003/10/24 21:09:24
Line 200  sub handler { Line 200  sub handler {
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
              ['catalogmode','launch','acts','mode','form','element','pause',               ['catalogmode','launch','acts','mode','form','element','pause',
               'phase','persistent_db_id','table','start','show',                'phase','persistent_db_id','table','start','show',
               'cleargroupsort']);                'cleargroupsort','titleelement']);
     ##      ##
     ## The following is a trick - we wait a few seconds if asked to so      ## The following is a trick - we wait a few seconds if asked to so
     ##     the daemon running the search can get ahead of the daemon      ##     the daemon running the search can get ahead of the daemon
Line 282  END Line 282  END
         $hidden_fields .= '<input type="hidden" name="element" value="'.          $hidden_fields .= '<input type="hidden" name="element" value="'.
                 $ENV{'form.element'}.'" />'."\n";                  $ENV{'form.element'}.'" />'."\n";
     }      }
       if (exists($ENV{'form.titleelement'})) {
           $hidden_fields .= '<input type="hidden" name="titleelement" value="'.
                   $ENV{'form.titleelement'}.'" />'."\n";
       }
     if (exists($ENV{'form.mode'})) {      if (exists($ENV{'form.mode'})) {
         $hidden_fields .= '<input type="hidden" name="mode" value="'.          $hidden_fields .= '<input type="hidden" name="mode" value="'.
                 $ENV{'form.mode'}.'" />'."\n";                  $ENV{'form.mode'}.'" />'."\n";
Line 441  sub course_search { Line 445  sub course_search {
    }     }
    &untiehash();     &untiehash();
     unless ($totalfound) {      unless ($totalfound) {
  $r->print('<p>No resources found.</p>');   $r->print('<p>'.&mt('No resources found').'.</p>');
     }      }
 # =================================================== Done going through course  # =================================================== Done going through course
     $r->print('</body></html>');      $r->print('</body></html>');
Line 559  ENDDOCUMENT Line 563  ENDDOCUMENT
     my $relatedcheckbox = &simplecheckbox('related',$ENV{'form.related'});      my $relatedcheckbox = &simplecheckbox('related',$ENV{'form.related'});
     my $domain = $r->dir_config('lonDefDomain');      my $domain = $r->dir_config('lonDefDomain');
     my $domaincheckbox = &simplecheckbox('domains',$domain);      my $domaincheckbox = &simplecheckbox('domains',$domain);
       my $srch=&mt('Search');
       my $header=&mt('Advanced Search');
     $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'}&mode=$ENV{'form.mode'}"
 >Advanced Search</a></td></tr>  >$header</a></td></tr>
 <tr><td>$relatedcheckbox use related words</td>  <tr><td>$relatedcheckbox use related words</td>
     <td>$domaincheckbox only search domain <b>$domain</b></td></tr>      <td>$domaincheckbox only search domain <b>$domain</b></td></tr>
 </table>  </table>
 </p>  </p>
 <p>  <p>
 &nbsp;<input type="submit" name="basicsubmit" value='SEARCH' />&nbsp;  &nbsp;<input type="submit" name="basicsubmit" value='$srch' />&nbsp;
 $closebutton  $closebutton
 END  END
     $scrout.=&selectbox(undef,'viewselect',      $scrout.=&selectbox('View','viewselect',
  $ENV{'form.viewselect'},   $ENV{'form.viewselect'},
  undef,undef,undef,   undef,undef,undef,
  sort(keys(%Views)));   sort(keys(%Views)));
     $scrout.=&selectbox(undef,'show',      $scrout.=&selectbox('Per Page','show',
  $ENV{'form.show'},   $ENV{'form.show'},
  undef,undef,undef,   undef,undef,undef,
  (10,20,50,100));   (10,20,50,100));
     $scrout.=<<ENDDOCUMENT;      $scrout.=<<ENDDOCUMENT;
 per page.  
 </p>  </p>
 </form>  </form>
 ENDDOCUMENT  ENDDOCUMENT
     }      }
     if ($ENV{'request.course.id'}) {      if ($ENV{'request.course.id'}) {
    my %lt=&Apache::lonlocal::texthash(
      'srch' => 'Search',
                                              'header' => 'Course Search',
    'note' => 'Enter terms or phrases, then press "Search" below',
      );
         $scrout.=(<<ENDCOURSESEARCH);          $scrout.=(<<ENDCOURSESEARCH);
 <hr />  <hr />
 <h1>Course Search</h1>      <h1>$lt{'header'}</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" />
 $hidden_fields  $hidden_fields
 <p>  <p>
 Enter terms or phrases, then press SEARCH below.  $lt{'note'}.
 </p>  </p>
 <p>  <p>
 <table>  <table>
Line 610  ENDCOURSESEARCH Line 620  ENDCOURSESEARCH
 <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>
 </table><p>  </table><p>
 &nbsp;<input type="submit" name="coursesubmit" value='SEARCH' />  &nbsp;<input type="submit" name="coursesubmit" value='$lt{'srch'}' />
 </p>  </p>
 ENDENDCOURSE  ENDENDCOURSE
     }      }
Line 682  ENDHEADER Line 692  ENDHEADER
  undef,undef,undef,   undef,undef,undef,
  (10,20,50,100));   (10,20,50,100));
     $scrout.='&nbsp;'.      $scrout.='&nbsp;'.
         '<font color="#800000" face="helvetica">Per Page</font>';          '<font color="#800000" face="helvetica">'.&mt('Per Page').'</font>';
     $scrout.="</td><td>Related<br />Words</td></tr>\n";      $scrout.="</td><td>".&mt('Related').'<br />'.&mt('Words')."</td></tr>\n";
     $scrout.=&searchphrasefield_with_related('title',   'title'   ,      $scrout.=&searchphrasefield_with_related('title',   'title'   ,
                                              $ENV{'form.title'});                                               $ENV{'form.title'});
     $scrout.=&searchphrasefield('author',  'author'  ,$ENV{'form.author'});      $scrout.=&searchphrasefield('author',  'author'  ,$ENV{'form.author'});
Line 1058  field heading. Line 1068  field heading.
 ###############################################  ###############################################
   
 sub fieldtitle {  sub fieldtitle {
     my $title = uc(shift());      my $title = uc(&mt(shift()));
     return '<font color="#800000" face="helvetica"><b>'.$title.      return '<font color="#800000" face="helvetica"><b>'.$title.
         ':&nbsp;</b></font>';          ':&nbsp;</b></font>';
 }  }
Line 1153  END Line 1163  END
     my $i = 1;      my $i = 1;
     foreach (qw/January February March April May June       foreach (qw/January February March April May June 
      July August September October November December /){       July August September October November December /){
  $month .="<option value=\"$i\">$_</option>\n";   $month .="<option value=\"$i\">".&mt($_)."</option>\n";
  $i++;   $i++;
     }      }
     $month.="</select>\n";      $month.="</select>\n";
Line 1241  sub selectbox { Line 1251  sub selectbox {
     foreach (@idlist) {      foreach (@idlist) {
         $selout.='<option value="'.$_.'"';          $selout.='<option value="'.$_.'"';
         if ($_ eq $default and !/^any$/) {          if ($_ eq $default and !/^any$/) {
     $selout.=' selected >'.&{$functionref}($_).'</option>';      $selout.=' selected >'.&mt(&{$functionref}($_)).'</option>';
  }   }
  elsif ($_ eq $default and /^$anyvalue$/) {   elsif ($_ eq $default and /^$anyvalue$/) {
     $selout.=' selected >'.$anytag.'</option>';      $selout.=' selected >'.&mt($anytag).'</option>';
  }   }
         else {$selout.='>'.&{$functionref}($_).'</option>';}          else {$selout.='>'.&mt(&{$functionref}($_)).'</option>';}
     }      }
     return $selout.'</select>'.(defined($title)?'</p>':' ');      return $selout.'</select>'.(defined($title)?'</p>':' ');
 }  }
Line 1841  sub ensure_db_and_table { Line 1851  sub ensure_db_and_table {
 sub print_sort_form {  sub print_sort_form {
     my ($r,$pretty_query_string) = @_;      my ($r,$pretty_query_string) = @_;
     ##      ##
     my %SortableFields =       my %SortableFields=&Apache::lonlocal::texthash( 
         (id        => 'Default',           id        => 'Default',
          title     => 'Title',           title     => 'Title',
          author    => 'Author',           author    => 'Author',
          subject   => 'Subject',           subject   => 'Subject',
Line 1854  sub print_sort_form { Line 1864  sub print_sort_form {
          copyright => 'Copyright',           copyright => 'Copyright',
          hostname  => 'Host',           hostname  => 'Host',
          creationdate     => 'Creation Date',           creationdate     => 'Creation Date',
          lastrevisiondate => 'Revision Date',           lastrevisiondate => 'Revision Date'
      );       );
     ##      ##
     my $table = $ENV{'form.table'};      my $table = $ENV{'form.table'};
Line 2108  END Line 2118  END
     if (@Lines > 2) {      if (@Lines > 2) {
         $pretty_string = join '<br \>',(@Lines[0..2],'....<br />');          $pretty_string = join '<br \>',(@Lines[0..2],'....<br />');
     }      }
     $r->print("Search: ".$pretty_string);      $r->print(&mt("Search").": ".$pretty_string);
     $r->rflush();      $r->rflush();
     #      #
     # Determine the servers we need to contact.      # Determine the servers we need to contact.
Line 2174  END Line 2184  END
         if (@Servers_to_contact) {          if (@Servers_to_contact) {
             # Contact one server              # Contact one server
             my $server = shift(@Servers_to_contact);              my $server = shift(@Servers_to_contact);
             &update_status($r,'contacting '.$server);              &update_status($r,&mt('contacting').' '.$server);
             my $reply=&Apache::lonnet::metadata_query($query,$customquery,              my $reply=&Apache::lonnet::metadata_query($query,$customquery,
                                                       $customshow,[$server]);                                                        $customshow,[$server]);
             ($server) = keys(%$reply);              ($server) = keys(%$reply);
Line 2186  END Line 2196  END
             # left to contact.                # left to contact.  
             if (scalar (keys(%Server_status))) {              if (scalar (keys(%Server_status))) {
                 &update_status($r,                  &update_status($r,
                                'waiting on '.(join(' ',keys(%Server_status))));                         &mt('waiting on').' '.(join(' ',keys(%Server_status))));
             }              }
             sleep(1)              sleep(1)
         }          }
Line 2203  END Line 2213  END
             $status=~/^([\.\w]+)$/;               $status=~/^([\.\w]+)$/; 
            my $datafile=$r->dir_config('lonDaemons').'/tmp/'.$1;             my $datafile=$r->dir_config('lonDaemons').'/tmp/'.$1;
             if (-e $datafile && ! -e "$datafile.end") {              if (-e $datafile && ! -e "$datafile.end") {
                 &update_status($r,'Receiving results from '.$server);                  &update_status($r,&mt('Receiving results from').' '.$server);
                 next;                  next;
             }              }
             last if ($connection->aborted());              last if ($connection->aborted());
             if (-e "$datafile.end") {              if (-e "$datafile.end") {
                 &update_status($r,'Reading results from '.$server);                  &update_status($r,&mt('Reading results from').' '.$server);
                 if (-z "$datafile") {                  if (-z "$datafile") {
                     delete($Server_status{$server});                      delete($Server_status{$server});
                     next;                      next;
Line 2263  END Line 2273  END
             &update_seconds($r,$time_remaining);              &update_seconds($r,$time_remaining);
         }          }
     }      }
     &update_status($r,'Search Complete'.$server);      &update_status($r,&mt('Search Complete').$server);
     &update_seconds($r,0);      &update_seconds($r,0);
     &Apache::lonmysql::disconnect_from_db();      &Apache::lonmysql::disconnect_from_db();
     # We have run out of time or run out of servers to talk to and      # We have run out of time or run out of servers to talk to and
Line 2408  sub display_results { Line 2418  sub display_results {
          );           );
     if ($total_results == 0) {      if ($total_results == 0) {
         $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="1">'.          $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="1">'.
                   '<h3>There are currently no results.</h3>'.                    '<h3>'.&mt('There are currently no results').'.</h3>'.
                   "</form></body></html>");                    "</form></body></html>");
         return;          return;
     } else {      } else {
Line 2439  sub display_results { Line 2449  sub display_results {
         $r->rflush();          $r->rflush();
     }      }
     if (@Results < 1) {      if (@Results < 1) {
         $r->print("There were no results matching your query");          $r->print(&mt("There were no results matching your query"));
     } else {      } else {
         $r->print          $r->print
             ('<center>'.              ('<center>'.
Line 2682  Checked for existance & 'edit' mode. Line 2692  Checked for existance & 'edit' mode.
   
 =item 'form.form'  =item 'form.form'
   
   Contains the name of the form that has the input fields to set
   
 =item 'form.element'  =item 'form.element'
   
   the name of the input field to put the URL into
   
   =item 'form.titleelement'
   
   the name of the input field to put the title into
   
 =back  =back
   
 =cut  =cut
Line 2720  SCRIPT Line 2738  SCRIPT
         } elsif ($ENV{'form.mode'} eq 'edit') {          } elsif ($ENV{'form.mode'} eq 'edit') {
             my $form = $ENV{'form.form'};              my $form = $ENV{'form.form'};
             my $element = $ENV{'form.element'};              my $element = $ENV{'form.element'};
               my $titleelement = $ENV{'form.titleelement'};
       my $changetitle;
       if (!$titleelement) {
    $changetitle='function changeTitle(val) {}';
       } else {
       $changetitle=<<END;
   function changeTitle(val) {
       if (parent.targetwin.document) {
           parent.targetwin.document.forms["$form"].elements["$titleelement"].value=val;
       } else {
    var url = 'forms[\"$form\"].elements[\"$titleelement\"].value';
           alert("Unable to transfer data to "+url);
       }
   }
   END
               }
   
             $result.=<<SCRIPT;              $result.=<<SCRIPT;
 <script type="text/javascript">  <script type="text/javascript">
 function select_data(title,url) {  function select_data(title,url) {
     changeURL(url);      changeURL(url);
       changeTitle(title);
     parent.close();      parent.close();
 }  }
 function changeTitle(val) {  $changetitle
 }  
 function changeURL(val) {  function changeURL(val) {
     if (parent.targetwin.document) {      if (parent.targetwin.document) {
         parent.targetwin.document.forms["$form"].elements["$element"].value=val;          parent.targetwin.document.forms["$form"].elements["$element"].value=val;

Removed from v.1.186  
changed lines
  Added in v.1.191


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