@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function addParsedObject($object) |
48 | 48 | { |
49 | - if($object instanceof THotSpot) |
|
49 | + if ($object instanceof THotSpot) |
|
50 | 50 | $this->getHotSpots()->add($object); |
51 | 51 | } |
52 | 52 | |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | protected function addAttributesToRender($writer) |
59 | 59 | { |
60 | 60 | parent::addAttributesToRender($writer); |
61 | - if($this->getHotSpots()->getCount() > 0) |
|
61 | + if ($this->getHotSpots()->getCount() > 0) |
|
62 | 62 | { |
63 | - $writer->addAttribute('usemap', '#' . self::MAP_NAME_PREFIX . $this->getClientID()); |
|
63 | + $writer->addAttribute('usemap', '#'.self::MAP_NAME_PREFIX.$this->getClientID()); |
|
64 | 64 | $writer->addAttribute('id', $this->getUniqueID()); |
65 | 65 | } |
66 | - if($this->getEnabled() && !$this->getEnabled(true)) |
|
66 | + if ($this->getEnabled() && !$this->getEnabled(true)) |
|
67 | 67 | $writer->addAttribute('disabled', 'disabled'); |
68 | 68 | } |
69 | 69 | |
@@ -77,32 +77,32 @@ discard block |
||
77 | 77 | |
78 | 78 | $hotspots = $this->getHotSpots(); |
79 | 79 | |
80 | - if($hotspots->getCount() > 0) |
|
80 | + if ($hotspots->getCount() > 0) |
|
81 | 81 | { |
82 | 82 | $clientID = $this->getClientID(); |
83 | 83 | $cs = $this->getPage()->getClientScript(); |
84 | 84 | $writer->writeLine(); |
85 | - $writer->addAttribute('name', self::MAP_NAME_PREFIX . $clientID); |
|
85 | + $writer->addAttribute('name', self::MAP_NAME_PREFIX.$clientID); |
|
86 | 86 | $writer->renderBeginTag('map'); |
87 | 87 | $writer->writeLine(); |
88 | - if(($mode = $this->getHotSpotMode()) === THotSpotMode::NotSet) |
|
88 | + if (($mode = $this->getHotSpotMode()) === THotSpotMode::NotSet) |
|
89 | 89 | $mode = THotSpotMode::Navigate; |
90 | 90 | $target = $this->getTarget(); |
91 | 91 | $i = 0; |
92 | 92 | $options['EventTarget'] = $this->getUniqueID(); |
93 | 93 | $options['StopEvent'] = true; |
94 | 94 | $cs = $this->getPage()->getClientScript(); |
95 | - foreach($hotspots as $hotspot) |
|
95 | + foreach ($hotspots as $hotspot) |
|
96 | 96 | { |
97 | - if($hotspot->getHotSpotMode() === THotSpotMode::NotSet) |
|
97 | + if ($hotspot->getHotSpotMode() === THotSpotMode::NotSet) |
|
98 | 98 | $hotspot->setHotSpotMode($mode); |
99 | - if($target !== '' && $hotspot->getTarget() === '') |
|
99 | + if ($target !== '' && $hotspot->getTarget() === '') |
|
100 | 100 | $hotspot->setTarget($target); |
101 | - if($hotspot->getHotSpotMode() === THotSpotMode::PostBack) |
|
101 | + if ($hotspot->getHotSpotMode() === THotSpotMode::PostBack) |
|
102 | 102 | { |
103 | - $id = $clientID . '_' . $i; |
|
103 | + $id = $clientID.'_'.$i; |
|
104 | 104 | $writer->addAttribute('id', $id); |
105 | - $writer->addAttribute('href', '#' . $id); //create unique no-op url references |
|
105 | + $writer->addAttribute('href', '#'.$id); //create unique no-op url references |
|
106 | 106 | $options['ID'] = $id; |
107 | 107 | $options['EventParameter'] = "$i"; |
108 | 108 | $options['CausesValidation'] = $hotspot->getCausesValidation(); |
@@ -136,24 +136,24 @@ discard block |
||
136 | 136 | public function raisePostBackEvent($param) |
137 | 137 | { |
138 | 138 | $postBackValue = null; |
139 | - if($param !== '') |
|
139 | + if ($param !== '') |
|
140 | 140 | { |
141 | 141 | $index = TPropertyValue::ensureInteger($param); |
142 | 142 | $hotspots = $this->getHotSpots(); |
143 | - if($index >= 0 && $index < $hotspots->getCount()) |
|
143 | + if ($index >= 0 && $index < $hotspots->getCount()) |
|
144 | 144 | { |
145 | 145 | $hotspot = $hotspots->itemAt($index); |
146 | - if(($mode = $hotspot->getHotSpotMode()) === THotSpotMode::NotSet) |
|
146 | + if (($mode = $hotspot->getHotSpotMode()) === THotSpotMode::NotSet) |
|
147 | 147 | $mode = $this->getHotSpotMode(); |
148 | - if($mode === THotSpotMode::PostBack) |
|
148 | + if ($mode === THotSpotMode::PostBack) |
|
149 | 149 | { |
150 | 150 | $postBackValue = $hotspot->getPostBackValue(); |
151 | - if($hotspot->getCausesValidation()) |
|
151 | + if ($hotspot->getCausesValidation()) |
|
152 | 152 | $this->getPage()->validate($hotspot->getValidationGroup()); |
153 | 153 | } |
154 | 154 | } |
155 | 155 | } |
156 | - if($postBackValue !== null) |
|
156 | + if ($postBackValue !== null) |
|
157 | 157 | $this->onClick(new TImageMapEventParameter($postBackValue)); |
158 | 158 | } |
159 | 159 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function getHotSpots() |
183 | 183 | { |
184 | - if(($hotspots = $this->getViewState('HotSpots', null)) === null) |
|
184 | + if (($hotspots = $this->getViewState('HotSpots', null)) === null) |
|
185 | 185 | { |
186 | 186 | $hotspots = new THotSpotCollection; |
187 | 187 | $this->setViewState('HotSpots', $hotspots); |
@@ -46,8 +46,9 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function addParsedObject($object) |
48 | 48 | { |
49 | - if($object instanceof THotSpot) |
|
50 | - $this->getHotSpots()->add($object); |
|
49 | + if($object instanceof THotSpot) { |
|
50 | + $this->getHotSpots()->add($object); |
|
51 | + } |
|
51 | 52 | } |
52 | 53 | |
53 | 54 | /** |
@@ -63,8 +64,9 @@ discard block |
||
63 | 64 | $writer->addAttribute('usemap', '#' . self::MAP_NAME_PREFIX . $this->getClientID()); |
64 | 65 | $writer->addAttribute('id', $this->getUniqueID()); |
65 | 66 | } |
66 | - if($this->getEnabled() && !$this->getEnabled(true)) |
|
67 | - $writer->addAttribute('disabled', 'disabled'); |
|
67 | + if($this->getEnabled() && !$this->getEnabled(true)) { |
|
68 | + $writer->addAttribute('disabled', 'disabled'); |
|
69 | + } |
|
68 | 70 | } |
69 | 71 | |
70 | 72 | /** |
@@ -85,8 +87,9 @@ discard block |
||
85 | 87 | $writer->addAttribute('name', self::MAP_NAME_PREFIX . $clientID); |
86 | 88 | $writer->renderBeginTag('map'); |
87 | 89 | $writer->writeLine(); |
88 | - if(($mode = $this->getHotSpotMode()) === THotSpotMode::NotSet) |
|
89 | - $mode = THotSpotMode::Navigate; |
|
90 | + if(($mode = $this->getHotSpotMode()) === THotSpotMode::NotSet) { |
|
91 | + $mode = THotSpotMode::Navigate; |
|
92 | + } |
|
90 | 93 | $target = $this->getTarget(); |
91 | 94 | $i = 0; |
92 | 95 | $options['EventTarget'] = $this->getUniqueID(); |
@@ -94,10 +97,12 @@ discard block |
||
94 | 97 | $cs = $this->getPage()->getClientScript(); |
95 | 98 | foreach($hotspots as $hotspot) |
96 | 99 | { |
97 | - if($hotspot->getHotSpotMode() === THotSpotMode::NotSet) |
|
98 | - $hotspot->setHotSpotMode($mode); |
|
99 | - if($target !== '' && $hotspot->getTarget() === '') |
|
100 | - $hotspot->setTarget($target); |
|
100 | + if($hotspot->getHotSpotMode() === THotSpotMode::NotSet) { |
|
101 | + $hotspot->setHotSpotMode($mode); |
|
102 | + } |
|
103 | + if($target !== '' && $hotspot->getTarget() === '') { |
|
104 | + $hotspot->setTarget($target); |
|
105 | + } |
|
101 | 106 | if($hotspot->getHotSpotMode() === THotSpotMode::PostBack) |
102 | 107 | { |
103 | 108 | $id = $clientID . '_' . $i; |
@@ -143,18 +148,21 @@ discard block |
||
143 | 148 | if($index >= 0 && $index < $hotspots->getCount()) |
144 | 149 | { |
145 | 150 | $hotspot = $hotspots->itemAt($index); |
146 | - if(($mode = $hotspot->getHotSpotMode()) === THotSpotMode::NotSet) |
|
147 | - $mode = $this->getHotSpotMode(); |
|
151 | + if(($mode = $hotspot->getHotSpotMode()) === THotSpotMode::NotSet) { |
|
152 | + $mode = $this->getHotSpotMode(); |
|
153 | + } |
|
148 | 154 | if($mode === THotSpotMode::PostBack) |
149 | 155 | { |
150 | 156 | $postBackValue = $hotspot->getPostBackValue(); |
151 | - if($hotspot->getCausesValidation()) |
|
152 | - $this->getPage()->validate($hotspot->getValidationGroup()); |
|
157 | + if($hotspot->getCausesValidation()) { |
|
158 | + $this->getPage()->validate($hotspot->getValidationGroup()); |
|
159 | + } |
|
153 | 160 | } |
154 | 161 | } |
155 | 162 | } |
156 | - if($postBackValue !== null) |
|
157 | - $this->onClick(new TImageMapEventParameter($postBackValue)); |
|
163 | + if($postBackValue !== null) { |
|
164 | + $this->onClick(new TImageMapEventParameter($postBackValue)); |
|
165 | + } |
|
158 | 166 | } |
159 | 167 | |
160 | 168 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function setRepeatColumns($value) |
102 | 102 | { |
103 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
103 | + if (($value = TPropertyValue::ensureInteger($value)) < 0) |
|
104 | 104 | throw new TInvalidDataValueException('repeatinfo_repeatcolumns_invalid'); |
105 | 105 | $this->_repeatColumns = $value; |
106 | 106 | } |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function renderRepeater($writer, IRepeatInfoUser $user) |
146 | 146 | { |
147 | - if($this->_repeatLayout === TRepeatLayout::Table) |
|
147 | + if ($this->_repeatLayout === TRepeatLayout::Table) |
|
148 | 148 | { |
149 | 149 | $control = new TTable; |
150 | - if($this->_caption !== '') |
|
150 | + if ($this->_caption !== '') |
|
151 | 151 | { |
152 | 152 | $control->setCaption($this->_caption); |
153 | 153 | $control->setCaptionAlign($this->_captionAlign); |
154 | 154 | } |
155 | 155 | } |
156 | - elseif($this->_repeatLayout === TRepeatLayout::Raw) |
|
156 | + elseif ($this->_repeatLayout === TRepeatLayout::Raw) |
|
157 | 157 | { |
158 | 158 | $this->renderRawContents($writer, $user); |
159 | 159 | return; |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | $control = new TWebControl; |
163 | 163 | $control->setID($user->getClientID()); |
164 | 164 | $control->copyBaseAttributes($user); |
165 | - if($user->getHasStyle()) |
|
165 | + if ($user->getHasStyle()) |
|
166 | 166 | $control->getStyle()->copyFrom($user->getStyle()); |
167 | 167 | $control->renderBeginTag($writer); |
168 | 168 | $writer->writeLine(); |
169 | 169 | |
170 | - if($this->_repeatDirection === TRepeatDirection::Vertical) |
|
170 | + if ($this->_repeatDirection === TRepeatDirection::Vertical) |
|
171 | 171 | $this->renderVerticalContents($writer, $user); |
172 | 172 | else |
173 | 173 | $this->renderHorizontalContents($writer, $user); |
@@ -182,19 +182,19 @@ discard block |
||
182 | 182 | */ |
183 | 183 | protected function renderRawContents($writer, $user) |
184 | 184 | { |
185 | - if($user->getHasHeader()) |
|
185 | + if ($user->getHasHeader()) |
|
186 | 186 | $user->renderItem($writer, $this, 'Header', -1); |
187 | 187 | |
188 | 188 | // render items |
189 | 189 | $hasSeparators = $user->getHasSeparators(); |
190 | 190 | $itemCount = $user->getItemCount(); |
191 | - for($i = 0;$i < $itemCount;++$i) |
|
191 | + for ($i = 0; $i < $itemCount; ++$i) |
|
192 | 192 | { |
193 | 193 | $user->renderItem($writer, $this, 'Item', $i); |
194 | - if($hasSeparators && $i != $itemCount - 1) |
|
194 | + if ($hasSeparators && $i != $itemCount - 1) |
|
195 | 195 | $user->renderItem($writer, $this, 'Separator', $i); |
196 | 196 | } |
197 | - if($user->getHasFooter()) |
|
197 | + if ($user->getHasFooter()) |
|
198 | 198 | $user->renderItem($writer, $this, 'Footer', -1); |
199 | 199 | } |
200 | 200 | |
@@ -208,31 +208,31 @@ discard block |
||
208 | 208 | $tableLayout = ($this->_repeatLayout === TRepeatLayout::Table); |
209 | 209 | $hasSeparators = $user->getHasSeparators(); |
210 | 210 | $itemCount = $user->getItemCount(); |
211 | - $columns = $this->_repeatColumns === 0?$itemCount:$this->_repeatColumns; |
|
212 | - $totalColumns = $hasSeparators?$columns + $columns:$columns; |
|
211 | + $columns = $this->_repeatColumns === 0 ? $itemCount : $this->_repeatColumns; |
|
212 | + $totalColumns = $hasSeparators ? $columns + $columns : $columns; |
|
213 | 213 | $needBreak = $columns < $itemCount; |
214 | 214 | |
215 | - if($user->getHasHeader()) |
|
215 | + if ($user->getHasHeader()) |
|
216 | 216 | $this->renderHeader($writer, $user, $tableLayout, $totalColumns, $needBreak); |
217 | 217 | |
218 | 218 | // render items |
219 | - if($tableLayout) |
|
219 | + if ($tableLayout) |
|
220 | 220 | { |
221 | 221 | $writer->renderBeginTag('tbody'); |
222 | 222 | $column = 0; |
223 | - for($i = 0;$i < $itemCount;++$i) |
|
223 | + for ($i = 0; $i < $itemCount; ++$i) |
|
224 | 224 | { |
225 | - if($column == 0) |
|
225 | + if ($column == 0) |
|
226 | 226 | $writer->renderBeginTag('tr'); |
227 | - if(($style = $user->generateItemStyle('Item', $i)) !== null) |
|
227 | + if (($style = $user->generateItemStyle('Item', $i)) !== null) |
|
228 | 228 | $style->addAttributesToRender($writer); |
229 | 229 | $writer->renderBeginTag('td'); |
230 | 230 | $user->renderItem($writer, $this, 'Item', $i); |
231 | 231 | $writer->renderEndTag(); |
232 | 232 | $writer->writeLine(); |
233 | - if($hasSeparators && $i != $itemCount - 1) |
|
233 | + if ($hasSeparators && $i != $itemCount - 1) |
|
234 | 234 | { |
235 | - if(($style = $user->generateItemStyle('Separator', $i)) !== null) |
|
235 | + if (($style = $user->generateItemStyle('Separator', $i)) !== null) |
|
236 | 236 | $style->addAttributesToRender($writer); |
237 | 237 | $writer->renderBeginTag('td'); |
238 | 238 | $user->renderItem($writer, $this, 'Separator', $i); |
@@ -240,15 +240,15 @@ discard block |
||
240 | 240 | $writer->writeLine(); |
241 | 241 | } |
242 | 242 | $column++; |
243 | - if($i == $itemCount - 1) |
|
243 | + if ($i == $itemCount - 1) |
|
244 | 244 | { |
245 | 245 | $restColumns = $columns - $column; |
246 | - if($hasSeparators) |
|
247 | - $restColumns = $restColumns?$restColumns + $restColumns + 1:1; |
|
248 | - for($j = 0;$j < $restColumns;++$j) |
|
246 | + if ($hasSeparators) |
|
247 | + $restColumns = $restColumns ? $restColumns + $restColumns + 1 : 1; |
|
248 | + for ($j = 0; $j < $restColumns; ++$j) |
|
249 | 249 | $writer->write("<td></td>\n"); |
250 | 250 | } |
251 | - if($column == $columns || $i == $itemCount - 1) |
|
251 | + if ($column == $columns || $i == $itemCount - 1) |
|
252 | 252 | { |
253 | 253 | $writer->renderEndTag(); |
254 | 254 | $writer->writeLine(); |
@@ -260,15 +260,15 @@ discard block |
||
260 | 260 | else |
261 | 261 | { |
262 | 262 | $column = 0; |
263 | - for($i = 0;$i < $itemCount;++$i) |
|
263 | + for ($i = 0; $i < $itemCount; ++$i) |
|
264 | 264 | { |
265 | 265 | $user->renderItem($writer, $this, 'Item', $i); |
266 | - if($hasSeparators && $i != $itemCount - 1) |
|
266 | + if ($hasSeparators && $i != $itemCount - 1) |
|
267 | 267 | $user->renderItem($writer, $this, 'Separator', $i); |
268 | 268 | $column++; |
269 | - if($column == $columns || $i == $itemCount - 1) |
|
269 | + if ($column == $columns || $i == $itemCount - 1) |
|
270 | 270 | { |
271 | - if($needBreak) |
|
271 | + if ($needBreak) |
|
272 | 272 | $writer->writeBreak(); |
273 | 273 | $column = 0; |
274 | 274 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | } |
277 | 277 | } |
278 | 278 | |
279 | - if($user->getHasFooter()) |
|
279 | + if ($user->getHasFooter()) |
|
280 | 280 | $this->renderFooter($writer, $user, $tableLayout, $totalColumns, $needBreak); |
281 | 281 | } |
282 | 282 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $tableLayout = ($this->_repeatLayout === TRepeatLayout::Table); |
291 | 291 | $hasSeparators = $user->getHasSeparators(); |
292 | 292 | $itemCount = $user->getItemCount(); |
293 | - if($this->_repeatColumns <= 1) |
|
293 | + if ($this->_repeatColumns <= 1) |
|
294 | 294 | { |
295 | 295 | $rows = $itemCount; |
296 | 296 | $columns = 1; |
@@ -299,69 +299,69 @@ discard block |
||
299 | 299 | else |
300 | 300 | { |
301 | 301 | $columns = $this->_repeatColumns; |
302 | - $rows = (int)(($itemCount + $columns - 1) / $columns); |
|
303 | - if($rows == 0 && $itemCount > 0) |
|
302 | + $rows = (int) (($itemCount + $columns - 1) / $columns); |
|
303 | + if ($rows == 0 && $itemCount > 0) |
|
304 | 304 | $rows = 1; |
305 | - if(($lastColumns = $itemCount % $columns) == 0) |
|
305 | + if (($lastColumns = $itemCount % $columns) == 0) |
|
306 | 306 | $lastColumns = $columns; |
307 | 307 | } |
308 | - $totalColumns = $hasSeparators?$columns + $columns:$columns; |
|
308 | + $totalColumns = $hasSeparators ? $columns + $columns : $columns; |
|
309 | 309 | |
310 | - if($user->getHasHeader()) |
|
310 | + if ($user->getHasHeader()) |
|
311 | 311 | $this->renderHeader($writer, $user, $tableLayout, $totalColumns, false); |
312 | 312 | |
313 | - if($tableLayout) |
|
313 | + if ($tableLayout) |
|
314 | 314 | { |
315 | 315 | $writer->renderBeginTag('tbody'); |
316 | 316 | $renderedItems = 0; |
317 | - for($row = 0;$row < $rows;++$row) |
|
317 | + for ($row = 0; $row < $rows; ++$row) |
|
318 | 318 | { |
319 | 319 | $index = $row; |
320 | 320 | $writer->renderBeginTag('tr'); |
321 | - for($col = 0;$col < $columns;++$col) |
|
321 | + for ($col = 0; $col < $columns; ++$col) |
|
322 | 322 | { |
323 | - if($renderedItems >= $itemCount) |
|
323 | + if ($renderedItems >= $itemCount) |
|
324 | 324 | break; |
325 | - if($col > 0) |
|
325 | + if ($col > 0) |
|
326 | 326 | { |
327 | 327 | $index += $rows; |
328 | - if($col - 1 >= $lastColumns) |
|
328 | + if ($col - 1 >= $lastColumns) |
|
329 | 329 | $index--; |
330 | 330 | } |
331 | - if($index >= $itemCount) |
|
331 | + if ($index >= $itemCount) |
|
332 | 332 | continue; |
333 | 333 | $renderedItems++; |
334 | - if(($style = $user->generateItemStyle('Item', $index)) !== null) |
|
334 | + if (($style = $user->generateItemStyle('Item', $index)) !== null) |
|
335 | 335 | $style->addAttributesToRender($writer); |
336 | 336 | $writer->renderBeginTag('td'); |
337 | 337 | $user->renderItem($writer, $this, 'Item', $index); |
338 | 338 | $writer->renderEndTag(); |
339 | 339 | $writer->writeLine(); |
340 | - if(!$hasSeparators) |
|
340 | + if (!$hasSeparators) |
|
341 | 341 | continue; |
342 | - if($renderedItems < $itemCount - 1) |
|
342 | + if ($renderedItems < $itemCount - 1) |
|
343 | 343 | { |
344 | - if($columns == 1) |
|
344 | + if ($columns == 1) |
|
345 | 345 | { |
346 | 346 | $writer->renderEndTag(); |
347 | 347 | $writer->renderBeginTag('tr'); |
348 | 348 | } |
349 | - if(($style = $user->generateItemStyle('Separator', $index)) !== null) |
|
349 | + if (($style = $user->generateItemStyle('Separator', $index)) !== null) |
|
350 | 350 | $style->addAttributesToRender($writer); |
351 | 351 | $writer->renderBeginTag('td'); |
352 | 352 | $user->renderItem($writer, $this, 'Separator', $index); |
353 | 353 | $writer->renderEndTag(); |
354 | 354 | $writer->writeLine(); |
355 | 355 | } |
356 | - elseif($columns > 1) |
|
356 | + elseif ($columns > 1) |
|
357 | 357 | $writer->write("<td></td>\n"); |
358 | 358 | } |
359 | - if($row == $rows - 1) |
|
359 | + if ($row == $rows - 1) |
|
360 | 360 | { |
361 | 361 | $restColumns = $columns - $lastColumns; |
362 | - if($hasSeparators) |
|
362 | + if ($hasSeparators) |
|
363 | 363 | $restColumns += $restColumns; |
364 | - for($col = 0;$col < $restColumns;++$col) |
|
364 | + for ($col = 0; $col < $restColumns; ++$col) |
|
365 | 365 | $writer->write("<td></td>\n"); |
366 | 366 | } |
367 | 367 | $writer->renderEndTag(); |
@@ -372,40 +372,40 @@ discard block |
||
372 | 372 | else |
373 | 373 | { |
374 | 374 | $renderedItems = 0; |
375 | - for($row = 0;$row < $rows;++$row) |
|
375 | + for ($row = 0; $row < $rows; ++$row) |
|
376 | 376 | { |
377 | 377 | $index = $row; |
378 | - for($col = 0;$col < $columns;++$col) |
|
378 | + for ($col = 0; $col < $columns; ++$col) |
|
379 | 379 | { |
380 | - if($renderedItems >= $itemCount) |
|
380 | + if ($renderedItems >= $itemCount) |
|
381 | 381 | break; |
382 | - if($col > 0) |
|
382 | + if ($col > 0) |
|
383 | 383 | { |
384 | 384 | $index += $rows; |
385 | - if($col - 1 >= $lastColumns) |
|
385 | + if ($col - 1 >= $lastColumns) |
|
386 | 386 | $index--; |
387 | 387 | } |
388 | - if($index >= $itemCount) |
|
388 | + if ($index >= $itemCount) |
|
389 | 389 | continue; |
390 | 390 | $renderedItems++; |
391 | 391 | $user->renderItem($writer, $this, 'Item', $index); |
392 | 392 | $writer->writeLine(); |
393 | - if(!$hasSeparators) |
|
393 | + if (!$hasSeparators) |
|
394 | 394 | continue; |
395 | - if($renderedItems < $itemCount - 1) |
|
395 | + if ($renderedItems < $itemCount - 1) |
|
396 | 396 | { |
397 | - if($columns == 1) |
|
397 | + if ($columns == 1) |
|
398 | 398 | $writer->writeBreak(); |
399 | 399 | $user->renderItem($writer, $this, 'Separator', $index); |
400 | 400 | } |
401 | 401 | $writer->writeLine(); |
402 | 402 | } |
403 | - if($row < $rows - 1 || $user->getHasFooter()) |
|
403 | + if ($row < $rows - 1 || $user->getHasFooter()) |
|
404 | 404 | $writer->writeBreak(); |
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
408 | - if($user->getHasFooter()) |
|
408 | + if ($user->getHasFooter()) |
|
409 | 409 | $this->renderFooter($writer, $user, $tableLayout, $totalColumns, false); |
410 | 410 | |
411 | 411 | } |
@@ -420,14 +420,14 @@ discard block |
||
420 | 420 | */ |
421 | 421 | protected function renderHeader($writer, $user, $tableLayout, $columns, $needBreak) |
422 | 422 | { |
423 | - if($tableLayout) |
|
423 | + if ($tableLayout) |
|
424 | 424 | { |
425 | 425 | $writer->renderBeginTag('thead'); |
426 | 426 | $writer->renderBeginTag('tr'); |
427 | - if($columns > 1) |
|
427 | + if ($columns > 1) |
|
428 | 428 | $writer->addAttribute('colspan', "$columns"); |
429 | 429 | $writer->addAttribute('scope', 'col'); |
430 | - if(($style = $user->generateItemStyle('Header', -1)) !== null) |
|
430 | + if (($style = $user->generateItemStyle('Header', -1)) !== null) |
|
431 | 431 | $style->addAttributesToRender($writer); |
432 | 432 | $writer->renderBeginTag('th'); |
433 | 433 | $user->renderItem($writer, $this, 'Header', -1); |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | else |
439 | 439 | { |
440 | 440 | $user->renderItem($writer, $this, 'Header', -1); |
441 | - if($needBreak) |
|
441 | + if ($needBreak) |
|
442 | 442 | $writer->writeBreak(); |
443 | 443 | } |
444 | 444 | $writer->writeLine(); |
@@ -453,13 +453,13 @@ discard block |
||
453 | 453 | */ |
454 | 454 | protected function renderFooter($writer, $user, $tableLayout, $columns) |
455 | 455 | { |
456 | - if($tableLayout) |
|
456 | + if ($tableLayout) |
|
457 | 457 | { |
458 | 458 | $writer->renderBeginTag('tfoot'); |
459 | 459 | $writer->renderBeginTag('tr'); |
460 | - if($columns > 1) |
|
460 | + if ($columns > 1) |
|
461 | 461 | $writer->addAttribute('colspan', "$columns"); |
462 | - if(($style = $user->generateItemStyle('Footer', -1)) !== null) |
|
462 | + if (($style = $user->generateItemStyle('Footer', -1)) !== null) |
|
463 | 463 | $style->addAttributesToRender($writer); |
464 | 464 | $writer->renderBeginTag('td'); |
465 | 465 | $user->renderItem($writer, $this, 'Footer', -1); |
@@ -100,8 +100,9 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function setRepeatColumns($value) |
102 | 102 | { |
103 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
104 | - throw new TInvalidDataValueException('repeatinfo_repeatcolumns_invalid'); |
|
103 | + if(($value = TPropertyValue::ensureInteger($value)) < 0) { |
|
104 | + throw new TInvalidDataValueException('repeatinfo_repeatcolumns_invalid'); |
|
105 | + } |
|
105 | 106 | $this->_repeatColumns = $value; |
106 | 107 | } |
107 | 108 | |
@@ -152,25 +153,26 @@ discard block |
||
152 | 153 | $control->setCaption($this->_caption); |
153 | 154 | $control->setCaptionAlign($this->_captionAlign); |
154 | 155 | } |
155 | - } |
|
156 | - elseif($this->_repeatLayout === TRepeatLayout::Raw) |
|
156 | + } elseif($this->_repeatLayout === TRepeatLayout::Raw) |
|
157 | 157 | { |
158 | 158 | $this->renderRawContents($writer, $user); |
159 | 159 | return; |
160 | + } else { |
|
161 | + $control = new TWebControl; |
|
160 | 162 | } |
161 | - else |
|
162 | - $control = new TWebControl; |
|
163 | 163 | $control->setID($user->getClientID()); |
164 | 164 | $control->copyBaseAttributes($user); |
165 | - if($user->getHasStyle()) |
|
166 | - $control->getStyle()->copyFrom($user->getStyle()); |
|
165 | + if($user->getHasStyle()) { |
|
166 | + $control->getStyle()->copyFrom($user->getStyle()); |
|
167 | + } |
|
167 | 168 | $control->renderBeginTag($writer); |
168 | 169 | $writer->writeLine(); |
169 | 170 | |
170 | - if($this->_repeatDirection === TRepeatDirection::Vertical) |
|
171 | - $this->renderVerticalContents($writer, $user); |
|
172 | - else |
|
173 | - $this->renderHorizontalContents($writer, $user); |
|
171 | + if($this->_repeatDirection === TRepeatDirection::Vertical) { |
|
172 | + $this->renderVerticalContents($writer, $user); |
|
173 | + } else { |
|
174 | + $this->renderHorizontalContents($writer, $user); |
|
175 | + } |
|
174 | 176 | |
175 | 177 | $control->renderEndTag($writer); |
176 | 178 | } |
@@ -182,8 +184,9 @@ discard block |
||
182 | 184 | */ |
183 | 185 | protected function renderRawContents($writer, $user) |
184 | 186 | { |
185 | - if($user->getHasHeader()) |
|
186 | - $user->renderItem($writer, $this, 'Header', -1); |
|
187 | + if($user->getHasHeader()) { |
|
188 | + $user->renderItem($writer, $this, 'Header', -1); |
|
189 | + } |
|
187 | 190 | |
188 | 191 | // render items |
189 | 192 | $hasSeparators = $user->getHasSeparators(); |
@@ -191,11 +194,13 @@ discard block |
||
191 | 194 | for($i = 0;$i < $itemCount;++$i) |
192 | 195 | { |
193 | 196 | $user->renderItem($writer, $this, 'Item', $i); |
194 | - if($hasSeparators && $i != $itemCount - 1) |
|
195 | - $user->renderItem($writer, $this, 'Separator', $i); |
|
197 | + if($hasSeparators && $i != $itemCount - 1) { |
|
198 | + $user->renderItem($writer, $this, 'Separator', $i); |
|
199 | + } |
|
200 | + } |
|
201 | + if($user->getHasFooter()) { |
|
202 | + $user->renderItem($writer, $this, 'Footer', -1); |
|
196 | 203 | } |
197 | - if($user->getHasFooter()) |
|
198 | - $user->renderItem($writer, $this, 'Footer', -1); |
|
199 | 204 | } |
200 | 205 | |
201 | 206 | /** |
@@ -212,8 +217,9 @@ discard block |
||
212 | 217 | $totalColumns = $hasSeparators?$columns + $columns:$columns; |
213 | 218 | $needBreak = $columns < $itemCount; |
214 | 219 | |
215 | - if($user->getHasHeader()) |
|
216 | - $this->renderHeader($writer, $user, $tableLayout, $totalColumns, $needBreak); |
|
220 | + if($user->getHasHeader()) { |
|
221 | + $this->renderHeader($writer, $user, $tableLayout, $totalColumns, $needBreak); |
|
222 | + } |
|
217 | 223 | |
218 | 224 | // render items |
219 | 225 | if($tableLayout) |
@@ -222,18 +228,21 @@ discard block |
||
222 | 228 | $column = 0; |
223 | 229 | for($i = 0;$i < $itemCount;++$i) |
224 | 230 | { |
225 | - if($column == 0) |
|
226 | - $writer->renderBeginTag('tr'); |
|
227 | - if(($style = $user->generateItemStyle('Item', $i)) !== null) |
|
228 | - $style->addAttributesToRender($writer); |
|
231 | + if($column == 0) { |
|
232 | + $writer->renderBeginTag('tr'); |
|
233 | + } |
|
234 | + if(($style = $user->generateItemStyle('Item', $i)) !== null) { |
|
235 | + $style->addAttributesToRender($writer); |
|
236 | + } |
|
229 | 237 | $writer->renderBeginTag('td'); |
230 | 238 | $user->renderItem($writer, $this, 'Item', $i); |
231 | 239 | $writer->renderEndTag(); |
232 | 240 | $writer->writeLine(); |
233 | 241 | if($hasSeparators && $i != $itemCount - 1) |
234 | 242 | { |
235 | - if(($style = $user->generateItemStyle('Separator', $i)) !== null) |
|
236 | - $style->addAttributesToRender($writer); |
|
243 | + if(($style = $user->generateItemStyle('Separator', $i)) !== null) { |
|
244 | + $style->addAttributesToRender($writer); |
|
245 | + } |
|
237 | 246 | $writer->renderBeginTag('td'); |
238 | 247 | $user->renderItem($writer, $this, 'Separator', $i); |
239 | 248 | $writer->renderEndTag(); |
@@ -243,10 +252,12 @@ discard block |
||
243 | 252 | if($i == $itemCount - 1) |
244 | 253 | { |
245 | 254 | $restColumns = $columns - $column; |
246 | - if($hasSeparators) |
|
247 | - $restColumns = $restColumns?$restColumns + $restColumns + 1:1; |
|
248 | - for($j = 0;$j < $restColumns;++$j) |
|
249 | - $writer->write("<td></td>\n"); |
|
255 | + if($hasSeparators) { |
|
256 | + $restColumns = $restColumns?$restColumns + $restColumns + 1:1; |
|
257 | + } |
|
258 | + for($j = 0;$j < $restColumns;++$j) { |
|
259 | + $writer->write("<td></td>\n"); |
|
260 | + } |
|
250 | 261 | } |
251 | 262 | if($column == $columns || $i == $itemCount - 1) |
252 | 263 | { |
@@ -256,28 +267,30 @@ discard block |
||
256 | 267 | } |
257 | 268 | } |
258 | 269 | $writer->renderEndTag(); |
259 | - } |
|
260 | - else |
|
270 | + } else |
|
261 | 271 | { |
262 | 272 | $column = 0; |
263 | 273 | for($i = 0;$i < $itemCount;++$i) |
264 | 274 | { |
265 | 275 | $user->renderItem($writer, $this, 'Item', $i); |
266 | - if($hasSeparators && $i != $itemCount - 1) |
|
267 | - $user->renderItem($writer, $this, 'Separator', $i); |
|
276 | + if($hasSeparators && $i != $itemCount - 1) { |
|
277 | + $user->renderItem($writer, $this, 'Separator', $i); |
|
278 | + } |
|
268 | 279 | $column++; |
269 | 280 | if($column == $columns || $i == $itemCount - 1) |
270 | 281 | { |
271 | - if($needBreak) |
|
272 | - $writer->writeBreak(); |
|
282 | + if($needBreak) { |
|
283 | + $writer->writeBreak(); |
|
284 | + } |
|
273 | 285 | $column = 0; |
274 | 286 | } |
275 | 287 | $writer->writeLine(); |
276 | 288 | } |
277 | 289 | } |
278 | 290 | |
279 | - if($user->getHasFooter()) |
|
280 | - $this->renderFooter($writer, $user, $tableLayout, $totalColumns, $needBreak); |
|
291 | + if($user->getHasFooter()) { |
|
292 | + $this->renderFooter($writer, $user, $tableLayout, $totalColumns, $needBreak); |
|
293 | + } |
|
281 | 294 | } |
282 | 295 | |
283 | 296 | /** |
@@ -295,20 +308,22 @@ discard block |
||
295 | 308 | $rows = $itemCount; |
296 | 309 | $columns = 1; |
297 | 310 | $lastColumns = 1; |
298 | - } |
|
299 | - else |
|
311 | + } else |
|
300 | 312 | { |
301 | 313 | $columns = $this->_repeatColumns; |
302 | 314 | $rows = (int)(($itemCount + $columns - 1) / $columns); |
303 | - if($rows == 0 && $itemCount > 0) |
|
304 | - $rows = 1; |
|
305 | - if(($lastColumns = $itemCount % $columns) == 0) |
|
306 | - $lastColumns = $columns; |
|
315 | + if($rows == 0 && $itemCount > 0) { |
|
316 | + $rows = 1; |
|
317 | + } |
|
318 | + if(($lastColumns = $itemCount % $columns) == 0) { |
|
319 | + $lastColumns = $columns; |
|
320 | + } |
|
307 | 321 | } |
308 | 322 | $totalColumns = $hasSeparators?$columns + $columns:$columns; |
309 | 323 | |
310 | - if($user->getHasHeader()) |
|
311 | - $this->renderHeader($writer, $user, $tableLayout, $totalColumns, false); |
|
324 | + if($user->getHasHeader()) { |
|
325 | + $this->renderHeader($writer, $user, $tableLayout, $totalColumns, false); |
|
326 | + } |
|
312 | 327 | |
313 | 328 | if($tableLayout) |
314 | 329 | { |
@@ -320,25 +335,30 @@ discard block |
||
320 | 335 | $writer->renderBeginTag('tr'); |
321 | 336 | for($col = 0;$col < $columns;++$col) |
322 | 337 | { |
323 | - if($renderedItems >= $itemCount) |
|
324 | - break; |
|
338 | + if($renderedItems >= $itemCount) { |
|
339 | + break; |
|
340 | + } |
|
325 | 341 | if($col > 0) |
326 | 342 | { |
327 | 343 | $index += $rows; |
328 | - if($col - 1 >= $lastColumns) |
|
329 | - $index--; |
|
344 | + if($col - 1 >= $lastColumns) { |
|
345 | + $index--; |
|
346 | + } |
|
347 | + } |
|
348 | + if($index >= $itemCount) { |
|
349 | + continue; |
|
330 | 350 | } |
331 | - if($index >= $itemCount) |
|
332 | - continue; |
|
333 | 351 | $renderedItems++; |
334 | - if(($style = $user->generateItemStyle('Item', $index)) !== null) |
|
335 | - $style->addAttributesToRender($writer); |
|
352 | + if(($style = $user->generateItemStyle('Item', $index)) !== null) { |
|
353 | + $style->addAttributesToRender($writer); |
|
354 | + } |
|
336 | 355 | $writer->renderBeginTag('td'); |
337 | 356 | $user->renderItem($writer, $this, 'Item', $index); |
338 | 357 | $writer->renderEndTag(); |
339 | 358 | $writer->writeLine(); |
340 | - if(!$hasSeparators) |
|
341 | - continue; |
|
359 | + if(!$hasSeparators) { |
|
360 | + continue; |
|
361 | + } |
|
342 | 362 | if($renderedItems < $itemCount - 1) |
343 | 363 | { |
344 | 364 | if($columns == 1) |
@@ -346,30 +366,32 @@ discard block |
||
346 | 366 | $writer->renderEndTag(); |
347 | 367 | $writer->renderBeginTag('tr'); |
348 | 368 | } |
349 | - if(($style = $user->generateItemStyle('Separator', $index)) !== null) |
|
350 | - $style->addAttributesToRender($writer); |
|
369 | + if(($style = $user->generateItemStyle('Separator', $index)) !== null) { |
|
370 | + $style->addAttributesToRender($writer); |
|
371 | + } |
|
351 | 372 | $writer->renderBeginTag('td'); |
352 | 373 | $user->renderItem($writer, $this, 'Separator', $index); |
353 | 374 | $writer->renderEndTag(); |
354 | 375 | $writer->writeLine(); |
376 | + } elseif($columns > 1) { |
|
377 | + $writer->write("<td></td>\n"); |
|
355 | 378 | } |
356 | - elseif($columns > 1) |
|
357 | - $writer->write("<td></td>\n"); |
|
358 | 379 | } |
359 | 380 | if($row == $rows - 1) |
360 | 381 | { |
361 | 382 | $restColumns = $columns - $lastColumns; |
362 | - if($hasSeparators) |
|
363 | - $restColumns += $restColumns; |
|
364 | - for($col = 0;$col < $restColumns;++$col) |
|
365 | - $writer->write("<td></td>\n"); |
|
383 | + if($hasSeparators) { |
|
384 | + $restColumns += $restColumns; |
|
385 | + } |
|
386 | + for($col = 0;$col < $restColumns;++$col) { |
|
387 | + $writer->write("<td></td>\n"); |
|
388 | + } |
|
366 | 389 | } |
367 | 390 | $writer->renderEndTag(); |
368 | 391 | $writer->writeLine(); |
369 | 392 | } |
370 | 393 | $writer->renderEndTag(); |
371 | - } |
|
372 | - else |
|
394 | + } else |
|
373 | 395 | { |
374 | 396 | $renderedItems = 0; |
375 | 397 | for($row = 0;$row < $rows;++$row) |
@@ -377,36 +399,43 @@ discard block |
||
377 | 399 | $index = $row; |
378 | 400 | for($col = 0;$col < $columns;++$col) |
379 | 401 | { |
380 | - if($renderedItems >= $itemCount) |
|
381 | - break; |
|
402 | + if($renderedItems >= $itemCount) { |
|
403 | + break; |
|
404 | + } |
|
382 | 405 | if($col > 0) |
383 | 406 | { |
384 | 407 | $index += $rows; |
385 | - if($col - 1 >= $lastColumns) |
|
386 | - $index--; |
|
408 | + if($col - 1 >= $lastColumns) { |
|
409 | + $index--; |
|
410 | + } |
|
411 | + } |
|
412 | + if($index >= $itemCount) { |
|
413 | + continue; |
|
387 | 414 | } |
388 | - if($index >= $itemCount) |
|
389 | - continue; |
|
390 | 415 | $renderedItems++; |
391 | 416 | $user->renderItem($writer, $this, 'Item', $index); |
392 | 417 | $writer->writeLine(); |
393 | - if(!$hasSeparators) |
|
394 | - continue; |
|
418 | + if(!$hasSeparators) { |
|
419 | + continue; |
|
420 | + } |
|
395 | 421 | if($renderedItems < $itemCount - 1) |
396 | 422 | { |
397 | - if($columns == 1) |
|
398 | - $writer->writeBreak(); |
|
423 | + if($columns == 1) { |
|
424 | + $writer->writeBreak(); |
|
425 | + } |
|
399 | 426 | $user->renderItem($writer, $this, 'Separator', $index); |
400 | 427 | } |
401 | 428 | $writer->writeLine(); |
402 | 429 | } |
403 | - if($row < $rows - 1 || $user->getHasFooter()) |
|
404 | - $writer->writeBreak(); |
|
430 | + if($row < $rows - 1 || $user->getHasFooter()) { |
|
431 | + $writer->writeBreak(); |
|
432 | + } |
|
405 | 433 | } |
406 | 434 | } |
407 | 435 | |
408 | - if($user->getHasFooter()) |
|
409 | - $this->renderFooter($writer, $user, $tableLayout, $totalColumns, false); |
|
436 | + if($user->getHasFooter()) { |
|
437 | + $this->renderFooter($writer, $user, $tableLayout, $totalColumns, false); |
|
438 | + } |
|
410 | 439 | |
411 | 440 | } |
412 | 441 | |
@@ -424,22 +453,24 @@ discard block |
||
424 | 453 | { |
425 | 454 | $writer->renderBeginTag('thead'); |
426 | 455 | $writer->renderBeginTag('tr'); |
427 | - if($columns > 1) |
|
428 | - $writer->addAttribute('colspan', "$columns"); |
|
456 | + if($columns > 1) { |
|
457 | + $writer->addAttribute('colspan', "$columns"); |
|
458 | + } |
|
429 | 459 | $writer->addAttribute('scope', 'col'); |
430 | - if(($style = $user->generateItemStyle('Header', -1)) !== null) |
|
431 | - $style->addAttributesToRender($writer); |
|
460 | + if(($style = $user->generateItemStyle('Header', -1)) !== null) { |
|
461 | + $style->addAttributesToRender($writer); |
|
462 | + } |
|
432 | 463 | $writer->renderBeginTag('th'); |
433 | 464 | $user->renderItem($writer, $this, 'Header', -1); |
434 | 465 | $writer->renderEndTag(); |
435 | 466 | $writer->renderEndTag(); |
436 | 467 | $writer->renderEndTag(); |
437 | - } |
|
438 | - else |
|
468 | + } else |
|
439 | 469 | { |
440 | 470 | $user->renderItem($writer, $this, 'Header', -1); |
441 | - if($needBreak) |
|
442 | - $writer->writeBreak(); |
|
471 | + if($needBreak) { |
|
472 | + $writer->writeBreak(); |
|
473 | + } |
|
443 | 474 | } |
444 | 475 | $writer->writeLine(); |
445 | 476 | } |
@@ -457,18 +488,20 @@ discard block |
||
457 | 488 | { |
458 | 489 | $writer->renderBeginTag('tfoot'); |
459 | 490 | $writer->renderBeginTag('tr'); |
460 | - if($columns > 1) |
|
461 | - $writer->addAttribute('colspan', "$columns"); |
|
462 | - if(($style = $user->generateItemStyle('Footer', -1)) !== null) |
|
463 | - $style->addAttributesToRender($writer); |
|
491 | + if($columns > 1) { |
|
492 | + $writer->addAttribute('colspan', "$columns"); |
|
493 | + } |
|
494 | + if(($style = $user->generateItemStyle('Footer', -1)) !== null) { |
|
495 | + $style->addAttributesToRender($writer); |
|
496 | + } |
|
464 | 497 | $writer->renderBeginTag('td'); |
465 | 498 | $user->renderItem($writer, $this, 'Footer', -1); |
466 | 499 | $writer->renderEndTag(); |
467 | 500 | $writer->renderEndTag(); |
468 | 501 | $writer->renderEndTag(); |
502 | + } else { |
|
503 | + $user->renderItem($writer, $this, 'Footer', -1); |
|
469 | 504 | } |
470 | - else |
|
471 | - $user->renderItem($writer, $this, 'Footer', -1); |
|
472 | 505 | $writer->writeLine(); |
473 | 506 | } |
474 | 507 | } |
475 | 508 | \ No newline at end of file |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function setID($value) |
91 | 91 | { |
92 | - if(!preg_match(TControl::ID_FORMAT, $value)) |
|
92 | + if (!preg_match(TControl::ID_FORMAT, $value)) |
|
93 | 93 | throw new TInvalidDataValueException('datagridcolumn_id_invalid', get_class($this), $value); |
94 | 94 | $this->_id = $value; |
95 | 95 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function getHeaderStyle($createStyle = true) |
158 | 158 | { |
159 | - if(($style = $this->getViewState('HeaderStyle', null)) === null && $createStyle) |
|
159 | + if (($style = $this->getViewState('HeaderStyle', null)) === null && $createStyle) |
|
160 | 160 | { |
161 | 161 | $style = new TTableItemStyle; |
162 | 162 | $this->setViewState('HeaderStyle', $style, null); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function getFooterStyle($createStyle = true) |
212 | 212 | { |
213 | - if(($style = $this->getViewState('FooterStyle', null)) === null && $createStyle) |
|
213 | + if (($style = $this->getViewState('FooterStyle', null)) === null && $createStyle) |
|
214 | 214 | { |
215 | 215 | $style = new TTableItemStyle; |
216 | 216 | $this->setViewState('FooterStyle', $style, null); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function getItemStyle($createStyle = true) |
226 | 226 | { |
227 | - if(($style = $this->getViewState('ItemStyle', null)) === null && $createStyle) |
|
227 | + if (($style = $this->getViewState('ItemStyle', null)) === null && $createStyle) |
|
228 | 228 | { |
229 | 229 | $style = new TTableItemStyle; |
230 | 230 | $this->setViewState('ItemStyle', $style, null); |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | protected function getViewState($key, $defaultValue = null) |
293 | 293 | { |
294 | - return isset($this->_viewState[$key])?$this->_viewState[$key]:$defaultValue; |
|
294 | + return isset($this->_viewState[$key]) ? $this->_viewState[$key] : $defaultValue; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | */ |
305 | 305 | protected function setViewState($key, $value, $defaultValue = null) |
306 | 306 | { |
307 | - if($value === $defaultValue) |
|
307 | + if ($value === $defaultValue) |
|
308 | 308 | unset($this->_viewState[$key]); |
309 | 309 | else |
310 | 310 | $this->_viewState[$key] = $value; |
@@ -384,9 +384,9 @@ discard block |
||
384 | 384 | */ |
385 | 385 | public function initializeCell($cell, $columnIndex, $itemType) |
386 | 386 | { |
387 | - if($itemType === TListItemType::Header) |
|
387 | + if ($itemType === TListItemType::Header) |
|
388 | 388 | $this->initializeHeaderCell($cell, $columnIndex); |
389 | - elseif($itemType === TListItemType::Footer) |
|
389 | + elseif ($itemType === TListItemType::Footer) |
|
390 | 390 | $this->initializeFooterCell($cell, $columnIndex); |
391 | 391 | } |
392 | 392 | |
@@ -419,13 +419,13 @@ discard block |
||
419 | 419 | { |
420 | 420 | $text = $this->getHeaderText(); |
421 | 421 | |
422 | - if(($classPath = $this->getHeaderRenderer()) !== '') |
|
422 | + if (($classPath = $this->getHeaderRenderer()) !== '') |
|
423 | 423 | { |
424 | 424 | $control = Prado::createComponent($classPath); |
425 | 425 | $cell->getControls()->add($control); |
426 | - if($control instanceof \Prado\IDataRenderer) |
|
426 | + if ($control instanceof \Prado\IDataRenderer) |
|
427 | 427 | { |
428 | - if($control instanceof IItemDataRenderer) |
|
428 | + if ($control instanceof IItemDataRenderer) |
|
429 | 429 | { |
430 | 430 | $item = $cell->getParent(); |
431 | 431 | $control->setItemIndex($item->getItemIndex()); |
@@ -434,21 +434,21 @@ discard block |
||
434 | 434 | $control->setData($text); |
435 | 435 | } |
436 | 436 | } |
437 | - elseif($this->getAllowSorting()) |
|
437 | + elseif ($this->getAllowSorting()) |
|
438 | 438 | { |
439 | 439 | $sortExpression = $this->getSortExpression(); |
440 | - if(($url = $this->getHeaderImageUrl()) !== '') |
|
440 | + if (($url = $this->getHeaderImageUrl()) !== '') |
|
441 | 441 | { |
442 | 442 | $button = new TImageButton; |
443 | 443 | $button->setImageUrl($url); |
444 | 444 | $button->setCommandName(TDataGrid::CMD_SORT); |
445 | 445 | $button->setCommandParameter($sortExpression); |
446 | - if($text !== '') |
|
446 | + if ($text !== '') |
|
447 | 447 | $button->setAlternateText($text); |
448 | 448 | $button->setCausesValidation(false); |
449 | 449 | $cell->getControls()->add($button); |
450 | 450 | } |
451 | - elseif($text !== '') |
|
451 | + elseif ($text !== '') |
|
452 | 452 | { |
453 | 453 | $button = new TLinkButton; |
454 | 454 | $button->setText($text); |
@@ -462,15 +462,15 @@ discard block |
||
462 | 462 | } |
463 | 463 | else |
464 | 464 | { |
465 | - if(($url = $this->getHeaderImageUrl()) !== '') |
|
465 | + if (($url = $this->getHeaderImageUrl()) !== '') |
|
466 | 466 | { |
467 | 467 | $image = new TImage; |
468 | 468 | $image->setImageUrl($url); |
469 | - if($text !== '') |
|
469 | + if ($text !== '') |
|
470 | 470 | $image->setAlternateText($text); |
471 | 471 | $cell->getControls()->add($image); |
472 | 472 | } |
473 | - elseif($text !== '') |
|
473 | + elseif ($text !== '') |
|
474 | 474 | $cell->setText($text); |
475 | 475 | else |
476 | 476 | $cell->setText(' '); |
@@ -490,13 +490,13 @@ discard block |
||
490 | 490 | protected function initializeFooterCell($cell, $columnIndex) |
491 | 491 | { |
492 | 492 | $text = $this->getFooterText(); |
493 | - if(($classPath = $this->getFooterRenderer()) !== '') |
|
493 | + if (($classPath = $this->getFooterRenderer()) !== '') |
|
494 | 494 | { |
495 | 495 | $control = Prado::createComponent($classPath); |
496 | 496 | $cell->getControls()->add($control); |
497 | - if($control instanceof \Prado\IDataRenderer) |
|
497 | + if ($control instanceof \Prado\IDataRenderer) |
|
498 | 498 | { |
499 | - if($control instanceof IItemDataRenderer) |
|
499 | + if ($control instanceof IItemDataRenderer) |
|
500 | 500 | { |
501 | 501 | $item = $cell->getParent(); |
502 | 502 | $control->setItemIndex($item->getItemIndex()); |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | $control->setData($text); |
506 | 506 | } |
507 | 507 | } |
508 | - elseif($text !== '') |
|
508 | + elseif ($text !== '') |
|
509 | 509 | $cell->setText($text); |
510 | 510 | else |
511 | 511 | $cell->setText(' '); |
@@ -525,18 +525,18 @@ discard block |
||
525 | 525 | */ |
526 | 526 | protected function formatDataValue($formatString, $value) |
527 | 527 | { |
528 | - if($formatString === '') |
|
528 | + if ($formatString === '') |
|
529 | 529 | return TPropertyValue::ensureString($value); |
530 | - elseif($formatString[0] === '#') |
|
530 | + elseif ($formatString[0] === '#') |
|
531 | 531 | { |
532 | 532 | $expression = strtr(substr($formatString, 1), ['{0}' => '$value']); |
533 | 533 | try |
534 | 534 | { |
535 | - if(eval("\$result=$expression;") === false) |
|
535 | + if (eval("\$result=$expression;") === false) |
|
536 | 536 | throw new Exception(''); |
537 | 537 | return $result; |
538 | 538 | } |
539 | - catch(Exception $e) |
|
539 | + catch (Exception $e) |
|
540 | 540 | { |
541 | 541 | throw new TInvalidDataValueException('datagridcolumn_expression_invalid', get_class($this), $expression, $e->getMessage()); |
542 | 542 | } |
@@ -89,8 +89,9 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function setID($value) |
91 | 91 | { |
92 | - if(!preg_match(TControl::ID_FORMAT, $value)) |
|
93 | - throw new TInvalidDataValueException('datagridcolumn_id_invalid', get_class($this), $value); |
|
92 | + if(!preg_match(TControl::ID_FORMAT, $value)) { |
|
93 | + throw new TInvalidDataValueException('datagridcolumn_id_invalid', get_class($this), $value); |
|
94 | + } |
|
94 | 95 | $this->_id = $value; |
95 | 96 | } |
96 | 97 | |
@@ -304,10 +305,11 @@ discard block |
||
304 | 305 | */ |
305 | 306 | protected function setViewState($key, $value, $defaultValue = null) |
306 | 307 | { |
307 | - if($value === $defaultValue) |
|
308 | - unset($this->_viewState[$key]); |
|
309 | - else |
|
310 | - $this->_viewState[$key] = $value; |
|
308 | + if($value === $defaultValue) { |
|
309 | + unset($this->_viewState[$key]); |
|
310 | + } else { |
|
311 | + $this->_viewState[$key] = $value; |
|
312 | + } |
|
311 | 313 | } |
312 | 314 | |
313 | 315 | /** |
@@ -384,10 +386,11 @@ discard block |
||
384 | 386 | */ |
385 | 387 | public function initializeCell($cell, $columnIndex, $itemType) |
386 | 388 | { |
387 | - if($itemType === TListItemType::Header) |
|
388 | - $this->initializeHeaderCell($cell, $columnIndex); |
|
389 | - elseif($itemType === TListItemType::Footer) |
|
390 | - $this->initializeFooterCell($cell, $columnIndex); |
|
389 | + if($itemType === TListItemType::Header) { |
|
390 | + $this->initializeHeaderCell($cell, $columnIndex); |
|
391 | + } elseif($itemType === TListItemType::Footer) { |
|
392 | + $this->initializeFooterCell($cell, $columnIndex); |
|
393 | + } |
|
391 | 394 | } |
392 | 395 | |
393 | 396 | /** |
@@ -433,8 +436,7 @@ discard block |
||
433 | 436 | } |
434 | 437 | $control->setData($text); |
435 | 438 | } |
436 | - } |
|
437 | - elseif($this->getAllowSorting()) |
|
439 | + } elseif($this->getAllowSorting()) |
|
438 | 440 | { |
439 | 441 | $sortExpression = $this->getSortExpression(); |
440 | 442 | if(($url = $this->getHeaderImageUrl()) !== '') |
@@ -443,12 +445,12 @@ discard block |
||
443 | 445 | $button->setImageUrl($url); |
444 | 446 | $button->setCommandName(TDataGrid::CMD_SORT); |
445 | 447 | $button->setCommandParameter($sortExpression); |
446 | - if($text !== '') |
|
447 | - $button->setAlternateText($text); |
|
448 | + if($text !== '') { |
|
449 | + $button->setAlternateText($text); |
|
450 | + } |
|
448 | 451 | $button->setCausesValidation(false); |
449 | 452 | $cell->getControls()->add($button); |
450 | - } |
|
451 | - elseif($text !== '') |
|
453 | + } elseif($text !== '') |
|
452 | 454 | { |
453 | 455 | $button = new TLinkButton; |
454 | 456 | $button->setText($text); |
@@ -456,24 +458,24 @@ discard block |
||
456 | 458 | $button->setCommandParameter($sortExpression); |
457 | 459 | $button->setCausesValidation(false); |
458 | 460 | $cell->getControls()->add($button); |
461 | + } else { |
|
462 | + $cell->setText(' '); |
|
459 | 463 | } |
460 | - else |
|
461 | - $cell->setText(' '); |
|
462 | - } |
|
463 | - else |
|
464 | + } else |
|
464 | 465 | { |
465 | 466 | if(($url = $this->getHeaderImageUrl()) !== '') |
466 | 467 | { |
467 | 468 | $image = new TImage; |
468 | 469 | $image->setImageUrl($url); |
469 | - if($text !== '') |
|
470 | - $image->setAlternateText($text); |
|
470 | + if($text !== '') { |
|
471 | + $image->setAlternateText($text); |
|
472 | + } |
|
471 | 473 | $cell->getControls()->add($image); |
474 | + } elseif($text !== '') { |
|
475 | + $cell->setText($text); |
|
476 | + } else { |
|
477 | + $cell->setText(' '); |
|
472 | 478 | } |
473 | - elseif($text !== '') |
|
474 | - $cell->setText($text); |
|
475 | - else |
|
476 | - $cell->setText(' '); |
|
477 | 479 | } |
478 | 480 | } |
479 | 481 | |
@@ -504,11 +506,11 @@ discard block |
||
504 | 506 | } |
505 | 507 | $control->setData($text); |
506 | 508 | } |
509 | + } elseif($text !== '') { |
|
510 | + $cell->setText($text); |
|
511 | + } else { |
|
512 | + $cell->setText(' '); |
|
507 | 513 | } |
508 | - elseif($text !== '') |
|
509 | - $cell->setText($text); |
|
510 | - else |
|
511 | - $cell->setText(' '); |
|
512 | 514 | } |
513 | 515 | |
514 | 516 | /** |
@@ -525,23 +527,23 @@ discard block |
||
525 | 527 | */ |
526 | 528 | protected function formatDataValue($formatString, $value) |
527 | 529 | { |
528 | - if($formatString === '') |
|
529 | - return TPropertyValue::ensureString($value); |
|
530 | - elseif($formatString[0] === '#') |
|
530 | + if($formatString === '') { |
|
531 | + return TPropertyValue::ensureString($value); |
|
532 | + } elseif($formatString[0] === '#') |
|
531 | 533 | { |
532 | 534 | $expression = strtr(substr($formatString, 1), ['{0}' => '$value']); |
533 | 535 | try |
534 | 536 | { |
535 | - if(eval("\$result=$expression;") === false) |
|
536 | - throw new Exception(''); |
|
537 | + if(eval("\$result=$expression;") === false) { |
|
538 | + throw new Exception(''); |
|
539 | + } |
|
537 | 540 | return $result; |
538 | - } |
|
539 | - catch(Exception $e) |
|
541 | + } catch(Exception $e) |
|
540 | 542 | { |
541 | 543 | throw new TInvalidDataValueException('datagridcolumn_expression_invalid', get_class($this), $expression, $e->getMessage()); |
542 | 544 | } |
545 | + } else { |
|
546 | + return sprintf($formatString, $value); |
|
543 | 547 | } |
544 | - else |
|
545 | - return sprintf($formatString, $value); |
|
546 | 548 | } |
547 | 549 | } |
548 | 550 | \ No newline at end of file |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @throws TConfigurationException If XSL extension is not available |
57 | 57 | */ |
58 | 58 | public function __construct() { |
59 | - if(!class_exists('XSLTProcessor', false)) { |
|
59 | + if (!class_exists('XSLTProcessor', false)) { |
|
60 | 60 | throw new TConfigurationException('xmltransform_xslextension_required'); |
61 | 61 | } |
62 | 62 | } |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | * @param string The path to the XML style sheet. It must be in namespace format. |
73 | 73 | */ |
74 | 74 | public function setTransformPath($value) { |
75 | - if(!is_file($value)) { |
|
75 | + if (!is_file($value)) { |
|
76 | 76 | $value = Prado::getPathOfNamespace($value, self::EXT_XSL_FILE); |
77 | - if($value === null) { |
|
77 | + if ($value === null) { |
|
78 | 78 | throw new TInvalidDataValueException('xmltransform_transformpath_invalid', $value); |
79 | 79 | } |
80 | 80 | } |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | * @throws TInvalidDataValueException |
108 | 108 | */ |
109 | 109 | public function setDocumentPath($value) { |
110 | - if(!is_file($value)) { |
|
110 | + if (!is_file($value)) { |
|
111 | 111 | $value = Prado::getPathOfNamespace($value, self::EXT_XML_FILE); |
112 | - if($value === null) { |
|
112 | + if ($value === null) { |
|
113 | 113 | throw new TInvalidDataValueException('xmltransform_documentpath_invalid', $value); |
114 | 114 | } |
115 | 115 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @return TAttributeCollection the list of custom parameters |
136 | 136 | */ |
137 | 137 | public function getParameters() { |
138 | - if($params = $this->getViewState('Parameters', null)) { |
|
138 | + if ($params = $this->getViewState('Parameters', null)) { |
|
139 | 139 | return $params; |
140 | 140 | } else { |
141 | 141 | $params = new TAttributeCollection(); |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | private function getTransformXmlDocument() { |
148 | - if(($content = $this->getTransformContent()) !== '') { |
|
148 | + if (($content = $this->getTransformContent()) !== '') { |
|
149 | 149 | $document = new DOMDocument(); |
150 | 150 | $document->loadXML($content); |
151 | 151 | return $document; |
152 | - } elseif(($path = $this->getTransformPath()) !== '') { |
|
152 | + } elseif (($path = $this->getTransformPath()) !== '') { |
|
153 | 153 | $document = new DOMDocument(); |
154 | 154 | $document->load($path); |
155 | 155 | return $document; |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | private function getSourceXmlDocument() { |
162 | - if(($content = $this->getDocumentContent()) !== '') { |
|
162 | + if (($content = $this->getDocumentContent()) !== '') { |
|
163 | 163 | $document = new DOMDocument(); |
164 | 164 | $document->loadXML($content); |
165 | 165 | return $document; |
166 | - } elseif(($path = $this->getDocumentPath()) !== '') { |
|
166 | + } elseif (($path = $this->getDocumentPath()) !== '') { |
|
167 | 167 | $document = new DOMDocument(); |
168 | 168 | $document->load($path); |
169 | 169 | return $document; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param THtmlWriter The writer used for the rendering purpose |
178 | 178 | */ |
179 | 179 | public function render($writer) { |
180 | - if(($document = $this->getSourceXmlDocument()) === null) { |
|
180 | + if (($document = $this->getSourceXmlDocument()) === null) { |
|
181 | 181 | $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
182 | 182 | parent::render($htmlWriter); |
183 | 183 | $document = new DOMDocument(); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | // Check for parameters |
193 | 193 | $parameters = $this->getParameters(); |
194 | - foreach($parameters as $name => $value) { |
|
194 | + foreach ($parameters as $name => $value) { |
|
195 | 195 | $xslt->setParameter('', $name, $value); |
196 | 196 | } |
197 | 197 | $output = $xslt->transformToXML($document); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function setMinSelection($value) |
86 | 86 | { |
87 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
87 | + if (($value = TPropertyValue::ensureInteger($value)) < 0) |
|
88 | 88 | $value = -1; |
89 | 89 | $this->setViewState('MinSelection', $value, -1); |
90 | 90 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function setMaxSelection($value) |
104 | 104 | { |
105 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
105 | + if (($value = TPropertyValue::ensureInteger($value)) < 0) |
|
106 | 106 | $value = -1; |
107 | 107 | $this->setViewState('MaxSelection', $value, -1); |
108 | 108 | } |
@@ -141,22 +141,22 @@ discard block |
||
141 | 141 | $required = $this->getRequiredValues(); |
142 | 142 | |
143 | 143 | //if required, check the values |
144 | - if(!empty($required)) |
|
144 | + if (!empty($required)) |
|
145 | 145 | { |
146 | - if($count < count($required)) |
|
146 | + if ($count < count($required)) |
|
147 | 147 | return false; |
148 | - foreach($required as $require) |
|
148 | + foreach ($required as $require) |
|
149 | 149 | $exists = $exists && in_array($require, $values); |
150 | 150 | } |
151 | 151 | |
152 | 152 | $min = $this->getMinSelection(); |
153 | 153 | $max = $this->getMaxSelection(); |
154 | 154 | |
155 | - if($min !== -1 && $max !== -1) |
|
155 | + if ($min !== -1 && $max !== -1) |
|
156 | 156 | return $exists && $count >= $min && $count <= $max; |
157 | - elseif($min === -1 && $max !== -1) |
|
157 | + elseif ($min === -1 && $max !== -1) |
|
158 | 158 | return $exists && $count <= $max; |
159 | - elseif($min !== -1 && $max === -1) |
|
159 | + elseif ($min !== -1 && $max === -1) |
|
160 | 160 | return $exists && $count >= $min; |
161 | 161 | else |
162 | 162 | return $exists; |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | $values = []; |
172 | 172 | |
173 | 173 | //get the data |
174 | - foreach($control->getItems() as $item) |
|
174 | + foreach ($control->getItems() as $item) |
|
175 | 175 | { |
176 | - if($item->getSelected()) |
|
176 | + if ($item->getSelected()) |
|
177 | 177 | $values[] = $item->getValue(); |
178 | 178 | } |
179 | 179 | return $values; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | { |
187 | 187 | $required = []; |
188 | 188 | $string = $this->getRequiredSelections(); |
189 | - if(!empty($string)) |
|
189 | + if (!empty($string)) |
|
190 | 190 | $required = preg_split('/,\s*/', $string); |
191 | 191 | return $required; |
192 | 192 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $options = parent::getClientScriptOptions(); |
201 | 201 | $control = $this->getValidationTarget(); |
202 | 202 | |
203 | - if(!$control instanceof TListControl) |
|
203 | + if (!$control instanceof TListControl) |
|
204 | 204 | { |
205 | 205 | throw new TConfigurationException( |
206 | 206 | 'listcontrolvalidator_invalid_control', |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | |
210 | 210 | $min = $this->getMinSelection(); |
211 | 211 | $max = $this->getMaxSelection(); |
212 | - if($min !== -1) |
|
212 | + if ($min !== -1) |
|
213 | 213 | $options['Min'] = $min; |
214 | - if($max !== -1) |
|
214 | + if ($max !== -1) |
|
215 | 215 | $options['Max'] = $max; |
216 | 216 | $required = $this->getRequiredSelections(); |
217 | - if(strlen($required) > 0) |
|
217 | + if (strlen($required) > 0) |
|
218 | 218 | $options['Required'] = $required; |
219 | 219 | $options['TotalItems'] = $control->getItemCount(); |
220 | 220 |
@@ -84,8 +84,9 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function setMinSelection($value) |
86 | 86 | { |
87 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
88 | - $value = -1; |
|
87 | + if(($value = TPropertyValue::ensureInteger($value)) < 0) { |
|
88 | + $value = -1; |
|
89 | + } |
|
89 | 90 | $this->setViewState('MinSelection', $value, -1); |
90 | 91 | } |
91 | 92 | |
@@ -102,8 +103,9 @@ discard block |
||
102 | 103 | */ |
103 | 104 | public function setMaxSelection($value) |
104 | 105 | { |
105 | - if(($value = TPropertyValue::ensureInteger($value)) < 0) |
|
106 | - $value = -1; |
|
106 | + if(($value = TPropertyValue::ensureInteger($value)) < 0) { |
|
107 | + $value = -1; |
|
108 | + } |
|
107 | 109 | $this->setViewState('MaxSelection', $value, -1); |
108 | 110 | } |
109 | 111 | |
@@ -143,23 +145,26 @@ discard block |
||
143 | 145 | //if required, check the values |
144 | 146 | if(!empty($required)) |
145 | 147 | { |
146 | - if($count < count($required)) |
|
147 | - return false; |
|
148 | - foreach($required as $require) |
|
149 | - $exists = $exists && in_array($require, $values); |
|
148 | + if($count < count($required)) { |
|
149 | + return false; |
|
150 | + } |
|
151 | + foreach($required as $require) { |
|
152 | + $exists = $exists && in_array($require, $values); |
|
153 | + } |
|
150 | 154 | } |
151 | 155 | |
152 | 156 | $min = $this->getMinSelection(); |
153 | 157 | $max = $this->getMaxSelection(); |
154 | 158 | |
155 | - if($min !== -1 && $max !== -1) |
|
156 | - return $exists && $count >= $min && $count <= $max; |
|
157 | - elseif($min === -1 && $max !== -1) |
|
158 | - return $exists && $count <= $max; |
|
159 | - elseif($min !== -1 && $max === -1) |
|
160 | - return $exists && $count >= $min; |
|
161 | - else |
|
162 | - return $exists; |
|
159 | + if($min !== -1 && $max !== -1) { |
|
160 | + return $exists && $count >= $min && $count <= $max; |
|
161 | + } elseif($min === -1 && $max !== -1) { |
|
162 | + return $exists && $count <= $max; |
|
163 | + } elseif($min !== -1 && $max === -1) { |
|
164 | + return $exists && $count >= $min; |
|
165 | + } else { |
|
166 | + return $exists; |
|
167 | + } |
|
163 | 168 | } |
164 | 169 | |
165 | 170 | /** |
@@ -173,8 +178,9 @@ discard block |
||
173 | 178 | //get the data |
174 | 179 | foreach($control->getItems() as $item) |
175 | 180 | { |
176 | - if($item->getSelected()) |
|
177 | - $values[] = $item->getValue(); |
|
181 | + if($item->getSelected()) { |
|
182 | + $values[] = $item->getValue(); |
|
183 | + } |
|
178 | 184 | } |
179 | 185 | return $values; |
180 | 186 | } |
@@ -186,8 +192,9 @@ discard block |
||
186 | 192 | { |
187 | 193 | $required = []; |
188 | 194 | $string = $this->getRequiredSelections(); |
189 | - if(!empty($string)) |
|
190 | - $required = preg_split('/,\s*/', $string); |
|
195 | + if(!empty($string)) { |
|
196 | + $required = preg_split('/,\s*/', $string); |
|
197 | + } |
|
191 | 198 | return $required; |
192 | 199 | } |
193 | 200 | |
@@ -209,13 +216,16 @@ discard block |
||
209 | 216 | |
210 | 217 | $min = $this->getMinSelection(); |
211 | 218 | $max = $this->getMaxSelection(); |
212 | - if($min !== -1) |
|
213 | - $options['Min'] = $min; |
|
214 | - if($max !== -1) |
|
215 | - $options['Max'] = $max; |
|
219 | + if($min !== -1) { |
|
220 | + $options['Min'] = $min; |
|
221 | + } |
|
222 | + if($max !== -1) { |
|
223 | + $options['Max'] = $max; |
|
224 | + } |
|
216 | 225 | $required = $this->getRequiredSelections(); |
217 | - if(strlen($required) > 0) |
|
218 | - $options['Required'] = $required; |
|
226 | + if(strlen($required) > 0) { |
|
227 | + $options['Required'] = $required; |
|
228 | + } |
|
219 | 229 | $options['TotalItems'] = $control->getItemCount(); |
220 | 230 | |
221 | 231 | return $options; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function addParsedObject($object) |
85 | 85 | { |
86 | - if($object instanceof TTabView) |
|
86 | + if ($object instanceof TTabView) |
|
87 | 87 | $this->getControls()->add($object); |
88 | 88 | } |
89 | 89 | |
@@ -137,32 +137,32 @@ discard block |
||
137 | 137 | { |
138 | 138 | $activeView = null; |
139 | 139 | $views = $this->getViews(); |
140 | - if(($id = $this->getActiveViewID()) !== '') |
|
140 | + if (($id = $this->getActiveViewID()) !== '') |
|
141 | 141 | { |
142 | - if(($index = $views->findIndexByID($id)) >= 0) |
|
142 | + if (($index = $views->findIndexByID($id)) >= 0) |
|
143 | 143 | $activeView = $views->itemAt($index); |
144 | 144 | else |
145 | 145 | throw new TInvalidDataValueException('tabpanel_activeviewid_invalid', $id); |
146 | 146 | } |
147 | - elseif(($index = $this->getActiveViewIndex()) >= 0) |
|
147 | + elseif (($index = $this->getActiveViewIndex()) >= 0) |
|
148 | 148 | { |
149 | - if($index < $views->getCount()) |
|
149 | + if ($index < $views->getCount()) |
|
150 | 150 | $activeView = $views->itemAt($index); |
151 | 151 | else |
152 | 152 | throw new TInvalidDataValueException('tabpanel_activeviewindex_invalid', $index); |
153 | 153 | } |
154 | 154 | else |
155 | 155 | { |
156 | - foreach($views as $index => $view) |
|
156 | + foreach ($views as $index => $view) |
|
157 | 157 | { |
158 | - if($view->getActive()) |
|
158 | + if ($view->getActive()) |
|
159 | 159 | { |
160 | 160 | $activeView = $view; |
161 | 161 | break; |
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
165 | - if($activeView !== null) |
|
165 | + if ($activeView !== null) |
|
166 | 166 | $this->activateView($activeView); |
167 | 167 | return $activeView; |
168 | 168 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function setActiveView($view) |
175 | 175 | { |
176 | - if($this->getViews()->indexOf($view) >= 0) |
|
176 | + if ($this->getViews()->indexOf($view) >= 0) |
|
177 | 177 | $this->activateView($view); |
178 | 178 | else |
179 | 179 | throw new TInvalidOperationException('tabpanel_view_inexistent'); |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | public function getCssClass() |
219 | 219 | { |
220 | 220 | $cssClass = parent::getCssClass(); |
221 | - return $cssClass === ''?'tab-panel':$cssClass; |
|
221 | + return $cssClass === '' ? 'tab-panel' : $cssClass; |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public function getViewStyle() |
244 | 244 | { |
245 | - if(($style = $this->getViewState('ViewStyle', null)) === null) |
|
245 | + if (($style = $this->getViewState('ViewStyle', null)) === null) |
|
246 | 246 | { |
247 | 247 | $style = new TStyle; |
248 | 248 | $style->setCssClass('tab-view'); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function getTabStyle() |
274 | 274 | { |
275 | - if(($style = $this->getViewState('TabStyle', null)) === null) |
|
275 | + if (($style = $this->getViewState('TabStyle', null)) === null) |
|
276 | 276 | { |
277 | 277 | $style = new TStyle; |
278 | 278 | $style->setCssClass('tab-normal'); |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public function getActiveTabStyle() |
304 | 304 | { |
305 | - if(($style = $this->getViewState('ActiveTabStyle', null)) === null) |
|
305 | + if (($style = $this->getViewState('ActiveTabStyle', null)) === null) |
|
306 | 306 | { |
307 | 307 | $style = new TStyle; |
308 | 308 | $style->setCssClass('tab-active'); |
@@ -320,9 +320,9 @@ discard block |
||
320 | 320 | { |
321 | 321 | $this->setActiveViewIndex(-1); |
322 | 322 | $this->setActiveViewID(''); |
323 | - foreach($this->getViews() as $index => $v) |
|
323 | + foreach ($this->getViews() as $index => $v) |
|
324 | 324 | { |
325 | - if($view === $v) |
|
325 | + if ($view === $v) |
|
326 | 326 | { |
327 | 327 | $this->setActiveViewIndex($index); |
328 | 328 | $this->setActiveViewID($view->getID(false)); |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | */ |
343 | 343 | public function loadPostData($key, $values) |
344 | 344 | { |
345 | - if(($index = $values[$this->getClientID() . '_1']) !== null) |
|
345 | + if (($index = $values[$this->getClientID().'_1']) !== null) |
|
346 | 346 | { |
347 | - $index = (int)$index; |
|
347 | + $index = (int) $index; |
|
348 | 348 | $currentIndex = $this->getActiveViewIndex(); |
349 | - if($currentIndex !== $index) |
|
349 | + if ($currentIndex !== $index) |
|
350 | 350 | { |
351 | 351 | $this->setActiveViewID(''); // clear up view ID |
352 | 352 | $this->setActiveViewIndex($index); |
@@ -397,12 +397,12 @@ discard block |
||
397 | 397 | public function onPreRender($param) |
398 | 398 | { |
399 | 399 | parent::onPreRender($param); |
400 | - $this->getActiveView(); // determine the active view |
|
400 | + $this->getActiveView(); // determine the active view |
|
401 | 401 | $this->registerStyleSheet(); |
402 | 402 | |
403 | 403 | $page = $this->getPage(); |
404 | 404 | $page->registerRequiresPostData($this); |
405 | - $page->registerRequiresPostData($this->getClientID() . "_1"); |
|
405 | + $page->registerRequiresPostData($this->getClientID()."_1"); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -414,15 +414,15 @@ discard block |
||
414 | 414 | { |
415 | 415 | $url = $this->getCssUrl(); |
416 | 416 | |
417 | - if($url === '') { |
|
417 | + if ($url === '') { |
|
418 | 418 | return; |
419 | 419 | } |
420 | 420 | |
421 | - if($url === 'default') { |
|
422 | - $url = $this->getApplication()->getAssetManager()->publishFilePath(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'tabpanel.css'); |
|
421 | + if ($url === 'default') { |
|
422 | + $url = $this->getApplication()->getAssetManager()->publishFilePath(dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'tabpanel.css'); |
|
423 | 423 | } |
424 | 424 | |
425 | - if($url !== '') { |
|
425 | + if ($url !== '') { |
|
426 | 426 | $this->getPage()->getClientScript()->registerStyleSheetFile($url, $url); |
427 | 427 | } |
428 | 428 | } |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | $cs->registerEndScript("prado:$id", $code); |
442 | 442 | // ensure an item is always active and visible |
443 | 443 | $index = $this->getActiveViewIndex(); |
444 | - if(!$this->getViews()->itemAt($index)->Visible) |
|
444 | + if (!$this->getViews()->itemAt($index)->Visible) |
|
445 | 445 | $index = 0; |
446 | - $cs->registerHiddenField($id . '_1', $index); |
|
446 | + $cs->registerHiddenField($id.'_1', $index); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | $options['NormalCssClass'] = $this->getTabCssClass(); |
467 | 467 | $viewIDs = []; |
468 | 468 | $viewVis = []; |
469 | - foreach($this->getViews() as $view) |
|
469 | + foreach ($this->getViews() as $view) |
|
470 | 470 | { |
471 | 471 | $viewIDs[] = $view->getClientID(); |
472 | 472 | $viewVis[] = $view->getVisible(); |
@@ -508,17 +508,17 @@ discard block |
||
508 | 508 | public function renderContents($writer) |
509 | 509 | { |
510 | 510 | $views = $this->getViews(); |
511 | - if($views->getCount() > 0) |
|
511 | + if ($views->getCount() > 0) |
|
512 | 512 | { |
513 | 513 | $writer->writeLine(); |
514 | 514 | // render tab bar |
515 | - foreach($views as $view) |
|
515 | + foreach ($views as $view) |
|
516 | 516 | { |
517 | 517 | $view->renderTab($writer); |
518 | 518 | $writer->writeLine(); |
519 | 519 | } |
520 | 520 | // render tab views |
521 | - foreach($views as $view) |
|
521 | + foreach ($views as $view) |
|
522 | 522 | { |
523 | 523 | $view->renderControl($writer); |
524 | 524 | $writer->writeLine(); |
@@ -83,8 +83,9 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function addParsedObject($object) |
85 | 85 | { |
86 | - if($object instanceof TTabView) |
|
87 | - $this->getControls()->add($object); |
|
86 | + if($object instanceof TTabView) { |
|
87 | + $this->getControls()->add($object); |
|
88 | + } |
|
88 | 89 | } |
89 | 90 | |
90 | 91 | /** |
@@ -139,19 +140,19 @@ discard block |
||
139 | 140 | $views = $this->getViews(); |
140 | 141 | if(($id = $this->getActiveViewID()) !== '') |
141 | 142 | { |
142 | - if(($index = $views->findIndexByID($id)) >= 0) |
|
143 | - $activeView = $views->itemAt($index); |
|
144 | - else |
|
145 | - throw new TInvalidDataValueException('tabpanel_activeviewid_invalid', $id); |
|
146 | - } |
|
147 | - elseif(($index = $this->getActiveViewIndex()) >= 0) |
|
143 | + if(($index = $views->findIndexByID($id)) >= 0) { |
|
144 | + $activeView = $views->itemAt($index); |
|
145 | + } else { |
|
146 | + throw new TInvalidDataValueException('tabpanel_activeviewid_invalid', $id); |
|
147 | + } |
|
148 | + } elseif(($index = $this->getActiveViewIndex()) >= 0) |
|
148 | 149 | { |
149 | - if($index < $views->getCount()) |
|
150 | - $activeView = $views->itemAt($index); |
|
151 | - else |
|
152 | - throw new TInvalidDataValueException('tabpanel_activeviewindex_invalid', $index); |
|
153 | - } |
|
154 | - else |
|
150 | + if($index < $views->getCount()) { |
|
151 | + $activeView = $views->itemAt($index); |
|
152 | + } else { |
|
153 | + throw new TInvalidDataValueException('tabpanel_activeviewindex_invalid', $index); |
|
154 | + } |
|
155 | + } else |
|
155 | 156 | { |
156 | 157 | foreach($views as $index => $view) |
157 | 158 | { |
@@ -162,8 +163,9 @@ discard block |
||
162 | 163 | } |
163 | 164 | } |
164 | 165 | } |
165 | - if($activeView !== null) |
|
166 | - $this->activateView($activeView); |
|
166 | + if($activeView !== null) { |
|
167 | + $this->activateView($activeView); |
|
168 | + } |
|
167 | 169 | return $activeView; |
168 | 170 | } |
169 | 171 | |
@@ -173,10 +175,11 @@ discard block |
||
173 | 175 | */ |
174 | 176 | public function setActiveView($view) |
175 | 177 | { |
176 | - if($this->getViews()->indexOf($view) >= 0) |
|
177 | - $this->activateView($view); |
|
178 | - else |
|
179 | - throw new TInvalidOperationException('tabpanel_view_inexistent'); |
|
178 | + if($this->getViews()->indexOf($view) >= 0) { |
|
179 | + $this->activateView($view); |
|
180 | + } else { |
|
181 | + throw new TInvalidOperationException('tabpanel_view_inexistent'); |
|
182 | + } |
|
180 | 183 | } |
181 | 184 | |
182 | 185 | /** |
@@ -327,9 +330,9 @@ discard block |
||
327 | 330 | $this->setActiveViewIndex($index); |
328 | 331 | $this->setActiveViewID($view->getID(false)); |
329 | 332 | $view->setActive(true); |
333 | + } else { |
|
334 | + $v->setActive(false); |
|
330 | 335 | } |
331 | - else |
|
332 | - $v->setActive(false); |
|
333 | 336 | } |
334 | 337 | } |
335 | 338 | |
@@ -441,8 +444,9 @@ discard block |
||
441 | 444 | $cs->registerEndScript("prado:$id", $code); |
442 | 445 | // ensure an item is always active and visible |
443 | 446 | $index = $this->getActiveViewIndex(); |
444 | - if(!$this->getViews()->itemAt($index)->Visible) |
|
445 | - $index = 0; |
|
447 | + if(!$this->getViews()->itemAt($index)->Visible) { |
|
448 | + $index = 0; |
|
449 | + } |
|
446 | 450 | $cs->registerHiddenField($id . '_1', $index); |
447 | 451 | } |
448 | 452 |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | |
94 | 94 | // communicate validation status to the client side |
95 | 95 | $value = $this->_isvalid === false ? '0' : '1'; |
96 | - $cs->registerHiddenField($this->getClientID() . '_1', $value); |
|
96 | + $cs->registerHiddenField($this->getClientID().'_1', $value); |
|
97 | 97 | |
98 | 98 | // update validator display |
99 | 99 | if ($control = $this->getValidationTarget()) |
100 | 100 | { |
101 | - $fn = 'captchaUpdateValidatorStatus_' . $this->getClientID(); |
|
101 | + $fn = 'captchaUpdateValidatorStatus_'.$this->getClientID(); |
|
102 | 102 | |
103 | 103 | // check if we need to request a new captcha too |
104 | 104 | if ($this->Page->IsCallback) |
@@ -114,21 +114,21 @@ discard block |
||
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - $cs->registerEndScript($this->getClientID() . '::validate', implode(' ', [ |
|
117 | + $cs->registerEndScript($this->getClientID().'::validate', implode(' ', [ |
|
118 | 118 | // this function will be used to update the validator |
119 | - 'function ' . $fn . '(valid)', |
|
119 | + 'function '.$fn.'(valid)', |
|
120 | 120 | '{', |
121 | - ' jQuery(' . TJavaScript::quoteString('#' . $this->getClientID() . '_1') . ').val(valid);', |
|
122 | - ' Prado.Validation.validateControl(' . TJavaScript::quoteString($control->ClientID) . '); ', |
|
121 | + ' jQuery('.TJavaScript::quoteString('#'.$this->getClientID().'_1').').val(valid);', |
|
122 | + ' Prado.Validation.validateControl('.TJavaScript::quoteString($control->ClientID).'); ', |
|
123 | 123 | '}', |
124 | 124 | '', |
125 | 125 | // update the validator to the result if we're in a callback |
126 | 126 | // (if we're in initial rendering or a postback then the result will be rendered directly to the page html anyway) |
127 | - $this->Page->IsCallback ? $fn . '(' . $value . ');' : '', |
|
127 | + $this->Page->IsCallback ? $fn.'('.$value.');' : '', |
|
128 | 128 | '', |
129 | 129 | // install event handler that clears the validation error when user changes the captcha response field |
130 | - 'jQuery("#' . $control->getClientID() . '").on("keyup", ' . TJavaScript::quoteString('#' . $control->getResponseFieldName()) . ', function() { ', |
|
131 | - $fn . '("1");', |
|
130 | + 'jQuery("#'.$control->getClientID().'").on("keyup", '.TJavaScript::quoteString('#'.$control->getResponseFieldName()).', function() { ', |
|
131 | + $fn.'("1");', |
|
132 | 132 | '});', |
133 | 133 | ])); |
134 | 134 | } |
@@ -52,10 +52,12 @@ discard block |
||
52 | 52 | protected function getCaptchaControl() |
53 | 53 | { |
54 | 54 | $control = $this->getValidationTarget(); |
55 | - if (!$control) |
|
56 | - throw new Exception('No target control specified for TReCaptchaValidator'); |
|
57 | - if (!($control instanceof TReCaptcha)) |
|
58 | - throw new Exception('TReCaptchaValidator only works with TReCaptcha controls'); |
|
55 | + if (!$control) { |
|
56 | + throw new Exception('No target control specified for TReCaptchaValidator'); |
|
57 | + } |
|
58 | + if (!($control instanceof TReCaptcha)) { |
|
59 | + throw new Exception('TReCaptchaValidator only works with TReCaptcha controls'); |
|
60 | + } |
|
59 | 61 | return $control; |
60 | 62 | } |
61 | 63 | |
@@ -103,14 +105,15 @@ discard block |
||
103 | 105 | // check if we need to request a new captcha too |
104 | 106 | if ($this->Page->IsCallback) |
105 | 107 | { |
106 | - if ($control->getVisible(true)) |
|
107 | - if (null !== $this->_isvalid) |
|
108 | + if ($control->getVisible(true)) { |
|
109 | + if (null !== $this->_isvalid) |
|
108 | 110 | { |
109 | 111 | // if the response has been tested and we reach the pre-render phase |
110 | 112 | // then we need to regenerate the token, because it won't test positive |
111 | 113 | // anymore, even if solves correctly |
112 | 114 | |
113 | 115 | $control->regenerateToken(); |
116 | + } |
|
114 | 117 | } |
115 | 118 | } |
116 | 119 |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function onUnload($param) |
126 | 126 | { |
127 | - if($this->_registered && ($page = $this->getPage()) !== null) |
|
127 | + if ($this->_registered && ($page = $this->getPage()) !== null) |
|
128 | 128 | $page->getValidators()->remove($this); |
129 | 129 | $this->_registered = false; |
130 | 130 | parent::onUnload($param); |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | { |
140 | 140 | $display = $this->getDisplay(); |
141 | 141 | $visible = $this->getEnabled(true) && !$this->getIsValid(); |
142 | - if($display === TValidatorDisplayStyle::None || (!$visible && $display === TValidatorDisplayStyle::Dynamic)) |
|
142 | + if ($display === TValidatorDisplayStyle::None || (!$visible && $display === TValidatorDisplayStyle::Dynamic)) |
|
143 | 143 | $writer->addStyleAttribute('display', 'none'); |
144 | - elseif(!$visible) |
|
144 | + elseif (!$visible) |
|
145 | 145 | $writer->addStyleAttribute('visibility', 'hidden'); |
146 | 146 | $writer->addAttribute('id', $this->getClientID()); |
147 | 147 | parent::addAttributesToRender($writer); |
@@ -159,13 +159,13 @@ discard block |
||
159 | 159 | $options['FormID'] = $this->getPage()->getForm()->getClientID(); |
160 | 160 | $options['Display'] = $this->getDisplay(); |
161 | 161 | $options['ErrorMessage'] = $this->getErrorMessage(); |
162 | - if($this->getFocusOnError()) |
|
162 | + if ($this->getFocusOnError()) |
|
163 | 163 | { |
164 | 164 | $options['FocusOnError'] = $this->getFocusOnError(); |
165 | 165 | $options['FocusElementID'] = $this->getFocusElementID(); |
166 | 166 | } |
167 | 167 | $options['ValidationGroup'] = $this->getValidationGroup(); |
168 | - if($control) |
|
168 | + if ($control) |
|
169 | 169 | $options['ControlToValidate'] = $control->getClientID(); |
170 | 170 | $options['ControlCssClass'] = $this->getControlCssClass(); |
171 | 171 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $options['Enabled'] = $this->getEnabled(true); |
174 | 174 | |
175 | 175 | //get date format from date picker target control |
176 | - if($control instanceof TDatePicker) |
|
176 | + if ($control instanceof TDatePicker) |
|
177 | 177 | $options['DateFormat'] = $control->getDateFormat(); |
178 | 178 | |
179 | 179 | $options = array_merge($options, $this->getClientSide()->getOptions()->toArray()); |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | */ |
191 | 191 | private function getClientControlClass($control) |
192 | 192 | { |
193 | - foreach(self::$_clientClass as $type) |
|
194 | - if($control instanceof $type) |
|
193 | + foreach (self::$_clientClass as $type) |
|
194 | + if ($control instanceof $type) |
|
195 | 195 | return $type; |
196 | 196 | $reflectionClass = new \ReflectionClass($control); |
197 | 197 | return $reflectionClass->getShortName(); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function getClientSide() |
217 | 217 | { |
218 | - if($this->_clientSide === null) |
|
218 | + if ($this->_clientSide === null) |
|
219 | 219 | $this->_clientSide = $this->createClientSide(); |
220 | 220 | return $this->_clientSide; |
221 | 221 | } |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | $scripts->registerPradoScript('validator'); |
242 | 242 | $formID = $this->getPage()->getForm()->getClientID(); |
243 | 243 | $scriptKey = "TBaseValidator:$formID"; |
244 | - if($this->getEnableClientScript() && !$scripts->isEndScriptRegistered($scriptKey)) |
|
244 | + if ($this->getEnableClientScript() && !$scripts->isEndScriptRegistered($scriptKey)) |
|
245 | 245 | { |
246 | 246 | $manager['FormID'] = $formID; |
247 | 247 | $options = TJavaScript::encode($manager); |
248 | 248 | $scripts->registerEndScript($scriptKey, "new Prado.ValidationManager({$options});"); |
249 | 249 | } |
250 | - if($this->getEnableClientScript()) |
|
250 | + if ($this->getEnableClientScript()) |
|
251 | 251 | $this->registerClientScriptValidator(); |
252 | 252 | } |
253 | 253 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * Override parent implementation to update the control CSS Class before |
256 | 256 | * the validated control is rendered |
257 | 257 | */ |
258 | - public function onPreRender ($param) |
|
258 | + public function onPreRender($param) |
|
259 | 259 | { |
260 | 260 | parent::onPreRender($param); |
261 | 261 | $this->updateControlCssClass(); |
@@ -268,15 +268,15 @@ discard block |
||
268 | 268 | */ |
269 | 269 | protected function updateControlCssClass() |
270 | 270 | { |
271 | - if(($cssClass = $this->getControlCssClass()) !== '') |
|
271 | + if (($cssClass = $this->getControlCssClass()) !== '') |
|
272 | 272 | { |
273 | 273 | $control = $this->getValidationTarget(); |
274 | - if($control instanceof TWebControl) |
|
274 | + if ($control instanceof TWebControl) |
|
275 | 275 | { |
276 | - $class = preg_replace('/ ' . preg_quote($cssClass) . '/', '', $control->getCssClass()); |
|
277 | - if(!$this->getIsValid()) |
|
276 | + $class = preg_replace('/ '.preg_quote($cssClass).'/', '', $control->getCssClass()); |
|
277 | + if (!$this->getIsValid()) |
|
278 | 278 | { |
279 | - $class .= ' ' . $cssClass; |
|
279 | + $class .= ' '.$cssClass; |
|
280 | 280 | $control->setCssClass($class); |
281 | 281 | } elseif ($control->getIsValid()) |
282 | 282 | $control->setCssClass($class); |
@@ -289,11 +289,11 @@ discard block |
||
289 | 289 | */ |
290 | 290 | protected function registerClientScriptValidator() |
291 | 291 | { |
292 | - $key = 'prado:' . $this->getClientID(); |
|
293 | - if(!$this->getPage()->getClientScript()->isEndScriptRegistered($key)) |
|
292 | + $key = 'prado:'.$this->getClientID(); |
|
293 | + if (!$this->getPage()->getClientScript()->isEndScriptRegistered($key)) |
|
294 | 294 | { |
295 | 295 | $options = TJavaScript::encode($this->getClientScriptOptions()); |
296 | - $script = 'new ' . $this->getClientClassName() . '(' . $options . ');'; |
|
296 | + $script = 'new '.$this->getClientClassName().'('.$options.');'; |
|
297 | 297 | $this->getPage()->getClientScript()->registerEndScript($key, $script); |
298 | 298 | } |
299 | 299 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | { |
324 | 324 | $value = TPropertyValue::ensureBoolean($value); |
325 | 325 | parent::setEnabled($value); |
326 | - if(!$value) |
|
326 | + if (!$value) |
|
327 | 327 | $this->_isValid = true; |
328 | 328 | } |
329 | 329 | |
@@ -418,15 +418,15 @@ discard block |
||
418 | 418 | */ |
419 | 419 | public function getFocusElementID() |
420 | 420 | { |
421 | - if(($id = $this->getViewState('FocusElementID', '')) === '') |
|
421 | + if (($id = $this->getViewState('FocusElementID', '')) === '') |
|
422 | 422 | { |
423 | 423 | $target = $this->getValidationTarget(); |
424 | 424 | /* Workaround: TCheckBoxList and TRadioButtonList nests the actual |
425 | 425 | * inputs inside a table; we ensure the first input gets focused |
426 | 426 | */ |
427 | - if($target instanceof TCheckBoxList && $target->getItemCount() > 0) |
|
427 | + if ($target instanceof TCheckBoxList && $target->getItemCount() > 0) |
|
428 | 428 | { |
429 | - $id = $target->getClientID() . '_c0'; |
|
429 | + $id = $target->getClientID().'_c0'; |
|
430 | 430 | } else { |
431 | 431 | $id = $target->getClientID(); |
432 | 432 | } |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | */ |
484 | 484 | public function getValidationTarget() |
485 | 485 | { |
486 | - if(($id = $this->getControlToValidate()) !== '' && ($control = $this->findControl($id)) !== null) |
|
486 | + if (($id = $this->getControlToValidate()) !== '' && ($control = $this->findControl($id)) !== null) |
|
487 | 487 | return $control; |
488 | 488 | else |
489 | 489 | throw new TConfigurationException('basevalidator_controltovalidate_invalid', get_class($this)); |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | */ |
498 | 498 | protected function getValidationValue($control) |
499 | 499 | { |
500 | - if($control instanceof \Prado\Web\UI\IValidatable) |
|
500 | + if ($control instanceof \Prado\Web\UI\IValidatable) |
|
501 | 501 | return $control->getValidationPropertyValue(); |
502 | 502 | else |
503 | 503 | throw new TInvalidDataTypeException('basevalidator_validatable_required', get_class($this)); |
@@ -511,22 +511,22 @@ discard block |
||
511 | 511 | public function validate() |
512 | 512 | { |
513 | 513 | $this->onValidate(); |
514 | - if($this->getVisible(true) && $this->getEnabled(true)) |
|
514 | + if ($this->getVisible(true) && $this->getEnabled(true)) |
|
515 | 515 | { |
516 | 516 | $target = $this->getValidationTarget(); |
517 | 517 | // if the target is not a disabled web control |
518 | - if($target === null || |
|
518 | + if ($target === null || |
|
519 | 519 | ($target !== null && |
520 | 520 | !($target instanceof TWebControl && !$target->getEnabled(true)))) |
521 | 521 | { |
522 | - if($this->evaluateIsValid()) |
|
522 | + if ($this->evaluateIsValid()) |
|
523 | 523 | { |
524 | 524 | $this->setIsValid(true); |
525 | 525 | $this->onValidationSuccess(); |
526 | 526 | } |
527 | 527 | else |
528 | 528 | { |
529 | - if($target) |
|
529 | + if ($target) |
|
530 | 530 | $target->setIsValid(false); |
531 | 531 | $this->setIsValid(false); |
532 | 532 | $this->onValidationError(); |
@@ -600,9 +600,9 @@ discard block |
||
600 | 600 | */ |
601 | 601 | public function renderContents($writer) |
602 | 602 | { |
603 | - if(($text = $this->getText()) !== '') |
|
603 | + if (($text = $this->getText()) !== '') |
|
604 | 604 | $writer->write($text); |
605 | - elseif(($text = $this->getErrorMessage()) !== '') |
|
605 | + elseif (($text = $this->getErrorMessage()) !== '') |
|
606 | 606 | $writer->write($text); |
607 | 607 | else |
608 | 608 | parent::renderContents($writer); |
@@ -124,8 +124,9 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function onUnload($param) |
126 | 126 | { |
127 | - if($this->_registered && ($page = $this->getPage()) !== null) |
|
128 | - $page->getValidators()->remove($this); |
|
127 | + if($this->_registered && ($page = $this->getPage()) !== null) { |
|
128 | + $page->getValidators()->remove($this); |
|
129 | + } |
|
129 | 130 | $this->_registered = false; |
130 | 131 | parent::onUnload($param); |
131 | 132 | } |
@@ -139,10 +140,11 @@ discard block |
||
139 | 140 | { |
140 | 141 | $display = $this->getDisplay(); |
141 | 142 | $visible = $this->getEnabled(true) && !$this->getIsValid(); |
142 | - if($display === TValidatorDisplayStyle::None || (!$visible && $display === TValidatorDisplayStyle::Dynamic)) |
|
143 | - $writer->addStyleAttribute('display', 'none'); |
|
144 | - elseif(!$visible) |
|
145 | - $writer->addStyleAttribute('visibility', 'hidden'); |
|
143 | + if($display === TValidatorDisplayStyle::None || (!$visible && $display === TValidatorDisplayStyle::Dynamic)) { |
|
144 | + $writer->addStyleAttribute('display', 'none'); |
|
145 | + } elseif(!$visible) { |
|
146 | + $writer->addStyleAttribute('visibility', 'hidden'); |
|
147 | + } |
|
146 | 148 | $writer->addAttribute('id', $this->getClientID()); |
147 | 149 | parent::addAttributesToRender($writer); |
148 | 150 | $this->renderClientControlScript($writer); |
@@ -165,16 +167,18 @@ discard block |
||
165 | 167 | $options['FocusElementID'] = $this->getFocusElementID(); |
166 | 168 | } |
167 | 169 | $options['ValidationGroup'] = $this->getValidationGroup(); |
168 | - if($control) |
|
169 | - $options['ControlToValidate'] = $control->getClientID(); |
|
170 | + if($control) { |
|
171 | + $options['ControlToValidate'] = $control->getClientID(); |
|
172 | + } |
|
170 | 173 | $options['ControlCssClass'] = $this->getControlCssClass(); |
171 | 174 | |
172 | 175 | $options['ControlType'] = $this->getClientControlClass($control); |
173 | 176 | $options['Enabled'] = $this->getEnabled(true); |
174 | 177 | |
175 | 178 | //get date format from date picker target control |
176 | - if($control instanceof TDatePicker) |
|
177 | - $options['DateFormat'] = $control->getDateFormat(); |
|
179 | + if($control instanceof TDatePicker) { |
|
180 | + $options['DateFormat'] = $control->getDateFormat(); |
|
181 | + } |
|
178 | 182 | |
179 | 183 | $options = array_merge($options, $this->getClientSide()->getOptions()->toArray()); |
180 | 184 | |
@@ -190,9 +194,10 @@ discard block |
||
190 | 194 | */ |
191 | 195 | private function getClientControlClass($control) |
192 | 196 | { |
193 | - foreach(self::$_clientClass as $type) |
|
194 | - if($control instanceof $type) |
|
197 | + foreach(self::$_clientClass as $type) { |
|
198 | + if($control instanceof $type) |
|
195 | 199 | return $type; |
200 | + } |
|
196 | 201 | $reflectionClass = new \ReflectionClass($control); |
197 | 202 | return $reflectionClass->getShortName(); |
198 | 203 | } |
@@ -215,8 +220,9 @@ discard block |
||
215 | 220 | */ |
216 | 221 | public function getClientSide() |
217 | 222 | { |
218 | - if($this->_clientSide === null) |
|
219 | - $this->_clientSide = $this->createClientSide(); |
|
223 | + if($this->_clientSide === null) { |
|
224 | + $this->_clientSide = $this->createClientSide(); |
|
225 | + } |
|
220 | 226 | return $this->_clientSide; |
221 | 227 | } |
222 | 228 | |
@@ -237,8 +243,9 @@ discard block |
||
237 | 243 | public function renderClientControlScript($writer) |
238 | 244 | { |
239 | 245 | $scripts = $this->getPage()->getClientScript(); |
240 | - if ($this->getEnableClientScript()) |
|
241 | - $scripts->registerPradoScript('validator'); |
|
246 | + if ($this->getEnableClientScript()) { |
|
247 | + $scripts->registerPradoScript('validator'); |
|
248 | + } |
|
242 | 249 | $formID = $this->getPage()->getForm()->getClientID(); |
243 | 250 | $scriptKey = "TBaseValidator:$formID"; |
244 | 251 | if($this->getEnableClientScript() && !$scripts->isEndScriptRegistered($scriptKey)) |
@@ -247,8 +254,9 @@ discard block |
||
247 | 254 | $options = TJavaScript::encode($manager); |
248 | 255 | $scripts->registerEndScript($scriptKey, "new Prado.ValidationManager({$options});"); |
249 | 256 | } |
250 | - if($this->getEnableClientScript()) |
|
251 | - $this->registerClientScriptValidator(); |
|
257 | + if($this->getEnableClientScript()) { |
|
258 | + $this->registerClientScriptValidator(); |
|
259 | + } |
|
252 | 260 | } |
253 | 261 | |
254 | 262 | /** |
@@ -278,8 +286,9 @@ discard block |
||
278 | 286 | { |
279 | 287 | $class .= ' ' . $cssClass; |
280 | 288 | $control->setCssClass($class); |
281 | - } elseif ($control->getIsValid()) |
|
282 | - $control->setCssClass($class); |
|
289 | + } elseif ($control->getIsValid()) { |
|
290 | + $control->setCssClass($class); |
|
291 | + } |
|
283 | 292 | } |
284 | 293 | } |
285 | 294 | } |
@@ -323,8 +332,9 @@ discard block |
||
323 | 332 | { |
324 | 333 | $value = TPropertyValue::ensureBoolean($value); |
325 | 334 | parent::setEnabled($value); |
326 | - if(!$value) |
|
327 | - $this->_isValid = true; |
|
335 | + if(!$value) { |
|
336 | + $this->_isValid = true; |
|
337 | + } |
|
328 | 338 | } |
329 | 339 | |
330 | 340 | /** |
@@ -483,10 +493,11 @@ discard block |
||
483 | 493 | */ |
484 | 494 | public function getValidationTarget() |
485 | 495 | { |
486 | - if(($id = $this->getControlToValidate()) !== '' && ($control = $this->findControl($id)) !== null) |
|
487 | - return $control; |
|
488 | - else |
|
489 | - throw new TConfigurationException('basevalidator_controltovalidate_invalid', get_class($this)); |
|
496 | + if(($id = $this->getControlToValidate()) !== '' && ($control = $this->findControl($id)) !== null) { |
|
497 | + return $control; |
|
498 | + } else { |
|
499 | + throw new TConfigurationException('basevalidator_controltovalidate_invalid', get_class($this)); |
|
500 | + } |
|
490 | 501 | } |
491 | 502 | |
492 | 503 | /** |
@@ -497,10 +508,11 @@ discard block |
||
497 | 508 | */ |
498 | 509 | protected function getValidationValue($control) |
499 | 510 | { |
500 | - if($control instanceof \Prado\Web\UI\IValidatable) |
|
501 | - return $control->getValidationPropertyValue(); |
|
502 | - else |
|
503 | - throw new TInvalidDataTypeException('basevalidator_validatable_required', get_class($this)); |
|
511 | + if($control instanceof \Prado\Web\UI\IValidatable) { |
|
512 | + return $control->getValidationPropertyValue(); |
|
513 | + } else { |
|
514 | + throw new TInvalidDataTypeException('basevalidator_validatable_required', get_class($this)); |
|
515 | + } |
|
504 | 516 | } |
505 | 517 | |
506 | 518 | /** |
@@ -523,16 +535,15 @@ discard block |
||
523 | 535 | { |
524 | 536 | $this->setIsValid(true); |
525 | 537 | $this->onValidationSuccess(); |
526 | - } |
|
527 | - else |
|
538 | + } else |
|
528 | 539 | { |
529 | - if($target) |
|
530 | - $target->setIsValid(false); |
|
540 | + if($target) { |
|
541 | + $target->setIsValid(false); |
|
542 | + } |
|
531 | 543 | $this->setIsValid(false); |
532 | 544 | $this->onValidationError(); |
533 | 545 | } |
534 | - } |
|
535 | - else |
|
546 | + } else |
|
536 | 547 | { |
537 | 548 | $this->evaluateIsValid(); |
538 | 549 | $this->setIsValid(true); |
@@ -600,11 +611,12 @@ discard block |
||
600 | 611 | */ |
601 | 612 | public function renderContents($writer) |
602 | 613 | { |
603 | - if(($text = $this->getText()) !== '') |
|
604 | - $writer->write($text); |
|
605 | - elseif(($text = $this->getErrorMessage()) !== '') |
|
606 | - $writer->write($text); |
|
607 | - else |
|
608 | - parent::renderContents($writer); |
|
614 | + if(($text = $this->getText()) !== '') { |
|
615 | + $writer->write($text); |
|
616 | + } elseif(($text = $this->getErrorMessage()) !== '') { |
|
617 | + $writer->write($text); |
|
618 | + } else { |
|
619 | + parent::renderContents($writer); |
|
620 | + } |
|
609 | 621 | } |
610 | 622 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function insertAt($index, $item) |
36 | 36 | { |
37 | - if($item instanceof TTabView) |
|
37 | + if ($item instanceof TTabView) |
|
38 | 38 | parent::insertAt($index, $item); |
39 | 39 | else |
40 | 40 | throw new TInvalidDataTypeException('tabviewcollection_tabview_required'); |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function findIndexByID($id) |
49 | 49 | { |
50 | - foreach($this as $index => $view) |
|
50 | + foreach ($this as $index => $view) |
|
51 | 51 | { |
52 | - if($view->getID(false) === $id) |
|
52 | + if ($view->getID(false) === $id) |
|
53 | 53 | return $index; |
54 | 54 | } |
55 | 55 | return -1; |
@@ -34,10 +34,11 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function insertAt($index, $item) |
36 | 36 | { |
37 | - if($item instanceof TTabView) |
|
38 | - parent::insertAt($index, $item); |
|
39 | - else |
|
40 | - throw new TInvalidDataTypeException('tabviewcollection_tabview_required'); |
|
37 | + if($item instanceof TTabView) { |
|
38 | + parent::insertAt($index, $item); |
|
39 | + } else { |
|
40 | + throw new TInvalidDataTypeException('tabviewcollection_tabview_required'); |
|
41 | + } |
|
41 | 42 | } |
42 | 43 | |
43 | 44 | /** |
@@ -49,8 +50,9 @@ discard block |
||
49 | 50 | { |
50 | 51 | foreach($this as $index => $view) |
51 | 52 | { |
52 | - if($view->getID(false) === $id) |
|
53 | - return $index; |
|
53 | + if($view->getID(false) === $id) { |
|
54 | + return $index; |
|
55 | + } |
|
54 | 56 | } |
55 | 57 | return -1; |
56 | 58 | } |