Diff for /loncom/interface/lonsearchcat.pm between versions 1.251 and 1.268

version 1.251, 2006/02/05 20:56:57 version 1.268, 2006/06/08 16:58:56
Line 77  use LONCAPA::lonmetadata(); Line 77  use LONCAPA::lonmetadata();
 use HTML::Entities();  use HTML::Entities();
 use Parse::RecDescent;  use Parse::RecDescent;
 use Apache::lonnavmaps;  use Apache::lonnavmaps;
   use Apache::lonindexer();
   use lib '/home/httpd/lib/perl/';
   use LONCAPA;
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
Line 93  my %persistent_db;   # gdbm hash which h Line 96  my %persistent_db;   # gdbm hash which h
 # The different view modes and associated functions  # The different view modes and associated functions
   
 my %Views = ("detailed" => \&detailed_citation_view,  my %Views = ("detailed" => \&detailed_citation_view,
                "detailedpreview" => \&detailed_citation_preview,
      "summary"  => \&summary_view,       "summary"  => \&summary_view,
                "summarypreview" => \&summary_preview,
      "fielded"  => \&fielded_format_view,       "fielded"  => \&fielded_format_view,
      "xml"      => \&xml_sgml_view,       "xml"      => \&xml_sgml_view,
      "compact"  => \&compact_view);       "compact"  => \&compact_view);
