1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\content; |
4
|
|
|
|
5
|
|
|
use Ajax\semantic\html\base\HtmlSemDoubleElement; |
6
|
|
|
use Ajax\semantic\html\base\constants\Wide; |
7
|
|
|
use Ajax\semantic\html\base\traits\TextAlignmentTrait; |
8
|
|
|
use Ajax\semantic\html\base\constants\Direction; |
9
|
|
|
use Ajax\semantic\html\elements\HtmlDivider; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* A col in the Semantic Grid component |
13
|
|
|
* @see http://semantic-ui.com/collections/grid.html |
14
|
|
|
* @author jc |
15
|
|
|
* @version 1.001 |
16
|
|
|
*/ |
17
|
|
|
class HtmlGridCol extends HtmlSemDoubleElement { |
18
|
|
|
use TextAlignmentTrait; |
19
|
|
|
|
20
|
|
|
public function __construct($identifier, $width=NULL) { |
21
|
|
|
parent::__construct($identifier, "div"); |
22
|
|
|
$this->setClass("column"); |
23
|
|
|
if (isset($width)) |
24
|
|
|
$this->setWidth($width); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Defines the col width |
29
|
|
|
* @param int $width |
30
|
|
|
* @return \Ajax\semantic\html\content\HtmlGridCol |
31
|
|
|
*/ |
32
|
|
View Code Duplication |
public function setWidth($width) { |
|
|
|
|
33
|
|
|
if (\is_int($width)) { |
34
|
|
|
$width=Wide::getConstants()["W" . $width]; |
35
|
|
|
} |
36
|
|
|
$this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
37
|
|
|
return $this->addToPropertyCtrl("class", "wide", array ("wide" )); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function setValue($value) { |
41
|
|
|
$this->content=$value; |
42
|
|
|
return $this; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function setValues($value) { |
46
|
|
|
return $this->setValue($value); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function addDivider($vertical=true, $content=NULL) { |
50
|
|
|
$divider=new HtmlDivider("", $content); |
51
|
|
|
if ($vertical) |
52
|
|
|
$divider->setVertical(); |
53
|
|
|
else |
54
|
|
|
$divider->setHorizontal(); |
55
|
|
|
$this->wrap("", $divider); |
56
|
|
|
return $divider; |
57
|
|
|
} |
58
|
|
|
} |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.