');
} else {
&cat_header($r,$codedom,$js,\%add_entries,$catlinks,$numtitles);
my $cat_maxdepth = $env{'form.catalog_maxdepth'};
@@ -367,6 +391,7 @@ sub category_breadcrumbs {
my ($currdepth,$deeper) = &get_depth_values();
my $currcat_str = '';
my $catlinks = '
'.&mt('Catalog:').'
';
+ my $has_subcats;
for (my $i=0; $i<$deeper; $i++) {
$currcat_str .= '';
my ($cattitle,$shallower);
@@ -387,22 +412,19 @@ sub category_breadcrumbs {
'';
$env{'form.currcat_0'} = 'instcode::0';
} else {
+ $has_subcats = 1;
$catlinks .= '
';
- return $catlinks;
+ return ($catlinks,$has_subcats);
}
sub get_depth_values {
@@ -463,12 +488,40 @@ sub get_depth_values {
}
sub additional_filters {
- my ($codedom) = @_;
+ my ($codedom,$has_subcats) = @_;
my $output = '
';
+ if (($env{'form.currcat_0'} ne 'instcode::0') &&
+ ($env{'form.currcat_0'} ne '') && ($has_subcats)) {
+ my $include_subcat_status;
+ if ($env{'form.withsubcats'}) {
+ $include_subcat_status = 'checked="checked" ';
+ }
+ my $counter = $env{'form.catalog_maxdepth'};
+ if ($counter > 0) {
+ if ($env{'form.state'} eq 'listing') {
+ $counter --;
+ } elsif ($env{'form.currcat_'.$counter} eq '') {
+ $counter --;
+ }
+ }
+ my ($catname) = split(/:/,$env{'form.currcat_'.$counter});
+ if ($catname ne '') {
+ $output .= '
';
+ }
+ }
my $show_selfenroll_status;
if ($env{'form.showselfenroll'}) {
$show_selfenroll_status = 'checked="checked" ';
}
+ $output .= '
'.
+ '
';
if (&user_is_dc($codedom)) {
my $showdetails_status;
if ($env{'form.showdetails'}) {
@@ -481,7 +534,7 @@ sub additional_filters {
my $dc_title = &Apache::lonnet::plaintext('dc');
$output .= '
'."\n".
''."\n".'
'.
'
';
}
- $output .= '
'.
- '
';
+ $output .= ' ';
return $output;
}
@@ -629,7 +678,7 @@ sub search_official_courselist {
}
sub search_courselist {
- my ($domain) = @_;
+ my ($domain,$subcats) = @_;
my $cat_maxdepth = $env{'form.catalog_maxdepth'};
my $filter = $env{'form.currcat_'.$cat_maxdepth};
if (($filter eq '') && ($cat_maxdepth > 0)) {
@@ -637,7 +686,24 @@ sub search_courselist {
$filter = $env{'form.currcat_'.$shallower};
}
my %courses;
+ my $filterstr;
if ($filter ne '') {
+ if ($env{'form.withsubcats'}) {
+ if (ref($subcats) eq 'HASH') {
+ if (ref($subcats->{$filter}) eq 'ARRAY') {
+ $filterstr = join('&',@{$subcats->{$filter}});
+ if ($filterstr ne '') {
+ $filterstr = $filter.'&'.$filterstr;
+ }
+ } else {
+ $filterstr = $filter;
+ }
+ } else {
+ $filterstr = $filter;
+ }
+ } else {
+ $filterstr = $filter;
+ }
my $showhidden;
if (&user_is_dc($domain)) {
$showhidden = $env{'form.showhidden'};
@@ -645,13 +711,13 @@ sub search_courselist {
%courses =
&Apache::lonnet::courseiddump($domain,'.',1,'.','.','.',undef,undef,
'.',1,$env{'form.showselfenroll'},
- $filter,$showhidden,'coursecatalog');
+ $filterstr,$showhidden,'coursecatalog');
}
return %courses;
}
sub print_course_listing {
- my ($domain,$numtitles,$trails,$allitems) = @_;
+ my ($domain,$numtitles,$trails,$allitems,$subcats) = @_;
my $output;
my %courses;
my $knownuser = &user_is_known();
@@ -673,7 +739,7 @@ sub print_course_listing {
if ($env{'form.currcat_0'} eq 'instcode::0') {
%courses = &search_official_courselist($domain,$numtitles);
} else {
- %courses = &search_courselist($domain);
+ %courses = &search_courselist($domain,$subcats);
}
if (keys(%courses) == 0) {
$output = &mt('No courses match the criteria you selected.');
@@ -689,7 +755,9 @@ sub print_course_listing {
my %domconfig =
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
$output .= &construct_data_table($knownuser,\%courses,$details,undef,$now,\%domconfig,$trails,$allitems);
- $output .= &Apache::lonhtmlcommon::echo_form_input(['coursenum','state','catalogfilter','sortby','showdetails']);
+ $output .= "\n".'