--- loncom/interface/lonsearchcat.pm 2005/11/29 20:25:44 1.248 +++ loncom/interface/lonsearchcat.pm 2006/05/30 12:46:09 1.265 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.248 2005/11/29 20:25:44 www Exp $ +# $Id: lonsearchcat.pm,v 1.265 2006/05/30 12:46:09 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -77,6 +77,9 @@ use LONCAPA::lonmetadata(); use HTML::Entities(); use Parse::RecDescent; use Apache::lonnavmaps; +use Apache::lonindexer(); +use lib '/home/httpd/lib/perl/'; +use LONCAPA; ###################################################################### ###################################################################### @@ -93,7 +96,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 +118,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,10 +164,10 @@ 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'}). + &escape($domain). + '_'.&escape($env{'user.name'}). '_'.$env{'form.persistent_db_id'}.'_persistent_search.db'; ## &Apache::lonhtmlcommon::clear_breadcrumbs(); @@ -195,18 +197,13 @@ 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.'; + &Apache::loncommon::simple_error_page($r,'Search Error', + $msg); + return OK; } } } else { @@ -226,9 +223,9 @@ 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'); + my $msg = 'Unable to tie hash to db file.'; + &Apache::loncommon::simple_error_page($r,'Search Error', + $msg); return OK; } } @@ -366,33 +363,23 @@ 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.'; + &Apache::loncommon::simple_error_page($r,'Search Error', + $msg); + return OK; } 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.'; + &Apache::loncommon::simple_error_page($r,'Search Error', + $msg); + return OK; + } ## ## Print out the frames interface ## @@ -464,7 +451,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 +467,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; @@ -566,7 +553,7 @@ sub course_search { } else { $url .= '?symb='; } - $url .= &Apache::lonnet::escape($resource->symb()); + $url .= &escape($resource->symb()); my $title = $resource->compTitle(); $r->print('
'. ($title?$title:$url).'  - '.$disctype.'
'); @@ -581,7 +568,7 @@ sub course_search { } # =================================================== Done going through course - $r->print(''); + $r->print(&Apache::loncommon::end_page()); } # =============================== This pulls up a resource and its dependencies @@ -602,7 +589,7 @@ sub checkonthis { my ($extension)=($url=~/\.(\w+)$/); if (&Apache::loncommon::fileembstyle($extension) eq 'ssi' && ($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; my $applies = 0; @@ -618,7 +605,7 @@ sub checkonthis { $href=&Apache::lonenc::encrypted($href) .'?symb='.&Apache::lonenc::encrypted($symb); } else { - $href.='?symb='.&Apache::lonnet::escape($symb); + $href.='?symb='.&escape($symb); } $r->print(''.($title?$title:$url). '
'); @@ -657,16 +644,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 +661,10 @@ 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'). - &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Search_Basic', - undef,undef, - $env{'form.catalogmode'} ne 'groupsearch'); - my $scrout = &search_html_header().$bodytag; + my $bread_crumb = + &Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Basic', + $env{'form.catalogmode'} ne 'groupsearch'); + my $scrout = &Apache::loncommon::start_page('Search').$bread_crumb; if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) { # Define interface components my $userelatedwords= '