[Bio] / WebApplication / WebMenu.pm Repository:
ViewVC logotype

Diff of /WebApplication/WebMenu.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3, Fri Apr 27 16:02:14 2007 UTC revision 1.4, Thu Jun 14 16:34:57 2007 UTC
# Line 117  Line 117 
117  =cut  =cut
118    
119  sub add_category {  sub add_category {
120      my ($self, $category, $url, $target, $right) = @_;      my ($self, $category, $url, $target, $right, $order) = @_;
121    
122      unless ($category) {      unless ($category) {
123          confess 'No category given.';          confess 'No category given.';
124      }      }
125    
126        unless ($order) {
127          $order = scalar(@{$self->{categories}});
128        }
129    
130      if (exists($self->{categories_index}->{$category})) {      if (exists($self->{categories_index}->{$category})) {
131          confess "Trying to add category '$category' which already exists.";          confess "Trying to add category '$category' which already exists.";
132      }      }
# Line 134  Line 138 
138      $self->{categories_index}->{$category} = scalar(@{$self->{categories}});      $self->{categories_index}->{$category} = scalar(@{$self->{categories}});
139    
140      # add the category and link      # add the category and link
141      push @{$self->{categories}}, [ $category, $url, $target, $right ];      push @{$self->{categories}}, [ $category, $url, $target, $right, $order ];
142    
143      # init the entries array for that category      # init the entries array for that category
144      $self->{entries}->{$category} = [];      $self->{entries}->{$category} = [];
# Line 233  Line 237 
237    my $html = "<div id='menu'>\n";    my $html = "<div id='menu'>\n";
238    $html .= "\t<ul id='nav'>\n";    $html .= "\t<ul id='nav'>\n";
239    
240    foreach (@{$self->{categories}}) {    my @ordered_categories = sort { $a->[4] <=> $b->[4] } @{$self->{categories}};
241      foreach (@ordered_categories) {
242    
243      my ($cat, $c_url, $c_target, $right) = @$_;      my ($cat, $c_url, $c_target, $right, $order) = @$_;
244    
245      # check if a right is required to see this category      # check if a right is required to see this category
246      if (defined($right)) {      if (defined($right)) {

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3