Completed
Push — scrutinizer ( c2ef4a )
by Fabio
21:50
created
framework/Web/UI/TTemplateControlInheritable.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
 	/**
77 77
 	 * This method creates the template object for the given class
78 78
 	 *
79
-	 * @param string $p_class The class to create the template from
79
+	 * @param string $parentClass
80 80
 	 * @return void
81 81
 	 * @throws TConfigurationException if a template control directive is invalid
82 82
 	 */
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
 	 */	
44 44
 	public function createChildControls()
45 45
 	{
46
-		if(null === ($_template = $this->getTemplate())) {
46
+		if (null === ($_template = $this->getTemplate())) {
47 47
 			return $this->doCreateChildControlsFor(get_class($this));
48 48
 		}
49 49
 
50
-		foreach($_template->getDirective() as $_name => $_value) {
51
-			if(!is_string($_value)) {
50
+		foreach ($_template->getDirective() as $_name => $_value) {
51
+			if (!is_string($_value)) {
52 52
 				throw new TConfigurationException('templatecontrol_directive_invalid', get_class($this), $name);
53 53
 			}
54 54
 			
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function doCreateChildControlsFor($parentClass)
68 68
 	{
69
-		if(false !== ($_parentClass = get_parent_class($parentClass)) && 'TTemplateControl' != $_parentClass) {
69
+		if (false !== ($_parentClass = get_parent_class($parentClass)) && 'TTemplateControl' != $_parentClass) {
70 70
 			$this->doCreateChildControlsFor($_parentClass);
71 71
 		}
72 72
 
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	public function doTemplateForClass($parentClass)
84 84
 	{
85
-		if(null !== ($_template = $this->getService()->getTemplateManager()->getTemplateByClassName($parentClass))) {
86
-			foreach($_template->getDirective() as $_name => $_value) {
87
-				if(!is_string($_value)) {
85
+		if (null !== ($_template = $this->getService()->getTemplateManager()->getTemplateByClassName($parentClass))) {
86
+			foreach ($_template->getDirective() as $_name => $_value) {
87
+				if (!is_string($_value)) {
88 88
 					throw new TConfigurationException('templatecontrol_directive_invalid', get_class(this), $_name);
89 89
 				}
90 90
 				
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public function getIsSourceTemplateControl()
107 107
 	{
108
-		if(null !== ($_template = $this->getTemplate())) {
108
+		if (null !== ($_template = $this->getTemplate())) {
109 109
 			return $_template->getIsSourceTemplate();
110 110
 		}
111 111
 
Please login to merge, or discard this patch.
framework/Web/UI/TTemplateManager.php 4 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -69,6 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
 	/**
71 71
 	 * Loads the template from the specified file.
72
+	 * @param string $fileName
72 73
 	 * @return ITemplate template parsed from the specified file, null if the file doesn't exist.
73 74
 	 */
74 75
 	public function getTemplateByFileName($fileName)
@@ -415,6 +416,7 @@  discard block
 block discarded – undo
415 416
 	 * @param TControl control to be configured
416 417
 	 * @param string property name
417 418
 	 * @param mixed property initial value
419
+	 * @param TControl $control
418 420
 	 */
419 421
 	protected function configureControl($control,$name,$value)
420 422
 	{
@@ -431,6 +433,7 @@  discard block
 block discarded – undo
431 433
 	 * @param TComponent component to be configured
432 434
 	 * @param string property name
433 435
 	 * @param mixed property initial value
436
+	 * @param TComponent $component
434 437
 	 */
435 438
 	protected function configureComponent($component,$name,$value)
436 439
 	{
@@ -817,6 +820,8 @@  discard block
 block discarded – undo
817 820
 	/**
818 821
 	 * Parses the attributes of a tag from a string.
819 822
 	 * @param string the string to be parsed.
823
+	 * @param string $str
824
+	 * @param string $offset
820 825
 	 * @return array attribute values indexed by names.
821 826
 	 */
822 827
 	protected function parseAttributes($str,$offset)
@@ -851,6 +856,9 @@  discard block
 block discarded – undo
851 856
 		return $attributes;
852 857
 	}
853 858
 
859
+	/**
860
+	 * @param string $content
861
+	 */
854 862
 	protected function parseTemplateProperty($content,$offset)
855 863
 	{
856 864
 		$line=$this->_startingLine+count(explode("\n",substr($this->_content,0,$offset)))-1;
@@ -860,6 +868,7 @@  discard block
 block discarded – undo
860 868
 	/**
861 869
 	 * Parses a single attribute.
862 870
 	 * @param string the string to be parsed.
871
+	 * @param string $value
863 872
 	 * @return array attribute initialization
864 873
 	 */
865 874
 	protected function parseAttribute($value)
@@ -1002,6 +1011,8 @@  discard block
 block discarded – undo
1002 1011
 	 * @param Exception template exception
1003 1012
 	 * @param int line number
1004 1013
 	 * @param string template string if no source file is used
1014
+	 * @param Exception $e
1015
+	 * @param integer $line
1005 1016
 	 */
1006 1017
 	protected function handleException($e,$line,$input=null)
1007 1018
 	{
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 {
168 168
 	/**
169 169
 	 *  '<!--.*?--!>' - template comments
170
-		 *  '<!--.*?-->'  - HTML comments
170
+	 *  '<!--.*?-->'  - HTML comments
171 171
 	 *	'<\/?com:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/?>' - component tags
172 172
 	 *	'<\/?prop:([\w\.]+)\s*>'  - property tags
173 173
 	 *	'<%@\s*((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?")*)\s*%>'  - directives
@@ -1080,15 +1080,15 @@  discard block
 block discarded – undo
1080 1080
 	  $component=new ReflectionClass('TComponent');
1081 1081
 	  $behaviors=$component->getStaticProperties();
1082 1082
 	  if(!isset($behaviors['_um']))
1083
-	    return false;
1083
+		return false;
1084 1084
 	  foreach($behaviors['_um'] as $name=>$list)
1085 1085
 	  {
1086
-	    if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue;
1087
-	    foreach($list as $param)
1088
-	    {
1089
-	      if(method_exists($param->getBehavior(),$method))
1090
-	        return true;
1091
-	    }
1086
+		if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue;
1087
+		foreach($list as $param)
1088
+		{
1089
+		  if(method_exists($param->getBehavior(),$method))
1090
+			return true;
1091
+		}
1092 1092
 	  }
1093 1093
 	  return false;
1094 1094
 	}
Please login to merge, or discard this patch.
Spacing   +428 added lines, -428 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * Template file extension
41 41
 	 */
42
-	const TEMPLATE_FILE_EXT='.tpl';
42
+	const TEMPLATE_FILE_EXT = '.tpl';
43 43
 	/**
44 44
 	 * Prefix of the cache variable name for storing parsed templates
45 45
 	 */
46
-	const TEMPLATE_CACHE_PREFIX='prado:template:';
46
+	const TEMPLATE_CACHE_PREFIX = 'prado:template:';
47 47
 
48 48
 	/**
49 49
 	 * Initializes the module.
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function getTemplateByClassName($className)
64 64
 	{
65
-		$class=new ReflectionClass($className);
66
-		$tplFile=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$className.self::TEMPLATE_FILE_EXT;
65
+		$class = new ReflectionClass($className);
66
+		$tplFile = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $className . self::TEMPLATE_FILE_EXT;
67 67
 		return $this->getTemplateByFileName($tplFile);
68 68
 	}
69 69
 
@@ -73,38 +73,38 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public function getTemplateByFileName($fileName)
75 75
 	{
76
-		if(($fileName=$this->getLocalizedTemplate($fileName))!==null)
76
+		if (($fileName = $this->getLocalizedTemplate($fileName)) !== null)
77 77
 		{
78
-			Prado::trace("Loading template $fileName",'System.Web.UI.TTemplateManager');
79
-			if(($cache=$this->getApplication()->getCache())===null)
80
-				return new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName);
78
+			Prado::trace("Loading template $fileName", 'System.Web.UI.TTemplateManager');
79
+			if (($cache = $this->getApplication()->getCache()) === null)
80
+				return new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName);
81 81
 			else
82 82
 			{
83
-				$array=$cache->get(self::TEMPLATE_CACHE_PREFIX.$fileName);
84
-				if(is_array($array))
83
+				$array = $cache->get(self::TEMPLATE_CACHE_PREFIX . $fileName);
84
+				if (is_array($array))
85 85
 				{
86
-					list($template,$timestamps)=$array;
87
-					if($this->getApplication()->getMode()===TApplicationMode::Performance)
86
+					list($template, $timestamps) = $array;
87
+					if ($this->getApplication()->getMode() === TApplicationMode::Performance)
88 88
 						return $template;
89
-					$cacheValid=true;
90
-					foreach($timestamps as $tplFile=>$timestamp)
89
+					$cacheValid = true;
90
+					foreach ($timestamps as $tplFile=>$timestamp)
91 91
 					{
92
-						if(!is_file($tplFile) || filemtime($tplFile)>$timestamp)
92
+						if (!is_file($tplFile) || filemtime($tplFile) > $timestamp)
93 93
 						{
94
-							$cacheValid=false;
94
+							$cacheValid = false;
95 95
 							break;
96 96
 						}
97 97
 					}
98
-					if($cacheValid)
98
+					if ($cacheValid)
99 99
 						return $template;
100 100
 				}
101
-				$template=new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName);
102
-				$includedFiles=$template->getIncludedFiles();
103
-				$timestamps=array();
104
-				$timestamps[$fileName]=filemtime($fileName);
105
-				foreach($includedFiles as $includedFile)
106
-					$timestamps[$includedFile]=filemtime($includedFile);
107
-				$cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName,array($template,$timestamps));
101
+				$template = new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName);
102
+				$includedFiles = $template->getIncludedFiles();
103
+				$timestamps = array();
104
+				$timestamps[$fileName] = filemtime($fileName);
105
+				foreach ($includedFiles as $includedFile)
106
+					$timestamps[$includedFile] = filemtime($includedFile);
107
+				$cache->set(self::TEMPLATE_CACHE_PREFIX . $fileName, array($template, $timestamps));
108 108
 				return $template;
109 109
 			}
110 110
 		}
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	protected function getLocalizedTemplate($filename)
121 121
 	{
122
-		if(($app=$this->getApplication()->getGlobalization(false))===null)
123
-			return is_file($filename)?$filename:null;
124
-		foreach($app->getLocalizedResource($filename) as $file)
122
+		if (($app = $this->getApplication()->getGlobalization(false)) === null)
123
+			return is_file($filename) ? $filename : null;
124
+		foreach ($app->getLocalizedResource($filename) as $file)
125 125
 		{
126
-			if(($file=realpath($file))!==false && is_file($file))
126
+			if (($file = realpath($file)) !== false && is_file($file))
127 127
 				return $file;
128 128
 		}
129 129
 		return null;
@@ -174,26 +174,26 @@  discard block
 block discarded – undo
174 174
 	 *	'<%[%#~\/\\$=\\[](.*?)%>'  - expressions
175 175
 	 *  '<prop:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\s*\/>' - group subproperty tags
176 176
 	 */
177
-	const REGEX_RULES='/<!--.*?--!>|<!---.*?--->|<\/?com:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/?>|<\/?prop:([\w\.]+)\s*>|<%@\s*((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?")*)\s*%>|<%[%#~\/\\$=\\[](.*?)%>|<prop:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/>/msS';
177
+	const REGEX_RULES = '/<!--.*?--!>|<!---.*?--->|<\/?com:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/?>|<\/?prop:([\w\.]+)\s*>|<%@\s*((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?")*)\s*%>|<%[%#~\/\\$=\\[](.*?)%>|<prop:([\w\.]+)((?:\s*[\w\.]+\s*=\s*\'.*?\'|\s*[\w\.]+\s*=\s*".*?"|\s*[\w\.]+\s*=\s*<%.*?%>)*)\s*\/>/msS';
178 178
 
179 179
 	/**
180 180
 	 * Different configurations of component property/event/attribute
181 181
 	 */
182
-	const CONFIG_DATABIND=0;
183
-	const CONFIG_EXPRESSION=1;
184
-	const CONFIG_ASSET=2;
185
-	const CONFIG_PARAMETER=3;
186
-	const CONFIG_LOCALIZATION=4;
187
-	const CONFIG_TEMPLATE=5;
182
+	const CONFIG_DATABIND = 0;
183
+	const CONFIG_EXPRESSION = 1;
184
+	const CONFIG_ASSET = 2;
185
+	const CONFIG_PARAMETER = 3;
186
+	const CONFIG_LOCALIZATION = 4;
187
+	const CONFIG_TEMPLATE = 5;
188 188
 
189 189
 	/**
190 190
 	 * @var array list of component tags and strings
191 191
 	 */
192
-	private $_tpl=array();
192
+	private $_tpl = array();
193 193
 	/**
194 194
 	 * @var array list of directive settings
195 195
 	 */
196
-	private $_directive=array();
196
+	private $_directive = array();
197 197
 	/**
198 198
 	 * @var string context path
199 199
 	 */
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 	/**
202 202
 	 * @var string template file path (if available)
203 203
 	 */
204
-	private $_tplFile=null;
204
+	private $_tplFile = null;
205 205
 	/**
206 206
 	 * @var integer the line number that parsing starts from (internal use)
207 207
 	 */
208
-	private $_startingLine=0;
208
+	private $_startingLine = 0;
209 209
 	/**
210 210
 	 * @var string template content to be parsed
211 211
 	 */
@@ -213,15 +213,15 @@  discard block
 block discarded – undo
213 213
 	/**
214 214
 	 * @var boolean whether this template is a source template
215 215
 	 */
216
-	private $_sourceTemplate=true;
216
+	private $_sourceTemplate = true;
217 217
 	/**
218 218
 	 * @var string hash code of the template
219 219
 	 */
220
-	private $_hashCode='';
221
-	private $_tplControl=null;
222
-	private $_includedFiles=array();
223
-	private $_includeAtLine=array();
224
-	private $_includeLines=array();
220
+	private $_hashCode = '';
221
+	private $_tplControl = null;
222
+	private $_includedFiles = array();
223
+	private $_includeAtLine = array();
224
+	private $_includeLines = array();
225 225
 
226 226
 
227 227
 	/**
@@ -234,16 +234,16 @@  discard block
 block discarded – undo
234 234
 	 * @param boolean whether this template is a source template, i.e., this template is loaded from
235 235
 	 * some external storage rather than from within another template.
236 236
 	 */
237
-	public function __construct($template,$contextPath,$tplFile=null,$startingLine=0,$sourceTemplate=true)
237
+	public function __construct($template, $contextPath, $tplFile = null, $startingLine = 0, $sourceTemplate = true)
238 238
 	{
239
-		$this->_sourceTemplate=$sourceTemplate;
240
-		$this->_contextPath=$contextPath;
241
-		$this->_tplFile=$tplFile;
242
-		$this->_startingLine=$startingLine;
243
-		$this->_content=$template;
244
-		$this->_hashCode=md5($template);
239
+		$this->_sourceTemplate = $sourceTemplate;
240
+		$this->_contextPath = $contextPath;
241
+		$this->_tplFile = $tplFile;
242
+		$this->_startingLine = $startingLine;
243
+		$this->_content = $template;
244
+		$this->_hashCode = md5($template);
245 245
 		$this->parse($template);
246
-		$this->_content=null; // reset to save memory
246
+		$this->_content = null; // reset to save memory
247 247
 	}
248 248
 
249 249
 	/**
@@ -302,41 +302,41 @@  discard block
 block discarded – undo
302 302
 	 * @param TControl the control who owns the template
303 303
 	 * @param TControl the control who will become the root parent of the controls on the template. If null, it uses the template control.
304 304
 	 */
305
-	public function instantiateIn($tplControl,$parentControl=null)
305
+	public function instantiateIn($tplControl, $parentControl = null)
306 306
 	{
307
-		$this->_tplControl=$tplControl;
308
-		if($parentControl===null)
309
-			$parentControl=$tplControl;
310
-		if(($page=$tplControl->getPage())===null)
311
-			$page=$this->getService()->getRequestedPage();
312
-		$controls=array();
313
-		$directChildren=array();
314
-		foreach($this->_tpl as $key=>$object)
307
+		$this->_tplControl = $tplControl;
308
+		if ($parentControl === null)
309
+			$parentControl = $tplControl;
310
+		if (($page = $tplControl->getPage()) === null)
311
+			$page = $this->getService()->getRequestedPage();
312
+		$controls = array();
313
+		$directChildren = array();
314
+		foreach ($this->_tpl as $key=>$object)
315 315
 		{
316
-			if($object[0]===-1)
317
-				$parent=$parentControl;
318
-			else if(isset($controls[$object[0]]))
319
-				$parent=$controls[$object[0]];
316
+			if ($object[0] === -1)
317
+				$parent = $parentControl;
318
+			else if (isset($controls[$object[0]]))
319
+				$parent = $controls[$object[0]];
320 320
 			else
321 321
 				continue;
322
-			if(isset($object[2]))	// component
322
+			if (isset($object[2]))	// component
323 323
 			{
324
-				$component=Prado::createComponent($object[1]);
325
-				$properties=&$object[2];
326
-				if($component instanceof TControl)
324
+				$component = Prado::createComponent($object[1]);
325
+				$properties = &$object[2];
326
+				if ($component instanceof TControl)
327 327
 				{
328
-					if($component instanceof TOutputCache)
329
-						$component->setCacheKeyPrefix($this->_hashCode.$key);
328
+					if ($component instanceof TOutputCache)
329
+						$component->setCacheKeyPrefix($this->_hashCode . $key);
330 330
 					$component->setTemplateControl($tplControl);
331
-					if(isset($properties['id']))
331
+					if (isset($properties['id']))
332 332
 					{
333
-						if(is_array($properties['id']))
334
-							$properties['id']=$component->evaluateExpression($properties['id'][1]);
335
-						$tplControl->registerObject($properties['id'],$component);
333
+						if (is_array($properties['id']))
334
+							$properties['id'] = $component->evaluateExpression($properties['id'][1]);
335
+						$tplControl->registerObject($properties['id'], $component);
336 336
 					}
337
-					if(isset($properties['skinid']))
337
+					if (isset($properties['skinid']))
338 338
 					{
339
-						if(is_array($properties['skinid']))
339
+						if (is_array($properties['skinid']))
340 340
 							$component->setSkinID($component->evaluateExpression($properties['skinid'][1]));
341 341
 						else
342 342
 							$component->setSkinID($properties['skinid']);
@@ -346,53 +346,53 @@  discard block
 block discarded – undo
346 346
 					$component->trackViewState(false);
347 347
 
348 348
 					$component->applyStyleSheetSkin($page);
349
-					foreach($properties as $name=>$value)
350
-						$this->configureControl($component,$name,$value);
349
+					foreach ($properties as $name=>$value)
350
+						$this->configureControl($component, $name, $value);
351 351
 
352 352
 					$component->trackViewState(true);
353 353
 
354
-					if($parent===$parentControl)
355
-						$directChildren[]=$component;
354
+					if ($parent === $parentControl)
355
+						$directChildren[] = $component;
356 356
 					else
357 357
 						$component->createdOnTemplate($parent);
358
-					if($component->getAllowChildControls())
359
-						$controls[$key]=$component;
358
+					if ($component->getAllowChildControls())
359
+						$controls[$key] = $component;
360 360
 				}
361
-				else if($component instanceof TComponent)
361
+				else if ($component instanceof TComponent)
362 362
 				{
363
-					$controls[$key]=$component;
364
-					if(isset($properties['id']))
363
+					$controls[$key] = $component;
364
+					if (isset($properties['id']))
365 365
 					{
366
-						if(is_array($properties['id']))
367
-							$properties['id']=$component->evaluateExpression($properties['id'][1]);
368
-						$tplControl->registerObject($properties['id'],$component);
369
-						if(!$component->hasProperty('id'))
366
+						if (is_array($properties['id']))
367
+							$properties['id'] = $component->evaluateExpression($properties['id'][1]);
368
+						$tplControl->registerObject($properties['id'], $component);
369
+						if (!$component->hasProperty('id'))
370 370
 							unset($properties['id']);
371 371
 					}
372
-					foreach($properties as $name=>$value)
373
-						$this->configureComponent($component,$name,$value);
374
-					if($parent===$parentControl)
375
-						$directChildren[]=$component;
372
+					foreach ($properties as $name=>$value)
373
+						$this->configureComponent($component, $name, $value);
374
+					if ($parent === $parentControl)
375
+						$directChildren[] = $component;
376 376
 					else
377 377
 						$component->createdOnTemplate($parent);
378 378
 				}
379 379
 			}
380 380
 			else
381 381
 			{
382
-				if($object[1] instanceof TCompositeLiteral)
382
+				if ($object[1] instanceof TCompositeLiteral)
383 383
 				{
384 384
 					// need to clone a new object because the one in template is reused
385
-					$o=clone $object[1];
385
+					$o = clone $object[1];
386 386
 					$o->setContainer($tplControl);
387
-					if($parent===$parentControl)
388
-						$directChildren[]=$o;
387
+					if ($parent === $parentControl)
388
+						$directChildren[] = $o;
389 389
 					else
390 390
 						$parent->addParsedObject($o);
391 391
 				}
392 392
 				else
393 393
 				{
394
-					if($parent===$parentControl)
395
-						$directChildren[]=$object[1];
394
+					if ($parent === $parentControl)
395
+						$directChildren[] = $object[1];
396 396
 					else
397 397
 						$parent->addParsedObject($object[1]);
398 398
 				}
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
 		// delay setting parent till now because the parent may cause
402 402
 		// the child to do lifecycle catchup which may cause problem
403 403
 		// if the child needs its own child controls.
404
-		foreach($directChildren as $control)
404
+		foreach ($directChildren as $control)
405 405
 		{
406
-			if($control instanceof TComponent)
406
+			if ($control instanceof TComponent)
407 407
 				$control->createdOnTemplate($parentControl);
408 408
 			else
409 409
 				$parentControl->addParsedObject($control);
@@ -416,14 +416,14 @@  discard block
 block discarded – undo
416 416
 	 * @param string property name
417 417
 	 * @param mixed property initial value
418 418
 	 */
419
-	protected function configureControl($control,$name,$value)
419
+	protected function configureControl($control, $name, $value)
420 420
 	{
421
-		if(strncasecmp($name,'on',2)===0)		// is an event
422
-			$this->configureEvent($control,$name,$value,$control);
423
-		else if(($pos=strrpos($name,'.'))===false)	// is a simple property or custom attribute
424
-			$this->configureProperty($control,$name,$value);
421
+		if (strncasecmp($name, 'on', 2) === 0)		// is an event
422
+			$this->configureEvent($control, $name, $value, $control);
423
+		else if (($pos = strrpos($name, '.')) === false)	// is a simple property or custom attribute
424
+			$this->configureProperty($control, $name, $value);
425 425
 		else	// is a subproperty
426
-			$this->configureSubProperty($control,$name,$value);
426
+			$this->configureSubProperty($control, $name, $value);
427 427
 	}
428 428
 
429 429
 	/**
@@ -432,12 +432,12 @@  discard block
 block discarded – undo
432 432
 	 * @param string property name
433 433
 	 * @param mixed property initial value
434 434
 	 */
435
-	protected function configureComponent($component,$name,$value)
435
+	protected function configureComponent($component, $name, $value)
436 436
 	{
437
-		if(strpos($name,'.')===false)	// is a simple property or custom attribute
438
-			$this->configureProperty($component,$name,$value);
437
+		if (strpos($name, '.') === false)	// is a simple property or custom attribute
438
+			$this->configureProperty($component, $name, $value);
439 439
 		else	// is a subproperty
440
-			$this->configureSubProperty($component,$name,$value);
440
+			$this->configureSubProperty($component, $name, $value);
441 441
 	}
442 442
 
443 443
 	/**
@@ -447,12 +447,12 @@  discard block
 block discarded – undo
447 447
 	 * @param string event handler
448 448
 	 * @param TControl context control
449 449
 	 */
450
-	protected function configureEvent($control,$name,$value,$contextControl)
450
+	protected function configureEvent($control, $name, $value, $contextControl)
451 451
 	{
452
-		if(strpos($value,'.')===false)
453
-			$control->attachEventHandler($name,array($contextControl,'TemplateControl.'.$value));
452
+		if (strpos($value, '.') === false)
453
+			$control->attachEventHandler($name, array($contextControl, 'TemplateControl.' . $value));
454 454
 		else
455
-			$control->attachEventHandler($name,array($contextControl,$value));
455
+			$control->attachEventHandler($name, array($contextControl, $value));
456 456
 	}
457 457
 
458 458
 	/**
@@ -461,52 +461,52 @@  discard block
 block discarded – undo
461 461
 	 * @param string property name
462 462
 	 * @param mixed property initial value
463 463
 	 */
464
-	protected function configureProperty($component,$name,$value)
464
+	protected function configureProperty($component, $name, $value)
465 465
 	{
466
-		if(is_array($value))
466
+		if (is_array($value))
467 467
 		{
468
-			switch($value[0])
468
+			switch ($value[0])
469 469
 			{
470 470
 				case self::CONFIG_DATABIND:
471
-					$component->bindProperty($name,$value[1]);
471
+					$component->bindProperty($name, $value[1]);
472 472
 					break;
473 473
 				case self::CONFIG_EXPRESSION:
474
-					if($component instanceof TControl)
475
-						$component->autoBindProperty($name,$value[1]);
474
+					if ($component instanceof TControl)
475
+						$component->autoBindProperty($name, $value[1]);
476 476
 					else
477 477
 					{
478
-						$setter='set'.$name;
478
+						$setter = 'set' . $name;
479 479
 						$component->$setter($this->_tplControl->evaluateExpression($value[1]));
480 480
 					}
481 481
 					break;
482 482
 				case self::CONFIG_TEMPLATE:
483
-					$setter='set'.$name;
483
+					$setter = 'set' . $name;
484 484
 					$component->$setter($value[1]);
485 485
 					break;
486 486
 				case self::CONFIG_ASSET:		// asset URL
487
-					$setter='set'.$name;
488
-					$url=$this->publishFilePath($this->_contextPath.DIRECTORY_SEPARATOR.$value[1]);
487
+					$setter = 'set' . $name;
488
+					$url = $this->publishFilePath($this->_contextPath . DIRECTORY_SEPARATOR . $value[1]);
489 489
 					$component->$setter($url);
490 490
 					break;
491 491
 				case self::CONFIG_PARAMETER:		// application parameter
492
-					$setter='set'.$name;
492
+					$setter = 'set' . $name;
493 493
 					$component->$setter($this->getApplication()->getParameters()->itemAt($value[1]));
494 494
 					break;
495 495
 				case self::CONFIG_LOCALIZATION:
496
-					$setter='set'.$name;
496
+					$setter = 'set' . $name;
497 497
 					$component->$setter(Prado::localize($value[1]));
498 498
 					break;
499 499
 				default:	// an error if reaching here
500
-					throw new TConfigurationException('template_tag_unexpected',$name,$value[1]);
500
+					throw new TConfigurationException('template_tag_unexpected', $name, $value[1]);
501 501
 					break;
502 502
 			}
503 503
 		}
504 504
 		else
505 505
 		{
506
-			if (substr($name,0,2)=='js')
506
+			if (substr($name, 0, 2) == 'js')
507 507
 				if ($value and !($value instanceof TJavaScriptLiteral))
508 508
 					$value = new TJavaScriptLiteral($value);
509
-			$setter='set'.$name;
509
+			$setter = 'set' . $name;
510 510
 			$component->$setter($value);
511 511
 		}
512 512
 	}
@@ -517,41 +517,41 @@  discard block
 block discarded – undo
517 517
 	 * @param string subproperty name
518 518
 	 * @param mixed subproperty initial value
519 519
 	 */
520
-	protected function configureSubProperty($component,$name,$value)
520
+	protected function configureSubProperty($component, $name, $value)
521 521
 	{
522
-		if(is_array($value))
522
+		if (is_array($value))
523 523
 		{
524
-			switch($value[0])
524
+			switch ($value[0])
525 525
 			{
526 526
 				case self::CONFIG_DATABIND:		// databinding
527
-					$component->bindProperty($name,$value[1]);
527
+					$component->bindProperty($name, $value[1]);
528 528
 					break;
529 529
 				case self::CONFIG_EXPRESSION:		// expression
530
-					if($component instanceof TControl)
531
-						$component->autoBindProperty($name,$value[1]);
530
+					if ($component instanceof TControl)
531
+						$component->autoBindProperty($name, $value[1]);
532 532
 					else
533
-						$component->setSubProperty($name,$this->_tplControl->evaluateExpression($value[1]));
533
+						$component->setSubProperty($name, $this->_tplControl->evaluateExpression($value[1]));
534 534
 					break;
535 535
 				case self::CONFIG_TEMPLATE:
536
-					$component->setSubProperty($name,$value[1]);
536
+					$component->setSubProperty($name, $value[1]);
537 537
 					break;
538 538
 				case self::CONFIG_ASSET:		// asset URL
539
-					$url=$this->publishFilePath($this->_contextPath.DIRECTORY_SEPARATOR.$value[1]);
540
-					$component->setSubProperty($name,$url);
539
+					$url = $this->publishFilePath($this->_contextPath . DIRECTORY_SEPARATOR . $value[1]);
540
+					$component->setSubProperty($name, $url);
541 541
 					break;
542 542
 				case self::CONFIG_PARAMETER:		// application parameter
543
-					$component->setSubProperty($name,$this->getApplication()->getParameters()->itemAt($value[1]));
543
+					$component->setSubProperty($name, $this->getApplication()->getParameters()->itemAt($value[1]));
544 544
 					break;
545 545
 				case self::CONFIG_LOCALIZATION:
546
-					$component->setSubProperty($name,Prado::localize($value[1]));
546
+					$component->setSubProperty($name, Prado::localize($value[1]));
547 547
 					break;
548 548
 				default:	// an error if reaching here
549
-					throw new TConfigurationException('template_tag_unexpected',$name,$value[1]);
549
+					throw new TConfigurationException('template_tag_unexpected', $name, $value[1]);
550 550
 					break;
551 551
 			}
552 552
 		}
553 553
 		else
554
-			$component->setSubProperty($name,$value);
554
+			$component->setSubProperty($name, $value);
555 555
 	}
556 556
 
557 557
 	/**
@@ -577,240 +577,240 @@  discard block
 block discarded – undo
577 577
 	 */
578 578
 	protected function parse($input)
579 579
 	{
580
-		$input=$this->preprocess($input);
581
-		$tpl=&$this->_tpl;
582
-		$n=preg_match_all(self::REGEX_RULES,$input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
583
-		$expectPropEnd=false;
584
-		$textStart=0;
585
-				$stack=array();
586
-		$container=-1;
587
-		$matchEnd=0;
588
-		$c=0;
589
-		$this->_directive=null;
580
+		$input = $this->preprocess($input);
581
+		$tpl = &$this->_tpl;
582
+		$n = preg_match_all(self::REGEX_RULES, $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
583
+		$expectPropEnd = false;
584
+		$textStart = 0;
585
+				$stack = array();
586
+		$container = -1;
587
+		$matchEnd = 0;
588
+		$c = 0;
589
+		$this->_directive = null;
590 590
 		try
591 591
 		{
592
-			for($i=0;$i<$n;++$i)
592
+			for ($i = 0; $i < $n; ++$i)
593 593
 			{
594
-				$match=&$matches[$i];
595
-				$str=$match[0][0];
596
-				$matchStart=$match[0][1];
597
-				$matchEnd=$matchStart+strlen($str)-1;
598
-				if(strpos($str,'<com:')===0)	// opening component tag
594
+				$match = &$matches[$i];
595
+				$str = $match[0][0];
596
+				$matchStart = $match[0][1];
597
+				$matchEnd = $matchStart + strlen($str) - 1;
598
+				if (strpos($str, '<com:') === 0)	// opening component tag
599 599
 				{
600
-					if($expectPropEnd)
600
+					if ($expectPropEnd)
601 601
 						continue;
602
-					if($matchStart>$textStart)
603
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
604
-					$textStart=$matchEnd+1;
605
-					$type=$match[1][0];
606
-					$attributes=$this->parseAttributes($match[2][0],$match[2][1]);
607
-					$this->validateAttributes($type,$attributes);
608
-					$tpl[$c++]=array($container,$type,$attributes);
609
-					if($str[strlen($str)-2]!=='/')  // open tag
602
+					if ($matchStart > $textStart)
603
+						$tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart));
604
+					$textStart = $matchEnd + 1;
605
+					$type = $match[1][0];
606
+					$attributes = $this->parseAttributes($match[2][0], $match[2][1]);
607
+					$this->validateAttributes($type, $attributes);
608
+					$tpl[$c++] = array($container, $type, $attributes);
609
+					if ($str[strlen($str) - 2] !== '/')  // open tag
610 610
 					{
611 611
 						$stack[] = $type;
612
-						$container=$c-1;
612
+						$container = $c - 1;
613 613
 					}
614 614
 				}
615
-				else if(strpos($str,'</com:')===0)	// closing component tag
615
+				else if (strpos($str, '</com:') === 0)	// closing component tag
616 616
 				{
617
-					if($expectPropEnd)
617
+					if ($expectPropEnd)
618 618
 						continue;
619
-					if($matchStart>$textStart)
620
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
621
-					$textStart=$matchEnd+1;
622
-					$type=$match[1][0];
619
+					if ($matchStart > $textStart)
620
+						$tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart));
621
+					$textStart = $matchEnd + 1;
622
+					$type = $match[1][0];
623 623
 
624
-					if(empty($stack))
625
-						throw new TConfigurationException('template_closingtag_unexpected',"</com:$type>");
624
+					if (empty($stack))
625
+						throw new TConfigurationException('template_closingtag_unexpected', "</com:$type>");
626 626
 
627
-					$name=array_pop($stack);
628
-					if($name!==$type)
627
+					$name = array_pop($stack);
628
+					if ($name !== $type)
629 629
 					{
630
-						$tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>";
631
-						throw new TConfigurationException('template_closingtag_expected',$tag);
630
+						$tag = $name[0] === '@' ? '</prop:' . substr($name, 1) . '>' : "</com:$name>";
631
+						throw new TConfigurationException('template_closingtag_expected', $tag);
632 632
 					}
633
-					$container=$tpl[$container][0];
633
+					$container = $tpl[$container][0];
634 634
 				}
635
-				else if(strpos($str,'<%@')===0)	// directive
635
+				else if (strpos($str, '<%@') === 0)	// directive
636 636
 				{
637
-					if($expectPropEnd)
637
+					if ($expectPropEnd)
638 638
 						continue;
639
-					if($matchStart>$textStart)
640
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
641
-					$textStart=$matchEnd+1;
642
-					if(isset($tpl[0]) || $this->_directive!==null)
639
+					if ($matchStart > $textStart)
640
+						$tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart));
641
+					$textStart = $matchEnd + 1;
642
+					if (isset($tpl[0]) || $this->_directive !== null)
643 643
 						throw new TConfigurationException('template_directive_nonunique');
644
-					$this->_directive=$this->parseAttributes($match[4][0],$match[4][1]);
644
+					$this->_directive = $this->parseAttributes($match[4][0], $match[4][1]);
645 645
 				}
646
-				else if(strpos($str,'<%')===0)	// expression
646
+				else if (strpos($str, '<%') === 0)	// expression
647 647
 				{
648
-					if($expectPropEnd)
648
+					if ($expectPropEnd)
649 649
 						continue;
650
-					if($matchStart>$textStart)
651
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
652
-					$textStart=$matchEnd+1;
653
-					$literal=trim($match[5][0]);
654
-					if($str[2]==='=')	// expression
655
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,$literal));
656
-					else if($str[2]==='%')  // statements
657
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_STATEMENTS,$literal));
658
-					else if($str[2]==='#')
659
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_DATABINDING,$literal));
660
-					else if($str[2]==='$')
661
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')"));
662
-					else if($str[2]==='~')
663
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')"));
664
-					else if($str[2]==='/')
665
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'"));
666
-					else if($str[2]==='[')
650
+					if ($matchStart > $textStart)
651
+						$tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart));
652
+					$textStart = $matchEnd + 1;
653
+					$literal = trim($match[5][0]);
654
+					if ($str[2] === '=')	// expression
655
+						$tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, $literal));
656
+					else if ($str[2] === '%')  // statements
657
+						$tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_STATEMENTS, $literal));
658
+					else if ($str[2] === '#')
659
+						$tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_DATABINDING, $literal));
660
+					else if ($str[2] === '$')
661
+						$tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "\$this->getApplication()->getParameters()->itemAt('$literal')"));
662
+					else if ($str[2] === '~')
663
+						$tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "\$this->publishFilePath('$this->_contextPath/$literal')"));
664
+					else if ($str[2] === '/')
665
+						$tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'"));
666
+					else if ($str[2] === '[')
667 667
 					{
668
-						$literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\"));
669
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')"));
668
+						$literal = strtr(trim(substr($literal, 0, strlen($literal) - 1)), array("'"=>"\'", "\\"=>"\\\\"));
669
+						$tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "Prado::localize('$literal')"));
670 670
 					}
671 671
 				}
672
-				else if(strpos($str,'<prop:')===0)	// opening property
672
+				else if (strpos($str, '<prop:') === 0)	// opening property
673 673
 				{
674
-					if(strrpos($str,'/>')===strlen($str)-2)  //subproperties
674
+					if (strrpos($str, '/>') === strlen($str) - 2)  //subproperties
675 675
 					{
676
-						if($expectPropEnd)
676
+						if ($expectPropEnd)
677 677
 							continue;
678
-						if($matchStart>$textStart)
679
-							$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
680
-						$textStart=$matchEnd+1;
681
-						$prop=strtolower($match[6][0]);
682
-						$attrs=$this->parseAttributes($match[7][0],$match[7][1]);
683
-						$attributes=array();
684
-						foreach($attrs as $name=>$value)
685
-							$attributes[$prop.'.'.$name]=$value;
686
-						$type=$tpl[$container][1];
687
-						$this->validateAttributes($type,$attributes);
688
-						foreach($attributes as $name=>$value)
678
+						if ($matchStart > $textStart)
679
+							$tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart));
680
+						$textStart = $matchEnd + 1;
681
+						$prop = strtolower($match[6][0]);
682
+						$attrs = $this->parseAttributes($match[7][0], $match[7][1]);
683
+						$attributes = array();
684
+						foreach ($attrs as $name=>$value)
685
+							$attributes[$prop . '.' . $name] = $value;
686
+						$type = $tpl[$container][1];
687
+						$this->validateAttributes($type, $attributes);
688
+						foreach ($attributes as $name=>$value)
689 689
 						{
690
-							if(isset($tpl[$container][2][$name]))
691
-								throw new TConfigurationException('template_property_duplicated',$name);
692
-							$tpl[$container][2][$name]=$value;
690
+							if (isset($tpl[$container][2][$name]))
691
+								throw new TConfigurationException('template_property_duplicated', $name);
692
+							$tpl[$container][2][$name] = $value;
693 693
 						}
694 694
 					}
695 695
 					else  // regular property
696 696
 					{
697
-						$prop=strtolower($match[3][0]);
698
-						$stack[] = '@'.$prop;
699
-						if(!$expectPropEnd)
697
+						$prop = strtolower($match[3][0]);
698
+						$stack[] = '@' . $prop;
699
+						if (!$expectPropEnd)
700 700
 						{
701
-							if($matchStart>$textStart)
702
-								$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
703
-							$textStart=$matchEnd+1;
704
-							$expectPropEnd=true;
701
+							if ($matchStart > $textStart)
702
+								$tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart));
703
+							$textStart = $matchEnd + 1;
704
+							$expectPropEnd = true;
705 705
 						}
706 706
 					}
