phpMv
-UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
HtmlTD.php
Go to the documentation of this file.
1
<?php
2
namespace
Ajax\semantic\html\content\table
;
3
4
use
Ajax\semantic\html\base\HtmlSemDoubleElement
;
5
use
Ajax\semantic\html\base\traits\TextAlignmentTrait
;
6
use
Ajax\semantic\html\base\constants\Variation
;
7
use
Ajax\semantic\html\base\constants\State
;
8
use
Ajax\semantic\html\base\traits\TableElementTrait
;
9
use
Ajax\semantic\html\elements\html5\HtmlLink
;
10
use
Ajax\semantic\html\base\constants\Wide
;
11
use
Ajax\JsUtils
;
12
13
class
HtmlTD
extends
HtmlSemDoubleElement
,
TextAlignmentTrait
,
TableElementTrait
{
14
15
private
$_container
;
16
17
private
$_row
;
18
19
private
$_col
;
20
21
private
$_colMerged
=
false
;
22
23
private
$_rowMerged
=
false
;
24
25
private
$_deleted
=
false
;
26
33
public
function
__construct
(
$identifier
,
$content
= NULL,
$tagName
=
"td"
) {
34
parent::__construct(
$identifier
,
$tagName
,
""
,
$content
);
35
$this->_variations = [
36
Variation::COLLAPSING
37
];
38
$this->_states = [
39
State::ACTIVE,
40
State::POSITIVE,
41
State::NEGATIVE,
42
State::WARNING,
43
State::ERROR,
44
State::DISABLED
45
];
46
}
47
48
public
function
setContainer
($container, $row, $col) {
49
$this->_container = $container;
50
$this->_row = $row;
51
$this->_col = $col;
52
}
53
54
public
function
setValue
($value) {
55
$this->content = $value;
56
return
$this;
57
}
58
59
public
function
addValue
($value) {
60
$this->
addContent
($value);
61
return
$this;
62
}
63
64
public
function
setRowspan
($rowspan) {
65
$to = min($this->_container->count(), $this->_row + $rowspan - 1);
66
for
($i = $to; $i >
$this->_row
; $i --) {
67
$this->_container->toDelete($i, $this->_col);
68
}
69
$this->
setProperty
(
"rowspan"
, $rowspan);
70
return
$this->_container->_setMerged(
true
);
71
}
72
73
public
function
setRowspanned
($rowspan) {
74
$to = min($this->_container->count(), $this->_row + $rowspan - 1);
75
for
($i = $to; $i >
$this->_row
; $i --) {
76
$this->_container->toRowspanned($i, $this->_col);
77
}
78
$this->
setProperty
(
"rowspan"
, $rowspan);
79
return
$this->_container->_setMerged(
true
);
80
}
81
82
public
function
mergeRow
() {
83
if
(! $this->_rowMerged) {
84
$this->_rowMerged =
true
;
85
return
$this->
setRowspan
($this->_container->count());
86
}
87
return
$this->_container
;
88
}
89
90
public
function
mergeCol
() {
91
if
(! $this->_colMerged) {
92
$this->_colMerged =
true
;
93
return
$this->
setColspan
($this->_container->getRow($this->_row)
94
->count());
95
}
96
return
$this->_container
;
97
}
98
99
public
function
setColspan
($colspan) {
100
$to = min($this->_container->getRow($this->_row)->count(), $this->_col + $colspan - 1);
101
for
($i = $to; $i >
$this->_col
; $i --) {
102
$this->_container->delete($this->_row, $this->_col + 1);
103
}
104
$this->
setProperty
(
"colspan"
, $colspan);
105
return
$this->_container
;
106
}
107
108
public
function
getColspan
() {
109
$colspan = 1;
110
if
(\array_key_exists(
"colspan"
, $this->properties))
111
$colspan = $this->
getProperty
(
"colspan"
);
112
return
$colspan;
113
}
114
115
public
function
getRowspan
() {
116
$rowspan = 1;
117
if
(\array_key_exists(
"rowspan"
, $this->properties))
118
$rowspan = $this->
getProperty
(
"rowspan"
);
119
return
$rowspan;
120
}
121
122
public
function
conditionalCellFormat
($callback, $format) {
123
if
($callback($this)) {
124
$this->
addToProperty
(
"class"
, $format);
125
}
126
return
$this;
127
}
128
129
public
function
apply
($callback) {
130
$callback($this);
131
return
$this;
132
}
133
134
public
function
setSelectable
($href =
"#"
) {
135
if
(\is_string($this->content)) {
136
$this->content =
new
HtmlLink
(
""
, $href, $this->content);
137
}
138
return
$this->
addToProperty
(
"class"
,
"selectable"
);
139
}
140
141
public
function
setWidth
($width) {
142
if
(\is_int($width)) {
143
$width = Wide::getConstants()[
"W"
. $width];
144
}
145
$this->
addToPropertyCtrl
(
"class"
, $width, Wide::getConstants());
146
return
$this->
addToPropertyCtrl
(
"class"
,
"wide"
, array(
147
"wide"
148
));
149
}
150
151
public
function
toDelete
() {
152
$this->_deleted =
true
;
153
return
$this;
154
}
155
156
public
function
compile
(
JsUtils
$js = NULL, &$view = NULL) {
157
if
(! $this->_deleted)
158
return
parent::compile($js, $view);
159
}
160
}
Ajax\JsUtils
JQuery PHP library.
Definition
JsUtils.php:23
Ajax\common\html\BaseHtml\$tagName
$tagName
Definition
BaseHtml.php:21
Ajax\common\html\BaseWidget\$identifier
$identifier
Definition
BaseWidget.php:14
Ajax\common\html\HtmlDoubleElement\$content
$content
Definition
HtmlDoubleElement.php:14
Ajax\common\html\HtmlDoubleElement\addContent
addContent($content, $before=false)
Definition
HtmlDoubleElement.php:36
Ajax\common\html\traits\BaseHtmlPropertiesTrait\getProperty
getProperty($name)
Definition
BaseHtmlPropertiesTrait.php:35
Ajax\semantic\html\base\HtmlSemDoubleElement
Base class for Semantic double elements.
Definition
HtmlSemDoubleElement.php:23
Ajax\semantic\html\base\constants\State
Definition
State.php:8
Ajax\semantic\html\base\constants\Variation
Definition
Variation.php:7
Ajax\semantic\html\base\constants\Wide
Definition
Wide.php:4
Ajax\semantic\html\base\traits\BaseTrait\addToProperty
addToProperty($name, $value, $separator=" ")
Ajax\semantic\html\base\traits\BaseTrait\setProperty
setProperty($name, $value)
Ajax\semantic\html\base\traits\TableElementTrait
Definition
TableElementTrait.php:7
Ajax\semantic\html\base\traits\TextAlignmentTrait
Definition
TextAlignmentTrait.php:7
Ajax\semantic\html\base\traits\TextAlignmentTrait\addToPropertyCtrl
addToPropertyCtrl($name, $value, $typeCtrl)
Ajax\semantic\html\content\table\HtmlTD
Definition
HtmlTD.php:13
Ajax\semantic\html\content\table\HtmlTD\$_col
$_col
Definition
HtmlTD.php:19
Ajax\semantic\html\content\table\HtmlTD\setSelectable
setSelectable($href="#")
Definition
HtmlTD.php:134
Ajax\semantic\html\content\table\HtmlTD\setColspan
setColspan($colspan)
Definition
HtmlTD.php:99
Ajax\semantic\html\content\table\HtmlTD\conditionalCellFormat
conditionalCellFormat($callback, $format)
Definition
HtmlTD.php:122
Ajax\semantic\html\content\table\HtmlTD\getColspan
getColspan()
Definition
HtmlTD.php:108
Ajax\semantic\html\content\table\HtmlTD\setRowspan
setRowspan($rowspan)
Definition
HtmlTD.php:64
Ajax\semantic\html\content\table\HtmlTD\addValue
addValue($value)
Definition
HtmlTD.php:59
Ajax\semantic\html\content\table\HtmlTD\$_deleted
$_deleted
Definition
HtmlTD.php:25
Ajax\semantic\html\content\table\HtmlTD\setValue
setValue($value)
Definition
HtmlTD.php:54
Ajax\semantic\html\content\table\HtmlTD\$_row
$_row
Definition
HtmlTD.php:17
Ajax\semantic\html\content\table\HtmlTD\mergeRow
mergeRow()
Definition
HtmlTD.php:82
Ajax\semantic\html\content\table\HtmlTD\toDelete
toDelete()
Definition
HtmlTD.php:151
Ajax\semantic\html\content\table\HtmlTD\__construct
__construct($identifier, $content=NULL, $tagName="td")
Definition
HtmlTD.php:33
Ajax\semantic\html\content\table\HtmlTD\compile
compile(JsUtils $js=NULL, &$view=NULL)
{{}BaseHtml::compile()}
Definition
HtmlTD.php:156
Ajax\semantic\html\content\table\HtmlTD\$_container
$_container
Definition
HtmlTD.php:15
Ajax\semantic\html\content\table\HtmlTD\$_rowMerged
$_rowMerged
Definition
HtmlTD.php:23
Ajax\semantic\html\content\table\HtmlTD\setRowspanned
setRowspanned($rowspan)
Definition
HtmlTD.php:73
Ajax\semantic\html\content\table\HtmlTD\$_colMerged
$_colMerged
Definition
HtmlTD.php:21
Ajax\semantic\html\content\table\HtmlTD\mergeCol
mergeCol()
Definition
HtmlTD.php:90
Ajax\semantic\html\content\table\HtmlTD\getRowspan
getRowspan()
Definition
HtmlTD.php:115
Ajax\semantic\html\content\table\HtmlTD\setWidth
setWidth($width)
Definition
HtmlTD.php:141
Ajax\semantic\html\content\table\HtmlTD\setContainer
setContainer($container, $row, $col)
Definition
HtmlTD.php:48
Ajax\semantic\html\content\table\HtmlTD\apply
apply($callback)
Definition
HtmlTD.php:129
Ajax\semantic\html\elements\html5\HtmlLink
Definition
HtmlLink.php:10
Ajax\semantic\html\content\table
Definition
HtmlTableContent.php:2
Ajax
semantic
html
content
table
HtmlTD.php
Generated on Sun Dec 10 2023 16:16:06 for
phpMv-UI
by
doxygen
1.9.8