@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | protected function addAttributesToRender($writer) |
288 | 288 | { |
289 | - if($this->getEnableVisualEdit() && $this->getEnabled(true)) |
|
289 | + if ($this->getEnableVisualEdit() && $this->getEnabled(true)) |
|
290 | 290 | { |
291 | 291 | $writer->addAttribute('id', $this->getClientID()); |
292 | 292 | $this->registerEditorClientScript($writer); |
@@ -333,19 +333,19 @@ discard block |
||
333 | 333 | |
334 | 334 | $options = TJavaScript::encode($options, true, true); |
335 | 335 | $script = "new {$this->getClientClassName()}($options)"; |
336 | - $scripts->registerEndScript('prado:THtmlArea4' . $this->ClientID, $script); |
|
336 | + $scripts->registerEndScript('prado:THtmlArea4'.$this->ClientID, $script); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | protected function copyCustomPlugins() |
340 | 340 | { |
341 | - if($plugins = $this->getCustomPluginPath()) |
|
341 | + if ($plugins = $this->getCustomPluginPath()) |
|
342 | 342 | { |
343 | 343 | $basepath = $this->getPage()->getClientScript()->getPradoScriptAssetPath('tinymce'); |
344 | 344 | $assets = $this->getApplication()->getAssetManager(); |
345 | 345 | $path = is_dir($plugins) ? $plugins : Prado::getPathOfNameSpace($plugins); |
346 | 346 | $name = basename($path); |
347 | - $dest = $basepath . '/plugins/' . $name; |
|
348 | - if(!is_dir($dest) || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
347 | + $dest = $basepath.'/plugins/'.$name; |
|
348 | + if (!is_dir($dest) || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
349 | 349 | $assets->copyDirectory($path, $dest); |
350 | 350 | } |
351 | 351 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | $options['height'] = $this->getHeight(); |
366 | 366 | $options['resize'] = 'both'; |
367 | 367 | $options['menubar'] = false; |
368 | - if($this->getReadOnly()) |
|
368 | + if ($this->getReadOnly()) |
|
369 | 369 | { |
370 | 370 | $options['readonly'] = true; |
371 | 371 | $options['toolbar'] = false; |
@@ -387,11 +387,11 @@ discard block |
||
387 | 387 | { |
388 | 388 | $options = []; |
389 | 389 | $substrings = preg_split('/,\s*\n|\n/', trim($string)); |
390 | - foreach($substrings as $bits) |
|
390 | + foreach ($substrings as $bits) |
|
391 | 391 | { |
392 | 392 | $option = explode(":", $bits, 2); |
393 | 393 | |
394 | - if(count($option) == 2) |
|
394 | + if (count($option) == 2) |
|
395 | 395 | { |
396 | 396 | $value = trim(trim($option[1]), "'\""); |
397 | 397 | if (($s = strtolower($value)) === 'false') |
@@ -410,15 +410,15 @@ discard block |
||
410 | 410 | protected function getLanguageSuffix($culture) |
411 | 411 | { |
412 | 412 | $app = $this->getApplication()->getGlobalization(); |
413 | - if(empty($culture) && ($app !== null)) |
|
413 | + if (empty($culture) && ($app !== null)) |
|
414 | 414 | $culture = $app->getCulture(); |
415 | 415 | $variants = []; |
416 | - if($app !== null) |
|
416 | + if ($app !== null) |
|
417 | 417 | $variants = $app->getCultureVariants($culture); |
418 | 418 | |
419 | - foreach($variants as $variant) |
|
419 | + foreach ($variants as $variant) |
|
420 | 420 | { |
421 | - if(isset(self::$_langs[$variant])) |
|
421 | + if (isset(self::$_langs[$variant])) |
|
422 | 422 | return self::$_langs[$variant]; |
423 | 423 | } |
424 | 424 |
@@ -345,8 +345,9 @@ discard block |
||
345 | 345 | $path = is_dir($plugins) ? $plugins : Prado::getPathOfNameSpace($plugins); |
346 | 346 | $name = basename($path); |
347 | 347 | $dest = $basepath . '/plugins/' . $name; |
348 | - if(!is_dir($dest) || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
349 | - $assets->copyDirectory($path, $dest); |
|
348 | + if(!is_dir($dest) || $this->getApplication()->getMode() !== TApplicationMode::Performance) { |
|
349 | + $assets->copyDirectory($path, $dest); |
|
350 | + } |
|
350 | 351 | } |
351 | 352 | } |
352 | 353 | |
@@ -394,10 +395,11 @@ discard block |
||
394 | 395 | if(count($option) == 2) |
395 | 396 | { |
396 | 397 | $value = trim(trim($option[1]), "'\""); |
397 | - if (($s = strtolower($value)) === 'false') |
|
398 | - $value = false; |
|
399 | - elseif ($s === 'true') |
|
400 | - $value = true; |
|
398 | + if (($s = strtolower($value)) === 'false') { |
|
399 | + $value = false; |
|
400 | + } elseif ($s === 'true') { |
|
401 | + $value = true; |
|
402 | + } |
|
401 | 403 | $options[trim($option[0])] = $value; |
402 | 404 | } |
403 | 405 | } |
@@ -410,16 +412,19 @@ discard block |
||
410 | 412 | protected function getLanguageSuffix($culture) |
411 | 413 | { |
412 | 414 | $app = $this->getApplication()->getGlobalization(); |
413 | - if(empty($culture) && ($app !== null)) |
|
414 | - $culture = $app->getCulture(); |
|
415 | + if(empty($culture) && ($app !== null)) { |
|
416 | + $culture = $app->getCulture(); |
|
417 | + } |
|
415 | 418 | $variants = []; |
416 | - if($app !== null) |
|
417 | - $variants = $app->getCultureVariants($culture); |
|
419 | + if($app !== null) { |
|
420 | + $variants = $app->getCultureVariants($culture); |
|
421 | + } |
|
418 | 422 | |
419 | 423 | foreach($variants as $variant) |
420 | 424 | { |
421 | - if(isset(self::$_langs[$variant])) |
|
422 | - return self::$_langs[$variant]; |
|
425 | + if(isset(self::$_langs[$variant])) { |
|
426 | + return self::$_langs[$variant]; |
|
427 | + } |
|
423 | 428 | } |
424 | 429 | |
425 | 430 | return 'en'; |
@@ -18,19 +18,19 @@ discard block |
||
18 | 18 | define('THEME_MORPH_BACKGROUND', 0x0010); |
19 | 19 | define('THEME_SHADOWED_TEXT', 0x0020); |
20 | 20 | |
21 | -require_once(dirname(__FILE__) . '/captcha_key.php'); |
|
21 | +require_once(dirname(__FILE__).'/captcha_key.php'); |
|
22 | 22 | |
23 | 23 | $token = 'error'; |
24 | 24 | $theme = 0; |
25 | 25 | |
26 | -if(isset($_GET['options'])) |
|
26 | +if (isset($_GET['options'])) |
|
27 | 27 | { |
28 | 28 | $str = base64_decode($_GET['options']); |
29 | - if(strlen($str) > 32) |
|
29 | + if (strlen($str) > 32) |
|
30 | 30 | { |
31 | 31 | $hash = substr($str, 0, 32); |
32 | 32 | $str = substr($str, 32); |
33 | - if(md5($privateKey . $str) === $hash) |
|
33 | + if (md5($privateKey.$str) === $hash) |
|
34 | 34 | { |
35 | 35 | $options = unserialize($str); |
36 | 36 | $publicKey = $options['publicKey']; |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | $alphabet = $options['alphabet']; |
40 | 40 | $fontSize = $options['fontSize']; |
41 | 41 | $theme = $options['theme']; |
42 | - if(($randomSeed = $options['randomSeed']) > 0) |
|
42 | + if (($randomSeed = $options['randomSeed']) > 0) |
|
43 | 43 | srand($randomSeed); |
44 | 44 | else |
45 | - srand((int)(microtime() * 1000000)); |
|
45 | + srand((int) (microtime() * 1000000)); |
|
46 | 46 | $token = generateToken($publicKey, $privateKey, $alphabet, $tokenLength, $caseSensitive); |
47 | 47 | } |
48 | 48 | } |
@@ -52,21 +52,21 @@ discard block |
||
52 | 52 | |
53 | 53 | function generateToken($publicKey, $privateKey, $alphabet, $tokenLength, $caseSensitive) |
54 | 54 | { |
55 | - $token = substr(hash2string(md5($publicKey . $privateKey), $alphabet) . hash2string(md5($privateKey . $publicKey), $alphabet), 0, $tokenLength); |
|
56 | - return $caseSensitive?$token:strtoupper($token); |
|
55 | + $token = substr(hash2string(md5($publicKey.$privateKey), $alphabet).hash2string(md5($privateKey.$publicKey), $alphabet), 0, $tokenLength); |
|
56 | + return $caseSensitive ? $token : strtoupper($token); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function hash2string($hex, $alphabet) |
60 | 60 | { |
61 | - if(strlen($alphabet) < 2) |
|
61 | + if (strlen($alphabet) < 2) |
|
62 | 62 | $alphabet = '234578adefhijmnrtABDEFGHJLMNRT'; |
63 | 63 | $hexLength = strlen($hex); |
64 | 64 | $base = strlen($alphabet); |
65 | 65 | $result = ''; |
66 | - for($i = 0;$i < $hexLength;$i += 6) |
|
66 | + for ($i = 0; $i < $hexLength; $i += 6) |
|
67 | 67 | { |
68 | 68 | $number = hexdec(substr($hex, $i, 6)); |
69 | - while($number) |
|
69 | + while ($number) |
|
70 | 70 | { |
71 | 71 | $result .= $alphabet[$number % $base]; |
72 | 72 | $number = floor($number / $base); |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | |
78 | 78 | function displayToken($token, $fontSize, $theme) |
79 | 79 | { |
80 | - if(($fontSize = (int)$fontSize) < 22) |
|
80 | + if (($fontSize = (int) $fontSize) < 22) |
|
81 | 81 | $fontSize = 22; |
82 | - if($fontSize > 100) |
|
82 | + if ($fontSize > 100) |
|
83 | 83 | $fontSize = 100; |
84 | 84 | $length = strlen($token); |
85 | 85 | $padding = 10; |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | $theme & THEME_MORPH_BACKGROUND |
99 | 99 | ); |
100 | 100 | |
101 | - $font = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'verase.ttf'; |
|
101 | + $font = dirname(__FILE__).DIRECTORY_SEPARATOR.'verase.ttf'; |
|
102 | 102 | |
103 | - if(function_exists('imagefilter')) |
|
103 | + if (function_exists('imagefilter')) |
|
104 | 104 | imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); |
105 | 105 | |
106 | 106 | $hasShadow = ($theme & THEME_SHADOWED_TEXT); |
107 | - for($i = 0;$i < $length;$i++) |
|
107 | + for ($i = 0; $i < $length; $i++) |
|
108 | 108 | { |
109 | 109 | $color = imagecolorallocate($image, rand(150, 220), rand(150, 220), rand(150, 220)); |
110 | 110 | $size = rand($fontWidth - 10, $fontWidth); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $x = $padding + $i * $fontWidth; |
113 | 113 | $y = rand($fontHeight - 15, $fontHeight - 10); |
114 | 114 | imagettftext($image, $size, $angle, $x, $y, $color, $font, $token[$i]); |
115 | - if($hasShadow) |
|
115 | + if ($hasShadow) |
|
116 | 116 | imagettftext($image, $size, $angle, $x + 2, $y + 2, $color, $font, $token[$i]); |
117 | 117 | imagecolordeallocate($image, $color); |
118 | 118 | } |
@@ -128,34 +128,34 @@ discard block |
||
128 | 128 | $white = imagecolorallocate($background, 255, 255, 255); |
129 | 129 | imagefill($background, 0, 0, $white); |
130 | 130 | |
131 | - if($opaque) |
|
131 | + if ($opaque) |
|
132 | 132 | imagefill($background, 0, 0, imagecolorallocate($background, 100, 100, 100)); |
133 | 133 | |
134 | - if($noisy) |
|
134 | + if ($noisy) |
|
135 | 135 | addNoise($background, $width * 2, $height * 2); |
136 | 136 | |
137 | - if($hasGrid) |
|
137 | + if ($hasGrid) |
|
138 | 138 | addGrid($background, $width * 2, $height * 2); |
139 | 139 | |
140 | - if($hasScribble) |
|
140 | + if ($hasScribble) |
|
141 | 141 | addScribble($background, $width * 2, $height * 2); |
142 | 142 | |
143 | - if($morph) |
|
143 | + if ($morph) |
|
144 | 144 | morphImage($background, $width * 2, $height * 2); |
145 | 145 | |
146 | 146 | imagecopy($image, $background, 0, 0, 30, 30, $width, $height); |
147 | 147 | |
148 | - if(!$opaque) |
|
148 | + if (!$opaque) |
|
149 | 149 | imagecolortransparent($image, $white); |
150 | 150 | } |
151 | 151 | |
152 | 152 | function addNoise($image, $width, $height) |
153 | 153 | { |
154 | - for($x = 0;$x < $width;++$x) |
|
154 | + for ($x = 0; $x < $width; ++$x) |
|
155 | 155 | { |
156 | - for($y = 0;$y < $height;++$y) |
|
156 | + for ($y = 0; $y < $height; ++$y) |
|
157 | 157 | { |
158 | - if(rand(0, 100) < 25) |
|
158 | + if (rand(0, 100) < 25) |
|
159 | 159 | { |
160 | 160 | $color = imagecolorallocate($image, rand(150, 220), rand(150, 220), rand(150, 220)); |
161 | 161 | imagesetpixel($image, $x, $y, $color); |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | |
168 | 168 | function addGrid($image, $width, $height) |
169 | 169 | { |
170 | - for($i = 0;$i < $width;$i += rand(15, 25)) |
|
170 | + for ($i = 0; $i < $width; $i += rand(15, 25)) |
|
171 | 171 | { |
172 | 172 | imagesetthickness($image, rand(2, 6)); |
173 | 173 | $color = imagecolorallocate($image, rand(100, 180), rand(100, 180), rand(100, 180)); |
174 | 174 | imageline($image, $i + rand(-10, 20), 0, $i + rand(-10, 20), $height, $color); |
175 | 175 | imagecolordeallocate($image, $color); |
176 | 176 | } |
177 | - for($i = 0;$i < $height;$i += rand(15, 25)) |
|
177 | + for ($i = 0; $i < $height; $i += rand(15, 25)) |
|
178 | 178 | { |
179 | 179 | imagesetthickness($image, rand(2, 6)); |
180 | 180 | $color = imagecolorallocate($image, rand(100, 180), rand(100, 180), rand(100, 180)); |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | |
186 | 186 | function addScribble($image, $width, $height) |
187 | 187 | { |
188 | - for($i = 0;$i < 8;$i++) |
|
188 | + for ($i = 0; $i < 8; $i++) |
|
189 | 189 | { |
190 | 190 | $color = imagecolorallocate($image, rand(100, 180), rand(100, 180), rand(100, 180)); |
191 | 191 | $points = []; |
192 | - for($j = 1;$j < rand(5, 10);$j++) |
|
192 | + for ($j = 1; $j < rand(5, 10); $j++) |
|
193 | 193 | { |
194 | 194 | $points[] = rand(2 * (20 * ($i + 1)), 2 * (50 * ($i + 1))); |
195 | 195 | $points[] = rand(30, $height + 30); |
@@ -204,20 +204,20 @@ discard block |
||
204 | 204 | { |
205 | 205 | $tempImage = imagecreatetruecolor($width, $height); |
206 | 206 | $chunk = rand(1, 5); |
207 | - for($x = $y = 0;$x < $width;$x += $chunk) |
|
207 | + for ($x = $y = 0; $x < $width; $x += $chunk) |
|
208 | 208 | { |
209 | 209 | $chunk = rand(1, 5); |
210 | 210 | $y += rand(-1, 1); |
211 | - if($y >= $height) $y = $height - 5; |
|
212 | - if($y < 0) $y = 5; |
|
211 | + if ($y >= $height) $y = $height - 5; |
|
212 | + if ($y < 0) $y = 5; |
|
213 | 213 | imagecopy($tempImage, $image, $x, 0, $x, $y, $chunk, $height); |
214 | 214 | } |
215 | - for($x = $y = 0;$y < $height;$y += $chunk) |
|
215 | + for ($x = $y = 0; $y < $height; $y += $chunk) |
|
216 | 216 | { |
217 | 217 | $chunk = rand(1, 5); |
218 | 218 | $x += rand(-1, 1); |
219 | - if($x >= $width) $x = $width - 5; |
|
220 | - if($x < 0) $x = 5; |
|
219 | + if ($x >= $width) $x = $width - 5; |
|
220 | + if ($x < 0) $x = 5; |
|
221 | 221 | imagecopy($image, $tempImage, $x, $y, 0, $y, $width, $chunk); |
222 | 222 | } |
223 | 223 | } |
@@ -39,10 +39,11 @@ discard block |
||
39 | 39 | $alphabet = $options['alphabet']; |
40 | 40 | $fontSize = $options['fontSize']; |
41 | 41 | $theme = $options['theme']; |
42 | - if(($randomSeed = $options['randomSeed']) > 0) |
|
43 | - srand($randomSeed); |
|
44 | - else |
|
45 | - srand((int)(microtime() * 1000000)); |
|
42 | + if(($randomSeed = $options['randomSeed']) > 0) { |
|
43 | + srand($randomSeed); |
|
44 | + } else { |
|
45 | + srand((int)(microtime() * 1000000)); |
|
46 | + } |
|
46 | 47 | $token = generateToken($publicKey, $privateKey, $alphabet, $tokenLength, $caseSensitive); |
47 | 48 | } |
48 | 49 | } |
@@ -58,8 +59,9 @@ discard block |
||
58 | 59 | |
59 | 60 | function hash2string($hex, $alphabet) |
60 | 61 | { |
61 | - if(strlen($alphabet) < 2) |
|
62 | - $alphabet = '234578adefhijmnrtABDEFGHJLMNRT'; |
|
62 | + if(strlen($alphabet) < 2) { |
|
63 | + $alphabet = '234578adefhijmnrtABDEFGHJLMNRT'; |
|
64 | + } |
|
63 | 65 | $hexLength = strlen($hex); |
64 | 66 | $base = strlen($alphabet); |
65 | 67 | $result = ''; |
@@ -77,10 +79,12 @@ discard block |
||
77 | 79 | |
78 | 80 | function displayToken($token, $fontSize, $theme) |
79 | 81 | { |
80 | - if(($fontSize = (int)$fontSize) < 22) |
|
81 | - $fontSize = 22; |
|
82 | - if($fontSize > 100) |
|
83 | - $fontSize = 100; |
|
82 | + if(($fontSize = (int)$fontSize) < 22) { |
|
83 | + $fontSize = 22; |
|
84 | + } |
|
85 | + if($fontSize > 100) { |
|
86 | + $fontSize = 100; |
|
87 | + } |
|
84 | 88 | $length = strlen($token); |
85 | 89 | $padding = 10; |
86 | 90 | $fontWidth = $fontSize; |
@@ -100,8 +104,9 @@ discard block |
||
100 | 104 | |
101 | 105 | $font = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'verase.ttf'; |
102 | 106 | |
103 | - if(function_exists('imagefilter')) |
|
104 | - imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); |
|
107 | + if(function_exists('imagefilter')) { |
|
108 | + imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); |
|
109 | + } |
|
105 | 110 | |
106 | 111 | $hasShadow = ($theme & THEME_SHADOWED_TEXT); |
107 | 112 | for($i = 0;$i < $length;$i++) |
@@ -112,8 +117,9 @@ discard block |
||
112 | 117 | $x = $padding + $i * $fontWidth; |
113 | 118 | $y = rand($fontHeight - 15, $fontHeight - 10); |
114 | 119 | imagettftext($image, $size, $angle, $x, $y, $color, $font, $token[$i]); |
115 | - if($hasShadow) |
|
116 | - imagettftext($image, $size, $angle, $x + 2, $y + 2, $color, $font, $token[$i]); |
|
120 | + if($hasShadow) { |
|
121 | + imagettftext($image, $size, $angle, $x + 2, $y + 2, $color, $font, $token[$i]); |
|
122 | + } |
|
117 | 123 | imagecolordeallocate($image, $color); |
118 | 124 | } |
119 | 125 | |
@@ -128,26 +134,32 @@ discard block |
||
128 | 134 | $white = imagecolorallocate($background, 255, 255, 255); |
129 | 135 | imagefill($background, 0, 0, $white); |
130 | 136 | |
131 | - if($opaque) |
|
132 | - imagefill($background, 0, 0, imagecolorallocate($background, 100, 100, 100)); |
|
137 | + if($opaque) { |
|
138 | + imagefill($background, 0, 0, imagecolorallocate($background, 100, 100, 100)); |
|
139 | + } |
|
133 | 140 | |
134 | - if($noisy) |
|
135 | - addNoise($background, $width * 2, $height * 2); |
|
141 | + if($noisy) { |
|
142 | + addNoise($background, $width * 2, $height * 2); |
|
143 | + } |
|
136 | 144 | |
137 | - if($hasGrid) |
|
138 | - addGrid($background, $width * 2, $height * 2); |
|
145 | + if($hasGrid) { |
|
146 | + addGrid($background, $width * 2, $height * 2); |
|
147 | + } |
|
139 | 148 | |
140 | - if($hasScribble) |
|
141 | - addScribble($background, $width * 2, $height * 2); |
|
149 | + if($hasScribble) { |
|
150 | + addScribble($background, $width * 2, $height * 2); |
|
151 | + } |
|
142 | 152 | |
143 | - if($morph) |
|
144 | - morphImage($background, $width * 2, $height * 2); |
|
153 | + if($morph) { |
|
154 | + morphImage($background, $width * 2, $height * 2); |
|
155 | + } |
|
145 | 156 | |
146 | 157 | imagecopy($image, $background, 0, 0, 30, 30, $width, $height); |
147 | 158 | |
148 | - if(!$opaque) |
|
149 | - imagecolortransparent($image, $white); |
|
150 | -} |
|
159 | + if(!$opaque) { |
|
160 | + imagecolortransparent($image, $white); |
|
161 | + } |
|
162 | + } |
|
151 | 163 | |
152 | 164 | function addNoise($image, $width, $height) |
153 | 165 | { |
@@ -208,16 +220,24 @@ discard block |
||
208 | 220 | { |
209 | 221 | $chunk = rand(1, 5); |
210 | 222 | $y += rand(-1, 1); |
211 | - if($y >= $height) $y = $height - 5; |
|
212 | - if($y < 0) $y = 5; |
|
223 | + if($y >= $height) { |
|
224 | + $y = $height - 5; |
|
225 | + } |
|
226 | + if($y < 0) { |
|
227 | + $y = 5; |
|
228 | + } |
|
213 | 229 | imagecopy($tempImage, $image, $x, 0, $x, $y, $chunk, $height); |
214 | 230 | } |
215 | 231 | for($x = $y = 0;$y < $height;$y += $chunk) |
216 | 232 | { |
217 | 233 | $chunk = rand(1, 5); |
218 | 234 | $x += rand(-1, 1); |
219 | - if($x >= $width) $x = $width - 5; |
|
220 | - if($x < 0) $x = 5; |
|
235 | + if($x >= $width) { |
|
236 | + $x = $width - 5; |
|
237 | + } |
|
238 | + if($x < 0) { |
|
239 | + $x = 5; |
|
240 | + } |
|
221 | 241 | imagecopy($image, $tempImage, $x, $y, 0, $y, $width, $chunk); |
222 | 242 | } |
223 | 243 | } |
@@ -39,11 +39,11 @@ |
||
39 | 39 | protected function addAttributesToRender($writer) |
40 | 40 | { |
41 | 41 | parent::addAttributesToRender($writer); |
42 | - if(($scope = $this->getScope()) !== TTableHeaderScope::NotSet) |
|
43 | - $writer->addAttribute('scope', $scope === TTableHeaderScope::Row?'row':'col'); |
|
44 | - if(($text = $this->getAbbreviatedText()) !== '') |
|
42 | + if (($scope = $this->getScope()) !== TTableHeaderScope::NotSet) |
|
43 | + $writer->addAttribute('scope', $scope === TTableHeaderScope::Row ? 'row' : 'col'); |
|
44 | + if (($text = $this->getAbbreviatedText()) !== '') |
|
45 | 45 | $writer->addAttribute('abbr', $text); |
46 | - if(($text = $this->getCategoryText()) !== '') |
|
46 | + if (($text = $this->getCategoryText()) !== '') |
|
47 | 47 | $writer->addAttribute('axis', $text); |
48 | 48 | } |
49 | 49 |
@@ -39,12 +39,15 @@ |
||
39 | 39 | protected function addAttributesToRender($writer) |
40 | 40 | { |
41 | 41 | parent::addAttributesToRender($writer); |
42 | - if(($scope = $this->getScope()) !== TTableHeaderScope::NotSet) |
|
43 | - $writer->addAttribute('scope', $scope === TTableHeaderScope::Row?'row':'col'); |
|
44 | - if(($text = $this->getAbbreviatedText()) !== '') |
|
45 | - $writer->addAttribute('abbr', $text); |
|
46 | - if(($text = $this->getCategoryText()) !== '') |
|
47 | - $writer->addAttribute('axis', $text); |
|
42 | + if(($scope = $this->getScope()) !== TTableHeaderScope::NotSet) { |
|
43 | + $writer->addAttribute('scope', $scope === TTableHeaderScope::Row?'row':'col'); |
|
44 | + } |
|
45 | + if(($text = $this->getAbbreviatedText()) !== '') { |
|
46 | + $writer->addAttribute('abbr', $text); |
|
47 | + } |
|
48 | + if(($text = $this->getCategoryText()) !== '') { |
|
49 | + $writer->addAttribute('axis', $text); |
|
50 | + } |
|
48 | 51 | } |
49 | 52 | |
50 | 53 | /** |
@@ -131,18 +131,18 @@ discard block |
||
131 | 131 | { |
132 | 132 | $page = $this->getPage(); |
133 | 133 | $page->ensureRenderInForm($this); |
134 | - if($this->getIsMultiSelect()) |
|
134 | + if ($this->getIsMultiSelect()) |
|
135 | 135 | $writer->addAttribute('multiple', 'multiple'); |
136 | - if($this->getEnabled(true)) |
|
136 | + if ($this->getEnabled(true)) |
|
137 | 137 | { |
138 | - if($this->getAutoPostBack() |
|
138 | + if ($this->getAutoPostBack() |
|
139 | 139 | && $this->getEnableClientScript() |
140 | 140 | && $page->getClientSupportsJavaScript()) |
141 | 141 | { |
142 | 142 | $this->renderClientControlScript($writer); |
143 | 143 | } |
144 | 144 | } |
145 | - elseif($this->getEnabled()) |
|
145 | + elseif ($this->getEnabled()) |
|
146 | 146 | $writer->addAttribute('disabled', 'disabled'); |
147 | 147 | parent::addAttributesToRender($writer); |
148 | 148 | } |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | public function addParsedObject($object) |
188 | 188 | { |
189 | 189 | // Do not add items from template if items are loaded from viewstate |
190 | - if(!$this->_stateLoaded && ($object instanceof TListItem)) |
|
190 | + if (!$this->_stateLoaded && ($object instanceof TListItem)) |
|
191 | 191 | { |
192 | 192 | $index = $this->getItems()->add($object); |
193 | - if(($this->_cachedSelectedValue !== null && $this->_cachedSelectedValue === $object->getValue()) || ($this->_cachedSelectedIndex === $index)) |
|
193 | + if (($this->_cachedSelectedValue !== null && $this->_cachedSelectedValue === $object->getValue()) || ($this->_cachedSelectedIndex === $index)) |
|
194 | 194 | { |
195 | 195 | $object->setSelected(true); |
196 | 196 | $this->_cachedSelectedValue = null; |
@@ -208,25 +208,25 @@ discard block |
||
208 | 208 | protected function performDataBinding($data) |
209 | 209 | { |
210 | 210 | $items = $this->getItems(); |
211 | - if(!$this->getAppendDataBoundItems()) |
|
211 | + if (!$this->getAppendDataBoundItems()) |
|
212 | 212 | $items->clear(); |
213 | 213 | $textField = $this->getDataTextField(); |
214 | - if($textField === '') |
|
214 | + if ($textField === '') |
|
215 | 215 | $textField = 0; |
216 | 216 | $valueField = $this->getDataValueField(); |
217 | - if($valueField === '') |
|
217 | + if ($valueField === '') |
|
218 | 218 | $valueField = 1; |
219 | 219 | $textFormat = $this->getDataTextFormatString(); |
220 | 220 | $groupField = $this->getDataGroupField(); |
221 | - foreach($data as $key => $object) |
|
221 | + foreach ($data as $key => $object) |
|
222 | 222 | { |
223 | 223 | $item = $items->createListItem(); |
224 | - if(is_array($object) || is_object($object)) |
|
224 | + if (is_array($object) || is_object($object)) |
|
225 | 225 | { |
226 | 226 | $text = TDataFieldAccessor::getDataFieldValue($object, $textField); |
227 | 227 | $value = TDataFieldAccessor::getDataFieldValue($object, $valueField); |
228 | 228 | $item->setValue($value); |
229 | - if($groupField !== '') |
|
229 | + if ($groupField !== '') |
|
230 | 230 | $item->setAttribute('Group', TDataFieldAccessor::getDataFieldValue($object, $groupField)); |
231 | 231 | } |
232 | 232 | else |
@@ -238,22 +238,22 @@ discard block |
||
238 | 238 | } |
239 | 239 | // SelectedValue or SelectedIndex may be set before databinding |
240 | 240 | // so we make them be effective now |
241 | - if($this->_cachedSelectedValue !== null) |
|
241 | + if ($this->_cachedSelectedValue !== null) |
|
242 | 242 | { |
243 | 243 | $this->setSelectedValue($this->_cachedSelectedValue); |
244 | 244 | $this->resetCachedSelections(); |
245 | 245 | } |
246 | - elseif($this->_cachedSelectedIndex !== -1) |
|
246 | + elseif ($this->_cachedSelectedIndex !== -1) |
|
247 | 247 | { |
248 | 248 | $this->setSelectedIndex($this->_cachedSelectedIndex); |
249 | 249 | $this->resetCachedSelections(); |
250 | 250 | } |
251 | - elseif($this->_cachedSelectedValues !== null) |
|
251 | + elseif ($this->_cachedSelectedValues !== null) |
|
252 | 252 | { |
253 | 253 | $this->setSelectedValues($this->_cachedSelectedValues); |
254 | 254 | $this->resetCachedSelections(); |
255 | 255 | } |
256 | - elseif($this->_cachedSelectedIndices !== null) |
|
256 | + elseif ($this->_cachedSelectedIndices !== null) |
|
257 | 257 | { |
258 | 258 | $this->setSelectedIndices($this->_cachedSelectedIndices); |
259 | 259 | $this->resetCachedSelections(); |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | public function saveState() |
286 | 286 | { |
287 | 287 | parent::saveState(); |
288 | - if($this->_items) |
|
288 | + if ($this->_items) |
|
289 | 289 | $this->setViewState('Items', $this->_items->saveState(), null); |
290 | 290 | else |
291 | 291 | $this->clearViewState('Items'); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | { |
300 | 300 | parent::loadState(); |
301 | 301 | $this->_stateLoaded = true; |
302 | - if(!$this->getIsDataBound()) |
|
302 | + if (!$this->getIsDataBound()) |
|
303 | 303 | { |
304 | 304 | $this->_items = $this->createListItemCollection(); |
305 | 305 | $this->_items->loadState($this->getViewState('Items', null)); |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | */ |
442 | 442 | public function getItemCount() |
443 | 443 | { |
444 | - return $this->_items?$this->_items->getCount():0; |
|
444 | + return $this->_items ? $this->_items->getCount() : 0; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | */ |
458 | 458 | public function getItems() |
459 | 459 | { |
460 | - if(!$this->_items) |
|
460 | + if (!$this->_items) |
|
461 | 461 | $this->_items = $this->createListItemCollection(); |
462 | 462 | return $this->_items; |
463 | 463 | } |
@@ -467,11 +467,11 @@ discard block |
||
467 | 467 | */ |
468 | 468 | public function getSelectedIndex() |
469 | 469 | { |
470 | - if($this->_items) |
|
470 | + if ($this->_items) |
|
471 | 471 | { |
472 | 472 | $n = $this->_items->getCount(); |
473 | - for($i = 0;$i < $n;++$i) |
|
474 | - if($this->_items->itemAt($i)->getSelected()) |
|
473 | + for ($i = 0; $i < $n; ++$i) |
|
474 | + if ($this->_items->itemAt($i)->getSelected()) |
|
475 | 475 | return $i; |
476 | 476 | } |
477 | 477 | return -1; |
@@ -482,16 +482,16 @@ discard block |
||
482 | 482 | */ |
483 | 483 | public function setSelectedIndex($index) |
484 | 484 | { |
485 | - if(($index = TPropertyValue::ensureInteger($index)) < 0) |
|
485 | + if (($index = TPropertyValue::ensureInteger($index)) < 0) |
|
486 | 486 | $index = -1; |
487 | - if($this->_items) |
|
487 | + if ($this->_items) |
|
488 | 488 | { |
489 | 489 | $this->clearSelection(); |
490 | - if($index >= 0 && $index < $this->_items->getCount()) |
|
490 | + if ($index >= 0 && $index < $this->_items->getCount()) |
|
491 | 491 | $this->_items->itemAt($index)->setSelected(true); |
492 | 492 | } |
493 | 493 | $this->_cachedSelectedIndex = $index; |
494 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
494 | + if ($this->getAdapter() instanceof IListControlAdapter) |
|
495 | 495 | $this->getAdapter()->setSelectedIndex($index); |
496 | 496 | } |
497 | 497 | |
@@ -501,11 +501,11 @@ discard block |
||
501 | 501 | public function getSelectedIndices() |
502 | 502 | { |
503 | 503 | $selections = []; |
504 | - if($this->_items) |
|
504 | + if ($this->_items) |
|
505 | 505 | { |
506 | 506 | $n = $this->_items->getCount(); |
507 | - for($i = 0;$i < $n;++$i) |
|
508 | - if($this->_items->itemAt($i)->getSelected()) |
|
507 | + for ($i = 0; $i < $n; ++$i) |
|
508 | + if ($this->_items->itemAt($i)->getSelected()) |
|
509 | 509 | $selections[] = $i; |
510 | 510 | } |
511 | 511 | return $selections; |
@@ -516,15 +516,15 @@ discard block |
||
516 | 516 | */ |
517 | 517 | public function setSelectedIndices($indices) |
518 | 518 | { |
519 | - if($this->getIsMultiSelect()) |
|
519 | + if ($this->getIsMultiSelect()) |
|
520 | 520 | { |
521 | - if($this->_items) |
|
521 | + if ($this->_items) |
|
522 | 522 | { |
523 | 523 | $this->clearSelection(); |
524 | 524 | $n = $this->_items->getCount(); |
525 | - foreach($indices as $index) |
|
525 | + foreach ($indices as $index) |
|
526 | 526 | { |
527 | - if($index >= 0 && $index < $n) |
|
527 | + if ($index >= 0 && $index < $n) |
|
528 | 528 | $this->_items->itemAt($index)->setSelected(true); |
529 | 529 | } |
530 | 530 | } |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | else |
534 | 534 | throw new TNotSupportedException('listcontrol_multiselect_unsupported', get_class($this)); |
535 | 535 | |
536 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
536 | + if ($this->getAdapter() instanceof IListControlAdapter) |
|
537 | 537 | $this->getAdapter()->setSelectedIndices($indices); |
538 | 538 | } |
539 | 539 | |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | */ |
543 | 543 | public function getSelectedItem() |
544 | 544 | { |
545 | - if(($index = $this->getSelectedIndex()) >= 0) |
|
545 | + if (($index = $this->getSelectedIndex()) >= 0) |
|
546 | 546 | return $this->_items->itemAt($index); |
547 | 547 | else |
548 | 548 | return null; |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | public function getSelectedValue() |
581 | 581 | { |
582 | 582 | $index = $this->getSelectedIndex(); |
583 | - return $index >= 0?$this->getItems()->itemAt($index)->getValue():''; |
|
583 | + return $index >= 0 ? $this->getItems()->itemAt($index)->getValue() : ''; |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | /** |
@@ -591,11 +591,11 @@ discard block |
||
591 | 591 | */ |
592 | 592 | public function setSelectedValue($value) |
593 | 593 | { |
594 | - if($this->_items) |
|
594 | + if ($this->_items) |
|
595 | 595 | { |
596 | - if($value === null) |
|
596 | + if ($value === null) |
|
597 | 597 | $this->clearSelection(); |
598 | - elseif(($item = $this->_items->findItemByValue($value)) !== null) |
|
598 | + elseif (($item = $this->_items->findItemByValue($value)) !== null) |
|
599 | 599 | { |
600 | 600 | $this->clearSelection(); |
601 | 601 | $item->setSelected(true); |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | $this->clearSelection(); |
605 | 605 | } |
606 | 606 | $this->_cachedSelectedValue = $value; |
607 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
607 | + if ($this->getAdapter() instanceof IListControlAdapter) |
|
608 | 608 | $this->getAdapter()->setSelectedValue($value); |
609 | 609 | } |
610 | 610 | |
@@ -615,11 +615,11 @@ discard block |
||
615 | 615 | public function getSelectedValues() |
616 | 616 | { |
617 | 617 | $values = []; |
618 | - if($this->_items) |
|
618 | + if ($this->_items) |
|
619 | 619 | { |
620 | - foreach($this->_items as $item) |
|
620 | + foreach ($this->_items as $item) |
|
621 | 621 | { |
622 | - if($item->getSelected()) |
|
622 | + if ($item->getSelected()) |
|
623 | 623 | $values[] = $item->getValue(); |
624 | 624 | } |
625 | 625 | } |
@@ -631,17 +631,17 @@ discard block |
||
631 | 631 | */ |
632 | 632 | public function setSelectedValues($values) |
633 | 633 | { |
634 | - if($this->getIsMultiSelect()) |
|
634 | + if ($this->getIsMultiSelect()) |
|
635 | 635 | { |
636 | - if($this->_items) |
|
636 | + if ($this->_items) |
|
637 | 637 | { |
638 | 638 | $this->clearSelection(); |
639 | 639 | $lookup = []; |
640 | - foreach($this->_items as $item) |
|
640 | + foreach ($this->_items as $item) |
|
641 | 641 | $lookup[$item->getValue()] = $item; |
642 | - foreach($values as $value) |
|
642 | + foreach ($values as $value) |
|
643 | 643 | { |
644 | - if(isset($lookup["$value"])) |
|
644 | + if (isset($lookup["$value"])) |
|
645 | 645 | $lookup["$value"]->setSelected(true); |
646 | 646 | } |
647 | 647 | } |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | else |
651 | 651 | throw new TNotSupportedException('listcontrol_multiselect_unsupported', get_class($this)); |
652 | 652 | |
653 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
653 | + if ($this->getAdapter() instanceof IListControlAdapter) |
|
654 | 654 | $this->getAdapter()->setSelectedValues($values); |
655 | 655 | } |
656 | 656 | |
@@ -675,13 +675,13 @@ discard block |
||
675 | 675 | */ |
676 | 676 | public function clearSelection() |
677 | 677 | { |
678 | - if($this->_items) |
|
678 | + if ($this->_items) |
|
679 | 679 | { |
680 | - foreach($this->_items as $item) |
|
680 | + foreach ($this->_items as $item) |
|
681 | 681 | $item->setSelected(false); |
682 | 682 | } |
683 | 683 | |
684 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
684 | + if ($this->getAdapter() instanceof IListControlAdapter) |
|
685 | 685 | $this->getAdapter()->clearSelection(); |
686 | 686 | } |
687 | 687 | |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | */ |
737 | 737 | public function setPromptValue($value) |
738 | 738 | { |
739 | - $this->setViewState('PromptValue', (string)$value, ''); |
|
739 | + $this->setViewState('PromptValue', (string) $value, ''); |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | /** |
@@ -771,9 +771,9 @@ discard block |
||
771 | 771 | { |
772 | 772 | $text = $this->getPromptText(); |
773 | 773 | $value = $this->getPromptValue(); |
774 | - if($value === '') |
|
774 | + if ($value === '') |
|
775 | 775 | $value = $text; |
776 | - if($value !== '') |
|
776 | + if ($value !== '') |
|
777 | 777 | { |
778 | 778 | $writer->addAttribute('value', $value); |
779 | 779 | $writer->renderBeginTag('option'); |
@@ -792,26 +792,26 @@ discard block |
||
792 | 792 | { |
793 | 793 | $this->renderPrompt($writer); |
794 | 794 | |
795 | - if($this->_items) |
|
795 | + if ($this->_items) |
|
796 | 796 | { |
797 | 797 | $writer->writeLine(); |
798 | 798 | $previousGroup = null; |
799 | - foreach($this->_items as $item) |
|
799 | + foreach ($this->_items as $item) |
|
800 | 800 | { |
801 | - if($item->getEnabled()) |
|
801 | + if ($item->getEnabled()) |
|
802 | 802 | { |
803 | - if($item->getHasAttributes()) |
|
803 | + if ($item->getHasAttributes()) |
|
804 | 804 | { |
805 | 805 | $group = $item->getAttributes()->remove('Group'); |
806 | - if($group !== $previousGroup) |
|
806 | + if ($group !== $previousGroup) |
|
807 | 807 | { |
808 | - if($previousGroup !== null) |
|
808 | + if ($previousGroup !== null) |
|
809 | 809 | { |
810 | 810 | $writer->renderEndTag(); |
811 | 811 | $writer->writeLine(); |
812 | 812 | $previousGroup = null; |
813 | 813 | } |
814 | - if($group !== null) |
|
814 | + if ($group !== null) |
|
815 | 815 | { |
816 | 816 | $writer->addAttribute('label', $group); |
817 | 817 | $writer->renderBeginTag('optgroup'); |
@@ -819,16 +819,16 @@ discard block |
||
819 | 819 | $previousGroup = $group; |
820 | 820 | } |
821 | 821 | } |
822 | - foreach($item->getAttributes() as $name => $value) |
|
822 | + foreach ($item->getAttributes() as $name => $value) |
|
823 | 823 | $writer->addAttribute($name, $value); |
824 | 824 | } |
825 | - elseif($previousGroup !== null) |
|
825 | + elseif ($previousGroup !== null) |
|
826 | 826 | { |
827 | 827 | $writer->renderEndTag(); |
828 | 828 | $writer->writeLine(); |
829 | 829 | $previousGroup = null; |
830 | 830 | } |
831 | - if($item->getSelected()) |
|
831 | + if ($item->getSelected()) |
|
832 | 832 | $writer->addAttribute('selected', 'selected'); |
833 | 833 | $writer->addAttribute('value', $item->getValue()); |
834 | 834 | $writer->renderBeginTag('option'); |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | $writer->writeLine(); |
838 | 838 | } |
839 | 839 | } |
840 | - if($previousGroup !== null) |
|
840 | + if ($previousGroup !== null) |
|
841 | 841 | { |
842 | 842 | $writer->renderEndTag(); |
843 | 843 | $writer->writeLine(); |
@@ -859,18 +859,18 @@ discard block |
||
859 | 859 | */ |
860 | 860 | protected function formatDataValue($formatString, $value) |
861 | 861 | { |
862 | - if($formatString === '') |
|
862 | + if ($formatString === '') |
|
863 | 863 | return TPropertyValue::ensureString($value); |
864 | - elseif($formatString[0] === '#') |
|
864 | + elseif ($formatString[0] === '#') |
|
865 | 865 | { |
866 | 866 | $expression = strtr(substr($formatString, 1), ['{0}' => '$value']); |
867 | 867 | try |
868 | 868 | { |
869 | - if(eval("\$result=$expression;") === false) |
|
869 | + if (eval("\$result=$expression;") === false) |
|
870 | 870 | throw new Exception(''); |
871 | 871 | return $result; |
872 | 872 | } |
873 | - catch(Exception $e) |
|
873 | + catch (Exception $e) |
|
874 | 874 | { |
875 | 875 | throw new TInvalidDataValueException('listcontrol_expression_invalid', get_class($this), $expression, $e->getMessage()); |
876 | 876 | } |
@@ -131,8 +131,9 @@ discard block |
||
131 | 131 | { |
132 | 132 | $page = $this->getPage(); |
133 | 133 | $page->ensureRenderInForm($this); |
134 | - if($this->getIsMultiSelect()) |
|
135 | - $writer->addAttribute('multiple', 'multiple'); |
|
134 | + if($this->getIsMultiSelect()) { |
|
135 | + $writer->addAttribute('multiple', 'multiple'); |
|
136 | + } |
|
136 | 137 | if($this->getEnabled(true)) |
137 | 138 | { |
138 | 139 | if($this->getAutoPostBack() |
@@ -141,9 +142,9 @@ discard block |
||
141 | 142 | { |
142 | 143 | $this->renderClientControlScript($writer); |
143 | 144 | } |
145 | + } elseif($this->getEnabled()) { |
|
146 | + $writer->addAttribute('disabled', 'disabled'); |
|
144 | 147 | } |
145 | - elseif($this->getEnabled()) |
|
146 | - $writer->addAttribute('disabled', 'disabled'); |
|
147 | 148 | parent::addAttributesToRender($writer); |
148 | 149 | } |
149 | 150 | |
@@ -208,14 +209,17 @@ discard block |
||
208 | 209 | protected function performDataBinding($data) |
209 | 210 | { |
210 | 211 | $items = $this->getItems(); |
211 | - if(!$this->getAppendDataBoundItems()) |
|
212 | - $items->clear(); |
|
212 | + if(!$this->getAppendDataBoundItems()) { |
|
213 | + $items->clear(); |
|
214 | + } |
|
213 | 215 | $textField = $this->getDataTextField(); |
214 | - if($textField === '') |
|
215 | - $textField = 0; |
|
216 | + if($textField === '') { |
|
217 | + $textField = 0; |
|
218 | + } |
|
216 | 219 | $valueField = $this->getDataValueField(); |
217 | - if($valueField === '') |
|
218 | - $valueField = 1; |
|
220 | + if($valueField === '') { |
|
221 | + $valueField = 1; |
|
222 | + } |
|
219 | 223 | $textFormat = $this->getDataTextFormatString(); |
220 | 224 | $groupField = $this->getDataGroupField(); |
221 | 225 | foreach($data as $key => $object) |
@@ -226,10 +230,10 @@ discard block |
||
226 | 230 | $text = TDataFieldAccessor::getDataFieldValue($object, $textField); |
227 | 231 | $value = TDataFieldAccessor::getDataFieldValue($object, $valueField); |
228 | 232 | $item->setValue($value); |
229 | - if($groupField !== '') |
|
230 | - $item->setAttribute('Group', TDataFieldAccessor::getDataFieldValue($object, $groupField)); |
|
231 | - } |
|
232 | - else |
|
233 | + if($groupField !== '') { |
|
234 | + $item->setAttribute('Group', TDataFieldAccessor::getDataFieldValue($object, $groupField)); |
|
235 | + } |
|
236 | + } else |
|
233 | 237 | { |
234 | 238 | $text = $object; |
235 | 239 | $item->setValue("$key"); |
@@ -242,18 +246,15 @@ discard block |
||
242 | 246 | { |
243 | 247 | $this->setSelectedValue($this->_cachedSelectedValue); |
244 | 248 | $this->resetCachedSelections(); |
245 | - } |
|
246 | - elseif($this->_cachedSelectedIndex !== -1) |
|
249 | + } elseif($this->_cachedSelectedIndex !== -1) |
|
247 | 250 | { |
248 | 251 | $this->setSelectedIndex($this->_cachedSelectedIndex); |
249 | 252 | $this->resetCachedSelections(); |
250 | - } |
|
251 | - elseif($this->_cachedSelectedValues !== null) |
|
253 | + } elseif($this->_cachedSelectedValues !== null) |
|
252 | 254 | { |
253 | 255 | $this->setSelectedValues($this->_cachedSelectedValues); |
254 | 256 | $this->resetCachedSelections(); |
255 | - } |
|
256 | - elseif($this->_cachedSelectedIndices !== null) |
|
257 | + } elseif($this->_cachedSelectedIndices !== null) |
|
257 | 258 | { |
258 | 259 | $this->setSelectedIndices($this->_cachedSelectedIndices); |
259 | 260 | $this->resetCachedSelections(); |
@@ -285,10 +286,11 @@ discard block |
||
285 | 286 | public function saveState() |
286 | 287 | { |
287 | 288 | parent::saveState(); |
288 | - if($this->_items) |
|
289 | - $this->setViewState('Items', $this->_items->saveState(), null); |
|
290 | - else |
|
291 | - $this->clearViewState('Items'); |
|
289 | + if($this->_items) { |
|
290 | + $this->setViewState('Items', $this->_items->saveState(), null); |
|
291 | + } else { |
|
292 | + $this->clearViewState('Items'); |
|
293 | + } |
|
292 | 294 | } |
293 | 295 | |
294 | 296 | /** |
@@ -457,8 +459,9 @@ discard block |
||
457 | 459 | */ |
458 | 460 | public function getItems() |
459 | 461 | { |
460 | - if(!$this->_items) |
|
461 | - $this->_items = $this->createListItemCollection(); |
|
462 | + if(!$this->_items) { |
|
463 | + $this->_items = $this->createListItemCollection(); |
|
464 | + } |
|
462 | 465 | return $this->_items; |
463 | 466 | } |
464 | 467 | |
@@ -470,9 +473,10 @@ discard block |
||
470 | 473 | if($this->_items) |
471 | 474 | { |
472 | 475 | $n = $this->_items->getCount(); |
473 | - for($i = 0;$i < $n;++$i) |
|
474 | - if($this->_items->itemAt($i)->getSelected()) |
|
476 | + for($i = 0;$i < $n;++$i) { |
|
477 | + if($this->_items->itemAt($i)->getSelected()) |
|
475 | 478 | return $i; |
479 | + } |
|
476 | 480 | } |
477 | 481 | return -1; |
478 | 482 | } |
@@ -482,17 +486,20 @@ discard block |
||
482 | 486 | */ |
483 | 487 | public function setSelectedIndex($index) |
484 | 488 | { |
485 | - if(($index = TPropertyValue::ensureInteger($index)) < 0) |
|
486 | - $index = -1; |
|
489 | + if(($index = TPropertyValue::ensureInteger($index)) < 0) { |
|
490 | + $index = -1; |
|
491 | + } |
|
487 | 492 | if($this->_items) |
488 | 493 | { |
489 | 494 | $this->clearSelection(); |
490 | - if($index >= 0 && $index < $this->_items->getCount()) |
|
491 | - $this->_items->itemAt($index)->setSelected(true); |
|
495 | + if($index >= 0 && $index < $this->_items->getCount()) { |
|
496 | + $this->_items->itemAt($index)->setSelected(true); |
|
497 | + } |
|
492 | 498 | } |
493 | 499 | $this->_cachedSelectedIndex = $index; |
494 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
495 | - $this->getAdapter()->setSelectedIndex($index); |
|
500 | + if($this->getAdapter() instanceof IListControlAdapter) { |
|
501 | + $this->getAdapter()->setSelectedIndex($index); |
|
502 | + } |
|
496 | 503 | } |
497 | 504 | |
498 | 505 | /** |
@@ -504,9 +511,10 @@ discard block |
||
504 | 511 | if($this->_items) |
505 | 512 | { |
506 | 513 | $n = $this->_items->getCount(); |
507 | - for($i = 0;$i < $n;++$i) |
|
508 | - if($this->_items->itemAt($i)->getSelected()) |
|
514 | + for($i = 0;$i < $n;++$i) { |
|
515 | + if($this->_items->itemAt($i)->getSelected()) |
|
509 | 516 | $selections[] = $i; |
517 | + } |
|
510 | 518 | } |
511 | 519 | return $selections; |
512 | 520 | } |
@@ -524,17 +532,19 @@ discard block |
||
524 | 532 | $n = $this->_items->getCount(); |
525 | 533 | foreach($indices as $index) |
526 | 534 | { |
527 | - if($index >= 0 && $index < $n) |
|
528 | - $this->_items->itemAt($index)->setSelected(true); |
|
535 | + if($index >= 0 && $index < $n) { |
|
536 | + $this->_items->itemAt($index)->setSelected(true); |
|
537 | + } |
|
529 | 538 | } |
530 | 539 | } |
531 | 540 | $this->_cachedSelectedIndices = $indices; |
541 | + } else { |
|
542 | + throw new TNotSupportedException('listcontrol_multiselect_unsupported', get_class($this)); |
|
532 | 543 | } |
533 | - else |
|
534 | - throw new TNotSupportedException('listcontrol_multiselect_unsupported', get_class($this)); |
|
535 | 544 | |
536 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
537 | - $this->getAdapter()->setSelectedIndices($indices); |
|
545 | + if($this->getAdapter() instanceof IListControlAdapter) { |
|
546 | + $this->getAdapter()->setSelectedIndices($indices); |
|
547 | + } |
|
538 | 548 | } |
539 | 549 | |
540 | 550 | /** |
@@ -542,10 +552,11 @@ discard block |
||
542 | 552 | */ |
543 | 553 | public function getSelectedItem() |
544 | 554 | { |
545 | - if(($index = $this->getSelectedIndex()) >= 0) |
|
546 | - return $this->_items->itemAt($index); |
|
547 | - else |
|
548 | - return null; |
|
555 | + if(($index = $this->getSelectedIndex()) >= 0) { |
|
556 | + return $this->_items->itemAt($index); |
|
557 | + } else { |
|
558 | + return null; |
|
559 | + } |
|
549 | 560 | } |
550 | 561 | |
551 | 562 | /** |
@@ -593,19 +604,20 @@ discard block |
||
593 | 604 | { |
594 | 605 | if($this->_items) |
595 | 606 | { |
596 | - if($value === null) |
|
597 | - $this->clearSelection(); |
|
598 | - elseif(($item = $this->_items->findItemByValue($value)) !== null) |
|
607 | + if($value === null) { |
|
608 | + $this->clearSelection(); |
|
609 | + } elseif(($item = $this->_items->findItemByValue($value)) !== null) |
|
599 | 610 | { |
600 | 611 | $this->clearSelection(); |
601 | 612 | $item->setSelected(true); |
613 | + } else { |
|
614 | + $this->clearSelection(); |
|
602 | 615 | } |
603 | - else |
|
604 | - $this->clearSelection(); |
|
605 | 616 | } |
606 | 617 | $this->_cachedSelectedValue = $value; |
607 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
608 | - $this->getAdapter()->setSelectedValue($value); |
|
618 | + if($this->getAdapter() instanceof IListControlAdapter) { |
|
619 | + $this->getAdapter()->setSelectedValue($value); |
|
620 | + } |
|
609 | 621 | } |
610 | 622 | |
611 | 623 | |
@@ -619,8 +631,9 @@ discard block |
||
619 | 631 | { |
620 | 632 | foreach($this->_items as $item) |
621 | 633 | { |
622 | - if($item->getSelected()) |
|
623 | - $values[] = $item->getValue(); |
|
634 | + if($item->getSelected()) { |
|
635 | + $values[] = $item->getValue(); |
|
636 | + } |
|
624 | 637 | } |
625 | 638 | } |
626 | 639 | return $values; |
@@ -637,21 +650,24 @@ discard block |
||
637 | 650 | { |
638 | 651 | $this->clearSelection(); |
639 | 652 | $lookup = []; |
640 | - foreach($this->_items as $item) |
|
641 | - $lookup[$item->getValue()] = $item; |
|
653 | + foreach($this->_items as $item) { |
|
654 | + $lookup[$item->getValue()] = $item; |
|
655 | + } |
|
642 | 656 | foreach($values as $value) |
643 | 657 | { |
644 | - if(isset($lookup["$value"])) |
|
645 | - $lookup["$value"]->setSelected(true); |
|
658 | + if(isset($lookup["$value"])) { |
|
659 | + $lookup["$value"]->setSelected(true); |
|
660 | + } |
|
646 | 661 | } |
647 | 662 | } |
648 | 663 | $this->_cachedSelectedValues = $values; |
664 | + } else { |
|
665 | + throw new TNotSupportedException('listcontrol_multiselect_unsupported', get_class($this)); |
|
649 | 666 | } |
650 | - else |
|
651 | - throw new TNotSupportedException('listcontrol_multiselect_unsupported', get_class($this)); |
|
652 | 667 | |
653 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
654 | - $this->getAdapter()->setSelectedValues($values); |
|
668 | + if($this->getAdapter() instanceof IListControlAdapter) { |
|
669 | + $this->getAdapter()->setSelectedValues($values); |
|
670 | + } |
|
655 | 671 | } |
656 | 672 | |
657 | 673 | /** |
@@ -677,12 +693,14 @@ discard block |
||
677 | 693 | { |
678 | 694 | if($this->_items) |
679 | 695 | { |
680 | - foreach($this->_items as $item) |
|
681 | - $item->setSelected(false); |
|
696 | + foreach($this->_items as $item) { |
|
697 | + $item->setSelected(false); |
|
698 | + } |
|
682 | 699 | } |
683 | 700 | |
684 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
685 | - $this->getAdapter()->clearSelection(); |
|
701 | + if($this->getAdapter() instanceof IListControlAdapter) { |
|
702 | + $this->getAdapter()->clearSelection(); |
|
703 | + } |
|
686 | 704 | } |
687 | 705 | |
688 | 706 | /** |
@@ -771,8 +789,9 @@ discard block |
||
771 | 789 | { |
772 | 790 | $text = $this->getPromptText(); |
773 | 791 | $value = $this->getPromptValue(); |
774 | - if($value === '') |
|
775 | - $value = $text; |
|
792 | + if($value === '') { |
|
793 | + $value = $text; |
|
794 | + } |
|
776 | 795 | if($value !== '') |
777 | 796 | { |
778 | 797 | $writer->addAttribute('value', $value); |
@@ -819,17 +838,18 @@ discard block |
||
819 | 838 | $previousGroup = $group; |
820 | 839 | } |
821 | 840 | } |
822 | - foreach($item->getAttributes() as $name => $value) |
|
823 | - $writer->addAttribute($name, $value); |
|
824 | - } |
|
825 | - elseif($previousGroup !== null) |
|
841 | + foreach($item->getAttributes() as $name => $value) { |
|
842 | + $writer->addAttribute($name, $value); |
|
843 | + } |
|
844 | + } elseif($previousGroup !== null) |
|
826 | 845 | { |
827 | 846 | $writer->renderEndTag(); |
828 | 847 | $writer->writeLine(); |
829 | 848 | $previousGroup = null; |
830 | 849 | } |
831 | - if($item->getSelected()) |
|
832 | - $writer->addAttribute('selected', 'selected'); |
|
850 | + if($item->getSelected()) { |
|
851 | + $writer->addAttribute('selected', 'selected'); |
|
852 | + } |
|
833 | 853 | $writer->addAttribute('value', $item->getValue()); |
834 | 854 | $writer->renderBeginTag('option'); |
835 | 855 | $writer->write(THttpUtility::htmlEncode($item->getText())); |
@@ -859,23 +879,23 @@ discard block |
||
859 | 879 | */ |
860 | 880 | protected function formatDataValue($formatString, $value) |
861 | 881 | { |
862 | - if($formatString === '') |
|
863 | - return TPropertyValue::ensureString($value); |
|
864 | - elseif($formatString[0] === '#') |
|
882 | + if($formatString === '') { |
|
883 | + return TPropertyValue::ensureString($value); |
|
884 | + } elseif($formatString[0] === '#') |
|
865 | 885 | { |
866 | 886 | $expression = strtr(substr($formatString, 1), ['{0}' => '$value']); |
867 | 887 | try |
868 | 888 | { |
869 | - if(eval("\$result=$expression;") === false) |
|
870 | - throw new Exception(''); |
|
889 | + if(eval("\$result=$expression;") === false) { |
|
890 | + throw new Exception(''); |
|
891 | + } |
|
871 | 892 | return $result; |
872 | - } |
|
873 | - catch(Exception $e) |
|
893 | + } catch(Exception $e) |
|
874 | 894 | { |
875 | 895 | throw new TInvalidDataValueException('listcontrol_expression_invalid', get_class($this), $expression, $e->getMessage()); |
876 | 896 | } |
897 | + } else { |
|
898 | + return sprintf($formatString, $value); |
|
877 | 899 | } |
878 | - else |
|
879 | - return sprintf($formatString, $value); |
|
880 | 900 | } |
881 | 901 | } |
882 | 902 | \ No newline at end of file |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function setItemTemplate($value) |
293 | 293 | { |
294 | - if($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
294 | + if ($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
295 | 295 | $this->_itemTemplate = $value; |
296 | 296 | else |
297 | 297 | throw new TInvalidDataTypeException('repeater_template_required', 'ItemTemplate'); |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function setAlternatingItemTemplate($value) |
313 | 313 | { |
314 | - if($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
314 | + if ($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
315 | 315 | $this->_alternatingItemTemplate = $value; |
316 | 316 | else |
317 | 317 | throw new TInvalidDataTypeException('repeater_template_required', 'AlternatingItemTemplate'); |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | public function setHeaderTemplate($value) |
333 | 333 | { |
334 | - if($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
334 | + if ($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
335 | 335 | $this->_headerTemplate = $value; |
336 | 336 | else |
337 | 337 | throw new TInvalidDataTypeException('repeater_template_required', 'HeaderTemplate'); |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | */ |
352 | 352 | public function setFooterTemplate($value) |
353 | 353 | { |
354 | - if($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
354 | + if ($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
355 | 355 | $this->_footerTemplate = $value; |
356 | 356 | else |
357 | 357 | throw new TInvalidDataTypeException('repeater_template_required', 'FooterTemplate'); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | */ |
372 | 372 | public function setEmptyTemplate($value) |
373 | 373 | { |
374 | - if($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
374 | + if ($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
375 | 375 | $this->_emptyTemplate = $value; |
376 | 376 | else |
377 | 377 | throw new TInvalidDataTypeException('repeater_template_required', 'EmptyTemplate'); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | */ |
392 | 392 | public function setSeparatorTemplate($value) |
393 | 393 | { |
394 | - if($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
394 | + if ($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
395 | 395 | $this->_separatorTemplate = $value; |
396 | 396 | else |
397 | 397 | throw new TInvalidDataTypeException('repeater_template_required', 'SeparatorTemplate'); |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | */ |
419 | 419 | public function getItems() |
420 | 420 | { |
421 | - if(!$this->_items) |
|
421 | + if (!$this->_items) |
|
422 | 422 | $this->_items = new TRepeaterItemCollection; |
423 | 423 | return $this->_items; |
424 | 424 | } |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | */ |
445 | 445 | public function getDataKeys() |
446 | 446 | { |
447 | - if(($dataKeys = $this->getViewState('DataKeys', null)) === null) |
|
447 | + if (($dataKeys = $this->getViewState('DataKeys', null)) === null) |
|
448 | 448 | { |
449 | 449 | $dataKeys = new TList; |
450 | 450 | $this->setViewState('DataKeys', $dataKeys, null); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | */ |
462 | 462 | private function createItemInternal($itemIndex, $itemType) |
463 | 463 | { |
464 | - if(($item = $this->createItem($itemIndex, $itemType)) !== null) |
|
464 | + if (($item = $this->createItem($itemIndex, $itemType)) !== null) |
|
465 | 465 | { |
466 | 466 | $param = new TRepeaterItemEventParameter($item); |
467 | 467 | $this->onItemCreated($param); |
@@ -482,10 +482,10 @@ discard block |
||
482 | 482 | */ |
483 | 483 | private function createItemWithDataInternal($itemIndex, $itemType, $dataItem) |
484 | 484 | { |
485 | - if(($item = $this->createItem($itemIndex, $itemType)) !== null) |
|
485 | + if (($item = $this->createItem($itemIndex, $itemType)) !== null) |
|
486 | 486 | { |
487 | 487 | $param = new TRepeaterItemEventParameter($item); |
488 | - if($item instanceof \Prado\IDataRenderer) |
|
488 | + if ($item instanceof \Prado\IDataRenderer) |
|
489 | 489 | $item->setData($dataItem); |
490 | 490 | $this->onItemCreated($param); |
491 | 491 | $this->getControls()->add($item); |
@@ -507,14 +507,14 @@ discard block |
||
507 | 507 | { |
508 | 508 | $template = null; |
509 | 509 | $classPath = null; |
510 | - switch($itemType) |
|
510 | + switch ($itemType) |
|
511 | 511 | { |
512 | 512 | case TListItemType::Item : |
513 | 513 | $classPath = $this->getItemRenderer(); |
514 | 514 | $template = $this->_itemTemplate; |
515 | 515 | break; |
516 | 516 | case TListItemType::AlternatingItem : |
517 | - if(($classPath = $this->getAlternatingItemRenderer()) === '' && ($template = $this->_alternatingItemTemplate) === null) |
|
517 | + if (($classPath = $this->getAlternatingItemRenderer()) === '' && ($template = $this->_alternatingItemTemplate) === null) |
|
518 | 518 | { |
519 | 519 | $classPath = $this->getItemRenderer(); |
520 | 520 | $template = $this->_itemTemplate; |
@@ -535,16 +535,16 @@ discard block |
||
535 | 535 | default: |
536 | 536 | throw new TInvalidDataValueException('repeater_itemtype_unknown', $itemType); |
537 | 537 | } |
538 | - if($classPath !== '') |
|
538 | + if ($classPath !== '') |
|
539 | 539 | { |
540 | 540 | $item = Prado::createComponent($classPath); |
541 | - if($item instanceof IItemDataRenderer) |
|
541 | + if ($item instanceof IItemDataRenderer) |
|
542 | 542 | { |
543 | 543 | $item->setItemIndex($itemIndex); |
544 | 544 | $item->setItemType($itemType); |
545 | 545 | } |
546 | 546 | } |
547 | - elseif($template !== null) |
|
547 | + elseif ($template !== null) |
|
548 | 548 | { |
549 | 549 | $item = new TRepeaterItem; |
550 | 550 | $item->setItemIndex($itemIndex); |
@@ -562,9 +562,9 @@ discard block |
||
562 | 562 | */ |
563 | 563 | protected function createEmptyContent() |
564 | 564 | { |
565 | - if(($classPath = $this->getEmptyRenderer()) !== '') |
|
565 | + if (($classPath = $this->getEmptyRenderer()) !== '') |
|
566 | 566 | $this->getControls()->add(Prado::createComponent($classPath)); |
567 | - elseif($this->_emptyTemplate !== null) |
|
567 | + elseif ($this->_emptyTemplate !== null) |
|
568 | 568 | $this->_emptyTemplate->instantiateIn($this); |
569 | 569 | } |
570 | 570 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | */ |
577 | 577 | public function render($writer) |
578 | 578 | { |
579 | - if($this->_items && $this->_items->getCount() || $this->_emptyTemplate !== null || $this->getEmptyRenderer() !== '') |
|
579 | + if ($this->_items && $this->_items->getCount() || $this->_emptyTemplate !== null || $this->getEmptyRenderer() !== '') |
|
580 | 580 | $this->renderContents($writer); |
581 | 581 | } |
582 | 582 | |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | public function saveState() |
588 | 588 | { |
589 | 589 | parent::saveState(); |
590 | - if($this->_items) |
|
590 | + if ($this->_items) |
|
591 | 591 | $this->setViewState('ItemCount', $this->_items->getCount(), 0); |
592 | 592 | else |
593 | 593 | $this->clearViewState('ItemCount'); |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | public function loadState() |
601 | 601 | { |
602 | 602 | parent::loadState(); |
603 | - if(!$this->getIsDataBound()) |
|
603 | + if (!$this->getIsDataBound()) |
|
604 | 604 | $this->restoreItemsFromViewState(); |
605 | 605 | $this->clearViewState('ItemCount'); |
606 | 606 | } |
@@ -622,16 +622,16 @@ discard block |
||
622 | 622 | protected function restoreItemsFromViewState() |
623 | 623 | { |
624 | 624 | $this->reset(); |
625 | - if(($itemCount = $this->getViewState('ItemCount', 0)) > 0) |
|
625 | + if (($itemCount = $this->getViewState('ItemCount', 0)) > 0) |
|
626 | 626 | { |
627 | 627 | $items = $this->getItems(); |
628 | 628 | $hasSeparator = $this->_separatorTemplate !== null || $this->getSeparatorRenderer() !== ''; |
629 | 629 | $this->_header = $this->createItemInternal(-1, TListItemType::Header); |
630 | - for($i = 0;$i < $itemCount;++$i) |
|
630 | + for ($i = 0; $i < $itemCount; ++$i) |
|
631 | 631 | { |
632 | - if($hasSeparator && $i > 0) |
|
632 | + if ($hasSeparator && $i > 0) |
|
633 | 633 | $this->createItemInternal($i - 1, TListItemType::Separator); |
634 | - $itemType = $i % 2 == 0?TListItemType::Item : TListItemType::AlternatingItem; |
|
634 | + $itemType = $i % 2 == 0 ?TListItemType::Item : TListItemType::AlternatingItem; |
|
635 | 635 | $items->add($this->createItemInternal($i, $itemType, false, null)); |
636 | 636 | } |
637 | 637 | $this->_footer = $this->createItemInternal(-1, TListItemType::Footer); |
@@ -658,21 +658,21 @@ discard block |
||
658 | 658 | $items = $this->getItems(); |
659 | 659 | $itemIndex = 0; |
660 | 660 | $hasSeparator = $this->_separatorTemplate !== null || $this->getSeparatorRenderer() !== ''; |
661 | - foreach($data as $key => $dataItem) |
|
661 | + foreach ($data as $key => $dataItem) |
|
662 | 662 | { |
663 | - if($keyField !== '') |
|
663 | + if ($keyField !== '') |
|
664 | 664 | $keys->add($this->getDataFieldValue($dataItem, $keyField)); |
665 | 665 | else |
666 | 666 | $keys->add($key); |
667 | - if($itemIndex === 0) |
|
667 | + if ($itemIndex === 0) |
|
668 | 668 | $this->_header = $this->createItemWithDataInternal(-1, TListItemType::Header, null); |
669 | - if($hasSeparator && $itemIndex > 0) |
|
669 | + if ($hasSeparator && $itemIndex > 0) |
|
670 | 670 | $this->createItemWithDataInternal($itemIndex - 1, TListItemType::Separator, null); |
671 | - $itemType = $itemIndex % 2 == 0?TListItemType::Item : TListItemType::AlternatingItem; |
|
671 | + $itemType = $itemIndex % 2 == 0 ?TListItemType::Item : TListItemType::AlternatingItem; |
|
672 | 672 | $items->add($this->createItemWithDataInternal($itemIndex, $itemType, $dataItem)); |
673 | 673 | $itemIndex++; |
674 | 674 | } |
675 | - if($itemIndex > 0) |
|
675 | + if ($itemIndex > 0) |
|
676 | 676 | $this->_footer = $this->createItemWithDataInternal(-1, TListItemType::Footer, null); |
677 | 677 | else |
678 | 678 | { |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | */ |
694 | 694 | public function bubbleEvent($sender, $param) |
695 | 695 | { |
696 | - if($param instanceof TRepeaterCommandEventParameter) |
|
696 | + if ($param instanceof TRepeaterCommandEventParameter) |
|
697 | 697 | { |
698 | 698 | $this->onItemCommand($param); |
699 | 699 | return true; |
@@ -291,10 +291,11 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function setItemTemplate($value) |
293 | 293 | { |
294 | - if($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
295 | - $this->_itemTemplate = $value; |
|
296 | - else |
|
297 | - throw new TInvalidDataTypeException('repeater_template_required', 'ItemTemplate'); |
|
294 | + if($value instanceof \Prado\Web\UI\ITemplate || $value === null) { |
|
295 | + $this->_itemTemplate = $value; |
|
296 | + } else { |
|
297 | + throw new TInvalidDataTypeException('repeater_template_required', 'ItemTemplate'); |
|
298 | + } |
|
298 | 299 | } |
299 | 300 | |
300 | 301 | /** |
@@ -311,10 +312,11 @@ discard block |
||
311 | 312 | */ |
312 | 313 | public function setAlternatingItemTemplate($value) |
313 | 314 | { |
314 | - if($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
315 | - $this->_alternatingItemTemplate = $value; |
|
316 | - else |
|
317 | - throw new TInvalidDataTypeException('repeater_template_required', 'AlternatingItemTemplate'); |
|
315 | + if($value instanceof \Prado\Web\UI\ITemplate || $value === null) { |
|
316 | + $this->_alternatingItemTemplate = $value; |
|
317 | + } else { |
|
318 | + throw new TInvalidDataTypeException('repeater_template_required', 'AlternatingItemTemplate'); |
|
319 | + } |
|
318 | 320 | } |
319 | 321 | |
320 | 322 | /** |
@@ -331,10 +333,11 @@ discard block |
||
331 | 333 | */ |
332 | 334 | public function setHeaderTemplate($value) |
333 | 335 | { |
334 | - if($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
335 | - $this->_headerTemplate = $value; |
|
336 | - else |
|
337 | - throw new TInvalidDataTypeException('repeater_template_required', 'HeaderTemplate'); |
|
336 | + if($value instanceof \Prado\Web\UI\ITemplate || $value === null) { |
|
337 | + $this->_headerTemplate = $value; |
|
338 | + } else { |
|
339 | + throw new TInvalidDataTypeException('repeater_template_required', 'HeaderTemplate'); |
|
340 | + } |
|
338 | 341 | } |
339 | 342 | |
340 | 343 | /** |
@@ -351,10 +354,11 @@ discard block |
||
351 | 354 | */ |
352 | 355 | public function setFooterTemplate($value) |
353 | 356 | { |
354 | - if($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
355 | - $this->_footerTemplate = $value; |
|
356 | - else |
|
357 | - throw new TInvalidDataTypeException('repeater_template_required', 'FooterTemplate'); |
|
357 | + if($value instanceof \Prado\Web\UI\ITemplate || $value === null) { |
|
358 | + $this->_footerTemplate = $value; |
|
359 | + } else { |
|
360 | + throw new TInvalidDataTypeException('repeater_template_required', 'FooterTemplate'); |
|
361 | + } |
|
358 | 362 | } |
359 | 363 | |
360 | 364 | /** |
@@ -371,10 +375,11 @@ discard block |
||
371 | 375 | */ |
372 | 376 | public function setEmptyTemplate($value) |
373 | 377 | { |
374 | - if($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
375 | - $this->_emptyTemplate = $value; |
|
376 | - else |
|
377 | - throw new TInvalidDataTypeException('repeater_template_required', 'EmptyTemplate'); |
|
378 | + if($value instanceof \Prado\Web\UI\ITemplate || $value === null) { |
|
379 | + $this->_emptyTemplate = $value; |
|
380 | + } else { |
|
381 | + throw new TInvalidDataTypeException('repeater_template_required', 'EmptyTemplate'); |
|
382 | + } |
|
378 | 383 | } |
379 | 384 | |
380 | 385 | /** |
@@ -391,10 +396,11 @@ discard block |
||
391 | 396 | */ |
392 | 397 | public function setSeparatorTemplate($value) |
393 | 398 | { |
394 | - if($value instanceof \Prado\Web\UI\ITemplate || $value === null) |
|
395 | - $this->_separatorTemplate = $value; |
|
396 | - else |
|
397 | - throw new TInvalidDataTypeException('repeater_template_required', 'SeparatorTemplate'); |
|
399 | + if($value instanceof \Prado\Web\UI\ITemplate || $value === null) { |
|
400 | + $this->_separatorTemplate = $value; |
|
401 | + } else { |
|
402 | + throw new TInvalidDataTypeException('repeater_template_required', 'SeparatorTemplate'); |
|
403 | + } |
|
398 | 404 | } |
399 | 405 | |
400 | 406 | /** |
@@ -418,8 +424,9 @@ discard block |
||
418 | 424 | */ |
419 | 425 | public function getItems() |
420 | 426 | { |
421 | - if(!$this->_items) |
|
422 | - $this->_items = new TRepeaterItemCollection; |
|
427 | + if(!$this->_items) { |
|
428 | + $this->_items = new TRepeaterItemCollection; |
|
429 | + } |
|
423 | 430 | return $this->_items; |
424 | 431 | } |
425 | 432 | |
@@ -467,9 +474,9 @@ discard block |
||
467 | 474 | $this->onItemCreated($param); |
468 | 475 | $this->getControls()->add($item); |
469 | 476 | return $item; |
477 | + } else { |
|
478 | + return null; |
|
470 | 479 | } |
471 | - else |
|
472 | - return null; |
|
473 | 480 | } |
474 | 481 | |
475 | 482 | /** |
@@ -485,16 +492,17 @@ discard block |
||
485 | 492 | if(($item = $this->createItem($itemIndex, $itemType)) !== null) |
486 | 493 | { |
487 | 494 | $param = new TRepeaterItemEventParameter($item); |
488 | - if($item instanceof \Prado\IDataRenderer) |
|
489 | - $item->setData($dataItem); |
|
495 | + if($item instanceof \Prado\IDataRenderer) { |
|
496 | + $item->setData($dataItem); |
|
497 | + } |
|
490 | 498 | $this->onItemCreated($param); |
491 | 499 | $this->getControls()->add($item); |
492 | 500 | $item->dataBind(); |
493 | 501 | $this->onItemDataBound($param); |
494 | 502 | return $item; |
503 | + } else { |
|
504 | + return null; |
|
495 | 505 | } |
496 | - else |
|
497 | - return null; |
|
498 | 506 | } |
499 | 507 | |
500 | 508 | /** |
@@ -543,16 +551,15 @@ discard block |
||
543 | 551 | $item->setItemIndex($itemIndex); |
544 | 552 | $item->setItemType($itemType); |
545 | 553 | } |
546 | - } |
|
547 | - elseif($template !== null) |
|
554 | + } elseif($template !== null) |
|
548 | 555 | { |
549 | 556 | $item = new TRepeaterItem; |
550 | 557 | $item->setItemIndex($itemIndex); |
551 | 558 | $item->setItemType($itemType); |
552 | 559 | $template->instantiateIn($item); |
560 | + } else { |
|
561 | + $item = null; |
|
553 | 562 | } |
554 | - else |
|
555 | - $item = null; |
|
556 | 563 | |
557 | 564 | return $item; |
558 | 565 | } |
@@ -562,10 +569,11 @@ discard block |
||
562 | 569 | */ |
563 | 570 | protected function createEmptyContent() |
564 | 571 | { |
565 | - if(($classPath = $this->getEmptyRenderer()) !== '') |
|
566 | - $this->getControls()->add(Prado::createComponent($classPath)); |
|
567 | - elseif($this->_emptyTemplate !== null) |
|
568 | - $this->_emptyTemplate->instantiateIn($this); |
|
572 | + if(($classPath = $this->getEmptyRenderer()) !== '') { |
|
573 | + $this->getControls()->add(Prado::createComponent($classPath)); |
|
574 | + } elseif($this->_emptyTemplate !== null) { |
|
575 | + $this->_emptyTemplate->instantiateIn($this); |
|
576 | + } |
|
569 | 577 | } |
570 | 578 | |
571 | 579 | /** |
@@ -576,8 +584,9 @@ discard block |
||
576 | 584 | */ |
577 | 585 | public function render($writer) |
578 | 586 | { |
579 | - if($this->_items && $this->_items->getCount() || $this->_emptyTemplate !== null || $this->getEmptyRenderer() !== '') |
|
580 | - $this->renderContents($writer); |
|
587 | + if($this->_items && $this->_items->getCount() || $this->_emptyTemplate !== null || $this->getEmptyRenderer() !== '') { |
|
588 | + $this->renderContents($writer); |
|
589 | + } |
|
581 | 590 | } |
582 | 591 | |
583 | 592 | /** |
@@ -587,10 +596,11 @@ discard block |
||
587 | 596 | public function saveState() |
588 | 597 | { |
589 | 598 | parent::saveState(); |
590 | - if($this->_items) |
|
591 | - $this->setViewState('ItemCount', $this->_items->getCount(), 0); |
|
592 | - else |
|
593 | - $this->clearViewState('ItemCount'); |
|
599 | + if($this->_items) { |
|
600 | + $this->setViewState('ItemCount', $this->_items->getCount(), 0); |
|
601 | + } else { |
|
602 | + $this->clearViewState('ItemCount'); |
|
603 | + } |
|
594 | 604 | } |
595 | 605 | |
596 | 606 | /** |
@@ -600,8 +610,9 @@ discard block |
||
600 | 610 | public function loadState() |
601 | 611 | { |
602 | 612 | parent::loadState(); |
603 | - if(!$this->getIsDataBound()) |
|
604 | - $this->restoreItemsFromViewState(); |
|
613 | + if(!$this->getIsDataBound()) { |
|
614 | + $this->restoreItemsFromViewState(); |
|
615 | + } |
|
605 | 616 | $this->clearViewState('ItemCount'); |
606 | 617 | } |
607 | 618 | |
@@ -629,15 +640,16 @@ discard block |
||
629 | 640 | $this->_header = $this->createItemInternal(-1, TListItemType::Header); |
630 | 641 | for($i = 0;$i < $itemCount;++$i) |
631 | 642 | { |
632 | - if($hasSeparator && $i > 0) |
|
633 | - $this->createItemInternal($i - 1, TListItemType::Separator); |
|
643 | + if($hasSeparator && $i > 0) { |
|
644 | + $this->createItemInternal($i - 1, TListItemType::Separator); |
|
645 | + } |
|
634 | 646 | $itemType = $i % 2 == 0?TListItemType::Item : TListItemType::AlternatingItem; |
635 | 647 | $items->add($this->createItemInternal($i, $itemType, false, null)); |
636 | 648 | } |
637 | 649 | $this->_footer = $this->createItemInternal(-1, TListItemType::Footer); |
650 | + } else { |
|
651 | + $this->createEmptyContent(); |
|
638 | 652 | } |
639 | - else |
|
640 | - $this->createEmptyContent(); |
|
641 | 653 | $this->clearChildState(); |
642 | 654 | } |
643 | 655 | |
@@ -660,21 +672,24 @@ discard block |
||
660 | 672 | $hasSeparator = $this->_separatorTemplate !== null || $this->getSeparatorRenderer() !== ''; |
661 | 673 | foreach($data as $key => $dataItem) |
662 | 674 | { |
663 | - if($keyField !== '') |
|
664 | - $keys->add($this->getDataFieldValue($dataItem, $keyField)); |
|
665 | - else |
|
666 | - $keys->add($key); |
|
667 | - if($itemIndex === 0) |
|
668 | - $this->_header = $this->createItemWithDataInternal(-1, TListItemType::Header, null); |
|
669 | - if($hasSeparator && $itemIndex > 0) |
|
670 | - $this->createItemWithDataInternal($itemIndex - 1, TListItemType::Separator, null); |
|
675 | + if($keyField !== '') { |
|
676 | + $keys->add($this->getDataFieldValue($dataItem, $keyField)); |
|
677 | + } else { |
|
678 | + $keys->add($key); |
|
679 | + } |
|
680 | + if($itemIndex === 0) { |
|
681 | + $this->_header = $this->createItemWithDataInternal(-1, TListItemType::Header, null); |
|
682 | + } |
|
683 | + if($hasSeparator && $itemIndex > 0) { |
|
684 | + $this->createItemWithDataInternal($itemIndex - 1, TListItemType::Separator, null); |
|
685 | + } |
|
671 | 686 | $itemType = $itemIndex % 2 == 0?TListItemType::Item : TListItemType::AlternatingItem; |
672 | 687 | $items->add($this->createItemWithDataInternal($itemIndex, $itemType, $dataItem)); |
673 | 688 | $itemIndex++; |
674 | 689 | } |
675 | - if($itemIndex > 0) |
|
676 | - $this->_footer = $this->createItemWithDataInternal(-1, TListItemType::Footer, null); |
|
677 | - else |
|
690 | + if($itemIndex > 0) { |
|
691 | + $this->_footer = $this->createItemWithDataInternal(-1, TListItemType::Footer, null); |
|
692 | + } else |
|
678 | 693 | { |
679 | 694 | $this->createEmptyContent(); |
680 | 695 | $this->dataBindChildren(); |
@@ -697,9 +712,9 @@ discard block |
||
697 | 712 | { |
698 | 713 | $this->onItemCommand($param); |
699 | 714 | return true; |
715 | + } else { |
|
716 | + return false; |
|
700 | 717 | } |
701 | - else |
|
702 | - return false; |
|
703 | 718 | } |
704 | 719 | |
705 | 720 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | /** |
152 | 152 | * @return boolean wether to display a progress indicator or not. Defaults to true. |
153 | 153 | */ |
154 | - public function getProgressIndicator () |
|
154 | + public function getProgressIndicator() |
|
155 | 155 | { |
156 | 156 | return $this->getViewState('ProgressIndicator', true); |
157 | 157 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | /** |
160 | 160 | * @param boolean wether to display a progress indicator or not. Defaults to true. |
161 | 161 | */ |
162 | - public function setProgressIndicator ($value) |
|
162 | + public function setProgressIndicator($value) |
|
163 | 163 | { |
164 | 164 | $this->setViewState('ProgressIndicator', TPropertyValue::ensureBoolean($value), true); |
165 | 165 | } |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | */ |
297 | 297 | public function loadPostData($key, $values) |
298 | 298 | { |
299 | - $value = (float)$values[$this->getClientID() . '_1']; |
|
300 | - if($this->getValue() !== $value) |
|
299 | + $value = (float) $values[$this->getClientID().'_1']; |
|
300 | + if ($this->getValue() !== $value) |
|
301 | 301 | { |
302 | 302 | $this->setValue($value); |
303 | 303 | return $this->_dataChanged = true; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function getClientSide() |
321 | 321 | { |
322 | - if($this->_clientScript === null) |
|
322 | + if ($this->_clientScript === null) |
|
323 | 323 | $this->_clientScript = $this->createClientScript(); |
324 | 324 | return $this->_clientScript; |
325 | 325 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | /** |
336 | 336 | * @return string the HTML tag name for slider. Defaults to div. |
337 | 337 | */ |
338 | - public function getTagName () |
|
338 | + public function getTagName() |
|
339 | 339 | { |
340 | 340 | return "div"; |
341 | 341 | } |
@@ -350,8 +350,8 @@ discard block |
||
350 | 350 | $writer->addAttribute('id', $this->getClientID()); |
351 | 351 | if ($this->getCssClass() === '') |
352 | 352 | { |
353 | - $class = ($this->getDirection() == TSliderDirection::Horizontal)?'HorizontalSlider':'VerticalSlider'; |
|
354 | - $writer->addAttribute('class', 'Slider ' . $class); |
|
353 | + $class = ($this->getDirection() == TSliderDirection::Horizontal) ? 'HorizontalSlider' : 'VerticalSlider'; |
|
354 | + $writer->addAttribute('class', 'Slider '.$class); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | } |
@@ -363,13 +363,13 @@ discard block |
||
363 | 363 | { |
364 | 364 | // Render the 'Track' |
365 | 365 | $writer->addAttribute('class', 'Track'); |
366 | - $writer->addAttribute('id', $this->getClientID() . '_track'); |
|
366 | + $writer->addAttribute('id', $this->getClientID().'_track'); |
|
367 | 367 | $writer->renderBeginTag('div'); |
368 | 368 | // Render the 'Progress Indicator' |
369 | 369 | if ($this->getProgressIndicator()) |
370 | 370 | { |
371 | 371 | $writer->addAttribute('class', 'Progress'); |
372 | - $writer->addAttribute('id', $this->getClientID() . '_progress'); |
|
372 | + $writer->addAttribute('id', $this->getClientID().'_progress'); |
|
373 | 373 | $writer->renderBeginTag('div'); |
374 | 374 | $writer->renderEndTag(); |
375 | 375 | } |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | |
395 | 395 | // Render the 'Handle' |
396 | 396 | $writer->addAttribute('class', 'Handle'); |
397 | - $writer->addAttribute('id', $this->getClientID() . '_handle'); |
|
397 | + $writer->addAttribute('id', $this->getClientID().'_handle'); |
|
398 | 398 | $writer->renderBeginTag('div'); |
399 | 399 | $writer->renderEndTag(); |
400 | 400 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * This method is invoked right before the control rendering, if the control is visible. |
404 | 404 | * @param mixed event parameter |
405 | 405 | */ |
406 | - public function onPreRender ($param) |
|
406 | + public function onPreRender($param) |
|
407 | 407 | { |
408 | 408 | parent::onPreRender($param); |
409 | 409 | $this->registerStyleSheet(); |
@@ -418,11 +418,11 @@ discard block |
||
418 | 418 | */ |
419 | 419 | protected function registerStyleSheet() |
420 | 420 | { |
421 | - if(($url = $this->getCssUrl()) === '') |
|
421 | + if (($url = $this->getCssUrl()) === '') |
|
422 | 422 | { |
423 | 423 | $manager = $this->getApplication()->getAssetManager(); |
424 | 424 | // publish the assets |
425 | - $url = $manager->publishFilePath(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'TSlider'); |
|
425 | + $url = $manager->publishFilePath(dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'TSlider'); |
|
426 | 426 | $url .= '/TSlider.css'; |
427 | 427 | } |
428 | 428 | $this->getPage()->getClientScript()->registerStyleSheetFile($url, $url); |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | $cs = $page->getClientScript(); |
438 | 438 | $cs->registerPradoScript("slider"); |
439 | 439 | $id = $this->getClientID(); |
440 | - $cs->registerHiddenField($id . '_1', $this->getValue()); |
|
440 | + $cs->registerHiddenField($id.'_1', $this->getValue()); |
|
441 | 441 | $page->registerRequiresPostData($this); |
442 | 442 | $cs->registerPostBackControl($this->getClientClassName(), $this->getSliderOptions()); |
443 | 443 | } |
@@ -485,13 +485,13 @@ discard block |
||
485 | 485 | $step = ($maxValue - $minValue) / self::MAX_STEPS; |
486 | 486 | } |
487 | 487 | $values = []; |
488 | - for ($i = $minValue;$i <= $maxValue;$i += $step) |
|
488 | + for ($i = $minValue; $i <= $maxValue; $i += $step) |
|
489 | 489 | $values[] = $i; |
490 | 490 | // Add max if it's not in the array because of step |
491 | 491 | if (!in_array($maxValue, $values)) $values[] = $maxValue; |
492 | 492 | } |
493 | 493 | $options['values'] = $values; |
494 | - if($this->_clientScript !== null) |
|
494 | + if ($this->_clientScript !== null) |
|
495 | 495 | $options = array_merge($options, $this->_clientScript->getOptions()->toArray()); |
496 | 496 | return $options; |
497 | 497 | } |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | { |
302 | 302 | $this->setValue($value); |
303 | 303 | return $this->_dataChanged = true; |
304 | + } else { |
|
305 | + return false; |
|
304 | 306 | } |
305 | - else |
|
306 | - return false; |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -319,8 +319,9 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function getClientSide() |
321 | 321 | { |
322 | - if($this->_clientScript === null) |
|
323 | - $this->_clientScript = $this->createClientScript(); |
|
322 | + if($this->_clientScript === null) { |
|
323 | + $this->_clientScript = $this->createClientScript(); |
|
324 | + } |
|
324 | 325 | return $this->_clientScript; |
325 | 326 | } |
326 | 327 | |
@@ -466,16 +467,23 @@ discard block |
||
466 | 467 | if (!empty($values)) |
467 | 468 | { |
468 | 469 | // Values are provided. Check if min/max are present in them |
469 | - if (!in_array($minValue, $values)) $values[] = $minValue; |
|
470 | - if (!in_array($maxValue, $values)) $values[] = $maxValue; |
|
470 | + if (!in_array($minValue, $values)) { |
|
471 | + $values[] = $minValue; |
|
472 | + } |
|
473 | + if (!in_array($maxValue, $values)) { |
|
474 | + $values[] = $maxValue; |
|
475 | + } |
|
471 | 476 | // Remove all values outsize the range [min..max] |
472 | 477 | foreach ($values as $idx => $value) |
473 | 478 | { |
474 | - if ($value < $minValue) unset($values[$idx]); |
|
475 | - if ($value > $maxValue) unset($values[$idx]); |
|
479 | + if ($value < $minValue) { |
|
480 | + unset($values[$idx]); |
|
481 | + } |
|
482 | + if ($value > $maxValue) { |
|
483 | + unset($values[$idx]); |
|
484 | + } |
|
476 | 485 | } |
477 | - } |
|
478 | - else |
|
486 | + } else |
|
479 | 487 | { |
480 | 488 | // Values are not provided, generate automatically using stepsize |
481 | 489 | $step = $this->getStepSize(); |
@@ -485,14 +493,18 @@ discard block |
||
485 | 493 | $step = ($maxValue - $minValue) / self::MAX_STEPS; |
486 | 494 | } |
487 | 495 | $values = []; |
488 | - for ($i = $minValue;$i <= $maxValue;$i += $step) |
|
489 | - $values[] = $i; |
|
496 | + for ($i = $minValue;$i <= $maxValue;$i += $step) { |
|
497 | + $values[] = $i; |
|
498 | + } |
|
490 | 499 | // Add max if it's not in the array because of step |
491 | - if (!in_array($maxValue, $values)) $values[] = $maxValue; |
|
500 | + if (!in_array($maxValue, $values)) { |
|
501 | + $values[] = $maxValue; |
|
502 | + } |
|
492 | 503 | } |
493 | 504 | $options['values'] = $values; |
494 | - if($this->_clientScript !== null) |
|
495 | - $options = array_merge($options, $this->_clientScript->getOptions()->toArray()); |
|
505 | + if($this->_clientScript !== null) { |
|
506 | + $options = array_merge($options, $this->_clientScript->getOptions()->toArray()); |
|
507 | + } |
|
496 | 508 | return $options; |
497 | 509 | } |
498 | 510 | } |
499 | 511 | \ No newline at end of file |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | public function createChildControls() |
49 | 49 | { |
50 | 50 | $this->getControls()->clear(); |
51 | - if($this->_contentTemplate) |
|
51 | + if ($this->_contentTemplate) |
|
52 | 52 | $this->_contentTemplate->instantiateIn($this); |
53 | 53 | } |
54 | 54 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function instantiateNavigationTemplate() |
110 | 110 | { |
111 | - if(!$this->_navigationContainer && $this->_navigationTemplate) |
|
111 | + if (!$this->_navigationContainer && $this->_navigationTemplate) |
|
112 | 112 | { |
113 | 113 | $this->_navigationContainer = new TWizardNavigationContainer; |
114 | 114 | $this->_navigationTemplate->instantiateIn($this->_navigationContainer); |
@@ -48,8 +48,9 @@ |
||
48 | 48 | public function createChildControls() |
49 | 49 | { |
50 | 50 | $this->getControls()->clear(); |
51 | - if($this->_contentTemplate) |
|
52 | - $this->_contentTemplate->instantiateIn($this); |
|
51 | + if($this->_contentTemplate) { |
|
52 | + $this->_contentTemplate->instantiateIn($this); |
|
53 | + } |
|
53 | 54 | } |
54 | 55 | |
55 | 56 | /** |
@@ -28,9 +28,9 @@ |
||
28 | 28 | public function __construct(IDataSource $owner, $viewName, $dataSource) |
29 | 29 | { |
30 | 30 | parent::__construct($owner, $viewName); |
31 | - if($dataSource === null || is_array($dataSource)) |
|
31 | + if ($dataSource === null || is_array($dataSource)) |
|
32 | 32 | $this->_dataSource = new TMap($dataSource); |
33 | - elseif($dataSource instanceof \Traversable) |
|
33 | + elseif ($dataSource instanceof \Traversable) |
|
34 | 34 | $this->_dataSource = $dataSource; |
35 | 35 | else |
36 | 36 | throw new TInvalidDataTypeException('readonlydatasourceview_datasource_invalid'); |
@@ -28,12 +28,13 @@ |
||
28 | 28 | public function __construct(IDataSource $owner, $viewName, $dataSource) |
29 | 29 | { |
30 | 30 | parent::__construct($owner, $viewName); |
31 | - if($dataSource === null || is_array($dataSource)) |
|
32 | - $this->_dataSource = new TMap($dataSource); |
|
33 | - elseif($dataSource instanceof \Traversable) |
|
34 | - $this->_dataSource = $dataSource; |
|
35 | - else |
|
36 | - throw new TInvalidDataTypeException('readonlydatasourceview_datasource_invalid'); |
|
31 | + if($dataSource === null || is_array($dataSource)) { |
|
32 | + $this->_dataSource = new TMap($dataSource); |
|
33 | + } elseif($dataSource instanceof \Traversable) { |
|
34 | + $this->_dataSource = $dataSource; |
|
35 | + } else { |
|
36 | + throw new TInvalidDataTypeException('readonlydatasourceview_datasource_invalid'); |
|
37 | + } |
|
37 | 38 | } |
38 | 39 | |
39 | 40 | public function select($parameters) |
@@ -43,9 +43,9 @@ |
||
43 | 43 | { |
44 | 44 | $writer->addAttribute('src', $this->getImageUrl()); |
45 | 45 | $writer->addAttribute('alt', $this->getAlternateText()); |
46 | - if(($desc = $this->getDescriptionUrl()) !== '') |
|
46 | + if (($desc = $this->getDescriptionUrl()) !== '') |
|
47 | 47 | $writer->addAttribute('longdesc', $desc); |
48 | - if(($align = $this->getImageAlign()) !== '') |
|
48 | + if (($align = $this->getImageAlign()) !== '') |
|
49 | 49 | $writer->addAttribute('align', $align); |
50 | 50 | parent::addAttributesToRender($writer); |
51 | 51 | } |
@@ -43,10 +43,12 @@ |
||
43 | 43 | { |
44 | 44 | $writer->addAttribute('src', $this->getImageUrl()); |
45 | 45 | $writer->addAttribute('alt', $this->getAlternateText()); |
46 | - if(($desc = $this->getDescriptionUrl()) !== '') |
|
47 | - $writer->addAttribute('longdesc', $desc); |
|
48 | - if(($align = $this->getImageAlign()) !== '') |
|
49 | - $writer->addAttribute('align', $align); |
|
46 | + if(($desc = $this->getDescriptionUrl()) !== '') { |
|
47 | + $writer->addAttribute('longdesc', $desc); |
|
48 | + } |
|
49 | + if(($align = $this->getImageAlign()) !== '') { |
|
50 | + $writer->addAttribute('align', $align); |
|
51 | + } |
|
50 | 52 | parent::addAttributesToRender($writer); |
51 | 53 | } |
52 | 54 |