--- loncom/interface/coursecatalog.pm 2010/02/12 00:21:30 1.53.4.4 +++ loncom/interface/coursecatalog.pm 2010/10/07 14:41:49 1.65 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler for displaying the course catalog interface # -# $Id: coursecatalog.pm,v 1.53.4.4 2010/02/12 00:21:30 raeburn Exp $ +# $Id: coursecatalog.pm,v 1.65 2010/10/07 14:41:49 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -87,8 +87,9 @@ 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); + &course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems,\@codetitles); } else { my ($catlinks,$has_subcats,$selitem) = &category_breadcrumbs($codedom,@cats); my $catjs = <<"ENDSCRIPT"; @@ -114,12 +115,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); + $catlinks,$catjs,\@codetitles); if ($env{'form.state'} eq 'listing') { - $r->print(&print_course_listing($codedom,$numtitles)); + $r->print(&print_course_listing($codedom,$numtitles,undef,undef,undef, + \@codetitles)); } } else { my (%add_entries); @@ -164,7 +165,7 @@ ENDJS $display_button.'" />

'); } if ($env{'form.state'} eq 'listing') { - $r->print(&print_course_listing($codedom,undef,\@trails,\%allitems,$subcats)); + $r->print(&print_course_listing($codedom,undef,\@trails,\%allitems,$subcats,\@codetitles)); } } } @@ -173,7 +174,7 @@ ENDJS } sub course_details { - my ($r,$codedom,$formname,$domdesc,$trails,$allitems) = @_; + my ($r,$codedom,$formname,$domdesc,$trails,$allitems,$codetitles) = @_; my $output; my %add_entries = (topmargin => "0", marginheight => "0",); @@ -181,26 +182,41 @@ 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 $brtexttwo = 'Course details'; + if ($env{'form.currcat_0'} eq 'communities::0') { + $brtextone = 'Community listing'; + $brtexttwo = 'Community details'; + } &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:document.$formname.submit()", - text=>"Course listing"}, - {text=>"Course details"}); + text=>$brtextone}, + {text=>$brtexttwo}); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog')); - $r->print('
'.&mt('Detailed course information:').'

'. - &print_course_listing($codedom,undef,$trails,$allitems). + $r->print('
'); + if ($env{'form.currcat_0'} eq 'communities::0') { + $r->print(&mt('Detailed community information:')); + } else { + $r->print(&mt('Detailed course information:')); + } + $r->print('

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

'); $r->print('
'. - ''. - &mt('Back to course listing').''. + ''); + if ($env{'form.currcat_0'} eq 'communities::0') { + $r->print(&mt('Back to community listing')); + } else { + $r->print(&mt('Back to course listing')); + } + $r->print(''. &Apache::lonhtmlcommon::echo_form_input(['coursenum','catalogfilter', 'showdetails','courseid']).'
'); return; @@ -233,10 +249,9 @@ END } sub instcode_course_selector { - my ($r,$codedom,$formname,$domdesc,$catlinks,$catjs) = @_; + my ($r,$codedom,$formname,$domdesc,$catlinks,$catjs,$codetitles) = @_; my %coursecodes = (); my %codes = (); - my @codetitles = (); my %cat_titles = (); my %cat_order = (); my %cat_items; @@ -246,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) { @@ -263,7 +278,7 @@ 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". @@ -289,20 +304,22 @@ sub instcode_course_selector { sub cat_header { my ($r,$codedom,$js,$add_entries,$catlinks,$numtitles) = @_; my $start_page = - &Apache::loncommon::start_page('Course/Community Catalog',$js, - { - 'add_entries' => $add_entries, - 'no_inline_link' => 1,}); + &Apache::loncommon::start_page('Other',$js, + { 'add_entries' => $add_entries, }); $r->print($start_page); + my $brtext = 'Course listing'; + if ($env{'form.currcat_0'} eq 'communities::0') { + $brtext = 'Community listing'; + } if ($env{'form.state'} eq 'listing') { if ($numtitles > 0) { &Apache::lonhtmlcommon::add_breadcrumb ({href=>"/adm/coursecatalog", text=>"Course/Community Catalog"}, - {text=>"Course listing"}); + {text=>$brtext}); } else { &Apache::lonhtmlcommon::add_breadcrumb - ({text=>"Course listing"}); + ({text=>$brtext}); } } else { &Apache::lonhtmlcommon::add_breadcrumb @@ -310,10 +327,7 @@ sub cat_header { text=>"Course/Community Catalog"}); } $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog')); - my $onchange; - unless (($env{'browser.interface'} eq 'textual') || ($env{'form.interface'} eq 'textual')) { - $onchange = 'this.form.submit()'; - } + my $onchange = 'this.form.submit()'; $r->print('
'. ''. - ''. - ''; + if ($env{'form.currcat_0'} eq 'communities::0') { + $output .= ''; + } else { + $output .= + ''. + ''. + ''; + } } else { $output .= ''; } @@ -975,10 +997,14 @@ sub courseinfo_row { ''; if ($knownuser) { if ($details) { - $output .= - ''. - ''. - ''; + if ($env{'form.currcat_0'} eq 'communities::0') { + $output .= ''; + } else { + $output .= + ''. + ''. + ''; + } } else { $output .= "'; }
'.&mt('Domain:').''. &Apache::loncommon::select_dom_form($codedom,'showdom','',1,$onchange)); @@ -366,7 +380,7 @@ sub category_breadcrumbs { } else { $catlinks .= &mt('Official courses (with institutional codes)'); $env{'form.currcat_0'} = 'instcode::0'; - $currcat_str .= ''; + $currcat_str .= ''; } if ($deeper) { for (my $i=1; $i<=$deeper; $i++) { @@ -381,7 +395,7 @@ sub category_breadcrumbs { $catlinks .= ''; for (my $j=0; $j<@{$cats[$shallower]{$container}}; $j++) { my $name = $cats[$shallower]{$container}[$j]; - my $item = &escape($name).':'.$container.':'.$shallower; + my $item = &escape($name).':'.&escape($container).':'.$shallower; my $selected = ''; if ($item eq $env{'form.currcat_'.$shallower}) { $selected = ' selected="selected"'; @@ -561,8 +575,8 @@ sub user_is_dc { } sub search_official_courselist { - my ($domain,$numtitles) = @_; - my $instcode = &Apache::courseclassifier::instcode_search_str($domain,$numtitles); + my ($domain,$numtitles,$codetitles) = @_; + my $instcode = &Apache::courseclassifier::instcode_search_str($domain,$numtitles,$codetitles); my $showhidden; if (&user_is_dc($domain)) { $showhidden = $env{'form.showhidden'}; @@ -619,7 +633,7 @@ sub search_courselist { } sub print_course_listing { - my ($domain,$numtitles,$trails,$allitems,$subcats) = @_; + my ($domain,$numtitles,$trails,$allitems,$subcats,$codetitles) = @_; my $output; my %courses; my $knownuser = &user_is_known(); @@ -634,12 +648,16 @@ sub print_course_listing { $env{'form.coursenum'}, undef,undef,'.',1); if (keys(%courses) == 0) { - $output .= &mt('The courseID provided does not match a course in this domain.'); + if ($env{'form.currcat_0'} eq 'communities::0') { + $output .= &mt('The courseID provided does not match a community in this domain.'); + } 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); + %courses = &search_official_courselist($domain,$numtitles,$codetitles); } else { %courses = &search_courselist($domain,$subcats); } @@ -703,10 +721,14 @@ sub construct_data_table { } if ($knownuser) { if ($details) { - $output .= - ''.&mt('Default Access Dates for Students').''.&mt('Student Counts').''.&mt('Auto-enrollment of[_1]registered students','
').'
'.&mt('Default Access Dates for Members').''.&mt('Default Access Dates for Students').''.&mt('Student Counts').''.&mt('Auto-enrollment of[_1]registered students','
').'
'.&mt('Details').''.$ownerlast.''.$accessdates.''.$counts.''.$autoenrollment.''.$accessdates.''.$accessdates.''.$counts.''.$autoenrollment.'".&mt('Show more details').'