Menu_Model Class Reference
Menu model for easily accessable hierarchal menus.
More...
Public Member Functions |
| __construct ($label=NULL, $href=NULL, $order=null, $icon=false, array $attributes=array()) |
| Instantiates a new Menu model node, children within the structure use the same model as the root node.
|
| has_children () |
| get_id () |
| This nodes unique identifier.
|
| set_separator ($title=null) |
| Sets this menu item as a separator.
|
| is_separator () |
| Is this menu item a separator.
|
| set_order ($order) |
| Set the position of this node relative to the other node's order value within this level.
|
| get_order () |
| Returns this nodes $order value.
|
| set_icon ($icon) |
| Sets this nodes $icon value.
|
| get_icon () |
| Returns this nodes $icon value.
|
| set_style ($style) |
| Sets this nodes $style value.
|
| get_style () |
| Returns this nodes $style value.
|
| set_href ($href) |
| Sets this nodes $href value.
|
| get_href () |
| Returns this nodes $href value.
|
| set_attributes ($attributes) |
| Sets this nodes $attributes value.
|
| set_html_label ($html) |
| Sets this nodes $label value as "valid html", meaning that it does not need further escaping in the view layer.
|
| get_attributes () |
| Returns this nodes $attributes value.
|
| set_label ($label) |
| Sets this nodes $label value.
|
| get_label_as_html () |
| get_branch () |
| Returns this nodes child-nodes.
|
| get ($namespace) |
| Returns the node reflected by the given namespace.
|
| set ($namespace, $href=NULL, $order=NULL, $icon=false, array $attributes=array()) |
| Sets properties on the node identified by the namespace, if the node or hierarchy doesn'texist it will be created.
|
| attach ($namespace, $node) |
| Attach a submenu to a menu.
|
Detailed Description
Menu model for easily accessable hierarchal menus.
Used to create a hierarchal menustructure through namespace set'ing. The hierarchy does not need to be set up in order, a lower node can be added and will create dummy nodes through any part of the hierarchy that does not yet exist. These nodes can later be populated with properties or be left as only sub-section nodes.
E.g. {Menu_Model}->set('My.Namespace.Foobar', '/something/cool') : {Menu_Model}->set('My', '/something/my') : My { href: '/something/cool' Namespace { Foobar { href: '/something/cool' } } }
- Author:
- Tobias Sjöndin <tobias.sjondin@op5.com>
- Version:
- 1.0
Constructor & Destructor Documentation
Menu_Model::__construct |
( |
$ |
label = NULL , |
|
|
$ |
href = NULL , |
|
|
$ |
order = null , |
|
|
$ |
icon = false , |
|
|
array $ |
attributes = array() | |
|
) |
| | |
Instantiates a new Menu model node, children within the structure use the same model as the root node.
- Parameters:
-
| $label | What label to display |
| $href | What URL this item should link to |
| $order | At what position should this item be rendered (relative to others at the same level), lower value is higher priority |
| $icon | What icon to use, within ninja this is an icon-class |
| $attributes | Additional attributes to add to the element |
Member Function Documentation
Menu_Model::attach |
( |
$ |
namespace, |
|
|
$ |
node | |
|
) |
| | |
Attach a submenu to a menu.
The submenu needs to have its orders, icons and other parametes set correctly
- Parameters:
-
| $namespace | Full namespace to the node you wish to create or manipulate |
| $node | The subtree, either as Menu_Model or a View |
- Returns:
- Menu_Model Returns $this for chainability
Menu_Model::get |
( |
$ |
namespace |
) |
|
Returns the node reflected by the given namespace.
If no node exists return null.
- Parameters:
-
| $namespace | Full namespace to the node you wish to access |
- Returns:
- Menu_Model Returns the node identified by the namespace
-
null If no node is found it returns null
Menu_Model::get_attributes |
( |
|
) |
|
Returns this nodes $attributes value.
- Returns:
- array This nodes $attributes value
Menu_Model::get_branch |
( |
|
) |
|
Returns this nodes child-nodes.
- Returns:
- Menu_Model[] This nodes child-nodes
Returns this nodes $href value.
- Returns:
- string This nodes $href value
Returns this nodes $icon value.
- Returns:
- string This nodes $icon value
This nodes unique identifier.
- Returns:
- string This nodes unique identifier
Menu_Model::get_label_as_html |
( |
|
) |
|
- Returns:
- string proper html to use as an element
Menu_Model::get_order |
( |
|
) |
|
Returns this nodes $order value.
- Returns:
- integer This nodes $order value
Menu_Model::get_style |
( |
|
) |
|
Returns this nodes $style value.
- Returns:
- string This nodes $style value
Menu_Model::has_children |
( |
|
) |
|
Menu_Model::is_separator |
( |
|
) |
|
Is this menu item a separator.
- Returns:
- bool
Menu_Model::set |
( |
$ |
namespace, |
|
|
$ |
href = NULL , |
|
|
$ |
order = NULL , |
|
|
$ |
icon = false , |
|
|
array $ |
attributes = array() | |
|
) |
| | |
Sets properties on the node identified by the namespace, if the node or hierarchy doesn'texist it will be created.
See constructor for usage of parameters.
- Parameters:
-
| $namespace | Full namespace to the node you wish to create or manipulate |
| $href | Link href or null |
| $order | Link order or null |
| $icon | Link icon or null |
| $attributes | Link attributes array or null |
- Returns:
- Menu_Model Returns $this for chainability
Menu_Model::set_attributes |
( |
$ |
attributes |
) |
|
Sets this nodes $attributes value.
- Parameters:
-
| $attributes | The attributes value to set |
- Returns:
- Menu_Model Returns $this for chainability
Menu_Model::set_href |
( |
$ |
href |
) |
|
Sets this nodes $href value.
- Parameters:
-
| $href | The href value to set |
- Returns:
- Menu_Model Returns $this for chainability
Menu_Model::set_html_label |
( |
$ |
html |
) |
|
Sets this nodes $label value as "valid html", meaning that it does not need further escaping in the view layer.
This complements
- See also:
- set_label()
- Parameters:
-
| $html | The label value to set |
- Returns:
- Menu_Model Returns $this for chainability
Menu_Model::set_icon |
( |
$ |
icon |
) |
|
Sets this nodes $icon value.
- Parameters:
-
| $icon | The icon value to set |
- Returns:
- Menu_Model Returns $this for chainability
Menu_Model::set_label |
( |
$ |
label |
) |
|
Sets this nodes $label value.
- Parameters:
-
| $label | The label value to set |
- Returns:
- Menu_Model Returns $this for chainability
Menu_Model::set_order |
( |
$ |
order |
) |
|
Set the position of this node relative to the other node's order value within this level.
- Parameters:
-
| $order | Relative order to render the item at in this level |
- Returns:
- Menu_Model Returns $this for chainability
Menu_Model::set_separator |
( |
$ |
title = null |
) |
|
Sets this menu item as a separator.
- Parameters:
-
| $title | Optional title for separator |
Menu_Model::set_style |
( |
$ |
style |
) |
|
Sets this nodes $style value.
Valid styles is "normal" and "image"
- Parameters:
-
| $style | The style value to set, null for inherit from parent |
- Returns:
- Menu_Model Returns $this for chainability
The documentation for this class was generated from the following file: