Back to index

awl  0.53
Public Member Functions | Public Attributes
MenuOption Class Reference

List of all members.

Public Member Functions

 MenuOption ($label, $target, $title="", $style="menu", $sortkey=1000)
 

@-


 Render ()
 Convert the menu option into an HTML string.
 Set ($attribute, $value)
 Set arbitrary attributes of the menu option.
 Active ($style=false)
 Mark it as active, with a fancy style to distinguish that.
 AddSubmenu (&$submenu_set)
 This menu option is now promoted to the head of a tree.
 IsActive ()
 Whether this option is currently active.
 MaybeActive ($test_pattern, $active_style)
 Whether this option is currently active.

Public Attributes

 $label
 $target
 $title
 $active
 $sortkey
 $style
 $submenu_set
 $self
 $rendered

Detailed Description

Definition at line 21 of file MenuSet.php.


Member Function Documentation

MenuOption::Active ( style = false)

Mark it as active, with a fancy style to distinguish that.

Parameters:
string$styleA style used to highlight that the option is active.

Definition at line 139 of file MenuSet.php.

                                  {
    $this->active = true;
    if ( $style ) $this->style = $style;
  }

Here is the caller graph for this function:

MenuOption::AddSubmenu ( &$  submenu_set)

This menu option is now promoted to the head of a tree.

Definition at line 147 of file MenuSet.php.

                                       {
    $this->submenu_set = &$submenu_set;
  }

Whether this option is currently active.

Returns:
boolean The value of the active flag.

Definition at line 155 of file MenuSet.php.

                       {
    return ( $this->active );
  }
MenuOption::MaybeActive ( test_pattern,
active_style 
)

Whether this option is currently active.

Returns:
boolean The value of the active flag.

Definition at line 163 of file MenuSet.php.

                                                       {
    if ( is_string($test_pattern) && preg_match($test_pattern,$_SERVER['REQUEST_URI']) ) {
      $this->Active($active_style);
    }
    return ( $this->active );
  }

Here is the call graph for this function:

MenuOption::MenuOption ( label,
target,
title = "",
style = "menu",
sortkey = 1000 
)

@-

The thing we click

Parameters:
string$labelThe label to display for this option.
string$targetThe URL to target for this option.
string$titleSome tooltip help for the title tag.
string$styleA base class name for this option.
int$sortkeyAn (optional) value to allow option ordering.

Definition at line 92 of file MenuSet.php.

                                                                                  {
    $this->label  = $label;
    $this->target = $target;
    $this->title  = $title;
    $this->style  = $style;
    $this->attributes = array();
    $this->active = false;
    $this->sortkey = $sortkey;

    $this->rendered = "";
    $this->self  =& $this;
  }

Convert the menu option into an HTML string.

Returns:
string The HTML fragment for the menu option.

Definition at line 109 of file MenuSet.php.

                     {
    $r = sprintf('<a href="%s" class="%s" title="%s"%s>%s</a>',
            $this->target, $this->style, htmlspecialchars($this->title), "%%attributes%%",
            htmlspecialchars($this->label), $this->style );

    // Now process the generic attributes
    $attribute_values = "";
    foreach( $this->attributes AS $k => $v ) {
      if ( substr($k, 0, 1) == '_' ) continue;
      $attribute_values .= ' '.$k.'="'.htmlspecialchars($v).'"';
    }
    $r = str_replace( '%%attributes%%', $attribute_values, $r );

    $this->rendered = $r;
    return "$r";
  }
MenuOption::Set ( attribute,
value 
)

Set arbitrary attributes of the menu option.

Parameters:
string$attributeAn arbitrary attribute to be set in the hyperlink.
string$valueA value for this attribute.

Definition at line 131 of file MenuSet.php.

                                     {
    $this->attributes[$attribute] = $value;
  }

Member Data Documentation

Definition at line 47 of file MenuSet.php.

Definition at line 29 of file MenuSet.php.

Definition at line 81 of file MenuSet.php.

Definition at line 72 of file MenuSet.php.

Definition at line 53 of file MenuSet.php.

Definition at line 59 of file MenuSet.php.

Definition at line 65 of file MenuSet.php.

Definition at line 35 of file MenuSet.php.

Definition at line 41 of file MenuSet.php.


The documentation for this class was generated from the following file: