Diff for /loncom/interface/lonsearchcat.pm between versions 1.243 and 1.263

version 1.243, 2005/04/07 06:56:23 version 1.263, 2006/05/01 19:37:34
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();
   
 ######################################################################  ######################################################################
 ######################################################################  ######################################################################
Line 93  my %persistent_db;   # gdbm hash which h Line 94  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 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 162  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 195  sub handler { Line 195  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 226  END Line 221  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 283  END Line 278  END
     ## Sanity checks on form elements      ## Sanity checks on form elements
     ##      ##
     if (!defined($env{'form.viewselect'})) {      if (!defined($env{'form.viewselect'})) {
         if (($env{'form.catalogmode'} eq 'groupsearch') ||   $env{'form.viewselect'} ="summary";
             ($env{'form.catalogmode'} eq 'interactive')) {  
             $env{'form.viewselect'} ="Compact View";  
         } else {  
             $env{'form.viewselect'} ="Detailed Citation View";  
         }  
     }      }
     $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'}));
Line 371  END Line 361  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 469  sub make_symb { Line 449  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 486  sub course_search { Line 465  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 586  sub course_search { Line 566  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 662  sub untiehash { Line 642  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 689  Prints the form for the basic search.  S Line 659  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 'groupsearch');
     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 'groupsearch');
                                    $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 708  sub print_basic_search_form { Line 677  sub print_basic_search_form {
                                                  ),                                                   ),
                 $r->dir_config('lonDefDomain')                  $r->dir_config('lonDefDomain')
                 ).'</label>';                  ).'</label>';
           my $inclext= '<label>'.
               &mt('[_1] include external resources',
                   &Apache::lonhtmlcommon::checkbox
                   ('inclext',$env{'form.inclext'})).'</label>';
         my $adv_search_link =           my $adv_search_link = 
             '<a href="/adm/searchcat?'.              '<a href="/adm/searchcat?'.
             'phase=disp_adv&'.              'phase=disp_adv&'.
