Diff for /loncom/interface/lonsearchcat.pm between versions 1.256 and 1.264

version 1.256, 2006/03/15 20:56:16 version 1.264, 2006/05/12 16:45:41
Line 116  sub handler { Line 116  sub handler {
     my $diropendb;    # The full path to the (temporary) search database file.      my $diropendb;    # The full path to the (temporary) search database file.
                       # This is set and used in &handler() and is also used in                         # This is set and used in &handler() and is also used in 
                       # &output_results().                        # &output_results().
     my $bodytag;  # LON-CAPA standard body tag, gotten from   
                   # &Apache::lonnet::bodytag.   
                   # No title, no table, just a <body> tag.  
   
     my $loaderror=&Apache::lonnet::overloaderror($r);      my $loaderror=&Apache::lonnet::overloaderror($r);
     if ($loaderror) { return $loaderror; }      if ($loaderror) { return $loaderror; }
Line 165  sub handler { Line 162  sub handler {
         ($env{'form.launch'} eq '1')) {          ($env{'form.launch'} eq '1')) {
         $env{'form.persistent_db_id'} = time;          $env{'form.persistent_db_id'} = time;
     }      }
     $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1);  
     my $persistent_db_file = "/home/httpd/perl/tmp/".      my $persistent_db_file = "/home/httpd/perl/tmp/".
         &Apache::lonnet::escape($domain).          &Apache::lonnet::escape($domain).
             '_'.&Apache::lonnet::escape($env{'user.name'}).              '_'.&Apache::lonnet::escape($env{'user.name'}).
Line 202  sub handler { Line 199  sub handler {
     'We were unable to retrieve data describing your search. '.      'We were unable to retrieve data describing your search. '.
     'This is a serious error and has been logged. '.      'This is a serious error and has been logged. '.
     'Please alert your LON-CAPA administrator.';      'Please alert your LON-CAPA administrator.';
  return &error_page($r,$msg);   &Apache::loncommon::simple_error_page($r,'Search Error',
         $msg);
    return OK;
             }              }
         }          }
     } else {      } else {
Line 223  sub handler { Line 222  sub handler {
             # This is a stupid error to give to the user.                # This is a stupid error to give to the user.  
             # It really tells them nothing.              # It really tells them nothing.
     my $msg = 'Unable to tie hash to db file.';      my $msg = 'Unable to tie hash to db file.';
     return &error_page($r,$msg);      &Apache::loncommon::simple_error_page($r,'Search Error',
     $msg);
       return OK;
  }   }
     }      }
     ##      ##
Line 364  END Line 365  END
     my $msg =       my $msg = 
  'Unable to create table in which to store search results. '.   'Unable to create table in which to store search results. '.
  'The search has been aborted.';   'The search has been aborted.';
     return &error_page($r,$msg);      &Apache::loncommon::simple_error_page($r,'Search Error',
     $msg);
       return OK;
         }          }
         delete($env{'form.launch'});          delete($env{'form.launch'});
         if (! &make_form_data_persistent($r,$persistent_db_file)) {          if (! &make_form_data_persistent($r,$persistent_db_file)) {
     my $msg=      my $msg=
  'Unable to properly store search information. '.   'Unable to properly store search information. '.
  'The search has been aborted.';   'The search has been aborted.';
             return &error_page($r,$msg);      &Apache::loncommon::simple_error_page($r,'Search Error',
     $msg);
       return OK;
  }   }
         ##          ##
         ## Print out the frames interface          ## Print out the frames interface
Line 383  END Line 388  END
     return OK;      return OK;
 }   } 
   
 sub error_page {  
     my ($r,$msg) = @_;  
     $r->print(&Apache::loncommon::start_page('Search Error').  
       &mt($msg).  
       &Apache::loncommon::end_page());  
     return OK;  
 }  
   
 #  #
 # The mechanism used to store values away and retrieve them does not  # The mechanism used to store values away and retrieve them does not
 # handle the case of missing environment variables being significant.  # handle the case of missing environment variables being significant.
