--- loncom/interface/lonsearchcat.pm 2025/03/19 15:18:59 1.362
+++ loncom/interface/lonsearchcat.pm 2025/03/19 15:30:29 1.363
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Search Catalog
#
-# $Id: lonsearchcat.pm,v 1.362 2025/03/19 15:18:59 raeburn Exp $
+# $Id: lonsearchcat.pm,v 1.363 2025/03/19 15:30:29 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -170,12 +170,26 @@ 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) {
+ 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';
@@ -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',});
@@ -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
##
@@ -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 = '
'."\n".
+ &start_search_tabs();
if (&Apache::lonnet::allowed('bre',$env{'request.role.domain'}) eq 'F') {
- $scrout .= &setup_basic_search($r,'res',$hidden_fields,$closebutton);
- $scrout .= '
';
- }
+ if ($env{'form.area'} eq 'portfolio') {
# Search form for accessible portfolio files
- $scrout.= &setup_basic_search($r,'portfolio',$hidden_fields,$closebutton);
- $scrout .= &Apache::loncommon::end_page();
+ $scrout .= &setup_basic_search($r,'portfolio',$hidden_fields,$closebutton);
+ } else {
+# Search form for resource space
+ $scrout .= &setup_basic_search($r,'res',$hidden_fields,$closebutton);
+ }
+ } else {
+# Search form for accessible portfolio files
+ $scrout .= &setup_basic_search($r,'portfolio',$hidden_fields,$closebutton);
+ }
+ $scrout .= &end_search_tabs().&Apache::loncommon::end_page();
$r->print($scrout);
return;
}
@@ -535,29 +611,20 @@ sub setup_basic_search {
$scrout .= '
';
}
#
- $scrout .= '
'.$/;
-# if ($env{'request.course.id'}) {
- $scrout .= '
'.$lt{$area}.' ';
-# } else {
- # No need to tell them they are searching
-# $scrout.= ('
'x2);
-# }
- $scrout.='
'.
- ''.
- &Apache::lonhtmlcommon::textbox('basicexp',
- $env{'form.basicexp'},50).
- ' '.
- ''.&searchhelp().' '.' '.
- ''.
- ''.(' 'x3).$adv_search_link.' '.' '.
- ''.(' 'x1).$userelatedwords.' '.' '.
- ''.(' 'x1).$onlysearchdomain.' '.' '.
- ''.(' 'x1).$inclext.' '.' '.
- ' '.
- ' '.
- '
'.$/;
+ $scrout .= '
'.
+ ''.
+ &Apache::lonhtmlcommon::textbox('basicexp',
+ $env{'form.basicexp'},50).
+ ' '.
+ ''.&searchhelp().'
'.
+ '
'.
+ ''.(' 'x3).$adv_search_link.' '.' '.
+ ''.(' 'x1).$userelatedwords.' '.' '.
+ ''.(' 'x1).$onlysearchdomain.' '.' '.
+ ''.(' 'x1).$inclext.' '.' '.
+ '
'.$/;
#
- $scrout .= '
'
+ $scrout .= '
'
.&viewoptions()
.'
'
.'
'
@@ -565,9 +632,9 @@ sub setup_basic_search {
.'value="'.&mt('Search').'" />'
.' '
.$closebutton
- .'
';
+ .'
';
#
- $scrout .= '
'.'';
+ $scrout .= '';
return $scrout;
}
@@ -617,7 +684,8 @@ function additional_metadata() {
}
my $scrout= &Apache::loncommon::start_page("Advanced $srchtype Search",
$jscript);
- $scrout .= $bread_crumb.'
'."\n";
+ $scrout .= $bread_crumb.'
'."\n".
+ &start_search_tabs();
$scrout .= '';
- $scrout .= '
'.&Apache::loncommon::end_page();
+ $scrout .= &end_search_tabs().'
'.&Apache::loncommon::end_page();
$r->print($scrout);
return;
}
@@ -1301,7 +1369,9 @@ sub parse_advanced_search {
}
if (! $fillflag) {
&output_blank_field_error($r,$closebutton,
- 'phase=disp_adv',$hidden_fields);
+ 'phase=disp_adv&area='.$env{'form.area'}.
+ '&catalogmode='.$env{'form.catalogmode'},
+ $hidden_fields);
return;
}
# Turn the form input into a SQL-based query
@@ -1315,7 +1385,9 @@ sub parse_advanced_search {
&process_phrase_input($env{'form.'.$field},
$env{'form.'.$field.'_related'},$field);
if (defined($error)) {
- &output_unparsed_phrase_error($r,$closebutton,'phase=disp_adv',
+ &output_unparsed_phrase_error($r,$closebutton,
+ 'phase=disp_adv&area='.$env{'form.area'}.
+ '&catalogmode='.$env{'form.catalogmode'}.
$hidden_fields,$field);
return;
} else {
@@ -1599,7 +1671,9 @@ sub parse_basic_search {
# Check to see if enough of a query is filled in
my $search_string = $env{'form.basicexp'};
if (! &filled($search_string)) {
- &output_blank_field_error($r,$closebutton,'phase=disp_basic');
+ &output_blank_field_error($r,$closebutton,'phase=disp_basic'.
+ '&area='.$env{'form.area'}.
+ '&catalogmode='.$env{'form.catalogmode'});
return OK;
}
my $pretty_search_string=$search_string;
@@ -1615,7 +1689,9 @@ sub parse_basic_search {
$env{'form.related'},
$searchfield);
if ($error) {
- &output_unparsed_phrase_error($r,$closebutton,'phase=disp_basic',
+ &output_unparsed_phrase_error($r,$closebutton,'phase=disp_basic'.
+ '&area='.$env{'form.area'}.
+ '&catalogmode='.$env{'form.catalogmode'},
'','basicexp');
return;
}
@@ -2307,7 +2383,8 @@ SCRIPT
sub reload_result_frame {
my ($r) = @_;
my $newloc = '/adm/searchcat?phase=results&persistent_db_id='.
- $env{'form.persistent_db_id'};
+ $env{'form.persistent_db_id'}.'&area='.$env{'form.area'}.
+ '&catalogmode='.$env{'form.catalogmode'};
$r->print(<
SCRIPT
# }
@@ -2724,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') {
@@ -3289,6 +3369,8 @@ END
sub results_link {
my $basic_link = "/adm/searchcat?"."&table=".$env{'form.table'}.
+ "&area=".$env{'form.area'}.
+ "&catalogmode=".$env{'form.catalogmode'}.
"&persistent_db_id=".$env{'form.persistent_db_id'};
my $results_link = $basic_link."&phase=results".
"&pause=1"."&start=1";
@@ -3299,7 +3381,9 @@ sub results_link {
######################################################################
sub print_frames_interface {
my $r = shift;
- my $basic_link = "/adm/searchcat?"."&table=".$env{'form.table'}.
+ my $basic_link = "/adm/searchcat?table=".$env{'form.table'}.
+ "&area=".$env{'form.area'}.
+ "&catalogmode=".$env{'form.catalogmode'}.
"&persistent_db_id=".$env{'form.persistent_db_id'};
my $run_search_link = $basic_link."&phase=run_search";
my $results_link = &results_link();