*
* @param Action $action current action, used for output
*/
- function __construct($action=null)
+ function __construct(Action $action=null)
{
parent::__construct($action);
$this->out->elementStart('ul', $attrs);
foreach ($items as $item) {
+ assert(is_array($item));
+ assert(count($item) == 5);
+
list($actionName, $args, $label, $description, $id) = $item;
+
$this->item($actionName, $args, $label, $description, $id);
}
-
+
$this->out->elementEnd('ul');
-
+
Event::handle('EndNav', array($this, $tag, $items));
}
}
-
- function item($actionName, $args, $label, $description, $id=null, $cls=null)
+
+ function item($actionName, array $args, $label, $description, $id=null, $cls=null)
{
if (empty($id)) {
$id = $this->menuItemID($actionName, $args);
$cls);
}
- function isCurrent($actionName, $args)
+ function isCurrent($actionName, array $args)
{
if ($actionName != $this->actionName) {
return false;
+ } elseif (!is_array($args)) {
+ /*
+ * No array, then the below loop doesn't need to run and
+ * 'return false' will never be reached.
+ */
+ return true;
}
foreach ($this->actionArgs as $k => $v) {
return true;
}
-
+
function menuItemID($actionName, $args = null)
{
$id = sprintf('nav_%s', $actionName);
-
+
if (!is_null($args)) {
foreach ($args as $key => $value) {
$id .= '_' . $key . '_' . $value;