Line 663  sub print_basic_search_form { Line 660  sub print_basic_search_form {
     my ($r,$closebutton,$hidden_fields) = @_;      my ($r,$closebutton,$hidden_fields) = @_;
     my $result = ($env{'form.catalogmode'} ne 'groupsearch');      my $result = ($env{'form.catalogmode'} ne 'groupsearch');
     my $bread_crumb =      my $bread_crumb =
         &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Search_Basic',          &Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Basic',
                                    undef,undef,      $env{'form.catalogmode'} ne 'groupsearch');
                                    $env{'form.catalogmode'} ne 'groupsearch');  
     my $scrout = &Apache::loncommon::start_page('Search').$bread_crumb;      my $scrout = &Apache::loncommon::start_page('Search').$bread_crumb;
     if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) {      if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) {
         # Define interface components          # Define interface components
Line 707  sub print_basic_search_form { Line 703  sub print_basic_search_form {
         }          }
         $scrout.='<table>'.          $scrout.='<table>'.
             '<tr><td align="center" valign="top">'.              '<tr><td align="center" valign="top">'.
             &Apache::lonhtmlcommon::textbox              &Apache::lonhtmlcommon::textbox('basicexp',
             ('basicexp',      $env{'form.basicexp'},50).
              &HTML::Entities::encode($env{'form.basicexp'},'<>&"'),50  
              ).  
              '<br />'.               '<br />'.
             '<font size="-1">'.&searchhelp().'</font>'.'</td>'.              '<font size="-1">'.&searchhelp().'</font>'.'</td>'.
             '<td><font size="-1">'.              '<td><font size="-1">'.
Line 797  Prints the advanced search form. Line 791  Prints the advanced search form.
 sub print_advanced_search_form{  sub print_advanced_search_form{
     my ($r,$closebutton,$hidden_fields) = @_;      my ($r,$closebutton,$hidden_fields) = @_;
     my $bread_crumb =       my $bread_crumb = 
         &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching',          &Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Advanced',
                                             'Search_Advanced',      $env{'form.catalogmode'} ne 'groupsearch');
                                             undef,undef,  
                                   $env{'form.catalogmode'} ne 'groupsearch');  
     my %lt=&Apache::lonlocal::texthash('srch' => 'Search',      my %lt=&Apache::lonlocal::texthash('srch' => 'Search',
        'reset' => 'Reset',         'reset' => 'Reset',
        'help' => 'Help');         'help' => 'Help');
Line 2065  a link to change the search query. Line 2057  a link to change the search query.
 ######################################################################  ######################################################################
 sub print_sort_form {  sub print_sort_form {
     my ($r,$pretty_query_string) = @_;      my ($r,$pretty_query_string) = @_;
     my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1).  
         &Apache::lonhtmlcommon::breadcrumbs  
         (undef,'Searching','Searching',undef,undef,  
          $env{'form.catalogmode'} ne 'groupsearch');  
   
     ##      ##
     my %SortableFields=&Apache::lonlocal::texthash(       my %SortableFields=&Apache::lonlocal::texthash( 
Line 2101  sub print_sort_form { Line 2089  sub print_sort_form {
         &Apache::lonnet::logthis(&Apache::lonmysql::get_error());          &Apache::lonnet::logthis(&Apache::lonmysql::get_error());
         return;          return;
     }      }
     my $result;      my $js =<<END;
     my $html     = &Apache::lonxml::xmlbegin();  <script type="text/javascript">
     my $head     = &Apache::lonxml::headtag('Results');  
     my $end_head = &Apache::loncommon::endheadtag();  
     $result.=<<END;  
 $html  
 $head  
 <script>  
     function change_sort() {      function change_sort() {
         var newloc = "/adm/searchcat?phase=results";          var newloc = "/adm/searchcat?phase=results";
         newloc += "&persistent_db_id=$env{'form.persistent_db_id'}";          newloc += "&persistent_db_id=$env{'form.persistent_db_id'}";
Line 2117  $head Line 2099  $head
         parent.resultsframe.location= newloc;          parent.resultsframe.location= newloc;
     }      }
 </script>  </script>
 $end_head  END
 $bodytag  
 <form name="statusform" action="" method="post">      my $start_page = &Apache::loncommon::start_page('Results',$js,
       {'only_body' => 1});
       my $breadcrumbs=
           &Apache::lonhtmlcommon::breadcrumbs('Searching','Searching',
       $env{'form.catalogmode'} ne 'groupsearch');
   
       my $result = <<END;
   $start_page
   $breadcrumbs
   <form name="statusform" action="" method="POST">
 <input type="hidden" name="Queue" value="" />  <input type="hidden" name="Queue" value="" />
 END  END
   
Line 2335  results into MySQL. Line 2326  results into MySQL.
 ######################################################################  ######################################################################
 sub run_search {  sub run_search {
     my ($r,$query,$customquery,$customshow,$serverlist,$pretty_string) = @_;      my ($r,$query,$customquery,$customshow,$serverlist,$pretty_string) = @_;
     my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1);  
     $bodytag.=&Apache::lonhtmlcommon::breadcrumbs  
         (undef,'Searching','Searching',undef,undef,  
          $env{'form.catalogmode'} ne 'groupsearch');  
     my $connection = $r->connection;      my $connection = $r->connection;
     #      #
     # Print run_search header      # Print run_search header
     #      #
     my $html = &Apache::lonxml::xmlbegin();      my $start_page = &Apache::loncommon::start_page('Search Status',undef,
     my $head = &Apache::loncommon::head('Search Status');      {'only_body' => 1});
       my $breadcrumbs =
    &Apache::lonhtmlcommon::breadcrumbs('Searching','Searching',
       $env{'form.catalogmode'} ne 'groupsearch');
     $r->print(<<END);      $r->print(<<END);
 $html  $start_page
 $head  $breadcrumbs
 $bodytag  
 <form name="statusform" action="" method="post">  <form name="statusform" action="" method="post">
 <input type="hidden" name="Queue" value="" />  <input type="hidden" name="Queue" value="" />
 END  END
Line 2998  the name of the input field to put the t Line 2988  the name of the input field to put the t
 ######################################################################  ######################################################################
 sub search_results_header {  sub search_results_header {
     my ($importbutton,$closebutton) = @_;      my ($importbutton,$closebutton) = @_;
     my $result =   
  &Apache::lonxml::xmlbegin().  
  &Apache::loncommon::headtag();  
   
       my $js;
     # output beginning of search page      # output beginning of search page
     # conditional output of script functions dependent on the mode in      # conditional output of script functions dependent on the mode in
     # which the search was invoked      # which the search was invoked
     if ($env{'form.catalogmode'} eq 'interactive'){      if ($env{'form.catalogmode'} eq 'interactive'){
  if (! exists($env{'form.mode'}) || $env{'form.mode'} ne 'edit') {   if (! exists($env{'form.mode'}) || $env{'form.mode'} ne 'edit') {
             $result.=<<SCRIPT;              $js.=<<SCRIPT;
 <script type="text/javascript">  <script type="text/javascript">
     function select_data(title,url) {      function select_data(title,url) {
  changeTitle(title);   changeTitle(title);
Line 3046  function changeTitle(val) { Line 3034  function changeTitle(val) {
 END  END
             }              }
   
             $result.=<<SCRIPT;              $js.=<<SCRIPT;
 <script type="text/javascript">  <script type="text/javascript">
 function select_data(title,url) {  function select_data(title,url) {
     changeURL(url);      changeURL(url);
Line 3066  function changeURL(val) { Line 3054  function changeURL(val) {
 SCRIPT  SCRIPT
         }          }
     }      }
     $result.=<<SCRIPT if $env{'form.catalogmode'} eq 'groupsearch';      $js.=<<SCRIPT if $env{'form.catalogmode'} eq 'groupsearch';
 <script type="text/javascript">  <script type="text/javascript">
     function queue(checkbox_num,val) {      function queue(checkbox_num,val) {
         if (document.forms.results.returnvalues.length != "undefined" &&          if (document.forms.results.returnvalues.length != "undefined" &&
Line 3092  SCRIPT Line 3080  SCRIPT
 </script>  </script>
 SCRIPT  SCRIPT
   
     my $end_head = &Apache::loncommon::endheadtag();      my $start_page  = &Apache::loncommon::start_page(undef,$js,
     my $bodytag  = &Apache::loncommon::bodytag(undef,undef,undef,1);       {'only_body' =>1});
     $result.=<<END;      my $result=<<END;
 $end_head  $start_page
 $bodytag  
 <form name="results" method="post" action="/adm/searchcat" >  <form name="results" method="post" action="/adm/searchcat" >
 <input type="hidden" name="Queue" value="" />  <input type="hidden" name="Queue" value="" />
 $importbutton  $importbutton
Line 3107  END Line 3094  END
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
 sub search_status_header {  sub search_status_header {
     my $bodytag = &Apache::loncommon::bodytag(undef,undef,undef,1);      my $start_page = &Apache::loncommon::start_page('Search Status',undef,
     my $html    = &Apache::lonxml::xmlbegin();      {'only_body' => 1});
     my $head    = &Apache::loncommon::head('Search Status');  
     return <<ENDSTATUS;      return <<ENDSTATUS;
 $html  $start_page
 $head  
 $bodytag  
 <h3>Search Status</h3>  <h3>Search Status</h3>
 Sending search request to LON-CAPA servers.<br />  Sending search request to LON-CAPA servers.<br />
 ENDSTATUS  ENDSTATUS
Line 3135  sub print_frames_interface { Line 3119  sub print_frames_interface {
         "&persistent_db_id=".$env{'form.persistent_db_id'};          "&persistent_db_id=".$env{'form.persistent_db_id'};
     my $run_search_link = $basic_link."&phase=run_search";      my $run_search_link = $basic_link."&phase=run_search";
     my $results_link = &results_link();      my $results_link = &results_link();
     my $html     = &Apache::lonxml::xmlbegin();      my $js = <<JS;
     my $head     = &Apache::loncommon::headtag('LON-CAPA Digital Library Search Results');  <script type="text/javascript">
     my $end_head = &Apache::loncommon::endheadtag();  
     my $result = <<"ENDFRAMES";  
 $html  
 $head  
 <script>  
 var targetwin = opener;  var targetwin = opener;
 var queue = '';  var queue = '';
 </script>  </script>
 $end_head  JS
 <frameset rows="150,*">  
       my $start_page =
           &Apache::loncommon::start_page('LON-CAPA Digital Library Search Results',
          $js,
          {'frameset'    => 1,
    'add_entries' => {
       'rows' => "150,*",},});
       my $end_page =
           &Apache::loncommon::end_page({'frameset' => 1});
   
       my $result = <<"ENDFRAMES";
   $start_page
     <frame name="statusframe"  src="$run_search_link">      <frame name="statusframe"  src="$run_search_link">
     <frame name="resultsframe" src="$results_link">      <frame name="resultsframe" src="$results_link">
 </frameset>  $end_page
 </html>  
 ENDFRAMES  ENDFRAMES
   
     $r->print($result);      $r->print($result);
Line 3621  $parms is extra information to include i Line 3610  $parms is extra information to include i
 ######################################################################  ######################################################################
 sub output_blank_field_error {  sub output_blank_field_error {
     my ($r,$closebutton,$parms,$hidden_fields)=@_;      my ($r,$closebutton,$parms,$hidden_fields)=@_;
     my $bodytag=&Apache::loncommon::bodytag('Search');  
     my $errormsg = &mt('You did not fill in enough information for the search to be started.  You need to fill in relevant fields on the search page in order for a query to be processed.');      my $errormsg = &mt('You did not fill in enough information for the search to be started.  You need to fill in relevant fields on the search page in order for a query to be processed.');
     my $revise = &mt('Revise Search Request');      my $revise = &mt('Revise Search Request');
     my $heading = &mt('Unactionable Search Queary');      my $heading = &mt('Unactionable Search Queary');

Removed from v.1.256  
changed lines
  Added in v.1.264


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