707 707
 				}
708
-				else if(strpos($str,'</prop:')===0)	// closing property
708
+				else if (strpos($str, '</prop:') === 0)	// closing property
709 709
 				{
710
-					$prop=strtolower($match[3][0]);
711
-					if(empty($stack))
712
-						throw new TConfigurationException('template_closingtag_unexpected',"</prop:$prop>");
713
-					$name=array_pop($stack);
714
-					if($name!=='@'.$prop)
710
+					$prop = strtolower($match[3][0]);
711
+					if (empty($stack))
712
+						throw new TConfigurationException('template_closingtag_unexpected', "</prop:$prop>");
713
+					$name = array_pop($stack);
714
+					if ($name !== '@' . $prop)
715 715
 					{
716
-						$tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>";
717
-						throw new TConfigurationException('template_closingtag_expected',$tag);
716
+						$tag = $name[0] === '@' ? '</prop:' . substr($name, 1) . '>' : "</com:$name>";
717
+						throw new TConfigurationException('template_closingtag_expected', $tag);
718 718
 					}
719
-					if(($last=count($stack))<1 || $stack[$last-1][0]!=='@')
719
+					if (($last = count($stack)) < 1 || $stack[$last - 1][0] !== '@')
720 720
 					{
721
-						if($matchStart>$textStart)
721
+						if ($matchStart > $textStart)
722 722
 						{
723
-							$value=substr($input,$textStart,$matchStart-$textStart);
724
-							if(substr($prop,-8,8)==='template')
725
-								$value=$this->parseTemplateProperty($value,$textStart);
723
+							$value = substr($input, $textStart, $matchStart - $textStart);
724
+							if (substr($prop, -8, 8) === 'template')
725
+								$value = $this->parseTemplateProperty($value, $textStart);
726 726
 							else
727
-								$value=$this->parseAttribute($value);
728
-							if($container>=0)
727
+								$value = $this->parseAttribute($value);
728
+							if ($container >= 0)
729 729
 							{
730
-								$type=$tpl[$container][1];
731
-								$this->validateAttributes($type,array($prop=>$value));
732
-								if(isset($tpl[$container][2][$prop]))
733
-									throw new TConfigurationException('template_property_duplicated',$prop);
734
-								$tpl[$container][2][$prop]=$value;
730
+								$type = $tpl[$container][1];
731
+								$this->validateAttributes($type, array($prop=>$value));
732
+								if (isset($tpl[$container][2][$prop]))
733
+									throw new TConfigurationException('template_property_duplicated', $prop);
734
+								$tpl[$container][2][$prop] = $value;
735 735
 							}
736 736
 							else	// a property for the template control
737
-								$this->_directive[$prop]=$value;
738
-							$textStart=$matchEnd+1;
737
+								$this->_directive[$prop] = $value;
738
+							$textStart = $matchEnd + 1;
739 739
 						}
740
-						$expectPropEnd=false;
740
+						$expectPropEnd = false;
741 741
 					}
742 742
 				}
743
-				else if(strpos($str,'<!--')===0)	// comments
743
+				else if (strpos($str, '<!--') === 0)	// comments
744 744
 				{
745
-					if($expectPropEnd)
745
+					if ($expectPropEnd)
746 746
 						throw new TConfigurationException('template_comments_forbidden');
747
-					if($matchStart>$textStart)
748
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
749
-					$textStart=$matchEnd+1;
747
+					if ($matchStart > $textStart)
748
+						$tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart));
749
+					$textStart = $matchEnd + 1;
750 750
 				}
751 751
 				else
752
-					throw new TConfigurationException('template_matching_unexpected',$match);
752
+					throw new TConfigurationException('template_matching_unexpected', $match);
753 753
 			}
754
-			if(!empty($stack))
754
+			if (!empty($stack))
755 755
 			{
756
-				$name=array_pop($stack);
757
-				$tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>";
758
-				throw new TConfigurationException('template_closingtag_expected',$tag);
756
+				$name = array_pop($stack);
757
+				$tag = $name[0] === '@' ? '</prop:' . substr($name, 1) . '>' : "</com:$name>";
758
+				throw new TConfigurationException('template_closingtag_expected', $tag);
759 759
 			}
760
-			if($textStart<strlen($input))
761
-				$tpl[$c++]=array($container,substr($input,$textStart));
760
+			if ($textStart < strlen($input))
761
+				$tpl[$c++] = array($container, substr($input, $textStart));
762 762
 		}
763
-		catch(Exception $e)
763
+		catch (Exception $e)
764 764
 		{
765
-			if(($e instanceof TException) && ($e instanceof TTemplateException))
765
+			if (($e instanceof TException) && ($e instanceof TTemplateException))
766 766
 				throw $e;
767
-			if($matchEnd===0)
768
-				$line=$this->_startingLine+1;
767
+			if ($matchEnd === 0)
768
+				$line = $this->_startingLine + 1;
769 769
 			else
770
-				$line=$this->_startingLine+count(explode("\n",substr($input,0,$matchEnd+1)));
771
-			$this->handleException($e,$line,$input);
770
+				$line = $this->_startingLine + count(explode("\n", substr($input, 0, $matchEnd + 1)));
771
+			$this->handleException($e, $line, $input);
772 772
 		}
773 773
 
774
-		if($this->_directive===null)
775
-			$this->_directive=array();
774
+		if ($this->_directive === null)
775
+			$this->_directive = array();
776 776
 
777 777
 		// optimization by merging consecutive strings, expressions, statements and bindings
778
-		$objects=array();
779
-		$parent=null;
780
-		$merged=array();
781
-		foreach($tpl as $id=>$object)
778
+		$objects = array();
779
+		$parent = null;
780
+		$merged = array();
781
+		foreach ($tpl as $id=>$object)
782 782
 		{
783
-			if(isset($object[2]) || $object[0]!==$parent)
783
+			if (isset($object[2]) || $object[0] !== $parent)
784 784
 			{
785
-				if($parent!==null)
785
+				if ($parent !== null)
786 786
 				{
787
-					if(count($merged[1])===1 && is_string($merged[1][0]))
788
-						$objects[$id-1]=array($merged[0],$merged[1][0]);
787
+					if (count($merged[1]) === 1 && is_string($merged[1][0]))
788
+						$objects[$id - 1] = array($merged[0], $merged[1][0]);
789 789
 					else
790
-						$objects[$id-1]=array($merged[0],new TCompositeLiteral($merged[1]));
790
+						$objects[$id - 1] = array($merged[0], new TCompositeLiteral($merged[1]));
791 791
 				}
792
-				if(isset($object[2]))
792
+				if (isset($object[2]))
793 793
 				{
794
-					$parent=null;
795
-					$objects[$id]=$object;
794
+					$parent = null;
795
+					$objects[$id] = $object;
796 796
 				}
797 797
 				else
798 798
 				{
799
-					$parent=$object[0];
800
-					$merged=array($parent,array($object[1]));
799
+					$parent = $object[0];
800
+					$merged = array($parent, array($object[1]));
801 801
 				}
802 802
 			}
803 803
 			else
804
-				$merged[1][]=$object[1];
804
+				$merged[1][] = $object[1];
805 805
 		}
806
-		if($parent!==null)
806
+		if ($parent !== null)
807 807
 		{
808
-			if(count($merged[1])===1 && is_string($merged[1][0]))
809
-				$objects[$id]=array($merged[0],$merged[1][0]);
808
+			if (count($merged[1]) === 1 && is_string($merged[1][0]))
809
+				$objects[$id] = array($merged[0], $merged[1][0]);
810 810
 			else
811
-				$objects[$id]=array($merged[0],new TCompositeLiteral($merged[1]));
811
+				$objects[$id] = array($merged[0], new TCompositeLiteral($merged[1]));
812 812
 		}
813
-		$tpl=$objects;
813
+		$tpl = $objects;
814 814
 		return $objects;
815 815
 	}
816 816
 
@@ -819,42 +819,42 @@  discard block
 block discarded – undo
819 819
 	 * @param string the string to be parsed.
820 820
 	 * @return array attribute values indexed by names.
821 821
 	 */
822
-	protected function parseAttributes($str,$offset)
822
+	protected function parseAttributes($str, $offset)
823 823
 	{
824
-		if($str==='')
824
+		if ($str === '')
825 825
 			return array();
826
-		$pattern='/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS';
827
-		$attributes=array();
828
-		$n=preg_match_all($pattern,$str,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
829
-		for($i=0;$i<$n;++$i)
826
+		$pattern = '/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS';
827
+		$attributes = array();
828
+		$n = preg_match_all($pattern, $str, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
829
+		for ($i = 0; $i < $n; ++$i)
830 830
 		{
831
-			$match=&$matches[$i];
832
-			$name=strtolower($match[1][0]);
833
-			if(isset($attributes[$name]))
834
-				throw new TConfigurationException('template_property_duplicated',$name);
835
-			$value=$match[2][0];
836
-			if(substr($name,-8,8)==='template')
831
+			$match = &$matches[$i];
832
+			$name = strtolower($match[1][0]);
833
+			if (isset($attributes[$name]))
834
+				throw new TConfigurationException('template_property_duplicated', $name);
835
+			$value = $match[2][0];
836
+			if (substr($name, -8, 8) === 'template')
837 837
 			{
838
-				if($value[0]==='\'' || $value[0]==='"')
839
-					$attributes[$name]=$this->parseTemplateProperty(substr($value,1,strlen($value)-2),$match[2][1]+1);
838
+				if ($value[0] === '\'' || $value[0] === '"')
839
+					$attributes[$name] = $this->parseTemplateProperty(substr($value, 1, strlen($value) - 2), $match[2][1] + 1);
840 840
 				else
841
-					$attributes[$name]=$this->parseTemplateProperty($value,$match[2][1]);
841
+					$attributes[$name] = $this->parseTemplateProperty($value, $match[2][1]);
842 842
 			}
843 843
 			else
844 844
 			{
845
-				if($value[0]==='\'' || $value[0]==='"')
846
-					$attributes[$name]=$this->parseAttribute(substr($value,1,strlen($value)-2));
845
+				if ($value[0] === '\'' || $value[0] === '"')
846
+					$attributes[$name] = $this->parseAttribute(substr($value, 1, strlen($value) - 2));
847 847
 				else
848
-					$attributes[$name]=$this->parseAttribute($value);
848
+					$attributes[$name] = $this->parseAttribute($value);
849 849
 			}
850 850
 		}
851 851
 		return $attributes;
852 852
 	}
853 853
 
854
-	protected function parseTemplateProperty($content,$offset)
854
+	protected function parseTemplateProperty($content, $offset)
855 855
 	{
856
-		$line=$this->_startingLine+count(explode("\n",substr($this->_content,0,$offset)))-1;
857
-		return array(self::CONFIG_TEMPLATE,new TTemplate($content,$this->_contextPath,$this->_tplFile,$line,false));
856
+		$line = $this->_startingLine + count(explode("\n", substr($this->_content, 0, $offset))) - 1;
857
+		return array(self::CONFIG_TEMPLATE, new TTemplate($content, $this->_contextPath, $this->_tplFile, $line, false));
858 858
 	}
859 859
 
860 860
 	/**
@@ -864,127 +864,127 @@  discard block
 block discarded – undo
864 864
 	 */
865 865
 	protected function parseAttribute($value)
866 866
 	{
867
-		if(($n=preg_match_all('/<%[#=].*?%>/msS',$value,$matches,PREG_OFFSET_CAPTURE))>0)
867
+		if (($n = preg_match_all('/<%[#=].*?%>/msS', $value, $matches, PREG_OFFSET_CAPTURE)) > 0)
868 868
 		{
869
-			$isDataBind=false;
870
-			$textStart=0;
871
-			$expr='';
872
-			for($i=0;$i<$n;++$i)
869
+			$isDataBind = false;
870
+			$textStart = 0;
871
+			$expr = '';
872
+			for ($i = 0; $i < $n; ++$i)
873 873
 			{
874
-				$match=$matches[0][$i];
875
-				$token=$match[0];
876
-				$offset=$match[1];
877
-				$length=strlen($token);
878
-				if($token[2]==='#')
879
-					$isDataBind=true;
880
-				if($offset>$textStart)
881
-					$expr.=".'".strtr(substr($value,$textStart,$offset-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'";
882
-				$expr.='.('.substr($token,3,$length-5).')';
883
-				$textStart=$offset+$length;
874
+				$match = $matches[0][$i];
875
+				$token = $match[0];
876
+				$offset = $match[1];
877
+				$length = strlen($token);
878
+				if ($token[2] === '#')
879
+					$isDataBind = true;
880
+				if ($offset > $textStart)
881
+					$expr .= ".'" . strtr(substr($value, $textStart, $offset - $textStart), array("'"=>"\\'", "\\"=>"\\\\")) . "'";
882
+				$expr .= '.(' . substr($token, 3, $length - 5) . ')';
883
+				$textStart = $offset + $length;
884 884
 			}
885
-			$length=strlen($value);
886
-			if($length>$textStart)
887
-				$expr.=".'".strtr(substr($value,$textStart,$length-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'";
888
-			if($isDataBind)
889
-				return array(self::CONFIG_DATABIND,ltrim($expr,'.'));
885
+			$length = strlen($value);
886
+			if ($length > $textStart)
887
+				$expr .= ".'" . strtr(substr($value, $textStart, $length - $textStart), array("'"=>"\\'", "\\"=>"\\\\")) . "'";
888
+			if ($isDataBind)
889
+				return array(self::CONFIG_DATABIND, ltrim($expr, '.'));
890 890
 			else
891
-				return array(self::CONFIG_EXPRESSION,ltrim($expr,'.'));
891
+				return array(self::CONFIG_EXPRESSION, ltrim($expr, '.'));
892 892
 		}
893
-		else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value)
893
+		else if (preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS', $value, $matches) && $matches[0] === $value)
894 894
 		{
895
-			$value=$matches[1];
896
-			if($value[2]==='~')
897
-				return array(self::CONFIG_ASSET,trim(substr($value,3,strlen($value)-5)));
898
-			elseif($value[2]==='[')
899
-				return array(self::CONFIG_LOCALIZATION,trim(substr($value,3,strlen($value)-6)));
900
-			elseif($value[2]==='$')
901
-				return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5)));
902
-			elseif($value[2]==='/') {
903
-				$literal = trim(substr($value,3,strlen($value)-5));
904
-				return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'");
895
+			$value = $matches[1];
896
+			if ($value[2] === '~')
897
+				return array(self::CONFIG_ASSET, trim(substr($value, 3, strlen($value) - 5)));
898
+			elseif ($value[2] === '[')
899
+				return array(self::CONFIG_LOCALIZATION, trim(substr($value, 3, strlen($value) - 6)));
900
+			elseif ($value[2] === '$')
901
+				return array(self::CONFIG_PARAMETER, trim(substr($value, 3, strlen($value) - 5)));
902
+			elseif ($value[2] === '/') {
903
+				$literal = trim(substr($value, 3, strlen($value) - 5));
904
+				return array(self::CONFIG_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'");
905 905
 			}
906 906
 		}
907 907
 		else
908 908
 			return $value;
909 909
 	}
910 910
 
911
-	protected function validateAttributes($type,$attributes)
911
+	protected function validateAttributes($type, $attributes)
912 912
 	{
913 913
 		Prado::using($type);
914
-		if(($pos=strrpos($type,'.'))!==false)
915
-			$className=substr($type,$pos+1);
914
+		if (($pos = strrpos($type, '.')) !== false)
915
+			$className = substr($type, $pos + 1);
916 916
 		else
917
-			$className=$type;
918
-		$class=new ReflectionClass($className);
919
-		if(is_subclass_of($className,'TControl') || $className==='TControl')
917
+			$className = $type;
918
+		$class = new ReflectionClass($className);
919
+		if (is_subclass_of($className, 'TControl') || $className === 'TControl')
920 920
 		{
921
-			foreach($attributes as $name=>$att)
921
+			foreach ($attributes as $name=>$att)
922 922
 			{
923
-				if(($pos=strpos($name,'.'))!==false)
923
+				if (($pos = strpos($name, '.')) !== false)
924 924
 				{
925 925
 					// a subproperty, so the first segment must be readable
926
-					$subname=substr($name,0,$pos);
927
-					if(!$class->hasMethod('get'.$subname))
928
-						throw new TConfigurationException('template_property_unknown',$type,$subname);
926
+					$subname = substr($name, 0, $pos);
927
+					if (!$class->hasMethod('get' . $subname))
928
+						throw new TConfigurationException('template_property_unknown', $type, $subname);
929 929
 				}
930
-				else if(strncasecmp($name,'on',2)===0)
930
+				else if (strncasecmp($name, 'on', 2) === 0)
931 931
 				{
932 932
 					// an event
933
-					if(!$class->hasMethod($name))
934
-						throw new TConfigurationException('template_event_unknown',$type,$name);
935
-					else if(!is_string($att))
936
-						throw new TConfigurationException('template_eventhandler_invalid',$type,$name);
933
+					if (!$class->hasMethod($name))
934
+						throw new TConfigurationException('template_event_unknown', $type, $name);
935
+					else if (!is_string($att))
936
+						throw new TConfigurationException('template_eventhandler_invalid', $type, $name);
937 937
 				}
938 938
 				else
939 939
 				{
940 940
 					// a simple property
941
-					if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)) )
941
+					if (!($class->hasMethod('set' . $name) || $class->hasMethod('setjs' . $name) || $this->isClassBehaviorMethod($class, 'set' . $name)))
942 942
 					{
943
-						if ($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name))
944
-							throw new TConfigurationException('template_property_readonly',$type,$name);
943
+						if ($class->hasMethod('get' . $name) || $class->hasMethod('getjs' . $name))
944
+							throw new TConfigurationException('template_property_readonly', $type, $name);
945 945
 						else
946
-							throw new TConfigurationException('template_property_unknown',$type,$name);
946
+							throw new TConfigurationException('template_property_unknown', $type, $name);
947 947
 					}
948
-					else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION)
948
+					else if (is_array($att) && $att[0] !== self::CONFIG_EXPRESSION)
949 949
 					{
950
-						if(strcasecmp($name,'id')===0)
951
-							throw new TConfigurationException('template_controlid_invalid',$type);
952
-						else if(strcasecmp($name,'skinid')===0)
953
-							throw new TConfigurationException('template_controlskinid_invalid',$type);
950
+						if (strcasecmp($name, 'id') === 0)
951
+							throw new TConfigurationException('template_controlid_invalid', $type);
952
+						else if (strcasecmp($name, 'skinid') === 0)
953
+							throw new TConfigurationException('template_controlskinid_invalid', $type);
954 954
 					}
955 955
 				}
956 956
 			}
957 957
 		}
958
-		else if(is_subclass_of($className,'TComponent') || $className==='TComponent')
958
+		else if (is_subclass_of($className, 'TComponent') || $className === 'TComponent')
959 959
 		{
960
-			foreach($attributes as $name=>$att)
960
+			foreach ($attributes as $name=>$att)
961 961
 			{
962
-				if(is_array($att) && ($att[0]===self::CONFIG_DATABIND))
963
-					throw new TConfigurationException('template_databind_forbidden',$type,$name);
964
-				if(($pos=strpos($name,'.'))!==false)
962
+				if (is_array($att) && ($att[0] === self::CONFIG_DATABIND))
963
+					throw new TConfigurationException('template_databind_forbidden', $type, $name);
964
+				if (($pos = strpos($name, '.')) !== false)
965 965
 				{
966 966
 					// a subproperty, so the first segment must be readable
967
-					$subname=substr($name,0,$pos);
968
-					if(!$class->hasMethod('get'.$subname))
969
-						throw new TConfigurationException('template_property_unknown',$type,$subname);
967
+					$subname = substr($name, 0, $pos);
968
+					if (!$class->hasMethod('get' . $subname))
969
+						throw new TConfigurationException('template_property_unknown', $type, $subname);
970 970
 				}
971
-				else if(strncasecmp($name,'on',2)===0)
972
-					throw new TConfigurationException('template_event_forbidden',$type,$name);
971
+				else if (strncasecmp($name, 'on', 2) === 0)
972
+					throw new TConfigurationException('template_event_forbidden', $type, $name);
973 973
 				else
974 974
 				{
975 975
 					// id is still alowed for TComponent, even if id property doesn't exist
976
-					if(strcasecmp($name,'id')!==0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)))
976
+					if (strcasecmp($name, 'id') !== 0 && !($class->hasMethod('set' . $name) || $this->isClassBehaviorMethod($class, 'set' . $name)))
977 977
 					{
978
-						if($class->hasMethod('get'.$name))
979
-							throw new TConfigurationException('template_property_readonly',$type,$name);
978
+						if ($class->hasMethod('get' . $name))
979
+							throw new TConfigurationException('template_property_readonly', $type, $name);
980 980
 						else
981
-							throw new TConfigurationException('template_property_unknown',$type,$name);
981
+							throw new TConfigurationException('template_property_unknown', $type, $name);
982 982
 					}
983 983
 				}
984 984
 			}
