--- loncom/interface/lonsearchcat.pm 2022/05/29 03:19:00 1.355 +++ loncom/interface/lonsearchcat.pm 2025/03/19 15:44:44 1.364 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.355 2022/05/29 03:19:00 raeburn Exp $ +# $Id: lonsearchcat.pm,v 1.364 2025/03/19 15:44:44 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -170,13 +170,27 @@ sub handler { ## &Apache::lonhtmlcommon::clear_breadcrumbs(); - my @allowed_searches = ('portfolio'); + my $crumb_text; + my @allowed_searches; + if ($env{'form.catalogmode'} eq 'import') { + $env{'form.area'} = 'res'; + $crumb_text = 'Content Library Search'; + } else { + push(@allowed_searches,'portfolio'); + } if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'}) eq 'F') { push(@allowed_searches,'res'); - } - my $crumb_text = 'Portfolio Search'; + } else { + unless ($env{'form.catalogmode'} eq 'import') { + $env{'form.area'} = 'portfolio'; + $crumb_text = 'Portfolio Search'; + } + } if (@allowed_searches ==2) { - $crumb_text = 'Portfolio and Catalog Search'; + unless (($env{'form.area'} eq 'portfolio') || ($env{'form.area'} eq 'res')) { + delete($env{'form.area'}); + } + $crumb_text = 'Portfolio and Content Library Search'; } my $target = '_top'; if ((($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) || @@ -184,7 +198,7 @@ sub handler { if ($env{'form.phase'} =~ /^(sort|run_search)$/) { $target = '_parent'; } else { - $target = ''; + $target = '_self'; } } &Apache::lonhtmlcommon::add_breadcrumb @@ -192,7 +206,8 @@ sub handler { &Apache::loncommon::inhibit_menu_check(). '&catalogmode='.$env{'form.catalogmode'}. '&launch='.$env{'form.launch'}. - '&mode='.$env{'form.mode'}, + '&mode='.$env{'form.mode'}. + '&area='.$env{'form.area'}, text=>"$crumb_text", target=>$target, bug=>'Searching',}); @@ -308,7 +323,7 @@ END } # if ($env{'form.searchmode'} eq 'advanced') { - my $srchtype = 'Catalog'; + my $srchtype = 'Content Library'; if ($env{'form.area'} eq 'portfolio') { $srchtype = 'Portfolio'; } @@ -317,10 +332,23 @@ END '&phase=disp_adv'. '&catalogmode='.$env{'form.catalogmode'}. '&launch='.$env{'form.launch'}. - '&mode='.$env{'form.mode'}, + '&mode='.$env{'form.mode'}. + '&area='.$env{'form.area'}, text=>"Advanced $srchtype Search", bug=>'Searching',}); - } + } elsif (($env{'form.phase'} eq 'results') || + ($env{'form.phase'} =~ /^(sort|run_search)$/)) { + &Apache::lonhtmlcommon::add_breadcrumb + ({href=>'/adm/searchcat?'.&Apache::loncommon::inhibit_menu_check(). + '&phase=disp_adv'. + '&catalogmode='.$env{'form.catalogmode'}. + '&launch='.$env{'form.launch'}. + '&mode='.$env{'form.mode'}. + '&area='.$env{'form.area'}. + '&searchmode='.$env{'form.searchmode'}, + text=>"Search Results", + bug=>'Searching',}); + } ## ## Switch on the phase ## @@ -337,10 +365,10 @@ END ['query','customquery','customshow', 'libraries','pretty_string','domains']); if ($env{'form.phase'} eq 'sort') { - &print_sort_form($r,$pretty_string); + &print_sort_form($r,$pretty_string,$target); } elsif ($env{'form.phase'} eq 'run_search') { &run_search($r,$query,$customquery,$customshow, - $libraries,$pretty_string,$env{'form.area'},$domainsref); + $libraries,$pretty_string,$env{'form.area'},$domainsref,$target); } } elsif(($env{'form.phase'} eq 'basic_search') || ($env{'form.phase'} eq 'adv_search')) { @@ -399,7 +427,7 @@ END } } return OK; -} +} # # The mechanism used to store values away and retrieve them does not @@ -437,6 +465,42 @@ sub hidden_field { return ''.$/; } +sub start_search_tabs { + my $area; + my %lt = &Apache::lonlocal::texthash ( + res => 'Content Library Search', + portfolio => 'Portfolio Search', + ); + my $output = '
'.
- &Apache::lonhtmlcommon::textbox('basicexp',
- $env{'form.basicexp'},50).
- ' '. - ''.&searchhelp().''.' | '.
- ''.
- ''.(' 'x3).$adv_search_link.''.' '. - ''.(' 'x1).$userelatedwords.''.' '. - ''.(' 'x1).$onlysearchdomain.''.' '. - ''.(' 'x1).$inclext.''.' '. - ' | '.
- '
' + $scrout .= '
' .&viewoptions() .'
' .'' @@ -565,9 +632,9 @@ sub setup_basic_search { .'value="'.&mt('Search').'" />' .' ' .$closebutton - .'
'; + .'' .&mt('Internal Error - Bad view selected.') - .'
'."\n"); + .''."\n" + .''.&Apache::loncommon::end_page()); $r->rflush(); return; } @@ -2680,7 +2803,8 @@ sub display_results { ## ## Get the catalog controls setup ## - my $action = "/adm/searchcat?phase=results"; + my $action = '/adm/searchcat?phase=results&area='.$env{'form.area'}. + '&catalogmode='.$env{'form.catalogmode'}; ## ## Deal with import by opening the import db file. if ($env{'form.catalogmode'} eq 'import') { @@ -2691,7 +2815,7 @@ sub display_results { $r->print(''. &mt('Unable to save import results.'). '
'. - ''. + ''. &Apache::loncommon::end_page()); $r->rflush(); return; @@ -2712,7 +2836,7 @@ sub display_results { $r->print(''. &mt('A MySQL error has occurred.'). '
'. - ''. + ''. &Apache::loncommon::end_page()); &Apache::lonnet::logthis("lonmysql was unable to determine the number". " of rows in table ".$table); @@ -2817,17 +2941,18 @@ sub display_results { $env{'form.sortorder'}='asc'; } } - my $sortform = '' - .&mt('Sort by:').' ' + my $sortform = '' + .&mt('Sort by:').' ' .&Apache::loncommon::select_form($env{'form.sortfield'}, - 'sortfield', - \%sort_fields) + 'sortfield', + \%sort_fields,'','','', + 'LC_sortby') .' ' .&Apache::loncommon::select_form($env{'form.sortorder'}, - 'sortorder', - {asc =>&mt('Ascending'), - desc=>&mt('Descending') - }) + 'sortorder', + {asc =>&mt('Ascending'), + desc=>&mt('Descending') + },'','','','LC_sortby') .''; ## ## Display links for 'prev' and 'next' pages (if necessary) and Display Options @@ -2841,15 +2966,15 @@ sub display_results { ); if ($total_results == 0) { - $r->print(''.&mt('There are currently no results.').'
'. - "". + $r->print('