Andrew's Web Libraries (AWL)
 All Classes Namespaces Functions Variables Pages
MenuSet Class Reference

Public Member Functions

 __construct ($div_id, $main_class= '', $active_class= 'active')
 
AddOption ($label, $target, $title="", $active=false, $sortkey=null, $external=false)
 
AddSubMenu (&$submenu_set, $label, $target, $title="", $active=false, $sortkey=2000)
 
 _HasActive ()
 
 Size ()
 
 _OptionExists ($newlabel)
 
 LinkActiveSubMenus ()
 
 MakeSomethingActive ($test_pattern)
 
 _CompareSequence ($a, $b)
 
 Render ($submenus_inline=false)
 
 RenderAsCSS ($depth=0, $skip_empty=true)
 

Public Attributes

 $div_id
 
 $main_class
 
 $active_class
 
 $options
 
 $parent
 
 $last_sortkey
 
 $has_active_options
 

Detailed Description

Definition at line 222 of file MenuSet.php.

Constructor & Destructor Documentation

MenuSet::__construct (   $div_id,
  $main_class = '',
  $active_class = 'active' 
)

#@- Start a new MenuSet with no options.

Parameters
string$div_idAn ID for the HTML div that the menu will be presented in.
string$main_classA CSS class for most menu options.
string$active_classA CSS class for active menu options.

Definition at line 276 of file MenuSet.php.

Member Function Documentation

MenuSet::_CompareSequence (   $a,
  $b 
)

_CompareSequence is used in sorting the menu options into the sequence order

Parameters
objectref$aThe first menu option
objectref$bThe second menu option
Returns
int ( $a == b ? 0 ( $a > b ? 1 : -1 ))

Definition at line 448 of file MenuSet.php.

MenuSet::_HasActive ( )

Does the menu have any options that are active. Most likely used so that we can then set the parent menu as active.

Parameters
string$labelA Label for the new menu option
Returns
boolean Whether the menu has options that are active.

Definition at line 354 of file MenuSet.php.

MenuSet::_OptionExists (   $newlabel)

See if a menu already has this option

Returns
boolean Whether the option already exists in the menu.

Definition at line 380 of file MenuSet.php.

& MenuSet::AddOption (   $label,
  $target,
  $title = "",
  $active = false,
  $sortkey = null,
  $external = false 
)

Add an option, which is a link. The call will attempt to work out whether the option should be marked as active, and will sometimes get it wrong.

Parameters
string$labelA Label for the new menu option
string$targetThe URL to target for this option.
string$titleSome tooltip help for the title tag.
string$activeWhether this option should be marked as Active.
int$sortkeyAn (optional) value to allow option ordering.
externalopen this link in a new window/tab.
Returns
mixed A reference to the MenuOption that was added, or false if none were added.

Definition at line 295 of file MenuSet.php.

& MenuSet::AddSubMenu ( $submenu_set,
  $label,
  $target,
  $title = "",
  $active = false,
  $sortkey = 2000 
)

Add an option, which is a submenu

Parameters
object&$submenu_setA reference to a menu tree
string$labelA Label for the new menu option
string$targetThe URL to target for this option.
string$titleSome tooltip help for the title tag.
string$activeWhether this option should be marked as Active.
int$sortkeyAn (optional) value to allow option ordering.
Returns
mixed A reference to the MenuOption that was added, or false if none were added.

Definition at line 341 of file MenuSet.php.

MenuSet::LinkActiveSubMenus ( )

Mark each MenuOption as active that has an active sub-menu entry.

Currently needs to be called manually before rendering but really should probably be called as part of the render now, and then this could be a private routine.

Definition at line 395 of file MenuSet.php.

MenuSet::MakeSomethingActive (   $test_pattern)

Mark each MenuOption as active that has an active sub-menu entry.

Currently needs to be called manually before rendering but really should probably be called as part of the render now, and then this could be a private routine.

Definition at line 413 of file MenuSet.php.

MenuSet::Render (   $submenus_inline = false)

Render the menu tree to an HTML fragment.

Parameters
boolean$submenus_inlineIndicate whether to render the sub-menus within the menus, or render them entirely separately after we finish rendering the top level ones.
Returns
string The HTML fragment.

Definition at line 462 of file MenuSet.php.

MenuSet::RenderAsCSS (   $depth = 0,
  $skip_empty = true 
)

Render the menu tree to an HTML fragment.

Parameters
boolean$submenus_inlineIndicate whether to render the sub-menus within the menus, or render them entirely separately after we finish rendering the top level ones.
Returns
string The HTML fragment.

Definition at line 494 of file MenuSet.php.

MenuSet::Size ( )

Find out how many options the menu has.

Returns
int The number of options in the menu.

Definition at line 372 of file MenuSet.php.


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