Files
grzanieplus.pl/plugins/stNavigationPlugin/lib/stNavigationMenuItem.class.php
2025-03-12 17:06:23 +01:00

122 lines
2.2 KiB
PHP

<?php
class stNavigationMenuItem
{
/**
* Adres url elementu menu
*
* @var string
*/
private $url;
/**
* Tytuł elementu menu
*
* @var string
*/
private $title;
/**
* Ikonka elementu menu
*
* @var string
*/
private $icon;
/**
* Katalog i18n elementu menu
*
* @var [type]
*/
private $i18n;
/**
* Tablica zawierająca elementy menu podrzędnego
*
* @var stNavigationMenuItem[]
*/
private $children;
public function __construct($title, $url = null, array $options = array())
{
$this->title = $title;
$this->url = $url;
if (isset($options['icon']))
{
$this->icon = $options['icon'];
}
if (isset($options['i18n']))
{
$this->i18n = $options['i18n'];
}
if (isset($options['children']))
{
$this->children = $options['children'];
}
}
/**
* Zwraca adres url elementu menu
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
public function getIcon()
{
return $this->icon;
}
/**
* Zwraca tytuł elementu menu
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Zwraca nazwę katalogu i18n elementu menu
*
* @return string
*/
public function getI18n()
{
return $this->i18n;
}
/**
* Zwraca tablicę zawierającą elementy menu podrzędnego
*
* @return stNavigationMenuItem[]
*/
public function getItems()
{
return $this->children;
}
/**
* Dodaje elementu menu
*
* @param string $id Unikalne id elementu
* @param string $title Tytuł elementu
* @param string $url Url elementu
* @param array $options Dodatkowe opcje elementu (icon, i18n, children)
* @return stNavigationMenuItem Instancja dodanego elementu
*/
public function addItem($id, $title, $url = null, array $options = array())
{
$item = new stNavigationMenuItem($title, $url, $options);
$this->children[$id] = $item;
return $item;
}
}