');
return;
}
sub category_breadcrumbs {
- my ($dom) = @_;
- my %domconfig =
- &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
- my (@cats,@trails,%allitems,%idx,@jsarray,$cathash);
- if (ref($domconfig{'coursecategories'}) eq 'HASH') {
- $cathash = $domconfig{'coursecategories'}{'cats'};
- } else {
- $cathash = {};
- }
- &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems,\%idx,
- \@jsarray);
+ my ($dom,@cats) = @_;
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);
@@ -383,25 +409,22 @@ sub category_breadcrumbs {
if (ref($cats[0]) eq 'ARRAY') {
if ((@{$cats[0]} == 1) && ($cats[0][0] eq 'instcode')) {
$catlinks .= &mt('Official courses (with institutional codes)').
- '';
+ '';
$env{'form.currcat_0'} = 'instcode::0';
} else {
+ $has_subcats = 1;
$catlinks .= '
';
- return $catlinks;
+ return ($catlinks,$has_subcats);
}
sub get_depth_values {
@@ -462,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'}) {
@@ -480,7 +534,7 @@ sub additional_filters {
my $dc_title = &Apache::lonnet::plaintext('dc');
$output .= '
'."\n".
''."\n".'
'.
'
';
}
- $output .= '
'.
- '
';
+ $output .= ' ';
return $output;
}
@@ -628,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)) {
@@ -636,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'};
@@ -644,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) = @_;
+ my ($domain,$numtitles,$trails,$allitems,$subcats) = @_;
my $output;
my %courses;
my $knownuser = &user_is_known();
@@ -672,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.');
@@ -687,22 +754,32 @@ sub print_course_listing {
my $now = time;
my %domconfig =
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
- $output .= &construct_data_table($knownuser,\%courses,$details,undef,$now,\%domconfig);
- $output .= &Apache::lonhtmlcommon::echo_form_input(['coursenum','state','catalogfilter','sortby','showdetails']);
+ $output .= &construct_data_table($knownuser,\%courses,$details,undef,$now,\%domconfig,$trails,$allitems);
+ $output .= "\n".'