2014-04-27 14:44:40 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FML\Script\Features;
|
|
|
|
|
|
|
|
use FML\Controls\Control;
|
2014-05-14 23:24:00 +02:00
|
|
|
use FML\Types\Scriptable;
|
2014-04-27 14:44:40 +02:00
|
|
|
|
|
|
|
/**
|
2014-06-21 03:18:21 +02:00
|
|
|
* Menu Element for the Menu Feature
|
2014-04-27 14:44:40 +02:00
|
|
|
*
|
2014-05-20 15:44:45 +02:00
|
|
|
* @author steeffeen <mail@steeffeen.com>
|
2014-04-27 14:44:40 +02:00
|
|
|
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
|
2014-05-14 23:24:00 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2014-04-27 14:44:40 +02:00
|
|
|
*/
|
|
|
|
class MenuElement {
|
|
|
|
/*
|
2014-06-21 03:18:21 +02:00
|
|
|
* Protected properties
|
2014-04-27 14:44:40 +02:00
|
|
|
*/
|
|
|
|
protected $item = null;
|
|
|
|
protected $control = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new Menu Element
|
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param Control $item (optional) Item Control in the Menu bar
|
2014-04-27 14:44:40 +02:00
|
|
|
* @param Control $control (optional) Toggled Menu Control
|
|
|
|
*/
|
|
|
|
public function __construct(Control $item = null, Control $control = null) {
|
2014-06-21 03:18:21 +02:00
|
|
|
if (!is_null($item)) {
|
|
|
|
$this->setItem($item);
|
|
|
|
}
|
|
|
|
if (!is_null($control)) {
|
|
|
|
$this->setControl($control);
|
|
|
|
}
|
2014-04-27 14:44:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the Item Control
|
|
|
|
*
|
2014-06-21 03:18:21 +02:00
|
|
|
* @param Control $item Item Control in the Menu bar
|
2014-07-03 22:34:47 +02:00
|
|
|
* @return static
|
2014-04-27 14:44:40 +02:00
|
|
|
*/
|
|
|
|
public function setItem(Control $item) {
|
|
|
|
$item->checkId();
|
2014-05-14 23:24:00 +02:00
|
|
|
if ($item instanceof Scriptable) {
|
|
|
|
$item->setScriptEvents(true);
|
|
|
|
}
|
2014-04-27 14:44:40 +02:00
|
|
|
$this->item = $item;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Item Control
|
|
|
|
*
|
|
|
|
* @return \FML\Controls\Control
|
|
|
|
*/
|
|
|
|
public function getItem() {
|
|
|
|
return $this->item;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the Menu Control
|
|
|
|
*
|
|
|
|
* @param Control $control Toggled Menu Control
|
2014-07-03 22:34:47 +02:00
|
|
|
* @return static
|
2014-04-27 14:44:40 +02:00
|
|
|
*/
|
|
|
|
public function setControl(Control $control) {
|
2014-06-21 03:18:21 +02:00
|
|
|
$this->control = $control->checkId();
|
2014-04-27 14:44:40 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Menu Control
|
|
|
|
*
|
|
|
|
* @return \FML\Controls\Control
|
|
|
|
*/
|
|
|
|
public function getControl() {
|
|
|
|
return $this->control;
|
|
|
|
}
|
|
|
|
}
|