1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ajax\semantic\traits; |
4
|
|
|
|
5
|
|
|
use Ajax\common\components\GenericComponent; |
6
|
|
|
use Ajax\semantic\components\Popup; |
7
|
|
|
use Ajax\semantic\components\Dropdown; |
8
|
|
|
use Ajax\semantic\components\Accordion; |
9
|
|
|
use Ajax\common\components\SimpleComponent; |
10
|
|
|
use Ajax\semantic\components\Sticky; |
11
|
|
|
use Ajax\semantic\components\Checkbox; |
12
|
|
|
use Ajax\semantic\components\Rating; |
13
|
|
|
use Ajax\semantic\components\Progress; |
14
|
|
|
use Ajax\semantic\components\Search; |
15
|
|
|
use Ajax\semantic\components\Dimmer; |
16
|
|
|
use Ajax\semantic\components\Modal; |
17
|
|
|
|
18
|
|
|
trait SemanticComponentsTrait { |
19
|
|
|
|
20
|
|
|
public abstract function addComponent(SimpleComponent $component, $attachTo, $params); |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* |
24
|
|
|
* @param string $attachTo |
25
|
|
|
* @param string|array $params |
26
|
|
|
* @return GenericComponent |
27
|
|
|
*/ |
28
|
|
|
public function generic($attachTo=NULL, $params=NULL) { |
29
|
|
|
return $this->addComponent(new GenericComponent($this->js), $attachTo, $params); |
|
|
|
|
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* |
34
|
|
|
* @param string $attachTo |
35
|
|
|
* @param string|array $params |
36
|
|
|
* @return Popup |
37
|
|
|
*/ |
38
|
|
|
public function popup($attachTo=NULL, $params=NULL) { |
39
|
|
|
return $this->addComponent(new Popup($this->js), $attachTo, $params); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* |
44
|
|
|
* @param string $attachTo |
45
|
|
|
* @param string|array $params |
46
|
|
|
* @return Dropdown |
47
|
|
|
*/ |
48
|
|
|
public function dropdown($attachTo=NULL, $params=NULL) { |
49
|
|
|
return $this->addComponent(new Dropdown($this->js), $attachTo, $params); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* |
54
|
|
|
* @param string $attachTo |
55
|
|
|
* @param string|array $params |
56
|
|
|
* @return Accordion |
57
|
|
|
*/ |
58
|
|
|
public function accordion($attachTo=NULL, $params=NULL) { |
59
|
|
|
return $this->addComponent(new Accordion($this->js), $attachTo, $params); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function sticky($attachTo=NULL, $params=NULL) { |
63
|
|
|
return $this->addComponent(new Sticky($this->js), $attachTo, $params); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function checkbox($attachTo=NULL, $params=NULL) { |
67
|
|
|
return $this->addComponent(new Checkbox($this->js), $attachTo, $params); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function rating($attachTo=NULL, $params=NULL) { |
71
|
|
|
return $this->addComponent(new Rating($this->js), $attachTo, $params); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function progress($attachTo=NULL, $params=NULL) { |
75
|
|
|
return $this->addComponent(new Progress($this->js), $attachTo, $params); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function search($attachTo=NULL, $params=NULL) { |
79
|
|
|
return $this->addComponent(new Search($this->js), $attachTo, $params); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function dimmer($attachTo=NULL, $params=NULL) { |
83
|
|
|
return $this->addComponent(new Dimmer($this->js), $attachTo, $params); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function modal($attachTo=NULL, $params=NULL,$paramsParts=NULL) { |
87
|
|
|
$result= $this->addComponent(new Modal($this->js), $attachTo, $params); |
88
|
|
|
$result->setParamParts($paramsParts); |
89
|
|
|
return $result; |
90
|
|
|
} |
91
|
|
|
} |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: