--- loncom/interface/lonhtmlcommon.pm 2009/01/22 14:44:40 1.200 +++ loncom/interface/lonhtmlcommon.pm 2009/04/25 20:22:07 1.209 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.200 2009/01/22 14:44:40 bisitz Exp $ +# $Id: lonhtmlcommon.pm,v 1.209 2009/04/25 20:22:07 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -62,6 +62,29 @@ use Apache::lonlocal; use Apache::lonnet; use LONCAPA; +############################################## +############################################## + +=pod + +=item confirm_success + +Successful completion of an operation message + +=cut + +sub confirm_success { + my ($message,$failure)=@_; + if ($failure) { + return ''. + $message. + ' '; + } else { + return ''. + $message. + ' '; + } +} ############################################## ############################################## @@ -285,7 +308,7 @@ sub checkbox { $Str .= 'value="'.$value.'"'; } if ($checked) { - $Str .= ' checked="1"'; + $Str .= ' checked="checked"'; } $Str .= ' />'; return $Str; @@ -307,7 +330,7 @@ sub radio { $Str .= 'value="'.$value.'"'; } if ($checked eq $value) { - $Str .= ' checked="1"'; + $Str .= ' checked="checked"'; } $Str .= ' />'; return $Str; @@ -1305,10 +1328,15 @@ returns: nothing my @Crumbs; sub breadcrumbs { - my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt) = @_; + my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt, $no_realBreadcrumb) = @_; # $css_class ||= 'LC_breadcrumbs'; my $Str1 = '
    '; + + if($no_realBreadcrumb){ + $Str1 = '
'; + + + if($no_realBreadcrumb){ + $Str1 .= $links.''; + } else { + $Str1 .= $links.''; + } # if (defined($component)) { $Str .= "\n".'' @@ -1402,7 +1443,7 @@ returns: nothing # Return the @Crumbs stack to what we started with push(@Crumbs,$last); shift(@Crumbs); - # + # Return a table and after that the breadcrumb's line return "$Str\n$Str1"; } @@ -2032,10 +2073,11 @@ END # An array of following structure: # ({ categorytitle => 'Categorytitle', # items => [ -# { linktext => 'Text to be displayed', -# url => 'URL the link is pointing to, i.e. /adm/site?action=dosomething', +# { +# linktext => 'Text to be displayed', +# url => 'URL the link is pointing to, i.e. /adm/site?action=dosomething', # permission => 'Contains permissions as returned from lonnet::allowed(), -# must evaluate to true in order to activate the link', +# must evaluate to true in order to activate the link', # icon => 'icon filename', # alttext => 'alt text for the icon', # help => 'Name of the corresponding helpfile', @@ -2054,42 +2096,74 @@ END # subject to change during this project. # Don't rely on its current functionality as it might be # changed or removed. -# TODO: -# check for empty values # -------------------------- - sub generate_menu { my @menu = @_; - my $menu_html = qq|
|; - foreach my $category (@menu) { #FIXME: insert appropriate classnames for styles when they're finished. - $menu_html .='
-

'.mt($category->{'categorytitle'}).'

-
'; + # usage: $wrap->(element, content, {attribute => value,...}); + # output: content enclosed in html conform tags + my $wrap = sub { + return + qq|<$_[0]| + . join( '', map { qq| $_="${$_[2]}{$_}"| } keys %{ $_[2] } ) + . ($_[1] ? qq|>$_[1]| : qq|/>|). "\n"; + }; + + # subs for specific html elements + my $h3 = sub { return $wrap->( "h3", @_ ) }; + my $div = sub { return $wrap->( "div", @_ ) }; + my $ul = sub { return $wrap->( "ul", @_ ) }; + my $li = sub { return $wrap->( "li", @_ ) }; + my $a = sub { return $wrap->( "a", @_ ) }; + my $img = sub { return $wrap->( "img", @_ ) }; + + my @categories; # each element represents the entire markup for a category + + foreach my $category (@menu) { + my @links; # contains the links for the current $category + foreach my $link (@{$$category{items}}) { + next unless $$link{permission}; + + # create the markup for the current $link and push it into @links. + # each entry consists of an image and a text optionally followed + # by a help link. + push @links, $li->( + $a->( + $img->("", { + class => "LC_noBorder LC_middle", + src => "/res/adm/pages/$$link{icon}", + alt => mt(defined($$link{alttext}) ? + $$link{alttext} : $$link{linktext}) + }), { + href => $$link{url}, + title => mt($$link{linktitle}) + }). + $a->(mt($$link{linktext}), { + href => $$link{url}, + title => mt($$link{linktitle}), + class => "LC_menubuttons_link" + }). + (defined($$link{help}) ? + Apache::loncommon::help_open_topic($$link{help}) : ''), + {class => "LC_menubuttons_inline_text"}); + } + + # wrap categorytitle in

, concatenate with + # joined and in