Exemple #1
0
 public function getItems()
 {
     $user = Transaction::getInstance()->getUser();
     $items = array();
     foreach ($this->xml->item as $element) {
         $item = new MenuItem($this, $element);
         if ($item->getId() == $this->mainMenuId) {
             $item->setSelected(true);
         }
         if (!$item->isAdminOnly() || $user->isAdmin()) {
             $items[] = $item;
         }
     }
     return $items;
 }
Exemple #2
0
 public function __construct($menu, $xmlElement)
 {
     $this->attributes = self::getXmlElementAttributes($xmlElement);
     $this->menu = $menu;
     $this->id = $xmlElement['id'];
     $this->adminOnly = $xmlElement['adminOnly'];
     $this->name = $xmlElement->name;
     $this->href = $xmlElement->href;
     $this->onclick = $xmlElement->onclick;
     $this->class = $xmlElement->class;
     $this->content = $xmlElement->content;
     $this->subcontent = $xmlElement->subcontent;
     $this->add = $xmlElement->add;
     $this->display = $xmlElement->disp;
     $this->xmlElement = $xmlElement;
     foreach ($xmlElement->item as $childItem) {
         $item = new MenuItem($this->menu, $childItem);
         if ($item->getId() == $menu->getSubMenuId()) {
             $item->setSelected(true);
         }
         $this->items[] = $item;
     }
 }
 /**
  * @covers MenuItem::setSelected
  */
 public function testSetSelected()
 {
     $this->assertFalse($this->menuItem->isSelected());
     $this->menuItem->setSelected(true);
     $this->assertTrue($this->menuItem->isSelected());
 }