Line 740  sub print_basic_search_form { Line 713  sub print_basic_search_form {
             '<nobr>'.('&nbsp;'x3).$adv_search_link.'</nobr>'.'<br />'.              '<nobr>'.('&nbsp;'x3).$adv_search_link.'</nobr>'.'<br />'.
             '<nobr>'.('&nbsp;'x1).$userelatedwords.'</nobr>'.'<br />'.              '<nobr>'.('&nbsp;'x1).$userelatedwords.'</nobr>'.'<br />'.
             '<nobr>'.('&nbsp;'x1).$onlysearchdomain.'</nobr>'.'<br />'.              '<nobr>'.('&nbsp;'x1).$onlysearchdomain.'</nobr>'.'<br />'.
             '</font></td>'.              '<nobr>'.('&nbsp;'x1).$inclext.'</nobr>'.'<br />'.
                '</font></td>'.
             '</tr>'.$/;              '</tr>'.$/;
         #          #
         $scrout .= '<tr><td align="center" colspan="2">'.          $scrout .= '<tr><td align="center" colspan="2">'.
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 '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 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 860  ENDHEADER Line 829  ENDHEADER
          'abstract' => 1,           'abstract' => 1,
          'standards'=> 1,           'standards'=> 1,
          'mime'     => 1,           'mime'     => 1,
    'subject'  => 1,
          );           );
     #      #
     foreach my $field ('title','author','owner','authorspace','modifyinguser',      foreach my $field ('title','author','subject','owner','authorspace',
      'keywords','notes','abstract','standards','mime') {         'modifyinguser','keywords','notes','abstract',
          'standards','mime') {
  $scrout.='<tr><td align="right">'.&titlefield($fields{$field}).'</td><td>'.   $scrout.='<tr><td align="right">'.&titlefield($fields{$field}).'</td><td>'.
     &Apache::lonmeta::prettyinput($field,      &Apache::lonmeta::prettyinput($field,
                                           $env{'form.'.$field},                                            $env{'form.'.$field},
Line 900  ENDHEADER Line 871  ENDHEADER
  &titlefield(&mt('Domains')).'</td><td colspan="2">'.    &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></tr>'.$/;     '<br /><label>'.
               &mt('[_1] include external resources',
                   &Apache::lonhtmlcommon::checkbox
                   ('inclext',$env{'form.inclext'})).'</label></td></tr>'.$/;
     #      #
     # Misc metadata      # Misc metadata
     $scrout.='<tr><td align="right" valign="top">'.      $scrout.='<tr><td align="right" valign="top">'.
Line 1026  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 1075  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 1535  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) {
     push(@queries,$domain_sql_restriction);         $pretty_search_string .= $pretty_domains_string."<br />\n";
     $pretty_search_string .= $pretty_domains_string."<br />\n";      }
     #      #
     if (@queries) {      if (@queries) {
  $query="SELECT * FROM metadata WHERE (".join(") AND (",@queries).')';   $query="SELECT * FROM metadata WHERE (".join(") AND (",@queries).')';
Line 1557  sub parse_domain_restrictions { Line 1532  sub parse_domain_restrictions {
     if (! exists($env{'form.domains'}) || $env{'form.domains'} eq '') {      if (! exists($env{'form.domains'}) || $env{'form.domains'} eq '') {
         return (undef,'',undef);          return (undef,'',undef);
     }      }
     my @allowed_domains;      my @allowed_domains = &Apache::loncommon::get_env_multiple('form.domains');
     if (ref($env{'form.domains'})) {  
         @allowed_domains =  @{$env{'form.domains'}};  
     } else {  
         @allowed_domains = ($env{'form.domains'});  
     }  
     #      #
     my %domain_hash = ();      my %domain_hash = ();
     my $pretty_domains_string;      my $pretty_domains_string;
     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 1591  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 1621  sub parse_basic_search { Line 1586  sub parse_basic_search {
  $env{"form.$_"}=&Apache::lonnet::unescape($env{"form.$_"});   $env{"form.$_"}=&Apache::lonnet::unescape($env{"form.$_"});
  $env{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g;   $env{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g;
     }      }
     my ($libraries_to_query,$pretty_domains_string,$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 1645  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 2050  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 2059  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 2067  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 2096  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 2125  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 2145  $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 '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 2171  There are $total_results matches to your Line 2135  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 2291  sub update_status { Line 2253  sub update_status {
 }  }
   
 {  {
     my $max_time  = 40;  # seconds for the search to complete      my $max_time  = 300;  # seconds for the search to complete
     my $start_time = 0;      my $start_time = 0;
     my $last_time = 0;      my $last_time = 0;
   
Line 2366  results into MySQL. Line 2328  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 'groupsearch');
     $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 2414  END Line 2375  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 2433  END Line 2396  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 2525  END Line 2489  END
                     my %Fields = &parse_raw_result($result,$server);                      my %Fields = &parse_raw_result($result,$server);
                     $Fields{'hostname'} = $server;                      $Fields{'hostname'} = $server;
                     #                      #
                       # Skip if external and we did not want that
                       next if ((! $env{'form.inclext'}) && ($Fields{'url'}=~/^\/ext\//));
                     # Skip based on copyright                      # Skip based on copyright
                     next if (! &copyright_check(\%Fields));                      next if (! &copyright_check(\%Fields));
   
                     #                      #
                     # Store the result in the mysql database                      # Store the result in the mysql database
                     my $result = &Apache::lonmysql::store_row($table,\%Fields);                      my $result = &Apache::lonmysql::store_row($table,\%Fields);
Line 2559  END Line 2526  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 'groupsearch') {
         $r->print("<script>".          $r->print("<script>".
                       "window.location='/adm/searchcat?".                        "window.location='/adm/searchcat?".
Line 2638  sub display_results { Line 2605  sub display_results {
     if ($env{'form.catalogmode'} eq 'groupsearch') {      if ($env{'form.catalogmode'} eq 'groupsearch') {
         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 2651  sub display_results { Line 2619  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 2685  sub display_results { Line 2654  sub display_results {
               );                );
     #      #
     # Build sorting selector      # Build sorting selector
 <<<<<<< lonsearchcat.pm  
     my @field_order =  ('default',  
                         'title',  
                         'author',  
                         'subject',  
                         'url',  
                         'keywords',  
                         'version',  
                         'language',  
                         'creationdate'=>,  
                         'lastrevisiondate',  
                         'owner',  
                         'copyright',  
                         'authorspace',  
                         'lowestgradeleve',  
                         'highestgradelevel',  
                         'standards',  
                         'count',  
                         'stdno',  
                         'avetries',  
                         'difficulty',  
                         'disc',  
                         'clear',  
                         'technical',  
                         'correct',  
                         'helpful',  
                         'depth',  
                         );                                                
     my %sort_fields = ('default'     => 'Default',  
                        'title'       => 'Title',  
                        'author'      => 'Author',  
                        'subject'     => 'Subject',  
                        'url'         => 'URL',  
                        'keywords'    => 'Keywords',  
                        'version'     => 'Version',  
                        'language'    => 'Language',  
                        'creationdate'=> 'Creation Date',  
                        'lastrevisiondate' => 'Last Revision Date',  
                        'owner'       => 'Owner',  
                        'copyright'   => 'Copyright',  
                        'authorspace' => 'Authorspace',  
                        'lowestgradeleve' => 'Lowest Grade Level',  
                        'highestgradelevel' => 'Highest Grade Level',  
                        'standards'   => 'Standards',  
                        'count'       => 'Number of Accesses',  
                        'stdno'       => 'Students Attempting',  
                        'avetries'    => 'Average Number of Tries',  
                        'difficulty'  => 'Mean Degree of Difficulty',  
                        'disc'        => 'Mean Degree of Discrimination',  
                        'clear'       => 'Evaluation: Clear',  
                        'technical'   => 'Evaluation: Technically Correct',  
                        'correct'     => 'Evaluation: Material is Correct',  
                        'helpful'     => 'Evaluation: Material is Helpful',  
                        'depth'       => 'Evaluation: Material has Depth',  
                        'select_form_order' => \@field_order,  
                        );  
   
     my $sortform = &mt('Sort by [_1]',  
                        &Apache::loncommon::select_form($env{'form.sortfield'},  
 =======  
     my @fields =       my @fields = 
         (          (
          {key=>'default' },           {key=>'default' },
Line 2788  sub display_results { Line 2697  sub display_results {
     }      }
     my %sort_fields = map {$_->{'key'},$_->{'desc'}} @fields;      my %sort_fields = map {$_->{'key'},$_->{'desc'}} @fields;
     $sort_fields{'select_form_order'} = \@field_order;      $sort_fields{'select_form_order'} = \@field_order;
     $ENV{'form.sortorder'} = 'asc' if (! exists($ENV{'form.sortorder'}));      $env{'form.sortorder'} = 'desc' if (! exists($env{'form.sortorder'}));
       $env{'form.sortfield'} = 'count' if (! exists($env{'form.sortfield'}));
       if (! exists($env{'form.sortorder'})) {
    if ($env{'form.sortfield'}=~/^(count|stdno|disc|clear|technical|correct|helpful)$/) {
       $env{'form.sortorder'}='desc';
    } else {
       $env{'form.sortorder'}='asc';
    }
       }
     my $sortform = &mt('Sort by [_1] [_2]',      my $sortform = &mt('Sort by [_1] [_2]',
                        &Apache::loncommon::select_form($ENV{'form.sortfield'},                         &Apache::loncommon::select_form($env{'form.sortfield'},
 >>>>>>> 1.242  
                                                       'sortfield',                                                        'sortfield',
                                                       %sort_fields),                                                        %sort_fields),
                        &Apache::loncommon::select_form($ENV{'form.sortorder'},                         &Apache::loncommon::select_form($env{'form.sortorder'},
                                                       'sortorder',                                                        'sortorder',
                                                       (asc =>&mt('Ascending'),                                                        (asc =>&mt('Ascending'),
                                                        desc=>&mt('Descending')                                                         desc=>&mt('Descending')
Line 2811  sub display_results { Line 2727  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 2824  sub display_results { Line 2741  sub display_results {
     ##      ##
     ## Get results from MySQL table      ## Get results from MySQL table
     my $sort_command  = 'id>='.$min.' AND id<='.$max;      my $sort_command  = 'id>='.$min.' AND id<='.$max;
 <<<<<<< lonsearchcat.pm  
     if ($env{'form.sortfield'} ne 'default' &&   
         exists($sort_fields{$env{'form.sortfield'}})) {  
         $sort_command = $env{'form.sortfield'}.' IS NOT NULL '.  
             'ORDER BY '.$env{'form.sortfield'}.  
 =======  
     my $order;      my $order;
     if (exists($ENV{'form.sortorder'})) {      if (exists($env{'form.sortorder'})) {
         if ($ENV{'form.sortorder'} eq 'asc') {          if ($env{'form.sortorder'} eq 'asc') {
             $order = 'ASC';              $order = 'ASC';
         } elsif ($ENV{'form.sortorder'} eq 'desc') {          } elsif ($env{'form.sortorder'} eq 'desc') {
             $order = 'DESC';              $order = 'DESC';
         } else {          } else {
             $order = '';              $order = '';
Line 2842  sub display_results { Line 2753  sub display_results {
     } else {      } else {
         $order = '';          $order = '';
     }      }
     if ($ENV{'form.sortfield'} ne 'default' &&       if ($env{'form.sortfield'} ne 'default' && 
         exists($sort_fields{$ENV{'form.sortfield'}})) {          exists($sort_fields{$env{'form.sortfield'}})) {
         $sort_command = $ENV{'form.sortfield'}.' IS NOT NULL '.          $sort_command = $env{'form.sortfield'}.' IS NOT NULL '.
             'ORDER BY '.$ENV{'form.sortfield'}.' '.$order.              'ORDER BY '.$env{'form.sortfield'}.' '.$order.
 >>>>>>> 1.242              '  LIMIT '.($min-1).','.($max-$min+1);
             '  LIMIT '.($min-1).','.($max-$min);  
     }      }
     my @Results = &Apache::lonmysql::get_rows($table,$sort_command);      my @Results = &Apache::lonmysql::get_rows($table,$sort_command);
     ##      ##
Line 2883  sub display_results { Line 2793  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 3080  the name of the input field to put the t Line 2990  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 3126  function changeTitle(val) { Line 3036  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 3146  function changeURL(val) { Line 3056  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 3171  SCRIPT Line 3081  SCRIPT
     }      }
 </script>  </script>
 SCRIPT  SCRIPT
     $result.=<<END;  
 </head>      my $start_page  = &Apache::loncommon::start_page(undef,$js,
 $bodytag       {'only_body' =>1});
       my $result=<<END;
   $start_page
 <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 3184  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 3212  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 3293  extra custom metadata to show. Line 3208  extra custom metadata to show.
 sub detailed_citation_view {  sub detailed_citation_view {
     my ($prefix,%values) = @_;      my ($prefix,%values) = @_;
     my $result;      my $result;
       my $jumpurl=$values{'url'};
       $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="http://'.$ENV{'HTTP_HOST'}.$values{'url'}.'" '.          '<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";
     $result .= '<b>'.$values{'author'}.'</b>,'.      $result .= '<b>'.$values{'author'}.'</b>,'.
Line 3364  sub detailed_citation_view { Line 3281  sub detailed_citation_view {
             foreach my $item (split(',',$values{$field->{'name'}})){              foreach my $item (split(',',$values{$field->{'name'}})){
                 $result .= '<li>'.                  $result .= '<li>'.
                     '<a target="search_preview" '.                      '<a target="search_preview" '.
                     'href="/res/'.$item.'">'.$item.'</a></li>';                      'href="'.$jumpurl.'">'.$item.'</a></li>';
             }              }
             $result .= '</ul>';              $result .= '</ul>';
         } elsif (exists($field->{'format'}) && $field->{'format'} ne ''){          } elsif (exists($field->{'format'}) && $field->{'format'} ne ''){
Line 3375  sub detailed_citation_view { Line 3292  sub detailed_citation_view {
             if ($field->{'special'} eq 'url link') {              if ($field->{'special'} eq 'url link') {
                 $result.=                   $result.= 
                      &mt($field->{'translate'},                       &mt($field->{'translate'},
                          '<a href="'.$values{'url'}.'" '.                           '<a href="'.$jumpurl.'" '.
                          'target="search_preview">'.                           'target="search_preview">'.
                          $values{$field->{'name'}}.                           $values{$field->{'name'}}.
                          '</a>');                           '</a>');
Line 3397  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 3411  sub summary_view { Line 3338  sub summary_view {
     my ($prefix,%values) = @_;      my ($prefix,%values) = @_;
     my $icon=&Apache::loncommon::icon($values{'url'});      my $icon=&Apache::loncommon::icon($values{'url'});
     my $result=qq{$prefix<img src="$icon" />};      my $result=qq{$prefix<img src="$icon" />};
     if (exists($ENV{'form.sortfield'}) &&       if (exists($env{'form.sortfield'}) && 
         $ENV{'form.sortfield'} !~ /^(default|          $env{'form.sortfield'} !~ /^(default|
                                      author|                                       author|
                                      url|                                       url|
                                      title|                                       title|
                                      owner|                                       owner|
                                      lastrevisiondate|                                       lastrevisiondate|
                                      copyright)$/x) {                                       copyright)$/x) {
         my $tmp = $values{$ENV{'form.sortfield'}};          my $tmp = $values{$env{'form.sortfield'}};
         if (! defined($tmp)) { $tmp = 'undefined'; }          if (! defined($tmp)) { $tmp = 'undefined'; }
         $result .= '&nbsp;'.$tmp.'&nbsp;';          $result .= '&nbsp;'.$tmp.'&nbsp;';
     }      }
       my $jumpurl=$values{'url'};
       $jumpurl=~s/^\/ext\//http\:\/\//;
   
     $result.=<<END;      $result.=<<END;
 <a href="http://$ENV{'HTTP_HOST'}$values{'url'}"   <a href="$jumpurl" 
    target='search_preview'>$values{'title'}</a><br />     target='search_preview'>$values{'title'}</a><br />
 $values{'author'}, $values{'owner'} -- $values{'lastrevisiondate'}<br />  $values{'author'}, $values{'owner'} -- $values{'lastrevisiondate'}<br />
 $values{'copyrighttag'}<br />  $values{'copyrighttag'}<br />
Line 3435  END Line 3365  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 3448  END Line 3387  END
 ######################################################################  ######################################################################
 sub compact_view {  sub compact_view {
     my ($prefix,%values) = @_;      my ($prefix,%values) = @_;
       my $jumpurl=$values{'url'};
       $jumpurl=~s/^\/ext\//http\:\/\//;
   
     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'}) && 
         $ENV{'form.sortfield'} !~ /^(default|author|url|title)$/) {          $env{'form.sortfield'} !~ /^(default|author|url|title)$/) {
         my $tmp = $values{$ENV{'form.sortfield'}};          my $tmp = $values{$env{'form.sortfield'}};
         if (! defined($tmp)) { $tmp = 'undefined'; }          if (! defined($tmp)) { $tmp = 'undefined'; }
         $result .= '&nbsp;'.$tmp.'&nbsp;';          $result .= '&nbsp;'.$tmp.'&nbsp;';
     }      }
     $result.='&nbsp;<a href="'.$values{'url'}.'" target="search_preview">'.      $result.='&nbsp;<a href="'.$jumpurl.'" target="search_preview">'.
         $values{'title'}.'</a>'.('&nbsp;'x2).          $values{'title'}.'</a>'.('&nbsp;'x2).
         '<b>'.$values{'author'}.'</b><br />';          '<b>'.$values{'author'}.'</b> ('.$values{'domain'}.')<br />';
     return $result;      return $result;
 }  }
   
Line 3478  sub fielded_format_view { Line 3420  sub fielded_format_view {
     my ($prefix,%values) = @_;      my ($prefix,%values) = @_;
     my $icon=&Apache::loncommon::icon($values{'url'});      my $icon=&Apache::loncommon::icon($values{'url'});
     my %Translated = &Apache::lonmeta::fieldnames();      my %Translated = &Apache::lonmeta::fieldnames();
       my $jumpurl=$values{'url'};
       $jumpurl=~s/^\/ext\//http\:\/\//;
   
     my $result=<<END;      my $result=<<END;
 $prefix <img src="$icon" />  $prefix <img src="$icon" />
 <dl>  <dl>
 <dt>URL:</dt>  <dt>URL:</dt>
     <dd><a href="http://$ENV{'HTTP_HOST'}$values{'url'}"       <dd><a href="$jumpurl" 
          target='search_preview'>$values{'url'}</a></dd>           target='search_preview'>$values{'url'}</a></dd>
 END  END
     foreach my $field ('title','author','domain','subject','keywords','notes',      foreach my $field ('title','author','domain','subject','keywords','notes',
Line 3623  sub output_unparsed_phrase_error { Line 3568  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 3645  $errorstring Line 3586  $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 3672  $parms is extra information to include i Line 3612  $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 3694  $errormsg Line 3630  $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 3722  Inputs: Line 3657  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 3742  $closebutton Line 3671  $closebutton
 <p>  <p>
 $message  $message
 </p>  </p>
 </body>  $end_page
 </html>  
 RESULTS  RESULTS
 }  }
   
Line 3783  sub cleanup { Line 3711  sub cleanup {
     }      }
     &untiehash();      &untiehash();
     &Apache::lonmysql::disconnect_from_db();      &Apache::lonmysql::disconnect_from_db();
       return OK;
 }  }
   
 __END__  __END__

Removed from v.1.243  
changed lines
  Added in v.1.263


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