Dynamically create vertical CSS menus.

Based on ?superfish? type CSS menus (see link), this class allows dynamic generation of CSS and HTML to produce horizantal menus at runtime.
This does not actually product Superfish functionality, but the code should be compatible with adding Superfish.
It is advisable to cache the menu if possible, as there is considerable overhead to running this every time the script is accessed and on a busy site with many buttons and layers could have a significant detrimental effect on performance. Simple example adding a three button menu where second button has a sub-button:

$vmenu = new VMenu;
$vmenu->addButton('Home', '/');
$parentid = $vmenu->getNextButton(); // next button will be a parent
$vmenu->addButton('Products' '');
$vmenu->addButton('Product One', '/prod1/', 'Product One', 2, $parentid);
$vmenu->addButton('Product Two', '/prod2/', 'Product Two', 2, $parentid);
$vmenu->addButton('Contact Us', '/contact/');

// then use...
// $vmenu->generateCSS() at the end of your  section
// optionally use $vmenu->generateConditionalStatements()
// and $vmenu->generateHTML() where the menu would go
link http://users.tpg.com.au/j_birch/plugins/superfish/
see \global\HMenu
package dstruct_presentation
todo This was written some years ago and probably needs updating to fit more recent menu technologies
todo Add method to get last button id rather than next button as it is counter-intuitive.

 Methods

Add a button to the menu If using javascript, you may need to use # for <var>$url</var>.

addButton(string $text, string $url, string $title, integer $level, integer $parentid, boolean $topbutton, string $onclick) 

If the button is $level 2 or 3, you will need to set the $parentid. Example:

addButton('Button 1'); // add a button
$parentid = $menu->getNextButton(); // get the ID of the next button. This will be the parent button.
$menu->addButton('Button 2');
$menu->addButton('Button 2-2','','',2,$parentid); // add a sub-button
?>

Parameters

$text

string

Text for the button

$url

string

$title

string

Set the title attribute of the anchor element

$level

integer

Level of the button in the structure - 1, 2 or 3

$parentid

integer

See above

$topbutton

boolean

If the button is the first of its group

$onclick

string

Insert into the onclick attribute of the anchor element

Outputs the CSS required for the menu.

generateCSS() : string

Echo this where you want the CSS on the page.

see \setIncludeStyleTags()

Returns

string

Outputs conditional statements required to make IE browsers work.

generateConditionalStatements() : string

Returns

string

Outputs the HTML required for the menu.

generateHTML() : string

echo this where your menu should be in the HTML

Returns

string

Button background colour.

getBGCol() : string

Returns

string

Button :hover colour.

getBGHover() : string

Returns

string

Button border colors

getBorderCols() : array
see \VMenu::setBorderCols()

Returns

array

Border widths in pixels.

getBorderWidths() : array
see \setBorderWidths()

Returns

array

Font colour

getFontCol() : string

Returns

string

Font :hover colour

getFontHoverCol() : string

Returns

string

Set font as italic

getFontItalic() : boolean

Returns

boolean

Get font size.

getFontSize() : integer

Returns

integer

Get font weight.

getFontWeight() : string

Returns

string

Will the HTML output include a div with id='menu'?

getIncludeDiv() : boolean

Returns

boolean

Will the CSS output be wrapped with the <style> tags.

getIncludeStyleTags() : boolean

Returns

boolean

Get menu width

getMenuWidth() : integer

Returns

integer

Get next button.

getNextButton() : integer

Returns

integer

Get button padding.

getPadding() : array

Returns

array

Get top border of first button.

getTopBorder() : array
see \setTopBorder()

Returns

array

Set background colour.

setBGCol(string $bgcol) 

Parameters

$bgcol

string

Hex colour code e.g. ec4a8f

Set background :hover colour.

setBGHoverCol(string $bghovercol) 

Parameters

$bghovercol

string

Hex colour code e.g. ec4a8f

Border colours.

setBorderCols(array $bordercols) 

Array with 4 elements for top, right, bottom and left. Elements should be hex colour codes e.g. ec4a8f

Parameters

$bordercols

array

Border widths.

setBorderWidths(array $borderwidths) 

Array with 4 integer elements for top, right, bottom and left.

Parameters

$borderwidths

array

Font colour.

setFontCol(string $fontcol) 

Parameters

$fontcol

string

Hex colour code e.g. ec4a8f

Font :hover colour.

setFontHoverCol(string $fonthovercol) 

Parameters

$fonthovercol

string

Hex colour code e.g. ec4a8f

Font is italic?

setFontItalic(boolean $fontitalic) 

Parameters

$fontitalic

boolean

Set font size.

setFontSize(float $fontsize) 

Parameters

$fontsize

float

Set font weight.

setFontWeight(\strong $fontweight) 

e.g. 'bolder'

Parameters

$fontweight

\strong

Wrap HTML output in a div with id of 'menu'>?

setIncludeDiv(boolean $includediv) 

Parameters

$includediv

boolean

Include style tags around the CSS output?

setIncludeStyleTags(boolean $includestyletags) 

If you already have a script with CSS in your page, you may want to exclude the script tags and just include the CSS in the existing block.

Parameters

$includestyletags

boolean

Set menu with in px.

setMenuWidth(integer $menuwidth) 

Parameters

$menuwidth

integer

Set button padding

setPadding(integer $padding) 

Parameters

$padding

integer

In pixels

Set top border on buttons added as a 'topbutton'.

setTopBorder(array $topborder) 

Array with two elements to set width in px and colour in hex.

todo confirm usage of this method.
see \addButton()

Parameters

$topborder

array

 Properties

 

$bgcol : string
 

$bghovercol : string
 

$bordercols : array
 

$borderwidths : array
 

$fontcol : string
 

$fonthovercol : string
 

$fontitalic : boolean
 

$fontsize : float
 

$fontweight : string
 

$includediv : boolean
 

$includestyletags : boolean
 

$level1 : array
 

$level2 : array
 

$level3 : array
 

$menuwidth : integer
 

$nextbutton : integer
 

$padding : array
 

$topborder : array