1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\base\traits; |
4
|
|
|
|
5
|
|
|
use Ajax\semantic\html\base\constants\Size; |
6
|
|
|
use Ajax\semantic\html\base\constants\Color; |
7
|
|
|
use Ajax\semantic\html\base\constants\Direction; |
8
|
|
|
use Ajax\semantic\html\elements\HtmlIcon; |
9
|
|
|
|
10
|
|
|
trait BaseTrait { |
11
|
|
|
protected $_variations=[ ]; |
12
|
|
|
protected $_states=[ ]; |
13
|
|
|
protected $_baseClass; |
14
|
|
|
|
15
|
|
|
protected abstract function setPropertyCtrl($name, $value, $typeCtrl); |
16
|
|
|
|
17
|
|
|
protected abstract function addToPropertyCtrl($name, $value, $typeCtrl); |
18
|
|
|
|
19
|
|
|
protected abstract function addToPropertyCtrlCheck($name, $value, $typeCtrl); |
20
|
|
|
|
21
|
|
|
public abstract function addToProperty($name, $value, $separator=" "); |
22
|
|
|
|
23
|
|
|
public function addVariation($variation) { |
24
|
|
|
return $this->addToPropertyCtrlCheck("class", $variation, $this->_variations); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function addState($state) { |
28
|
|
|
return $this->addToPropertyCtrlCheck("class", $state, $this->_states); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function setVariation($variation) { |
32
|
|
|
$this->setPropertyCtrl("class", $variation, $this->_variations); |
33
|
|
|
return $this->addToProperty("class", $this->_baseClass); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function setVariations($variations) { |
37
|
|
|
$this->setProperty("class", $this->_baseClass); |
|
|
|
|
38
|
|
|
if (\is_string($variations)) |
39
|
|
|
$variations=\explode(" ", $variations); |
40
|
|
|
foreach ( $variations as $variation ) { |
41
|
|
|
$this->addVariation($variation); |
42
|
|
|
} |
43
|
|
|
return $this; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function setState($state) { |
47
|
|
|
$this->setPropertyCtrl("class", $state, $this->_states); |
48
|
|
|
return $this->addToProperty("class", $this->_baseClass); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function addVariations($variations=array()) { |
52
|
|
|
if (\is_string($variations)) |
53
|
|
|
$variations=\explode(" ", $variations); |
54
|
|
|
foreach ( $variations as $variation ) { |
55
|
|
|
$this->addVariation($variation); |
56
|
|
|
} |
57
|
|
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function addStates($states=array()) { |
61
|
|
|
if (\is_string($states)) |
62
|
|
|
$states=\explode(" ", $states); |
63
|
|
|
foreach ( $states as $state ) { |
64
|
|
|
$this->addState($state); |
65
|
|
|
} |
66
|
|
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function setStates($states) { |
70
|
|
|
$this->setProperty("class", $this->_baseClass); |
|
|
|
|
71
|
|
|
if (\is_string($states)) |
72
|
|
|
$states=\explode(" ", $states); |
73
|
|
|
foreach ( $states as $state ) { |
74
|
|
|
$this->addState($state); |
75
|
|
|
} |
76
|
|
|
return $this; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function addIcon($icon, $before=true) { |
80
|
|
|
return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* |
85
|
|
|
* {@inheritDoc} |
86
|
|
|
* |
87
|
|
|
* @see \Ajax\common\html\HtmlSingleElement::setSize() |
88
|
|
|
*/ |
89
|
|
|
public function setSize($size) { |
90
|
|
|
return $this->addToPropertyCtrl("class", $size, Size::getConstants()); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* show it is currently unable to be interacted with |
95
|
|
|
* @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
96
|
|
|
*/ |
97
|
|
|
public function setDisabled() { |
98
|
|
|
return $this->addToProperty("class", "disabled"); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* |
103
|
|
|
* @param string $color |
104
|
|
|
* @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
105
|
|
|
*/ |
106
|
|
|
public function setColor($color) { |
107
|
|
|
return $this->addToPropertyCtrl("class", $color, Color::getConstants()); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* |
112
|
|
|
* @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
113
|
|
|
*/ |
114
|
|
|
public function setFluid() { |
115
|
|
|
return $this->addToProperty("class", "fluid"); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* |
120
|
|
|
* @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
121
|
|
|
*/ |
122
|
|
|
public function asHeader(){ |
123
|
|
|
return $this->addToProperty("class", "header"); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* show it is currently the active user selection |
128
|
|
|
* @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
129
|
|
|
*/ |
130
|
|
|
public function setActive($value=true){ |
|
|
|
|
131
|
|
|
return $this->addToProperty("class", "active"); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* can be formatted to appear on dark backgrounds |
136
|
|
|
*/ |
137
|
|
|
public function setInverted() { |
138
|
|
|
return $this->addToProperty("class", "inverted"); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
public function setCircular() { |
142
|
|
|
return $this->addToProperty("class", "circular"); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function setFloated($direction="right") { |
146
|
|
|
return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
public function floatRight() { |
150
|
|
|
return $this->setFloated(); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
public function floatLeft() { |
154
|
|
|
return $this->setFloated("left"); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function getBaseClass() { |
158
|
|
|
return $this->_baseClass; |
159
|
|
|
} |
160
|
|
|
} |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.