4.x style
[freeside.git] / httemplate / elements / menubar.html
index ec6c13f..ffe83ec 100644 (file)
@@ -1,10 +1,64 @@
-%
-%  my($item, $url, @html);
-%  while (@_) {
-%    ($item, $url) = splice(@_,0,2);
-%    next if $item =~ /^\s*Main\s+Menu\s*$/i;
-%    push @html, qq!<A HREF="$url">$item</A>!;
-%  }
-%
-
-<% join(' | ', @html) %>
+<%doc>
+
+Example:
+
+  include( '/elements/menubar.html',
+           
+           #options hashref (optional)
+           { 'newstyle' => 1,  #may become the default at some point
+             'url_base' => '', #prepended to menubar URLs, for convenience
+             'selected' => '', #currently selected label
+           },
+
+           #menubar entries (required)
+           'label'  => $url,
+           'label2' => $url2,
+           #etc.
+
+         );
+
+</%doc>
+%if ( $opt->{'newstyle'} ) {
+
+   <DIV CLASS="fstabs">
+   <% join('', @html ) %>
+   </DIV>
+
+%} else {
+
+   <% join(' | ', @html) %>
+
+%}
+<%init>
+
+my $opt = ref($_[0]) ? shift : {};
+
+my $url_base = $opt->{'url_base'};
+
+my @html;
+while (@_) {
+
+  my ($item, $url) = splice(@_,0,2);
+  next if $item =~ /^\s*Main\s+Menu\s*$/i;
+
+  my $style = '';
+  if ( $opt->{'newstyle'} ) {
+
+    my $dclass = $item eq $opt->{'selected'}
+                   ? 'fstabselected'
+                   : 'fstab';
+
+    $style = qq( CLASS="$dclass" );
+
+  }
+
+  if ($item eq 'popup') {
+   push @html, $url;
+  }
+  else {
+    push @html, qq!<A HREF="$url_base$url" $style>$item</A>!;
+  }
+
+}
+
+</%init>