[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.5, Wed Jun 27 21:04:32 2007 UTC
# Line 62  Line 62 
62                   entries => {},                   entries => {},
63                   categories => [],                   categories => [],
64                   categories_index => {},                   categories_index => {},
65                     search => 0,
66      };      };
67      bless $self, $class;      bless $self, $class;
68    
# Line 83  Line 84 
84      $self->{entries} = {};      $self->{entries} = {};
85      $self->{categories} = [];      $self->{categories} = [];
86      $self->{categories_index} = {};      $self->{categories_index} = {};
87        $self->{search} = 0;
88      return $self;      return $self;
89  }  }
90    
# Line 117  Line 119 
119  =cut  =cut
120    
121  sub add_category {  sub add_category {
122      my ($self, $category, $url, $target, $right) = @_;      my ($self, $category, $url, $target, $right, $order) = @_;
123    
124      unless ($category) {      unless ($category) {
125          confess 'No category given.';          confess 'No category given.';
126      }      }
127    
128        unless ($order) {
129          $order = scalar(@{$self->{categories}});
130        }
131    
132      if (exists($self->{categories_index}->{$category})) {      if (exists($self->{categories_index}->{$category})) {
133          confess "Trying to add category '$category' which already exists.";          confess "Trying to add category '$category' which already exists.";
134      }      }
# Line 134  Line 140 
140      $self->{categories_index}->{$category} = scalar(@{$self->{categories}});      $self->{categories_index}->{$category} = scalar(@{$self->{categories}});
141    
142      # add the category and link      # add the category and link
143      push @{$self->{categories}}, [ $category, $url, $target, $right ];      push @{$self->{categories}}, [ $category, $url, $target, $right, $order ];
144    
145      # init the entries array for that category      # init the entries array for that category
146      $self->{entries}->{$category} = [];      $self->{entries}->{$category} = [];
# Line 185  Line 191 
191      return keys(%{$_[0]->{categories_index}});      return keys(%{$_[0]->{categories_index}});
192  }  }
193    
194    =pod
195    
196    =item * B<search> (I<search_component>)
197    
198    Getter / Setter for the search component of the menu
199    
200    =cut
201    
202    sub search {
203      my ($self, $search) = @_;
204    
205      if (defined($search)) {
206        $self->{search} = $search;
207      }
208    
209      return $self->{search};
210    }
211    
212  =pod  =pod
213    
# Line 233  Line 256 
256    my $html = "<div id='menu'>\n";    my $html = "<div id='menu'>\n";
257    $html .= "\t<ul id='nav'>\n";    $html .= "\t<ul id='nav'>\n";
258    
259    foreach (@{$self->{categories}}) {    my @ordered_categories = sort { $a->[4] <=> $b->[4] } @{$self->{categories}};
260      foreach (@ordered_categories) {
261    
262      my ($cat, $c_url, $c_target, $right) = @$_;      my ($cat, $c_url, $c_target, $right, $order) = @$_;
263    
264      # check if a right is required to see this category      # check if a right is required to see this category
265      if (defined($right)) {      if (defined($right)) {
# Line 271  Line 295 
295    
296    $html .= "\t</ul>\n";    $html .= "\t</ul>\n";
297    
298      $html .= "<table style='position: absolute; right: 10px;'><tr>";
299      # check for search module
300      if ($self->search()) {
301        $html .= "<td>".$self->search->output()."</td>";
302      }
303    
304    # display user string    # display user string
305    if ($application->session->user) {    if ($application->session->user) {
306      $html .= qq~<div id="user" style="padding-top: 4px; padding-right: 5px; text-align: right;">      $html .= qq~<td><div id="user" style="padding-top: 2px;">
307                  <img height="15px" src="./Html/user.gif" title="Current User" />                  <img height="15px" src="./Html/user.gif" title="Current User" />
308                  <strong>~ . $application->session->user->firstname . " " . $application->session->user->lastname . qq~</strong></div>~;                  <strong>~ . $application->session->user->firstname . " " . $application->session->user->lastname . qq~</strong></div></td>~;
309    }    }
310      $html .= "</tr></table>";
311    
312    $html .= "</div>\n";    $html .= "</div>\n";
313    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3