Class WFMenuTree

Description

Class with helper methods for adapting data sources into a tree of WFMenuItem objects.

Located in /framework/WFMenuItem.php (line 185)


	
			
Method Summary
static array menuTreeBuildingToMenuTree (array $allItems)
static array nestedArrayToMenuTree (array $menuArray, [object WFMenuItemBasic $addToMenuItem = null])
Methods
static method menuTreeBuildingToMenuTree (line 259)

Generic algorithm for building a menu tree from a list of objects implementing WFMenuTreeBuilding.

This algorithm is intended to adapt a flat list of objects which contain information on their place within a hierarchy. For instance, this could be a list of "web page objects" that each know about their proper place in a hierarchical navigation system.

This algorithm takes an array of objects, each having a menuPath in the form of "a/b/c/d", and returns them in tree form. The tree form is suitable for WFDynarchMenu, WFYAHOO_widget_Menu, or other menu subsytems.

Items can be both a menu item and have children. Any nodes along the way that aren't explicitly specified will be created for you with a label but no link.

IMPORTANT: The order of the items passed in is important. They should be sorted such that the nodes appear in order of appearance, if you were walking through them recursively.

EXAMPLE: a/b/ a/b/c a/b/d a/c/a a/c/b

  • return: An arry of these same objects, but converted to tree form.
static array menuTreeBuildingToMenuTree (array $allItems)
  • array $allItems: A one-dimensional array of objects implementing WFMenuTreeBuilding.
static method nestedArrayToMenuTree (line 208)

Builds a hierarchical array of WFMenuItemBasic objects from the passed hierarchical associative array.

assoc array format:

  1.   $menuArray array(
  2.                   'topMenu1' => array(
  3.                                       'Menu Item 1' => '/link/to/target1',
  4.                                       'Menu Item 2' => '/link/to/target2',
  5.                                       ),
  6.                   'topMenuItem2' => '/link/to/target'
  7.                   );

NOTE: This function is very useful for converting menus set up in skin delegates (ie namedContent) to nice menus.

  • return: An array of WFMenuItemBasic objects.
  • todo: Amend the array structure to provide ALL properties of WFMenuItemBasic.
static array nestedArrayToMenuTree (array $menuArray, [object WFMenuItemBasic $addToMenuItem = null])
  • array $menuArray: The array of menu items.
  • object WFMenuItemBasic $addToMenuItem: The menu item to add items found to as submenus.

Documentation generated on Thu, 07 Aug 2008 10:36:50 -0400 by phpDocumentor 1.4.1