@@ -96,19 +96,19 @@ discard block |
||
96 | 96 | public function copyFrom($style) |
97 | 97 | { |
98 | 98 | parent::copyFrom($style); |
99 | - if($style instanceof TTableStyle) |
|
99 | + if ($style instanceof TTableStyle) |
|
100 | 100 | { |
101 | - if($style->_backImageUrl !== null) |
|
101 | + if ($style->_backImageUrl !== null) |
|
102 | 102 | $this->_backImageUrl = $style->_backImageUrl; |
103 | - if($style->_horizontalAlign !== null) |
|
103 | + if ($style->_horizontalAlign !== null) |
|
104 | 104 | $this->_horizontalAlign = $style->_horizontalAlign; |
105 | - if($style->_cellPadding !== null) |
|
105 | + if ($style->_cellPadding !== null) |
|
106 | 106 | $this->_cellPadding = $style->_cellPadding; |
107 | - if($style->_cellSpacing !== null) |
|
107 | + if ($style->_cellSpacing !== null) |
|
108 | 108 | $this->_cellSpacing = $style->_cellSpacing; |
109 | - if($style->_gridLines !== null) |
|
109 | + if ($style->_gridLines !== null) |
|
110 | 110 | $this->_gridLines = $style->_gridLines; |
111 | - if($style->_borderCollapse !== null) |
|
111 | + if ($style->_borderCollapse !== null) |
|
112 | 112 | $this->_borderCollapse = $style->_borderCollapse; |
113 | 113 | } |
114 | 114 | } |
@@ -122,19 +122,19 @@ discard block |
||
122 | 122 | public function mergeWith($style) |
123 | 123 | { |
124 | 124 | parent::mergeWith($style); |
125 | - if($style instanceof TTableStyle) |
|
125 | + if ($style instanceof TTableStyle) |
|
126 | 126 | { |
127 | - if($this->_backImageUrl === null && $style->_backImageUrl !== null) |
|
127 | + if ($this->_backImageUrl === null && $style->_backImageUrl !== null) |
|
128 | 128 | $this->_backImageUrl = $style->_backImageUrl; |
129 | - if($this->_horizontalAlign === null && $style->_horizontalAlign !== null) |
|
129 | + if ($this->_horizontalAlign === null && $style->_horizontalAlign !== null) |
|
130 | 130 | $this->_horizontalAlign = $style->_horizontalAlign; |
131 | - if($this->_cellPadding === null && $style->_cellPadding !== null) |
|
131 | + if ($this->_cellPadding === null && $style->_cellPadding !== null) |
|
132 | 132 | $this->_cellPadding = $style->_cellPadding; |
133 | - if($this->_cellSpacing === null && $style->_cellSpacing !== null) |
|
133 | + if ($this->_cellSpacing === null && $style->_cellSpacing !== null) |
|
134 | 134 | $this->_cellSpacing = $style->_cellSpacing; |
135 | - if($this->_gridLines === null && $style->_gridLines !== null) |
|
135 | + if ($this->_gridLines === null && $style->_gridLines !== null) |
|
136 | 136 | $this->_gridLines = $style->_gridLines; |
137 | - if($this->_borderCollapse === null && $style->_borderCollapse !== null) |
|
137 | + if ($this->_borderCollapse === null && $style->_borderCollapse !== null) |
|
138 | 138 | $this->_borderCollapse = $style->_borderCollapse; |
139 | 139 | } |
140 | 140 | } |
@@ -147,22 +147,22 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function addAttributesToRender($writer) |
149 | 149 | { |
150 | - if(($url = trim($this->getBackImageUrl())) !== '') |
|
151 | - $writer->addStyleAttribute('background-image', 'url(' . $url . ')'); |
|
150 | + if (($url = trim($this->getBackImageUrl())) !== '') |
|
151 | + $writer->addStyleAttribute('background-image', 'url('.$url.')'); |
|
152 | 152 | |
153 | - if(($horizontalAlign = $this->getHorizontalAlign()) !== THorizontalAlign::NotSet) |
|
153 | + if (($horizontalAlign = $this->getHorizontalAlign()) !== THorizontalAlign::NotSet) |
|
154 | 154 | $writer->addStyleAttribute('text-align', strtolower($horizontalAlign)); |
155 | 155 | |
156 | - if(($cellPadding = $this->getCellPadding()) >= 0) |
|
156 | + if (($cellPadding = $this->getCellPadding()) >= 0) |
|
157 | 157 | $writer->addAttribute('cellpadding', "$cellPadding"); |
158 | 158 | |
159 | - if(($cellSpacing = $this->getCellSpacing()) >= 0) |
|
159 | + if (($cellSpacing = $this->getCellSpacing()) >= 0) |
|
160 | 160 | $writer->addAttribute('cellspacing', "$cellSpacing"); |
161 | 161 | |
162 | - if($this->getBorderCollapse()) |
|
162 | + if ($this->getBorderCollapse()) |
|
163 | 163 | $writer->addStyleAttribute('border-collapse', 'collapse'); |
164 | 164 | |
165 | - switch($this->getGridLines()) |
|
165 | + switch ($this->getGridLines()) |
|
166 | 166 | { |
167 | 167 | case TTableGridLines::Horizontal : $writer->addAttribute('rules', 'rows'); break; |
168 | 168 | case TTableGridLines::Vertical : $writer->addAttribute('rules', 'cols'); break; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function getBackImageUrl() |
179 | 179 | { |
180 | - return $this->_backImageUrl === null?'':$this->_backImageUrl; |
|
180 | + return $this->_backImageUrl === null ? '' : $this->_backImageUrl; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function getHorizontalAlign() |
196 | 196 | { |
197 | - return $this->_horizontalAlign === null?THorizontalAlign::NotSet:$this->_horizontalAlign; |
|
197 | + return $this->_horizontalAlign === null ?THorizontalAlign::NotSet : $this->_horizontalAlign; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | */ |
212 | 212 | public function getCellPadding() |
213 | 213 | { |
214 | - return $this->_cellPadding === null?-1:$this->_cellPadding; |
|
214 | + return $this->_cellPadding === null ?-1 : $this->_cellPadding; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | public function setCellPadding($value) |
222 | 222 | { |
223 | - if(($this->_cellPadding = TPropertyValue::ensureInteger($value)) < -1) |
|
223 | + if (($this->_cellPadding = TPropertyValue::ensureInteger($value)) < -1) |
|
224 | 224 | throw new TInvalidDataValueException('tablestyle_cellpadding_invalid'); |
225 | 225 | } |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function getCellSpacing() |
231 | 231 | { |
232 | - return $this->_cellSpacing === null?-1:$this->_cellSpacing; |
|
232 | + return $this->_cellSpacing === null ?-1 : $this->_cellSpacing; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function setCellSpacing($value) |
240 | 240 | { |
241 | - if(($this->_cellSpacing = TPropertyValue::ensureInteger($value)) < -1) |
|
241 | + if (($this->_cellSpacing = TPropertyValue::ensureInteger($value)) < -1) |
|
242 | 242 | throw new TInvalidDataValueException('tablestyle_cellspacing_invalid'); |
243 | 243 | } |
244 | 244 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function getGridLines() |
249 | 249 | { |
250 | - return $this->_gridLines === null?TTableGridLines::None:$this->_gridLines; |
|
250 | + return $this->_gridLines === null ?TTableGridLines::None : $this->_gridLines; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function getBorderCollapse() |
267 | 267 | { |
268 | - return $this->_borderCollapse === null?false:$this->_borderCollapse; |
|
268 | + return $this->_borderCollapse === null ?false:$this->_borderCollapse; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -58,18 +58,24 @@ discard block |
||
58 | 58 | protected function _getZappableSleepProps(&$exprops) |
59 | 59 | { |
60 | 60 | parent::_getZappableSleepProps($exprops); |
61 | - if ($this->_backImageUrl === null) |
|
62 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_backImageUrl"; |
|
63 | - if ($this->_horizontalAlign === null) |
|
64 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_horizontalAlign"; |
|
65 | - if ($this->_cellPadding === null) |
|
66 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_cellPadding"; |
|
67 | - if ($this->_cellSpacing === null) |
|
68 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_cellSpacing"; |
|
69 | - if ($this->_gridLines === null) |
|
70 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_gridLines"; |
|
71 | - if ($this->_borderCollapse === null) |
|
72 | - $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_borderCollapse"; |
|
61 | + if ($this->_backImageUrl === null) { |
|
62 | + $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_backImageUrl"; |
|
63 | + } |
|
64 | + if ($this->_horizontalAlign === null) { |
|
65 | + $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_horizontalAlign"; |
|
66 | + } |
|
67 | + if ($this->_cellPadding === null) { |
|
68 | + $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_cellPadding"; |
|
69 | + } |
|
70 | + if ($this->_cellSpacing === null) { |
|
71 | + $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_cellSpacing"; |
|
72 | + } |
|
73 | + if ($this->_gridLines === null) { |
|
74 | + $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_gridLines"; |
|
75 | + } |
|
76 | + if ($this->_borderCollapse === null) { |
|
77 | + $exprops[] = "\0Prado\Web\UI\WebControls\TTableStyle\0_borderCollapse"; |
|
78 | + } |
|
73 | 79 | } |
74 | 80 | |
75 | 81 | /** |
@@ -98,18 +104,24 @@ discard block |
||
98 | 104 | parent::copyFrom($style); |
99 | 105 | if($style instanceof TTableStyle) |
100 | 106 | { |
101 | - if($style->_backImageUrl !== null) |
|
102 | - $this->_backImageUrl = $style->_backImageUrl; |
|
103 | - if($style->_horizontalAlign !== null) |
|
104 | - $this->_horizontalAlign = $style->_horizontalAlign; |
|
105 | - if($style->_cellPadding !== null) |
|
106 | - $this->_cellPadding = $style->_cellPadding; |
|
107 | - if($style->_cellSpacing !== null) |
|
108 | - $this->_cellSpacing = $style->_cellSpacing; |
|
109 | - if($style->_gridLines !== null) |
|
110 | - $this->_gridLines = $style->_gridLines; |
|
111 | - if($style->_borderCollapse !== null) |
|
112 | - $this->_borderCollapse = $style->_borderCollapse; |
|
107 | + if($style->_backImageUrl !== null) { |
|
108 | + $this->_backImageUrl = $style->_backImageUrl; |
|
109 | + } |
|
110 | + if($style->_horizontalAlign !== null) { |
|
111 | + $this->_horizontalAlign = $style->_horizontalAlign; |
|
112 | + } |
|
113 | + if($style->_cellPadding !== null) { |
|
114 | + $this->_cellPadding = $style->_cellPadding; |
|
115 | + } |
|
116 | + if($style->_cellSpacing !== null) { |
|
117 | + $this->_cellSpacing = $style->_cellSpacing; |
|
118 | + } |
|
119 | + if($style->_gridLines !== null) { |
|
120 | + $this->_gridLines = $style->_gridLines; |
|
121 | + } |
|
122 | + if($style->_borderCollapse !== null) { |
|
123 | + $this->_borderCollapse = $style->_borderCollapse; |
|
124 | + } |
|
113 | 125 | } |
114 | 126 | } |
115 | 127 | |
@@ -124,18 +136,24 @@ discard block |
||
124 | 136 | parent::mergeWith($style); |
125 | 137 | if($style instanceof TTableStyle) |
126 | 138 | { |
127 | - if($this->_backImageUrl === null && $style->_backImageUrl !== null) |
|
128 | - $this->_backImageUrl = $style->_backImageUrl; |
|
129 | - if($this->_horizontalAlign === null && $style->_horizontalAlign !== null) |
|
130 | - $this->_horizontalAlign = $style->_horizontalAlign; |
|
131 | - if($this->_cellPadding === null && $style->_cellPadding !== null) |
|
132 | - $this->_cellPadding = $style->_cellPadding; |
|
133 | - if($this->_cellSpacing === null && $style->_cellSpacing !== null) |
|
134 | - $this->_cellSpacing = $style->_cellSpacing; |
|
135 | - if($this->_gridLines === null && $style->_gridLines !== null) |
|
136 | - $this->_gridLines = $style->_gridLines; |
|
137 | - if($this->_borderCollapse === null && $style->_borderCollapse !== null) |
|
138 | - $this->_borderCollapse = $style->_borderCollapse; |
|
139 | + if($this->_backImageUrl === null && $style->_backImageUrl !== null) { |
|
140 | + $this->_backImageUrl = $style->_backImageUrl; |
|
141 | + } |
|
142 | + if($this->_horizontalAlign === null && $style->_horizontalAlign !== null) { |
|
143 | + $this->_horizontalAlign = $style->_horizontalAlign; |
|
144 | + } |
|
145 | + if($this->_cellPadding === null && $style->_cellPadding !== null) { |
|
146 | + $this->_cellPadding = $style->_cellPadding; |
|
147 | + } |
|
148 | + if($this->_cellSpacing === null && $style->_cellSpacing !== null) { |
|
149 | + $this->_cellSpacing = $style->_cellSpacing; |
|
150 | + } |
|
151 | + if($this->_gridLines === null && $style->_gridLines !== null) { |
|
152 | + $this->_gridLines = $style->_gridLines; |
|
153 | + } |
|
154 | + if($this->_borderCollapse === null && $style->_borderCollapse !== null) { |
|
155 | + $this->_borderCollapse = $style->_borderCollapse; |
|
156 | + } |
|
139 | 157 | } |
140 | 158 | } |
141 | 159 | |
@@ -147,20 +165,25 @@ discard block |
||
147 | 165 | */ |
148 | 166 | public function addAttributesToRender($writer) |
149 | 167 | { |
150 | - if(($url = trim($this->getBackImageUrl())) !== '') |
|
151 | - $writer->addStyleAttribute('background-image', 'url(' . $url . ')'); |
|
168 | + if(($url = trim($this->getBackImageUrl())) !== '') { |
|
169 | + $writer->addStyleAttribute('background-image', 'url(' . $url . ')'); |
|
170 | + } |
|
152 | 171 | |
153 | - if(($horizontalAlign = $this->getHorizontalAlign()) !== THorizontalAlign::NotSet) |
|
154 | - $writer->addStyleAttribute('text-align', strtolower($horizontalAlign)); |
|
172 | + if(($horizontalAlign = $this->getHorizontalAlign()) !== THorizontalAlign::NotSet) { |
|
173 | + $writer->addStyleAttribute('text-align', strtolower($horizontalAlign)); |
|
174 | + } |
|
155 | 175 | |
156 | - if(($cellPadding = $this->getCellPadding()) >= 0) |
|
157 | - $writer->addAttribute('cellpadding', "$cellPadding"); |
|
176 | + if(($cellPadding = $this->getCellPadding()) >= 0) { |
|
177 | + $writer->addAttribute('cellpadding', "$cellPadding"); |
|
178 | + } |
|
158 | 179 | |
159 | - if(($cellSpacing = $this->getCellSpacing()) >= 0) |
|
160 | - $writer->addAttribute('cellspacing', "$cellSpacing"); |
|
180 | + if(($cellSpacing = $this->getCellSpacing()) >= 0) { |
|
181 | + $writer->addAttribute('cellspacing', "$cellSpacing"); |
|
182 | + } |
|
161 | 183 | |
162 | - if($this->getBorderCollapse()) |
|
163 | - $writer->addStyleAttribute('border-collapse', 'collapse'); |
|
184 | + if($this->getBorderCollapse()) { |
|
185 | + $writer->addStyleAttribute('border-collapse', 'collapse'); |
|
186 | + } |
|
164 | 187 | |
165 | 188 | switch($this->getGridLines()) |
166 | 189 | { |
@@ -220,8 +243,9 @@ discard block |
||
220 | 243 | */ |
221 | 244 | public function setCellPadding($value) |
222 | 245 | { |
223 | - if(($this->_cellPadding = TPropertyValue::ensureInteger($value)) < -1) |
|
224 | - throw new TInvalidDataValueException('tablestyle_cellpadding_invalid'); |
|
246 | + if(($this->_cellPadding = TPropertyValue::ensureInteger($value)) < -1) { |
|
247 | + throw new TInvalidDataValueException('tablestyle_cellpadding_invalid'); |
|
248 | + } |
|
225 | 249 | } |
226 | 250 | |
227 | 251 | /** |
@@ -238,8 +262,9 @@ discard block |
||
238 | 262 | */ |
239 | 263 | public function setCellSpacing($value) |
240 | 264 | { |
241 | - if(($this->_cellSpacing = TPropertyValue::ensureInteger($value)) < -1) |
|
242 | - throw new TInvalidDataValueException('tablestyle_cellspacing_invalid'); |
|
265 | + if(($this->_cellSpacing = TPropertyValue::ensureInteger($value)) < -1) { |
|
266 | + throw new TInvalidDataValueException('tablestyle_cellspacing_invalid'); |
|
267 | + } |
|
243 | 268 | } |
244 | 269 | |
245 | 270 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function addParsedObject($object) |
91 | 91 | { |
92 | - if($object instanceof TAccordionView) |
|
92 | + if ($object instanceof TAccordionView) |
|
93 | 93 | $this->getControls()->add($object); |
94 | 94 | } |
95 | 95 | |
@@ -144,32 +144,32 @@ discard block |
||
144 | 144 | { |
145 | 145 | $activeView = null; |
146 | 146 | $views = $this->getViews(); |
147 | - if(($id = $this->getActiveViewID()) !== '') |
|
147 | + if (($id = $this->getActiveViewID()) !== '') |
|
148 | 148 | { |
149 | - if(($index = $views->findIndexByID($id)) >= 0) |
|
149 | + if (($index = $views->findIndexByID($id)) >= 0) |
|
150 | 150 | $activeView = $views->itemAt($index); |
151 | 151 | else |
152 | 152 | throw new TInvalidDataValueException('accordion_activeviewid_invalid', $id); |
153 | 153 | } |
154 | - elseif(($index = $this->getActiveViewIndex()) >= 0) |
|
154 | + elseif (($index = $this->getActiveViewIndex()) >= 0) |
|
155 | 155 | { |
156 | - if($index < $views->getCount()) |
|
156 | + if ($index < $views->getCount()) |
|
157 | 157 | $activeView = $views->itemAt($index); |
158 | 158 | else |
159 | 159 | throw new TInvalidDataValueException('accordion_activeviewindex_invalid', $index); |
160 | 160 | } |
161 | 161 | else |
162 | 162 | { |
163 | - foreach($views as $index => $view) |
|
163 | + foreach ($views as $index => $view) |
|
164 | 164 | { |
165 | - if($view->getActive()) |
|
165 | + if ($view->getActive()) |
|
166 | 166 | { |
167 | 167 | $activeView = $view; |
168 | 168 | break; |
169 | 169 | } |
170 | 170 | } |
171 | 171 | } |
172 | - if($activeView !== null) |
|
172 | + if ($activeView !== null) |
|
173 | 173 | $this->activateView($activeView); |
174 | 174 | return $activeView; |
175 | 175 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function setActiveView($view) |
182 | 182 | { |
183 | - if($this->getViews()->indexOf($view) >= 0) |
|
183 | + if ($this->getViews()->indexOf($view) >= 0) |
|
184 | 184 | $this->activateView($view); |
185 | 185 | else |
186 | 186 | throw new TInvalidOperationException('accordion_view_inexistent'); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | public function getCssClass() |
209 | 209 | { |
210 | 210 | $cssClass = parent::getCssClass(); |
211 | - return $cssClass === ''?'accordion':$cssClass; |
|
211 | + return $cssClass === '' ? 'accordion' : $cssClass; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function getViewStyle() |
250 | 250 | { |
251 | - if(($style = $this->getViewState('ViewStyle', null)) === null) |
|
251 | + if (($style = $this->getViewState('ViewStyle', null)) === null) |
|
252 | 252 | { |
253 | 253 | $style = new TStyle; |
254 | 254 | $style->setCssClass('accordion-view'); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | */ |
279 | 279 | public function getHeaderStyle() |
280 | 280 | { |
281 | - if(($style = $this->getViewState('HeaderStyle', null)) === null) |
|
281 | + if (($style = $this->getViewState('HeaderStyle', null)) === null) |
|
282 | 282 | { |
283 | 283 | $style = new TStyle; |
284 | 284 | $style->setCssClass('accordion-header'); |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | */ |
309 | 309 | public function getActiveHeaderStyle() |
310 | 310 | { |
311 | - if(($style = $this->getViewState('ActiveHeaderStyle', null)) === null) |
|
311 | + if (($style = $this->getViewState('ActiveHeaderStyle', null)) === null) |
|
312 | 312 | { |
313 | 313 | $style = new TStyle; |
314 | 314 | $style->setCssClass('accordion-header-active'); |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | { |
343 | 343 | $this->setActiveViewIndex(-1); |
344 | 344 | $this->setActiveViewID(''); |
345 | - foreach($this->getViews() as $index => $v) |
|
345 | + foreach ($this->getViews() as $index => $v) |
|
346 | 346 | { |
347 | - if($view === $v) |
|
347 | + if ($view === $v) |
|
348 | 348 | { |
349 | 349 | $this->setActiveViewIndex($index); |
350 | 350 | $this->setActiveViewID($view->getID(false)); |
@@ -364,11 +364,11 @@ discard block |
||
364 | 364 | */ |
365 | 365 | public function loadPostData($key, $values) |
366 | 366 | { |
367 | - if(($index = $values[$this->getClientID() . '_1']) !== null) |
|
367 | + if (($index = $values[$this->getClientID().'_1']) !== null) |
|
368 | 368 | { |
369 | - $index = (int)$index; |
|
369 | + $index = (int) $index; |
|
370 | 370 | $currentIndex = $this->getActiveViewIndex(); |
371 | - if($currentIndex !== $index) |
|
371 | + if ($currentIndex !== $index) |
|
372 | 372 | { |
373 | 373 | $this->setActiveViewID(''); // clear up view ID |
374 | 374 | $this->setActiveViewIndex($index); |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | public function onPreRender($param) |
420 | 420 | { |
421 | 421 | parent::onPreRender($param); |
422 | - $this->getActiveView(); // determine the active view |
|
422 | + $this->getActiveView(); // determine the active view |
|
423 | 423 | $this->registerStyleSheet(); |
424 | 424 | } |
425 | 425 | |
@@ -432,15 +432,15 @@ discard block |
||
432 | 432 | { |
433 | 433 | $url = $this->getCssUrl(); |
434 | 434 | |
435 | - if($url === '') { |
|
435 | + if ($url === '') { |
|
436 | 436 | return; |
437 | 437 | } |
438 | 438 | |
439 | - if($url === 'default') { |
|
440 | - $url = $this->getApplication()->getAssetManager()->publishFilePath(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'accordion.css'); |
|
439 | + if ($url === 'default') { |
|
440 | + $url = $this->getApplication()->getAssetManager()->publishFilePath(dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'accordion.css'); |
|
441 | 441 | } |
442 | 442 | |
443 | - if($url !== '') { |
|
443 | + if ($url !== '') { |
|
444 | 444 | $this->getPage()->getClientScript()->registerStyleSheetFile($url, $url); |
445 | 445 | } |
446 | 446 | } |
@@ -460,11 +460,11 @@ discard block |
||
460 | 460 | $cs->registerEndScript("prado:$id", $code); |
461 | 461 | // ensure an item is always active and visible |
462 | 462 | $index = $this->getActiveViewIndex(); |
463 | - if(!$this->getViews()->itemAt($index)->Visible) |
|
463 | + if (!$this->getViews()->itemAt($index)->Visible) |
|
464 | 464 | $index = 0; |
465 | - $cs->registerHiddenField($id . '_1', $index); |
|
465 | + $cs->registerHiddenField($id.'_1', $index); |
|
466 | 466 | $page->registerRequiresPostData($this); |
467 | - $page->registerRequiresPostData($id . "_1"); |
|
467 | + $page->registerRequiresPostData($id."_1"); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | if (($viewheight = $this->getViewHeight()) > 0) |
491 | 491 | $options['maxHeight'] = $viewheight; |
492 | 492 | $views = []; |
493 | - foreach($this->getViews() as $view) |
|
494 | - $views[$view->getClientID()] = $view->getVisible() ? '1': '0'; |
|
493 | + foreach ($this->getViews() as $view) |
|
494 | + $views[$view->getClientID()] = $view->getVisible() ? '1' : '0'; |
|
495 | 495 | $options['Views'] = $views; |
496 | 496 | |
497 | 497 | return $options; |
@@ -527,10 +527,10 @@ discard block |
||
527 | 527 | public function renderContents($writer) |
528 | 528 | { |
529 | 529 | $views = $this->getViews(); |
530 | - if($views->getCount() > 0) |
|
530 | + if ($views->getCount() > 0) |
|
531 | 531 | { |
532 | 532 | $writer->writeLine(); |
533 | - foreach($views as $view) |
|
533 | + foreach ($views as $view) |
|
534 | 534 | { |
535 | 535 | $view->renderHeader($writer); |
536 | 536 | $view->renderControl($writer); |
@@ -89,8 +89,9 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function addParsedObject($object) |
91 | 91 | { |
92 | - if($object instanceof TAccordionView) |
|
93 | - $this->getControls()->add($object); |
|
92 | + if($object instanceof TAccordionView) { |
|
93 | + $this->getControls()->add($object); |
|
94 | + } |
|
94 | 95 | } |
95 | 96 | |
96 | 97 | /** |
@@ -146,19 +147,19 @@ discard block |
||
146 | 147 | $views = $this->getViews(); |
147 | 148 | if(($id = $this->getActiveViewID()) !== '') |
148 | 149 | { |
149 | - if(($index = $views->findIndexByID($id)) >= 0) |
|
150 | - $activeView = $views->itemAt($index); |
|
151 | - else |
|
152 | - throw new TInvalidDataValueException('accordion_activeviewid_invalid', $id); |
|
153 | - } |
|
154 | - elseif(($index = $this->getActiveViewIndex()) >= 0) |
|
150 | + if(($index = $views->findIndexByID($id)) >= 0) { |
|
151 | + $activeView = $views->itemAt($index); |
|
152 | + } else { |
|
153 | + throw new TInvalidDataValueException('accordion_activeviewid_invalid', $id); |
|
154 | + } |
|
155 | + } elseif(($index = $this->getActiveViewIndex()) >= 0) |
|
155 | 156 | { |
156 | - if($index < $views->getCount()) |
|
157 | - $activeView = $views->itemAt($index); |
|
158 | - else |
|
159 | - throw new TInvalidDataValueException('accordion_activeviewindex_invalid', $index); |
|
160 | - } |
|
161 | - else |
|
157 | + if($index < $views->getCount()) { |
|
158 | + $activeView = $views->itemAt($index); |
|
159 | + } else { |
|
160 | + throw new TInvalidDataValueException('accordion_activeviewindex_invalid', $index); |
|
161 | + } |
|
162 | + } else |
|
162 | 163 | { |
163 | 164 | foreach($views as $index => $view) |
164 | 165 | { |
@@ -169,8 +170,9 @@ discard block |
||
169 | 170 | } |
170 | 171 | } |
171 | 172 | } |
172 | - if($activeView !== null) |
|
173 | - $this->activateView($activeView); |
|
173 | + if($activeView !== null) { |
|
174 | + $this->activateView($activeView); |
|
175 | + } |
|
174 | 176 | return $activeView; |
175 | 177 | } |
176 | 178 | |
@@ -180,10 +182,11 @@ discard block |
||
180 | 182 | */ |
181 | 183 | public function setActiveView($view) |
182 | 184 | { |
183 | - if($this->getViews()->indexOf($view) >= 0) |
|
184 | - $this->activateView($view); |
|
185 | - else |
|
186 | - throw new TInvalidOperationException('accordion_view_inexistent'); |
|
185 | + if($this->getViews()->indexOf($view) >= 0) { |
|
186 | + $this->activateView($view); |
|
187 | + } else { |
|
188 | + throw new TInvalidOperationException('accordion_view_inexistent'); |
|
189 | + } |
|
187 | 190 | } |
188 | 191 | |
189 | 192 | /** |
@@ -349,9 +352,9 @@ discard block |
||
349 | 352 | $this->setActiveViewIndex($index); |
350 | 353 | $this->setActiveViewID($view->getID(false)); |
351 | 354 | $view->setActive(true); |
355 | + } else { |
|
356 | + $v->setActive(false); |
|
352 | 357 | } |
353 | - else |
|
354 | - $v->setActive(false); |
|
355 | 358 | } |
356 | 359 | } |
357 | 360 | |
@@ -460,8 +463,9 @@ discard block |
||
460 | 463 | $cs->registerEndScript("prado:$id", $code); |
461 | 464 | // ensure an item is always active and visible |
462 | 465 | $index = $this->getActiveViewIndex(); |
463 | - if(!$this->getViews()->itemAt($index)->Visible) |
|
464 | - $index = 0; |
|
466 | + if(!$this->getViews()->itemAt($index)->Visible) { |
|
467 | + $index = 0; |
|
468 | + } |
|
465 | 469 | $cs->registerHiddenField($id . '_1', $index); |
466 | 470 | $page->registerRequiresPostData($this); |
467 | 471 | $page->registerRequiresPostData($id . "_1"); |
@@ -487,11 +491,13 @@ discard block |
||
487 | 491 | $options['HeaderCssClass'] = $this->getHeaderCssClass(); |
488 | 492 | $options['Duration'] = $this->getAnimationDuration(); |
489 | 493 | |
490 | - if (($viewheight = $this->getViewHeight()) > 0) |
|
491 | - $options['maxHeight'] = $viewheight; |
|
494 | + if (($viewheight = $this->getViewHeight()) > 0) { |
|
495 | + $options['maxHeight'] = $viewheight; |
|
496 | + } |
|
492 | 497 | $views = []; |
493 | - foreach($this->getViews() as $view) |
|
494 | - $views[$view->getClientID()] = $view->getVisible() ? '1': '0'; |
|
498 | + foreach($this->getViews() as $view) { |
|
499 | + $views[$view->getClientID()] = $view->getVisible() ? '1': '0'; |
|
500 | + } |
|
495 | 501 | $options['Views'] = $views; |
496 | 502 | |
497 | 503 | return $options; |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function initializeCell($cell, $columnIndex, $itemType) |
108 | 108 | { |
109 | - if($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::EditItem || $itemType === TListItemType::SelectedItem) |
|
109 | + if ($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::EditItem || $itemType === TListItemType::SelectedItem) |
|
110 | 110 | { |
111 | - if($this->getDataField() !== '') |
|
111 | + if ($this->getDataField() !== '') |
|
112 | 112 | { |
113 | - $cell->attachEventHandler('OnDataBinding', [$this,'dataBindColumn']); |
|
113 | + $cell->attachEventHandler('OnDataBinding', [$this, 'dataBindColumn']); |
|
114 | 114 | } else { |
115 | 115 | $text = $this->getText(); |
116 | - if($this->getEncode()) |
|
116 | + if ($this->getEncode()) |
|
117 | 117 | $text = THttpUtility::htmlEncode($text); |
118 | 118 | $cell->setText($text); |
119 | 119 | } |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | $item = $sender->getNamingContainer(); |
133 | 133 | $data = $item->getData(); |
134 | 134 | $formatString = $this->getDataFormatString(); |
135 | - if(($field = $this->getDataField()) !== '') |
|
135 | + if (($field = $this->getDataField()) !== '') |
|
136 | 136 | $value = $this->formatDataValue($formatString, $this->getDataFieldValue($data, $field)); |
137 | 137 | else |
138 | 138 | $value = $this->formatDataValue($formatString, $data); |
139 | - if($sender instanceof TTableCell) |
|
139 | + if ($sender instanceof TTableCell) |
|
140 | 140 | { |
141 | - if($this->getEncode()) |
|
141 | + if ($this->getEncode()) |
|
142 | 142 | $value = THttpUtility::htmlEncode($value); |
143 | 143 | $sender->setText($value); |
144 | 144 | } |
@@ -113,13 +113,14 @@ discard block |
||
113 | 113 | $cell->attachEventHandler('OnDataBinding', [$this,'dataBindColumn']); |
114 | 114 | } else { |
115 | 115 | $text = $this->getText(); |
116 | - if($this->getEncode()) |
|
117 | - $text = THttpUtility::htmlEncode($text); |
|
116 | + if($this->getEncode()) { |
|
117 | + $text = THttpUtility::htmlEncode($text); |
|
118 | + } |
|
118 | 119 | $cell->setText($text); |
119 | 120 | } |
121 | + } else { |
|
122 | + parent::initializeCell($cell, $columnIndex, $itemType); |
|
120 | 123 | } |
121 | - else |
|
122 | - parent::initializeCell($cell, $columnIndex, $itemType); |
|
123 | 124 | } |
124 | 125 | |
125 | 126 | /** |
@@ -132,14 +133,16 @@ discard block |
||
132 | 133 | $item = $sender->getNamingContainer(); |
133 | 134 | $data = $item->getData(); |
134 | 135 | $formatString = $this->getDataFormatString(); |
135 | - if(($field = $this->getDataField()) !== '') |
|
136 | - $value = $this->formatDataValue($formatString, $this->getDataFieldValue($data, $field)); |
|
137 | - else |
|
138 | - $value = $this->formatDataValue($formatString, $data); |
|
136 | + if(($field = $this->getDataField()) !== '') { |
|
137 | + $value = $this->formatDataValue($formatString, $this->getDataFieldValue($data, $field)); |
|
138 | + } else { |
|
139 | + $value = $this->formatDataValue($formatString, $data); |
|
140 | + } |
|
139 | 141 | if($sender instanceof TTableCell) |
140 | 142 | { |
141 | - if($this->getEncode()) |
|
142 | - $value = THttpUtility::htmlEncode($value); |
|
143 | + if($this->getEncode()) { |
|
144 | + $value = THttpUtility::htmlEncode($value); |
|
145 | + } |
|
143 | 146 | $sender->setText($value); |
144 | 147 | } |
145 | 148 | } |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | public function loadPostData($key, $values) |
113 | 113 | { |
114 | 114 | $uniqueGroupName = $this->getUniqueGroupName(); |
115 | - $value = isset($values[$uniqueGroupName])?$values[$uniqueGroupName]:null; |
|
116 | - if($value !== null && $value === $this->getValueAttribute()) |
|
115 | + $value = isset($values[$uniqueGroupName]) ? $values[$uniqueGroupName] : null; |
|
116 | + if ($value !== null && $value === $this->getValueAttribute()) |
|
117 | 117 | { |
118 | - if(!$this->getChecked()) |
|
118 | + if (!$this->getChecked()) |
|
119 | 119 | { |
120 | 120 | $this->setChecked(true); |
121 | 121 | return true; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | else |
124 | 124 | return false; |
125 | 125 | } |
126 | - elseif($this->getChecked()) |
|
126 | + elseif ($this->getChecked()) |
|
127 | 127 | $this->setChecked(false); |
128 | 128 | return false; |
129 | 129 | } |
@@ -153,22 +153,22 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function getUniqueGroupName() |
155 | 155 | { |
156 | - if(($groupName = $this->getViewState('UniqueGroupName', '')) !== '') |
|
156 | + if (($groupName = $this->getViewState('UniqueGroupName', '')) !== '') |
|
157 | 157 | return $groupName; |
158 | - elseif(($uniqueID = $this->getUniqueID()) !== $this->_previousUniqueID || $this->_uniqueGroupName === null) |
|
158 | + elseif (($uniqueID = $this->getUniqueID()) !== $this->_previousUniqueID || $this->_uniqueGroupName === null) |
|
159 | 159 | { |
160 | 160 | $groupName = $this->getGroupName(); |
161 | 161 | $this->_previousUniqueID = $uniqueID; |
162 | - if($uniqueID !== '') |
|
162 | + if ($uniqueID !== '') |
|
163 | 163 | { |
164 | - if(($pos = strrpos($uniqueID, \Prado\Web\UI\TControl::ID_SEPARATOR)) !== false) |
|
164 | + if (($pos = strrpos($uniqueID, \Prado\Web\UI\TControl::ID_SEPARATOR)) !== false) |
|
165 | 165 | { |
166 | - if($groupName !== '') |
|
167 | - $groupName = substr($uniqueID, 0, $pos + 1) . $groupName; |
|
168 | - elseif($this->getNamingContainer() instanceof TRadioButtonList) |
|
166 | + if ($groupName !== '') |
|
167 | + $groupName = substr($uniqueID, 0, $pos + 1).$groupName; |
|
168 | + elseif ($this->getNamingContainer() instanceof TRadioButtonList) |
|
169 | 169 | $groupName = substr($uniqueID, 0, $pos); |
170 | 170 | } |
171 | - if($groupName === '') |
|
171 | + if ($groupName === '') |
|
172 | 172 | $groupName = $uniqueID; |
173 | 173 | } |
174 | 174 | $this->_uniqueGroupName = $groupName; |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | { |
208 | 208 | $group = $this->getUniqueGroupName(); |
209 | 209 | $buttons = []; |
210 | - foreach(self::$_activeButtons as $control) |
|
210 | + foreach (self::$_activeButtons as $control) |
|
211 | 211 | { |
212 | - if($control->getUniqueGroupName() === $group) |
|
212 | + if ($control->getUniqueGroupName() === $group) |
|
213 | 213 | $buttons[] = $control; |
214 | 214 | } |
215 | 215 | return $buttons; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | protected function getValueAttribute() |
222 | 222 | { |
223 | - if(($value = parent::getValueAttribute()) === '') |
|
223 | + if (($value = parent::getValueAttribute()) === '') |
|
224 | 224 | return $this->getUniqueID(); |
225 | 225 | else |
226 | 226 | return $value; |
@@ -250,20 +250,20 @@ discard block |
||
250 | 250 | */ |
251 | 251 | protected function renderInputTag($writer, $clientID, $onclick) |
252 | 252 | { |
253 | - if($clientID !== '') |
|
253 | + if ($clientID !== '') |
|
254 | 254 | $writer->addAttribute('id', $clientID); |
255 | 255 | $writer->addAttribute('type', 'radio'); |
256 | 256 | $writer->addAttribute('name', $this->getUniqueGroupName()); |
257 | 257 | $writer->addAttribute('value', $this->getValueAttribute()); |
258 | - if(!empty($onclick)) |
|
258 | + if (!empty($onclick)) |
|
259 | 259 | $writer->addAttribute('onclick', $onclick); |
260 | - if($this->getChecked()) |
|
260 | + if ($this->getChecked()) |
|
261 | 261 | $writer->addAttribute('checked', 'checked'); |
262 | - if(!$this->getEnabled(true)) |
|
262 | + if (!$this->getEnabled(true)) |
|
263 | 263 | $writer->addAttribute('disabled', 'disabled'); |
264 | 264 | |
265 | 265 | $page = $this->getPage(); |
266 | - if($this->getEnabled(true) |
|
266 | + if ($this->getEnabled(true) |
|
267 | 267 | && $this->getEnableClientScript() |
268 | 268 | && $this->getAutoPostBack() |
269 | 269 | && $page->getClientSupportsJavaScript()) |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | $this->renderClientControlScript($writer); |
272 | 272 | } |
273 | 273 | |
274 | - if(($accesskey = $this->getAccessKey()) !== '') |
|
274 | + if (($accesskey = $this->getAccessKey()) !== '') |
|
275 | 275 | $writer->addAttribute('accesskey', $accesskey); |
276 | - if(($tabindex = $this->getTabIndex()) > 0) |
|
276 | + if (($tabindex = $this->getTabIndex()) > 0) |
|
277 | 277 | $writer->addAttribute('tabindex', "$tabindex"); |
278 | - if($attributes = $this->getViewState('InputAttributes', null)) |
|
278 | + if ($attributes = $this->getViewState('InputAttributes', null)) |
|
279 | 279 | $writer->addAttributes($attributes); |
280 | 280 | $writer->renderBeginTag('input'); |
281 | 281 | $writer->renderEndTag(); |
@@ -119,12 +119,12 @@ discard block |
||
119 | 119 | { |
120 | 120 | $this->setChecked(true); |
121 | 121 | return true; |
122 | + } else { |
|
123 | + return false; |
|
122 | 124 | } |
123 | - else |
|
124 | - return false; |
|
125 | + } elseif($this->getChecked()) { |
|
126 | + $this->setChecked(false); |
|
125 | 127 | } |
126 | - elseif($this->getChecked()) |
|
127 | - $this->setChecked(false); |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function getUniqueGroupName() |
155 | 155 | { |
156 | - if(($groupName = $this->getViewState('UniqueGroupName', '')) !== '') |
|
157 | - return $groupName; |
|
158 | - elseif(($uniqueID = $this->getUniqueID()) !== $this->_previousUniqueID || $this->_uniqueGroupName === null) |
|
156 | + if(($groupName = $this->getViewState('UniqueGroupName', '')) !== '') { |
|
157 | + return $groupName; |
|
158 | + } elseif(($uniqueID = $this->getUniqueID()) !== $this->_previousUniqueID || $this->_uniqueGroupName === null) |
|
159 | 159 | { |
160 | 160 | $groupName = $this->getGroupName(); |
161 | 161 | $this->_previousUniqueID = $uniqueID; |
@@ -163,13 +163,15 @@ discard block |
||
163 | 163 | { |
164 | 164 | if(($pos = strrpos($uniqueID, \Prado\Web\UI\TControl::ID_SEPARATOR)) !== false) |
165 | 165 | { |
166 | - if($groupName !== '') |
|
167 | - $groupName = substr($uniqueID, 0, $pos + 1) . $groupName; |
|
168 | - elseif($this->getNamingContainer() instanceof TRadioButtonList) |
|
169 | - $groupName = substr($uniqueID, 0, $pos); |
|
166 | + if($groupName !== '') { |
|
167 | + $groupName = substr($uniqueID, 0, $pos + 1) . $groupName; |
|
168 | + } elseif($this->getNamingContainer() instanceof TRadioButtonList) { |
|
169 | + $groupName = substr($uniqueID, 0, $pos); |
|
170 | + } |
|
171 | + } |
|
172 | + if($groupName === '') { |
|
173 | + $groupName = $uniqueID; |
|
170 | 174 | } |
171 | - if($groupName === '') |
|
172 | - $groupName = $uniqueID; |
|
173 | 175 | } |
174 | 176 | $this->_uniqueGroupName = $groupName; |
175 | 177 | } |
@@ -209,8 +211,9 @@ discard block |
||
209 | 211 | $buttons = []; |
210 | 212 | foreach(self::$_activeButtons as $control) |
211 | 213 | { |
212 | - if($control->getUniqueGroupName() === $group) |
|
213 | - $buttons[] = $control; |
|
214 | + if($control->getUniqueGroupName() === $group) { |
|
215 | + $buttons[] = $control; |
|
216 | + } |
|
214 | 217 | } |
215 | 218 | return $buttons; |
216 | 219 | } |
@@ -220,10 +223,11 @@ discard block |
||
220 | 223 | */ |
221 | 224 | protected function getValueAttribute() |
222 | 225 | { |
223 | - if(($value = parent::getValueAttribute()) === '') |
|
224 | - return $this->getUniqueID(); |
|
225 | - else |
|
226 | - return $value; |
|
226 | + if(($value = parent::getValueAttribute()) === '') { |
|
227 | + return $this->getUniqueID(); |
|
228 | + } else { |
|
229 | + return $value; |
|
230 | + } |
|
227 | 231 | } |
228 | 232 | |
229 | 233 | /** |
@@ -250,17 +254,21 @@ discard block |
||
250 | 254 | */ |
251 | 255 | protected function renderInputTag($writer, $clientID, $onclick) |
252 | 256 | { |
253 | - if($clientID !== '') |
|
254 | - $writer->addAttribute('id', $clientID); |
|
257 | + if($clientID !== '') { |
|
258 | + $writer->addAttribute('id', $clientID); |
|
259 | + } |
|
255 | 260 | $writer->addAttribute('type', 'radio'); |
256 | 261 | $writer->addAttribute('name', $this->getUniqueGroupName()); |
257 | 262 | $writer->addAttribute('value', $this->getValueAttribute()); |
258 | - if(!empty($onclick)) |
|
259 | - $writer->addAttribute('onclick', $onclick); |
|
260 | - if($this->getChecked()) |
|
261 | - $writer->addAttribute('checked', 'checked'); |
|
262 | - if(!$this->getEnabled(true)) |
|
263 | - $writer->addAttribute('disabled', 'disabled'); |
|
263 | + if(!empty($onclick)) { |
|
264 | + $writer->addAttribute('onclick', $onclick); |
|
265 | + } |
|
266 | + if($this->getChecked()) { |
|
267 | + $writer->addAttribute('checked', 'checked'); |
|
268 | + } |
|
269 | + if(!$this->getEnabled(true)) { |
|
270 | + $writer->addAttribute('disabled', 'disabled'); |
|
271 | + } |
|
264 | 272 | |
265 | 273 | $page = $this->getPage(); |
266 | 274 | if($this->getEnabled(true) |
@@ -271,12 +279,15 @@ discard block |
||
271 | 279 | $this->renderClientControlScript($writer); |
272 | 280 | } |
273 | 281 | |
274 | - if(($accesskey = $this->getAccessKey()) !== '') |
|
275 | - $writer->addAttribute('accesskey', $accesskey); |
|
276 | - if(($tabindex = $this->getTabIndex()) > 0) |
|
277 | - $writer->addAttribute('tabindex', "$tabindex"); |
|
278 | - if($attributes = $this->getViewState('InputAttributes', null)) |
|
279 | - $writer->addAttributes($attributes); |
|
282 | + if(($accesskey = $this->getAccessKey()) !== '') { |
|
283 | + $writer->addAttribute('accesskey', $accesskey); |
|
284 | + } |
|
285 | + if(($tabindex = $this->getTabIndex()) > 0) { |
|
286 | + $writer->addAttribute('tabindex', "$tabindex"); |
|
287 | + } |
|
288 | + if($attributes = $this->getViewState('InputAttributes', null)) { |
|
289 | + $writer->addAttributes($attributes); |
|
290 | + } |
|
280 | 291 | $writer->renderBeginTag('input'); |
281 | 292 | $writer->renderEndTag(); |
282 | 293 | } |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | protected function addAttributesToRender($writer) |
51 | 51 | { |
52 | 52 | $isEnabled = $this->getEnabled(true); |
53 | - if($this->getEnabled() && !$isEnabled) |
|
53 | + if ($this->getEnabled() && !$isEnabled) |
|
54 | 54 | $writer->addAttribute('disabled', 'disabled'); |
55 | 55 | parent::addAttributesToRender($writer); |
56 | - if(($url = $this->getNavigateUrl()) !== '' && $isEnabled) |
|
56 | + if (($url = $this->getNavigateUrl()) !== '' && $isEnabled) |
|
57 | 57 | $writer->addAttribute('href', $url); |
58 | - if(($target = $this->getTarget()) !== '') |
|
58 | + if (($target = $this->getTarget()) !== '') |
|
59 | 59 | $writer->addAttribute('target', $target); |
60 | 60 | } |
61 | 61 | |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function renderContents($writer) |
67 | 67 | { |
68 | - if(($imageUrl = $this->getImageUrl()) === '') |
|
68 | + if (($imageUrl = $this->getImageUrl()) === '') |
|
69 | 69 | { |
70 | - if(($text = $this->getText()) !== '') |
|
70 | + if (($text = $this->getText()) !== '') |
|
71 | 71 | $writer->write(THttpUtility::htmlEncode($text)); |
72 | - elseif($this->getHasControls()) |
|
72 | + elseif ($this->getHasControls()) |
|
73 | 73 | parent::renderContents($writer); |
74 | 74 | else |
75 | 75 | $writer->write(THttpUtility::htmlEncode($this->getNavigateUrl())); |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | { |
91 | 91 | $image = new TImage; |
92 | 92 | $image->setImageUrl($imageUrl); |
93 | - if(($width = $this->getImageWidth()) !== '') |
|
93 | + if (($width = $this->getImageWidth()) !== '') |
|
94 | 94 | $image->setWidth($width); |
95 | - if(($height = $this->getImageHeight()) !== '') |
|
95 | + if (($height = $this->getImageHeight()) !== '') |
|
96 | 96 | $image->setHeight($height); |
97 | - if(($toolTip = $this->getToolTip()) !== '') |
|
97 | + if (($toolTip = $this->getToolTip()) !== '') |
|
98 | 98 | $image->setToolTip($toolTip); |
99 | - if(($text = $this->getText()) !== '') |
|
99 | + if (($text = $this->getText()) !== '') |
|
100 | 100 | $image->setAlternateText($text); |
101 | - if(($align = $this->getImageAlign()) !== '') |
|
101 | + if (($align = $this->getImageAlign()) !== '') |
|
102 | 102 | $image->setImageAlign($align); |
103 | 103 | $image->setBorderWidth('0'); |
104 | 104 | return $image; |
@@ -50,13 +50,16 @@ discard block |
||
50 | 50 | protected function addAttributesToRender($writer) |
51 | 51 | { |
52 | 52 | $isEnabled = $this->getEnabled(true); |
53 | - if($this->getEnabled() && !$isEnabled) |
|
54 | - $writer->addAttribute('disabled', 'disabled'); |
|
53 | + if($this->getEnabled() && !$isEnabled) { |
|
54 | + $writer->addAttribute('disabled', 'disabled'); |
|
55 | + } |
|
55 | 56 | parent::addAttributesToRender($writer); |
56 | - if(($url = $this->getNavigateUrl()) !== '' && $isEnabled) |
|
57 | - $writer->addAttribute('href', $url); |
|
58 | - if(($target = $this->getTarget()) !== '') |
|
59 | - $writer->addAttribute('target', $target); |
|
57 | + if(($url = $this->getNavigateUrl()) !== '' && $isEnabled) { |
|
58 | + $writer->addAttribute('href', $url); |
|
59 | + } |
|
60 | + if(($target = $this->getTarget()) !== '') { |
|
61 | + $writer->addAttribute('target', $target); |
|
62 | + } |
|
60 | 63 | } |
61 | 64 | |
62 | 65 | /** |
@@ -67,14 +70,14 @@ discard block |
||
67 | 70 | { |
68 | 71 | if(($imageUrl = $this->getImageUrl()) === '') |
69 | 72 | { |
70 | - if(($text = $this->getText()) !== '') |
|
71 | - $writer->write(THttpUtility::htmlEncode($text)); |
|
72 | - elseif($this->getHasControls()) |
|
73 | - parent::renderContents($writer); |
|
74 | - else |
|
75 | - $writer->write(THttpUtility::htmlEncode($this->getNavigateUrl())); |
|
76 | - } |
|
77 | - else |
|
73 | + if(($text = $this->getText()) !== '') { |
|
74 | + $writer->write(THttpUtility::htmlEncode($text)); |
|
75 | + } elseif($this->getHasControls()) { |
|
76 | + parent::renderContents($writer); |
|
77 | + } else { |
|
78 | + $writer->write(THttpUtility::htmlEncode($this->getNavigateUrl())); |
|
79 | + } |
|
80 | + } else |
|
78 | 81 | { |
79 | 82 | $this->createImage($imageUrl)->renderControl($writer); |
80 | 83 | } |
@@ -90,16 +93,21 @@ discard block |
||
90 | 93 | { |
91 | 94 | $image = new TImage; |
92 | 95 | $image->setImageUrl($imageUrl); |
93 | - if(($width = $this->getImageWidth()) !== '') |
|
94 | - $image->setWidth($width); |
|
95 | - if(($height = $this->getImageHeight()) !== '') |
|
96 | - $image->setHeight($height); |
|
97 | - if(($toolTip = $this->getToolTip()) !== '') |
|
98 | - $image->setToolTip($toolTip); |
|
99 | - if(($text = $this->getText()) !== '') |
|
100 | - $image->setAlternateText($text); |
|
101 | - if(($align = $this->getImageAlign()) !== '') |
|
102 | - $image->setImageAlign($align); |
|
96 | + if(($width = $this->getImageWidth()) !== '') { |
|
97 | + $image->setWidth($width); |
|
98 | + } |
|
99 | + if(($height = $this->getImageHeight()) !== '') { |
|
100 | + $image->setHeight($height); |
|
101 | + } |
|
102 | + if(($toolTip = $this->getToolTip()) !== '') { |
|
103 | + $image->setToolTip($toolTip); |
|
104 | + } |
|
105 | + if(($text = $this->getText()) !== '') { |
|
106 | + $image->setAlternateText($text); |
|
107 | + } |
|
108 | + if(($align = $this->getImageAlign()) !== '') { |
|
109 | + $image->setImageAlign($align); |
|
110 | + } |
|
103 | 111 | $image->setBorderWidth('0'); |
104 | 112 | return $image; |
105 | 113 | } |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | protected function registerStyleSheet() |
166 | 166 | { |
167 | 167 | $cs = $this->getPage()->getClientScript(); |
168 | - $cssFile = Prado::getPathOfNamespace('Vendor.bower-asset.highlightjs.styles.' . $this->getSyntaxStyle(), '.css'); |
|
169 | - $cssKey = 'prado:TTextHighlighter:' . $cssFile; |
|
170 | - if(!$cs->isStyleSheetFileRegistered($cssKey)) |
|
168 | + $cssFile = Prado::getPathOfNamespace('Vendor.bower-asset.highlightjs.styles.'.$this->getSyntaxStyle(), '.css'); |
|
169 | + $cssKey = 'prado:TTextHighlighter:'.$cssFile; |
|
170 | + if (!$cs->isStyleSheetFileRegistered($cssKey)) |
|
171 | 171 | $cs->registerStyleSheetFile($cssKey, $this->publishFilePath($cssFile)); |
172 | 172 | } |
173 | 173 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $writer->addAttribute('id', $this->getClientID()); |
197 | 197 | parent::renderBeginTag($writer); |
198 | 198 | |
199 | - $writer->addAttribute('id', $this->getClientID() . '_code'); |
|
199 | + $writer->addAttribute('id', $this->getClientID().'_code'); |
|
200 | 200 | $writer->addAttribute('class', $this->getLanguage()); |
201 | 201 | $writer->renderBeginTag('code'); |
202 | 202 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function renderContents($writer) |
211 | 211 | { |
212 | - if($this->getEncodeHtml()) |
|
212 | + if ($this->getEncodeHtml()) |
|
213 | 213 | { |
214 | 214 | $escapedWriter = new TTextHighlighterWriter($writer); |
215 | 215 | parent::renderChildren($escapedWriter); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | $options = TJavaScript::encode($this->getTextHighlightOptions()); |
237 | 237 | $code = "new Prado.WebUI.TTextHighlighter($options);"; |
238 | - $cs->registerEndScript("prado:" . $this->getClientID(), $code); |
|
238 | + $cs->registerEndScript("prado:".$this->getClientID(), $code); |
|
239 | 239 | |
240 | 240 | } |
241 | 241 | } |
@@ -167,8 +167,9 @@ |
||
167 | 167 | $cs = $this->getPage()->getClientScript(); |
168 | 168 | $cssFile = Prado::getPathOfNamespace('Vendor.bower-asset.highlightjs.styles.' . $this->getSyntaxStyle(), '.css'); |
169 | 169 | $cssKey = 'prado:TTextHighlighter:' . $cssFile; |
170 | - if(!$cs->isStyleSheetFileRegistered($cssKey)) |
|
171 | - $cs->registerStyleSheetFile($cssKey, $this->publishFilePath($cssFile)); |
|
170 | + if(!$cs->isStyleSheetFileRegistered($cssKey)) { |
|
171 | + $cs->registerStyleSheetFile($cssKey, $this->publishFilePath($cssFile)); |
|
172 | + } |
|
172 | 173 | } |
173 | 174 | |
174 | 175 | /** |
@@ -224,10 +224,10 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function addParsedObject($object) |
226 | 226 | { |
227 | - if($object instanceof TDataGridColumn) |
|
227 | + if ($object instanceof TDataGridColumn) |
|
228 | 228 | $this->getColumns()->add($object); |
229 | 229 | else |
230 | - parent::addParsedObject($object); // this is needed by EmptyTemplate |
|
230 | + parent::addParsedObject($object); // this is needed by EmptyTemplate |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function getColumns() |
237 | 237 | { |
238 | - if(!$this->_columns) |
|
238 | + if (!$this->_columns) |
|
239 | 239 | $this->_columns = new TDataGridColumnCollection($this); |
240 | 240 | return $this->_columns; |
241 | 241 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public function getAutoColumns() |
247 | 247 | { |
248 | - if(!$this->_autoColumns) |
|
248 | + if (!$this->_autoColumns) |
|
249 | 249 | $this->_autoColumns = new TDataGridColumnCollection($this); |
250 | 250 | return $this->_autoColumns; |
251 | 251 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public function getItems() |
257 | 257 | { |
258 | - if(!$this->_items) |
|
258 | + if (!$this->_items) |
|
259 | 259 | $this->_items = new TDataGridItemCollection; |
260 | 260 | return $this->_items; |
261 | 261 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function getItemCount() |
267 | 267 | { |
268 | - return $this->_items?$this->_items->getCount():0; |
|
268 | + return $this->_items ? $this->_items->getCount() : 0; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | */ |
300 | 300 | public function getItemStyle() |
301 | 301 | { |
302 | - if(($style = $this->getViewState('ItemStyle', null)) === null) |
|
302 | + if (($style = $this->getViewState('ItemStyle', null)) === null) |
|
303 | 303 | { |
304 | 304 | $style = new TTableItemStyle; |
305 | 305 | $this->setViewState('ItemStyle', $style, null); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | */ |
313 | 313 | public function getAlternatingItemStyle() |
314 | 314 | { |
315 | - if(($style = $this->getViewState('AlternatingItemStyle', null)) === null) |
|
315 | + if (($style = $this->getViewState('AlternatingItemStyle', null)) === null) |
|
316 | 316 | { |
317 | 317 | $style = new TTableItemStyle; |
318 | 318 | $this->setViewState('AlternatingItemStyle', $style, null); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | */ |
326 | 326 | public function getSelectedItemStyle() |
327 | 327 | { |
328 | - if(($style = $this->getViewState('SelectedItemStyle', null)) === null) |
|
328 | + if (($style = $this->getViewState('SelectedItemStyle', null)) === null) |
|
329 | 329 | { |
330 | 330 | $style = new TTableItemStyle; |
331 | 331 | $this->setViewState('SelectedItemStyle', $style, null); |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | */ |
339 | 339 | public function getEditItemStyle() |
340 | 340 | { |
341 | - if(($style = $this->getViewState('EditItemStyle', null)) === null) |
|
341 | + if (($style = $this->getViewState('EditItemStyle', null)) === null) |
|
342 | 342 | { |
343 | 343 | $style = new TTableItemStyle; |
344 | 344 | $this->setViewState('EditItemStyle', $style, null); |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | */ |
352 | 352 | public function getHeaderStyle() |
353 | 353 | { |
354 | - if(($style = $this->getViewState('HeaderStyle', null)) === null) |
|
354 | + if (($style = $this->getViewState('HeaderStyle', null)) === null) |
|
355 | 355 | { |
356 | 356 | $style = new TTableItemStyle; |
357 | 357 | $this->setViewState('HeaderStyle', $style, null); |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | public function getFooterStyle() |
366 | 366 | { |
367 | - if(($style = $this->getViewState('FooterStyle', null)) === null) |
|
367 | + if (($style = $this->getViewState('FooterStyle', null)) === null) |
|
368 | 368 | { |
369 | 369 | $style = new TTableItemStyle; |
370 | 370 | $this->setViewState('FooterStyle', $style, null); |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | */ |
378 | 378 | public function getPagerStyle() |
379 | 379 | { |
380 | - if(($style = $this->getViewState('PagerStyle', null)) === null) |
|
380 | + if (($style = $this->getViewState('PagerStyle', null)) === null) |
|
381 | 381 | { |
382 | 382 | $style = new TDataGridPagerStyle; |
383 | 383 | $this->setViewState('PagerStyle', $style, null); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | */ |
392 | 392 | public function getTableHeadStyle() |
393 | 393 | { |
394 | - if(($style = $this->getViewState('TableHeadStyle', null)) === null) |
|
394 | + if (($style = $this->getViewState('TableHeadStyle', null)) === null) |
|
395 | 395 | { |
396 | 396 | $style = new TStyle; |
397 | 397 | $this->setViewState('TableHeadStyle', $style, null); |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | */ |
406 | 406 | public function getTableBodyStyle() |
407 | 407 | { |
408 | - if(($style = $this->getViewState('TableBodyStyle', null)) === null) |
|
408 | + if (($style = $this->getViewState('TableBodyStyle', null)) === null) |
|
409 | 409 | { |
410 | 410 | $style = new TStyle; |
411 | 411 | $this->setViewState('TableBodyStyle', $style, null); |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | */ |
420 | 420 | public function getTableFootStyle() |
421 | 421 | { |
422 | - if(($style = $this->getViewState('TableFootStyle', null)) === null) |
|
422 | + if (($style = $this->getViewState('TableFootStyle', null)) === null) |
|
423 | 423 | { |
424 | 424 | $style = new TStyle; |
425 | 425 | $this->setViewState('TableFootStyle', $style, null); |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | { |
499 | 499 | $index = $this->getSelectedItemIndex(); |
500 | 500 | $items = $this->getItems(); |
501 | - if($index >= 0 && $index < $items->getCount()) |
|
501 | + if ($index >= 0 && $index < $items->getCount()) |
|
502 | 502 | return $items->itemAt($index); |
503 | 503 | else |
504 | 504 | return null; |
@@ -522,23 +522,23 @@ discard block |
||
522 | 522 | */ |
523 | 523 | public function setSelectedItemIndex($value) |
524 | 524 | { |
525 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
525 | + if (($value = TPropertyValue::ensureInteger($value)) < 0) |
|
526 | 526 | $value = -1; |
527 | - if(($current = $this->getSelectedItemIndex()) !== $value) |
|
527 | + if (($current = $this->getSelectedItemIndex()) !== $value) |
|
528 | 528 | { |
529 | 529 | $this->setViewState('SelectedItemIndex', $value, -1); |
530 | 530 | $items = $this->getItems(); |
531 | 531 | $itemCount = $items->getCount(); |
532 | - if($current >= 0 && $current < $itemCount) |
|
532 | + if ($current >= 0 && $current < $itemCount) |
|
533 | 533 | { |
534 | 534 | $item = $items->itemAt($current); |
535 | - if($item->getItemType() !== TListItemType::EditItem) |
|
536 | - $item->setItemType($current % 2?TListItemType::AlternatingItem:TListItemType::Item); |
|
535 | + if ($item->getItemType() !== TListItemType::EditItem) |
|
536 | + $item->setItemType($current % 2 ?TListItemType::AlternatingItem : TListItemType::Item); |
|
537 | 537 | } |
538 | - if($value >= 0 && $value < $itemCount) |
|
538 | + if ($value >= 0 && $value < $itemCount) |
|
539 | 539 | { |
540 | 540 | $item = $items->itemAt($value); |
541 | - if($item->getItemType() !== TListItemType::EditItem) |
|
541 | + if ($item->getItemType() !== TListItemType::EditItem) |
|
542 | 542 | $item->setItemType(TListItemType::SelectedItem); |
543 | 543 | } |
544 | 544 | } |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | { |
552 | 552 | $index = $this->getEditItemIndex(); |
553 | 553 | $items = $this->getItems(); |
554 | - if($index >= 0 && $index < $items->getCount()) |
|
554 | + if ($index >= 0 && $index < $items->getCount()) |
|
555 | 555 | return $items->itemAt($index); |
556 | 556 | else |
557 | 557 | return null; |
@@ -574,16 +574,16 @@ discard block |
||
574 | 574 | */ |
575 | 575 | public function setEditItemIndex($value) |
576 | 576 | { |
577 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
577 | + if (($value = TPropertyValue::ensureInteger($value)) < 0) |
|
578 | 578 | $value = -1; |
579 | - if(($current = $this->getEditItemIndex()) !== $value) |
|
579 | + if (($current = $this->getEditItemIndex()) !== $value) |
|
580 | 580 | { |
581 | 581 | $this->setViewState('EditItemIndex', $value, -1); |
582 | 582 | $items = $this->getItems(); |
583 | 583 | $itemCount = $items->getCount(); |
584 | - if($current >= 0 && $current < $itemCount) |
|
585 | - $items->itemAt($current)->setItemType($current % 2?TListItemType::AlternatingItem:TListItemType::Item); |
|
586 | - if($value >= 0 && $value < $itemCount) |
|
584 | + if ($current >= 0 && $current < $itemCount) |
|
585 | + $items->itemAt($current)->setItemType($current % 2 ?TListItemType::AlternatingItem : TListItemType::Item); |
|
586 | + if ($value >= 0 && $value < $itemCount) |
|
587 | 587 | $items->itemAt($value)->setItemType(TListItemType::EditItem); |
588 | 588 | } |
589 | 589 | } |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | */ |
667 | 667 | public function setEmptyTemplate($value) |
668 | 668 | { |
669 | - if($value instanceof ITemplate || $value === null) |
|
669 | + if ($value instanceof ITemplate || $value === null) |
|
670 | 670 | $this->_emptyTemplate = $value; |
671 | 671 | else |
672 | 672 | throw new TInvalidDataTypeException('datagrid_template_required', 'EmptyTemplate'); |
@@ -687,51 +687,51 @@ discard block |
||
687 | 687 | */ |
688 | 688 | public function bubbleEvent($sender, $param) |
689 | 689 | { |
690 | - if($param instanceof TDataGridCommandEventParameter) |
|
690 | + if ($param instanceof TDataGridCommandEventParameter) |
|
691 | 691 | { |
692 | 692 | $this->onItemCommand($param); |
693 | 693 | $command = $param->getCommandName(); |
694 | - if(strcasecmp($command, self::CMD_SELECT) === 0) |
|
694 | + if (strcasecmp($command, self::CMD_SELECT) === 0) |
|
695 | 695 | { |
696 | 696 | $this->setSelectedItemIndex($param->getItem()->getItemIndex()); |
697 | 697 | $this->onSelectedIndexChanged($param); |
698 | 698 | return true; |
699 | 699 | } |
700 | - elseif(strcasecmp($command, self::CMD_EDIT) === 0) |
|
700 | + elseif (strcasecmp($command, self::CMD_EDIT) === 0) |
|
701 | 701 | { |
702 | 702 | $this->onEditCommand($param); |
703 | 703 | return true; |
704 | 704 | } |
705 | - elseif(strcasecmp($command, self::CMD_DELETE) === 0) |
|
705 | + elseif (strcasecmp($command, self::CMD_DELETE) === 0) |
|
706 | 706 | { |
707 | 707 | $this->onDeleteCommand($param); |
708 | 708 | return true; |
709 | 709 | } |
710 | - elseif(strcasecmp($command, self::CMD_UPDATE) === 0) |
|
710 | + elseif (strcasecmp($command, self::CMD_UPDATE) === 0) |
|
711 | 711 | { |
712 | 712 | $this->onUpdateCommand($param); |
713 | 713 | return true; |
714 | 714 | } |
715 | - elseif(strcasecmp($command, self::CMD_CANCEL) === 0) |
|
715 | + elseif (strcasecmp($command, self::CMD_CANCEL) === 0) |
|
716 | 716 | { |
717 | 717 | $this->onCancelCommand($param); |
718 | 718 | return true; |
719 | 719 | } |
720 | - elseif(strcasecmp($command, self::CMD_SORT) === 0) |
|
720 | + elseif (strcasecmp($command, self::CMD_SORT) === 0) |
|
721 | 721 | { |
722 | 722 | $this->onSortCommand(new TDataGridSortCommandEventParameter($sender, $param)); |
723 | 723 | return true; |
724 | 724 | } |
725 | - elseif(strcasecmp($command, self::CMD_PAGE) === 0) |
|
725 | + elseif (strcasecmp($command, self::CMD_PAGE) === 0) |
|
726 | 726 | { |
727 | 727 | $p = $param->getCommandParameter(); |
728 | - if(strcasecmp($p, self::CMD_PAGE_NEXT) === 0) |
|
728 | + if (strcasecmp($p, self::CMD_PAGE_NEXT) === 0) |
|
729 | 729 | $pageIndex = $this->getCurrentPageIndex() + 1; |
730 | - elseif(strcasecmp($p, self::CMD_PAGE_PREV) === 0) |
|
730 | + elseif (strcasecmp($p, self::CMD_PAGE_PREV) === 0) |
|
731 | 731 | $pageIndex = $this->getCurrentPageIndex() - 1; |
732 | - elseif(strcasecmp($p, self::CMD_PAGE_FIRST) === 0) |
|
732 | + elseif (strcasecmp($p, self::CMD_PAGE_FIRST) === 0) |
|
733 | 733 | $pageIndex = 0; |
734 | - elseif(strcasecmp($p, self::CMD_PAGE_LAST) === 0) |
|
734 | + elseif (strcasecmp($p, self::CMD_PAGE_LAST) === 0) |
|
735 | 735 | $pageIndex = $this->getPageCount() - 1; |
736 | 736 | else |
737 | 737 | $pageIndex = TPropertyValue::ensureInteger($p) - 1; |
@@ -857,25 +857,25 @@ discard block |
||
857 | 857 | public function saveState() |
858 | 858 | { |
859 | 859 | parent::saveState(); |
860 | - if(!$this->getEnableViewState(true)) |
|
860 | + if (!$this->getEnableViewState(true)) |
|
861 | 861 | return; |
862 | - if($this->_items) |
|
862 | + if ($this->_items) |
|
863 | 863 | $this->setViewState('ItemCount', $this->_items->getCount(), 0); |
864 | 864 | else |
865 | 865 | $this->clearViewState('ItemCount'); |
866 | - if($this->_autoColumns) |
|
866 | + if ($this->_autoColumns) |
|
867 | 867 | { |
868 | 868 | $state = []; |
869 | - foreach($this->_autoColumns as $column) |
|
869 | + foreach ($this->_autoColumns as $column) |
|
870 | 870 | $state[] = $column->saveState(); |
871 | 871 | $this->setViewState('AutoColumns', $state, []); |
872 | 872 | } |
873 | 873 | else |
874 | 874 | $this->clearViewState('AutoColumns'); |
875 | - if($this->_columns) |
|
875 | + if ($this->_columns) |
|
876 | 876 | { |
877 | 877 | $state = []; |
878 | - foreach($this->_columns as $column) |
|
878 | + foreach ($this->_columns as $column) |
|
879 | 879 | $state[] = $column->saveState(); |
880 | 880 | $this->setViewState('Columns', $state, []); |
881 | 881 | } |
@@ -890,15 +890,15 @@ discard block |
||
890 | 890 | public function loadState() |
891 | 891 | { |
892 | 892 | parent::loadState(); |
893 | - if(!$this->getEnableViewState(true)) |
|
893 | + if (!$this->getEnableViewState(true)) |
|
894 | 894 | return; |
895 | - if(!$this->getIsDataBound()) |
|
895 | + if (!$this->getIsDataBound()) |
|
896 | 896 | { |
897 | 897 | $state = $this->getViewState('AutoColumns', []); |
898 | - if(!empty($state)) |
|
898 | + if (!empty($state)) |
|
899 | 899 | { |
900 | 900 | $this->_autoColumns = new TDataGridColumnCollection($this); |
901 | - foreach($state as $st) |
|
901 | + foreach ($state as $st) |
|
902 | 902 | { |
903 | 903 | $column = new $this->AutoGenerateColumnName; |
904 | 904 | $column->loadState($st); |
@@ -908,10 +908,10 @@ discard block |
||
908 | 908 | else |
909 | 909 | $this->_autoColumns = null; |
910 | 910 | $state = $this->getViewState('Columns', []); |
911 | - if($this->_columns && $this->_columns->getCount() === count($state)) |
|
911 | + if ($this->_columns && $this->_columns->getCount() === count($state)) |
|
912 | 912 | { |
913 | 913 | $i = 0; |
914 | - foreach($this->_columns as $column) |
|
914 | + foreach ($this->_columns as $column) |
|
915 | 915 | { |
916 | 916 | $column->loadState($state[$i]); |
917 | 917 | $i++; |
@@ -953,39 +953,39 @@ discard block |
||
953 | 953 | |
954 | 954 | $items = $this->getItems(); |
955 | 955 | |
956 | - if($columns->getCount()) |
|
956 | + if ($columns->getCount()) |
|
957 | 957 | { |
958 | - foreach($columns as $column) |
|
958 | + foreach ($columns as $column) |
|
959 | 959 | $column->initialize(); |
960 | 960 | $selectedIndex = $this->getSelectedItemIndex(); |
961 | 961 | $editIndex = $this->getEditItemIndex(); |
962 | - for($index = 0;$index < $itemCount;++$index) |
|
962 | + for ($index = 0; $index < $itemCount; ++$index) |
|
963 | 963 | { |
964 | - if($index === 0) |
|
964 | + if ($index === 0) |
|
965 | 965 | { |
966 | - if($allowPaging) |
|
966 | + if ($allowPaging) |
|
967 | 967 | $this->_topPager = $this->createPager(); |
968 | 968 | $this->_header = $this->createItemInternal(-1, -1, TListItemType::Header, false, null, $columns); |
969 | 969 | } |
970 | - if($index === $editIndex) |
|
970 | + if ($index === $editIndex) |
|
971 | 971 | $itemType = TListItemType::EditItem; |
972 | - elseif($index === $selectedIndex) |
|
972 | + elseif ($index === $selectedIndex) |
|
973 | 973 | $itemType = TListItemType::SelectedItem; |
974 | - elseif($index % 2) |
|
974 | + elseif ($index % 2) |
|
975 | 975 | $itemType = TListItemType::AlternatingItem; |
976 | 976 | else |
977 | 977 | $itemType = TListItemType::Item; |
978 | 978 | $items->add($this->createItemInternal($index, $dsIndex, $itemType, false, null, $columns)); |
979 | 979 | $dsIndex++; |
980 | 980 | } |
981 | - if($index > 0) |
|
981 | + if ($index > 0) |
|
982 | 982 | { |
983 | 983 | $this->_footer = $this->createItemInternal(-1, -1, TListItemType::Footer, false, null, $columns); |
984 | - if($allowPaging) |
|
984 | + if ($allowPaging) |
|
985 | 985 | $this->_bottomPager = $this->createPager(); |
986 | 986 | } |
987 | 987 | } |
988 | - if(!$dsIndex && $this->_emptyTemplate !== null) |
|
988 | + if (!$dsIndex && $this->_emptyTemplate !== null) |
|
989 | 989 | { |
990 | 990 | $this->_useEmptyTemplate = true; |
991 | 991 | $this->_emptyTemplate->instantiateIn($this); |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | $keyField = $this->getDataKeyField(); |
1007 | 1007 | |
1008 | 1008 | // get all columns |
1009 | - if($this->getAutoGenerateColumns()) |
|
1009 | + if ($this->getAutoGenerateColumns()) |
|
1010 | 1010 | { |
1011 | 1011 | $columns = new TList($this->getColumns()); |
1012 | 1012 | $autoColumns = $this->createAutoColumns($data); |
@@ -1020,32 +1020,32 @@ discard block |
||
1020 | 1020 | |
1021 | 1021 | $index = 0; |
1022 | 1022 | $allowPaging = $this->getAllowPaging() && ($data instanceof TPagedDataSource); |
1023 | - $dsIndex = $allowPaging?$data->getFirstIndexInPage():0; |
|
1023 | + $dsIndex = $allowPaging ? $data->getFirstIndexInPage() : 0; |
|
1024 | 1024 | $this->setViewState('DataSourceIndex', $dsIndex, 0); |
1025 | - if($columns->getCount()) |
|
1025 | + if ($columns->getCount()) |
|
1026 | 1026 | { |
1027 | - foreach($columns as $column) |
|
1027 | + foreach ($columns as $column) |
|
1028 | 1028 | $column->initialize(); |
1029 | 1029 | |
1030 | 1030 | $selectedIndex = $this->getSelectedItemIndex(); |
1031 | 1031 | $editIndex = $this->getEditItemIndex(); |
1032 | - foreach($data as $key => $row) |
|
1032 | + foreach ($data as $key => $row) |
|
1033 | 1033 | { |
1034 | - if($keyField !== '') |
|
1034 | + if ($keyField !== '') |
|
1035 | 1035 | $keys->add($this->getDataFieldValue($row, $keyField)); |
1036 | 1036 | else |
1037 | 1037 | $keys->add($key); |
1038 | - if($index === 0) |
|
1038 | + if ($index === 0) |
|
1039 | 1039 | { |
1040 | - if($allowPaging) |
|
1040 | + if ($allowPaging) |
|
1041 | 1041 | $this->_topPager = $this->createPager(); |
1042 | 1042 | $this->_header = $this->createItemInternal(-1, -1, TListItemType::Header, true, null, $columns); |
1043 | 1043 | } |
1044 | - if($index === $editIndex) |
|
1044 | + if ($index === $editIndex) |
|
1045 | 1045 | $itemType = TListItemType::EditItem; |
1046 | - elseif($index === $selectedIndex) |
|
1046 | + elseif ($index === $selectedIndex) |
|
1047 | 1047 | $itemType = TListItemType::SelectedItem; |
1048 | - elseif($index % 2) |
|
1048 | + elseif ($index % 2) |
|
1049 | 1049 | $itemType = TListItemType::AlternatingItem; |
1050 | 1050 | else |
1051 | 1051 | $itemType = TListItemType::Item; |
@@ -1053,15 +1053,15 @@ discard block |
||
1053 | 1053 | $index++; |
1054 | 1054 | $dsIndex++; |
1055 | 1055 | } |
1056 | - if($index > 0) |
|
1056 | + if ($index > 0) |
|
1057 | 1057 | { |
1058 | 1058 | $this->_footer = $this->createItemInternal(-1, -1, TListItemType::Footer, true, null, $columns); |
1059 | - if($allowPaging) |
|
1059 | + if ($allowPaging) |
|
1060 | 1060 | $this->_bottomPager = $this->createPager(); |
1061 | 1061 | } |
1062 | 1062 | } |
1063 | 1063 | $this->setViewState('ItemCount', $index, 0); |
1064 | - if(!$dsIndex && $this->_emptyTemplate !== null) |
|
1064 | + if (!$dsIndex && $this->_emptyTemplate !== null) |
|
1065 | 1065 | { |
1066 | 1066 | $this->_useEmptyTemplate = true; |
1067 | 1067 | $this->_emptyTemplate->instantiateIn($this); |
@@ -1075,37 +1075,37 @@ discard block |
||
1075 | 1075 | */ |
1076 | 1076 | private function groupCells() |
1077 | 1077 | { |
1078 | - if(($columns = $this->_allColumns) === null) |
|
1078 | + if (($columns = $this->_allColumns) === null) |
|
1079 | 1079 | return; |
1080 | 1080 | $items = $this->getItems(); |
1081 | - foreach($columns as $id => $column) |
|
1081 | + foreach ($columns as $id => $column) |
|
1082 | 1082 | { |
1083 | - if(!$column->getEnableCellGrouping()) |
|
1083 | + if (!$column->getEnableCellGrouping()) |
|
1084 | 1084 | continue; |
1085 | 1085 | $prevCell = null; |
1086 | 1086 | $prevCellText = null; |
1087 | - foreach($items as $item) |
|
1087 | + foreach ($items as $item) |
|
1088 | 1088 | { |
1089 | 1089 | $itemType = $item->getItemType(); |
1090 | 1090 | $cell = $item->getCells()->itemAt($id); |
1091 | - if(!$cell->getVisible()) |
|
1091 | + if (!$cell->getVisible()) |
|
1092 | 1092 | continue; |
1093 | - if($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::SelectedItem) |
|
1093 | + if ($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::SelectedItem) |
|
1094 | 1094 | { |
1095 | - if(($cellText = $this->getCellText($cell)) === '') |
|
1095 | + if (($cellText = $this->getCellText($cell)) === '') |
|
1096 | 1096 | { |
1097 | 1097 | $prevCell = null; |
1098 | 1098 | $prevCellText = null; |
1099 | 1099 | continue; |
1100 | 1100 | } |
1101 | - if($prevCell === null || $prevCellText !== $cellText) |
|
1101 | + if ($prevCell === null || $prevCellText !== $cellText) |
|
1102 | 1102 | { |
1103 | 1103 | $prevCell = $cell; |
1104 | 1104 | $prevCellText = $cellText; |
1105 | 1105 | } |
1106 | 1106 | else |
1107 | 1107 | { |
1108 | - if(($rowSpan = $prevCell->getRowSpan()) === 0) |
|
1108 | + if (($rowSpan = $prevCell->getRowSpan()) === 0) |
|
1109 | 1109 | $rowSpan = 1; |
1110 | 1110 | $prevCell->setRowSpan($rowSpan + 1); |
1111 | 1111 | $cell->setVisible(false); |
@@ -1117,12 +1117,12 @@ discard block |
||
1117 | 1117 | |
1118 | 1118 | private function getCellText($cell) |
1119 | 1119 | { |
1120 | - if(($data = $cell->getText()) === '' && $cell->getHasControls()) |
|
1120 | + if (($data = $cell->getText()) === '' && $cell->getHasControls()) |
|
1121 | 1121 | { |
1122 | 1122 | $controls = $cell->getControls(); |
1123 | - foreach($controls as $control) |
|
1123 | + foreach ($controls as $control) |
|
1124 | 1124 | { |
1125 | - if($control instanceof \Prado\IDataRenderer) |
|
1125 | + if ($control instanceof \Prado\IDataRenderer) |
|
1126 | 1126 | return $control->getData(); |
1127 | 1127 | } |
1128 | 1128 | } |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | $item = $this->createItem($itemIndex, $dataSourceIndex, $itemType); |
1146 | 1146 | $this->initializeItem($item, $columns); |
1147 | 1147 | $param = new TDataGridItemEventParameter($item); |
1148 | - if($dataBind) |
|
1148 | + if ($dataBind) |
|
1149 | 1149 | { |
1150 | 1150 | $item->setData($dataItem); |
1151 | 1151 | $this->onItemCreated($param); |
@@ -1171,13 +1171,13 @@ discard block |
||
1171 | 1171 | $cells = $item->getCells(); |
1172 | 1172 | $itemType = $item->getItemType(); |
1173 | 1173 | $index = 0; |
1174 | - foreach($columns as $column) |
|
1174 | + foreach ($columns as $column) |
|
1175 | 1175 | { |
1176 | - if($itemType === TListItemType::Header) |
|
1176 | + if ($itemType === TListItemType::Header) |
|
1177 | 1177 | $cell = new TTableHeaderCell; |
1178 | 1178 | else |
1179 | 1179 | $cell = new TTableCell; |
1180 | - if(($id = $column->getID()) !== '') |
|
1180 | + if (($id = $column->getID()) !== '') |
|
1181 | 1181 | $item->registerObject($id, $cell); |
1182 | 1182 | $cells->add($cell); |
1183 | 1183 | $column->initializeCell($cell, $index, $itemType); |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | */ |
1201 | 1201 | protected function buildPager($pager) |
1202 | 1202 | { |
1203 | - switch($this->getPagerStyle()->getMode()) |
|
1203 | + switch ($this->getPagerStyle()->getMode()) |
|
1204 | 1204 | { |
1205 | 1205 | case TDataGridPagerMode::NextPrev: |
1206 | 1206 | $this->buildNextPrevPager($pager); |
@@ -1226,9 +1226,9 @@ discard block |
||
1226 | 1226 | */ |
1227 | 1227 | protected function createPagerButton($pager, $buttonType, $enabled, $text, $commandName, $commandParameter) |
1228 | 1228 | { |
1229 | - if($buttonType === TDataGridPagerButtonType::LinkButton) |
|
1229 | + if ($buttonType === TDataGridPagerButtonType::LinkButton) |
|
1230 | 1230 | { |
1231 | - if($enabled) |
|
1231 | + if ($enabled) |
|
1232 | 1232 | $button = new TLinkButton; |
1233 | 1233 | else |
1234 | 1234 | { |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | else |
1241 | 1241 | { |
1242 | 1242 | $button = new TButton; |
1243 | - if(!$enabled) |
|
1243 | + if (!$enabled) |
|
1244 | 1244 | $button->setEnabled(false); |
1245 | 1245 | } |
1246 | 1246 | $button->setText($text); |
@@ -1260,9 +1260,9 @@ discard block |
||
1260 | 1260 | $buttonType = $style->getButtonType(); |
1261 | 1261 | $controls = $pager->getControls(); |
1262 | 1262 | $currentPageIndex = $this->getCurrentPageIndex(); |
1263 | - if($currentPageIndex === 0) |
|
1263 | + if ($currentPageIndex === 0) |
|
1264 | 1264 | { |
1265 | - if(($text = $style->getFirstPageText()) !== '') |
|
1265 | + if (($text = $style->getFirstPageText()) !== '') |
|
1266 | 1266 | { |
1267 | 1267 | $label = $this->createPagerButton($pager, $buttonType, false, $text, '', ''); |
1268 | 1268 | $controls->add($label); |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | } |
1275 | 1275 | else |
1276 | 1276 | { |
1277 | - if(($text = $style->getFirstPageText()) !== '') |
|
1277 | + if (($text = $style->getFirstPageText()) !== '') |
|
1278 | 1278 | { |
1279 | 1279 | $button = $this->createPagerButton($pager, $buttonType, true, $text, self::CMD_PAGE, self::CMD_PAGE_FIRST); |
1280 | 1280 | $controls->add($button); |
@@ -1285,11 +1285,11 @@ discard block |
||
1285 | 1285 | $controls->add($button); |
1286 | 1286 | } |
1287 | 1287 | $controls->add("\n"); |
1288 | - if($currentPageIndex === $this->getPageCount() - 1) |
|
1288 | + if ($currentPageIndex === $this->getPageCount() - 1) |
|
1289 | 1289 | { |
1290 | 1290 | $label = $this->createPagerButton($pager, $buttonType, false, $style->getNextPageText(), '', ''); |
1291 | 1291 | $controls->add($label); |
1292 | - if(($text = $style->getLastPageText()) !== '') |
|
1292 | + if (($text = $style->getLastPageText()) !== '') |
|
1293 | 1293 | { |
1294 | 1294 | $controls->add("\n"); |
1295 | 1295 | $label = $this->createPagerButton($pager, $buttonType, false, $text, '', ''); |
@@ -1300,7 +1300,7 @@ discard block |
||
1300 | 1300 | { |
1301 | 1301 | $button = $this->createPagerButton($pager, $buttonType, true, $style->getNextPageText(), self::CMD_PAGE, self::CMD_PAGE_NEXT); |
1302 | 1302 | $controls->add($button); |
1303 | - if(($text = $style->getLastPageText()) !== '') |
|
1303 | + if (($text = $style->getLastPageText()) !== '') |
|
1304 | 1304 | { |
1305 | 1305 | $controls->add("\n"); |
1306 | 1306 | $button = $this->createPagerButton($pager, $buttonType, true, $text, self::CMD_PAGE, self::CMD_PAGE_LAST); |
@@ -1321,24 +1321,24 @@ discard block |
||
1321 | 1321 | $pageCount = $this->getPageCount(); |
1322 | 1322 | $pageIndex = $this->getCurrentPageIndex() + 1; |
1323 | 1323 | $maxButtonCount = $style->getPageButtonCount(); |
1324 | - $buttonCount = $maxButtonCount > $pageCount?$pageCount:$maxButtonCount; |
|
1324 | + $buttonCount = $maxButtonCount > $pageCount ? $pageCount : $maxButtonCount; |
|
1325 | 1325 | $startPageIndex = 1; |
1326 | 1326 | $endPageIndex = $buttonCount; |
1327 | - if($pageIndex > $endPageIndex) |
|
1327 | + if ($pageIndex > $endPageIndex) |
|
1328 | 1328 | { |
1329 | - $startPageIndex = ((int)(($pageIndex - 1) / $maxButtonCount)) * $maxButtonCount + 1; |
|
1330 | - if(($endPageIndex = $startPageIndex + $maxButtonCount - 1) > $pageCount) |
|
1329 | + $startPageIndex = ((int) (($pageIndex - 1) / $maxButtonCount)) * $maxButtonCount + 1; |
|
1330 | + if (($endPageIndex = $startPageIndex + $maxButtonCount - 1) > $pageCount) |
|
1331 | 1331 | $endPageIndex = $pageCount; |
1332 | - if($endPageIndex - $startPageIndex + 1 < $maxButtonCount) |
|
1332 | + if ($endPageIndex - $startPageIndex + 1 < $maxButtonCount) |
|
1333 | 1333 | { |
1334 | - if(($startPageIndex = $endPageIndex - $maxButtonCount + 1) < 1) |
|
1334 | + if (($startPageIndex = $endPageIndex - $maxButtonCount + 1) < 1) |
|
1335 | 1335 | $startPageIndex = 1; |
1336 | 1336 | } |
1337 | 1337 | } |
1338 | 1338 | |
1339 | - if($startPageIndex > 1) |
|
1339 | + if ($startPageIndex > 1) |
|
1340 | 1340 | { |
1341 | - if(($text = $style->getFirstPageText()) !== '') |
|
1341 | + if (($text = $style->getFirstPageText()) !== '') |
|
1342 | 1342 | { |
1343 | 1343 | $button = $this->createPagerButton($pager, $buttonType, true, $text, self::CMD_PAGE, self::CMD_PAGE_FIRST); |
1344 | 1344 | $controls->add($button); |
@@ -1350,9 +1350,9 @@ discard block |
||
1350 | 1350 | $controls->add("\n"); |
1351 | 1351 | } |
1352 | 1352 | |
1353 | - for($i = $startPageIndex;$i <= $endPageIndex;++$i) |
|
1353 | + for ($i = $startPageIndex; $i <= $endPageIndex; ++$i) |
|
1354 | 1354 | { |
1355 | - if($i === $pageIndex) |
|
1355 | + if ($i === $pageIndex) |
|
1356 | 1356 | { |
1357 | 1357 | $label = $this->createPagerButton($pager, $buttonType, false, "$i", '', ''); |
1358 | 1358 | $controls->add($label); |
@@ -1362,17 +1362,17 @@ discard block |
||
1362 | 1362 | $button = $this->createPagerButton($pager, $buttonType, true, "$i", self::CMD_PAGE, "$i"); |
1363 | 1363 | $controls->add($button); |
1364 | 1364 | } |
1365 | - if($i < $endPageIndex) |
|
1365 | + if ($i < $endPageIndex) |
|
1366 | 1366 | $controls->add("\n"); |
1367 | 1367 | } |
1368 | 1368 | |
1369 | - if($pageCount > $endPageIndex) |
|
1369 | + if ($pageCount > $endPageIndex) |
|
1370 | 1370 | { |
1371 | 1371 | $controls->add("\n"); |
1372 | 1372 | $nextPageIndex = $endPageIndex + 1; |
1373 | 1373 | $button = $this->createPagerButton($pager, $buttonType, true, $style->getNextPageText(), self::CMD_PAGE, "$nextPageIndex"); |
1374 | 1374 | $controls->add($button); |
1375 | - if(($text = $style->getLastPageText()) !== '') |
|
1375 | + if (($text = $style->getLastPageText()) !== '') |
|
1376 | 1376 | { |
1377 | 1377 | $controls->add("\n"); |
1378 | 1378 | $button = $this->createPagerButton($pager, $buttonType, true, $text, self::CMD_PAGE, self::CMD_PAGE_LAST); |
@@ -1388,16 +1388,16 @@ discard block |
||
1388 | 1388 | */ |
1389 | 1389 | protected function createAutoColumns($dataSource) |
1390 | 1390 | { |
1391 | - if(!$dataSource) |
|
1391 | + if (!$dataSource) |
|
1392 | 1392 | return null; |
1393 | 1393 | $autoColumns = $this->getAutoColumns(); |
1394 | 1394 | $autoColumns->clear(); |
1395 | - foreach($dataSource as $row) |
|
1395 | + foreach ($dataSource as $row) |
|
1396 | 1396 | { |
1397 | - foreach($row as $key => $value) |
|
1397 | + foreach ($row as $key => $value) |
|
1398 | 1398 | { |
1399 | 1399 | $column = new $this->AutoGenerateColumnName; |
1400 | - if(is_string($key)) |
|
1400 | + if (is_string($key)) |
|
1401 | 1401 | { |
1402 | 1402 | $column->setHeaderText($key); |
1403 | 1403 | $column->setDataField($key); |
@@ -1433,9 +1433,9 @@ discard block |
||
1433 | 1433 | $itemStyle = $this->getViewState('ItemStyle', null); |
1434 | 1434 | |
1435 | 1435 | $alternatingItemStyle = $this->getViewState('AlternatingItemStyle', null); |
1436 | - if($itemStyle !== null) |
|
1436 | + if ($itemStyle !== null) |
|
1437 | 1437 | { |
1438 | - if($alternatingItemStyle === null) |
|
1438 | + if ($alternatingItemStyle === null) |
|
1439 | 1439 | $alternatingItemStyle = $itemStyle; |
1440 | 1440 | else |
1441 | 1441 | $alternatingItemStyle->mergeWith($itemStyle); |
@@ -1444,9 +1444,9 @@ discard block |
||
1444 | 1444 | $selectedItemStyle = $this->getViewState('SelectedItemStyle', null); |
1445 | 1445 | |
1446 | 1446 | $editItemStyle = $this->getViewState('EditItemStyle', null); |
1447 | - if($selectedItemStyle !== null) |
|
1447 | + if ($selectedItemStyle !== null) |
|
1448 | 1448 | { |
1449 | - if($editItemStyle === null) |
|
1449 | + if ($editItemStyle === null) |
|
1450 | 1450 | $editItemStyle = $selectedItemStyle; |
1451 | 1451 | else |
1452 | 1452 | $editItemStyle->mergeWith($selectedItemStyle); |
@@ -1457,77 +1457,77 @@ discard block |
||
1457 | 1457 | $pagerStyle = $this->getViewState('PagerStyle', null); |
1458 | 1458 | $separatorStyle = $this->getViewState('SeparatorStyle', null); |
1459 | 1459 | |
1460 | - foreach($this->getControls() as $index => $item) |
|
1460 | + foreach ($this->getControls() as $index => $item) |
|
1461 | 1461 | { |
1462 | - if(!($item instanceof TDataGridItem) && !($item instanceof TDataGridPager)) |
|
1462 | + if (!($item instanceof TDataGridItem) && !($item instanceof TDataGridPager)) |
|
1463 | 1463 | continue; |
1464 | 1464 | $itemType = $item->getItemType(); |
1465 | - switch($itemType) |
|
1465 | + switch ($itemType) |
|
1466 | 1466 | { |
1467 | 1467 | case TListItemType::Header: |
1468 | - if($headerStyle) |
|
1468 | + if ($headerStyle) |
|
1469 | 1469 | $item->getStyle()->mergeWith($headerStyle); |
1470 | - if(!$this->getShowHeader()) |
|
1470 | + if (!$this->getShowHeader()) |
|
1471 | 1471 | $item->setVisible(false); |
1472 | 1472 | break; |
1473 | 1473 | case TListItemType::Footer: |
1474 | - if($footerStyle) |
|
1474 | + if ($footerStyle) |
|
1475 | 1475 | $item->getStyle()->mergeWith($footerStyle); |
1476 | - if(!$this->getShowFooter()) |
|
1476 | + if (!$this->getShowFooter()) |
|
1477 | 1477 | $item->setVisible(false); |
1478 | 1478 | break; |
1479 | 1479 | case TListItemType::Separator: |
1480 | - if($separatorStyle) |
|
1480 | + if ($separatorStyle) |
|
1481 | 1481 | $item->getStyle()->mergeWith($separatorStyle); |
1482 | 1482 | break; |
1483 | 1483 | case TListItemType::Item: |
1484 | - if($itemStyle) |
|
1484 | + if ($itemStyle) |
|
1485 | 1485 | $item->getStyle()->mergeWith($itemStyle); |
1486 | 1486 | break; |
1487 | 1487 | case TListItemType::AlternatingItem: |
1488 | - if($alternatingItemStyle) |
|
1488 | + if ($alternatingItemStyle) |
|
1489 | 1489 | $item->getStyle()->mergeWith($alternatingItemStyle); |
1490 | 1490 | break; |
1491 | 1491 | case TListItemType::SelectedItem: |
1492 | - if($selectedItemStyle) |
|
1492 | + if ($selectedItemStyle) |
|
1493 | 1493 | $item->getStyle()->mergeWith($selectedItemStyle); |
1494 | - if($index % 2 == 1) |
|
1494 | + if ($index % 2 == 1) |
|
1495 | 1495 | { |
1496 | - if($itemStyle) |
|
1496 | + if ($itemStyle) |
|
1497 | 1497 | $item->getStyle()->mergeWith($itemStyle); |
1498 | 1498 | } |
1499 | 1499 | else |
1500 | 1500 | { |
1501 | - if($alternatingItemStyle) |
|
1501 | + if ($alternatingItemStyle) |
|
1502 | 1502 | $item->getStyle()->mergeWith($alternatingItemStyle); |
1503 | 1503 | } |
1504 | 1504 | break; |
1505 | 1505 | case TListItemType::EditItem: |
1506 | - if($editItemStyle) |
|
1506 | + if ($editItemStyle) |
|
1507 | 1507 | $item->getStyle()->mergeWith($editItemStyle); |
1508 | - if($index % 2 == 1) |
|
1508 | + if ($index % 2 == 1) |
|
1509 | 1509 | { |
1510 | - if($itemStyle) |
|
1510 | + if ($itemStyle) |
|
1511 | 1511 | $item->getStyle()->mergeWith($itemStyle); |
1512 | 1512 | } |
1513 | 1513 | else |
1514 | 1514 | { |
1515 | - if($alternatingItemStyle) |
|
1515 | + if ($alternatingItemStyle) |
|
1516 | 1516 | $item->getStyle()->mergeWith($alternatingItemStyle); |
1517 | 1517 | } |
1518 | 1518 | break; |
1519 | 1519 | case TListItemType::Pager: |
1520 | - if($pagerStyle) |
|
1520 | + if ($pagerStyle) |
|
1521 | 1521 | { |
1522 | 1522 | $item->getStyle()->mergeWith($pagerStyle); |
1523 | - if($index === 0) |
|
1523 | + if ($index === 0) |
|
1524 | 1524 | { |
1525 | - if($pagerStyle->getPosition() === TDataGridPagerPosition::Bottom || !$pagerStyle->getVisible()) |
|
1525 | + if ($pagerStyle->getPosition() === TDataGridPagerPosition::Bottom || !$pagerStyle->getVisible()) |
|
1526 | 1526 | $item->setVisible(false); |
1527 | 1527 | } |
1528 | 1528 | else |
1529 | 1529 | { |
1530 | - if($pagerStyle->getPosition() === TDataGridPagerPosition::Top || !$pagerStyle->getVisible()) |
|
1530 | + if ($pagerStyle->getPosition() === TDataGridPagerPosition::Top || !$pagerStyle->getVisible()) |
|
1531 | 1531 | $item->setVisible(false); |
1532 | 1532 | } |
1533 | 1533 | } |
@@ -1535,25 +1535,25 @@ discard block |
||
1535 | 1535 | default: |
1536 | 1536 | break; |
1537 | 1537 | } |
1538 | - if($this->_columns && $itemType !== TListItemType::Pager) |
|
1538 | + if ($this->_columns && $itemType !== TListItemType::Pager) |
|
1539 | 1539 | { |
1540 | 1540 | $n = $this->_columns->getCount(); |
1541 | 1541 | $cells = $item->getCells(); |
1542 | - for($i = 0;$i < $n;++$i) |
|
1542 | + for ($i = 0; $i < $n; ++$i) |
|
1543 | 1543 | { |
1544 | 1544 | $cell = $cells->itemAt($i); |
1545 | 1545 | $column = $this->_columns->itemAt($i); |
1546 | - if(!$column->getVisible()) |
|
1546 | + if (!$column->getVisible()) |
|
1547 | 1547 | $cell->setVisible(false); |
1548 | 1548 | else |
1549 | 1549 | { |
1550 | - if($itemType === TListItemType::Header) |
|
1550 | + if ($itemType === TListItemType::Header) |
|
1551 | 1551 | $style = $column->getHeaderStyle(false); |
1552 | - elseif($itemType === TListItemType::Footer) |
|
1552 | + elseif ($itemType === TListItemType::Footer) |
|
1553 | 1553 | $style = $column->getFooterStyle(false); |
1554 | 1554 | else |
1555 | 1555 | $style = $column->getItemStyle(false); |
1556 | - if($style !== null) |
|
1556 | + if ($style !== null) |
|
1557 | 1557 | $cell->getStyle()->mergeWith($style); |
1558 | 1558 | } |
1559 | 1559 | } |
@@ -1568,9 +1568,9 @@ discard block |
||
1568 | 1568 | public function renderBeginTag($writer) |
1569 | 1569 | { |
1570 | 1570 | parent::renderBeginTag($writer); |
1571 | - if(($caption = $this->getCaption()) !== '') |
|
1571 | + if (($caption = $this->getCaption()) !== '') |
|
1572 | 1572 | { |
1573 | - if(($align = $this->getCaptionAlign()) !== TTableCaptionAlign::NotSet) |
|
1573 | + if (($align = $this->getCaptionAlign()) !== TTableCaptionAlign::NotSet) |
|
1574 | 1574 | $writer->addAttribute('align', strtolower($align)); |
1575 | 1575 | $writer->renderBeginTag('caption'); |
1576 | 1576 | $writer->write($caption); |
@@ -1584,30 +1584,30 @@ discard block |
||
1584 | 1584 | */ |
1585 | 1585 | public function render($writer) |
1586 | 1586 | { |
1587 | - if($this->getHasControls()) |
|
1587 | + if ($this->getHasControls()) |
|
1588 | 1588 | { |
1589 | 1589 | $this->groupCells(); |
1590 | - if($this->_useEmptyTemplate) |
|
1590 | + if ($this->_useEmptyTemplate) |
|
1591 | 1591 | { |
1592 | 1592 | $control = new TWebControl; |
1593 | 1593 | $control->setID($this->getClientID()); |
1594 | 1594 | $control->copyBaseAttributes($this); |
1595 | - if($this->getHasStyle()) |
|
1595 | + if ($this->getHasStyle()) |
|
1596 | 1596 | $control->getStyle()->copyFrom($this->getStyle()); |
1597 | 1597 | $control->renderBeginTag($writer); |
1598 | 1598 | $this->renderContents($writer); |
1599 | 1599 | $control->renderEndTag($writer); |
1600 | 1600 | } |
1601 | - elseif($this->getViewState('ItemCount', 0) > 0) |
|
1601 | + elseif ($this->getViewState('ItemCount', 0) > 0) |
|
1602 | 1602 | { |
1603 | 1603 | $this->applyItemStyles(); |
1604 | - if($this->_topPager) |
|
1604 | + if ($this->_topPager) |
|
1605 | 1605 | { |
1606 | 1606 | $this->_topPager->renderControl($writer); |
1607 | 1607 | $writer->writeLine(); |
1608 | 1608 | } |
1609 | 1609 | $this->renderTable($writer); |
1610 | - if($this->_bottomPager) |
|
1610 | + if ($this->_bottomPager) |
|
1611 | 1611 | { |
1612 | 1612 | $writer->writeLine(); |
1613 | 1613 | $this->_bottomPager->renderControl($writer); |
@@ -1623,27 +1623,27 @@ discard block |
||
1623 | 1623 | protected function renderTable($writer) |
1624 | 1624 | { |
1625 | 1625 | $this->renderBeginTag($writer); |
1626 | - if($this->_header && $this->_header->getVisible()) |
|
1626 | + if ($this->_header && $this->_header->getVisible()) |
|
1627 | 1627 | { |
1628 | 1628 | $writer->writeLine(); |
1629 | - if($style = $this->getViewState('TableHeadStyle', null)) |
|
1629 | + if ($style = $this->getViewState('TableHeadStyle', null)) |
|
1630 | 1630 | $style->addAttributesToRender($writer); |
1631 | 1631 | $writer->renderBeginTag('thead'); |
1632 | 1632 | $this->_header->render($writer); |
1633 | 1633 | $writer->renderEndTag(); |
1634 | 1634 | } |
1635 | 1635 | $writer->writeLine(); |
1636 | - if($style = $this->getViewState('TableBodyStyle', null)) |
|
1636 | + if ($style = $this->getViewState('TableBodyStyle', null)) |
|
1637 | 1637 | $style->addAttributesToRender($writer); |
1638 | 1638 | $writer->renderBeginTag('tbody'); |
1639 | - foreach($this->getItems() as $item) |
|
1639 | + foreach ($this->getItems() as $item) |
|
1640 | 1640 | $item->renderControl($writer); |
1641 | 1641 | $writer->renderEndTag(); |
1642 | 1642 | |
1643 | - if($this->_footer && $this->_footer->getVisible()) |
|
1643 | + if ($this->_footer && $this->_footer->getVisible()) |
|
1644 | 1644 | { |
1645 | 1645 | $writer->writeLine(); |
1646 | - if($style = $this->getViewState('TableFootStyle', null)) |
|
1646 | + if ($style = $this->getViewState('TableFootStyle', null)) |
|
1647 | 1647 | $style->addAttributesToRender($writer); |
1648 | 1648 | $writer->renderBeginTag('tfoot'); |
1649 | 1649 | $this->_footer->render($writer); |
@@ -224,10 +224,12 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function addParsedObject($object) |
226 | 226 | { |
227 | - if($object instanceof TDataGridColumn) |
|
228 | - $this->getColumns()->add($object); |
|
229 | - else |
|
230 | - parent::addParsedObject($object); // this is needed by EmptyTemplate |
|
227 | + if($object instanceof TDataGridColumn) { |
|
228 | + $this->getColumns()->add($object); |
|
229 | + } else { |
|
230 | + parent::addParsedObject($object); |
|
231 | + } |
|
232 | + // this is needed by EmptyTemplate |
|
231 | 233 | } |
232 | 234 | |
233 | 235 | /** |
@@ -235,8 +237,9 @@ discard block |
||
235 | 237 | */ |
236 | 238 | public function getColumns() |
237 | 239 | { |
238 | - if(!$this->_columns) |
|
239 | - $this->_columns = new TDataGridColumnCollection($this); |
|
240 | + if(!$this->_columns) { |
|
241 | + $this->_columns = new TDataGridColumnCollection($this); |
|
242 | + } |
|
240 | 243 | return $this->_columns; |
241 | 244 | } |
242 | 245 | |
@@ -245,8 +248,9 @@ discard block |
||
245 | 248 | */ |
246 | 249 | public function getAutoColumns() |
247 | 250 | { |
248 | - if(!$this->_autoColumns) |
|
249 | - $this->_autoColumns = new TDataGridColumnCollection($this); |
|
251 | + if(!$this->_autoColumns) { |
|
252 | + $this->_autoColumns = new TDataGridColumnCollection($this); |
|
253 | + } |
|
250 | 254 | return $this->_autoColumns; |
251 | 255 | } |
252 | 256 | |
@@ -255,8 +259,9 @@ discard block |
||
255 | 259 | */ |
256 | 260 | public function getItems() |
257 | 261 | { |
258 | - if(!$this->_items) |
|
259 | - $this->_items = new TDataGridItemCollection; |
|
262 | + if(!$this->_items) { |
|
263 | + $this->_items = new TDataGridItemCollection; |
|
264 | + } |
|
260 | 265 | return $this->_items; |
261 | 266 | } |
262 | 267 | |
@@ -498,10 +503,11 @@ discard block |
||
498 | 503 | { |
499 | 504 | $index = $this->getSelectedItemIndex(); |
500 | 505 | $items = $this->getItems(); |
501 | - if($index >= 0 && $index < $items->getCount()) |
|
502 | - return $items->itemAt($index); |
|
503 | - else |
|
504 | - return null; |
|
506 | + if($index >= 0 && $index < $items->getCount()) { |
|
507 | + return $items->itemAt($index); |
|
508 | + } else { |
|
509 | + return null; |
|
510 | + } |
|
505 | 511 | } |
506 | 512 | |
507 | 513 | /** |
@@ -522,8 +528,9 @@ discard block |
||
522 | 528 | */ |
523 | 529 | public function setSelectedItemIndex($value) |
524 | 530 | { |
525 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
526 | - $value = -1; |
|
531 | + if(($value = TPropertyValue::ensureInteger($value)) < 0) { |
|
532 | + $value = -1; |
|
533 | + } |
|
527 | 534 | if(($current = $this->getSelectedItemIndex()) !== $value) |
528 | 535 | { |
529 | 536 | $this->setViewState('SelectedItemIndex', $value, -1); |
@@ -532,14 +539,16 @@ discard block |
||
532 | 539 | if($current >= 0 && $current < $itemCount) |
533 | 540 | { |
534 | 541 | $item = $items->itemAt($current); |
535 | - if($item->getItemType() !== TListItemType::EditItem) |
|
536 | - $item->setItemType($current % 2?TListItemType::AlternatingItem:TListItemType::Item); |
|
542 | + if($item->getItemType() !== TListItemType::EditItem) { |
|
543 | + $item->setItemType($current % 2?TListItemType::AlternatingItem:TListItemType::Item); |
|
544 | + } |
|
537 | 545 | } |
538 | 546 | if($value >= 0 && $value < $itemCount) |
539 | 547 | { |
540 | 548 | $item = $items->itemAt($value); |
541 | - if($item->getItemType() !== TListItemType::EditItem) |
|
542 | - $item->setItemType(TListItemType::SelectedItem); |
|
549 | + if($item->getItemType() !== TListItemType::EditItem) { |
|
550 | + $item->setItemType(TListItemType::SelectedItem); |
|
551 | + } |
|
543 | 552 | } |
544 | 553 | } |
545 | 554 | } |
@@ -551,10 +560,11 @@ discard block |
||
551 | 560 | { |
552 | 561 | $index = $this->getEditItemIndex(); |
553 | 562 | $items = $this->getItems(); |
554 | - if($index >= 0 && $index < $items->getCount()) |
|
555 | - return $items->itemAt($index); |
|
556 | - else |
|
557 | - return null; |
|
563 | + if($index >= 0 && $index < $items->getCount()) { |
|
564 | + return $items->itemAt($index); |
|
565 | + } else { |
|
566 | + return null; |
|
567 | + } |
|
558 | 568 | } |
559 | 569 | |
560 | 570 | /** |
@@ -574,17 +584,20 @@ discard block |
||
574 | 584 | */ |
575 | 585 | public function setEditItemIndex($value) |
576 | 586 | { |
577 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
578 | - $value = -1; |
|
587 | + if(($value = TPropertyValue::ensureInteger($value)) < 0) { |
|
588 | + $value = -1; |
|
589 | + } |
|
579 | 590 | if(($current = $this->getEditItemIndex()) !== $value) |
580 | 591 | { |
581 | 592 | $this->setViewState('EditItemIndex', $value, -1); |
582 | 593 | $items = $this->getItems(); |
583 | 594 | $itemCount = $items->getCount(); |
584 | - if($current >= 0 && $current < $itemCount) |
|
585 | - $items->itemAt($current)->setItemType($current % 2?TListItemType::AlternatingItem:TListItemType::Item); |
|
586 | - if($value >= 0 && $value < $itemCount) |
|
587 | - $items->itemAt($value)->setItemType(TListItemType::EditItem); |
|
595 | + if($current >= 0 && $current < $itemCount) { |
|
596 | + $items->itemAt($current)->setItemType($current % 2?TListItemType::AlternatingItem:TListItemType::Item); |
|
597 | + } |
|
598 | + if($value >= 0 && $value < $itemCount) { |
|
599 | + $items->itemAt($value)->setItemType(TListItemType::EditItem); |
|
600 | + } |
|
588 | 601 | } |
589 | 602 | } |
590 | 603 | |
@@ -666,10 +679,11 @@ discard block |
||
666 | 679 | */ |
667 | 680 | public function setEmptyTemplate($value) |
668 | 681 | { |
669 | - if($value instanceof ITemplate || $value === null) |
|
670 | - $this->_emptyTemplate = $value; |
|
671 | - else |
|
672 | - throw new TInvalidDataTypeException('datagrid_template_required', 'EmptyTemplate'); |
|
682 | + if($value instanceof ITemplate || $value === null) { |
|
683 | + $this->_emptyTemplate = $value; |
|
684 | + } else { |
|
685 | + throw new TInvalidDataTypeException('datagrid_template_required', 'EmptyTemplate'); |
|
686 | + } |
|
673 | 687 | } |
674 | 688 | |
675 | 689 | /** |
@@ -696,45 +710,40 @@ discard block |
||
696 | 710 | $this->setSelectedItemIndex($param->getItem()->getItemIndex()); |
697 | 711 | $this->onSelectedIndexChanged($param); |
698 | 712 | return true; |
699 | - } |
|
700 | - elseif(strcasecmp($command, self::CMD_EDIT) === 0) |
|
713 | + } elseif(strcasecmp($command, self::CMD_EDIT) === 0) |
|
701 | 714 | { |
702 | 715 | $this->onEditCommand($param); |
703 | 716 | return true; |
704 | - } |
|
705 | - elseif(strcasecmp($command, self::CMD_DELETE) === 0) |
|
717 | + } elseif(strcasecmp($command, self::CMD_DELETE) === 0) |
|
706 | 718 | { |
707 | 719 | $this->onDeleteCommand($param); |
708 | 720 | return true; |
709 | - } |
|
710 | - elseif(strcasecmp($command, self::CMD_UPDATE) === 0) |
|
721 | + } elseif(strcasecmp($command, self::CMD_UPDATE) === 0) |
|
711 | 722 | { |
712 | 723 | $this->onUpdateCommand($param); |
713 | 724 | return true; |
714 | - } |
|
715 | - elseif(strcasecmp($command, self::CMD_CANCEL) === 0) |
|
725 | + } elseif(strcasecmp($command, self::CMD_CANCEL) === 0) |
|
716 | 726 | { |
717 | 727 | $this->onCancelCommand($param); |
718 | 728 | return true; |
719 | - } |
|
720 | - elseif(strcasecmp($command, self::CMD_SORT) === 0) |
|
729 | + } elseif(strcasecmp($command, self::CMD_SORT) === 0) |
|
721 | 730 | { |
722 | 731 | $this->onSortCommand(new TDataGridSortCommandEventParameter($sender, $param)); |
723 | 732 | return true; |
724 | - } |
|
725 | - elseif(strcasecmp($command, self::CMD_PAGE) === 0) |
|
733 | + } elseif(strcasecmp($command, self::CMD_PAGE) === 0) |
|
726 | 734 | { |
727 | 735 | $p = $param->getCommandParameter(); |
728 | - if(strcasecmp($p, self::CMD_PAGE_NEXT) === 0) |
|
729 | - $pageIndex = $this->getCurrentPageIndex() + 1; |
|
730 | - elseif(strcasecmp($p, self::CMD_PAGE_PREV) === 0) |
|
731 | - $pageIndex = $this->getCurrentPageIndex() - 1; |
|
732 | - elseif(strcasecmp($p, self::CMD_PAGE_FIRST) === 0) |
|
733 | - $pageIndex = 0; |
|
734 | - elseif(strcasecmp($p, self::CMD_PAGE_LAST) === 0) |
|
735 | - $pageIndex = $this->getPageCount() - 1; |
|
736 | - else |
|
737 | - $pageIndex = TPropertyValue::ensureInteger($p) - 1; |
|
736 | + if(strcasecmp($p, self::CMD_PAGE_NEXT) === 0) { |
|
737 | + $pageIndex = $this->getCurrentPageIndex() + 1; |
|
738 | + } elseif(strcasecmp($p, self::CMD_PAGE_PREV) === 0) { |
|
739 | + $pageIndex = $this->getCurrentPageIndex() - 1; |
|
740 | + } elseif(strcasecmp($p, self::CMD_PAGE_FIRST) === 0) { |
|
741 | + $pageIndex = 0; |
|
742 | + } elseif(strcasecmp($p, self::CMD_PAGE_LAST) === 0) { |
|
743 | + $pageIndex = $this->getPageCount() - 1; |
|
744 | + } else { |
|
745 | + $pageIndex = TPropertyValue::ensureInteger($p) - 1; |
|
746 | + } |
|
738 | 747 | $this->onPageIndexChanged(new TDataGridPageChangedEventParameter($sender, $pageIndex)); |
739 | 748 | return true; |
740 | 749 | } |
@@ -857,30 +866,34 @@ discard block |
||
857 | 866 | public function saveState() |
858 | 867 | { |
859 | 868 | parent::saveState(); |
860 | - if(!$this->getEnableViewState(true)) |
|
861 | - return; |
|
862 | - if($this->_items) |
|
863 | - $this->setViewState('ItemCount', $this->_items->getCount(), 0); |
|
864 | - else |
|
865 | - $this->clearViewState('ItemCount'); |
|
869 | + if(!$this->getEnableViewState(true)) { |
|
870 | + return; |
|
871 | + } |
|
872 | + if($this->_items) { |
|
873 | + $this->setViewState('ItemCount', $this->_items->getCount(), 0); |
|
874 | + } else { |
|
875 | + $this->clearViewState('ItemCount'); |
|
876 | + } |
|
866 | 877 | if($this->_autoColumns) |
867 | 878 | { |
868 | 879 | $state = []; |
869 | - foreach($this->_autoColumns as $column) |
|
870 | - $state[] = $column->saveState(); |
|
880 | + foreach($this->_autoColumns as $column) { |
|
881 | + $state[] = $column->saveState(); |
|
882 | + } |
|
871 | 883 | $this->setViewState('AutoColumns', $state, []); |
884 | + } else { |
|
885 | + $this->clearViewState('AutoColumns'); |
|
872 | 886 | } |
873 | - else |
|
874 | - $this->clearViewState('AutoColumns'); |
|
875 | 887 | if($this->_columns) |
876 | 888 | { |
877 | 889 | $state = []; |
878 | - foreach($this->_columns as $column) |
|
879 | - $state[] = $column->saveState(); |
|
890 | + foreach($this->_columns as $column) { |
|
891 | + $state[] = $column->saveState(); |
|
892 | + } |
|
880 | 893 | $this->setViewState('Columns', $state, []); |
894 | + } else { |
|
895 | + $this->clearViewState('Columns'); |
|
881 | 896 | } |
882 | - else |
|
883 | - $this->clearViewState('Columns'); |
|
884 | 897 | } |
885 | 898 | |
886 | 899 | /** |
@@ -890,8 +903,9 @@ discard block |
||
890 | 903 | public function loadState() |
891 | 904 | { |
892 | 905 | parent::loadState(); |
893 | - if(!$this->getEnableViewState(true)) |
|
894 | - return; |
|
906 | + if(!$this->getEnableViewState(true)) { |
|
907 | + return; |
|
908 | + } |
|
895 | 909 | if(!$this->getIsDataBound()) |
896 | 910 | { |
897 | 911 | $state = $this->getViewState('AutoColumns', []); |
@@ -904,9 +918,9 @@ discard block |
||
904 | 918 | $column->loadState($st); |
905 | 919 | $this->_autoColumns->add($column); |
906 | 920 | } |
921 | + } else { |
|
922 | + $this->_autoColumns = null; |
|
907 | 923 | } |
908 | - else |
|
909 | - $this->_autoColumns = null; |
|
910 | 924 | $state = $this->getViewState('Columns', []); |
911 | 925 | if($this->_columns && $this->_columns->getCount() === count($state)) |
912 | 926 | { |
@@ -955,34 +969,38 @@ discard block |
||
955 | 969 | |
956 | 970 | if($columns->getCount()) |
957 | 971 | { |
958 | - foreach($columns as $column) |
|
959 | - $column->initialize(); |
|
972 | + foreach($columns as $column) { |
|
973 | + $column->initialize(); |
|
974 | + } |
|
960 | 975 | $selectedIndex = $this->getSelectedItemIndex(); |
961 | 976 | $editIndex = $this->getEditItemIndex(); |
962 | 977 | for($index = 0;$index < $itemCount;++$index) |
963 | 978 | { |
964 | 979 | if($index === 0) |
965 | 980 | { |
966 | - if($allowPaging) |
|
967 | - $this->_topPager = $this->createPager(); |
|
981 | + if($allowPaging) { |
|
982 | + $this->_topPager = $this->createPager(); |
|
983 | + } |
|
968 | 984 | $this->_header = $this->createItemInternal(-1, -1, TListItemType::Header, false, null, $columns); |
969 | 985 | } |
970 | - if($index === $editIndex) |
|
971 | - $itemType = TListItemType::EditItem; |
|
972 | - elseif($index === $selectedIndex) |
|
973 | - $itemType = TListItemType::SelectedItem; |
|
974 | - elseif($index % 2) |
|
975 | - $itemType = TListItemType::AlternatingItem; |
|
976 | - else |
|
977 | - $itemType = TListItemType::Item; |
|
986 | + if($index === $editIndex) { |
|
987 | + $itemType = TListItemType::EditItem; |
|
988 | + } elseif($index === $selectedIndex) { |
|
989 | + $itemType = TListItemType::SelectedItem; |
|
990 | + } elseif($index % 2) { |
|
991 | + $itemType = TListItemType::AlternatingItem; |
|
992 | + } else { |
|
993 | + $itemType = TListItemType::Item; |
|
994 | + } |
|
978 | 995 | $items->add($this->createItemInternal($index, $dsIndex, $itemType, false, null, $columns)); |
979 | 996 | $dsIndex++; |
980 | 997 | } |
981 | 998 | if($index > 0) |
982 | 999 | { |
983 | 1000 | $this->_footer = $this->createItemInternal(-1, -1, TListItemType::Footer, false, null, $columns); |
984 | - if($allowPaging) |
|
985 | - $this->_bottomPager = $this->createPager(); |
|
1001 | + if($allowPaging) { |
|
1002 | + $this->_bottomPager = $this->createPager(); |
|
1003 | + } |
|
986 | 1004 | } |
987 | 1005 | } |
988 | 1006 | if(!$dsIndex && $this->_emptyTemplate !== null) |
@@ -1011,9 +1029,9 @@ discard block |
||
1011 | 1029 | $columns = new TList($this->getColumns()); |
1012 | 1030 | $autoColumns = $this->createAutoColumns($data); |
1013 | 1031 | $columns->mergeWith($autoColumns); |
1032 | + } else { |
|
1033 | + $columns = $this->getColumns(); |
|
1014 | 1034 | } |
1015 | - else |
|
1016 | - $columns = $this->getColumns(); |
|
1017 | 1035 | $this->_allColumns = $columns; |
1018 | 1036 | |
1019 | 1037 | $items = $this->getItems(); |
@@ -1024,31 +1042,35 @@ discard block |
||
1024 | 1042 | $this->setViewState('DataSourceIndex', $dsIndex, 0); |
1025 | 1043 | if($columns->getCount()) |
1026 | 1044 | { |
1027 | - foreach($columns as $column) |
|
1028 | - $column->initialize(); |
|
1045 | + foreach($columns as $column) { |
|
1046 | + $column->initialize(); |
|
1047 | + } |
|
1029 | 1048 | |
1030 | 1049 | $selectedIndex = $this->getSelectedItemIndex(); |
1031 | 1050 | $editIndex = $this->getEditItemIndex(); |
1032 | 1051 | foreach($data as $key => $row) |
1033 | 1052 | { |
1034 | - if($keyField !== '') |
|
1035 | - $keys->add($this->getDataFieldValue($row, $keyField)); |
|
1036 | - else |
|
1037 | - $keys->add($key); |
|
1053 | + if($keyField !== '') { |
|
1054 | + $keys->add($this->getDataFieldValue($row, $keyField)); |
|
1055 | + } else { |
|
1056 | + $keys->add($key); |
|
1057 | + } |
|
1038 | 1058 | if($index === 0) |
1039 | 1059 | { |
1040 | - if($allowPaging) |
|
1041 | - $this->_topPager = $this->createPager(); |
|
1060 | + if($allowPaging) { |
|
1061 | + $this->_topPager = $this->createPager(); |
|
1062 | + } |
|
1042 | 1063 | $this->_header = $this->createItemInternal(-1, -1, TListItemType::Header, true, null, $columns); |
1043 | 1064 | } |
1044 | - if($index === $editIndex) |
|
1045 | - $itemType = TListItemType::EditItem; |
|
1046 | - elseif($index === $selectedIndex) |
|
1047 | - $itemType = TListItemType::SelectedItem; |
|
1048 | - elseif($index % 2) |
|
1049 | - $itemType = TListItemType::AlternatingItem; |
|
1050 | - else |
|
1051 | - $itemType = TListItemType::Item; |
|
1065 | + if($index === $editIndex) { |
|
1066 | + $itemType = TListItemType::EditItem; |
|
1067 | + } elseif($index === $selectedIndex) { |
|
1068 | + $itemType = TListItemType::SelectedItem; |
|
1069 | + } elseif($index % 2) { |
|
1070 | + $itemType = TListItemType::AlternatingItem; |
|
1071 | + } else { |
|
1072 | + $itemType = TListItemType::Item; |
|
1073 | + } |
|
1052 | 1074 | $items->add($this->createItemInternal($index, $dsIndex, $itemType, true, $row, $columns)); |
1053 | 1075 | $index++; |
1054 | 1076 | $dsIndex++; |
@@ -1056,8 +1078,9 @@ discard block |
||
1056 | 1078 | if($index > 0) |
1057 | 1079 | { |
1058 | 1080 | $this->_footer = $this->createItemInternal(-1, -1, TListItemType::Footer, true, null, $columns); |
1059 | - if($allowPaging) |
|
1060 | - $this->_bottomPager = $this->createPager(); |
|
1081 | + if($allowPaging) { |
|
1082 | + $this->_bottomPager = $this->createPager(); |
|
1083 | + } |
|
1061 | 1084 | } |
1062 | 1085 | } |
1063 | 1086 | $this->setViewState('ItemCount', $index, 0); |
@@ -1075,21 +1098,24 @@ discard block |
||
1075 | 1098 | */ |
1076 | 1099 | private function groupCells() |
1077 | 1100 | { |
1078 | - if(($columns = $this->_allColumns) === null) |
|
1079 | - return; |
|
1101 | + if(($columns = $this->_allColumns) === null) { |
|
1102 | + return; |
|
1103 | + } |
|
1080 | 1104 | $items = $this->getItems(); |
1081 | 1105 | foreach($columns as $id => $column) |
1082 | 1106 | { |
1083 | - if(!$column->getEnableCellGrouping()) |
|
1084 | - continue; |
|
1107 | + if(!$column->getEnableCellGrouping()) { |
|
1108 | + continue; |
|
1109 | + } |
|
1085 | 1110 | $prevCell = null; |
1086 | 1111 | $prevCellText = null; |
1087 | 1112 | foreach($items as $item) |
1088 | 1113 | { |
1089 | 1114 | $itemType = $item->getItemType(); |
1090 | 1115 | $cell = $item->getCells()->itemAt($id); |
1091 | - if(!$cell->getVisible()) |
|
1092 | - continue; |
|
1116 | + if(!$cell->getVisible()) { |
|
1117 | + continue; |
|
1118 | + } |
|
1093 | 1119 | if($itemType === TListItemType::Item || $itemType === TListItemType::AlternatingItem || $itemType === TListItemType::SelectedItem) |
1094 | 1120 | { |
1095 | 1121 | if(($cellText = $this->getCellText($cell)) === '') |
@@ -1102,11 +1128,11 @@ discard block |
||
1102 | 1128 | { |
1103 | 1129 | $prevCell = $cell; |
1104 | 1130 | $prevCellText = $cellText; |
1105 | - } |
|
1106 | - else |
|
1131 | + } else |
|
1107 | 1132 | { |
1108 | - if(($rowSpan = $prevCell->getRowSpan()) === 0) |
|
1109 | - $rowSpan = 1; |
|
1133 | + if(($rowSpan = $prevCell->getRowSpan()) === 0) { |
|
1134 | + $rowSpan = 1; |
|
1135 | + } |
|
1110 | 1136 | $prevCell->setRowSpan($rowSpan + 1); |
1111 | 1137 | $cell->setVisible(false); |
1112 | 1138 | } |
@@ -1122,8 +1148,9 @@ discard block |
||
1122 | 1148 | $controls = $cell->getControls(); |
1123 | 1149 | foreach($controls as $control) |
1124 | 1150 | { |
1125 | - if($control instanceof \Prado\IDataRenderer) |
|
1126 | - return $control->getData(); |
|
1151 | + if($control instanceof \Prado\IDataRenderer) { |
|
1152 | + return $control->getData(); |
|
1153 | + } |
|
1127 | 1154 | } |
1128 | 1155 | } |
1129 | 1156 | return $data; |
@@ -1152,8 +1179,7 @@ discard block |
||
1152 | 1179 | $this->getControls()->add($item); |
1153 | 1180 | $item->dataBind(); |
1154 | 1181 | $this->onItemDataBound($param); |
1155 | - } |
|
1156 | - else |
|
1182 | + } else |
|
1157 | 1183 | { |
1158 | 1184 | $this->onItemCreated($param); |
1159 | 1185 | $this->getControls()->add($item); |
@@ -1173,12 +1199,14 @@ discard block |
||
1173 | 1199 | $index = 0; |
1174 | 1200 | foreach($columns as $column) |
1175 | 1201 | { |
1176 | - if($itemType === TListItemType::Header) |
|
1177 | - $cell = new TTableHeaderCell; |
|
1178 | - else |
|
1179 | - $cell = new TTableCell; |
|
1180 | - if(($id = $column->getID()) !== '') |
|
1181 | - $item->registerObject($id, $cell); |
|
1202 | + if($itemType === TListItemType::Header) { |
|
1203 | + $cell = new TTableHeaderCell; |
|
1204 | + } else { |
|
1205 | + $cell = new TTableCell; |
|
1206 | + } |
|
1207 | + if(($id = $column->getID()) !== '') { |
|
1208 | + $item->registerObject($id, $cell); |
|
1209 | + } |
|
1182 | 1210 | $cells->add($cell); |
1183 | 1211 | $column->initializeCell($cell, $index, $itemType); |
1184 | 1212 | $index++; |
@@ -1228,20 +1256,20 @@ discard block |
||
1228 | 1256 | { |
1229 | 1257 | if($buttonType === TDataGridPagerButtonType::LinkButton) |
1230 | 1258 | { |
1231 | - if($enabled) |
|
1232 | - $button = new TLinkButton; |
|
1233 | - else |
|
1259 | + if($enabled) { |
|
1260 | + $button = new TLinkButton; |
|
1261 | + } else |
|
1234 | 1262 | { |
1235 | 1263 | $button = new TLabel; |
1236 | 1264 | $button->setText($text); |
1237 | 1265 | return $button; |
1238 | 1266 | } |
1239 | - } |
|
1240 | - else |
|
1267 | + } else |
|
1241 | 1268 | { |
1242 | 1269 | $button = new TButton; |
1243 | - if(!$enabled) |
|
1244 | - $button->setEnabled(false); |
|
1270 | + if(!$enabled) { |
|
1271 | + $button->setEnabled(false); |
|
1272 | + } |
|
1245 | 1273 | } |
1246 | 1274 | $button->setText($text); |
1247 | 1275 | $button->setCommandName($commandName); |
@@ -1271,8 +1299,7 @@ discard block |
||
1271 | 1299 | |
1272 | 1300 | $label = $this->createPagerButton($pager, $buttonType, false, $style->getPrevPageText(), '', ''); |
1273 | 1301 | $controls->add($label); |
1274 | - } |
|
1275 | - else |
|
1302 | + } else |
|
1276 | 1303 | { |
1277 | 1304 | if(($text = $style->getFirstPageText()) !== '') |
1278 | 1305 | { |
@@ -1295,8 +1322,7 @@ discard block |
||
1295 | 1322 | $label = $this->createPagerButton($pager, $buttonType, false, $text, '', ''); |
1296 | 1323 | $controls->add($label); |
1297 | 1324 | } |
1298 | - } |
|
1299 | - else |
|
1325 | + } else |
|
1300 | 1326 | { |
1301 | 1327 | $button = $this->createPagerButton($pager, $buttonType, true, $style->getNextPageText(), self::CMD_PAGE, self::CMD_PAGE_NEXT); |
1302 | 1328 | $controls->add($button); |
@@ -1327,12 +1353,14 @@ discard block |
||
1327 | 1353 | if($pageIndex > $endPageIndex) |
1328 | 1354 | { |
1329 | 1355 | $startPageIndex = ((int)(($pageIndex - 1) / $maxButtonCount)) * $maxButtonCount + 1; |
1330 | - if(($endPageIndex = $startPageIndex + $maxButtonCount - 1) > $pageCount) |
|
1331 | - $endPageIndex = $pageCount; |
|
1356 | + if(($endPageIndex = $startPageIndex + $maxButtonCount - 1) > $pageCount) { |
|
1357 | + $endPageIndex = $pageCount; |
|
1358 | + } |
|
1332 | 1359 | if($endPageIndex - $startPageIndex + 1 < $maxButtonCount) |
1333 | 1360 | { |
1334 | - if(($startPageIndex = $endPageIndex - $maxButtonCount + 1) < 1) |
|
1335 | - $startPageIndex = 1; |
|
1361 | + if(($startPageIndex = $endPageIndex - $maxButtonCount + 1) < 1) { |
|
1362 | + $startPageIndex = 1; |
|
1363 | + } |
|
1336 | 1364 | } |
1337 | 1365 | } |
1338 | 1366 | |
@@ -1356,14 +1384,14 @@ discard block |
||
1356 | 1384 | { |
1357 | 1385 | $label = $this->createPagerButton($pager, $buttonType, false, "$i", '', ''); |
1358 | 1386 | $controls->add($label); |
1359 | - } |
|
1360 | - else |
|
1387 | + } else |
|
1361 | 1388 | { |
1362 | 1389 | $button = $this->createPagerButton($pager, $buttonType, true, "$i", self::CMD_PAGE, "$i"); |
1363 | 1390 | $controls->add($button); |
1364 | 1391 | } |
1365 | - if($i < $endPageIndex) |
|
1366 | - $controls->add("\n"); |
|
1392 | + if($i < $endPageIndex) { |
|
1393 | + $controls->add("\n"); |
|
1394 | + } |
|
1367 | 1395 | } |
1368 | 1396 | |
1369 | 1397 | if($pageCount > $endPageIndex) |
@@ -1388,8 +1416,9 @@ discard block |
||
1388 | 1416 | */ |
1389 | 1417 | protected function createAutoColumns($dataSource) |
1390 | 1418 | { |
1391 | - if(!$dataSource) |
|
1392 | - return null; |
|
1419 | + if(!$dataSource) { |
|
1420 | + return null; |
|
1421 | + } |
|
1393 | 1422 | $autoColumns = $this->getAutoColumns(); |
1394 | 1423 | $autoColumns->clear(); |
1395 | 1424 | foreach($dataSource as $row) |
@@ -1403,8 +1432,7 @@ discard block |
||
1403 | 1432 | $column->setDataField($key); |
1404 | 1433 | $column->setSortExpression($key); |
1405 | 1434 | $autoColumns->add($column); |
1406 | - } |
|
1407 | - else |
|
1435 | + } else |
|
1408 | 1436 | { |
1409 | 1437 | $column->setHeaderText(TListItemType::Item); |
1410 | 1438 | $column->setDataField($key); |
@@ -1435,10 +1463,11 @@ discard block |
||
1435 | 1463 | $alternatingItemStyle = $this->getViewState('AlternatingItemStyle', null); |
1436 | 1464 | if($itemStyle !== null) |
1437 | 1465 | { |
1438 | - if($alternatingItemStyle === null) |
|
1439 | - $alternatingItemStyle = $itemStyle; |
|
1440 | - else |
|
1441 | - $alternatingItemStyle->mergeWith($itemStyle); |
|
1466 | + if($alternatingItemStyle === null) { |
|
1467 | + $alternatingItemStyle = $itemStyle; |
|
1468 | + } else { |
|
1469 | + $alternatingItemStyle->mergeWith($itemStyle); |
|
1470 | + } |
|
1442 | 1471 | } |
1443 | 1472 | |
1444 | 1473 | $selectedItemStyle = $this->getViewState('SelectedItemStyle', null); |
@@ -1446,10 +1475,11 @@ discard block |
||
1446 | 1475 | $editItemStyle = $this->getViewState('EditItemStyle', null); |
1447 | 1476 | if($selectedItemStyle !== null) |
1448 | 1477 | { |
1449 | - if($editItemStyle === null) |
|
1450 | - $editItemStyle = $selectedItemStyle; |
|
1451 | - else |
|
1452 | - $editItemStyle->mergeWith($selectedItemStyle); |
|
1478 | + if($editItemStyle === null) { |
|
1479 | + $editItemStyle = $selectedItemStyle; |
|
1480 | + } else { |
|
1481 | + $editItemStyle->mergeWith($selectedItemStyle); |
|
1482 | + } |
|
1453 | 1483 | } |
1454 | 1484 | |
1455 | 1485 | $headerStyle = $this->getViewState('HeaderStyle', null); |
@@ -1459,61 +1489,73 @@ discard block |
||
1459 | 1489 | |
1460 | 1490 | foreach($this->getControls() as $index => $item) |
1461 | 1491 | { |
1462 | - if(!($item instanceof TDataGridItem) && !($item instanceof TDataGridPager)) |
|
1463 | - continue; |
|
1492 | + if(!($item instanceof TDataGridItem) && !($item instanceof TDataGridPager)) { |
|
1493 | + continue; |
|
1494 | + } |
|
1464 | 1495 | $itemType = $item->getItemType(); |
1465 | 1496 | switch($itemType) |
1466 | 1497 | { |
1467 | 1498 | case TListItemType::Header: |
1468 | - if($headerStyle) |
|
1469 | - $item->getStyle()->mergeWith($headerStyle); |
|
1470 | - if(!$this->getShowHeader()) |
|
1471 | - $item->setVisible(false); |
|
1499 | + if($headerStyle) { |
|
1500 | + $item->getStyle()->mergeWith($headerStyle); |
|
1501 | + } |
|
1502 | + if(!$this->getShowHeader()) { |
|
1503 | + $item->setVisible(false); |
|
1504 | + } |
|
1472 | 1505 | break; |
1473 | 1506 | case TListItemType::Footer: |
1474 | - if($footerStyle) |
|
1475 | - $item->getStyle()->mergeWith($footerStyle); |
|
1476 | - if(!$this->getShowFooter()) |
|
1477 | - $item->setVisible(false); |
|
1507 | + if($footerStyle) { |
|
1508 | + $item->getStyle()->mergeWith($footerStyle); |
|
1509 | + } |
|
1510 | + if(!$this->getShowFooter()) { |
|
1511 | + $item->setVisible(false); |
|
1512 | + } |
|
1478 | 1513 | break; |
1479 | 1514 | case TListItemType::Separator: |
1480 | - if($separatorStyle) |
|
1481 | - $item->getStyle()->mergeWith($separatorStyle); |
|
1515 | + if($separatorStyle) { |
|
1516 | + $item->getStyle()->mergeWith($separatorStyle); |
|
1517 | + } |
|
1482 | 1518 | break; |
1483 | 1519 | case TListItemType::Item: |
1484 | - if($itemStyle) |
|
1485 | - $item->getStyle()->mergeWith($itemStyle); |
|
1520 | + if($itemStyle) { |
|
1521 | + $item->getStyle()->mergeWith($itemStyle); |
|
1522 | + } |
|
1486 | 1523 | break; |
1487 | 1524 | case TListItemType::AlternatingItem: |
1488 | - if($alternatingItemStyle) |
|
1489 | - $item->getStyle()->mergeWith($alternatingItemStyle); |
|
1525 | + if($alternatingItemStyle) { |
|
1526 | + $item->getStyle()->mergeWith($alternatingItemStyle); |
|
1527 | + } |
|
1490 | 1528 | break; |
1491 | 1529 | case TListItemType::SelectedItem: |
1492 | - if($selectedItemStyle) |
|
1493 | - $item->getStyle()->mergeWith($selectedItemStyle); |
|
1530 | + if($selectedItemStyle) { |
|
1531 | + $item->getStyle()->mergeWith($selectedItemStyle); |
|
1532 | + } |
|
1494 | 1533 | if($index % 2 == 1) |
1495 | 1534 | { |
1496 | - if($itemStyle) |
|
1497 | - $item->getStyle()->mergeWith($itemStyle); |
|
1498 | - } |
|
1499 | - else |
|
1535 | + if($itemStyle) { |
|
1536 | + $item->getStyle()->mergeWith($itemStyle); |
|
1537 | + } |
|
1538 | + } else |
|
1500 | 1539 | { |
1501 | - if($alternatingItemStyle) |
|
1502 | - $item->getStyle()->mergeWith($alternatingItemStyle); |
|
1540 | + if($alternatingItemStyle) { |
|
1541 | + $item->getStyle()->mergeWith($alternatingItemStyle); |
|
1542 | + } |
|
1503 | 1543 | } |
1504 | 1544 | break; |
1505 | 1545 | case TListItemType::EditItem: |
1506 | - if($editItemStyle) |
|
1507 | - $item->getStyle()->mergeWith($editItemStyle); |
|
1546 | + if($editItemStyle) { |
|
1547 | + $item->getStyle()->mergeWith($editItemStyle); |
|
1548 | + } |
|
1508 | 1549 | if($index % 2 == 1) |
1509 | 1550 | { |
1510 | - if($itemStyle) |
|
1511 | - $item->getStyle()->mergeWith($itemStyle); |
|
1512 | - } |
|
1513 | - else |
|
1551 | + if($itemStyle) { |
|
1552 | + $item->getStyle()->mergeWith($itemStyle); |
|
1553 | + } |
|
1554 | + } else |
|
1514 | 1555 | { |
1515 | - if($alternatingItemStyle) |
|
1516 | - $item->getStyle()->mergeWith($alternatingItemStyle); |
|
1556 | + if($alternatingItemStyle) { |
|
1557 | + $item->getStyle()->mergeWith($alternatingItemStyle); |
|
1558 | + } |
|
1517 | 1559 | } |
1518 | 1560 | break; |
1519 | 1561 | case TListItemType::Pager: |
@@ -1522,13 +1564,14 @@ discard block |
||
1522 | 1564 | $item->getStyle()->mergeWith($pagerStyle); |
1523 | 1565 | if($index === 0) |
1524 | 1566 | { |
1525 | - if($pagerStyle->getPosition() === TDataGridPagerPosition::Bottom || !$pagerStyle->getVisible()) |
|
1526 | - $item->setVisible(false); |
|
1527 | - } |
|
1528 | - else |
|
1567 | + if($pagerStyle->getPosition() === TDataGridPagerPosition::Bottom || !$pagerStyle->getVisible()) { |
|
1568 | + $item->setVisible(false); |
|
1569 | + } |
|
1570 | + } else |
|
1529 | 1571 | { |
1530 | - if($pagerStyle->getPosition() === TDataGridPagerPosition::Top || !$pagerStyle->getVisible()) |
|
1531 | - $item->setVisible(false); |
|
1572 | + if($pagerStyle->getPosition() === TDataGridPagerPosition::Top || !$pagerStyle->getVisible()) { |
|
1573 | + $item->setVisible(false); |
|
1574 | + } |
|
1532 | 1575 | } |
1533 | 1576 | } |
1534 | 1577 | break; |
@@ -1543,18 +1586,20 @@ discard block |
||
1543 | 1586 | { |
1544 | 1587 | $cell = $cells->itemAt($i); |
1545 | 1588 | $column = $this->_columns->itemAt($i); |
1546 | - if(!$column->getVisible()) |
|
1547 | - $cell->setVisible(false); |
|
1548 | - else |
|
1589 | + if(!$column->getVisible()) { |
|
1590 | + $cell->setVisible(false); |
|
1591 | + } else |
|
1549 | 1592 | { |
1550 | - if($itemType === TListItemType::Header) |
|
1551 | - $style = $column->getHeaderStyle(false); |
|
1552 | - elseif($itemType === TListItemType::Footer) |
|
1553 | - $style = $column->getFooterStyle(false); |
|
1554 | - else |
|
1555 | - $style = $column->getItemStyle(false); |
|
1556 | - if($style !== null) |
|
1557 | - $cell->getStyle()->mergeWith($style); |
|
1593 | + if($itemType === TListItemType::Header) { |
|
1594 | + $style = $column->getHeaderStyle(false); |
|
1595 | + } elseif($itemType === TListItemType::Footer) { |
|
1596 | + $style = $column->getFooterStyle(false); |
|
1597 | + } else { |
|
1598 | + $style = $column->getItemStyle(false); |
|
1599 | + } |
|
1600 | + if($style !== null) { |
|
1601 | + $cell->getStyle()->mergeWith($style); |
|
1602 | + } |
|
1558 | 1603 | } |
1559 | 1604 | } |
1560 | 1605 | } |
@@ -1570,8 +1615,9 @@ discard block |
||
1570 | 1615 | parent::renderBeginTag($writer); |
1571 | 1616 | if(($caption = $this->getCaption()) !== '') |
1572 | 1617 | { |
1573 | - if(($align = $this->getCaptionAlign()) !== TTableCaptionAlign::NotSet) |
|
1574 | - $writer->addAttribute('align', strtolower($align)); |
|
1618 | + if(($align = $this->getCaptionAlign()) !== TTableCaptionAlign::NotSet) { |
|
1619 | + $writer->addAttribute('align', strtolower($align)); |
|
1620 | + } |
|
1575 | 1621 | $writer->renderBeginTag('caption'); |
1576 | 1622 | $writer->write($caption); |
1577 | 1623 | $writer->renderEndTag(); |
@@ -1592,13 +1638,13 @@ discard block |
||
1592 | 1638 | $control = new TWebControl; |
1593 | 1639 | $control->setID($this->getClientID()); |
1594 | 1640 | $control->copyBaseAttributes($this); |
1595 | - if($this->getHasStyle()) |
|
1596 | - $control->getStyle()->copyFrom($this->getStyle()); |
|
1641 | + if($this->getHasStyle()) { |
|
1642 | + $control->getStyle()->copyFrom($this->getStyle()); |
|
1643 | + } |
|
1597 | 1644 | $control->renderBeginTag($writer); |
1598 | 1645 | $this->renderContents($writer); |
1599 | 1646 | $control->renderEndTag($writer); |
1600 | - } |
|
1601 | - elseif($this->getViewState('ItemCount', 0) > 0) |
|
1647 | + } elseif($this->getViewState('ItemCount', 0) > 0) |
|
1602 | 1648 | { |
1603 | 1649 | $this->applyItemStyles(); |
1604 | 1650 | if($this->_topPager) |
@@ -1626,25 +1672,29 @@ discard block |
||
1626 | 1672 | if($this->_header && $this->_header->getVisible()) |
1627 | 1673 | { |
1628 | 1674 | $writer->writeLine(); |
1629 | - if($style = $this->getViewState('TableHeadStyle', null)) |
|
1630 | - $style->addAttributesToRender($writer); |
|
1675 | + if($style = $this->getViewState('TableHeadStyle', null)) { |
|
1676 | + $style->addAttributesToRender($writer); |
|
1677 | + } |
|
1631 | 1678 | $writer->renderBeginTag('thead'); |
1632 | 1679 | $this->_header->render($writer); |
1633 | 1680 | $writer->renderEndTag(); |
1634 | 1681 | } |
1635 | 1682 | $writer->writeLine(); |
1636 | - if($style = $this->getViewState('TableBodyStyle', null)) |
|
1637 | - $style->addAttributesToRender($writer); |
|
1683 | + if($style = $this->getViewState('TableBodyStyle', null)) { |
|
1684 | + $style->addAttributesToRender($writer); |
|
1685 | + } |
|
1638 | 1686 | $writer->renderBeginTag('tbody'); |
1639 | - foreach($this->getItems() as $item) |
|
1640 | - $item->renderControl($writer); |
|
1687 | + foreach($this->getItems() as $item) { |
|
1688 | + $item->renderControl($writer); |
|
1689 | + } |
|
1641 | 1690 | $writer->renderEndTag(); |
1642 | 1691 | |
1643 | 1692 | if($this->_footer && $this->_footer->getVisible()) |
1644 | 1693 | { |
1645 | 1694 | $writer->writeLine(); |
1646 | - if($style = $this->getViewState('TableFootStyle', null)) |
|
1647 | - $style->addAttributesToRender($writer); |
|
1695 | + if($style = $this->getViewState('TableFootStyle', null)) { |
|
1696 | + $style->addAttributesToRender($writer); |
|
1697 | + } |
|
1648 | 1698 | $writer->renderBeginTag('tfoot'); |
1649 | 1699 | $this->_footer->render($writer); |
1650 | 1700 | $writer->renderEndTag(); |
@@ -151,21 +151,21 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function evaluateIsValid() |
153 | 153 | { |
154 | - if(($value = $this->getValidationValue($this->getValidationTarget())) === '') |
|
154 | + if (($value = $this->getValidationValue($this->getValidationTarget())) === '') |
|
155 | 155 | return true; |
156 | 156 | |
157 | - if(($controlToCompare = $this->getControlToCompare()) !== '') |
|
157 | + if (($controlToCompare = $this->getControlToCompare()) !== '') |
|
158 | 158 | { |
159 | - if(($control2 = $this->findControl($controlToCompare)) === null) |
|
159 | + if (($control2 = $this->findControl($controlToCompare)) === null) |
|
160 | 160 | throw new TInvalidDataValueException('comparevalidator_controltocompare_invalid'); |
161 | - if(($value2 = $this->getValidationValue($control2)) === '') |
|
161 | + if (($value2 = $this->getValidationValue($control2)) === '') |
|
162 | 162 | return false; |
163 | 163 | } |
164 | 164 | else |
165 | 165 | $value2 = $this->getValueToCompare(); |
166 | 166 | |
167 | 167 | $values = $this->getComparisonValues($value, $value2); |
168 | - switch($this->getOperator()) |
|
168 | + switch ($this->getOperator()) |
|
169 | 169 | { |
170 | 170 | case TValidationCompareOperator::Equal: |
171 | 171 | return $values[0] == $values[1]; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | protected function getComparisonValues($value1, $value2) |
194 | 194 | { |
195 | - switch($this->getDataType()) |
|
195 | + switch ($this->getDataType()) |
|
196 | 196 | { |
197 | 197 | case TValidationDataType::Integer: |
198 | 198 | return [intval($value1), intval($value2)]; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | return [floatval($value1), floatval($value2)]; |
201 | 201 | case TValidationDataType::Date: |
202 | 202 | $dateFormat = $this->getDateFormat(); |
203 | - if($dateFormat !== '') |
|
203 | + if ($dateFormat !== '') |
|
204 | 204 | { |
205 | 205 | $formatter = new TSimpleDateFormatter($dateFormat); |
206 | 206 | return [$formatter->parse($value1), $formatter->parse($value2)]; |
@@ -218,17 +218,17 @@ discard block |
||
218 | 218 | protected function getClientScriptOptions() |
219 | 219 | { |
220 | 220 | $options = parent::getClientScriptOptions(); |
221 | - if(($name = $this->getControlToCompare()) !== '') |
|
221 | + if (($name = $this->getControlToCompare()) !== '') |
|
222 | 222 | { |
223 | - if(($control = $this->findControl($name)) !== null) |
|
223 | + if (($control = $this->findControl($name)) !== null) |
|
224 | 224 | $options['ControlToCompare'] = $control->getClientID(); |
225 | 225 | } |
226 | - if(($value = $this->getValueToCompare()) !== '') |
|
226 | + if (($value = $this->getValueToCompare()) !== '') |
|
227 | 227 | $options['ValueToCompare'] = $value; |
228 | - if(($operator = $this->getOperator()) !== TValidationCompareOperator::Equal) |
|
228 | + if (($operator = $this->getOperator()) !== TValidationCompareOperator::Equal) |
|
229 | 229 | $options['Operator'] = $operator; |
230 | 230 | $options['DataType'] = $this->getDataType(); |
231 | - if(($dateFormat = $this->getDateFormat()) !== '') |
|
231 | + if (($dateFormat = $this->getDateFormat()) !== '') |
|
232 | 232 | $options['DateFormat'] = $dateFormat; |
233 | 233 | return $options; |
234 | 234 | } |
@@ -151,18 +151,21 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function evaluateIsValid() |
153 | 153 | { |
154 | - if(($value = $this->getValidationValue($this->getValidationTarget())) === '') |
|
155 | - return true; |
|
154 | + if(($value = $this->getValidationValue($this->getValidationTarget())) === '') { |
|
155 | + return true; |
|
156 | + } |
|
156 | 157 | |
157 | 158 | if(($controlToCompare = $this->getControlToCompare()) !== '') |
158 | 159 | { |
159 | - if(($control2 = $this->findControl($controlToCompare)) === null) |
|
160 | - throw new TInvalidDataValueException('comparevalidator_controltocompare_invalid'); |
|
161 | - if(($value2 = $this->getValidationValue($control2)) === '') |
|
162 | - return false; |
|
160 | + if(($control2 = $this->findControl($controlToCompare)) === null) { |
|
161 | + throw new TInvalidDataValueException('comparevalidator_controltocompare_invalid'); |
|
162 | + } |
|
163 | + if(($value2 = $this->getValidationValue($control2)) === '') { |
|
164 | + return false; |
|
165 | + } |
|
166 | + } else { |
|
167 | + $value2 = $this->getValueToCompare(); |
|
163 | 168 | } |
164 | - else |
|
165 | - $value2 = $this->getValueToCompare(); |
|
166 | 169 | |
167 | 170 | $values = $this->getComparisonValues($value, $value2); |
168 | 171 | switch($this->getOperator()) |
@@ -204,9 +207,9 @@ discard block |
||
204 | 207 | { |
205 | 208 | $formatter = new TSimpleDateFormatter($dateFormat); |
206 | 209 | return [$formatter->parse($value1), $formatter->parse($value2)]; |
210 | + } else { |
|
211 | + return [strtotime($value1), strtotime($value2)]; |
|
207 | 212 | } |
208 | - else |
|
209 | - return [strtotime($value1), strtotime($value2)]; |
|
210 | 213 | } |
211 | 214 | return [$value1, $value2]; |
212 | 215 | } |
@@ -220,16 +223,20 @@ discard block |
||
220 | 223 | $options = parent::getClientScriptOptions(); |
221 | 224 | if(($name = $this->getControlToCompare()) !== '') |
222 | 225 | { |
223 | - if(($control = $this->findControl($name)) !== null) |
|
224 | - $options['ControlToCompare'] = $control->getClientID(); |
|
226 | + if(($control = $this->findControl($name)) !== null) { |
|
227 | + $options['ControlToCompare'] = $control->getClientID(); |
|
228 | + } |
|
229 | + } |
|
230 | + if(($value = $this->getValueToCompare()) !== '') { |
|
231 | + $options['ValueToCompare'] = $value; |
|
232 | + } |
|
233 | + if(($operator = $this->getOperator()) !== TValidationCompareOperator::Equal) { |
|
234 | + $options['Operator'] = $operator; |
|
225 | 235 | } |
226 | - if(($value = $this->getValueToCompare()) !== '') |
|
227 | - $options['ValueToCompare'] = $value; |
|
228 | - if(($operator = $this->getOperator()) !== TValidationCompareOperator::Equal) |
|
229 | - $options['Operator'] = $operator; |
|
230 | 236 | $options['DataType'] = $this->getDataType(); |
231 | - if(($dateFormat = $this->getDateFormat()) !== '') |
|
232 | - $options['DateFormat'] = $dateFormat; |
|
237 | + if(($dateFormat = $this->getDateFormat()) !== '') { |
|
238 | + $options['DateFormat'] = $dateFormat; |
|
239 | + } |
|
233 | 240 | return $options; |
234 | 241 | } |
235 | 242 | } |
236 | 243 | \ No newline at end of file |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function getHorizontalAlign() |
61 | 61 | { |
62 | - if($this->getHasStyle()) |
|
62 | + if ($this->getHasStyle()) |
|
63 | 63 | return $this->getStyle()->getHorizontalAlign(); |
64 | 64 | else |
65 | 65 | return 'NotSet'; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function getVerticalAlign() |
82 | 82 | { |
83 | - if($this->getHasStyle()) |
|
83 | + if ($this->getHasStyle()) |
|
84 | 84 | return $this->getStyle()->getVerticalAlign(); |
85 | 85 | else |
86 | 86 | return 'NotSet'; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function getWrap() |
137 | 137 | { |
138 | - if($this->getHasStyle()) |
|
138 | + if ($this->getHasStyle()) |
|
139 | 139 | return $this->getStyle()->getWrap(); |
140 | 140 | else |
141 | 141 | return true; |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | protected function addAttributesToRender($writer) |
202 | 202 | { |
203 | 203 | parent::addAttributesToRender($writer); |
204 | - if(($colspan = $this->getColumnSpan()) > 0) |
|
204 | + if (($colspan = $this->getColumnSpan()) > 0) |
|
205 | 205 | $writer->addAttribute('colspan', "$colspan"); |
206 | - if(($rowspan = $this->getRowSpan()) > 0) |
|
206 | + if (($rowspan = $this->getRowSpan()) > 0) |
|
207 | 207 | $writer->addAttribute('rowspan', "$rowspan"); |
208 | 208 | } |
209 | 209 | |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function renderContents($writer) |
215 | 215 | { |
216 | - if(($text = $this->getText()) !== '') |
|
216 | + if (($text = $this->getText()) !== '') |
|
217 | 217 | $writer->write($text); |
218 | - elseif($this->getHasControls()) |
|
218 | + elseif ($this->getHasControls()) |
|
219 | 219 | parent::renderContents($writer); |
220 | 220 | else |
221 | 221 | $writer->write(' '); |
@@ -59,10 +59,11 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function getHorizontalAlign() |
61 | 61 | { |
62 | - if($this->getHasStyle()) |
|
63 | - return $this->getStyle()->getHorizontalAlign(); |
|
64 | - else |
|
65 | - return 'NotSet'; |
|
62 | + if($this->getHasStyle()) { |
|
63 | + return $this->getStyle()->getHorizontalAlign(); |
|
64 | + } else { |
|
65 | + return 'NotSet'; |
|
66 | + } |
|
66 | 67 | } |
67 | 68 | |
68 | 69 | /** |
@@ -80,10 +81,11 @@ discard block |
||
80 | 81 | */ |
81 | 82 | public function getVerticalAlign() |
82 | 83 | { |
83 | - if($this->getHasStyle()) |
|
84 | - return $this->getStyle()->getVerticalAlign(); |
|
85 | - else |
|
86 | - return 'NotSet'; |
|
84 | + if($this->getHasStyle()) { |
|
85 | + return $this->getStyle()->getVerticalAlign(); |
|
86 | + } else { |
|
87 | + return 'NotSet'; |
|
88 | + } |
|
87 | 89 | } |
88 | 90 | |
89 | 91 | /** |
@@ -135,10 +137,11 @@ discard block |
||
135 | 137 | */ |
136 | 138 | public function getWrap() |
137 | 139 | { |
138 | - if($this->getHasStyle()) |
|
139 | - return $this->getStyle()->getWrap(); |
|
140 | - else |
|
141 | - return true; |
|
140 | + if($this->getHasStyle()) { |
|
141 | + return $this->getStyle()->getWrap(); |
|
142 | + } else { |
|
143 | + return true; |
|
144 | + } |
|
142 | 145 | } |
143 | 146 | |
144 | 147 | /** |
@@ -201,10 +204,12 @@ discard block |
||
201 | 204 | protected function addAttributesToRender($writer) |
202 | 205 | { |
203 | 206 | parent::addAttributesToRender($writer); |
204 | - if(($colspan = $this->getColumnSpan()) > 0) |
|
205 | - $writer->addAttribute('colspan', "$colspan"); |
|
206 | - if(($rowspan = $this->getRowSpan()) > 0) |
|
207 | - $writer->addAttribute('rowspan', "$rowspan"); |
|
207 | + if(($colspan = $this->getColumnSpan()) > 0) { |
|
208 | + $writer->addAttribute('colspan', "$colspan"); |
|
209 | + } |
|
210 | + if(($rowspan = $this->getRowSpan()) > 0) { |
|
211 | + $writer->addAttribute('rowspan', "$rowspan"); |
|
212 | + } |
|
208 | 213 | } |
209 | 214 | |
210 | 215 | /** |
@@ -213,12 +218,13 @@ discard block |
||
213 | 218 | */ |
214 | 219 | public function renderContents($writer) |
215 | 220 | { |
216 | - if(($text = $this->getText()) !== '') |
|
217 | - $writer->write($text); |
|
218 | - elseif($this->getHasControls()) |
|
219 | - parent::renderContents($writer); |
|
220 | - else |
|
221 | - $writer->write(' '); |
|
221 | + if(($text = $this->getText()) !== '') { |
|
222 | + $writer->write($text); |
|
223 | + } elseif($this->getHasControls()) { |
|
224 | + parent::renderContents($writer); |
|
225 | + } else { |
|
226 | + $writer->write(' '); |
|
227 | + } |
|
222 | 228 | } |
223 | 229 | } |
224 | 230 |