HTML_Menu
[ class tree: HTML_Menu ] [ index: HTML_Menu ] [ all elements ]

Class: HTML_Menu

Source Location: /HTML_Menu-2.1.1/Menu.php

Class Overview


Generates a HTML menu from a multidimensional hash.


Author(s):

Version:

  • $Revision: 1.11 $

Methods


Inherited Variables

Inherited Methods


Class Details

[line 44]
Generates a HTML menu from a multidimensional hash.

Special thanks to the original author: Alex Vorobiev <sasha@mathforum.com>.



[ Top ]


Method Detail

HTML_Menu (Constructor)   [line 116]

HTML_Menu HTML_Menu( [array $menu = null], [string $type = 'tree'], [string $urlEnvVar = 'PHP_SELF'])

Initializes the menu, sets the type and menu structure.

Parameters:

array   $menu   —  menu structure
string   $type   —  menu type
string   $urlEnvVar   —  env. variable used to determine current URL

[ Top ]

forceCurrentUrl   [line 523]

void forceCurrentUrl( string $url)

Forces the given URL to be "current"
  • Access: public

Parameters:

string   $url   —  Url to use

[ Top ]

get   [line 207]

string get( [string $menuType = ''])

Returns the HTML menu.

Parameters:

string   $menuType   —  Menu type: tree, urhere, rows, prevnext, sitemap

[ Top ]

getCurrentURL   [line 503]

string getCurrentURL( )

Returns the URL of the currently selected page.

The returned string is used for all test against the URL's in the menu structure hash.

  • Access: public

[ Top ]

getPath   [line 451]

array getPath( )

Returns the path of the current page in the menu 'tree'.
  • Return: path to the selected menu item
  • See: _buildUrlMap(), $_urlMap

[ Top ]

render   [line 237]

void render( object HTML_Menu_Renderer &$renderer, [string $menuType = ''])

Renders the menu.
  • Throws: PEAR_Error
  • Access: public

Parameters:

object HTML_Menu_Renderer   &$renderer   —  Renderer to use
string   $menuType   —  type of the menu

[ Top ]

setMenu   [line 161]

void setMenu( array $menu)

Sets the menu structure.

The menu structure is defined by a multidimensional hash. This is quite "dirty" but simple and easy to traverse. An example show the structure. To get the following menu:

  1. - Projects
11 - Projects => PHPDoc 12 - Projects => Forms 2 - Stuff

you 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, 2 must be unique. The class uses them as ID's.

  • Access: public

Parameters:

array   $menu   — 

[ Top ]

setMenuType   [line 176]

void setMenuType( string $menuType)

Sets the type of the menu.

Available types are: 'tree', 'rows', 'urhere', 'prevnext', 'sitemap'.

  • Access: public

Parameters:

string   $menuType   —  type name

[ Top ]

setURLEnvVar   [line 193]

void setURLEnvVar( string $urlEnvVar)

Sets the environment variable to use to get the current URL.
  • Access: public

Parameters:

string   $urlEnvVar   —  environment variable for current URL

[ Top ]

setUrlPrefix   [line 535]

void setUrlPrefix( string $prefix)

Sets the prefix for the URLs in the menu
  • Access: public

Parameters:

string   $prefix   — 

[ Top ]

show   [line 223]

void show( [string $menuType = ''])

Prints the HTML menu.

Parameters:

string   $menuType   —  Menu type: tree, urhere, rows, prevnext, sitemap

[ Top ]


Documentation generated on Mon, 11 Mar 2019 10:16:40 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.