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
3
11use Ajax\JsUtils;
12
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}
JQuery PHP library.
Definition JsUtils.php:23
addContent($content, $before=false)
Base class for Semantic double elements.
addToProperty($name, $value, $separator=" ")
conditionalCellFormat($callback, $format)
Definition HtmlTD.php:122
__construct($identifier, $content=NULL, $tagName="td")
Definition HtmlTD.php:33
compile(JsUtils $js=NULL, &$view=NULL)
{{}BaseHtml::compile()}
Definition HtmlTD.php:156
setContainer($container, $row, $col)
Definition HtmlTD.php:48