Packageindex Classtrees Modulegroups Elementlist Report XML Files
 
File: c:/www/apache/doc2//form/menu.php
PEAR Integrated Template [Extension] - IT[X], 11.02.2001 - HTML

menu

menu

Generates a HTML menu from a multidimensional hash.

 

public class menu

Generates a HTML menu from a multidimensional hash.
Special thanks to the original author: Alex Vorobiev <sasha@mathforum.com>

AuthorsUlf Wendel <ulf.wendel@phpdoc.de>
Version$id: $

 

Public Method Summary

void

menu([ string $menu, string $type ])

Initializes the menu, sets the type and menu structure.
void

setMenu(array $menu)

Sets the menu structure.
void

setMenuType(string $menu_type)

Sets the type / format of the menu: tree, rows or urhere.
string

get([ string $menu_type ])

Returns the HTML menu.
string

getSitemap()

Returns a sitemap.

Private Method Summary

void

show([ string $menu_type ])

Prints the HTML menu.
string

getStart()

Returns the prefix of the HTML menu items.
string

getEnd()

Returns the postfix of the HTML menu items.
void

buildMenu(array $menu, [ integer $level ])

Build the menu recursively.
void

buildSitemap(array $menu, [ integer $level ])

Build the menu recursively.
string

getEntry(array &$node, integer $level, string $item_type)

Returns the HTML of one menu item.
boolean

buildPath(array $menu, array $path)

Computes the path of the current page in the menu "tree".
void

getPath()

Warning: documentation is missing.

Private Field Summary

array

$menu

Menu structure as a multidimensional hash.
array

$urlmap

Mapping from URL to menu path.
string

$menu_type

Menu type: tree, rows, you-are-here.
array

$path

Path to a certain menu item.
string

$html

Generated HTML menu.

Public Method Details

menu

public void menu( [ string $menu, string $type ] )

  Initializes the menu, sets the type and menu structure.

Parameter
string $menu = >>""<<
string $type = >>"tree"<<
Returns void

See Also setMenuType(), setMenu()

setMenu

public void setMenu( array $menu )

  Sets the menu structure.
The menu structure is defined by a multidimensional hash. This isquite "dirty" but simple and easy to traverse. An exampleshow the structure. To get the following menu:1 - Projects11 - Projects => PHPDoc12 - Projects => Forms2 - Stuffyou need the array:$menu = array(1 => array("title" => "Projects","url" => "/projects/index.php","sub" => array(11 => array("title" => "PHPDoc",...),12 => array( ... ),)),2 => array( "title" => "Stuff", "url" => "/stuff/index.php" ))Note the index "sub" and the nesting. Note also that 1, 11, 12, 2must be unique. The class uses them as ID's.

Parameter
array $menu
Returns void


setMenuType

public void setMenuType( string $menu_type )

  Sets the type / format of the menu: tree, rows or urhere.

Parameter
string $menu_type
"tree", "rows", "urhere"
Returns void


get

public string get( [ string $menu_type ] )

  Returns the HTML menu.

Parameter
string $menu_type = >>""<<
type: tree, urhere, rows
Returns string

HTML of the menu


getSitemap

public string getSitemap( )

  Returns a sitemap.

Returns string

HTML code


Private Method Details

show

private void show( [ string $menu_type ] )

  Prints the HTML menu.

Parameter
string $menu_type = >>""<<
type: tree, urhere, rows
Returns void


getStart

private string getStart( )

  Returns the prefix of the HTML menu items.

Returns string

HTML menu prefix

See Also getEnd(), get()

getEnd

private string getEnd( )

  Returns the postfix of the HTML menu items.

Returns string

HTML menu postfix

See Also getStart(), get()

buildMenu

private void buildMenu( array $menu, [ integer $level ] )

  Build the menu recursively.

Parameter
array $menu
call: $this->menu, recursion: submenu
integer $level = >>0<<
of recursion, current depth in the tree structure
Returns void


buildSitemap

private void buildSitemap( array $menu, [ integer $level ] )

  Build the menu recursively.

Parameter
array $menu
call: $this->menu, recursion: submenu
integer $level = >>0<<
of recursion, current depth in the tree structure
Returns void


getEntry

private string getEntry( array &$node, integer $level, string $item_type )

  Returns the HTML of one menu item.

Parameter
array &$node
item data (node data)
integer $level
in the menu tree
string $item_type
item type: 0, 1, 2. 0 => plain menu item,
1 => selected (active) menu item, 2 => item
is a member of the path to the selected (active) menu item
Returns string

HTML

See Also buildMenu()

buildPath

private boolean buildPath( array $menu, array $path )

  Computes the path of the current page in the menu "tree".

Parameter
array $menu
call: menu hash / recursion: submenu hash
array $path
call: array() / recursion: path
Returns boolean

true if the path to the current page was found,
otherwise false. Only meaningful for the recursion.

See Also getPath(), $urlmap

getPath

private void getPath( )

 

Warning: documentation is missing.

Returns void


Private Field Details

$menu

private array $menu

>>array()<<

Menu structure as a multidimensional hash.

See Also setMenu(), Menu()

$urlmap

private array $urlmap

>>array()<<

Mapping from URL to menu path.

See Also getPath()

$menu_type

private string $menu_type

>>""<<

Menu type: tree, rows, you-are-here.

See Also setMenuType()

$path

private array $path

>>array()<<

Path to a certain menu item.
Internal class variable introduced to save some recursion overhead.

See Also get(), getPath()

$html

private string $html

>>""<<

Generated HTML menu.

See Also get()


Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta