--- loncom/interface/loncommon.pm 2009/11/23 14:04:36 1.918 +++ loncom/interface/loncommon.pm 2009/11/23 21:45:18 1.919 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.918 2009/11/23 14:04:36 wenzelju Exp $ +# $Id: loncommon.pm,v 1.919 2009/11/23 21:45:18 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -9648,6 +9648,8 @@ sub extract_categories { my $trailstr; if ($name eq 'instcode') { $trailstr = &mt('Official courses (with institutional codes)'); + } elsif ($name eq 'communities') { + $trailstr = &mt('Communities'); } else { $trailstr = $name; } @@ -9760,12 +9762,14 @@ cathash - reference to hash of categorie currcat - scalar with an & separated list of categories assigned to a course. +type - scalar contains course type (Course or Community). + Returns: $output (markup to be displayed) =cut sub assign_categories_table { - my ($cathash,$currcat) = @_; + my ($cathash,$currcat,$type) = @_; my $output; if (ref($cathash) eq 'HASH') { my (@cats,@trails,%allitems,%idx,@jsarray,@path,$maxdepth); @@ -9774,15 +9778,20 @@ sub assign_categories_table { if (@cats > 0) { my $itemcount = 0; if (ref($cats[0]) eq 'ARRAY') { - $output = &Apache::loncommon::start_data_table(); my @currcategories; if ($currcat ne '') { @currcategories = split('&',$currcat); } + my $table; for (my $i=0; $i<@{$cats[0]}; $i++) { my $parent = $cats[0][$i]; - my $css_class = $itemcount%2?' class="LC_odd_row"':''; next if ($parent eq 'instcode'); + if ($type eq 'Community') { + next unless ($parent eq 'communities'); + } else { + next if ($parent eq 'communities'); + } + my $css_class = $itemcount%2?' class="LC_odd_row"':''; my $item = &escape($parent).'::0'; my $checked = ''; if (@currcategories > 0) { @@ -9790,18 +9799,26 @@ sub assign_categories_table { $checked = ' checked="checked"'; } } - $output .= ''. - ''.$parent.''. - ''; + my $parent_title = $parent; + if ($parent eq 'communities') { + $parent_title = &mt('Communities'); + } + $table .= ''. + ''.$parent_title.''. + ''; my $depth = 1; push(@path,$parent); - $output .= &assign_category_rows($itemcount,\@cats,$depth,$parent,\@path,\@currcategories); + $table .= &assign_category_rows($itemcount,\@cats,$depth,$parent,\@path,\@currcategories); pop(@path); - $output .= ''; + $table .= ''; $itemcount ++; } - $output .= &Apache::loncommon::end_data_table(); + if ($itemcount) { + $output = &Apache::loncommon::start_data_table(). + $table. + &Apache::loncommon::end_data_table(); + } } } }