1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ajax\bootstrap\traits; |
4
|
|
|
|
5
|
|
|
use Ajax\common\components\GenericComponent; |
6
|
|
|
use Ajax\bootstrap\components\Modal; |
7
|
|
|
use Ajax\bootstrap\components\Tooltip; |
8
|
|
|
use Ajax\bootstrap\components\Popover; |
9
|
|
|
use Ajax\bootstrap\components\Dropdown; |
10
|
|
|
use Ajax\bootstrap\components\Splitbutton; |
11
|
|
|
use Ajax\bootstrap\components\Tab; |
12
|
|
|
use Ajax\bootstrap\components\Carousel; |
13
|
|
|
use Ajax\bootstrap\components\Collapse; |
14
|
|
|
use Ajax\Bootstrap; |
15
|
|
|
use Ajax\common\components\SimpleComponent; |
16
|
|
|
|
17
|
|
|
trait BootstrapComponentsTrait { |
18
|
|
|
|
19
|
|
|
public abstract function addComponent(SimpleComponent $component, $attachTo, $params); |
20
|
|
|
/** |
21
|
|
|
* |
22
|
|
|
* @param string $attachTo |
23
|
|
|
* @param string|array $params |
24
|
|
|
* @return GenericComponent |
25
|
|
|
*/ |
26
|
|
|
public function generic($attachTo=NULL, $params=NULL) { |
27
|
|
|
return $this->addComponent(new GenericComponent($this->js), $attachTo, $params); |
|
|
|
|
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* |
32
|
|
|
* @param string $attachTo |
33
|
|
|
* @param string|array $params |
34
|
|
|
* @return Modal |
35
|
|
|
*/ |
36
|
|
|
public function modal($attachTo=NULL, $params=NULL) { |
37
|
|
|
return $this->addComponent(new Modal($this->js), $attachTo, $params); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* |
42
|
|
|
* @param string $attachTo |
43
|
|
|
* @param string|array $params |
44
|
|
|
* @return Tooltip |
45
|
|
|
*/ |
46
|
|
|
public function tooltip($attachTo=NULL, $params=NULL) { |
47
|
|
|
return $this->addComponent(new Tooltip($this->js), $attachTo, $params); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* |
52
|
|
|
* @param string $attachTo |
53
|
|
|
* @param string|array $params |
54
|
|
|
* @return Popover |
55
|
|
|
*/ |
56
|
|
|
public function popover($attachTo=NULL, $params=NULL) { |
57
|
|
|
return $this->addComponent(new Popover($this->js), $attachTo, $params); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* |
62
|
|
|
* @param string $attachTo |
63
|
|
|
* @param string|array $params |
64
|
|
|
* @return Dropdown |
65
|
|
|
*/ |
66
|
|
|
public function dropdown($attachTo=NULL, $params=NULL) { |
67
|
|
|
return $this->addComponent(new Dropdown($this->js), $attachTo, $params); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* |
72
|
|
|
* @param string $attachTo |
73
|
|
|
* @param string|array $params |
74
|
|
|
* @return Splitbutton |
75
|
|
|
*/ |
76
|
|
|
public function splitbutton($attachTo=NULL, $params=NULL) { |
77
|
|
|
return $this->addComponent(new Splitbutton($this->js), $attachTo, $params); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* |
82
|
|
|
* @param string $attachTo |
83
|
|
|
* @param string|array $params |
84
|
|
|
* @return Tab |
85
|
|
|
*/ |
86
|
|
|
public function tab($attachTo=NULL, $params=NULL) { |
87
|
|
|
return $this->addComponent(new Tab($this->js), $attachTo, $params); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* |
92
|
|
|
* @param string $attachTo |
93
|
|
|
* @param string|array $params |
94
|
|
|
* @return Collapse |
95
|
|
|
*/ |
96
|
|
|
public function collapse($attachTo=NULL, $params=NULL) { |
97
|
|
|
return $this->addComponent(new Collapse($this->js), $attachTo, $params); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* |
102
|
|
|
* @param string $attachTo |
103
|
|
|
* @param string|array $params |
104
|
|
|
* @return Carousel |
105
|
|
|
*/ |
106
|
|
|
public function carousel($attachTo=NULL, $params=NULL) { |
107
|
|
|
return $this->addComponent(new Carousel($this->js), $attachTo, $params); |
108
|
|
|
} |
109
|
|
|
} |
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: