');
+ if ($cattype eq 'std') {
+ $r->print('
');
+ }
+ my $onsubmit;
+ unless ($env{'form.currcat_0'} eq 'instcode::0') {
+ $onsubmit = ' onsubmit="return check_selected();"';
}
- $r->print('
');
+ $r->print('
');
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 $crumbsymbol = ' ▶ ';
my ($currdepth,$deeper) = &get_depth_values();
- my $currcat_str = '
';
- my $catlinks = '
'.&mt('Catalog:').' | ';
- for (my $i=0; $i<$deeper; $i++) {
- $currcat_str .= '';
- my ($cattitle,$shallower);
- if ($i == 0) {
- $cattitle = &mt('Main Categories');
- } else {
- $shallower = $i-1;
- my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$shallower});
- $cattitle = $cat;
- }
- $catlinks .= ''.$cattitle.'-> | ';
- }
- if ($deeper == 0) {
- $catlinks .= ''.&mt('Main Categories').': ';
- if (ref($cats[0]) eq 'ARRAY') {
- if ((@{$cats[0]} == 1) && ($cats[0][0] eq 'instcode')) {
- $catlinks .= &mt('Official courses (with institutional codes)').
- '';
+ my $currcat_str =
+ ''.
+ '';
+ my $catlinks = ' | '.&mt('Catalog:').' | ';
+ my $has_subcats;
+ my $selitem;
+ my $update_button;
+ if (ref($cats[0]) eq 'ARRAY') {
+ if (@{$cats[0]} == 0) {
+ $catlinks .= &mt('No categories defined in this domain');
+ } elsif (@{$cats[0]} == 1) {
+ if ($cats[0][0] eq 'instcode') {
+ $catlinks .= &mt('Official courses (with institutional codes)');
$env{'form.currcat_0'} = 'instcode::0';
+ } elsif ($cats[0][0] eq 'communities') {
+ $catlinks .= &mt('Communities');
+ $env{'form.currcat_0'} = 'communities::0';
+ } elsif ($cats[0][0] eq 'placement') {
+ $catlinks .= &mt('Placement Tests');
+ $env{'form.currcat_0'} = 'placement::0';
} else {
- $catlinks .= ''."\n".
- ' ';
+ my $name = $cats[0][0];
+ my $item = &escape($name).'::0';
+ $catlinks .= $name;
+ $env{'form.currcat_0'} = $item;
}
+ $currcat_str .= '';
} else {
- $catlinks .= &mt('Official courses (with institutional codes)').
- '';
- $env{'form.currcat_0'} = 'instcode::0';
+ $update_button = 1;
+ $catlinks .= &main_category_selector(@cats);
+ if (($env{'form.currcat_0'} ne '') &&
+ ($env{'form.currcat_0'} ne 'instcode::0')) {
+ $catlinks .= $crumbsymbol;
+ }
}
} else {
+ $catlinks .= &mt('Official courses (with institutional codes)');
+ $env{'form.currcat_0'} = 'instcode::0';
+ $currcat_str .= '';
+ }
+ if ($deeper) {
+ for (my $i=1; $i<=$deeper; $i++) {
+ my $shallower = $i-1;
+ next if ($shallower == 0);
+ my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$shallower});
+ if ($cat ne '') {
+ my $labeltext = &HTML::Entities::encode(&mt('Level [_1] category',$shallower),'<>&"');
+ $catlinks .= ''.
+ '';
+ }
+ unless ($i == $deeper) {
+ $catlinks .= $crumbsymbol;
+ }
+ }
my ($cat,$container,$depth);
if ($env{'form.currcat_'.$currdepth} eq '') {
my $shallower = $currdepth - 1;
@@ -425,26 +961,73 @@ sub category_breadcrumbs {
} else {
($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$currdepth});
}
- my $deeper = $depth +1;
- my $currcat = $cat;
- if ($cat eq 'instcode') {
- $currcat = &mt('Official courses (with institutional codes)');
- }
- $catlinks .= ' | '.$currcat;
- if (ref($cats[$deeper]{$cat}) eq 'ARRAY') {
- $catlinks .= ': '."\n";
+ } elsif ($cat ne 'instcode') {
+ $catlinks .= ' '.&mt('(No subcategories)');
}
+ } else {
+ $selitem = 'currcat_0';
}
- $catlinks .= $currcat_str.' |
| ';
- return $catlinks;
+ $catlinks .= $currcat_str;
+ if ($update_button) {
+ $catlinks .= '
'."\n";
+ }
+ $catlinks .= '
';
+ return ($catlinks,$has_subcats,$selitem);
+}
+
+sub main_category_selector {
+ my (@cats) = @_;
+ my $labeltext = &HTML::Entities::encode(&mt('Top level category'),'<>&"');
+ my $maincatlinks = '';
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $output .= &mt('The courseID provided does not match a community in this domain.');
+ } elsif ($env{'form.currcat_0'} eq 'placement::0') {
+ $output .= &mt('The courseID provided does not match a placement test in this domain.');
+ } else {
+ $output .= &mt('The courseID provided does not match a course in this domain.');
+ }
+ $output .= '
';
return $output;
}
} else {
if ($env{'form.currcat_0'} eq 'instcode::0') {
- %courses = &search_official_courselist($domain,$numtitles);
+ %courses = &search_official_courselist($domain,$numtitles,$codetitles);
} else {
- %courses = &search_courselist($domain);
+ %courses = &search_courselist($domain,$subcats);
}
if (keys(%courses) == 0) {
- $output = &mt('No courses match the criteria you selected.');
+ $output = '';
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $output .= &mt('No communities match the criteria you selected.');
+ } elsif ($env{'form.currcat_0'} eq 'placement::0') {
+ $output .= &mt('No placement tests match the criteria you selected.');
+ } else {
+ $output .= &mt('No courses match the criteria you selected.');
+ }
+ $output .= '
';
return $output;
}
- if (($knownuser) && (!$env{'form.showdetails'}) && (!&user_is_dc($domain))) {
+ if (($knownuser) && (!$env{'form.showdetails'}) && (!&user_is_dc($domain)) && (!$canviewall)) {
$output = '