--- loncom/interface/lonsearchcat.pm 2005/04/07 06:59:55 1.244 +++ loncom/interface/lonsearchcat.pm 2006/07/17 19:47:20 1.273 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.244 2005/04/07 06:59:55 albertel Exp $ +# $Id: lonsearchcat.pm,v 1.273 2006/07/17 19:47:20 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; } @@ -153,7 +155,7 @@ sub handler { ## my $domain = $r->dir_config('lonDefDomain'); $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 # $env{'form.persistent_db_id'} can only have digits in it. @@ -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 { @@ -218,7 +215,7 @@ END untie %groupsearch_db if (tied(%groupsearch_db)); if (($env{'form.cleargroupsort'} 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)) { &start_fresh_session(); untie %groupsearch_db; @@ -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; } } @@ -263,7 +260,7 @@ END $closebutton .="onClick='self.close()'"; } $closebutton .=">\n"; - } elsif ($env{'form.catalogmode'} eq 'groupsearch') { + } elsif ($env{'form.catalogmode'} eq 'import') { $closebutton="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 ## @@ -469,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; @@ -486,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; @@ -571,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.'
'); @@ -586,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 @@ -607,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; @@ -623,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). '
'); @@ -662,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; -} ###################################################################### ###################################################################### @@ -688,12 +660,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'). - &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching','Search_Basic', - undef,undef, - $env{'form.catalogmode'} ne 'groupsearch'); - my $scrout = &search_html_header().$bodytag; + my $result = ($env{'form.catalogmode'} ne 'import'); + my $bread_crumb = + &Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Basic', + $env{'form.catalogmode'} ne 'import'); + my $scrout = &Apache::loncommon::start_page('Search').$bread_crumb; if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'})) { # Define interface components my $userelatedwords= ''; + my $inclext= ''; my $adv_search_link = ''. - &Apache::lonhtmlcommon::textbox - ('basicexp', - &HTML::Entities::encode($env{'form.basicexp'},'<>&"'),50 - ). + &Apache::lonhtmlcommon::textbox('basicexp', + $env{'form.basicexp'},50). '
'. ''.&searchhelp().''.''. ''. ''.(' 'x3).$adv_search_link.''.'
'. ''.(' 'x1).$userelatedwords.''.'
'. ''.(' 'x1).$onlysearchdomain.''.'
'. - '
'. + ''.(' 'x1).$inclext.''.'
'. + ''. ''.$/; # $scrout .= ''. @@ -799,10 +773,7 @@ ENDCOURSESEARCH ENDENDCOURSE } - $scrout.=(< - -ENDDOCUMENT + $scrout .= &Apache::loncommon::end_page(); $r->print($scrout); return; } @@ -821,11 +792,9 @@ Prints the advanced search form. ###################################################################### sub print_advanced_search_form{ my ($r,$closebutton,$hidden_fields) = @_; - my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search'). - &Apache::lonhtmlcommon::breadcrumbs(undef,'Searching', - 'Search_Advanced', - undef,undef, - $env{'form.catalogmode'} ne 'groupsearch'); + my $bread_crumb = + &Apache::lonhtmlcommon::breadcrumbs('Searching','Search_Advanced', + $env{'form.catalogmode'} ne 'import'); my %lt=&Apache::lonlocal::texthash('srch' => 'Search', 'reset' => 'Reset', 'help' => 'Help'); @@ -834,9 +803,9 @@ sub print_advanced_search_form{ $closebutton END - my $scrout=&search_html_header(); + my $scrout= &Apache::loncommon::start_page('Advanced Catalog Search'); $scrout .= <<"ENDHEADER"; -$bodytag +$bread_crumb

$advanced_buttons @@ -860,10 +829,12 @@ ENDHEADER 'abstract' => 1, 'standards'=> 1, 'mime' => 1, + 'subject' => 1, ); # - foreach my $field ('title','author','owner','authorspace','modifyinguser', - 'keywords','notes','abstract','standards','mime') { + foreach my $field ('title','author','subject','owner','authorspace', + 'modifyinguser','keywords','notes','abstract', + 'standards','mime') { $scrout.=''.&titlefield($fields{$field}).''. &Apache::lonmeta::prettyinput($field, $env{'form.'.$field}, @@ -900,7 +871,10 @@ ENDHEADER &titlefield(&mt('Domains')).''. &Apache::loncommon::domain_select('domains', $env{'form.domains'},1). - ''.$/; + '
'.$/; # # Misc metadata $scrout.=''. @@ -1026,9 +1000,8 @@ ENDHEADER $scrout.=< - - ENDDOCUMENT + $scrout .= &Apache::loncommon::end_page(); $r->print($scrout); return; } @@ -1075,7 +1048,9 @@ sub viewoptiontext { 'xml' => 'XML/SGML', 'compact' => 'Compact View', 'fielded' => 'Fielded Format', - 'summary' => 'Summary View'); + 'summary' => 'Summary View', + 'summarypreview' => 'Summary Preview', + 'detailedpreview' => 'Detailed Citation Preview'); return $desc{$code}; } @@ -1174,7 +1149,7 @@ sub get_persistent_form_data { # End kludge (hopefully) next if (exists($env{$name})); my @values = map { - &Apache::lonnet::unescape($_); + &unescape($_); } split(',',$persistent_db{$name}); next if (@values <1); if ($arrays_allowed{$name}) { @@ -1220,7 +1195,7 @@ sub get_persistent_data { next; } my @values = map { - &Apache::lonnet::unescape($_); + &unescape($_); } split(',',$persistent_db{$name}); if (@values <= 1) { push @Values,$values[0]; @@ -1257,7 +1232,7 @@ sub make_persistent { foreach my $name (keys(%save)) { my @values = (ref($save{$name}) ? @{$save{$name}} : ($save{$name})); # 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; } untie(%persistent_db); @@ -1340,7 +1315,7 @@ sub parse_advanced_search { foreach ('mode','form','element') { # is this required? Hmmm. next if (! exists($env{'form.'.$_})); - $env{'form.'.$_}=&Apache::lonnet::unescape($env{'form.'.$_}); + $env{'form.'.$_}=&unescape($env{'form.'.$_}); $env{'form.'.$_}=~s/[^\w\/\s\(\)\=\-\"\']//g; } # Preprocess the category form element. @@ -1535,10 +1510,10 @@ sub parse_advanced_search { ## ## Deal with restrictions to given domains ## - my ($libraries_to_query,$pretty_domains_string,$domain_sql_restriction) = - &parse_domain_restrictions(); - push(@queries,$domain_sql_restriction); - $pretty_search_string .= $pretty_domains_string."
\n"; + my ($libraries_to_query,$pretty_domains_string) = &parse_domain_restrictions(); + if ($pretty_domains_string) { + $pretty_search_string .= $pretty_domains_string."
\n"; + } # if (@queries) { $query="SELECT * FROM metadata WHERE (".join(") AND (",@queries).')'; @@ -1557,30 +1532,21 @@ sub parse_domain_restrictions { if (! exists($env{'form.domains'}) || $env{'form.domains'} eq '') { return (undef,'',undef); } - my @allowed_domains; - if (ref($env{'form.domains'})) { - @allowed_domains = @{$env{'form.domains'}}; - } else { - @allowed_domains = ($env{'form.domains'}); - } + my @allowed_domains = &Apache::loncommon::get_env_multiple('form.domains'); # my %domain_hash = (); my $pretty_domains_string; - my $domain_sql_restriction; foreach (@allowed_domains) { $domain_hash{$_}++; } if ($domain_hash{'any'}) { - $pretty_domains_string = "In all LON-CAPA domains."; - $domain_sql_restriction = undef; + $pretty_domains_string = &mt("in all LON-CAPA domains."); } else { if (@allowed_domains > 1) { - $pretty_domains_string = "In LON-CAPA domains:"; + $pretty_domains_string = &mt("in LON-CAPA domains:"); } else { - $pretty_domains_string = "In LON-CAPA domain "; + $pretty_domains_string = &mt("in LON-CAPA domain "); } - $domain_sql_restriction = - '(domain="'.join('" OR domain="',@allowed_domains).'")'; foreach (sort @allowed_domains) { $pretty_domains_string .= "".$_." "; } @@ -1591,8 +1557,7 @@ sub parse_domain_restrictions { } } return ($libraries_to_query, - $pretty_domains_string, - $domain_sql_restriction); + $pretty_domains_string); } ###################################################################### @@ -1618,11 +1583,10 @@ sub parse_basic_search { foreach ('mode','form','element') { # is this required? Hmmm. next unless (exists($env{"form.$_"})); - $env{"form.$_"}=&Apache::lonnet::unescape($env{"form.$_"}); + $env{"form.$_"}=&unescape($env{"form.$_"}); $env{"form.$_"}=~s/[^\w\/\s\(\)\=\-\"\']//g; } - my ($libraries_to_query,$pretty_domains_string,$domain_sql_restriction) = - &parse_domain_restrictions(); + my ($libraries_to_query,$pretty_domains_string) = &parse_domain_restrictions(); # # Check to see if enough of a query is filled in my $search_string = $env{'form.basicexp'}; @@ -1645,14 +1609,14 @@ sub parse_basic_search { return; } push(@Queries,$SQLQuery); - if (defined($domain_sql_restriction) && $domain_sql_restriction ne '') { - push(@Queries,$domain_sql_restriction); - } #foreach my $q (@Queries) { # &Apache::lonnet::logthis(' '.$q); #} my $final_query = 'SELECT * FROM metadata WHERE '.join(" AND ",@Queries); # + if ($env{'form.related'}) { + $pretty_search_string.=' '.&mt('(including related words)'); + } if (defined($pretty_domains_string) && $pretty_domains_string ne '') { $pretty_search_string .= ' '.$pretty_domains_string; } @@ -2050,7 +2014,7 @@ sub ensure_db_and_table { if (! defined($table) || $table eq '' || $table =~ /\D/ ) { $r->print("Unable to retrieve search results. ". "Unable to determine the table results were stored in. ". - ""); + &Apache::loncommon::end_page()); return undef; } ## @@ -2059,7 +2023,8 @@ sub ensure_db_and_table { my $connection_result = &Apache::lonmysql::connect_to_db(); if (!defined($connection_result)) { $r->print("Unable to connect to the MySQL database where your results". - " are stored. "); + " are stored.". + &Apache::loncommon::end_page()); &Apache::lonnet::logthis("lonsearchcat: unable to get lonmysql to". " connect to database."); &Apache::lonnet::logthis(&Apache::lonmysql::get_error()); @@ -2067,7 +2032,8 @@ sub ensure_db_and_table { } my $table_check = &Apache::lonmysql::check_table($table); if (! defined($table_check)) { - $r->print("A MySQL error has occurred."); + $r->print("A MySQL error has occurred.". + &Apache::loncommon::end_page()); &Apache::lonnet::logthis("lonmysql was unable to determine the status". " of table ".$table); return undef; @@ -2096,10 +2062,6 @@ a link to change the search query. ###################################################################### sub print_sort_form { 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( @@ -2125,18 +2087,15 @@ sub print_sort_form { ## my $total_results = &Apache::lonmysql::number_of_rows($table); if (! defined($total_results)) { - $r->print("A MySQL error has occurred."); + $r->print("A MySQL error has occurred.". + &Apache::loncommon::end_page()); &Apache::lonnet::logthis("lonmysql was unable to determine the number". " of rows in table ".$table); &Apache::lonnet::logthis(&Apache::lonmysql::get_error()); return; } - my $result; - my $html=&Apache::lonxml::xmlbegin(); - $result.=< - -Results - -$bodytag -

- +END + + my $start_page = &Apache::loncommon::start_page('Results',$js, + {'no_title' => 1}); + my $breadcrumbs= + &Apache::lonhtmlcommon::breadcrumbs('Searching','Searching', + $env{'form.catalogmode'} ne 'import'); + + my $result = < + + END #

Sort Results

@@ -2168,13 +2136,11 @@ END

There are $total_results matches to your query. $revise

-Search:$pretty_query_string +Search: $pretty_query_string

- - END - $r->print($result); + $r->print($result.&Apache::loncommon::end_page()); return; } @@ -2291,7 +2257,7 @@ 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 $last_time = 0; @@ -2366,22 +2332,21 @@ results into MySQL. ###################################################################### sub run_search { 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; # # Print run_search header # - my $html=&Apache::lonxml::xmlbegin(); + my $start_page = &Apache::loncommon::start_page('Search Status',undef, + {'no_title' => 1}); + my $breadcrumbs = + &Apache::lonhtmlcommon::breadcrumbs('Searching','Searching', + $env{'form.catalogmode'} ne 'import'); $r->print(< -Search Status -$bodytag +$start_page +$breadcrumbs
- + END # Remove leading and trailing
$pretty_string =~ s:^\s*
::i; @@ -2414,12 +2379,14 @@ END my $table =$env{'form.table'}; if (! defined($table) || $table eq '' || $table =~ /\D/ ) { $r->print("Unable to determine table id to store search results in.". - "The search has been aborted."); + "The search has been aborted.". + &Apache::loncommon::end_page()); return; } my $table_status = &Apache::lonmysql::check_table($table); if (! defined($table_status)) { - $r->print("Unable to determine status of table."); + $r->print("Unable to determine status of table.". + &Apache::loncommon::end_page()); &Apache::lonnet::logthis("Bogus table id of $table for ". "$env{'user.name'} @ $env{'user.domain'}"); &Apache::lonnet::logthis("lonmysql error = ". @@ -2433,7 +2400,8 @@ END &Apache::lonmysql::get_debug()); &Apache::lonnet::logthis('table status = "'.$table_status.'"'); $r->print("The table id,$table, we tried to use is invalid.". - "The search has been aborted."); + "The search has been aborted.". + &Apache::loncommon::end_page()); return; } ## @@ -2525,8 +2493,11 @@ END my %Fields = &parse_raw_result($result,$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 next if (! ©right_check(\%Fields)); + # # Store the result in the mysql database my $result = &Apache::lonmysql::store_row($table,\%Fields); @@ -2559,8 +2530,8 @@ END # 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 # loaded from /adm/searchcat - $r->print(""); -# if ($env{'form.catalogmode'} ne 'groupsearch') { + $r->print(&Apache::loncommon::end_page()); +# if ($env{'form.catalogmode'} ne 'import') { $r->print(" SCRIPT - $result.=< -$bodytag - - + + my $start_page = &Apache::loncommon::start_page(undef,$js, + {'only_body' =>1}); + my $result=< $importbutton END return $result; } -###################################################################### -###################################################################### -sub search_status_header { - my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); - my $html=&Apache::lonxml::xmlbegin(); - return < -Search Status -$bodytag -

Search Status

-Sending search request to LON-CAPA servers.
-ENDSTATUS -} - sub results_link { my $basic_link = "/adm/searchcat?"."&table=".$env{'form.table'}. "&persistent_db_id=".$env{'form.persistent_db_id'}; @@ -3144,21 +3112,27 @@ sub print_frames_interface { "&persistent_db_id=".$env{'form.persistent_db_id'}; my $run_search_link = $basic_link."&phase=run_search"; my $results_link = &results_link(); - my $html=&Apache::lonxml::xmlbegin(); - my $result = <<"ENDFRAMES"; -$html - - -LON-CAPA Digital Library Search Results - - +JS + + 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 - - +$end_page ENDFRAMES $r->print($result); @@ -3225,9 +3199,11 @@ extra custom metadata to show. sub detailed_citation_view { my ($prefix,%values) = @_; my $result; + my $jumpurl=$values{'url'}; + $jumpurl=~s/^\/ext\//http\:\/\//; $result .= ''.$prefix. - ''.' '. - '
'.' '. + ''.$values{'title'}."\n"; $result .= "

\n"; $result .= ''.$values{'author'}.','. @@ -3292,25 +3268,25 @@ sub detailed_citation_view { next if (! exists($values{$field->{'name'}}) || $values{$field->{'name'}} eq ''); if (exists($field->{'type'}) && $field->{'type'} eq 'list') { - $result .= ''.&mt($field->{'translate'}).'

    '; + $result .= ''.&mt($field->{'translate'}).''; foreach my $item (split(',',$values{$field->{'name'}})){ - $result .= '
  • '. - ''.$item.'
  • '; + $result .= + &Apache::lonhtmlcommon::crumbs($item, + (($env{'form.catalogmode'} eq 'import')?'_top':'preview'), + '/res', + (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),2,0,1); } - $result .= '
'; } elsif (exists($field->{'format'}) && $field->{'format'} ne ''){ $result.= &mt($field->{'translate'}, sprintf($field->{'format'}, $values{$field->{'name'}}))."
\n"; } else { if ($field->{'special'} eq 'url link') { - $result.= - &mt($field->{'translate'}, - ''. - $values{$field->{'name'}}. - ''); + $result.= + &Apache::lonhtmlcommon::crumbs($jumpurl, + (($env{'form.catalogmode'} eq 'import')?'_top':'preview'), + '', + (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),3,0,1); } else { $result.= &mt($field->{'translate'}, $values{$field->{'name'}}); @@ -3329,6 +3305,16 @@ sub detailed_citation_view { return $result; } +sub detailed_citation_preview { + my ($prefix,%values)=@_; + return '
'. + &detailed_citation_view($prefix,%values). + ''. + &Apache::lonindexer::showpreview($values{'url'}). + '

'; +} + + ###################################################################### ###################################################################### @@ -3355,9 +3341,16 @@ sub summary_view { if (! defined($tmp)) { $tmp = 'undefined'; } $result .= ' '.$tmp.' '; } + my $jumpurl=$values{'url'}; + $jumpurl=~s/^\/ext\//http\:\/\//; + my $link=&Apache::lonhtmlcommon::crumbs($jumpurl, + (($env{'form.catalogmode'} eq 'import')?'':'preview'), + '', + (($env{'form.catalogmode'} eq 'import')?'parent.statusframe.document.forms.statusform':''),2,0,1); + $result.=<$values{'title'}
+$values{'title'}$link $values{'author'}, $values{'owner'} -- $values{'lastrevisiondate'}
$values{'copyrighttag'}
$values{'extrashow'} @@ -3367,6 +3360,15 @@ END return $result; } +sub summary_preview { + my ($prefix,%values)=@_; + return '
'. + &summary_view($prefix,%values). + ''. + &Apache::lonindexer::showpreview($values{'url'}). + '

'; +} + ###################################################################### ###################################################################### @@ -3380,6 +3382,12 @@ END ###################################################################### sub compact_view { my ($prefix,%values) = @_; + my $jumpurl=$values{'url'}; + $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,1,1).' '; my $result = $prefix.''; if (exists($env{'form.sortfield'}) && @@ -3388,9 +3396,9 @@ sub compact_view { if (! defined($tmp)) { $tmp = 'undefined'; } $result .= ' '.$tmp.' '; } - $result.=' '. - $values{'title'}.''.(' 'x2). - ''.$values{'author'}.'
'; + $result.=' '. + $values{'title'}.''.(' 'x2).$link. + ''.$values{'author'}.' ('.$values{'domain'}.')
'; return $result; } @@ -3410,11 +3418,14 @@ sub fielded_format_view { my ($prefix,%values) = @_; my $icon=&Apache::loncommon::icon($values{'url'}); my %Translated = &Apache::lonmeta::fieldnames(); + my $jumpurl=$values{'url'}; + $jumpurl=~s/^\/ext\//http\:\/\//; + my $result=<
URL:
-
$values{'url'}
END foreach my $field ('title','author','domain','subject','keywords','notes', @@ -3555,17 +3566,13 @@ sub output_unparsed_phrase_error { } else { $errorstring = &mt('Unable to understand the search phrase [_1]:[_2].',$field,$env{'form.'.$field}); } - my $bodytag = &Apache::loncommon::bodytag('Search'); my $heading = &mt('Unparsed Field'); my $revise = &mt('Revise search request'); # 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(< -The LearningOnline Network with CAPA - -$bodytag +$start_page $hidden_fields $closebutton @@ -3577,8 +3584,7 @@ $errorstring

$revise

- - +$end_page ENDPAGE } @@ -3604,17 +3610,13 @@ $parms is extra information to include i ###################################################################### sub output_blank_field_error { 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 $revise = &mt('Revise Search Request'); 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(< -The LearningOnline Network with CAPA - -$bodytag +$start_page $hidden_fields $closebutton @@ -3626,8 +3628,7 @@ $errormsg

$revise 

- - +$end_page ENDPAGE return; } @@ -3654,16 +3655,10 @@ Inputs: sub output_date_error { my ($r,$message,$closebutton,$hidden_fields)=@_; # make query information persistent to allow for subsequent revision - my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); - my $html=&Apache::lonxml::xmlbegin(); + my $start_page = &Apache::loncommon::start_page('Search'); + my $end_page = &Apache::loncommon::end_page(); $r->print(< -The LearningOnline Network with CAPA - -$bodytag - -

Search Catalog

+$start_page $hidden_fields $message

- - +$end_page RESULTS } @@ -3715,6 +3709,7 @@ sub cleanup { } &untiehash(); &Apache::lonmysql::disconnect_from_db(); + return OK; } __END__