version 1.35, 2008/07/06 17:59:25
|
version 1.36, 2008/07/07 15:20:18
|
Line 74 sub handler {
|
Line 74 sub handler {
|
|
|
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['coursecategories'],$codedom); |
&Apache::lonnet::get_dom('configuration',['coursecategories'],$codedom); |
my (@cats,@trails,%allitems,%idx,@jsarray,$cathash); |
my (@cats,@trails,%allitems,%idx,@jsarray,%subcathash,$cathash); |
if (ref($domconfig{'coursecategories'}) eq 'HASH') { |
if (ref($domconfig{'coursecategories'}) eq 'HASH') { |
$cathash = $domconfig{'coursecategories'}{'cats'}; |
$cathash = $domconfig{'coursecategories'}{'cats'}; |
} else { |
} else { |
$cathash = {}; |
$cathash = {}; |
} |
} |
|
my $subcats; |
|
if ($env{'form.withsubcats'}) { |
|
$subcats = \%subcathash; |
|
} |
&Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems, |
&Apache::loncommon::extract_categories($cathash,\@cats,\@trails,\%allitems, |
\%idx,\@jsarray); |
\%idx,\@jsarray,$subcats); |
if ($env{'form.coursenum'} ne '' && &user_is_known()) { |
if ($env{'form.coursenum'} ne '' && &user_is_known()) { |
&course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems); |
&course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems); |
} else { |
} else { |
my $catlinks = &category_breadcrumbs($codedom,@cats); |
my ($catlinks,$has_subcats) = &category_breadcrumbs($codedom,@cats); |
my $catjs = <<"ENDSCRIPT"; |
my $catjs = <<"ENDSCRIPT"; |
|
|
function setCatDepth(depth) { |
function setCatDepth(depth) { |
document.coursecats.catalog_maxdepth.value = depth; |
document.coursecats.catalog_maxdepth.value = depth; |
|
if (depth == '') { |
|
document.coursecats.currcat_0.value = ''; |
|
} |
document.coursecats.submit(); |
document.coursecats.submit(); |
return; |
return; |
} |
} |
Line 120 function setCourseId(caller) {
|
Line 127 function setCourseId(caller) {
|
if ($env{'form.currcat_0'} ne '') { |
if ($env{'form.currcat_0'} ne '') { |
$r->print('<form name="'.$formname. |
$r->print('<form name="'.$formname. |
'" method="post" action="/adm/coursecatalog">'. |
'" method="post" action="/adm/coursecatalog">'. |
&additional_filters($codedom)."\n"); |
&additional_filters($codedom,$has_subcats)."\n"); |
my ($currdepth,$deeper) = &get_depth_values(); |
my ($currdepth,$deeper) = &get_depth_values(); |
$r->print('<input type="hidden" name="catalog_maxdepth" value="'. |
$r->print('<input type="hidden" name="catalog_maxdepth" value="'. |
$deeper.'" />'."\n"); |
$deeper.'" />'."\n"); |
Line 136 function setCourseId(caller) {
|
Line 143 function setCourseId(caller) {
|
&mt('Display courses').'" /></form><br /><br />'); |
&mt('Display courses').'" /></form><br /><br />'); |
} |
} |
if ($env{'form.state'} eq 'listing') { |
if ($env{'form.state'} eq 'listing') { |
$r->print(&print_course_listing($codedom,undef,\@trails,\%allitems)); |
$r->print(&print_course_listing($codedom,undef,\@trails,\%allitems,$subcats)); |
} |
} |
} |
} |
} |
} |
Line 367 sub category_breadcrumbs {
|
Line 374 sub category_breadcrumbs {
|
my ($currdepth,$deeper) = &get_depth_values(); |
my ($currdepth,$deeper) = &get_depth_values(); |
my $currcat_str = '<input type="hidden" name="catalog_maxdepth" value="'.$deeper.'" /><input type="hidden" name="showdom" value="'.$dom.'" />'; |
my $currcat_str = '<input type="hidden" name="catalog_maxdepth" value="'.$deeper.'" /><input type="hidden" name="showdom" value="'.$dom.'" />'; |
my $catlinks = '<td valign="top"><b>'.&mt('Catalog:').'</b></td><td><table><tr>'; |
my $catlinks = '<td valign="top"><b>'.&mt('Catalog:').'</b></td><td><table><tr>'; |
|
my $has_subcats; |
for (my $i=0; $i<$deeper; $i++) { |
for (my $i=0; $i<$deeper; $i++) { |
$currcat_str .= '<input type="hidden" name="currcat_'.$i.'" value="'.$env{'form.currcat_'.$i}.'" />'; |
$currcat_str .= '<input type="hidden" name="currcat_'.$i.'" value="'.$env{'form.currcat_'.$i}.'" />'; |
my ($cattitle,$shallower); |
my ($cattitle,$shallower); |
Line 387 sub category_breadcrumbs {
|
Line 395 sub category_breadcrumbs {
|
'<input type="hidden" name="currcat_0" value="instcode::0" />'; |
'<input type="hidden" name="currcat_0" value="instcode::0" />'; |
$env{'form.currcat_0'} = 'instcode::0'; |
$env{'form.currcat_0'} = 'instcode::0'; |
} else { |
} else { |
|
$has_subcats = 1; |
$catlinks .= '<select name="currcat_0">'."\n"; |
$catlinks .= '<select name="currcat_0">'."\n"; |
if (@{$cats[0]} > 1) { |
if (@{$cats[0]} > 1) { |
my $selstr; |
my $selstr; |
if ($env{'form.currcat_0'} eq '') { |
if ($env{'form.currcat_0'} eq '') { |
$selstr = ' selected="selected" '; |
$selstr = ' selected="selected" '; |
} |
} |
$catlinks .= '<option value=""'.$selstr.'>'.&mt('Select').'</option>'."\n"; |
$catlinks .= '<option value="" selected="selected">'.&mt('Select').'</option>'."\n"; |
} |
} |
for (my $i=0; $i<@{$cats[0]}; $i++) { |
for (my $i=0; $i<@{$cats[0]}; $i++) { |
my $name = $cats[0][$i]; |
my $name = $cats[0][$i]; |
my $item = &escape($name).'::0'; |
my $item = &escape($name).'::0'; |
my $selstr; |
$catlinks .= '<option value="'.$item.'">'; |
if ($env{'form.currcat_'.$i} eq $item) { |
|
$selstr = ' selected="selected" '; |
|
} |
|
$catlinks .= '<option value="'.$item.'"'.$selstr.'>'; |
|
if ($name eq 'instcode') { |
if ($name eq 'instcode') { |
$catlinks .= &mt('Official courses (with institutional codes)'); |
$catlinks .= &mt('Official courses (with institutional codes)'); |
} else { |
} else { |
Line 433 sub category_breadcrumbs {
|
Line 438 sub category_breadcrumbs {
|
} |
} |
$catlinks .= '<td>'.$currcat; |
$catlinks .= '<td>'.$currcat; |
if (ref($cats[$deeper]{$cat}) eq 'ARRAY') { |
if (ref($cats[$deeper]{$cat}) eq 'ARRAY') { |
|
$has_subcats = 1; |
|
my $selstr; |
$catlinks .= ': <select name="currcat_'.$deeper.'">'. |
$catlinks .= ': <select name="currcat_'.$deeper.'">'. |
'<option value="" selected="selected">'.&mt('Select').'</option>'; |
'<option value="" selected="selected">'. |
|
&mt('Select').'</option>'; |
for (my $k=0; $k<@{$cats[$deeper]{$cat}}; $k++) { |
for (my $k=0; $k<@{$cats[$deeper]{$cat}}; $k++) { |
my $name = $cats[$deeper]{$cat}[$k]; |
my $name = $cats[$deeper]{$cat}[$k]; |
my $item = &escape($name).':'.&escape($cat).':'.$deeper; |
my $item = &escape($name).':'.&escape($cat).':'.$deeper; |
Line 445 sub category_breadcrumbs {
|
Line 453 sub category_breadcrumbs {
|
} |
} |
} |
} |
$catlinks .= $currcat_str.'</td></tr></table></td>'; |
$catlinks .= $currcat_str.'</td></tr></table></td>'; |
return $catlinks; |
return ($catlinks,$has_subcats); |
} |
} |
|
|
sub get_depth_values { |
sub get_depth_values { |
Line 463 sub get_depth_values {
|
Line 471 sub get_depth_values {
|
} |
} |
|
|
sub additional_filters { |
sub additional_filters { |
my ($codedom) = @_; |
my ($codedom,$has_subcats) = @_; |
my $output = '<table>'; |
my $output = '<table>'; |
|
if (($env{'form.currcat_0'} ne 'instcode::0') && |
|
($env{'form.currcat_0'} ne '') && ($has_subcats)) { |
|
my $include_subcat_status; |
|
if ($env{'form.withsubcats'}) { |
|
$include_subcat_status = 'checked="checked" '; |
|
} |
|
my $counter = $env{'form.catalog_maxdepth'}; |
|
if ($counter > 0) { |
|
if ($env{'form.state'} eq 'listing') { |
|
$counter --; |
|
} elsif ($env{'form.currcat_'.$counter} eq '') { |
|
$counter --; |
|
} |
|
} |
|
my ($catname) = split(/:/,$env{'form.currcat_'.$counter}); |
|
if ($catname ne '') { |
|
$output .= '<tr><td><label>'. |
|
'<input type="checkbox" name="withsubcats" value="1" '. |
|
$include_subcat_status.'/>'. |
|
&mt('Include subcategories within "[_1]"',$catname). |
|
'</label></td></tr>'; |
|
} |
|
} |
my $show_selfenroll_status; |
my $show_selfenroll_status; |
if ($env{'form.showselfenroll'}) { |
if ($env{'form.showselfenroll'}) { |
$show_selfenroll_status = 'checked="checked" '; |
$show_selfenroll_status = 'checked="checked" '; |
} |
} |
|
$output .= '<tr><td>'. |
|
'<label><input type="checkbox" name="showselfenroll" value="1" '. |
|
$show_selfenroll_status.'/>'. |
|
&mt('Only show courses which allow self-enrollment'). |
|
'</label></td></tr>'; |
if (&user_is_dc($codedom)) { |
if (&user_is_dc($codedom)) { |
my $showdetails_status; |
my $showdetails_status; |
if ($env{'form.showdetails'}) { |
if ($env{'form.showdetails'}) { |
Line 481 sub additional_filters {
|
Line 517 sub additional_filters {
|
my $dc_title = &Apache::lonnet::plaintext('dc'); |
my $dc_title = &Apache::lonnet::plaintext('dc'); |
$output .= '<tr><td>'."\n". |
$output .= '<tr><td>'."\n". |
'<label><input type="checkbox" name="showdetails" value="1" '. |
'<label><input type="checkbox" name="showdetails" value="1" '. |
$showdetails_status.'/>'."\n". |
$showdetails_status.'/>'. |
&mt('Show full details for each course ([_1] only)',$dc_title). |
&mt('Show full details for each course ([_1] only)',$dc_title). |
'</label>'."\n".'</td></tr><tr><td>'. |
'</label>'."\n".'</td></tr><tr><td>'. |
'<label><input type="checkbox" name="showhidden" value="1" '. |
'<label><input type="checkbox" name="showhidden" value="1" '. |
Line 489 sub additional_filters {
|
Line 525 sub additional_filters {
|
&mt('Include courses set to be hidden from catalog ([_1] only)',$dc_title). |
&mt('Include courses set to be hidden from catalog ([_1] only)',$dc_title). |
'</label>'."\n".'</td></tr>'; |
'</label>'."\n".'</td></tr>'; |
} |
} |
$output .= '<tr><td>'. |
$output .= '</table><br />'; |
'<label><input type="checkbox" name="showselfenroll" value="1" '. |
|
$show_selfenroll_status.'/>'. |
|
&mt('Only show courses which allow self-enrollment'). |
|
'</label></td></tr></table><br />'; |
|
return $output; |
return $output; |
} |
} |
|
|
Line 629 sub search_official_courselist {
|
Line 661 sub search_official_courselist {
|
} |
} |
|
|
sub search_courselist { |
sub search_courselist { |
my ($domain) = @_; |
my ($domain,$subcats) = @_; |
my $cat_maxdepth = $env{'form.catalog_maxdepth'}; |
my $cat_maxdepth = $env{'form.catalog_maxdepth'}; |
my $filter = $env{'form.currcat_'.$cat_maxdepth}; |
my $filter = $env{'form.currcat_'.$cat_maxdepth}; |
if (($filter eq '') && ($cat_maxdepth > 0)) { |
if (($filter eq '') && ($cat_maxdepth > 0)) { |
Line 637 sub search_courselist {
|
Line 669 sub search_courselist {
|
$filter = $env{'form.currcat_'.$shallower}; |
$filter = $env{'form.currcat_'.$shallower}; |
} |
} |
my %courses; |
my %courses; |
|
my $filterstr; |
if ($filter ne '') { |
if ($filter ne '') { |
|
if ($env{'form.withsubcats'}) { |
|
if (ref($subcats) eq 'HASH') { |
|
if (ref($subcats->{$filter}) eq 'ARRAY') { |
|
$filterstr = join('&',@{$subcats->{$filter}}); |
|
if ($filterstr ne '') { |
|
$filterstr = $filter.'&'.$filterstr; |
|
} |
|
} else { |
|
$filterstr = $filter; |
|
} |
|
} else { |
|
$filterstr = $filter; |
|
} |
|
} else { |
|
$filterstr = $filter; |
|
} |
my $showhidden; |
my $showhidden; |
if (&user_is_dc($domain)) { |
if (&user_is_dc($domain)) { |
$showhidden = $env{'form.showhidden'}; |
$showhidden = $env{'form.showhidden'}; |
Line 645 sub search_courselist {
|
Line 694 sub search_courselist {
|
%courses = |
%courses = |
&Apache::lonnet::courseiddump($domain,'.',1,'.','.','.',undef,undef, |
&Apache::lonnet::courseiddump($domain,'.',1,'.','.','.',undef,undef, |
'.',1,$env{'form.showselfenroll'}, |
'.',1,$env{'form.showselfenroll'}, |
$filter,$showhidden,'coursecatalog'); |
$filterstr,$showhidden,'coursecatalog'); |
} |
} |
return %courses; |
return %courses; |
} |
} |
|
|
sub print_course_listing { |
sub print_course_listing { |
my ($domain,$numtitles,$trails,$allitems) = @_; |
my ($domain,$numtitles,$trails,$allitems,$subcats) = @_; |
my $output; |
my $output; |
my %courses; |
my %courses; |
my $knownuser = &user_is_known(); |
my $knownuser = &user_is_known(); |
Line 673 sub print_course_listing {
|
Line 722 sub print_course_listing {
|
if ($env{'form.currcat_0'} eq 'instcode::0') { |
if ($env{'form.currcat_0'} eq 'instcode::0') { |
%courses = &search_official_courselist($domain,$numtitles); |
%courses = &search_official_courselist($domain,$numtitles); |
} else { |
} else { |
%courses = &search_courselist($domain); |
%courses = &search_courselist($domain,$subcats); |
} |
} |
if (keys(%courses) == 0) { |
if (keys(%courses) == 0) { |
$output = &mt('No courses match the criteria you selected.'); |
$output = &mt('No courses match the criteria you selected.'); |
Line 689 sub print_course_listing {
|
Line 738 sub print_course_listing {
|
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
&Apache::lonnet::get_dom('configuration',['usercreation'],$domain); |
$output .= &construct_data_table($knownuser,\%courses,$details,undef,$now,\%domconfig,$trails,$allitems); |
$output .= &construct_data_table($knownuser,\%courses,$details,undef,$now,\%domconfig,$trails,$allitems); |
$output .= &Apache::lonhtmlcommon::echo_form_input(['coursenum','state','catalogfilter','sortby','showdetails']); |
if ($env{'form.coursenum'} ne '') { |
|
$output .= &Apache::lonhtmlcommon::echo_form_input(['coursenum','state','catalogfilter','sortby','showdetails']); |
|
} |
return $output; |
return $output; |
} |
} |
|
|