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

Class: HTML_Menu

Source Location: /HTML_Menu-2.1.4/Menu.php

Class Overview


Generates a HTML menu from a multidimensional hash.


Author(s):

Version:

  • Release: 2.1.4

Methods


Inherited Variables

Inherited Methods


Class Details

[line 47]
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 130]

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 ]

forceCurrentIndex   [line 595]

void forceCurrentIndex( mixed $index)

Forces the menu item with the given index to become "current"

Per request #3237

  • Access: public

Parameters:

mixed   $index   —  Menu item index

[ Top ]

forceCurrentUrl   [line 551]

void forceCurrentUrl( string $url)

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

Parameters:

string   $url   —  Url to use

[ Top ]

get   [line 225]

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

Returns the HTML menu.

Parameters:

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

[ Top ]

getCurrentURL   [line 527]

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 475]

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 255]

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

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

Parameters:

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

[ Top ]

setMenu   [line 179]

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 194]

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 211]

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 564]

void setUrlPrefix( string $prefix)

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

Parameters:

string   $prefix   — 

[ Top ]

show   [line 241]

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 15:02:05 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.