--- loncom/interface/coursecatalog.pm 2013/03/04 02:33:21 1.74 +++ loncom/interface/coursecatalog.pm 2014/03/17 01:48:34 1.79 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler for displaying the course catalog interface # -# $Id: coursecatalog.pm,v 1.74 2013/03/04 02:33:21 raeburn Exp $ +# $Id: coursecatalog.pm,v 1.79 2014/03/17 01:48:34 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -66,13 +66,20 @@ 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); @@ -229,26 +236,25 @@ sub course_details { ({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:')); - } else { - $r->print(&mt('Detailed course information:')); - } - $r->print('

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

'); - $r->print('
'. - ''); - 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']).'
'); + $r->print( + &Apache::lonhtmlcommon::breadcrumbs('Course/Community Catalog'). + '

'. + (($env{'form.currcat_0'} eq 'communities::0') ? + &mt('Detailed community information:') : + &mt('Detailed course information:')). + '

'. + &print_course_listing($codedom,undef,$trails,$allitems,undef,$codetitles). + '
'. + '
'. + &Apache::lonhtmlcommon::actionbox([ + ''. + (($env{'form.currcat_0'} eq 'communities::0') ? + &mt('Back to community listing') : &mt('Back to course listing')). + '' + ]). + &Apache::lonhtmlcommon::echo_form_input(['coursenum','catalogfilter', + 'showdetails','courseid']). + '
'); return; } @@ -292,8 +298,11 @@ sub instcode_course_selector { my ($jscript,$totcodes,$numtitles,$lasttitle) = &Apache::courseclassifier::instcode_selectors_data($codedom,$formname, \%cat_items,$codetitles,\%cat_titles,\%cat_order); - my $js = ''; + my $js = ''; if ($totcodes) { if (($env{'form.state'} eq 'listing') && ($numtitles > 0)) { $add_entries{'onLoad'} = 'setElements();'; @@ -636,7 +645,7 @@ sub additional_filters { date => 'immediately prior to specific date:', ); my @statuses = &Apache::loncommon::get_env_multiple('form.showcounts'); - $output .= ''; + $output .= ''; if ($checked) { $output .= &get_wasactive_text(); } @@ -815,11 +824,13 @@ sub print_course_listing { $env{'form.coursenum'}, undef,undef,'.',1); if (keys(%courses) == 0) { + $output = '

'; 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.'); } + $output .= '

'; return $output; } } else { @@ -829,17 +840,13 @@ sub print_course_listing { %courses = &search_courselist($domain,$subcats); } if (keys(%courses) == 0) { + $output = '

'; if ($env{'form.currcat_0'} eq 'communities::0') { - $output = - '

' - .&mt('No communities match the criteria you selected.') - .'

'; + $output .= &mt('No communities match the criteria you selected.'); } else { - $output = - '

' - .&mt('No courses match the criteria you selected.') - .'

'; + $output .= &mt('No courses match the criteria you selected.'); } + $output .= '

'; return $output; } if (($knownuser) && (!$env{'form.showdetails'}) && (!&user_is_dc($domain))) { @@ -944,19 +951,20 @@ sub construct_data_table { $output .= ''.&mt('Self-enroll (if permitted)').''; &Apache::loncommon::end_data_table_header_row(); my (%numbers,%creditsum); - my ($showcredits,$defofficial,$defunofficial); + my ($showcredits,$defofficial,$defunofficial,$deftextbook); my %domdefaults = &Apache::lonnet::get_domain_defaults($domain); unless ($env{'form.currcat_0'} eq 'communities::0') { - if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) { + if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) { $showcredits = 1; $defofficial = $domdefaults{'officialcredits'}; - $defunofficial = $domdefaults{'unofficialcredits'}; + $defunofficial = $domdefaults{'unofficialcredits'}; + $deftextbook = $domdefaults{'textbookcredits'}; } } my %courseinfo = &build_courseinfo_hash($courses,$knownuser,$domain,$details, $usersections,\@fields,\%fieldtitles, $wasactiveon,\%numbers,\%creditsum, - $showcredits,$defofficial,$defunofficial); + $showcredits,$defofficial,$defunofficial,$deftextbook); my %Sortby; foreach my $course (sort(keys(%{$courses}))) { if ($env{'form.sortby'} eq 'code') {