|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Bundle\Acme\Plugins\Gui; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Bundle\Acme\Plugins\Test; |
|
6
|
|
|
use eXpansion\Framework\Core\Model\Gui\ManialinkInterface; |
|
7
|
|
|
use eXpansion\Framework\Core\Model\Gui\Widget; |
|
8
|
|
|
use eXpansion\Framework\Core\Model\Gui\WidgetFactoryContext; |
|
9
|
|
|
use eXpansion\Framework\Core\Plugins\Gui\WidgetFactory; |
|
10
|
|
|
use eXpansion\Framework\Gui\Ui\Factory; |
|
11
|
|
|
use FML\Controls\Label; |
|
12
|
|
|
use FML\Script\Script; |
|
13
|
|
|
use FML\Script\ScriptLabel; |
|
14
|
|
|
|
|
15
|
|
|
class MemoryWidgetFactory extends WidgetFactory |
|
16
|
|
|
{ |
|
17
|
|
|
/** @var Label */ |
|
18
|
|
|
protected $memoryMessage; |
|
19
|
|
|
|
|
20
|
|
|
/** @var Factory */ |
|
21
|
|
|
protected $uiFactory; |
|
22
|
|
|
|
|
23
|
|
|
public static $exp_hash; |
|
24
|
|
|
|
|
25
|
|
|
public function __construct( |
|
26
|
|
|
$name, |
|
27
|
|
|
$sizeX, |
|
28
|
|
|
$sizeY, |
|
29
|
|
|
$posX, |
|
30
|
|
|
$posY, |
|
31
|
|
|
WidgetFactoryContext $context, |
|
32
|
|
|
Factory $uiFactory |
|
33
|
|
|
) { |
|
34
|
|
|
parent::__construct($name, $sizeX, $sizeY, $posX, $posY, $context); |
|
35
|
|
|
$this->uiFactory = $uiFactory; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param ManialinkInterface|Widget $manialink |
|
40
|
|
|
*/ |
|
41
|
|
|
protected function createContent(ManialinkInterface $manialink) |
|
42
|
|
|
{ |
|
43
|
|
|
|
|
44
|
|
|
$this->memoryMessage = $this->uiFactory->createLabel("awaiting data..."); |
|
45
|
|
|
$this->memoryMessage->setTextPrefix('$s')->setTextSize(3)->setSize(60, 5); |
|
46
|
|
|
$manialink->addChild($this->memoryMessage); |
|
47
|
|
|
|
|
48
|
|
|
self::$exp_hash = uniqid("exp"); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
protected function updateContent(ManialinkInterface $manialink) |
|
52
|
|
|
{ |
|
53
|
|
|
|
|
54
|
|
|
$this->memoryMessage->setText(Test::$memoryMsg); |
|
55
|
|
|
$now = uniqid("exp2"); |
|
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
$message = "Time now:".date("h:i:s"); |
|
58
|
|
|
|
|
59
|
|
|
$hash = self::$exp_hash; |
|
60
|
|
|
|
|
61
|
|
|
$script = new Script(); |
|
62
|
|
|
$script->addCustomScriptLabel(ScriptLabel::OnInit, |
|
63
|
|
|
' |
|
64
|
|
|
declare Text '.$hash.' for LocalUser = Text; |
|
65
|
|
|
'.$hash.' = "'.$message.'"; |
|
66
|
|
|
declare Text '.$hash.'_check for LocalUser = ""; |
|
67
|
|
|
'.$hash.'_check = "$now"; |
|
68
|
|
|
' |
|
69
|
|
|
); |
|
70
|
|
|
$manialink->getFmlManialink()->setScript($script); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
} |
|
74
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.