Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b251cc22

Von Sven Schöling vor mehr als 9 Jahren hinzugefügt

  • ID b251cc22f355941217493073e124ba3878d5530f
  • Vorgänger 15b1558e
  • Nachfolger cd306e61

Menüstruktur auf YAML geändert

Unterschiede anzeigen:

SL/Layout/MenuLeft.pm
40 40

  
41 41
sub section_menu {
42 42
  my ($menu) = @_;
43
  my @menuorder = @{ $menu->{ORDER} };
44 43
  my @items;
45 44
  my @id_stack = (-1);
46 45

  
47
  for my $item (@menuorder) {
48
    my $menuitem   = $menu->{$item};
49
    my $olabel     = apply { s/.*--// } $item;
50
    my $ml         = apply { s/--.*// } $item;
51
    my $icon_class = apply { $_ = lc $_; s/[^a-z0-9_-]/-/g } $menuitem->{ICON};
52
    my $level      = (0 + $item =~ s/--/--/g);
53
    my $spacer     = "s" . $level;
46
  for my $node ($menu->tree_walk) {
47
    my $level      = $node->{level};
54 48

  
55 49
    # do id stack
56 50
    push @id_stack, -1 if    $level > $#id_stack;
57 51
    pop @id_stack      while $level < $#id_stack;
58 52
    $id_stack[-1]++;
59 53

  
60
    my $label         = $::locale->text($olabel);
54
    my $label = $::locale->text($node->{name});
55
    my $href  = $menu->href_for_node($node);
61 56

  
62
    $menuitem->{module} ||= $::form->{script};
63
    $menuitem->{action} ||= "section_menu";
64
    $menuitem->{href}   ||= "$menuitem->{module}?action=$menuitem->{action}";
57
    my @common_args  = ($label, "s" . $level, join '_', @id_stack);
65 58

  
66
    # add other params
67
    foreach my $key (keys %$menuitem) {
68
      next if $key =~ /target|module|action|href|ICON/;
69
      $menuitem->{href} .= "&" . $::form->escape($key, 1) . "=";
70
      my ($value, $conf) = split(/=/, $menuitem->{$key}, 2);
71
      $value = $::myconfig{$value} . "/$conf" if ($conf);
72
      $menuitem->{href} .= $::form->escape($value, 1);
73
    }
74

  
75
    my @common_args  = ($label, $spacer, join '_', @id_stack);
76

  
77
    if ($spacer eq 's0') { # toplevel
78
      push @items, [ @common_args, "icon24 $icon_class", 'm' ];
79
    } elsif ($menuitem->{submenu}) {
59
    if (!$node->{parent}) { # toplevel
60
      push @items, [ @common_args, "icon24 $node->{icon}", 'm' ];
61
    } elsif ($node->{children}) {
80 62
      push @items, [ @common_args, "icon16 submenu", 'sm' ];
81
    } elsif ($menuitem->{module}) {
82
      push @items, [ @common_args, "icon16 $icon_class", 'i', $menuitem->{href}, $menuitem->{target} ];
63
    } else {
64
      push @items, [ @common_args, "icon16 $node->{icon}", 'i', $href, $node->{target} ];
83 65
    }
84 66
  }
85 67

  

Auch abrufbar als: Unified diff