Diff for /loncom/interface/coursecatalog.pm between versions 1.57 and 1.58

version 1.57, 2009/11/23 21:45:18 version 1.58, 2009/11/23 22:02:50
Line 334  sub category_breadcrumbs { Line 334  sub category_breadcrumbs {
     my $currcat_str =       my $currcat_str = 
         '<input type="hidden" name="catalog_maxdepth" value="'.$deeper.'" />'.          '<input type="hidden" name="catalog_maxdepth" value="'.$deeper.'" />'.
         '<input type="hidden" name="showdom" value="'.$dom.'" />';          '<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><td>';
     my $has_subcats;      my $has_subcats;
     my $selitem;      my $selitem;
     for (my $i=0; $i<$deeper; $i++) {      if (ref($cats[0]) eq 'ARRAY') {
         $currcat_str .= '<input type="hidden" name="currcat_'.$i.'" value="'.$env{'form.currcat_'.$i}.'" />';          if (@{$cats[0]} == 0) {
         my ($cattitle,$shallower);              $catlinks .= &mt('No categories defined in this domain'); 
         if ($i == 0) {          } elsif (@{$cats[0]} == 1) {
             if (ref($cats[0]) eq 'ARRAY') {              if ($cats[0][0] eq 'instcode') {
                 if (@{$cats[0]} > 1) {                  $catlinks .= &mt('Official courses (with institutional codes)');
                     $cattitle = &mt('Main Categories');                  $env{'form.currcat_0'} = 'instcode::0';
                 }              } elsif ($cats[0][0] eq 'communities') {
                   $catlinks .= &mt('Communities');
                   $env{'form.currcat_0'} = 'communities::0';
               } else {
                   my $name = $cats[0][0];
                   my $item = &escape($name).'::0';
                   $catlinks .= $name;
                   $env{'form.currcat_0'} = $item;
             }              }
               $currcat_str .= '<input type="hidden" name="currcat_0" value="'.$env{'form.currcat_0'}.'" />';
         } else {          } else {
             $shallower = $i-1;              $catlinks .= &main_category_selector(@cats);
             my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$shallower});              if (($env{'form.currcat_0'} ne '') && 
             $cattitle = $cat;                  ($env{'form.currcat_0'} ne 'instcode::0')) {
         }                  $catlinks .= $crumbsymbol;
         if ($cattitle ne '') {              } else {
             $catlinks .= '<td valign="top"><a href="javascript:setCatDepth('."'$shallower'".')">'.$cattitle.'</a>'.$crumbsymbol.'</td>';                  $catlinks .= '</td>';
               }
         }          }
       } else {
           $catlinks .= &mt('Official courses (with institutional codes)');
                        $env{'form.currcat_0'} = 'instcode::0';
            $currcat_str .= '<input type="hidden" name="currcat_0" value="'.$env{'form.currcat_0'}.'" />';
     }      }
     if ($deeper == 0) {      if ($deeper) {
         $catlinks .= '<td>';          for (my $i=1; $i<=$deeper; $i++) {
         if (ref($cats[0]) eq 'ARRAY') {              my $shallower = $i-1;
             if ((@{$cats[0]} == 1) && (@cats == 1)) {              next if ($shallower == 0);
                 if ($cats[0][0] eq 'instcode') {              my ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$shallower});
                     $catlinks .= &mt('Official courses (with institutional codes)').              if ($cat ne '') {
                                  '<input type="hidden" name="currcat_0" value="instcode::0" />';                  $catlinks .= '<td valign="top">'.
                     $env{'form.currcat_0'} = 'instcode::0';                               '<select name="currcat_'.$shallower.'" onchange="'.
                 } elsif ($cats[0][0] eq 'communities') {                               'setCatDepth('."'$shallower'".');this.form.submit();">';
                     $catlinks .= &mt('Communities').                  if (ref($cats[$shallower]{$container}) eq 'ARRAY') {
                                  '<input type="hidden" name="currcat_0" value="instcode::0" />';                      $catlinks .= '<option value="">'.&mt('De-select').'</option>';
                     $env{'form.currcat_0'} = 'communities::0';                      for (my $j=0; $j<@{$cats[$shallower]{$container}}; $j++) {
                 } else {                          my $name = $cats[$shallower]{$container}[$j];
                     my $name = $cats[0][0];                          my $item = &escape($name).':'.$container.':'.$shallower;
                     my $item = &escape($name).'::0';                          my $selected = '';
                     $catlinks .= $name.                          if ($item eq $env{'form.currcat_'.$shallower}) {
                              '<input type="hidden" name="currcat_0" value="'.$item.'" />';                              $selected = ' selected="selected"';
                     $env{'form.currcat_0'} = $item;                          }
                 }                          $catlinks .= 
             } else {                             '<option value="'.$item.'"'.$selected.'>'.$name.'</option>';
                 $has_subcats = 1;  
                 my $buttontext = &mt('Show subcategories');  
                 $selitem = 'currcat_0';  
                 $catlinks .= '<select name="'.$selitem.'">'."\n";  
                 if (@{$cats[0]} > 1) {  
                     $catlinks .= '<option value="" selected="selected">'.&mt('Select').'</option>'."\n";  
                     $buttontext = &mt('Pick main category');  
                 }  
                 for (my $i=0; $i<@{$cats[0]}; $i++) {  
                     my $name = $cats[0][$i];  
                     my $item = &escape($name).'::0';  
                     $catlinks .= '<option value="'.$item.'">';  
                     if ($name eq 'instcode') {  
                         $catlinks .= &mt('Official courses (with institutional codes)');  
                     } elsif ($name eq 'communities') {  
                         $catlinks .= &mt('Communities');  
                     } else {  
                         $catlinks .= $name;  
                     }                      }
                     $catlinks .= '</option>'."\n";  
                 }                  }
                 $catlinks .= '</select>'."\n".                  $catlinks .= '</select>';
                              '&nbsp;<input type="submit" name="gocats" value="'.  
                              $buttontext.'" />';  
             }              }
         } else {              unless ($i == $deeper) {
             $catlinks .= &mt('Official courses (with institutional codes)').                  $catlinks .= $crumbsymbol;
                          '<input type="hidden" name="currcat_0" value="instcode::0" />';              } 
             $env{'form.currcat_0'} = 'instcode::0';  
         }          }
     } else {  
         my ($cat,$container,$depth);          my ($cat,$container,$depth);
         if ($env{'form.currcat_'.$currdepth} eq '') {          if ($env{'form.currcat_'.$currdepth} eq '') {
             my $shallower = $currdepth - 1;              my $shallower = $currdepth - 1;
Line 413  sub category_breadcrumbs { Line 403  sub category_breadcrumbs {
         } else {          } else {
             ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$currdepth});              ($cat,$container,$depth) = map { &unescape($_); } split(/:/,$env{'form.currcat_'.$currdepth});
         }          }
         my $deeper = $depth +1;          my $deeperlevel = $depth +1;
         my $currcat = $cat;          if (ref($cats[$deeperlevel]{$cat}) eq 'ARRAY') {
         if ($cat eq 'instcode') {  
             $currcat = &mt('Official courses (with institutional codes)');  
         } elsif ($cat eq 'communities') {  
             $currcat = &mt('Communities');  
         }  
         $catlinks .= '<td><b>'.$currcat.'</b>';  
         if (ref($cats[$deeper]{$cat}) eq 'ARRAY') {  
             $has_subcats = 1;              $has_subcats = 1;
             my $buttontext = &mt('Show subcategories');              my $buttontext = &mt('Show subcategories');
             $selitem = 'currcat_'.$deeper;              my $selitem = 'currcat_'.$deeperlevel;
             $catlinks .= ':&nbsp;<select name="'.$selitem.'">';              $catlinks .= '&nbsp;<select name="'.$selitem.'" onchange="this.form.submit()">';
             if (@{$cats[$deeper]{$cat}} > 1) {              if (@{$cats[$deeperlevel]{$cat}}) {
                 $catlinks .= '<option value="" selected="selected">'.                  $catlinks .= '<option value="" selected="selected">'.
                              &mt('Select').'</option>';                               &mt('Subcategory ...').'</option>';
                 $buttontext = &mt('Pick subcategory');  
             }              }
             for (my $k=0; $k<@{$cats[$deeper]{$cat}}; $k++) {              for (my $k=0; $k<@{$cats[$deeperlevel]{$cat}}; $k++) {
                 my $name = $cats[$deeper]{$cat}[$k];                  my $name = $cats[$deeperlevel]{$cat}[$k];
                 my $item = &escape($name).':'.&escape($cat).':'.$deeper;                  my $item = &escape($name).':'.&escape($cat).':'.$deeperlevel;
                 $catlinks .= '<option value="'.$item.'">'.$name.'</option>'."\n";                  $catlinks .= '<option value="'.$item.'">'.$name.'</option>'."\n";
             }              }
             $catlinks .= '</select>'."\n".              $catlinks .= '</select>'."\n";
                          '&nbsp;<input type="submit" name="gocats" value="'.  
                          $buttontext.'" />';  
         } elsif ($cat ne 'instcode') {          } elsif ($cat ne 'instcode') {
             $catlinks .= '&nbsp;'.&mt('(No subcategories)');              $catlinks .= '&nbsp;'.&mt('(No subcategories)');
         }          }
       } else {
           $selitem = 'currcat_0';
     }      }
     $catlinks .= $currcat_str.'</td></tr></table></td>';      $catlinks .= $currcat_str.'</td></tr></table></td>';
     return ($catlinks,$has_subcats,$selitem);      return ($catlinks,$has_subcats,$selitem);
 }  }
   
   sub main_category_selector {
       my (@cats) = @_;
       my $maincatlinks = '<select name="currcat_0" onchange="setCatDepth('."'0'".');this.form.submit();">'."\n";
       if (ref($cats[0]) eq 'ARRAY') {
           if (@{$cats[0]} > 1) {
               my $selected = '';
               if ($env{'form.currcat_0'} eq '') {
                   $selected = ' selected="selected"';    
               }
               $maincatlinks .= 
                   '<option value=""'.$selected.'>'.&mt('Select').'</option>'."\n";
           }
           for (my $i=0; $i<@{$cats[0]}; $i++) {
               my $name = $cats[0][$i];
               my $item = &escape($name).'::0';
               my $selected;
               if ($env{'form.currcat_0'} eq $item) {
                   $selected = ' selected="selected"';
               }
               $maincatlinks .= '<option value="'.$item.'"'.$selected.'>';
               if ($name eq 'instcode') {
                   $maincatlinks .= &mt('Official courses (with institutional codes)');
               } elsif ($name eq 'communities') {
                   $maincatlinks .= &mt('Communities');
               } else {
                   $maincatlinks .= $name;
               }
               $maincatlinks .= '</option>'."\n";
           }
           $maincatlinks .= '</select>'."\n";
       }
       return $maincatlinks;
   }
   
 sub get_depth_values {  sub get_depth_values {
     my $currdepth = 0;      my $currdepth = 0;
     my $deeper = 0;      my $deeper = 0;

Removed from v.1.57  
changed lines
  Added in v.1.58


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>