--- loncom/interface/lonhtmlcommon.pm 2004/02/18 08:07:16 1.52 +++ loncom/interface/lonhtmlcommon.pm 2004/02/20 16:21:49 1.53 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.52 2004/02/18 08:07:16 www Exp $ +# $Id: lonhtmlcommon.pm,v 1.53 2004/02/20 16:21:49 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -835,6 +835,115 @@ sub htmlareabrowser { 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". + ''. + ''; + if (defined($component)) { + $Str .= ''; + } + $Str .= '
'. + ''; + # 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('->', + map { + ''. + $_->{'text'}.'' + } @Crumbs + ); + $links .= '->' if ($links ne ''); + $links .= ''.$last->{'text'}.''; + 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.''. + ''.$component.''; + if (defined($component_help)) { + $Str .= + &Apache::loncommon::help_open_topic($component_help); + } + $Str.= '
'."\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; __END__