985 985
 		}
986 986
 		else
987
-			throw new TConfigurationException('template_component_required',$type);
987
+			throw new TConfigurationException('template_component_required', $type);
988 988
 	}
989 989
 
990 990
 	/**
@@ -1003,30 +1003,30 @@  discard block
 block discarded – undo
1003 1003
 	 * @param int line number
1004 1004
 	 * @param string template string if no source file is used
1005 1005
 	 */
1006
-	protected function handleException($e,$line,$input=null)
1006
+	protected function handleException($e, $line, $input = null)
1007 1007
 	{
1008
-		$srcFile=$this->_tplFile;
1008
+		$srcFile = $this->_tplFile;
1009 1009
 
1010
-		if(($n=count($this->_includedFiles))>0) // need to adjust error row number and file name
1010
+		if (($n = count($this->_includedFiles)) > 0) // need to adjust error row number and file name
1011 1011
 		{
1012
-			for($i=$n-1;$i>=0;--$i)
1012
+			for ($i = $n - 1; $i >= 0; --$i)
1013 1013
 			{
1014
-				if($this->_includeAtLine[$i]<=$line)
1014
+				if ($this->_includeAtLine[$i] <= $line)
1015 1015
 				{
1016
-					if($line<$this->_includeAtLine[$i]+$this->_includeLines[$i])
1016
+					if ($line < $this->_includeAtLine[$i] + $this->_includeLines[$i])
1017 1017
 					{
1018
-						$line=$line-$this->_includeAtLine[$i]+1;
1019
-						$srcFile=$this->_includedFiles[$i];
1018
+						$line = $line - $this->_includeAtLine[$i] + 1;
1019
+						$srcFile = $this->_includedFiles[$i];
1020 1020
 						break;
1021 1021
 					}
1022 1022
 					else
1023
-						$line=$line-$this->_includeLines[$i]+1;
1023
+						$line = $line - $this->_includeLines[$i] + 1;
1024 1024
 				}
1025 1025
 			}
1026 1026
 		}
1027
-		$exception=new TTemplateException('template_format_invalid',$e->getMessage());
1027
+		$exception = new TTemplateException('template_format_invalid', $e->getMessage());
1028 1028
 		$exception->setLineNumber($line);
1029
-		if(!empty($srcFile))
1029
+		if (!empty($srcFile))
1030 1030
 			$exception->setTemplateFile($srcFile);
1031 1031
 		else
1032 1032
 			$exception->setTemplateSource($input);
@@ -1040,29 +1040,29 @@  discard block
 block discarded – undo
1040 1040
 	 */
1041 1041
 	protected function preprocess($input)
1042 1042
 	{
1043
-		if($n=preg_match_all('/<%include(.*?)%>/',$input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE))
1043
+		if ($n = preg_match_all('/<%include(.*?)%>/', $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
1044 1044
 		{
1045
-			for($i=0;$i<$n;++$i)
1045
+			for ($i = 0; $i < $n; ++$i)
1046 1046
 			{
1047
-				$filePath=Prado::getPathOfNamespace(trim($matches[$i][1][0]),TTemplateManager::TEMPLATE_FILE_EXT);
1048
-				if($filePath!==null && is_file($filePath))
1049
-					$this->_includedFiles[]=$filePath;
1047
+				$filePath = Prado::getPathOfNamespace(trim($matches[$i][1][0]), TTemplateManager::TEMPLATE_FILE_EXT);
1048
+				if ($filePath !== null && is_file($filePath))
1049
+					$this->_includedFiles[] = $filePath;
1050 1050
 				else
1051 1051
 				{
1052
-					$errorLine=count(explode("\n",substr($input,0,$matches[$i][0][1]+1)));
1053
-					$this->handleException(new TConfigurationException('template_include_invalid',trim($matches[$i][1][0])),$errorLine,$input);
1052
+					$errorLine = count(explode("\n", substr($input, 0, $matches[$i][0][1] + 1)));
1053
+					$this->handleException(new TConfigurationException('template_include_invalid', trim($matches[$i][1][0])), $errorLine, $input);
1054 1054
 				}
1055 1055
 			}
1056
-			$base=0;
1057
-			for($i=0;$i<$n;++$i)
1056
+			$base = 0;
1057
+			for ($i = 0; $i < $n; ++$i)
1058 1058
 			{
1059
-				$ext=file_get_contents($this->_includedFiles[$i]);
1060
-				$length=strlen($matches[$i][0][0]);
1061
-				$offset=$base+$matches[$i][0][1];
1062
-				$this->_includeAtLine[$i]=count(explode("\n",substr($input,0,$offset)));
1063
-				$this->_includeLines[$i]=count(explode("\n",$ext));
1064
-				$input=substr_replace($input,$ext,$offset,$length);
1065
-				$base+=strlen($ext)-$length;
1059
+				$ext = file_get_contents($this->_includedFiles[$i]);
1060
+				$length = strlen($matches[$i][0][0]);
1061
+				$offset = $base + $matches[$i][0][1];
1062
+				$this->_includeAtLine[$i] = count(explode("\n", substr($input, 0, $offset)));
1063
+				$this->_includeLines[$i] = count(explode("\n", $ext));
1064
+				$input = substr_replace($input, $ext, $offset, $length);
1065
+				$base += strlen($ext) - $length;
1066 1066
 			}
1067 1067
 		}
1068 1068
 
@@ -1075,18 +1075,18 @@  discard block
 block discarded – undo
1075 1075
 	 * @param string $method
1076 1076
 	 * @return boolean
1077 1077
 	 */
1078
-	protected function isClassBehaviorMethod(ReflectionClass $class,$method)
1078
+	protected function isClassBehaviorMethod(ReflectionClass $class, $method)
1079 1079
 	{
1080
-	  $component=new ReflectionClass('TComponent');
1081
-	  $behaviors=$component->getStaticProperties();
1082
-	  if(!isset($behaviors['_um']))
1080
+	  $component = new ReflectionClass('TComponent');
1081
+	  $behaviors = $component->getStaticProperties();
1082
+	  if (!isset($behaviors['_um']))
1083 1083
 	    return false;
1084
-	  foreach($behaviors['_um'] as $name=>$list)
1084
+	  foreach ($behaviors['_um'] as $name=>$list)
1085 1085
 	  {
1086
-	    if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue;
1087
-	    foreach($list as $param)
1086
+	    if (strtolower($class->getShortName()) !== $name && !$class->isSubclassOf($name)) continue;
1087
+	    foreach ($list as $param)
1088 1088
 	    {
1089
-	      if(method_exists($param->getBehavior(),$method))
1089
+	      if (method_exists($param->getBehavior(), $method))
1090 1090
 	        return true;
1091 1091
 	    }
1092 1092
 	  }
Please login to merge, or discard this patch.
Braces   +344 added lines, -268 removed lines patch added patch discarded remove patch
@@ -76,16 +76,17 @@  discard block
 block discarded – undo
76 76
 		if(($fileName=$this->getLocalizedTemplate($fileName))!==null)
77 77
 		{
78 78
 			Prado::trace("Loading template $fileName",'System.Web.UI.TTemplateManager');
79
-			if(($cache=$this->getApplication()->getCache())===null)
80
-				return new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName);
81
-			else
79
+			if(($cache=$this->getApplication()->getCache())===null) {
80
+							return new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName);
81
+			} else
82 82
 			{
83 83
 				$array=$cache->get(self::TEMPLATE_CACHE_PREFIX.$fileName);
84 84
 				if(is_array($array))
85 85
 				{
86 86
 					list($template,$timestamps)=$array;
87
-					if($this->getApplication()->getMode()===TApplicationMode::Performance)
88
-						return $template;
87
+					if($this->getApplication()->getMode()===TApplicationMode::Performance) {
88
+											return $template;
89
+					}
89 90
 					$cacheValid=true;
90 91
 					foreach($timestamps as $tplFile=>$timestamp)
91 92
 					{
@@ -95,21 +96,23 @@  discard block
 block discarded – undo
95 96
 							break;
96 97
 						}
97 98
 					}
98
-					if($cacheValid)
99
-						return $template;
99
+					if($cacheValid) {
100
+											return $template;
101
+					}
100 102
 				}
101 103
 				$template=new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName);
102 104
 				$includedFiles=$template->getIncludedFiles();
103 105
 				$timestamps=array();
104 106
 				$timestamps[$fileName]=filemtime($fileName);
105
-				foreach($includedFiles as $includedFile)
106
-					$timestamps[$includedFile]=filemtime($includedFile);
107
+				foreach($includedFiles as $includedFile) {
108
+									$timestamps[$includedFile]=filemtime($includedFile);
109
+				}
107 110
 				$cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName,array($template,$timestamps));
108 111
 				return $template;
109 112
 			}
113
+		} else {
114
+					return null;
110 115
 		}
111
-		else
112
-			return null;
113 116
 	}
114 117
 
115 118
 	/**
@@ -119,12 +122,14 @@  discard block
 block discarded – undo
119 122
 	 */
120 123
 	protected function getLocalizedTemplate($filename)
121 124
 	{
122
-		if(($app=$this->getApplication()->getGlobalization(false))===null)
123
-			return is_file($filename)?$filename:null;
125
+		if(($app=$this->getApplication()->getGlobalization(false))===null) {
126
+					return is_file($filename)?$filename:null;
127
+		}
124 128
 		foreach($app->getLocalizedResource($filename) as $file)
125 129
 		{
126
-			if(($file=realpath($file))!==false && is_file($file))
127
-				return $file;
130
+			if(($file=realpath($file))!==false && is_file($file)) {
131
+							return $file;
132
+			}
128 133
 		}
129 134
 		return null;
130 135
 	}
@@ -305,96 +310,110 @@  discard block
 block discarded – undo
305 310
 	public function instantiateIn($tplControl,$parentControl=null)
306 311
 	{
307 312
 		$this->_tplControl=$tplControl;
308
-		if($parentControl===null)
309
-			$parentControl=$tplControl;
310
-		if(($page=$tplControl->getPage())===null)
311
-			$page=$this->getService()->getRequestedPage();
313
+		if($parentControl===null) {
314
+					$parentControl=$tplControl;
315
+		}
316
+		if(($page=$tplControl->getPage())===null) {
317
+					$page=$this->getService()->getRequestedPage();
318
+		}
312 319
 		$controls=array();
313 320
 		$directChildren=array();
314 321
 		foreach($this->_tpl as $key=>$object)
315 322
 		{
316
-			if($object[0]===-1)
317
-				$parent=$parentControl;
318
-			else if(isset($controls[$object[0]]))
319
-				$parent=$controls[$object[0]];
320
-			else
321
-				continue;
322
-			if(isset($object[2]))	// component
323
+			if($object[0]===-1) {
324
+							$parent=$parentControl;
325
+			} else if(isset($controls[$object[0]])) {
326
+							$parent=$controls[$object[0]];
327
+			} else {
328
+							continue;
329
+			}
330
+			if(isset($object[2])) {
331
+				// component
323 332
 			{
324 333
 				$component=Prado::createComponent($object[1]);
334
+			}
325 335
 				$properties=&$object[2];
326 336
 				if($component instanceof TControl)
327 337
 				{
328
-					if($component instanceof TOutputCache)
329
-						$component->setCacheKeyPrefix($this->_hashCode.$key);
338
+					if($component instanceof TOutputCache) {
339
+											$component->setCacheKeyPrefix($this->_hashCode.$key);
340
+					}
330 341
 					$component->setTemplateControl($tplControl);
331 342
 					if(isset($properties['id']))
332 343
 					{
333
-						if(is_array($properties['id']))
334
-							$properties['id']=$component->evaluateExpression($properties['id'][1]);
344
+						if(is_array($properties['id'])) {
345
+													$properties['id']=$component->evaluateExpression($properties['id'][1]);
346
+						}
335 347
 						$tplControl->registerObject($properties['id'],$component);
336 348
 					}
337 349
 					if(isset($properties['skinid']))
338 350
 					{
339
-						if(is_array($properties['skinid']))
340
-							$component->setSkinID($component->evaluateExpression($properties['skinid'][1]));
341
-						else
342
-							$component->setSkinID($properties['skinid']);
351
+						if(is_array($properties['skinid'])) {
352
+													$component->setSkinID($component->evaluateExpression($properties['skinid'][1]));
353
+						} else {
354
+													$component->setSkinID($properties['skinid']);
355
+						}
343 356
 						unset($properties['skinid']);
344 357
 					}
345 358
 
346 359
 					$component->trackViewState(false);
347 360
 
348 361
 					$component->applyStyleSheetSkin($page);
349
-					foreach($properties as $name=>$value)
350
-						$this->configureControl($component,$name,$value);
362
+					foreach($properties as $name=>$value) {
363
+											$this->configureControl($component,$name,$value);
364
+					}
351 365
 
352 366
 					$component->trackViewState(true);
353 367
 
354
-					if($parent===$parentControl)
355
-						$directChildren[]=$component;
356
-					else
357
-						$component->createdOnTemplate($parent);
358
-					if($component->getAllowChildControls())
359
-						$controls[$key]=$component;
360
-				}
361
-				else if($component instanceof TComponent)
368
+					if($parent===$parentControl) {
369
+											$directChildren[]=$component;
370
+					} else {
371
+											$component->createdOnTemplate($parent);
372
+					}
373
+					if($component->getAllowChildControls()) {
374
+											$controls[$key]=$component;
375
+					}
376
+				} else if($component instanceof TComponent)
362 377
 				{
363 378
 					$controls[$key]=$component;
364 379
 					if(isset($properties['id']))
365 380
 					{
366
-						if(is_array($properties['id']))
367
-							$properties['id']=$component->evaluateExpression($properties['id'][1]);
381
+						if(is_array($properties['id'])) {
382
+													$properties['id']=$component->evaluateExpression($properties['id'][1]);
383
+						}
368 384
 						$tplControl->registerObject($properties['id'],$component);
369
-						if(!$component->hasProperty('id'))
370
-							unset($properties['id']);
385
+						if(!$component->hasProperty('id')) {
386
+													unset($properties['id']);
387
+						}
388
+					}
389
+					foreach($properties as $name=>$value) {
390
+											$this->configureComponent($component,$name,$value);
391
+					}
392
+					if($parent===$parentControl) {
393
+											$directChildren[]=$component;
394
+					} else {
395
+											$component->createdOnTemplate($parent);
371 396
 					}
372
-					foreach($properties as $name=>$value)
373
-						$this->configureComponent($component,$name,$value);
374
-					if($parent===$parentControl)
375
-						$directChildren[]=$component;
376
-					else
377
-						$component->createdOnTemplate($parent);
378 397
 				}
379
-			}
380
-			else
398
+			} else
381 399
 			{
382 400
 				if($object[1] instanceof TCompositeLiteral)
383 401
 				{
384 402
 					// need to clone a new object because the one in template is reused
385 403
 					$o=clone $object[1];
386 404
 					$o->setContainer($tplControl);
387
-					if($parent===$parentControl)
388
-						$directChildren[]=$o;
389
-					else
390
-						$parent->addParsedObject($o);
391
-				}
392
-				else
405
+					if($parent===$parentControl) {
406
+											$directChildren[]=$o;
407
+					} else {
408
+											$parent->addParsedObject($o);
409
+					}
410
+				} else
393 411
 				{
394
-					if($parent===$parentControl)
395
-						$directChildren[]=$object[1];
396
-					else
397
-						$parent->addParsedObject($object[1]);
412
+					if($parent===$parentControl) {
413
+											$directChildren[]=$object[1];
414
+					} else {
415
+											$parent->addParsedObject($object[1]);
416
+					}
398 417
 				}
399 418
 			}
400 419
 		}
@@ -403,10 +422,11 @@  discard block
 block discarded – undo
403 422
 		// if the child needs its own child controls.
404 423
 		foreach($directChildren as $control)
405 424
 		{
406
-			if($control instanceof TComponent)
407
-				$control->createdOnTemplate($parentControl);
408
-			else
409
-				$parentControl->addParsedObject($control);
425
+			if($control instanceof TComponent) {
426
+							$control->createdOnTemplate($parentControl);
427
+			} else {
428
+							$parentControl->addParsedObject($control);
429
+			}
410 430
 		}
411 431
 	}
412 432
 
@@ -418,12 +438,16 @@  discard block
 block discarded – undo
418 438
 	 */
419 439
 	protected function configureControl($control,$name,$value)
420 440
 	{
421
-		if(strncasecmp($name,'on',2)===0)		// is an event
441
+		if(strncasecmp($name,'on',2)===0) {
442
+			// is an event
422 443
 			$this->configureEvent($control,$name,$value,$control);
423
-		else if(($pos=strrpos($name,'.'))===false)	// is a simple property or custom attribute
444
+		} else if(($pos=strrpos($name,'.'))===false) {
445
+			// is a simple property or custom attribute
424 446
 			$this->configureProperty($control,$name,$value);
425
-		else	// is a subproperty
447
+		} else {
448
+			// is a subproperty
426 449
 			$this->configureSubProperty($control,$name,$value);
450
+		}
427 451
 	}
428 452
 
429 453
 	/**
@@ -434,10 +458,13 @@  discard block
 block discarded – undo
434 458
 	 */
435 459
 	protected function configureComponent($component,$name,$value)
436 460
 	{
437
-		if(strpos($name,'.')===false)	// is a simple property or custom attribute
461
+		if(strpos($name,'.')===false) {
462
+			// is a simple property or custom attribute
438 463
 			$this->configureProperty($component,$name,$value);
439
-		else	// is a subproperty
464
+		} else {
465
+			// is a subproperty
440 466
 			$this->configureSubProperty($component,$name,$value);
467
+		}
441 468
 	}
442 469
 
443 470
 	/**
@@ -449,10 +476,11 @@  discard block
 block discarded – undo
449 476
 	 */
450 477
 	protected function configureEvent($control,$name,$value,$contextControl)
451 478
 	{
452
-		if(strpos($value,'.')===false)
453
-			$control->attachEventHandler($name,array($contextControl,'TemplateControl.'.$value));
454
-		else
455
-			$control->attachEventHandler($name,array($contextControl,$value));
479
+		if(strpos($value,'.')===false) {
480
+					$control->attachEventHandler($name,array($contextControl,'TemplateControl.'.$value));
481
+		} else {
482
+					$control->attachEventHandler($name,array($contextControl,$value));
483
+		}
456 484
 	}
457 485
 
458 486
 	/**
@@ -471,9 +499,9 @@  discard block
 block discarded – undo
471 499
 					$component->bindProperty($name,$value[1]);
472 500
 					break;
473 501
 				case self::CONFIG_EXPRESSION:
474
-					if($component instanceof TControl)
475
-						$component->autoBindProperty($name,$value[1]);
476
-					else
502
+					if($component instanceof TControl) {
503
+											$component->autoBindProperty($name,$value[1]);
504
+					} else
477 505
 					{
478 506
 						$setter='set'.$name;
479 507
 						$component->$setter($this->_tplControl->evaluateExpression($value[1]));
@@ -500,12 +528,12 @@  discard block
 block discarded – undo
500 528
 					throw new TConfigurationException('template_tag_unexpected',$name,$value[1]);
501 529
 					break;
502 530
 			}
503
-		}
504
-		else
531
+		} else
505 532
 		{
506
-			if (substr($name,0,2)=='js')
507
-				if ($value and !($value instanceof TJavaScriptLiteral))
533
+			if (substr($name,0,2)=='js') {
534
+							if ($value and !($value instanceof TJavaScriptLiteral))
508 535
 					$value = new TJavaScriptLiteral($value);
536
+			}
509 537
 			$setter='set'.$name;
510 538
 			$component->$setter($value);
511 539
 		}
@@ -527,10 +555,11 @@  discard block
 block discarded – undo
527 555
 					$component->bindProperty($name,$value[1]);
528 556
 					break;
529 557
 				case self::CONFIG_EXPRESSION:		// expression
530
-					if($component instanceof TControl)
531
-						$component->autoBindProperty($name,$value[1]);
532
-					else
533
-						$component->setSubProperty($name,$this->_tplControl->evaluateExpression($value[1]));
558
+					if($component instanceof TControl) {
559
+											$component->autoBindProperty($name,$value[1]);
560
+					} else {
561
+											$component->setSubProperty($name,$this->_tplControl->evaluateExpression($value[1]));
562
+					}
534 563
 					break;
535 564
 				case self::CONFIG_TEMPLATE:
536 565
 					$component->setSubProperty($name,$value[1]);
@@ -549,9 +578,9 @@  discard block
 block discarded – undo
549 578
 					throw new TConfigurationException('template_tag_unexpected',$name,$value[1]);
550 579
 					break;
551 580
 			}
581
+		} else {
582
+					$component->setSubProperty($name,$value);
552 583
 		}
553
-		else
554
-			$component->setSubProperty($name,$value);
555 584
 	}
556 585
 
557 586
 	/**
@@ -595,34 +624,42 @@  discard block
 block discarded – undo
595 624
 				$str=$match[0][0];
596 625
 				$matchStart=$match[0][1];
597 626
 				$matchEnd=$matchStart+strlen($str)-1;
598
-				if(strpos($str,'<com:')===0)	// opening component tag
627
+				if(strpos($str,'<com:')===0) {
628
+					// opening component tag
599 629
 				{
600 630
 					if($expectPropEnd)
601 631
 						continue;
602
-					if($matchStart>$textStart)
603
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
632
+				}
633
+					if($matchStart>$textStart) {
634
+											$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
635
+					}
604 636
 					$textStart=$matchEnd+1;
605 637
 					$type=$match[1][0];
606 638
 					$attributes=$this->parseAttributes($match[2][0],$match[2][1]);
607 639
 					$this->validateAttributes($type,$attributes);
608 640
 					$tpl[$c++]=array($container,$type,$attributes);
609
-					if($str[strlen($str)-2]!=='/')  // open tag
641
+					if($str[strlen($str)-2]!=='/') {
642
+						// open tag
610 643
 					{
611 644
 						$stack[] = $type;
645
+					}
612 646
 						$container=$c-1;
613 647
 					}
614
-				}
615
-				else if(strpos($str,'</com:')===0)	// closing component tag
648
+				} else if(strpos($str,'</com:')===0) {
649
+					// closing component tag
616 650
 				{
617 651
 					if($expectPropEnd)
618 652
 						continue;
619
-					if($matchStart>$textStart)
620
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
653
+				}
654
+					if($matchStart>$textStart) {
655
+											$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
656
+					}
621 657
 					$textStart=$matchEnd+1;
622 658
 					$type=$match[1][0];
623 659
 
624
-					if(empty($stack))
625
-						throw new TConfigurationException('template_closingtag_unexpected',"</com:$type>");
660
+					if(empty($stack)) {
661
+											throw new TConfigurationException('template_closingtag_unexpected',"</com:$type>");
662
+					}
626 663
 
627 664
 					$name=array_pop($stack);
628 665
 					if($name!==$type)
@@ -631,85 +668,98 @@  discard block
 block discarded – undo
631 668
 						throw new TConfigurationException('template_closingtag_expected',$tag);
632 669
 					}
633 670
 					$container=$tpl[$container][0];
634
-				}
635
-				else if(strpos($str,'<%@')===0)	// directive
671
+				} else if(strpos($str,'<%@')===0) {
672
+					// directive
636 673
 				{
637 674
 					if($expectPropEnd)
638 675
 						continue;
639
-					if($matchStart>$textStart)
640
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
676
+				}
677
+					if($matchStart>$textStart) {
678
+											$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
679
+					}
641 680
 					$textStart=$matchEnd+1;
642
-					if(isset($tpl[0]) || $this->_directive!==null)
643
-						throw new TConfigurationException('template_directive_nonunique');
681
+					if(isset($tpl[0]) || $this->_directive!==null) {
682
+											throw new TConfigurationException('template_directive_nonunique');
683
+					}
644 684
 					$this->_directive=$this->parseAttributes($match[4][0],$match[4][1]);
645
-				}
646
-				else if(strpos($str,'<%')===0)	// expression
685
+				} else if(strpos($str,'<%')===0) {
686
+					// expression
647 687
 				{
648 688
 					if($expectPropEnd)
649 689
 						continue;
650
-					if($matchStart>$textStart)
651
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
690
+				}
691
+					if($matchStart>$textStart) {
692
+											$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
693
+					}
652 694
 					$textStart=$matchEnd+1;
653 695
 					$literal=trim($match[5][0]);
654
-					if($str[2]==='=')	// expression
696
+					if($str[2]==='=') {
697
+						// expression
655 698
 						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,$literal));
656
-					else if($str[2]==='%')  // statements
699
+					} else if($str[2]==='%') {
700
+						// statements
657 701
 						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_STATEMENTS,$literal));
658
-					else if($str[2]==='#')
659
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_DATABINDING,$literal));
660
-					else if($str[2]==='$')
661
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')"));
662
-					else if($str[2]==='~')
663
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')"));
664
-					else if($str[2]==='/')
665
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'"));
666
-					else if($str[2]==='[')
702
+					} else if($str[2]==='#') {
703
+											$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_DATABINDING,$literal));
704
+					} else if($str[2]==='$') {
705
+											$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')"));
706
+					} else if($str[2]==='~') {
707
+											$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')"));
708
+					} else if($str[2]==='/') {
709
+											$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'"));
710
+					} else if($str[2]==='[')
667 711
 					{
668 712
 						$literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\"));
669 713
 						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')"));
670 714
 					}
671
-				}
672
-				else if(strpos($str,'<prop:')===0)	// opening property
715
+				} else if(strpos($str,'<prop:')===0) {
716
+					// opening property
673 717
 				{
674 718
 					if(strrpos($str,'/>')===strlen($str)-2)  //subproperties
675 719
 					{
676 720
 						if($expectPropEnd)
677 721
 							continue;
678
-						if($matchStart>$textStart)
679
-							$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
722
+				}
723
+						if($matchStart>$textStart) {
724
+													$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
725
+						}
680 726
 						$textStart=$matchEnd+1;
681 727
 						$prop=strtolower($match[6][0]);
682 728
 						$attrs=$this->parseAttributes($match[7][0],$match[7][1]);
683 729
 						$attributes=array();
684
-						foreach($attrs as $name=>$value)
685
-							$attributes[$prop.'.'.$name]=$value;
730
+						foreach($attrs as $name=>$value) {
731
+													$attributes[$prop.'.'.$name]=$value;
732
+						}
686 733
 						$type=$tpl[$container][1];
687 734
 						$this->validateAttributes($type,$attributes);
688 735
 						foreach($attributes as $name=>$value)
689 736
 						{
690
-							if(isset($tpl[$container][2][$name]))
691
-								throw new TConfigurationException('template_property_duplicated',$name);
737
+							if(isset($tpl[$container][2][$name])) {
738
+															throw new TConfigurationException('template_property_duplicated',$name);
739
+							}
692 740
 							$tpl[$container][2][$name]=$value;
693 741
 						}
694
-					}
695
-					else  // regular property
742
+					} else  // regular property
696 743
 					{
697 744
 						$prop=strtolower($match[3][0]);
698 745
 						$stack[] = '@'.$prop;
699 746
 						if(!$expectPropEnd)
700 747
 						{
701
-							if($matchStart>$textStart)
702
-								$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
748
+							if($matchStart>$textStart) {
749
+															$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
750
+							}
703 751
 							$textStart=$matchEnd+1;
704 752
 							$expectPropEnd=true;
705 753
 						}
706 754
 					}
707
-				}
708
-				else if(strpos($str,'</prop:')===0)	// closing property
755
+				} else if(strpos($str,'</prop:')===0) {
756
+					// closing property
709 757
 				{
710 758
 					$prop=strtolower($match[3][0]);
711
-					if(empty($stack))
712
-						throw new TConfigurationException('template_closingtag_unexpected',"</prop:$prop>");
759
+				}
760
+					if(empty($stack)) {
761
+											throw new TConfigurationException('template_closingtag_unexpected',"</prop:$prop>");
762
+					}
713 763
 					$name=array_pop($stack);
714 764
 					if($name!=='@'.$prop)
715 765
 					{
@@ -721,35 +771,40 @@  discard block
 block discarded – undo
721 771
 						if($matchStart>$textStart)
722 772
 						{
723 773
 							$value=substr($input,$textStart,$matchStart-$textStart);
724
-							if(substr($prop,-8,8)==='template')
725
-								$value=$this->parseTemplateProperty($value,$textStart);
726
-							else
727
-								$value=$this->parseAttribute($value);
774
+							if(substr($prop,-8,8)==='template') {
775
+															$value=$this->parseTemplateProperty($value,$textStart);
776
+							} else {
777
+															$value=$this->parseAttribute($value);
778
+							}
728 779
 							if($container>=0)
729 780
 							{
730 781
 								$type=$tpl[$container][1];
731 782
 								$this->validateAttributes($type,array($prop=>$value));
732
-								if(isset($tpl[$container][2][$prop]))
733
-									throw new TConfigurationException('template_property_duplicated',$prop);
783
+								if(isset($tpl[$container][2][$prop])) {
784
+																	throw new TConfigurationException('template_property_duplicated',$prop);
785
+								}
734 786
 								$tpl[$container][2][$prop]=$value;
735
-							}
736
-							else	// a property for the template control
787
+							} else {
788
+								// a property for the template control
737 789
 								$this->_directive[$prop]=$value;
790
+							}
738 791
 							$textStart=$matchEnd+1;
739 792
 						}
740 793
 						$expectPropEnd=false;
741 794
 					}
742
-				}
743
-				else if(strpos($str,'<!--')===0)	// comments
795
+				} else if(strpos($str,'<!--')===0) {
796
+					// comments
744 797
 				{
745 798
 					if($expectPropEnd)
746 799
 						throw new TConfigurationException('template_comments_forbidden');
747
-					if($matchStart>$textStart)
748
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
800
+				}
801
+					if($matchStart>$textStart) {
802
+											$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
803
+					}
749 804
 					$textStart=$matchEnd+1;
805
+				} else {
806
+									throw new TConfigurationException('template_matching_unexpected',$match);
750 807
 				}
751
-				else
752
-					throw new TConfigurationException('template_matching_unexpected',$match);
753 808
 			}
754 809
 			if(!empty($stack))
755 810
 			{
@@ -757,22 +812,25 @@  discard block
 block discarded – undo
757 812
 				$tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>";
758 813
 				throw new TConfigurationException('template_closingtag_expected',$tag);
759 814
 			}
760
-			if($textStart<strlen($input))
761
-				$tpl[$c++]=array($container,substr($input,$textStart));
762
-		}
763
-		catch(Exception $e)
815
+			if($textStart<strlen($input)) {
816
+							$tpl[$c++]=array($container,substr($input,$textStart));
817
+			}
818
+		} catch(Exception $e)
764 819
 		{
765
-			if(($e instanceof TException) && ($e instanceof TTemplateException))
766
-				throw $e;
767
-			if($matchEnd===0)
768
-				$line=$this->_startingLine+1;
769
-			else
770
-				$line=$this->_startingLine+count(explode("\n",substr($input,0,$matchEnd+1)));
820
+			if(($e instanceof TException) && ($e instanceof TTemplateException)) {
821
+							throw $e;
822
+			}
823
+			if($matchEnd===0) {
824
+							$line=$this->_startingLine+1;
825
+			} else {
826
+							$line=$this->_startingLine+count(explode("\n",substr($input,0,$matchEnd+1)));
827
+			}
771 828
 			$this->handleException($e,$line,$input);
772 829
 		}
773 830
 
774
-		if($this->_directive===null)
775
-			$this->_directive=array();
831
+		if($this->_directive===null) {
832
+					$this->_directive=array();
833
+		}
776 834
 
777 835
 		// optimization by merging consecutive strings, expressions, statements and bindings
778 836
 		$objects=array();
@@ -784,31 +842,32 @@  discard block
 block discarded – undo
784 842
 			{
785 843
 				if($parent!==null)
786 844
 				{
787
-					if(count($merged[1])===1 && is_string($merged[1][0]))
788
-						$objects[$id-1]=array($merged[0],$merged[1][0]);
789
-					else
790
-						$objects[$id-1]=array($merged[0],new TCompositeLiteral($merged[1]));
845
+					if(count($merged[1])===1 && is_string($merged[1][0])) {
846
+											$objects[$id-1]=array($merged[0],$merged[1][0]);
847
+					} else {
848
+											$objects[$id-1]=array($merged[0],new TCompositeLiteral($merged[1]));
849
+					}
791 850
 				}
792 851
 				if(isset($object[2]))
793 852
 				{
794 853
 					$parent=null;
795 854
 					$objects[$id]=$object;
796
-				}
797
-				else
855
+				} else
798 856
 				{
799 857
 					$parent=$object[0];
800 858
 					$merged=array($parent,array($object[1]));
801 859
 				}
860
+			} else {
861
+							$merged[1][]=$object[1];
802 862
 			}
803
-			else
804
-				$merged[1][]=$object[1];
805 863
 		}
806 864
 		if($parent!==null)
807 865
 		{
808
-			if(count($merged[1])===1 && is_string($merged[1][0]))
809
-				$objects[$id]=array($merged[0],$merged[1][0]);
810
-			else
811
-				$objects[$id]=array($merged[0],new TCompositeLiteral($merged[1]));
866
+			if(count($merged[1])===1 && is_string($merged[1][0])) {
867
+							$objects[$id]=array($merged[0],$merged[1][0]);
868
+			} else {
869
+							$objects[$id]=array($merged[0],new TCompositeLiteral($merged[1]));
870
+			}
812 871
 		}
813 872
 		$tpl=$objects;
814 873
 		return $objects;
@@ -821,8 +880,9 @@  discard block
 block discarded – undo
821 880
 	 */
822 881
 	protected function parseAttributes($str,$offset)
823 882
 	{
824
-		if($str==='')
825
-			return array();
883
+		if($str==='') {
884
+					return array();
885
+		}
826 886
 		$pattern='/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS';
827 887
 		$attributes=array();
828 888
 		$n=preg_match_all($pattern,$str,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
@@ -830,22 +890,24 @@  discard block
 block discarded – undo
830 890
 		{
831 891
 			$match=&$matches[$i];
832 892
 			$name=strtolower($match[1][0]);
833
-			if(isset($attributes[$name]))
834
-				throw new TConfigurationException('template_property_duplicated',$name);
893
+			if(isset($attributes[$name])) {
894
+							throw new TConfigurationException('template_property_duplicated',$name);
895
+			}
835 896
 			$value=$match[2][0];
836 897
 			if(substr($name,-8,8)==='template')
837 898
 			{
838
-				if($value[0]==='\'' || $value[0]==='"')
839
-					$attributes[$name]=$this->parseTemplateProperty(substr($value,1,strlen($value)-2),$match[2][1]+1);
840
-				else
841
-					$attributes[$name]=$this->parseTemplateProperty($value,$match[2][1]);
842
-			}
843
-			else
899
+				if($value[0]==='\'' || $value[0]==='"') {
900
+									$attributes[$name]=$this->parseTemplateProperty(substr($value,1,strlen($value)-2),$match[2][1]+1);
901
+				} else {
902
+									$attributes[$name]=$this->parseTemplateProperty($value,$match[2][1]);
903
+				}
904
+			} else
844 905
 			{
845
-				if($value[0]==='\'' || $value[0]==='"')
846
-					$attributes[$name]=$this->parseAttribute(substr($value,1,strlen($value)-2));
847
-				else
848
-					$attributes[$name]=$this->parseAttribute($value);
906
+				if($value[0]==='\'' || $value[0]==='"') {
907
+									$attributes[$name]=$this->parseAttribute(substr($value,1,strlen($value)-2));
908
+				} else {
909
+									$attributes[$name]=$this->parseAttribute($value);
910
+				}
849 911
 			}
850 912
 		}
851 913
 		return $attributes;
@@ -875,46 +937,50 @@  discard block
 block discarded – undo
875 937
 				$token=$match[0];
876 938
 				$offset=$match[1];
877 939
 				$length=strlen($token);
878
-				if($token[2]==='#')
879
-					$isDataBind=true;
880
-				if($offset>$textStart)
881
-					$expr.=".'".strtr(substr($value,$textStart,$offset-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'";
940
+				if($token[2]==='#') {
941
+									$isDataBind=true;
942
+				}
943
+				if($offset>$textStart) {
944
+									$expr.=".'".strtr(substr($value,$textStart,$offset-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'";
945
+				}
882 946
 				$expr.='.('.substr($token,3,$length-5).')';
883 947
 				$textStart=$offset+$length;
884 948
 			}
885 949
 			$length=strlen($value);
886
-			if($length>$textStart)
887
-				$expr.=".'".strtr(substr($value,$textStart,$length-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'";
888
-			if($isDataBind)
889
-				return array(self::CONFIG_DATABIND,ltrim($expr,'.'));
890
-			else
891
-				return array(self::CONFIG_EXPRESSION,ltrim($expr,'.'));
892
-		}
893
-		else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value)
950
+			if($length>$textStart) {
951
+							$expr.=".'".strtr(substr($value,$textStart,$length-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'";
952
+			}
953
+			if($isDataBind) {
954
+							return array(self::CONFIG_DATABIND,ltrim($expr,'.'));
955
+			} else {
956
+							return array(self::CONFIG_EXPRESSION,ltrim($expr,'.'));
957
+			}
958
+		} else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value)
894 959
 		{
895 960
 			$value=$matches[1];
896
-			if($value[2]==='~')
897
-				return array(self::CONFIG_ASSET,trim(substr($value,3,strlen($value)-5)));
898
-			elseif($value[2]==='[')
899
-				return array(self::CONFIG_LOCALIZATION,trim(substr($value,3,strlen($value)-6)));
900
-			elseif($value[2]==='$')
901
-				return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5)));
902
-			elseif($value[2]==='/') {
961
+			if($value[2]==='~') {
962
+							return array(self::CONFIG_ASSET,trim(substr($value,3,strlen($value)-5)));
963
+			} elseif($value[2]==='[') {
964
+							return array(self::CONFIG_LOCALIZATION,trim(substr($value,3,strlen($value)-6)));
965
+			} elseif($value[2]==='$') {
966
+							return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5)));
967
+			} elseif($value[2]==='/') {
903 968
 				$literal = trim(substr($value,3,strlen($value)-5));
904 969
 				return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'");
905 970
 			}
971
+		} else {
972
+					return $value;
906 973
 		}
907
-		else
908
-			return $value;
909 974
 	}
910 975
 
911 976
 	protected function validateAttributes($type,$attributes)
912 977
 	{
913 978
 		Prado::using($type);
914
-		if(($pos=strrpos($type,'.'))!==false)
915
-			$className=substr($type,$pos+1);
916
-		else
917
-			$className=$type;
979
+		if(($pos=strrpos($type,'.'))!==false) {
980
+					$className=substr($type,$pos+1);
981
+		} else {
982
+					$className=$type;
983
+		}
918 984
 		$class=new ReflectionClass($className);
919 985
 		if(is_subclass_of($className,'TControl') || $className==='TControl')
920 986
 		{
@@ -924,67 +990,69 @@  discard block
 block discarded – undo
924 990
 				{
925 991
 					// a subproperty, so the first segment must be readable
926 992
 					$subname=substr($name,0,$pos);
927
-					if(!$class->hasMethod('get'.$subname))
928
-						throw new TConfigurationException('template_property_unknown',$type,$subname);
929
-				}
930
-				else if(strncasecmp($name,'on',2)===0)
993
+					if(!$class->hasMethod('get'.$subname)) {
994
+											throw new TConfigurationException('template_property_unknown',$type,$subname);
995
+					}
996
+				} else if(strncasecmp($name,'on',2)===0)
931 997
 				{
932 998
 					// an event
933
-					if(!$class->hasMethod($name))
934
-						throw new TConfigurationException('template_event_unknown',$type,$name);
935
-					else if(!is_string($att))
936
-						throw new TConfigurationException('template_eventhandler_invalid',$type,$name);
937
-				}
938
-				else
999
+					if(!$class->hasMethod($name)) {
1000
+											throw new TConfigurationException('template_event_unknown',$type,$name);
1001
+					} else if(!is_string($att)) {
1002
+											throw new TConfigurationException('template_eventhandler_invalid',$type,$name);
1003
+					}
1004
+				} else
939 1005
 				{
940 1006
 					// a simple property
941 1007
 					if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)) )
942 1008
 					{
943
-						if ($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name))
944
-							throw new TConfigurationException('template_property_readonly',$type,$name);
945
-						else
946
-							throw new TConfigurationException('template_property_unknown',$type,$name);
947
-					}
948
-					else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION)
1009
+						if ($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name)) {
1010
+													throw new TConfigurationException('template_property_readonly',$type,$name);
1011
+						} else {
1012
+													throw new TConfigurationException('template_property_unknown',$type,$name);
1013
+						}
1014
+					} else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION)
949 1015
 					{
950
-						if(strcasecmp($name,'id')===0)
951
-							throw new TConfigurationException('template_controlid_invalid',$type);
952
-						else if(strcasecmp($name,'skinid')===0)
953
-							throw new TConfigurationException('template_controlskinid_invalid',$type);
1016
+						if(strcasecmp($name,'id')===0) {
1017
+													throw new TConfigurationException('template_controlid_invalid',$type);
1018
+						} else if(strcasecmp($name,'skinid')===0) {
1019
+													throw new TConfigurationException('template_controlskinid_invalid',$type);
1020
+						}
954 1021
 					}
955 1022
 				}
956 1023
 			}
957
-		}
958
-		else if(is_subclass_of($className,'TComponent') || $className==='TComponent')
1024
+		} else if(is_subclass_of($className,'TComponent') || $className==='TComponent')
959 1025
 		{
960 1026
 			foreach($attributes as $name=>$att)
961 1027
 			{
962
-				if(is_array($att) && ($att[0]===self::CONFIG_DATABIND))
963
-					throw new TConfigurationException('template_databind_forbidden',$type,$name);
1028
+				if(is_array($att) && ($att[0]===self::CONFIG_DATABIND)) {
1029
+									throw new TConfigurationException('template_databind_forbidden',$type,$name);
1030
+				}
964 1031
 				if(($pos=strpos($name,'.'))!==false)
965 1032
 				{
966 1033
 					// a subproperty, so the first segment must be readable
967 1034
 					$subname=substr($name,0,$pos);
968
-					if(!$class->hasMethod('get'.$subname))
969
-						throw new TConfigurationException('template_property_unknown',$type,$subname);
970
-				}
971
-				else if(strncasecmp($name,'on',2)===0)
972
-					throw new TConfigurationException('template_event_forbidden',$type,$name);
973
-				else
1035
+					if(!$class->hasMethod('get'.$subname)) {
1036
+											throw new TConfigurationException('template_property_unknown',$type,$subname);
1037
+					}
1038
+				} else if(strncasecmp($name,'on',2)===0) {
1039
+									throw new TConfigurationException('template_event_forbidden',$type,$name);
1040
+				} else
974 1041
 				{
975 1042
 					// id is still alowed for TComponent, even if id property doesn't exist
976 1043
 					if(strcasecmp($name,'id')!==0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)))
977 1044
 					{
978
-						if($class->hasMethod('get'.$name))
979
-							throw new TConfigurationException('template_property_readonly',$type,$name);
980
-						else
981
-							throw new TConfigurationException('template_property_unknown',$type,$name);
1045
+						if($class->hasMethod('get'.$name)) {
1046
+													throw new TConfigurationException('template_property_readonly',$type,$name);
1047
+						} else {
1048
+													throw new TConfigurationException('template_property_unknown',$type,$name);
1049
+						}
982 1050
 					}
983 1051
 				}
984 1052
 			}
1053
+		} else {
1054
+					throw new TConfigurationException('template_component_required',$type);
985 1055
 		}
986
-		else
987
-			throw new TConfigurationException('template_component_required',$type);
988 1056
 	}
989 1057
 
990 1058
 	/**
@@ -1007,9 +1075,12 @@  discard block
 block discarded – undo
1007 1075
 	{
1008 1076
 		$srcFile=$this->_tplFile;
1009 1077
 
1010
-		if(($n=count($this->_includedFiles))>0) // need to adjust error row number and file name
1078
+		if(($n=count($this->_includedFiles))>0) {
1079
+			// need to adjust error row number and file name
1011 1080
 		{
1012
-			for($i=$n-1;$i>=0;--$i)
1081
+			for($i=$n-1;
1082
+		}
1083
+		$i>=0;--$i)
1013 1084
 			{
1014 1085
 				if($this->_includeAtLine[$i]<=$line)
1015 1086
 				{
@@ -1018,18 +1089,19 @@  discard block
 block discarded – undo
1018 1089
 						$line=$line-$this->_includeAtLine[$i]+1;
1019 1090
 						$srcFile=$this->_includedFiles[$i];
1020 1091
 						break;
1092
+					} else {
1093
+											$line=$line-$this->_includeLines[$i]+1;
1021 1094
 					}
1022
-					else
1023
-						$line=$line-$this->_includeLines[$i]+1;
1024 1095
 				}
1025 1096
 			}
1026 1097
 		}
1027 1098
 		$exception=new TTemplateException('template_format_invalid',$e->getMessage());
1028 1099
 		$exception->setLineNumber($line);
1029
-		if(!empty($srcFile))
1030
-			$exception->setTemplateFile($srcFile);
1031
-		else
1032
-			$exception->setTemplateSource($input);
1100
+		if(!empty($srcFile)) {
1101
+					$exception->setTemplateFile($srcFile);
1102
+		} else {
1103
+					$exception->setTemplateSource($input);
1104
+		}
1033 1105
 		throw $exception;
1034 1106
 	}
1035 1107
 
@@ -1045,9 +1117,9 @@  discard block
 block discarded – undo
1045 1117
 			for($i=0;$i<$n;++$i)
1046 1118
 			{
1047 1119
 				$filePath=Prado::getPathOfNamespace(trim($matches[$i][1][0]),TTemplateManager::TEMPLATE_FILE_EXT);
1048
-				if($filePath!==null && is_file($filePath))
1049
-					$this->_includedFiles[]=$filePath;
1050
-				else
1120
+				if($filePath!==null && is_file($filePath)) {
1121
+									$this->_includedFiles[]=$filePath;
1122
+				} else
1051 1123
 				{
1052 1124
 					$errorLine=count(explode("\n",substr($input,0,$matches[$i][0][1]+1)));
1053 1125
 					$this->handleException(new TConfigurationException('template_include_invalid',trim($matches[$i][1][0])),$errorLine,$input);
@@ -1079,15 +1151,19 @@  discard block
 block discarded – undo
1079 1151
 	{
1080 1152
 	  $component=new ReflectionClass('TComponent');
1081 1153
 	  $behaviors=$component->getStaticProperties();
1082
-	  if(!isset($behaviors['_um']))
1083
-	    return false;
1154
+	  if(!isset($behaviors['_um'])) {
1155
+	  	    return false;
1156
+	  }
1084 1157
 	  foreach($behaviors['_um'] as $name=>$list)
1085 1158
 	  {
1086
-	    if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue;
1159
+	    if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) {
1160
+	    	continue;
1161
+	    }
1087 1162
 	    foreach($list as $param)
1088 1163
 	    {
1089
-	      if(method_exists($param->getBehavior(),$method))
1090
-	        return true;
1164
+	      if(method_exists($param->getBehavior(),$method)) {
1165
+	      	        return true;
1166
+	      }
1091 1167
 	    }
1092 1168
 	  }
1093 1169
 	  return false;
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/assets/captcha.php 4 patches
Doc Comments   +20 added lines patch added patch discarded remove patch
@@ -54,6 +54,9 @@  discard block
 block discarded – undo
54 54
 	return $caseSensitive?$token:strtoupper($token);
55 55
 }
56 56
 
57
+/**
58
+ * @param string $hex
59
+ */
57 60
 function hash2string($hex,$alphabet)
58 61
 {
59 62
 	if(strlen($alphabet)<2)
@@ -121,6 +124,11 @@  discard block
 block discarded – undo
121 124
 	imagedestroy($image);
122 125
 }
123 126
 
127
+/**
128
+ * @param resource $image
129
+ * @param double $width
130
+ * @param double $height
131
+ */
124 132
 function addBackground($image,$width,$height,$opaque,$noisy,$hasGrid,$hasScribble,$morph)
125 133
 {
126 134
 	$background=imagecreatetruecolor($width*2,$height*2);
@@ -148,6 +156,9 @@  discard block
 block discarded – undo
148 156
 		imagecolortransparent($image,$white);
149 157
 }
150 158
 
159
+/**
160
+ * @param resource $image
161
+ */
151 162
 function addNoise($image,$width,$height)
152 163
 {
153 164
 	for($x=0;$x<$width;++$x)
@@ -164,6 +175,9 @@  discard block
 block discarded – undo
164 175
 	}
165 176
 }
166 177
 
178
+/**
179
+ * @param resource $image
180
+ */
167 181
 function addGrid($image,$width,$height)
168 182
 {
169 183
 	for($i=0;$i<$width;$i+=rand(15,25))
@@ -182,6 +196,9 @@  discard block
 block discarded – undo
182 196
 	}
183 197
 }
184 198
 
199
+/**
200
+ * @param resource $image
201
+ */
185 202
 function addScribble($image,$width,$height)
186 203
 {
187 204
 	for($i=0;$i<8;$i++)
@@ -199,6 +216,9 @@  discard block
 block discarded – undo
199 216
 	}
200 217
 }
201 218
 
219
+/**
220
+ * @param resource $image
221
+ */
202 222
 function morphImage($image,$width,$height)
203 223
 {
204 224
 	$tempImage=imagecreatetruecolor($width,$height);
Please login to merge, or discard this patch.
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -100,21 +100,21 @@  discard block
 block discarded – undo
100 100
 	$font=dirname(__FILE__).DIRECTORY_SEPARATOR.'verase.ttf';
101 101
 
102 102
 	if(function_exists('imagefilter'))
103
-    	imagefilter($image,IMG_FILTER_GAUSSIAN_BLUR);
103
+		imagefilter($image,IMG_FILTER_GAUSSIAN_BLUR);
104 104
 
105 105
 	$hasShadow=($theme&THEME_SHADOWED_TEXT);
106
-    for($i=0;$i<$length;$i++)
106
+	for($i=0;$i<$length;$i++)
107 107
 	{
108
-        $color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220));
109
-        $size=rand($fontWidth-10,$fontWidth);
110
-        $angle=rand(-30,30);
111
-        $x=$padding+$i*$fontWidth;
112
-        $y=rand($fontHeight-15,$fontHeight-10);
113
-        imagettftext($image,$size,$angle,$x,$y,$color,$font,$token[$i]);
114
-        if($hasShadow)
115
-        	imagettftext($image,$size,$angle,$x+2,$y+2,$color,$font,$token[$i]);
116
-        imagecolordeallocate($image,$color);
117
-    }
108
+		$color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220));
109
+		$size=rand($fontWidth-10,$fontWidth);
110
+		$angle=rand(-30,30);
111
+		$x=$padding+$i*$fontWidth;
112
+		$y=rand($fontHeight-15,$fontHeight-10);
113
+		imagettftext($image,$size,$angle,$x,$y,$color,$font,$token[$i]);
114
+		if($hasShadow)
115
+			imagettftext($image,$size,$angle,$x+2,$y+2,$color,$font,$token[$i]);
116
+		imagecolordeallocate($image,$color);
117
+	}
118 118
 
119 119
 	header('Content-Type: image/png');
120 120
 	imagepng($image);
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 			{
159 159
 				$color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220));
160 160
 				imagesetpixel($image,$x,$y,$color);
161
-	            imagecolordeallocate($image,$color);
162
-	        }
161
+				imagecolordeallocate($image,$color);
162
+			}
163 163
 		}
164 164
 	}
165 165
 }
Please login to merge, or discard this patch.
Spacing   +133 added lines, -134 removed lines patch added patch discarded remove patch
@@ -9,111 +9,110 @@  discard block
 block discarded – undo
9 9
  * @package System.Web.UI.WebControls.assets
10 10
  */
11 11
 
12
-define('THEME_OPAQUE_BACKGROUND',0x0001);
13
-define('THEME_NOISY_BACKGROUND',0x0002);
14
-define('THEME_HAS_GRID',0x0004);
15
-define('THEME_HAS_SCRIBBLE',0x0008);
16
-define('THEME_MORPH_BACKGROUND',0x0010);
17
-define('THEME_SHADOWED_TEXT',0x0020);
12
+define('THEME_OPAQUE_BACKGROUND', 0x0001);
13
+define('THEME_NOISY_BACKGROUND', 0x0002);
14
+define('THEME_HAS_GRID', 0x0004);
15
+define('THEME_HAS_SCRIBBLE', 0x0008);
16
+define('THEME_MORPH_BACKGROUND', 0x0010);
17
+define('THEME_SHADOWED_TEXT', 0x0020);
18 18
 
19
-require_once(dirname(__FILE__).'/captcha_key.php');
19
+require_once(dirname(__FILE__) . '/captcha_key.php');
20 20
 
21
-$token='error';
22
-$theme=0;
21
+$token = 'error';
22
+$theme = 0;
23 23
 
24
-if(isset($_GET['options']))
24
+if (isset($_GET['options']))
25 25
 {
26
-	$str=base64_decode($_GET['options']);
27
-	if(strlen($str)>32)
26
+	$str = base64_decode($_GET['options']);
27
+	if (strlen($str) > 32)
28 28
 	{
29
-		$hash=substr($str,0,32);
30
-		$str=substr($str,32);
31
-		if(md5($privateKey.$str)===$hash)
29
+		$hash = substr($str, 0, 32);
30
+		$str = substr($str, 32);
31
+		if (md5($privateKey . $str) === $hash)
32 32
 		{
33
-			$options=unserialize($str);
34
-			$publicKey=$options['publicKey'];
35
-			$tokenLength=$options['tokenLength'];
36
-			$caseSensitive=$options['caseSensitive'];
37
-			$alphabet=$options['alphabet'];
38
-			$fontSize=$options['fontSize'];
39
-			$theme=$options['theme'];
40
-			if(($randomSeed=$options['randomSeed'])>0)
33
+			$options = unserialize($str);
34
+			$publicKey = $options['publicKey'];
35
+			$tokenLength = $options['tokenLength'];
36
+			$caseSensitive = $options['caseSensitive'];
37
+			$alphabet = $options['alphabet'];
38
+			$fontSize = $options['fontSize'];
39
+			$theme = $options['theme'];
40
+			if (($randomSeed = $options['randomSeed']) > 0)
41 41
 				srand($randomSeed);
42 42
 			else
43
-				srand((int)(microtime()*1000000));
44
-			$token=generateToken($publicKey,$privateKey,$alphabet,$tokenLength,$caseSensitive);
43
+				srand((int) (microtime() * 1000000));
44
+			$token = generateToken($publicKey, $privateKey, $alphabet, $tokenLength, $caseSensitive);
45 45
 		}
46 46
 	}
47 47
 }
48 48
 
49
-displayToken($token,$fontSize,$theme);
49
+displayToken($token, $fontSize, $theme);
50 50
 
51
-function generateToken($publicKey,$privateKey,$alphabet,$tokenLength,$caseSensitive)
51
+function generateToken($publicKey, $privateKey, $alphabet, $tokenLength, $caseSensitive)
52 52
 {
53
-	$token=substr(hash2string(md5($publicKey.$privateKey),$alphabet).hash2string(md5($privateKey.$publicKey),$alphabet),0,$tokenLength);
54
-	return $caseSensitive?$token:strtoupper($token);
53
+	$token = substr(hash2string(md5($publicKey . $privateKey), $alphabet) . hash2string(md5($privateKey . $publicKey), $alphabet), 0, $tokenLength);
54
+	return $caseSensitive ? $token : strtoupper($token);
55 55
 }
56 56
 
57
-function hash2string($hex,$alphabet)
57
+function hash2string($hex, $alphabet)
58 58
 {
59
-	if(strlen($alphabet)<2)
60
-		$alphabet='234578adefhijmnrtABDEFGHJLMNRT';
61
-	$hexLength=strlen($hex);
62
-	$base=strlen($alphabet);
63
-	$result='';
64
-	for($i=0;$i<$hexLength;$i+=6)
59
+	if (strlen($alphabet) < 2)
60
+		$alphabet = '234578adefhijmnrtABDEFGHJLMNRT';
61
+	$hexLength = strlen($hex);
62
+	$base = strlen($alphabet);
63
+	$result = '';
64
+	for ($i = 0; $i < $hexLength; $i += 6)
65 65
 	{
66
-		$number=hexdec(substr($hex,$i,6));
67
-		while($number)
66
+		$number = hexdec(substr($hex, $i, 6));
67
+		while ($number)
68 68
 		{
69
-			$result.=$alphabet[$number%$base];
70
-			$number=floor($number/$base);
69
+			$result .= $alphabet[$number % $base];
70
+			$number = floor($number / $base);
71 71
 		}
72 72
 	}
73 73
 	return $result;
74 74
 }
75 75
 
76
-function displayToken($token,$fontSize,$theme)
76
+function displayToken($token, $fontSize, $theme)
77 77
 {
78
-	if(($fontSize=(int)$fontSize)<22)
79
-		$fontSize=22;
80
-	if($fontSize>100)
81
-		$fontSize=100;
82
-	$length=strlen($token);
83
-	$padding=10;
84
-	$fontWidth=$fontSize;
85
-	$fontHeight=floor($fontWidth*1.5);
86
-	$width=$fontWidth*$length+$padding*2;
87
-	$height=$fontHeight;
88
-	$image=imagecreatetruecolor($width,$height);
89
-
90
-	addBackground
91
-	(
78
+	if (($fontSize = (int) $fontSize) < 22)
79
+		$fontSize = 22;
80
+	if ($fontSize > 100)
81
+		$fontSize = 100;
82
+	$length = strlen($token);
83
+	$padding = 10;
84
+	$fontWidth = $fontSize;
85
+	$fontHeight = floor($fontWidth * 1.5);
86
+	$width = $fontWidth * $length + $padding * 2;
87
+	$height = $fontHeight;
88
+	$image = imagecreatetruecolor($width, $height);
89
+
90
+	addBackground(
92 91
 		$image, $width, $height,
93
-		$theme&THEME_OPAQUE_BACKGROUND,
94
-		$theme&THEME_NOISY_BACKGROUND,
95
-		$theme&THEME_HAS_GRID,
96
-		$theme&THEME_HAS_SCRIBBLE,
97
-		$theme&THEME_MORPH_BACKGROUND
92
+		$theme & THEME_OPAQUE_BACKGROUND,
93
+		$theme & THEME_NOISY_BACKGROUND,
94
+		$theme & THEME_HAS_GRID,
95
+		$theme & THEME_HAS_SCRIBBLE,
96
+		$theme & THEME_MORPH_BACKGROUND
98 97
 	);
99 98
 
100
-	$font=dirname(__FILE__).DIRECTORY_SEPARATOR.'verase.ttf';
99
+	$font = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'verase.ttf';
101 100
 
102
-	if(function_exists('imagefilter'))
103
-    	imagefilter($image,IMG_FILTER_GAUSSIAN_BLUR);
101
+	if (function_exists('imagefilter'))
102
+    	imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR);
104 103
 
105
-	$hasShadow=($theme&THEME_SHADOWED_TEXT);
106
-    for($i=0;$i<$length;$i++)
104
+	$hasShadow = ($theme & THEME_SHADOWED_TEXT);
105
+    for ($i = 0; $i < $length; $i++)
107 106
 	{
108
-        $color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220));
109
-        $size=rand($fontWidth-10,$fontWidth);
110
-        $angle=rand(-30,30);
111
-        $x=$padding+$i*$fontWidth;
112
-        $y=rand($fontHeight-15,$fontHeight-10);
113
-        imagettftext($image,$size,$angle,$x,$y,$color,$font,$token[$i]);
114
-        if($hasShadow)
115
-        	imagettftext($image,$size,$angle,$x+2,$y+2,$color,$font,$token[$i]);
116
-        imagecolordeallocate($image,$color);
107
+        $color = imagecolorallocate($image, rand(150, 220), rand(150, 220), rand(150, 220));
108
+        $size = rand($fontWidth - 10, $fontWidth);
109
+        $angle = rand(-30, 30);
110
+        $x = $padding + $i * $fontWidth;
111
+        $y = rand($fontHeight - 15, $fontHeight - 10);
112
+        imagettftext($image, $size, $angle, $x, $y, $color, $font, $token[$i]);
113
+        if ($hasShadow)
114
+        	imagettftext($image, $size, $angle, $x + 2, $y + 2, $color, $font, $token[$i]);
115
+        imagecolordeallocate($image, $color);
117 116
     }
