--- loncom/interface/lonsearchcat.pm 2006/02/07 19:46:30 1.252 +++ loncom/interface/lonsearchcat.pm 2006/03/19 22:08:38 1.258 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.252 2006/02/07 19:46:30 albertel Exp $ +# $Id: lonsearchcat.pm,v 1.258 2006/03/19 22:08:38 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -77,6 +77,7 @@ use LONCAPA::lonmetadata(); use HTML::Entities(); use Parse::RecDescent; use Apache::lonnavmaps; +use Apache::lonindexer(); ###################################################################### ###################################################################### @@ -93,7 +94,9 @@ my %persistent_db; # gdbm hash which h # The different view modes and associated functions my %Views = ("detailed" => \&detailed_citation_view, + "detailedpreview" => \&detailed_citation_preview, "summary" => \&summary_view, + "summarypreview" => \&summary_preview, "fielded" => \&fielded_format_view, "xml" => \&xml_sgml_view, "compact" => \&compact_view); @@ -113,9 +116,6 @@ sub handler { my $diropendb; # The full path to the (temporary) search database file. # This is set and used in &handler() and is also used in # &output_results(). - my $bodytag; # LON-CAPA standard body tag, gotten from - # &Apache::lonnet::bodytag. - # No title, no table, just a tag. my $loaderror=&Apache::lonnet::overloaderror($r); if ($loaderror) { return $loaderror; } @@ -162,7 +162,7 @@ sub handler { ($env{'form.launch'} eq '1')) { $env{'form.persistent_db_id'} = time; } - $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); + my $persistent_db_file = "/home/httpd/perl/tmp/". &Apache::lonnet::escape($domain). '_'.&Apache::lonnet::escape($env{'user.name'}). @@ -195,18 +195,11 @@ sub handler { &Apache::lonnet::logthis('lonsearchcat:'. 'Unable to recover data from '. $persistent_db_file); - my $html=&Apache::lonxml::xmlbegin(); - $r->print(< -LON-CAPA Search Error -$bodytag -We were unable to retrieve data describing your search. This is a serious -error and has been logged. Please alert your LON-CAPA administrator. - - -END - return OK; + my $msg = + 'We were unable to retrieve data describing your search. '. + 'This is a serious error and has been logged. '. + 'Please alert your LON-CAPA administrator.'; + return &error_page($r,$msg); } } } else { @@ -226,10 +219,8 @@ END } else { # This is a stupid error to give to the user. # It really tells them nothing. - my $html=&Apache::lonxml::xmlbegin(); - $r->print($html.''.$bodytag. - 'Unable to tie hash to db file'); - return OK; + my $msg = 'Unable to tie hash to db file.'; + return &error_page($r,$msg); } } ## @@ -366,33 +357,19 @@ END &Apache::lonnet::logthis('lonsearchcat.pm: Unable to create '. 'needed table. lonmysql error:'. $errorstring); - my $html=&Apache::lonxml::xmlbegin(); - $r->print(< -Search Error -$bodytag -Unable to create table in which to store search results. -The search has been aborted. - - -END - return OK; + + my $msg = + 'Unable to create table in which to store search results. '. + 'The search has been aborted.'; + return &error_page($r,$msg); } delete($env{'form.launch'}); if (! &make_form_data_persistent($r,$persistent_db_file)) { - my $html=&Apache::lonxml::xmlbegin(); - $r->print(< -Search Error -$bodytag -Unable to properly store search information. The search has been aborted. - - -END - return OK; - } + my $msg= + 'Unable to properly store search information. '. + 'The search has been aborted.'; + return &error_page($r,$msg); + } ## ## Print out the frames interface ## @@ -403,6 +380,14 @@ END return OK; } +sub error_page { + my ($r,$msg) = @_; + $r->print(&Apache::loncommon::start_page('Search Error'). + &mt($msg). + &Apache::loncommon::end_page()); + return OK; +} + # # The mechanism used to store values away and retrieve them does not # handle the case of missing environment variables being significant. @@ -464,7 +449,6 @@ sub make_symb { sub course_search { my $r=shift; - my $bodytag=&Apache::loncommon::bodytag('Course Search'); my $pretty_search_string = ''.$env{'form.courseexp'}.''; my $search_string = $env{'form.courseexp'}; my @New_Words; @@ -481,9 +465,10 @@ sub course_search { my $discuss=$env{'form.crsdiscuss'}; my @allwords=($search_string,@New_Words); $totalfound=0; - my $html=&Apache::lonxml::xmlbegin(); - $r->print($html.'LON-CAPA Course Search'. - $bodytag.'
'.$pretty_search_string.'

'.&mt('Course content').':
'); + $r->print(&Apache::loncommon::start_page('Course Search'). + '
'. + $pretty_search_string.'
'. + '
'.&mt('Course content').':
'); $r->rflush(); # ======================================================= Go through the course my $c=$r->connection; @@ -581,7 +566,7 @@ sub course_search { } # =================================================== Done going through course - $r->print(''); + $r->print(&Apache::loncommon::end_page()); } # =============================== This pulls up a resource and its dependencies @@ -657,16 +642,6 @@ sub untiehash { } # End of course search scoping -sub search_html_header { - my $html=&Apache::lonxml::xmlbegin(); - my $Str = < -The LearningOnline Network with CAPA - -ENDHEADER - return $Str; -} ###################################################################### ###################################################################### @@ -684,11 +659,11 @@ Prints the form for the basic search. S sub print_basic_search_form { my ($r,$closebutton,$hidden_fields) = @_; my $result = ($env{'form.catalogmode'} ne 'groupsearch'); - my $bodytag=&Apache::loncommon::bodytag('Search'). + my $bread_crumb = &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Search_Basic', undef,undef, $env{'form.catalogmode'} ne 'groupsearch'); - my $scrout = &search_html_header().$bodytag; + my $scrout = &Apache::loncommon::start_page('Search').$bread_crumb; if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) { # Define interface components my $userelatedwords= '