--- loncom/interface/coursecatalog.pm 2013/11/21 16:34:23 1.58.4.9 +++ loncom/interface/coursecatalog.pm 2010/04/04 15:38:34 1.60 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler for displaying the course catalog interface # -# $Id: coursecatalog.pm,v 1.58.4.9 2013/11/21 16:34:23 raeburn Exp $ +# $Id: coursecatalog.pm,v 1.60 2010/04/04 15:38:34 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -66,20 +66,13 @@ sub handler { } my $formname = 'coursecatalog'; if ($env{'form.showdom'} ne '') { - $env{'form.showdom'} = &LONCAPA::clean_domain($env{'form.showdom'}); if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') { $codedom = $env{'form.showdom'}; - } else { - $env{'form.showdom'} = ''; } } my $domdesc = &Apache::lonnet::domain($codedom,'description'); &Apache::lonhtmlcommon::clear_breadcrumbs(); - if ($env{'form.catalog_maxdepth'} ne '') { - $env{'form.catalog_maxdepth'} =~ s{\D}{}g; - } - my %domconfig = &Apache::lonnet::get_dom('configuration',['coursecategories'],$codedom); my (@cats,@trails,%allitems,%idx,@jsarray,%subcathash,$cathash); @@ -94,9 +87,8 @@ sub handler { } &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems, \%idx,\@jsarray,$subcats); - my ($numtitles,@codetitles); if ($env{'form.coursenum'} ne '' && &user_is_known()) { - &course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems,\@codetitles); + &course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems); } else { my ($catlinks,$has_subcats,$selitem) = &category_breadcrumbs($codedom,@cats); my $catjs = <<"ENDSCRIPT"; @@ -122,12 +114,12 @@ function setCourseId(caller) { ENDSCRIPT $catjs .= &courselink_javascript(); + my $numtitles; if ($env{'form.currcat_0'} eq 'instcode::0') { $numtitles = &instcode_course_selector($r,$codedom,$formname,$domdesc, - $catlinks,$catjs,\@codetitles); + $catlinks,$catjs); if ($env{'form.state'} eq 'listing') { - $r->print(&print_course_listing($codedom,$numtitles,undef,undef,undef, - \@codetitles)); + $r->print(&print_course_listing($codedom,$numtitles)); } } else { my (%add_entries); @@ -172,7 +164,7 @@ ENDJS $display_button.'" />

