--- loncom/interface/coursecatalog.pm 2008/06/27 04:59:45 1.32 +++ loncom/interface/coursecatalog.pm 2008/06/30 04:07:06 1.33 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler for displaying the course catalog interface # -# $Id: coursecatalog.pm,v 1.32 2008/06/27 04:59:45 raeburn Exp $ +# $Id: coursecatalog.pm,v 1.33 2008/06/30 04:07:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -84,6 +84,17 @@ function setCatDepth(depth) { } ENDSCRIPT + if ($env{'form.state'} eq 'listing') { + $catjs .= qq| +function changeSort(caller) { + document.$formname.sortby.value = caller; + document.$formname.submit(); +} +function setCourseId(caller) { + document.$formname.coursenum.value = caller; + document.$formname.submit(); +}\n|; + } my $numtitles; if ($env{'form.currcat_0'} eq 'instcode::0') { $numtitles = &instcode_course_selector($r,$codedom,$formname,$domdesc, @@ -96,6 +107,24 @@ ENDSCRIPT $catjs = ''; &cat_header($r,$codedom,$catjs,\%add_entries,$catlinks); if ($env{'form.currcat_0'} ne '') { + $r->print('
'. + &additional_filters($codedom)."\n"); + my ($currdepth,$deeper) = &get_depth_values(); + $r->print(''."\n"); + for (my $i=0; $i<$deeper; $i++) { + $r->print(''."\n"); + } + $r->print(''."\n". + ''."\n". + ''."\n". + ''. + '


'); + } + if ($env{'form.state'} eq 'listing') { $r->print(&print_course_listing($codedom)); } } @@ -212,51 +241,7 @@ function setElements() { $jscript .= '}'; } } - if ($env{'form.state'} eq 'listing') { - $jscript .= qq| -function changeSort(caller) { - document.$formname.sortby.value = caller; - copy_filters(); - document.$formname.submit(); -} -function setCourseId(caller) { - document.$formname.coursenum.value = caller; - copy_filters(); - document.$formname.submit(); -}\n|; - } - } - $jscript .= qq| -function copy_filters() { - if (document.coursecats.showselfenroll.checked) { - document.$formname.showselfenroll.value = '1'; - } else { - document.$formname.showselfenroll.value = ''; - } -|; - if (&user_is_dc($codedom)) { - $jscript .= qq| - if (document.coursecats.showhidden.checked) { - document.$formname.showhidden.value = '1'; - } else { - document.$formname.showhidden.value = ''; - } - if (document.coursecats.showdetails.checked) { - document.$formname.showdetails.value = '1'; - } else { - document.$formname.showdetails.value = ''; - } -|; } - $jscript .= qq| -} - -function display_courses() { - copy_filters(); - document.$formname.submit(); -} - -|; $js = ''; if (($env{'form.state'} eq 'listing') && ($numtitles > 0)) { @@ -268,11 +253,7 @@ function display_courses() { ''."\n". ''."\n". ''. - ''."\n"); - if (&user_is_dc($codedom)) { - $r->print(''."\n". - ''."\n"); - } + &additional_filters($codedom)); if ($numtitles > 0) { $r->print(''.&mt('Choose which course(s) to list.').'
'); $r->print(''); @@ -312,12 +293,14 @@ function display_courses() { } $r->print('
'); } - $r->print(''); - if ($numtitles > 0) { - $r->print(''); - } - $r->print(''); + $r->print(''."\n". + ''."\n". + ''."\n". + ''."\n". + ''. + ''); if (($numtitles > 0) && ($env{'form.state'} eq 'listing')) { $r->print('
'); } @@ -362,29 +345,9 @@ sub cat_header { ''. ''. - ''. - $catlinks.''); - my $show_selfenroll_status; - if ($env{'form.showselfenroll'}) { - $show_selfenroll_status = 'checked="checked" '; - } - if (&user_is_dc($codedom)) { - my $showdetails_status; - if ($env{'form.showdetails'}) { - $showdetails_status = 'checked="checked" '; - } - my $showhidden_status; - if ($env{'form.showhidden'}) { - $showhidden_status = 'checked="checked" '; - } - $r->print(''); - } - $r->print('
'.&mt('Domain:').''. &Apache::loncommon::select_dom_form($codedom,'showdom','',1). - ' 
'. - '

'); + ' '. + '
'. + $catlinks.'
'); return; } @@ -400,18 +363,8 @@ sub category_breadcrumbs { } &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems,\%idx, \@jsarray); - my $currdepth = 0; - my $deeper = 0; - my $currcat_str; - if ($env{'form.catalog_maxdepth'} ne '') { - $currdepth = $env{'form.catalog_maxdepth'}; - if ($env{'form.currcat_'.$currdepth} eq '') { - $deeper = $currdepth; - } else { - $deeper = $currdepth + 1; - } - } - $currcat_str = ''; + my ($currdepth,$deeper) = &get_depth_values(); + my $currcat_str = ''; my $catlinks = ''.&mt('Catalog:').''; for (my $i=0; $i<$deeper; $i++) { $currcat_str .= ''; @@ -457,7 +410,7 @@ sub category_breadcrumbs { $catlinks .= ''."\n"; } $catlinks .= ''."\n". - ' '; + ' '; } } else { $catlinks .= &mt('Official courses (with institutional codes)'). @@ -487,13 +440,62 @@ sub category_breadcrumbs { $catlinks .= ''."\n"; } $catlinks .= ''."\n". - ' '; + ' '; } } $catlinks .= $currcat_str.'
'; return $catlinks; } +sub get_depth_values { + my $currdepth = 0; + my $deeper = 0; + if ($env{'form.catalog_maxdepth'} ne '') { + $currdepth = $env{'form.catalog_maxdepth'}; + if ($env{'form.currcat_'.$currdepth} eq '') { + $deeper = $currdepth; + } else { + $deeper = $currdepth + 1; + } + } + return ($currdepth,$deeper); +} + +sub additional_filters { + my ($codedom) = @_; + my $output = ''; + my $show_selfenroll_status; + if ($env{'form.showselfenroll'}) { + $show_selfenroll_status = 'checked="checked" '; + } + if (&user_is_dc($codedom)) { + my $showdetails_status; + if ($env{'form.showdetails'}) { + $showdetails_status = 'checked="checked" '; + } + my $showhidden_status; + if ($env{'form.showhidden'}) { + $showhidden_status = 'checked="checked" '; + } + my $dc_title = &Apache::lonnet::plaintext('dc'); + $output .= ''; + } + $output .= '
'."\n". + ''."\n".'
'. + ''."\n".'
'. + '

'; + return $output; +} + sub user_is_dc { my ($codedom) = @_; if (exists($env{'user.role.dc./'.$codedom.'/'})) { @@ -661,7 +663,7 @@ sub print_course_listing { if ($env{'form.coursenum'} ne '') { %courses = &Apache::lonnet::courseiddump($domain,'.',1,'.','.', $env{'form.coursenum'}, - undef,undef,'Course',1); + undef,undef,'.',1); if (keys(%courses) == 0) { $output .= &mt('The courseID provided does not match a course in this domain.'); return $output;