118 117
 
119 118
 	header('Content-Type: image/png');
@@ -121,103 +120,103 @@  discard block
 block discarded – undo
121 120
 	imagedestroy($image);
122 121
 }
123 122
 
124
-function addBackground($image,$width,$height,$opaque,$noisy,$hasGrid,$hasScribble,$morph)
123
+function addBackground($image, $width, $height, $opaque, $noisy, $hasGrid, $hasScribble, $morph)
125 124
 {
126
-	$background=imagecreatetruecolor($width*2,$height*2);
127
-	$white=imagecolorallocate($background,255,255,255);
128
-	imagefill($background,0,0,$white);
125
+	$background = imagecreatetruecolor($width * 2, $height * 2);
126
+	$white = imagecolorallocate($background, 255, 255, 255);
127
+	imagefill($background, 0, 0, $white);
129 128
 
130
-	if($opaque)
131
-		imagefill($background,0,0,imagecolorallocate($background,100,100,100));
129
+	if ($opaque)
130
+		imagefill($background, 0, 0, imagecolorallocate($background, 100, 100, 100));
132 131
 
133
-	if($noisy)
134
-		addNoise($background,$width*2,$height*2);
132
+	if ($noisy)
133
+		addNoise($background, $width * 2, $height * 2);
135 134
 
136
-	if($hasGrid)
137
-		addGrid($background,$width*2,$height*2);
135
+	if ($hasGrid)
136
+		addGrid($background, $width * 2, $height * 2);
138 137
 
139
-	if($hasScribble)
140
-		addScribble($background,$width*2,$height*2);
138
+	if ($hasScribble)
139
+		addScribble($background, $width * 2, $height * 2);
141 140
 
142
-	if($morph)
143
-		morphImage($background,$width*2,$height*2);
141
+	if ($morph)
142
+		morphImage($background, $width * 2, $height * 2);
144 143
 
145
-	imagecopy($image,$background,0,0,30,30,$width,$height);
144
+	imagecopy($image, $background, 0, 0, 30, 30, $width, $height);
146 145
 
147
-	if(!$opaque)
148
-		imagecolortransparent($image,$white);
146
+	if (!$opaque)
147
+		imagecolortransparent($image, $white);
149 148
 }
150 149
 
151
-function addNoise($image,$width,$height)
150
+function addNoise($image, $width, $height)
152 151
 {
153
-	for($x=0;$x<$width;++$x)
152
+	for ($x = 0; $x < $width; ++$x)
154 153
 	{
155
-		for($y=0;$y<$height;++$y)
154
+		for ($y = 0; $y < $height; ++$y)
156 155
 		{
157
-			if(rand(0,100)<25)
156
+			if (rand(0, 100) < 25)
158 157
 			{
159
-				$color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220));
160
-				imagesetpixel($image,$x,$y,$color);
161
-	            imagecolordeallocate($image,$color);
158
+				$color = imagecolorallocate($image, rand(150, 220), rand(150, 220), rand(150, 220));
159
+				imagesetpixel($image, $x, $y, $color);
160
+	            imagecolordeallocate($image, $color);
162 161
 	        }
163 162
 		}
164 163
 	}
165 164
 }
166 165
 
167
-function addGrid($image,$width,$height)
166
+function addGrid($image, $width, $height)
168 167
 {
169
-	for($i=0;$i<$width;$i+=rand(15,25))
168
+	for ($i = 0; $i < $width; $i += rand(15, 25))
170 169
 	{
171
-		imagesetthickness($image,rand(2,6));
172
-		$color=imagecolorallocate($image,rand(100,180),rand(100,180),rand(100,180));
173
-		imageline($image,$i+rand(-10,20),0,$i+rand(-10,20),$height,$color);
174
-		imagecolordeallocate($image,$color);
170
+		imagesetthickness($image, rand(2, 6));
171
+		$color = imagecolorallocate($image, rand(100, 180), rand(100, 180), rand(100, 180));
172
+		imageline($image, $i + rand(-10, 20), 0, $i + rand(-10, 20), $height, $color);
173
+		imagecolordeallocate($image, $color);
175 174
 	}
176
-	for($i=0;$i<$height;$i+=rand(15,25))
175
+	for ($i = 0; $i < $height; $i += rand(15, 25))
177 176
 	{
178
-		imagesetthickness($image,rand(2,6));
179
-		$color=imagecolorallocate($image,rand(100,180),rand(100,180),rand(100,180));
180
-		imageline($image,0,$i+rand(-10,20),$width,$i+rand(-10,20),$color);
181
-		imagecolordeallocate($image,$color);
177
+		imagesetthickness($image, rand(2, 6));
178
+		$color = imagecolorallocate($image, rand(100, 180), rand(100, 180), rand(100, 180));
179
+		imageline($image, 0, $i + rand(-10, 20), $width, $i + rand(-10, 20), $color);
180
+		imagecolordeallocate($image, $color);
182 181
 	}
183 182
 }
184 183
 
185
-function addScribble($image,$width,$height)
184
+function addScribble($image, $width, $height)
186 185
 {
187
-	for($i=0;$i<8;$i++)
186
+	for ($i = 0; $i < 8; $i++)
188 187
 	{
189
-		$color=imagecolorallocate($image,rand(100,180),rand(100,180),rand(100,180));
190
-		$points=array();
191
-		for($j=1;$j<rand(5,10);$j++)
188
+		$color = imagecolorallocate($image, rand(100, 180), rand(100, 180), rand(100, 180));
189
+		$points = array();
190
+		for ($j = 1; $j < rand(5, 10); $j++)
192 191
 		{
193
-			$points[]=rand(2*(20*($i+1)),2*(50*($i+1)));
194
-			$points[]=rand(30,$height+30);
192
+			$points[] = rand(2 * (20 * ($i + 1)), 2 * (50 * ($i + 1)));
193
+			$points[] = rand(30, $height + 30);
195 194
 		}
196
-		imagesetthickness($image,rand(2,6));
197
-		imagepolygon($image,$points,intval(sizeof($points)/2),$color);
198
-		imagecolordeallocate($image,$color);
195
+		imagesetthickness($image, rand(2, 6));
196
+		imagepolygon($image, $points, intval(sizeof($points) / 2), $color);
197
+		imagecolordeallocate($image, $color);
199 198
 	}
200 199
 }
201 200
 
202
-function morphImage($image,$width,$height)
201
+function morphImage($image, $width, $height)
203 202
 {
204
-	$tempImage=imagecreatetruecolor($width,$height);
205
-	$chunk=rand(1,5);
206
-	for($x=$y=0;$x<$width;$x+=$chunk)
203
+	$tempImage = imagecreatetruecolor($width, $height);
204
+	$chunk = rand(1, 5);
205
+	for ($x = $y = 0; $x < $width; $x += $chunk)
207 206
 	{
208
-		$chunk=rand(1,5);
209
-		$y+=rand(-1,1);
210
-		if($y>=$height)	$y=$height-5;
211
-		if($y<0) $y=5;
212
-		imagecopy($tempImage,$image,$x,0,$x,$y,$chunk,$height);
207
+		$chunk = rand(1, 5);
208
+		$y += rand(-1, 1);
209
+		if ($y >= $height)	$y = $height - 5;
210
+		if ($y < 0) $y = 5;
211
+		imagecopy($tempImage, $image, $x, 0, $x, $y, $chunk, $height);
213 212
 	}
214
-	for($x=$y=0;$y<$height;$y+=$chunk)
213
+	for ($x = $y = 0; $y < $height; $y += $chunk)
215 214
 	{
216
-		$chunk=rand(1,5);
217
-		$x+=rand(-1,1);
218
-		if($x>=$width)	$x=$width-5;
219
-		if($x<0) $x=5;
220
-		imagecopy($image,$tempImage,$x,$y,0,$y,$width,$chunk);
215
+		$chunk = rand(1, 5);
216
+		$x += rand(-1, 1);
217
+		if ($x >= $width)	$x = $width - 5;
218
+		if ($x < 0) $x = 5;
219
+		imagecopy($image, $tempImage, $x, $y, 0, $y, $width, $chunk);
221 220
 	}
222 221
 }
223 222
 
Please login to merge, or discard this patch.
Braces   +51 added lines, -31 removed lines patch added patch discarded remove patch
@@ -37,10 +37,11 @@  discard block
 block discarded – undo
37 37
 			$alphabet=$options['alphabet'];
38 38
 			$fontSize=$options['fontSize'];
39 39
 			$theme=$options['theme'];
40
-			if(($randomSeed=$options['randomSeed'])>0)
41
-				srand($randomSeed);
42
-			else
43
-				srand((int)(microtime()*1000000));
40
+			if(($randomSeed=$options['randomSeed'])>0) {
41
+							srand($randomSeed);
42
+			} else {
43
+							srand((int)(microtime()*1000000));
44
+			}
44 45
 			$token=generateToken($publicKey,$privateKey,$alphabet,$tokenLength,$caseSensitive);
45 46
 		}
46 47
 	}
@@ -56,8 +57,9 @@  discard block
 block discarded – undo
56 57
 
57 58
 function hash2string($hex,$alphabet)
58 59
 {
59
-	if(strlen($alphabet)<2)
60
-		$alphabet='234578adefhijmnrtABDEFGHJLMNRT';
60
+	if(strlen($alphabet)<2) {
61
+			$alphabet='234578adefhijmnrtABDEFGHJLMNRT';
62
+	}
61 63
 	$hexLength=strlen($hex);
62 64
 	$base=strlen($alphabet);
63 65
 	$result='';
@@ -75,10 +77,12 @@  discard block
 block discarded – undo
75 77
 
76 78
 function displayToken($token,$fontSize,$theme)
77 79
 {
78
-	if(($fontSize=(int)$fontSize)<22)
79
-		$fontSize=22;
80
-	if($fontSize>100)
81
-		$fontSize=100;
80
+	if(($fontSize=(int)$fontSize)<22) {
81
+			$fontSize=22;
82
+	}
83
+	if($fontSize>100) {
84
+			$fontSize=100;
85
+	}
82 86
 	$length=strlen($token);
83 87
 	$padding=10;
84 88
 	$fontWidth=$fontSize;
@@ -99,8 +103,9 @@  discard block
 block discarded – undo
99 103
 
100 104
 	$font=dirname(__FILE__).DIRECTORY_SEPARATOR.'verase.ttf';
101 105
 
102
-	if(function_exists('imagefilter'))
103
-    	imagefilter($image,IMG_FILTER_GAUSSIAN_BLUR);
106
+	if(function_exists('imagefilter')) {
107
+	    	imagefilter($image,IMG_FILTER_GAUSSIAN_BLUR);
108
+	}
104 109
 
105 110
 	$hasShadow=($theme&THEME_SHADOWED_TEXT);
106 111
     for($i=0;$i<$length;$i++)
@@ -111,8 +116,9 @@  discard block
 block discarded – undo
111 116
         $x=$padding+$i*$fontWidth;
112 117
         $y=rand($fontHeight-15,$fontHeight-10);
113 118
         imagettftext($image,$size,$angle,$x,$y,$color,$font,$token[$i]);
114
-        if($hasShadow)
115
-        	imagettftext($image,$size,$angle,$x+2,$y+2,$color,$font,$token[$i]);
119
+        if($hasShadow) {
120
+                	imagettftext($image,$size,$angle,$x+2,$y+2,$color,$font,$token[$i]);
121
+        }
116 122
         imagecolordeallocate($image,$color);
117 123
     }
118 124
 
@@ -127,26 +133,32 @@  discard block
 block discarded – undo
127 133
 	$white=imagecolorallocate($background,255,255,255);
128 134
 	imagefill($background,0,0,$white);
129 135
 
130
-	if($opaque)
131
-		imagefill($background,0,0,imagecolorallocate($background,100,100,100));
136
+	if($opaque) {
137
+			imagefill($background,0,0,imagecolorallocate($background,100,100,100));
138
+	}
132 139
 
133
-	if($noisy)
134
-		addNoise($background,$width*2,$height*2);
140
+	if($noisy) {
141
+			addNoise($background,$width*2,$height*2);
142
+	}
135 143
 
136
-	if($hasGrid)
137
-		addGrid($background,$width*2,$height*2);
144
+	if($hasGrid) {
145
+			addGrid($background,$width*2,$height*2);
146
+	}
138 147
 
139
-	if($hasScribble)
140
-		addScribble($background,$width*2,$height*2);
148
+	if($hasScribble) {
149
+			addScribble($background,$width*2,$height*2);
150
+	}
141 151
 
142
-	if($morph)
143
-		morphImage($background,$width*2,$height*2);
152
+	if($morph) {
153
+			morphImage($background,$width*2,$height*2);
154
+	}
144 155
 
145 156
 	imagecopy($image,$background,0,0,30,30,$width,$height);
146 157
 
147
-	if(!$opaque)
148
-		imagecolortransparent($image,$white);
149
-}
158
+	if(!$opaque) {
159
+			imagecolortransparent($image,$white);
160
+	}
161
+	}
150 162
 
151 163
 function addNoise($image,$width,$height)
152 164
 {
@@ -207,16 +219,24 @@  discard block
 block discarded – undo
207 219
 	{
208 220
 		$chunk=rand(1,5);
209 221
 		$y+=rand(-1,1);
210
-		if($y>=$height)	$y=$height-5;
211
-		if($y<0) $y=5;
222
+		if($y>=$height) {
223
+			$y=$height-5;
224
+		}
225
+		if($y<0) {
226
+			$y=5;
227
+		}
212 228
 		imagecopy($tempImage,$image,$x,0,$x,$y,$chunk,$height);
213 229
 	}
214 230
 	for($x=$y=0;$y<$height;$y+=$chunk)
215 231
 	{
216 232
 		$chunk=rand(1,5);
217 233
 		$x+=rand(-1,1);
218
-		if($x>=$width)	$x=$width-5;
219
-		if($x<0) $x=5;
234
+		if($x>=$width) {
235
+			$x=$width-5;
236
+		}
237
+		if($x<0) {
238
+			$x=5;
239
+		}
220 240
 		imagecopy($image,$tempImage,$x,$y,0,$y,$width,$chunk);
221 241
 	}
222 242
 }
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TBaseDataList.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -166,6 +166,7 @@
 block discarded – undo
166 166
 	 * Otherwise, an exception will be raised.
167 167
 	 * @param mixed data item
168 168
 	 * @param mixed field name
169
+	 * @param string $field
169 170
 	 * @return mixed data value at the specified field
170 171
 	 * @throws TInvalidDataValueException if the data is invalid
