|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Framework\Core\Plugins\Gui; |
|
4
|
|
|
use eXpansion\Framework\Core\Helpers\Translations; |
|
5
|
|
|
use eXpansion\Framework\Core\Model\Gui\Manialink; |
|
6
|
|
|
use eXpansion\Framework\Core\Model\Gui\ManiaScriptFactory; |
|
7
|
|
|
use eXpansion\Framework\Core\Model\Gui\Window; |
|
8
|
|
|
use eXpansion\Framework\Core\Model\Gui\WindowFactoryContext; |
|
9
|
|
|
use eXpansion\Framework\Core\Model\UserGroups\Group; |
|
10
|
|
|
use eXpansion\Framework\Core\Plugins\GuiHandler; |
|
11
|
|
|
use eXpansion\Framework\Core\Plugins\UserGroups\Factory; |
|
12
|
|
|
use FML\Controls\Control; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class ManialiveFactory allow the creation of manialinks. |
|
16
|
|
|
* |
|
17
|
|
|
* @package eXpansion\Framework\Core\Plugins\Gui |
|
18
|
|
|
* @author Oliver de Cramer |
|
19
|
|
|
*/ |
|
20
|
|
|
class WindowFactory extends WidgetFactory { |
|
21
|
|
|
|
|
22
|
|
|
/** @var ManiaScriptFactory */ |
|
23
|
|
|
protected $windowManiaScriptFactory; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* WindowFactory constructor. |
|
27
|
|
|
* |
|
28
|
|
|
* @param $name |
|
29
|
|
|
* @param $sizeX |
|
30
|
|
|
* @param $sizeY |
|
31
|
|
|
* @param null $posX |
|
32
|
|
|
* @param null $posY |
|
33
|
|
|
* @param WindowFactoryContext $context |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct( |
|
36
|
|
|
$name, |
|
37
|
|
|
$sizeX, |
|
38
|
|
|
$sizeY, |
|
39
|
|
|
$posX, |
|
40
|
|
|
$posY, |
|
41
|
|
|
WindowFactoryContext $context |
|
42
|
|
|
) { |
|
43
|
|
|
parent::__construct( |
|
44
|
|
|
$name, |
|
45
|
|
|
$sizeX, |
|
46
|
|
|
$sizeY, |
|
47
|
|
|
$posX, |
|
48
|
|
|
$posY, |
|
49
|
|
|
$context |
|
50
|
|
|
); |
|
51
|
|
|
|
|
52
|
|
|
$this->windowManiaScriptFactory = $context->getWindowManiaScriptFactory(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param Group $group |
|
59
|
|
|
* |
|
60
|
|
|
* @return Window |
|
61
|
|
|
*/ |
|
62
|
|
|
protected function createManialink(Group $group) |
|
63
|
|
|
{ |
|
64
|
|
|
$className = $this->className; |
|
65
|
|
|
|
|
66
|
|
|
$manialink = new $className( |
|
67
|
|
|
$group, |
|
68
|
|
|
$this->windowManiaScriptFactory, |
|
69
|
|
|
$this->translationsHelper, |
|
70
|
|
|
$this->name, |
|
71
|
|
|
$this->sizeX, |
|
72
|
|
|
$this->sizeY, |
|
73
|
|
|
$this->posX, |
|
74
|
|
|
$this->posY |
|
75
|
|
|
); |
|
76
|
|
|
|
|
77
|
|
|
$actionId = $this->actionFactory->createManialinkAction( |
|
78
|
|
|
$manialink, |
|
79
|
|
|
[$this, 'closeManialink'], |
|
80
|
|
|
['manialink' => $manialink] |
|
81
|
|
|
); |
|
82
|
|
|
|
|
83
|
|
|
$manialink->setCloseAction($actionId); |
|
84
|
|
|
|
|
85
|
|
|
return $manialink; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function closeManialink($login, $answerValues, $arguments) |
|
89
|
|
|
{ |
|
90
|
|
|
/** @var Manialink $manialink */ |
|
91
|
|
|
$manialink = $arguments['manialink']; |
|
92
|
|
|
$this->destroy($manialink->getUserGroup()); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|