Diff for /loncom/interface/lonhtmlcommon.pm between versions 1.52 and 1.53

version 1.52, 2004/02/18 08:07:16 version 1.53, 2004/02/20 16:21:49
Line 835  sub htmlareabrowser { Line 835  sub htmlareabrowser {
     return 1;      return 1;
 }  }
   
   ############################################################
   ############################################################
   
   =pod
   
   =item breadcrumbs
   
   Compiles the previously registered breadcrumbs into an series of links.
   FAQ and BUG links will be placed on the left side of the table if they
   are defined for the last registered breadcrumb.  
   Additionally supports a 'component', which will be displayed on the
   right side of the table (without a link).
   A link to help for the component will be included if one is specified.
   
   All inputs can be undef without problems.
   
   Inputs: $color (the background color of the table returned),
           $component (the large text on the right side of the table),
           $component_help
   
   Returns a string containing breadcrumbs for the current page.
   
   =item clear_breadcrumbs
   
   Clears the previously stored breadcrumbs.
   
   =item add_breadcrumb
   
   Pushes a breadcrumb on the stack of crumbs.
   
   input: $breadcrumb, a hash reference.  The keys 'href','title', and 'text'
   are required.  If present the keys 'faq' and 'bug' will be used to provide
   links to the FAQ and bug sites.
   
   returns: nothing    
   
   =cut
   
   ############################################################
   ############################################################
   {
       my @Crumbs;
   
       sub breadcrumbs {
           my ($color,$component,$component_help) = @_;
           $color = '#CCCCFF' if (! defined($color));
           #
           my $Str = "\n".
               '<table width="100%" border="0" cellpadding="0" cellspacing="0">'.
               '<tr><td bgcolor="'.$color.'">'.
               '<font size="-1">';
           # The last breadcrumb does not have a link, so handle it seperately.
           my $last = pop(@Crumbs);
           # The first one should be the course, I guess.
           if (exists($ENV{'request.course.id'})) {
               my $cid = $ENV{'request.course.id'};
               unshift(@Crumbs,{href=>'/adm/menu',
                                title=>'Go to main menu',
                                text=>$ENV{'course.'.$cid.'.description'},
                            });
           }
           my $links .= 
               join('-&gt;',
                    map {
                        '<a href="'.$_->{'href'}.'" title="'.$_->{'title'}.'">'.
                            $_->{'text'}.'</a>' 
                        } @Crumbs
                    );
           $links .= '-&gt;' if ($links ne '');
           $links .= '<b>'.$last->{'text'}.'</b>';
           if (exists($last->{'bug'})) {
               $links = &Apache::loncommon::help_open_bug($last->{'bug'}).$links;
           }
           if (exists($last->{'faq'})) {
               $links = &Apache::loncommon::help_open_faq($last->{'faq'}).$links;
           }
           $Str .= $links.'</font></td>';
           if (defined($component)) {
               $Str .= '<td align="right" bgcolor="'.$color.'">'.
                   '<font size="+1">'.$component.'</font>';
               if (defined($component_help)) {
                   $Str .= 
                       &Apache::loncommon::help_open_topic($component_help);
               }
               $Str.= '</td>';
           }
           $Str .= '</tr></table>'."\n";
           #
           # Return the @Crumbs stack to what we started with
           push(@Crumbs,$last);
           shift(@Crumbs);
           #
           return $Str;
       }
   
       sub clear_breadcrumbs {
           undef(@Crumbs);
       }
   
       sub add_breadcrumb {
           push (@Crumbs,@_);
       }
   
   }
   
   ############################################################
   ############################################################
   
   
 1;  1;
   
 __END__  __END__

Removed from v.1.52  
changed lines
  Added in v.1.53


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