171 172
 	 */
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TBaseDataList class file
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Web.UI.WebControls
10
- */
3
+	 * TBaseDataList class file
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 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 TDataBoundControl and TDataFieldAccessor classes
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function getCellSpacing()
58 58
 	{
59
-		if($this->getHasStyle())
59
+		if ($this->getHasStyle())
60 60
 			return $this->getStyle()->getCellSpacing();
61 61
 		else
62 62
 			return -1;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function getCellPadding()
77 77
 	{
78
-		if($this->getHasStyle())
78
+		if ($this->getHasStyle())
79 79
 			return $this->getStyle()->getCellPadding();
80 80
 		else
81 81
 			return -1;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	public function getHorizontalAlign()
96 96
 	{
97
-		if($this->getHasStyle())
97
+		if ($this->getHasStyle())
98 98
 			return $this->getStyle()->getHorizontalAlign();
99 99
 		else
100 100
 			return THorizontalAlign::NotSet;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function getGridLines()
115 115
 	{
116
-		if($this->getHasStyle())
116
+		if ($this->getHasStyle())
117 117
 			return $this->getStyle()->getGridLines();
118 118
 		else
119 119
 			return TTableGridLines::None;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public function getDataKeyField()
136 136
 	{
137
-		return $this->getViewState('DataKeyField','');
137
+		return $this->getViewState('DataKeyField', '');
138 138
 	}
139 139
 
140 140
 	/**
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	public function setDataKeyField($value)
144 144
 	{
145
-		$this->setViewState('DataKeyField',$value,'');
145
+		$this->setViewState('DataKeyField', $value, '');
146 146
 	}
147 147
 
148 148
 	/**
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
 	 */
151 151
 	public function getDataKeys()
152 152
 	{
153
-		if(($dataKeys=$this->getViewState('DataKeys',null))===null)
153
+		if (($dataKeys = $this->getViewState('DataKeys', null)) === null)
154 154
 		{
155
-			$dataKeys=new TList;
156
-			$this->setViewState('DataKeys',$dataKeys,null);
155
+			$dataKeys = new TList;
156
+			$this->setViewState('DataKeys', $dataKeys, null);
157 157
 		}
158 158
 		return $dataKeys;
159 159
 	}
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
 	 * @return mixed data value at the specified field
170 170
 	 * @throws TInvalidDataValueException if the data is invalid
171 171
 	 */
172
-	protected function getDataFieldValue($data,$field)
172
+	protected function getDataFieldValue($data, $field)
173 173
 	{
174
-		return TDataFieldAccessor::getDataFieldValue($data,$field);
174
+		return TDataFieldAccessor::getDataFieldValue($data, $field);
175 175
 	}
176 176
 
177 177
 	/**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 */
183 183
 	public function onSelectedIndexChanged($param)
184 184
 	{
185
-		$this->raiseEvent('OnSelectedIndexChanged',$this,$param);
185
+		$this->raiseEvent('OnSelectedIndexChanged', $this, $param);
186 186
 	}
187 187
 }
188 188
 
Please login to merge, or discard this patch.
Braces   +20 added lines, -16 removed lines patch added patch discarded remove patch
@@ -56,10 +56,11 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function getCellSpacing()
58 58
 	{
59
-		if($this->getHasStyle())
60
-			return $this->getStyle()->getCellSpacing();
61
-		else
62
-			return -1;
59
+		if($this->getHasStyle()) {
60
+					return $this->getStyle()->getCellSpacing();
61
+		} else {
62
+					return -1;
63
+		}
63 64
 	}
64 65
 
65 66
 	/**
@@ -75,10 +76,11 @@  discard block
 block discarded – undo
75 76
 	 */
76 77
 	public function getCellPadding()
77 78
 	{
78
-		if($this->getHasStyle())
79
-			return $this->getStyle()->getCellPadding();
80
-		else
81
-			return -1;
79
+		if($this->getHasStyle()) {
80
+					return $this->getStyle()->getCellPadding();
81
+		} else {
82
+					return -1;
83
+		}
82 84
 	}
83 85
 
84 86
 	/**
@@ -94,10 +96,11 @@  discard block
 block discarded – undo
94 96
 	 */
95 97
 	public function getHorizontalAlign()
96 98
 	{
97
-		if($this->getHasStyle())
98
-			return $this->getStyle()->getHorizontalAlign();
99
-		else
100
-			return THorizontalAlign::NotSet;
99
+		if($this->getHasStyle()) {
100
+					return $this->getStyle()->getHorizontalAlign();
101
+		} else {
102
+					return THorizontalAlign::NotSet;
103
+		}
101 104
 	}
102 105
 
103 106
 	/**
@@ -113,10 +116,11 @@  discard block
 block discarded – undo
113 116
 	 */
114 117
 	public function getGridLines()
115 118
 	{
116
-		if($this->getHasStyle())
117
-			return $this->getStyle()->getGridLines();
118
-		else
119
-			return TTableGridLines::None;
119
+		if($this->getHasStyle()) {
120
+					return $this->getStyle()->getGridLines();
121
+		} else {
122
+					return TTableGridLines::None;
123
+		}
120 124
 	}
121 125
 
122 126
 	/**
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TBaseValidator.php 3 patches
Doc Comments   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -182,6 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * TBaseValidator::$_clientClass, be sure to update the corresponding
183 183
 	 * "Javascript/validation3.js" file as well.
184 184
 	 * @param TControl control to validate.
185
+	 * @param TControl $control
185 186
 	 * @return string control type for client-side validation.
186 187
 	 */
187 188
 	private function getClientControlClass($control)
@@ -259,7 +260,7 @@  discard block
 block discarded – undo
259 260
 	/**
260 261
 	 * Update the ControlToValidate component's css class depending
261 262
 	 * if the ControlCssClass property is set, and whether this is valid.
262
-	 * @return boolean true if change, false otherwise.
263
+	 * @return boolean|null true if change, false otherwise.
263 264
 	 */
264 265
 	protected function updateControlCssClass()
265 266
 	{
@@ -384,6 +385,7 @@  discard block
 block discarded – undo
384 385
 	 * The ID path is the dot-connected IDs of the controls reaching from
385 386
 	 * the validator's naming container to the target control.
386 387
 	 * @param string the ID path
388
+	 * @param string $value
387 389
 	 */
388 390
 	public function setControlToValidate($value)
389 391
 	{
@@ -549,6 +551,7 @@  discard block
 block discarded – undo
549 551
 
550 552
 	/**
551 553
 	 * @param string the css class that is applied to the control being validated in case the validation fails
554
+	 * @param string $value
552 555
 	 */
553 556
 	public function setControlCssClass($value)
554 557
 	{
@@ -691,7 +694,7 @@  discard block
 block discarded – undo
691 694
 	}
692 695
 
693 696
 	/**
694
-	 * @return boolean true to observe changes.
697
+	 * @return boolean|string true to observe changes.
695 698
 	 */
696 699
 	public function getObserveChanges()
697 700
 	{
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
 	/**
78 78
 	 * @var boolean whether the validation succeeds
79 79
 	 */
80
-	private $_isValid=true;
80
+	private $_isValid = true;
81 81
 	/**
82 82
 	 * @var boolean whether the validator has been registered with the page
83 83
 	 */
84
-	private $_registered=false;
84
+	private $_registered = false;
85 85
 	/**
86 86
 	 * @var TValidatorClientSide validator client-script options.
87 87
 	 */
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	{
112 112
 		parent::onInit($param);
113 113
 		$this->getPage()->getValidators()->add($this);
114
-		$this->_registered=true;
114
+		$this->_registered = true;
115 115
 	}
116 116
 
117 117
 	/**
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function onUnload($param)
122 122
 	{
123
-		if($this->_registered && ($page=$this->getPage())!==null)
123
+		if ($this->_registered && ($page = $this->getPage()) !== null)
124 124
 			$page->getValidators()->remove($this);
125
-		$this->_registered=false;
125
+		$this->_registered = false;
126 126
 		parent::onUnload($param);
127 127
 	}
128 128
 
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	protected function addAttributesToRender($writer)
135 135
 	{
136
-		$display=$this->getDisplay();
137
-		$visible=$this->getEnabled(true) && !$this->getIsValid();
138
-		if($display===TValidatorDisplayStyle::None || (!$visible && $display===TValidatorDisplayStyle::Dynamic))
139
-			$writer->addStyleAttribute('display','none');
140
-		else if(!$visible)
141
-			$writer->addStyleAttribute('visibility','hidden');
142
-		$writer->addAttribute('id',$this->getClientID());
136
+		$display = $this->getDisplay();
137
+		$visible = $this->getEnabled(true) && !$this->getIsValid();
138
+		if ($display === TValidatorDisplayStyle::None || (!$visible && $display === TValidatorDisplayStyle::Dynamic))
139
+			$writer->addStyleAttribute('display', 'none');
140
+		else if (!$visible)
141
+			$writer->addStyleAttribute('visibility', 'hidden');
142
+		$writer->addAttribute('id', $this->getClientID());
143 143
 		parent::addAttributesToRender($writer);
144 144
 		$this->renderClientControlScript($writer);
145 145
 	}
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
 		$options['FormID'] = $this->getPage()->getForm()->getClientID();
156 156
 		$options['Display'] = $this->getDisplay();
157 157
 		$options['ErrorMessage'] = $this->getErrorMessage();
158
-		if($this->getFocusOnError())
158
+		if ($this->getFocusOnError())
159 159
 		{
160 160
 			$options['FocusOnError'] = $this->getFocusOnError();
161 161
 			$options['FocusElementID'] = $this->getFocusElementID();
162 162
 		}
163 163
 		$options['ValidationGroup'] = $this->getValidationGroup();
164
-		if($control)
164
+		if ($control)
165 165
 			$options['ControlToValidate'] = $control->getClientID();
166 166
 		$options['ControlCssClass'] = $this->getControlCssClass();
167 167
 
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 		$options['Enabled'] = $this->getEnabled(true);
170 170
 
171 171
 		//get date format from date picker target control
172
-		if($control instanceof TDatePicker)
172
+		if ($control instanceof TDatePicker)
173 173
 			$options['DateFormat'] = $control->getDateFormat();
174 174
 
175
-		$options = array_merge($options,$this->getClientSide()->getOptions()->toArray());
175
+		$options = array_merge($options, $this->getClientSide()->getOptions()->toArray());
176 176
 
177 177
 		return $options;
178 178
 	}
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 */
187 187
 	private function getClientControlClass($control)
188 188
 	{
189
-		foreach(self::$_clientClass as $type)
190
-			if($control instanceof $type)
189
+		foreach (self::$_clientClass as $type)
190
+			if ($control instanceof $type)
191 191
 				return $type;
192 192
 		return get_class($control);
193 193
 	}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 */
211 211
 	public function getClientSide()
212 212
 	{
213
-		if($this->_clientSide===null)
213
+		if ($this->_clientSide === null)
214 214
 			$this->_clientSide = $this->createClientSide();
215 215
 		return $this->_clientSide;
216 216
 	}
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
 		$scripts = $this->getPage()->getClientScript();
235 235
 		if ($this->getEnableClientScript())
236 236
 			$scripts->registerPradoScript('validator');
237
-		$formID=$this->getPage()->getForm()->getClientID();
237
+		$formID = $this->getPage()->getForm()->getClientID();
238 238
 		$scriptKey = "TBaseValidator:$formID";
239
-		if($this->getEnableClientScript() && !$scripts->isEndScriptRegistered($scriptKey))
239
+		if ($this->getEnableClientScript() && !$scripts->isEndScriptRegistered($scriptKey))
240 240
 		{
241 241
 			$manager['FormID'] = $formID;
242 242
 			$options = TJavaScript::encode($manager);
243 243
 			$scripts->registerEndScript($scriptKey, "new Prado.ValidationManager({$options});");
244 244
 		}
245
-		if($this->getEnableClientScript())
245
+		if ($this->getEnableClientScript())
246 246
 			$this->registerClientScriptValidator();
247 247
 	}
248 248
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 * Override parent implementation to update the control CSS Class before
251 251
 	 * the validated control is rendered
252 252
 	 */
253
-	public function onPreRender ($param)
253
+	public function onPreRender($param)
254 254
 	{
255 255
 		parent::onPreRender($param);
256 256
 		$this->updateControlCssClass();
@@ -263,15 +263,15 @@  discard block
 block discarded – undo
263 263
 	 */
264 264
 	protected function updateControlCssClass()
265 265
 	{
266
-		if(($cssClass=$this->getControlCssClass())!=='')
266
+		if (($cssClass = $this->getControlCssClass()) !== '')
267 267
 		{
268
-			$control=$this->getValidationTarget();
269
-			if($control instanceof TWebControl)
268
+			$control = $this->getValidationTarget();
269
+			if ($control instanceof TWebControl)
270 270
 			{
271
-				$class = preg_replace ('/ '.preg_quote($cssClass).'/', '',$control->getCssClass());
272
-				if(!$this->getIsValid())
271
+				$class = preg_replace('/ ' . preg_quote($cssClass) . '/', '', $control->getCssClass());
272
+				if (!$this->getIsValid())
273 273
 				{
274
-					$class .= ' '.$cssClass;
274
+					$class .= ' ' . $cssClass;
275 275
 					$control->setCssClass($class);
276 276
 				} elseif ($control->getIsValid())
277 277
 					$control->setCssClass($class);
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 	 */
285 285
 	protected function registerClientScriptValidator()
286 286
 	{
287
-		$key = 'prado:'.$this->getClientID();
288
-		if(!$this->getPage()->getClientScript()->isEndScriptRegistered($key))
287
+		$key = 'prado:' . $this->getClientID();
288
+		if (!$this->getPage()->getClientScript()->isEndScriptRegistered($key))
289 289
 		{
290 290
 			$options = TJavaScript::encode($this->getClientScriptOptions());
291
-			$script = 'new '.$this->getClientClassName().'('.$options.');';
291
+			$script = 'new ' . $this->getClientClassName() . '(' . $options . ');';
292 292
 			$this->getPage()->getClientScript()->registerEndScript($key, $script);
293 293
 		}
294 294
 	}
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	 */
308 308
 	public function setForControl($value)
309 309
 	{
310
-		throw new TNotSupportedException('basevalidator_forcontrol_unsupported',get_class($this));
310
+		throw new TNotSupportedException('basevalidator_forcontrol_unsupported', get_class($this));
311 311
 	}
312 312
 
313 313
 	/**
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 	 */
317 317
 	public function setEnabled($value)
318 318
 	{
319
-		$value=TPropertyValue::ensureBoolean($value);
319
+		$value = TPropertyValue::ensureBoolean($value);
320 320
 		parent::setEnabled($value);
321
-		if(!$value)
322
-			$this->_isValid=true;
321
+		if (!$value)
322
+			$this->_isValid = true;
323 323
 	}
324 324
 
325 325
 	/**
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 	 */
328 328
 	public function getDisplay()
329 329
 	{
330
-		return $this->getViewState('Display',TValidatorDisplayStyle::Fixed);
330
+		return $this->getViewState('Display', TValidatorDisplayStyle::Fixed);
331 331
 	}
332 332
 
333 333
 	/**
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 	 */
336 336
 	public function setDisplay($value)
337 337
 	{
338
-		$this->setViewState('Display',TPropertyValue::ensureEnum($value,'TValidatorDisplayStyle'),TValidatorDisplayStyle::Fixed);
338
+		$this->setViewState('Display', TPropertyValue::ensureEnum($value, 'TValidatorDisplayStyle'), TValidatorDisplayStyle::Fixed);
339 339
 	}
340 340
 
341 341
 	/**
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 	 */
344 344
 	public function getEnableClientScript()
345 345
 	{
346
-		return $this->getViewState('EnableClientScript',true);
346
+		return $this->getViewState('EnableClientScript', true);
347 347
 	}
348 348
 
349 349
 	/**
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	 */
352 352
 	public function setEnableClientScript($value)
353 353
 	{
354
-		$this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
354
+		$this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true);
355 355
 	}
356 356
 
357 357
 	/**
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	 */
360 360
 	public function getErrorMessage()
361 361
 	{
362
-		return $this->getViewState('ErrorMessage','');
362
+		return $this->getViewState('ErrorMessage', '');
363 363
 	}
364 364
 
365 365
 	/**
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 */
369 369
 	public function setErrorMessage($value)
370 370
 	{
371
-		$this->setViewState('ErrorMessage',$value,'');
371
+		$this->setViewState('ErrorMessage', $value, '');
372 372
 	}
373 373
 
374 374
 	/**
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	 */
377 377
 	public function getControlToValidate()
378 378
 	{
379
-		return $this->getViewState('ControlToValidate','');
379
+		return $this->getViewState('ControlToValidate', '');
380 380
 	}
381 381
 
382 382
 	/**
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 */
388 388
 	public function setControlToValidate($value)
389 389
 	{
390
-		$this->setViewState('ControlToValidate',$value,'');
390
+		$this->setViewState('ControlToValidate', $value, '');
391 391
 	}
392 392
 
393 393
 	/**
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	 */
396 396
 	public function getFocusOnError()
397 397
 	{
398
-		return $this->getViewState('FocusOnError',false);
398
+		return $this->getViewState('FocusOnError', false);
399 399
 	}
400 400
 
401 401
 	/**
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	 */
404 404
 	public function setFocusOnError($value)
405 405
 	{
406
-		$this->setViewState('FocusOnError',TPropertyValue::ensureBoolean($value),false);
406
+		$this->setViewState('FocusOnError', TPropertyValue::ensureBoolean($value), false);
407 407
 	}
408 408
 
409 409
 	/**
@@ -413,17 +413,17 @@  discard block
 block discarded – undo
413 413
 	 */
414 414
 	public function getFocusElementID()
415 415
 	{
416
-		if(($id=$this->getViewState('FocusElementID',''))==='')
416
+		if (($id = $this->getViewState('FocusElementID', '')) === '')
417 417
 		{
418
-			$target=$this->getValidationTarget();
418
+			$target = $this->getValidationTarget();
419 419
 			/* Workaround: TCheckBoxList and TRadioButtonList nests the actual
420 420
 			 * inputs inside a table; we ensure the first input gets focused
421 421
 			 */
422
-			if($target instanceof TCheckBoxList && $target->getItemCount()>0)
422
+			if ($target instanceof TCheckBoxList && $target->getItemCount() > 0)
423 423
 			{
424
-				$id=$target->getClientID().'_c0';
424
+				$id = $target->getClientID() . '_c0';
425 425
 			} else {
426
-				$id=$target->getClientID();
426
+				$id = $target->getClientID();
427 427
 			}
428 428
 		}
429 429
 		return $id;
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 	 */
444 444
 	public function getValidationGroup()
445 445
 	{
446
-		return $this->getViewState('ValidationGroup','');
446
+		return $this->getViewState('ValidationGroup', '');
447 447
 	}
448 448
 
449 449
 	/**
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	 */
452 452
 	public function setValidationGroup($value)
453 453
 	{
454
-		$this->setViewState('ValidationGroup',$value,'');
454
+		$this->setViewState('ValidationGroup', $value, '');
455 455
 	}
456 456
 
457 457
 	/**
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 	 */
469 469
 	public function setIsValid($value)
470 470
 	{
471
-		$this->_isValid=TPropertyValue::ensureBoolean($value);
471
+		$this->_isValid = TPropertyValue::ensureBoolean($value);
472 472
 	}
473 473
 
474 474
 	/**
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
 	 */
479 479
 	public function getValidationTarget()
480 480
 	{
481
-		if(($id=$this->getControlToValidate())!=='' && ($control=$this->findControl($id))!==null)
481
+		if (($id = $this->getControlToValidate()) !== '' && ($control = $this->findControl($id)) !== null)
482 482
 			return $control;
483 483
 		else
484
-			throw new TConfigurationException('basevalidator_controltovalidate_invalid',get_class($this));
484
+			throw new TConfigurationException('basevalidator_controltovalidate_invalid', get_class($this));
485 485
 	}
486 486
 
487 487
 	/**
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 	 */
493 493
 	protected function getValidationValue($control)
494 494
 	{
495
-		if($control instanceof IValidatable)
495
+		if ($control instanceof IValidatable)
496 496
 			return $control->getValidationPropertyValue();
497 497
 		else
498
-			throw new TInvalidDataTypeException('basevalidator_validatable_required',get_class($this));
498
+			throw new TInvalidDataTypeException('basevalidator_validatable_required', get_class($this));
499 499
 	}
500 500
 
501 501
 	/**
@@ -506,22 +506,22 @@  discard block
 block discarded – undo
506 506
 	public function validate()
507 507
 	{
508 508
 		$this->onValidate();
509
-		if($this->getVisible(true) && $this->getEnabled(true))
509
+		if ($this->getVisible(true) && $this->getEnabled(true))
510 510
 		{
511
-			$target=$this->getValidationTarget();
511
+			$target = $this->getValidationTarget();
512 512
 			// if the target is not a disabled web control
513
-			if($target===null ||
514
-				($target!==null &&
513
+			if ($target === null ||
514
+				($target !== null &&
515 515
 				!($target instanceof TWebControl && !$target->getEnabled(true))))
516 516
 			{
517
-				if($this->evaluateIsValid())
517
+				if ($this->evaluateIsValid())
518 518
 				{
519 519
 					$this->setIsValid(true);
520 520
 					$this->onValidationSuccess();
521 521
 				}
522 522
 				else
523 523
 				{
524
-					if($target)
524
+					if ($target)
525 525
 						$target->setIsValid(false);
526 526
 					$this->setIsValid(false);
527 527
 					$this->onValidationError();
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 	 */
545 545
 	public function getControlCssClass()
546 546
 	{
547
-		return $this->getViewState('ControlCssClass','');
547
+		return $this->getViewState('ControlCssClass', '');
548 548
 	}
549 549
 
550 550
 	/**
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 	 */
553 553
 	public function setControlCssClass($value)
554 554
 	{
555
-		$this->setViewState('ControlCssClass',$value,'');
555
+		$this->setViewState('ControlCssClass', $value, '');
556 556
 	}
557 557
 
558 558
 	/**
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 	 */
568 568
 	public function onValidationSuccess()
569 569
 	{
570
-		$this->raiseEvent('OnValidationSuccess',$this,null);
570
+		$this->raiseEvent('OnValidationSuccess', $this, null);
571 571
 	}
572 572
 
573 573
 	/**
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 	 */
576 576
 	public function onValidationError()
577 577
 	{
578
-		$this->raiseEvent('OnValidationError',$this,null);
578
+		$this->raiseEvent('OnValidationError', $this, null);
579 579
 	}
580 580
 
581 581
 	/**
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 	 */
587 587
 	public function onValidate()
588 588
 	{
589
-		$this->raiseEvent('OnValidate',$this,null);
589
+		$this->raiseEvent('OnValidate', $this, null);
590 590
 	}
591 591
 
592 592
 	/**
@@ -595,9 +595,9 @@  discard block
 block discarded – undo
595 595
 	 */
596 596
 	public function renderContents($writer)
597 597
 	{
598
-		if(($text=$this->getText())!=='')
598
+		if (($text = $this->getText()) !== '')
599 599
 			$writer->write($text);
600
-		else if(($text=$this->getErrorMessage())!=='')
600
+		else if (($text = $this->getErrorMessage()) !== '')
601 601
 			$writer->write($text);
602 602
 		else
603 603
 			parent::renderContents($writer);
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 	public function getObserveChanges()
697 697
 	{
698 698
 		$changes = $this->getOption('ObserveChanges');
699
-		return ($changes===null) ? true : $changes;
699
+		return ($changes === null) ? true : $changes;
700 700
 	}
701 701
 }
702 702
 
@@ -717,9 +717,9 @@  discard block
 block discarded – undo
717 717
  */
718 718
 class TValidatorDisplayStyle extends TEnumerable
719 719
 {
720
-	const None='None';
721
-	const Dynamic='Dynamic';
722
-	const Fixed='Fixed';
720
+	const None = 'None';
721
+	const Dynamic = 'Dynamic';
722
+	const Fixed = 'Fixed';
723 723
 }
724 724
 
725 725
 /**
@@ -739,9 +739,9 @@  discard block
 block discarded – undo
739 739
  */
740 740
 class TValidationDataType extends TEnumerable
741 741
 {
742
-	const Integer='Integer';
743
-	const Float='Float';
744
-	const Date='Date';
745
-	const String='String';
742
+	const Integer = 'Integer';
743
+	const Float = 'Float';
744
+	const Date = 'Date';
745
+	const String = 'String';
746 746
 }
747 747
 
Please login to merge, or discard this patch.
Braces   +54 added lines, -42 removed lines patch added patch discarded remove patch
@@ -120,8 +120,9 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function onUnload($param)
122 122
 	{
123
-		if($this->_registered && ($page=$this->getPage())!==null)
124
-			$page->getValidators()->remove($this);
123
+		if($this->_registered && ($page=$this->getPage())!==null) {
124
+					$page->getValidators()->remove($this);
125
+		}
125 126
 		$this->_registered=false;
126 127
 		parent::onUnload($param);
127 128
 	}
@@ -135,10 +136,11 @@  discard block
 block discarded – undo
135 136
 	{
136 137
 		$display=$this->getDisplay();
137 138
 		$visible=$this->getEnabled(true) && !$this->getIsValid();
138
-		if($display===TValidatorDisplayStyle::None || (!$visible && $display===TValidatorDisplayStyle::Dynamic))
139
-			$writer->addStyleAttribute('display','none');
140
-		else if(!$visible)
141
-			$writer->addStyleAttribute('visibility','hidden');
139
+		if($display===TValidatorDisplayStyle::None || (!$visible && $display===TValidatorDisplayStyle::Dynamic)) {
140
+					$writer->addStyleAttribute('display','none');
141
+		} else if(!$visible) {
142
+					$writer->addStyleAttribute('visibility','hidden');
143
+		}
142 144
 		$writer->addAttribute('id',$this->getClientID());
143 145
 		parent::addAttributesToRender($writer);
144 146
 		$this->renderClientControlScript($writer);
@@ -161,16 +163,18 @@  discard block
 block discarded – undo
161 163
 			$options['FocusElementID'] = $this->getFocusElementID();
162 164
 		}
163 165
 		$options['ValidationGroup'] = $this->getValidationGroup();
164
-		if($control)
165
-			$options['ControlToValidate'] = $control->getClientID();
166
+		if($control) {
167
+					$options['ControlToValidate'] = $control->getClientID();
168
+		}
166 169
 		$options['ControlCssClass'] = $this->getControlCssClass();
167 170
 
168 171
 		$options['ControlType'] = $this->getClientControlClass($control);
169 172
 		$options['Enabled'] = $this->getEnabled(true);
170 173
 
171 174
 		//get date format from date picker target control
172
-		if($control instanceof TDatePicker)
173
-			$options['DateFormat'] = $control->getDateFormat();
175
+		if($control instanceof TDatePicker) {
176
+					$options['DateFormat'] = $control->getDateFormat();
177
+		}
174 178
 
175 179
 		$options = array_merge($options,$this->getClientSide()->getOptions()->toArray());
176 180
 
@@ -186,9 +190,10 @@  discard block
 block discarded – undo
186 190
 	 */
187 191
 	private function getClientControlClass($control)
188 192
 	{
189
-		foreach(self::$_clientClass as $type)
190
-			if($control instanceof $type)
193
+		foreach(self::$_clientClass as $type) {
194
+					if($control instanceof $type)
191 195
 				return $type;
196
+		}
192 197
 		return get_class($control);
193 198
 	}
194 199
 
@@ -210,8 +215,9 @@  discard block
 block discarded – undo
210 215
 	 */
211 216
 	public function getClientSide()
212 217
 	{
213
-		if($this->_clientSide===null)
214
-			$this->_clientSide = $this->createClientSide();
218
+		if($this->_clientSide===null) {
219
+					$this->_clientSide = $this->createClientSide();
220
+		}
215 221
 		return $this->_clientSide;
216 222
 	}
217 223
 
@@ -232,8 +238,9 @@  discard block
 block discarded – undo
232 238
 	public function renderClientControlScript($writer)
233 239
 	{
234 240
 		$scripts = $this->getPage()->getClientScript();
235
-		if ($this->getEnableClientScript())
236
-			$scripts->registerPradoScript('validator');
241
+		if ($this->getEnableClientScript()) {
242
+					$scripts->registerPradoScript('validator');
243
+		}
237 244
 		$formID=$this->getPage()->getForm()->getClientID();
238 245
 		$scriptKey = "TBaseValidator:$formID";
239 246
 		if($this->getEnableClientScript() && !$scripts->isEndScriptRegistered($scriptKey))
@@ -242,8 +249,9 @@  discard block
 block discarded – undo
242 249
 			$options = TJavaScript::encode($manager);
243 250
 			$scripts->registerEndScript($scriptKey, "new Prado.ValidationManager({$options});");
244 251
 		}
245
-		if($this->getEnableClientScript())
246
-			$this->registerClientScriptValidator();
252
+		if($this->getEnableClientScript()) {
253
+					$this->registerClientScriptValidator();
254
+		}
247 255
 	}
248 256
 
249 257
 	/**
@@ -273,8 +281,9 @@  discard block
 block discarded – undo
273 281
 				{
274 282
 					$class .= ' '.$cssClass;
275 283
 					$control->setCssClass($class);
276
-				} elseif ($control->getIsValid())
277
-					$control->setCssClass($class);
284
+				} elseif ($control->getIsValid()) {
285
+									$control->setCssClass($class);
286
+				}
278 287
 			}
279 288
 		}
280 289
 	}
@@ -318,8 +327,9 @@  discard block
 block discarded – undo
318 327
 	{
319 328
 		$value=TPropertyValue::ensureBoolean($value);
320 329
 		parent::setEnabled($value);
321
-		if(!$value)
322
-			$this->_isValid=true;
330
+		if(!$value) {
331
+					$this->_isValid=true;
332
+		}
323 333
 	}
324 334
 
325 335
 	/**
@@ -478,10 +488,11 @@  discard block
 block discarded – undo
478 488
 	 */
479 489
 	public function getValidationTarget()
480 490
 	{
481
-		if(($id=$this->getControlToValidate())!=='' && ($control=$this->findControl($id))!==null)
482
-			return $control;
483
-		else
484
-			throw new TConfigurationException('basevalidator_controltovalidate_invalid',get_class($this));
491
+		if(($id=$this->getControlToValidate())!=='' && ($control=$this->findControl($id))!==null) {
492
+					return $control;
493
+		} else {
494
+					throw new TConfigurationException('basevalidator_controltovalidate_invalid',get_class($this));
495
+		}
485 496
 	}
486 497
 
487 498
 	/**
@@ -492,10 +503,11 @@  discard block
 block discarded – undo
492 503
 	 */
493 504
 	protected function getValidationValue($control)
494 505
 	{
495
-		if($control instanceof IValidatable)
496
-			return $control->getValidationPropertyValue();
497
-		else
498
-			throw new TInvalidDataTypeException('basevalidator_validatable_required',get_class($this));
506
+		if($control instanceof IValidatable) {
507
+					return $control->getValidationPropertyValue();
508
+		} else {
509
+					throw new TInvalidDataTypeException('basevalidator_validatable_required',get_class($this));
510
+		}
499 511
 	}
500 512
 
501 513
 	/**
@@ -518,16 +530,15 @@  discard block
 block discarded – undo
518 530
 				{
519 531
 					$this->setIsValid(true);
520 532
 					$this->onValidationSuccess();
521
-				}
522
-				else
533
+				} else
523 534
 				{
524
-					if($target)
525
-						$target->setIsValid(false);
535
+					if($target) {
536
+											$target->setIsValid(false);
537
+					}
526 538
 					$this->setIsValid(false);
527 539
 					$this->onValidationError();
528 540
 				}
529
-			}
530
-			else
541
+			} else
531 542
 			{
532 543
 				$this->evaluateIsValid();
533 544
 				$this->setIsValid(true);
@@ -595,12 +606,13 @@  discard block
 block discarded – undo
595 606
 	 */
596 607
 	public function renderContents($writer)
597 608
 	{
598
-		if(($text=$this->getText())!=='')
599
-			$writer->write($text);
600
-		else if(($text=$this->getErrorMessage())!=='')
601
-			$writer->write($text);
602
-		else
603
-			parent::renderContents($writer);
609
+		if(($text=$this->getText())!=='') {
610
+					$writer->write($text);
611
+		} else if(($text=$this->getErrorMessage())!=='') {
612
+					$writer->write($text);
613
+		} else {
614
+					parent::renderContents($writer);
615
+		}
604 616
 	}
605 617
 }
606 618
 
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TBulletedList.php 4 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -216,6 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * This method is invoked when the {@link getDisplayMode DisplayMode} is 'LinkButton'
217 217
 	 * and end-users click on one of the buttons.
218 218
 	 * @param TBulletedListEventParameter event parameter.
219
+	 * @param TBulletedListEventParameter $param
219 220
 	 */
220 221
 	public function onClick($param)
221 222
 	{
@@ -425,6 +426,7 @@  discard block
 block discarded – undo
425 426
 	/**
426 427
 	 * Constructor.
427 428
 	 * @param integer index of the item clicked
429
+	 * @param integer $index
428 430
 	 */
429 431
 	public function __construct($index)
430 432
 	{
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public function raisePostBackEvent($param)
61 61
 	{
62
-		if($this->getCausesValidation())
62
+		if ($this->getCausesValidation())
63 63
 			$this->getPage()->validate($this->getValidationGroup());
64
-		$this->onClick(new TBulletedListEventParameter((int)$param));
64
+		$this->onClick(new TBulletedListEventParameter((int) $param));
65 65
 	}
66 66
 
67 67
 	/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	protected function getTagName()
71 71
 	{
72
-		switch($this->getBulletStyle())
72
+		switch ($this->getBulletStyle())
73 73
 		{
74 74
 			case TBulletStyle::Numbered:
75 75
 			case TBulletStyle::LowerAlpha:
@@ -98,49 +98,49 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	protected function addAttributesToRender($writer)
100 100
 	{
101
-		$needStart=false;
102
-		switch($this->getBulletStyle())
101
+		$needStart = false;
102
+		switch ($this->getBulletStyle())
103 103
 		{
104 104
 			case TBulletStyle::None:
105
-				$writer->addStyleAttribute('list-style-type','none');
106
-				$needStart=true;
105
+				$writer->addStyleAttribute('list-style-type', 'none');
106
+				$needStart = true;
107 107
 				break;
108 108
 			case TBulletStyle::Numbered:
109
-				$writer->addStyleAttribute('list-style-type','decimal');
110
-				$needStart=true;
109
+				$writer->addStyleAttribute('list-style-type', 'decimal');
110
+				$needStart = true;
111 111
 				break;
112 112
 			case TBulletStyle::LowerAlpha:
113
-				$writer->addStyleAttribute('list-style-type','lower-alpha');
114
-				$needStart=true;
113
+				$writer->addStyleAttribute('list-style-type', 'lower-alpha');
114
+				$needStart = true;
115 115
 				break;
116 116
 			case TBulletStyle::UpperAlpha:
117
-				$writer->addStyleAttribute('list-style-type','upper-alpha');
118
-				$needStart=true;
117
+				$writer->addStyleAttribute('list-style-type', 'upper-alpha');
118
+				$needStart = true;
119 119
 				break;
120 120
 			case TBulletStyle::LowerRoman:
121
-				$writer->addStyleAttribute('list-style-type','lower-roman');
122
-				$needStart=true;
121
+				$writer->addStyleAttribute('list-style-type', 'lower-roman');
122
+				$needStart = true;
123 123
 				break;
124 124
 			case TBulletStyle::UpperRoman:
125
-				$writer->addStyleAttribute('list-style-type','upper-roman');
126
-				$needStart=true;
125
+				$writer->addStyleAttribute('list-style-type', 'upper-roman');
126
+				$needStart = true;
127 127
 				break;
128 128
 			case TBulletStyle::Disc:
129
-				$writer->addStyleAttribute('list-style-type','disc');
129
+				$writer->addStyleAttribute('list-style-type', 'disc');
130 130
 				break;
131 131
 			case TBulletStyle::Circle:
132
-				$writer->addStyleAttribute('list-style-type','circle');
132
+				$writer->addStyleAttribute('list-style-type', 'circle');
133 133
 				break;
134 134
 			case TBulletStyle::Square:
135
-				$writer->addStyleAttribute('list-style-type','square');
135
+				$writer->addStyleAttribute('list-style-type', 'square');
136 136
 				break;
137 137
 			case TBulletStyle::CustomImage:
138
-				$url=$this->getBulletImageUrl();
139
-				$writer->addStyleAttribute('list-style-image',"url($url)");
138
+				$url = $this->getBulletImageUrl();
139
+				$writer->addStyleAttribute('list-style-image', "url($url)");
140 140
 				break;
141 141
 		}
142
-		if($needStart && ($start=$this->getFirstBulletNumber())!=1)
143
-			$writer->addAttribute('start',"$start");
142
+		if ($needStart && ($start = $this->getFirstBulletNumber()) != 1)
143
+			$writer->addAttribute('start', "$start");
144 144
 		parent::addAttributesToRender($writer);
145 145
 	}
146 146
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	public function getBulletImageUrl()
151 151
 	{
152
-		return $this->getViewState('BulletImageUrl','');
152
+		return $this->getViewState('BulletImageUrl', '');
153 153
 	}
154 154
 
155 155
 	/**
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 */
158 158
 	public function setBulletImageUrl($value)
159 159
 	{
160
-		$this->setViewState('BulletImageUrl',$value,'');
160
+		$this->setViewState('BulletImageUrl', $value, '');
161 161
 	}
162 162
 
163 163
 	/**
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 */
166 166
 	public function getBulletStyle()
167 167
 	{
168
-		return $this->getViewState('BulletStyle',TBulletStyle::NotSet);
168
+		return $this->getViewState('BulletStyle', TBulletStyle::NotSet);
169 169
 	}
170 170
 
171 171
 	/**
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	public function setBulletStyle($value)
175 175
 	{
176
-		$this->setViewState('BulletStyle',TPropertyValue::ensureEnum($value,'TBulletStyle'),TBulletStyle::NotSet);
176
+		$this->setViewState('BulletStyle', TPropertyValue::ensureEnum($value, 'TBulletStyle'), TBulletStyle::NotSet);
177 177
 	}
178 178
 
179 179
 	/**
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	public function getDisplayMode()
183 183
 	{
184
-		return $this->getViewState('DisplayMode',TBulletedListDisplayMode::Text);
184
+		return $this->getViewState('DisplayMode', TBulletedListDisplayMode::Text);
185 185
 	}
186 186
 
187 187
 	/**
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 */
190 190
 	public function setDisplayMode($value)
191 191
 	{
192
-		$this->setViewState('DisplayMode',TPropertyValue::ensureEnum($value,'TBulletedListDisplayMode'),TBulletedListDisplayMode::Text);
192
+		$this->setViewState('DisplayMode', TPropertyValue::ensureEnum($value, 'TBulletedListDisplayMode'), TBulletedListDisplayMode::Text);
193 193
 	}
194 194
 
195 195
 	/**
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 */
200 200
 	public function getFirstBulletNumber()
201 201
 	{
202
-		return $this->getViewState('FirstBulletNumber',1);
202
+		return $this->getViewState('FirstBulletNumber', 1);
203 203
 	}
204 204
 
205 205
 	/**
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 */
209 209
 	public function setFirstBulletNumber($value)
210 210
 	{
211
-		$this->setViewState('FirstBulletNumber',TPropertyValue::ensureInteger($value),1);
211
+		$this->setViewState('FirstBulletNumber', TPropertyValue::ensureInteger($value), 1);
212 212
 	}
213 213
 
214 214
 	/**
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public function onClick($param)
221 221
 	{
222
-		$this->raiseEvent('OnClick',$this,$param);
222
+		$this->raiseEvent('OnClick', $this, $param);
223 223
 	}
224 224
 
225 225
 	/**
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	public function getTarget()
231 231
 	{
232
-		return $this->getViewState('Target','');
232
+		return $this->getViewState('Target', '');
233 233
 	}
234 234
 
235 235
 	/**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 */
240 240
 	public function setTarget($value)
241 241
 	{
242
-		$this->setViewState('Target',$value,'');
242
+		$this->setViewState('Target', $value, '');
243 243
 	}
244 244
 
245 245
 	/**
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	 */
249 249
 	public function render($writer)
250 250
 	{
251
-		if($this->getHasItems())
251
+		if ($this->getHasItems())
252 252
 			parent::render($writer);
253 253
 	}
254 254
 
@@ -258,15 +258,15 @@  discard block
 block discarded – undo
258 258
 	 */
259 259
 	public function renderContents($writer)
260 260
 	{
261
-		$this->_isEnabled=$this->getEnabled(true);
262
-		$this->_postBackOptions=$this->getPostBackOptions();
261
+		$this->_isEnabled = $this->getEnabled(true);
262
+		$this->_postBackOptions = $this->getPostBackOptions();
263 263
 		$writer->writeLine();
264
-		foreach($this->getItems() as $index=>$item)
264
+		foreach ($this->getItems() as $index=>$item)
265 265
 		{
266
-			if($item->getHasAttributes())
266
+			if ($item->getHasAttributes())
267 267
 				$writer->addAttributes($item->getAttributes());
268 268
 			$writer->renderBeginTag('li');
269
-			$this->renderBulletText($writer,$item,$index);
269
+			$this->renderBulletText($writer, $item, $index);
270 270
 			$writer->renderEndTag();
271 271
 			$writer->writeLine();
272 272
 		}
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 	 * @param TListItem item to be rendered
279 279
 	 * @param integer index of the item being rendered
280 280
 	 */
281
-	protected function renderBulletText($writer,$item,$index)
281
+	protected function renderBulletText($writer, $item, $index)
282 282
 	{
283
-		switch($this->getDisplayMode())
283
+		switch ($this->getDisplayMode())
284 284
 		{
285 285
 			case TBulletedListDisplayMode::Text:
286 286
 				$this->renderTextItem($writer, $item, $index);
@@ -296,11 +296,11 @@  discard block
 block discarded – undo
296 296
 
297 297
 	protected function renderTextItem($writer, $item, $index)
298 298
 	{
299
-		if($item->getEnabled())
299
+		if ($item->getEnabled())
300 300
 			$writer->write(THttpUtility::htmlEncode($item->getText()));
301 301
 		else
302 302
 		{
303
-			$writer->addAttribute('disabled','disabled');
303
+			$writer->addAttribute('disabled', 'disabled');
304 304
 			$writer->renderBeginTag('span');
305 305
 			$writer->write(THttpUtility::htmlEncode($item->getText()));
306 306
 			$writer->renderEndTag();
@@ -309,16 +309,16 @@  discard block
 block discarded – undo
309 309
 
310 310
 	protected function renderHyperLinkItem($writer, $item, $index)
311 311
 	{
312
-		if(!$this->_isEnabled || !$item->getEnabled())
313
-			$writer->addAttribute('disabled','disabled');
312
+		if (!$this->_isEnabled || !$item->getEnabled())
313
+			$writer->addAttribute('disabled', 'disabled');
314 314
 		else
315 315
 		{
316
-			$writer->addAttribute('href',$item->getValue());
317
-			if(($target=$this->getTarget())!=='')
318
-				$writer->addAttribute('target',$target);
316
+			$writer->addAttribute('href', $item->getValue());
317
+			if (($target = $this->getTarget()) !== '')
318
+				$writer->addAttribute('target', $target);
319 319
 		}
320
-		if(($accesskey=$this->getAccessKey())!=='')
321
-			$writer->addAttribute('accesskey',$accesskey);
320
+		if (($accesskey = $this->getAccessKey()) !== '')
321
+			$writer->addAttribute('accesskey', $accesskey);
322 322
 		$writer->renderBeginTag('a');
323 323
 		$writer->write(THttpUtility::htmlEncode($item->getText()));
324 324
 		$writer->renderEndTag();
@@ -326,18 +326,18 @@  discard block
 block discarded – undo
326 326
 
327 327
 	protected function renderLinkButtonItem($writer, $item, $index)
328 328
 	{
329
-		if(!$this->_isEnabled || !$item->getEnabled())
330
-			$writer->addAttribute('disabled','disabled');
329
+		if (!$this->_isEnabled || !$item->getEnabled())
330
+			$writer->addAttribute('disabled', 'disabled');
331 331
 		else
332 332
 		{
333 333
 			$this->_currentRenderItemIndex = $index;
334
-			$writer->addAttribute('id', $this->getClientID().$index);
335
-			$writer->addAttribute('href', "javascript:;//".$this->getClientID().$index);
334
+			$writer->addAttribute('id', $this->getClientID() . $index);
335
+			$writer->addAttribute('href', "javascript:;//" . $this->getClientID() . $index);
336 336
 			$cs = $this->getPage()->getClientScript();
337
-			$cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions());
337
+			$cs->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions());
338 338
 		}
339
-		if(($accesskey=$this->getAccessKey())!=='')
340
-			$writer->addAttribute('accesskey',$accesskey);
339
+		if (($accesskey = $this->getAccessKey()) !== '')
340
+			$writer->addAttribute('accesskey', $accesskey);
341 341
 		$writer->renderBeginTag('a');
342 342
 		$writer->write(THttpUtility::htmlEncode($item->getText()));
343 343
 		$writer->renderEndTag();
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 		$options['CausesValidation'] = $this->getCausesValidation();
353 353
 		$options['EventTarget'] = $this->getUniqueID();
354 354
 		$options['EventParameter'] = $this->_currentRenderItemIndex;
355
-		$options['ID'] = $this->getClientID().$this->_currentRenderItemIndex;
355
+		$options['ID'] = $this->getClientID() . $this->_currentRenderItemIndex;
356 356
 		$options['StopEvent'] = true;
357 357
 		return $options;
358 358
 	}
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	protected function canCauseValidation()
361 361
 	{
362 362
 		$group = $this->getValidationGroup();
363
-		$hasValidators = $this->getPage()->getValidators($group)->getCount()>0;
363
+		$hasValidators = $this->getPage()->getValidators($group)->getCount() > 0;
364 364
 		return $this->getCausesValidation() && $hasValidators;
365 365
 	}
366 366
 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	 */
429 429
 	public function __construct($index)
430 430
 	{
431
-		$this->_index=$index;
431
+		$this->_index = $index;
432 432
 	}
433 433
 
434 434
 	/**
@@ -451,17 +451,17 @@  discard block
 block discarded – undo
451 451
  */
452 452
 class TBulletStyle extends TEnumerable
453 453
 {
454
-	const NotSet='NotSet';
455
-	const None='None';
456
-	const Numbered='Numbered';
457
-	const LowerAlpha='LowerAlpha';
458
-	const UpperAlpha='UpperAlpha';
459
-	const LowerRoman='LowerRoman';
460
-	const UpperRoman='UpperRoman';
461
-	const Disc='Disc';
462
-	const Circle='Circle';
463
-	const Square='Square';
464
-	const CustomImage='CustomImage';
454
+	const NotSet = 'NotSet';
455
+	const None = 'None';
456
+	const Numbered = 'Numbered';
457
+	const LowerAlpha = 'LowerAlpha';
458
+	const UpperAlpha = 'UpperAlpha';
459
+	const LowerRoman = 'LowerRoman';
460
+	const UpperRoman = 'UpperRoman';
461
+	const Disc = 'Disc';
462
+	const Circle = 'Circle';
463
+	const Square = 'Square';
464
+	const CustomImage = 'CustomImage';
465 465
 }
466 466
 
467 467
 /**
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
  */
481 481
 class TBulletedListDisplayMode extends TEnumerable
482 482
 {
483
-	const Text='Text';
484
-	const HyperLink='HyperLink';
485
-	const LinkButton='LinkButton';
483
+	const Text = 'Text';
484
+	const HyperLink = 'HyperLink';
485
+	const LinkButton = 'LinkButton';
486 486
 }
487 487
 
Please login to merge, or discard this patch.
Braces   +30 added lines, -23 removed lines patch added patch discarded remove patch
@@ -59,8 +59,9 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public function raisePostBackEvent($param)
61 61
 	{
62
-		if($this->getCausesValidation())
63
-			$this->getPage()->validate($this->getValidationGroup());
62
+		if($this->getCausesValidation()) {
63
+					$this->getPage()->validate($this->getValidationGroup());
64
+		}
64 65
 		$this->onClick(new TBulletedListEventParameter((int)$param));
65 66
 	}
66 67
 
@@ -139,8 +140,9 @@  discard block
 block discarded – undo
139 140
 				$writer->addStyleAttribute('list-style-image',"url($url)");
140 141
 				break;
141 142
 		}
142
-		if($needStart && ($start=$this->getFirstBulletNumber())!=1)
143
-			$writer->addAttribute('start',"$start");
143
+		if($needStart && ($start=$this->getFirstBulletNumber())!=1) {
144
+					$writer->addAttribute('start',"$start");
145
+		}
144 146
 		parent::addAttributesToRender($writer);
145 147
 	}
146 148
 
@@ -248,8 +250,9 @@  discard block
 block discarded – undo
248 250
 	 */
249 251
 	public function render($writer)
250 252
 	{
251
-		if($this->getHasItems())
252
-			parent::render($writer);
253
+		if($this->getHasItems()) {
254
+					parent::render($writer);
255
+		}
253 256
 	}
254 257
 
255 258
 	/**
@@ -263,8 +266,9 @@  discard block
 block discarded – undo
263 266
 		$writer->writeLine();
264 267
 		foreach($this->getItems() as $index=>$item)
265 268
 		{
266
-			if($item->getHasAttributes())
267
-				$writer->addAttributes($item->getAttributes());
269
+			if($item->getHasAttributes()) {
270
+							$writer->addAttributes($item->getAttributes());
271
+			}
268 272
 			$writer->renderBeginTag('li');
269 273
 			$this->renderBulletText($writer,$item,$index);
270 274
 			$writer->renderEndTag();
@@ -296,9 +300,9 @@  discard block
 block discarded – undo
296 300
 
297 301
 	protected function renderTextItem($writer, $item, $index)
298 302
 	{
299
-		if($item->getEnabled())
300
-			$writer->write(THttpUtility::htmlEncode($item->getText()));
301
-		else
303
+		if($item->getEnabled()) {
304
+					$writer->write(THttpUtility::htmlEncode($item->getText()));
305
+		} else
302 306
 		{
303 307
 			$writer->addAttribute('disabled','disabled');
304 308
 			$writer->renderBeginTag('span');
@@ -309,16 +313,18 @@  discard block
 block discarded – undo
309 313
 
310 314
 	protected function renderHyperLinkItem($writer, $item, $index)
311 315
 	{
312
-		if(!$this->_isEnabled || !$item->getEnabled())
313
-			$writer->addAttribute('disabled','disabled');
314
-		else
316
+		if(!$this->_isEnabled || !$item->getEnabled()) {
317
+					$writer->addAttribute('disabled','disabled');
318
+		} else
315 319
 		{
316 320
 			$writer->addAttribute('href',$item->getValue());
317
-			if(($target=$this->getTarget())!=='')
318
-				$writer->addAttribute('target',$target);
321
+			if(($target=$this->getTarget())!=='') {
322
+							$writer->addAttribute('target',$target);
323
+			}
324
+		}
325
+		if(($accesskey=$this->getAccessKey())!=='') {
326
+					$writer->addAttribute('accesskey',$accesskey);
319 327
 		}
320
-		if(($accesskey=$this->getAccessKey())!=='')
321
-			$writer->addAttribute('accesskey',$accesskey);
322 328
 		$writer->renderBeginTag('a');
323 329
 		$writer->write(THttpUtility::htmlEncode($item->getText()));
324 330
 		$writer->renderEndTag();
@@ -326,9 +332,9 @@  discard block
 block discarded – undo
326 332
 
327 333
 	protected function renderLinkButtonItem($writer, $item, $index)
328 334
 	{
329
-		if(!$this->_isEnabled || !$item->getEnabled())
330
-			$writer->addAttribute('disabled','disabled');
331
-		else
335
+		if(!$this->_isEnabled || !$item->getEnabled()) {
336
+					$writer->addAttribute('disabled','disabled');
337
+		} else
332 338
 		{
333 339
 			$this->_currentRenderItemIndex = $index;
334 340
 			$writer->addAttribute('id', $this->getClientID().$index);
@@ -336,8 +342,9 @@  discard block
 block discarded – undo
336 342
 			$cs = $this->getPage()->getClientScript();
337 343
 			$cs->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions());
338 344
 		}
339
-		if(($accesskey=$this->getAccessKey())!=='')
340
-			$writer->addAttribute('accesskey',$accesskey);
345
+		if(($accesskey=$this->getAccessKey())!=='') {
346
+					$writer->addAttribute('accesskey',$accesskey);
347
+		}
341 348
 		$writer->renderBeginTag('a');
342 349
 		$writer->write(THttpUtility::htmlEncode($item->getText()));
343 350
 		$writer->renderEndTag();
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TBulletedList class file
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Web.UI.WebControls
10
- */
3
+	 * TBulletedList class file
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 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 TListControl class
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TButton.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -218,6 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * If you override this method, be sure to call the parent implementation
219 219
 	 * so that the event handlers can be invoked.
220 220
 	 * @param TCommandEventParameter event parameter to be passed to the event handlers
221
+	 * @param TCommandEventParameter $param
221 222
 	 */
222 223
 	public function onCommand($param)
223 224
 	{
@@ -342,6 +343,7 @@  discard block
 block discarded – undo
342 343
 
343 344
 	/**
344 345
 	 * @param string the group of validators which the button causes validation upon postback
346
+	 * @param string $value
345 347
 	 */
346 348
 	public function setValidationGroup($value)
347 349
 	{
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	public function getButtonTag()
62 62
 	{
63
-		return $this->getViewState('ButtonTag',TButtonTag::Input);
63
+		return $this->getViewState('ButtonTag', TButtonTag::Input);
64 64
 	}
65 65
 
66 66
 	/**
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function setButtonTag($value)
70 70
 	{
71
-		$this->setViewState('ButtonTag',TPropertyValue::ensureEnum($value,'TButtonTag'),TButtonTag::Input);
71
+		$this->setViewState('ButtonTag', TPropertyValue::ensureEnum($value, 'TButtonTag'), TButtonTag::Input);
72 72
 	}
73 73
 
74 74
 	/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function getEnableClientScript()
78 78
 	{
79
-		return $this->getViewState('EnableClientScript',true);
79
+		return $this->getViewState('EnableClientScript', true);
80 80
 	}
81 81
 
82 82
 	/**
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public function setEnableClientScript($value)
86 86
 	{
87
-		$this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
87
+		$this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true);
88 88
 	}
89 89
 
90 90
 	/**
@@ -94,22 +94,22 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	protected function addAttributesToRender($writer)
96 96
 	{
97
-		$page=$this->getPage();
97
+		$page = $this->getPage();
98 98
 		$page->ensureRenderInForm($this);
99
-		$writer->addAttribute('type',strtolower($this->getButtonType()));
100
-		if(($uniqueID=$this->getUniqueID())!=='')
101
-			$writer->addAttribute('name',$uniqueID);
102
-		if($this->getButtonTag()===TButtonTag::Button)
99
+		$writer->addAttribute('type', strtolower($this->getButtonType()));
100
+		if (($uniqueID = $this->getUniqueID()) !== '')
101
+			$writer->addAttribute('name', $uniqueID);
102
+		if ($this->getButtonTag() === TButtonTag::Button)
103 103
 		  $this->addParsedObject($this->getText());
104 104
 		else
105
-		  $writer->addAttribute('value',$this->getText());
106
-		if($this->getEnabled(true))
105
+		  $writer->addAttribute('value', $this->getText());
106
+		if ($this->getEnabled(true))
107 107
 		{
108
-			if($this->getEnableClientScript() && $this->needPostBackScript())
108
+			if ($this->getEnableClientScript() && $this->needPostBackScript())
109 109
 				$this->renderClientControlScript($writer);
110 110
 		}
111
-		else if($this->getEnabled()) // in this case, parent will not render 'disabled'
112
-			$writer->addAttribute('disabled','disabled');
111
+		else if ($this->getEnabled()) // in this case, parent will not render 'disabled'
112
+			$writer->addAttribute('disabled', 'disabled');
113 113
 
114 114
 		parent::addAttributesToRender($writer);
115 115
 	}
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	protected function renderClientControlScript($writer)
121 121
 	{
122
-		$writer->addAttribute('id',$this->getClientID());
123
-		$this->getPage()->getClientScript()->registerPostBackControl($this->getClientClassName(),$this->getPostBackOptions());
122
+		$writer->addAttribute('id', $this->getClientID());
123
+		$this->getPage()->getClientScript()->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions());
124 124
 	}
125 125
 
126 126
 	/**
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	protected function canCauseValidation()
140 140
 	{
141
-		if($this->getCausesValidation())
141
+		if ($this->getCausesValidation())
142 142
 		{
143
-			$group=$this->getValidationGroup();
144
-			return $this->getPage()->getValidators($group)->getCount()>0;
143
+			$group = $this->getValidationGroup();
144
+			return $this->getPage()->getValidators($group)->getCount() > 0;
145 145
 		}
146 146
 		else
147 147
 			return false;
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function setIsDefaultButton($value)
154 154
 	{
155
-		$this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value),false);
155
+		$this->setViewState('IsDefaultButton', TPropertyValue::ensureBoolean($value), false);
156 156
 	}
157 157
 
158 158
 	/**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	protected function needPostBackScript()
170 170
 	{
171
-		return $this->canCauseValidation() || ($this->getButtonType()!==TButtonType::Submit &&
171
+		return $this->canCauseValidation() || ($this->getButtonType() !== TButtonType::Submit &&
172 172
 			($this->hasEventHandler('OnClick') || $this->hasEventHandler('OnCommand')))
173 173
 			|| $this->getIsDefaultButton();
174 174
 	}
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	protected function getPostBackOptions()
182 182
 	{
183
-		$options['ID']=$this->getClientID();
184
-		$options['CausesValidation']=$this->getCausesValidation();
183
+		$options['ID'] = $this->getClientID();
184
+		$options['CausesValidation'] = $this->getCausesValidation();
185 185
 		$options['EventTarget'] = $this->getUniqueID();
186
-		$options['ValidationGroup']=$this->getValidationGroup();
186
+		$options['ValidationGroup'] = $this->getValidationGroup();
187 187
 
188 188
 		return $options;
189 189
 	}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 */
197 197
 	public function renderContents($writer)
198 198
 	{
199
-		if($this->getButtonTag()===TButtonTag::Button)
199
+		if ($this->getButtonTag() === TButtonTag::Button)
200 200
 			parent::renderContents($writer);
201 201
 	}
202 202
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	public function onClick($param)
211 211
 	{
212
-		$this->raiseEvent('OnClick',$this,$param);
212
+		$this->raiseEvent('OnClick', $this, $param);
213 213
 	}
214 214
 
215 215
 	/**
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	 */
222 222
 	public function onCommand($param)
223 223
 	{
224
-		$this->raiseEvent('OnCommand',$this,$param);
225
-		$this->raiseBubbleEvent($this,$param);
224
+		$this->raiseEvent('OnCommand', $this, $param);
225
+		$this->raiseBubbleEvent($this, $param);
226 226
 	}
227 227
 
228 228
 	/**
@@ -236,10 +236,10 @@  discard block
 block discarded – undo
236 236
 	 */
237 237
 	public function raisePostBackEvent($param)
238 238
 	{
239
-		if($this->getCausesValidation())
239
+		if ($this->getCausesValidation())
240 240
 			$this->getPage()->validate($this->getValidationGroup());
241 241
 		$this->onClick(null);
242
-		$this->onCommand(new TCommandEventParameter($this->getCommandName(),$this->getCommandParameter()));
242
+		$this->onCommand(new TCommandEventParameter($this->getCommandName(), $this->getCommandParameter()));
243 243
 	}
244 244
 
245 245
 	/**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	 */
248 248
 	public function getText()
249 249
 	{
250
-		return $this->getViewState('Text','');
250
+		return $this->getViewState('Text', '');
251 251
 	}
252 252
 
253 253
 	/**
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	 */
256 256
 	public function setText($value)
257 257
 	{
258
-		$this->setViewState('Text',$value,'');
258
+		$this->setViewState('Text', $value, '');
259 259
 	}
260 260
 
261 261
 	/**
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 */
290 290
 	public function getCausesValidation()
291 291
 	{
292
-		return $this->getViewState('CausesValidation',true);
292
+		return $this->getViewState('CausesValidation', true);
293 293
 	}
294 294
 
295 295
 	/**
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	public function setCausesValidation($value)
299 299
 	{
300
-		$this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true);
300
+		$this->setViewState('CausesValidation', TPropertyValue::ensureBoolean($value), true);
301 301
 	}
302 302
 
303 303
 	/**
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	 */
306 306
 	public function getCommandName()
307 307
 	{
308
-		return $this->getViewState('CommandName','');
308
+		return $this->getViewState('CommandName', '');
309 309
 	}
310 310
 
311 311
 	/**
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 	 */
314 314
 	public function setCommandName($value)
315 315
 	{
316
-		$this->setViewState('CommandName',$value,'');
316
+		$this->setViewState('CommandName', $value, '');
317 317
 	}
318 318
 
319 319
 	/**
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 	 */
322 322
 	public function getCommandParameter()
323 323
 	{
324
-		return $this->getViewState('CommandParameter','');
324
+		return $this->getViewState('CommandParameter', '');
325 325
 	}
326 326
 
327 327
 	/**
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 	 */
330 330
 	public function setCommandParameter($value)
331 331
 	{
332
-		$this->setViewState('CommandParameter',$value,'');
332
+		$this->setViewState('CommandParameter', $value, '');
333 333
 	}
334 334
 
335 335
 	/**
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 */
338 338
 	public function getValidationGroup()
339 339
 	{
340
-		return $this->getViewState('ValidationGroup','');
340
+		return $this->getViewState('ValidationGroup', '');
341 341
 	}
342 342
 
343 343
 	/**
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	 */
346 346
 	public function setValidationGroup($value)
347 347
 	{
348
-		$this->setViewState('ValidationGroup',$value,'');
348
+		$this->setViewState('ValidationGroup', $value, '');
349 349
 	}
350 350
 
351 351
 	/**
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 	 */
354 354
 	public function getButtonType()
355 355
 	{
356
-		return $this->getViewState('ButtonType',TButtonType::Submit);
356
+		return $this->getViewState('ButtonType', TButtonType::Submit);
357 357
 	}
358 358
 
359 359
 	/**
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	 */
362 362
 	public function setButtonType($value)
363 363
 	{
364
-		$this->setViewState('ButtonType',TPropertyValue::ensureEnum($value,'TButtonType'),TButtonType::Submit);
364
+		$this->setViewState('ButtonType', TPropertyValue::ensureEnum($value, 'TButtonType'), TButtonType::Submit);
365 365
 	}
366 366
 }
367 367
 
@@ -380,9 +380,9 @@  discard block
 block discarded – undo
380 380
  */
381 381
 class TButtonType extends TEnumerable
382 382
 {
383
-	const Submit='Submit';
384
-	const Reset='Reset';
385
-	const Button='Button';
383
+	const Submit = 'Submit';
384
+	const Reset = 'Reset';
385
+	const Button = 'Button';
386 386
 }
387 387
 
388 388
 /**
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
  */
399 399
 class TButtonTag extends TEnumerable
400 400
 {
401
-	const Input='Input';
402
-	const Button='Button';
401
+	const Input = 'Input';
402
+	const Button = 'Button';
403 403
 }
404 404
 
Please login to merge, or discard this patch.
Braces   +22 added lines, -16 removed lines patch added patch discarded remove patch
@@ -97,19 +97,23 @@  discard block
 block discarded – undo
97 97
 		$page=$this->getPage();
98 98
 		$page->ensureRenderInForm($this);
99 99
 		$writer->addAttribute('type',strtolower($this->getButtonType()));
100
-		if(($uniqueID=$this->getUniqueID())!=='')
101
-			$writer->addAttribute('name',$uniqueID);
102
-		if($this->getButtonTag()===TButtonTag::Button)
103
-		  $this->addParsedObject($this->getText());
104
-		else
105
-		  $writer->addAttribute('value',$this->getText());
100
+		if(($uniqueID=$this->getUniqueID())!=='') {
101
+					$writer->addAttribute('name',$uniqueID);
102
+		}
103
+		if($this->getButtonTag()===TButtonTag::Button) {
104
+				  $this->addParsedObject($this->getText());
105
+		} else {
106
+				  $writer->addAttribute('value',$this->getText());
107
+		}
106 108
 		if($this->getEnabled(true))
107 109
 		{
108
-			if($this->getEnableClientScript() && $this->needPostBackScript())
109
-				$this->renderClientControlScript($writer);
110
-		}
111
-		else if($this->getEnabled()) // in this case, parent will not render 'disabled'
110
+			if($this->getEnableClientScript() && $this->needPostBackScript()) {
111
+							$this->renderClientControlScript($writer);
112
+			}
113
+		} else if($this->getEnabled()) {
114
+			// in this case, parent will not render 'disabled'
112 115
 			$writer->addAttribute('disabled','disabled');
116
+		}
113 117
 
114 118
 		parent::addAttributesToRender($writer);
115 119
 	}
@@ -142,9 +146,9 @@  discard block
 block discarded – undo
142 146
 		{
143 147
 			$group=$this->getValidationGroup();
144 148
 			return $this->getPage()->getValidators($group)->getCount()>0;
149
+		} else {
150
+					return false;
145 151
 		}
146
-		else
147
-			return false;
148 152
 	}
149 153
 
150 154
 	/**
@@ -196,8 +200,9 @@  discard block
 block discarded – undo
196 200
 	 */
197 201
 	public function renderContents($writer)
198 202
 	{
199
-		if($this->getButtonTag()===TButtonTag::Button)
200
-			parent::renderContents($writer);
203
+		if($this->getButtonTag()===TButtonTag::Button) {
204
+					parent::renderContents($writer);
205
+		}
201 206
 	}
202 207
 
203 208
 	/**
@@ -236,8 +241,9 @@  discard block
 block discarded – undo
236 241
 	 */
237 242
 	public function raisePostBackEvent($param)
238 243
 	{
239
-		if($this->getCausesValidation())
240
-			$this->getPage()->validate($this->getValidationGroup());
244
+		if($this->getCausesValidation()) {
245
+					$this->getPage()->validate($this->getValidationGroup());
246
+		}
241 247
 		$this->onClick(null);
242 248
 		$this->onCommand(new TCommandEventParameter($this->getCommandName(),$this->getCommandParameter()));
243 249
 	}
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TCaptcha.php 3 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -267,6 +267,7 @@  discard block
 block discarded – undo
267 267
 
268 268
 	/**
269 269
 	 * @param string the public key used for generating the token. A random one will be generated if this is not set.
270
+	 * @param string $value
270 271
 	 */
271 272
 	public function setPublicKey($value)
272 273
 	{
@@ -322,6 +323,7 @@  discard block
 block discarded – undo
322 323
 	/**
323 324
 	 * Validates a user input with the token.
324 325
 	 * @param string user input
326
+	 * @param string $input
325 327
 	 * @return boolean if the user input is not the same as the token.
326 328
 	 */
327 329
 	public function validate($input)
@@ -447,6 +449,11 @@  discard block
 block discarded – undo
447 449
 	 * @param string private key
448 450
 	 * @param integer the length of the token
449 451
 	 * @param boolean whether the token is case sensitive
452
+	 * @param string $publicKey
453
+	 * @param string $privateKey
454
+	 * @param string $alphabet
455
+	 * @param integer $tokenLength
456
+	 * @param boolean $caseSensitive
450 457
 	 * @return string the token generated.
451 458
 	 */
452 459
 	protected function generateToken($publicKey,$privateKey,$alphabet,$tokenLength,$caseSensitive)
@@ -459,6 +466,7 @@  discard block
 block discarded – undo
459 466
 	 * Converts a hash string into a string with characters consisting of alphanumeric characters.
460 467
 	 * @param string the hexadecimal representation of the hash string
461 468
 	 * @param string the alphabet used to represent the converted string. If empty, it means '234578adefhijmnrtwyABDEFGHIJLMNQRTWY', which excludes those confusing characters.
469
+	 * @param string $hex
462 470
 	 * @return string the converted string
463 471
 	 */
464 472
 	protected function hash2string($hex,$alphabet='')
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
  */
62 62
 class TCaptcha extends TImage
63 63
 {
64
-	const MIN_TOKEN_LENGTH=2;
65
-	const MAX_TOKEN_LENGTH=40;
64
+	const MIN_TOKEN_LENGTH = 2;
65
+	const MAX_TOKEN_LENGTH = 40;
66 66
 	private $_privateKey;
67
-	private $_validated=false;
67
+	private $_validated = false;
68 68
 
69 69
 	/**
70 70
 	 * @return integer the theme of the token image. Defaults to 0.
71 71
 	 */
72 72
 	public function getTokenImageTheme()
73 73
 	{
74
-		return $this->getViewState('TokenImageTheme',0);
74
+		return $this->getViewState('TokenImageTheme', 0);
75 75
 	}
76 76
 
77 77
 	/**
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function setTokenImageTheme($value)
91 91
 	{
92
-		$value=TPropertyValue::ensureInteger($value);
93
-		if($value>=0 && $value<=63)
94
-			$this->setViewState('TokenImageTheme',$value,0);
92
+		$value = TPropertyValue::ensureInteger($value);
93
+		if ($value >= 0 && $value <= 63)
94
+			$this->setViewState('TokenImageTheme', $value, 0);
95 95
 		else
96
-			throw new TConfigurationException('captcha_tokenimagetheme_invalid',0,63);
96
+			throw new TConfigurationException('captcha_tokenimagetheme_invalid', 0, 63);
97 97
 	}
98 98
 
99 99
 	/**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function getTokenFontSize()
103 103
 	{
104
-		return $this->getViewState('TokenFontSize',30);
104
+		return $this->getViewState('TokenFontSize', 30);
105 105
 	}
106 106
 
107 107
 	/**
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
 	 */
113 113
 	public function setTokenFontSize($value)
114 114
 	{
115
-		$value=TPropertyValue::ensureInteger($value);
116
-		if($value>=20 && $value<=100)
117
-			$this->setViewState('TokenFontSize',$value,30);
115
+		$value = TPropertyValue::ensureInteger($value);
116
+		if ($value >= 20 && $value <= 100)
117
+			$this->setViewState('TokenFontSize', $value, 30);
118 118
 		else
119
-			throw new TConfigurationException('captcha_tokenfontsize_invalid',20,100);
119
+			throw new TConfigurationException('captcha_tokenfontsize_invalid', 20, 100);
120 120
 	}
121 121
 
122 122
 	/**
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 */
125 125
 	public function getMinTokenLength()
126 126
 	{
127
-		return $this->getViewState('MinTokenLength',4);
127
+		return $this->getViewState('MinTokenLength', 4);
128 128
 	}
129 129
 
130 130
 	/**
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	 */
133 133
 	public function setMinTokenLength($value)
134 134
 	{
135
-		$length=TPropertyValue::ensureInteger($value);
136
-		if($length>=self::MIN_TOKEN_LENGTH && $length<=self::MAX_TOKEN_LENGTH)
137
-			$this->setViewState('MinTokenLength',$length,4);
135
+		$length = TPropertyValue::ensureInteger($value);
136
+		if ($length >= self::MIN_TOKEN_LENGTH && $length <= self::MAX_TOKEN_LENGTH)
137
+			$this->setViewState('MinTokenLength', $length, 4);
138 138
 		else
139
-			throw new TConfigurationException('captcha_mintokenlength_invalid',self::MIN_TOKEN_LENGTH,self::MAX_TOKEN_LENGTH);
139
+			throw new TConfigurationException('captcha_mintokenlength_invalid', self::MIN_TOKEN_LENGTH, self::MAX_TOKEN_LENGTH);
140 140
 	}
141 141
 
142 142
 	/**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	public function getMaxTokenLength()
146 146
 	{
147
-		return $this->getViewState('MaxTokenLength',6);
147
+		return $this->getViewState('MaxTokenLength', 6);
148 148
 	}
149 149
 
150 150
 	/**
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function setMaxTokenLength($value)
154 154
 	{
155
-		$length=TPropertyValue::ensureInteger($value);
156
-		if($length>=self::MIN_TOKEN_LENGTH && $length<=self::MAX_TOKEN_LENGTH)
157
-			$this->setViewState('MaxTokenLength',$length,6);
155
+		$length = TPropertyValue::ensureInteger($value);
156
+		if ($length >= self::MIN_TOKEN_LENGTH && $length <= self::MAX_TOKEN_LENGTH)
157
+			$this->setViewState('MaxTokenLength', $length, 6);
158 158
 		else
159
-			throw new TConfigurationException('captcha_maxtokenlength_invalid',self::MIN_TOKEN_LENGTH,self::MAX_TOKEN_LENGTH);
159
+			throw new TConfigurationException('captcha_maxtokenlength_invalid', self::MIN_TOKEN_LENGTH, self::MAX_TOKEN_LENGTH);
160 160
 	}
161 161
 
162 162
 	/**
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	public function getCaseSensitive()
166 166
 	{
167
-		return $this->getViewState('CaseSensitive',true);
167
+		return $this->getViewState('CaseSensitive', true);
168 168
 	}
169 169
 
170 170
 	/**
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	public function setCaseSensitive($value)
174 174
 	{
175
-		$this->setViewState('CaseSensitive',TPropertyValue::ensureBoolean($value),true);
175
+		$this->setViewState('CaseSensitive', TPropertyValue::ensureBoolean($value), true);
176 176
 	}
177 177
 
178 178
 	/**
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	public function getTokenAlphabet()
182 182
 	{
183
-		return $this->getViewState('TokenAlphabet','234578adefhijmnrtABDEFGHJLMNRT');
183
+		return $this->getViewState('TokenAlphabet', '234578adefhijmnrtABDEFGHJLMNRT');
184 184
 	}
185 185
 
186 186
 	/**
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	public function setTokenAlphabet($value)
190 190
 	{
191
-		if(strlen($value)<2)
191
+		if (strlen($value) < 2)
192 192
 			throw new TConfigurationException('captcha_tokenalphabet_invalid');
193
-		$this->setViewState('TokenAlphabet',$value,'234578adefhijmnrtABDEFGHJLMNRT');
193
+		$this->setViewState('TokenAlphabet', $value, '234578adefhijmnrtABDEFGHJLMNRT');
194 194
 	}
195 195
 
196 196
 	/**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public function getTokenExpiry()
200 200
 	{
201
-		return $this->getViewState('TokenExpiry',600);
201
+		return $this->getViewState('TokenExpiry', 600);
202 202
 	}
203 203
 
204 204
 	/**
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function setTokenExpiry($value)
208 208
 	{
209
-		$this->setViewState('TokenExpiry',TPropertyValue::ensureInteger($value),600);
209
+		$this->setViewState('TokenExpiry', TPropertyValue::ensureInteger($value), 600);
210 210
 	}
211 211
 
212 212
 	/**
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	public function getChangingTokenBackground()
216 216
 	{
217
-		return $this->getViewState('ChangingTokenBackground',false);
217
+		return $this->getViewState('ChangingTokenBackground', false);
218 218
 	}
219 219
 
220 220
 	/**
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	public function setChangingTokenBackground($value)
224 224
 	{
225
-		$this->setViewState('ChangingTokenBackground',TPropertyValue::ensureBoolean($value),false);
225
+		$this->setViewState('ChangingTokenBackground', TPropertyValue::ensureBoolean($value), false);
226 226
 	}
227 227
 
228 228
 	/**
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 */
231 231
 	public function getTestLimit()
232 232
 	{
233
-		return $this->getViewState('TestLimit',5);
233
+		return $this->getViewState('TestLimit', 5);
234 234
 	}
235 235
 
236 236
 	/**
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	public function setTestLimit($value)
240 240
 	{
241
-		$this->setViewState('TestLimit',TPropertyValue::ensureInteger($value),5);
241
+		$this->setViewState('TestLimit', TPropertyValue::ensureInteger($value), 5);
242 242
 	}
243 243
 
244 244
 	/**
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	public function getIsTokenExpired()
248 248
 	{
249
-		if(($expiry=$this->getTokenExpiry())>0 && ($start=$this->getViewState('TokenGenerated',0))>0)
250
-			return $expiry+$start<time();
249
+		if (($expiry = $this->getTokenExpiry()) > 0 && ($start = $this->getViewState('TokenGenerated', 0)) > 0)
250
+			return $expiry + $start < time();
251 251
 		else
252 252
 			return false;
253 253
 	}
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
 	 */
258 258
 	public function getPublicKey()
259 259
 	{
260
-		if(($publicKey=$this->getViewState('PublicKey',''))==='')
260
+		if (($publicKey = $this->getViewState('PublicKey', '')) === '')
261 261
 		{
262
-			$publicKey=$this->generateRandomKey();
262
+			$publicKey = $this->generateRandomKey();
263 263
 			$this->setPublicKey($publicKey);
264 264
 		}
265 265
 		return $publicKey;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 */
271 271
 	public function setPublicKey($value)
272 272
 	{
273
-		$this->setViewState('PublicKey',$value,'');
273
+		$this->setViewState('PublicKey', $value, '');
274 274
 	}
275 275
 
276 276
 	/**
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 */
279 279
 	public function getToken()
280 280
 	{
281
-		return $this->generateToken($this->getPublicKey(),$this->getPrivateKey(),$this->getTokenAlphabet(),$this->getTokenLength(),$this->getCaseSensitive());
281
+		return $this->generateToken($this->getPublicKey(), $this->getPrivateKey(), $this->getTokenAlphabet(), $this->getTokenLength(), $this->getCaseSensitive());
282 282
 	}
283 283
 
284 284
 	/**
@@ -286,17 +286,17 @@  discard block
 block discarded – undo
286 286
 	 */
287 287
 	protected function getTokenLength()
288 288
 	{
289
-		if(($tokenLength=$this->getViewState('TokenLength'))===null)
289
+		if (($tokenLength = $this->getViewState('TokenLength')) === null)
290 290
 		{
291
-			$minLength=$this->getMinTokenLength();
292
-			$maxLength=$this->getMaxTokenLength();
293
-			if($minLength>$maxLength)
294
-				$tokenLength=rand($maxLength,$minLength);
295
-			else if($minLength<$maxLength)
296
-				$tokenLength=rand($minLength,$maxLength);
291
+			$minLength = $this->getMinTokenLength();
292
+			$maxLength = $this->getMaxTokenLength();
293
+			if ($minLength > $maxLength)
294
+				$tokenLength = rand($maxLength, $minLength);
295
+			else if ($minLength < $maxLength)
296
+				$tokenLength = rand($minLength, $maxLength);
297 297
 			else
298
-				$tokenLength=$minLength;
299
-			$this->setViewState('TokenLength',$tokenLength);
298
+				$tokenLength = $minLength;
299
+			$this->setViewState('TokenLength', $tokenLength);
300 300
 		}
301 301
 		return $tokenLength;
302 302
 	}
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
 	 */
307 307
 	public function getPrivateKey()
308 308
 	{
309
-		if($this->_privateKey===null)
309
+		if ($this->_privateKey === null)
310 310
 		{
311
-			$fileName=$this->generatePrivateKeyFile();
312
-			$content=file_get_contents($fileName);
313
-			$matches=array();
314
-			if(preg_match("/privateKey='(.*?)'/ms",$content,$matches)>0)
315
-				$this->_privateKey=$matches[1];
311
+			$fileName = $this->generatePrivateKeyFile();
312
+			$content = file_get_contents($fileName);
313
+			$matches = array();
314
+			if (preg_match("/privateKey='(.*?)'/ms", $content, $matches) > 0)
315
+				$this->_privateKey = $matches[1];
316 316
 			else
317 317
 				throw new TConfigurationException('captcha_privatekey_unknown');
318 318
 		}
@@ -326,18 +326,18 @@  discard block
 block discarded – undo
326 326
 	 */
327 327
 	public function validate($input)
328 328
 	{
329
-		$number=$this->getViewState('TestNumber',0);
330
-		if(!$this->_validated)
329
+		$number = $this->getViewState('TestNumber', 0);
330
+		if (!$this->_validated)
331 331
 		{
332
-			$this->setViewState('TestNumber',++$number);
333
-			$this->_validated=true;
332
+			$this->setViewState('TestNumber', ++$number);
333
+			$this->_validated = true;
334 334
 		}
335
-		if($this->getIsTokenExpired() || (($limit=$this->getTestLimit())>0 && $number>$limit))
335
+		if ($this->getIsTokenExpired() || (($limit = $this->getTestLimit()) > 0 && $number > $limit))
336 336
 		{
337 337
 			$this->regenerateToken();
338 338
 			return false;
339 339
 		}
340
-		return ($this->getToken()===($this->getCaseSensitive()?$input:strtoupper($input)));
340
+		return ($this->getToken() === ($this->getCaseSensitive() ? $input : strtoupper($input)));
341 341
 	}
342 342
 
343 343
 	/**
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 		$this->setPublicKey('');
352 352
 		$this->clearViewState('TokenGenerated');
353 353
 		$this->clearViewState('RandomSeed');
354
-		$this->clearViewState('TestNumber',0);
354
+		$this->clearViewState('TestNumber', 0);
355 355
 	}
356 356
 
357 357
 	/**
@@ -361,17 +361,17 @@  discard block
 block discarded – undo
361 361
 	public function onPreRender($param)
362 362
 	{
363 363
 		parent::onPreRender($param);
364
-		if(!self::checkRequirements())
364
+		if (!self::checkRequirements())
365 365
 			throw new TConfigurationException('captcha_imagettftext_required');
366
-		if(!$this->getViewState('TokenGenerated',0))
366
+		if (!$this->getViewState('TokenGenerated', 0))
367 367
 		{
368
-			$manager=$this->getApplication()->getAssetManager();
368
+			$manager = $this->getApplication()->getAssetManager();
369 369
 			$manager->publishFilePath($this->getFontFile());
370
-			$url=$manager->publishFilePath($this->getCaptchaScriptFile());
371
-			$url.='?options='.urlencode($this->getTokenImageOptions());
370
+			$url = $manager->publishFilePath($this->getCaptchaScriptFile());
371
+			$url .= '?options=' . urlencode($this->getTokenImageOptions());
372 372
 			$this->setImageUrl($url);
373 373
 
374
-			$this->setViewState('TokenGenerated',time());
374
+			$this->setViewState('TokenGenerated', time());
375 375
 		}
376 376
 	}
377 377
 
@@ -380,23 +380,23 @@  discard block
 block discarded – undo
380 380
 	 */
381 381
 	protected function getTokenImageOptions()
382 382
 	{
383
-		$privateKey=$this->getPrivateKey();  // call this method to ensure private key is generated
384
-		$token=$this->getToken();
385
-		$options=array();
386
-		$options['publicKey']=$this->getPublicKey();
387
-		$options['tokenLength']=strlen($token);
388
-		$options['caseSensitive']=$this->getCaseSensitive();
389
-		$options['alphabet']=$this->getTokenAlphabet();
390
-		$options['fontSize']=$this->getTokenFontSize();
391
-		$options['theme']=$this->getTokenImageTheme();
392
-		if(($randomSeed=$this->getViewState('RandomSeed',0))===0)
383
+		$privateKey = $this->getPrivateKey(); // call this method to ensure private key is generated
384
+		$token = $this->getToken();
385
+		$options = array();
386
+		$options['publicKey'] = $this->getPublicKey();
387
+		$options['tokenLength'] = strlen($token);
388
+		$options['caseSensitive'] = $this->getCaseSensitive();
389
+		$options['alphabet'] = $this->getTokenAlphabet();
390
+		$options['fontSize'] = $this->getTokenFontSize();
391
+		$options['theme'] = $this->getTokenImageTheme();
392
+		if (($randomSeed = $this->getViewState('RandomSeed', 0)) === 0)
393 393
 		{
394
-			$randomSeed=(int)(microtime()*1000000);
395
-			$this->setViewState('RandomSeed',$randomSeed);
394
+			$randomSeed = (int) (microtime() * 1000000);
395
+			$this->setViewState('RandomSeed', $randomSeed);
396 396
 		}
397
-		$options['randomSeed']=$this->getChangingTokenBackground()?0:$randomSeed;
398
-		$str=serialize($options);
399
-		return base64_encode(md5($privateKey.$str).$str);
397
+		$options['randomSeed'] = $this->getChangingTokenBackground() ? 0 : $randomSeed;
398
+		$str = serialize($options);
399
+		return base64_encode(md5($privateKey . $str) . $str);
400 400
 	}
401 401
 
402 402
 	/**
@@ -404,12 +404,12 @@  discard block
 block discarded – undo
404 404
 	 */
405 405
 	protected function getCaptchaScriptFile()
406 406
 	{
407
-		return dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'captcha.php';
407
+		return dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'captcha.php';
408 408
 	}
409 409
 
410 410
 	protected function getFontFile()
411 411
 	{
412
-		return dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'verase.ttf';
412
+		return dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'verase.ttf';
413 413
 	}
414 414
 
415 415
 	/**
@@ -418,17 +418,17 @@  discard block
 block discarded – undo
418 418
 	 */
419 419
 	protected function generatePrivateKeyFile()
420 420
 	{
421
-		$captchaScript=$this->getCaptchaScriptFile();
422
-		$path=dirname($this->getApplication()->getAssetManager()->getPublishedPath($captchaScript));
423
-		$fileName=$path.DIRECTORY_SEPARATOR.'captcha_key.php';
424
-		if(!is_file($fileName))
421
+		$captchaScript = $this->getCaptchaScriptFile();
422
+		$path = dirname($this->getApplication()->getAssetManager()->getPublishedPath($captchaScript));
423
+		$fileName = $path . DIRECTORY_SEPARATOR . 'captcha_key.php';
424
+		if (!is_file($fileName))
425 425
 		{
426 426
 			@mkdir($path);
427
-			$key=$this->generateRandomKey();
428
-			$content="<?php
427
+			$key = $this->generateRandomKey();
428
+			$content = "<?php
429 429
 \$privateKey='$key';
430 430
 ?>";
431
-			file_put_contents($fileName,$content);
431
+			file_put_contents($fileName, $content);
432 432
 		}
433 433
 		return $fileName;
434 434
 	}
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	 */
439 439
 	protected function generateRandomKey()
440 440
 	{
441
-		return md5(rand().rand().rand().rand());
441
+		return md5(rand() . rand() . rand() . rand());
442 442
 	}
443 443
 
444 444
 	/**
@@ -449,10 +449,10 @@  discard block
 block discarded – undo
449 449
 	 * @param boolean whether the token is case sensitive
450 450
 	 * @return string the token generated.
451 451
 	 */
452
-	protected function generateToken($publicKey,$privateKey,$alphabet,$tokenLength,$caseSensitive)
452
+	protected function generateToken($publicKey, $privateKey, $alphabet, $tokenLength, $caseSensitive)
453 453
 	{
454
-		$token=substr($this->hash2string(md5($publicKey.$privateKey),$alphabet).$this->hash2string(md5($privateKey.$publicKey),$alphabet),0,$tokenLength);
455
-		return $caseSensitive?$token:strtoupper($token);
454
+		$token = substr($this->hash2string(md5($publicKey . $privateKey), $alphabet) . $this->hash2string(md5($privateKey . $publicKey), $alphabet), 0, $tokenLength);
455
+		return $caseSensitive ? $token : strtoupper($token);
456 456
 	}
457 457
 
458 458
 	/**
@@ -461,20 +461,20 @@  discard block
 block discarded – undo
461 461
 	 * @param string the alphabet used to represent the converted string. If empty, it means '234578adefhijmnrtwyABDEFGHIJLMNQRTWY', which excludes those confusing characters.
462 462
 	 * @return string the converted string
463 463
 	 */
464
-	protected function hash2string($hex,$alphabet='')
464
+	protected function hash2string($hex, $alphabet = '')
465 465
 	{
466
-		if(strlen($alphabet)<2)
467
-			$alphabet='234578adefhijmnrtABDEFGHJLMNQRT';
468
-		$hexLength=strlen($hex);
469
-		$base=strlen($alphabet);
470
-		$result='';
471
-		for($i=0;$i<$hexLength;$i+=6)
466
+		if (strlen($alphabet) < 2)
467
+			$alphabet = '234578adefhijmnrtABDEFGHJLMNQRT';
468
+		$hexLength = strlen($hex);
469
+		$base = strlen($alphabet);
470
+		$result = '';
471
+		for ($i = 0; $i < $hexLength; $i += 6)
472 472
 		{
473
-			$number=hexdec(substr($hex,$i,6));
474
-			while($number)
473
+			$number = hexdec(substr($hex, $i, 6));
474
+			while ($number)
475 475
 			{
476
-				$result.=$alphabet[$number%$base];
477
-				$number=floor($number/$base);
476
+				$result .= $alphabet[$number % $base];
477
+				$number = floor($number / $base);
478 478
 			}
479 479
 		}
480 480
 		return $result;
Please login to merge, or discard this patch.
Braces   +46 added lines, -36 removed lines patch added patch discarded remove patch
@@ -90,10 +90,11 @@  discard block
 block discarded – undo
90 90
 	public function setTokenImageTheme($value)
91 91
 	{
92 92
 		$value=TPropertyValue::ensureInteger($value);
93
-		if($value>=0 && $value<=63)
94
-			$this->setViewState('TokenImageTheme',$value,0);
95
-		else
96
-			throw new TConfigurationException('captcha_tokenimagetheme_invalid',0,63);
93
+		if($value>=0 && $value<=63) {
94
+					$this->setViewState('TokenImageTheme',$value,0);
95
+		} else {
96
+					throw new TConfigurationException('captcha_tokenimagetheme_invalid',0,63);
97
+		}
97 98
 	}
98 99
 
99 100
 	/**
@@ -113,10 +114,11 @@  discard block
 block discarded – undo
113 114
 	public function setTokenFontSize($value)
114 115
 	{
115 116
 		$value=TPropertyValue::ensureInteger($value);
116
-		if($value>=20 && $value<=100)
117
-			$this->setViewState('TokenFontSize',$value,30);
118
-		else
119
-			throw new TConfigurationException('captcha_tokenfontsize_invalid',20,100);
117
+		if($value>=20 && $value<=100) {
118
+					$this->setViewState('TokenFontSize',$value,30);
119
+		} else {
120
+					throw new TConfigurationException('captcha_tokenfontsize_invalid',20,100);
121
+		}
120 122
 	}
121 123
 
122 124
 	/**
@@ -133,10 +135,11 @@  discard block
 block discarded – undo
133 135
 	public function setMinTokenLength($value)
134 136
 	{
135 137
 		$length=TPropertyValue::ensureInteger($value);
136
-		if($length>=self::MIN_TOKEN_LENGTH && $length<=self::MAX_TOKEN_LENGTH)
137
-			$this->setViewState('MinTokenLength',$length,4);
138
-		else
139
-			throw new TConfigurationException('captcha_mintokenlength_invalid',self::MIN_TOKEN_LENGTH,self::MAX_TOKEN_LENGTH);
138
+		if($length>=self::MIN_TOKEN_LENGTH && $length<=self::MAX_TOKEN_LENGTH) {
139
+					$this->setViewState('MinTokenLength',$length,4);
140
+		} else {
141
+					throw new TConfigurationException('captcha_mintokenlength_invalid',self::MIN_TOKEN_LENGTH,self::MAX_TOKEN_LENGTH);
142
+		}
140 143
 	}
141 144
 
142 145
 	/**
@@ -153,10 +156,11 @@  discard block
 block discarded – undo
153 156
 	public function setMaxTokenLength($value)
154 157
 	{
155 158
 		$length=TPropertyValue::ensureInteger($value);
156
-		if($length>=self::MIN_TOKEN_LENGTH && $length<=self::MAX_TOKEN_LENGTH)
157
-			$this->setViewState('MaxTokenLength',$length,6);
158
-		else
159
-			throw new TConfigurationException('captcha_maxtokenlength_invalid',self::MIN_TOKEN_LENGTH,self::MAX_TOKEN_LENGTH);
159
+		if($length>=self::MIN_TOKEN_LENGTH && $length<=self::MAX_TOKEN_LENGTH) {
160
+					$this->setViewState('MaxTokenLength',$length,6);
161
+		} else {
162
+					throw new TConfigurationException('captcha_maxtokenlength_invalid',self::MIN_TOKEN_LENGTH,self::MAX_TOKEN_LENGTH);
163
+		}
160 164
 	}
161 165
 
162 166
 	/**
@@ -188,8 +192,9 @@  discard block
 block discarded – undo
188 192
 	 */
189 193
 	public function setTokenAlphabet($value)
190 194
 	{
191
-		if(strlen($value)<2)
192
-			throw new TConfigurationException('captcha_tokenalphabet_invalid');
195
+		if(strlen($value)<2) {
196
+					throw new TConfigurationException('captcha_tokenalphabet_invalid');
197
+		}
193 198
 		$this->setViewState('TokenAlphabet',$value,'234578adefhijmnrtABDEFGHJLMNRT');
194 199
 	}
195 200
 
@@ -246,10 +251,11 @@  discard block
 block discarded – undo
246 251
 	 */
247 252
 	public function getIsTokenExpired()
248 253
 	{
249
-		if(($expiry=$this->getTokenExpiry())>0 && ($start=$this->getViewState('TokenGenerated',0))>0)
250
-			return $expiry+$start<time();
251
-		else
252
-			return false;
254
+		if(($expiry=$this->getTokenExpiry())>0 && ($start=$this->getViewState('TokenGenerated',0))>0) {
255
+					return $expiry+$start<time();
256
+		} else {
257
+					return false;
258
+		}
253 259
 	}
254 260
 
255 261
 	/**
@@ -290,12 +296,13 @@  discard block
 block discarded – undo
290 296
 		{
291 297
 			$minLength=$this->getMinTokenLength();
292 298
 			$maxLength=$this->getMaxTokenLength();
293
-			if($minLength>$maxLength)
294
-				$tokenLength=rand($maxLength,$minLength);
295
-			else if($minLength<$maxLength)
296
-				$tokenLength=rand($minLength,$maxLength);
297
-			else
298
-				$tokenLength=$minLength;
299
+			if($minLength>$maxLength) {
300
+							$tokenLength=rand($maxLength,$minLength);
301
+			} else if($minLength<$maxLength) {
302
+							$tokenLength=rand($minLength,$maxLength);
303
+			} else {
304
+							$tokenLength=$minLength;
305
+			}
299 306
 			$this->setViewState('TokenLength',$tokenLength);
300 307
 		}
301 308
 		return $tokenLength;
@@ -311,10 +318,11 @@  discard block
 block discarded – undo
311 318
 			$fileName=$this->generatePrivateKeyFile();
312 319
 			$content=file_get_contents($fileName);
313 320
 			$matches=array();
314
-			if(preg_match("/privateKey='(.*?)'/ms",$content,$matches)>0)
315
-				$this->_privateKey=$matches[1];
316
-			else
317
-				throw new TConfigurationException('captcha_privatekey_unknown');
321
+			if(preg_match("/privateKey='(.*?)'/ms",$content,$matches)>0) {
322
+							$this->_privateKey=$matches[1];
323
+			} else {
324
+							throw new TConfigurationException('captcha_privatekey_unknown');
325
+			}
318 326
 		}
319 327
 		return $this->_privateKey;
320 328
 	}
@@ -361,8 +369,9 @@  discard block
 block discarded – undo
361 369
 	public function onPreRender($param)
362 370
 	{
363 371
 		parent::onPreRender($param);
364
-		if(!self::checkRequirements())
365
-			throw new TConfigurationException('captcha_imagettftext_required');
372
+		if(!self::checkRequirements()) {
373
+					throw new TConfigurationException('captcha_imagettftext_required');
374
+		}
366 375
 		if(!$this->getViewState('TokenGenerated',0))
367 376
 		{
368 377
 			$manager=$this->getApplication()->getAssetManager();
@@ -463,8 +472,9 @@  discard block
 block discarded – undo
463 472
 	 */
464 473
 	protected function hash2string($hex,$alphabet='')
465 474
 	{
466
-		if(strlen($alphabet)<2)
467
-			$alphabet='234578adefhijmnrtABDEFGHJLMNQRT';
475
+		if(strlen($alphabet)<2) {
476
+					$alphabet='234578adefhijmnrtABDEFGHJLMNQRT';
477
+		}
468 478
 		$hexLength=strlen($hex);
469 479
 		$base=strlen($alphabet);
470 480
 		$result='';
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TCaptchaValidator.php 4 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	}
80 80
 
81 81
 	/**
82
-	 * @return TCaptchaControl the CAPTCHA control to be validated against
82
+	 * @return TCaptcha the CAPTCHA control to be validated against
83 83
 	 * @throws TConfigurationException if the CAPTCHA cannot be found according to {@link setCaptchaControl CaptchaControl}
84 84
 	 */
85 85
 	protected function findCaptchaControl()
@@ -115,6 +115,9 @@  discard block
 block discarded – undo
115 115
 		return $options;
116 116
 	}
117 117
 
118
+	/**
119
+	 * @param string $token
120
+	 */
118 121
 	private function generateTokenHash($token)
119 122
 	{
120 123
 		for($h=0,$i=strlen($token)-1;$i>=0;--$i)
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function getCaptchaControl()
52 52
 	{
53
-		return $this->getViewState('CaptchaControl','');
53
+		return $this->getViewState('CaptchaControl', '');
54 54
 	}
55 55
 
56 56
 	/**
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function setCaptchaControl($value)
63 63
 	{
64
-		$this->setViewState('CaptchaControl',TPropertyValue::ensureString($value),'');
64
+		$this->setViewState('CaptchaControl', TPropertyValue::ensureString($value), '');
65 65
 	}
66 66
 
67 67
 	/**
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	protected function evaluateIsValid()
75 75
 	{
76
-		$value=$this->getValidationValue($this->getValidationTarget());
77
-		$control=$this->findCaptchaControl();
76
+		$value = $this->getValidationValue($this->getValidationTarget());
77
+		$control = $this->findCaptchaControl();
78 78
 		return $control->validate(trim($value));
79 79
 	}
80 80
 
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	protected function findCaptchaControl()
86 86
 	{
87
-		if(($id=$this->getCaptchaControl())==='')
87
+		if (($id = $this->getCaptchaControl()) === '')
88 88
 			throw new TConfigurationException('captchavalidator_captchacontrol_required');
89
-		else if(($control=$this->findControl($id))===null)
90
-			throw new TConfigurationException('captchavalidator_captchacontrol_inexistent',$id);
91
-		else if(!($control instanceof TCaptcha))
92
-			throw new TConfigurationException('captchavalidator_captchacontrol_invalid',$id);
89
+		else if (($control = $this->findControl($id)) === null)
90
+			throw new TConfigurationException('captchavalidator_captchacontrol_inexistent', $id);
91
+		else if (!($control instanceof TCaptcha))
92
+			throw new TConfigurationException('captchavalidator_captchacontrol_invalid', $id);
93 93
 		else
94 94
 			return $control;
95 95
 	}
@@ -100,25 +100,25 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	protected function getClientScriptOptions()
102 102
 	{
103
-		$options=parent::getClientScriptOptions();
104
-		$control=$this->findCaptchaControl();
105
-		if($control->getCaseSensitive())
103
+		$options = parent::getClientScriptOptions();
104
+		$control = $this->findCaptchaControl();
105
+		if ($control->getCaseSensitive())
106 106
 		{
107
-			$options['TokenHash']=$this->generateTokenHash($control->getToken());
108
-			$options['CaseSensitive']=true;
107
+			$options['TokenHash'] = $this->generateTokenHash($control->getToken());
108
+			$options['CaseSensitive'] = true;
109 109
 		}
110 110
 		else
111 111
 		{
112
-			$options['TokenHash']=$this->generateTokenHash(strtoupper($control->getToken()));
113
-			$options['CaseSensitive']=false;
112
+			$options['TokenHash'] = $this->generateTokenHash(strtoupper($control->getToken()));
113
+			$options['CaseSensitive'] = false;
114 114
 		}
115 115
 		return $options;
116 116
 	}
117 117
 
118 118
 	private function generateTokenHash($token)
119 119
 	{
120
-		for($h=0,$i=strlen($token)-1;$i>=0;--$i)
121
-			$h+=ord($token[$i]);
120
+		for ($h = 0, $i = strlen($token) - 1; $i >= 0; --$i)
121
+			$h += ord($token[$i]);
122 122
 		return $h;
123 123
 	}
124 124
 }
Please login to merge, or discard this patch.
Braces   +13 added lines, -12 removed lines patch added patch discarded remove patch
@@ -84,14 +84,15 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	protected function findCaptchaControl()
86 86
 	{
87
-		if(($id=$this->getCaptchaControl())==='')
88
-			throw new TConfigurationException('captchavalidator_captchacontrol_required');
89
-		else if(($control=$this->findControl($id))===null)
90
-			throw new TConfigurationException('captchavalidator_captchacontrol_inexistent',$id);
91
-		else if(!($control instanceof TCaptcha))
92
-			throw new TConfigurationException('captchavalidator_captchacontrol_invalid',$id);
93
-		else
94
-			return $control;
87
+		if(($id=$this->getCaptchaControl())==='') {
88
+					throw new TConfigurationException('captchavalidator_captchacontrol_required');
89
+		} else if(($control=$this->findControl($id))===null) {
90
+					throw new TConfigurationException('captchavalidator_captchacontrol_inexistent',$id);
91
+		} else if(!($control instanceof TCaptcha)) {
92
+					throw new TConfigurationException('captchavalidator_captchacontrol_invalid',$id);
93
+		} else {
94
+					return $control;
95
+		}
95 96
 	}
96 97
 
97 98
 	/**
@@ -106,8 +107,7 @@  discard block
 block discarded – undo
106 107
 		{
107 108
 			$options['TokenHash']=$this->generateTokenHash($control->getToken());
108 109
 			$options['CaseSensitive']=true;
109
-		}
110
-		else
110
+		} else
111 111
 		{
112 112
 			$options['TokenHash']=$this->generateTokenHash(strtoupper($control->getToken()));
113 113
 			$options['CaseSensitive']=false;
@@ -117,8 +117,9 @@  discard block
 block discarded – undo
117 117
 
118 118
 	private function generateTokenHash($token)
119 119
 	{
120
-		for($h=0,$i=strlen($token)-1;$i>=0;--$i)
121
-			$h+=ord($token[$i]);
120
+		for($h=0,$i=strlen($token)-1;$i>=0;--$i) {
121
+					$h+=ord($token[$i]);
122
+		}
122 123
 		return $h;
123 124
 	}
124 125
 }
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TCaptchaValidator class file
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Web.UI.WebControls
10
- */
3
+	 * TCaptchaValidator class file
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 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
 Prado::using('System.Web.UI.WebControls.TBaseValidator');
13 13
 Prado::using('System.Web.UI.WebControls.TCaptcha');
Please login to merge, or discard this patch.