<?php
class MNavigationBar extends MMenu
{
    const SEPARATOR = '&raquo;&raquo;';
    public $labelHome = 'Home';

    public function __construct($name = '')
    {
        parent::__construct($name);
    }

    public function setLabelHome($label)
    {
        $this->labelHome = $label;
    }

    public function generateInner()
    {
        if ($this->base)
        {
            $base = $this->base;
        }
        else
        {
            $base = $this->manager->dispatch;
        }

        $this->setCssClassItem('link', 'mTopMenuLink');
        $this->setCssClassItem('option', 'mTopMenuLink');

        $ul = new MUnorderedList();

        if ($this->caption != '')
        {
            $ul->addOption($this->caption);
        }

        $options = $this->getOptions();
        if ($count = count($options))
        {
            $url = $this->manager->getActionURL($this->home,'main','','',$base);
            $link = new MLink('', $this->labelHome, $url);
            $link->setClass('mTopMenuLink');
            $ul->addOption($link->generate());
            $ul->addOption(self::SEPARATOR);

            foreach ($options as $o)
            {
                if (--$count)
                {
                    $ul->addOption($o->generate());
                    $ul->addOption(self::SEPARATOR);
                }
                else
                {
                    $span = new MSpan('', $o->control->label, 'mTopMenuCurrent');
                    $ul->addOption($span->generate());
                }
            }
        }
        else // root item
        {
//            $ul->addOption($this->caption);
        }

//        $this->setClass('mTopmenuBox');
        $box = new MDiv('',$ul,'mTopMenuBox',"dojoType=\"dojox.layout.ContentPane\"");
        $this->inner = $box;
    }
}
?>
