Class: MenuItem
- Package: saf.GUI
- Author: John Luxford <lux@simian.ca>
- Copyright: Copyright (C) 2001-2003, Simian Systems Inc.
- License: http://www.sitellite.org/index/license Simian Open Software License
- Version: 1.2, 2002-09-27, $Id: MenuItem.php,v 1.3 2007/10/06 00:06:30 lux Exp $
- Access: public
MenuItem is the item class that compliments the Menu class and provides
much of its recursive logic.
New in 1.2:
- The $id property value now has no bearing on which template to use if an array
of templates is provided. This was a problem when the template array keys
and $id values were both numeric.
Usage Example
<?php
$foo = new MenuItem ('foo', 'Foo');
$bar =& $foo->addChild ('bar', 'Bar');
echo $foo->display ('html', '<a href="/index/##id##">##title##</a>');
?>
Return to Top
Properties
$template
The template to use to generate the menu item.
$fill
The object or associative array to use to fill the template with upon
calling render().
$span
The span of this cell. Set to -1 and the cell will disappear. Use
$this->attrs['colspan'] or ['rowspan'] to set these properties in the
corresponding HTML <td> tag.
$attrs = array ()
Contains all HTML <td> properties for the current object.
$default
$default is an optional default value to place in cells whose
templates result in no output.
$type = 'db'
$collection
$limit
$fields
$total = 0
$list = false
$remember = array ()
$skipHeaders = array ()
$header = ''
$footer = ''
$editUrl = false
$addUrl = false
$deleteUrl = false
$error
Contains the most recent error message if an error has occurred,
false otherwise.
$name
The name of the menu.
$xpos
The distance from the left edge of the browser window to display
the menu in collapsible display mode. Default is 0.
$ypos
The distance from the top edge of the browser window to display
the menu in collapsible display mode. Default is 0.
$menuWidth
The width of the drop menu this item is a part of. Used for
inheriting to a child menu.
$lineHeight
The height of this item and each item in its parent drop menu.
Used for inheriting to a child menu.
$itemTemplate
The template used to draw each drop menu item.
$direction = 'right'
The direction of the drop menu this item is a part of. Used for
inheriting to a child menu.
$items = array ()
An array of DropMenuItem objects
$extraMouseOver = ''
Optional extra JavaScript to call when the item is in focus.
$extraMouseOut = ''
Optional extra JavaScript to call when the item loses focus.
$text
The text of the menu item.
$link
The URL to link this item to.
$menu_tpl
The menu template to use to generate child drop menus.
$child
The child DropMenu object of this item.
$mouseover
The private mouseover data detailing this item's behaviour.
$matrix = array ()
Contains the grid.
$table
The name of the database table (if any) that this menu is being
pulled from.
$row = array ()
Contains all HTML <tr> properties for the current object.
$cell = array ()
Contains all HTML <td> properties for the current object,
if this layout is not the top-level layout object.
$tree
Contains a multi-dimensional array of MenuItem objects.
$idcolumn
The name of the column in the database table that contains the
primary key values.
$showcolumn
The name of the column in the database table that is to be
displayed.
$refcolumn
The name of the column in the database table that makes a
self-reference to the primary key, or id, column.
$listcolumn
The name of the column in the database table that says
whether or not to display each record as an item.
$sortcolumn
The field to sort by, in case of a sort field. A sort field outweighs
the default sorting alphabetically.
$sortorder
The sort order, either 'ASC' (ascending) or 'DESC' (descending).
$sitelliteAllowed
Specifies whether or not to use the global $sitellite object
(from the Sitellite CMS-only package saf.App.Conf.Sitellite) to add
automatic permission limits on the database query. For more information,
see saf.App.Conf.Sitellite in DocReader.
$cache = false
$cacheLocation = 'cache/.menu'
$closedPic
The path to the image to use for the'"closed' graphic in the
collapsible display mode. Defaults to '/pix/false.gif'.
$openedPic
The path to the image to use for the'"opened' graphic in the
collapsible display mode. Defaults to '/pix/true.gif'.
$hideValue
The value that the database column in $listcolumn is supposed
to contain when a field is not to be shown. Defaults to 'no'.
$colours
An array of background colours for this item, which is the
same as the $colours property of saf.GUI.Menu.
$jsDir
The directory to find the JavaScript for the collapsible view
in. Default is '/js'.
$includedJs
Remembers whether or not the JavaScript for the collapsible
display mode has been included yet or not.
$initFunc
The name of the JavaScript init() function for this menu.
Different menus on the same page need separate init() functions.
The default is 'saf_xbinit_' plus the name of the database table
linked to this menu.
$id
The (usually) unique id of this item.
$title
The title of this item.
$parent
A reference to the parent of this item, or false if there
is no parent.
$children
An array of child items.
Return to Top
Methods
MenuItem ($id, $title)
Constructor method.
&addChild ($id, $title)
- Access: public
- Return: object reference
Creates a new child item below the current item.
trail ()
- Access: public
- Return: array
Creates a breadcrumb trail as an array of item objects.
display ($mode = 'html', $tplt = '', $recursive = 1)
- Access: public
- Return: string
Renders this item and those below it. $mode can be 'html' or
'collapsible'. $tplt can be a single template or an array of templates.
If $tplt is an associative array, the appropriate template will be chosen.
If there aren't an equal number of templates in the array to the number
of levels in the menu, the last template in the list will be used
repeatedly for all subsequent levels. If $recursive is set to false,
it will only render a single level of the tree.
Return to Top