Line 113  sub handler { Line 118  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 153  sub handler { Line 155  sub handler {
     ##      ##
     my $domain  = $r->dir_config('lonDefDomain');      my $domain  = $r->dir_config('lonDefDomain');
     $diropendb= "/home/httpd/perl/tmp/".      $diropendb= "/home/httpd/perl/tmp/".
         "$env{'user.domain'}_$env{'user.name'}_searchcat.db";          "$env{'user.domain'}_$env{'user.name'}_sel_res.db";
     #      #
     # set the name of the persistent database      # set the name of the persistent database
     #          $env{'form.persistent_db_id'} can only have digits in it.      #          $env{'form.persistent_db_id'} can only have digits in it.
Line 162  sub handler { Line 164  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).          &escape($domain).
             '_'.&Apache::lonnet::escape($env{'user.name'}).              '_'.&escape($env{'user.name'}).
                 '_'.$env{'form.persistent_db_id'}.'_persistent_search.db';                  '_'.$env{'form.persistent_db_id'}.'_persistent_search.db';
     ##      ##
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
Line 195  sub handler { Line 197  sub handler {
                 &Apache::lonnet::logthis('lonsearchcat:'.                  &Apache::lonnet::logthis('lonsearchcat:'.
                                          'Unable to recover data from '.                                           'Unable to recover data from '.
                                          $persistent_db_file);                                           $persistent_db_file);
  my $html=&Apache::lonxml::xmlbegin();   my $msg =
  $r->print(<<END);      'We were unable to retrieve data describing your search. '.
 $html      'This is a serious error and has been logged. '.
 <head>      'Please alert your LON-CAPA administrator.';
 <title>LON-CAPA Search Error</title></head>   &Apache::loncommon::simple_error_page($r,'Search Error',
 $bodytag        $msg);
 We were unable to retrieve data describing your search.  This is a serious   return OK;
 error and has been logged.  Please alert your LON-CAPA administrator.  
 </body>  
 </html>  
 END  
                 return OK;  
             }              }
         }          }
     } else {      } else {
Line 218  END Line 215  END
     untie %groupsearch_db if (tied(%groupsearch_db));      untie %groupsearch_db if (tied(%groupsearch_db));
     if (($env{'form.cleargroupsort'} eq '1') ||       if (($env{'form.cleargroupsort'} eq '1') || 
         (($env{'form.launch'} eq '1') &&           (($env{'form.launch'} eq '1') && 
          ($env{'form.catalogmode'} eq 'groupsearch'))) {           ($env{'form.catalogmode'} eq 'import'))) {
  if (tie(%groupsearch_db,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {   if (tie(%groupsearch_db,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {
     &start_fresh_session();      &start_fresh_session();
     untie %groupsearch_db;      untie %groupsearch_db;
Line 226  END Line 223  END
  } else {   } else {
             # 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 $html=&Apache::lonxml::xmlbegin();      my $msg = 'Unable to tie hash to db file.';
     $r->print($html.'<head></head>'.$bodytag.      &Apache::loncommon::simple_error_page($r,'Search Error',
                       'Unable to tie hash to db file</body></html>');    $msg);
     return OK;      return OK;
  }   }
     }      }
Line 263  END Line 260  END
             $closebutton .="onClick='self.close()'";              $closebutton .="onClick='self.close()'";
         }          }
         $closebutton .=">\n";          $closebutton .=">\n";
     } elsif ($env{'form.catalogmode'} eq 'groupsearch') {      } elsif ($env{'form.catalogmode'} eq 'import') {
         $closebutton="<input type='button' name='close' value='CLOSE' ";          $closebutton="<input type='button' name='close' value='CLOSE' ";
         if ($env{'form.phase'} =~ /(results|run_search)/) {          if ($env{'form.phase'} =~ /(results|run_search)/) {
     $closebutton .="onClick='parent.close()'";      $closebutton .="onClick='parent.close()'";
Line 366  END Line 363  END
             &Apache::lonnet::logthis('lonsearchcat.pm: Unable to create '.              &Apache::lonnet::logthis('lonsearchcat.pm: Unable to create '.
                                      'needed table.  lonmysql error:'.                                       'needed table.  lonmysql error:'.
                                      $errorstring);                                       $errorstring);
     my $html=&Apache::lonxml::xmlbegin();  
             $r->print(<<END);      my $msg = 
 $html   'Unable to create table in which to store search results. '.
 <head>   'The search has been aborted.';
 <title>Search Error</title></head>      &Apache::loncommon::simple_error_page($r,'Search Error',
 $bodytag    $msg);
 Unable to create table in which to store search results.        return OK;
 The search has been aborted.  
 </body>  
 </html>  
 END  
             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 $html=&Apache::lonxml::xmlbegin();      my $msg=
     $r->print(<<END);   'Unable to properly store search information. '.
 $html   'The search has been aborted.';
 <head>      &Apache::loncommon::simple_error_page($r,'Search Error',
 <title>Search Error</title></head>    $msg);
 $bodytag      return OK;
 Unable to properly store search information.  The search has been aborted.   }
 </body>  
 </html>  
 END  
             return OK;  
         }  
         ##          ##
         ## Print out the frames interface          ## Print out the frames interface
         ##          ##
Line 464  sub make_symb { Line 451  sub make_symb {
   
 sub course_search {  sub course_search {
     my $r=shift;      my $r=shift;
     my $bodytag=&Apache::loncommon::bodytag('Course Search');  
     my $pretty_search_string = '<b>'.$env{'form.courseexp'}.'</b>';      my $pretty_search_string = '<b>'.$env{'form.courseexp'}.'</b>';
     my $search_string = $env{'form.courseexp'};      my $search_string = $env{'form.courseexp'};
     my @New_Words;      my @New_Words;
Line 481  sub course_search { Line 467  sub course_search {
     my $discuss=$env{'form.crsdiscuss'};      my $discuss=$env{'form.crsdiscuss'};
     my @allwords=($search_string,@New_Words);      my @allwords=($search_string,@New_Words);
     $totalfound=0;      $totalfound=0;
     my $html=&Apache::lonxml::xmlbegin();      $r->print(&Apache::loncommon::start_page('Course Search').
     $r->print($html.'<head><title>LON-CAPA Course Search</title></head>'.        '<hr /><center><font size="+2" face="arial">'.
       $bodytag.'<hr /><center><font size="+2" face="arial">'.$pretty_search_string.'</font></center><hr /><b>'.&mt('Course content').':</b><br />');        $pretty_search_string.'</font></center>'.
         '<hr /><b>'.&mt('Course content').':</b><br />');
     $r->rflush();      $r->rflush();
 # ======================================================= Go through the course  # ======================================================= Go through the course
     my $c=$r->connection;      my $c=$r->connection;
Line 566  sub course_search { Line 553  sub course_search {
                 } else {                  } else {
                     $url .= '?symb=';                      $url .= '?symb=';
                 }                  }
                 $url .= &Apache::lonnet::escape($resource->symb());                  $url .= &escape($resource->symb());
                 my $title = $resource->compTitle();                  my $title = $resource->compTitle();
                 $r->print('<br /><a href="'.$url.'" target="cat">'.                  $r->print('<br /><a href="'.$url.'" target="cat">'.
                      ($title?$title:$url).'</a>&nbsp;&nbsp;-&nbsp;'.$disctype.'<br />');                       ($title?$title:$url).'</a>&nbsp;&nbsp;-&nbsp;'.$disctype.'<br />');
Line 581  sub course_search { Line 568  sub course_search {
     }      }
     
 # =================================================== Done going through course  # =================================================== Done going through course
     $r->print('</body></html>');      $r->print(&Apache::loncommon::end_page());
 }  }
   
 # =============================== This pulls up a resource and its dependencies  # =============================== This pulls up a resource and its dependencies
Line 602  sub checkonthis { Line 589  sub checkonthis {
     my ($extension)=($url=~/\.(\w+)$/);      my ($extension)=($url=~/\.(\w+)$/);
     if (&Apache::loncommon::fileembstyle($extension) eq 'ssi' &&      if (&Apache::loncommon::fileembstyle($extension) eq 'ssi' &&
  ($url) && ($fulltext)) {   ($url) && ($fulltext)) {
  $result.=&Apache::lonnet::ssi_body($url.'?symb='.&Apache::lonnet::escape($symb));   $result.=&Apache::lonnet::ssi_body($url.'?symb='.&escape($symb));
     }      }
     $result=~s/\s+/ /gs;      $result=~s/\s+/ /gs;
     my $applies = 0;      my $applies = 0;
Line 618  sub checkonthis { Line 605  sub checkonthis {
    $href=&Apache::lonenc::encrypted($href)     $href=&Apache::lonenc::encrypted($href)
        .'?symb='.&Apache::lonenc::encrypted($symb);         .'?symb='.&Apache::lonenc::encrypted($symb);
        } else {         } else {
    $href.='?symb='.&Apache::lonnet::escape($symb);     $href.='?symb='.&escape($symb);
        }         }
        $r->print('<a href="'.$href.'" target="cat">'.($title?$title:$url).         $r->print('<a href="'.$href.'" target="cat">'.($title?$title:$url).
  '</a><br />');   '</a><br />');
Line 657  sub untiehash { Line 644  sub untiehash {
   
 } # End of course search scoping  } # End of course search scoping
   
 sub search_html_header {  
     my $html=&Apache::lonxml::xmlbegin();  
     my $Str = <<ENDHEADER;  
 $html  
 <head>  
 <title>The LearningOnline Network with CAPA</title>  
 </head>  
 ENDHEADER  
     return $Str;  
 }  
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
Line 683  Prints the form for the basic search.  S Line 660  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 $result = ($env{'form.catalogmode'} ne 'groupsearch');      my $result = ($env{'form.catalogmode'} ne 'import');
     my $bodytag=&Apache::loncommon::bodytag('Search').      my $bread_crumb =
         &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Search_Basic',          &Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Basic',
                                    undef,undef,      $env{'form.catalogmode'} ne 'import');
                                    $env{'form.catalogmode'} ne 'groupsearch');      my $scrout = &Apache::loncommon::start_page('Search').$bread_crumb;
     my $scrout = &search_html_header().$bodytag;  
     if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) {      if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) {
         # Define interface components          # Define interface components
         my $userelatedwords= '<label>'.          my $userelatedwords= '<label>'.
Line 729  sub print_basic_search_form { Line 705  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 799  ENDCOURSESEARCH Line 773  ENDCOURSESEARCH
 </form>  </form>
 ENDENDCOURSE  ENDENDCOURSE
     }      }
     $scrout.=(<<ENDDOCUMENT);      $scrout .= &Apache::loncommon::end_page();
 </body>  
 </html>  
 ENDDOCUMENT  
     $r->print($scrout);      $r->print($scrout);
     return;      return;
 }  }
Line 821  Prints the advanced search form. Line 792  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 $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search').      my $bread_crumb = 
         &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching',          &Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Advanced',
                                             'Search_Advanced',      $env{'form.catalogmode'} ne 'import');
                                             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 834  sub print_advanced_search_form{ Line 803  sub print_advanced_search_form{
 <input type="reset" name="reset" value='$lt{"reset"}' />  <input type="reset" name="reset" value='$lt{"reset"}' />
 $closebutton  $closebutton
 END  END
     my $scrout=&search_html_header();      my $scrout= &Apache::loncommon::start_page('Advanced Catalog Search');
     $scrout .= <<"ENDHEADER";      $scrout .= <<"ENDHEADER";
 $bodytag  $bread_crumb
 <form method="post" action="/adm/searchcat" name="advsearch">  <form method="post" action="/adm/searchcat" name="advsearch">
 <p>  <p>
 $advanced_buttons  $advanced_buttons
Line 1031  ENDHEADER Line 1000  ENDHEADER
     $scrout.=<<ENDDOCUMENT;      $scrout.=<<ENDDOCUMENT;
 $advanced_buttons  $advanced_buttons
 </form>  </form>
 </body>  
 </html>  
 ENDDOCUMENT  ENDDOCUMENT
       $scrout .= &Apache::loncommon::end_page();
     $r->print($scrout);      $r->print($scrout);
     return;      return;
 }  }
Line 1080  sub viewoptiontext { Line 1048  sub viewoptiontext {
          'xml' => 'XML/SGML',           'xml' => 'XML/SGML',
          'compact' => 'Compact View',           'compact' => 'Compact View',
          'fielded' => 'Fielded Format',           'fielded' => 'Fielded Format',
          'summary' => 'Summary View');           'summary' => 'Summary View',
            'summarypreview' => 'Summary Preview',
            'detailedpreview' => 'Detailed Citation Preview');
     return $desc{$code};      return $desc{$code};
 }  }
   
Line 1179  sub get_persistent_form_data { Line 1149  sub get_persistent_form_data {
         # End kludge (hopefully)          # End kludge (hopefully)
         next if (exists($env{$name}));          next if (exists($env{$name}));
         my @values = map {           my @values = map { 
             &Apache::lonnet::unescape($_);              &unescape($_);
         } split(',',$persistent_db{$name});          } split(',',$persistent_db{$name});
         next if (@values <1);          next if (@values <1);
         if ($arrays_allowed{$name}) {          if ($arrays_allowed{$name}) {
Line 1225  sub get_persistent_data { Line 1195  sub get_persistent_data {
             next;              next;
         }          }
         my @values = map {           my @values = map { 
             &Apache::lonnet::unescape($_);              &unescape($_);
         } split(',',$persistent_db{$name});          } split(',',$persistent_db{$name});
         if (@values <= 1) {          if (@values <= 1) {
             push @Values,$values[0];              push @Values,$values[0];
Line 1262  sub make_persistent { Line 1232  sub make_persistent {
     foreach my $name (keys(%save)) {      foreach my $name (keys(%save)) {
         my @values = (ref($save{$name}) ? @{$save{$name}} : ($save{$name}));          my @values = (ref($save{$name}) ? @{$save{$name}} : ($save{$name}));
         # We handle array references, but not recursively.          # We handle array references, but not recursively.
         my $store = join(',', map { &Apache::lonnet::escape($_); } @values );          my $store = join(',', map { &escape($_); } @values );
         $persistent_db{$name} = $store;          $persistent_db{$name} = $store;
     }      }
     untie(%persistent_db);      untie(%persistent_db);
Line 1345  sub parse_advanced_search { Line 1315  sub parse_advanced_search {
     foreach ('mode','form','element') {      foreach ('mode','form','element') {
  # is this required?  Hmmm.   # is this required?  Hmmm.
  next if (! exists($env{'form.'.$_}));   next if (! exists($env{'form.'.$_}));
  $env{'form.'.$_}=&Apache::lonnet::unescape($env{'form.'.$_});   $env{'form.'.$_}=&unescape($env{'form.'.$_});
  $env{'form.'.$_}=~s/[^\w\/\s\(\)\=\-\"\']//g;   $env{'form.'.$_}=~s/[^\w\/\s\(\)\=\-\"\']//g;
     }      }
     # Preprocess the category form element.      # Preprocess the category form element.
Line 1540  sub parse_advanced_search { Line 1510  sub parse_advanced_search {
     ##      ##
     ## Deal with restrictions to given domains      ## Deal with restrictions to given domains
     ##       ## 
     my ($libraries_to_query,$pretty_domains_string,$domain_sql_restriction) =       my ($libraries_to_query,$pretty_domains_string) = &parse_domain_restrictions();
         &parse_domain_restrictions();      if ($pretty_domains_string) {
     if ((defined($domain_sql_restriction)) && ($domain_sql_restriction ne '')) {  
        push(@queries,$domain_sql_restriction);  
        $pretty_search_string .= $pretty_domains_string."<br />\n";         $pretty_search_string .= $pretty_domains_string."<br />\n";
     }      }
     #      #
Line 1568  sub parse_domain_restrictions { Line 1536  sub parse_domain_restrictions {
     #      #
     my %domain_hash = ();      my %domain_hash = ();
     my $pretty_domains_string;      my $pretty_domains_string;
     my $domain_sql_restriction;  
     foreach (@allowed_domains) {      foreach (@allowed_domains) {
         $domain_hash{$_}++;          $domain_hash{$_}++;
     }      }
     if ($domain_hash{'any'}) {      if ($domain_hash{'any'}) {
         $pretty_domains_string = "In all LON-CAPA domains.";          $pretty_domains_string = "In all LON-CAPA domains.";
         $domain_sql_restriction = undef;  
     } else {      } else {
         if (@allowed_domains > 1) {          if (@allowed_domains > 1) {
             $pretty_domains_string = "In LON-CAPA domains:";              $pretty_domains_string = "In LON-CAPA domains:";
         } else {          } else {
             $pretty_domains_string = "In LON-CAPA domain ";              $pretty_domains_string = "In LON-CAPA domain ";
         }          }
         $domain_sql_restriction =   
             '(domain="'.join('" OR domain="',@allowed_domains).'")';  
         foreach (sort @allowed_domains) {          foreach (sort @allowed_domains) {
             $pretty_domains_string .= "<b>".$_."</b> ";              $pretty_domains_string .= "<b>".$_."</b> ";
         }          }
Line 1593  sub parse_domain_restrictions { Line 1557  sub parse_domain_restrictions {
         }          }
     }      }
     return ($libraries_to_query,      return ($libraries_to_query,
             $pretty_domains_string,              $pretty_domains_string);
             $domain_sql_restriction);  
 }  }
   
 ######################################################################  ######################################################################
Line 1620  sub parse_basic_search { Line 1583  sub parse_basic_search {
     foreach ('mode','form','element') {      foreach ('mode','form','element') {
  # is this required?  Hmmm.   # is this required?  Hmmm.
  next unless (exists($env{"form.$_"}));   next unless (exists($env{"form.$_"}));
  $env{"form.$_"}=&Apache::lonnet::unescape($env{"form.$_"});   $env{"form.$_"}=&unescape($env{"form.$_"});
  $env{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g;   $env{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g;
     }      }
     my ($libraries_to_query,$pretty_domains_string,$domain_sql_restriction) =       my ($libraries_to_query,$pretty_domains_string) = &parse_domain_restrictions();
         &parse_domain_restrictions();  
     #      #
     # Check to see if enough of a query is filled in      # Check to see if enough of a query is filled in
     my $search_string = $env{'form.basicexp'};      my $search_string = $env{'form.basicexp'};
Line 1647  sub parse_basic_search { Line 1609  sub parse_basic_search {
         return;          return;
     }      }
     push(@Queries,$SQLQuery);      push(@Queries,$SQLQuery);
     if (defined($domain_sql_restriction) && $domain_sql_restriction ne '') {  
         push(@Queries,$domain_sql_restriction);  
     }  
     #foreach my $q (@Queries) {      #foreach my $q (@Queries) {
     #    &Apache::lonnet::logthis('    '.$q);      #    &Apache::lonnet::logthis('    '.$q);
     #}      #}
Line 2052  sub ensure_db_and_table { Line 2011  sub ensure_db_and_table {
     if (! defined($table) || $table eq '' || $table =~ /\D/ ) {      if (! defined($table) || $table eq '' || $table =~ /\D/ ) {
         $r->print("Unable to retrieve search results.  ".          $r->print("Unable to retrieve search results.  ".
                   "Unable to determine the table results were stored in.  ".                    "Unable to determine the table results were stored in.  ".
                   "</body></html>");    &Apache::loncommon::end_page());
         return undef;          return undef;
     }      }
     ##      ##
Line 2061  sub ensure_db_and_table { Line 2020  sub ensure_db_and_table {
     my $connection_result = &Apache::lonmysql::connect_to_db();      my $connection_result = &Apache::lonmysql::connect_to_db();
     if (!defined($connection_result)) {      if (!defined($connection_result)) {
         $r->print("Unable to connect to the MySQL database where your results".          $r->print("Unable to connect to the MySQL database where your results".
                   " are stored. </body></html>");                    " are stored.".
     &Apache::loncommon::end_page());
         &Apache::lonnet::logthis("lonsearchcat: unable to get lonmysql to".          &Apache::lonnet::logthis("lonsearchcat: unable to get lonmysql to".
                                  " connect to database.");                                   " connect to database.");
         &Apache::lonnet::logthis(&Apache::lonmysql::get_error());          &Apache::lonnet::logthis(&Apache::lonmysql::get_error());
Line 2069  sub ensure_db_and_table { Line 2029  sub ensure_db_and_table {
     }      }
     my $table_check = &Apache::lonmysql::check_table($table);      my $table_check = &Apache::lonmysql::check_table($table);
     if (! defined($table_check)) {      if (! defined($table_check)) {
         $r->print("A MySQL error has occurred.</form></body></html>");          $r->print("A MySQL error has occurred.</form>".
     &Apache::loncommon::end_page());
         &Apache::lonnet::logthis("lonmysql was unable to determine the status".          &Apache::lonnet::logthis("lonmysql was unable to determine the status".
                                  " of table ".$table);                                   " of table ".$table);
         return undef;          return undef;
Line 2098  a link to change the search query. Line 2059  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 2127  sub print_sort_form { Line 2084  sub print_sort_form {
     ##      ##
     my $total_results = &Apache::lonmysql::number_of_rows($table);      my $total_results = &Apache::lonmysql::number_of_rows($table);
     if (! defined($total_results)) {      if (! defined($total_results)) {
         $r->print("A MySQL error has occurred.</form></body></html>");          $r->print("A MySQL error has occurred.</form>".
     &Apache::loncommon::end_page());
         &Apache::lonnet::logthis("lonmysql was unable to determine the number".          &Apache::lonnet::logthis("lonmysql was unable to determine the number".
                                  " of rows in table ".$table);                                   " of rows in table ".$table);
         &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">
     $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 2147  $html Line 2101  $html
         parent.resultsframe.location= newloc;          parent.resultsframe.location= newloc;
     }      }
 </script>  </script>
 <title>Results</title>  END
 </head>  
 $bodytag      my $start_page = &Apache::loncommon::start_page('Results',$js,
 <form name="statusform" action="" method="post">      {'only_body' => 1});
       my $breadcrumbs=
           &Apache::lonhtmlcommon::breadcrumbs('Searching','Searching',
       $env{'form.catalogmode'} ne 'import');
   
       my $result = <<END;
   $start_page
   $breadcrumbs
   <form name="statusform" action="" method="post" target="_top">
   <input type="hidden" name="catalogmode" value="import" />
 <input type="hidden" name="Queue" value="" />  <input type="hidden" name="Queue" value="" />
 END  END
   
Line 2173  There are $total_results matches to your Line 2136  There are $total_results matches to your
 Search:$pretty_query_string  Search:$pretty_query_string
 </p>  </p>
 </form>  </form>
 </body>  
 </html>  
 END  END
     $r->print($result);      $r->print($result.&Apache::loncommon::end_page());
     return;      return;
 }  }
   
Line 2368  results into MySQL. Line 2329  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,
       {'only_body' => 1});
       my $breadcrumbs =
    &Apache::lonhtmlcommon::breadcrumbs('Searching','Searching',
       $env{'form.catalogmode'} ne 'import');
     $r->print(<<END);      $r->print(<<END);
 $html  $start_page
 <head>  $breadcrumbs
 <title>Search Status</title></head>  
 $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 2416  END Line 2376  END
     my $table =$env{'form.table'};      my $table =$env{'form.table'};
     if (! defined($table) || $table eq '' || $table =~ /\D/ ) {      if (! defined($table) || $table eq '' || $table =~ /\D/ ) {
         $r->print("Unable to determine table id to store search results in.".          $r->print("Unable to determine table id to store search results in.".
                   "The search has been aborted.</body></html>");                    "The search has been aborted.".
     &Apache::loncommon::end_page());
         return;          return;
     }      }
     my $table_status = &Apache::lonmysql::check_table($table);      my $table_status = &Apache::lonmysql::check_table($table);
     if (! defined($table_status)) {      if (! defined($table_status)) {
         $r->print("Unable to determine status of table.</body></html>");          $r->print("Unable to determine status of table.".
     &Apache::loncommon::end_page());
         &Apache::lonnet::logthis("Bogus table id of $table for ".          &Apache::lonnet::logthis("Bogus table id of $table for ".
                                  "$env{'user.name'} @ $env{'user.domain'}");                                   "$env{'user.name'} @ $env{'user.domain'}");
         &Apache::lonnet::logthis("lonmysql error = ".          &Apache::lonnet::logthis("lonmysql error = ".
Line 2435  END Line 2397  END
                                  &Apache::lonmysql::get_debug());                                   &Apache::lonmysql::get_debug());
         &Apache::lonnet::logthis('table status = "'.$table_status.'"');          &Apache::lonnet::logthis('table status = "'.$table_status.'"');
         $r->print("The table id,$table, we tried to use is invalid.".          $r->print("The table id,$table, we tried to use is invalid.".
                   "The search has been aborted.</body></html>");                    "The search has been aborted.".
     &Apache::loncommon::end_page());
         return;          return;
     }      }
     ##      ##
Line 2564  END Line 2527  END
     # 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
     # results to get, so let the client know the top frame needs to be      # results to get, so let the client know the top frame needs to be
     # loaded from /adm/searchcat      # loaded from /adm/searchcat
     $r->print("</body></html>");      $r->print(&Apache::loncommon::end_page());
 #    if ($env{'form.catalogmode'} ne 'groupsearch') {  #    if ($env{'form.catalogmode'} ne 'import') {
         $r->print("<script>".          $r->print("<script>".
                       "window.location='/adm/searchcat?".                        "window.location='/adm/searchcat?".
                       "phase=sort&".                        "phase=sort&".
Line 2632  sub display_results { Line 2595  sub display_results {
     }      }
     ##      ##
     ## $checkbox_num is a count of the number of checkboxes output on the       ## $checkbox_num is a count of the number of checkboxes output on the 
     ## page this is used only during catalogmode=groupsearch.      ## page this is used only during catalogmode=import.
     my $checkbox_num = 0;      my $checkbox_num = 0;
     ##      ##
     ## Get the catalog controls setup      ## Get the catalog controls setup
     ##      ##
     my $action = "/adm/searchcat?phase=results";      my $action = "/adm/searchcat?phase=results";
     ##      ##
     ## Deal with groupsearch by opening the groupsearch db file.      ## Deal with import by opening the import db file.
     if ($env{'form.catalogmode'} eq 'groupsearch') {      if ($env{'form.catalogmode'} eq 'import') {
         if (! tie(%groupsearch_db,'GDBM_File',$diropendb,          if (! tie(%groupsearch_db,'GDBM_File',$diropendb,
                   &GDBM_WRCREAT(),0640)) {                    &GDBM_WRCREAT(),0640)) {
             $r->print('Unable to store import results.</form></body></html>');              $r->print('Unable to store import results.</form>'.
         &Apache::loncommon::end_page());
             $r->rflush();              $r->rflush();
             return;              return;
         }           } 
Line 2656  sub display_results { Line 2620  sub display_results {
     ## Get the number of results       ## Get the number of results 
     my $total_results = &Apache::lonmysql::number_of_rows($table);      my $total_results = &Apache::lonmysql::number_of_rows($table);
     if (! defined($total_results)) {      if (! defined($total_results)) {
         $r->print("A MySQL error has occurred.</form></body></html>");          $r->print("A MySQL error has occurred.</form>".
     &Apache::loncommon::end_page());
         &Apache::lonnet::logthis("lonmysql was unable to determine the number".          &Apache::lonnet::logthis("lonmysql was unable to determine the number".
                                  " of rows in table ".$table);                                   " of rows in table ".$table);
         &Apache::lonnet::logthis(&Apache::lonmysql::get_error());          &Apache::lonnet::logthis(&Apache::lonmysql::get_error());
Line 2763  sub display_results { Line 2728  sub display_results {
          &viewoptions().'</td></tr></table>'           &viewoptions().'</td></tr></table>'
          );           );
     if ($total_results == 0) {      if ($total_results == 0) {
         $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2">'.          $r->print('<meta HTTP-EQUIV="Refresh" CONTENT="2" />'.
                   '<h3>'.&mt('There are currently no results').'.</h3>'.                    '<h3>'.&mt('There are currently no results').'.</h3>'.
                   "</form></body></html>");                    "</form>".
     &Apache::loncommon::end_page());
         return;          return;
     } else {      } else {
         $r->print('<center>'.          $r->print('<center>'.
Line 2828  sub display_results { Line 2794  sub display_results {
              ."</center>\n"               ."</center>\n"
              );               );
     }      }
     $r->print("</form></body></html>");      $r->print("</form>".&Apache::loncommon::end_page());
     $r->rflush();      $r->rflush();
     untie %groupsearch_db if (tied(%groupsearch_db));      untie %groupsearch_db if (tied(%groupsearch_db));
     return;      return;
Line 2860  onClick="javascript:select_data('$title' Line 2826  onClick="javascript:select_data('$title'
 </font>  </font>
 END  END
         }          }
     } elsif ($env{'form.catalogmode'} eq 'groupsearch') {      } elsif ($env{'form.catalogmode'} eq 'import') {
         $groupsearch_db{"pre_${fnum}_link"}=$url;          $groupsearch_db{"pre_${fnum}_link"}=$url;
         $groupsearch_db{"pre_${fnum}_title"}=$title;          $groupsearch_db{"pre_${fnum}_title"}=$title;
         $output.=<<END;          $output.=<<END;
Line 2892  sub parse_row { Line 2858  sub parse_row {
         &set_up_table_structure();          &set_up_table_structure();
     }      }
     for (my $i=0;$i<=$#Row;$i++) {      for (my $i=0;$i<=$#Row;$i++) {
         $Fields{$Datatypes[$i]->{'name'}}=&Apache::lonnet::unescape($Row[$i]);          $Fields{$Datatypes[$i]->{'name'}}=&unescape($Row[$i]);
     }      }
     $Fields{'language'} =       $Fields{'language'} = 
         &Apache::loncommon::languagedescription($Fields{'language'});          &Apache::loncommon::languagedescription($Fields{'language'});
Line 2929  sub parse_raw_result { Line 2895  sub parse_raw_result {
     # conclude from self to others regarding fields      # conclude from self to others regarding fields
     my %Fields=&LONCAPA::lonmetadata::metadata_col_to_hash      my %Fields=&LONCAPA::lonmetadata::metadata_col_to_hash
         (map {          (map {
             &Apache::lonnet::unescape($_);              &unescape($_);
         } (split(/\,/,$result)) );          } (split(/\,/,$result)) );
     return %Fields;      return %Fields;
 }  }
Line 2967  sub handle_custom_fields { Line 2933  sub handle_custom_fields {
         if ($result=~/^(custom\=.*)$/) { # grab all custom metadata          if ($result=~/^(custom\=.*)$/) { # grab all custom metadata
             my $tmp=$result;              my $tmp=$result;
             $tmp=~s/^custom\=//;              $tmp=~s/^custom\=//;
             my ($k,$v)=map {&Apache::lonnet::unescape($_);              my ($k,$v)=map {&unescape($_);
                         } split(/\,/,$tmp);                          } split(/\,/,$tmp);
             $customhash{$k}=$v;              $customhash{$k}=$v;
         }          }
Line 2999  The following environment variables are Line 2965  The following environment variables are
   
 =item 'form.catalogmode'   =item 'form.catalogmode' 
   
 Checked for 'interactive' and 'groupsearch'.  Checked for 'interactive' and 'import'.
   
 =item 'form.mode'  =item 'form.mode'
   
Line 3025  the name of the input field to put the t Line 2991  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 $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1);  
     my $result = '';      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 3071  function changeTitle(val) { Line 3037  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 3091  function changeURL(val) { Line 3057  function changeURL(val) {
 SCRIPT  SCRIPT
         }          }
     }      }
     $result.=<<SCRIPT if $env{'form.catalogmode'} eq 'groupsearch';      $js.=<<SCRIPT if $env{'form.catalogmode'} eq 'import';
 <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 3111  SCRIPT Line 3077  SCRIPT
     }      }
     function select_group() {      function select_group() {
  parent.window.location=   parent.window.location=
     "/adm/groupsort?mode=$env{'form.mode'}&catalogmode=groupsearch&acts="+      "/adm/groupsort?mode=$env{'form.mode'}&catalogmode=import&acts="+
     parent.statusframe.document.forms.statusform.elements.Queue.value;      parent.statusframe.document.forms.statusform.elements.Queue.value;
     }      }
 </script>  </script>
 SCRIPT  SCRIPT
     $result.=<<END;  
 </head>      my $start_page  = &Apache::loncommon::start_page(undef,$js,
 $bodytag       {'only_body' =>1});
 <form name="results" method="post" action="/adm/searchcat" >      my $result=<<END;
 <input type="hidden" name="Queue" value="" />  $start_page
   <form name="results" method="post" action="/adm/searchcat">
 $importbutton  $importbutton
 END  END
     return $result;      return $result;
Line 3129  END Line 3096  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});
     return <<ENDSTATUS;      return <<ENDSTATUS;
 $html  $start_page
 <head>  
 <title>Search Status</title></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 3157  sub print_frames_interface { Line 3121  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 $result = <<"ENDFRAMES";  <script type="text/javascript">
 $html  
 <head>  
 <script>  
 var targetwin = opener;  var targetwin = opener;
 var queue = '';  var queue = '';
 </script>  </script>
 <title>LON-CAPA Digital Library Search Results</title>  JS
 </head>  
 <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 3241  sub detailed_citation_view { Line 3211  sub detailed_citation_view {
     my $jumpurl=$values{'url'};      my $jumpurl=$values{'url'};
     $jumpurl=~s/^\/ext\//http\:\/\//;      $jumpurl=~s/^\/ext\//http\:\/\//;
     $result .= '<b>'.$prefix.      $result .= '<b>'.$prefix.
         '<img src="'.&Apache::loncommon::icon($values{'url'}).' " />'.'&nbsp;'.          '<img src="'.&Apache::loncommon::icon($values{'url'}).'" />'.'&nbsp;'.
         '<a href="'.$jumpurl.'" '.          '<a href="'.$jumpurl.'" '.
         'target="search_preview">'.$values{'title'}."</a></b>\n";          'target="search_preview">'.$values{'title'}."</a></b>\n";
     $result .= "<p>\n";      $result .= "<p>\n";
Line 3307  sub detailed_citation_view { Line 3277  sub detailed_citation_view {
         next if (! exists($values{$field->{'name'}}) ||          next if (! exists($values{$field->{'name'}}) ||
                  $values{$field->{'name'}} eq '');                   $values{$field->{'name'}} eq '');
         if (exists($field->{'type'}) && $field->{'type'} eq 'list') {          if (exists($field->{'type'}) && $field->{'type'} eq 'list') {
             $result .= '<b>'.&mt($field->{'translate'}).'</b><ul>';              $result .= '<b>'.&mt($field->{'translate'}).'</b>';
             foreach my $item (split(',',$values{$field->{'name'}})){              foreach my $item (split(',',$values{$field->{'name'}})){
                 $result .= '<li>'.                  $result .= 
                     '<a target="search_preview" '.    &Apache::lonhtmlcommon::crumbs($item,
                     'href="'.$jumpurl.'">'.$item.'</a></li>';    (($env{'form.catalogmode'} eq 'import')?'_top':'preview'),
     '/res',
     (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),1);
             }              }
             $result .= '</ul>';  
         } elsif (exists($field->{'format'}) && $field->{'format'} ne ''){          } elsif (exists($field->{'format'}) && $field->{'format'} ne ''){
             $result.= &mt($field->{'translate'},              $result.= &mt($field->{'translate'},
                           sprintf($field->{'format'},                            sprintf($field->{'format'},
                                   $values{$field->{'name'}}))."<br />\n";                                    $values{$field->{'name'}}))."<br />\n";
         } else {          } else {
             if ($field->{'special'} eq 'url link') {              if ($field->{'special'} eq 'url link') {
                 $result.=                   $result.=
                      &mt($field->{'translate'},    &Apache::lonhtmlcommon::crumbs($jumpurl,
                          '<a href="'.$jumpurl.'" '.    (($env{'form.catalogmode'} eq 'import')?'_top':'preview'),
                          'target="search_preview">'.    '',
                          $values{$field->{'name'}}.    (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),1);
                          '</a>');  
             } else {              } else {
                 $result.= &mt($field->{'translate'},                  $result.= &mt($field->{'translate'},
                               $values{$field->{'name'}});                                $values{$field->{'name'}});
Line 3344  sub detailed_citation_view { Line 3314  sub detailed_citation_view {
     return $result;      return $result;
 }  }
   
   sub detailed_citation_preview {
       my ($prefix,%values)=@_;
       return '<table><tr><td>'.
              &detailed_citation_view($prefix,%values).
              '</td><td>'.
              &Apache::lonindexer::showpreview($values{'url'}).
              '</td></tr></table><hr />';
   }
   
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
Line 3372  sub summary_view { Line 3352  sub summary_view {
     }      }
     my $jumpurl=$values{'url'};      my $jumpurl=$values{'url'};
     $jumpurl=~s/^\/ext\//http\:\/\//;      $jumpurl=~s/^\/ext\//http\:\/\//;
       my $link=&Apache::lonhtmlcommon::crumbs($jumpurl,
     (($env{'form.catalogmode'} eq 'import')?'_top':'preview'),
     '',
     (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),1);
   
     $result.=<<END;      $result.=<<END;
 <a href="$jumpurl"   <a href="$jumpurl" 
    target='search_preview'>$values{'title'}</a><br />     target='search_preview'>$values{'title'}</a>$link
 $values{'author'}, $values{'owner'} -- $values{'lastrevisiondate'}<br />  $values{'author'}, $values{'owner'} -- $values{'lastrevisiondate'}<br />
 $values{'copyrighttag'}<br />  $values{'copyrighttag'}<br />
 $values{'extrashow'}  $values{'extrashow'}
Line 3385  END Line 3369  END
     return $result;      return $result;
 }  }
   
   sub summary_preview {
       my ($prefix,%values)=@_;
       return '<table><tr><td>'.
              &summary_view($prefix,%values).
              '</td><td>'.
              &Apache::lonindexer::showpreview($values{'url'}).
              '</td></tr></table><hr />';
   }
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
   
Line 3400  sub compact_view { Line 3393  sub compact_view {
     my ($prefix,%values) = @_;      my ($prefix,%values) = @_;
     my $jumpurl=$values{'url'};      my $jumpurl=$values{'url'};
     $jumpurl=~s/^\/ext\//http\:\/\//;      $jumpurl=~s/^\/ext\//http\:\/\//;
       my $link=&Apache::lonhtmlcommon::crumbs($jumpurl,
     (($env{'form.catalogmode'} eq 'import')?'_top':'preview'),
     '',
     (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),1);
     my $result =       my $result = 
         $prefix.'<img src="'.&Apache::loncommon::icon($values{'url'}).'">';          $prefix.'<img src="'.&Apache::loncommon::icon($values{'url'}).'">';
     if (exists($env{'form.sortfield'}) &&       if (exists($env{'form.sortfield'}) && 
Line 3410  sub compact_view { Line 3406  sub compact_view {
         $result .= '&nbsp;'.$tmp.'&nbsp;';          $result .= '&nbsp;'.$tmp.'&nbsp;';
     }      }
     $result.='&nbsp;<a href="'.$jumpurl.'" target="search_preview">'.      $result.='&nbsp;<a href="'.$jumpurl.'" target="search_preview">'.
         $values{'title'}.'</a>'.('&nbsp;'x2).          $values{'title'}.'</a>'.('&nbsp;'x2).$link.
         '<b>'.$values{'author'}.'</b> ('.$values{'domain'}.')<br />';          '<b>'.$values{'author'}.'</b> ('.$values{'domain'}.')<br />';
     return $result;      return $result;
 }  }
Line 3579  sub output_unparsed_phrase_error { Line 3575  sub output_unparsed_phrase_error {
     } else {      } else {
         $errorstring = &mt('Unable to understand the search phrase <b>[_1]</b>:<i>[_2]</i>.',$field,$env{'form.'.$field});          $errorstring = &mt('Unable to understand the search phrase <b>[_1]</b>:<i>[_2]</i>.',$field,$env{'form.'.$field});
     }      }
     my $bodytag = &Apache::loncommon::bodytag('Search');  
     my $heading = &mt('Unparsed Field');      my $heading = &mt('Unparsed Field');
     my $revise  = &mt('Revise search request');      my $revise  = &mt('Revise search request');
     # make query information persistent to allow for subsequent revision      # make query information persistent to allow for subsequent revision
     my $html=&Apache::lonxml::xmlbegin();      my $start_page = &Apache::loncommon::start_page('Search');
       my $end_page   = &Apache::loncommon::end_page();
     $r->print(<<ENDPAGE);      $r->print(<<ENDPAGE);
 $html  $start_page
 <head>  
 <title>The LearningOnline Network with CAPA</title>  
 </head>  
 $bodytag  
 <form method="post" action="/adm/searchcat">  <form method="post" action="/adm/searchcat">
 $hidden_fields  $hidden_fields
 $closebutton  $closebutton
Line 3601  $errorstring Line 3593  $errorstring
 <p>  <p>
 <a href="/adm/searchcat?$parms&persistent_db_id=$env{'form.persistent_db_id'}">$revise</a>  <a href="/adm/searchcat?$parms&persistent_db_id=$env{'form.persistent_db_id'}">$revise</a>
 </p>  </p>
 </body>  $end_page
 </html>  
 ENDPAGE  ENDPAGE
 }  }
   
Line 3628  $parms is extra information to include i Line 3619  $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');
     my $html=&Apache::lonxml::xmlbegin();      my $start_page = &Apache::loncommon::start_page('Search');
       my $end_page   = &Apache::loncommon::end_page();
     $r->print(<<ENDPAGE);      $r->print(<<ENDPAGE);
 $html  $start_page
 <head>  
 <title>The LearningOnline Network with CAPA</title>  
 </head>  
 $bodytag  
 <form method="post" action="/adm/searchcat">  <form method="post" action="/adm/searchcat">
 $hidden_fields  $hidden_fields
 $closebutton  $closebutton
Line 3650  $errormsg Line 3637  $errormsg
 <p>  <p>
 <a href="/adm/searchcat?$parms&persistent_db_id=$env{'form.persistent_db_id'}">$revise</a>&nbsp;  <a href="/adm/searchcat?$parms&persistent_db_id=$env{'form.persistent_db_id'}">$revise</a>&nbsp;
 </p>  </p>
 </body>  $end_page
 </html>  
 ENDPAGE  ENDPAGE
     return;      return;
 }  }
Line 3678  Inputs: Line 3664  Inputs:
 sub output_date_error {  sub output_date_error {
     my ($r,$message,$closebutton,$hidden_fields)=@_;      my ($r,$message,$closebutton,$hidden_fields)=@_;
     # make query information persistent to allow for subsequent revision      # make query information persistent to allow for subsequent revision
     my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1);      my $start_page = &Apache::loncommon::start_page('Search');
     my $html=&Apache::lonxml::xmlbegin();      my $end_page   = &Apache::loncommon::end_page();
     $r->print(<<RESULTS);      $r->print(<<RESULTS);
 $html  $start_page
 <head>  
 <title>The LearningOnline Network with CAPA</title>  
 </head>  
 $bodytag  
 <img align='right' src='/adm/lonIcons/lonlogos.gif' />  
 <h1>Search Catalog</h1>  
 <form method="post" action="/adm/searchcat">  <form method="post" action="/adm/searchcat">
 $hidden_fields  $hidden_fields
 <input type='button' value='Revise search request'  <input type='button' value='Revise search request'
Line 3698  $closebutton Line 3678  $closebutton
 <p>  <p>
 $message  $message
 </p>  </p>
 </body>  $end_page
 </html>  
 RESULTS  RESULTS
 }  }
   
Line 3739  sub cleanup { Line 3718  sub cleanup {
     }      }
     &untiehash();      &untiehash();
     &Apache::lonmysql::disconnect_from_db();      &Apache::lonmysql::disconnect_from_db();
       return OK;
 }  }
   
 __END__  __END__

Removed from v.1.251  
changed lines
  Added in v.1.268


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