<?php
  /*
    -oddelil som Menu classy od Page-ovych z dovodu prehladnosti, totiz som potreboval
     dedit z triedy cMenu
  */
  class cMenuItem
  {
    public $label;
    public $urlParams;
    public $bExpanded;
    public $bSelected;
    public $items;
    
    function __construct( $label, $urlParams )
    {
      $this->label = $label;
      $this->urlParams = $urlParams; 
      $this->bExpanded = false;
      $this->bSelected = false;
      $this->items = array();
    }
    
    function AddItem( $label, $urlParams )
    {
      $count = count($this->items);
      $this->items[$count] = new cMenuItem( $label, $urlParams );
      return $this->items[$count];  
    }
    
    function GetItemByLabel( $label )
    {
      for ( $i = 0; $i < count($this->items); $i++ )
      {
        if ( $this->items[$i]->label === $label )
      	  return $this->items[$i];
      }
      return NULL;
    }

    function GetItemByIndex( $index )
    {
      if ( $index < count($this->items) )
      	  return $this->items[$index];
                	  
      return NULL;
    }
  }
  
  class cMenu
  {
    public $items;
    
    function __construct()
    {
      $this->items = array();
    }
    
    function AddItem( $label, $urlParams )
    {
      $count = count($this->items);
      $this->items[$count] = new cMenuItem( $label, $urlParams );
      return $this->items[$count];  
    }
    
    function AddSeparator()
    {
      $count = count($this->items);
      $this->items[$count] = new cMenuItem( "separator", "" );
      return $this->items[$count];  
    }  
    
    function GetItemByLabel( $label )
    {
      for ( $i = 0; $i < count($this->items); $i++ )
      {
        if ( $this->items[$i]->label === $label )
      	  return $this->items[$i];
      }
      return NULL;
    }

    function GetItemByIndex( $index )
    {
      if ( $index < count($this->items) )
      	  return $this->items[$index];
                	  
      return NULL;
    }
  }
?>