'); } if ($env{'form.state'} eq 'listing') { - $r->print(&print_course_listing($codedom,undef,\@trails,\%allitems,$subcats,\@codetitles)); + $r->print(&print_course_listing($codedom,undef,\@trails,\%allitems,$subcats)); } } } @@ -181,7 +173,7 @@ ENDJS } sub course_details { - my ($r,$codedom,$formname,$domdesc,$trails,$allitems,$codetitles) = @_; + my ($r,$codedom,$formname,$domdesc,$trails,$allitems) = @_; my $output; my %add_entries = (topmargin => "0", marginheight => "0",); @@ -189,25 +181,24 @@ sub course_details { &courselink_javascript().''."\n"; my $start_page = &Apache::loncommon::start_page('Course/Community Catalog',$js, - { - 'add_entries' => \%add_entries, - 'no_inline_link' => 1,}); + {'add_entries' => \%add_entries, }); $r->print($start_page); if ($env{'form.numtitles'} > 0) { &Apache::lonhtmlcommon::add_breadcrumb ({href=>"/adm/coursecatalog", text=>"Course/Community Catalog"}); } - my $brtextone = 'Course listing'; + my $brtextone = 'Course listing'; my $brtexttwo = 'Course details'; if ($env{'form.currcat_0'} eq 'communities::0') { $brtextone = 'Community listing'; - $brtexttwo = 'Community details'; + $brtextone = 'Community details'; } &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:document.$formname.submit()", text=>$brtextone}, {text=>$brtexttwo}); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog')); $r->print('
'); if ($env{'form.currcat_0'} eq 'communities::0') { $r->print(&mt('Detailed community information:')); @@ -215,7 +206,7 @@ sub course_details { $r->print(&mt('Detailed course information:')); } $r->print('

'. - &print_course_listing($codedom,undef,$trails,$allitems,undef,$codetitles). + &print_course_listing($codedom,undef,$trails,$allitems). '

'); $r->print('
'. ''); @@ -257,9 +248,10 @@ END } sub instcode_course_selector { - my ($r,$codedom,$formname,$domdesc,$catlinks,$catjs,$codetitles) = @_; + my ($r,$codedom,$formname,$domdesc,$catlinks,$catjs) = @_; my %coursecodes = (); my %codes = (); + my @codetitles = (); my %cat_titles = (); my %cat_order = (); my %cat_items; @@ -269,7 +261,7 @@ sub instcode_course_selector { marginheight => "0",); my ($jscript,$totcodes,$numtitles,$lasttitle) = &Apache::courseclassifier::instcode_selectors_data($codedom,$formname, - \%cat_items,$codetitles,\%cat_titles,\%cat_order); + \%cat_items,\@codetitles,\%cat_titles,\%cat_order); my $js = ''; if ($totcodes) { @@ -286,11 +278,12 @@ sub instcode_course_selector { if ($numtitles > 0) { $r->print(''.&mt('Choose which course(s) to list.').'
'. &Apache::courseclassifier::build_instcode_selectors($numtitles, - $lasttitle,\%cat_items,$codetitles,\%cat_titles,\%cat_order)); + $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order)); } $r->print(''."\n". ''."\n". ''."\n". + ''."\n". ''. ''.&mt('De-select').''; for (my $j=0; $j<@{$cats[$shallower]{$container}}; $j++) { my $name = $cats[$shallower]{$container}[$j]; - my $item = &escape($name).':'.&escape($container).':'.$shallower; + my $item = &escape($name).':'.$container.':'.$shallower; my $selected = ''; if ($item eq $env{'form.currcat_'.$shallower}) { $selected = ' selected="selected"'; @@ -587,8 +578,8 @@ sub user_is_dc { } sub search_official_courselist { - my ($domain,$numtitles,$codetitles) = @_; - my $instcode = &Apache::courseclassifier::instcode_search_str($domain,$numtitles,$codetitles); + my ($domain,$numtitles) = @_; + my $instcode = &Apache::courseclassifier::instcode_search_str($domain,$numtitles); my $showhidden; if (&user_is_dc($domain)) { $showhidden = $env{'form.showhidden'}; @@ -645,7 +636,7 @@ sub search_courselist { } sub print_course_listing { - my ($domain,$numtitles,$trails,$allitems,$subcats,$codetitles) = @_; + my ($domain,$numtitles,$trails,$allitems,$subcats) = @_; my $output; my %courses; my $knownuser = &user_is_known(); @@ -662,14 +653,14 @@ sub print_course_listing { if (keys(%courses) == 0) { if ($env{'form.currcat_0'} eq 'communities::0') { $output .= &mt('The courseID provided does not match a community in this domain.'); - } else { + } else { $output .= &mt('The courseID provided does not match a course in this domain.'); } return $output; } } else { if ($env{'form.currcat_0'} eq 'instcode::0') { - %courses = &search_official_courselist($domain,$numtitles,$codetitles); + %courses = &search_official_courselist($domain,$numtitles); } else { %courses = &search_courselist($domain,$subcats); } @@ -811,8 +802,8 @@ sub build_courseinfo_hash { $selfenroll_end = $courses->{$course}{'selfenroll_end_date'}; $categories = $courses->{$course}{'categories'}; push(@owners,$singleowner); - if ($courses->{$course}{'co-owners'} ne '') { - foreach my $item (split(/,/,$courses->{$course}{'co-owners'})) { + if (ref($courses->{$course}{'co-owners'}) eq 'ARRAY') { + foreach my $item (@{$courses->{$course}{'co-owners'}}) { push(@owners,$item); } } @@ -1011,9 +1002,9 @@ sub courseinfo_row { if ($details) { if ($env{'form.currcat_0'} eq 'communities::0') { $output .= ''.$accessdates.''; - } else { + } else { $output .= - ''.$accessdates.''. + ''.$accessdates.''. ''.$counts.''. ''.$autoenrollment.''; } @@ -1029,13 +1020,7 @@ sub courseinfo_row { if (($info->{'selfenroll_start'} > 0) && ($info->{'selfenroll_start'} > $now)) { $output .= ''.&mt('Starts: [_1]',''.$showstart.'').'
'.&mt('Ends: [_1]',''.$showend.'').''; } else { - $output .= '
'.&mt('Enroll in course').'
'; - if ($info->{'selfenroll_end'} == 0) { - $output .= &mt('Available permanently'); - } elsif ($info->{'selfenroll_end'} > $now) { - $output .= &mt('Self-enrollment ends: [_1]',''.$showend.''); - } - $output .= ''; + $output .= ''.&mt('Enroll in course').''; } $selfenroll = 1; }