@@ -422,6 +422,7 @@ discard block |
||
422 | 422 | |
423 | 423 | /** |
424 | 424 | * Parse additional options set in the Options property. |
425 | + * @param string $string |
|
425 | 426 | * @return array additional custom options |
426 | 427 | */ |
427 | 428 | protected function parseEditorOptions($string) |
@@ -446,6 +447,7 @@ discard block |
||
446 | 447 | } |
447 | 448 | |
448 | 449 | /** |
450 | + * @param string $culture |
|
449 | 451 | * @return string localized editor interface language extension. |
450 | 452 | */ |
451 | 453 | protected function getLanguageSuffix($culture) |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function getEnableVisualEdit() |
211 | 211 | { |
212 | - return $this->getViewState('EnableVisualEdit',true); |
|
212 | + return $this->getViewState('EnableVisualEdit', true); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | */ |
219 | 219 | public function setEnableVisualEdit($value) |
220 | 220 | { |
221 | - $this->setViewState('EnableVisualEdit',TPropertyValue::ensureBoolean($value),true); |
|
221 | + $this->setViewState('EnableVisualEdit', TPropertyValue::ensureBoolean($value), true); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | */ |
302 | 302 | protected function addAttributesToRender($writer) |
303 | 303 | { |
304 | - if($this->getEnableVisualEdit() && $this->getEnabled(true)) |
|
304 | + if ($this->getEnableVisualEdit() && $this->getEnabled(true)) |
|
305 | 305 | { |
306 | - $writer->addAttribute('id',$this->getClientID()); |
|
306 | + $writer->addAttribute('id', $this->getClientID()); |
|
307 | 307 | $this->registerEditorClientScript($writer); |
308 | 308 | } |
309 | 309 | |
@@ -354,9 +354,9 @@ discard block |
||
354 | 354 | 'EditorOptions' => $this->getEditorOptions() |
355 | 355 | ); |
356 | 356 | |
357 | - $options = TJavaScript::encode($options,true,true); |
|
357 | + $options = TJavaScript::encode($options, true, true); |
|
358 | 358 | $script = "new {$this->getClientClassName()}($options)"; |
359 | - $scripts->registerEndScript('prado:THtmlArea4'.$this->ClientID,$script); |
|
359 | + $scripts->registerEndScript('prado:THtmlArea4' . $this->ClientID, $script); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | protected function getScriptUrl() |
366 | 366 | { |
367 | - return $this->getScriptDeploymentPath().'/tinymce.min.js'; |
|
367 | + return $this->getScriptDeploymentPath() . '/tinymce.min.js'; |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | |
382 | 382 | protected function copyCustomPlugins($url) |
383 | 383 | { |
384 | - if($plugins = $this->getCustomPluginPath()) |
|
384 | + if ($plugins = $this->getCustomPluginPath()) |
|
385 | 385 | { |
386 | 386 | $assets = $this->getApplication()->getAssetManager(); |
387 | 387 | $path = is_dir($plugins) ? $plugins : Prado::getPathOfNameSpace($plugins); |
388 | - $dest = $assets->getBasePath().'/'.basename($url).'/plugins/'; |
|
389 | - if(!is_dir($dest) || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
388 | + $dest = $assets->getBasePath() . '/' . basename($url) . '/plugins/'; |
|
389 | + if (!is_dir($dest) || $this->getApplication()->getMode() !== TApplicationMode::Performance) |
|
390 | 390 | $assets->copyDirectory($path, $dest); |
391 | 391 | } |
392 | 392 | } |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | $options['height'] = $this->getHeight(); |
407 | 407 | $options['resize'] = 'both'; |
408 | 408 | $options['menubar'] = false; |
409 | - if($this->getReadOnly()) |
|
409 | + if ($this->getReadOnly()) |
|
410 | 410 | { |
411 | 411 | $options['readonly'] = true; |
412 | 412 | $options['toolbar'] = false; |
@@ -428,17 +428,17 @@ discard block |
||
428 | 428 | { |
429 | 429 | $options = array(); |
430 | 430 | $substrings = preg_split('/,\s*\n|\n/', trim($string)); |
431 | - foreach($substrings as $bits) |
|
431 | + foreach ($substrings as $bits) |
|
432 | 432 | { |
433 | - $option = explode(":",$bits,2); |
|
433 | + $option = explode(":", $bits, 2); |
|
434 | 434 | |
435 | - if(count($option) == 2) |
|
435 | + if (count($option) == 2) |
|
436 | 436 | { |
437 | - $value=trim(trim($option[1]),"'\""); |
|
438 | - if (($s=strtolower($value))==='false') |
|
439 | - $value=false; |
|
440 | - elseif ($s==='true') |
|
441 | - $value=true; |
|
437 | + $value = trim(trim($option[1]), "'\""); |
|
438 | + if (($s = strtolower($value)) === 'false') |
|
439 | + $value = false; |
|
440 | + elseif ($s === 'true') |
|
441 | + $value = true; |
|
442 | 442 | $options[trim($option[0])] = $value; |
443 | 443 | } |
444 | 444 | } |
@@ -451,15 +451,15 @@ discard block |
||
451 | 451 | protected function getLanguageSuffix($culture) |
452 | 452 | { |
453 | 453 | $app = $this->getApplication()->getGlobalization(); |
454 | - if(empty($culture) && ($app!==null)) |
|
454 | + if (empty($culture) && ($app !== null)) |
|
455 | 455 | $culture = $app->getCulture(); |
456 | 456 | $variants = array(); |
457 | - if($app!==null) |
|
457 | + if ($app !== null) |
|
458 | 458 | $variants = $app->getCultureVariants($culture); |
459 | 459 | |
460 | - foreach($variants as $variant) |
|
460 | + foreach ($variants as $variant) |
|
461 | 461 | { |
462 | - if(isset(self::$_langs[$variant])) |
|
462 | + if (isset(self::$_langs[$variant])) |
|
463 | 463 | return self::$_langs[$variant]; |
464 | 464 | } |
465 | 465 |
@@ -386,8 +386,9 @@ discard block |
||
386 | 386 | $assets = $this->getApplication()->getAssetManager(); |
387 | 387 | $path = is_dir($plugins) ? $plugins : Prado::getPathOfNameSpace($plugins); |
388 | 388 | $dest = $assets->getBasePath().'/'.basename($url).'/plugins/'; |
389 | - if(!is_dir($dest) || $this->getApplication()->getMode()!==TApplicationMode::Performance) |
|
390 | - $assets->copyDirectory($path, $dest); |
|
389 | + if(!is_dir($dest) || $this->getApplication()->getMode()!==TApplicationMode::Performance) { |
|
390 | + $assets->copyDirectory($path, $dest); |
|
391 | + } |
|
391 | 392 | } |
392 | 393 | } |
393 | 394 | |
@@ -435,10 +436,11 @@ discard block |
||
435 | 436 | if(count($option) == 2) |
436 | 437 | { |
437 | 438 | $value=trim(trim($option[1]),"'\""); |
438 | - if (($s=strtolower($value))==='false') |
|
439 | - $value=false; |
|
440 | - elseif ($s==='true') |
|
441 | - $value=true; |
|
439 | + if (($s=strtolower($value))==='false') { |
|
440 | + $value=false; |
|
441 | + } elseif ($s==='true') { |
|
442 | + $value=true; |
|
443 | + } |
|
442 | 444 | $options[trim($option[0])] = $value; |
443 | 445 | } |
444 | 446 | } |
@@ -451,16 +453,19 @@ discard block |
||
451 | 453 | protected function getLanguageSuffix($culture) |
452 | 454 | { |
453 | 455 | $app = $this->getApplication()->getGlobalization(); |
454 | - if(empty($culture) && ($app!==null)) |
|
455 | - $culture = $app->getCulture(); |
|
456 | + if(empty($culture) && ($app!==null)) { |
|
457 | + $culture = $app->getCulture(); |
|
458 | + } |
|
456 | 459 | $variants = array(); |
457 | - if($app!==null) |
|
458 | - $variants = $app->getCultureVariants($culture); |
|
460 | + if($app!==null) { |
|
461 | + $variants = $app->getCultureVariants($culture); |
|
462 | + } |
|
459 | 463 | |
460 | 464 | foreach($variants as $variant) |
461 | 465 | { |
462 | - if(isset(self::$_langs[$variant])) |
|
463 | - return self::$_langs[$variant]; |
|
466 | + if(isset(self::$_langs[$variant])) { |
|
467 | + return self::$_langs[$variant]; |
|
468 | + } |
|
464 | 469 | } |
465 | 470 | |
466 | 471 | return 'en'; |
@@ -147,6 +147,7 @@ discard block |
||
147 | 147 | /** |
148 | 148 | * Sets the height of the image in the THyperLink |
149 | 149 | * @param string height of the image in the THyperLink |
150 | + * @param string $value |
|
150 | 151 | */ |
151 | 152 | public function setImageHeight($value) |
152 | 153 | { |
@@ -181,6 +182,7 @@ discard block |
||
181 | 182 | /** |
182 | 183 | * Sets the width of the image in the THyperLink |
183 | 184 | * @param string width of the image |
185 | + * @param string $value |
|
184 | 186 | */ |
185 | 187 | public function setImageWidth($value) |
186 | 188 | { |
@@ -44,14 +44,14 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected function addAttributesToRender($writer) |
46 | 46 | { |
47 | - $isEnabled=$this->getEnabled(true); |
|
48 | - if($this->getEnabled() && !$isEnabled) |
|
49 | - $writer->addAttribute('disabled','disabled'); |
|
47 | + $isEnabled = $this->getEnabled(true); |
|
48 | + if ($this->getEnabled() && !$isEnabled) |
|
49 | + $writer->addAttribute('disabled', 'disabled'); |
|
50 | 50 | parent::addAttributesToRender($writer); |
51 | - if(($url=$this->getNavigateUrl())!=='' && $isEnabled) |
|
52 | - $writer->addAttribute('href',$url); |
|
53 | - if(($target=$this->getTarget())!=='') |
|
54 | - $writer->addAttribute('target',$target); |
|
51 | + if (($url = $this->getNavigateUrl()) !== '' && $isEnabled) |
|
52 | + $writer->addAttribute('href', $url); |
|
53 | + if (($target = $this->getTarget()) !== '') |
|
54 | + $writer->addAttribute('target', $target); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function renderContents($writer) |
62 | 62 | { |
63 | - if(($imageUrl=$this->getImageUrl())==='') |
|
63 | + if (($imageUrl = $this->getImageUrl()) === '') |
|
64 | 64 | { |
65 | - if(($text=$this->getText())!=='') |
|
65 | + if (($text = $this->getText()) !== '') |
|
66 | 66 | $writer->write(THttpUtility::htmlEncode($text)); |
67 | - else if($this->getHasControls()) |
|
67 | + else if ($this->getHasControls()) |
|
68 | 68 | parent::renderContents($writer); |
69 | 69 | else |
70 | 70 | $writer->write(THttpUtility::htmlEncode($this->getNavigateUrl())); |
@@ -83,17 +83,17 @@ discard block |
||
83 | 83 | */ |
84 | 84 | protected function createImage($imageUrl) |
85 | 85 | { |
86 | - $image=Prado::createComponent('System.Web.UI.WebControls.TImage'); |
|
86 | + $image = Prado::createComponent('System.Web.UI.WebControls.TImage'); |
|
87 | 87 | $image->setImageUrl($imageUrl); |
88 | - if(($width=$this->getImageWidth())!=='') |
|
88 | + if (($width = $this->getImageWidth()) !== '') |
|
89 | 89 | $image->setWidth($width); |
90 | - if(($height=$this->getImageHeight())!=='') |
|
90 | + if (($height = $this->getImageHeight()) !== '') |
|
91 | 91 | $image->setHeight($height); |
92 | - if(($toolTip=$this->getToolTip())!=='') |
|
92 | + if (($toolTip = $this->getToolTip()) !== '') |
|
93 | 93 | $image->setToolTip($toolTip); |
94 | - if(($text=$this->getText())!=='') |
|
94 | + if (($text = $this->getText()) !== '') |
|
95 | 95 | $image->setAlternateText($text); |
96 | - if(($align=$this->getImageAlign())!=='') |
|
96 | + if (($align = $this->getImageAlign()) !== '') |
|
97 | 97 | $image->setImageAlign($align); |
98 | 98 | $image->setBorderWidth('0'); |
99 | 99 | return $image; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function getText() |
106 | 106 | { |
107 | - return $this->getViewState('Text',''); |
|
107 | + return $this->getViewState('Text', ''); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function setText($value) |
115 | 115 | { |
116 | - $this->setViewState('Text',$value,''); |
|
116 | + $this->setViewState('Text', $value, ''); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function getImageAlign() |
123 | 123 | { |
124 | - return $this->getViewState('ImageAlign',''); |
|
124 | + return $this->getViewState('ImageAlign', ''); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function setImageAlign($value) |
135 | 135 | { |
136 | - $this->setViewState('ImageAlign',$value,''); |
|
136 | + $this->setViewState('ImageAlign', $value, ''); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function getImageHeight() |
143 | 143 | { |
144 | - return $this->getViewState('ImageHeight',''); |
|
144 | + return $this->getViewState('ImageHeight', ''); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function setImageHeight($value) |
152 | 152 | { |
153 | - $this->setViewSTate('ImageHeight',$value,''); |
|
153 | + $this->setViewSTate('ImageHeight', $value, ''); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function getImageUrl() |
160 | 160 | { |
161 | - return $this->getViewState('ImageUrl',''); |
|
161 | + return $this->getViewState('ImageUrl', ''); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function setImageUrl($value) |
169 | 169 | { |
170 | - $this->setViewState('ImageUrl',$value,''); |
|
170 | + $this->setViewState('ImageUrl', $value, ''); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function getImageWidth() |
177 | 177 | { |
178 | - return $this->getViewState('ImageWidth',''); |
|
178 | + return $this->getViewState('ImageWidth', ''); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function setImageWidth($value) |
186 | 186 | { |
187 | - $this->setViewState('ImageWidth',$value,''); |
|
187 | + $this->setViewState('ImageWidth', $value, ''); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function getNavigateUrl() |
194 | 194 | { |
195 | - return $this->getViewState('NavigateUrl',''); |
|
195 | + return $this->getViewState('NavigateUrl', ''); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function setNavigateUrl($value) |
203 | 203 | { |
204 | - $this->setViewState('NavigateUrl',$value,''); |
|
204 | + $this->setViewState('NavigateUrl', $value, ''); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function getTarget() |
237 | 237 | { |
238 | - return $this->getViewState('Target',''); |
|
238 | + return $this->getViewState('Target', ''); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function setTarget($value) |
246 | 246 | { |
247 | - $this->setViewState('Target',$value,''); |
|
247 | + $this->setViewState('Target', $value, ''); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 |
@@ -45,13 +45,16 @@ discard block |
||
45 | 45 | protected function addAttributesToRender($writer) |
46 | 46 | { |
47 | 47 | $isEnabled=$this->getEnabled(true); |
48 | - if($this->getEnabled() && !$isEnabled) |
|
49 | - $writer->addAttribute('disabled','disabled'); |
|
48 | + if($this->getEnabled() && !$isEnabled) { |
|
49 | + $writer->addAttribute('disabled','disabled'); |
|
50 | + } |
|
50 | 51 | parent::addAttributesToRender($writer); |
51 | - if(($url=$this->getNavigateUrl())!=='' && $isEnabled) |
|
52 | - $writer->addAttribute('href',$url); |
|
53 | - if(($target=$this->getTarget())!=='') |
|
54 | - $writer->addAttribute('target',$target); |
|
52 | + if(($url=$this->getNavigateUrl())!=='' && $isEnabled) { |
|
53 | + $writer->addAttribute('href',$url); |
|
54 | + } |
|
55 | + if(($target=$this->getTarget())!=='') { |
|
56 | + $writer->addAttribute('target',$target); |
|
57 | + } |
|
55 | 58 | } |
56 | 59 | |
57 | 60 | /** |
@@ -62,14 +65,14 @@ discard block |
||
62 | 65 | { |
63 | 66 | if(($imageUrl=$this->getImageUrl())==='') |
64 | 67 | { |
65 | - if(($text=$this->getText())!=='') |
|
66 | - $writer->write(THttpUtility::htmlEncode($text)); |
|
67 | - else if($this->getHasControls()) |
|
68 | - parent::renderContents($writer); |
|
69 | - else |
|
70 | - $writer->write(THttpUtility::htmlEncode($this->getNavigateUrl())); |
|
71 | - } |
|
72 | - else |
|
68 | + if(($text=$this->getText())!=='') { |
|
69 | + $writer->write(THttpUtility::htmlEncode($text)); |
|
70 | + } else if($this->getHasControls()) { |
|
71 | + parent::renderContents($writer); |
|
72 | + } else { |
|
73 | + $writer->write(THttpUtility::htmlEncode($this->getNavigateUrl())); |
|
74 | + } |
|
75 | + } else |
|
73 | 76 | { |
74 | 77 | $this->createImage($imageUrl)->renderControl($writer); |
75 | 78 | } |
@@ -85,16 +88,21 @@ discard block |
||
85 | 88 | { |
86 | 89 | $image=Prado::createComponent('System.Web.UI.WebControls.TImage'); |
87 | 90 | $image->setImageUrl($imageUrl); |
88 | - if(($width=$this->getImageWidth())!=='') |
|
89 | - $image->setWidth($width); |
|
90 | - if(($height=$this->getImageHeight())!=='') |
|
91 | - $image->setHeight($height); |
|
92 | - if(($toolTip=$this->getToolTip())!=='') |
|
93 | - $image->setToolTip($toolTip); |
|
94 | - if(($text=$this->getText())!=='') |
|
95 | - $image->setAlternateText($text); |
|
96 | - if(($align=$this->getImageAlign())!=='') |
|
97 | - $image->setImageAlign($align); |
|
91 | + if(($width=$this->getImageWidth())!=='') { |
|
92 | + $image->setWidth($width); |
|
93 | + } |
|
94 | + if(($height=$this->getImageHeight())!=='') { |
|
95 | + $image->setHeight($height); |
|
96 | + } |
|
97 | + if(($toolTip=$this->getToolTip())!=='') { |
|
98 | + $image->setToolTip($toolTip); |
|
99 | + } |
|
100 | + if(($text=$this->getText())!=='') { |
|
101 | + $image->setAlternateText($text); |
|
102 | + } |
|
103 | + if(($align=$this->getImageAlign())!=='') { |
|
104 | + $image->setImageAlign($align); |
|
105 | + } |
|
98 | 106 | $image->setBorderWidth('0'); |
99 | 107 | return $image; |
100 | 108 | } |
@@ -232,6 +232,7 @@ discard block |
||
232 | 232 | * If you override this method, be sure to call the parent implementation |
233 | 233 | * so that the event handlers can be invoked. |
234 | 234 | * @param TCommandEventParameter event parameter to be passed to the event handlers |
235 | + * @param TCommandEventParameter $param |
|
235 | 236 | */ |
236 | 237 | public function onCommand($param) |
237 | 238 | { |
@@ -324,6 +325,7 @@ discard block |
||
324 | 325 | |
325 | 326 | /** |
326 | 327 | * @param string the group of validators which the button causes validation upon postback |
328 | + * @param string $value |
|
327 | 329 | */ |
328 | 330 | public function setValidationGroup($value) |
329 | 331 | { |
@@ -396,6 +398,8 @@ discard block |
||
396 | 398 | * Constructor. |
397 | 399 | * @param integer X coordinate of the clicking point |
398 | 400 | * @param integer Y coordinate of the clicking point |
401 | + * @param integer $x |
|
402 | + * @param integer $y |
|
399 | 403 | */ |
400 | 404 | public function __construct($x,$y) |
401 | 405 | { |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | /** |
60 | 60 | * @var integer x coordinate that the image is being clicked at |
61 | 61 | */ |
62 | - private $_x=0; |
|
62 | + private $_x = 0; |
|
63 | 63 | /** |
64 | 64 | * @var integer y coordinate that the image is being clicked at |
65 | 65 | */ |
66 | - private $_y=0; |
|
67 | - private $_dataChanged=false; |
|
66 | + private $_y = 0; |
|
67 | + private $_dataChanged = false; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * @return string tag name of the button |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function getEnableClientScript() |
81 | 81 | { |
82 | - return $this->getViewState('EnableClientScript',true); |
|
82 | + return $this->getViewState('EnableClientScript', true); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function setEnableClientScript($value) |
89 | 89 | { |
90 | - $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
|
90 | + $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | */ |
98 | 98 | protected function addAttributesToRender($writer) |
99 | 99 | { |
100 | - $page=$this->getPage(); |
|
100 | + $page = $this->getPage(); |
|
101 | 101 | $page->ensureRenderInForm($this); |
102 | - $writer->addAttribute('type','image'); |
|
103 | - if(($uniqueID=$this->getUniqueID())!=='') |
|
104 | - $writer->addAttribute('name',$uniqueID); |
|
105 | - if($this->getEnabled(true)) |
|
102 | + $writer->addAttribute('type', 'image'); |
|
103 | + if (($uniqueID = $this->getUniqueID()) !== '') |
|
104 | + $writer->addAttribute('name', $uniqueID); |
|
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 | - else if($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
111 | - $writer->addAttribute('disabled','disabled'); |
|
110 | + else if ($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
111 | + $writer->addAttribute('disabled', 'disabled'); |
|
112 | 112 | parent::addAttributesToRender($writer); |
113 | 113 | } |
114 | 114 | |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function renderClientControlScript($writer) |
119 | 119 | { |
120 | - $writer->addAttribute('id',$this->getClientID()); |
|
120 | + $writer->addAttribute('id', $this->getClientID()); |
|
121 | 121 | $cs = $this->getPage()->getClientScript(); |
122 | - $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); |
|
122 | + $cs->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions()); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected function canCauseValidation() |
139 | 139 | { |
140 | - if($this->getCausesValidation()) |
|
140 | + if ($this->getCausesValidation()) |
|
141 | 141 | { |
142 | - $group=$this->getValidationGroup(); |
|
143 | - return $this->getPage()->getValidators($group)->getCount()>0; |
|
142 | + $group = $this->getValidationGroup(); |
|
143 | + return $this->getPage()->getValidators($group)->getCount() > 0; |
|
144 | 144 | } |
145 | 145 | else |
146 | 146 | return false; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function setIsDefaultButton($value) |
153 | 153 | { |
154 | - $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value),false); |
|
154 | + $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value), false); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -192,16 +192,16 @@ discard block |
||
192 | 192 | * @param array the input data collection |
193 | 193 | * @return boolean whether the data of the component has been changed |
194 | 194 | */ |
195 | - public function loadPostData($key,$values) |
|
195 | + public function loadPostData($key, $values) |
|
196 | 196 | { |
197 | - $uid=$this->getUniqueID(); |
|
198 | - if(isset($values["{$uid}_x"]) && isset($values["{$uid}_y"])) |
|
197 | + $uid = $this->getUniqueID(); |
|
198 | + if (isset($values["{$uid}_x"]) && isset($values["{$uid}_y"])) |
|
199 | 199 | { |
200 | - $this->_x=intval($values["{$uid}_x"]); |
|
201 | - $this->_y=intval($values["{$uid}_y"]); |
|
202 | - if($this->getPage()->getPostBackEventTarget()===null) |
|
200 | + $this->_x = intval($values["{$uid}_x"]); |
|
201 | + $this->_y = intval($values["{$uid}_y"]); |
|
202 | + if ($this->getPage()->getPostBackEventTarget() === null) |
|
203 | 203 | $this->getPage()->setPostBackEventTarget($this); |
204 | - $this->_dataChanged=true; |
|
204 | + $this->_dataChanged = true; |
|
205 | 205 | } |
206 | 206 | return false; |
207 | 207 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function onClick($param) |
225 | 225 | { |
226 | - $this->raiseEvent('OnClick',$this,$param); |
|
226 | + $this->raiseEvent('OnClick', $this, $param); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function onCommand($param) |
237 | 237 | { |
238 | - $this->raiseEvent('OnCommand',$this,$param); |
|
239 | - $this->raiseBubbleEvent($this,$param); |
|
238 | + $this->raiseEvent('OnCommand', $this, $param); |
|
239 | + $this->raiseBubbleEvent($this, $param); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -250,10 +250,10 @@ 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 | - $this->onClick(new TImageClickEventParameter($this->_x,$this->_y)); |
|
256 | - $this->onCommand(new TCommandEventParameter($this->getCommandName(),$this->getCommandParameter())); |
|
255 | + $this->onClick(new TImageClickEventParameter($this->_x, $this->_y)); |
|
256 | + $this->onCommand(new TCommandEventParameter($this->getCommandName(), $this->getCommandParameter())); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public function getCausesValidation() |
273 | 273 | { |
274 | - return $this->getViewState('CausesValidation',true); |
|
274 | + return $this->getViewState('CausesValidation', true); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function setCausesValidation($value) |
281 | 281 | { |
282 | - $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true); |
|
282 | + $this->setViewState('CausesValidation', TPropertyValue::ensureBoolean($value), true); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | public function getCommandName() |
289 | 289 | { |
290 | - return $this->getViewState('CommandName',''); |
|
290 | + return $this->getViewState('CommandName', ''); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | */ |
296 | 296 | public function setCommandName($value) |
297 | 297 | { |
298 | - $this->setViewState('CommandName',$value,''); |
|
298 | + $this->setViewState('CommandName', $value, ''); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function getCommandParameter() |
305 | 305 | { |
306 | - return $this->getViewState('CommandParameter',''); |
|
306 | + return $this->getViewState('CommandParameter', ''); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function setCommandParameter($value) |
313 | 313 | { |
314 | - $this->setViewState('CommandParameter',$value,''); |
|
314 | + $this->setViewState('CommandParameter', $value, ''); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function getValidationGroup() |
321 | 321 | { |
322 | - return $this->getViewState('ValidationGroup',''); |
|
322 | + return $this->getViewState('ValidationGroup', ''); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | */ |
328 | 328 | public function setValidationGroup($value) |
329 | 329 | { |
330 | - $this->setViewState('ValidationGroup',$value,''); |
|
330 | + $this->setViewState('ValidationGroup', $value, ''); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -385,22 +385,22 @@ discard block |
||
385 | 385 | * the X coordinate of the clicking point |
386 | 386 | * @var integer |
387 | 387 | */ |
388 | - private $_x=0; |
|
388 | + private $_x = 0; |
|
389 | 389 | /** |
390 | 390 | * the Y coordinate of the clicking point |
391 | 391 | * @var integer |
392 | 392 | */ |
393 | - private $_y=0; |
|
393 | + private $_y = 0; |
|
394 | 394 | |
395 | 395 | /** |
396 | 396 | * Constructor. |
397 | 397 | * @param integer X coordinate of the clicking point |
398 | 398 | * @param integer Y coordinate of the clicking point |
399 | 399 | */ |
400 | - public function __construct($x,$y) |
|
400 | + public function __construct($x, $y) |
|
401 | 401 | { |
402 | - $this->_x=$x; |
|
403 | - $this->_y=$y; |
|
402 | + $this->_x = $x; |
|
403 | + $this->_y = $y; |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | */ |
417 | 417 | public function setX($value) |
418 | 418 | { |
419 | - $this->_x=TPropertyValue::ensureInteger($value); |
|
419 | + $this->_x = TPropertyValue::ensureInteger($value); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | */ |
433 | 433 | public function setY($value) |
434 | 434 | { |
435 | - $this->_y=TPropertyValue::ensureInteger($value); |
|
435 | + $this->_y = TPropertyValue::ensureInteger($value); |
|
436 | 436 | } |
437 | 437 | } |
438 | 438 |
@@ -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 | - else if($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
108 | + if($this->getEnableClientScript() && $this->needPostBackScript()) { |
|
109 | + $this->renderClientControlScript($writer); |
|
110 | + } |
|
111 | + } else if($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 TCommandEventParameter($this->getCommandName(),$this->getCommandParameter())); |
257 | 262 | } |
@@ -212,6 +212,7 @@ discard block |
||
212 | 212 | * If you override this method, be sure to call the parent implementation |
213 | 213 | * so that the event handler can be invoked. |
214 | 214 | * @param TImageMapEventParameter event parameter to be passed to the event handlers |
215 | + * @param TImageMapEventParameter $param |
|
215 | 216 | */ |
216 | 217 | public function onClick($param) |
217 | 218 | { |
@@ -303,6 +304,7 @@ discard block |
||
303 | 304 | * that must be kept in viewstate. |
304 | 305 | * @param string the name of the viewstate value to be returned |
305 | 306 | * @param mixed the default value. If $key is not found in viewstate, $defaultValue will be returned |
307 | + * @param string $key |
|
306 | 308 | * @return mixed the viewstate value corresponding to $key |
307 | 309 | */ |
308 | 310 | protected function getViewState($key,$defaultValue=null) |
@@ -319,6 +321,7 @@ discard block |
||
319 | 321 | * @param string the name of the viewstate value |
320 | 322 | * @param mixed the viewstate value to be set |
321 | 323 | * @param mixed default value. If $value===$defaultValue, the item will be cleared from the viewstate. |
324 | + * @param string $key |
|
322 | 325 | */ |
323 | 326 | protected function setViewState($key,$value,$defaultValue=null) |
324 | 327 | { |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | class TImageMap extends TImage implements IPostBackEventHandler |
39 | 39 | { |
40 | - const MAP_NAME_PREFIX='ImageMap'; |
|
40 | + const MAP_NAME_PREFIX = 'ImageMap'; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Processes an object that is created during parsing template. |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function addParsedObject($object) |
49 | 49 | { |
50 | - if($object instanceof THotSpot) |
|
50 | + if ($object instanceof THotSpot) |
|
51 | 51 | $this->getHotSpots()->add($object); |
52 | 52 | } |
53 | 53 | |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | protected function addAttributesToRender($writer) |
60 | 60 | { |
61 | 61 | parent::addAttributesToRender($writer); |
62 | - if($this->getHotSpots()->getCount()>0) |
|
62 | + if ($this->getHotSpots()->getCount() > 0) |
|
63 | 63 | { |
64 | - $writer->addAttribute('usemap','#'.self::MAP_NAME_PREFIX.$this->getClientID()); |
|
65 | - $writer->addAttribute('id',$this->getUniqueID()); |
|
64 | + $writer->addAttribute('usemap', '#' . self::MAP_NAME_PREFIX . $this->getClientID()); |
|
65 | + $writer->addAttribute('id', $this->getUniqueID()); |
|
66 | 66 | } |
67 | - if($this->getEnabled() && !$this->getEnabled(true)) |
|
68 | - $writer->addAttribute('disabled','disabled'); |
|
67 | + if ($this->getEnabled() && !$this->getEnabled(true)) |
|
68 | + $writer->addAttribute('disabled', 'disabled'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -76,39 +76,39 @@ discard block |
||
76 | 76 | { |
77 | 77 | parent::render($writer); |
78 | 78 | |
79 | - $hotspots=$this->getHotSpots(); |
|
79 | + $hotspots = $this->getHotSpots(); |
|
80 | 80 | |
81 | - if($hotspots->getCount()>0) |
|
81 | + if ($hotspots->getCount() > 0) |
|
82 | 82 | { |
83 | - $clientID=$this->getClientID(); |
|
84 | - $cs=$this->getPage()->getClientScript(); |
|
83 | + $clientID = $this->getClientID(); |
|
84 | + $cs = $this->getPage()->getClientScript(); |
|
85 | 85 | $writer->writeLine(); |
86 | - $writer->addAttribute('name',self::MAP_NAME_PREFIX.$clientID); |
|
86 | + $writer->addAttribute('name', self::MAP_NAME_PREFIX . $clientID); |
|
87 | 87 | $writer->renderBeginTag('map'); |
88 | 88 | $writer->writeLine(); |
89 | - if(($mode=$this->getHotSpotMode())===THotSpotMode::NotSet) |
|
90 | - $mode=THotSpotMode::Navigate; |
|
91 | - $target=$this->getTarget(); |
|
92 | - $i=0; |
|
89 | + if (($mode = $this->getHotSpotMode()) === THotSpotMode::NotSet) |
|
90 | + $mode = THotSpotMode::Navigate; |
|
91 | + $target = $this->getTarget(); |
|
92 | + $i = 0; |
|
93 | 93 | $options['EventTarget'] = $this->getUniqueID(); |
94 | 94 | $options['StopEvent'] = true; |
95 | - $cs=$this->getPage()->getClientScript(); |
|
96 | - foreach($hotspots as $hotspot) |
|
95 | + $cs = $this->getPage()->getClientScript(); |
|
96 | + foreach ($hotspots as $hotspot) |
|
97 | 97 | { |
98 | - if($hotspot->getHotSpotMode()===THotSpotMode::NotSet) |
|
98 | + if ($hotspot->getHotSpotMode() === THotSpotMode::NotSet) |
|
99 | 99 | $hotspot->setHotSpotMode($mode); |
100 | - if($target!=='' && $hotspot->getTarget()==='') |
|
100 | + if ($target !== '' && $hotspot->getTarget() === '') |
|
101 | 101 | $hotspot->setTarget($target); |
102 | - if($hotspot->getHotSpotMode()===THotSpotMode::PostBack) |
|
102 | + if ($hotspot->getHotSpotMode() === THotSpotMode::PostBack) |
|
103 | 103 | { |
104 | - $id=$clientID.'_'.$i; |
|
105 | - $writer->addAttribute('id',$id); |
|
106 | - $writer->addAttribute('href','#'.$id); //create unique no-op url references |
|
107 | - $options['ID']=$id; |
|
108 | - $options['EventParameter']="$i"; |
|
109 | - $options['CausesValidation']=$hotspot->getCausesValidation(); |
|
110 | - $options['ValidationGroup']=$hotspot->getValidationGroup(); |
|
111 | - $cs->registerPostBackControl($this->getClientClassName(),$options); |
|
104 | + $id = $clientID . '_' . $i; |
|
105 | + $writer->addAttribute('id', $id); |
|
106 | + $writer->addAttribute('href', '#' . $id); //create unique no-op url references |
|
107 | + $options['ID'] = $id; |
|
108 | + $options['EventParameter'] = "$i"; |
|
109 | + $options['CausesValidation'] = $hotspot->getCausesValidation(); |
|
110 | + $options['ValidationGroup'] = $hotspot->getValidationGroup(); |
|
111 | + $cs->registerPostBackControl($this->getClientClassName(), $options); |
|
112 | 112 | } |
113 | 113 | $hotspot->render($writer); |
114 | 114 | $writer->writeLine(); |
@@ -136,25 +136,25 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function raisePostBackEvent($param) |
138 | 138 | { |
139 | - $postBackValue=null; |
|
140 | - if($param!=='') |
|
139 | + $postBackValue = null; |
|
140 | + if ($param !== '') |
|
141 | 141 | { |
142 | - $index=TPropertyValue::ensureInteger($param); |
|
143 | - $hotspots=$this->getHotSpots(); |
|
144 | - if($index>=0 && $index<$hotspots->getCount()) |
|
142 | + $index = TPropertyValue::ensureInteger($param); |
|
143 | + $hotspots = $this->getHotSpots(); |
|
144 | + if ($index >= 0 && $index < $hotspots->getCount()) |
|
145 | 145 | { |
146 | - $hotspot=$hotspots->itemAt($index); |
|
147 | - if(($mode=$hotspot->getHotSpotMode())===THotSpotMode::NotSet) |
|
148 | - $mode=$this->getHotSpotMode(); |
|
149 | - if($mode===THotSpotMode::PostBack) |
|
146 | + $hotspot = $hotspots->itemAt($index); |
|
147 | + if (($mode = $hotspot->getHotSpotMode()) === THotSpotMode::NotSet) |
|
148 | + $mode = $this->getHotSpotMode(); |
|
149 | + if ($mode === THotSpotMode::PostBack) |
|
150 | 150 | { |
151 | - $postBackValue=$hotspot->getPostBackValue(); |
|
152 | - if($hotspot->getCausesValidation()) |
|
151 | + $postBackValue = $hotspot->getPostBackValue(); |
|
152 | + if ($hotspot->getCausesValidation()) |
|
153 | 153 | $this->getPage()->validate($hotspot->getValidationGroup()); |
154 | 154 | } |
155 | 155 | } |
156 | 156 | } |
157 | - if($postBackValue!==null) |
|
157 | + if ($postBackValue !== null) |
|
158 | 158 | $this->onClick(new TImageMapEventParameter($postBackValue)); |
159 | 159 | } |
160 | 160 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function getHotSpotMode() |
165 | 165 | { |
166 | - return $this->getViewState('HotSpotMode',THotSpotMode::NotSet); |
|
166 | + return $this->getViewState('HotSpotMode', THotSpotMode::NotSet); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function setHotSpotMode($value) |
176 | 176 | { |
177 | - $this->setViewState('HotSpotMode',TPropertyValue::ensureEnum($value,'THotSpotMode'),THotSpotMode::NotSet); |
|
177 | + $this->setViewState('HotSpotMode', TPropertyValue::ensureEnum($value, 'THotSpotMode'), THotSpotMode::NotSet); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function getHotSpots() |
184 | 184 | { |
185 | - if(($hotspots=$this->getViewState('HotSpots',null))===null) |
|
185 | + if (($hotspots = $this->getViewState('HotSpots', null)) === null) |
|
186 | 186 | { |
187 | - $hotspots=new THotSpotCollection; |
|
188 | - $this->setViewState('HotSpots',$hotspots); |
|
187 | + $hotspots = new THotSpotCollection; |
|
188 | + $this->setViewState('HotSpots', $hotspots); |
|
189 | 189 | } |
190 | 190 | return $hotspots; |
191 | 191 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function getTarget() |
197 | 197 | { |
198 | - return $this->getViewState('Target',''); |
|
198 | + return $this->getViewState('Target', ''); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public function setTarget($value) |
205 | 205 | { |
206 | - $this->setViewState('Target',TPropertyValue::ensureString($value),''); |
|
206 | + $this->setViewState('Target', TPropertyValue::ensureString($value), ''); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function onClick($param) |
217 | 217 | { |
218 | - $this->raiseEvent('OnClick',$this,$param); |
|
218 | + $this->raiseEvent('OnClick', $this, $param); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function __construct($postBackValue) |
243 | 243 | { |
244 | - $this->_postBackValue=$postBackValue; |
|
244 | + $this->_postBackValue = $postBackValue; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -271,10 +271,10 @@ discard block |
||
271 | 271 | * @param mixed new item |
272 | 272 | * @throws TInvalidDataTypeException if the item to be inserted is not a THotSpot. |
273 | 273 | */ |
274 | - public function insertAt($index,$item) |
|
274 | + public function insertAt($index, $item) |
|
275 | 275 | { |
276 | - if($item instanceof THotSpot) |
|
277 | - parent::insertAt($index,$item); |
|
276 | + if ($item instanceof THotSpot) |
|
277 | + parent::insertAt($index, $item); |
|
278 | 278 | else |
279 | 279 | throw new TInvalidDataTypeException('hotspotcollection_hotspot_required'); |
280 | 280 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | */ |
295 | 295 | abstract class THotSpot extends TComponent |
296 | 296 | { |
297 | - private $_viewState=array(); |
|
297 | + private $_viewState = array(); |
|
298 | 298 | |
299 | 299 | /** |
300 | 300 | * Returns a viewstate value. |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | * @param mixed the default value. If $key is not found in viewstate, $defaultValue will be returned |
306 | 306 | * @return mixed the viewstate value corresponding to $key |
307 | 307 | */ |
308 | - protected function getViewState($key,$defaultValue=null) |
|
308 | + protected function getViewState($key, $defaultValue = null) |
|
309 | 309 | { |
310 | - return isset($this->_viewState[$key])?$this->_viewState[$key]:$defaultValue; |
|
310 | + return isset($this->_viewState[$key]) ? $this->_viewState[$key] : $defaultValue; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -320,12 +320,12 @@ discard block |
||
320 | 320 | * @param mixed the viewstate value to be set |
321 | 321 | * @param mixed default value. If $value===$defaultValue, the item will be cleared from the viewstate. |
322 | 322 | */ |
323 | - protected function setViewState($key,$value,$defaultValue=null) |
|
323 | + protected function setViewState($key, $value, $defaultValue = null) |
|
324 | 324 | { |
325 | - if($value===$defaultValue) |
|
325 | + if ($value === $defaultValue) |
|
326 | 326 | unset($this->_viewState[$key]); |
327 | 327 | else |
328 | - $this->_viewState[$key]=$value; |
|
328 | + $this->_viewState[$key] = $value; |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | */ |
343 | 343 | public function getAccessKey() |
344 | 344 | { |
345 | - return $this->getViewState('AccessKey',''); |
|
345 | + return $this->getViewState('AccessKey', ''); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | */ |
351 | 351 | public function setAccessKey($value) |
352 | 352 | { |
353 | - $this->setViewState('AccessKey',TPropertyValue::ensureString($value),''); |
|
353 | + $this->setViewState('AccessKey', TPropertyValue::ensureString($value), ''); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | */ |
359 | 359 | public function getAlternateText() |
360 | 360 | { |
361 | - return $this->getViewState('AlternateText',''); |
|
361 | + return $this->getViewState('AlternateText', ''); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | */ |
367 | 367 | public function setAlternateText($value) |
368 | 368 | { |
369 | - $this->setViewState('AlternateText',TPropertyValue::ensureString($value),''); |
|
369 | + $this->setViewState('AlternateText', TPropertyValue::ensureString($value), ''); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | */ |
375 | 375 | public function getHotSpotMode() |
376 | 376 | { |
377 | - return $this->getViewState('HotSpotMode',THotSpotMode::NotSet); |
|
377 | + return $this->getViewState('HotSpotMode', THotSpotMode::NotSet); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | public function setHotSpotMode($value) |
384 | 384 | { |
385 | - $this->setViewState('HotSpotMode',TPropertyValue::ensureEnum($value,'THotSpotMode'),THotSpotMode::NotSet); |
|
385 | + $this->setViewState('HotSpotMode', TPropertyValue::ensureEnum($value, 'THotSpotMode'), THotSpotMode::NotSet); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | */ |
391 | 391 | public function getNavigateUrl() |
392 | 392 | { |
393 | - return $this->getViewState('NavigateUrl',''); |
|
393 | + return $this->getViewState('NavigateUrl', ''); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | */ |
399 | 399 | public function setNavigateUrl($value) |
400 | 400 | { |
401 | - $this->setViewState('NavigateUrl',TPropertyValue::ensureString($value),''); |
|
401 | + $this->setViewState('NavigateUrl', TPropertyValue::ensureString($value), ''); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | */ |
407 | 407 | public function getPostBackValue() |
408 | 408 | { |
409 | - return $this->getViewState('PostBackValue',''); |
|
409 | + return $this->getViewState('PostBackValue', ''); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | /** |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | */ |
415 | 415 | public function setPostBackValue($value) |
416 | 416 | { |
417 | - $this->setViewState('PostBackValue',TPropertyValue::ensureString($value),''); |
|
417 | + $this->setViewState('PostBackValue', TPropertyValue::ensureString($value), ''); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | */ |
423 | 423 | public function getTabIndex() |
424 | 424 | { |
425 | - return $this->getViewState('TabIndex',0); |
|
425 | + return $this->getViewState('TabIndex', 0); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | */ |
431 | 431 | public function setTabIndex($value) |
432 | 432 | { |
433 | - $this->setViewState('TabIndex',TPropertyValue::ensureInteger($value),0); |
|
433 | + $this->setViewState('TabIndex', TPropertyValue::ensureInteger($value), 0); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | */ |
439 | 439 | public function getCausesValidation() |
440 | 440 | { |
441 | - return $this->getViewState('CausesValidation',true); |
|
441 | + return $this->getViewState('CausesValidation', true); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | */ |
447 | 447 | public function setCausesValidation($value) |
448 | 448 | { |
449 | - $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true); |
|
449 | + $this->setViewState('CausesValidation', TPropertyValue::ensureBoolean($value), true); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | */ |
455 | 455 | public function getValidationGroup() |
456 | 456 | { |
457 | - return $this->getViewState('ValidationGroup',''); |
|
457 | + return $this->getViewState('ValidationGroup', ''); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | */ |
463 | 463 | public function setValidationGroup($value) |
464 | 464 | { |
465 | - $this->setViewState('ValidationGroup',$value,''); |
|
465 | + $this->setViewState('ValidationGroup', $value, ''); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | */ |
472 | 472 | public function getTarget() |
473 | 473 | { |
474 | - return $this->getViewState('Target',''); |
|
474 | + return $this->getViewState('Target', ''); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | /** |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | */ |
481 | 481 | public function setTarget($value) |
482 | 482 | { |
483 | - $this->setViewState('Target',TPropertyValue::ensureString($value),''); |
|
483 | + $this->setViewState('Target', TPropertyValue::ensureString($value), ''); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
@@ -488,8 +488,8 @@ discard block |
||
488 | 488 | */ |
489 | 489 | public function getHasAttributes() |
490 | 490 | { |
491 | - if($attributes=$this->getViewState('Attributes',null)) |
|
492 | - return $attributes->getCount()>0; |
|
491 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
492 | + return $attributes->getCount() > 0; |
|
493 | 493 | else |
494 | 494 | return false; |
495 | 495 | } |
@@ -502,12 +502,12 @@ discard block |
||
502 | 502 | */ |
503 | 503 | public function getAttributes() |
504 | 504 | { |
505 | - if($attributes=$this->getViewState('Attributes',null)) |
|
505 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
506 | 506 | return $attributes; |
507 | 507 | else |
508 | 508 | { |
509 | - $attributes=new TAttributeCollection; |
|
510 | - $this->setViewState('Attributes',$attributes,null); |
|
509 | + $attributes = new TAttributeCollection; |
|
510 | + $this->setViewState('Attributes', $attributes, null); |
|
511 | 511 | return $attributes; |
512 | 512 | } |
513 | 513 | } |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | */ |
518 | 518 | public function hasAttribute($name) |
519 | 519 | { |
520 | - if($attributes=$this->getViewState('Attributes',null)) |
|
520 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
521 | 521 | return $attributes->contains($name); |
522 | 522 | else |
523 | 523 | return false; |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | */ |
529 | 529 | public function getAttribute($name) |
530 | 530 | { |
531 | - if($attributes=$this->getViewState('Attributes',null)) |
|
531 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
532 | 532 | return $attributes->itemAt($name); |
533 | 533 | else |
534 | 534 | return null; |
@@ -539,9 +539,9 @@ discard block |
||
539 | 539 | * @param string attribute name |
540 | 540 | * @param string value of the attribute |
541 | 541 | */ |
542 | - public function setAttribute($name,$value) |
|
542 | + public function setAttribute($name, $value) |
|
543 | 543 | { |
544 | - $this->getAttributes()->add($name,$value); |
|
544 | + $this->getAttributes()->add($name, $value); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | */ |
552 | 552 | public function removeAttribute($name) |
553 | 553 | { |
554 | - if($attributes=$this->getViewState('Attributes',null)) |
|
554 | + if ($attributes = $this->getViewState('Attributes', null)) |
|
555 | 555 | return $attributes->remove($name); |
556 | 556 | else |
557 | 557 | return null; |
@@ -563,29 +563,29 @@ discard block |
||
563 | 563 | */ |
564 | 564 | public function render($writer) |
565 | 565 | { |
566 | - $writer->addAttribute('shape',$this->getShape()); |
|
567 | - $writer->addAttribute('coords',$this->getCoordinates()); |
|
568 | - if(($mode=$this->getHotSpotMode())===THotSpotMode::NotSet) |
|
569 | - $mode=THotSpotMode::Navigate; |
|
570 | - if($mode===THotSpotMode::Navigate) |
|
566 | + $writer->addAttribute('shape', $this->getShape()); |
|
567 | + $writer->addAttribute('coords', $this->getCoordinates()); |
|
568 | + if (($mode = $this->getHotSpotMode()) === THotSpotMode::NotSet) |
|
569 | + $mode = THotSpotMode::Navigate; |
|
570 | + if ($mode === THotSpotMode::Navigate) |
|
571 | 571 | { |
572 | - $writer->addAttribute('href',$this->getNavigateUrl()); |
|
573 | - if(($target=$this->getTarget())!=='') |
|
574 | - $writer->addAttribute('target',$target); |
|
572 | + $writer->addAttribute('href', $this->getNavigateUrl()); |
|
573 | + if (($target = $this->getTarget()) !== '') |
|
574 | + $writer->addAttribute('target', $target); |
|
575 | 575 | } |
576 | - else if($mode===THotSpotMode::Inactive) |
|
577 | - $writer->addAttribute('nohref','true'); |
|
578 | - $text=$this->getAlternateText(); |
|
579 | - $writer->addAttribute('title',$text); |
|
580 | - $writer->addAttribute('alt',$text); |
|
581 | - if(($accessKey=$this->getAccessKey())!=='') |
|
582 | - $writer->addAttribute('accesskey',$accessKey); |
|
583 | - if(($tabIndex=$this->getTabIndex())!==0) |
|
584 | - $writer->addAttribute('tabindex',"$tabIndex"); |
|
585 | - if($this->getHasAttributes()) |
|
576 | + else if ($mode === THotSpotMode::Inactive) |
|
577 | + $writer->addAttribute('nohref', 'true'); |
|
578 | + $text = $this->getAlternateText(); |
|
579 | + $writer->addAttribute('title', $text); |
|
580 | + $writer->addAttribute('alt', $text); |
|
581 | + if (($accessKey = $this->getAccessKey()) !== '') |
|
582 | + $writer->addAttribute('accesskey', $accessKey); |
|
583 | + if (($tabIndex = $this->getTabIndex()) !== 0) |
|
584 | + $writer->addAttribute('tabindex', "$tabIndex"); |
|
585 | + if ($this->getHasAttributes()) |
|
586 | 586 | { |
587 | - foreach($this->getAttributes() as $name=>$value) |
|
588 | - $writer->addAttribute($name,$value); |
|
587 | + foreach ($this->getAttributes() as $name=>$value) |
|
588 | + $writer->addAttribute($name, $value); |
|
589 | 589 | } |
590 | 590 | $writer->renderBeginTag('area'); |
591 | 591 | $writer->renderEndTag(); |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | */ |
618 | 618 | public function getCoordinates() |
619 | 619 | { |
620 | - return $this->getX().','.$this->getY().','.$this->getRadius(); |
|
620 | + return $this->getX() . ',' . $this->getY() . ',' . $this->getRadius(); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | /** |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | */ |
626 | 626 | public function getRadius() |
627 | 627 | { |
628 | - return $this->getViewState('Radius',0); |
|
628 | + return $this->getViewState('Radius', 0); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | */ |
634 | 634 | public function setRadius($value) |
635 | 635 | { |
636 | - $this->setViewState('Radius',TPropertyValue::ensureInteger($value),0); |
|
636 | + $this->setViewState('Radius', TPropertyValue::ensureInteger($value), 0); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | /** |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | */ |
642 | 642 | public function getX() |
643 | 643 | { |
644 | - return $this->getViewState('X',0); |
|
644 | + return $this->getViewState('X', 0); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | */ |
650 | 650 | public function setX($value) |
651 | 651 | { |
652 | - $this->setViewState('X',TPropertyValue::ensureInteger($value),0); |
|
652 | + $this->setViewState('X', TPropertyValue::ensureInteger($value), 0); |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | /** |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | */ |
658 | 658 | public function getY() |
659 | 659 | { |
660 | - return $this->getViewState('Y',0); |
|
660 | + return $this->getViewState('Y', 0); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | /** |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | */ |
666 | 666 | public function setY($value) |
667 | 667 | { |
668 | - $this->setViewState('Y',TPropertyValue::ensureInteger($value),0); |
|
668 | + $this->setViewState('Y', TPropertyValue::ensureInteger($value), 0); |
|
669 | 669 | } |
670 | 670 | } |
671 | 671 | |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | */ |
695 | 695 | public function getCoordinates() |
696 | 696 | { |
697 | - return $this->getLeft().','.$this->getTop().','.$this->getRight().','.$this->getBottom(); |
|
697 | + return $this->getLeft() . ',' . $this->getTop() . ',' . $this->getRight() . ',' . $this->getBottom(); |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | */ |
703 | 703 | public function getBottom() |
704 | 704 | { |
705 | - return $this->getViewState('Bottom',0); |
|
705 | + return $this->getViewState('Bottom', 0); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | /** |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | */ |
711 | 711 | public function setBottom($value) |
712 | 712 | { |
713 | - $this->setViewState('Bottom',TPropertyValue::ensureInteger($value),0); |
|
713 | + $this->setViewState('Bottom', TPropertyValue::ensureInteger($value), 0); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | /** |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | */ |
719 | 719 | public function getLeft() |
720 | 720 | { |
721 | - return $this->getViewState('Left',0); |
|
721 | + return $this->getViewState('Left', 0); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | /** |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | */ |
727 | 727 | public function setLeft($value) |
728 | 728 | { |
729 | - $this->setViewState('Left',TPropertyValue::ensureInteger($value),0); |
|
729 | + $this->setViewState('Left', TPropertyValue::ensureInteger($value), 0); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | /** |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | */ |
735 | 735 | public function getRight() |
736 | 736 | { |
737 | - return $this->getViewState('Right',0); |
|
737 | + return $this->getViewState('Right', 0); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | /** |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | */ |
743 | 743 | public function setRight($value) |
744 | 744 | { |
745 | - $this->setViewState('Right',TPropertyValue::ensureInteger($value),0); |
|
745 | + $this->setViewState('Right', TPropertyValue::ensureInteger($value), 0); |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | /** |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | */ |
751 | 751 | public function getTop() |
752 | 752 | { |
753 | - return $this->getViewState('Top',0); |
|
753 | + return $this->getViewState('Top', 0); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | /** |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | */ |
759 | 759 | public function setTop($value) |
760 | 760 | { |
761 | - $this->setViewState('Top',TPropertyValue::ensureInteger($value),0); |
|
761 | + $this->setViewState('Top', TPropertyValue::ensureInteger($value), 0); |
|
762 | 762 | } |
763 | 763 | } |
764 | 764 | |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | */ |
790 | 790 | public function getCoordinates() |
791 | 791 | { |
792 | - return $this->getViewState('Coordinates',''); |
|
792 | + return $this->getViewState('Coordinates', ''); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | /** |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | */ |
800 | 800 | public function setCoordinates($value) |
801 | 801 | { |
802 | - $this->setViewState('Coordinates',$value,''); |
|
802 | + $this->setViewState('Coordinates', $value, ''); |
|
803 | 803 | } |
804 | 804 | } |
805 | 805 | |
@@ -820,9 +820,9 @@ discard block |
||
820 | 820 | */ |
821 | 821 | class THotSpotMode extends TEnumerable |
822 | 822 | { |
823 | - const NotSet='NotSet'; |
|
824 | - const Navigate='Navigate'; |
|
825 | - const PostBack='PostBack'; |
|
826 | - const Inactive='Inactive'; |
|
823 | + const NotSet = 'NotSet'; |
|
824 | + const Navigate = 'Navigate'; |
|
825 | + const PostBack = 'PostBack'; |
|
826 | + const Inactive = 'Inactive'; |
|
827 | 827 | } |
828 | 828 |
@@ -47,8 +47,9 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function addParsedObject($object) |
49 | 49 | { |
50 | - if($object instanceof THotSpot) |
|
51 | - $this->getHotSpots()->add($object); |
|
50 | + if($object instanceof THotSpot) { |
|
51 | + $this->getHotSpots()->add($object); |
|
52 | + } |
|
52 | 53 | } |
53 | 54 | |
54 | 55 | /** |
@@ -64,8 +65,9 @@ discard block |
||
64 | 65 | $writer->addAttribute('usemap','#'.self::MAP_NAME_PREFIX.$this->getClientID()); |
65 | 66 | $writer->addAttribute('id',$this->getUniqueID()); |
66 | 67 | } |
67 | - if($this->getEnabled() && !$this->getEnabled(true)) |
|
68 | - $writer->addAttribute('disabled','disabled'); |
|
68 | + if($this->getEnabled() && !$this->getEnabled(true)) { |
|
69 | + $writer->addAttribute('disabled','disabled'); |
|
70 | + } |
|
69 | 71 | } |
70 | 72 | |
71 | 73 | /** |
@@ -86,8 +88,9 @@ discard block |
||
86 | 88 | $writer->addAttribute('name',self::MAP_NAME_PREFIX.$clientID); |
87 | 89 | $writer->renderBeginTag('map'); |
88 | 90 | $writer->writeLine(); |
89 | - if(($mode=$this->getHotSpotMode())===THotSpotMode::NotSet) |
|
90 | - $mode=THotSpotMode::Navigate; |
|
91 | + if(($mode=$this->getHotSpotMode())===THotSpotMode::NotSet) { |
|
92 | + $mode=THotSpotMode::Navigate; |
|
93 | + } |
|
91 | 94 | $target=$this->getTarget(); |
92 | 95 | $i=0; |
93 | 96 | $options['EventTarget'] = $this->getUniqueID(); |
@@ -95,10 +98,12 @@ discard block |
||
95 | 98 | $cs=$this->getPage()->getClientScript(); |
96 | 99 | foreach($hotspots as $hotspot) |
97 | 100 | { |
98 | - if($hotspot->getHotSpotMode()===THotSpotMode::NotSet) |
|
99 | - $hotspot->setHotSpotMode($mode); |
|
100 | - if($target!=='' && $hotspot->getTarget()==='') |
|
101 | - $hotspot->setTarget($target); |
|
101 | + if($hotspot->getHotSpotMode()===THotSpotMode::NotSet) { |
|
102 | + $hotspot->setHotSpotMode($mode); |
|
103 | + } |
|
104 | + if($target!=='' && $hotspot->getTarget()==='') { |
|
105 | + $hotspot->setTarget($target); |
|
106 | + } |
|
102 | 107 | if($hotspot->getHotSpotMode()===THotSpotMode::PostBack) |
103 | 108 | { |
104 | 109 | $id=$clientID.'_'.$i; |
@@ -144,18 +149,21 @@ discard block |
||
144 | 149 | if($index>=0 && $index<$hotspots->getCount()) |
145 | 150 | { |
146 | 151 | $hotspot=$hotspots->itemAt($index); |
147 | - if(($mode=$hotspot->getHotSpotMode())===THotSpotMode::NotSet) |
|
148 | - $mode=$this->getHotSpotMode(); |
|
152 | + if(($mode=$hotspot->getHotSpotMode())===THotSpotMode::NotSet) { |
|
153 | + $mode=$this->getHotSpotMode(); |
|
154 | + } |
|
149 | 155 | if($mode===THotSpotMode::PostBack) |
150 | 156 | { |
151 | 157 | $postBackValue=$hotspot->getPostBackValue(); |
152 | - if($hotspot->getCausesValidation()) |
|
153 | - $this->getPage()->validate($hotspot->getValidationGroup()); |
|
158 | + if($hotspot->getCausesValidation()) { |
|
159 | + $this->getPage()->validate($hotspot->getValidationGroup()); |
|
160 | + } |
|
154 | 161 | } |
155 | 162 | } |
156 | 163 | } |
157 | - if($postBackValue!==null) |
|
158 | - $this->onClick(new TImageMapEventParameter($postBackValue)); |
|
164 | + if($postBackValue!==null) { |
|
165 | + $this->onClick(new TImageMapEventParameter($postBackValue)); |
|
166 | + } |
|
159 | 167 | } |
160 | 168 | |
161 | 169 | /** |
@@ -273,10 +281,11 @@ discard block |
||
273 | 281 | */ |
274 | 282 | public function insertAt($index,$item) |
275 | 283 | { |
276 | - if($item instanceof THotSpot) |
|
277 | - parent::insertAt($index,$item); |
|
278 | - else |
|
279 | - throw new TInvalidDataTypeException('hotspotcollection_hotspot_required'); |
|
284 | + if($item instanceof THotSpot) { |
|
285 | + parent::insertAt($index,$item); |
|
286 | + } else { |
|
287 | + throw new TInvalidDataTypeException('hotspotcollection_hotspot_required'); |
|
288 | + } |
|
280 | 289 | } |
281 | 290 | } |
282 | 291 | |
@@ -322,10 +331,11 @@ discard block |
||
322 | 331 | */ |
323 | 332 | protected function setViewState($key,$value,$defaultValue=null) |
324 | 333 | { |
325 | - if($value===$defaultValue) |
|
326 | - unset($this->_viewState[$key]); |
|
327 | - else |
|
328 | - $this->_viewState[$key]=$value; |
|
334 | + if($value===$defaultValue) { |
|
335 | + unset($this->_viewState[$key]); |
|
336 | + } else { |
|
337 | + $this->_viewState[$key]=$value; |
|
338 | + } |
|
329 | 339 | } |
330 | 340 | |
331 | 341 | /** |
@@ -488,10 +498,11 @@ discard block |
||
488 | 498 | */ |
489 | 499 | public function getHasAttributes() |
490 | 500 | { |
491 | - if($attributes=$this->getViewState('Attributes',null)) |
|
492 | - return $attributes->getCount()>0; |
|
493 | - else |
|
494 | - return false; |
|
501 | + if($attributes=$this->getViewState('Attributes',null)) { |
|
502 | + return $attributes->getCount()>0; |
|
503 | + } else { |
|
504 | + return false; |
|
505 | + } |
|
495 | 506 | } |
496 | 507 | |
497 | 508 | /** |
@@ -502,9 +513,9 @@ discard block |
||
502 | 513 | */ |
503 | 514 | public function getAttributes() |
504 | 515 | { |
505 | - if($attributes=$this->getViewState('Attributes',null)) |
|
506 | - return $attributes; |
|
507 | - else |
|
516 | + if($attributes=$this->getViewState('Attributes',null)) { |
|
517 | + return $attributes; |
|
518 | + } else |
|
508 | 519 | { |
509 | 520 | $attributes=new TAttributeCollection; |
510 | 521 | $this->setViewState('Attributes',$attributes,null); |
@@ -517,10 +528,11 @@ discard block |
||
517 | 528 | */ |
518 | 529 | public function hasAttribute($name) |
519 | 530 | { |
520 | - if($attributes=$this->getViewState('Attributes',null)) |
|
521 | - return $attributes->contains($name); |
|
522 | - else |
|
523 | - return false; |
|
531 | + if($attributes=$this->getViewState('Attributes',null)) { |
|
532 | + return $attributes->contains($name); |
|
533 | + } else { |
|
534 | + return false; |
|
535 | + } |
|
524 | 536 | } |
525 | 537 | |
526 | 538 | /** |
@@ -528,10 +540,11 @@ discard block |
||
528 | 540 | */ |
529 | 541 | public function getAttribute($name) |
530 | 542 | { |
531 | - if($attributes=$this->getViewState('Attributes',null)) |
|
532 | - return $attributes->itemAt($name); |
|
533 | - else |
|
534 | - return null; |
|
543 | + if($attributes=$this->getViewState('Attributes',null)) { |
|
544 | + return $attributes->itemAt($name); |
|
545 | + } else { |
|
546 | + return null; |
|
547 | + } |
|
535 | 548 | } |
536 | 549 | |
537 | 550 | /** |
@@ -551,10 +564,11 @@ discard block |
||
551 | 564 | */ |
552 | 565 | public function removeAttribute($name) |
553 | 566 | { |
554 | - if($attributes=$this->getViewState('Attributes',null)) |
|
555 | - return $attributes->remove($name); |
|
556 | - else |
|
557 | - return null; |
|
567 | + if($attributes=$this->getViewState('Attributes',null)) { |
|
568 | + return $attributes->remove($name); |
|
569 | + } else { |
|
570 | + return null; |
|
571 | + } |
|
558 | 572 | } |
559 | 573 | |
560 | 574 | /** |
@@ -565,27 +579,32 @@ discard block |
||
565 | 579 | { |
566 | 580 | $writer->addAttribute('shape',$this->getShape()); |
567 | 581 | $writer->addAttribute('coords',$this->getCoordinates()); |
568 | - if(($mode=$this->getHotSpotMode())===THotSpotMode::NotSet) |
|
569 | - $mode=THotSpotMode::Navigate; |
|
582 | + if(($mode=$this->getHotSpotMode())===THotSpotMode::NotSet) { |
|
583 | + $mode=THotSpotMode::Navigate; |
|
584 | + } |
|
570 | 585 | if($mode===THotSpotMode::Navigate) |
571 | 586 | { |
572 | 587 | $writer->addAttribute('href',$this->getNavigateUrl()); |
573 | - if(($target=$this->getTarget())!=='') |
|
574 | - $writer->addAttribute('target',$target); |
|
588 | + if(($target=$this->getTarget())!=='') { |
|
589 | + $writer->addAttribute('target',$target); |
|
590 | + } |
|
591 | + } else if($mode===THotSpotMode::Inactive) { |
|
592 | + $writer->addAttribute('nohref','true'); |
|
575 | 593 | } |
576 | - else if($mode===THotSpotMode::Inactive) |
|
577 | - $writer->addAttribute('nohref','true'); |
|
578 | 594 | $text=$this->getAlternateText(); |
579 | 595 | $writer->addAttribute('title',$text); |
580 | 596 | $writer->addAttribute('alt',$text); |
581 | - if(($accessKey=$this->getAccessKey())!=='') |
|
582 | - $writer->addAttribute('accesskey',$accessKey); |
|
583 | - if(($tabIndex=$this->getTabIndex())!==0) |
|
584 | - $writer->addAttribute('tabindex',"$tabIndex"); |
|
597 | + if(($accessKey=$this->getAccessKey())!=='') { |
|
598 | + $writer->addAttribute('accesskey',$accessKey); |
|
599 | + } |
|
600 | + if(($tabIndex=$this->getTabIndex())!==0) { |
|
601 | + $writer->addAttribute('tabindex',"$tabIndex"); |
|
602 | + } |
|
585 | 603 | if($this->getHasAttributes()) |
586 | 604 | { |
587 | - foreach($this->getAttributes() as $name=>$value) |
|
588 | - $writer->addAttribute($name,$value); |
|
605 | + foreach($this->getAttributes() as $name=>$value) { |
|
606 | + $writer->addAttribute($name,$value); |
|
607 | + } |
|
589 | 608 | } |
590 | 609 | $writer->renderBeginTag('area'); |
591 | 610 | $writer->renderEndTag(); |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * TImageMap and related class file. |
|
4 | - * |
|
5 | - * @author Qiang Xue <[email protected]> |
|
6 | - * @link https://github.com/pradosoft/prado |
|
7 | - * @copyright Copyright © 2005-2015 The PRADO Group |
|
8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | - * @package System.Web.UI.WebControls |
|
10 | - */ |
|
3 | + * TImageMap and related class file. |
|
4 | + * |
|
5 | + * @author Qiang Xue <[email protected]> |
|
6 | + * @link https://github.com/pradosoft/prado |
|
7 | + * @copyright Copyright © 2005-2015 The PRADO Group |
|
8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | + * @package System.Web.UI.WebControls |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Includes TImage class file |
@@ -281,6 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | /** |
283 | 283 | * @param string the group of validators which the button causes validation upon postback |
284 | + * @param string $value |
|
284 | 285 | */ |
285 | 286 | public function setValidationGroup($value) |
286 | 287 | { |
@@ -322,6 +323,7 @@ discard block |
||
322 | 323 | * If you override this method, be sure to call the parent implementation |
323 | 324 | * so that the event handlers can be invoked. |
324 | 325 | * @param TCommandEventParameter event parameter to be passed to the event handlers |
326 | + * @param TCommandEventParameter $param |
|
325 | 327 | */ |
326 | 328 | public function onCommand($param) |
327 | 329 | { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function getEnableClientScript() |
69 | 69 | { |
70 | - return $this->getViewState('EnableClientScript',true); |
|
70 | + return $this->getViewState('EnableClientScript', true); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function setEnableClientScript($value) |
77 | 77 | { |
78 | - $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
|
78 | + $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -85,22 +85,22 @@ discard block |
||
85 | 85 | */ |
86 | 86 | protected function addAttributesToRender($writer) |
87 | 87 | { |
88 | - $page=$this->getPage(); |
|
88 | + $page = $this->getPage(); |
|
89 | 89 | $page->ensureRenderInForm($this); |
90 | 90 | |
91 | - $writer->addAttribute('id',$this->getClientID()); |
|
91 | + $writer->addAttribute('id', $this->getClientID()); |
|
92 | 92 | |
93 | 93 | // We call parent implementation here because some attributes |
94 | 94 | // may be overwritten in the following |
95 | 95 | parent::addAttributesToRender($writer); |
96 | 96 | |
97 | - if($this->getEnabled(true) && $this->getEnableClientScript()) |
|
97 | + if ($this->getEnabled(true) && $this->getEnableClientScript()) |
|
98 | 98 | { |
99 | 99 | $this->renderLinkButtonHref($writer); |
100 | 100 | $this->renderClientControlScript($writer); |
101 | 101 | } |
102 | - else if($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
103 | - $writer->addAttribute('disabled','disabled'); |
|
102 | + else if ($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
103 | + $writer->addAttribute('disabled', 'disabled'); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | protected function renderClientControlScript($writer) |
111 | 111 | { |
112 | 112 | $cs = $this->getPage()->getClientScript(); |
113 | - $cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); |
|
113 | + $cs->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions()); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function setIsDefaultButton($value) |
120 | 120 | { |
121 | - $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value),false); |
|
121 | + $this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value), false); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | protected function renderLinkButtonHref($writer) |
137 | 137 | { |
138 | 138 | //create unique no-op url references |
139 | - $nop = "javascript:;//".$this->getClientID(); |
|
139 | + $nop = "javascript:;//" . $this->getClientID(); |
|
140 | 140 | $writer->addAttribute('href', $nop); |
141 | 141 | } |
142 | 142 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function renderContents($writer) |
176 | 176 | { |
177 | - if(($text=$this->getText())==='') |
|
177 | + if (($text = $this->getText()) === '') |
|
178 | 178 | parent::renderContents($writer); |
179 | 179 | else |
180 | 180 | $writer->write($text); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function getText() |
187 | 187 | { |
188 | - return $this->getViewState('Text',''); |
|
188 | + return $this->getViewState('Text', ''); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function setText($value) |
195 | 195 | { |
196 | - $this->setViewState('Text',$value,''); |
|
196 | + $this->setViewState('Text', $value, ''); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function getCommandName() |
229 | 229 | { |
230 | - return $this->getViewState('CommandName',''); |
|
230 | + return $this->getViewState('CommandName', ''); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | */ |
236 | 236 | public function setCommandName($value) |
237 | 237 | { |
238 | - $this->setViewState('CommandName',$value,''); |
|
238 | + $this->setViewState('CommandName', $value, ''); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public function getCommandParameter() |
245 | 245 | { |
246 | - return $this->getViewState('CommandParameter',''); |
|
246 | + return $this->getViewState('CommandParameter', ''); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | */ |
252 | 252 | public function setCommandParameter($value) |
253 | 253 | { |
254 | - $this->setViewState('CommandParameter',$value,''); |
|
254 | + $this->setViewState('CommandParameter', $value, ''); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | */ |
260 | 260 | public function getCausesValidation() |
261 | 261 | { |
262 | - return $this->getViewState('CausesValidation',true); |
|
262 | + return $this->getViewState('CausesValidation', true); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | */ |
269 | 269 | public function setCausesValidation($value) |
270 | 270 | { |
271 | - $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true); |
|
271 | + $this->setViewState('CausesValidation', TPropertyValue::ensureBoolean($value), true); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function getValidationGroup() |
278 | 278 | { |
279 | - return $this->getViewState('ValidationGroup',''); |
|
279 | + return $this->getViewState('ValidationGroup', ''); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | */ |
285 | 285 | public function setValidationGroup($value) |
286 | 286 | { |
287 | - $this->setViewState('ValidationGroup',$value,''); |
|
287 | + $this->setViewState('ValidationGroup', $value, ''); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | */ |
299 | 299 | public function raisePostBackEvent($param) |
300 | 300 | { |
301 | - if($this->getCausesValidation()) |
|
301 | + if ($this->getCausesValidation()) |
|
302 | 302 | $this->getPage()->validate($this->getValidationGroup()); |
303 | 303 | $this->onClick(null); |
304 | - $this->onCommand(new TCommandEventParameter($this->getCommandName(),$this->getCommandParameter())); |
|
304 | + $this->onCommand(new TCommandEventParameter($this->getCommandName(), $this->getCommandParameter())); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | */ |
314 | 314 | public function onClick($param) |
315 | 315 | { |
316 | - $this->raiseEvent('OnClick',$this,$param); |
|
316 | + $this->raiseEvent('OnClick', $this, $param); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -325,8 +325,8 @@ discard block |
||
325 | 325 | */ |
326 | 326 | public function onCommand($param) |
327 | 327 | { |
328 | - $this->raiseEvent('OnCommand',$this,$param); |
|
329 | - $this->raiseBubbleEvent($this,$param); |
|
328 | + $this->raiseEvent('OnCommand', $this, $param); |
|
329 | + $this->raiseBubbleEvent($this, $param); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 |
@@ -98,9 +98,10 @@ discard block |
||
98 | 98 | { |
99 | 99 | $this->renderLinkButtonHref($writer); |
100 | 100 | $this->renderClientControlScript($writer); |
101 | - } |
|
102 | - else if($this->getEnabled()) // in this case, parent will not render 'disabled' |
|
101 | + } else if($this->getEnabled()) { |
|
102 | + // in this case, parent will not render 'disabled' |
|
103 | 103 | $writer->addAttribute('disabled','disabled'); |
104 | + } |
|
104 | 105 | } |
105 | 106 | |
106 | 107 | /** |
@@ -174,10 +175,11 @@ discard block |
||
174 | 175 | */ |
175 | 176 | public function renderContents($writer) |
176 | 177 | { |
177 | - if(($text=$this->getText())==='') |
|
178 | - parent::renderContents($writer); |
|
179 | - else |
|
180 | - $writer->write($text); |
|
178 | + if(($text=$this->getText())==='') { |
|
179 | + parent::renderContents($writer); |
|
180 | + } else { |
|
181 | + $writer->write($text); |
|
182 | + } |
|
181 | 183 | } |
182 | 184 | |
183 | 185 | /** |
@@ -298,8 +300,9 @@ discard block |
||
298 | 300 | */ |
299 | 301 | public function raisePostBackEvent($param) |
300 | 302 | { |
301 | - if($this->getCausesValidation()) |
|
302 | - $this->getPage()->validate($this->getValidationGroup()); |
|
303 | + if($this->getCausesValidation()) { |
|
304 | + $this->getPage()->validate($this->getValidationGroup()); |
|
305 | + } |
|
303 | 306 | $this->onClick(null); |
304 | 307 | $this->onCommand(new TCommandEventParameter($this->getCommandName(),$this->getCommandParameter())); |
305 | 308 | } |
@@ -213,7 +213,7 @@ |
||
213 | 213 | /** |
214 | 214 | * Returns the value to be validated. |
215 | 215 | * This methid is required by IValidatable interface. |
216 | - * @return mixed the value of the property to be validated. |
|
216 | + * @return string the value of the property to be validated. |
|
217 | 217 | */ |
218 | 218 | public function getValidationPropertyValue() |
219 | 219 | { |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | */ |
37 | 37 | class TListBox extends TListControl implements IPostBackDataHandler, IValidatable |
38 | 38 | { |
39 | - private $_dataChanged=false; |
|
40 | - private $_isValid=true; |
|
39 | + private $_dataChanged = false; |
|
40 | + private $_isValid = true; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Adds attribute name-value pairs to renderer. |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | */ |
47 | 47 | protected function addAttributesToRender($writer) |
48 | 48 | { |
49 | - $rows=$this->getRows(); |
|
50 | - $writer->addAttribute('size',"$rows"); |
|
51 | - if($this->getSelectionMode()===TListSelectionMode::Multiple) |
|
52 | - $writer->addAttribute('name',$this->getUniqueID().'[]'); |
|
49 | + $rows = $this->getRows(); |
|
50 | + $writer->addAttribute('size', "$rows"); |
|
51 | + if ($this->getSelectionMode() === TListSelectionMode::Multiple) |
|
52 | + $writer->addAttribute('name', $this->getUniqueID() . '[]'); |
|
53 | 53 | else |
54 | - $writer->addAttribute('name',$this->getUniqueID()); |
|
54 | + $writer->addAttribute('name', $this->getUniqueID()); |
|
55 | 55 | parent::addAttributesToRender($writer); |
56 | 56 | } |
57 | 57 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function onPreRender($param) |
74 | 74 | { |
75 | 75 | parent::onPreRender($param); |
76 | - if($this->getEnabled(true)) |
|
76 | + if ($this->getEnabled(true)) |
|
77 | 77 | $this->getPage()->registerRequiresPostData($this); |
78 | 78 | } |
79 | 79 | |
@@ -84,60 +84,60 @@ discard block |
||
84 | 84 | * @param array the input data collection |
85 | 85 | * @return boolean whether the data of the component has been changed |
86 | 86 | */ |
87 | - public function loadPostData($key,$values) |
|
87 | + public function loadPostData($key, $values) |
|
88 | 88 | { |
89 | - if(!$this->getEnabled(true)) |
|
89 | + if (!$this->getEnabled(true)) |
|
90 | 90 | return false; |
91 | 91 | $this->ensureDataBound(); |
92 | - $selections=isset($values[$key])?$values[$key]:null; |
|
93 | - if($selections!==null) |
|
92 | + $selections = isset($values[$key]) ? $values[$key] : null; |
|
93 | + if ($selections !== null) |
|
94 | 94 | { |
95 | - $items=$this->getItems(); |
|
96 | - if($this->getSelectionMode()===TListSelectionMode::Single) |
|
95 | + $items = $this->getItems(); |
|
96 | + if ($this->getSelectionMode() === TListSelectionMode::Single) |
|
97 | 97 | { |
98 | - $selection=is_array($selections)?$selections[0]:$selections; |
|
99 | - $index=$items->findIndexByValue($selection,false); |
|
100 | - if($this->getSelectedIndex()!==$index) |
|
98 | + $selection = is_array($selections) ? $selections[0] : $selections; |
|
99 | + $index = $items->findIndexByValue($selection, false); |
|
100 | + if ($this->getSelectedIndex() !== $index) |
|
101 | 101 | { |
102 | 102 | $this->setSelectedIndex($index); |
103 | - return $this->_dataChanged=true; |
|
103 | + return $this->_dataChanged = true; |
|
104 | 104 | } |
105 | 105 | else |
106 | 106 | return false; |
107 | 107 | } |
108 | - if(!is_array($selections)) |
|
109 | - $selections=array($selections); |
|
110 | - $list=array(); |
|
111 | - foreach($selections as $selection) |
|
112 | - $list[]=$items->findIndexByValue($selection,false); |
|
113 | - $list2=$this->getSelectedIndices(); |
|
114 | - $n=count($list); |
|
115 | - $flag=false; |
|
116 | - if($n===count($list2)) |
|
108 | + if (!is_array($selections)) |
|
109 | + $selections = array($selections); |
|
110 | + $list = array(); |
|
111 | + foreach ($selections as $selection) |
|
112 | + $list[] = $items->findIndexByValue($selection, false); |
|
113 | + $list2 = $this->getSelectedIndices(); |
|
114 | + $n = count($list); |
|
115 | + $flag = false; |
|
116 | + if ($n === count($list2)) |
|
117 | 117 | { |
118 | - sort($list,SORT_NUMERIC); |
|
119 | - for($i=0;$i<$n;++$i) |
|
118 | + sort($list, SORT_NUMERIC); |
|
119 | + for ($i = 0; $i < $n; ++$i) |
|
120 | 120 | { |
121 | - if($list[$i]!==$list2[$i]) |
|
121 | + if ($list[$i] !== $list2[$i]) |
|
122 | 122 | { |
123 | - $flag=true; |
|
123 | + $flag = true; |
|
124 | 124 | break; |
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
128 | 128 | else |
129 | - $flag=true; |
|
130 | - if($flag) |
|
129 | + $flag = true; |
|
130 | + if ($flag) |
|
131 | 131 | { |
132 | 132 | $this->setSelectedIndices($list); |
133 | - $this->_dataChanged=true; |
|
133 | + $this->_dataChanged = true; |
|
134 | 134 | } |
135 | 135 | return $flag; |
136 | 136 | } |
137 | - else if($this->getSelectedIndex()!==-1) |
|
137 | + else if ($this->getSelectedIndex() !== -1) |
|
138 | 138 | { |
139 | 139 | $this->clearSelection(); |
140 | - return $this->_dataChanged=true; |
|
140 | + return $this->_dataChanged = true; |
|
141 | 141 | } |
142 | 142 | else |
143 | 143 | return false; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function raisePostDataChangedEvent() |
154 | 154 | { |
155 | - if($this->getAutoPostBack() && $this->getCausesValidation()) |
|
155 | + if ($this->getAutoPostBack() && $this->getCausesValidation()) |
|
156 | 156 | $this->getPage()->validate($this->getValidationGroup()); |
157 | 157 | $this->onSelectedIndexChanged(null); |
158 | 158 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | protected function getIsMultiSelect() |
174 | 174 | { |
175 | - return $this->getSelectionMode()===TListSelectionMode::Multiple; |
|
175 | + return $this->getSelectionMode() === TListSelectionMode::Multiple; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public function setRows($value) |
190 | 190 | { |
191 | - $value=TPropertyValue::ensureInteger($value); |
|
192 | - if($value<=0) |
|
193 | - $value=4; |
|
191 | + $value = TPropertyValue::ensureInteger($value); |
|
192 | + if ($value <= 0) |
|
193 | + $value = 4; |
|
194 | 194 | $this->setViewState('Rows', $value, 4); |
195 | 195 | } |
196 | 196 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function setSelectionMode($value) |
209 | 209 | { |
210 | - $this->setViewState('SelectionMode',TPropertyValue::ensureEnum($value,'TListSelectionMode'),TListSelectionMode::Single); |
|
210 | + $this->setViewState('SelectionMode', TPropertyValue::ensureEnum($value, 'TListSelectionMode'), TListSelectionMode::Single); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | */ |
235 | 235 | public function setIsValid($value) |
236 | 236 | { |
237 | - $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
237 | + $this->_isValid = TPropertyValue::ensureBoolean($value); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | */ |
254 | 254 | class TListSelectionMode extends TEnumerable |
255 | 255 | { |
256 | - const Single='Single'; |
|
257 | - const Multiple='Multiple'; |
|
256 | + const Single = 'Single'; |
|
257 | + const Multiple = 'Multiple'; |
|
258 | 258 | } |
259 | 259 |
@@ -48,10 +48,11 @@ discard block |
||
48 | 48 | { |
49 | 49 | $rows=$this->getRows(); |
50 | 50 | $writer->addAttribute('size',"$rows"); |
51 | - if($this->getSelectionMode()===TListSelectionMode::Multiple) |
|
52 | - $writer->addAttribute('name',$this->getUniqueID().'[]'); |
|
53 | - else |
|
54 | - $writer->addAttribute('name',$this->getUniqueID()); |
|
51 | + if($this->getSelectionMode()===TListSelectionMode::Multiple) { |
|
52 | + $writer->addAttribute('name',$this->getUniqueID().'[]'); |
|
53 | + } else { |
|
54 | + $writer->addAttribute('name',$this->getUniqueID()); |
|
55 | + } |
|
55 | 56 | parent::addAttributesToRender($writer); |
56 | 57 | } |
57 | 58 | |
@@ -73,8 +74,9 @@ discard block |
||
73 | 74 | public function onPreRender($param) |
74 | 75 | { |
75 | 76 | parent::onPreRender($param); |
76 | - if($this->getEnabled(true)) |
|
77 | - $this->getPage()->registerRequiresPostData($this); |
|
77 | + if($this->getEnabled(true)) { |
|
78 | + $this->getPage()->registerRequiresPostData($this); |
|
79 | + } |
|
78 | 80 | } |
79 | 81 | |
80 | 82 | /** |
@@ -86,8 +88,9 @@ discard block |
||
86 | 88 | */ |
87 | 89 | public function loadPostData($key,$values) |
88 | 90 | { |
89 | - if(!$this->getEnabled(true)) |
|
90 | - return false; |
|
91 | + if(!$this->getEnabled(true)) { |
|
92 | + return false; |
|
93 | + } |
|
91 | 94 | $this->ensureDataBound(); |
92 | 95 | $selections=isset($values[$key])?$values[$key]:null; |
93 | 96 | if($selections!==null) |
@@ -101,15 +104,17 @@ discard block |
||
101 | 104 | { |
102 | 105 | $this->setSelectedIndex($index); |
103 | 106 | return $this->_dataChanged=true; |
107 | + } else { |
|
108 | + return false; |
|
104 | 109 | } |
105 | - else |
|
106 | - return false; |
|
107 | 110 | } |
108 | - if(!is_array($selections)) |
|
109 | - $selections=array($selections); |
|
111 | + if(!is_array($selections)) { |
|
112 | + $selections=array($selections); |
|
113 | + } |
|
110 | 114 | $list=array(); |
111 | - foreach($selections as $selection) |
|
112 | - $list[]=$items->findIndexByValue($selection,false); |
|
115 | + foreach($selections as $selection) { |
|
116 | + $list[]=$items->findIndexByValue($selection,false); |
|
117 | + } |
|
113 | 118 | $list2=$this->getSelectedIndices(); |
114 | 119 | $n=count($list); |
115 | 120 | $flag=false; |
@@ -124,23 +129,22 @@ discard block |
||
124 | 129 | break; |
125 | 130 | } |
126 | 131 | } |
132 | + } else { |
|
133 | + $flag=true; |
|
127 | 134 | } |
128 | - else |
|
129 | - $flag=true; |
|
130 | 135 | if($flag) |
131 | 136 | { |
132 | 137 | $this->setSelectedIndices($list); |
133 | 138 | $this->_dataChanged=true; |
134 | 139 | } |
135 | 140 | return $flag; |
136 | - } |
|
137 | - else if($this->getSelectedIndex()!==-1) |
|
141 | + } else if($this->getSelectedIndex()!==-1) |
|
138 | 142 | { |
139 | 143 | $this->clearSelection(); |
140 | 144 | return $this->_dataChanged=true; |
145 | + } else { |
|
146 | + return false; |
|
141 | 147 | } |
142 | - else |
|
143 | - return false; |
|
144 | 148 | } |
145 | 149 | |
146 | 150 | /** |
@@ -152,8 +156,9 @@ discard block |
||
152 | 156 | */ |
153 | 157 | public function raisePostDataChangedEvent() |
154 | 158 | { |
155 | - if($this->getAutoPostBack() && $this->getCausesValidation()) |
|
156 | - $this->getPage()->validate($this->getValidationGroup()); |
|
159 | + if($this->getAutoPostBack() && $this->getCausesValidation()) { |
|
160 | + $this->getPage()->validate($this->getValidationGroup()); |
|
161 | + } |
|
157 | 162 | $this->onSelectedIndexChanged(null); |
158 | 163 | } |
159 | 164 | |
@@ -189,8 +194,9 @@ discard block |
||
189 | 194 | public function setRows($value) |
190 | 195 | { |
191 | 196 | $value=TPropertyValue::ensureInteger($value); |
192 | - if($value<=0) |
|
193 | - $value=4; |
|
197 | + if($value<=0) { |
|
198 | + $value=4; |
|
199 | + } |
|
194 | 200 | $this->setViewState('Rows', $value, 4); |
195 | 201 | } |
196 | 202 |
@@ -463,14 +463,14 @@ |
||
463 | 463 | */ |
464 | 464 | public function getIsValid() |
465 | 465 | { |
466 | - return $this->_isValid; |
|
466 | + return $this->_isValid; |
|
467 | 467 | } |
468 | 468 | /** |
469 | 469 | * @param bool wether this control is valid. |
470 | 470 | */ |
471 | 471 | public function setIsValid($value) |
472 | 472 | { |
473 | - $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
473 | + $this->_isValid=TPropertyValue::ensureBoolean($value); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -184,6 +184,7 @@ discard block |
||
184 | 184 | * This method adds only {@link TListItem} objects into the {@link getItems Items} collection. |
185 | 185 | * All other objects are ignored. |
186 | 186 | * @param mixed object parsed from template |
187 | + * @param XListMenuItem $object |
|
187 | 188 | */ |
188 | 189 | public function addParsedObject($object) |
189 | 190 | { |
@@ -347,6 +348,7 @@ discard block |
||
347 | 348 | * An automatic postback to the server will occur whenever the user |
348 | 349 | * makes change to the list control and then tabs out of it. |
349 | 350 | * @param boolean the value indicating if postback automatically |
351 | + * @param boolean $value |
|
350 | 352 | */ |
351 | 353 | public function setAutoPostBack($value) |
352 | 354 | { |
@@ -379,6 +381,7 @@ discard block |
||
379 | 381 | |
380 | 382 | /** |
381 | 383 | * @param string the field of the data source that provides the text content of the list items. |
384 | + * @param string $value |
|
382 | 385 | */ |
383 | 386 | public function setDataTextField($value) |
384 | 387 | { |
@@ -398,6 +401,7 @@ discard block |
||
398 | 401 | * The format string is used in {@link TDataValueFormatter::format()} to format the Text property value |
399 | 402 | * of each item in the list control. |
400 | 403 | * @param string the formatting string used to control how data bound to the list control is displayed. |
404 | + * @param string $value |
|
401 | 405 | * @see TDataValueFormatter::format() |
402 | 406 | */ |
403 | 407 | public function setDataTextFormatString($value) |
@@ -415,6 +419,7 @@ discard block |
||
415 | 419 | |
416 | 420 | /** |
417 | 421 | * @param string the field of the data source that provides the value of each list item. |
422 | + * @param string $value |
|
418 | 423 | */ |
419 | 424 | public function setDataValueField($value) |
420 | 425 | { |
@@ -856,6 +861,7 @@ discard block |
||
856 | 861 | * as the first and second parameters in {@link sprintf}. |
857 | 862 | * @param string format string |
858 | 863 | * @param mixed the data to be formatted |
864 | + * @param string $formatString |
|
859 | 865 | * @return string the formatted result |
860 | 866 | */ |
861 | 867 | protected function formatDataValue($formatString,$value) |
@@ -894,28 +900,33 @@ discard block |
||
894 | 900 | /** |
895 | 901 | * Selects an item based on zero-base index on the client side. |
896 | 902 | * @param integer the index (zero-based) of the item to be selected |
903 | + * @return void |
|
897 | 904 | */ |
898 | 905 | public function setSelectedIndex($index); |
899 | 906 | /** |
900 | 907 | * Selects a list of item based on zero-base indices on the client side. |
901 | 908 | * @param array list of index of items to be selected |
909 | + * @return void |
|
902 | 910 | */ |
903 | 911 | public function setSelectedIndices($indices); |
904 | 912 | |
905 | 913 | /** |
906 | 914 | * Sets selection by item value on the client side. |
907 | 915 | * @param string the value of the item to be selected. |
916 | + * @return void |
|
908 | 917 | */ |
909 | 918 | public function setSelectedValue($value); |
910 | 919 | |
911 | 920 | /** |
912 | 921 | * Sets selection by a list of item values on the client side. |
913 | 922 | * @param array list of the selected item values |
923 | + * @return void |
|
914 | 924 | */ |
915 | 925 | public function setSelectedValues($values); |
916 | 926 | |
917 | 927 | /** |
918 | 928 | * Clears all existing selections on the client side. |
929 | + * @return void |
|
919 | 930 | */ |
920 | 931 | public function clearSelection(); |
921 | 932 | } |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | |
335 | 335 | /** |
336 | 336 | * @return boolean a value indicating whether an automatic postback to the server |
337 | - * will occur whenever the user makes change to the list control and then tabs out of it. |
|
338 | - * Defaults to false. |
|
337 | + * will occur whenever the user makes change to the list control and then tabs out of it. |
|
338 | + * Defaults to false. |
|
339 | 339 | */ |
340 | 340 | public function getAutoPostBack() |
341 | 341 | { |
@@ -591,23 +591,23 @@ discard block |
||
591 | 591 | * @param string the value of the item to be selected. |
592 | 592 | */ |
593 | 593 | public function setSelectedValue($value) |
594 | - { |
|
595 | - if($this->_items) |
|
596 | - { |
|
597 | - if($value===null) |
|
598 | - $this->clearSelection(); |
|
599 | - else if(($item=$this->_items->findItemByValue($value))!==null) |
|
600 | - { |
|
601 | - $this->clearSelection(); |
|
602 | - $item->setSelected(true); |
|
603 | - } |
|
604 | - else |
|
594 | + { |
|
595 | + if($this->_items) |
|
596 | + { |
|
597 | + if($value===null) |
|
598 | + $this->clearSelection(); |
|
599 | + else if(($item=$this->_items->findItemByValue($value))!==null) |
|
600 | + { |
|
601 | + $this->clearSelection(); |
|
602 | + $item->setSelected(true); |
|
603 | + } |
|
604 | + else |
|
605 | 605 | $this->clearSelection(); |
606 | - } |
|
607 | - $this->_cachedSelectedValue=$value; |
|
606 | + } |
|
607 | + $this->_cachedSelectedValue=$value; |
|
608 | 608 | if($this->getAdapter() instanceof IListControlAdapter) |
609 | 609 | $this->getAdapter()->setSelectedValue($value); |
610 | - } |
|
610 | + } |
|
611 | 611 | |
612 | 612 | |
613 | 613 | /** |
@@ -655,36 +655,36 @@ discard block |
||
655 | 655 | $this->getAdapter()->setSelectedValues($values); |
656 | 656 | } |
657 | 657 | |
658 | - /** |
|
659 | - * @return string selected value |
|
660 | - */ |
|
661 | - public function getText() |
|
662 | - { |
|
663 | - return $this->getSelectedValue(); |
|
664 | - } |
|
665 | - |
|
666 | - /** |
|
667 | - * @param string value to be selected |
|
668 | - */ |
|
669 | - public function setText($value) |
|
670 | - { |
|
671 | - $this->setSelectedValue($value); |
|
672 | - } |
|
673 | - |
|
674 | - /** |
|
675 | - * Clears all existing selections. |
|
676 | - */ |
|
677 | - public function clearSelection() |
|
678 | - { |
|
679 | - if($this->_items) |
|
680 | - { |
|
681 | - foreach($this->_items as $item) |
|
682 | - $item->setSelected(false); |
|
683 | - } |
|
658 | + /** |
|
659 | + * @return string selected value |
|
660 | + */ |
|
661 | + public function getText() |
|
662 | + { |
|
663 | + return $this->getSelectedValue(); |
|
664 | + } |
|
665 | + |
|
666 | + /** |
|
667 | + * @param string value to be selected |
|
668 | + */ |
|
669 | + public function setText($value) |
|
670 | + { |
|
671 | + $this->setSelectedValue($value); |
|
672 | + } |
|
673 | + |
|
674 | + /** |
|
675 | + * Clears all existing selections. |
|
676 | + */ |
|
677 | + public function clearSelection() |
|
678 | + { |
|
679 | + if($this->_items) |
|
680 | + { |
|
681 | + foreach($this->_items as $item) |
|
682 | + $item->setSelected(false); |
|
683 | + } |
|
684 | 684 | |
685 | 685 | if($this->getAdapter() instanceof IListControlAdapter) |
686 | 686 | $this->getAdapter()->clearSelection(); |
687 | - } |
|
687 | + } |
|
688 | 688 | |
689 | 689 | /** |
690 | 690 | * @return string the group of validators which the list control causes validation upon postback |
@@ -914,10 +914,10 @@ discard block |
||
914 | 914 | */ |
915 | 915 | public function setSelectedValues($values); |
916 | 916 | |
917 | - /** |
|
918 | - * Clears all existing selections on the client side. |
|
919 | - */ |
|
920 | - public function clearSelection(); |
|
917 | + /** |
|
918 | + * Clears all existing selections on the client side. |
|
919 | + */ |
|
920 | + public function clearSelection(); |
|
921 | 921 | } |
922 | 922 | |
923 | 923 |
@@ -86,19 +86,19 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * @var TListItemCollection item list |
88 | 88 | */ |
89 | - private $_items=null; |
|
89 | + private $_items = null; |
|
90 | 90 | /** |
91 | 91 | * @var boolean whether items are restored from viewstate |
92 | 92 | */ |
93 | - private $_stateLoaded=false; |
|
93 | + private $_stateLoaded = false; |
|
94 | 94 | /** |
95 | 95 | * @var mixed the following selection variables are used |
96 | 96 | * to keep selections when Items are not available |
97 | 97 | */ |
98 | - private $_cachedSelectedIndex=-1; |
|
99 | - private $_cachedSelectedValue=null; |
|
100 | - private $_cachedSelectedIndices=null; |
|
101 | - private $_cachedSelectedValues=null; |
|
98 | + private $_cachedSelectedIndex = -1; |
|
99 | + private $_cachedSelectedValue = null; |
|
100 | + private $_cachedSelectedIndices = null; |
|
101 | + private $_cachedSelectedValues = null; |
|
102 | 102 | |
103 | 103 | /** |
104 | 104 | * @return string tag name of the list control |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function getEnableClientScript() |
115 | 115 | { |
116 | - return $this->getViewState('EnableClientScript',true); |
|
116 | + return $this->getViewState('EnableClientScript', true); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function setEnableClientScript($value) |
123 | 123 | { |
124 | - $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true); |
|
124 | + $this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -130,21 +130,21 @@ discard block |
||
130 | 130 | */ |
131 | 131 | protected function addAttributesToRender($writer) |
132 | 132 | { |
133 | - $page=$this->getPage(); |
|
133 | + $page = $this->getPage(); |
|
134 | 134 | $page->ensureRenderInForm($this); |
135 | - if($this->getIsMultiSelect()) |
|
136 | - $writer->addAttribute('multiple','multiple'); |
|
137 | - if($this->getEnabled(true)) |
|
135 | + if ($this->getIsMultiSelect()) |
|
136 | + $writer->addAttribute('multiple', 'multiple'); |
|
137 | + if ($this->getEnabled(true)) |
|
138 | 138 | { |
139 | - if($this->getAutoPostBack() |
|
139 | + if ($this->getAutoPostBack() |
|
140 | 140 | && $this->getEnableClientScript() |
141 | 141 | && $page->getClientSupportsJavaScript()) |
142 | 142 | { |
143 | 143 | $this->renderClientControlScript($writer); |
144 | 144 | } |
145 | 145 | } |
146 | - else if($this->getEnabled()) |
|
147 | - $writer->addAttribute('disabled','disabled'); |
|
146 | + else if ($this->getEnabled()) |
|
147 | + $writer->addAttribute('disabled', 'disabled'); |
|
148 | 148 | parent::addAttributesToRender($writer); |
149 | 149 | } |
150 | 150 | |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | */ |
154 | 154 | protected function renderClientControlScript($writer) |
155 | 155 | { |
156 | - $writer->addAttribute('id',$this->getClientID()); |
|
157 | - $this->getPage()->getClientScript()->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions()); |
|
156 | + $writer->addAttribute('id', $this->getClientID()); |
|
157 | + $this->getPage()->getClientScript()->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions()); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | public function addParsedObject($object) |
189 | 189 | { |
190 | 190 | // Do not add items from template if items are loaded from viewstate |
191 | - if(!$this->_stateLoaded && ($object instanceof TListItem)) |
|
191 | + if (!$this->_stateLoaded && ($object instanceof TListItem)) |
|
192 | 192 | { |
193 | - $index=$this->getItems()->add($object); |
|
194 | - if(($this->_cachedSelectedValue!==null && $this->_cachedSelectedValue===$object->getValue()) || ($this->_cachedSelectedIndex===$index)) |
|
193 | + $index = $this->getItems()->add($object); |
|
194 | + if (($this->_cachedSelectedValue !== null && $this->_cachedSelectedValue === $object->getValue()) || ($this->_cachedSelectedIndex === $index)) |
|
195 | 195 | { |
196 | 196 | $object->setSelected(true); |
197 | - $this->_cachedSelectedValue=null; |
|
198 | - $this->_cachedSelectedIndex=-1; |
|
197 | + $this->_cachedSelectedValue = null; |
|
198 | + $this->_cachedSelectedIndex = -1; |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | } |
@@ -208,53 +208,53 @@ discard block |
||
208 | 208 | */ |
209 | 209 | protected function performDataBinding($data) |
210 | 210 | { |
211 | - $items=$this->getItems(); |
|
212 | - if(!$this->getAppendDataBoundItems()) |
|
211 | + $items = $this->getItems(); |
|
212 | + if (!$this->getAppendDataBoundItems()) |
|
213 | 213 | $items->clear(); |
214 | - $textField=$this->getDataTextField(); |
|
215 | - if($textField==='') |
|
216 | - $textField=0; |
|
217 | - $valueField=$this->getDataValueField(); |
|
218 | - if($valueField==='') |
|
219 | - $valueField=1; |
|
220 | - $textFormat=$this->getDataTextFormatString(); |
|
221 | - $groupField=$this->getDataGroupField(); |
|
222 | - foreach($data as $key=>$object) |
|
214 | + $textField = $this->getDataTextField(); |
|
215 | + if ($textField === '') |
|
216 | + $textField = 0; |
|
217 | + $valueField = $this->getDataValueField(); |
|
218 | + if ($valueField === '') |
|
219 | + $valueField = 1; |
|
220 | + $textFormat = $this->getDataTextFormatString(); |
|
221 | + $groupField = $this->getDataGroupField(); |
|
222 | + foreach ($data as $key=>$object) |
|
223 | 223 | { |
224 | - $item=$items->createListItem(); |
|
225 | - if(is_array($object) || is_object($object)) |
|
224 | + $item = $items->createListItem(); |
|
225 | + if (is_array($object) || is_object($object)) |
|
226 | 226 | { |
227 | - $text=TDataFieldAccessor::getDataFieldValue($object,$textField); |
|
228 | - $value=TDataFieldAccessor::getDataFieldValue($object,$valueField); |
|
227 | + $text = TDataFieldAccessor::getDataFieldValue($object, $textField); |
|
228 | + $value = TDataFieldAccessor::getDataFieldValue($object, $valueField); |
|
229 | 229 | $item->setValue($value); |
230 | - if($groupField!=='') |
|
231 | - $item->setAttribute('Group',TDataFieldAccessor::getDataFieldValue($object,$groupField)); |
|
230 | + if ($groupField !== '') |
|
231 | + $item->setAttribute('Group', TDataFieldAccessor::getDataFieldValue($object, $groupField)); |
|
232 | 232 | } |
233 | 233 | else |
234 | 234 | { |
235 | - $text=$object; |
|
235 | + $text = $object; |
|
236 | 236 | $item->setValue("$key"); |
237 | 237 | } |
238 | - $item->setText($this->formatDataValue($textFormat,$text)); |
|
238 | + $item->setText($this->formatDataValue($textFormat, $text)); |
|
239 | 239 | } |
240 | 240 | // SelectedValue or SelectedIndex may be set before databinding |
241 | 241 | // so we make them be effective now |
242 | - if($this->_cachedSelectedValue!==null) |
|
242 | + if ($this->_cachedSelectedValue !== null) |
|
243 | 243 | { |
244 | 244 | $this->setSelectedValue($this->_cachedSelectedValue); |
245 | 245 | $this->resetCachedSelections(); |
246 | 246 | } |
247 | - else if($this->_cachedSelectedIndex!==-1) |
|
247 | + else if ($this->_cachedSelectedIndex !== -1) |
|
248 | 248 | { |
249 | 249 | $this->setSelectedIndex($this->_cachedSelectedIndex); |
250 | 250 | $this->resetCachedSelections(); |
251 | 251 | } |
252 | - else if($this->_cachedSelectedValues!==null) |
|
252 | + else if ($this->_cachedSelectedValues !== null) |
|
253 | 253 | { |
254 | 254 | $this->setSelectedValues($this->_cachedSelectedValues); |
255 | 255 | $this->resetCachedSelections(); |
256 | 256 | } |
257 | - else if($this->_cachedSelectedIndices!==null) |
|
257 | + else if ($this->_cachedSelectedIndices !== null) |
|
258 | 258 | { |
259 | 259 | $this->setSelectedIndices($this->_cachedSelectedIndices); |
260 | 260 | $this->resetCachedSelections(); |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | |
264 | 264 | private function resetCachedSelections() |
265 | 265 | { |
266 | - $this->_cachedSelectedValue=null; |
|
267 | - $this->_cachedSelectedIndex=-1; |
|
268 | - $this->_cachedSelectedValues=null; |
|
269 | - $this->_cachedSelectedIndices=null; |
|
266 | + $this->_cachedSelectedValue = null; |
|
267 | + $this->_cachedSelectedIndex = -1; |
|
268 | + $this->_cachedSelectedValues = null; |
|
269 | + $this->_cachedSelectedIndices = null; |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | public function saveState() |
287 | 287 | { |
288 | 288 | parent::saveState(); |
289 | - if($this->_items) |
|
290 | - $this->setViewState('Items',$this->_items->saveState(),null); |
|
289 | + if ($this->_items) |
|
290 | + $this->setViewState('Items', $this->_items->saveState(), null); |
|
291 | 291 | else |
292 | 292 | $this->clearViewState('Items'); |
293 | 293 | } |
@@ -299,11 +299,11 @@ discard block |
||
299 | 299 | public function loadState() |
300 | 300 | { |
301 | 301 | parent::loadState(); |
302 | - $this->_stateLoaded=true; |
|
303 | - if(!$this->getIsDataBound()) |
|
302 | + $this->_stateLoaded = true; |
|
303 | + if (!$this->getIsDataBound()) |
|
304 | 304 | { |
305 | - $this->_items=$this->createListItemCollection(); |
|
306 | - $this->_items->loadState($this->getViewState('Items',null)); |
|
305 | + $this->_items = $this->createListItemCollection(); |
|
306 | + $this->_items->loadState($this->getViewState('Items', null)); |
|
307 | 307 | } |
308 | 308 | $this->clearViewState('Items'); |
309 | 309 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | */ |
322 | 322 | public function getAppendDataBoundItems() |
323 | 323 | { |
324 | - return $this->getViewState('AppendDataBoundItems',false); |
|
324 | + return $this->getViewState('AppendDataBoundItems', false); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | /** |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | */ |
330 | 330 | public function setAppendDataBoundItems($value) |
331 | 331 | { |
332 | - $this->setViewState('AppendDataBoundItems',TPropertyValue::ensureBoolean($value),false); |
|
332 | + $this->setViewState('AppendDataBoundItems', TPropertyValue::ensureBoolean($value), false); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | public function getAutoPostBack() |
341 | 341 | { |
342 | - return $this->getViewState('AutoPostBack',false); |
|
342 | + return $this->getViewState('AutoPostBack', false); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | */ |
351 | 351 | public function setAutoPostBack($value) |
352 | 352 | { |
353 | - $this->setViewState('AutoPostBack',TPropertyValue::ensureBoolean($value),false); |
|
353 | + $this->setViewState('AutoPostBack', TPropertyValue::ensureBoolean($value), false); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | */ |
359 | 359 | public function getCausesValidation() |
360 | 360 | { |
361 | - return $this->getViewState('CausesValidation',true); |
|
361 | + return $this->getViewState('CausesValidation', true); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | */ |
367 | 367 | public function setCausesValidation($value) |
368 | 368 | { |
369 | - $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true); |
|
369 | + $this->setViewState('CausesValidation', TPropertyValue::ensureBoolean($value), true); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | */ |
375 | 375 | public function getDataTextField() |
376 | 376 | { |
377 | - return $this->getViewState('DataTextField',''); |
|
377 | + return $this->getViewState('DataTextField', ''); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | public function setDataTextField($value) |
384 | 384 | { |
385 | - $this->setViewState('DataTextField',$value,''); |
|
385 | + $this->setViewState('DataTextField', $value, ''); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | */ |
391 | 391 | public function getDataTextFormatString() |
392 | 392 | { |
393 | - return $this->getViewState('DataTextFormatString',''); |
|
393 | + return $this->getViewState('DataTextFormatString', ''); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | */ |
403 | 403 | public function setDataTextFormatString($value) |
404 | 404 | { |
405 | - $this->setViewState('DataTextFormatString',$value,''); |
|
405 | + $this->setViewState('DataTextFormatString', $value, ''); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | */ |
411 | 411 | public function getDataValueField() |
412 | 412 | { |
413 | - return $this->getViewState('DataValueField',''); |
|
413 | + return $this->getViewState('DataValueField', ''); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | */ |
419 | 419 | public function setDataValueField($value) |
420 | 420 | { |
421 | - $this->setViewState('DataValueField',$value,''); |
|
421 | + $this->setViewState('DataValueField', $value, ''); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | */ |
427 | 427 | public function getDataGroupField() |
428 | 428 | { |
429 | - return $this->getViewState('DataGroupField',''); |
|
429 | + return $this->getViewState('DataGroupField', ''); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | */ |
435 | 435 | public function setDataGroupField($value) |
436 | 436 | { |
437 | - $this->setViewState('DataGroupField',$value,''); |
|
437 | + $this->setViewState('DataGroupField', $value, ''); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | */ |
443 | 443 | public function getItemCount() |
444 | 444 | { |
445 | - return $this->_items?$this->_items->getCount():0; |
|
445 | + return $this->_items ? $this->_items->getCount() : 0; |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | /** |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | */ |
451 | 451 | public function getHasItems() |
452 | 452 | { |
453 | - return ($this->_items && $this->_items->getCount()>0); |
|
453 | + return ($this->_items && $this->_items->getCount() > 0); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** |
@@ -458,8 +458,8 @@ discard block |
||
458 | 458 | */ |
459 | 459 | public function getItems() |
460 | 460 | { |
461 | - if(!$this->_items) |
|
462 | - $this->_items=$this->createListItemCollection(); |
|
461 | + if (!$this->_items) |
|
462 | + $this->_items = $this->createListItemCollection(); |
|
463 | 463 | return $this->_items; |
464 | 464 | } |
465 | 465 | |
@@ -468,11 +468,11 @@ discard block |
||
468 | 468 | */ |
469 | 469 | public function getSelectedIndex() |
470 | 470 | { |
471 | - if($this->_items) |
|
471 | + if ($this->_items) |
|
472 | 472 | { |
473 | - $n=$this->_items->getCount(); |
|
474 | - for($i=0;$i<$n;++$i) |
|
475 | - if($this->_items->itemAt($i)->getSelected()) |
|
473 | + $n = $this->_items->getCount(); |
|
474 | + for ($i = 0; $i < $n; ++$i) |
|
475 | + if ($this->_items->itemAt($i)->getSelected()) |
|
476 | 476 | return $i; |
477 | 477 | } |
478 | 478 | return -1; |
@@ -483,16 +483,16 @@ discard block |
||
483 | 483 | */ |
484 | 484 | public function setSelectedIndex($index) |
485 | 485 | { |
486 | - if(($index=TPropertyValue::ensureInteger($index))<0) |
|
487 | - $index=-1; |
|
488 | - if($this->_items) |
|
486 | + if (($index = TPropertyValue::ensureInteger($index)) < 0) |
|
487 | + $index = -1; |
|
488 | + if ($this->_items) |
|
489 | 489 | { |
490 | 490 | $this->clearSelection(); |
491 | - if($index>=0 && $index<$this->_items->getCount()) |
|
491 | + if ($index >= 0 && $index < $this->_items->getCount()) |
|
492 | 492 | $this->_items->itemAt($index)->setSelected(true); |
493 | 493 | } |
494 | - $this->_cachedSelectedIndex=$index; |
|
495 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
494 | + $this->_cachedSelectedIndex = $index; |
|
495 | + if ($this->getAdapter() instanceof IListControlAdapter) |
|
496 | 496 | $this->getAdapter()->setSelectedIndex($index); |
497 | 497 | } |
498 | 498 | |
@@ -501,13 +501,13 @@ discard block |
||
501 | 501 | */ |
502 | 502 | public function getSelectedIndices() |
503 | 503 | { |
504 | - $selections=array(); |
|
505 | - if($this->_items) |
|
504 | + $selections = array(); |
|
505 | + if ($this->_items) |
|
506 | 506 | { |
507 | - $n=$this->_items->getCount(); |
|
508 | - for($i=0;$i<$n;++$i) |
|
509 | - if($this->_items->itemAt($i)->getSelected()) |
|
510 | - $selections[]=$i; |
|
507 | + $n = $this->_items->getCount(); |
|
508 | + for ($i = 0; $i < $n; ++$i) |
|
509 | + if ($this->_items->itemAt($i)->getSelected()) |
|
510 | + $selections[] = $i; |
|
511 | 511 | } |
512 | 512 | return $selections; |
513 | 513 | } |
@@ -517,24 +517,24 @@ discard block |
||
517 | 517 | */ |
518 | 518 | public function setSelectedIndices($indices) |
519 | 519 | { |
520 | - if($this->getIsMultiSelect()) |
|
520 | + if ($this->getIsMultiSelect()) |
|
521 | 521 | { |
522 | - if($this->_items) |
|
522 | + if ($this->_items) |
|
523 | 523 | { |
524 | 524 | $this->clearSelection(); |
525 | - $n=$this->_items->getCount(); |
|
526 | - foreach($indices as $index) |
|
525 | + $n = $this->_items->getCount(); |
|
526 | + foreach ($indices as $index) |
|
527 | 527 | { |
528 | - if($index>=0 && $index<$n) |
|
528 | + if ($index >= 0 && $index < $n) |
|
529 | 529 | $this->_items->itemAt($index)->setSelected(true); |
530 | 530 | } |
531 | 531 | } |
532 | - $this->_cachedSelectedIndices=$indices; |
|
532 | + $this->_cachedSelectedIndices = $indices; |
|
533 | 533 | } |
534 | 534 | else |
535 | - throw new TNotSupportedException('listcontrol_multiselect_unsupported',get_class($this)); |
|
535 | + throw new TNotSupportedException('listcontrol_multiselect_unsupported', get_class($this)); |
|
536 | 536 | |
537 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
537 | + if ($this->getAdapter() instanceof IListControlAdapter) |
|
538 | 538 | $this->getAdapter()->setSelectedIndices($indices); |
539 | 539 | } |
540 | 540 | |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | */ |
544 | 544 | public function getSelectedItem() |
545 | 545 | { |
546 | - if(($index=$this->getSelectedIndex())>=0) |
|
546 | + if (($index = $this->getSelectedIndex()) >= 0) |
|
547 | 547 | return $this->_items->itemAt($index); |
548 | 548 | else |
549 | 549 | return null; |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | */ |
581 | 581 | public function getSelectedValue() |
582 | 582 | { |
583 | - $index=$this->getSelectedIndex(); |
|
584 | - return $index>=0?$this->getItems()->itemAt($index)->getValue():''; |
|
583 | + $index = $this->getSelectedIndex(); |
|
584 | + return $index >= 0 ? $this->getItems()->itemAt($index)->getValue() : ''; |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
@@ -592,11 +592,11 @@ discard block |
||
592 | 592 | */ |
593 | 593 | public function setSelectedValue($value) |
594 | 594 | { |
595 | - if($this->_items) |
|
595 | + if ($this->_items) |
|
596 | 596 | { |
597 | - if($value===null) |
|
597 | + if ($value === null) |
|
598 | 598 | $this->clearSelection(); |
599 | - else if(($item=$this->_items->findItemByValue($value))!==null) |
|
599 | + else if (($item = $this->_items->findItemByValue($value)) !== null) |
|
600 | 600 | { |
601 | 601 | $this->clearSelection(); |
602 | 602 | $item->setSelected(true); |
@@ -604,8 +604,8 @@ discard block |
||
604 | 604 | else |
605 | 605 | $this->clearSelection(); |
606 | 606 | } |
607 | - $this->_cachedSelectedValue=$value; |
|
608 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
607 | + $this->_cachedSelectedValue = $value; |
|
608 | + if ($this->getAdapter() instanceof IListControlAdapter) |
|
609 | 609 | $this->getAdapter()->setSelectedValue($value); |
610 | 610 | } |
611 | 611 | |
@@ -615,13 +615,13 @@ discard block |
||
615 | 615 | */ |
616 | 616 | public function getSelectedValues() |
617 | 617 | { |
618 | - $values=array(); |
|
619 | - if($this->_items) |
|
618 | + $values = array(); |
|
619 | + if ($this->_items) |
|
620 | 620 | { |
621 | - foreach($this->_items as $item) |
|
621 | + foreach ($this->_items as $item) |
|
622 | 622 | { |
623 | - if($item->getSelected()) |
|
624 | - $values[]=$item->getValue(); |
|
623 | + if ($item->getSelected()) |
|
624 | + $values[] = $item->getValue(); |
|
625 | 625 | } |
626 | 626 | } |
627 | 627 | return $values; |
@@ -632,26 +632,26 @@ discard block |
||
632 | 632 | */ |
633 | 633 | public function setSelectedValues($values) |
634 | 634 | { |
635 | - if($this->getIsMultiSelect()) |
|
635 | + if ($this->getIsMultiSelect()) |
|
636 | 636 | { |
637 | - if($this->_items) |
|
637 | + if ($this->_items) |
|
638 | 638 | { |
639 | 639 | $this->clearSelection(); |
640 | - $lookup=array(); |
|
641 | - foreach($this->_items as $item) |
|
642 | - $lookup[$item->getValue()]=$item; |
|
643 | - foreach($values as $value) |
|
640 | + $lookup = array(); |
|
641 | + foreach ($this->_items as $item) |
|
642 | + $lookup[$item->getValue()] = $item; |
|
643 | + foreach ($values as $value) |
|
644 | 644 | { |
645 | - if(isset($lookup["$value"])) |
|
645 | + if (isset($lookup["$value"])) |
|
646 | 646 | $lookup["$value"]->setSelected(true); |
647 | 647 | } |
648 | 648 | } |
649 | - $this->_cachedSelectedValues=$values; |
|
649 | + $this->_cachedSelectedValues = $values; |
|
650 | 650 | } |
651 | 651 | else |
652 | - throw new TNotSupportedException('listcontrol_multiselect_unsupported',get_class($this)); |
|
652 | + throw new TNotSupportedException('listcontrol_multiselect_unsupported', get_class($this)); |
|
653 | 653 | |
654 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
654 | + if ($this->getAdapter() instanceof IListControlAdapter) |
|
655 | 655 | $this->getAdapter()->setSelectedValues($values); |
656 | 656 | } |
657 | 657 | |
@@ -676,13 +676,13 @@ discard block |
||
676 | 676 | */ |
677 | 677 | public function clearSelection() |
678 | 678 | { |
679 | - if($this->_items) |
|
679 | + if ($this->_items) |
|
680 | 680 | { |
681 | - foreach($this->_items as $item) |
|
681 | + foreach ($this->_items as $item) |
|
682 | 682 | $item->setSelected(false); |
683 | 683 | } |
684 | 684 | |
685 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
685 | + if ($this->getAdapter() instanceof IListControlAdapter) |
|
686 | 686 | $this->getAdapter()->clearSelection(); |
687 | 687 | } |
688 | 688 | |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | */ |
692 | 692 | public function getValidationGroup() |
693 | 693 | { |
694 | - return $this->getViewState('ValidationGroup',''); |
|
694 | + return $this->getViewState('ValidationGroup', ''); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | */ |
700 | 700 | public function setValidationGroup($value) |
701 | 701 | { |
702 | - $this->setViewState('ValidationGroup',$value,''); |
|
702 | + $this->setViewState('ValidationGroup', $value, ''); |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | /** |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | */ |
709 | 709 | public function getPromptText() |
710 | 710 | { |
711 | - return $this->getViewState('PromptText',''); |
|
711 | + return $this->getViewState('PromptText', ''); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | /** |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | */ |
718 | 718 | public function setPromptText($value) |
719 | 719 | { |
720 | - $this->setViewState('PromptText',$value,''); |
|
720 | + $this->setViewState('PromptText', $value, ''); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | /** |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | */ |
728 | 728 | public function getPromptValue() |
729 | 729 | { |
730 | - return $this->getViewState('PromptValue',''); |
|
730 | + return $this->getViewState('PromptValue', ''); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | /** |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | */ |
738 | 738 | public function setPromptValue($value) |
739 | 739 | { |
740 | - $this->setViewState('PromptValue',(string)$value,''); |
|
740 | + $this->setViewState('PromptValue', (string) $value, ''); |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | /** |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | */ |
749 | 749 | public function onSelectedIndexChanged($param) |
750 | 750 | { |
751 | - $this->raiseEvent('OnSelectedIndexChanged',$this,$param); |
|
751 | + $this->raiseEvent('OnSelectedIndexChanged', $this, $param); |
|
752 | 752 | $this->onTextChanged($param); |
753 | 753 | } |
754 | 754 | |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | */ |
761 | 761 | public function onTextChanged($param) |
762 | 762 | { |
763 | - $this->raiseEvent('OnTextChanged',$this,$param); |
|
763 | + $this->raiseEvent('OnTextChanged', $this, $param); |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | /** |
@@ -770,13 +770,13 @@ discard block |
||
770 | 770 | */ |
771 | 771 | protected function renderPrompt($writer) |
772 | 772 | { |
773 | - $text=$this->getPromptText(); |
|
774 | - $value=$this->getPromptValue(); |
|
775 | - if($value==='') |
|
776 | - $value=$text; |
|
777 | - if($value!=='') |
|
773 | + $text = $this->getPromptText(); |
|
774 | + $value = $this->getPromptValue(); |
|
775 | + if ($value === '') |
|
776 | + $value = $text; |
|
777 | + if ($value !== '') |
|
778 | 778 | { |
779 | - $writer->addAttribute('value',$value); |
|
779 | + $writer->addAttribute('value', $value); |
|
780 | 780 | $writer->renderBeginTag('option'); |
781 | 781 | $writer->write(THttpUtility::htmlEncode($text)); |
782 | 782 | $writer->renderEndTag(); |
@@ -793,52 +793,52 @@ discard block |
||
793 | 793 | { |
794 | 794 | $this->renderPrompt($writer); |
795 | 795 | |
796 | - if($this->_items) |
|
796 | + if ($this->_items) |
|
797 | 797 | { |
798 | 798 | $writer->writeLine(); |
799 | - $previousGroup=null; |
|
800 | - foreach($this->_items as $item) |
|
799 | + $previousGroup = null; |
|
800 | + foreach ($this->_items as $item) |
|
801 | 801 | { |
802 | - if($item->getEnabled()) |
|
802 | + if ($item->getEnabled()) |
|
803 | 803 | { |
804 | - if($item->getHasAttributes()) |
|
804 | + if ($item->getHasAttributes()) |
|
805 | 805 | { |
806 | - $group=$item->getAttributes()->remove('Group'); |
|
807 | - if($group!==$previousGroup) |
|
806 | + $group = $item->getAttributes()->remove('Group'); |
|
807 | + if ($group !== $previousGroup) |
|
808 | 808 | { |
809 | - if($previousGroup!==null) |
|
809 | + if ($previousGroup !== null) |
|
810 | 810 | { |
811 | 811 | $writer->renderEndTag(); |
812 | 812 | $writer->writeLine(); |
813 | - $previousGroup=null; |
|
813 | + $previousGroup = null; |
|
814 | 814 | } |
815 | - if($group!==null) |
|
815 | + if ($group !== null) |
|
816 | 816 | { |
817 | - $writer->addAttribute('label',$group); |
|
817 | + $writer->addAttribute('label', $group); |
|
818 | 818 | $writer->renderBeginTag('optgroup'); |
819 | 819 | $writer->writeLine(); |
820 | - $previousGroup=$group; |
|
820 | + $previousGroup = $group; |
|
821 | 821 | } |
822 | 822 | } |
823 | - foreach($item->getAttributes() as $name=>$value) |
|
824 | - $writer->addAttribute($name,$value); |
|
823 | + foreach ($item->getAttributes() as $name=>$value) |
|
824 | + $writer->addAttribute($name, $value); |
|
825 | 825 | } |
826 | - else if($previousGroup!==null) |
|
826 | + else if ($previousGroup !== null) |
|
827 | 827 | { |
828 | 828 | $writer->renderEndTag(); |
829 | 829 | $writer->writeLine(); |
830 | - $previousGroup=null; |
|
830 | + $previousGroup = null; |
|
831 | 831 | } |
832 | - if($item->getSelected()) |
|
833 | - $writer->addAttribute('selected','selected'); |
|
834 | - $writer->addAttribute('value',$item->getValue()); |
|
832 | + if ($item->getSelected()) |
|
833 | + $writer->addAttribute('selected', 'selected'); |
|
834 | + $writer->addAttribute('value', $item->getValue()); |
|
835 | 835 | $writer->renderBeginTag('option'); |
836 | 836 | $writer->write(THttpUtility::htmlEncode($item->getText())); |
837 | 837 | $writer->renderEndTag(); |
838 | 838 | $writer->writeLine(); |
839 | 839 | } |
840 | 840 | } |
841 | - if($previousGroup!==null) |
|
841 | + if ($previousGroup !== null) |
|
842 | 842 | { |
843 | 843 | $writer->renderEndTag(); |
844 | 844 | $writer->writeLine(); |
@@ -858,26 +858,26 @@ discard block |
||
858 | 858 | * @param mixed the data to be formatted |
859 | 859 | * @return string the formatted result |
860 | 860 | */ |
861 | - protected function formatDataValue($formatString,$value) |
|
861 | + protected function formatDataValue($formatString, $value) |
|
862 | 862 | { |
863 | - if($formatString==='') |
|
863 | + if ($formatString === '') |
|
864 | 864 | return TPropertyValue::ensureString($value); |
865 | - else if($formatString[0]==='#') |
|
865 | + else if ($formatString[0] === '#') |
|
866 | 866 | { |
867 | - $expression=strtr(substr($formatString,1),array('{0}'=>'$value')); |
|
867 | + $expression = strtr(substr($formatString, 1), array('{0}'=>'$value')); |
|
868 | 868 | try |
869 | 869 | { |
870 | - if(eval("\$result=$expression;")===false) |
|
870 | + if (eval("\$result=$expression;") === false) |
|
871 | 871 | throw new Exception(''); |
872 | 872 | return $result; |
873 | 873 | } |
874 | - catch(Exception $e) |
|
874 | + catch (Exception $e) |
|
875 | 875 | { |
876 | - throw new TInvalidDataValueException('listcontrol_expression_invalid',get_class($this),$expression,$e->getMessage()); |
|
876 | + throw new TInvalidDataValueException('listcontrol_expression_invalid', get_class($this), $expression, $e->getMessage()); |
|
877 | 877 | } |
878 | 878 | } |
879 | 879 | else |
880 | - return sprintf($formatString,$value); |
|
880 | + return sprintf($formatString, $value); |
|
881 | 881 | } |
882 | 882 | } |
883 | 883 |
@@ -132,8 +132,9 @@ discard block |
||
132 | 132 | { |
133 | 133 | $page=$this->getPage(); |
134 | 134 | $page->ensureRenderInForm($this); |
135 | - if($this->getIsMultiSelect()) |
|
136 | - $writer->addAttribute('multiple','multiple'); |
|
135 | + if($this->getIsMultiSelect()) { |
|
136 | + $writer->addAttribute('multiple','multiple'); |
|
137 | + } |
|
137 | 138 | if($this->getEnabled(true)) |
138 | 139 | { |
139 | 140 | if($this->getAutoPostBack() |
@@ -142,9 +143,9 @@ discard block |
||
142 | 143 | { |
143 | 144 | $this->renderClientControlScript($writer); |
144 | 145 | } |
146 | + } else if($this->getEnabled()) { |
|
147 | + $writer->addAttribute('disabled','disabled'); |
|
145 | 148 | } |
146 | - else if($this->getEnabled()) |
|
147 | - $writer->addAttribute('disabled','disabled'); |
|
148 | 149 | parent::addAttributesToRender($writer); |
149 | 150 | } |
150 | 151 | |
@@ -209,14 +210,17 @@ discard block |
||
209 | 210 | protected function performDataBinding($data) |
210 | 211 | { |
211 | 212 | $items=$this->getItems(); |
212 | - if(!$this->getAppendDataBoundItems()) |
|
213 | - $items->clear(); |
|
213 | + if(!$this->getAppendDataBoundItems()) { |
|
214 | + $items->clear(); |
|
215 | + } |
|
214 | 216 | $textField=$this->getDataTextField(); |
215 | - if($textField==='') |
|
216 | - $textField=0; |
|
217 | + if($textField==='') { |
|
218 | + $textField=0; |
|
219 | + } |
|
217 | 220 | $valueField=$this->getDataValueField(); |
218 | - if($valueField==='') |
|
219 | - $valueField=1; |
|
221 | + if($valueField==='') { |
|
222 | + $valueField=1; |
|
223 | + } |
|
220 | 224 | $textFormat=$this->getDataTextFormatString(); |
221 | 225 | $groupField=$this->getDataGroupField(); |
222 | 226 | foreach($data as $key=>$object) |
@@ -227,10 +231,10 @@ discard block |
||
227 | 231 | $text=TDataFieldAccessor::getDataFieldValue($object,$textField); |
228 | 232 | $value=TDataFieldAccessor::getDataFieldValue($object,$valueField); |
229 | 233 | $item->setValue($value); |
230 | - if($groupField!=='') |
|
231 | - $item->setAttribute('Group',TDataFieldAccessor::getDataFieldValue($object,$groupField)); |
|
232 | - } |
|
233 | - else |
|
234 | + if($groupField!=='') { |
|
235 | + $item->setAttribute('Group',TDataFieldAccessor::getDataFieldValue($object,$groupField)); |
|
236 | + } |
|
237 | + } else |
|
234 | 238 | { |
235 | 239 | $text=$object; |
236 | 240 | $item->setValue("$key"); |
@@ -243,18 +247,15 @@ discard block |
||
243 | 247 | { |
244 | 248 | $this->setSelectedValue($this->_cachedSelectedValue); |
245 | 249 | $this->resetCachedSelections(); |
246 | - } |
|
247 | - else if($this->_cachedSelectedIndex!==-1) |
|
250 | + } else if($this->_cachedSelectedIndex!==-1) |
|
248 | 251 | { |
249 | 252 | $this->setSelectedIndex($this->_cachedSelectedIndex); |
250 | 253 | $this->resetCachedSelections(); |
251 | - } |
|
252 | - else if($this->_cachedSelectedValues!==null) |
|
254 | + } else if($this->_cachedSelectedValues!==null) |
|
253 | 255 | { |
254 | 256 | $this->setSelectedValues($this->_cachedSelectedValues); |
255 | 257 | $this->resetCachedSelections(); |
256 | - } |
|
257 | - else if($this->_cachedSelectedIndices!==null) |
|
258 | + } else if($this->_cachedSelectedIndices!==null) |
|
258 | 259 | { |
259 | 260 | $this->setSelectedIndices($this->_cachedSelectedIndices); |
260 | 261 | $this->resetCachedSelections(); |
@@ -286,10 +287,11 @@ discard block |
||
286 | 287 | public function saveState() |
287 | 288 | { |
288 | 289 | parent::saveState(); |
289 | - if($this->_items) |
|
290 | - $this->setViewState('Items',$this->_items->saveState(),null); |
|
291 | - else |
|
292 | - $this->clearViewState('Items'); |
|
290 | + if($this->_items) { |
|
291 | + $this->setViewState('Items',$this->_items->saveState(),null); |
|
292 | + } else { |
|
293 | + $this->clearViewState('Items'); |
|
294 | + } |
|
293 | 295 | } |
294 | 296 | |
295 | 297 | /** |
@@ -458,8 +460,9 @@ discard block |
||
458 | 460 | */ |
459 | 461 | public function getItems() |
460 | 462 | { |
461 | - if(!$this->_items) |
|
462 | - $this->_items=$this->createListItemCollection(); |
|
463 | + if(!$this->_items) { |
|
464 | + $this->_items=$this->createListItemCollection(); |
|
465 | + } |
|
463 | 466 | return $this->_items; |
464 | 467 | } |
465 | 468 | |
@@ -471,9 +474,10 @@ discard block |
||
471 | 474 | if($this->_items) |
472 | 475 | { |
473 | 476 | $n=$this->_items->getCount(); |
474 | - for($i=0;$i<$n;++$i) |
|
475 | - if($this->_items->itemAt($i)->getSelected()) |
|
477 | + for($i=0;$i<$n;++$i) { |
|
478 | + if($this->_items->itemAt($i)->getSelected()) |
|
476 | 479 | return $i; |
480 | + } |
|
477 | 481 | } |
478 | 482 | return -1; |
479 | 483 | } |
@@ -483,17 +487,20 @@ discard block |
||
483 | 487 | */ |
484 | 488 | public function setSelectedIndex($index) |
485 | 489 | { |
486 | - if(($index=TPropertyValue::ensureInteger($index))<0) |
|
487 | - $index=-1; |
|
490 | + if(($index=TPropertyValue::ensureInteger($index))<0) { |
|
491 | + $index=-1; |
|
492 | + } |
|
488 | 493 | if($this->_items) |
489 | 494 | { |
490 | 495 | $this->clearSelection(); |
491 | - if($index>=0 && $index<$this->_items->getCount()) |
|
492 | - $this->_items->itemAt($index)->setSelected(true); |
|
496 | + if($index>=0 && $index<$this->_items->getCount()) { |
|
497 | + $this->_items->itemAt($index)->setSelected(true); |
|
498 | + } |
|
493 | 499 | } |
494 | 500 | $this->_cachedSelectedIndex=$index; |
495 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
496 | - $this->getAdapter()->setSelectedIndex($index); |
|
501 | + if($this->getAdapter() instanceof IListControlAdapter) { |
|
502 | + $this->getAdapter()->setSelectedIndex($index); |
|
503 | + } |
|
497 | 504 | } |
498 | 505 | |
499 | 506 | /** |
@@ -505,9 +512,10 @@ discard block |
||
505 | 512 | if($this->_items) |
506 | 513 | { |
507 | 514 | $n=$this->_items->getCount(); |
508 | - for($i=0;$i<$n;++$i) |
|
509 | - if($this->_items->itemAt($i)->getSelected()) |
|
515 | + for($i=0;$i<$n;++$i) { |
|
516 | + if($this->_items->itemAt($i)->getSelected()) |
|
510 | 517 | $selections[]=$i; |
518 | + } |
|
511 | 519 | } |
512 | 520 | return $selections; |
513 | 521 | } |
@@ -525,17 +533,19 @@ discard block |
||
525 | 533 | $n=$this->_items->getCount(); |
526 | 534 | foreach($indices as $index) |
527 | 535 | { |
528 | - if($index>=0 && $index<$n) |
|
529 | - $this->_items->itemAt($index)->setSelected(true); |
|
536 | + if($index>=0 && $index<$n) { |
|
537 | + $this->_items->itemAt($index)->setSelected(true); |
|
538 | + } |
|
530 | 539 | } |
531 | 540 | } |
532 | 541 | $this->_cachedSelectedIndices=$indices; |
542 | + } else { |
|
543 | + throw new TNotSupportedException('listcontrol_multiselect_unsupported',get_class($this)); |
|
533 | 544 | } |
534 | - else |
|
535 | - throw new TNotSupportedException('listcontrol_multiselect_unsupported',get_class($this)); |
|
536 | 545 | |
537 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
538 | - $this->getAdapter()->setSelectedIndices($indices); |
|
546 | + if($this->getAdapter() instanceof IListControlAdapter) { |
|
547 | + $this->getAdapter()->setSelectedIndices($indices); |
|
548 | + } |
|
539 | 549 | } |
540 | 550 | |
541 | 551 | /** |
@@ -543,10 +553,11 @@ discard block |
||
543 | 553 | */ |
544 | 554 | public function getSelectedItem() |
545 | 555 | { |
546 | - if(($index=$this->getSelectedIndex())>=0) |
|
547 | - return $this->_items->itemAt($index); |
|
548 | - else |
|
549 | - return null; |
|
556 | + if(($index=$this->getSelectedIndex())>=0) { |
|
557 | + return $this->_items->itemAt($index); |
|
558 | + } else { |
|
559 | + return null; |
|
560 | + } |
|
550 | 561 | } |
551 | 562 | |
552 | 563 | /** |
@@ -594,19 +605,20 @@ discard block |
||
594 | 605 | { |
595 | 606 | if($this->_items) |
596 | 607 | { |
597 | - if($value===null) |
|
598 | - $this->clearSelection(); |
|
599 | - else if(($item=$this->_items->findItemByValue($value))!==null) |
|
608 | + if($value===null) { |
|
609 | + $this->clearSelection(); |
|
610 | + } else if(($item=$this->_items->findItemByValue($value))!==null) |
|
600 | 611 | { |
601 | 612 | $this->clearSelection(); |
602 | 613 | $item->setSelected(true); |
614 | + } else { |
|
615 | + $this->clearSelection(); |
|
603 | 616 | } |
604 | - else |
|
605 | - $this->clearSelection(); |
|
606 | 617 | } |
607 | 618 | $this->_cachedSelectedValue=$value; |
608 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
609 | - $this->getAdapter()->setSelectedValue($value); |
|
619 | + if($this->getAdapter() instanceof IListControlAdapter) { |
|
620 | + $this->getAdapter()->setSelectedValue($value); |
|
621 | + } |
|
610 | 622 | } |
611 | 623 | |
612 | 624 | |
@@ -620,8 +632,9 @@ discard block |
||
620 | 632 | { |
621 | 633 | foreach($this->_items as $item) |
622 | 634 | { |
623 | - if($item->getSelected()) |
|
624 | - $values[]=$item->getValue(); |
|
635 | + if($item->getSelected()) { |
|
636 | + $values[]=$item->getValue(); |
|
637 | + } |
|
625 | 638 | } |
626 | 639 | } |
627 | 640 | return $values; |
@@ -638,21 +651,24 @@ discard block |
||
638 | 651 | { |
639 | 652 | $this->clearSelection(); |
640 | 653 | $lookup=array(); |
641 | - foreach($this->_items as $item) |
|
642 | - $lookup[$item->getValue()]=$item; |
|
654 | + foreach($this->_items as $item) { |
|
655 | + $lookup[$item->getValue()]=$item; |
|
656 | + } |
|
643 | 657 | foreach($values as $value) |
644 | 658 | { |
645 | - if(isset($lookup["$value"])) |
|
646 | - $lookup["$value"]->setSelected(true); |
|
659 | + if(isset($lookup["$value"])) { |
|
660 | + $lookup["$value"]->setSelected(true); |
|
661 | + } |
|
647 | 662 | } |
648 | 663 | } |
649 | 664 | $this->_cachedSelectedValues=$values; |
665 | + } else { |
|
666 | + throw new TNotSupportedException('listcontrol_multiselect_unsupported',get_class($this)); |
|
650 | 667 | } |
651 | - else |
|
652 | - throw new TNotSupportedException('listcontrol_multiselect_unsupported',get_class($this)); |
|
653 | 668 | |
654 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
655 | - $this->getAdapter()->setSelectedValues($values); |
|
669 | + if($this->getAdapter() instanceof IListControlAdapter) { |
|
670 | + $this->getAdapter()->setSelectedValues($values); |
|
671 | + } |
|
656 | 672 | } |
657 | 673 | |
658 | 674 | /** |
@@ -678,12 +694,14 @@ discard block |
||
678 | 694 | { |
679 | 695 | if($this->_items) |
680 | 696 | { |
681 | - foreach($this->_items as $item) |
|
682 | - $item->setSelected(false); |
|
697 | + foreach($this->_items as $item) { |
|
698 | + $item->setSelected(false); |
|
699 | + } |
|
683 | 700 | } |
684 | 701 | |
685 | - if($this->getAdapter() instanceof IListControlAdapter) |
|
686 | - $this->getAdapter()->clearSelection(); |
|
702 | + if($this->getAdapter() instanceof IListControlAdapter) { |
|
703 | + $this->getAdapter()->clearSelection(); |
|
704 | + } |
|
687 | 705 | } |
688 | 706 | |
689 | 707 | /** |
@@ -772,8 +790,9 @@ discard block |
||
772 | 790 | { |
773 | 791 | $text=$this->getPromptText(); |
774 | 792 | $value=$this->getPromptValue(); |
775 | - if($value==='') |
|
776 | - $value=$text; |
|
793 | + if($value==='') { |
|
794 | + $value=$text; |
|
795 | + } |
|
777 | 796 | if($value!=='') |
778 | 797 | { |
779 | 798 | $writer->addAttribute('value',$value); |
@@ -820,17 +839,18 @@ discard block |
||
820 | 839 | $previousGroup=$group; |
821 | 840 | } |
822 | 841 | } |
823 | - foreach($item->getAttributes() as $name=>$value) |
|
824 | - $writer->addAttribute($name,$value); |
|
825 | - } |
|
826 | - else if($previousGroup!==null) |
|
842 | + foreach($item->getAttributes() as $name=>$value) { |
|
843 | + $writer->addAttribute($name,$value); |
|
844 | + } |
|
845 | + } else if($previousGroup!==null) |
|
827 | 846 | { |
828 | 847 | $writer->renderEndTag(); |
829 | 848 | $writer->writeLine(); |
830 | 849 | $previousGroup=null; |
831 | 850 | } |
832 | - if($item->getSelected()) |
|
833 | - $writer->addAttribute('selected','selected'); |
|
851 | + if($item->getSelected()) { |
|
852 | + $writer->addAttribute('selected','selected'); |
|
853 | + } |
|
834 | 854 | $writer->addAttribute('value',$item->getValue()); |
835 | 855 | $writer->renderBeginTag('option'); |
836 | 856 | $writer->write(THttpUtility::htmlEncode($item->getText())); |
@@ -860,24 +880,24 @@ discard block |
||
860 | 880 | */ |
861 | 881 | protected function formatDataValue($formatString,$value) |
862 | 882 | { |
863 | - if($formatString==='') |
|
864 | - return TPropertyValue::ensureString($value); |
|
865 | - else if($formatString[0]==='#') |
|
883 | + if($formatString==='') { |
|
884 | + return TPropertyValue::ensureString($value); |
|
885 | + } else if($formatString[0]==='#') |
|
866 | 886 | { |
867 | 887 | $expression=strtr(substr($formatString,1),array('{0}'=>'$value')); |
868 | 888 | try |
869 | 889 | { |
870 | - if(eval("\$result=$expression;")===false) |
|
871 | - throw new Exception(''); |
|
890 | + if(eval("\$result=$expression;")===false) { |
|
891 | + throw new Exception(''); |
|
892 | + } |
|
872 | 893 | return $result; |
873 | - } |
|
874 | - catch(Exception $e) |
|
894 | + } catch(Exception $e) |
|
875 | 895 | { |
876 | 896 | throw new TInvalidDataValueException('listcontrol_expression_invalid',get_class($this),$expression,$e->getMessage()); |
877 | 897 | } |
898 | + } else { |
|
899 | + return sprintf($formatString,$value); |
|
878 | 900 | } |
879 | - else |
|
880 | - return sprintf($formatString,$value); |
|
881 | 901 | } |
882 | 902 | } |
883 | 903 |
@@ -164,6 +164,7 @@ |
||
164 | 164 | |
165 | 165 | /** |
166 | 166 | * @param TListControl control to validate |
167 | + * @param TControl $control |
|
167 | 168 | * @return array number of selected values and its values. |
168 | 169 | */ |
169 | 170 | protected function getSelection($control) |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function getMinSelection() |
78 | 78 | { |
79 | - return $this->getViewState('MinSelection',-1); |
|
79 | + return $this->getViewState('MinSelection', -1); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function setMinSelection($value) |
86 | 86 | { |
87 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
88 | - $value=-1; |
|
89 | - $this->setViewState('MinSelection',$value,-1); |
|
87 | + if (($value = TPropertyValue::ensureInteger($value)) < 0) |
|
88 | + $value = -1; |
|
89 | + $this->setViewState('MinSelection', $value, -1); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function getMaxSelection() |
96 | 96 | { |
97 | - return $this->getViewState('MaxSelection',-1); |
|
97 | + return $this->getViewState('MaxSelection', -1); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function setMaxSelection($value) |
104 | 104 | { |
105 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
106 | - $value=-1; |
|
107 | - $this->setViewState('MaxSelection',$value,-1); |
|
105 | + if (($value = TPropertyValue::ensureInteger($value)) < 0) |
|
106 | + $value = -1; |
|
107 | + $this->setViewState('MaxSelection', $value, -1); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function getRequiredSelections() |
115 | 115 | { |
116 | - return $this->getViewState('RequiredSelections',''); |
|
116 | + return $this->getViewState('RequiredSelections', ''); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function setRequiredSelections($value) |
124 | 124 | { |
125 | - $this->setViewState('RequiredSelections',$value,''); |
|
125 | + $this->setViewState('RequiredSelections', $value, ''); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function evaluateIsValid() |
135 | 135 | { |
136 | - $control=$this->getValidationTarget(); |
|
136 | + $control = $this->getValidationTarget(); |
|
137 | 137 | |
138 | 138 | $exists = true; |
139 | 139 | $values = $this->getSelection($control); |
@@ -141,22 +141,22 @@ discard block |
||
141 | 141 | $required = $this->getRequiredValues(); |
142 | 142 | |
143 | 143 | //if required, check the values |
144 | - if(!empty($required)) |
|
144 | + if (!empty($required)) |
|
145 | 145 | { |
146 | - if($count < count($required) ) |
|
146 | + if ($count < count($required)) |
|
147 | 147 | return false; |
148 | - foreach($required as $require) |
|
148 | + foreach ($required as $require) |
|
149 | 149 | $exists = $exists && in_array($require, $values); |
150 | 150 | } |
151 | 151 | |
152 | 152 | $min = $this->getMinSelection(); |
153 | 153 | $max = $this->getMaxSelection(); |
154 | 154 | |
155 | - if($min !== -1 && $max !== -1) |
|
155 | + if ($min !== -1 && $max !== -1) |
|
156 | 156 | return $exists && $count >= $min && $count <= $max; |
157 | - else if($min === -1 && $max !== -1) |
|
157 | + else if ($min === -1 && $max !== -1) |
|
158 | 158 | return $exists && $count <= $max; |
159 | - else if($min !== -1 && $max === -1) |
|
159 | + else if ($min !== -1 && $max === -1) |
|
160 | 160 | return $exists && $count >= $min; |
161 | 161 | else |
162 | 162 | return $exists; |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | $values = array(); |
172 | 172 | |
173 | 173 | //get the data |
174 | - foreach($control->getItems() as $item) |
|
174 | + foreach ($control->getItems() as $item) |
|
175 | 175 | { |
176 | - if($item->getSelected()) |
|
176 | + if ($item->getSelected()) |
|
177 | 177 | $values[] = $item->getValue(); |
178 | 178 | } |
179 | 179 | return $values; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | { |
187 | 187 | $required = array(); |
188 | 188 | $string = $this->getRequiredSelections(); |
189 | - if(!empty($string)) |
|
189 | + if (!empty($string)) |
|
190 | 190 | $required = preg_split('/,\s*/', $string); |
191 | 191 | return $required; |
192 | 192 | } |
@@ -200,22 +200,22 @@ discard block |
||
200 | 200 | $options = parent::getClientScriptOptions(); |
201 | 201 | $control = $this->getValidationTarget(); |
202 | 202 | |
203 | - if(!$control instanceof TListControl) |
|
203 | + if (!$control instanceof TListControl) |
|
204 | 204 | { |
205 | 205 | throw new TConfigurationException( |
206 | 206 | 'listcontrolvalidator_invalid_control', |
207 | - $this->getID(),$this->getControlToValidate(), get_class($control)); |
|
207 | + $this->getID(), $this->getControlToValidate(), get_class($control)); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | $min = $this->getMinSelection(); |
211 | 211 | $max = $this->getMaxSelection(); |
212 | - if($min !== -1) |
|
213 | - $options['Min']= $min; |
|
214 | - if($max !== -1) |
|
215 | - $options['Max']= $max; |
|
212 | + if ($min !== -1) |
|
213 | + $options['Min'] = $min; |
|
214 | + if ($max !== -1) |
|
215 | + $options['Max'] = $max; |
|
216 | 216 | $required = $this->getRequiredSelections(); |
217 | - if(strlen($required) > 0) |
|
218 | - $options['Required']= $required; |
|
217 | + if (strlen($required) > 0) |
|
218 | + $options['Required'] = $required; |
|
219 | 219 | $options['TotalItems'] = $control->getItemCount(); |
220 | 220 | |
221 | 221 | return $options; |
@@ -84,8 +84,9 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function setMinSelection($value) |
86 | 86 | { |
87 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
88 | - $value=-1; |
|
87 | + if(($value=TPropertyValue::ensureInteger($value))<0) { |
|
88 | + $value=-1; |
|
89 | + } |
|
89 | 90 | $this->setViewState('MinSelection',$value,-1); |
90 | 91 | } |
91 | 92 | |
@@ -102,8 +103,9 @@ discard block |
||
102 | 103 | */ |
103 | 104 | public function setMaxSelection($value) |
104 | 105 | { |
105 | - if(($value=TPropertyValue::ensureInteger($value))<0) |
|
106 | - $value=-1; |
|
106 | + if(($value=TPropertyValue::ensureInteger($value))<0) { |
|
107 | + $value=-1; |
|
108 | + } |
|
107 | 109 | $this->setViewState('MaxSelection',$value,-1); |
108 | 110 | } |
109 | 111 | |
@@ -143,23 +145,26 @@ discard block |
||
143 | 145 | //if required, check the values |
144 | 146 | if(!empty($required)) |
145 | 147 | { |
146 | - if($count < count($required) ) |
|
147 | - return false; |
|
148 | - foreach($required as $require) |
|
149 | - $exists = $exists && in_array($require, $values); |
|
148 | + if($count < count($required) ) { |
|
149 | + return false; |
|
150 | + } |
|
151 | + foreach($required as $require) { |
|
152 | + $exists = $exists && in_array($require, $values); |
|
153 | + } |
|
150 | 154 | } |
151 | 155 | |
152 | 156 | $min = $this->getMinSelection(); |
153 | 157 | $max = $this->getMaxSelection(); |
154 | 158 | |
155 | - if($min !== -1 && $max !== -1) |
|
156 | - return $exists && $count >= $min && $count <= $max; |
|
157 | - else if($min === -1 && $max !== -1) |
|
158 | - return $exists && $count <= $max; |
|
159 | - else if($min !== -1 && $max === -1) |
|
160 | - return $exists && $count >= $min; |
|
161 | - else |
|
162 | - return $exists; |
|
159 | + if($min !== -1 && $max !== -1) { |
|
160 | + return $exists && $count >= $min && $count <= $max; |
|
161 | + } else if($min === -1 && $max !== -1) { |
|
162 | + return $exists && $count <= $max; |
|
163 | + } else if($min !== -1 && $max === -1) { |
|
164 | + return $exists && $count >= $min; |
|
165 | + } else { |
|
166 | + return $exists; |
|
167 | + } |
|
163 | 168 | } |
164 | 169 | |
165 | 170 | /** |
@@ -173,8 +178,9 @@ discard block |
||
173 | 178 | //get the data |
174 | 179 | foreach($control->getItems() as $item) |
175 | 180 | { |
176 | - if($item->getSelected()) |
|
177 | - $values[] = $item->getValue(); |
|
181 | + if($item->getSelected()) { |
|
182 | + $values[] = $item->getValue(); |
|
183 | + } |
|
178 | 184 | } |
179 | 185 | return $values; |
180 | 186 | } |
@@ -186,8 +192,9 @@ discard block |
||
186 | 192 | { |
187 | 193 | $required = array(); |
188 | 194 | $string = $this->getRequiredSelections(); |
189 | - if(!empty($string)) |
|
190 | - $required = preg_split('/,\s*/', $string); |
|
195 | + if(!empty($string)) { |
|
196 | + $required = preg_split('/,\s*/', $string); |
|
197 | + } |
|
191 | 198 | return $required; |
192 | 199 | } |
193 | 200 | |
@@ -209,13 +216,16 @@ discard block |
||
209 | 216 | |
210 | 217 | $min = $this->getMinSelection(); |
211 | 218 | $max = $this->getMaxSelection(); |
212 | - if($min !== -1) |
|
213 | - $options['Min']= $min; |
|
214 | - if($max !== -1) |
|
215 | - $options['Max']= $max; |
|
219 | + if($min !== -1) { |
|
220 | + $options['Min']= $min; |
|
221 | + } |
|
222 | + if($max !== -1) { |
|
223 | + $options['Max']= $max; |
|
224 | + } |
|
216 | 225 | $required = $this->getRequiredSelections(); |
217 | - if(strlen($required) > 0) |
|
218 | - $options['Required']= $required; |
|
226 | + if(strlen($required) > 0) { |
|
227 | + $options['Required']= $required; |
|
228 | + } |
|
219 | 229 | $options['TotalItems'] = $control->getItemCount(); |
220 | 230 | |
221 | 231 | return $options; |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * TListControlValidator class file |
|
4 | - * |
|
5 | - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
|
6 | - * @link https://github.com/pradosoft/prado |
|
7 | - * @copyright Copyright © 2005-2015 The PRADO Group |
|
8 | - * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | - * @package System.Web.UI.WebControls |
|
10 | - */ |
|
3 | + * TListControlValidator class file |
|
4 | + * |
|
5 | + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
|
6 | + * @link https://github.com/pradosoft/prado |
|
7 | + * @copyright Copyright © 2005-2015 The PRADO Group |
|
8 | + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9 | + * @package System.Web.UI.WebControls |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Using TBaseValidator class |
@@ -92,6 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @param boolean whether the item is enabled |
95 | + * @param boolean $value |
|
95 | 96 | */ |
96 | 97 | public function setEnabled($value) |
97 | 98 | { |
@@ -108,6 +109,7 @@ discard block |
||
108 | 109 | |
109 | 110 | /** |
110 | 111 | * @param boolean whether the item is selected |
112 | + * @param boolean $value |
|
111 | 113 | */ |
112 | 114 | public function setSelected($value) |
113 | 115 | { |
@@ -166,6 +168,7 @@ discard block |
||
166 | 168 | |
167 | 169 | /** |
168 | 170 | * @param string name of the attribute |
171 | + * @param string $name |
|
169 | 172 | * @return boolean whether the named attribute exists |
170 | 173 | */ |
171 | 174 | public function hasAttribute($name) |
@@ -174,6 +177,7 @@ discard block |
||
174 | 177 | } |
175 | 178 | |
176 | 179 | /** |
180 | + * @param string $name |
|
177 | 181 | * @return string the named attribute value, null if attribute does not exist |
178 | 182 | */ |
179 | 183 | public function getAttribute($name) |
@@ -184,6 +188,7 @@ discard block |
||
184 | 188 | /** |
185 | 189 | * @param string attribute name |
186 | 190 | * @param string value of the attribute |
191 | + * @param string $name |
|
187 | 192 | */ |
188 | 193 | public function setAttribute($name,$value) |
189 | 194 | { |
@@ -28,23 +28,23 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * @var TMap list of custom attributes |
30 | 30 | */ |
31 | - private $_attributes=null; |
|
31 | + private $_attributes = null; |
|
32 | 32 | /** |
33 | 33 | * @var string text of the item |
34 | 34 | */ |
35 | - private $_text=''; |
|
35 | + private $_text = ''; |
|
36 | 36 | /** |
37 | 37 | * @var string value of the item |
38 | 38 | */ |
39 | - private $_value=''; |
|
39 | + private $_value = ''; |
|
40 | 40 | /** |
41 | 41 | * @var boolean whether the item is enabled |
42 | 42 | */ |
43 | - private $_enabled=true; |
|
43 | + private $_enabled = true; |
|
44 | 44 | /** |
45 | 45 | * @var boolean whether the item is selected |
46 | 46 | */ |
47 | - private $_selected=false; |
|
47 | + private $_selected = false; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Constructor. |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param boolean whether the item is enabled |
54 | 54 | * @param boolean whether the item is selected |
55 | 55 | */ |
56 | - public function __construct($text='',$value='',$enabled=true,$selected=false) |
|
56 | + public function __construct($text = '', $value = '', $enabled = true, $selected = false) |
|
57 | 57 | { |
58 | 58 | $this->setText($text); |
59 | 59 | $this->setValue($value); |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | protected function __getZappableSleepProps(&$exprops) |
71 | 71 | { |
72 | 72 | parent::__getZappableSleepProps($exprops); |
73 | - if ($this->_attributes===null) |
|
73 | + if ($this->_attributes === null) |
|
74 | 74 | $exprops[] = "\0TListItem\0_attributes"; |
75 | - if($this->_text==='') |
|
75 | + if ($this->_text === '') |
|
76 | 76 | $exprops[] = "\0TListItem\0_text"; |
77 | - if($this->_value==='') |
|
77 | + if ($this->_value === '') |
|
78 | 78 | $exprops[] = "\0TListItem\0_value"; |
79 | - if ($this->_enabled===true) |
|
79 | + if ($this->_enabled === true) |
|
80 | 80 | $exprops[] = "\0TListItem\0_enabled"; |
81 | - if ($this->_selected===false) |
|
81 | + if ($this->_selected === false) |
|
82 | 82 | $exprops[] = "\0TListItem\0_selected"; |
83 | 83 | } |
84 | 84 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function setEnabled($value) |
97 | 97 | { |
98 | - $this->_enabled=TPropertyValue::ensureBoolean($value); |
|
98 | + $this->_enabled = TPropertyValue::ensureBoolean($value); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function setSelected($value) |
113 | 113 | { |
114 | - $this->_selected=TPropertyValue::ensureBoolean($value); |
|
114 | + $this->_selected = TPropertyValue::ensureBoolean($value); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function getText() |
121 | 121 | { |
122 | - return $this->_text===''?$this->_value:$this->_text; |
|
122 | + return $this->_text === '' ? $this->_value : $this->_text; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function setText($value) |
129 | 129 | { |
130 | - $this->_text=TPropertyValue::ensureString($value); |
|
130 | + $this->_text = TPropertyValue::ensureString($value); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function getValue() |
137 | 137 | { |
138 | - return $this->_value===''?$this->_text:$this->_value; |
|
138 | + return $this->_value === '' ? $this->_text : $this->_value; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function setValue($value) |
145 | 145 | { |
146 | - $this->_value=TPropertyValue::ensureString($value); |
|
146 | + $this->_value = TPropertyValue::ensureString($value); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function getAttributes() |
153 | 153 | { |
154 | - if(!$this->_attributes) |
|
155 | - $this->_attributes=new TAttributeCollection; |
|
154 | + if (!$this->_attributes) |
|
155 | + $this->_attributes = new TAttributeCollection; |
|
156 | 156 | return $this->_attributes; |
157 | 157 | } |
158 | 158 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function getHasAttributes() |
163 | 163 | { |
164 | - return $this->_attributes && $this->_attributes->getCount()>0; |
|
164 | + return $this->_attributes && $this->_attributes->getCount() > 0; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function hasAttribute($name) |
172 | 172 | { |
173 | - return $this->_attributes?$this->_attributes->contains($name):false; |
|
173 | + return $this->_attributes ? $this->_attributes->contains($name) : false; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -178,16 +178,16 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function getAttribute($name) |
180 | 180 | { |
181 | - return $this->_attributes?$this->_attributes->itemAt($name):null; |
|
181 | + return $this->_attributes ? $this->_attributes->itemAt($name) : null; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | 185 | * @param string attribute name |
186 | 186 | * @param string value of the attribute |
187 | 187 | */ |
188 | - public function setAttribute($name,$value) |
|
188 | + public function setAttribute($name, $value) |
|
189 | 189 | { |
190 | - $this->getAttributes()->add($name,$value); |
|
190 | + $this->getAttributes()->add($name, $value); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function removeAttribute($name) |
199 | 199 | { |
200 | - return $this->_attributes?$this->_attributes->remove($name):null; |
|
200 | + return $this->_attributes ? $this->_attributes->remove($name) : null; |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 |
@@ -70,16 +70,21 @@ discard block |
||
70 | 70 | protected function __getZappableSleepProps(&$exprops) |
71 | 71 | { |
72 | 72 | parent::__getZappableSleepProps($exprops); |
73 | - if ($this->_attributes===null) |
|
74 | - $exprops[] = "\0TListItem\0_attributes"; |
|
75 | - if($this->_text==='') |
|
76 | - $exprops[] = "\0TListItem\0_text"; |
|
77 | - if($this->_value==='') |
|
78 | - $exprops[] = "\0TListItem\0_value"; |
|
79 | - if ($this->_enabled===true) |
|
80 | - $exprops[] = "\0TListItem\0_enabled"; |
|
81 | - if ($this->_selected===false) |
|
82 | - $exprops[] = "\0TListItem\0_selected"; |
|
73 | + if ($this->_attributes===null) { |
|
74 | + $exprops[] = "\0TListItem\0_attributes"; |
|
75 | + } |
|
76 | + if($this->_text==='') { |
|
77 | + $exprops[] = "\0TListItem\0_text"; |
|
78 | + } |
|
79 | + if($this->_value==='') { |
|
80 | + $exprops[] = "\0TListItem\0_value"; |
|
81 | + } |
|
82 | + if ($this->_enabled===true) { |
|
83 | + $exprops[] = "\0TListItem\0_enabled"; |
|
84 | + } |
|
85 | + if ($this->_selected===false) { |
|
86 | + $exprops[] = "\0TListItem\0_selected"; |
|
87 | + } |
|
83 | 88 | } |
84 | 89 | |
85 | 90 | /** |
@@ -151,8 +156,9 @@ discard block |
||
151 | 156 | */ |
152 | 157 | public function getAttributes() |
153 | 158 | { |
154 | - if(!$this->_attributes) |
|
155 | - $this->_attributes=new TAttributeCollection; |
|
159 | + if(!$this->_attributes) { |
|
160 | + $this->_attributes=new TAttributeCollection; |
|
161 | + } |
|
156 | 162 | return $this->_attributes; |
157 | 163 | } |
158 | 164 |