Horde_Menu::addArray PHP 메소드

addArray() 공개 메소드

Add an item to the menu array.
public addArray ( array $item ) : integer
$item array The item to add. Valid keys:
'class' - (string) CSS classname.
'icon' - (string) Filename of the image icon.
'icon_path' - (string) Non-default directory path for icon.
'onclick' - (string) Onclick javascript.
'target' - (string) HREF target parameter.
'text' - (string) Label.
'url' - (string) Hyperlink.
리턴 integer The id (NOT guaranteed to be an array index) of the item just added to the menu.
    public function addArray($item)
    {
        if (!isset($item['url'])) {
            $item['url'] = new Horde_Url();
        } elseif (!$item['url'] instanceof Horde_Url) {
            $item['url'] = new Horde_Url($item['url']);
        }
        $this->_menu[] = array_merge(array('class' => null, 'icon' => '', 'icon_path' => null, 'onclick' => null, 'target' => '', 'text' => ''), $item);
    }

Usage Example

예제 #1
0
파일: Hylax.php 프로젝트: horde/horde
 function getMenu($returnType = 'object')
 {
     global $registry;
     $menu = new Horde_Menu();
     $menu->addArray(array('url' => Horde::url('summary.php'), 'text' => _("Summary"), 'icon' => 'fax.png'));
     $menu->addArray(array('url' => Horde::url('folder.php'), 'text' => _("Folders"), 'icon' => 'folder.png'));
     $menu->addArray(array('url' => Horde::url('compose.php'), 'text' => _("Compose"), 'icon' => 'compose.png'));
     if ($returnType == 'object') {
         return $menu;
     } else {
         return $menu->render();
     }
 }