@@ -54,14 +54,14 @@ |
||
54 | 54 | */ |
55 | 55 | public function loadPostData($key, $values) |
56 | 56 | { |
57 | - $value = isset($values[$key])?$values[$key]:''; |
|
57 | + $value = isset($values[$key]) ? $values[$key] : ''; |
|
58 | 58 | $oldSelection = $this->getSelectedIndex(); |
59 | 59 | $this->ensureDataBound(); |
60 | - foreach($this->getItems() as $index => $item) |
|
60 | + foreach ($this->getItems() as $index => $item) |
|
61 | 61 | { |
62 | - if($item->getEnabled() && $item->getValue() === $value) |
|
62 | + if ($item->getEnabled() && $item->getValue() === $value) |
|
63 | 63 | { |
64 | - if($index === $oldSelection) |
|
64 | + if ($index === $oldSelection) |
|
65 | 65 | return false; |
66 | 66 | else |
67 | 67 | { |
@@ -61,9 +61,9 @@ |
||
61 | 61 | { |
62 | 62 | if($item->getEnabled() && $item->getValue() === $value) |
63 | 63 | { |
64 | - if($index === $oldSelection) |
|
65 | - return false; |
|
66 | - else |
|
64 | + if($index === $oldSelection) { |
|
65 | + return false; |
|
66 | + } else |
|
67 | 67 | { |
68 | 68 | $this->setSelectedIndex($index); |
69 | 69 | return true; |
@@ -178,8 +178,7 @@ discard block |
||
178 | 178 | |
179 | 179 | public function validate() |
180 | 180 | { |
181 | - if (! |
|
182 | - ( |
|
181 | + if (!( |
|
183 | 182 | ($challenge = @$_POST[$this->getChallengeFieldName()]) |
184 | 183 | and |
185 | 184 | ($response = @$_POST[$this->getResponseFieldName()]) |
@@ -203,9 +202,9 @@ discard block |
||
203 | 202 | { |
204 | 203 | parent::onPreRender($param); |
205 | 204 | |
206 | - if("" == $this->getPublicKey()) |
|
205 | + if ("" == $this->getPublicKey()) |
|
207 | 206 | throw new TConfigurationException('recaptcha_publickey_unknown'); |
208 | - if("" == $this->getPrivateKey()) |
|
207 | + if ("" == $this->getPrivateKey()) |
|
209 | 208 | throw new TConfigurationException('recaptcha_privatekey_unknown'); |
210 | 209 | |
211 | 210 | // need to register captcha fields so they will be sent back also in callbacks |
@@ -225,21 +224,21 @@ discard block |
||
225 | 224 | // if we're in a callback, then schedule re-rendering of the control |
226 | 225 | // if not, don't do anything, because a new challenge will be rendered anyway |
227 | 226 | if ($this->Page->IsCallback) |
228 | - $this->Page->CallbackClient->jQuery($this->getClientID() . ' #recaptcha_reload', 'click'); |
|
227 | + $this->Page->CallbackClient->jQuery($this->getClientID().' #recaptcha_reload', 'click'); |
|
229 | 228 | } |
230 | 229 | |
231 | 230 | public function renderContents($writer) |
232 | 231 | { |
233 | - $readyscript = 'jQuery(document).trigger(' . TJavaScript::quoteString('captchaready:' . $this->getClientID()) . ')'; |
|
232 | + $readyscript = 'jQuery(document).trigger('.TJavaScript::quoteString('captchaready:'.$this->getClientID()).')'; |
|
234 | 233 | $cs = $this->Page->ClientScript; |
235 | 234 | $id = $this->getClientID(); |
236 | - $divid = $id . '_1_recaptchadiv'; |
|
237 | - $writer->write('<div id="' . htmlspecialchars($divid) . '">'); |
|
235 | + $divid = $id.'_1_recaptchadiv'; |
|
236 | + $writer->write('<div id="'.htmlspecialchars($divid).'">'); |
|
238 | 237 | |
239 | 238 | if (!$this->Page->IsCallback) |
240 | 239 | { |
241 | 240 | $writer->write(TJavaScript::renderScriptBlock( |
242 | - 'var RecaptchaOptions = ' . TJavaScript::jsonEncode($this->getClientSideOptions()) . ';' |
|
241 | + 'var RecaptchaOptions = '.TJavaScript::jsonEncode($this->getClientSideOptions()).';' |
|
243 | 242 | )); |
244 | 243 | |
245 | 244 | $html = $this->recaptcha_get_html($this->getPublicKey()); |
@@ -253,20 +252,20 @@ discard block |
||
253 | 252 | */ |
254 | 253 | $writer->write($html); |
255 | 254 | |
256 | - $cs->registerEndScript('ReCaptcha::EventScript', 'jQuery(document).ready(function() { ' . $readyscript . '; } );'); |
|
255 | + $cs->registerEndScript('ReCaptcha::EventScript', 'jQuery(document).ready(function() { '.$readyscript.'; } );'); |
|
257 | 256 | } |
258 | 257 | else |
259 | 258 | { |
260 | 259 | $options = $this->getClientSideOptions(); |
261 | - $options['callback'] = new TJavaScriptLiteral('function() { ' . $readyscript . '; ' . $this->getCallbackScript() . '; }'); |
|
260 | + $options['callback'] = new TJavaScriptLiteral('function() { '.$readyscript.'; '.$this->getCallbackScript().'; }'); |
|
262 | 261 | $cs->registerScriptFile('ReCaptcha::AjaxScript', self::RECAPTCHA_JS); |
263 | - $cs->registerEndScript('ReCaptcha::CreateScript::' . $id, implode(' ', [ |
|
264 | - 'if (!jQuery(' . TJavaScript::quoteString('#' . $this->getResponseFieldName()) . '))', |
|
262 | + $cs->registerEndScript('ReCaptcha::CreateScript::'.$id, implode(' ', [ |
|
263 | + 'if (!jQuery('.TJavaScript::quoteString('#'.$this->getResponseFieldName()).'))', |
|
265 | 264 | '{', |
266 | 265 | 'Recaptcha.destroy();', |
267 | 266 | 'Recaptcha.create(', |
268 | - TJavaScript::quoteString($this->getPublicKey()) . ', ', |
|
269 | - TJavaScript::quoteString($divid) . ', ', |
|
267 | + TJavaScript::quoteString($this->getPublicKey()).', ', |
|
268 | + TJavaScript::quoteString($divid).', ', |
|
270 | 269 | TJavaScript::encode($options), |
271 | 270 | ');', |
272 | 271 | '}', |
@@ -291,11 +290,11 @@ discard block |
||
291 | 290 | $server = $use_ssl ? self::RECAPTCHA_API_SECURE_SERVER : $server = self::RECAPTCHA_API_SERVER; |
292 | 291 | $errorpart = ''; |
293 | 292 | if ($error) |
294 | - $errorpart = "&error=" . $error; |
|
293 | + $errorpart = "&error=".$error; |
|
295 | 294 | |
296 | - return '<script type="text/javascript" src="' . $server . '/challenge?k=' . $pubkey . $errorpart . '"></script> |
|
295 | + return '<script type="text/javascript" src="'.$server.'/challenge?k='.$pubkey.$errorpart.'"></script> |
|
297 | 296 | <noscript> |
298 | - <iframe src="' . $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/> |
|
297 | + <iframe src="' . $server.'/noscript?k='.$pubkey.$errorpart.'" height="300" width="500" frameborder="0"></iframe><br/> |
|
299 | 298 | <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> |
300 | 299 | <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/> |
301 | 300 | </noscript>'; |
@@ -306,10 +305,10 @@ discard block |
||
306 | 305 | * @param $data - array of string elements to be encoded |
307 | 306 | * @return string - encoded request |
308 | 307 | */ |
309 | - private function recaptcha_qsencode ($data) { |
|
308 | + private function recaptcha_qsencode($data) { |
|
310 | 309 | $req = ""; |
311 | 310 | foreach ($data as $key => $value) |
312 | - $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; |
|
311 | + $req .= $key.'='.urlencode(stripslashes($value)).'&'; |
|
313 | 312 | |
314 | 313 | // Cut the last '&' |
315 | 314 | $req = substr($req, 0, strlen($req) - 1); |
@@ -331,13 +330,13 @@ discard block |
||
331 | 330 | $http_request = "POST $path HTTP/1.0\r\n"; |
332 | 331 | $http_request .= "Host: $host\r\n"; |
333 | 332 | $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; |
334 | - $http_request .= "Content-Length: " . strlen($req) . "\r\n"; |
|
333 | + $http_request .= "Content-Length: ".strlen($req)."\r\n"; |
|
335 | 334 | $http_request .= "User-Agent: reCAPTCHA/PHP\r\n"; |
336 | 335 | $http_request .= "\r\n"; |
337 | 336 | $http_request .= $req; |
338 | 337 | |
339 | 338 | $response = ''; |
340 | - if(false == ($fs = @fsockopen($host, $port, $errno, $errstr, 10))) |
|
339 | + if (false == ($fs = @fsockopen($host, $port, $errno, $errstr, 10))) |
|
341 | 340 | die('Could not open socket'); |
342 | 341 | |
343 | 342 | fwrite($fs, $http_request); |
@@ -167,12 +167,15 @@ discard block |
||
167 | 167 | public function getClientSideOptions() |
168 | 168 | { |
169 | 169 | $options = []; |
170 | - if ($theme = $this->getThemeName()) |
|
171 | - $options['theme'] = $theme; |
|
172 | - if ($lang = $this->getLanguage()) |
|
173 | - $options['lang'] = $lang; |
|
174 | - if ($trans = $this->getCustomTranslations()) |
|
175 | - $options['custom_translations'] = $trans; |
|
170 | + if ($theme = $this->getThemeName()) { |
|
171 | + $options['theme'] = $theme; |
|
172 | + } |
|
173 | + if ($lang = $this->getLanguage()) { |
|
174 | + $options['lang'] = $lang; |
|
175 | + } |
|
176 | + if ($trans = $this->getCustomTranslations()) { |
|
177 | + $options['custom_translations'] = $trans; |
|
178 | + } |
|
176 | 179 | return $options; |
177 | 180 | } |
178 | 181 | |
@@ -184,8 +187,9 @@ discard block |
||
184 | 187 | and |
185 | 188 | ($response = @$_POST[$this->getResponseFieldName()]) |
186 | 189 | ) |
187 | - ) |
|
188 | - return false; |
|
190 | + ) { |
|
191 | + return false; |
|
192 | + } |
|
189 | 193 | |
190 | 194 | return $this->recaptcha_check_answer( |
191 | 195 | $this->getPrivateKey(), |
@@ -203,10 +207,12 @@ discard block |
||
203 | 207 | { |
204 | 208 | parent::onPreRender($param); |
205 | 209 | |
206 | - if("" == $this->getPublicKey()) |
|
207 | - throw new TConfigurationException('recaptcha_publickey_unknown'); |
|
208 | - if("" == $this->getPrivateKey()) |
|
209 | - throw new TConfigurationException('recaptcha_privatekey_unknown'); |
|
210 | + if("" == $this->getPublicKey()) { |
|
211 | + throw new TConfigurationException('recaptcha_publickey_unknown'); |
|
212 | + } |
|
213 | + if("" == $this->getPrivateKey()) { |
|
214 | + throw new TConfigurationException('recaptcha_privatekey_unknown'); |
|
215 | + } |
|
210 | 216 | |
211 | 217 | // need to register captcha fields so they will be sent back also in callbacks |
212 | 218 | $page = $this->getPage(); |
@@ -224,8 +230,9 @@ discard block |
||
224 | 230 | { |
225 | 231 | // if we're in a callback, then schedule re-rendering of the control |
226 | 232 | // if not, don't do anything, because a new challenge will be rendered anyway |
227 | - if ($this->Page->IsCallback) |
|
228 | - $this->Page->CallbackClient->jQuery($this->getClientID() . ' #recaptcha_reload', 'click'); |
|
233 | + if ($this->Page->IsCallback) { |
|
234 | + $this->Page->CallbackClient->jQuery($this->getClientID() . ' #recaptcha_reload', 'click'); |
|
235 | + } |
|
229 | 236 | } |
230 | 237 | |
231 | 238 | public function renderContents($writer) |
@@ -254,8 +261,7 @@ discard block |
||
254 | 261 | $writer->write($html); |
255 | 262 | |
256 | 263 | $cs->registerEndScript('ReCaptcha::EventScript', 'jQuery(document).ready(function() { ' . $readyscript . '; } );'); |
257 | - } |
|
258 | - else |
|
264 | + } else |
|
259 | 265 | { |
260 | 266 | $options = $this->getClientSideOptions(); |
261 | 267 | $options['callback'] = new TJavaScriptLiteral('function() { ' . $readyscript . '; ' . $this->getCallbackScript() . '; }'); |
@@ -290,8 +296,9 @@ discard block |
||
290 | 296 | { |
291 | 297 | $server = $use_ssl ? self::RECAPTCHA_API_SECURE_SERVER : $server = self::RECAPTCHA_API_SERVER; |
292 | 298 | $errorpart = ''; |
293 | - if ($error) |
|
294 | - $errorpart = "&error=" . $error; |
|
299 | + if ($error) { |
|
300 | + $errorpart = "&error=" . $error; |
|
301 | + } |
|
295 | 302 | |
296 | 303 | return '<script type="text/javascript" src="' . $server . '/challenge?k=' . $pubkey . $errorpart . '"></script> |
297 | 304 | <noscript> |
@@ -308,8 +315,9 @@ discard block |
||
308 | 315 | */ |
309 | 316 | private function recaptcha_qsencode ($data) { |
310 | 317 | $req = ""; |
311 | - foreach ($data as $key => $value) |
|
312 | - $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; |
|
318 | + foreach ($data as $key => $value) { |
|
319 | + $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; |
|
320 | + } |
|
313 | 321 | |
314 | 322 | // Cut the last '&' |
315 | 323 | $req = substr($req, 0, strlen($req) - 1); |
@@ -337,13 +345,16 @@ discard block |
||
337 | 345 | $http_request .= $req; |
338 | 346 | |
339 | 347 | $response = ''; |
340 | - if(false == ($fs = @fsockopen($host, $port, $errno, $errstr, 10))) |
|
341 | - die('Could not open socket'); |
|
348 | + if(false == ($fs = @fsockopen($host, $port, $errno, $errstr, 10))) { |
|
349 | + die('Could not open socket'); |
|
350 | + } |
|
342 | 351 | |
343 | 352 | fwrite($fs, $http_request); |
344 | 353 | |
345 | - while (!feof($fs)) |
|
346 | - $response .= fgets($fs, 1160); // One TCP-IP packet |
|
354 | + while (!feof($fs)) { |
|
355 | + $response .= fgets($fs, 1160); |
|
356 | + } |
|
357 | + // One TCP-IP packet |
|
347 | 358 | fclose($fs); |
348 | 359 | $response = explode("\r\n\r\n", $response, 2); |
349 | 360 | |
@@ -362,8 +373,9 @@ discard block |
||
362 | 373 | private function recaptcha_check_answer($privkey, $remoteip, $challenge, $response, $extra_params = []) |
363 | 374 | { |
364 | 375 | //discard spam submissions |
365 | - if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) |
|
366 | - return false; |
|
376 | + if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) { |
|
377 | + return false; |
|
378 | + } |
|
367 | 379 | |
368 | 380 | $response = $this->recaptcha_http_post(self::RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify", |
369 | 381 | [ |
@@ -376,9 +388,10 @@ discard block |
||
376 | 388 | |
377 | 389 | $answers = explode("\n", $response [1]); |
378 | 390 | |
379 | - if (trim($answers [0]) == 'true') |
|
380 | - return true; |
|
381 | - else |
|
382 | - return false; |
|
391 | + if (trim($answers [0]) == 'true') { |
|
392 | + return true; |
|
393 | + } else { |
|
394 | + return false; |
|
395 | + } |
|
383 | 396 | } |
384 | 397 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | public function setBold($value) |
89 | 89 | { |
90 | 90 | $this->_flags |= self::IS_SET_BOLD; |
91 | - if(TPropertyValue::ensureBoolean($value)) |
|
91 | + if (TPropertyValue::ensureBoolean($value)) |
|
92 | 92 | $this->_flags |= self::IS_BOLD; |
93 | 93 | else |
94 | 94 | $this->_flags &= ~self::IS_BOLD; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | public function setItalic($value) |
109 | 109 | { |
110 | 110 | $this->_flags |= self::IS_SET_ITALIC; |
111 | - if(TPropertyValue::ensureBoolean($value)) |
|
111 | + if (TPropertyValue::ensureBoolean($value)) |
|
112 | 112 | $this->_flags |= self::IS_ITALIC; |
113 | 113 | else |
114 | 114 | $this->_flags &= ~self::IS_ITALIC; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | public function setOverline($value) |
129 | 129 | { |
130 | 130 | $this->_flags |= self::IS_SET_OVERLINE; |
131 | - if(TPropertyValue::ensureBoolean($value)) |
|
131 | + if (TPropertyValue::ensureBoolean($value)) |
|
132 | 132 | $this->_flags |= self::IS_OVERLINE; |
133 | 133 | else |
134 | 134 | $this->_flags &= ~self::IS_OVERLINE; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | public function setStrikeout($value) |
166 | 166 | { |
167 | 167 | $this->_flags |= self::IS_SET_STRIKEOUT; |
168 | - if(TPropertyValue::ensureBoolean($value)) |
|
168 | + if (TPropertyValue::ensureBoolean($value)) |
|
169 | 169 | $this->_flags |= self::IS_STRIKEOUT; |
170 | 170 | else |
171 | 171 | $this->_flags &= ~self::IS_STRIKEOUT; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | public function setUnderline($value) |
186 | 186 | { |
187 | 187 | $this->_flags |= self::IS_SET_UNDERLINE; |
188 | - if(TPropertyValue::ensureBoolean($value)) |
|
188 | + if (TPropertyValue::ensureBoolean($value)) |
|
189 | 189 | $this->_flags |= self::IS_UNDERLINE; |
190 | 190 | else |
191 | 191 | $this->_flags &= ~self::IS_UNDERLINE; |
@@ -234,21 +234,21 @@ discard block |
||
234 | 234 | */ |
235 | 235 | public function mergeWith($font) |
236 | 236 | { |
237 | - if($font === null || $font->_flags === 0) |
|
237 | + if ($font === null || $font->_flags === 0) |
|
238 | 238 | return; |
239 | - if(!($this->_flags & self::IS_SET_BOLD) && ($font->_flags & self::IS_SET_BOLD)) |
|
239 | + if (!($this->_flags & self::IS_SET_BOLD) && ($font->_flags & self::IS_SET_BOLD)) |
|
240 | 240 | $this->setBold($font->getBold()); |
241 | - if(!($this->_flags & self::IS_SET_ITALIC) && ($font->_flags & self::IS_SET_ITALIC)) |
|
241 | + if (!($this->_flags & self::IS_SET_ITALIC) && ($font->_flags & self::IS_SET_ITALIC)) |
|
242 | 242 | $this->setItalic($font->getItalic()); |
243 | - if(!($this->_flags & self::IS_SET_OVERLINE) && ($font->_flags & self::IS_SET_OVERLINE)) |
|
243 | + if (!($this->_flags & self::IS_SET_OVERLINE) && ($font->_flags & self::IS_SET_OVERLINE)) |
|
244 | 244 | $this->setOverline($font->getOverline()); |
245 | - if(!($this->_flags & self::IS_SET_STRIKEOUT) && ($font->_flags & self::IS_SET_STRIKEOUT)) |
|
245 | + if (!($this->_flags & self::IS_SET_STRIKEOUT) && ($font->_flags & self::IS_SET_STRIKEOUT)) |
|
246 | 246 | $this->setStrikeout($font->getStrikeout()); |
247 | - if(!($this->_flags & self::IS_SET_UNDERLINE) && ($font->_flags & self::IS_SET_UNDERLINE)) |
|
247 | + if (!($this->_flags & self::IS_SET_UNDERLINE) && ($font->_flags & self::IS_SET_UNDERLINE)) |
|
248 | 248 | $this->setUnderline($font->getUnderline()); |
249 | - if(!($this->_flags & self::IS_SET_SIZE) && ($font->_flags & self::IS_SET_SIZE)) |
|
249 | + if (!($this->_flags & self::IS_SET_SIZE) && ($font->_flags & self::IS_SET_SIZE)) |
|
250 | 250 | $this->setSize($font->getSize()); |
251 | - if(!($this->_flags & self::IS_SET_NAME) && ($font->_flags & self::IS_SET_NAME)) |
|
251 | + if (!($this->_flags & self::IS_SET_NAME) && ($font->_flags & self::IS_SET_NAME)) |
|
252 | 252 | $this->setName($font->getName()); |
253 | 253 | } |
254 | 254 | |
@@ -260,21 +260,21 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function copyFrom($font) |
262 | 262 | { |
263 | - if($font === null || $font->_flags === 0) |
|
263 | + if ($font === null || $font->_flags === 0) |
|
264 | 264 | return; |
265 | - if($font->_flags & self::IS_SET_BOLD) |
|
265 | + if ($font->_flags & self::IS_SET_BOLD) |
|
266 | 266 | $this->setBold($font->getBold()); |
267 | - if($font->_flags & self::IS_SET_ITALIC) |
|
267 | + if ($font->_flags & self::IS_SET_ITALIC) |
|
268 | 268 | $this->setItalic($font->getItalic()); |
269 | - if($font->_flags & self::IS_SET_OVERLINE) |
|
269 | + if ($font->_flags & self::IS_SET_OVERLINE) |
|
270 | 270 | $this->setOverline($font->getOverline()); |
271 | - if($font->_flags & self::IS_SET_STRIKEOUT) |
|
271 | + if ($font->_flags & self::IS_SET_STRIKEOUT) |
|
272 | 272 | $this->setStrikeout($font->getStrikeout()); |
273 | - if($font->_flags & self::IS_SET_UNDERLINE) |
|
273 | + if ($font->_flags & self::IS_SET_UNDERLINE) |
|
274 | 274 | $this->setUnderline($font->getUnderline()); |
275 | - if($font->_flags & self::IS_SET_SIZE) |
|
275 | + if ($font->_flags & self::IS_SET_SIZE) |
|
276 | 276 | $this->setSize($font->getSize()); |
277 | - if($font->_flags & self::IS_SET_NAME) |
|
277 | + if ($font->_flags & self::IS_SET_NAME) |
|
278 | 278 | $this->setName($font->getName()); |
279 | 279 | } |
280 | 280 | |
@@ -283,27 +283,27 @@ discard block |
||
283 | 283 | */ |
284 | 284 | public function toString() |
285 | 285 | { |
286 | - if($this->_flags === 0) |
|
286 | + if ($this->_flags === 0) |
|
287 | 287 | return ''; |
288 | 288 | $str = ''; |
289 | - if($this->_flags & self::IS_SET_BOLD) |
|
290 | - $str .= 'font-weight:' . (($this->_flags & self::IS_BOLD)?'bold;':'normal;'); |
|
291 | - if($this->_flags & self::IS_SET_ITALIC) |
|
292 | - $str .= 'font-style:' . (($this->_flags & self::IS_ITALIC)?'italic;':'normal;'); |
|
289 | + if ($this->_flags & self::IS_SET_BOLD) |
|
290 | + $str .= 'font-weight:'.(($this->_flags & self::IS_BOLD) ? 'bold;' : 'normal;'); |
|
291 | + if ($this->_flags & self::IS_SET_ITALIC) |
|
292 | + $str .= 'font-style:'.(($this->_flags & self::IS_ITALIC) ? 'italic;' : 'normal;'); |
|
293 | 293 | $textDec = ''; |
294 | - if($this->_flags & self::IS_UNDERLINE) |
|
294 | + if ($this->_flags & self::IS_UNDERLINE) |
|
295 | 295 | $textDec .= 'underline'; |
296 | - if($this->_flags & self::IS_OVERLINE) |
|
296 | + if ($this->_flags & self::IS_OVERLINE) |
|
297 | 297 | $textDec .= ' overline'; |
298 | - if($this->_flags & self::IS_STRIKEOUT) |
|
298 | + if ($this->_flags & self::IS_STRIKEOUT) |
|
299 | 299 | $textDec .= ' line-through'; |
300 | 300 | $textDec = ltrim($textDec); |
301 | - if($textDec !== '') |
|
302 | - $str .= 'text-decoration:' . $textDec . ';'; |
|
303 | - if($this->_size !== '') |
|
304 | - $str .= 'font-size:' . $this->_size . ';'; |
|
305 | - if($this->_name !== '') |
|
306 | - $str .= 'font-family:' . $this->_name . ';'; |
|
301 | + if ($textDec !== '') |
|
302 | + $str .= 'text-decoration:'.$textDec.';'; |
|
303 | + if ($this->_size !== '') |
|
304 | + $str .= 'font-size:'.$this->_size.';'; |
|
305 | + if ($this->_name !== '') |
|
306 | + $str .= 'font-family:'.$this->_name.';'; |
|
307 | 307 | return $str; |
308 | 308 | } |
309 | 309 | |
@@ -313,25 +313,25 @@ discard block |
||
313 | 313 | */ |
314 | 314 | public function addAttributesToRender($writer) |
315 | 315 | { |
316 | - if($this->_flags === 0) |
|
316 | + if ($this->_flags === 0) |
|
317 | 317 | return; |
318 | - if($this->_flags & self::IS_SET_BOLD) |
|
319 | - $writer->addStyleAttribute('font-weight', (($this->_flags & self::IS_BOLD)?'bold':'normal')); |
|
320 | - if($this->_flags & self::IS_SET_ITALIC) |
|
321 | - $writer->addStyleAttribute('font-style', (($this->_flags & self::IS_ITALIC)?'italic':'normal')); |
|
318 | + if ($this->_flags & self::IS_SET_BOLD) |
|
319 | + $writer->addStyleAttribute('font-weight', (($this->_flags & self::IS_BOLD) ? 'bold' : 'normal')); |
|
320 | + if ($this->_flags & self::IS_SET_ITALIC) |
|
321 | + $writer->addStyleAttribute('font-style', (($this->_flags & self::IS_ITALIC) ? 'italic' : 'normal')); |
|
322 | 322 | $textDec = ''; |
323 | - if($this->_flags & self::IS_UNDERLINE) |
|
323 | + if ($this->_flags & self::IS_UNDERLINE) |
|
324 | 324 | $textDec .= 'underline'; |
325 | - if($this->_flags & self::IS_OVERLINE) |
|
325 | + if ($this->_flags & self::IS_OVERLINE) |
|
326 | 326 | $textDec .= ' overline'; |
327 | - if($this->_flags & self::IS_STRIKEOUT) |
|
327 | + if ($this->_flags & self::IS_STRIKEOUT) |
|
328 | 328 | $textDec .= ' line-through'; |
329 | 329 | $textDec = ltrim($textDec); |
330 | - if($textDec !== '') |
|
330 | + if ($textDec !== '') |
|
331 | 331 | $writer->addStyleAttribute('text-decoration', $textDec); |
332 | - if($this->_size !== '') |
|
332 | + if ($this->_size !== '') |
|
333 | 333 | $writer->addStyleAttribute('font-size', $this->_size); |
334 | - if($this->_name !== '') |
|
334 | + if ($this->_name !== '') |
|
335 | 335 | $writer->addStyleAttribute('font-family', $this->_name); |
336 | 336 | } |
337 | 337 | } |
@@ -66,12 +66,15 @@ discard block |
||
66 | 66 | protected function _getZappableSleepProps(&$exprops) |
67 | 67 | { |
68 | 68 | parent::_getZappableSleepProps($exprops); |
69 | - if ($this->_flags === 0) |
|
70 | - $exprops[] = "\0Prado\Web\UI\WebControls\TFont\0_flags"; |
|
71 | - if ($this->_name === '') |
|
72 | - $exprops[] = "\0Prado\Web\UI\WebControls\TFont\0_name"; |
|
73 | - if ($this->_size === '') |
|
74 | - $exprops[] = "\0Prado\Web\UI\WebControls\TFont\0_size"; |
|
69 | + if ($this->_flags === 0) { |
|
70 | + $exprops[] = "\0Prado\Web\UI\WebControls\TFont\0_flags"; |
|
71 | + } |
|
72 | + if ($this->_name === '') { |
|
73 | + $exprops[] = "\0Prado\Web\UI\WebControls\TFont\0_name"; |
|
74 | + } |
|
75 | + if ($this->_size === '') { |
|
76 | + $exprops[] = "\0Prado\Web\UI\WebControls\TFont\0_size"; |
|
77 | + } |
|
75 | 78 | } |
76 | 79 | |
77 | 80 | /** |
@@ -88,10 +91,11 @@ discard block |
||
88 | 91 | public function setBold($value) |
89 | 92 | { |
90 | 93 | $this->_flags |= self::IS_SET_BOLD; |
91 | - if(TPropertyValue::ensureBoolean($value)) |
|
92 | - $this->_flags |= self::IS_BOLD; |
|
93 | - else |
|
94 | - $this->_flags &= ~self::IS_BOLD; |
|
94 | + if(TPropertyValue::ensureBoolean($value)) { |
|
95 | + $this->_flags |= self::IS_BOLD; |
|
96 | + } else { |
|
97 | + $this->_flags &= ~self::IS_BOLD; |
|
98 | + } |
|
95 | 99 | } |
96 | 100 | |
97 | 101 | /** |
@@ -108,10 +112,11 @@ discard block |
||
108 | 112 | public function setItalic($value) |
109 | 113 | { |
110 | 114 | $this->_flags |= self::IS_SET_ITALIC; |
111 | - if(TPropertyValue::ensureBoolean($value)) |
|
112 | - $this->_flags |= self::IS_ITALIC; |
|
113 | - else |
|
114 | - $this->_flags &= ~self::IS_ITALIC; |
|
115 | + if(TPropertyValue::ensureBoolean($value)) { |
|
116 | + $this->_flags |= self::IS_ITALIC; |
|
117 | + } else { |
|
118 | + $this->_flags &= ~self::IS_ITALIC; |
|
119 | + } |
|
115 | 120 | } |
116 | 121 | |
117 | 122 | /** |
@@ -128,10 +133,11 @@ discard block |
||
128 | 133 | public function setOverline($value) |
129 | 134 | { |
130 | 135 | $this->_flags |= self::IS_SET_OVERLINE; |
131 | - if(TPropertyValue::ensureBoolean($value)) |
|
132 | - $this->_flags |= self::IS_OVERLINE; |
|
133 | - else |
|
134 | - $this->_flags &= ~self::IS_OVERLINE; |
|
136 | + if(TPropertyValue::ensureBoolean($value)) { |
|
137 | + $this->_flags |= self::IS_OVERLINE; |
|
138 | + } else { |
|
139 | + $this->_flags &= ~self::IS_OVERLINE; |
|
140 | + } |
|
135 | 141 | } |
136 | 142 | |
137 | 143 | /** |
@@ -165,10 +171,11 @@ discard block |
||
165 | 171 | public function setStrikeout($value) |
166 | 172 | { |
167 | 173 | $this->_flags |= self::IS_SET_STRIKEOUT; |
168 | - if(TPropertyValue::ensureBoolean($value)) |
|
169 | - $this->_flags |= self::IS_STRIKEOUT; |
|
170 | - else |
|
171 | - $this->_flags &= ~self::IS_STRIKEOUT; |
|
174 | + if(TPropertyValue::ensureBoolean($value)) { |
|
175 | + $this->_flags |= self::IS_STRIKEOUT; |
|
176 | + } else { |
|
177 | + $this->_flags &= ~self::IS_STRIKEOUT; |
|
178 | + } |
|
172 | 179 | } |
173 | 180 | |
174 | 181 | /** |
@@ -185,10 +192,11 @@ discard block |
||
185 | 192 | public function setUnderline($value) |
186 | 193 | { |
187 | 194 | $this->_flags |= self::IS_SET_UNDERLINE; |
188 | - if(TPropertyValue::ensureBoolean($value)) |
|
189 | - $this->_flags |= self::IS_UNDERLINE; |
|
190 | - else |
|
191 | - $this->_flags &= ~self::IS_UNDERLINE; |
|
195 | + if(TPropertyValue::ensureBoolean($value)) { |
|
196 | + $this->_flags |= self::IS_UNDERLINE; |
|
197 | + } else { |
|
198 | + $this->_flags &= ~self::IS_UNDERLINE; |
|
199 | + } |
|
192 | 200 | } |
193 | 201 | |
194 | 202 | /** |
@@ -234,22 +242,30 @@ discard block |
||
234 | 242 | */ |
235 | 243 | public function mergeWith($font) |
236 | 244 | { |
237 | - if($font === null || $font->_flags === 0) |
|
238 | - return; |
|
239 | - if(!($this->_flags & self::IS_SET_BOLD) && ($font->_flags & self::IS_SET_BOLD)) |
|
240 | - $this->setBold($font->getBold()); |
|
241 | - if(!($this->_flags & self::IS_SET_ITALIC) && ($font->_flags & self::IS_SET_ITALIC)) |
|
242 | - $this->setItalic($font->getItalic()); |
|
243 | - if(!($this->_flags & self::IS_SET_OVERLINE) && ($font->_flags & self::IS_SET_OVERLINE)) |
|
244 | - $this->setOverline($font->getOverline()); |
|
245 | - if(!($this->_flags & self::IS_SET_STRIKEOUT) && ($font->_flags & self::IS_SET_STRIKEOUT)) |
|
246 | - $this->setStrikeout($font->getStrikeout()); |
|
247 | - if(!($this->_flags & self::IS_SET_UNDERLINE) && ($font->_flags & self::IS_SET_UNDERLINE)) |
|
248 | - $this->setUnderline($font->getUnderline()); |
|
249 | - if(!($this->_flags & self::IS_SET_SIZE) && ($font->_flags & self::IS_SET_SIZE)) |
|
250 | - $this->setSize($font->getSize()); |
|
251 | - if(!($this->_flags & self::IS_SET_NAME) && ($font->_flags & self::IS_SET_NAME)) |
|
252 | - $this->setName($font->getName()); |
|
245 | + if($font === null || $font->_flags === 0) { |
|
246 | + return; |
|
247 | + } |
|
248 | + if(!($this->_flags & self::IS_SET_BOLD) && ($font->_flags & self::IS_SET_BOLD)) { |
|
249 | + $this->setBold($font->getBold()); |
|
250 | + } |
|
251 | + if(!($this->_flags & self::IS_SET_ITALIC) && ($font->_flags & self::IS_SET_ITALIC)) { |
|
252 | + $this->setItalic($font->getItalic()); |
|
253 | + } |
|
254 | + if(!($this->_flags & self::IS_SET_OVERLINE) && ($font->_flags & self::IS_SET_OVERLINE)) { |
|
255 | + $this->setOverline($font->getOverline()); |
|
256 | + } |
|
257 | + if(!($this->_flags & self::IS_SET_STRIKEOUT) && ($font->_flags & self::IS_SET_STRIKEOUT)) { |
|
258 | + $this->setStrikeout($font->getStrikeout()); |
|
259 | + } |
|
260 | + if(!($this->_flags & self::IS_SET_UNDERLINE) && ($font->_flags & self::IS_SET_UNDERLINE)) { |
|
261 | + $this->setUnderline($font->getUnderline()); |
|
262 | + } |
|
263 | + if(!($this->_flags & self::IS_SET_SIZE) && ($font->_flags & self::IS_SET_SIZE)) { |
|
264 | + $this->setSize($font->getSize()); |
|
265 | + } |
|
266 | + if(!($this->_flags & self::IS_SET_NAME) && ($font->_flags & self::IS_SET_NAME)) { |
|
267 | + $this->setName($font->getName()); |
|
268 | + } |
|
253 | 269 | } |
254 | 270 | |
255 | 271 | /** |
@@ -260,22 +276,30 @@ discard block |
||
260 | 276 | */ |
261 | 277 | public function copyFrom($font) |
262 | 278 | { |
263 | - if($font === null || $font->_flags === 0) |
|
264 | - return; |
|
265 | - if($font->_flags & self::IS_SET_BOLD) |
|
266 | - $this->setBold($font->getBold()); |
|
267 | - if($font->_flags & self::IS_SET_ITALIC) |
|
268 | - $this->setItalic($font->getItalic()); |
|
269 | - if($font->_flags & self::IS_SET_OVERLINE) |
|
270 | - $this->setOverline($font->getOverline()); |
|
271 | - if($font->_flags & self::IS_SET_STRIKEOUT) |
|
272 | - $this->setStrikeout($font->getStrikeout()); |
|
273 | - if($font->_flags & self::IS_SET_UNDERLINE) |
|
274 | - $this->setUnderline($font->getUnderline()); |
|
275 | - if($font->_flags & self::IS_SET_SIZE) |
|
276 | - $this->setSize($font->getSize()); |
|
277 | - if($font->_flags & self::IS_SET_NAME) |
|
278 | - $this->setName($font->getName()); |
|
279 | + if($font === null || $font->_flags === 0) { |
|
280 | + return; |
|
281 | + } |
|
282 | + if($font->_flags & self::IS_SET_BOLD) { |
|
283 | + $this->setBold($font->getBold()); |
|
284 | + } |
|
285 | + if($font->_flags & self::IS_SET_ITALIC) { |
|
286 | + $this->setItalic($font->getItalic()); |
|
287 | + } |
|
288 | + if($font->_flags & self::IS_SET_OVERLINE) { |
|
289 | + $this->setOverline($font->getOverline()); |
|
290 | + } |
|
291 | + if($font->_flags & self::IS_SET_STRIKEOUT) { |
|
292 | + $this->setStrikeout($font->getStrikeout()); |
|
293 | + } |
|
294 | + if($font->_flags & self::IS_SET_UNDERLINE) { |
|
295 | + $this->setUnderline($font->getUnderline()); |
|
296 | + } |
|
297 | + if($font->_flags & self::IS_SET_SIZE) { |
|
298 | + $this->setSize($font->getSize()); |
|
299 | + } |
|
300 | + if($font->_flags & self::IS_SET_NAME) { |
|
301 | + $this->setName($font->getName()); |
|
302 | + } |
|
279 | 303 | } |
280 | 304 | |
281 | 305 | /** |
@@ -283,27 +307,36 @@ discard block |
||
283 | 307 | */ |
284 | 308 | public function toString() |
285 | 309 | { |
286 | - if($this->_flags === 0) |
|
287 | - return ''; |
|
310 | + if($this->_flags === 0) { |
|
311 | + return ''; |
|
312 | + } |
|
288 | 313 | $str = ''; |
289 | - if($this->_flags & self::IS_SET_BOLD) |
|
290 | - $str .= 'font-weight:' . (($this->_flags & self::IS_BOLD)?'bold;':'normal;'); |
|
291 | - if($this->_flags & self::IS_SET_ITALIC) |
|
292 | - $str .= 'font-style:' . (($this->_flags & self::IS_ITALIC)?'italic;':'normal;'); |
|
314 | + if($this->_flags & self::IS_SET_BOLD) { |
|
315 | + $str .= 'font-weight:' . (($this->_flags & self::IS_BOLD)?'bold;':'normal;'); |
|
316 | + } |
|
317 | + if($this->_flags & self::IS_SET_ITALIC) { |
|
318 | + $str .= 'font-style:' . (($this->_flags & self::IS_ITALIC)?'italic;':'normal;'); |
|
319 | + } |
|
293 | 320 | $textDec = ''; |
294 | - if($this->_flags & self::IS_UNDERLINE) |
|
295 | - $textDec .= 'underline'; |
|
296 | - if($this->_flags & self::IS_OVERLINE) |
|
297 | - $textDec .= ' overline'; |
|
298 | - if($this->_flags & self::IS_STRIKEOUT) |
|
299 | - $textDec .= ' line-through'; |
|
321 | + if($this->_flags & self::IS_UNDERLINE) { |
|
322 | + $textDec .= 'underline'; |
|
323 | + } |
|
324 | + if($this->_flags & self::IS_OVERLINE) { |
|
325 | + $textDec .= ' overline'; |
|
326 | + } |
|
327 | + if($this->_flags & self::IS_STRIKEOUT) { |
|
328 | + $textDec .= ' line-through'; |
|
329 | + } |
|
300 | 330 | $textDec = ltrim($textDec); |
301 | - if($textDec !== '') |
|
302 | - $str .= 'text-decoration:' . $textDec . ';'; |
|
303 | - if($this->_size !== '') |
|
304 | - $str .= 'font-size:' . $this->_size . ';'; |
|
305 | - if($this->_name !== '') |
|
306 | - $str .= 'font-family:' . $this->_name . ';'; |
|
331 | + if($textDec !== '') { |
|
332 | + $str .= 'text-decoration:' . $textDec . ';'; |
|
333 | + } |
|
334 | + if($this->_size !== '') { |
|
335 | + $str .= 'font-size:' . $this->_size . ';'; |
|
336 | + } |
|
337 | + if($this->_name !== '') { |
|
338 | + $str .= 'font-family:' . $this->_name . ';'; |
|
339 | + } |
|
307 | 340 | return $str; |
308 | 341 | } |
309 | 342 | |
@@ -313,25 +346,34 @@ discard block |
||
313 | 346 | */ |
314 | 347 | public function addAttributesToRender($writer) |
315 | 348 | { |
316 | - if($this->_flags === 0) |
|
317 | - return; |
|
318 | - if($this->_flags & self::IS_SET_BOLD) |
|
319 | - $writer->addStyleAttribute('font-weight', (($this->_flags & self::IS_BOLD)?'bold':'normal')); |
|
320 | - if($this->_flags & self::IS_SET_ITALIC) |
|
321 | - $writer->addStyleAttribute('font-style', (($this->_flags & self::IS_ITALIC)?'italic':'normal')); |
|
349 | + if($this->_flags === 0) { |
|
350 | + return; |
|
351 | + } |
|
352 | + if($this->_flags & self::IS_SET_BOLD) { |
|
353 | + $writer->addStyleAttribute('font-weight', (($this->_flags & self::IS_BOLD)?'bold':'normal')); |
|
354 | + } |
|
355 | + if($this->_flags & self::IS_SET_ITALIC) { |
|
356 | + $writer->addStyleAttribute('font-style', (($this->_flags & self::IS_ITALIC)?'italic':'normal')); |
|
357 | + } |
|
322 | 358 | $textDec = ''; |
323 | - if($this->_flags & self::IS_UNDERLINE) |
|
324 | - $textDec .= 'underline'; |
|
325 | - if($this->_flags & self::IS_OVERLINE) |
|
326 | - $textDec .= ' overline'; |
|
327 | - if($this->_flags & self::IS_STRIKEOUT) |
|
328 | - $textDec .= ' line-through'; |
|
359 | + if($this->_flags & self::IS_UNDERLINE) { |
|
360 | + $textDec .= 'underline'; |
|
361 | + } |
|
362 | + if($this->_flags & self::IS_OVERLINE) { |
|
363 | + $textDec .= ' overline'; |
|
364 | + } |
|
365 | + if($this->_flags & self::IS_STRIKEOUT) { |
|
366 | + $textDec .= ' line-through'; |
|
367 | + } |
|
329 | 368 | $textDec = ltrim($textDec); |
330 | - if($textDec !== '') |
|
331 | - $writer->addStyleAttribute('text-decoration', $textDec); |
|
332 | - if($this->_size !== '') |
|
333 | - $writer->addStyleAttribute('font-size', $this->_size); |
|
334 | - if($this->_name !== '') |
|
335 | - $writer->addStyleAttribute('font-family', $this->_name); |
|
369 | + if($textDec !== '') { |
|
370 | + $writer->addStyleAttribute('text-decoration', $textDec); |
|
371 | + } |
|
372 | + if($this->_size !== '') { |
|
373 | + $writer->addStyleAttribute('font-size', $this->_size); |
|
374 | + } |
|
375 | + if($this->_name !== '') { |
|
376 | + $writer->addStyleAttribute('font-family', $this->_name); |
|
377 | + } |
|
336 | 378 | } |
337 | 379 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | */ |
302 | 302 | public function getTimeStamp() |
303 | 303 | { |
304 | - if(trim($this->getText()) === '') |
|
304 | + if (trim($this->getText()) === '') |
|
305 | 305 | return null; |
306 | 306 | else |
307 | 307 | return $this->getTimeStampFromText(); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | */ |
314 | 314 | public function setTimeStamp($value) |
315 | 315 | { |
316 | - if($value === null || (is_string($value) && trim($value) === '')) |
|
316 | + if ($value === null || (is_string($value) && trim($value) === '')) |
|
317 | 317 | $this->setText(''); |
318 | 318 | else |
319 | 319 | { |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | */ |
378 | 378 | public function getClientSide() |
379 | 379 | { |
380 | - if($this->_clientScript === null) |
|
380 | + if ($this->_clientScript === null) |
|
381 | 381 | $this->_clientScript = $this->createClientScript(); |
382 | 382 | return $this->_clientScript; |
383 | 383 | } |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | */ |
398 | 398 | public function getValidationPropertyValue() |
399 | 399 | { |
400 | - if(($text = $this->getText()) === '') |
|
400 | + if (($text = $this->getText()) === '') |
|
401 | 401 | return ''; |
402 | 402 | $date = $this->getTimeStamp(); |
403 | 403 | return $date == null ? $text : $date; |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | */ |
422 | 422 | public function render($writer) |
423 | 423 | { |
424 | - if($this->getInputMode() == TDatePickerInputMode::TextBox) |
|
424 | + if ($this->getInputMode() == TDatePickerInputMode::TextBox) |
|
425 | 425 | { |
426 | 426 | parent::render($writer); |
427 | 427 | $this->renderDatePickerButtons($writer); |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | else |
430 | 430 | { |
431 | 431 | $this->renderDropDownListCalendar($writer); |
432 | - if($this->hasDayPattern()) |
|
432 | + if ($this->hasDayPattern()) |
|
433 | 433 | { |
434 | 434 | $this->renderClientControlScript($writer); |
435 | 435 | $this->renderDatePickerButtons($writer); |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | */ |
443 | 443 | protected function renderDatePickerButtons($writer) |
444 | 444 | { |
445 | - if($this->getShowCalendar()) |
|
445 | + if ($this->getShowCalendar()) |
|
446 | 446 | { |
447 | 447 | switch ($this->getMode()) |
448 | 448 | { |
@@ -466,10 +466,10 @@ discard block |
||
466 | 466 | */ |
467 | 467 | public function loadPostData($key, $values) |
468 | 468 | { |
469 | - if($this->getInputMode() == TDatePickerInputMode::TextBox) |
|
469 | + if ($this->getInputMode() == TDatePickerInputMode::TextBox) |
|
470 | 470 | return parent::loadPostData($key, $values); |
471 | 471 | $value = $this->getDateFromPostData($key, $values); |
472 | - if(!$this->getReadOnly() && $this->getText() !== $value) |
|
472 | + if (!$this->getReadOnly() && $this->getText() !== $value) |
|
473 | 473 | { |
474 | 474 | $this->setText($value); |
475 | 475 | return true; |
@@ -489,26 +489,26 @@ discard block |
||
489 | 489 | $date = @getdate(); |
490 | 490 | |
491 | 491 | $pattern = $this->getDateFormat(); |
492 | - $pattern = str_replace(['MMMM', 'MMM'], ['MM','MM'], $pattern); |
|
492 | + $pattern = str_replace(['MMMM', 'MMM'], ['MM', 'MM'], $pattern); |
|
493 | 493 | $formatter = new TSimpleDateFormatter($pattern); |
494 | 494 | |
495 | 495 | $order = $formatter->getDayMonthYearOrdering(); |
496 | 496 | |
497 | - if(isset($values[$key . '$day'])) { |
|
498 | - $day = intval($values[$key . '$day']); |
|
499 | - } elseif(in_array('day', $order)) { |
|
497 | + if (isset($values[$key.'$day'])) { |
|
498 | + $day = intval($values[$key.'$day']); |
|
499 | + } elseif (in_array('day', $order)) { |
|
500 | 500 | $day = $date['mday']; |
501 | 501 | } else { |
502 | 502 | $day = 1; |
503 | 503 | } |
504 | 504 | |
505 | - if(isset($values[$key . '$month'])) |
|
506 | - $month = intval($values[$key . '$month']) + 1; |
|
505 | + if (isset($values[$key.'$month'])) |
|
506 | + $month = intval($values[$key.'$month']) + 1; |
|
507 | 507 | else |
508 | 508 | $month = $date['mon']; |
509 | 509 | |
510 | - if(isset($values[$key . '$year'])) |
|
511 | - $year = intval($values[$key . '$year']); |
|
510 | + if (isset($values[$key.'$year'])) |
|
511 | + $year = intval($values[$key.'$year']); |
|
512 | 512 | else |
513 | 513 | $year = $date['year']; |
514 | 514 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | //$date = @mktime(0, 0, 0, $month, $day, $year); |
520 | 520 | |
521 | 521 | $pattern = $this->getDateFormat(); |
522 | - $pattern = str_replace(['MMMM', 'MMM'], ['MM','MM'], $pattern); |
|
522 | + $pattern = str_replace(['MMMM', 'MMM'], ['MM', 'MM'], $pattern); |
|
523 | 523 | |
524 | 524 | $formatter = new TSimpleDateFormatter($pattern); |
525 | 525 | return $formatter->format($date); |
@@ -535,12 +535,12 @@ discard block |
||
535 | 535 | $options['InputMode'] = $this->getInputMode(); |
536 | 536 | $options['Format'] = $this->getDateFormat(); |
537 | 537 | $options['FirstDayOfWeek'] = $this->getFirstDayOfWeek(); |
538 | - if(($cssClass = $this->getCssClass()) !== '') |
|
538 | + if (($cssClass = $this->getCssClass()) !== '') |
|
539 | 539 | $options['ClassName'] = $cssClass; |
540 | 540 | $options['CalendarStyle'] = $this->getCalendarStyle(); |
541 | 541 | $options['FromYear'] = $this->getFromYear(); |
542 | 542 | $options['UpToYear'] = $this->getUpToYear(); |
543 | - switch($this->getMode()) |
|
543 | + switch ($this->getMode()) |
|
544 | 544 | { |
545 | 545 | case TDatePickerMode::Basic: |
546 | 546 | break; |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | $options['PositionMode'] = $this->getPositionMode(); |
555 | 555 | |
556 | 556 | $options = array_merge($options, $this->getCulturalOptions()); |
557 | - if($this->_clientScript !== null) |
|
557 | + if ($this->_clientScript !== null) |
|
558 | 558 | $options = array_merge($options, |
559 | 559 | $this->_clientScript->getOptions()->toArray()); |
560 | 560 | return $options; |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | */ |
567 | 567 | protected function getCulturalOptions() |
568 | 568 | { |
569 | - if($this->getCurrentCulture() == 'en') |
|
569 | + if ($this->getCurrentCulture() == 'en') |
|
570 | 570 | return []; |
571 | 571 | |
572 | 572 | $date = $this->getLocalizedCalendarInfo(); |
@@ -603,14 +603,14 @@ discard block |
||
603 | 603 | */ |
604 | 604 | protected function renderDropDownListCalendar($writer) |
605 | 605 | { |
606 | - if($this->getMode() == TDatePickerMode::Basic) |
|
606 | + if ($this->getMode() == TDatePickerMode::Basic) |
|
607 | 607 | $this->setMode(TDatePickerMode::ImageButton); |
608 | 608 | parent::addAttributesToRender($writer); |
609 | 609 | $writer->removeAttribute('name'); |
610 | 610 | $writer->removeAttribute('type'); |
611 | 611 | $writer->addAttribute('id', $this->getClientID()); |
612 | 612 | |
613 | - if(strlen($class = $this->getCssClass()) > 0) |
|
613 | + if (strlen($class = $this->getCssClass()) > 0) |
|
614 | 614 | $writer->addAttribute('class', $class); |
615 | 615 | $writer->renderBeginTag('span'); |
616 | 616 | |
@@ -643,13 +643,13 @@ discard block |
||
643 | 643 | { |
644 | 644 | $formatter = new TSimpleDateFormatter($this->getDateFormat()); |
645 | 645 | |
646 | - foreach($formatter->getDayMonthYearOrdering() as $type) |
|
646 | + foreach ($formatter->getDayMonthYearOrdering() as $type) |
|
647 | 647 | { |
648 | - if($type == 'day') |
|
648 | + if ($type == 'day') |
|
649 | 649 | $this->renderCalendarDayOptions($writer, $date->format('j')); |
650 | - elseif($type == 'month') |
|
650 | + elseif ($type == 'month') |
|
651 | 651 | $this->renderCalendarMonthOptions($writer, $date->format('n')); |
652 | - elseif($type == 'year') |
|
652 | + elseif ($type == 'year') |
|
653 | 653 | $this->renderCalendarYearOptions($writer, $date->format('Y')); |
654 | 654 | } |
655 | 655 | } |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | protected function getTimeStampFromText() |
662 | 662 | { |
663 | 663 | $pattern = $this->getDateFormat(); |
664 | - $pattern = str_replace(['MMMM', 'MMM'], ['MM','MM'], $pattern); |
|
664 | + $pattern = str_replace(['MMMM', 'MMM'], ['MM', 'MM'], $pattern); |
|
665 | 665 | $formatter = new TSimpleDateFormatter($pattern); |
666 | 666 | return $formatter->parse($this->getText()); |
667 | 667 | } |
@@ -674,10 +674,10 @@ discard block |
||
674 | 674 | */ |
675 | 675 | private function renderDropDownListOptions($writer, $options, $selected = null) |
676 | 676 | { |
677 | - foreach($options as $k => $v) |
|
677 | + foreach ($options as $k => $v) |
|
678 | 678 | { |
679 | 679 | $writer->addAttribute('value', $k); |
680 | - if($k == $selected) |
|
680 | + if ($k == $selected) |
|
681 | 681 | $writer->addAttribute('selected', 'selected'); |
682 | 682 | $writer->renderBeginTag('option'); |
683 | 683 | $writer->write($v); |
@@ -693,10 +693,10 @@ discard block |
||
693 | 693 | protected function renderCalendarDayOptions($writer, $selected = null) |
694 | 694 | { |
695 | 695 | $days = $this->getDropDownDayOptions(); |
696 | - $writer->addAttribute('id', $this->getClientID() . TControl::CLIENT_ID_SEPARATOR . 'day'); |
|
697 | - $writer->addAttribute('name', $this->getUniqueID() . TControl::ID_SEPARATOR . 'day'); |
|
696 | + $writer->addAttribute('id', $this->getClientID().TControl::CLIENT_ID_SEPARATOR.'day'); |
|
697 | + $writer->addAttribute('name', $this->getUniqueID().TControl::ID_SEPARATOR.'day'); |
|
698 | 698 | $writer->addAttribute('class', 'datepicker_day_options'); |
699 | - if($this->getReadOnly() || !$this->getEnabled(true)) |
|
699 | + if ($this->getReadOnly() || !$this->getEnabled(true)) |
|
700 | 700 | $writer->addAttribute('disabled', 'disabled'); |
701 | 701 | $writer->renderBeginTag('select'); |
702 | 702 | $this->renderDropDownListOptions($writer, $days, $selected); |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | $formatter = new TSimpleDateFormatter($this->getDateFormat()); |
712 | 712 | $days = []; |
713 | 713 | $requiresPadding = $formatter->getDayPattern() === 'dd'; |
714 | - for($i = 1;$i <= 31;$i++) |
|
714 | + for ($i = 1; $i <= 31; $i++) |
|
715 | 715 | { |
716 | 716 | $days[$i] = $requiresPadding ? str_pad($i, 2, '0', STR_PAD_LEFT) : $i; |
717 | 717 | } |
@@ -726,10 +726,10 @@ discard block |
||
726 | 726 | protected function renderCalendarMonthOptions($writer, $selected = null) |
727 | 727 | { |
728 | 728 | $info = $this->getLocalizedCalendarInfo(); |
729 | - $writer->addAttribute('id', $this->getClientID() . TControl::CLIENT_ID_SEPARATOR . 'month'); |
|
730 | - $writer->addAttribute('name', $this->getUniqueID() . TControl::ID_SEPARATOR . 'month'); |
|
729 | + $writer->addAttribute('id', $this->getClientID().TControl::CLIENT_ID_SEPARATOR.'month'); |
|
730 | + $writer->addAttribute('name', $this->getUniqueID().TControl::ID_SEPARATOR.'month'); |
|
731 | 731 | $writer->addAttribute('class', 'datepicker_month_options'); |
732 | - if($this->getReadOnly() || !$this->getEnabled(true)) |
|
732 | + if ($this->getReadOnly() || !$this->getEnabled(true)) |
|
733 | 733 | $writer->addAttribute('disabled', 'disabled'); |
734 | 734 | $writer->renderBeginTag('select'); |
735 | 735 | $this->renderDropDownListOptions($writer, |
@@ -747,16 +747,16 @@ discard block |
||
747 | 747 | protected function getLocalizedMonthNames($info) |
748 | 748 | { |
749 | 749 | $formatter = new TSimpleDateFormatter($this->getDateFormat()); |
750 | - switch($formatter->getMonthPattern()) |
|
750 | + switch ($formatter->getMonthPattern()) |
|
751 | 751 | { |
752 | 752 | case 'MMM': return $info->getAbbreviatedMonthNames(); |
753 | 753 | case 'MM': |
754 | 754 | $array = []; |
755 | - for($i = 1;$i <= 12;$i++) |
|
756 | - $array[$i - 1] = $i < 10 ? '0' . $i : $i; |
|
755 | + for ($i = 1; $i <= 12; $i++) |
|
756 | + $array[$i - 1] = $i < 10 ? '0'.$i : $i; |
|
757 | 757 | return $array; |
758 | 758 | case 'M': |
759 | - $array = []; for($i = 1;$i <= 12;$i++) $array[$i - 1] = $i; |
|
759 | + $array = []; for ($i = 1; $i <= 12; $i++) $array[$i - 1] = $i; |
|
760 | 760 | return $array; |
761 | 761 | default : return $info->getMonthNames(); |
762 | 762 | } |
@@ -770,12 +770,12 @@ discard block |
||
770 | 770 | protected function renderCalendarYearOptions($writer, $selected = null) |
771 | 771 | { |
772 | 772 | $years = []; |
773 | - for($i = $this->getFromYear(); $i <= $this->getUpToYear(); $i++) |
|
773 | + for ($i = $this->getFromYear(); $i <= $this->getUpToYear(); $i++) |
|
774 | 774 | $years[$i] = $i; |
775 | - $writer->addAttribute('id', $this->getClientID() . TControl::CLIENT_ID_SEPARATOR . 'year'); |
|
776 | - $writer->addAttribute('name', $this->getUniqueID() . TControl::ID_SEPARATOR . 'year'); |
|
775 | + $writer->addAttribute('id', $this->getClientID().TControl::CLIENT_ID_SEPARATOR.'year'); |
|
776 | + $writer->addAttribute('name', $this->getUniqueID().TControl::ID_SEPARATOR.'year'); |
|
777 | 777 | $writer->addAttribute('class', 'datepicker_year_options'); |
778 | - if($this->getReadOnly() || !$this->getEnabled(true)) |
|
778 | + if ($this->getReadOnly() || !$this->getEnabled(true)) |
|
779 | 779 | $writer->addAttribute('disabled', 'disabled'); |
780 | 780 | $writer->renderBeginTag('select'); |
781 | 781 | $this->renderDropDownListOptions($writer, $years, $selected); |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | */ |
789 | 789 | protected function getDatePickerButtonID() |
790 | 790 | { |
791 | - return $this->getClientID() . 'button'; |
|
791 | + return $this->getClientID().'button'; |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | /** |
@@ -799,9 +799,9 @@ discard block |
||
799 | 799 | { |
800 | 800 | $writer->addAttribute('id', $this->getDatePickerButtonID()); |
801 | 801 | $writer->addAttribute('type', 'button'); |
802 | - $writer->addAttribute('class', $this->getCssClass() . ' TDatePickerButton'); |
|
802 | + $writer->addAttribute('class', $this->getCssClass().' TDatePickerButton'); |
|
803 | 803 | $writer->addAttribute('value', $this->getButtonText()); |
804 | - if(!$this->getEnabled(true)) |
|
804 | + if (!$this->getEnabled(true)) |
|
805 | 805 | $writer->addAttribute('disabled', 'disabled'); |
806 | 806 | $writer->renderBeginTag("input"); |
807 | 807 | $writer->renderEndTag(); |
@@ -818,8 +818,8 @@ discard block |
||
818 | 818 | $writer->addAttribute('id', $this->getDatePickerButtonID()); |
819 | 819 | $writer->addAttribute('src', $url); |
820 | 820 | $writer->addAttribute('alt', ' '); |
821 | - $writer->addAttribute('class', $this->getCssClass() . ' TDatePickerImageButton'); |
|
822 | - if(!$this->getEnabled(true)) |
|
821 | + $writer->addAttribute('class', $this->getCssClass().' TDatePickerImageButton'); |
|
822 | + if (!$this->getEnabled(true)) |
|
823 | 823 | $writer->addAttribute('disabled', 'disabled'); |
824 | 824 | $writer->addAttribute('type', 'image'); |
825 | 825 | $writer->addAttribute('onclick', 'return false;'); |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | protected function getAssetUrl($file = '') |
835 | 835 | { |
836 | 836 | $base = $this->getPage()->getClientScript()->getPradoScriptAssetUrl(); |
837 | - return $base . '/' . self::SCRIPT_PATH . '/' . $file; |
|
837 | + return $base.'/'.self::SCRIPT_PATH.'/'.$file; |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | /** |
@@ -843,9 +843,9 @@ discard block |
||
843 | 843 | */ |
844 | 844 | protected function publishCalendarStyle() |
845 | 845 | { |
846 | - $url = $this->getAssetUrl($this->getCalendarStyle() . '.css'); |
|
846 | + $url = $this->getAssetUrl($this->getCalendarStyle().'.css'); |
|
847 | 847 | $cs = $this->getPage()->getClientScript(); |
848 | - if(!$cs->isStyleSheetFileRegistered($url)) |
|
848 | + if (!$cs->isStyleSheetFileRegistered($url)) |
|
849 | 849 | $cs->registerStyleSheetFile($url, $url); |
850 | 850 | return $url; |
851 | 851 | } |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | */ |
866 | 866 | protected function registerCalendarClientScriptPre() |
867 | 867 | { |
868 | - if($this->getShowCalendar()) |
|
868 | + if ($this->getShowCalendar()) |
|
869 | 869 | { |
870 | 870 | $cs = $this->getPage()->getClientScript(); |
871 | 871 | $cs->registerPradoScript("datepicker"); |
@@ -874,10 +874,10 @@ discard block |
||
874 | 874 | |
875 | 875 | protected function renderClientControlScript($writer) |
876 | 876 | { |
877 | - if($this->getShowCalendar()) |
|
877 | + if ($this->getShowCalendar()) |
|
878 | 878 | { |
879 | 879 | $cs = $this->getPage()->getClientScript(); |
880 | - if(!$cs->isEndScriptRegistered('TDatePicker.spacer')) |
|
880 | + if (!$cs->isEndScriptRegistered('TDatePicker.spacer')) |
|
881 | 881 | { |
882 | 882 | $spacer = $this->getAssetUrl('spacer.gif'); |
883 | 883 | $code = "Prado.WebUI.TDatePicker.spacer = '$spacer';"; |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | |
887 | 887 | $options = TJavaScript::encode($this->getDatePickerOptions()); |
888 | 888 | $code = "new Prado.WebUI.TDatePicker($options);"; |
889 | - $cs->registerEndScript("prado:" . $this->getClientID(), $code); |
|
889 | + $cs->registerEndScript("prado:".$this->getClientID(), $code); |
|
890 | 890 | } |
891 | 891 | } |
892 | 892 | } |
893 | 893 | \ No newline at end of file |
@@ -301,10 +301,11 @@ discard block |
||
301 | 301 | */ |
302 | 302 | public function getTimeStamp() |
303 | 303 | { |
304 | - if(trim($this->getText()) === '') |
|
305 | - return null; |
|
306 | - else |
|
307 | - return $this->getTimeStampFromText(); |
|
304 | + if(trim($this->getText()) === '') { |
|
305 | + return null; |
|
306 | + } else { |
|
307 | + return $this->getTimeStampFromText(); |
|
308 | + } |
|
308 | 309 | } |
309 | 310 | |
310 | 311 | /** |
@@ -313,9 +314,9 @@ discard block |
||
313 | 314 | */ |
314 | 315 | public function setTimeStamp($value) |
315 | 316 | { |
316 | - if($value === null || (is_string($value) && trim($value) === '')) |
|
317 | - $this->setText(''); |
|
318 | - else |
|
317 | + if($value === null || (is_string($value) && trim($value) === '')) { |
|
318 | + $this->setText(''); |
|
319 | + } else |
|
319 | 320 | { |
320 | 321 | $date = TPropertyValue::ensureFloat($value); |
321 | 322 | $formatter = new TSimpleDateFormatter($this->getDateFormat()); |
@@ -377,8 +378,9 @@ discard block |
||
377 | 378 | */ |
378 | 379 | public function getClientSide() |
379 | 380 | { |
380 | - if($this->_clientScript === null) |
|
381 | - $this->_clientScript = $this->createClientScript(); |
|
381 | + if($this->_clientScript === null) { |
|
382 | + $this->_clientScript = $this->createClientScript(); |
|
383 | + } |
|
382 | 384 | return $this->_clientScript; |
383 | 385 | } |
384 | 386 | |
@@ -397,8 +399,9 @@ discard block |
||
397 | 399 | */ |
398 | 400 | public function getValidationPropertyValue() |
399 | 401 | { |
400 | - if(($text = $this->getText()) === '') |
|
401 | - return ''; |
|
402 | + if(($text = $this->getText()) === '') { |
|
403 | + return ''; |
|
404 | + } |
|
402 | 405 | $date = $this->getTimeStamp(); |
403 | 406 | return $date == null ? $text : $date; |
404 | 407 | } |
@@ -425,8 +428,7 @@ discard block |
||
425 | 428 | { |
426 | 429 | parent::render($writer); |
427 | 430 | $this->renderDatePickerButtons($writer); |
428 | - } |
|
429 | - else |
|
431 | + } else |
|
430 | 432 | { |
431 | 433 | $this->renderDropDownListCalendar($writer); |
432 | 434 | if($this->hasDayPattern()) |
@@ -466,16 +468,17 @@ discard block |
||
466 | 468 | */ |
467 | 469 | public function loadPostData($key, $values) |
468 | 470 | { |
469 | - if($this->getInputMode() == TDatePickerInputMode::TextBox) |
|
470 | - return parent::loadPostData($key, $values); |
|
471 | + if($this->getInputMode() == TDatePickerInputMode::TextBox) { |
|
472 | + return parent::loadPostData($key, $values); |
|
473 | + } |
|
471 | 474 | $value = $this->getDateFromPostData($key, $values); |
472 | 475 | if(!$this->getReadOnly() && $this->getText() !== $value) |
473 | 476 | { |
474 | 477 | $this->setText($value); |
475 | 478 | return true; |
479 | + } else { |
|
480 | + return false; |
|
476 | 481 | } |
477 | - else |
|
478 | - return false; |
|
479 | 482 | } |
480 | 483 | |
481 | 484 | /** |
@@ -502,15 +505,17 @@ discard block |
||
502 | 505 | $day = 1; |
503 | 506 | } |
504 | 507 | |
505 | - if(isset($values[$key . '$month'])) |
|
506 | - $month = intval($values[$key . '$month']) + 1; |
|
507 | - else |
|
508 | - $month = $date['mon']; |
|
508 | + if(isset($values[$key . '$month'])) { |
|
509 | + $month = intval($values[$key . '$month']) + 1; |
|
510 | + } else { |
|
511 | + $month = $date['mon']; |
|
512 | + } |
|
509 | 513 | |
510 | - if(isset($values[$key . '$year'])) |
|
511 | - $year = intval($values[$key . '$year']); |
|
512 | - else |
|
513 | - $year = $date['year']; |
|
514 | + if(isset($values[$key . '$year'])) { |
|
515 | + $year = intval($values[$key . '$year']); |
|
516 | + } else { |
|
517 | + $year = $date['year']; |
|
518 | + } |
|
514 | 519 | |
515 | 520 | $s = new \DateTime; |
516 | 521 | $s->setDate($year, $month, $day); |
@@ -535,8 +540,9 @@ discard block |
||
535 | 540 | $options['InputMode'] = $this->getInputMode(); |
536 | 541 | $options['Format'] = $this->getDateFormat(); |
537 | 542 | $options['FirstDayOfWeek'] = $this->getFirstDayOfWeek(); |
538 | - if(($cssClass = $this->getCssClass()) !== '') |
|
539 | - $options['ClassName'] = $cssClass; |
|
543 | + if(($cssClass = $this->getCssClass()) !== '') { |
|
544 | + $options['ClassName'] = $cssClass; |
|
545 | + } |
|
540 | 546 | $options['CalendarStyle'] = $this->getCalendarStyle(); |
541 | 547 | $options['FromYear'] = $this->getFromYear(); |
542 | 548 | $options['UpToYear'] = $this->getUpToYear(); |
@@ -554,9 +560,10 @@ discard block |
||
554 | 560 | $options['PositionMode'] = $this->getPositionMode(); |
555 | 561 | |
556 | 562 | $options = array_merge($options, $this->getCulturalOptions()); |
557 | - if($this->_clientScript !== null) |
|
558 | - $options = array_merge($options, |
|
563 | + if($this->_clientScript !== null) { |
|
564 | + $options = array_merge($options, |
|
559 | 565 | $this->_clientScript->getOptions()->toArray()); |
566 | + } |
|
560 | 567 | return $options; |
561 | 568 | } |
562 | 569 | |
@@ -566,8 +573,9 @@ discard block |
||
566 | 573 | */ |
567 | 574 | protected function getCulturalOptions() |
568 | 575 | { |
569 | - if($this->getCurrentCulture() == 'en') |
|
570 | - return []; |
|
576 | + if($this->getCurrentCulture() == 'en') { |
|
577 | + return []; |
|
578 | + } |
|
571 | 579 | |
572 | 580 | $date = $this->getLocalizedCalendarInfo(); |
573 | 581 | $options['MonthNames'] = $date->getMonthNames(); |
@@ -603,15 +611,17 @@ discard block |
||
603 | 611 | */ |
604 | 612 | protected function renderDropDownListCalendar($writer) |
605 | 613 | { |
606 | - if($this->getMode() == TDatePickerMode::Basic) |
|
607 | - $this->setMode(TDatePickerMode::ImageButton); |
|
614 | + if($this->getMode() == TDatePickerMode::Basic) { |
|
615 | + $this->setMode(TDatePickerMode::ImageButton); |
|
616 | + } |
|
608 | 617 | parent::addAttributesToRender($writer); |
609 | 618 | $writer->removeAttribute('name'); |
610 | 619 | $writer->removeAttribute('type'); |
611 | 620 | $writer->addAttribute('id', $this->getClientID()); |
612 | 621 | |
613 | - if(strlen($class = $this->getCssClass()) > 0) |
|
614 | - $writer->addAttribute('class', $class); |
|
622 | + if(strlen($class = $this->getCssClass()) > 0) { |
|
623 | + $writer->addAttribute('class', $class); |
|
624 | + } |
|
615 | 625 | $writer->renderBeginTag('span'); |
616 | 626 | |
617 | 627 | $date = new \DateTime; |
@@ -645,12 +655,13 @@ discard block |
||
645 | 655 | |
646 | 656 | foreach($formatter->getDayMonthYearOrdering() as $type) |
647 | 657 | { |
648 | - if($type == 'day') |
|
649 | - $this->renderCalendarDayOptions($writer, $date->format('j')); |
|
650 | - elseif($type == 'month') |
|
651 | - $this->renderCalendarMonthOptions($writer, $date->format('n')); |
|
652 | - elseif($type == 'year') |
|
653 | - $this->renderCalendarYearOptions($writer, $date->format('Y')); |
|
658 | + if($type == 'day') { |
|
659 | + $this->renderCalendarDayOptions($writer, $date->format('j')); |
|
660 | + } elseif($type == 'month') { |
|
661 | + $this->renderCalendarMonthOptions($writer, $date->format('n')); |
|
662 | + } elseif($type == 'year') { |
|
663 | + $this->renderCalendarYearOptions($writer, $date->format('Y')); |
|
664 | + } |
|
654 | 665 | } |
655 | 666 | } |
656 | 667 | |
@@ -677,8 +688,9 @@ discard block |
||
677 | 688 | foreach($options as $k => $v) |
678 | 689 | { |
679 | 690 | $writer->addAttribute('value', $k); |
680 | - if($k == $selected) |
|
681 | - $writer->addAttribute('selected', 'selected'); |
|
691 | + if($k == $selected) { |
|
692 | + $writer->addAttribute('selected', 'selected'); |
|
693 | + } |
|
682 | 694 | $writer->renderBeginTag('option'); |
683 | 695 | $writer->write($v); |
684 | 696 | $writer->renderEndTag(); |
@@ -696,8 +708,9 @@ discard block |
||
696 | 708 | $writer->addAttribute('id', $this->getClientID() . TControl::CLIENT_ID_SEPARATOR . 'day'); |
697 | 709 | $writer->addAttribute('name', $this->getUniqueID() . TControl::ID_SEPARATOR . 'day'); |
698 | 710 | $writer->addAttribute('class', 'datepicker_day_options'); |
699 | - if($this->getReadOnly() || !$this->getEnabled(true)) |
|
700 | - $writer->addAttribute('disabled', 'disabled'); |
|
711 | + if($this->getReadOnly() || !$this->getEnabled(true)) { |
|
712 | + $writer->addAttribute('disabled', 'disabled'); |
|
713 | + } |
|
701 | 714 | $writer->renderBeginTag('select'); |
702 | 715 | $this->renderDropDownListOptions($writer, $days, $selected); |
703 | 716 | $writer->renderEndTag(); |
@@ -729,8 +742,9 @@ discard block |
||
729 | 742 | $writer->addAttribute('id', $this->getClientID() . TControl::CLIENT_ID_SEPARATOR . 'month'); |
730 | 743 | $writer->addAttribute('name', $this->getUniqueID() . TControl::ID_SEPARATOR . 'month'); |
731 | 744 | $writer->addAttribute('class', 'datepicker_month_options'); |
732 | - if($this->getReadOnly() || !$this->getEnabled(true)) |
|
733 | - $writer->addAttribute('disabled', 'disabled'); |
|
745 | + if($this->getReadOnly() || !$this->getEnabled(true)) { |
|
746 | + $writer->addAttribute('disabled', 'disabled'); |
|
747 | + } |
|
734 | 748 | $writer->renderBeginTag('select'); |
735 | 749 | $this->renderDropDownListOptions($writer, |
736 | 750 | $this->getLocalizedMonthNames($info), $selected - 1); |
@@ -752,11 +766,14 @@ discard block |
||
752 | 766 | case 'MMM': return $info->getAbbreviatedMonthNames(); |
753 | 767 | case 'MM': |
754 | 768 | $array = []; |
755 | - for($i = 1;$i <= 12;$i++) |
|
756 | - $array[$i - 1] = $i < 10 ? '0' . $i : $i; |
|
769 | + for($i = 1;$i <= 12;$i++) { |
|
770 | + $array[$i - 1] = $i < 10 ? '0' . $i : $i; |
|
771 | + } |
|
757 | 772 | return $array; |
758 | 773 | case 'M': |
759 | - $array = []; for($i = 1;$i <= 12;$i++) $array[$i - 1] = $i; |
|
774 | + $array = []; for($i = 1;$i <= 12;$i++) { |
|
775 | + $array[$i - 1] = $i; |
|
776 | + } |
|
760 | 777 | return $array; |
761 | 778 | default : return $info->getMonthNames(); |
762 | 779 | } |
@@ -770,13 +787,15 @@ discard block |
||
770 | 787 | protected function renderCalendarYearOptions($writer, $selected = null) |
771 | 788 | { |
772 | 789 | $years = []; |
773 | - for($i = $this->getFromYear(); $i <= $this->getUpToYear(); $i++) |
|
774 | - $years[$i] = $i; |
|
790 | + for($i = $this->getFromYear(); $i <= $this->getUpToYear(); $i++) { |
|
791 | + $years[$i] = $i; |
|
792 | + } |
|
775 | 793 | $writer->addAttribute('id', $this->getClientID() . TControl::CLIENT_ID_SEPARATOR . 'year'); |
776 | 794 | $writer->addAttribute('name', $this->getUniqueID() . TControl::ID_SEPARATOR . 'year'); |
777 | 795 | $writer->addAttribute('class', 'datepicker_year_options'); |
778 | - if($this->getReadOnly() || !$this->getEnabled(true)) |
|
779 | - $writer->addAttribute('disabled', 'disabled'); |
|
796 | + if($this->getReadOnly() || !$this->getEnabled(true)) { |
|
797 | + $writer->addAttribute('disabled', 'disabled'); |
|
798 | + } |
|
780 | 799 | $writer->renderBeginTag('select'); |
781 | 800 | $this->renderDropDownListOptions($writer, $years, $selected); |
782 | 801 | $writer->renderEndTag(); |
@@ -801,8 +820,9 @@ discard block |
||
801 | 820 | $writer->addAttribute('type', 'button'); |
802 | 821 | $writer->addAttribute('class', $this->getCssClass() . ' TDatePickerButton'); |
803 | 822 | $writer->addAttribute('value', $this->getButtonText()); |
804 | - if(!$this->getEnabled(true)) |
|
805 | - $writer->addAttribute('disabled', 'disabled'); |
|
823 | + if(!$this->getEnabled(true)) { |
|
824 | + $writer->addAttribute('disabled', 'disabled'); |
|
825 | + } |
|
806 | 826 | $writer->renderBeginTag("input"); |
807 | 827 | $writer->renderEndTag(); |
808 | 828 | } |
@@ -819,8 +839,9 @@ discard block |
||
819 | 839 | $writer->addAttribute('src', $url); |
820 | 840 | $writer->addAttribute('alt', ' '); |
821 | 841 | $writer->addAttribute('class', $this->getCssClass() . ' TDatePickerImageButton'); |
822 | - if(!$this->getEnabled(true)) |
|
823 | - $writer->addAttribute('disabled', 'disabled'); |
|
842 | + if(!$this->getEnabled(true)) { |
|
843 | + $writer->addAttribute('disabled', 'disabled'); |
|
844 | + } |
|
824 | 845 | $writer->addAttribute('type', 'image'); |
825 | 846 | $writer->addAttribute('onclick', 'return false;'); |
826 | 847 | $writer->renderBeginTag('input'); |
@@ -845,8 +866,9 @@ discard block |
||
845 | 866 | { |
846 | 867 | $url = $this->getAssetUrl($this->getCalendarStyle() . '.css'); |
847 | 868 | $cs = $this->getPage()->getClientScript(); |
848 | - if(!$cs->isStyleSheetFileRegistered($url)) |
|
849 | - $cs->registerStyleSheetFile($url, $url); |
|
869 | + if(!$cs->isStyleSheetFileRegistered($url)) { |
|
870 | + $cs->registerStyleSheetFile($url, $url); |
|
871 | + } |
|
850 | 872 | return $url; |
851 | 873 | } |
852 | 874 |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | $page = $this->getPage(); |
101 | 101 | $page->ensureRenderInForm($this); |
102 | 102 | $writer->addAttribute('type', 'image'); |
103 | - if(($uniqueID = $this->getUniqueID()) !== '') |
|
103 | + if (($uniqueID = $this->getUniqueID()) !== '') |
|
104 | 104 | $writer->addAttribute('name', $uniqueID); |
105 | - if($this->getEnabled(true)) |
|
105 | + if ($this->getEnabled(true)) |
|
106 | 106 | { |
107 | - if($this->getEnableClientScript() && $this->needPostBackScript()) |
|
107 | + if ($this->getEnableClientScript() && $this->needPostBackScript()) |
|
108 | 108 | $this->renderClientControlScript($writer); |
109 | 109 | } |
110 | - elseif($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
110 | + elseif ($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
111 | 111 | $writer->addAttribute('disabled', 'disabled'); |
112 | 112 | parent::addAttributesToRender($writer); |
113 | 113 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected function canCauseValidation() |
139 | 139 | { |
140 | - if($this->getCausesValidation()) |
|
140 | + if ($this->getCausesValidation()) |
|
141 | 141 | { |
142 | 142 | $group = $this->getValidationGroup(); |
143 | 143 | return $this->getPage()->getValidators($group)->getCount() > 0; |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | public function loadPostData($key, $values) |
196 | 196 | { |
197 | 197 | $uid = $this->getUniqueID(); |
198 | - if(isset($values["{$uid}_x"]) && isset($values["{$uid}_y"])) |
|
198 | + if (isset($values["{$uid}_x"]) && isset($values["{$uid}_y"])) |
|
199 | 199 | { |
200 | 200 | $this->_x = intval($values["{$uid}_x"]); |
201 | 201 | $this->_y = intval($values["{$uid}_y"]); |
202 | - if($this->getPage()->getPostBackEventTarget() === null) |
|
202 | + if ($this->getPage()->getPostBackEventTarget() === null) |
|
203 | 203 | $this->getPage()->setPostBackEventTarget($this); |
204 | 204 | $this->_dataChanged = true; |
205 | 205 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public function raisePostBackEvent($param) |
252 | 252 | { |
253 | - if($this->getCausesValidation()) |
|
253 | + if ($this->getCausesValidation()) |
|
254 | 254 | $this->getPage()->validate($this->getValidationGroup()); |
255 | 255 | $this->onClick(new TImageClickEventParameter($this->_x, $this->_y)); |
256 | 256 | $this->onCommand(new \Prado\Web\UI\TCommandEventParameter($this->getCommandName(), $this->getCommandParameter())); |
@@ -100,15 +100,18 @@ discard block |
||
100 | 100 | $page = $this->getPage(); |
101 | 101 | $page->ensureRenderInForm($this); |
102 | 102 | $writer->addAttribute('type', 'image'); |
103 | - if(($uniqueID = $this->getUniqueID()) !== '') |
|
104 | - $writer->addAttribute('name', $uniqueID); |
|
103 | + if(($uniqueID = $this->getUniqueID()) !== '') { |
|
104 | + $writer->addAttribute('name', $uniqueID); |
|
105 | + } |
|
105 | 106 | if($this->getEnabled(true)) |
106 | 107 | { |
107 | - if($this->getEnableClientScript() && $this->needPostBackScript()) |
|
108 | - $this->renderClientControlScript($writer); |
|
109 | - } |
|
110 | - elseif($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
108 | + if($this->getEnableClientScript() && $this->needPostBackScript()) { |
|
109 | + $this->renderClientControlScript($writer); |
|
110 | + } |
|
111 | + } elseif($this->getEnabled()) { |
|
112 | + // in this case, parent will not render 'disabled' |
|
111 | 113 | $writer->addAttribute('disabled', 'disabled'); |
114 | + } |
|
112 | 115 | parent::addAttributesToRender($writer); |
113 | 116 | } |
114 | 117 | |
@@ -141,9 +144,9 @@ discard block |
||
141 | 144 | { |
142 | 145 | $group = $this->getValidationGroup(); |
143 | 146 | return $this->getPage()->getValidators($group)->getCount() > 0; |
147 | + } else { |
|
148 | + return false; |
|
144 | 149 | } |
145 | - else |
|
146 | - return false; |
|
147 | 150 | } |
148 | 151 | |
149 | 152 | /** |
@@ -199,8 +202,9 @@ discard block |
||
199 | 202 | { |
200 | 203 | $this->_x = intval($values["{$uid}_x"]); |
201 | 204 | $this->_y = intval($values["{$uid}_y"]); |
202 | - if($this->getPage()->getPostBackEventTarget() === null) |
|
203 | - $this->getPage()->setPostBackEventTarget($this); |
|
205 | + if($this->getPage()->getPostBackEventTarget() === null) { |
|
206 | + $this->getPage()->setPostBackEventTarget($this); |
|
207 | + } |
|
204 | 208 | $this->_dataChanged = true; |
205 | 209 | } |
206 | 210 | return false; |
@@ -250,8 +254,9 @@ discard block |
||
250 | 254 | */ |
251 | 255 | public function raisePostBackEvent($param) |
252 | 256 | { |
253 | - if($this->getCausesValidation()) |
|
254 | - $this->getPage()->validate($this->getValidationGroup()); |
|
257 | + if($this->getCausesValidation()) { |
|
258 | + $this->getPage()->validate($this->getValidationGroup()); |
|
259 | + } |
|
255 | 260 | $this->onClick(new TImageClickEventParameter($this->_x, $this->_y)); |
256 | 261 | $this->onCommand(new \Prado\Web\UI\TCommandEventParameter($this->getCommandName(), $this->getCommandParameter())); |
257 | 262 | } |
@@ -86,14 +86,14 @@ discard block |
||
86 | 86 | parent::addAttributesToRender($writer); |
87 | 87 | $writer->addAttribute('type', 'file'); |
88 | 88 | $name = $this->getUniqueID(); |
89 | - if($this->getMultiple()) |
|
89 | + if ($this->getMultiple()) |
|
90 | 90 | { |
91 | 91 | $name .= '[]'; |
92 | 92 | $writer->addAttribute('multiple', 'multiple'); |
93 | 93 | } |
94 | 94 | $writer->addAttribute('name', $name); |
95 | 95 | $isEnabled = $this->getEnabled(true); |
96 | - if(!$isEnabled && $this->getEnabled()) // in this case parent will not render 'disabled' |
|
96 | + if (!$isEnabled && $this->getEnabled()) // in this case parent will not render 'disabled' |
|
97 | 97 | $writer->addAttribute('disabled', 'disabled'); |
98 | 98 | } |
99 | 99 | |
@@ -105,15 +105,15 @@ discard block |
||
105 | 105 | public function onPreRender($param) |
106 | 106 | { |
107 | 107 | parent::onPreRender($param); |
108 | - if(($form = $this->getPage()->getForm()) !== null) |
|
108 | + if (($form = $this->getPage()->getForm()) !== null) |
|
109 | 109 | { |
110 | - if($this->getPage()->getIsCallback()) |
|
110 | + if ($this->getPage()->getIsCallback()) |
|
111 | 111 | $this->getPage()->getCallbackClient()->setAttribute($form, 'enctype', 'multipart/form-data'); |
112 | 112 | else |
113 | 113 | $form->setEnctype('multipart/form-data'); |
114 | 114 | } |
115 | 115 | $this->getPage()->getClientScript()->registerHiddenField('MAX_FILE_SIZE', $this->getMaxFileSize()); |
116 | - if($this->getEnabled(true)) |
|
116 | + if ($this->getEnabled(true)) |
|
117 | 117 | $this->getPage()->registerRequiresPostData($this); |
118 | 118 | } |
119 | 119 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function getFileName($index = 0) |
148 | 148 | { |
149 | - return isset($this->_files[$index])?$this->_files[$index]->getFileName():''; |
|
149 | + return isset($this->_files[$index]) ? $this->_files[$index]->getFileName() : ''; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function getFileSize($index = 0) |
158 | 158 | { |
159 | - return isset($this->_files[$index])?$this->_files[$index]->getFileSize():0; |
|
159 | + return isset($this->_files[$index]) ? $this->_files[$index]->getFileSize() : 0; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function getFileType($index = 0) |
169 | 169 | { |
170 | - return isset($this->_files[$index])?$this->_files[$index]->getFileType():''; |
|
170 | + return isset($this->_files[$index]) ? $this->_files[$index]->getFileType() : ''; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function getLocalName($index = 0) |
180 | 180 | { |
181 | - return isset($this->_files[$index])?$this->_files[$index]->getLocalName():''; |
|
181 | + return isset($this->_files[$index]) ? $this->_files[$index]->getLocalName() : ''; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function getErrorCode($index = 0) |
192 | 192 | { |
193 | - return isset($this->_files[$index])?$this->_files[$index]->getErrorCode():UPLOAD_ERR_NO_FILE; |
|
193 | + return isset($this->_files[$index]) ? $this->_files[$index]->getErrorCode() : UPLOAD_ERR_NO_FILE; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function getHasFile($index = 0) |
202 | 202 | { |
203 | - return isset($this->_files[$index])?$this->_files[$index]->getHasFile():false; |
|
203 | + return isset($this->_files[$index]) ? $this->_files[$index]->getHasFile() : false; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | * @return boolean whether all files are uploaded successfully |
209 | 209 | */ |
210 | 210 | public function getHasAllFiles() { |
211 | - foreach($this->_files as $file) |
|
212 | - if(!$file->getHasFile()) |
|
211 | + foreach ($this->_files as $file) |
|
212 | + if (!$file->getHasFile()) |
|
213 | 213 | return false; |
214 | 214 | return true; |
215 | 215 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function saveAs($fileName, $deleteTempFile = true, $index = 0) |
228 | 228 | { |
229 | - return isset($this->_files[$index])?$this->_files[$index]->saveAs($fileName, $deleteTempFile):false; |
|
229 | + return isset($this->_files[$index]) ? $this->_files[$index]->saveAs($fileName, $deleteTempFile) : false; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -238,11 +238,11 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function loadPostData($key, $values) |
240 | 240 | { |
241 | - if(isset($_FILES[$key])) |
|
241 | + if (isset($_FILES[$key])) |
|
242 | 242 | { |
243 | - if($this->getMultiple() || is_array($_FILES[$key]['name'])) |
|
243 | + if ($this->getMultiple() || is_array($_FILES[$key]['name'])) |
|
244 | 244 | { |
245 | - foreach($_FILES[$key]['name'] as $index => $name) |
|
245 | + foreach ($_FILES[$key]['name'] as $index => $name) |
|
246 | 246 | $this->_files[$index] = new TFileUploadItem($name, $_FILES[$key]['size'][$index], $_FILES[$key]['type'][$index], $_FILES[$key]['error'][$index], $_FILES[$key]['tmp_name'][$index]); |
247 | 247 | } |
248 | 248 | else |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function getValidationPropertyValue() |
294 | 294 | { |
295 | - return implode(',', array_map(function($file){return $file->getFileName();}, $this->_files)); |
|
295 | + return implode(',', array_map(function($file) {return $file->getFileName(); }, $this->_files)); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -93,8 +93,10 @@ discard block |
||
93 | 93 | } |
94 | 94 | $writer->addAttribute('name', $name); |
95 | 95 | $isEnabled = $this->getEnabled(true); |
96 | - if(!$isEnabled && $this->getEnabled()) // in this case parent will not render 'disabled' |
|
96 | + if(!$isEnabled && $this->getEnabled()) { |
|
97 | + // in this case parent will not render 'disabled' |
|
97 | 98 | $writer->addAttribute('disabled', 'disabled'); |
99 | + } |
|
98 | 100 | } |
99 | 101 | |
100 | 102 | /** |
@@ -107,14 +109,16 @@ discard block |
||
107 | 109 | parent::onPreRender($param); |
108 | 110 | if(($form = $this->getPage()->getForm()) !== null) |
109 | 111 | { |
110 | - if($this->getPage()->getIsCallback()) |
|
111 | - $this->getPage()->getCallbackClient()->setAttribute($form, 'enctype', 'multipart/form-data'); |
|
112 | - else |
|
113 | - $form->setEnctype('multipart/form-data'); |
|
112 | + if($this->getPage()->getIsCallback()) { |
|
113 | + $this->getPage()->getCallbackClient()->setAttribute($form, 'enctype', 'multipart/form-data'); |
|
114 | + } else { |
|
115 | + $form->setEnctype('multipart/form-data'); |
|
116 | + } |
|
114 | 117 | } |
115 | 118 | $this->getPage()->getClientScript()->registerHiddenField('MAX_FILE_SIZE', $this->getMaxFileSize()); |
116 | - if($this->getEnabled(true)) |
|
117 | - $this->getPage()->registerRequiresPostData($this); |
|
119 | + if($this->getEnabled(true)) { |
|
120 | + $this->getPage()->registerRequiresPostData($this); |
|
121 | + } |
|
118 | 122 | } |
119 | 123 | |
120 | 124 | /** |
@@ -208,9 +212,10 @@ discard block |
||
208 | 212 | * @return boolean whether all files are uploaded successfully |
209 | 213 | */ |
210 | 214 | public function getHasAllFiles() { |
211 | - foreach($this->_files as $file) |
|
212 | - if(!$file->getHasFile()) |
|
215 | + foreach($this->_files as $file) { |
|
216 | + if(!$file->getHasFile()) |
|
213 | 217 | return false; |
218 | + } |
|
214 | 219 | return true; |
215 | 220 | } |
216 | 221 | |
@@ -242,15 +247,16 @@ discard block |
||
242 | 247 | { |
243 | 248 | if($this->getMultiple() || is_array($_FILES[$key]['name'])) |
244 | 249 | { |
245 | - foreach($_FILES[$key]['name'] as $index => $name) |
|
246 | - $this->_files[$index] = new TFileUploadItem($name, $_FILES[$key]['size'][$index], $_FILES[$key]['type'][$index], $_FILES[$key]['error'][$index], $_FILES[$key]['tmp_name'][$index]); |
|
250 | + foreach($_FILES[$key]['name'] as $index => $name) { |
|
251 | + $this->_files[$index] = new TFileUploadItem($name, $_FILES[$key]['size'][$index], $_FILES[$key]['type'][$index], $_FILES[$key]['error'][$index], $_FILES[$key]['tmp_name'][$index]); |
|
252 | + } |
|
253 | + } else { |
|
254 | + $this->_files[0] = new TFileUploadItem($_FILES[$key]['name'], $_FILES[$key]['size'], $_FILES[$key]['type'], $_FILES[$key]['error'], $_FILES[$key]['tmp_name']); |
|
247 | 255 | } |
248 | - else |
|
249 | - $this->_files[0] = new TFileUploadItem($_FILES[$key]['name'], $_FILES[$key]['size'], $_FILES[$key]['type'], $_FILES[$key]['error'], $_FILES[$key]['tmp_name']); |
|
250 | 256 | return $this->_dataChanged = true; |
257 | + } else { |
|
258 | + return false; |
|
251 | 259 | } |
252 | - else |
|
253 | - return false; |
|
254 | 260 | } |
255 | 261 | |
256 | 262 | /** |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | $this->_itemIndex = $itemIndex; |
64 | 64 | $this->_dataSourceIndex = $dataSourceIndex; |
65 | 65 | $this->setItemType($itemType); |
66 | - if($itemType === TListItemType::Header) |
|
66 | + if ($itemType === TListItemType::Header) |
|
67 | 67 | $this->setTableSection(TTableRowSection::Header); |
68 | - elseif($itemType === TListItemType::Footer) |
|
68 | + elseif ($itemType === TListItemType::Footer) |
|
69 | 69 | $this->setTableSection(TTableRowSection::Footer); |
70 | 70 | } |
71 | 71 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function bubbleEvent($sender, $param) |
130 | 130 | { |
131 | - if($param instanceof \Prado\Web\UI\TCommandEventParameter) |
|
131 | + if ($param instanceof \Prado\Web\UI\TCommandEventParameter) |
|
132 | 132 | { |
133 | 133 | $this->raiseBubbleEvent($this, new TDataGridCommandEventParameter($this, $sender, $param)); |
134 | 134 | return true; |
@@ -63,10 +63,11 @@ discard block |
||
63 | 63 | $this->_itemIndex = $itemIndex; |
64 | 64 | $this->_dataSourceIndex = $dataSourceIndex; |
65 | 65 | $this->setItemType($itemType); |
66 | - if($itemType === TListItemType::Header) |
|
67 | - $this->setTableSection(TTableRowSection::Header); |
|
68 | - elseif($itemType === TListItemType::Footer) |
|
69 | - $this->setTableSection(TTableRowSection::Footer); |
|
66 | + if($itemType === TListItemType::Header) { |
|
67 | + $this->setTableSection(TTableRowSection::Header); |
|
68 | + } elseif($itemType === TListItemType::Footer) { |
|
69 | + $this->setTableSection(TTableRowSection::Footer); |
|
70 | + } |
|
70 | 71 | } |
71 | 72 | |
72 | 73 | /** |
@@ -132,8 +133,8 @@ discard block |
||
132 | 133 | { |
133 | 134 | $this->raiseBubbleEvent($this, new TDataGridCommandEventParameter($this, $sender, $param)); |
134 | 135 | return true; |
136 | + } else { |
|
137 | + return false; |
|
135 | 138 | } |
136 | - else |
|
137 | - return false; |
|
138 | 139 | } |
139 | 140 | } |
140 | 141 | \ No newline at end of file |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | parent::_getZappableSleepProps($exprops); |
79 | 79 | if ($this->_attributes === null) |
80 | 80 | $exprops[] = "\0Prado\Web\UI\WebControls\TListItem\0_attributes"; |
81 | - if($this->_text === '') |
|
81 | + if ($this->_text === '') |
|
82 | 82 | $exprops[] = "\0Prado\Web\UI\WebControls\TListItem\0_text"; |
83 | - if($this->_value === '') |
|
83 | + if ($this->_value === '') |
|
84 | 84 | $exprops[] = "\0Prado\Web\UI\WebControls\TListItem\0_value"; |
85 | 85 | if ($this->_enabled === true) |
86 | 86 | $exprops[] = "\0Prado\Web\UI\WebControls\TListItem\0_enabled"; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function getText() |
127 | 127 | { |
128 | - return $this->_text === ''?$this->_value:$this->_text; |
|
128 | + return $this->_text === '' ? $this->_value : $this->_text; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function getValue() |
143 | 143 | { |
144 | - return $this->_value === ''?$this->_text:$this->_value; |
|
144 | + return $this->_value === '' ? $this->_text : $this->_value; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function getAttributes() |
159 | 159 | { |
160 | - if(!$this->_attributes) |
|
160 | + if (!$this->_attributes) |
|
161 | 161 | $this->_attributes = new TAttributeCollection; |
162 | 162 | return $this->_attributes; |
163 | 163 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function hasAttribute($name) |
178 | 178 | { |
179 | - return $this->_attributes?$this->_attributes->contains($name):false; |
|
179 | + return $this->_attributes ? $this->_attributes->contains($name) : false; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function getAttribute($name) |
186 | 186 | { |
187 | - return $this->_attributes?$this->_attributes->itemAt($name):null; |
|
187 | + return $this->_attributes ? $this->_attributes->itemAt($name) : null; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public function removeAttribute($name) |
205 | 205 | { |
206 | - return $this->_attributes?$this->_attributes->remove($name):null; |
|
206 | + return $this->_attributes ? $this->_attributes->remove($name) : null; |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 |
@@ -76,16 +76,21 @@ discard block |
||
76 | 76 | protected function _getZappableSleepProps(&$exprops) |
77 | 77 | { |
78 | 78 | parent::_getZappableSleepProps($exprops); |
79 | - if ($this->_attributes === null) |
|
80 | - $exprops[] = "\0Prado\Web\UI\WebControls\TListItem\0_attributes"; |
|
81 | - if($this->_text === '') |
|
82 | - $exprops[] = "\0Prado\Web\UI\WebControls\TListItem\0_text"; |
|
83 | - if($this->_value === '') |
|
84 | - $exprops[] = "\0Prado\Web\UI\WebControls\TListItem\0_value"; |
|
85 | - if ($this->_enabled === true) |
|
86 | - $exprops[] = "\0Prado\Web\UI\WebControls\TListItem\0_enabled"; |
|
87 | - if ($this->_selected === false) |
|
88 | - $exprops[] = "\0Prado\Web\UI\WebControls\TListItem\0_selected"; |
|
79 | + if ($this->_attributes === null) { |
|
80 | + $exprops[] = "\0Prado\Web\UI\WebControls\TListItem\0_attributes"; |
|
81 | + } |
|
82 | + if($this->_text === '') { |
|
83 | + $exprops[] = "\0Prado\Web\UI\WebControls\TListItem\0_text"; |
|
84 | + } |
|
85 | + if($this->_value === '') { |
|
86 | + $exprops[] = "\0Prado\Web\UI\WebControls\TListItem\0_value"; |
|
87 | + } |
|
88 | + if ($this->_enabled === true) { |
|
89 | + $exprops[] = "\0Prado\Web\UI\WebControls\TListItem\0_enabled"; |
|
90 | + } |
|
91 | + if ($this->_selected === false) { |
|
92 | + $exprops[] = "\0Prado\Web\UI\WebControls\TListItem\0_selected"; |
|
93 | + } |
|
89 | 94 | } |
90 | 95 | |
91 | 96 | /** |
@@ -157,8 +162,9 @@ discard block |
||
157 | 162 | */ |
158 | 163 | public function getAttributes() |
159 | 164 | { |
160 | - if(!$this->_attributes) |
|
161 | - $this->_attributes = new TAttributeCollection; |
|
165 | + if(!$this->_attributes) { |
|
166 | + $this->_attributes = new TAttributeCollection; |
|
167 | + } |
|
162 | 168 | return $this->_attributes; |
163 | 169 | } |
164 | 170 |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | // may be overwritten in the following |
99 | 99 | parent::addAttributesToRender($writer); |
100 | 100 | |
101 | - if($this->getEnabled(true) && $this->getEnableClientScript()) |
|
101 | + if ($this->getEnabled(true) && $this->getEnableClientScript()) |
|
102 | 102 | { |
103 | 103 | $this->renderLinkButtonHref($writer); |
104 | 104 | $this->renderClientControlScript($writer); |
105 | 105 | } |
106 | - elseif($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
106 | + elseif ($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
107 | 107 | $writer->addAttribute('disabled', 'disabled'); |
108 | 108 | } |
109 | 109 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | protected function renderLinkButtonHref($writer) |
141 | 141 | { |
142 | 142 | //create unique no-op url references |
143 | - $nop = "javascript:;//" . $this->getClientID(); |
|
143 | + $nop = "javascript:;//".$this->getClientID(); |
|
144 | 144 | $writer->addAttribute('href', $nop); |
145 | 145 | } |
146 | 146 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function renderContents($writer) |
180 | 180 | { |
181 | - if(($text = $this->getText()) === '') |
|
181 | + if (($text = $this->getText()) === '') |
|
182 | 182 | parent::renderContents($writer); |
183 | 183 | else |
184 | 184 | $writer->write($text); |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public function raisePostBackEvent($param) |
304 | 304 | { |
305 | - if($this->getCausesValidation()) |
|
305 | + if ($this->getCausesValidation()) |
|
306 | 306 | $this->getPage()->validate($this->getValidationGroup()); |
307 | 307 | $this->onClick(null); |
308 | 308 | $this->onCommand(new \Prado\Web\UI\TCommandEventParameter($this->getCommandName(), $this->getCommandParameter())); |
@@ -102,9 +102,10 @@ discard block |
||
102 | 102 | { |
103 | 103 | $this->renderLinkButtonHref($writer); |
104 | 104 | $this->renderClientControlScript($writer); |
105 | - } |
|
106 | - elseif($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
105 | + } elseif($this->getEnabled()) { |
|
106 | + // in this case, parent will not render 'disabled' |
|
107 | 107 | $writer->addAttribute('disabled', 'disabled'); |
108 | + } |
|
108 | 109 | } |
109 | 110 | |
110 | 111 | /** |
@@ -178,10 +179,11 @@ discard block |
||
178 | 179 | */ |
179 | 180 | public function renderContents($writer) |
180 | 181 | { |
181 | - if(($text = $this->getText()) === '') |
|
182 | - parent::renderContents($writer); |
|
183 | - else |
|
184 | - $writer->write($text); |
|
182 | + if(($text = $this->getText()) === '') { |
|
183 | + parent::renderContents($writer); |
|
184 | + } else { |
|
185 | + $writer->write($text); |
|
186 | + } |
|
185 | 187 | } |
186 | 188 | |
187 | 189 | /** |
@@ -302,8 +304,9 @@ discard block |
||
302 | 304 | */ |
303 | 305 | public function raisePostBackEvent($param) |
304 | 306 | { |
305 | - if($this->getCausesValidation()) |
|
306 | - $this->getPage()->validate($this->getValidationGroup()); |
|
307 | + if($this->getCausesValidation()) { |
|
308 | + $this->getPage()->validate($this->getValidationGroup()); |
|
309 | + } |
|
307 | 310 | $this->onClick(null); |
308 | 311 | $this->onCommand(new \Prado\Web\UI\TCommandEventParameter($this->getCommandName(), $this->getCommandParameter())); |
309 | 312 | } |