|;
- foreach my $category (@menu) { #FIXME: insert appropriate classnames for styles when they're finished.
- $menu_html .='
-
'.mt($category->{'categorytitle'}).'
-
';
- foreach my $item ( @{ $category->{items} } ) {
- next unless $item->{'permission'};
- $menu_html .= qq|';
- }
- $menu_html .= '
';
+ # 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]$_[0]>| : 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 tags wrapped @links
+ # and wrap everything in an enclosing and push it into
+ # @categories
+ # such that each element looks like:
+ #
+ # the category won't be added if there aren't any links
+ push @categories,
+ $div->($h3->(mt($$category{categorytitle}), {class=>"LC_hcell"}).
+ $ul->(join('' ,@links), {class =>"LC_ListStyleNormal" }),
+ {class=>"LC_ContentBoxSpecial"}) if scalar(@links);
}
- $menu_html .= qq|
|;
- return $menu_html;
-}
+ # wrap the joined @categories in another (column layout)
+ return $div->(join('', @categories), {class => "LC_columnSection"});
+}
1;