--- loncom/interface/coursecatalog.pm 2009/02/07 18:06:19 1.45 +++ loncom/interface/coursecatalog.pm 2009/02/07 22:03:45 1.48 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler for displaying the course catalog interface # -# $Id: coursecatalog.pm,v 1.45 2009/02/07 18:06:19 raeburn Exp $ +# $Id: coursecatalog.pm,v 1.48 2009/02/07 22:03:45 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -90,7 +90,7 @@ sub handler { if ($env{'form.coursenum'} ne '' && &user_is_known()) { &course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems); } else { - my ($catlinks,$has_subcats) = &category_breadcrumbs($codedom,@cats); + my ($catlinks,$has_subcats,$selitem) = &category_breadcrumbs($codedom,@cats); my $catjs = <<"ENDSCRIPT"; function setCatDepth(depth) { @@ -123,6 +123,16 @@ ENDSCRIPT } } else { my (%add_entries); + if ($selitem) { + $catjs .= <'; &cat_header($r,$codedom,$catjs,\%add_entries,$catlinks); if ($env{'form.currcat_0'} ne '') { @@ -388,11 +398,19 @@ sub cat_header { text=>"Select courses"}); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Select courses')); } + my $onchange; + unless (($env{'browser.interface'} eq 'textual') || ($env{'form.interface'} eq 'textual')) { + $onchange = 1; + } $r->print('
'. '
'.&mt('Domain:').''. - &Apache::loncommon::select_dom_form($codedom,'showdom','',1). - ' 
'. - '
'. + &Apache::loncommon::select_dom_form($codedom,'showdom','',1,$onchange)); + if (!$onchange) { + $r->print(' '); + } + $r->print('
'. + '
'. ''.$catlinks.'
'); return; } @@ -404,34 +422,48 @@ sub category_breadcrumbs { my $currcat_str = ''; my $catlinks = ''.&mt('Catalog:').''; my $has_subcats; + my $selitem; for (my $i=0; $i<$deeper; $i++) { $currcat_str .= ''; my ($cattitle,$shallower); if ($i == 0) { - $cattitle = &mt('Main Categories'); + if (ref($cats[0]) eq 'ARRAY') { + if (@{$cats[0]} > 1) { + $cattitle = &mt('Main Categories'); + } + } } else { $shallower = $i-1; my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$shallower}); $cattitle = $cat; } - $catlinks .= ''; + if ($cattitle ne '') { + $catlinks .= ''; + } } if ($deeper == 0) { - $catlinks .= '
'.$cattitle.''.$crumbsymbol.''.$cattitle.''.$crumbsymbol.''.&mt('Main Categories').': '; + $catlinks .= ''; 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'; + if ((@{$cats[0]} == 1) && (@cats == 1)) { + if ($cats[0][0] eq 'instcode') { + $catlinks .= &mt('Official courses (with institutional codes)'). + ''; + $env{'form.currcat_0'} = 'instcode::0'; + } else { + my $name = $cats[0][0]; + my $item = &escape($name).'::0'; + $catlinks .= $name. + ''; + $env{'form.currcat_0'} = $item; + } } else { $has_subcats = 1; - $catlinks .= ''."\n"; if (@{$cats[0]} > 1) { - my $selstr; - if ($env{'form.currcat_0'} eq '') { - $selstr = ' selected="selected" '; - } - $catlinks .= ''."\n"; + $catlinks .= ''."\n"; + $buttontext = &mt('Pick main category'); } for (my $i=0; $i<@{$cats[0]}; $i++) { my $name = $cats[0][$i]; @@ -445,7 +477,8 @@ sub category_breadcrumbs { $catlinks .= ''."\n"; } $catlinks .= ''."\n". - ' '; + ' '; } } else { $catlinks .= &mt('Official courses (with institutional codes)'). @@ -465,24 +498,31 @@ sub category_breadcrumbs { if ($cat eq 'instcode') { $currcat = &mt('Official courses (with institutional codes)'); } - $catlinks .= ''.$currcat; + $catlinks .= ''.$currcat.''; if (ref($cats[$deeper]{$cat}) eq 'ARRAY') { $has_subcats = 1; - my $selstr; - $catlinks .= ': '; + if (@{$cats[$deeper]{$cat}} > 1) { + $catlinks .= ''; + $buttontext = &mt('Pick subcategory'); + } for (my $k=0; $k<@{$cats[$deeper]{$cat}}; $k++) { my $name = $cats[$deeper]{$cat}[$k]; my $item = &escape($name).':'.&escape($cat).':'.$deeper; $catlinks .= ''."\n"; } $catlinks .= ''."\n". - ' '; + ' '; + } elsif ($cat ne 'instcode') { + $catlinks .= ' '.&mt('(No subcategories)'); } } $catlinks .= $currcat_str.'
'; - return ($catlinks,$has_subcats); + return ($catlinks,$has_subcats,$selitem); } sub get_depth_values {