Completed
Push — scrutinizer ( c2ef4a...84e9d0 )
by Fabio
22:07
created
framework/I18N/TGlobalization.php 4 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	}
91 91
 
92 92
 	/**
93
-	 * @return string default culture
93
+	 * @return boolean default culture
94 94
 	 */
95 95
 	public function getTranslateDefaultCulture()
96 96
 	{
@@ -163,6 +163,7 @@  discard block
 block discarded – undo
163 163
 
164 164
 	/**
165 165
 	 * @param string localization charset, e.g. <tt>UTF-8</tt>
166
+	 * @param string $charset
166 167
 	 */
167 168
 	public function setCharset($charset)
168 169
 	{
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
- * TGlobalization class file.
4
- *
5
- * @author Wei Zhuo<weizhuo[at]gmail[dot]com>
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.I18N
10
- */
3
+	 * TGlobalization class file.
4
+	 *
5
+	 * @author Wei Zhuo<weizhuo[at]gmail[dot]com>
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.I18N
10
+	 */
11 11
 
12 12
 
13 13
 /**
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
 	 * The current charset.
42 42
 	 * @var string
43 43
 	 */
44
-	private $_charset=null;
44
+	private $_charset = null;
45 45
 
46 46
 	/**
47 47
 	 * The current culture.
48 48
 	 * @var string
49 49
 	 */
50
-	private $_culture=null;
50
+	private $_culture = null;
51 51
 
52 52
 	/**
53 53
 	 * Translation source parameters.
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	/**
59 59
 	 * @var boolean whether we should translate the default culture
60 60
 	 */
61
-	private $_translateDefaultCulture=true;
61
+	private $_translateDefaultCulture = true;
62 62
 
63 63
 	/**
64 64
 	 * Initialize the Culture and Charset for this application.
@@ -69,21 +69,21 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function init($config)
71 71
 	{
72
-		if($this->_charset===null)
73
-			$this->_charset=$this->getDefaultCharset();
74
-		if($this->_culture===null)
75
-			$this->_culture=$this->getDefaultCulture();
72
+		if ($this->_charset === null)
73
+			$this->_charset = $this->getDefaultCharset();
74
+		if ($this->_culture === null)
75
+			$this->_culture = $this->getDefaultCulture();
76 76
 
77
-		if($config!==null)
77
+		if ($config !== null)
78 78
 		{
79
-			if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
80
-				$translation = isset($config['translate'])?$config['translate']:null;
79
+			if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
80
+				$translation = isset($config['translate']) ? $config['translate'] : null;
81 81
 			else
82 82
 			{
83 83
 				$t = $config->getElementByTagName('translation');
84
-				$translation = ($t)?$t->getAttributes():null;
84
+				$translation = ($t) ? $t->getAttributes() : null;
85 85
 			}
86
-			if($translation)
86
+			if ($translation)
87 87
 				$this->setTranslationConfiguration($translation);
88 88
 		}
89 89
 		$this->getApplication()->setGlobalization($this);
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function setDefaultCulture($culture)
120 120
 	{
121
-		$this->_defaultCulture = str_replace('-','_',$culture);
121
+		$this->_defaultCulture = str_replace('-', '_', $culture);
122 122
 	}
123 123
 
124 124
 	/**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 */
151 151
 	public function setCulture($culture)
152 152
 	{
153
-		$this->_culture = str_replace('-','_',$culture);
153
+		$this->_culture = str_replace('-', '_', $culture);
154 154
 	}
155 155
 
156 156
 	/**
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
 	 */
197 197
 	protected function setTranslationConfiguration($config)
198 198
 	{
199
-		if($config['type'] == 'XLIFF' || $config['type'] == 'gettext')
199
+		if ($config['type'] == 'XLIFF' || $config['type'] == 'gettext')
200 200
 		{
201
-			if($config['source'])
201
+			if ($config['source'])
202 202
 			{
203 203
 				$config['source'] = Prado::getPathOfNamespace($config['source']);
204
-				if(!is_dir($config['source']))
204
+				if (!is_dir($config['source']))
205 205
 				{
206
-					if(@mkdir($config['source'])===false)
206
+					if (@mkdir($config['source']) === false)
207 207
 					throw new TConfigurationException('globalization_source_path_failed',
208 208
 						$config['source']);
209 209
 					chmod($config['source'], PRADO_CHMOD); //make it deletable
@@ -214,12 +214,12 @@  discard block
 block discarded – undo
214 214
 				throw new TConfigurationException("invalid source dir '{$config['source']}'");
215 215
 			}
216 216
 		}
217
-		if($config['cache'])
217
+		if ($config['cache'])
218 218
 		{
219
-			$config['cache'] = $this->getApplication()->getRunTimePath().'/i18n';
220
-			if(!is_dir($config['cache']))
219
+			$config['cache'] = $this->getApplication()->getRunTimePath() . '/i18n';
220
+			if (!is_dir($config['cache']))
221 221
 			{
222
-				if(@mkdir($config['cache'])===false)
222
+				if (@mkdir($config['cache']) === false)
223 223
 					throw new TConfigurationException('globalization_cache_path_failed',
224 224
 						$config['cache']);
225 225
 				chmod($config['cache'], PRADO_CHMOD); //make it deletable
@@ -250,12 +250,12 @@  discard block
 block discarded – undo
250 250
 	 * @param string $culture the Culture string
251 251
 	 * @return array variants of the culture.
252 252
 	 */
253
-	public function getCultureVariants($culture=null)
253
+	public function getCultureVariants($culture = null)
254 254
 	{
255
-		if($culture===null) $culture = $this->getCulture();
255
+		if ($culture === null) $culture = $this->getCulture();
256 256
 		$variants = explode('_', $culture);
257 257
 		$result = array();
258
-		for(; count($variants) > 0; array_pop($variants))
258
+		for (; count($variants) > 0; array_pop($variants))
259 259
 			$result[] = implode('_', $variants);
260 260
 		return $result;
261 261
 	}
@@ -279,16 +279,16 @@  discard block
 block discarded – undo
279 279
 	 * @param string culture string, null to use current culture
280 280
 	 * @return array list of possible localized resource files.
281 281
 	 */
282
-	public function getLocalizedResource($file,$culture=null)
282
+	public function getLocalizedResource($file, $culture = null)
283 283
 	{
284 284
 		$files = array();
285 285
 		$variants = $this->getCultureVariants($culture);
286 286
 		$path = pathinfo($file);
287
-		foreach($variants as $variant)
288
-			$files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename'];
289
-		$filename = substr($path['basename'],0,strrpos($path['basename'],'.'));
290
-		foreach($variants as $variant)
291
-			$files[] = $path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension'];
287
+		foreach ($variants as $variant)
288
+			$files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $variant . DIRECTORY_SEPARATOR . $path['basename'];
289
+		$filename = substr($path['basename'], 0, strrpos($path['basename'], '.'));
290
+		foreach ($variants as $variant)
291
+			$files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $filename . '.' . $variant . '.' . $path['extension'];
292 292
 		$files[] = $file;
293 293
 		return $files;
294 294
 	}
Please login to merge, or discard this patch.
Braces   +31 added lines, -22 removed lines patch added patch discarded remove patch
@@ -69,22 +69,25 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function init($config)
71 71
 	{
72
-		if($this->_charset===null)
73
-			$this->_charset=$this->getDefaultCharset();
74
-		if($this->_culture===null)
75
-			$this->_culture=$this->getDefaultCulture();
72
+		if($this->_charset===null) {
73
+					$this->_charset=$this->getDefaultCharset();
74
+		}
75
+		if($this->_culture===null) {
76
+					$this->_culture=$this->getDefaultCulture();
77
+		}
76 78
 
77 79
 		if($config!==null)
78 80
 		{
79
-			if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
80
-				$translation = isset($config['translate'])?$config['translate']:null;
81
-			else
81
+			if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) {
82
+							$translation = isset($config['translate'])?$config['translate']:null;
83
+			} else
82 84
 			{
83 85
 				$t = $config->getElementByTagName('translation');
84 86
 				$translation = ($t)?$t->getAttributes():null;
85 87
 			}
86
-			if($translation)
87
-				$this->setTranslationConfiguration($translation);
88
+			if($translation) {
89
+							$this->setTranslationConfiguration($translation);
90
+			}
88 91
 		}
89 92
 		$this->getApplication()->setGlobalization($this);
90 93
 	}
@@ -203,13 +206,13 @@  discard block
 block discarded – undo
203 206
 				$config['source'] = Prado::getPathOfNamespace($config['source']);
204 207
 				if(!is_dir($config['source']))
205 208
 				{
206
-					if(@mkdir($config['source'])===false)
207
-					throw new TConfigurationException('globalization_source_path_failed',
209
+					if(@mkdir($config['source'])===false) {
210
+										throw new TConfigurationException('globalization_source_path_failed',
208 211
 						$config['source']);
212
+					}
209 213
 					chmod($config['source'], PRADO_CHMOD); //make it deletable
210 214
 				}
211
-			}
212
-			else
215
+			} else
213 216
 			{
214 217
 				throw new TConfigurationException("invalid source dir '{$config['source']}'");
215 218
 			}
@@ -219,9 +222,10 @@  discard block
 block discarded – undo
219 222
 			$config['cache'] = $this->getApplication()->getRunTimePath().'/i18n';
220 223
 			if(!is_dir($config['cache']))
221 224
 			{
222
-				if(@mkdir($config['cache'])===false)
223
-					throw new TConfigurationException('globalization_cache_path_failed',
225
+				if(@mkdir($config['cache'])===false) {
226
+									throw new TConfigurationException('globalization_cache_path_failed',
224 227
 						$config['cache']);
228
+				}
225 229
 				chmod($config['cache'], PRADO_CHMOD); //make it deletable
226 230
 			}
227 231
 		}
@@ -252,11 +256,14 @@  discard block
 block discarded – undo
252 256
 	 */
253 257
 	public function getCultureVariants($culture=null)
254 258
 	{
255
-		if($culture===null) $culture = $this->getCulture();
259
+		if($culture===null) {
260
+			$culture = $this->getCulture();
261
+		}
256 262
 		$variants = explode('_', $culture);
257 263
 		$result = array();
258
-		for(; count($variants) > 0; array_pop($variants))
259
-			$result[] = implode('_', $variants);
264
+		for(; count($variants) > 0; array_pop($variants)) {
265
+					$result[] = implode('_', $variants);
266
+		}
260 267
 		return $result;
261 268
 	}
262 269
 
@@ -284,11 +291,13 @@  discard block
 block discarded – undo
284 291
 		$files = array();
285 292
 		$variants = $this->getCultureVariants($culture);
286 293
 		$path = pathinfo($file);
287
-		foreach($variants as $variant)
288
-			$files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename'];
294
+		foreach($variants as $variant) {
295
+					$files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename'];
296
+		}
289 297
 		$filename = substr($path['basename'],0,strrpos($path['basename'],'.'));
290
-		foreach($variants as $variant)
291
-			$files[] = $path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension'];
298
+		foreach($variants as $variant) {
299
+					$files[] = $path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension'];
300
+		}
292 301
 		$files[] = $file;
293 302
 		return $files;
294 303
 	}
Please login to merge, or discard this patch.
framework/interfaces.php 2 patches
Doc Comments   +18 added lines patch added patch discarded remove patch
@@ -23,6 +23,7 @@  discard block
 block discarded – undo
23 23
 	/**
24 24
 	 * Initializes the module.
25 25
 	 * @param TXmlElement the configuration for the module
26
+	 * @return void
26 27
 	 */
27 28
 	public function init($config);
28 29
 	/**
@@ -31,6 +32,7 @@  discard block
 block discarded – undo
31 32
 	public function getID();
32 33
 	/**
33 34
 	 * @param string ID of the module
35
+	 * @return void
34 36
 	 */
35 37
 	public function setID($id);
36 38
 }
@@ -49,6 +51,7 @@  discard block
 block discarded – undo
49 51
 	/**
50 52
 	 * Initializes the service.
51 53
 	 * @param TXmlElement the configuration for the service
54
+	 * @return void
52 55
 	 */
53 56
 	public function init($config);
54 57
 	/**
@@ -57,6 +60,7 @@  discard block
 block discarded – undo
57 60
 	public function getID();
58 61
 	/**
59 62
 	 * @param string ID of the service
63
+	 * @return void
60 64
 	 */
61 65
 	public function setID($id);
62 66
 	/**
@@ -65,10 +69,12 @@  discard block
 block discarded – undo
65 69
 	public function getEnabled();
66 70
 	/**
67 71
 	 * @param boolean whether the service is enabled
72
+	 * @return void
68 73
 	 */
69 74
 	public function setEnabled($value);
70 75
 	/**
71 76
 	 * Runs the service.
77
+	 * @return void
72 78
 	 */
73 79
 	public function run();
74 80
 }
@@ -87,6 +93,7 @@  discard block
 block discarded – undo
87 93
 	/**
88 94
 	 * Writes a string.
89 95
 	 * @param string string to be written
96
+	 * @return void
90 97
 	 */
91 98
 	public function write($str);
92 99
 	/**
@@ -113,6 +120,7 @@  discard block
 block discarded – undo
113 120
 	public function getName();
114 121
 	/**
115 122
 	 * @param string username
123
+	 * @return void
116 124
 	 */
117 125
 	public function setName($value);
118 126
 	/**
@@ -121,6 +129,8 @@  discard block
 block discarded – undo
121 129
 	public function getIsGuest();
122 130
 	/**
123 131
 	 * @param boolean if the user is a guest
132
+	 * @param boolean $value
133
+	 * @return void
124 134
 	 */
125 135
 	public function setIsGuest($value);
126 136
 	/**
@@ -167,6 +177,7 @@  discard block
 block discarded – undo
167 177
 	/**
168 178
 	 * Saves state into a persistent storage.
169 179
 	 * @param mixed the state to be saved
180
+	 * @return void
170 181
 	 */
171 182
 	public function save($state);
172 183
 }
@@ -208,6 +219,7 @@  discard block
 block discarded – undo
208 219
 	 * @param mixed the value to be cached
209 220
 	 * @param integer the number of seconds in which the cached value will expire. 0 means never expire.
210 221
 	 * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labelled invalid.
222
+	 * @param string $id
211 223
 	 * @return boolean true if the value is successfully stored into cache, false otherwise
212 224
 	 */
213 225
 	public function add($id,$value,$expire=0,$dependency=null);
@@ -259,6 +271,7 @@  discard block
 block discarded – undo
259 271
 	/**
260 272
 	 * Renders the component to end-users.
261 273
 	 * @param ITextWriter writer for the rendering purpose
274
+	 * @return void
262 275
 	 */
263 276
 	public function render($writer);
264 277
 }
@@ -276,6 +289,7 @@  discard block
 block discarded – undo
276 289
 {
277 290
 	/**
278 291
 	 * Performs databinding.
292
+	 * @return void
279 293
 	 */
280 294
 	public function dataBind();
281 295
 }
@@ -301,6 +315,7 @@  discard block
 block discarded – undo
301 315
 	public function getStyle();
302 316
 	/**
303 317
 	 * Removes all styles associated with the object
318
+	 * @return void
304 319
 	 */
305 320
 	public function clearStyle();
306 321
 }
@@ -339,6 +354,7 @@  discard block
 block discarded – undo
339 354
 	 * appropriate event(s) (e.g. OnClick, OnCommand) indicating the component
340 355
 	 * is responsible for the callback event.
341 356
 	 * @param TCallbackEventParameter the parameter associated with the callback event
357
+	 * @return void
342 358
 	 */
343 359
 	public function raiseCallbackEvent($eventArgument);
344 360
 }
@@ -362,6 +378,8 @@  discard block
 block discarded – undo
362 378
 
363 379
 	/**
364 380
 	 * @param mixed the data to be bound to this object
381
+	 * @param TActiveRecord $value
382
+	 * @return void
365 383
 	 */
366 384
 	public function setData($value);
367 385
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labelled invalid.
201 201
 	 * @return boolean true if the value is successfully stored into cache, false otherwise
202 202
 	 */
203
-	public function set($id,$value,$expire=0,$dependency=null);
203
+	public function set($id, $value, $expire = 0, $dependency = null);
204 204
 	/**
205 205
 	 * Stores a value identified by a key into cache if the cache does not contain this key.
206 206
 	 * Nothing will be done if the cache already contains the key.
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labelled invalid.
211 211
 	 * @return boolean true if the value is successfully stored into cache, false otherwise
212 212
 	 */
213
-	public function add($id,$value,$expire=0,$dependency=null);
213
+	public function add($id, $value, $expire = 0, $dependency = null);
214 214
 	/**
215 215
 	 * Deletes a value with the specified key from cache
216 216
 	 * @param string the key of the value to be deleted
Please login to merge, or discard this patch.
framework/IO/TTarFileExtractor.php 4 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -224,6 +224,9 @@  discard block
 block discarded – undo
224 224
       return $v_block;
225 225
     }
226 226
 
227
+    /**
228
+     * @param double $p_len
229
+     */
227 230
     private function _jumpBlock($p_len=null)
228 231
     {
229 232
       if (is_resource($this->_file)) {
@@ -317,6 +320,12 @@  discard block
 block discarded – undo
317 320
       return true;
318 321
     }
319 322
 
323
+    /**
324
+     * @param string $p_path
325
+     * @param string $p_mode
326
+     * @param integer $p_file_list
327
+     * @param string $p_remove_path
328
+     */
320 329
     protected function _extractList($p_path, &$p_list_detail, $p_mode,
321 330
 	                      $p_file_list, $p_remove_path)
322 331
     {
Please login to merge, or discard this patch.
Indentation   +510 added lines, -510 removed lines patch added patch discarded remove patch
@@ -35,537 +35,537 @@
 block discarded – undo
35 35
  */
36 36
 class TTarFileExtractor
37 37
 {
38
-    /**
39
-    * @var string Name of the Tar
40
-    */
41
-    private $_tarname='';
42
-
43
-    /**
44
-    * @var file descriptor
45
-    */
46
-    private $_file=0;
47
-
48
-    /**
49
-    * @var string Local Tar name of a remote Tar (http:// or ftp://)
50
-    */
51
-    private $_temp_tarname='';
52
-
53
-    /**
54
-    * Archive_Tar Class constructor. This flavour of the constructor only
55
-    * declare a new Archive_Tar object, identifying it by the name of the
56
-    * tar file.
57
-    *
58
-    * @param    string  $p_tarname  The name of the tar archive to create
59
-    * @access public
60
-    */
61
-    public function __construct($p_tarname)
62
-    {
63
-        $this->_tarname = $p_tarname;
64
-    }
65
-
66
-    public function __destruct()
67
-    {
68
-        $this->_close();
69
-        // ----- Look for a local copy to delete
70
-        if ($this->_temp_tarname != '')
71
-            @unlink($this->_temp_tarname);
72
-    }
73
-
74
-    public function extract($p_path='')
75
-    {
76
-        return $this->extractModify($p_path, '');
77
-    }
78
-
79
-    /**
80
-    * This method extract all the content of the archive in the directory
81
-    * indicated by $p_path. When relevant the memorized path of the
82
-    * files/dir can be modified by removing the $p_remove_path path at the
83
-    * beginning of the file/dir path.
84
-    * While extracting a file, if the directory path does not exists it is
85
-    * created.
86
-    * While extracting a file, if the file already exists it is replaced
87
-    * without looking for last modification date.
88
-    * While extracting a file, if the file already exists and is write
89
-    * protected, the extraction is aborted.
90
-    * While extracting a file, if a directory with the same name already
91
-    * exists, the extraction is aborted.
92
-    * While extracting a directory, if a file with the same name already
93
-    * exists, the extraction is aborted.
94
-    * While extracting a file/directory if the destination directory exist
95
-    * and is write protected, or does not exist but can not be created,
96
-    * the extraction is aborted.
97
-    * If after extraction an extracted file does not show the correct
98
-    * stored file size, the extraction is aborted.
99
-    * When the extraction is aborted, a PEAR error text is set and false
100
-    * is returned. However the result can be a partial extraction that may
101
-    * need to be manually cleaned.
102
-    *
103
-    * @param string $p_path         The path of the directory where the
104
-	*                               files/dir need to by extracted.
105
-    * @param string $p_remove_path  Part of the memorized path that can be
106
-	*                               removed if present at the beginning of
107
-	*                               the file/dir path.
108
-    * @return boolean               true on success, false on error.
109
-    * @access public
110
-    */
111
-    protected function extractModify($p_path, $p_remove_path)
112
-    {
113
-        $v_result = true;
114
-        $v_list_detail = array();
115
-
116
-        if ($v_result = $this->_openRead()) {
117
-            $v_result = $this->_extractList($p_path, $v_list_detail,
118
-			                                "complete", 0, $p_remove_path);
119
-            $this->_close();
120
-        }
121
-
122
-        return $v_result;
123
-    }
124
-
125
-    protected function _error($p_message)
126
-    {
38
+	/**
39
+	 * @var string Name of the Tar
40
+	 */
41
+	private $_tarname='';
42
+
43
+	/**
44
+	 * @var file descriptor
45
+	 */
46
+	private $_file=0;
47
+
48
+	/**
49
+	 * @var string Local Tar name of a remote Tar (http:// or ftp://)
50
+	 */
51
+	private $_temp_tarname='';
52
+
53
+	/**
54
+	 * Archive_Tar Class constructor. This flavour of the constructor only
55
+	 * declare a new Archive_Tar object, identifying it by the name of the
56
+	 * tar file.
57
+	 *
58
+	 * @param    string  $p_tarname  The name of the tar archive to create
59
+	 * @access public
60
+	 */
61
+	public function __construct($p_tarname)
62
+	{
63
+		$this->_tarname = $p_tarname;
64
+	}
65
+
66
+	public function __destruct()
67
+	{
68
+		$this->_close();
69
+		// ----- Look for a local copy to delete
70
+		if ($this->_temp_tarname != '')
71
+			@unlink($this->_temp_tarname);
72
+	}
73
+
74
+	public function extract($p_path='')
75
+	{
76
+		return $this->extractModify($p_path, '');
77
+	}
78
+
79
+	/**
80
+	 * This method extract all the content of the archive in the directory
81
+	 * indicated by $p_path. When relevant the memorized path of the
82
+	 * files/dir can be modified by removing the $p_remove_path path at the
83
+	 * beginning of the file/dir path.
84
+	 * While extracting a file, if the directory path does not exists it is
85
+	 * created.
86
+	 * While extracting a file, if the file already exists it is replaced
87
+	 * without looking for last modification date.
88
+	 * While extracting a file, if the file already exists and is write
89
+	 * protected, the extraction is aborted.
90
+	 * While extracting a file, if a directory with the same name already
91
+	 * exists, the extraction is aborted.
92
+	 * While extracting a directory, if a file with the same name already
93
+	 * exists, the extraction is aborted.
94
+	 * While extracting a file/directory if the destination directory exist
95
+	 * and is write protected, or does not exist but can not be created,
96
+	 * the extraction is aborted.
97
+	 * If after extraction an extracted file does not show the correct
98
+	 * stored file size, the extraction is aborted.
99
+	 * When the extraction is aborted, a PEAR error text is set and false
100
+	 * is returned. However the result can be a partial extraction that may
101
+	 * need to be manually cleaned.
102
+	 *
103
+	 * @param string $p_path         The path of the directory where the
104
+	 *                               files/dir need to by extracted.
105
+	 * @param string $p_remove_path  Part of the memorized path that can be
106
+	 *                               removed if present at the beginning of
107
+	 *                               the file/dir path.
108
+	 * @return boolean               true on success, false on error.
109
+	 * @access public
110
+	 */
111
+	protected function extractModify($p_path, $p_remove_path)
112
+	{
113
+		$v_result = true;
114
+		$v_list_detail = array();
115
+
116
+		if ($v_result = $this->_openRead()) {
117
+			$v_result = $this->_extractList($p_path, $v_list_detail,
118
+											"complete", 0, $p_remove_path);
119
+			$this->_close();
120
+		}
121
+
122
+		return $v_result;
123
+	}
124
+
125
+	protected function _error($p_message)
126
+	{
127 127
 		throw new Exception($p_message);
128
-    }
129
-
130
-    private function _isArchive($p_filename=null)
131
-    {
132
-        if ($p_filename == null) {
133
-            $p_filename = $this->_tarname;
134
-        }
135
-        clearstatcache();
136
-        return @is_file($p_filename);
137
-    }
138
-
139
-    private function _openRead()
140
-    {
141
-        if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') {
142
-
143
-          // ----- Look if a local copy need to be done
144
-          if ($this->_temp_tarname == '') {
145
-              $this->_temp_tarname = uniqid('tar').'.tmp';
146
-              if (!$v_file_from = @fopen($this->_tarname, 'rb')) {
147
-                $this->_error('Unable to open in read mode \''
148
-				              .$this->_tarname.'\'');
149
-                $this->_temp_tarname = '';
150
-                return false;
151
-              }
152
-              if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) {
153
-                $this->_error('Unable to open in write mode \''
154
-				              .$this->_temp_tarname.'\'');
155
-                $this->_temp_tarname = '';
156
-                return false;
157
-              }
158
-              while ($v_data = @fread($v_file_from, 1024))
159
-                  @fwrite($v_file_to, $v_data);
160
-              @fclose($v_file_from);
161
-              @fclose($v_file_to);
162
-          }
163
-
164
-          // ----- File to open if the local copy
165
-          $v_filename = $this->_temp_tarname;
166
-
167
-        } else
168
-          // ----- File to open if the normal Tar file
169
-          $v_filename = $this->_tarname;
128
+	}
129
+
130
+	private function _isArchive($p_filename=null)
131
+	{
132
+		if ($p_filename == null) {
133
+			$p_filename = $this->_tarname;
134
+		}
135
+		clearstatcache();
136
+		return @is_file($p_filename);
137
+	}
138
+
139
+	private function _openRead()
140
+	{
141
+		if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') {
142
+
143
+		  // ----- Look if a local copy need to be done
144
+		  if ($this->_temp_tarname == '') {
145
+			  $this->_temp_tarname = uniqid('tar').'.tmp';
146
+			  if (!$v_file_from = @fopen($this->_tarname, 'rb')) {
147
+				$this->_error('Unable to open in read mode \''
148
+							  .$this->_tarname.'\'');
149
+				$this->_temp_tarname = '';
150
+				return false;
151
+			  }
152
+			  if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) {
153
+				$this->_error('Unable to open in write mode \''
154
+							  .$this->_temp_tarname.'\'');
155
+				$this->_temp_tarname = '';
156
+				return false;
157
+			  }
158
+			  while ($v_data = @fread($v_file_from, 1024))
159
+				  @fwrite($v_file_to, $v_data);
160
+			  @fclose($v_file_from);
161
+			  @fclose($v_file_to);
162
+		  }
163
+
164
+		  // ----- File to open if the local copy
165
+		  $v_filename = $this->_temp_tarname;
166
+
167
+		} else
168
+		  // ----- File to open if the normal Tar file
169
+		  $v_filename = $this->_tarname;
170 170
 
171 171
 		$this->_file = @fopen($v_filename, "rb");
172 172
 
173
-        if ($this->_file == 0) {
174
-            $this->_error('Unable to open in read mode \''.$v_filename.'\'');
175
-            return false;
176
-        }
173
+		if ($this->_file == 0) {
174
+			$this->_error('Unable to open in read mode \''.$v_filename.'\'');
175
+			return false;
176
+		}
177 177
 
178
-        return true;
179
-    }
178
+		return true;
179
+	}
180 180
 
181
-    private function _close()
182
-    {
183
-        //if (isset($this->_file)) {
184
-        if (is_resource($this->_file))
181
+	private function _close()
182
+	{
183
+		//if (isset($this->_file)) {
184
+		if (is_resource($this->_file))
185 185
 		{
186
-               @fclose($this->_file);
187
-            $this->_file = 0;
188
-        }
189
-
190
-        // ----- Look if a local copy need to be erase
191
-        // Note that it might be interesting to keep the url for a time : ToDo
192
-        if ($this->_temp_tarname != '') {
193
-            @unlink($this->_temp_tarname);
194
-            $this->_temp_tarname = '';
195
-        }
196
-
197
-        return true;
198
-    }
199
-
200
-    private function _cleanFile()
201
-    {
202
-        $this->_close();
203
-
204
-        // ----- Look for a local copy
205
-        if ($this->_temp_tarname != '') {
206
-            // ----- Remove the local copy but not the remote tarname
207
-            @unlink($this->_temp_tarname);
208
-            $this->_temp_tarname = '';
209
-        } else {
210
-            // ----- Remove the local tarname file
211
-            @unlink($this->_tarname);
212
-        }
213
-        $this->_tarname = '';
214
-
215
-        return true;
216
-    }
217
-
218
-    private function _readBlock()
219
-    {
220
-      $v_block = null;
221
-      if (is_resource($this->_file)) {
222
-              $v_block = @fread($this->_file, 512);
223
-      }
224
-      return $v_block;
225
-    }
226
-
227
-    private function _jumpBlock($p_len=null)
228
-    {
229
-      if (is_resource($this->_file)) {
230
-          if ($p_len === null)
231
-              $p_len = 1;
232
-
233
-              @fseek($this->_file, @ftell($this->_file)+($p_len*512));
234
-      }
235
-      return true;
236
-    }
237
-
238
-    private function _readHeader($v_binary_data, &$v_header)
239
-    {
240
-        if (strlen($v_binary_data)==0) {
241
-            $v_header['filename'] = '';
242
-            return true;
243
-        }
244
-
245
-        if (strlen($v_binary_data) != 512) {
246
-            $v_header['filename'] = '';
247
-            $this->_error('Invalid block size : '.strlen($v_binary_data));
248
-            return false;
249
-        }
250
-
251
-        // ----- Calculate the checksum
252
-        $v_checksum = 0;
253
-        // ..... First part of the header
254
-        for ($i=0; $i<148; $i++)
255
-            $v_checksum+=ord(substr($v_binary_data,$i,1));
256
-        // ..... Ignore the checksum value and replace it by ' ' (space)
257
-        for ($i=148; $i<156; $i++)
258
-            $v_checksum += ord(' ');
259
-        // ..... Last part of the header
260
-        for ($i=156; $i<512; $i++)
261
-           $v_checksum+=ord(substr($v_binary_data,$i,1));
262
-
263
-        $v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/"
264
-		                 ."a8checksum/a1typeflag/a100link/a6magic/a2version/"
186
+			   @fclose($this->_file);
187
+			$this->_file = 0;
188
+		}
189
+
190
+		// ----- Look if a local copy need to be erase
191
+		// Note that it might be interesting to keep the url for a time : ToDo
192
+		if ($this->_temp_tarname != '') {
193
+			@unlink($this->_temp_tarname);
194
+			$this->_temp_tarname = '';
195
+		}
196
+
197
+		return true;
198
+	}
199
+
200
+	private function _cleanFile()
201
+	{
202
+		$this->_close();
203
+
204
+		// ----- Look for a local copy
205
+		if ($this->_temp_tarname != '') {
206
+			// ----- Remove the local copy but not the remote tarname
207
+			@unlink($this->_temp_tarname);
208
+			$this->_temp_tarname = '';
209
+		} else {
210
+			// ----- Remove the local tarname file
211
+			@unlink($this->_tarname);
212
+		}
213
+		$this->_tarname = '';
214
+
215
+		return true;
216
+	}
217
+
218
+	private function _readBlock()
219
+	{
220
+	  $v_block = null;
221
+	  if (is_resource($this->_file)) {
222
+			  $v_block = @fread($this->_file, 512);
223
+	  }
224
+	  return $v_block;
225
+	}
226
+
227
+	private function _jumpBlock($p_len=null)
228
+	{
229
+	  if (is_resource($this->_file)) {
230
+		  if ($p_len === null)
231
+			  $p_len = 1;
232
+
233
+			  @fseek($this->_file, @ftell($this->_file)+($p_len*512));
234
+	  }
235
+	  return true;
236
+	}
237
+
238
+	private function _readHeader($v_binary_data, &$v_header)
239
+	{
240
+		if (strlen($v_binary_data)==0) {
241
+			$v_header['filename'] = '';
242
+			return true;
243
+		}
244
+
245
+		if (strlen($v_binary_data) != 512) {
246
+			$v_header['filename'] = '';
247
+			$this->_error('Invalid block size : '.strlen($v_binary_data));
248
+			return false;
249
+		}
250
+
251
+		// ----- Calculate the checksum
252
+		$v_checksum = 0;
253
+		// ..... First part of the header
254
+		for ($i=0; $i<148; $i++)
255
+			$v_checksum+=ord(substr($v_binary_data,$i,1));
256
+		// ..... Ignore the checksum value and replace it by ' ' (space)
257
+		for ($i=148; $i<156; $i++)
258
+			$v_checksum += ord(' ');
259
+		// ..... Last part of the header
260
+		for ($i=156; $i<512; $i++)
261
+		   $v_checksum+=ord(substr($v_binary_data,$i,1));
262
+
263
+		$v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/"
264
+						 ."a8checksum/a1typeflag/a100link/a6magic/a2version/"
265 265
 						 ."a32uname/a32gname/a8devmajor/a8devminor",
266 266
 						 $v_binary_data);
267 267
 
268
-        // ----- Extract the checksum
269
-        $v_header['checksum'] = OctDec(trim($v_data['checksum']));
270
-        if ($v_header['checksum'] != $v_checksum) {
271
-            $v_header['filename'] = '';
268
+		// ----- Extract the checksum
269
+		$v_header['checksum'] = OctDec(trim($v_data['checksum']));
270
+		if ($v_header['checksum'] != $v_checksum) {
271
+			$v_header['filename'] = '';
272 272
 
273
-            // ----- Look for last block (empty block)
274
-            if (($v_checksum == 256) && ($v_header['checksum'] == 0))
275
-                return true;
273
+			// ----- Look for last block (empty block)
274
+			if (($v_checksum == 256) && ($v_header['checksum'] == 0))
275
+				return true;
276 276
 
277
-            $this->_error('Invalid checksum for file "'.$v_data['filename']
278
-			              .'" : '.$v_checksum.' calculated, '
277
+			$this->_error('Invalid checksum for file "'.$v_data['filename']
278
+						  .'" : '.$v_checksum.' calculated, '
279 279
 						  .$v_header['checksum'].' expected');
280
-            return false;
281
-        }
282
-
283
-        // ----- Extract the properties
284
-        $v_header['filename'] = trim($v_data['filename']);
285
-        $v_header['mode'] = OctDec(trim($v_data['mode']));
286
-        $v_header['uid'] = OctDec(trim($v_data['uid']));
287
-        $v_header['gid'] = OctDec(trim($v_data['gid']));
288
-        $v_header['size'] = OctDec(trim($v_data['size']));
289
-        $v_header['mtime'] = OctDec(trim($v_data['mtime']));
290
-        if (($v_header['typeflag'] = $v_data['typeflag']) == "5") {
291
-          $v_header['size'] = 0;
292
-        }
293
-        return true;
294
-    }
295
-
296
-    private function _readLongHeader(&$v_header)
297
-    {
298
-      $v_filename = '';
299
-      $n = floor($v_header['size']/512);
300
-      for ($i=0; $i<$n; $i++) {
301
-        $v_content = $this->_readBlock();
302
-        $v_filename .= $v_content;
303
-      }
304
-      if (($v_header['size'] % 512) != 0) {
305
-        $v_content = $this->_readBlock();
306
-        $v_filename .= $v_content;
307
-      }
308
-
309
-      // ----- Read the next header
310
-      $v_binary_data = $this->_readBlock();
311
-
312
-      if (!$this->_readHeader($v_binary_data, $v_header))
313
-        return false;
314
-
315
-      $v_header['filename'] = $v_filename;
316
-
317
-      return true;
318
-    }
319
-
320
-    protected function _extractList($p_path, &$p_list_detail, $p_mode,
321
-	                      $p_file_list, $p_remove_path)
322
-    {
323
-    $v_result=true;
324
-    $v_nb = 0;
325
-    $v_extract_all = true;
326
-    $v_listing = false;
327
-
328
-    $p_path = $this->_translateWinPath($p_path, false);
329
-    if ($p_path == '' || (substr($p_path, 0, 1) != '/'
330
-	    && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) {
331
-      $p_path = "./".$p_path;
332
-    }
333
-    $p_remove_path = $this->_translateWinPath($p_remove_path);
334
-
335
-    // ----- Look for path to remove format (should end by /)
336
-    if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/'))
337
-      $p_remove_path .= '/';
338
-    $p_remove_path_size = strlen($p_remove_path);
339
-
340
-    switch ($p_mode) {
341
-      case "complete" :
342
-        $v_extract_all = true;
343
-        $v_listing = false;
344
-      break;
345
-      case "partial" :
346
-          $v_extract_all = false;
347
-          $v_listing = false;
348
-      break;
349
-      case "list" :
350
-          $v_extract_all = false;
351
-          $v_listing = true;
352
-      break;
353
-      default :
354
-        $this->_error('Invalid extract mode ('.$p_mode.')');
355
-        return false;
356
-    }
357
-
358
-    clearstatcache();
359
-
360
-    while (strlen($v_binary_data = $this->_readBlock()) != 0)
361
-    {
362
-      $v_extract_file = false;
363
-      $v_extraction_stopped = 0;
364
-
365
-      if (!$this->_readHeader($v_binary_data, $v_header))
366
-        return false;
367
-
368
-      if ($v_header['filename'] == '') {
369
-        continue;
370
-      }
371
-
372
-      // ----- Look for long filename
373
-      if ($v_header['typeflag'] == 'L') {
374
-        if (!$this->_readLongHeader($v_header))
375
-          return false;
376
-      }
377
-
378
-      if ((!$v_extract_all) && (is_array($p_file_list))) {
379
-        // ----- By default no unzip if the file is not found
380
-        $v_extract_file = false;
381
-
382
-        for ($i=0; $i<sizeof($p_file_list); $i++) {
383
-          // ----- Look if it is a directory
384
-          if (substr($p_file_list[$i], -1) == '/') {
385
-            // ----- Look if the directory is in the filename path
386
-            if ((strlen($v_header['filename']) > strlen($p_file_list[$i]))
387
-			    && (substr($v_header['filename'], 0, strlen($p_file_list[$i]))
388
-				    == $p_file_list[$i])) {
389
-              $v_extract_file = true;
390
-              break;
391
-            }
392
-          }
393
-
394
-          // ----- It is a file, so compare the file names
395
-          elseif ($p_file_list[$i] == $v_header['filename']) {
396
-            $v_extract_file = true;
397
-            break;
398
-          }
399
-        }
400
-      } else {
401
-        $v_extract_file = true;
402
-      }
403
-
404
-      // ----- Look if this file need to be extracted
405
-      if (($v_extract_file) && (!$v_listing))
406
-      {
407
-        if (($p_remove_path != '')
408
-            && (substr($v_header['filename'], 0, $p_remove_path_size)
409
-			    == $p_remove_path))
410
-          $v_header['filename'] = substr($v_header['filename'],
411
-		                                 $p_remove_path_size);
412
-        if (($p_path != './') && ($p_path != '/')) {
413
-          while (substr($p_path, -1) == '/')
414
-            $p_path = substr($p_path, 0, strlen($p_path)-1);
415
-
416
-          if (substr($v_header['filename'], 0, 1) == '/')
417
-              $v_header['filename'] = $p_path.$v_header['filename'];
418
-          else
419
-            $v_header['filename'] = $p_path.'/'.$v_header['filename'];
420
-        }
421
-        if (file_exists($v_header['filename'])) {
422
-          if (   (@is_dir($v_header['filename']))
423
-		      && ($v_header['typeflag'] == '')) {
424
-            $this->_error('File '.$v_header['filename']
425
-			              .' already exists as a directory');
426
-            return false;
427
-          }
428
-          if (   ($this->_isArchive($v_header['filename']))
429
-		      && ($v_header['typeflag'] == "5")) {
430
-            $this->_error('Directory '.$v_header['filename']
431
-			              .' already exists as a file');
432
-            return false;
433
-          }
434
-          if (!is_writeable($v_header['filename'])) {
435
-            $this->_error('File '.$v_header['filename']
436
-			              .' already exists and is write protected');
437
-            return false;
438
-          }
439
-          if (filemtime($v_header['filename']) > $v_header['mtime']) {
440
-            // To be completed : An error or silent no replace ?
441
-          }
442
-        }
443
-
444
-        // ----- Check the directory availability and create it if necessary
445
-        elseif (($v_result
446
-		         = $this->_dirCheck(($v_header['typeflag'] == "5"
447
-				                    ?$v_header['filename']
280
+			return false;
281
+		}
282
+
283
+		// ----- Extract the properties
284
+		$v_header['filename'] = trim($v_data['filename']);
285
+		$v_header['mode'] = OctDec(trim($v_data['mode']));
286
+		$v_header['uid'] = OctDec(trim($v_data['uid']));
287
+		$v_header['gid'] = OctDec(trim($v_data['gid']));
288
+		$v_header['size'] = OctDec(trim($v_data['size']));
289
+		$v_header['mtime'] = OctDec(trim($v_data['mtime']));
290
+		if (($v_header['typeflag'] = $v_data['typeflag']) == "5") {
291
+		  $v_header['size'] = 0;
292
+		}
293
+		return true;
294
+	}
295
+
296
+	private function _readLongHeader(&$v_header)
297
+	{
298
+	  $v_filename = '';
299
+	  $n = floor($v_header['size']/512);
300
+	  for ($i=0; $i<$n; $i++) {
301
+		$v_content = $this->_readBlock();
302
+		$v_filename .= $v_content;
303
+	  }
304
+	  if (($v_header['size'] % 512) != 0) {
305
+		$v_content = $this->_readBlock();
306
+		$v_filename .= $v_content;
307
+	  }
308
+
309
+	  // ----- Read the next header
310
+	  $v_binary_data = $this->_readBlock();
311
+
312
+	  if (!$this->_readHeader($v_binary_data, $v_header))
313
+		return false;
314
+
315
+	  $v_header['filename'] = $v_filename;
316
+
317
+	  return true;
318
+	}
319
+
320
+	protected function _extractList($p_path, &$p_list_detail, $p_mode,
321
+						  $p_file_list, $p_remove_path)
322
+	{
323
+	$v_result=true;
324
+	$v_nb = 0;
325
+	$v_extract_all = true;
326
+	$v_listing = false;
327
+
328
+	$p_path = $this->_translateWinPath($p_path, false);
329
+	if ($p_path == '' || (substr($p_path, 0, 1) != '/'
330
+		&& substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) {
331
+	  $p_path = "./".$p_path;
332
+	}
333
+	$p_remove_path = $this->_translateWinPath($p_remove_path);
334
+
335
+	// ----- Look for path to remove format (should end by /)
336
+	if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/'))
337
+	  $p_remove_path .= '/';
338
+	$p_remove_path_size = strlen($p_remove_path);
339
+
340
+	switch ($p_mode) {
341
+	  case "complete" :
342
+		$v_extract_all = true;
343
+		$v_listing = false;
344
+	  break;
345
+	  case "partial" :
346
+		  $v_extract_all = false;
347
+		  $v_listing = false;
348
+	  break;
349
+	  case "list" :
350
+		  $v_extract_all = false;
351
+		  $v_listing = true;
352
+	  break;
353
+	  default :
354
+		$this->_error('Invalid extract mode ('.$p_mode.')');
355
+		return false;
356
+	}
357
+
358
+	clearstatcache();
359
+
360
+	while (strlen($v_binary_data = $this->_readBlock()) != 0)
361
+	{
362
+	  $v_extract_file = false;
363
+	  $v_extraction_stopped = 0;
364
+
365
+	  if (!$this->_readHeader($v_binary_data, $v_header))
366
+		return false;
367
+
368
+	  if ($v_header['filename'] == '') {
369
+		continue;
370
+	  }
371
+
372
+	  // ----- Look for long filename
373
+	  if ($v_header['typeflag'] == 'L') {
374
+		if (!$this->_readLongHeader($v_header))
375
+		  return false;
376
+	  }
377
+
378
+	  if ((!$v_extract_all) && (is_array($p_file_list))) {
379
+		// ----- By default no unzip if the file is not found
380
+		$v_extract_file = false;
381
+
382
+		for ($i=0; $i<sizeof($p_file_list); $i++) {
383
+		  // ----- Look if it is a directory
384
+		  if (substr($p_file_list[$i], -1) == '/') {
385
+			// ----- Look if the directory is in the filename path
386
+			if ((strlen($v_header['filename']) > strlen($p_file_list[$i]))
387
+				&& (substr($v_header['filename'], 0, strlen($p_file_list[$i]))
388
+					== $p_file_list[$i])) {
389
+			  $v_extract_file = true;
390
+			  break;
391
+			}
392
+		  }
393
+
394
+		  // ----- It is a file, so compare the file names
395
+		  elseif ($p_file_list[$i] == $v_header['filename']) {
396
+			$v_extract_file = true;
397
+			break;
398
+		  }
399
+		}
400
+	  } else {
401
+		$v_extract_file = true;
402
+	  }
403
+
404
+	  // ----- Look if this file need to be extracted
405
+	  if (($v_extract_file) && (!$v_listing))
406
+	  {
407
+		if (($p_remove_path != '')
408
+			&& (substr($v_header['filename'], 0, $p_remove_path_size)
409
+				== $p_remove_path))
410
+		  $v_header['filename'] = substr($v_header['filename'],
411
+										 $p_remove_path_size);
412
+		if (($p_path != './') && ($p_path != '/')) {
413
+		  while (substr($p_path, -1) == '/')
414
+			$p_path = substr($p_path, 0, strlen($p_path)-1);
415
+
416
+		  if (substr($v_header['filename'], 0, 1) == '/')
417
+			  $v_header['filename'] = $p_path.$v_header['filename'];
418
+		  else
419
+			$v_header['filename'] = $p_path.'/'.$v_header['filename'];
420
+		}
421
+		if (file_exists($v_header['filename'])) {
422
+		  if (   (@is_dir($v_header['filename']))
423
+			  && ($v_header['typeflag'] == '')) {
424
+			$this->_error('File '.$v_header['filename']
425
+						  .' already exists as a directory');
426
+			return false;
427
+		  }
428
+		  if (   ($this->_isArchive($v_header['filename']))
429
+			  && ($v_header['typeflag'] == "5")) {
430
+			$this->_error('Directory '.$v_header['filename']
431
+						  .' already exists as a file');
432
+			return false;
433
+		  }
434
+		  if (!is_writeable($v_header['filename'])) {
435
+			$this->_error('File '.$v_header['filename']
436
+						  .' already exists and is write protected');
437
+			return false;
438
+		  }
439
+		  if (filemtime($v_header['filename']) > $v_header['mtime']) {
440
+			// To be completed : An error or silent no replace ?
441
+		  }
442
+		}
443
+
444
+		// ----- Check the directory availability and create it if necessary
445
+		elseif (($v_result
446
+				 = $this->_dirCheck(($v_header['typeflag'] == "5"
447
+									?$v_header['filename']
448 448
 									:dirname($v_header['filename'])))) != 1) {
449
-            $this->_error('Unable to create path for '.$v_header['filename']);
450
-            return false;
451
-        }
452
-
453
-        if ($v_extract_file) {
454
-          if ($v_header['typeflag'] == "5") {
455
-            if (!@file_exists($v_header['filename'])) {
456
-                if (!@mkdir($v_header['filename'], PRADO_CHMOD)) {
457
-                    $this->_error('Unable to create directory {'
458
-					              .$v_header['filename'].'}');
459
-                    return false;
460
-                }
461
-                chmod($v_header['filename'], PRADO_CHMOD);
462
-            }
463
-          } else {
464
-              if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) {
465
-                  $this->_error('Error while opening {'.$v_header['filename']
466
-				                .'} in write binary mode');
467
-                  return false;
468
-              } else {
469
-                  $n = floor($v_header['size']/512);
470
-                  for ($i=0; $i<$n; $i++) {
471
-                      $v_content = $this->_readBlock();
472
-                      fwrite($v_dest_file, $v_content, 512);
473
-                  }
474
-            if (($v_header['size'] % 512) != 0) {
475
-              $v_content = $this->_readBlock();
476
-              fwrite($v_dest_file, $v_content, ($v_header['size'] % 512));
477
-            }
478
-
479
-            @fclose($v_dest_file);
480
-
481
-            // ----- Change the file mode, mtime
482
-            @touch($v_header['filename'], $v_header['mtime']);
483
-            // To be completed
484
-            //chmod($v_header[filename], DecOct($v_header[mode]));
485
-          }
486
-
487
-          // ----- Check the file size
488
-          clearstatcache();
489
-          if (filesize($v_header['filename']) != $v_header['size']) {
490
-              $this->_error('Extracted file '.$v_header['filename']
491
-			                .' does not have the correct file size \''
449
+			$this->_error('Unable to create path for '.$v_header['filename']);
450
+			return false;
451
+		}
452
+
453
+		if ($v_extract_file) {
454
+		  if ($v_header['typeflag'] == "5") {
455
+			if (!@file_exists($v_header['filename'])) {
456
+				if (!@mkdir($v_header['filename'], PRADO_CHMOD)) {
457
+					$this->_error('Unable to create directory {'
458
+								  .$v_header['filename'].'}');
459
+					return false;
460
+				}
461
+				chmod($v_header['filename'], PRADO_CHMOD);
462
+			}
463
+		  } else {
464
+			  if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) {
465
+				  $this->_error('Error while opening {'.$v_header['filename']
466
+								.'} in write binary mode');
467
+				  return false;
468
+			  } else {
469
+				  $n = floor($v_header['size']/512);
470
+				  for ($i=0; $i<$n; $i++) {
471
+					  $v_content = $this->_readBlock();
472
+					  fwrite($v_dest_file, $v_content, 512);
473
+				  }
474
+			if (($v_header['size'] % 512) != 0) {
475
+			  $v_content = $this->_readBlock();
476
+			  fwrite($v_dest_file, $v_content, ($v_header['size'] % 512));
477
+			}
478
+
479
+			@fclose($v_dest_file);
480
+
481
+			// ----- Change the file mode, mtime
482
+			@touch($v_header['filename'], $v_header['mtime']);
483
+			// To be completed
484
+			//chmod($v_header[filename], DecOct($v_header[mode]));
485
+		  }
486
+
487
+		  // ----- Check the file size
488
+		  clearstatcache();
489
+		  if (filesize($v_header['filename']) != $v_header['size']) {
490
+			  $this->_error('Extracted file '.$v_header['filename']
491
+							.' does not have the correct file size \''
492 492
 							.filesize($v_header['filename'])
493 493
 							.'\' ('.$v_header['size']
494 494
 							.' expected). Archive may be corrupted.');
495
-              return false;
496
-          }
497
-          }
498
-        } else {
499
-          $this->_jumpBlock(ceil(($v_header['size']/512)));
500
-        }
501
-      } else {
502
-          $this->_jumpBlock(ceil(($v_header['size']/512)));
503
-      }
504
-
505
-      /* TBC : Seems to be unused ...
495
+			  return false;
496
+		  }
497
+		  }
498
+		} else {
499
+		  $this->_jumpBlock(ceil(($v_header['size']/512)));
500
+		}
501
+	  } else {
502
+		  $this->_jumpBlock(ceil(($v_header['size']/512)));
503
+	  }
504
+
505
+	  /* TBC : Seems to be unused ...
506 506
       if ($this->_compress)
507 507
         $v_end_of_file = @gzeof($this->_file);
508 508
       else
509 509
         $v_end_of_file = @feof($this->_file);
510 510
         */
511 511
 
512
-      if ($v_listing || $v_extract_file || $v_extraction_stopped) {
513
-        // ----- Log extracted files
514
-        if (($v_file_dir = dirname($v_header['filename']))
515
-		    == $v_header['filename'])
516
-          $v_file_dir = '';
517
-        if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == ''))
518
-          $v_file_dir = '/';
519
-
520
-        $p_list_detail[$v_nb++] = $v_header;
521
-      }
522
-    }
523
-
524
-        return true;
525
-    }
526
-
527
-    /**
528
-     * Check if a directory exists and create it (including parent
529
-     * dirs) if not.
530
-     *
531
-     * @param string $p_dir directory to check
532
-     *
533
-     * @return bool true if the directory exists or was created
534
-     */
535
-    protected function _dirCheck($p_dir)
536
-    {
537
-        if ((@is_dir($p_dir)) || ($p_dir == ''))
538
-            return true;
539
-
540
-        $p_parent_dir = dirname($p_dir);
541
-
542
-        if (($p_parent_dir != $p_dir) &&
543
-            ($p_parent_dir != '') &&
544
-            (!$this->_dirCheck($p_parent_dir)))
545
-             return false;
546
-
547
-        if (!@mkdir($p_dir, PRADO_CHMOD)) {
548
-            $this->_error("Unable to create directory '$p_dir'");
549
-            return false;
550
-        }
551
-        chmod($p_dir,PRADO_CHMOD);
552
-
553
-        return true;
554
-    }
555
-
556
-    protected function _translateWinPath($p_path, $p_remove_disk_letter=true)
557
-    {
558
-      if (substr(PHP_OS, 0, 3) == 'WIN') {
559
-          // ----- Look for potential disk letter
560
-          if (   ($p_remove_disk_letter)
561
-		      && (($v_position = strpos($p_path, ':')) != false)) {
562
-              $p_path = substr($p_path, $v_position+1);
563
-          }
564
-          // ----- Change potential windows directory separator
565
-          if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
566
-              $p_path = strtr($p_path, '\\', '/');
567
-          }
568
-      }
569
-      return $p_path;
570
-    }
512
+	  if ($v_listing || $v_extract_file || $v_extraction_stopped) {
513
+		// ----- Log extracted files
514
+		if (($v_file_dir = dirname($v_header['filename']))
515
+			== $v_header['filename'])
516
+		  $v_file_dir = '';
517
+		if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == ''))
518
+		  $v_file_dir = '/';
519
+
520
+		$p_list_detail[$v_nb++] = $v_header;
521
+	  }
522
+	}
523
+
524
+		return true;
525
+	}
526
+
527
+	/**
528
+	 * Check if a directory exists and create it (including parent
529
+	 * dirs) if not.
530
+	 *
531
+	 * @param string $p_dir directory to check
532
+	 *
533
+	 * @return bool true if the directory exists or was created
534
+	 */
535
+	protected function _dirCheck($p_dir)
536
+	{
537
+		if ((@is_dir($p_dir)) || ($p_dir == ''))
538
+			return true;
539
+
540
+		$p_parent_dir = dirname($p_dir);
541
+
542
+		if (($p_parent_dir != $p_dir) &&
543
+			($p_parent_dir != '') &&
544
+			(!$this->_dirCheck($p_parent_dir)))
545
+			 return false;
546
+
547
+		if (!@mkdir($p_dir, PRADO_CHMOD)) {
548
+			$this->_error("Unable to create directory '$p_dir'");
549
+			return false;
550
+		}
551
+		chmod($p_dir,PRADO_CHMOD);
552
+
553
+		return true;
554
+	}
555
+
556
+	protected function _translateWinPath($p_path, $p_remove_disk_letter=true)
557
+	{
558
+	  if (substr(PHP_OS, 0, 3) == 'WIN') {
559
+		  // ----- Look for potential disk letter
560
+		  if (   ($p_remove_disk_letter)
561
+			  && (($v_position = strpos($p_path, ':')) != false)) {
562
+			  $p_path = substr($p_path, $v_position+1);
563
+		  }
564
+		  // ----- Change potential windows directory separator
565
+		  if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
566
+			  $p_path = strtr($p_path, '\\', '/');
567
+		  }
568
+	  }
569
+	  return $p_path;
570
+	}
571 571
 }
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
     /**
39 39
     * @var string Name of the Tar
40 40
     */
41
-    private $_tarname='';
41
+    private $_tarname = '';
42 42
 
43 43
     /**
44 44
     * @var file descriptor
45 45
     */
46
-    private $_file=0;
46
+    private $_file = 0;
47 47
 
48 48
     /**
49 49
     * @var string Local Tar name of a remote Tar (http:// or ftp://)
50 50
     */
51
-    private $_temp_tarname='';
51
+    private $_temp_tarname = '';
52 52
 
53 53
     /**
54 54
     * Archive_Tar Class constructor. This flavour of the constructor only
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             @unlink($this->_temp_tarname);
72 72
     }
73 73
 
74
-    public function extract($p_path='')
74
+    public function extract($p_path = '')
75 75
     {
76 76
         return $this->extractModify($p_path, '');
77 77
     }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		throw new Exception($p_message);
128 128
     }
129 129
 
130
-    private function _isArchive($p_filename=null)
130
+    private function _isArchive($p_filename = null)
131 131
     {
132 132
         if ($p_filename == null) {
133 133
             $p_filename = $this->_tarname;
@@ -142,16 +142,16 @@  discard block
 block discarded – undo
142 142
 
143 143
           // ----- Look if a local copy need to be done
144 144
           if ($this->_temp_tarname == '') {
145
-              $this->_temp_tarname = uniqid('tar').'.tmp';
145
+              $this->_temp_tarname = uniqid('tar') . '.tmp';
146 146
               if (!$v_file_from = @fopen($this->_tarname, 'rb')) {
147 147
                 $this->_error('Unable to open in read mode \''
148
-				              .$this->_tarname.'\'');
148
+				              .$this->_tarname . '\'');
149 149
                 $this->_temp_tarname = '';
150 150
                 return false;
151 151
               }
152 152
               if (!$v_file_to = @fopen($this->_temp_tarname, 'wb')) {
153 153
                 $this->_error('Unable to open in write mode \''
154
-				              .$this->_temp_tarname.'\'');
154
+				              .$this->_temp_tarname . '\'');
155 155
                 $this->_temp_tarname = '';
156 156
                 return false;
157 157
               }
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		$this->_file = @fopen($v_filename, "rb");
172 172
 
173 173
         if ($this->_file == 0) {
174
-            $this->_error('Unable to open in read mode \''.$v_filename.'\'');
174
+            $this->_error('Unable to open in read mode \'' . $v_filename . '\'');
175 175
             return false;
176 176
         }
177 177
 
@@ -224,41 +224,41 @@  discard block
 block discarded – undo
224 224
       return $v_block;
225 225
     }
226 226
 
227
-    private function _jumpBlock($p_len=null)
227
+    private function _jumpBlock($p_len = null)
228 228
     {
229 229
       if (is_resource($this->_file)) {
230 230
           if ($p_len === null)
231 231
               $p_len = 1;
232 232
 
233
-              @fseek($this->_file, @ftell($this->_file)+($p_len*512));
233
+              @fseek($this->_file, @ftell($this->_file) + ($p_len * 512));
234 234
       }
235 235
       return true;
236 236
     }
237 237
 
238 238
     private function _readHeader($v_binary_data, &$v_header)
239 239
     {
240
-        if (strlen($v_binary_data)==0) {
240
+        if (strlen($v_binary_data) == 0) {
241 241
             $v_header['filename'] = '';
242 242
             return true;
243 243
         }
244 244
 
245 245
         if (strlen($v_binary_data) != 512) {
246 246
             $v_header['filename'] = '';
247
-            $this->_error('Invalid block size : '.strlen($v_binary_data));
247
+            $this->_error('Invalid block size : ' . strlen($v_binary_data));
248 248
             return false;
249 249
         }
250 250
 
251 251
         // ----- Calculate the checksum
252 252
         $v_checksum = 0;
253 253
         // ..... First part of the header
254
-        for ($i=0; $i<148; $i++)
255
-            $v_checksum+=ord(substr($v_binary_data,$i,1));
254
+        for ($i = 0; $i < 148; $i++)
255
+            $v_checksum += ord(substr($v_binary_data, $i, 1));
256 256
         // ..... Ignore the checksum value and replace it by ' ' (space)
257
-        for ($i=148; $i<156; $i++)
257
+        for ($i = 148; $i < 156; $i++)
258 258
             $v_checksum += ord(' ');
259 259
         // ..... Last part of the header
260
-        for ($i=156; $i<512; $i++)
261
-           $v_checksum+=ord(substr($v_binary_data,$i,1));
260
+        for ($i = 156; $i < 512; $i++)
261
+           $v_checksum += ord(substr($v_binary_data, $i, 1));
262 262
 
263 263
         $v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/"
264 264
 		                 ."a8checksum/a1typeflag/a100link/a6magic/a2version/"
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
             if (($v_checksum == 256) && ($v_header['checksum'] == 0))
275 275
                 return true;
276 276
 
277
-            $this->_error('Invalid checksum for file "'.$v_data['filename']
278
-			              .'" : '.$v_checksum.' calculated, '
279
-						  .$v_header['checksum'].' expected');
277
+            $this->_error('Invalid checksum for file "' . $v_data['filename']
278
+			              .'" : ' . $v_checksum . ' calculated, '
279
+						  .$v_header['checksum'] . ' expected');
280 280
             return false;
281 281
         }
282 282
 
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
     private function _readLongHeader(&$v_header)
297 297
     {
298 298
       $v_filename = '';
299
-      $n = floor($v_header['size']/512);
300
-      for ($i=0; $i<$n; $i++) {
299
+      $n = floor($v_header['size'] / 512);
300
+      for ($i = 0; $i < $n; $i++) {
301 301
         $v_content = $this->_readBlock();
302 302
         $v_filename .= $v_content;
303 303
       }
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
     protected function _extractList($p_path, &$p_list_detail, $p_mode,
321 321
 	                      $p_file_list, $p_remove_path)
322 322
     {
323
-    $v_result=true;
323
+    $v_result = true;
324 324
     $v_nb = 0;
325 325
     $v_extract_all = true;
326 326
     $v_listing = false;
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
     $p_path = $this->_translateWinPath($p_path, false);
329 329
     if ($p_path == '' || (substr($p_path, 0, 1) != '/'
330 330
 	    && substr($p_path, 0, 3) != "../" && !strpos($p_path, ':'))) {
331
-      $p_path = "./".$p_path;
331
+      $p_path = "./" . $p_path;
332 332
     }
333 333
     $p_remove_path = $this->_translateWinPath($p_remove_path);
334 334
 
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
           $v_listing = true;
352 352
       break;
353 353
       default :
354
-        $this->_error('Invalid extract mode ('.$p_mode.')');
354
+        $this->_error('Invalid extract mode (' . $p_mode . ')');
355 355
         return false;
356 356
     }
357 357
 
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
         // ----- By default no unzip if the file is not found
380 380
         $v_extract_file = false;
381 381
 
382
-        for ($i=0; $i<sizeof($p_file_list); $i++) {
382
+        for ($i = 0; $i < sizeof($p_file_list); $i++) {
383 383
           // ----- Look if it is a directory
384 384
           if (substr($p_file_list[$i], -1) == '/') {
385 385
             // ----- Look if the directory is in the filename path
@@ -411,28 +411,28 @@  discard block
 block discarded – undo
411 411
 		                                 $p_remove_path_size);
412 412
         if (($p_path != './') && ($p_path != '/')) {
413 413
           while (substr($p_path, -1) == '/')
414
-            $p_path = substr($p_path, 0, strlen($p_path)-1);
414
+            $p_path = substr($p_path, 0, strlen($p_path) - 1);
415 415
 
416 416
           if (substr($v_header['filename'], 0, 1) == '/')
417
-              $v_header['filename'] = $p_path.$v_header['filename'];
417
+              $v_header['filename'] = $p_path . $v_header['filename'];
418 418
           else
419
-            $v_header['filename'] = $p_path.'/'.$v_header['filename'];
419
+            $v_header['filename'] = $p_path . '/' . $v_header['filename'];
420 420
         }
421 421
         if (file_exists($v_header['filename'])) {
422
-          if (   (@is_dir($v_header['filename']))
422
+          if ((@is_dir($v_header['filename']))
423 423
 		      && ($v_header['typeflag'] == '')) {
424
-            $this->_error('File '.$v_header['filename']
424
+            $this->_error('File ' . $v_header['filename']
425 425
 			              .' already exists as a directory');
426 426
             return false;
427 427
           }
428
-          if (   ($this->_isArchive($v_header['filename']))
428
+          if (($this->_isArchive($v_header['filename']))
429 429
 		      && ($v_header['typeflag'] == "5")) {
430
-            $this->_error('Directory '.$v_header['filename']
430
+            $this->_error('Directory ' . $v_header['filename']
431 431
 			              .' already exists as a file');
432 432
             return false;
433 433
           }
434 434
           if (!is_writeable($v_header['filename'])) {
435
-            $this->_error('File '.$v_header['filename']
435
+            $this->_error('File ' . $v_header['filename']
436 436
 			              .' already exists and is write protected');
437 437
             return false;
438 438
           }
@@ -444,9 +444,9 @@  discard block
 block discarded – undo
444 444
         // ----- Check the directory availability and create it if necessary
445 445
         elseif (($v_result
446 446
 		         = $this->_dirCheck(($v_header['typeflag'] == "5"
447
-				                    ?$v_header['filename']
447
+				                    ? $v_header['filename']
448 448
 									:dirname($v_header['filename'])))) != 1) {
449
-            $this->_error('Unable to create path for '.$v_header['filename']);
449
+            $this->_error('Unable to create path for ' . $v_header['filename']);
450 450
             return false;
451 451
         }
452 452
 
@@ -455,19 +455,19 @@  discard block
 block discarded – undo
455 455
             if (!@file_exists($v_header['filename'])) {
456 456
                 if (!@mkdir($v_header['filename'], PRADO_CHMOD)) {
457 457
                     $this->_error('Unable to create directory {'
458
-					              .$v_header['filename'].'}');
458
+					              .$v_header['filename'] . '}');
459 459
                     return false;
460 460
                 }
461 461
                 chmod($v_header['filename'], PRADO_CHMOD);
462 462
             }
463 463
           } else {
464 464
               if (($v_dest_file = @fopen($v_header['filename'], "wb")) == 0) {
465
-                  $this->_error('Error while opening {'.$v_header['filename']
465
+                  $this->_error('Error while opening {' . $v_header['filename']
466 466
 				                .'} in write binary mode');
467 467
                   return false;
468 468
               } else {
469
-                  $n = floor($v_header['size']/512);
470
-                  for ($i=0; $i<$n; $i++) {
469
+                  $n = floor($v_header['size'] / 512);
470
+                  for ($i = 0; $i < $n; $i++) {
471 471
                       $v_content = $this->_readBlock();
472 472
                       fwrite($v_dest_file, $v_content, 512);
473 473
                   }
@@ -487,19 +487,19 @@  discard block
 block discarded – undo
487 487
           // ----- Check the file size
488 488
           clearstatcache();
489 489
           if (filesize($v_header['filename']) != $v_header['size']) {
490
-              $this->_error('Extracted file '.$v_header['filename']
490
+              $this->_error('Extracted file ' . $v_header['filename']
491 491
 			                .' does not have the correct file size \''
492 492
 							.filesize($v_header['filename'])
493
-							.'\' ('.$v_header['size']
493
+							.'\' (' . $v_header['size']
494 494
 							.' expected). Archive may be corrupted.');
495 495
               return false;
496 496
           }
497 497
           }
498 498
         } else {
499
-          $this->_jumpBlock(ceil(($v_header['size']/512)));
499
+          $this->_jumpBlock(ceil(($v_header['size'] / 512)));
500 500
         }
501 501
       } else {
502
-          $this->_jumpBlock(ceil(($v_header['size']/512)));
502
+          $this->_jumpBlock(ceil(($v_header['size'] / 512)));
503 503
       }
504 504
 
505 505
       /* TBC : Seems to be unused ...
@@ -548,21 +548,21 @@  discard block
 block discarded – undo
548 548
             $this->_error("Unable to create directory '$p_dir'");
549 549
             return false;
550 550
         }
551
-        chmod($p_dir,PRADO_CHMOD);
551
+        chmod($p_dir, PRADO_CHMOD);
552 552
 
553 553
         return true;
554 554
     }
555 555
 
556
-    protected function _translateWinPath($p_path, $p_remove_disk_letter=true)
556
+    protected function _translateWinPath($p_path, $p_remove_disk_letter = true)
557 557
     {
558 558
       if (substr(PHP_OS, 0, 3) == 'WIN') {
559 559
           // ----- Look for potential disk letter
560
-          if (   ($p_remove_disk_letter)
560
+          if (($p_remove_disk_letter)
561 561
 		      && (($v_position = strpos($p_path, ':')) != false)) {
562
-              $p_path = substr($p_path, $v_position+1);
562
+              $p_path = substr($p_path, $v_position + 1);
563 563
           }
564 564
           // ----- Change potential windows directory separator
565
-          if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
565
+          if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) {
566 566
               $p_path = strtr($p_path, '\\', '/');
567 567
           }
568 568
       }
Please login to merge, or discard this patch.
Braces   +59 added lines, -40 removed lines patch added patch discarded remove patch
@@ -67,8 +67,9 @@  discard block
 block discarded – undo
67 67
     {
68 68
         $this->_close();
69 69
         // ----- Look for a local copy to delete
70
-        if ($this->_temp_tarname != '')
71
-            @unlink($this->_temp_tarname);
70
+        if ($this->_temp_tarname != '') {
71
+                    @unlink($this->_temp_tarname);
72
+        }
72 73
     }
73 74
 
74 75
     public function extract($p_path='')
@@ -155,8 +156,9 @@  discard block
 block discarded – undo
155 156
                 $this->_temp_tarname = '';
156 157
                 return false;
157 158
               }
158
-              while ($v_data = @fread($v_file_from, 1024))
159
-                  @fwrite($v_file_to, $v_data);
159
+              while ($v_data = @fread($v_file_from, 1024)) {
160
+                                @fwrite($v_file_to, $v_data);
161
+              }
160 162
               @fclose($v_file_from);
161 163
               @fclose($v_file_to);
162 164
           }
@@ -164,9 +166,10 @@  discard block
 block discarded – undo
164 166
           // ----- File to open if the local copy
165 167
           $v_filename = $this->_temp_tarname;
166 168
 
167
-        } else
168
-          // ----- File to open if the normal Tar file
169
+        } else {
170
+                  // ----- File to open if the normal Tar file
169 171
           $v_filename = $this->_tarname;
172
+        }
170 173
 
171 174
 		$this->_file = @fopen($v_filename, "rb");
172 175
 
@@ -227,8 +230,9 @@  discard block
 block discarded – undo
227 230
     private function _jumpBlock($p_len=null)
228 231
     {
229 232
       if (is_resource($this->_file)) {
230
-          if ($p_len === null)
231
-              $p_len = 1;
233
+          if ($p_len === null) {
234
+                        $p_len = 1;
235
+          }
232 236
 
233 237
               @fseek($this->_file, @ftell($this->_file)+($p_len*512));
234 238
       }
@@ -251,14 +255,17 @@  discard block
 block discarded – undo
251 255
         // ----- Calculate the checksum
252 256
         $v_checksum = 0;
253 257
         // ..... First part of the header
254
-        for ($i=0; $i<148; $i++)
255
-            $v_checksum+=ord(substr($v_binary_data,$i,1));
258
+        for ($i=0; $i<148; $i++) {
259
+                    $v_checksum+=ord(substr($v_binary_data,$i,1));
260
+        }
256 261
         // ..... Ignore the checksum value and replace it by ' ' (space)
257
-        for ($i=148; $i<156; $i++)
258
-            $v_checksum += ord(' ');
262
+        for ($i=148; $i<156; $i++) {
263
+                    $v_checksum += ord(' ');
264
+        }
259 265
         // ..... Last part of the header
260
-        for ($i=156; $i<512; $i++)
261
-           $v_checksum+=ord(substr($v_binary_data,$i,1));
266
+        for ($i=156; $i<512; $i++) {
267
+                   $v_checksum+=ord(substr($v_binary_data,$i,1));
268
+        }
262 269
 
263 270
         $v_data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/"
264 271
 		                 ."a8checksum/a1typeflag/a100link/a6magic/a2version/"
@@ -271,8 +278,9 @@  discard block
 block discarded – undo
271 278
             $v_header['filename'] = '';
272 279
 
273 280
             // ----- Look for last block (empty block)
274
-            if (($v_checksum == 256) && ($v_header['checksum'] == 0))
275
-                return true;
281
+            if (($v_checksum == 256) && ($v_header['checksum'] == 0)) {
282
+                            return true;
283
+            }
276 284
 
277 285
             $this->_error('Invalid checksum for file "'.$v_data['filename']
278 286
 			              .'" : '.$v_checksum.' calculated, '
@@ -309,8 +317,9 @@  discard block
 block discarded – undo
309 317
       // ----- Read the next header
310 318
       $v_binary_data = $this->_readBlock();
311 319
 
312
-      if (!$this->_readHeader($v_binary_data, $v_header))
313
-        return false;
320
+      if (!$this->_readHeader($v_binary_data, $v_header)) {
321
+              return false;
322
+      }
314 323
 
315 324
       $v_header['filename'] = $v_filename;
316 325
 
@@ -333,8 +342,9 @@  discard block
 block discarded – undo
333 342
     $p_remove_path = $this->_translateWinPath($p_remove_path);
334 343
 
335 344
     // ----- Look for path to remove format (should end by /)
336
-    if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/'))
337
-      $p_remove_path .= '/';
345
+    if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) {
346
+          $p_remove_path .= '/';
347
+    }
338 348
     $p_remove_path_size = strlen($p_remove_path);
339 349
 
340 350
     switch ($p_mode) {
@@ -362,8 +372,9 @@  discard block
 block discarded – undo
362 372
       $v_extract_file = false;
363 373
       $v_extraction_stopped = 0;
364 374
 
365
-      if (!$this->_readHeader($v_binary_data, $v_header))
366
-        return false;
375
+      if (!$this->_readHeader($v_binary_data, $v_header)) {
376
+              return false;
377
+      }
367 378
 
368 379
       if ($v_header['filename'] == '') {
369 380
         continue;
@@ -371,8 +382,9 @@  discard block
 block discarded – undo
371 382
 
372 383
       // ----- Look for long filename
373 384
       if ($v_header['typeflag'] == 'L') {
374
-        if (!$this->_readLongHeader($v_header))
375
-          return false;
385
+        if (!$this->_readLongHeader($v_header)) {
386
+                  return false;
387
+        }
376 388
       }
377 389
 
378 390
       if ((!$v_extract_all) && (is_array($p_file_list))) {
@@ -406,17 +418,20 @@  discard block
 block discarded – undo
406 418
       {
407 419
         if (($p_remove_path != '')
408 420
             && (substr($v_header['filename'], 0, $p_remove_path_size)
409
-			    == $p_remove_path))
410
-          $v_header['filename'] = substr($v_header['filename'],
421
+			    == $p_remove_path)) {
422
+                  $v_header['filename'] = substr($v_header['filename'],
411 423
 		                                 $p_remove_path_size);
424
+        }
412 425
         if (($p_path != './') && ($p_path != '/')) {
413
-          while (substr($p_path, -1) == '/')
414
-            $p_path = substr($p_path, 0, strlen($p_path)-1);
426
+          while (substr($p_path, -1) == '/') {
427
+                      $p_path = substr($p_path, 0, strlen($p_path)-1);
428
+          }
415 429
 
416
-          if (substr($v_header['filename'], 0, 1) == '/')
417
-              $v_header['filename'] = $p_path.$v_header['filename'];
418
-          else
419
-            $v_header['filename'] = $p_path.'/'.$v_header['filename'];
430
+          if (substr($v_header['filename'], 0, 1) == '/') {
431
+                        $v_header['filename'] = $p_path.$v_header['filename'];
432
+          } else {
433
+                      $v_header['filename'] = $p_path.'/'.$v_header['filename'];
434
+          }
420 435
         }
421 436
         if (file_exists($v_header['filename'])) {
422 437
           if (   (@is_dir($v_header['filename']))
@@ -512,10 +527,12 @@  discard block
 block discarded – undo
512 527
       if ($v_listing || $v_extract_file || $v_extraction_stopped) {
513 528
         // ----- Log extracted files
514 529
         if (($v_file_dir = dirname($v_header['filename']))
515
-		    == $v_header['filename'])
516
-          $v_file_dir = '';
517
-        if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == ''))
518
-          $v_file_dir = '/';
530
+		    == $v_header['filename']) {
531
+                  $v_file_dir = '';
532
+        }
533
+        if ((substr($v_header['filename'], 0, 1) == '/') && ($v_file_dir == '')) {
534
+                  $v_file_dir = '/';
535
+        }
519 536
 
520 537
         $p_list_detail[$v_nb++] = $v_header;
521 538
       }
@@ -534,15 +551,17 @@  discard block
 block discarded – undo
534 551
      */
535 552
     protected function _dirCheck($p_dir)
536 553
     {
537
-        if ((@is_dir($p_dir)) || ($p_dir == ''))
538
-            return true;
554
+        if ((@is_dir($p_dir)) || ($p_dir == '')) {
555
+                    return true;
556
+        }
539 557
 
540 558
         $p_parent_dir = dirname($p_dir);
541 559
 
542 560
         if (($p_parent_dir != $p_dir) &&
543 561
             ($p_parent_dir != '') &&
544
-            (!$this->_dirCheck($p_parent_dir)))
545
-             return false;
562
+            (!$this->_dirCheck($p_parent_dir))) {
563
+                     return false;
564
+        }
546 565
 
547 566
         if (!@mkdir($p_dir, PRADO_CHMOD)) {
548 567
             $this->_error("Unable to create directory '$p_dir'");
Please login to merge, or discard this patch.
framework/IO/TTextWriter.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -38,6 +38,7 @@
 block discarded – undo
38 38
 	/**
39 39
 	 * Writes a string.
40 40
 	 * @param string string to be written
41
+	 * @param string $str
41 42
 	 */
42 43
 	public function write($str)
43 44
 	{
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class TTextWriter extends TComponent implements ITextWriter
24 24
 {
25
-	private $_str='';
25
+	private $_str = '';
26 26
 
27 27
 	/**
28 28
 	 * Flushes the content that has been written.
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	public function flush()
32 32
 	{
33
-		$str=$this->_str;
34
-		$this->_str='';
33
+		$str = $this->_str;
34
+		$this->_str = '';
35 35
 		return $str;
36 36
 	}
37 37
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public function write($str)
43 43
 	{
44
-		$this->_str.=$str;
44
+		$this->_str .= $str;
45 45
 	}
46 46
 
47 47
 	/**
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 	 * @param string content to be written
50 50
 	 * @see write
51 51
 	 */
52
-	public function writeLine($str='')
52
+	public function writeLine($str = '')
53 53
 	{
54
-		$this->write($str."\n");
54
+		$this->write($str . "\n");
55 55
 	}
56 56
 }
57 57
 
Please login to merge, or discard this patch.
framework/PradoBase.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -184,6 +184,7 @@
 block discarded – undo
184 184
 	 * will cause the throw of an exception.
185 185
 	 * This method should only be used by framework developers.
186 186
 	 * @param TApplication the application instance
187
+	 * @param TApplication $application
187 188
 	 * @throws TInvalidOperationException if this method is invoked twice or more.
188 189
 	 */
189 190
 	public static function setApplication($application)
Please login to merge, or discard this patch.
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * PradoBase class file.
4
- *
5
- * This is the file that establishes the PRADO component model
6
- * and error handling mechanism.
7
- *
8
- * @author Qiang Xue <[email protected]>
9
- * @link https://github.com/pradosoft/prado
10
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
11
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
12
- * @package System
13
- */
3
+	 * PradoBase class file.
4
+	 *
5
+	 * This is the file that establishes the PRADO component model
6
+	 * and error handling mechanism.
7
+	 *
8
+	 * @author Qiang Xue <[email protected]>
9
+	 * @link https://github.com/pradosoft/prado
10
+	 * @copyright Copyright &copy; 2005-2015 The PRADO Group
11
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
12
+	 * @package System
13
+	 */
14 14
 
15 15
 /**
16 16
  * Defines the PRADO framework installation path.
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 if(!defined('PRADO_DIR'))
19 19
 	define('PRADO_DIR',dirname(__FILE__));
20 20
 /**
21
- * Defines the default permission for writable directories and files
22
- */
21
+	 * Defines the default permission for writable directories and files
22
+	 */
23 23
 if(!defined('PRADO_CHMOD'))
24 24
 	define('PRADO_CHMOD',0777);
25 25
 
Please login to merge, or discard this patch.
Spacing   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -15,13 +15,13 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * Defines the PRADO framework installation path.
17 17
  */
18
-if(!defined('PRADO_DIR'))
19
-	define('PRADO_DIR',dirname(__FILE__));
18
+if (!defined('PRADO_DIR'))
19
+	define('PRADO_DIR', dirname(__FILE__));
20 20
 /**
21 21
  * Defines the default permission for writable directories and files
22 22
  */
23
-if(!defined('PRADO_CHMOD'))
24
-	define('PRADO_CHMOD',0777);
23
+if (!defined('PRADO_CHMOD'))
24
+	define('PRADO_CHMOD', 0777);
25 25
 
26 26
 /**
27 27
  * PradoBase class.
@@ -41,23 +41,23 @@  discard block
 block discarded – undo
41 41
 	/**
42 42
 	 * File extension for Prado class files.
43 43
 	 */
44
-	const CLASS_FILE_EXT='.php';
44
+	const CLASS_FILE_EXT = '.php';
45 45
 	/**
46 46
 	 * @var array list of path aliases
47 47
 	 */
48
-	private static $_aliases=array('System'=>PRADO_DIR);
48
+	private static $_aliases = array('System'=>PRADO_DIR);
49 49
 	/**
50 50
 	 * @var array list of namespaces currently in use
51 51
 	 */
52
-	private static $_usings=array();
52
+	private static $_usings = array();
53 53
 	/**
54 54
 	 * @var TApplication the application instance
55 55
 	 */
56
-	private static $_application=null;
56
+	private static $_application = null;
57 57
 	/**
58 58
 	 * @var TLogger logger instance
59 59
 	 */
60
-	private static $_logger=null;
60
+	private static $_logger = null;
61 61
 
62 62
 	/**
63 63
 	 * @var array list of class exists checks
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
 		/**
83 83
 		 * Sets error handler to be Prado::phpErrorHandler
84 84
 		 */
85
-		set_error_handler(array('PradoBase','phpErrorHandler'));
85
+		set_error_handler(array('PradoBase', 'phpErrorHandler'));
86 86
 		/**
87 87
 		 * Sets shutdown function to be Prado::phpFatalErrorHandler
88 88
 		 */
89
-		register_shutdown_function(array('PradoBase','phpFatalErrorHandler'));
89
+		register_shutdown_function(array('PradoBase', 'phpFatalErrorHandler'));
90 90
 		/**
91 91
 		 * Sets exception handler to be Prado::exceptionHandler
92 92
 		 */
93
-		set_exception_handler(array('PradoBase','exceptionHandler'));
93
+		set_exception_handler(array('PradoBase', 'exceptionHandler'));
94 94
 	}
95 95
 
96 96
 	/**
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public static function autoload($className)
102 102
 	{
103
-		include_once($className.self::CLASS_FILE_EXT);
104
-		if(!class_exists($className,false) && !interface_exists($className,false))
103
+		include_once($className . self::CLASS_FILE_EXT);
104
+		if (!class_exists($className, false) && !interface_exists($className, false))
105 105
 			self::fatalError("Class file for '$className' cannot be found.");
106 106
 	}
107 107
 
@@ -109,17 +109,17 @@  discard block
 block discarded – undo
109 109
 	 * @param integer the type of "powered logo". Valid values include 0 and 1.
110 110
 	 * @return string a string that can be displayed on your Web page showing powered-by-PRADO information
111 111
 	 */
112
-	public static function poweredByPrado($logoType=0)
112
+	public static function poweredByPrado($logoType = 0)
113 113
 	{
114
-		$logoName=$logoType==1?'powered2':'powered';
115
-		if(self::$_application!==null)
114
+		$logoName = $logoType == 1 ? 'powered2' : 'powered';
115
+		if (self::$_application !== null)
116 116
 		{
117
-			$am=self::$_application->getAssetManager();
118
-			$url=$am->publishFilePath(self::getPathOfNamespace('System.'.$logoName,'.gif'));
117
+			$am = self::$_application->getAssetManager();
118
+			$url = $am->publishFilePath(self::getPathOfNamespace('System.' . $logoName, '.gif'));
119 119
 		}
120 120
 		else
121
-			$url='http://pradosoft.github.io/docs/'.$logoName.'.gif';
122
-		return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="'.$url.'" style="border-width:0px;" alt="Powered by PRADO" /></a>';
121
+			$url = 'http://pradosoft.github.io/docs/' . $logoName . '.gif';
122
+		return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="' . $url . '" style="border-width:0px;" alt="Powered by PRADO" /></a>';
123 123
 	}
124 124
 
125 125
 	/**
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
 	 * @param string the filename that the error was raised in
133 133
 	 * @param integer the line number the error was raised at
134 134
 	 */
135
-	public static function phpErrorHandler($errno,$errstr,$errfile,$errline)
135
+	public static function phpErrorHandler($errno, $errstr, $errfile, $errline)
136 136
 	{
137
-		if(error_reporting() & $errno)
138
-			throw new TPhpErrorException($errno,$errstr,$errfile,$errline);
137
+		if (error_reporting() & $errno)
138
+			throw new TPhpErrorException($errno, $errstr, $errfile, $errline);
139 139
 	}
140 140
 
141 141
 	/**
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 	public static function phpFatalErrorHandler()
148 148
 	{
149 149
 		$error = error_get_last();
150
-		if($error && 
150
+		if ($error && 
151 151
 			TPhpErrorException::isFatalError($error) &&
152 152
 			error_reporting() & $error['type'])
153 153
 		{
154
-			self::exceptionHandler(new TPhpErrorException($error['type'],$error['message'],$error['file'],$error['line']));
154
+			self::exceptionHandler(new TPhpErrorException($error['type'], $error['message'], $error['file'], $error['line']));
155 155
 		}
156 156
 	}
157 157
 
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	public static function exceptionHandler($exception)
168 168
 	{
169
-		if(self::$_application!==null && ($errorHandler=self::$_application->getErrorHandler())!==null)
169
+		if (self::$_application !== null && ($errorHandler = self::$_application->getErrorHandler()) !== null)
170 170
 		{
171
-			$errorHandler->handleError(null,$exception);
171
+			$errorHandler->handleError(null, $exception);
172 172
 		}
173 173
 		else
174 174
 		{
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	public static function setApplication($application)
190 190
 	{
191
-		if(self::$_application!==null && !defined('PRADO_TEST_RUN'))
191
+		if (self::$_application !== null && !defined('PRADO_TEST_RUN'))
192 192
 			throw new TInvalidOperationException('prado_application_singleton_required');
193
-		self::$_application=$application;
193
+		self::$_application = $application;
194 194
 	}
195 195
 
196 196
 	/**
@@ -224,21 +224,21 @@  discard block
 block discarded – undo
224 224
 	 */
225 225
 	public static function createComponent($type)
226 226
 	{
227
-		if(!isset(self::$classExists[$type]))
227
+		if (!isset(self::$classExists[$type]))
228 228
 			self::$classExists[$type] = class_exists($type, false);
229 229
 
230
-		if( !isset(self::$_usings[$type]) && !self::$classExists[$type]) {
230
+		if (!isset(self::$_usings[$type]) && !self::$classExists[$type]) {
231 231
 			self::using($type);
232 232
 			self::$classExists[$type] = class_exists($type, false);
233 233
 		}
234 234
 
235
-		if( ($pos = strrpos($type, '.')) !== false)
236
-			$type = substr($type,$pos+1);
235
+		if (($pos = strrpos($type, '.')) !== false)
236
+			$type = substr($type, $pos + 1);
237 237
 
238
-		if(($n=func_num_args())>1)
238
+		if (($n = func_num_args()) > 1)
239 239
 		{
240 240
 			$args = func_get_args();
241
-			switch($n) {
241
+			switch ($n) {
242 242
 				case 2:
243 243
 					return new $type($args[1]);
244 244
 				break;
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
 					return new $type($args[1], $args[2], $args[3], $args[4]);
253 253
 				break;
254 254
 				default:
255
-					$s='$args[1]';
256
-					for($i=2;$i<$n;++$i)
257
-						$s.=",\$args[$i]";
255
+					$s = '$args[1]';
256
+					for ($i = 2; $i < $n; ++$i)
257
+						$s .= ",\$args[$i]";
258 258
 					eval("\$component=new $type($s);");
259 259
 					return $component;
260 260
 				break;
@@ -273,45 +273,45 @@  discard block
 block discarded – undo
273 273
 	 * @param boolean whether to check the existence of the class after the class file is included
274 274
 	 * @throws TInvalidDataValueException if the namespace is invalid
275 275
 	 */
276
-	public static function using($namespace,$checkClassExistence=true)
276
+	public static function using($namespace, $checkClassExistence = true)
277 277
 	{
278
-		if(isset(self::$_usings[$namespace]) || class_exists($namespace,false))
278
+		if (isset(self::$_usings[$namespace]) || class_exists($namespace, false))
279 279
 			return;
280
-		if(($pos=strrpos($namespace,'.'))===false)  // a class name
280
+		if (($pos = strrpos($namespace, '.')) === false)  // a class name
281 281
 		{
282 282
 			try
283 283
 			{
284
-				include_once($namespace.self::CLASS_FILE_EXT);
284
+				include_once($namespace . self::CLASS_FILE_EXT);
285 285
 			}
286
-			catch(Exception $e)
286
+			catch (Exception $e)
287 287
 			{
288
-				if($checkClassExistence && !class_exists($namespace,false))
289
-					throw new TInvalidOperationException('prado_component_unknown',$namespace,$e->getMessage());
288
+				if ($checkClassExistence && !class_exists($namespace, false))
289
+					throw new TInvalidOperationException('prado_component_unknown', $namespace, $e->getMessage());
290 290
 				else
291 291
 					throw $e;
292 292
 			}
293 293
 		}
294
-		else if(($path=self::getPathOfNamespace($namespace,self::CLASS_FILE_EXT))!==null)
294
+		else if (($path = self::getPathOfNamespace($namespace, self::CLASS_FILE_EXT)) !== null)
295 295
 		{
296
-			$className=substr($namespace,$pos+1);
297
-			if($className==='*')  // a directory
296
+			$className = substr($namespace, $pos + 1);
297
+			if ($className === '*')  // a directory
298 298
 			{
299
-				self::$_usings[$namespace]=$path;
300
-				set_include_path(get_include_path().PATH_SEPARATOR.$path);
299
+				self::$_usings[$namespace] = $path;
300
+				set_include_path(get_include_path() . PATH_SEPARATOR . $path);
301 301
 			}
302 302
 			else  // a file
303 303
 			{
304
-				self::$_usings[$namespace]=$path;
305
-				if(!$checkClassExistence || !class_exists($className,false))
304
+				self::$_usings[$namespace] = $path;
305
+				if (!$checkClassExistence || !class_exists($className, false))
306 306
 				{
307 307
 					try
308 308
 					{
309 309
 						include_once($path);
310 310
 					}
311
-					catch(Exception $e)
311
+					catch (Exception $e)
312 312
 					{
313
-						if($checkClassExistence && !class_exists($className,false))
314
-							throw new TInvalidOperationException('prado_component_unknown',$className,$e->getMessage());
313
+						if ($checkClassExistence && !class_exists($className, false))
314
+							throw new TInvalidOperationException('prado_component_unknown', $className, $e->getMessage());
315 315
 						else
316 316
 							throw $e;
317 317
 					}
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 			}
320 320
 		}
321 321
 		else
322
-			throw new TInvalidDataValueException('prado_using_invalid',$namespace);
322
+			throw new TInvalidDataValueException('prado_using_invalid', $namespace);
323 323
 	}
324 324
 
325 325
 	/**
@@ -334,22 +334,22 @@  discard block
 block discarded – undo
334 334
 	 * @param string extension to be appended if the namespace refers to a file
335 335
 	 * @return string file path corresponding to the namespace, null if namespace is invalid
336 336
 	 */
337
-	public static function getPathOfNamespace($namespace, $ext='')
337
+	public static function getPathOfNamespace($namespace, $ext = '')
338 338
 	{
339
-		if(self::CLASS_FILE_EXT === $ext || empty($ext))
339
+		if (self::CLASS_FILE_EXT === $ext || empty($ext))
340 340
 		{
341
-			if(isset(self::$_usings[$namespace]))
341
+			if (isset(self::$_usings[$namespace]))
342 342
 				return self::$_usings[$namespace];
343 343
 
344
-			if(isset(self::$_aliases[$namespace]))
344
+			if (isset(self::$_aliases[$namespace]))
345 345
 				return self::$_aliases[$namespace];
346 346
 		}
347 347
 
348
-		$segs = explode('.',$namespace);
348
+		$segs = explode('.', $namespace);
349 349
 		$alias = array_shift($segs);
350 350
 
351
-		if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias)))
352
-			return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR ,$segs),'/\\').(($file === '*') ? '' : DIRECTORY_SEPARATOR.$file.$ext);
351
+		if (null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias)))
352
+			return rtrim($root . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $segs), '/\\') . (($file === '*') ? '' : DIRECTORY_SEPARATOR . $file . $ext);
353 353
 
354 354
 		return null;
355 355
 	}
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 */
361 361
 	public static function getPathOfAlias($alias)
362 362
 	{
363
-		return isset(self::$_aliases[$alias])?self::$_aliases[$alias]:null;
363
+		return isset(self::$_aliases[$alias]) ? self::$_aliases[$alias] : null;
364 364
 	}
365 365
 
366 366
 	protected static function getPathAliases()
@@ -374,19 +374,19 @@  discard block
 block discarded – undo
374 374
 	 * @throws TInvalidOperationException if the alias is already defined
375 375
 	 * @throws TInvalidDataValueException if the path is not a valid file path
376 376
 	 */
377
-	public static function setPathOfAlias($alias,$path)
377
+	public static function setPathOfAlias($alias, $path)
378 378
 	{
379
-		if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN'))
380
-			throw new TInvalidOperationException('prado_alias_redefined',$alias);
381
-		else if(($rp=realpath($path))!==false && is_dir($rp))
379
+		if (isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN'))
380
+			throw new TInvalidOperationException('prado_alias_redefined', $alias);
381
+		else if (($rp = realpath($path)) !== false && is_dir($rp))
382 382
 		{
383
-			if(strpos($alias,'.')===false)
384
-				self::$_aliases[$alias]=$rp;
383
+			if (strpos($alias, '.') === false)
384
+				self::$_aliases[$alias] = $rp;
385 385
 			else
386
-				throw new TInvalidDataValueException('prado_aliasname_invalid',$alias);
386
+				throw new TInvalidDataValueException('prado_aliasname_invalid', $alias);
387 387
 		}
388 388
 		else
389
-			throw new TInvalidDataValueException('prado_alias_invalid',$alias,$path);
389
+			throw new TInvalidDataValueException('prado_alias_invalid', $alias, $path);
390 390
 	}
391 391
 
392 392
 	/**
@@ -398,36 +398,36 @@  discard block
 block discarded – undo
398 398
 	public static function fatalError($msg)
399 399
 	{
400 400
 		echo '<h1>Fatal Error</h1>';
401
-		echo '<p>'.$msg.'</p>';
402
-		if(!function_exists('debug_backtrace'))
401
+		echo '<p>' . $msg . '</p>';
402
+		if (!function_exists('debug_backtrace'))
403 403
 			return;
404 404
 		echo '<h2>Debug Backtrace</h2>';
405 405
 		echo '<pre>';
406
-		$index=-1;
407
-		foreach(debug_backtrace() as $t)
406
+		$index = -1;
407
+		foreach (debug_backtrace() as $t)
408 408
 		{
409 409
 			$index++;
410
-			if($index==0)  // hide the backtrace of this function
410
+			if ($index == 0)  // hide the backtrace of this function
411 411
 				continue;
412
-			echo '#'.$index.' ';
413
-			if(isset($t['file']))
412
+			echo '#' . $index . ' ';
413
+			if (isset($t['file']))
414 414
 				echo basename($t['file']) . ':' . $t['line'];
415 415
 			else
416 416
 				 echo '<PHP inner-code>';
417 417
 			echo ' -- ';
418
-			if(isset($t['class']))
418
+			if (isset($t['class']))
419 419
 				echo $t['class'] . $t['type'];
420 420
 			echo $t['function'] . '(';
421
-			if(isset($t['args']) && sizeof($t['args']) > 0)
421
+			if (isset($t['args']) && sizeof($t['args']) > 0)
422 422
 			{
423
-				$count=0;
424
-				foreach($t['args'] as $item)
423
+				$count = 0;
424
+				foreach ($t['args'] as $item)
425 425
 				{
426
-					if(is_string($item))
426
+					if (is_string($item))
427 427
 					{
428
-						$str=htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES);
428
+						$str = htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES);
429 429
 						if (strlen($item) > 70)
430
-							echo "'". substr($str, 0, 70) . "...'";
430
+							echo "'" . substr($str, 0, 70) . "...'";
431 431
 						else
432 432
 							echo "'" . $str . "'";
433 433
 					}
@@ -463,23 +463,23 @@  discard block
 block discarded – undo
463 463
 	 */
464 464
 	public static function getUserLanguages()
465 465
 	{
466
-		static $languages=null;
467
-		if($languages===null)
466
+		static $languages = null;
467
+		if ($languages === null)
468 468
 		{
469
-			if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
470
-				$languages[0]='en';
469
+			if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
470
+				$languages[0] = 'en';
471 471
 			else
472 472
 			{
473
-				$languages=array();
474
-				foreach(explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language)
473
+				$languages = array();
474
+				foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language)
475 475
 				{
476
-					$array=explode(';q=',trim($language));
477
-					$languages[trim($array[0])]=isset($array[1])?(float)$array[1]:1.0;
476
+					$array = explode(';q=', trim($language));
477
+					$languages[trim($array[0])] = isset($array[1]) ? (float) $array[1] : 1.0;
478 478
 				}
479 479
 				arsort($languages);
480
-				$languages=array_keys($languages);
481
-				if(empty($languages))
482
-					$languages[0]='en';
480
+				$languages = array_keys($languages);
481
+				if (empty($languages))
482
+					$languages[0] = 'en';
483 483
 			}
484 484
 		}
485 485
 		return $languages;
@@ -491,15 +491,15 @@  discard block
 block discarded – undo
491 491
 	 */
492 492
 	public static function getPreferredLanguage()
493 493
 	{
494
-		static $language=null;
495
-		if($language===null)
494
+		static $language = null;
495
+		if ($language === null)
496 496
 		{
497
-			$langs=Prado::getUserLanguages();
498
-			$lang=explode('-',$langs[0]);
499
-			if(empty($lang[0]) || !ctype_alpha($lang[0]))
500
-				$language='en';
497
+			$langs = Prado::getUserLanguages();
498
+			$lang = explode('-', $langs[0]);
499
+			if (empty($lang[0]) || !ctype_alpha($lang[0]))
500
+				$language = 'en';
501 501
 			else
502
-				$language=$lang[0];
502
+				$language = $lang[0];
503 503
 		}
504 504
 		return $language;
505 505
 	}
@@ -516,20 +516,20 @@  discard block
 block discarded – undo
516 516
 	 * @param (string|TControl) control of the message
517 517
 	 * @see log, getLogger
518 518
 	 */
519
-	public static function trace($msg,$category='Uncategorized',$ctl=null)
519
+	public static function trace($msg, $category = 'Uncategorized', $ctl = null)
520 520
 	{
521
-		if(self::$_application && self::$_application->getMode()===TApplicationMode::Performance)
521
+		if (self::$_application && self::$_application->getMode() === TApplicationMode::Performance)
522 522
 			return;
523
-		if(!self::$_application || self::$_application->getMode()===TApplicationMode::Debug)
523
+		if (!self::$_application || self::$_application->getMode() === TApplicationMode::Debug)
524 524
 		{
525
-			$trace=debug_backtrace();
526
-			if(isset($trace[0]['file']) && isset($trace[0]['line']))
527
-				$msg.=" (line {$trace[0]['line']}, {$trace[0]['file']})";
528
-			$level=TLogger::DEBUG;
525
+			$trace = debug_backtrace();
526
+			if (isset($trace[0]['file']) && isset($trace[0]['line']))
527
+				$msg .= " (line {$trace[0]['line']}, {$trace[0]['file']})";
528
+			$level = TLogger::DEBUG;
529 529
 		}
530 530
 		else
531
-			$level=TLogger::INFO;
532
-		self::log($msg,$level,$category,$ctl);
531
+			$level = TLogger::INFO;
532
+		self::log($msg, $level, $category, $ctl);
533 533
 	}
534 534
 
535 535
 	/**
@@ -544,11 +544,11 @@  discard block
 block discarded – undo
544 544
 	 * @param string category of the message
545 545
 	 * @param (string|TControl) control of the message
546 546
 	 */
547
-	public static function log($msg,$level=TLogger::INFO,$category='Uncategorized',$ctl=null)
547
+	public static function log($msg, $level = TLogger::INFO, $category = 'Uncategorized', $ctl = null)
548 548
 	{
549
-		if(self::$_logger===null)
550
-			self::$_logger=new TLogger;
551
-		self::$_logger->log($msg,$level,$category,$ctl);
549
+		if (self::$_logger === null)
550
+			self::$_logger = new TLogger;
551
+		self::$_logger->log($msg, $level, $category, $ctl);
552 552
 	}
553 553
 
554 554
 	/**
@@ -556,8 +556,8 @@  discard block
 block discarded – undo
556 556
 	 */
557 557
 	public static function getLogger()
558 558
 	{
559
-		if(self::$_logger===null)
560
-			self::$_logger=new TLogger;
559
+		if (self::$_logger === null)
560
+			self::$_logger = new TLogger;
561 561
 		return self::$_logger;
562 562
 	}
563 563
 
@@ -570,10 +570,10 @@  discard block
 block discarded – undo
570 570
 	 * @param boolean whether to syntax highlight the output. Defaults to false.
571 571
 	 * @return string the string representation of the variable
572 572
 	 */
573
-	public static function varDump($var,$depth=10,$highlight=false)
573
+	public static function varDump($var, $depth = 10, $highlight = false)
574 574
 	{
575 575
 		Prado::using('System.Util.TVarDumper');
576
-		return TVarDumper::dump($var,$depth,$highlight);
576
+		return TVarDumper::dump($var, $depth, $highlight);
577 577
 	}
578 578
 
579 579
 	/**
@@ -586,35 +586,35 @@  discard block
 block discarded – undo
586 586
 	 * @see TTranslate::formatter()
587 587
 	 * @see TTranslate::init()
588 588
 	 */
589
-	public static function localize($text, $parameters=array(), $catalogue=null, $charset=null)
589
+	public static function localize($text, $parameters = array(), $catalogue = null, $charset = null)
590 590
 	{
591 591
 		Prado::using('System.I18N.Translation');
592 592
 		$app = Prado::getApplication()->getGlobalization(false);
593 593
 
594 594
 		$params = array();
595
-		foreach($parameters as $key => $value)
596
-			$params['{'.$key.'}'] = $value;
595
+		foreach ($parameters as $key => $value)
596
+			$params['{' . $key . '}'] = $value;
597 597
 
598 598
 		//no translation handler provided
599
-		if($app===null || ($config = $app->getTranslationConfiguration())===null)
599
+		if ($app === null || ($config = $app->getTranslationConfiguration()) === null)
600 600
 			return strtr($text, $params);
601 601
 
602
-		if ($catalogue===null)
603
-			$catalogue=isset($config['catalogue'])?$config['catalogue']:'messages';
602
+		if ($catalogue === null)
603
+			$catalogue = isset($config['catalogue']) ? $config['catalogue'] : 'messages';
604 604
 
605 605
 		Translation::init($catalogue);
606 606
 
607 607
 		//globalization charset
608
-		$appCharset = $app===null ? '' : $app->getCharset();
608
+		$appCharset = $app === null ? '' : $app->getCharset();
609 609
 
610 610
 		//default charset
611
-		$defaultCharset = ($app===null) ? 'UTF-8' : $app->getDefaultCharset();
611
+		$defaultCharset = ($app === null) ? 'UTF-8' : $app->getDefaultCharset();
612 612
 
613 613
 		//fall back
614
-		if(empty($charset)) $charset = $appCharset;
615
-		if(empty($charset)) $charset = $defaultCharset;
614
+		if (empty($charset)) $charset = $appCharset;
615
+		if (empty($charset)) $charset = $defaultCharset;
616 616
 
617
-		return Translation::formatter($catalogue)->format($text,$params,$catalogue,$charset);
617
+		return Translation::formatter($catalogue)->format($text, $params, $catalogue, $charset);
618 618
 	}
619 619
 }
620 620
 
Please login to merge, or discard this patch.
Braces   +145 added lines, -111 removed lines patch added patch discarded remove patch
@@ -15,13 +15,15 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * Defines the PRADO framework installation path.
17 17
  */
18
-if(!defined('PRADO_DIR'))
18
+if(!defined('PRADO_DIR')) {
19 19
 	define('PRADO_DIR',dirname(__FILE__));
20
+}
20 21
 /**
21 22
  * Defines the default permission for writable directories and files
22 23
  */
23
-if(!defined('PRADO_CHMOD'))
24
+if(!defined('PRADO_CHMOD')) {
24 25
 	define('PRADO_CHMOD',0777);
26
+}
25 27
 
26 28
 /**
27 29
  * PradoBase class.
@@ -101,8 +103,9 @@  discard block
 block discarded – undo
101 103
 	public static function autoload($className)
102 104
 	{
103 105
 		include_once($className.self::CLASS_FILE_EXT);
104
-		if(!class_exists($className,false) && !interface_exists($className,false))
105
-			self::fatalError("Class file for '$className' cannot be found.");
106
+		if(!class_exists($className,false) && !interface_exists($className,false)) {
107
+					self::fatalError("Class file for '$className' cannot be found.");
108
+		}
106 109
 	}
107 110
 
108 111
 	/**
@@ -116,9 +119,9 @@  discard block
 block discarded – undo
116 119
 		{
117 120
 			$am=self::$_application->getAssetManager();
118 121
 			$url=$am->publishFilePath(self::getPathOfNamespace('System.'.$logoName,'.gif'));
122
+		} else {
123
+					$url='http://pradosoft.github.io/docs/'.$logoName.'.gif';
119 124
 		}
120
-		else
121
-			$url='http://pradosoft.github.io/docs/'.$logoName.'.gif';
122 125
 		return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="'.$url.'" style="border-width:0px;" alt="Powered by PRADO" /></a>';
123 126
 	}
124 127
 
@@ -134,8 +137,9 @@  discard block
 block discarded – undo
134 137
 	 */
135 138
 	public static function phpErrorHandler($errno,$errstr,$errfile,$errline)
136 139
 	{
137
-		if(error_reporting() & $errno)
138
-			throw new TPhpErrorException($errno,$errstr,$errfile,$errline);
140
+		if(error_reporting() & $errno) {
141
+					throw new TPhpErrorException($errno,$errstr,$errfile,$errline);
142
+		}
139 143
 	}
140 144
 
141 145
 	/**
@@ -169,8 +173,7 @@  discard block
 block discarded – undo
169 173
 		if(self::$_application!==null && ($errorHandler=self::$_application->getErrorHandler())!==null)
170 174
 		{
171 175
 			$errorHandler->handleError(null,$exception);
172
-		}
173
-		else
176
+		} else
174 177
 		{
175 178
 			echo $exception;
176 179
 		}
@@ -188,8 +191,9 @@  discard block
 block discarded – undo
188 191
 	 */
189 192
 	public static function setApplication($application)
190 193
 	{
191
-		if(self::$_application!==null && !defined('PRADO_TEST_RUN'))
192
-			throw new TInvalidOperationException('prado_application_singleton_required');
194
+		if(self::$_application!==null && !defined('PRADO_TEST_RUN')) {
195
+					throw new TInvalidOperationException('prado_application_singleton_required');
196
+		}
193 197
 		self::$_application=$application;
194 198
 	}
195 199
 
@@ -224,16 +228,18 @@  discard block
 block discarded – undo
224 228
 	 */
225 229
 	public static function createComponent($type)
226 230
 	{
227
-		if(!isset(self::$classExists[$type]))
228
-			self::$classExists[$type] = class_exists($type, false);
231
+		if(!isset(self::$classExists[$type])) {
232
+					self::$classExists[$type] = class_exists($type, false);
233
+		}
229 234
 
230 235
 		if( !isset(self::$_usings[$type]) && !self::$classExists[$type]) {
231 236
 			self::using($type);
232 237
 			self::$classExists[$type] = class_exists($type, false);
233 238
 		}
234 239
 
235
-		if( ($pos = strrpos($type, '.')) !== false)
236
-			$type = substr($type,$pos+1);
240
+		if( ($pos = strrpos($type, '.')) !== false) {
241
+					$type = substr($type,$pos+1);
242
+		}
237 243
 
238 244
 		if(($n=func_num_args())>1)
239 245
 		{
@@ -253,15 +259,16 @@  discard block
 block discarded – undo
253 259
 				break;
254 260
 				default:
255 261
 					$s='$args[1]';
256
-					for($i=2;$i<$n;++$i)
257
-						$s.=",\$args[$i]";
262
+					for($i=2;$i<$n;++$i) {
263
+											$s.=",\$args[$i]";
264
+					}
258 265
 					eval("\$component=new $type($s);");
259 266
 					return $component;
260 267
 				break;
261 268
 			}
269
+		} else {
270
+					return new $type;
262 271
 		}
263
-		else
264
-			return new $type;
265 272
 	}
266 273
 
267 274
 	/**
@@ -275,31 +282,34 @@  discard block
 block discarded – undo
275 282
 	 */
276 283
 	public static function using($namespace,$checkClassExistence=true)
277 284
 	{
278
-		if(isset(self::$_usings[$namespace]) || class_exists($namespace,false))
279
-			return;
280
-		if(($pos=strrpos($namespace,'.'))===false)  // a class name
285
+		if(isset(self::$_usings[$namespace]) || class_exists($namespace,false)) {
286
+					return;
287
+		}
288
+		if(($pos=strrpos($namespace,'.'))===false) {
289
+			// a class name
281 290
 		{
282 291
 			try
283 292
 			{
284 293
 				include_once($namespace.self::CLASS_FILE_EXT);
285
-			}
286
-			catch(Exception $e)
294
+		}
295
+			} catch(Exception $e)
287 296
 			{
288
-				if($checkClassExistence && !class_exists($namespace,false))
289
-					throw new TInvalidOperationException('prado_component_unknown',$namespace,$e->getMessage());
290
-				else
291
-					throw $e;
297
+				if($checkClassExistence && !class_exists($namespace,false)) {
298
+									throw new TInvalidOperationException('prado_component_unknown',$namespace,$e->getMessage());
299
+				} else {
300
+									throw $e;
301
+				}
292 302
 			}
293
-		}
294
-		else if(($path=self::getPathOfNamespace($namespace,self::CLASS_FILE_EXT))!==null)
303
+		} else if(($path=self::getPathOfNamespace($namespace,self::CLASS_FILE_EXT))!==null)
295 304
 		{
296 305
 			$className=substr($namespace,$pos+1);
297
-			if($className==='*')  // a directory
306
+			if($className==='*') {
307
+				// a directory
298 308
 			{
299 309
 				self::$_usings[$namespace]=$path;
300
-				set_include_path(get_include_path().PATH_SEPARATOR.$path);
301 310
 			}
302
-			else  // a file
311
+				set_include_path(get_include_path().PATH_SEPARATOR.$path);
312
+			} else  // a file
303 313
 			{
304 314
 				self::$_usings[$namespace]=$path;
305 315
 				if(!$checkClassExistence || !class_exists($className,false))
@@ -307,19 +317,19 @@  discard block
 block discarded – undo
307 317
 					try
308 318
 					{
309 319
 						include_once($path);
310
-					}
311
-					catch(Exception $e)
320
+					} catch(Exception $e)
312 321
 					{
313
-						if($checkClassExistence && !class_exists($className,false))
314
-							throw new TInvalidOperationException('prado_component_unknown',$className,$e->getMessage());
315
-						else
316
-							throw $e;
322
+						if($checkClassExistence && !class_exists($className,false)) {
323
+													throw new TInvalidOperationException('prado_component_unknown',$className,$e->getMessage());
324
+						} else {
325
+													throw $e;
326
+						}
317 327
 					}
318 328
 				}
319 329
 			}
330
+		} else {
331
+					throw new TInvalidDataValueException('prado_using_invalid',$namespace);
320 332
 		}
321
-		else
322
-			throw new TInvalidDataValueException('prado_using_invalid',$namespace);
323 333
 	}
324 334
 
325 335
 	/**
@@ -338,18 +348,21 @@  discard block
 block discarded – undo
338 348
 	{
339 349
 		if(self::CLASS_FILE_EXT === $ext || empty($ext))
340 350
 		{
341
-			if(isset(self::$_usings[$namespace]))
342
-				return self::$_usings[$namespace];
351
+			if(isset(self::$_usings[$namespace])) {
352
+							return self::$_usings[$namespace];
353
+			}
343 354
 
344
-			if(isset(self::$_aliases[$namespace]))
345
-				return self::$_aliases[$namespace];
355
+			if(isset(self::$_aliases[$namespace])) {
356
+							return self::$_aliases[$namespace];
357
+			}
346 358
 		}
347 359
 
348 360
 		$segs = explode('.',$namespace);
349 361
 		$alias = array_shift($segs);
350 362
 
351
-		if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias)))
352
-			return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR ,$segs),'/\\').(($file === '*') ? '' : DIRECTORY_SEPARATOR.$file.$ext);
363
+		if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias))) {
364
+					return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR ,$segs),'/\\').(($file === '*') ? '' : DIRECTORY_SEPARATOR.$file.$ext);
365
+		}
353 366
 
354 367
 		return null;
355 368
 	}
@@ -376,17 +389,18 @@  discard block
 block discarded – undo
376 389
 	 */
377 390
 	public static function setPathOfAlias($alias,$path)
378 391
 	{
379
-		if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN'))
380
-			throw new TInvalidOperationException('prado_alias_redefined',$alias);
381
-		else if(($rp=realpath($path))!==false && is_dir($rp))
392
+		if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN')) {
393
+					throw new TInvalidOperationException('prado_alias_redefined',$alias);
394
+		} else if(($rp=realpath($path))!==false && is_dir($rp))
382 395
 		{
383
-			if(strpos($alias,'.')===false)
384
-				self::$_aliases[$alias]=$rp;
385
-			else
386
-				throw new TInvalidDataValueException('prado_aliasname_invalid',$alias);
396
+			if(strpos($alias,'.')===false) {
397
+							self::$_aliases[$alias]=$rp;
398
+			} else {
399
+							throw new TInvalidDataValueException('prado_aliasname_invalid',$alias);
400
+			}
401
+		} else {
402
+					throw new TInvalidDataValueException('prado_alias_invalid',$alias,$path);
387 403
 		}
388
-		else
389
-			throw new TInvalidDataValueException('prado_alias_invalid',$alias,$path);
390 404
 	}
391 405
 
392 406
 	/**
@@ -399,24 +413,29 @@  discard block
 block discarded – undo
399 413
 	{
400 414
 		echo '<h1>Fatal Error</h1>';
401 415
 		echo '<p>'.$msg.'</p>';
402
-		if(!function_exists('debug_backtrace'))
403
-			return;
416
+		if(!function_exists('debug_backtrace')) {
417
+					return;
418
+		}
404 419
 		echo '<h2>Debug Backtrace</h2>';
405 420
 		echo '<pre>';
406 421
 		$index=-1;
407 422
 		foreach(debug_backtrace() as $t)
408 423
 		{
409 424
 			$index++;
410
-			if($index==0)  // hide the backtrace of this function
425
+			if($index==0) {
426
+				// hide the backtrace of this function
411 427
 				continue;
428
+			}
412 429
 			echo '#'.$index.' ';
413
-			if(isset($t['file']))
414
-				echo basename($t['file']) . ':' . $t['line'];
415
-			else
416
-				 echo '<PHP inner-code>';
430
+			if(isset($t['file'])) {
431
+							echo basename($t['file']) . ':' . $t['line'];
432
+			} else {
433
+							 echo '<PHP inner-code>';
434
+			}
417 435
 			echo ' -- ';
418
-			if(isset($t['class']))
419
-				echo $t['class'] . $t['type'];
436
+			if(isset($t['class'])) {
437
+							echo $t['class'] . $t['type'];
438
+			}
420 439
 			echo $t['function'] . '(';
421 440
 			if(isset($t['args']) && sizeof($t['args']) > 0)
422 441
 			{
@@ -426,26 +445,28 @@  discard block
 block discarded – undo
426 445
 					if(is_string($item))
427 446
 					{
428 447
 						$str=htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES);
429
-						if (strlen($item) > 70)
430
-							echo "'". substr($str, 0, 70) . "...'";
431
-						else
432
-							echo "'" . $str . "'";
448
+						if (strlen($item) > 70) {
449
+													echo "'". substr($str, 0, 70) . "...'";
450
+						} else {
451
+													echo "'" . $str . "'";
452
+						}
453
+					} else if (is_int($item) || is_float($item)) {
454
+											echo $item;
455
+					} else if (is_object($item)) {
456
+											echo get_class($item);
457
+					} else if (is_array($item)) {
458
+											echo 'array(' . count($item) . ')';
459
+					} else if (is_bool($item)) {
460
+											echo $item ? 'true' : 'false';
461
+					} else if ($item === null) {
462
+											echo 'NULL';
463
+					} else if (is_resource($item)) {
464
+											echo get_resource_type($item);
433 465
 					}
434
-					else if (is_int($item) || is_float($item))
435
-						echo $item;
436
-					else if (is_object($item))
437
-						echo get_class($item);
438
-					else if (is_array($item))
439
-						echo 'array(' . count($item) . ')';
440
-					else if (is_bool($item))
441
-						echo $item ? 'true' : 'false';
442
-					else if ($item === null)
443
-						echo 'NULL';
444
-					else if (is_resource($item))
445
-						echo get_resource_type($item);
446 466
 					$count++;
447
-					if (count($t['args']) > $count)
448
-						echo ', ';
467
+					if (count($t['args']) > $count) {
468
+											echo ', ';
469
+					}
449 470
 				}
450 471
 			}
451 472
 			echo ")\n";
@@ -466,9 +487,9 @@  discard block
 block discarded – undo
466 487
 		static $languages=null;
467 488
 		if($languages===null)
468 489
 		{
469
-			if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
470
-				$languages[0]='en';
471
-			else
490
+			if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
491
+							$languages[0]='en';
492
+			} else
472 493
 			{
473 494
 				$languages=array();
474 495
 				foreach(explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language)
@@ -478,8 +499,9 @@  discard block
 block discarded – undo
478 499
 				}
479 500
 				arsort($languages);
480 501
 				$languages=array_keys($languages);
481
-				if(empty($languages))
482
-					$languages[0]='en';
502
+				if(empty($languages)) {
503
+									$languages[0]='en';
504
+				}
483 505
 			}
484 506
 		}
485 507
 		return $languages;
@@ -496,10 +518,11 @@  discard block
 block discarded – undo
496 518
 		{
497 519
 			$langs=Prado::getUserLanguages();
498 520
 			$lang=explode('-',$langs[0]);
499
-			if(empty($lang[0]) || !ctype_alpha($lang[0]))
500
-				$language='en';
501
-			else
502
-				$language=$lang[0];
521
+			if(empty($lang[0]) || !ctype_alpha($lang[0])) {
522
+							$language='en';
523
+			} else {
524
+							$language=$lang[0];
525
+			}
503 526
 		}
504 527
 		return $language;
505 528
 	}
@@ -518,17 +541,19 @@  discard block
 block discarded – undo
518 541
 	 */
519 542
 	public static function trace($msg,$category='Uncategorized',$ctl=null)
520 543
 	{
521
-		if(self::$_application && self::$_application->getMode()===TApplicationMode::Performance)
522
-			return;
544
+		if(self::$_application && self::$_application->getMode()===TApplicationMode::Performance) {
545
+					return;
546
+		}
523 547
 		if(!self::$_application || self::$_application->getMode()===TApplicationMode::Debug)
524 548
 		{
525 549
 			$trace=debug_backtrace();
526
-			if(isset($trace[0]['file']) && isset($trace[0]['line']))
527
-				$msg.=" (line {$trace[0]['line']}, {$trace[0]['file']})";
550
+			if(isset($trace[0]['file']) && isset($trace[0]['line'])) {
551
+							$msg.=" (line {$trace[0]['line']}, {$trace[0]['file']})";
552
+			}
528 553
 			$level=TLogger::DEBUG;
554
+		} else {
555
+					$level=TLogger::INFO;
529 556
 		}
530
-		else
531
-			$level=TLogger::INFO;
532 557
 		self::log($msg,$level,$category,$ctl);
533 558
 	}
534 559
 
@@ -546,8 +571,9 @@  discard block
 block discarded – undo
546 571
 	 */
547 572
 	public static function log($msg,$level=TLogger::INFO,$category='Uncategorized',$ctl=null)
548 573
 	{
549
-		if(self::$_logger===null)
550
-			self::$_logger=new TLogger;
574
+		if(self::$_logger===null) {
575
+					self::$_logger=new TLogger;
576
+		}
551 577
 		self::$_logger->log($msg,$level,$category,$ctl);
552 578
 	}
553 579
 
@@ -556,8 +582,9 @@  discard block
 block discarded – undo
556 582
 	 */
557 583
 	public static function getLogger()
558 584
 	{
559
-		if(self::$_logger===null)
560
-			self::$_logger=new TLogger;
585
+		if(self::$_logger===null) {
586
+					self::$_logger=new TLogger;
587
+		}
561 588
 		return self::$_logger;
562 589
 	}
563 590
 
@@ -592,15 +619,18 @@  discard block
 block discarded – undo
592 619
 		$app = Prado::getApplication()->getGlobalization(false);
593 620
 
594 621
 		$params = array();
595
-		foreach($parameters as $key => $value)
596
-			$params['{'.$key.'}'] = $value;
622
+		foreach($parameters as $key => $value) {
623
+					$params['{'.$key.'}'] = $value;
624
+		}
597 625
 
598 626
 		//no translation handler provided
599
-		if($app===null || ($config = $app->getTranslationConfiguration())===null)
600
-			return strtr($text, $params);
627
+		if($app===null || ($config = $app->getTranslationConfiguration())===null) {
628
+					return strtr($text, $params);
629
+		}
601 630
 
602
-		if ($catalogue===null)
603
-			$catalogue=isset($config['catalogue'])?$config['catalogue']:'messages';
631
+		if ($catalogue===null) {
632
+					$catalogue=isset($config['catalogue'])?$config['catalogue']:'messages';
633
+		}
604 634
 
605 635
 		Translation::init($catalogue);
606 636
 
@@ -611,8 +641,12 @@  discard block
 block discarded – undo
611 641
 		$defaultCharset = ($app===null) ? 'UTF-8' : $app->getDefaultCharset();
612 642
 
613 643
 		//fall back
614
-		if(empty($charset)) $charset = $appCharset;
615
-		if(empty($charset)) $charset = $defaultCharset;
644
+		if(empty($charset)) {
645
+			$charset = $appCharset;
646
+		}
647
+		if(empty($charset)) {
648
+			$charset = $defaultCharset;
649
+		}
616 650
 
617 651
 		return Translation::formatter($catalogue)->format($text,$params,$catalogue,$charset);
618 652
 	}
Please login to merge, or discard this patch.
framework/pradolite.php 4 patches
Doc Comments   +857 added lines patch added patch discarded remove patch
@@ -67,6 +67,10 @@  discard block
 block discarded – undo
67 67
 		}
68 68
 		exit(1);
69 69
 	}
70
+
71
+	/**
72
+	 * @param TApplication $application
73
+	 */
70 74
 	public static function setApplication($application)
71 75
 	{
72 76
 		if(self::$_application!==null && !defined('PRADO_TEST_RUN'))
@@ -360,14 +364,26 @@  discard block
 block discarded – undo
360 364
 interface IModule
361 365
 {
362 366
 	public function init($config);
367
+
368
+	/**
369
+	 * @return string
370
+	 */
363 371
 	public function getID();
364 372
 	public function setID($id);
365 373
 }
366 374
 interface IService
367 375
 {
368 376
 	public function init($config);
377
+
378
+	/**
379
+	 * @return string
380
+	 */
369 381
 	public function getID();
370 382
 	public function setID($id);
383
+
384
+	/**
385
+	 * @return boolean
386
+	 */
371 387
 	public function getEnabled();
372 388
 	public function setEnabled($value);
373 389
 	public function run();
@@ -379,14 +395,37 @@  discard block
 block discarded – undo
379 395
 }
380 396
 interface IUser
381 397
 {
398
+	/**
399
+	 * @return string
400
+	 */
382 401
 	public function getName();
383 402
 	public function setName($value);
403
+
404
+	/**
405
+	 * @return boolean
406
+	 */
384 407
 	public function getIsGuest();
408
+
409
+	/**
410
+	 * @param boolean $value
411
+	 */
385 412
 	public function setIsGuest($value);
386 413
 	public function getRoles();
387 414
 	public function setRoles($value);
415
+
416
+	/**
417
+	 * @return boolean
418
+	 */
388 419
 	public function isInRole($role);
420
+
421
+	/**
422
+	 * @return string
423
+	 */
389 424
 	public function saveToString();
425
+
426
+	/**
427
+	 * @return BlogUser
428
+	 */
390 429
 	public function loadFromString($string);
391 430
 }
392 431
 interface IStatePersister
@@ -398,6 +437,12 @@  discard block
 block discarded – undo
398 437
 {
399 438
 	public function get($id);
400 439
 	public function set($id,$value,$expire=0,$dependency=null);
440
+
441
+	/**
442
+	 * @param string $id
443
+	 *
444
+	 * @return boolean
445
+	 */
401 446
 	public function add($id,$value,$expire=0,$dependency=null);
402 447
 	public function delete($id);
403 448
 	public function flush();
@@ -416,12 +461,22 @@  discard block
 block discarded – undo
416 461
 }
417 462
 interface IStyleable
418 463
 {
464
+	/**
465
+	 * @return boolean
466
+	 */
419 467
 	public function getHasStyle();
468
+
469
+	/**
470
+	 * @return TStyle
471
+	 */
420 472
 	public function getStyle();
421 473
 	public function clearStyle();
422 474
 }
423 475
 interface IActiveControl
424 476
 {
477
+	/**
478
+	 * @return TBaseActiveControl
479
+	 */
425 480
 	public function getActiveControl();
426 481
 }
427 482
 interface ICallbackEventHandler
@@ -431,6 +486,10 @@  discard block
 block discarded – undo
431 486
 interface IDataRenderer
432 487
 {
433 488
 	public function getData();
489
+
490
+	/**
491
+	 * @param TActiveRecord $value
492
+	 */
434 493
 	public function setData($value);
435 494
 }
436 495
 class TApplicationComponent extends TComponent
@@ -459,6 +518,11 @@  discard block
 block discarded – undo
459 518
 	{
460 519
 		return Prado::getApplication()->getUser();
461 520
 	}
521
+
522
+	/**
523
+	 * @param string $assetPath
524
+	 * @param string $className
525
+	 */
462 526
 	public function publishAsset($assetPath,$className=null)
463 527
 	{
464 528
 		if($className===null)
@@ -467,6 +531,10 @@  discard block
 block discarded – undo
467 531
 		$fullPath=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$assetPath;
468 532
 		return $this->publishFilePath($fullPath);
469 533
 	}
534
+
535
+	/**
536
+	 * @param string $fullPath
537
+	 */
470 538
 	public function publishFilePath($fullPath, $checkTimestamp=false)
471 539
 	{
472 540
 		return Prado::getApplication()->getAssetManager()->publishFilePath($fullPath, $checkTimestamp);
@@ -498,6 +566,10 @@  discard block
 block discarded – undo
498 566
 	{
499 567
 		return $this->_id;
500 568
 	}
569
+
570
+	/**
571
+	 * @param string $value
572
+	 */
501 573
 	public function setID($value)
502 574
 	{
503 575
 		$this->_id=$value;
@@ -537,6 +609,10 @@  discard block
 block discarded – undo
537 609
 		else
538 610
 			throw new TConfigurationException('errorhandler_errortemplatepath_invalid',$value);
539 611
 	}
612
+
613
+	/**
614
+	 * @param null|TApplication $sender
615
+	 */
540 616
 	public function handleError($sender,$param)
541 617
 	{
542 618
 		static $handling=false;
@@ -559,6 +635,10 @@  discard block
 block discarded – undo
559 635
 				$this->handleExternalError(500,$param);
560 636
 		}
561 637
 	}
638
+
639
+	/**
640
+	 * @return string
641
+	 */
562 642
 	protected static function hideSecurityRelated($value, $exception=null)
563 643
 	{
564 644
 		$aRpl = array();
@@ -706,6 +786,10 @@  discard block
 block discarded – undo
706 786
 			return null;
707 787
 		return $result;
708 788
 	}
789
+
790
+	/**
791
+	 * @param string $pattern
792
+	 */
709 793
 	private function getPropertyAccessTrace($trace,$pattern)
710 794
 	{
711 795
 		$result=null;
@@ -735,6 +819,10 @@  discard block
 block discarded – undo
735 819
 		}
736 820
 		return $source;
737 821
 	}
822
+
823
+	/**
824
+	 * @param string $message
825
+	 */
738 826
 	private function addLink($message)
739 827
 	{
740 828
 		$baseUrl='http://pradosoft.github.io/docs/manual/class-';
@@ -756,6 +844,10 @@  discard block
 block discarded – undo
756 844
 	{
757 845
 		return $this->_r;
758 846
 	}
847
+
848
+	/**
849
+	 * @param boolean $value
850
+	 */
759 851
 	protected function setReadOnly($value)
760 852
 	{
761 853
 		$this->_r=TPropertyValue::ensureBoolean($value);
@@ -912,6 +1004,11 @@  discard block
 block discarded – undo
912 1004
 	{
913 1005
 		return $this->itemAt($offset);
914 1006
 	}
1007
+
1008
+	/**
1009
+	 * @param null|integer $offset
1010
+	 * @param integer $item
1011
+	 */
915 1012
 	public function offsetSet($offset,$item)
916 1013
 	{
917 1014
 		if($offset===null || $offset===$this->_c)
@@ -922,6 +1019,10 @@  discard block
 block discarded – undo
922 1019
 			$this->insertAt($offset,$item);
923 1020
 		}
924 1021
 	}
1022
+
1023
+	/**
1024
+	 * @param integer $offset
1025
+	 */
925 1026
 	public function offsetUnset($offset)
926 1027
 	{
927 1028
 		$this->removeAt($offset);
@@ -987,6 +1088,10 @@  discard block
 block discarded – undo
987 1088
 	{
988 1089
 		return $this->_prefix;
989 1090
 	}
1091
+
1092
+	/**
1093
+	 * @param string $value
1094
+	 */
990 1095
 	public function setKeyPrefix($value)
991 1096
 	{
992 1097
 		$this->_prefix=$value;
@@ -1016,6 +1121,11 @@  discard block
 block discarded – undo
1016 1121
 			return $this->setValue($this->generateUniqueKey($id),$data,$expire);
1017 1122
 		}
1018 1123
 	}
1124
+
1125
+	/**
1126
+	 * @param string $id
1127
+	 * @param string $value
1128
+	 */
1019 1129
 	public function add($id,$value,$expire=0,$dependency=null)
1020 1130
 	{
1021 1131
 		if(empty($value) && $expire === 0)
@@ -1031,9 +1141,27 @@  discard block
 block discarded – undo
1031 1141
 	{
1032 1142
 		throw new TNotSupportedException('cache_flush_unsupported');
1033 1143
 	}
1144
+
1145
+	/**
1146
+	 * @param string $key
1147
+	 */
1034 1148
 	abstract protected function getValue($key);
1149
+
1150
+	/**
1151
+	 * @param string $key
1152
+	 * @param integer $expire
1153
+	 */
1035 1154
 	abstract protected function setValue($key,$value,$expire);
1155
+
1156
+	/**
1157
+	 * @param string $key
1158
+	 * @param integer $expire
1159
+	 */
1036 1160
 	abstract protected function addValue($key,$value,$expire);
1161
+
1162
+	/**
1163
+	 * @param string $key
1164
+	 */
1037 1165
 	abstract protected function deleteValue($key);
1038 1166
 	public function offsetExists($id)
1039 1167
 	{
@@ -1087,6 +1215,10 @@  discard block
 block discarded – undo
1087 1215
 	private $_recursiveLevel=-1;
1088 1216
 	private $_timestamps;
1089 1217
 	private $_directory;
1218
+
1219
+	/**
1220
+	 * @param string $directory
1221
+	 */
1090 1222
 	public function __construct($directory)
1091 1223
 	{
1092 1224
 		$this->setDirectory($directory);
@@ -1106,6 +1238,10 @@  discard block
 block discarded – undo
1106 1238
 	{
1107 1239
 		return $this->_recursiveCheck;
1108 1240
 	}
1241
+
1242
+	/**
1243
+	 * @param boolean $value
1244
+	 */
1109 1245
 	public function setRecursiveCheck($value)
1110 1246
 	{
1111 1247
 		$this->_recursiveCheck=TPropertyValue::ensureBoolean($value);
@@ -1114,6 +1250,10 @@  discard block
 block discarded – undo
1114 1250
 	{
1115 1251
 		return $this->_recursiveLevel;
1116 1252
 	}
1253
+
1254
+	/**
1255
+	 * @param integer $value
1256
+	 */
1117 1257
 	public function setRecursiveLevel($value)
1118 1258
 	{
1119 1259
 		$this->_recursiveLevel=TPropertyValue::ensureInteger($value);
@@ -1122,14 +1262,26 @@  discard block
 block discarded – undo
1122 1262
 	{
1123 1263
 		return $this->generateTimestamps($this->_directory)!=$this->_timestamps;
1124 1264
 	}
1265
+
1266
+	/**
1267
+	 * @param string $fileName
1268
+	 */
1125 1269
 	protected function validateFile($fileName)
1126 1270
 	{
1127 1271
 		return true;
1128 1272
 	}
1273
+
1274
+	/**
1275
+	 * @param string $directory
1276
+	 */
1129 1277
 	protected function validateDirectory($directory)
1130 1278
 	{
1131 1279
 		return true;
1132 1280
 	}
1281
+
1282
+	/**
1283
+	 * @param string $directory
1284
+	 */
1133 1285
 	protected function generateTimestamps($directory,$level=0)
1134 1286
 	{
1135 1287
 		if(($dir=opendir($directory))===false)
@@ -1220,6 +1372,10 @@  discard block
 block discarded – undo
1220 1372
 		$this->_str='';
1221 1373
 		return $str;
1222 1374
 	}
1375
+
1376
+	/**
1377
+	 * @param string $str
1378
+	 */
1223 1379
 	public function write($str)
1224 1380
 	{
1225 1381
 		$this->_str.=$str;
@@ -1254,6 +1410,10 @@  discard block
 block discarded – undo
1254 1410
 	{
1255 1411
 		return $this->_c;
1256 1412
 	}
1413
+
1414
+	/**
1415
+	 * @param integer $priority
1416
+	 */
1257 1417
 	public function getPriorityCount($priority=null)
1258 1418
 	{
1259 1419
 		if($priority===null)
@@ -1267,6 +1427,10 @@  discard block
 block discarded – undo
1267 1427
 	{
1268 1428
 		return $this->_dp;
1269 1429
 	}
1430
+
1431
+	/**
1432
+	 * @param integer $value
1433
+	 */
1270 1434
 	protected function setDefaultPriority($value)
1271 1435
 	{
1272 1436
 		$this->_dp=(string)round(TPropertyValue::ensureFloat($value),$this->_p);
@@ -1275,6 +1439,10 @@  discard block
 block discarded – undo
1275 1439
 	{
1276 1440
 		return $this->_p;
1277 1441
 	}
1442
+
1443
+	/**
1444
+	 * @param integer $value
1445
+	 */
1278 1446
 	protected function setPrecision($value)
1279 1447
 	{
1280 1448
 		$this->_p=TPropertyValue::ensureInteger($value);
@@ -1318,6 +1486,10 @@  discard block
 block discarded – undo
1318 1486
 		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1319 1487
 		return isset($this->_d[$priority])?$this->_d[$priority]:null;
1320 1488
 	}
1489
+
1490
+	/**
1491
+	 * @param integer $index
1492
+	 */
1321 1493
 	public function itemAtIndexInPriority($index,$priority=null)
1322 1494
 	{
1323 1495
 		if($priority===null)
@@ -1333,6 +1505,10 @@  discard block
 block discarded – undo
1333 1505
 			throw new TInvalidOperationException('list_readonly',get_class($this));
1334 1506
 		return $this->insertAtIndexInPriority($item,false,$priority,true);
1335 1507
 	}
1508
+
1509
+	/**
1510
+	 * @param integer $index
1511
+	 */
1336 1512
 	public function insertAt($index,$item)
1337 1513
 	{
1338 1514
 		if($this->getReadOnly())
@@ -1446,6 +1622,10 @@  discard block
 block discarded – undo
1446 1622
 			unset($this->_d[$priority]);
1447 1623
 		}
1448 1624
 	}
1625
+
1626
+	/**
1627
+	 * @param PriorityListItem $item
1628
+	 */
1449 1629
 	public function contains($item)
1450 1630
 	{
1451 1631
 		return $this->indexOf($item)>=0;
@@ -1513,6 +1693,10 @@  discard block
 block discarded – undo
1513 1693
 		$this->sortPriorities();
1514 1694
 		return $this->_d;
1515 1695
 	}
1696
+
1697
+	/**
1698
+	 * @param integer $priority
1699
+	 */
1516 1700
 	public function toArrayBelowPriority($priority,$inclusive=false)
1517 1701
 	{
1518 1702
 		$this->sortPriorities();
@@ -1525,6 +1709,10 @@  discard block
 block discarded – undo
1525 1709
 		}
1526 1710
 		return $items;
1527 1711
 	}
1712
+
1713
+	/**
1714
+	 * @param integer $priority
1715
+	 */
1528 1716
 	public function toArrayAbovePriority($priority,$inclusive=true)
1529 1717
 	{
1530 1718
 		$this->sortPriorities();
@@ -1582,6 +1770,11 @@  discard block
 block discarded – undo
1582 1770
 	{
1583 1771
 		return $this->itemAt($offset);
1584 1772
 	}
1773
+
1774
+	/**
1775
+	 * @param null|integer $offset
1776
+	 * @param integer $item
1777
+	 */
1585 1778
 	public function offsetSet($offset,$item)
1586 1779
 	{
1587 1780
 		if($offset===null)
@@ -1595,6 +1788,10 @@  discard block
 block discarded – undo
1595 1788
 		}
1596 1789
 		$this->insertAtIndexInPriority($item,$priority[1],$priority[0]);
1597 1790
 	}
1791
+
1792
+	/**
1793
+	 * @param integer $offset
1794
+	 */
1598 1795
 	public function offsetUnset($offset)
1599 1796
 	{
1600 1797
 		$this->removeAt($offset);
@@ -1614,6 +1811,10 @@  discard block
 block discarded – undo
1614 1811
 	{
1615 1812
 		return $this->_r;
1616 1813
 	}
1814
+
1815
+	/**
1816
+	 * @param boolean $value
1817
+	 */
1617 1818
 	protected function setReadOnly($value)
1618 1819
 	{
1619 1820
 		$this->_r=TPropertyValue::ensureBoolean($value);
@@ -1765,6 +1966,10 @@  discard block
 block discarded – undo
1765 1966
 	{
1766 1967
 		return $this->_r;
1767 1968
 	}
1969
+
1970
+	/**
1971
+	 * @param boolean $value
1972
+	 */
1768 1973
 	protected function setReadOnly($value)
1769 1974
 	{
1770 1975
 		$this->_r=TPropertyValue::ensureBoolean($value);
@@ -1773,6 +1978,10 @@  discard block
 block discarded – undo
1773 1978
 	{
1774 1979
 		return $this->_dp;
1775 1980
 	}
1981
+
1982
+	/**
1983
+	 * @param integer $value
1984
+	 */
1776 1985
 	protected function setDefaultPriority($value)
1777 1986
 	{
1778 1987
 		$this->_dp = (string)round(TPropertyValue::ensureFloat($value), $this->_p);
@@ -1781,6 +1990,10 @@  discard block
 block discarded – undo
1781 1990
 	{
1782 1991
 		return $this->_p;
1783 1992
 	}
1993
+
1994
+	/**
1995
+	 * @param integer $value
1996
+	 */
1784 1997
 	protected function setPrecision($value)
1785 1998
 	{
1786 1999
 		$this->_p=TPropertyValue::ensureInteger($value);
@@ -1842,6 +2055,11 @@  discard block
 block discarded – undo
1842 2055
 			return (isset($this->_d[$priority])&&isset($this->_d[$priority][$key]))?$this->_d[$priority][$key]:null;
1843 2056
 		}
1844 2057
 	}
2058
+
2059
+	/**
2060
+	 * @param string $key
2061
+	 * @param integer $priority
2062
+	 */
1845 2063
 	public function setPriorityAt($key,$priority=null)
1846 2064
 	{
1847 2065
 		if($priority===null)
@@ -1967,6 +2185,10 @@  discard block
 block discarded – undo
1967 2185
 	{
1968 2186
 		return $this->flattenPriorities();
1969 2187
 	}
2188
+
2189
+	/**
2190
+	 * @param integer $priority
2191
+	 */
1970 2192
 	public function toArrayBelowPriority($priority,$inclusive=false)
1971 2193
 	{
1972 2194
 		$this->sortPriorities();
@@ -1979,6 +2201,10 @@  discard block
 block discarded – undo
1979 2201
 		}
1980 2202
 		return $items;
1981 2203
 	}
2204
+
2205
+	/**
2206
+	 * @param integer $priority
2207
+	 */
1982 2208
 	public function toArrayAbovePriority($priority,$inclusive=true)
1983 2209
 	{
1984 2210
 		$this->sortPriorities();
@@ -2052,6 +2278,10 @@  discard block
 block discarded – undo
2052 2278
 {
2053 2279
 	private $_d=array();
2054 2280
 	private $_c=0;
2281
+
2282
+	/**
2283
+	 * @param integer[] $data
2284
+	 */
2055 2285
 	public function __construct($data=null)
2056 2286
 	{
2057 2287
 		if($data!==null)
@@ -2166,6 +2396,10 @@  discard block
 block discarded – undo
2166 2396
 	{
2167 2397
 		return $this->_parent;
2168 2398
 	}
2399
+
2400
+	/**
2401
+	 * @param TXmlElement|null $parent
2402
+	 */
2169 2403
 	public function setParent($parent)
2170 2404
 	{
2171 2405
 		$this->_parent=$parent;
@@ -2194,6 +2428,10 @@  discard block
 block discarded – undo
2194 2428
 	{
2195 2429
 		return $this->_attributes!==null && $this->_attributes->getCount()>0;
2196 2430
 	}
2431
+
2432
+	/**
2433
+	 * @param string $name
2434
+	 */
2197 2435
 	public function getAttribute($name)
2198 2436
 	{
2199 2437
 		if($this->_attributes!==null)
@@ -2201,6 +2439,11 @@  discard block
 block discarded – undo
2201 2439
 		else
2202 2440
 			return null;
2203 2441
 	}
2442
+
2443
+	/**
2444
+	 * @param string $name
2445
+	 * @param string $value
2446
+	 */
2204 2447
 	public function setAttribute($name,$value)
2205 2448
 	{
2206 2449
 		$this->getAttributes()->add($name,TPropertyValue::ensureString($value));
@@ -2217,6 +2460,10 @@  discard block
 block discarded – undo
2217 2460
 			$this->_attributes=new TMap;
2218 2461
 		return $this->_attributes;
2219 2462
 	}
2463
+
2464
+	/**
2465
+	 * @param string $tagName
2466
+	 */
2220 2467
 	public function getElementByTagName($tagName)
2221 2468
 	{
2222 2469
 		if($this->_elements)
@@ -2227,6 +2474,10 @@  discard block
 block discarded – undo
2227 2474
 		}
2228 2475
 		return null;
2229 2476
 	}
2477
+
2478
+	/**
2479
+	 * @param string $tagName
2480
+	 */
2230 2481
 	public function getElementsByTagName($tagName)
2231 2482
 	{
2232 2483
 		$list=new TList;
@@ -2296,6 +2547,10 @@  discard block
 block discarded – undo
2296 2547
 	{
2297 2548
 		return $this->_version;
2298 2549
 	}
2550
+
2551
+	/**
2552
+	 * @param string $version
2553
+	 */
2299 2554
 	public function setVersion($version)
2300 2555
 	{
2301 2556
 		$this->_version=$version;
@@ -2304,6 +2559,10 @@  discard block
 block discarded – undo
2304 2559
 	{
2305 2560
 		return $this->_encoding;
2306 2561
 	}
2562
+
2563
+	/**
2564
+	 * @param string $encoding
2565
+	 */
2307 2566
 	public function setEncoding($encoding)
2308 2567
 	{
2309 2568
 		$this->_encoding=$encoding;
@@ -2354,6 +2613,10 @@  discard block
 block discarded – undo
2354 2613
 		}
2355 2614
 		return true;
2356 2615
 	}
2616
+
2617
+	/**
2618
+	 * @param string $file
2619
+	 */
2357 2620
 	public function saveToFile($file)
2358 2621
 	{
2359 2622
 		if(($fw=fopen($file,'w'))!==false)
@@ -2399,6 +2662,10 @@  discard block
 block discarded – undo
2399 2662
 	{
2400 2663
 		return $this->_o;
2401 2664
 	}
2665
+
2666
+	/**
2667
+	 * @param integer $index
2668
+	 */
2402 2669
 	public function insertAt($index,$item)
2403 2670
 	{
2404 2671
 		if($item instanceof TXmlElement)
@@ -2411,6 +2678,10 @@  discard block
 block discarded – undo
2411 2678
 		else
2412 2679
 			throw new TInvalidDataTypeException('xmlelementlist_xmlelement_required');
2413 2680
 	}
2681
+
2682
+	/**
2683
+	 * @param integer $index
2684
+	 */
2414 2685
 	public function removeAt($index)
2415 2686
 	{
2416 2687
 		$item=parent::removeAt($index);
@@ -2532,10 +2803,18 @@  discard block
 block discarded – undo
2532 2803
 		}
2533 2804
 		return 0;
2534 2805
 	}
2806
+
2807
+	/**
2808
+	 * @param IUser $user
2809
+	 */
2535 2810
 	private function isUserMatched($user)
2536 2811
 	{
2537 2812
 		return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()),$this->_users));
2538 2813
 	}
2814
+
2815
+	/**
2816
+	 * @param IUser $user
2817
+	 */
2539 2818
 	private function isRoleMatched($user)
2540 2819
 	{
2541 2820
 		foreach($this->_roles as $role)
@@ -2552,6 +2831,11 @@  discard block
 block discarded – undo
2552 2831
 }
2553 2832
 class TAuthorizationRuleCollection extends TList
2554 2833
 {
2834
+	/**
2835
+	 * @param IUser $user
2836
+	 * @param string $verb
2837
+	 * @param string $ip
2838
+	 */
2555 2839
 	public function isUserAllowed($user,$verb,$ip)
2556 2840
 	{
2557 2841
 		if($user instanceof IUser)
@@ -2603,6 +2887,10 @@  discard block
 block discarded – undo
2603 2887
 		}
2604 2888
 		return $this->_validationKey;
2605 2889
 	}
2890
+
2891
+	/**
2892
+	 * @param string $value
2893
+	 */
2606 2894
 	public function setValidationKey($value)
2607 2895
 	{
2608 2896
 		if('' === $value)
@@ -2619,6 +2907,10 @@  discard block
 block discarded – undo
2619 2907
 		}
2620 2908
 		return $this->_encryptionKey;
2621 2909
 	}
2910
+
2911
+	/**
2912
+	 * @param string $value
2913
+	 */
2622 2914
 	public function setEncryptionKey($value)
2623 2915
 	{
2624 2916
 		if('' === $value)
@@ -2633,6 +2925,10 @@  discard block
 block discarded – undo
2633 2925
 	{
2634 2926
 		return $this->_hashAlgorithm;
2635 2927
 	}
2928
+
2929
+	/**
2930
+	 * @param string $value
2931
+	 */
2636 2932
 	public function setValidation($value)
2637 2933
 	{
2638 2934
 		$this->_hashAlgorithm = TPropertyValue::ensureEnum($value, 'TSecurityManagerValidationMode');
@@ -2655,10 +2951,18 @@  discard block
 block discarded – undo
2655 2951
 	{
2656 2952
 		return $this->_cryptAlgorithm;
2657 2953
 	}
2954
+
2955
+	/**
2956
+	 * @param string $value
2957
+	 */
2658 2958
 	public function setCryptAlgorithm($value)
2659 2959
 	{
2660 2960
 		$this->_cryptAlgorithm = $value;
2661 2961
 	}
2962
+
2963
+	/**
2964
+	 * @param string $data
2965
+	 */
2662 2966
 	public function encrypt($data)
2663 2967
 	{
2664 2968
 		$module=$this->openCryptModule();
@@ -2671,6 +2975,10 @@  discard block
 block discarded – undo
2671 2975
 		mcrypt_module_close($module);
2672 2976
 		return $encrypted;
2673 2977
 	}
2978
+
2979
+	/**
2980
+	 * @param string $data
2981
+	 */
2674 2982
 	public function decrypt($data)
2675 2983
 	{
2676 2984
 		$module=$this->openCryptModule();
@@ -2732,6 +3040,11 @@  discard block
 block discarded – undo
2732 3040
 	{
2733 3041
 		return $this->_mbstring ? mb_strlen($string,'8bit') : strlen($string);
2734 3042
 	}
3043
+
3044
+	/**
3045
+	 * @param integer $start
3046
+	 * @param integer $length
3047
+	 */
2735 3048
 	private function substr($string,$start,$length)
2736 3049
 	{
2737 3050
 		return $this->_mbstring ? mb_substr($string,$start,$length,'8bit') : substr($string,$start,$length);
@@ -2751,6 +3064,10 @@  discard block
 block discarded – undo
2751 3064
 	{
2752 3065
 		return strtr($s,self::$_encodeTable);
2753 3066
 	}
3067
+
3068
+	/**
3069
+	 * @param string $s
3070
+	 */
2754 3071
 	public static function htmlDecode($s)
2755 3072
 	{
2756 3073
 		return strtr($s,self::$_decodeTable);
@@ -2891,6 +3208,10 @@  discard block
 block discarded – undo
2891 3208
 		self::checkJsonError();
2892 3209
 		return $s;
2893 3210
 	}
3211
+
3212
+	/**
3213
+	 * @param string $sourceEncoding
3214
+	 */
2894 3215
 	private static function convertToUtf8(&$value, $sourceEncoding) {
2895 3216
 		if(is_string($value))
2896 3217
 			$value=iconv($sourceEncoding, 'UTF-8', $value);
@@ -2900,6 +3221,10 @@  discard block
 block discarded – undo
2900 3221
 				self::convertToUtf8($element, $sourceEncoding);
2901 3222
 		}
2902 3223
 	}
3224
+
3225
+	/**
3226
+	 * @param string $value
3227
+	 */
2903 3228
 	public static function jsonDecode($value, $assoc = false, $depth = 512)
2904 3229
 	{
2905 3230
 		$s= @json_decode($value, $assoc, $depth);
@@ -2934,6 +3259,10 @@  discard block
 block discarded – undo
2934 3259
 		}
2935 3260
 		throw new Exception("JSON error ($err): $msg");
2936 3261
 	}
3262
+
3263
+	/**
3264
+	 * @param string $code
3265
+	 */
2937 3266
 	public static function JSMin($code)
2938 3267
 	{
2939 3268
 		Prado::using('System.Web.Javascripts.JSMin');
@@ -3047,6 +3376,10 @@  discard block
 block discarded – undo
3047 3376
 	{
3048 3377
 		return $this->_id;
3049 3378
 	}
3379
+
3380
+	/**
3381
+	 * @param string $value
3382
+	 */
3050 3383
 	public function setID($value)
3051 3384
 	{
3052 3385
 		$this->_id=$value;
@@ -3121,6 +3454,10 @@  discard block
 block discarded – undo
3121 3454
 	{
3122 3455
 		return $this->getID();
3123 3456
 	}
3457
+
3458
+	/**
3459
+	 * @param TUrlManager $manager
3460
+	 */
3124 3461
 	protected function cacheUrlManager($manager)
3125 3462
 	{
3126 3463
 		if($this->getEnableCache())
@@ -3158,6 +3495,10 @@  discard block
 block discarded – undo
3158 3495
 	{
3159 3496
 		return $this->_urlManagerID;
3160 3497
 	}
3498
+
3499
+	/**
3500
+	 * @param string $value
3501
+	 */
3161 3502
 	public function setUrlManager($value)
3162 3503
 	{
3163 3504
 		$this->_urlManagerID=$value;
@@ -3198,6 +3539,10 @@  discard block
 block discarded – undo
3198 3539
 	{
3199 3540
 		return $this->_separator;
3200 3541
 	}
3542
+
3543
+	/**
3544
+	 * @param string $value
3545
+	 */
3201 3546
 	public function setUrlParamSeparator($value)
3202 3547
 	{
3203 3548
 		if(strlen($value)===1)
@@ -3324,6 +3669,10 @@  discard block
 block discarded – undo
3324 3669
 	{
3325 3670
 		return $this->_enableCookieValidation;
3326 3671
 	}
3672
+
3673
+	/**
3674
+	 * @param boolean $value
3675
+	 */
3327 3676
 	public function setEnableCookieValidation($value)
3328 3677
 	{
3329 3678
 		$this->_enableCookieValidation=TPropertyValue::ensureBoolean($value);
@@ -3370,6 +3719,10 @@  discard block
 block discarded – undo
3370 3719
 	{
3371 3720
 		return $_ENV;
3372 3721
 	}
3722
+
3723
+	/**
3724
+	 * @param string $serviceID
3725
+	 */
3373 3726
 	public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=true,$encodeGetItems=true)
3374 3727
 	{
3375 3728
 		if ($this->_cookieOnly===null)
@@ -3470,18 +3823,35 @@  discard block
 block discarded – undo
3470 3823
 	{
3471 3824
 		return $this->_items;
3472 3825
 	}
3826
+
3827
+	/**
3828
+	 * @param integer $offset
3829
+	 */
3473 3830
 	public function offsetExists($offset)
3474 3831
 	{
3475 3832
 		return $this->contains($offset);
3476 3833
 	}
3834
+
3835
+	/**
3836
+	 * @param integer $offset
3837
+	 */
3477 3838
 	public function offsetGet($offset)
3478 3839
 	{
3479 3840
 		return $this->itemAt($offset);
3480 3841
 	}
3842
+
3843
+	/**
3844
+	 * @param integer $offset
3845
+	 * @param string $item
3846
+	 */
3481 3847
 	public function offsetSet($offset,$item)
3482 3848
 	{
3483 3849
 		$this->add($offset,$item);
3484 3850
 	}
3851
+
3852
+	/**
3853
+	 * @param integer $offset
3854
+	 */
3485 3855
 	public function offsetUnset($offset)
3486 3856
 	{
3487 3857
 		$this->remove($offset);
@@ -3490,10 +3860,18 @@  discard block
 block discarded – undo
3490 3860
 class THttpCookieCollection extends TList
3491 3861
 {
3492 3862
 	private $_o;
3863
+
3864
+	/**
3865
+	 * @param THttpResponse $owner
3866
+	 */
3493 3867
 	public function __construct($owner=null)
3494 3868
 	{
3495 3869
 		$this->_o=$owner;
3496 3870
 	}
3871
+
3872
+	/**
3873
+	 * @param integer $index
3874
+	 */
3497 3875
 	public function insertAt($index,$item)
3498 3876
 	{
3499 3877
 		if($item instanceof THttpCookie)
@@ -3505,6 +3883,10 @@  discard block
 block discarded – undo
3505 3883
 		else
3506 3884
 			throw new TInvalidDataTypeException('httpcookiecollection_httpcookie_required');
3507 3885
 	}
3886
+
3887
+	/**
3888
+	 * @param integer $index
3889
+	 */
3508 3890
 	public function removeAt($index)
3509 3891
 	{
3510 3892
 		$item=parent::removeAt($index);
@@ -3545,6 +3927,10 @@  discard block
 block discarded – undo
3545 3927
 	{
3546 3928
 		return $this->_domain;
3547 3929
 	}
3930
+
3931
+	/**
3932
+	 * @param string $value
3933
+	 */
3548 3934
 	public function setDomain($value)
3549 3935
 	{
3550 3936
 		$this->_domain=$value;
@@ -3553,6 +3939,10 @@  discard block
 block discarded – undo
3553 3939
 	{
3554 3940
 		return $this->_expire;
3555 3941
 	}
3942
+
3943
+	/**
3944
+	 * @param integer $value
3945
+	 */
3556 3946
 	public function setExpire($value)
3557 3947
 	{
3558 3948
 		$this->_expire=TPropertyValue::ensureInteger($value);
@@ -3569,6 +3959,10 @@  discard block
 block discarded – undo
3569 3959
 	{
3570 3960
 		return $this->_name;
3571 3961
 	}
3962
+
3963
+	/**
3964
+	 * @param string $value
3965
+	 */
3572 3966
 	public function setName($value)
3573 3967
 	{
3574 3968
 		$this->_name=$value;
@@ -3577,6 +3971,10 @@  discard block
 block discarded – undo
3577 3971
 	{
3578 3972
 		return $this->_value;
3579 3973
 	}
3974
+
3975
+	/**
3976
+	 * @param string $value
3977
+	 */
3580 3978
 	public function setValue($value)
3581 3979
 	{
3582 3980
 		$this->_value=$value;
@@ -3585,6 +3983,10 @@  discard block
 block discarded – undo
3585 3983
 	{
3586 3984
 		return $this->_path;
3587 3985
 	}
3986
+
3987
+	/**
3988
+	 * @param string $value
3989
+	 */
3588 3990
 	public function setPath($value)
3589 3991
 	{
3590 3992
 		$this->_path=$value;
@@ -3593,6 +3995,10 @@  discard block
 block discarded – undo
3593 3995
 	{
3594 3996
 		return $this->_secure;
3595 3997
 	}
3998
+
3999
+	/**
4000
+	 * @param boolean $value
4001
+	 */
3596 4002
 	public function setSecure($value)
3597 4003
 	{
3598 4004
 		$this->_secure=TPropertyValue::ensureBoolean($value);
@@ -3619,6 +4025,10 @@  discard block
 block discarded – undo
3619 4025
 	private $_query;
3620 4026
 	private $_fragment;
3621 4027
 	private $_uri;
4028
+
4029
+	/**
4030
+	 * @param string $uri
4031
+	 */
3622 4032
 	public function __construct($uri)
3623 4033
 	{
3624 4034
 		if(($ret=@parse_url($uri))!==false)
@@ -3684,6 +4094,10 @@  discard block
 block discarded – undo
3684 4094
 class THttpResponseAdapter extends TApplicationComponent
3685 4095
 {
3686 4096
 	private $_response;
4097
+
4098
+	/**
4099
+	 * @param THttpResponse $response
4100
+	 */
3687 4101
 	public function __construct($response)
3688 4102
 	{
3689 4103
 		$this->_response=$response;
@@ -3753,6 +4167,10 @@  discard block
 block discarded – undo
3753 4167
 	{
3754 4168
 		return session_cache_expire();
3755 4169
 	}
4170
+
4171
+	/**
4172
+	 * @param integer $value
4173
+	 */
3756 4174
 	public function setCacheExpire($value)
3757 4175
 	{
3758 4176
 		session_cache_expire(TPropertyValue::ensureInteger($value));
@@ -3761,6 +4179,10 @@  discard block
 block discarded – undo
3761 4179
 	{
3762 4180
 		return session_cache_limiter();
3763 4181
 	}
4182
+
4183
+	/**
4184
+	 * @param string $value
4185
+	 */
3764 4186
 	public function setCacheControl($value)
3765 4187
 	{
3766 4188
 		session_cache_limiter(TPropertyValue::ensureEnum($value,array('none','nocache','private','private_no_expire','public')));
@@ -3779,6 +4201,10 @@  discard block
 block discarded – undo
3779 4201
 	{
3780 4202
 		return $this->_charset;
3781 4203
 	}
4204
+
4205
+	/**
4206
+	 * @param string $charset
4207
+	 */
3782 4208
 	public function setCharset($charset)
3783 4209
 	{
3784 4210
 		$this->_charset = (strToLower($charset) === 'false') ? false : (string)$charset;
@@ -3787,6 +4213,10 @@  discard block
 block discarded – undo
3787 4213
 	{
3788 4214
 		return $this->_bufferOutput;
3789 4215
 	}
4216
+
4217
+	/**
4218
+	 * @param boolean $value
4219
+	 */
3790 4220
 	public function setBufferOutput($value)
3791 4221
 	{
3792 4222
 		if($this->_initialized)
@@ -4002,6 +4432,10 @@  discard block
 block discarded – undo
4002 4432
 			return array_change_key_case($result, $case);
4003 4433
 		return $result;
4004 4434
 	}
4435
+
4436
+	/**
4437
+	 * @param string $value
4438
+	 */
4005 4439
 	public function appendHeader($value, $replace=true)
4006 4440
 	{
4007 4441
 		header($value, $replace);
@@ -4010,6 +4444,10 @@  discard block
 block discarded – undo
4010 4444
 	{
4011 4445
 		error_log($message,$messageType,$destination,$extraHeaders);
4012 4446
 	}
4447
+
4448
+	/**
4449
+	 * @param THttpCookie $cookie
4450
+	 */
4013 4451
 	public function addCookie($cookie)
4014 4452
 	{
4015 4453
 		$request=$this->getRequest();
@@ -4067,6 +4505,10 @@  discard block
 block discarded – undo
4067 4505
 		else
4068 4506
 			return $this->createNewHtmlWriter($type, $this);
4069 4507
 	}
4508
+
4509
+	/**
4510
+	 * @param THttpResponse $writer
4511
+	 */
4070 4512
 	public function createNewHtmlWriter($type, $writer)
4071 4513
 	{
4072 4514
 		return Prado::createComponent($type, $writer);
@@ -4176,6 +4618,10 @@  discard block
 block discarded – undo
4176 4618
 	{
4177 4619
 		return $this->_customStorage;
4178 4620
 	}
4621
+
4622
+	/**
4623
+	 * @param boolean $value
4624
+	 */
4179 4625
 	public function setUseCustomStorage($value)
4180 4626
 	{
4181 4627
 		$this->_customStorage=TPropertyValue::ensureBoolean($value);
@@ -4318,10 +4764,18 @@  discard block
 block discarded – undo
4318 4764
 	{
4319 4765
 		return array_keys($_SESSION);
4320 4766
 	}
4767
+
4768
+	/**
4769
+	 * @param string $key
4770
+	 */
4321 4771
 	public function itemAt($key)
4322 4772
 	{
4323 4773
 		return isset($_SESSION[$key]) ? $_SESSION[$key] : null;
4324 4774
 	}
4775
+
4776
+	/**
4777
+	 * @param string $key
4778
+	 */
4325 4779
 	public function add($key,$value)
4326 4780
 	{
4327 4781
 		$_SESSION[$key]=$value;
@@ -4422,6 +4876,10 @@  discard block
 block discarded – undo
4422 4876
 	{
4423 4877
 		return $this->_caseSensitive;
4424 4878
 	}
4879
+
4880
+	/**
4881
+	 * @param boolean $value
4882
+	 */
4425 4883
 	public function setCaseSensitive($value)
4426 4884
 	{
4427 4885
 		$this->_caseSensitive=TPropertyValue::ensureBoolean($value);
@@ -4434,6 +4892,10 @@  discard block
 block discarded – undo
4434 4892
 	{
4435 4893
 		parent::add($this->_caseSensitive?$key:strtolower($key),$value);
4436 4894
 	}
4895
+
4896
+	/**
4897
+	 * @param string $key
4898
+	 */
4437 4899
 	public function remove($key)
4438 4900
 	{
4439 4901
 		return parent::remove($this->_caseSensitive?$key:strtolower($key));
@@ -4442,14 +4904,26 @@  discard block
 block discarded – undo
4442 4904
 	{
4443 4905
 		return parent::contains($this->_caseSensitive?$key:strtolower($key));
4444 4906
 	}
4907
+
4908
+	/**
4909
+	 * @param string $name
4910
+	 */
4445 4911
 	public function hasProperty($name)
4446 4912
 	{
4447 4913
 		return $this->contains($name) || parent::canGetProperty($name) || parent::canSetProperty($name);
4448 4914
 	}
4915
+
4916
+	/**
4917
+	 * @param string $name
4918
+	 */
4449 4919
 	public function canGetProperty($name)
4450 4920
 	{
4451 4921
 		return $this->contains($name) || parent::canGetProperty($name);
4452 4922
 	}
4923
+
4924
+	/**
4925
+	 * @param string $name
4926
+	 */
4453 4927
 	public function canSetProperty($name)
4454 4928
 	{
4455 4929
 		return true;
@@ -4584,6 +5058,10 @@  discard block
 block discarded – undo
4584 5058
 		}
4585 5059
 		return $this->_page;
4586 5060
 	}
5061
+
5062
+	/**
5063
+	 * @param TPage $page
5064
+	 */
4587 5065
 	public function setPage($page)
4588 5066
 	{
4589 5067
 		$this->_page=$page;
@@ -4727,6 +5205,10 @@  discard block
 block discarded – undo
4727 5205
 		else
4728 5206
 			return $this->getViewState('Visible',true);
4729 5207
 	}
5208
+
5209
+	/**
5210
+	 * @param boolean $value
5211
+	 */
4730 5212
 	public function setVisible($value)
4731 5213
 	{
4732 5214
 		$this->setViewState('Visible',TPropertyValue::ensureBoolean($value),true);
@@ -4765,6 +5247,10 @@  discard block
 block discarded – undo
4765 5247
 			return $attributes;
4766 5248
 		}
4767 5249
 	}
5250
+
5251
+	/**
5252
+	 * @param string $name
5253
+	 */
4768 5254
 	public function hasAttribute($name)
4769 5255
 	{
4770 5256
 		if($attributes=$this->getViewState('Attributes',null))
@@ -4772,6 +5258,10 @@  discard block
 block discarded – undo
4772 5258
 		else
4773 5259
 			return false;
4774 5260
 	}
5261
+
5262
+	/**
5263
+	 * @param string $name
5264
+	 */
4775 5265
 	public function getAttribute($name)
4776 5266
 	{
4777 5267
 		if($attributes=$this->getViewState('Attributes',null))
@@ -4779,6 +5269,10 @@  discard block
 block discarded – undo
4779 5269
 		else
4780 5270
 			return null;
4781 5271
 	}
5272
+
5273
+	/**
5274
+	 * @param string $name
5275
+	 */
4782 5276
 	public function setAttribute($name,$value)
4783 5277
 	{
4784 5278
 		$this->getAttributes()->add($name,$value);
@@ -4802,6 +5296,10 @@  discard block
 block discarded – undo
4802 5296
 		else
4803 5297
 			return !($this->_flags & self::IS_DISABLE_VIEWSTATE);
4804 5298
 	}
5299
+
5300
+	/**
5301
+	 * @param boolean $value
5302
+	 */
4805 5303
 	public function setEnableViewState($value)
4806 5304
 	{
4807 5305
 		if(TPropertyValue::ensureBoolean($value))
@@ -4809,10 +5307,19 @@  discard block
 block discarded – undo
4809 5307
 		else
4810 5308
 			$this->_flags |= self::IS_DISABLE_VIEWSTATE;
4811 5309
 	}
5310
+
5311
+	/**
5312
+	 * @param string $key
5313
+	 */
4812 5314
 	protected function getControlState($key,$defaultValue=null)
4813 5315
 	{
4814 5316
 		return isset($this->_rf[self::RF_CONTROLSTATE][$key])?$this->_rf[self::RF_CONTROLSTATE][$key]:$defaultValue;
4815 5317
 	}
5318
+
5319
+	/**
5320
+	 * @param string $key
5321
+	 * @param integer $defaultValue
5322
+	 */
4816 5323
 	protected function setControlState($key,$value,$defaultValue=null)
4817 5324
 	{
4818 5325
 		if($value===$defaultValue)
@@ -4824,6 +5331,10 @@  discard block
 block discarded – undo
4824 5331
 	{
4825 5332
 		unset($this->_rf[self::RF_CONTROLSTATE][$key]);
4826 5333
 	}
5334
+
5335
+	/**
5336
+	 * @param boolean $enabled
5337
+	 */
4827 5338
 	public function trackViewState($enabled)
4828 5339
 	{
4829 5340
 		$this->_trackViewState=TPropertyValue::ensureBoolean($enabled);
@@ -4841,6 +5352,10 @@  discard block
 block discarded – undo
4841 5352
 		else
4842 5353
 			return $defaultValue;
4843 5354
 	}
5355
+
5356
+	/**
5357
+	 * @param string $key
5358
+	 */
4844 5359
 	public function setViewState($key,$value,$defaultValue=null)
4845 5360
 	{
4846 5361
 		if($this->_trackViewState)
@@ -4854,6 +5369,10 @@  discard block
 block discarded – undo
4854 5369
 			$this->_tempState[$key]=$value;
4855 5370
 		}
4856 5371
 	}
5372
+
5373
+	/**
5374
+	 * @param string $key
5375
+	 */
4857 5376
 	public function clearViewState($key)
4858 5377
 	{
4859 5378
 		unset($this->_viewState[$key]);
@@ -4910,6 +5429,10 @@  discard block
 block discarded – undo
4910 5429
 	{
4911 5430
 		return ($this->_flags & self::IS_CHILD_CREATED)!==0;
4912 5431
 	}
5432
+
5433
+	/**
5434
+	 * @param boolean $value
5435
+	 */
4913 5436
 	final protected function setChildControlsCreated($value)
4914 5437
 	{
4915 5438
 		if($value)
@@ -4969,6 +5492,10 @@  discard block
 block discarded – undo
4969 5492
 				return null;
4970 5493
 		}
4971 5494
 	}
5495
+
5496
+	/**
5497
+	 * @param string $type
5498
+	 */
4972 5499
 	public function findControlsByType($type,$strict=true)
4973 5500
 	{
4974 5501
 		$controls=array();
@@ -5040,6 +5567,10 @@  discard block
 block discarded – undo
5040 5567
 	{
5041 5568
 		return $this->getControlStage() >= self::CS_PRERENDERED;
5042 5569
 	}
5570
+
5571
+	/**
5572
+	 * @param string $name
5573
+	 */
5043 5574
 	public function getRegisteredObject($name)
5044 5575
 	{
5045 5576
 		return isset($this->_rf[self::RF_NAMED_OBJECTS][$name])?$this->_rf[self::RF_NAMED_OBJECTS][$name]:null;
@@ -5063,6 +5594,10 @@  discard block
 block discarded – undo
5063 5594
 			$control=$control->_parent;
5064 5595
 		return $control===$ancestor;
5065 5596
 	}
5597
+
5598
+	/**
5599
+	 * @param TControl $control
5600
+	 */
5066 5601
 	public function addedControl($control)
5067 5602
 	{
5068 5603
 		if($control->_parent)
@@ -5101,6 +5636,10 @@  discard block
 block discarded – undo
5101 5636
 			}
5102 5637
 		}
5103 5638
 	}
5639
+
5640
+	/**
5641
+	 * @param TControl $control
5642
+	 */
5104 5643
 	public function removedControl($control)
5105 5644
 	{
5106 5645
 		if($this->_namingContainer)
@@ -5246,6 +5785,10 @@  discard block
 block discarded – undo
5246 5785
 		$rootControl=(($page=$this->getPage())===null)?$this:$page;
5247 5786
 		$rootControl->broadcastEventInternal($name,$sender,new TBroadcastEventParameter($name,$param));
5248 5787
 	}
5788
+
5789
+	/**
5790
+	 * @param TBroadcastEventParameter $param
5791
+	 */
5249 5792
 	private function broadcastEventInternal($name,$sender,$param)
5250 5793
 	{
5251 5794
 		if($this->hasEvent($name))
@@ -5388,6 +5931,10 @@  discard block
 block discarded – undo
5388 5931
 		else if($this->_flags & self::IS_STYLESHEET_APPLIED)
5389 5932
 			throw new TInvalidOperationException('control_stylesheet_applied',get_class($this));
5390 5933
 	}
5934
+
5935
+	/**
5936
+	 * @param boolean $recursive
5937
+	 */
5391 5938
 	private function clearCachedUniqueID($recursive)
5392 5939
 	{
5393 5940
 		if($recursive && $this->_uid!==null && isset($this->_rf[self::RF_CONTROLS]))
@@ -5411,6 +5958,10 @@  discard block
 block discarded – undo
5411 5958
 	{
5412 5959
 		unset($this->_rf[self::RF_NAMED_CONTROLS]);
5413 5960
 	}
5961
+
5962
+	/**
5963
+	 * @param TControl $container
5964
+	 */
5414 5965
 	private function fillNameTable($container,$controls)
5415 5966
 	{
5416 5967
 		foreach($controls as $control)
@@ -5483,11 +6034,18 @@  discard block
 block discarded – undo
5483 6034
 }
5484 6035
 interface IPostBackEventHandler
5485 6036
 {
6037
+	/**
6038
+	 * @return void
6039
+	 */
5486 6040
 	public function raisePostBackEvent($param);
5487 6041
 }
5488 6042
 interface IPostBackDataHandler
5489 6043
 {
5490 6044
 	public function loadPostData($key,$values);
6045
+
6046
+	/**
6047
+	 * @return void
6048
+	 */
5491 6049
 	public function raisePostDataChangedEvent();
5492 6050
 	public function getDataChanged();
5493 6051
 }
@@ -5495,8 +6053,16 @@  discard block
 block discarded – undo
5495 6053
 {
5496 6054
 	public function validate();
5497 6055
 	public function getIsValid();
6056
+
6057
+	/**
6058
+	 * @return void
6059
+	 */
5498 6060
 	public function setIsValid($value);
5499 6061
 	public function getErrorMessage();
6062
+
6063
+	/**
6064
+	 * @return void
6065
+	 */
5500 6066
 	public function setErrorMessage($value);
5501 6067
 }
5502 6068
 interface IValidatable
@@ -5511,26 +6077,66 @@  discard block
 block discarded – undo
5511 6077
 }
5512 6078
 interface ITheme
5513 6079
 {
6080
+	/**
6081
+	 * @return boolean
6082
+	 */
5514 6083
 	public function applySkin($control);
5515 6084
 }
5516 6085
 interface ITemplate
5517 6086
 {
6087
+	/**
6088
+	 * @return void
6089
+	 */
5518 6090
 	public function instantiateIn($parent);
5519 6091
 }
5520 6092
 interface IButtonControl
5521 6093
 {
5522 6094
 	public function getText();
6095
+
6096
+	/**
6097
+	 * @param string $value
6098
+	 *
6099
+	 * @return void
6100
+	 */
5523 6101
 	public function setText($value);
5524 6102
 	public function getCausesValidation();
6103
+
6104
+	/**
6105
+	 * @return void
6106
+	 */
5525 6107
 	public function setCausesValidation($value);
5526 6108
 	public function getCommandName();
6109
+
6110
+	/**
6111
+	 * @return void
6112
+	 */
5527 6113
 	public function setCommandName($value);
5528 6114
 	public function getCommandParameter();
6115
+
6116
+	/**
6117
+	 * @return void
6118
+	 */
5529 6119
 	public function setCommandParameter($value);
5530 6120
 	public function getValidationGroup();
6121
+
6122
+	/**
6123
+	 * @return void
6124
+	 */
5531 6125
 	public function setValidationGroup($value);
6126
+
6127
+	/**
6128
+	 * @return void
6129
+	 */
5532 6130
 	public function onClick($param);
6131
+
6132
+	/**
6133
+	 * @return void
6134
+	 */
5533 6135
 	public function onCommand($param);
6136
+
6137
+	/**
6138
+	 * @return void
6139
+	 */
5534 6140
 	public function setIsDefaultButton($value);
5535 6141
 	public function getIsDefaultButton();
5536 6142
 }
@@ -5964,6 +6570,10 @@  discard block
 block discarded – undo
5964 6570
 	{
5965 6571
 		return $this->_customStyle===null?'':$this->_customStyle;
5966 6572
 	}
6573
+
6574
+	/**
6575
+	 * @param string $value
6576
+	 */
5967 6577
 	public function setCustomStyle($value)
5968 6578
 	{
5969 6579
 		$this->_customStyle=$value;
@@ -5972,6 +6582,11 @@  discard block
 block discarded – undo
5972 6582
 	{
5973 6583
 		return isset($this->_fields[$name])?$this->_fields[$name]:'';
5974 6584
 	}
6585
+
6586
+	/**
6587
+	 * @param string $name
6588
+	 * @param string $value
6589
+	 */
5975 6590
 	public function setStyleField($name,$value)
5976 6591
 	{
5977 6592
 		$this->_fields[$name]=$value;
@@ -6441,6 +7056,10 @@  discard block
 block discarded – undo
6441 7056
 {
6442 7057
 	private $_ensureid=false;
6443 7058
 	protected $_decorator;
7059
+
7060
+	/**
7061
+	 * @param boolean $value
7062
+	 */
6444 7063
 	public function setEnsureId($value)
6445 7064
 	{
6446 7065
 		$this->_ensureid |= TPropertyValue::ensureBoolean($value);
@@ -6530,6 +7149,10 @@  discard block
 block discarded – undo
6530 7149
 		else
6531 7150
 			return '';
6532 7151
 	}
7152
+
7153
+	/**
7154
+	 * @param string $value
7155
+	 */
6533 7156
 	public function setForeColor($value)
6534 7157
 	{
6535 7158
 		$this->getStyle()->setForeColor($value);
@@ -6560,6 +7183,10 @@  discard block
 block discarded – undo
6560 7183
 		else
6561 7184
 			return '';
6562 7185
 	}
7186
+
7187
+	/**
7188
+	 * @param string $value
7189
+	 */
6563 7190
 	public function setHeight($value)
6564 7191
 	{
6565 7192
 		$this->getStyle()->setHeight($value);
@@ -6621,6 +7248,10 @@  discard block
 block discarded – undo
6621 7248
 		else
6622 7249
 			return '';
6623 7250
 	}
7251
+
7252
+	/**
7253
+	 * @param string $value
7254
+	 */
6624 7255
 	public function setWidth($value)
6625 7256
 	{
6626 7257
 		$this->getStyle()->setWidth($value);
@@ -6748,6 +7379,10 @@  discard block
 block discarded – undo
6748 7379
 			$tpl->instantiateIn($this);
6749 7380
 		}
6750 7381
 	}
7382
+
7383
+	/**
7384
+	 * @param string $id
7385
+	 */
6751 7386
 	public function registerContent($id,TContent $object)
6752 7387
 	{
6753 7388
 		if(isset($this->_contents[$id]))
@@ -6755,6 +7390,10 @@  discard block
 block discarded – undo
6755 7390
 		else
6756 7391
 			$this->_contents[$id]=$object;
6757 7392
 	}
7393
+
7394
+	/**
7395
+	 * @param string $id
7396
+	 */
6758 7397
 	public function registerContentPlaceHolder($id,TContentPlaceHolder $object)
6759 7398
 	{
6760 7399
 		if(isset($this->_placeholders[$id]))
@@ -6951,6 +7590,10 @@  discard block
 block discarded – undo
6951 7590
 	{
6952 7591
 		return $this->getViewState('Enctype','');
6953 7592
 	}
7593
+
7594
+	/**
7595
+	 * @param string $value
7596
+	 */
6954 7597
 	public function setEnctype($value)
6955 7598
 	{
6956 7599
 		$this->setViewState('Enctype',$value,'');
@@ -7070,6 +7713,10 @@  discard block
 block discarded – undo
7070 7713
 		$scripts = array_unique($scripts);
7071 7714
 		return $scripts;
7072 7715
 	}
7716
+
7717
+	/**
7718
+	 * @param string $base
7719
+	 */
7073 7720
 	protected function getPackagePathUrl($base)
7074 7721
 	{
7075 7722
 		$assets = Prado::getApplication()->getAssetManager();
@@ -7219,6 +7866,11 @@  discard block
 block discarded – undo
7219 7866
 		$params=func_get_args();
7220 7867
 		$this->_page->registerCachingAction('Page.ClientScript','registerEndScript',$params);
7221 7868
 	}
7869
+
7870
+	/**
7871
+	 * @param string $name
7872
+	 * @param string $value
7873
+	 */
7222 7874
 	public function registerHiddenField($name,$value)
7223 7875
 	{
7224 7876
 		$this->_hiddenFields[$name]=$value;
@@ -7356,6 +8008,10 @@  discard block
 block discarded – undo
7356 8008
 			$this->renderAllPendingScriptFiles($writer);
7357 8009
 		}
7358 8010
 	}
8011
+
8012
+	/**
8013
+	 * @param boolean $initial
8014
+	 */
7359 8015
 	protected function renderHiddenFieldsInt($writer, $initial)
7360 8016
  	{
7361 8017
 		if ($initial) $this->_renderedHiddenFields = array();
@@ -7391,12 +8047,20 @@  discard block
 block discarded – undo
7391 8047
 abstract class TClientSideOptions extends TComponent
7392 8048
 {
7393 8049
 	private $_options;
8050
+
8051
+	/**
8052
+	 * @param string $name
8053
+	 */
7394 8054
 	protected function setFunction($name, $code)
7395 8055
 	{
7396 8056
 		if(!TJavaScript::isJsLiteral($code))
7397 8057
 			$code = TJavaScript::quoteJsLiteral($this->ensureFunction($code));
7398 8058
 		$this->setOption($name, $code);
7399 8059
 	}
8060
+
8061
+	/**
8062
+	 * @param string $name
8063
+	 */
7400 8064
 	protected function getOption($name)
7401 8065
 	{
7402 8066
 		if ($this->_options)
@@ -7519,6 +8183,10 @@  discard block
 block discarded – undo
7519 8183
 		$this->renderControl($writer);
7520 8184
 		$this->unloadRecursive();
7521 8185
 	}
8186
+
8187
+	/**
8188
+	 * @param string $enc
8189
+	 */
7522 8190
 	protected static function decodeUTF8($data, $enc)
7523 8191
 	{
7524 8192
 		if(is_array($data))
@@ -7600,6 +8268,10 @@  discard block
 block discarded – undo
7600 8268
 		else
7601 8269
 			throw new TInvalidOperationException('page_form_duplicated');
7602 8270
 	}
8271
+
8272
+	/**
8273
+	 * @param string $validationGroup
8274
+	 */
7603 8275
 	public function getValidators($validationGroup=null)
7604 8276
 	{
7605 8277
 		if(!$this->_validators)
@@ -7670,6 +8342,10 @@  discard block
 block discarded – undo
7670 8342
 	{
7671 8343
 		$this->_styleSheet=empty($value)?null:$value;
7672 8344
 	}
8345
+
8346
+	/**
8347
+	 * @param TControl $control
8348
+	 */
7673 8349
 	public function applyControlSkin($control)
7674 8350
 	{
7675 8351
 		if(($theme=$this->getTheme())!==null)
@@ -7817,6 +8493,10 @@  discard block
 block discarded – undo
7817 8493
 	{
7818 8494
 		$this->_postBackEventParameter=$value;
7819 8495
 	}
8496
+
8497
+	/**
8498
+	 * @param boolean $beforeLoad
8499
+	 */
7820 8500
 	protected function processPostData($postData,$beforeLoad)
7821 8501
 	{
7822 8502
 		$this->_isLoadingPostData=true;
@@ -7905,6 +8585,10 @@  discard block
 block discarded – undo
7905 8585
 			$this->getClientScript()->registerFocusControl($lastFocus);
7906 8586
 		$this->_inFormRender=false;
7907 8587
 	}
8588
+
8589
+	/**
8590
+	 * @param TControl $value
8591
+	 */
7908 8592
 	public function setFocus($value)
7909 8593
 	{
7910 8594
 		$this->_focus=$value;
@@ -7950,6 +8634,10 @@  discard block
 block discarded – undo
7950 8634
 	{
7951 8635
 		return $this->_clientState;
7952 8636
 	}
8637
+
8638
+	/**
8639
+	 * @param string $state
8640
+	 */
7953 8641
 	public function setClientState($state)
7954 8642
 	{
7955 8643
 		$this->_clientState=$state;
@@ -8009,6 +8697,11 @@  discard block
 block discarded – undo
8009 8697
 	{
8010 8698
 		$this->_pagePath=$value;
8011 8699
 	}
8700
+
8701
+	/**
8702
+	 * @param string $context
8703
+	 * @param string $funcName
8704
+	 */
8012 8705
 	public function registerCachingAction($context,$funcName,$funcParams)
8013 8706
 	{
8014 8707
 		if($this->_cachingStack)
@@ -8031,13 +8724,27 @@  discard block
 block discarded – undo
8031 8724
 }
8032 8725
 interface IPageStatePersister
8033 8726
 {
8727
+	/**
8728
+	 * @return TPage
8729
+	 */
8034 8730
 	public function getPage();
8731
+
8732
+	/**
8733
+	 * @return void
8734
+	 */
8035 8735
 	public function setPage(TPage $page);
8736
+
8737
+	/**
8738
+	 * @return void
8739
+	 */
8036 8740
 	public function save($state);
8037 8741
 	public function load();
8038 8742
 }
8039 8743
 class TPageStateFormatter
8040 8744
 {
8745
+	/**
8746
+	 * @param TPage $page
8747
+	 */
8041 8748
 	public static function serialize($page,$data)
8042 8749
 	{
8043 8750
 		$sm=$page->getApplication()->getSecurityManager();
@@ -8051,6 +8758,10 @@  discard block
 block discarded – undo
8051 8758
 			$str=$sm->encrypt($str);
8052 8759
 		return base64_encode($str);
8053 8760
 	}
8761
+
8762
+	/**
8763
+	 * @param TPage $page
8764
+	 */
8054 8765
 	public static function unserialize($page,$data)
8055 8766
 	{
8056 8767
 		$str=base64_decode($data);
@@ -8244,6 +8955,10 @@  discard block
 block discarded – undo
8244 8955
 	{
8245 8956
 		$this->_cacheModuleID=$value;
8246 8957
 	}
8958
+
8959
+	/**
8960
+	 * @param string $value
8961
+	 */
8247 8962
 	public function setCacheKeyPrefix($value)
8248 8963
 	{
8249 8964
 		$this->_keyPrefix=$value;
@@ -8294,10 +9009,18 @@  discard block
 block discarded – undo
8294 9009
 	{
8295 9010
 		$this->_cachePostBack=TPropertyValue::ensureBoolean($value);
8296 9011
 	}
9012
+
9013
+	/**
9014
+	 * @param TOutputCacheCheckDependencyEventParameter $param
9015
+	 */
8297 9016
 	public function onCheckDependency($param)
8298 9017
 	{
8299 9018
 		$this->raiseEvent('OnCheckDependency',$this,$param);
8300 9019
 	}
9020
+
9021
+	/**
9022
+	 * @param TOutputCacheCalculateKeyEventParameter $param
9023
+	 */
8301 9024
 	public function onCalculateKey($param)
8302 9025
 	{
8303 9026
 		$this->raiseEvent('OnCalculateKey',$this,$param);
@@ -8389,6 +9112,10 @@  discard block
 block discarded – undo
8389 9112
 		$tplFile=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$className.self::TEMPLATE_FILE_EXT;
8390 9113
 		return $this->getTemplateByFileName($tplFile);
8391 9114
 	}
9115
+
9116
+	/**
9117
+	 * @param string $fileName
9118
+	 */
8392 9119
 	public function getTemplateByFileName($fileName)
8393 9120
 	{
8394 9121
 		if(($fileName=$this->getLocalizedTemplate($fileName))!==null)
@@ -8428,6 +9155,10 @@  discard block
 block discarded – undo
8428 9155
 		else
8429 9156
 			return null;
8430 9157
 	}
9158
+
9159
+	/**
9160
+	 * @return string
9161
+	 */
8431 9162
 	protected function getLocalizedTemplate($filename)
8432 9163
 	{
8433 9164
 		if(($app=$this->getApplication()->getGlobalization(false))===null)
@@ -8593,12 +9324,20 @@  discard block
 block discarded – undo
8593 9324
 				$parentControl->addParsedObject($control);
8594 9325
 		}
8595 9326
 	}
9327
+
9328
+	/**
9329
+	 * @param TControl $control
9330
+	 */
8596 9331
 	protected function configureControl($control,$name,$value)
8597 9332
 	{
8598 9333
 		if(strncasecmp($name,'on',2)===0)					$this->configureEvent($control,$name,$value,$control);
8599 9334
 		else if(($pos=strrpos($name,'.'))===false)				$this->configureProperty($control,$name,$value);
8600 9335
 		else				$this->configureSubProperty($control,$name,$value);
8601 9336
 	}
9337
+
9338
+	/**
9339
+	 * @param TComponent $component
9340
+	 */
8602 9341
 	protected function configureComponent($component,$name,$value)
8603 9342
 	{
8604 9343
 		if(strpos($name,'.')===false)				$this->configureProperty($component,$name,$value);
@@ -8908,6 +9647,11 @@  discard block
 block discarded – undo
8908 9647
 		$tpl=$objects;
8909 9648
 		return $objects;
8910 9649
 	}
9650
+
9651
+	/**
9652
+	 * @param string $str
9653
+	 * @param string $offset
9654
+	 */
8911 9655
 	protected function parseAttributes($str,$offset)
8912 9656
 	{
8913 9657
 		if($str==='')
@@ -8939,11 +9683,19 @@  discard block
 block discarded – undo
8939 9683
 		}
8940 9684
 		return $attributes;
8941 9685
 	}
9686
+
9687
+	/**
9688
+	 * @param string $content
9689
+	 */
8942 9690
 	protected function parseTemplateProperty($content,$offset)
8943 9691
 	{
8944 9692
 		$line=$this->_startingLine+count(explode("\n",substr($this->_content,0,$offset)))-1;
8945 9693
 		return array(self::CONFIG_TEMPLATE,new TTemplate($content,$this->_contextPath,$this->_tplFile,$line,false));
8946 9694
 	}
9695
+
9696
+	/**
9697
+	 * @param string $value
9698
+	 */
8947 9699
 	protected function parseAttribute($value)
8948 9700
 	{
8949 9701
 		if(($n=preg_match_all('/<%[#=].*?%>/msS',$value,$matches,PREG_OFFSET_CAPTURE))>0)
@@ -9066,6 +9818,11 @@  discard block
 block discarded – undo
9066 9818
 	{
9067 9819
 		return $this->_includedFiles;
9068 9820
 	}
9821
+
9822
+	/**
9823
+	 * @param Exception $e
9824
+	 * @param integer $line
9825
+	 */
9069 9826
 	protected function handleException($e,$line,$input=null)
9070 9827
 	{
9071 9828
 		$srcFile=$this->_tplFile;
@@ -9122,6 +9879,10 @@  discard block
 block discarded – undo
9122 9879
 		}
9123 9880
 		return $input;
9124 9881
 	}
9882
+
9883
+	/**
9884
+	 * @param string $method
9885
+	 */
9125 9886
 	protected function isClassBehaviorMethod(ReflectionClass $class,$method)
9126 9887
 	{
9127 9888
 	  $component=new ReflectionClass('TComponent');
@@ -9204,6 +9965,10 @@  discard block
 block discarded – undo
9204 9965
 				throw new TInvalidDataValueException('thememanager_basepath_invalid',$value);
9205 9966
 		}
9206 9967
 	}
9968
+
9969
+	/**
9970
+	 * @return string
9971
+	 */
9207 9972
 	public function getBaseUrl()
9208 9973
 	{
9209 9974
 		if($this->_baseUrl===null)
@@ -9602,6 +10367,10 @@  discard block
 block discarded – undo
9602 10367
 	{
9603 10368
 		return $this->_defaultPage;
9604 10369
 	}
10370
+
10371
+	/**
10372
+	 * @param string $value
10373
+	 */
9605 10374
 	public function setDefaultPage($value)
9606 10375
 	{
9607 10376
 		if($this->_initialized)
@@ -9690,6 +10459,10 @@  discard block
 block discarded – undo
9690 10459
 			$page->setSubProperty($name,$value);
9691 10460
 		$page->run($this->getResponse()->createHtmlWriter());
9692 10461
 	}
10462
+
10463
+	/**
10464
+	 * @param string $pagePath
10465
+	 */
9693 10466
 	public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true)
9694 10467
 	{
9695 10468
 		return $this->getRequest()->constructUrl($this->getID(),$pagePath,$getParams,$encodeAmpersand,$encodeGetItems);
@@ -9761,11 +10534,20 @@  discard block
 block discarded – undo
9761 10534
 				throw new TConfigurationException('pageserviceconf_file_invalid',$fname);
9762 10535
 		}
9763 10536
 	}
10537
+
10538
+	/**
10539
+	 * @param string $configPath
10540
+	 */
9764 10541
 	public function loadFromPhp($config,$configPath,$configPagePath)
9765 10542
 	{
9766 10543
 		$this->loadApplicationConfigurationFromPhp($config,$configPath);
9767 10544
 		$this->loadPageConfigurationFromPhp($config,$configPath,$configPagePath);
9768 10545
 	}
10546
+
10547
+	/**
10548
+	 * @param TXmlDocument $dom
10549
+	 * @param string $configPath
10550
+	 */
9769 10551
 	public function loadFromXml($dom,$configPath,$configPagePath)
9770 10552
 	{
9771 10553
 		$this->loadApplicationConfigurationFromXml($dom,$configPath);
@@ -9959,6 +10741,10 @@  discard block
 block discarded – undo
9959 10741
 	{
9960 10742
 		return $this->_basePath;
9961 10743
 	}
10744
+
10745
+	/**
10746
+	 * @param string $value
10747
+	 */
9962 10748
 	public function setBasePath($value)
9963 10749
 	{
9964 10750
 		if($this->_initialized)
@@ -9974,6 +10760,10 @@  discard block
 block discarded – undo
9974 10760
 	{
9975 10761
 		return $this->_baseUrl;
9976 10762
 	}
10763
+
10764
+	/**
10765
+	 * @param string $value
10766
+	 */
9977 10767
 	public function setBaseUrl($value)
9978 10768
 	{
9979 10769
 		if($this->_initialized)
@@ -10022,6 +10812,10 @@  discard block
 block discarded – undo
10022 10812
 		else
10023 10813
 			return $this->_basePath.DIRECTORY_SEPARATOR.$this->hash($path);
10024 10814
 	}
10815
+
10816
+	/**
10817
+	 * @param string $path
10818
+	 */
10025 10819
 	public function getPublishedUrl($path)
10026 10820
 	{
10027 10821
 		$path=realpath($path);
@@ -10030,10 +10824,19 @@  discard block
 block discarded – undo
10030 10824
 		else
10031 10825
 			return $this->_baseUrl.'/'.$this->hash($path);
10032 10826
 	}
10827
+
10828
+	/**
10829
+	 * @param string $dir
10830
+	 */
10033 10831
 	protected function hash($dir)
10034 10832
 	{
10035 10833
 		return sprintf('%x',crc32($dir.Prado::getVersion()));
10036 10834
 	}
10835
+
10836
+	/**
10837
+	 * @param string $src
10838
+	 * @param string $dst
10839
+	 */
10037 10840
 	protected function copyFile($src,$dst)
10038 10841
 	{
10039 10842
 		if(!is_dir($dst))
@@ -10047,6 +10850,11 @@  discard block
 block discarded – undo
10047 10850
 			@copy($src,$dstFile);
10048 10851
 		}
10049 10852
 	}
10853
+
10854
+	/**
10855
+	 * @param string $src
10856
+	 * @param string $dst
10857
+	 */
10050 10858
 	public function copyDirectory($src,$dst)
10051 10859
 	{
10052 10860
 		if(!is_dir($dst))
@@ -10076,6 +10884,11 @@  discard block
 block discarded – undo
10076 10884
 			throw new TInvalidDataValueException('assetmanager_source_directory_invalid', $src);
10077 10885
 		}
10078 10886
 	}
10887
+
10888
+	/**
10889
+	 * @param string $tarfile
10890
+	 * @param string $md5sum
10891
+	 */
10079 10892
 	public function publishTarFile($tarfile, $md5sum, $checkTimestamp=false)
10080 10893
 	{
10081 10894
 		if(isset($this->_published[$md5sum]))
@@ -10098,6 +10911,10 @@  discard block
 block discarded – undo
10098 10911
 			return $this->_published[$md5sum]=$this->_baseUrl.'/'.$dir;
10099 10912
 		}
10100 10913
 	}
10914
+
10915
+	/**
10916
+	 * @param string $destination
10917
+	 */
10101 10918
 	protected function deployTarFile($path,$destination)
10102 10919
 	{
10103 10920
 		if(($fullpath=realpath($path))===false || !is_file($fullpath))
@@ -10174,6 +10991,10 @@  discard block
 block discarded – undo
10174 10991
 	{
10175 10992
 		return $this->_charset;
10176 10993
 	}
10994
+
10995
+	/**
10996
+	 * @param string $charset
10997
+	 */
10177 10998
 	public function setCharset($charset)
10178 10999
 	{
10179 11000
 		$this->_charset = $charset;
@@ -10319,6 +11140,10 @@  discard block
 block discarded – undo
10319 11140
 		$this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null));
10320 11141
 		Prado::setPathOfAlias('Application',$this->_basePath);
10321 11142
 	}
11143
+
11144
+	/**
11145
+	 * @param string $basePath
11146
+	 */
10322 11147
 	protected function resolvePaths($basePath)
10323 11148
 	{
10324 11149
 				if(empty($basePath) || ($basePath=realpath($basePath))===false)
@@ -10384,10 +11209,18 @@  discard block
 block discarded – undo
10384 11209
 	{
10385 11210
 		return $this->_requestCompleted;
10386 11211
 	}
11212
+
11213
+	/**
11214
+	 * @param integer $defaultValue
11215
+	 */
10387 11216
 	public function getGlobalState($key,$defaultValue=null)
10388 11217
 	{
10389 11218
 		return isset($this->_globals[$key])?$this->_globals[$key]:$defaultValue;
10390 11219
 	}
11220
+
11221
+	/**
11222
+	 * @param string $key
11223
+	 */
10391 11224
 	public function setGlobalState($key,$value,$defaultValue=null,$forceSave=false)
10392 11225
 	{
10393 11226
 		$this->_stateChanged=true;
@@ -10447,6 +11280,10 @@  discard block
 block discarded – undo
10447 11280
 	{
10448 11281
 		return $this->_basePath;
10449 11282
 	}
11283
+
11284
+	/**
11285
+	 * @param string $value
11286
+	 */
10450 11287
 	public function setBasePath($value)
10451 11288
 	{
10452 11289
 		$this->_basePath=$value;
@@ -10455,6 +11292,10 @@  discard block
 block discarded – undo
10455 11292
 	{
10456 11293
 		return $this->_configFile;
10457 11294
 	}
11295
+
11296
+	/**
11297
+	 * @param string $value
11298
+	 */
10458 11299
 	public function setConfigurationFile($value)
10459 11300
 	{
10460 11301
 		$this->_configFile=$value;
@@ -10463,6 +11304,10 @@  discard block
 block discarded – undo
10463 11304
 	{
10464 11305
 		return $this->_configType;
10465 11306
 	}
11307
+
11308
+	/**
11309
+	 * @param string $value
11310
+	 */
10466 11311
 	public function setConfigurationType($value)
10467 11312
 	{
10468 11313
 		$this->_configType = $value;
@@ -10502,6 +11347,10 @@  discard block
 block discarded – undo
10502 11347
 	{
10503 11348
 		return $this->_runtimePath;
10504 11349
 	}
11350
+
11351
+	/**
11352
+	 * @param string $value
11353
+	 */
10505 11354
 	public function setRuntimePath($value)
10506 11355
 	{
10507 11356
 		$this->_runtimePath=$value;
@@ -10513,6 +11362,10 @@  discard block
 block discarded – undo
10513 11362
 	{
10514 11363
 		return $this->_service;
10515 11364
 	}
11365
+
11366
+	/**
11367
+	 * @param IService $value
11368
+	 */
10516 11369
 	public function setService($value)
10517 11370
 	{
10518 11371
 		$this->_service=$value;
@@ -10793,6 +11646,10 @@  discard block
 block discarded – undo
10793 11646
 		else
10794 11647
 			throw new THttpException(500,'application_service_unknown',$serviceID);
10795 11648
 	}
11649
+
11650
+	/**
11651
+	 * @param Exception $param
11652
+	 */
10796 11653
 	public function onError($param)
10797 11654
 	{
10798 11655
 		Prado::log($param->getMessage(),TLogger::ERROR,'System.TApplication');
Please login to merge, or discard this patch.
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * File Name: pradolite.php
4
- * Last Update: 2015/12/07 15:35:09
5
- * Generated By: buildscripts/phpbuilder/build.php
6
- *
7
- * This file is used in lieu of prado.php to boost PRADO application performance.
8
- * It is generated by expanding prado.php with included files.
9
- * Comments and trace statements are stripped off.
10
- *
11
- * Do not modify this file manually.
12
- */
3
+	 * File Name: pradolite.php
4
+	 * Last Update: 2015/12/07 15:35:09
5
+	 * Generated By: buildscripts/phpbuilder/build.php
6
+	 *
7
+	 * This file is used in lieu of prado.php to boost PRADO application performance.
8
+	 * It is generated by expanding prado.php with included files.
9
+	 * Comments and trace statements are stripped off.
10
+	 *
11
+	 * Do not modify this file manually.
12
+	 */
13 13
 
14 14
 if(!defined('PRADO_DIR'))
15 15
 	define('PRADO_DIR',dirname(__FILE__));
@@ -4203,10 +4203,10 @@  discard block
 block discarded – undo
4203 4203
 		{
4204 4204
 			$value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode');
4205 4205
 			if($value===THttpSessionCookieMode::None) 
4206
-      {
4206
+	  {
4207 4207
 				ini_set('session.use_cookies','0');
4208 4208
 			  ini_set('session.use_only_cookies','0');
4209
-      }
4209
+	  }
4210 4210
 			else if($value===THttpSessionCookieMode::Allow)
4211 4211
 			{
4212 4212
 				ini_set('session.use_cookies','1');
@@ -6805,77 +6805,77 @@  discard block
 block discarded – undo
6805 6805
 			throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this));
6806 6806
 		parent::initRecursive($namingContainer);
6807 6807
 	}
6808
-        public function tryToUpdateView($arObj, $throwExceptions = false)
6809
-        {
6810
-                $objAttrs = get_class_vars(get_class($arObj));
6811
-                foreach (array_keys($objAttrs) as $key)
6812
-                {
6813
-                        try
6814
-                        {
6815
-                                if ($key != "RELATIONS")
6816
-                                {
6817
-                                        $control = $this->{$key};
6818
-                                        if ($control instanceof TTextBox)
6819
-                                                $control->Text = $arObj->{$key};
6820
-                                        elseif ($control instanceof TCheckBox)
6821
-                                                $control->Checked = (boolean) $arObj->{$key};
6822
-                                        elseif ($control instanceof TDatePicker)
6823
-                                                $control->Date = $arObj->{$key};
6824
-                                }
6825
-                                else
6826
-                                {
6827
-                                        foreach ($objAttrs["RELATIONS"] as $relKey => $relValues)
6828
-                                        {
6829
-                                                $relControl = $this->{$relKey};
6830
-                                                switch ($relValues[0])
6831
-                                                {
6832
-                                                        case TActiveRecord::BELONGS_TO:
6833
-                                                        case TActiveRecord::HAS_ONE:
6834
-                                                                $relControl->Text = $arObj->{$relKey};
6835
-                                                                break;
6836
-                                                        case TActiveRecord::HAS_MANY:
6837
-                                                                if ($relControl instanceof TListControl)
6838
-                                                                {
6839
-                                                                        $relControl->DataSource = $arObj->{$relKey};
6840
-                                                                        $relControl->dataBind();
6841
-                                                                }
6842
-                                                                break;
6843
-                                                }
6844
-                                        }
6845
-                                        break;
6846
-                                }
6847
-                        } 
6848
-                        catch (Exception $ex)
6849
-                        {
6850
-                                if ($throwExceptions)
6851
-                                        throw $ex;
6852
-                        }
6853
-                }
6854
-        }
6855
-        public function tryToUpdateAR($arObj, $throwExceptions = false)
6856
-        {
6857
-                $objAttrs = get_class_vars(get_class($arObj));
6858
-                foreach (array_keys($objAttrs) as $key)
6859
-                {
6860
-                        try
6861
-                        {
6862
-                                if ($key == "RELATIONS")
6863
-                                        break;
6864
-                                $control = $this->{$key};
6865
-                                if ($control instanceof TTextBox)
6866
-                                        $arObj->{$key} = $control->Text;
6867
-                                elseif ($control instanceof TCheckBox)
6868
-                                        $arObj->{$key} = $control->Checked;
6869
-                                elseif ($control instanceof TDatePicker)
6870
-                                        $arObj->{$key} = $control->Date;
6871
-                        } 
6872
-                        catch (Exception $ex)
6873
-                        {
6874
-                                if ($throwExceptions)
6875
-                                        throw $ex;
6876
-                        }
6877
-                }
6878
-        }
6808
+		public function tryToUpdateView($arObj, $throwExceptions = false)
6809
+		{
6810
+				$objAttrs = get_class_vars(get_class($arObj));
6811
+				foreach (array_keys($objAttrs) as $key)
6812
+				{
6813
+						try
6814
+						{
6815
+								if ($key != "RELATIONS")
6816
+								{
6817
+										$control = $this->{$key};
6818
+										if ($control instanceof TTextBox)
6819
+												$control->Text = $arObj->{$key};
6820
+										elseif ($control instanceof TCheckBox)
6821
+												$control->Checked = (boolean) $arObj->{$key};
6822
+										elseif ($control instanceof TDatePicker)
6823
+												$control->Date = $arObj->{$key};
6824
+								}
6825
+								else
6826
+								{
6827
+										foreach ($objAttrs["RELATIONS"] as $relKey => $relValues)
6828
+										{
6829
+												$relControl = $this->{$relKey};
6830
+												switch ($relValues[0])
6831
+												{
6832
+														case TActiveRecord::BELONGS_TO:
6833
+														case TActiveRecord::HAS_ONE:
6834
+																$relControl->Text = $arObj->{$relKey};
6835
+																break;
6836
+														case TActiveRecord::HAS_MANY:
6837
+																if ($relControl instanceof TListControl)
6838
+																{
6839
+																		$relControl->DataSource = $arObj->{$relKey};
6840
+																		$relControl->dataBind();
6841
+																}
6842
+																break;
6843
+												}
6844
+										}
6845
+										break;
6846
+								}
6847
+						} 
6848
+						catch (Exception $ex)
6849
+						{
6850
+								if ($throwExceptions)
6851
+										throw $ex;
6852
+						}
6853
+				}
6854
+		}
6855
+		public function tryToUpdateAR($arObj, $throwExceptions = false)
6856
+		{
6857
+				$objAttrs = get_class_vars(get_class($arObj));
6858
+				foreach (array_keys($objAttrs) as $key)
6859
+				{
6860
+						try
6861
+						{
6862
+								if ($key == "RELATIONS")
6863
+										break;
6864
+								$control = $this->{$key};
6865
+								if ($control instanceof TTextBox)
6866
+										$arObj->{$key} = $control->Text;
6867
+								elseif ($control instanceof TCheckBox)
6868
+										$arObj->{$key} = $control->Checked;
6869
+								elseif ($control instanceof TDatePicker)
6870
+										$arObj->{$key} = $control->Date;
6871
+						} 
6872
+						catch (Exception $ex)
6873
+						{
6874
+								if ($throwExceptions)
6875
+										throw $ex;
6876
+						}
6877
+				}
6878
+		}
6879 6879
 }
6880 6880
 class TForm extends TControl
6881 6881
 {
@@ -7536,13 +7536,13 @@  discard block
 block discarded – undo
7536 7536
 	{
7537 7537
 		Prado::using('System.Web.UI.ActiveControls.TActivePageAdapter');
7538 7538
 		$this->setAdapter(new TActivePageAdapter($this));
7539
-        $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER);
7540
-        if(strlen($callbackEventParameter) > 0)
7541
-            $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter);
7542
-                if (($g=$this->getApplication()->getGlobalization(false))!==null &&
7543
-            strtoupper($enc=$g->getCharset())!='UTF-8')
7544
-                foreach ($this->_postData as $k=>$v)
7545
-                	$this->_postData[$k]=self::decodeUTF8($v, $enc);
7539
+		$callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER);
7540
+		if(strlen($callbackEventParameter) > 0)
7541
+			$this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter);
7542
+				if (($g=$this->getApplication()->getGlobalization(false))!==null &&
7543
+			strtoupper($enc=$g->getCharset())!='UTF-8')
7544
+				foreach ($this->_postData as $k=>$v)
7545
+					$this->_postData[$k]=self::decodeUTF8($v, $enc);
7546 7546
 		$this->onPreInit(null);
7547 7547
 		$this->initRecursive();
7548 7548
 		$this->onInitComplete(null);
@@ -9127,15 +9127,15 @@  discard block
 block discarded – undo
9127 9127
 	  $component=new ReflectionClass('TComponent');
9128 9128
 	  $behaviors=$component->getStaticProperties();
9129 9129
 	  if(!isset($behaviors['_um']))
9130
-	    return false;
9130
+		return false;
9131 9131
 	  foreach($behaviors['_um'] as $name=>$list)
9132 9132
 	  {
9133
-	    if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue;
9134
-	    foreach($list as $param)
9135
-	    {
9136
-	      if(method_exists($param->getBehavior(),$method))
9137
-	        return true;
9138
-	    }
9133
+		if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue;
9134
+		foreach($list as $param)
9135
+		{
9136
+		  if(method_exists($param->getBehavior(),$method))
9137
+			return true;
9138
+		}
9139 9139
 	  }
9140 9140
 	  return false;
9141 9141
 	}
Please login to merge, or discard this patch.
Spacing   +3777 added lines, -3777 removed lines patch added patch discarded remove patch
@@ -11,17 +11,17 @@  discard block
 block discarded – undo
11 11
  * Do not modify this file manually.
12 12
  */
13 13
 
14
-if(!defined('PRADO_DIR'))
15
-	define('PRADO_DIR',dirname(__FILE__));
16
-if(!defined('PRADO_CHMOD'))
17
-	define('PRADO_CHMOD',0777);
14
+if (!defined('PRADO_DIR'))
15
+	define('PRADO_DIR', dirname(__FILE__));
16
+if (!defined('PRADO_CHMOD'))
17
+	define('PRADO_CHMOD', 0777);
18 18
 class PradoBase
19 19
 {
20
-	const CLASS_FILE_EXT='.php';
21
-	private static $_aliases=array('System'=>PRADO_DIR);
22
-	private static $_usings=array();
23
-	private static $_application=null;
24
-	private static $_logger=null;
20
+	const CLASS_FILE_EXT = '.php';
21
+	private static $_aliases = array('System'=>PRADO_DIR);
22
+	private static $_usings = array();
23
+	private static $_application = null;
24
+	private static $_logger = null;
25 25
 	protected static $classExists = array();
26 26
 	public static function getVersion()
27 27
 	{
@@ -29,37 +29,37 @@  discard block
 block discarded – undo
29 29
 	}
30 30
 	public static function initErrorHandlers()
31 31
 	{
32
-		set_error_handler(array('PradoBase','phpErrorHandler'));
33
-		set_exception_handler(array('PradoBase','exceptionHandler'));
32
+		set_error_handler(array('PradoBase', 'phpErrorHandler'));
33
+		set_exception_handler(array('PradoBase', 'exceptionHandler'));
34 34
 	}
35 35
 	public static function autoload($className)
36 36
 	{
37
-		include_once($className.self::CLASS_FILE_EXT);
38
-		if(!class_exists($className,false) && !interface_exists($className,false))
37
+		include_once($className . self::CLASS_FILE_EXT);
38
+		if (!class_exists($className, false) && !interface_exists($className, false))
39 39
 			self::fatalError("Class file for '$className' cannot be found.");
40 40
 	}
41
-	public static function poweredByPrado($logoType=0)
41
+	public static function poweredByPrado($logoType = 0)
42 42
 	{
43
-		$logoName=$logoType==1?'powered2':'powered';
44
-		if(self::$_application!==null)
43
+		$logoName = $logoType == 1 ? 'powered2' : 'powered';
44
+		if (self::$_application !== null)
45 45
 		{
46
-			$am=self::$_application->getAssetManager();
47
-			$url=$am->publishFilePath(self::getPathOfNamespace('System.'.$logoName,'.gif'));
46
+			$am = self::$_application->getAssetManager();
47
+			$url = $am->publishFilePath(self::getPathOfNamespace('System.' . $logoName, '.gif'));
48 48
 		}
49 49
 		else
50
-			$url='http://pradosoft.github.io/docs/'.$logoName.'.gif';
51
-		return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="'.$url.'" style="border-width:0px;" alt="Powered by PRADO" /></a>';
50
+			$url = 'http://pradosoft.github.io/docs/' . $logoName . '.gif';
51
+		return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="' . $url . '" style="border-width:0px;" alt="Powered by PRADO" /></a>';
52 52
 	}
53
-	public static function phpErrorHandler($errno,$errstr,$errfile,$errline)
53
+	public static function phpErrorHandler($errno, $errstr, $errfile, $errline)
54 54
 	{
55
-		if(error_reporting() & $errno)
56
-			throw new TPhpErrorException($errno,$errstr,$errfile,$errline);
55
+		if (error_reporting() & $errno)
56
+			throw new TPhpErrorException($errno, $errstr, $errfile, $errline);
57 57
 	}
58 58
 	public static function exceptionHandler($exception)
59 59
 	{
60
-		if(self::$_application!==null && ($errorHandler=self::$_application->getErrorHandler())!==null)
60
+		if (self::$_application !== null && ($errorHandler = self::$_application->getErrorHandler()) !== null)
61 61
 		{
62
-			$errorHandler->handleError(null,$exception);
62
+			$errorHandler->handleError(null, $exception);
63 63
 		}
64 64
 		else
65 65
 		{
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	}
70 70
 	public static function setApplication($application)
71 71
 	{
72
-		if(self::$_application!==null && !defined('PRADO_TEST_RUN'))
72
+		if (self::$_application !== null && !defined('PRADO_TEST_RUN'))
73 73
 			throw new TInvalidOperationException('prado_application_singleton_required');
74
-		self::$_application=$application;
74
+		self::$_application = $application;
75 75
 	}
76 76
 	public static function getApplication()
77 77
 	{
@@ -83,18 +83,18 @@  discard block
 block discarded – undo
83 83
 	}
84 84
 	public static function createComponent($type)
85 85
 	{
86
-		if(!isset(self::$classExists[$type]))
86
+		if (!isset(self::$classExists[$type]))
87 87
 			self::$classExists[$type] = class_exists($type, false);
88
-		if( !isset(self::$_usings[$type]) && !self::$classExists[$type]) {
88
+		if (!isset(self::$_usings[$type]) && !self::$classExists[$type]) {
89 89
 			self::using($type);
90 90
 			self::$classExists[$type] = class_exists($type, false);
91 91
 		}
92
-		if( ($pos = strrpos($type, '.')) !== false)
93
-			$type = substr($type,$pos+1);
94
-		if(($n=func_num_args())>1)
92
+		if (($pos = strrpos($type, '.')) !== false)
93
+			$type = substr($type, $pos + 1);
94
+		if (($n = func_num_args()) > 1)
95 95
 		{
96 96
 			$args = func_get_args();
97
-			switch($n) {
97
+			switch ($n) {
98 98
 				case 2:
99 99
 					return new $type($args[1]);
100 100
 				break;
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 					return new $type($args[1], $args[2], $args[3], $args[4]);
109 109
 				break;
110 110
 				default:
111
-					$s='$args[1]';
112
-					for($i=2;$i<$n;++$i)
113
-						$s.=",\$args[$i]";
111
+					$s = '$args[1]';
112
+					for ($i = 2; $i < $n; ++$i)
113
+						$s .= ",\$args[$i]";
114 114
 					eval("\$component=new $type($s);");
115 115
 					return $component;
116 116
 				break;
@@ -119,42 +119,42 @@  discard block
 block discarded – undo
119 119
 		else
120 120
 			return new $type;
121 121
 	}
122
-	public static function using($namespace,$checkClassExistence=true)
122
+	public static function using($namespace, $checkClassExistence = true)
123 123
 	{
124
-		if(isset(self::$_usings[$namespace]) || class_exists($namespace,false))
124
+		if (isset(self::$_usings[$namespace]) || class_exists($namespace, false))
125 125
 			return;
126
-		if(($pos=strrpos($namespace,'.'))===false)  		{
126
+		if (($pos = strrpos($namespace, '.')) === false) {
127 127
 			try
128 128
 			{
129
-				include_once($namespace.self::CLASS_FILE_EXT);
129
+				include_once($namespace . self::CLASS_FILE_EXT);
130 130
 			}
131
-			catch(Exception $e)
131
+			catch (Exception $e)
132 132
 			{
133
-				if($checkClassExistence && !class_exists($namespace,false))
134
-					throw new TInvalidOperationException('prado_component_unknown',$namespace,$e->getMessage());
133
+				if ($checkClassExistence && !class_exists($namespace, false))
134
+					throw new TInvalidOperationException('prado_component_unknown', $namespace, $e->getMessage());
135 135
 				else
136 136
 					throw $e;
137 137
 			}
138 138
 		}
139
-		else if(($path=self::getPathOfNamespace($namespace,self::CLASS_FILE_EXT))!==null)
139
+		else if (($path = self::getPathOfNamespace($namespace, self::CLASS_FILE_EXT)) !== null)
140 140
 		{
141
-			$className=substr($namespace,$pos+1);
142
-			if($className==='*')  			{
143
-				self::$_usings[$namespace]=$path;
144
-				set_include_path(get_include_path().PATH_SEPARATOR.$path);
141
+			$className = substr($namespace, $pos + 1);
142
+			if ($className === '*') {
143
+				self::$_usings[$namespace] = $path;
144
+				set_include_path(get_include_path() . PATH_SEPARATOR . $path);
145 145
 			}
146
-			else  			{
147
-				self::$_usings[$namespace]=$path;
148
-				if(!$checkClassExistence || !class_exists($className,false))
146
+			else {
147
+				self::$_usings[$namespace] = $path;
148
+				if (!$checkClassExistence || !class_exists($className, false))
149 149
 				{
150 150
 					try
151 151
 					{
152 152
 						include_once($path);
153 153
 					}
154
-					catch(Exception $e)
154
+					catch (Exception $e)
155 155
 					{
156
-						if($checkClassExistence && !class_exists($className,false))
157
-							throw new TInvalidOperationException('prado_component_unknown',$className,$e->getMessage());
156
+						if ($checkClassExistence && !class_exists($className, false))
157
+							throw new TInvalidOperationException('prado_component_unknown', $className, $e->getMessage());
158 158
 						else
159 159
 							throw $e;
160 160
 					}
@@ -162,77 +162,77 @@  discard block
 block discarded – undo
162 162
 			}
163 163
 		}
164 164
 		else
165
-			throw new TInvalidDataValueException('prado_using_invalid',$namespace);
165
+			throw new TInvalidDataValueException('prado_using_invalid', $namespace);
166 166
 	}
167
-	public static function getPathOfNamespace($namespace, $ext='')
167
+	public static function getPathOfNamespace($namespace, $ext = '')
168 168
 	{
169
-		if(self::CLASS_FILE_EXT === $ext || empty($ext))
169
+		if (self::CLASS_FILE_EXT === $ext || empty($ext))
170 170
 		{
171
-			if(isset(self::$_usings[$namespace]))
171
+			if (isset(self::$_usings[$namespace]))
172 172
 				return self::$_usings[$namespace];
173
-			if(isset(self::$_aliases[$namespace]))
173
+			if (isset(self::$_aliases[$namespace]))
174 174
 				return self::$_aliases[$namespace];
175 175
 		}
176
-		$segs = explode('.',$namespace);
176
+		$segs = explode('.', $namespace);
177 177
 		$alias = array_shift($segs);
178
-		if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias)))
179
-			return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR ,$segs),'/\\').(($file === '*') ? '' : DIRECTORY_SEPARATOR.$file.$ext);
178
+		if (null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias)))
179
+			return rtrim($root . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $segs), '/\\') . (($file === '*') ? '' : DIRECTORY_SEPARATOR . $file . $ext);
180 180
 		return null;
181 181
 	}
182 182
 	public static function getPathOfAlias($alias)
183 183
 	{
184
-		return isset(self::$_aliases[$alias])?self::$_aliases[$alias]:null;
184
+		return isset(self::$_aliases[$alias]) ? self::$_aliases[$alias] : null;
185 185
 	}
186 186
 	protected static function getPathAliases()
187 187
 	{
188 188
 		return self::$_aliases;
189 189
 	}
190
-	public static function setPathOfAlias($alias,$path)
190
+	public static function setPathOfAlias($alias, $path)
191 191
 	{
192
-		if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN'))
193
-			throw new TInvalidOperationException('prado_alias_redefined',$alias);
194
-		else if(($rp=realpath($path))!==false && is_dir($rp))
192
+		if (isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN'))
193
+			throw new TInvalidOperationException('prado_alias_redefined', $alias);
194
+		else if (($rp = realpath($path)) !== false && is_dir($rp))
195 195
 		{
196
-			if(strpos($alias,'.')===false)
197
-				self::$_aliases[$alias]=$rp;
196
+			if (strpos($alias, '.') === false)
197
+				self::$_aliases[$alias] = $rp;
198 198
 			else
199
-				throw new TInvalidDataValueException('prado_aliasname_invalid',$alias);
199
+				throw new TInvalidDataValueException('prado_aliasname_invalid', $alias);
200 200
 		}
201 201
 		else
202
-			throw new TInvalidDataValueException('prado_alias_invalid',$alias,$path);
202
+			throw new TInvalidDataValueException('prado_alias_invalid', $alias, $path);
203 203
 	}
204 204
 	public static function fatalError($msg)
205 205
 	{
206 206
 		echo '<h1>Fatal Error</h1>';
207
-		echo '<p>'.$msg.'</p>';
208
-		if(!function_exists('debug_backtrace'))
207
+		echo '<p>' . $msg . '</p>';
208
+		if (!function_exists('debug_backtrace'))
209 209
 			return;
210 210
 		echo '<h2>Debug Backtrace</h2>';
211 211
 		echo '<pre>';
212
-		$index=-1;
213
-		foreach(debug_backtrace() as $t)
212
+		$index = -1;
213
+		foreach (debug_backtrace() as $t)
214 214
 		{
215 215
 			$index++;
216
-			if($index==0)  				continue;
217
-			echo '#'.$index.' ';
218
-			if(isset($t['file']))
216
+			if ($index == 0)  				continue;
217
+			echo '#' . $index . ' ';
218
+			if (isset($t['file']))
219 219
 				echo basename($t['file']) . ':' . $t['line'];
220 220
 			else
221 221
 				 echo '<PHP inner-code>';
222 222
 			echo ' -- ';
223
-			if(isset($t['class']))
223
+			if (isset($t['class']))
224 224
 				echo $t['class'] . $t['type'];
225 225
 			echo $t['function'] . '(';
226
-			if(isset($t['args']) && sizeof($t['args']) > 0)
226
+			if (isset($t['args']) && sizeof($t['args']) > 0)
227 227
 			{
228
-				$count=0;
229
-				foreach($t['args'] as $item)
228
+				$count = 0;
229
+				foreach ($t['args'] as $item)
230 230
 				{
231
-					if(is_string($item))
231
+					if (is_string($item))
232 232
 					{
233
-						$str=htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES);
233
+						$str = htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES);
234 234
 						if (strlen($item) > 70)
235
-							echo "'". substr($str, 0, 70) . "...'";
235
+							echo "'" . substr($str, 0, 70) . "...'";
236 236
 						else
237 237
 							echo "'" . $str . "'";
238 238
 					}
@@ -260,102 +260,102 @@  discard block
 block discarded – undo
260 260
 	}
261 261
 	public static function getUserLanguages()
262 262
 	{
263
-		static $languages=null;
264
-		if($languages===null)
263
+		static $languages = null;
264
+		if ($languages === null)
265 265
 		{
266
-			if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
267
-				$languages[0]='en';
266
+			if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
267
+				$languages[0] = 'en';
268 268
 			else
269 269
 			{
270
-				$languages=array();
271
-				foreach(explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language)
270
+				$languages = array();
271
+				foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language)
272 272
 				{
273
-					$array=explode(';q=',trim($language));
274
-					$languages[trim($array[0])]=isset($array[1])?(float)$array[1]:1.0;
273
+					$array = explode(';q=', trim($language));
274
+					$languages[trim($array[0])] = isset($array[1]) ? (float) $array[1] : 1.0;
275 275
 				}
276 276
 				arsort($languages);
277
-				$languages=array_keys($languages);
278
-				if(empty($languages))
279
-					$languages[0]='en';
277
+				$languages = array_keys($languages);
278
+				if (empty($languages))
279
+					$languages[0] = 'en';
280 280
 			}
281 281
 		}
282 282
 		return $languages;
283 283
 	}
284 284
 	public static function getPreferredLanguage()
285 285
 	{
286
-		static $language=null;
287
-		if($language===null)
286
+		static $language = null;
287
+		if ($language === null)
288 288
 		{
289
-			$langs=Prado::getUserLanguages();
290
-			$lang=explode('-',$langs[0]);
291
-			if(empty($lang[0]) || !ctype_alpha($lang[0]))
292
-				$language='en';
289
+			$langs = Prado::getUserLanguages();
290
+			$lang = explode('-', $langs[0]);
291
+			if (empty($lang[0]) || !ctype_alpha($lang[0]))
292
+				$language = 'en';
293 293
 			else
294
-				$language=$lang[0];
294
+				$language = $lang[0];
295 295
 		}
296 296
 		return $language;
297 297
 	}
298
-	public static function trace($msg,$category='Uncategorized',$ctl=null)
298
+	public static function trace($msg, $category = 'Uncategorized', $ctl = null)
299 299
 	{
300
-		if(self::$_application && self::$_application->getMode()===TApplicationMode::Performance)
300
+		if (self::$_application && self::$_application->getMode() === TApplicationMode::Performance)
301 301
 			return;
302
-		if(!self::$_application || self::$_application->getMode()===TApplicationMode::Debug)
302
+		if (!self::$_application || self::$_application->getMode() === TApplicationMode::Debug)
303 303
 		{
304
-			$trace=debug_backtrace();
305
-			if(isset($trace[0]['file']) && isset($trace[0]['line']))
306
-				$msg.=" (line {$trace[0]['line']}, {$trace[0]['file']})";
307
-			$level=TLogger::DEBUG;
304
+			$trace = debug_backtrace();
305
+			if (isset($trace[0]['file']) && isset($trace[0]['line']))
306
+				$msg .= " (line {$trace[0]['line']}, {$trace[0]['file']})";
307
+			$level = TLogger::DEBUG;
308 308
 		}
309 309
 		else
310
-			$level=TLogger::INFO;
311
-		self::log($msg,$level,$category,$ctl);
310
+			$level = TLogger::INFO;
311
+		self::log($msg, $level, $category, $ctl);
312 312
 	}
313
-	public static function log($msg,$level=TLogger::INFO,$category='Uncategorized',$ctl=null)
313
+	public static function log($msg, $level = TLogger::INFO, $category = 'Uncategorized', $ctl = null)
314 314
 	{
315
-		if(self::$_logger===null)
316
-			self::$_logger=new TLogger;
317
-		self::$_logger->log($msg,$level,$category,$ctl);
315
+		if (self::$_logger === null)
316
+			self::$_logger = new TLogger;
317
+		self::$_logger->log($msg, $level, $category, $ctl);
318 318
 	}
319 319
 	public static function getLogger()
320 320
 	{
321
-		if(self::$_logger===null)
322
-			self::$_logger=new TLogger;
321
+		if (self::$_logger === null)
322
+			self::$_logger = new TLogger;
323 323
 		return self::$_logger;
324 324
 	}
325
-	public static function varDump($var,$depth=10,$highlight=false)
325
+	public static function varDump($var, $depth = 10, $highlight = false)
326 326
 	{
327 327
 		Prado::using('System.Util.TVarDumper');
328
-		return TVarDumper::dump($var,$depth,$highlight);
328
+		return TVarDumper::dump($var, $depth, $highlight);
329 329
 	}
330
-	public static function localize($text, $parameters=array(), $catalogue=null, $charset=null)
330
+	public static function localize($text, $parameters = array(), $catalogue = null, $charset = null)
331 331
 	{
332 332
 		Prado::using('System.I18N.Translation');
333 333
 		$app = Prado::getApplication()->getGlobalization(false);
334 334
 		$params = array();
335
-		foreach($parameters as $key => $value)
336
-			$params['{'.$key.'}'] = $value;
337
-				if($app===null || ($config = $app->getTranslationConfiguration())===null)
335
+		foreach ($parameters as $key => $value)
336
+			$params['{' . $key . '}'] = $value;
337
+				if ($app === null || ($config = $app->getTranslationConfiguration()) === null)
338 338
 			return strtr($text, $params);
339
-		if ($catalogue===null)
340
-			$catalogue=isset($config['catalogue'])?$config['catalogue']:'messages';
339
+		if ($catalogue === null)
340
+			$catalogue = isset($config['catalogue']) ? $config['catalogue'] : 'messages';
341 341
 		Translation::init($catalogue);
342
-				$appCharset = $app===null ? '' : $app->getCharset();
343
-				$defaultCharset = ($app===null) ? 'UTF-8' : $app->getDefaultCharset();
344
-				if(empty($charset)) $charset = $appCharset;
345
-		if(empty($charset)) $charset = $defaultCharset;
346
-		return Translation::formatter($catalogue)->format($text,$params,$catalogue,$charset);
342
+				$appCharset = $app === null ? '' : $app->getCharset();
343
+				$defaultCharset = ($app === null) ? 'UTF-8' : $app->getDefaultCharset();
344
+				if (empty($charset)) $charset = $appCharset;
345
+		if (empty($charset)) $charset = $defaultCharset;
346
+		return Translation::formatter($catalogue)->format($text, $params, $catalogue, $charset);
347 347
 	}
348 348
 }
349 349
 PradoBase::using('System.TComponent');
350 350
 PradoBase::using('System.Exceptions.TException');
351 351
 PradoBase::using('System.Util.TLogger');
352
-if(!class_exists('Prado',false))
352
+if (!class_exists('Prado', false))
353 353
 {
354 354
 	class Prado extends PradoBase
355 355
 	{
356 356
 	}
357 357
 }
358
-spl_autoload_register(array('Prado','autoload'));
358
+spl_autoload_register(array('Prado', 'autoload'));
359 359
 Prado::initErrorHandlers();
360 360
 interface IModule
361 361
 {
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
 interface ICache
398 398
 {
399 399
 	public function get($id);
400
-	public function set($id,$value,$expire=0,$dependency=null);
401
-	public function add($id,$value,$expire=0,$dependency=null);
400
+	public function set($id, $value, $expire = 0, $dependency = null);
401
+	public function add($id, $value, $expire = 0, $dependency = null);
402 402
 	public function delete($id);
403 403
 	public function flush();
404 404
 }
@@ -459,15 +459,15 @@  discard block
 block discarded – undo
459 459
 	{
460 460
 		return Prado::getApplication()->getUser();
461 461
 	}
462
-	public function publishAsset($assetPath,$className=null)
462
+	public function publishAsset($assetPath, $className = null)
463 463
 	{
464
-		if($className===null)
465
-			$className=get_class($this);
466
-		$class=new ReflectionClass($className);
467
-		$fullPath=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$assetPath;
464
+		if ($className === null)
465
+			$className = get_class($this);
466
+		$class = new ReflectionClass($className);
467
+		$fullPath = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $assetPath;
468 468
 		return $this->publishFilePath($fullPath);
469 469
 	}
470
-	public function publishFilePath($fullPath, $checkTimestamp=false)
470
+	public function publishFilePath($fullPath, $checkTimestamp = false)
471 471
 	{
472 472
 		return Prado::getApplication()->getAssetManager()->publishFilePath($fullPath, $checkTimestamp);
473 473
 	}
@@ -484,13 +484,13 @@  discard block
 block discarded – undo
484 484
 	}
485 485
 	public function setID($value)
486 486
 	{
487
-		$this->_id=$value;
487
+		$this->_id = $value;
488 488
 	}
489 489
 }
490 490
 abstract class TService extends TApplicationComponent implements IService
491 491
 {
492 492
 	private $_id;
493
-	private $_enabled=true;
493
+	private $_enabled = true;
494 494
 	public function init($config)
495 495
 	{
496 496
 	}
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 	}
501 501
 	public function setID($value)
502 502
 	{
503
-		$this->_id=$value;
503
+		$this->_id = $value;
504 504
 	}
505 505
 	public function getEnabled()
506 506
 	{
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 	}
509 509
 	public function setEnabled($value)
510 510
 	{
511
-		$this->_enabled=TPropertyValue::ensureBoolean($value);
511
+		$this->_enabled = TPropertyValue::ensureBoolean($value);
512 512
 	}
513 513
 	public function run()
514 514
 	{
@@ -516,239 +516,239 @@  discard block
 block discarded – undo
516 516
 }
517 517
 class TErrorHandler extends TModule
518 518
 {
519
-	const ERROR_FILE_NAME='error';
520
-	const EXCEPTION_FILE_NAME='exception';
521
-	const SOURCE_LINES=12;
522
-	private $_templatePath=null;
519
+	const ERROR_FILE_NAME = 'error';
520
+	const EXCEPTION_FILE_NAME = 'exception';
521
+	const SOURCE_LINES = 12;
522
+	private $_templatePath = null;
523 523
 	public function init($config)
524 524
 	{
525 525
 		$this->getApplication()->setErrorHandler($this);
526 526
 	}
527 527
 	public function getErrorTemplatePath()
528 528
 	{
529
-		if($this->_templatePath===null)
530
-			$this->_templatePath=Prado::getFrameworkPath().'/Exceptions/templates';
529
+		if ($this->_templatePath === null)
530
+			$this->_templatePath = Prado::getFrameworkPath() . '/Exceptions/templates';
531 531
 		return $this->_templatePath;
532 532
 	}
533 533
 	public function setErrorTemplatePath($value)
534 534
 	{
535
-		if(($templatePath=Prado::getPathOfNamespace($value))!==null && is_dir($templatePath))
536
-			$this->_templatePath=$templatePath;
535
+		if (($templatePath = Prado::getPathOfNamespace($value)) !== null && is_dir($templatePath))
536
+			$this->_templatePath = $templatePath;
537 537
 		else
538
-			throw new TConfigurationException('errorhandler_errortemplatepath_invalid',$value);
538
+			throw new TConfigurationException('errorhandler_errortemplatepath_invalid', $value);
539 539
 	}
540
-	public function handleError($sender,$param)
540
+	public function handleError($sender, $param)
541 541
 	{
542
-		static $handling=false;
542
+		static $handling = false;
543 543
 								restore_error_handler();
544 544
 		restore_exception_handler();
545
-				if($handling)
545
+				if ($handling)
546 546
 			$this->handleRecursiveError($param);
547 547
 		else
548 548
 		{
549
-			$handling=true;
550
-			if(($response=$this->getResponse())!==null)
549
+			$handling = true;
550
+			if (($response = $this->getResponse()) !== null)
551 551
 				$response->clear();
552
-			if(!headers_sent())
552
+			if (!headers_sent())
553 553
 				header('Content-Type: text/html; charset=UTF-8');
554
-			if($param instanceof THttpException)
555
-				$this->handleExternalError($param->getStatusCode(),$param);
556
-			else if($this->getApplication()->getMode()===TApplicationMode::Debug)
554
+			if ($param instanceof THttpException)
555
+				$this->handleExternalError($param->getStatusCode(), $param);
556
+			else if ($this->getApplication()->getMode() === TApplicationMode::Debug)
557 557
 				$this->displayException($param);
558 558
 			else
559
-				$this->handleExternalError(500,$param);
559
+				$this->handleExternalError(500, $param);
560 560
 		}
561 561
 	}
562
-	protected static function hideSecurityRelated($value, $exception=null)
562
+	protected static function hideSecurityRelated($value, $exception = null)
563 563
 	{
564 564
 		$aRpl = array();
565
-		if($exception !== null && $exception instanceof Exception)
565
+		if ($exception !== null && $exception instanceof Exception)
566 566
 		{
567 567
 			$aTrace = $exception->getTrace();
568
-			foreach($aTrace as $item)
568
+			foreach ($aTrace as $item)
569 569
 			{
570
-				if(isset($item['file']))
570
+				if (isset($item['file']))
571 571
 					$aRpl[dirname($item['file']) . DIRECTORY_SEPARATOR] = '<hidden>' . DIRECTORY_SEPARATOR;
572 572
 			}
573 573
 		}
574 574
 		$aRpl[$_SERVER['DOCUMENT_ROOT']] = '${DocumentRoot}';
575 575
 		$aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])] = '${DocumentRoot}';
576 576
 		$aRpl[PRADO_DIR . DIRECTORY_SEPARATOR] = '${PradoFramework}' . DIRECTORY_SEPARATOR;
577
-		if(isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]);
577
+		if (isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]);
578 578
 		$aRpl = array_reverse($aRpl, true);
579 579
 		return str_replace(array_keys($aRpl), $aRpl, $value);
580 580
 	}
581
-	protected function handleExternalError($statusCode,$exception)
581
+	protected function handleExternalError($statusCode, $exception)
582 582
 	{
583
-		if(!($exception instanceof THttpException))
583
+		if (!($exception instanceof THttpException))
584 584
 			error_log($exception->__toString());
585
-		$content=$this->getErrorTemplate($statusCode,$exception);
586
-		$serverAdmin=isset($_SERVER['SERVER_ADMIN'])?$_SERVER['SERVER_ADMIN']:'';
587
-		$isDebug = $this->getApplication()->getMode()===TApplicationMode::Debug;
585
+		$content = $this->getErrorTemplate($statusCode, $exception);
586
+		$serverAdmin = isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : '';
587
+		$isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug;
588 588
 		$errorMessage = $exception->getMessage();
589
-		if($isDebug)
590
-			$version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion();
589
+		if ($isDebug)
590
+			$version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado">PRADO</a>/' . Prado::getVersion();
591 591
 		else
592 592
 		{
593
-			$version='';
593
+			$version = '';
594 594
 			$errorMessage = self::hideSecurityRelated($errorMessage, $exception);
595 595
 		}
596
-		$tokens=array(
596
+		$tokens = array(
597 597
 			'%%StatusCode%%' => "$statusCode",
598 598
 			'%%ErrorMessage%%' => htmlspecialchars($errorMessage),
599 599
 			'%%ServerAdmin%%' => $serverAdmin,
600 600
 			'%%Version%%' => $version,
601
-			'%%Time%%' => @strftime('%Y-%m-%d %H:%M',time())
601
+			'%%Time%%' => @strftime('%Y-%m-%d %H:%M', time())
602 602
 		);
603 603
 		$this->getApplication()->getResponse()->setStatusCode($statusCode, $isDebug ? $exception->getMessage() : null);
604
-		echo strtr($content,$tokens);
604
+		echo strtr($content, $tokens);
605 605
 	}
606 606
 	protected function handleRecursiveError($exception)
607 607
 	{
608
-		if($this->getApplication()->getMode()===TApplicationMode::Debug)
608
+		if ($this->getApplication()->getMode() === TApplicationMode::Debug)
609 609
 		{
610 610
 			echo "<html><head><title>Recursive Error</title></head>\n";
611 611
 			echo "<body><h1>Recursive Error</h1>\n";
612
-			echo "<pre>".$exception->__toString()."</pre>\n";
612
+			echo "<pre>" . $exception->__toString() . "</pre>\n";
613 613
 			echo "</body></html>";
614 614
 		}
615 615
 		else
616 616
 		{
617
-			error_log("Error happened while processing an existing error:\n".$exception->__toString());
617
+			error_log("Error happened while processing an existing error:\n" . $exception->__toString());
618 618
 			header('HTTP/1.0 500 Internal Error');
619 619
 		}
620 620
 	}
621 621
 	protected function displayException($exception)
622 622
 	{
623
-		if(php_sapi_name()==='cli')
623
+		if (php_sapi_name() === 'cli')
624 624
 		{
625
-			echo $exception->getMessage()."\n";
625
+			echo $exception->getMessage() . "\n";
626 626
 			echo $exception->getTraceAsString();
627 627
 			return;
628 628
 		}
629
-		if($exception instanceof TTemplateException)
629
+		if ($exception instanceof TTemplateException)
630 630
 		{
631
-			$fileName=$exception->getTemplateFile();
632
-			$lines=empty($fileName)?explode("\n",$exception->getTemplateSource()):@file($fileName);
633
-			$source=$this->getSourceCode($lines,$exception->getLineNumber());
634
-			if($fileName==='')
635
-				$fileName='---embedded template---';
636
-			$errorLine=$exception->getLineNumber();
631
+			$fileName = $exception->getTemplateFile();
632
+			$lines = empty($fileName) ? explode("\n", $exception->getTemplateSource()) : @file($fileName);
633
+			$source = $this->getSourceCode($lines, $exception->getLineNumber());
634
+			if ($fileName === '')
635
+				$fileName = '---embedded template---';
636
+			$errorLine = $exception->getLineNumber();
637 637
 		}
638 638
 		else
639 639
 		{
640
-			if(($trace=$this->getExactTrace($exception))!==null)
640
+			if (($trace = $this->getExactTrace($exception)) !== null)
641 641
 			{
642
-				$fileName=$trace['file'];
643
-				$errorLine=$trace['line'];
642
+				$fileName = $trace['file'];
643
+				$errorLine = $trace['line'];
644 644
 			}
645 645
 			else
646 646
 			{
647
-				$fileName=$exception->getFile();
648
-				$errorLine=$exception->getLine();
647
+				$fileName = $exception->getFile();
648
+				$errorLine = $exception->getLine();
649 649
 			}
650
-			$source=$this->getSourceCode(@file($fileName),$errorLine);
650
+			$source = $this->getSourceCode(@file($fileName), $errorLine);
651 651
 		}
652
-		if($this->getApplication()->getMode()===TApplicationMode::Debug)
653
-			$version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion();
652
+		if ($this->getApplication()->getMode() === TApplicationMode::Debug)
653
+			$version = $_SERVER['SERVER_SOFTWARE'] . ' <a href="https://github.com/pradosoft/prado">PRADO</a>/' . Prado::getVersion();
654 654
 		else
655
-			$version='';
656
-		$tokens=array(
655
+			$version = '';
656
+		$tokens = array(
657 657
 			'%%ErrorType%%' => get_class($exception),
658 658
 			'%%ErrorMessage%%' => $this->addLink(htmlspecialchars($exception->getMessage())),
659
-			'%%SourceFile%%' => htmlspecialchars($fileName).' ('.$errorLine.')',
659
+			'%%SourceFile%%' => htmlspecialchars($fileName) . ' (' . $errorLine . ')',
660 660
 			'%%SourceCode%%' => $source,
661 661
 			'%%StackTrace%%' => htmlspecialchars($exception->getTraceAsString()),
662 662
 			'%%Version%%' => $version,
663
-			'%%Time%%' => @strftime('%Y-%m-%d %H:%M',time())
663
+			'%%Time%%' => @strftime('%Y-%m-%d %H:%M', time())
664 664
 		);
665
-		$content=$this->getExceptionTemplate($exception);
666
-		echo strtr($content,$tokens);
665
+		$content = $this->getExceptionTemplate($exception);
666
+		echo strtr($content, $tokens);
667 667
 	}
668 668
 	protected function getExceptionTemplate($exception)
669 669
 	{
670
-		$lang=Prado::getPreferredLanguage();
671
-		$exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'-'.$lang.'.html';
672
-		if(!is_file($exceptionFile))
673
-			$exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'.html';
674
-		if(($content=@file_get_contents($exceptionFile))===false)
670
+		$lang = Prado::getPreferredLanguage();
671
+		$exceptionFile = Prado::getFrameworkPath() . '/Exceptions/templates/' . self::EXCEPTION_FILE_NAME . '-' . $lang . '.html';
672
+		if (!is_file($exceptionFile))
673
+			$exceptionFile = Prado::getFrameworkPath() . '/Exceptions/templates/' . self::EXCEPTION_FILE_NAME . '.html';
674
+		if (($content = @file_get_contents($exceptionFile)) === false)
675 675
 			die("Unable to open exception template file '$exceptionFile'.");
676 676
 		return $content;
677 677
 	}
678
-	protected function getErrorTemplate($statusCode,$exception)
678
+	protected function getErrorTemplate($statusCode, $exception)
679 679
 	{
680
-		$base=$this->getErrorTemplatePath().DIRECTORY_SEPARATOR.self::ERROR_FILE_NAME;
681
-		$lang=Prado::getPreferredLanguage();
682
-		if(is_file("$base$statusCode-$lang.html"))
683
-			$errorFile="$base$statusCode-$lang.html";
684
-		else if(is_file("$base$statusCode.html"))
685
-			$errorFile="$base$statusCode.html";
686
-		else if(is_file("$base-$lang.html"))
687
-			$errorFile="$base-$lang.html";
680
+		$base = $this->getErrorTemplatePath() . DIRECTORY_SEPARATOR . self::ERROR_FILE_NAME;
681
+		$lang = Prado::getPreferredLanguage();
682
+		if (is_file("$base$statusCode-$lang.html"))
683
+			$errorFile = "$base$statusCode-$lang.html";
684
+		else if (is_file("$base$statusCode.html"))
685
+			$errorFile = "$base$statusCode.html";
686
+		else if (is_file("$base-$lang.html"))
687
+			$errorFile = "$base-$lang.html";
688 688
 		else
689
-			$errorFile="$base.html";
690
-		if(($content=@file_get_contents($errorFile))===false)
689
+			$errorFile = "$base.html";
690
+		if (($content = @file_get_contents($errorFile)) === false)
691 691
 			die("Unable to open error template file '$errorFile'.");
692 692
 		return $content;
693 693
 	}
694 694
 	private function getExactTrace($exception)
695 695
 	{
696
-		$trace=$exception->getTrace();
697
-		$result=null;
698
-						if($exception instanceof TPhpErrorException)
699
-			$result=isset($trace[0]['file'])?$trace[0]:$trace[1];
700
-		else if($exception instanceof TInvalidOperationException)
696
+		$trace = $exception->getTrace();
697
+		$result = null;
698
+						if ($exception instanceof TPhpErrorException)
699
+			$result = isset($trace[0]['file']) ? $trace[0] : $trace[1];
700
+		else if ($exception instanceof TInvalidOperationException)
701 701
 		{
702
-						if(($result=$this->getPropertyAccessTrace($trace,'__get'))===null)
703
-				$result=$this->getPropertyAccessTrace($trace,'__set');
702
+						if (($result = $this->getPropertyAccessTrace($trace, '__get')) === null)
703
+				$result = $this->getPropertyAccessTrace($trace, '__set');
704 704
 		}
705
-		if($result!==null && strpos($result['file'],': eval()\'d code')!==false)
705
+		if ($result !== null && strpos($result['file'], ': eval()\'d code') !== false)
706 706
 			return null;
707 707
 		return $result;
708 708
 	}
709
-	private function getPropertyAccessTrace($trace,$pattern)
709
+	private function getPropertyAccessTrace($trace, $pattern)
710 710
 	{
711
-		$result=null;
712
-		foreach($trace as $t)
711
+		$result = null;
712
+		foreach ($trace as $t)
713 713
 		{
714
-			if(isset($t['function']) && $t['function']===$pattern)
715
-				$result=$t;
714
+			if (isset($t['function']) && $t['function'] === $pattern)
715
+				$result = $t;
716 716
 			else
717 717
 				break;
718 718
 		}
719 719
 		return $result;
720 720
 	}
721
-	private function getSourceCode($lines,$errorLine)
721
+	private function getSourceCode($lines, $errorLine)
722 722
 	{
723
-		$beginLine=$errorLine-self::SOURCE_LINES>=0?$errorLine-self::SOURCE_LINES:0;
724
-		$endLine=$errorLine+self::SOURCE_LINES<=count($lines)?$errorLine+self::SOURCE_LINES:count($lines);
725
-		$source='';
726
-		for($i=$beginLine;$i<$endLine;++$i)
723
+		$beginLine = $errorLine - self::SOURCE_LINES >= 0 ? $errorLine - self::SOURCE_LINES : 0;
724
+		$endLine = $errorLine + self::SOURCE_LINES <= count($lines) ? $errorLine + self::SOURCE_LINES : count($lines);
725
+		$source = '';
726
+		for ($i = $beginLine; $i < $endLine; ++$i)
727 727
 		{
728
-			if($i===$errorLine-1)
728
+			if ($i === $errorLine - 1)
729 729
 			{
730
-				$line=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",'    ',$lines[$i])));
731
-				$source.="<div class=\"error\">".$line."</div>";
730
+				$line = htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", '    ', $lines[$i])));
731
+				$source .= "<div class=\"error\">" . $line . "</div>";
732 732
 			}
733 733
 			else
734
-				$source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",'    ',$lines[$i])));
734
+				$source .= htmlspecialchars(sprintf("%04d: %s", $i + 1, str_replace("\t", '    ', $lines[$i])));
735 735
 		}
736 736
 		return $source;
737 737
 	}
738 738
 	private function addLink($message)
739 739
 	{
740
-		$baseUrl='http://pradosoft.github.io/docs/manual/class-';
741
-		return preg_replace('/\b(T[A-Z]\w+)\b/',"<a href=\"$baseUrl/\${1}\" target=\"_blank\">\${1}</a>",$message);
740
+		$baseUrl = 'http://pradosoft.github.io/docs/manual/class-';
741
+		return preg_replace('/\b(T[A-Z]\w+)\b/', "<a href=\"$baseUrl/\${1}\" target=\"_blank\">\${1}</a>", $message);
742 742
 	}
743 743
 }
744
-class TList extends TComponent implements IteratorAggregate,ArrayAccess,Countable
744
+class TList extends TComponent implements IteratorAggregate, ArrayAccess, Countable
745 745
 {
746
-	private $_d=array();
747
-	private $_c=0;
748
-	private $_r=false;
749
-	public function __construct($data=null,$readOnly=false)
746
+	private $_d = array();
747
+	private $_c = 0;
748
+	private $_r = false;
749
+	public function __construct($data = null, $readOnly = false)
750 750
 	{
751
-		if($data!==null)
751
+		if ($data !== null)
752 752
 			$this->copyFrom($data);
753 753
 		$this->setReadOnly($readOnly);
754 754
 	}
@@ -758,11 +758,11 @@  discard block
 block discarded – undo
758 758
 	}
759 759
 	protected function setReadOnly($value)
760 760
 	{
761
-		$this->_r=TPropertyValue::ensureBoolean($value);
761
+		$this->_r = TPropertyValue::ensureBoolean($value);
762 762
 	}
763 763
 	public function getIterator()
764 764
 	{
765
-		return new ArrayIterator( $this->_d );
765
+		return new ArrayIterator($this->_d);
766 766
 	}
767 767
 	public function count()
768 768
 	{
@@ -774,38 +774,38 @@  discard block
 block discarded – undo
774 774
 	}
775 775
 	public function itemAt($index)
776 776
 	{
777
-		if($index>=0 && $index<$this->_c)
777
+		if ($index >= 0 && $index < $this->_c)
778 778
 			return $this->_d[$index];
779 779
 		else
780
-			throw new TInvalidDataValueException('list_index_invalid',$index);
780
+			throw new TInvalidDataValueException('list_index_invalid', $index);
781 781
 	}
782 782
 	public function add($item)
783 783
 	{
784
-		$this->insertAt($this->_c,$item);
785
-		return $this->_c-1;
784
+		$this->insertAt($this->_c, $item);
785
+		return $this->_c - 1;
786 786
 	}
787
-	public function insertAt($index,$item)
787
+	public function insertAt($index, $item)
788 788
 	{
789
-		if(!$this->_r)
789
+		if (!$this->_r)
790 790
 		{
791
-			if($index===$this->_c)
792
-				$this->_d[$this->_c++]=$item;
793
-			else if($index>=0 && $index<$this->_c)
791
+			if ($index === $this->_c)
792
+				$this->_d[$this->_c++] = $item;
793
+			else if ($index >= 0 && $index < $this->_c)
794 794
 			{
795
-				array_splice($this->_d,$index,0,array($item));
795
+				array_splice($this->_d, $index, 0, array($item));
796 796
 				$this->_c++;
797 797
 			}
798 798
 			else
799
-				throw new TInvalidDataValueException('list_index_invalid',$index);
799
+				throw new TInvalidDataValueException('list_index_invalid', $index);
800 800
 		}
801 801
 		else
802
-			throw new TInvalidOperationException('list_readonly',get_class($this));
802
+			throw new TInvalidOperationException('list_readonly', get_class($this));
803 803
 	}
804 804
 	public function remove($item)
805 805
 	{
806
-		if(!$this->_r)
806
+		if (!$this->_r)
807 807
 		{
808
-			if(($index=$this->indexOf($item))>=0)
808
+			if (($index = $this->indexOf($item)) >= 0)
809 809
 			{
810 810
 				$this->removeAt($index);
811 811
 				return $index;
@@ -814,69 +814,69 @@  discard block
 block discarded – undo
814 814
 				throw new TInvalidDataValueException('list_item_inexistent');
815 815
 		}
816 816
 		else
817
-			throw new TInvalidOperationException('list_readonly',get_class($this));
817
+			throw new TInvalidOperationException('list_readonly', get_class($this));
818 818
 	}
819 819
 	public function removeAt($index)
820 820
 	{
821
-		if(!$this->_r)
821
+		if (!$this->_r)
822 822
 		{
823
-			if($index>=0 && $index<$this->_c)
823
+			if ($index >= 0 && $index < $this->_c)
824 824
 			{
825 825
 				$this->_c--;
826
-				if($index===$this->_c)
826
+				if ($index === $this->_c)
827 827
 					return array_pop($this->_d);
828 828
 				else
829 829
 				{
830
-					$item=$this->_d[$index];
831
-					array_splice($this->_d,$index,1);
830
+					$item = $this->_d[$index];
831
+					array_splice($this->_d, $index, 1);
832 832
 					return $item;
833 833
 				}
834 834
 			}
835 835
 			else
836
-				throw new TInvalidDataValueException('list_index_invalid',$index);
836
+				throw new TInvalidDataValueException('list_index_invalid', $index);
837 837
 		}
838 838
 		else
839
-			throw new TInvalidOperationException('list_readonly',get_class($this));
839
+			throw new TInvalidOperationException('list_readonly', get_class($this));
840 840
 	}
841 841
 	public function clear()
842 842
 	{
843
-		for($i=$this->_c-1;$i>=0;--$i)
843
+		for ($i = $this->_c - 1; $i >= 0; --$i)
844 844
 			$this->removeAt($i);
845 845
 	}
846 846
 	public function contains($item)
847 847
 	{
848
-		return $this->indexOf($item)>=0;
848
+		return $this->indexOf($item) >= 0;
849 849
 	}
850 850
 	public function indexOf($item)
851 851
 	{
852
-		if(($index=array_search($item,$this->_d,true))===false)
852
+		if (($index = array_search($item, $this->_d, true)) === false)
853 853
 			return -1;
854 854
 		else
855 855
 			return $index;
856 856
 	}
857 857
 	public function insertBefore($baseitem, $item)
858 858
 	{
859
-		if(!$this->_r)
859
+		if (!$this->_r)
860 860
 		{
861
-			if(($index = $this->indexOf($baseitem)) == -1)
861
+			if (($index = $this->indexOf($baseitem)) == -1)
862 862
 				throw new TInvalidDataValueException('list_item_inexistent');
863 863
 			$this->insertAt($index, $item);
864 864
 			return $index;
865 865
 		}
866 866
 		else
867
-			throw new TInvalidOperationException('list_readonly',get_class($this));
867
+			throw new TInvalidOperationException('list_readonly', get_class($this));
868 868
 	}
869 869
 	public function insertAfter($baseitem, $item)
870 870
 	{
871
-		if(!$this->_r)
871
+		if (!$this->_r)
872 872
 		{
873
-			if(($index = $this->indexOf($baseitem)) == -1)
873
+			if (($index = $this->indexOf($baseitem)) == -1)
874 874
 				throw new TInvalidDataValueException('list_item_inexistent');
875 875
 			$this->insertAt($index + 1, $item);
876 876
 			return $index + 1;
877 877
 		}
878 878
 		else
879
-			throw new TInvalidOperationException('list_readonly',get_class($this));
879
+			throw new TInvalidOperationException('list_readonly', get_class($this));
880 880
 	}
881 881
 	public function toArray()
882 882
 	{
@@ -884,42 +884,42 @@  discard block
 block discarded – undo
884 884
 	}
885 885
 	public function copyFrom($data)
886 886
 	{
887
-		if(is_array($data) || ($data instanceof Traversable))
887
+		if (is_array($data) || ($data instanceof Traversable))
888 888
 		{
889
-			if($this->_c>0)
889
+			if ($this->_c > 0)
890 890
 				$this->clear();
891
-			foreach($data as $item)
891
+			foreach ($data as $item)
892 892
 				$this->add($item);
893 893
 		}
894
-		else if($data!==null)
894
+		else if ($data !== null)
895 895
 			throw new TInvalidDataTypeException('list_data_not_iterable');
896 896
 	}
897 897
 	public function mergeWith($data)
898 898
 	{
899
-		if(is_array($data) || ($data instanceof Traversable))
899
+		if (is_array($data) || ($data instanceof Traversable))
900 900
 		{
901
-			foreach($data as $item)
901
+			foreach ($data as $item)
902 902
 				$this->add($item);
903 903
 		}
904
-		else if($data!==null)
904
+		else if ($data !== null)
905 905
 			throw new TInvalidDataTypeException('list_data_not_iterable');
906 906
 	}
907 907
 	public function offsetExists($offset)
908 908
 	{
909
-		return ($offset>=0 && $offset<$this->_c);
909
+		return ($offset >= 0 && $offset < $this->_c);
910 910
 	}
911 911
 	public function offsetGet($offset)
912 912
 	{
913 913
 		return $this->itemAt($offset);
914 914
 	}
915
-	public function offsetSet($offset,$item)
915
+	public function offsetSet($offset, $item)
916 916
 	{
917
-		if($offset===null || $offset===$this->_c)
918
-			$this->insertAt($this->_c,$item);
917
+		if ($offset === null || $offset === $this->_c)
918
+			$this->insertAt($this->_c, $item);
919 919
 		else
920 920
 		{
921 921
 			$this->removeAt($offset);
922
-			$this->insertAt($offset,$item);
922
+			$this->insertAt($offset, $item);
923 923
 		}
924 924
 	}
925 925
 	public function offsetUnset($offset)
@@ -934,13 +934,13 @@  discard block
 block discarded – undo
934 934
 	private $_c;
935 935
 	public function __construct(&$data)
936 936
 	{
937
-		$this->_d=&$data;
938
-		$this->_i=0;
939
-		$this->_c=count($this->_d);
937
+		$this->_d = &$data;
938
+		$this->_i = 0;
939
+		$this->_c = count($this->_d);
940 940
 	}
941 941
 	public function rewind()
942 942
 	{
943
-		$this->_i=0;
943
+		$this->_i = 0;
944 944
 	}
945 945
 	public function key()
946 946
 	{
@@ -956,23 +956,23 @@  discard block
 block discarded – undo
956 956
 	}
957 957
 	public function valid()
958 958
 	{
959
-		return $this->_i<$this->_c;
959
+		return $this->_i < $this->_c;
960 960
 	}
961 961
 }
962 962
 abstract class TCache extends TModule implements ICache, ArrayAccess
963 963
 {
964
-	private $_prefix=null;
965
-	private $_primary=true;
964
+	private $_prefix = null;
965
+	private $_primary = true;
966 966
 	public function init($config)
967 967
 	{
968
-		if($this->_prefix===null)
969
-			$this->_prefix=$this->getApplication()->getUniqueID();
970
-		if($this->_primary)
968
+		if ($this->_prefix === null)
969
+			$this->_prefix = $this->getApplication()->getUniqueID();
970
+		if ($this->_primary)
971 971
 		{
972
-			if($this->getApplication()->getCache()===null)
972
+			if ($this->getApplication()->getCache() === null)
973 973
 				$this->getApplication()->setCache($this);
974 974
 			else
975
-				throw new TConfigurationException('cache_primary_duplicated',get_class($this));
975
+				throw new TConfigurationException('cache_primary_duplicated', get_class($this));
976 976
 		}
977 977
 	}
978 978
 	public function getPrimaryCache()
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 	}
982 982
 	public function setPrimaryCache($value)
983 983
 	{
984
-		$this->_primary=TPropertyValue::ensureBoolean($value);
984
+		$this->_primary = TPropertyValue::ensureBoolean($value);
985 985
 	}
986 986
 	public function getKeyPrefix()
987 987
 	{
@@ -989,39 +989,39 @@  discard block
 block discarded – undo
989 989
 	}
990 990
 	public function setKeyPrefix($value)
991 991
 	{
992
-		$this->_prefix=$value;
992
+		$this->_prefix = $value;
993 993
 	}
994 994
 	protected function generateUniqueKey($key)
995 995
 	{
996
-		return md5($this->_prefix.$key);
996
+		return md5($this->_prefix . $key);
997 997
 	}
998 998
 	public function get($id)
999 999
 	{
1000
-		if(($data=$this->getValue($this->generateUniqueKey($id)))!==false)
1000
+		if (($data = $this->getValue($this->generateUniqueKey($id))) !== false)
1001 1001
 		{
1002
-			if(!is_array($data))
1002
+			if (!is_array($data))
1003 1003
 				return false;
1004
-			if(!($data[1] instanceof ICacheDependency) || !$data[1]->getHasChanged())
1004
+			if (!($data[1] instanceof ICacheDependency) || !$data[1]->getHasChanged())
1005 1005
 				return $data[0];
1006 1006
 		}
1007 1007
 		return false;
1008 1008
 	}
1009
-	public function set($id,$value,$expire=0,$dependency=null)
1009
+	public function set($id, $value, $expire = 0, $dependency = null)
1010 1010
 	{
1011
-		if(empty($value) && $expire === 0)
1011
+		if (empty($value) && $expire === 0)
1012 1012
 			$this->delete($id);
1013 1013
 		else
1014 1014
 		{
1015
-			$data=array($value,$dependency);
1016
-			return $this->setValue($this->generateUniqueKey($id),$data,$expire);
1015
+			$data = array($value, $dependency);
1016
+			return $this->setValue($this->generateUniqueKey($id), $data, $expire);
1017 1017
 		}
1018 1018
 	}
1019
-	public function add($id,$value,$expire=0,$dependency=null)
1019
+	public function add($id, $value, $expire = 0, $dependency = null)
1020 1020
 	{
1021
-		if(empty($value) && $expire === 0)
1021
+		if (empty($value) && $expire === 0)
1022 1022
 			return false;
1023
-		$data=array($value,$dependency);
1024
-		return $this->addValue($this->generateUniqueKey($id),$data,$expire);
1023
+		$data = array($value, $dependency);
1024
+		return $this->addValue($this->generateUniqueKey($id), $data, $expire);
1025 1025
 	}
1026 1026
 	public function delete($id)
1027 1027
 	{
@@ -1032,8 +1032,8 @@  discard block
 block discarded – undo
1032 1032
 		throw new TNotSupportedException('cache_flush_unsupported');
1033 1033
 	}
1034 1034
 	abstract protected function getValue($key);
1035
-	abstract protected function setValue($key,$value,$expire);
1036
-	abstract protected function addValue($key,$value,$expire);
1035
+	abstract protected function setValue($key, $value, $expire);
1036
+	abstract protected function addValue($key, $value, $expire);
1037 1037
 	abstract protected function deleteValue($key);
1038 1038
 	public function offsetExists($id)
1039 1039
 	{
@@ -1069,8 +1069,8 @@  discard block
 block discarded – undo
1069 1069
 	}
1070 1070
 	public function setFileName($value)
1071 1071
 	{
1072
-		$this->_fileName=$value;
1073
-		$this->_timestamp=@filemtime($value);
1072
+		$this->_fileName = $value;
1073
+		$this->_timestamp = @filemtime($value);
1074 1074
 	}
1075 1075
 	public function getTimestamp()
1076 1076
 	{
@@ -1078,13 +1078,13 @@  discard block
 block discarded – undo
1078 1078
 	}
1079 1079
 	public function getHasChanged()
1080 1080
 	{
1081
-		return @filemtime($this->_fileName)!==$this->_timestamp;
1081
+		return @filemtime($this->_fileName) !== $this->_timestamp;
1082 1082
 	}
1083 1083
 }
1084 1084
 class TDirectoryCacheDependency extends TCacheDependency
1085 1085
 {
1086
-	private $_recursiveCheck=true;
1087
-	private $_recursiveLevel=-1;
1086
+	private $_recursiveCheck = true;
1087
+	private $_recursiveLevel = -1;
1088 1088
 	private $_timestamps;
1089 1089
 	private $_directory;
1090 1090
 	public function __construct($directory)
@@ -1097,10 +1097,10 @@  discard block
 block discarded – undo
1097 1097
 	}
1098 1098
 	public function setDirectory($directory)
1099 1099
 	{
1100
-		if(($path=realpath($directory))===false || !is_dir($path))
1101
-			throw new TInvalidDataValueException('directorycachedependency_directory_invalid',$directory);
1102
-		$this->_directory=$path;
1103
-		$this->_timestamps=$this->generateTimestamps($path);
1100
+		if (($path = realpath($directory)) === false || !is_dir($path))
1101
+			throw new TInvalidDataValueException('directorycachedependency_directory_invalid', $directory);
1102
+		$this->_directory = $path;
1103
+		$this->_timestamps = $this->generateTimestamps($path);
1104 1104
 	}
1105 1105
 	public function getRecursiveCheck()
1106 1106
 	{
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
 	}
1109 1109
 	public function setRecursiveCheck($value)
1110 1110
 	{
1111
-		$this->_recursiveCheck=TPropertyValue::ensureBoolean($value);
1111
+		$this->_recursiveCheck = TPropertyValue::ensureBoolean($value);
1112 1112
 	}
1113 1113
 	public function getRecursiveLevel()
1114 1114
 	{
@@ -1116,11 +1116,11 @@  discard block
 block discarded – undo
1116 1116
 	}
1117 1117
 	public function setRecursiveLevel($value)
1118 1118
 	{
1119
-		$this->_recursiveLevel=TPropertyValue::ensureInteger($value);
1119
+		$this->_recursiveLevel = TPropertyValue::ensureInteger($value);
1120 1120
 	}
1121 1121
 	public function getHasChanged()
1122 1122
 	{
1123
-		return $this->generateTimestamps($this->_directory)!=$this->_timestamps;
1123
+		return $this->generateTimestamps($this->_directory) != $this->_timestamps;
1124 1124
 	}
1125 1125
 	protected function validateFile($fileName)
1126 1126
 	{
@@ -1130,23 +1130,23 @@  discard block
 block discarded – undo
1130 1130
 	{
1131 1131
 		return true;
1132 1132
 	}
1133
-	protected function generateTimestamps($directory,$level=0)
1133
+	protected function generateTimestamps($directory, $level = 0)
1134 1134
 	{
1135
-		if(($dir=opendir($directory))===false)
1136
-			throw new TIOException('directorycachedependency_directory_invalid',$directory);
1137
-		$timestamps=array();
1138
-		while(($file=readdir($dir))!==false)
1135
+		if (($dir = opendir($directory)) === false)
1136
+			throw new TIOException('directorycachedependency_directory_invalid', $directory);
1137
+		$timestamps = array();
1138
+		while (($file = readdir($dir)) !== false)
1139 1139
 		{
1140
-			$path=$directory.DIRECTORY_SEPARATOR.$file;
1141
-			if($file==='.' || $file==='..')
1140
+			$path = $directory . DIRECTORY_SEPARATOR . $file;
1141
+			if ($file === '.' || $file === '..')
1142 1142
 				continue;
1143
-			else if(is_dir($path))
1143
+			else if (is_dir($path))
1144 1144
 			{
1145
-				if(($this->_recursiveLevel<0 || $level<$this->_recursiveLevel) && $this->validateDirectory($path))
1146
-					$timestamps=array_merge($this->generateTimestamps($path,$level+1));
1145
+				if (($this->_recursiveLevel < 0 || $level < $this->_recursiveLevel) && $this->validateDirectory($path))
1146
+					$timestamps = array_merge($this->generateTimestamps($path, $level + 1));
1147 1147
 			}
1148
-			else if($this->validateFile($path))
1149
-				$timestamps[$path]=filemtime($path);
1148
+			else if ($this->validateFile($path))
1149
+				$timestamps[$path] = filemtime($path);
1150 1150
 		}
1151 1151
 		closedir($dir);
1152 1152
 		return $timestamps;
@@ -1166,29 +1166,29 @@  discard block
 block discarded – undo
1166 1166
 	}
1167 1167
 	public function setStateName($value)
1168 1168
 	{
1169
-		$this->_stateName=$value;
1170
-		$this->_stateValue=Prado::getApplication()->getGlobalState($value);
1169
+		$this->_stateName = $value;
1170
+		$this->_stateValue = Prado::getApplication()->getGlobalState($value);
1171 1171
 	}
1172 1172
 	public function getHasChanged()
1173 1173
 	{
1174
-		return $this->_stateValue!==Prado::getApplication()->getGlobalState($this->_stateName);
1174
+		return $this->_stateValue !== Prado::getApplication()->getGlobalState($this->_stateName);
1175 1175
 	}
1176 1176
 }
1177 1177
 class TChainedCacheDependency extends TCacheDependency
1178 1178
 {
1179
-	private $_dependencies=null;
1179
+	private $_dependencies = null;
1180 1180
 	public function getDependencies()
1181 1181
 	{
1182
-		if($this->_dependencies===null)
1183
-			$this->_dependencies=new TCacheDependencyList;
1182
+		if ($this->_dependencies === null)
1183
+			$this->_dependencies = new TCacheDependencyList;
1184 1184
 		return $this->_dependencies;
1185 1185
 	}
1186 1186
 	public function getHasChanged()
1187 1187
 	{
1188
-		if($this->_dependencies!==null)
1188
+		if ($this->_dependencies !== null)
1189 1189
 		{
1190
-			foreach($this->_dependencies as $dependency)
1191
-				if($dependency->getHasChanged())
1190
+			foreach ($this->_dependencies as $dependency)
1191
+				if ($dependency->getHasChanged())
1192 1192
 					return true;
1193 1193
 		}
1194 1194
 		return false;
@@ -1198,49 +1198,49 @@  discard block
 block discarded – undo
1198 1198
 {
1199 1199
 	public function getHasChanged()
1200 1200
 	{
1201
-		return Prado::getApplication()->getMode()!==TApplicationMode::Performance;
1201
+		return Prado::getApplication()->getMode() !== TApplicationMode::Performance;
1202 1202
 	}
1203 1203
 }
1204 1204
 class TCacheDependencyList extends TList
1205 1205
 {
1206
-	public function insertAt($index,$item)
1206
+	public function insertAt($index, $item)
1207 1207
 	{
1208
-		if($item instanceof ICacheDependency)
1209
-			parent::insertAt($index,$item);
1208
+		if ($item instanceof ICacheDependency)
1209
+			parent::insertAt($index, $item);
1210 1210
 		else
1211 1211
 			throw new TInvalidDataTypeException('cachedependencylist_cachedependency_required');
1212 1212
 	}
1213 1213
 }
1214 1214
 class TTextWriter extends TComponent implements ITextWriter
1215 1215
 {
1216
-	private $_str='';
1216
+	private $_str = '';
1217 1217
 	public function flush()
1218 1218
 	{
1219
-		$str=$this->_str;
1220
-		$this->_str='';
1219
+		$str = $this->_str;
1220
+		$this->_str = '';
1221 1221
 		return $str;
1222 1222
 	}
1223 1223
 	public function write($str)
1224 1224
 	{
1225
-		$this->_str.=$str;
1225
+		$this->_str .= $str;
1226 1226
 	}
1227
-	public function writeLine($str='')
1227
+	public function writeLine($str = '')
1228 1228
 	{
1229
-		$this->write($str."\n");
1229
+		$this->write($str . "\n");
1230 1230
 	}
1231 1231
 }
1232 1232
 class TPriorityList extends TList
1233 1233
 {
1234
-	private $_d=array();
1235
-	private $_o=false;
1236
-	private $_fd=null;
1237
-	private $_c=0;
1238
-	private $_dp=10;
1239
-	private $_p=8;
1240
-	public function __construct($data=null,$readOnly=false,$defaultPriority=10,$precision=8)
1234
+	private $_d = array();
1235
+	private $_o = false;
1236
+	private $_fd = null;
1237
+	private $_c = 0;
1238
+	private $_dp = 10;
1239
+	private $_p = 8;
1240
+	public function __construct($data = null, $readOnly = false, $defaultPriority = 10, $precision = 8)
1241 1241
 	{
1242 1242
 		parent::__construct();
1243
-		if($data!==null)
1243
+		if ($data !== null)
1244 1244
 			$this->copyFrom($data);
1245 1245
 		$this->setReadOnly($readOnly);
1246 1246
 		$this->setPrecision($precision);
@@ -1254,12 +1254,12 @@  discard block
 block discarded – undo
1254 1254
 	{
1255 1255
 		return $this->_c;
1256 1256
 	}
1257
-	public function getPriorityCount($priority=null)
1257
+	public function getPriorityCount($priority = null)
1258 1258
 	{
1259
-		if($priority===null)
1260
-			$priority=$this->getDefaultPriority();
1261
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1262
-		if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority]))
1259
+		if ($priority === null)
1260
+			$priority = $this->getDefaultPriority();
1261
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
1262
+		if (!isset($this->_d[$priority]) || !is_array($this->_d[$priority]))
1263 1263
 			return false;
1264 1264
 		return count($this->_d[$priority]);
1265 1265
 	}
@@ -1269,7 +1269,7 @@  discard block
 block discarded – undo
1269 1269
 	}
1270 1270
 	protected function setDefaultPriority($value)
1271 1271
 	{
1272
-		$this->_dp=(string)round(TPropertyValue::ensureFloat($value),$this->_p);
1272
+		$this->_dp = (string) round(TPropertyValue::ensureFloat($value), $this->_p);
1273 1273
 	}
1274 1274
 	public function getPrecision()
1275 1275
 	{
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
 	}
1278 1278
 	protected function setPrecision($value)
1279 1279
 	{
1280
-		$this->_p=TPropertyValue::ensureInteger($value);
1280
+		$this->_p = TPropertyValue::ensureInteger($value);
1281 1281
 	}
1282 1282
 	public function getIterator()
1283 1283
 	{
@@ -1289,122 +1289,122 @@  discard block
 block discarded – undo
1289 1289
 		return array_keys($this->_d);
1290 1290
 	}
1291 1291
 	protected function sortPriorities() {
1292
-		if(!$this->_o) {
1293
-			ksort($this->_d,SORT_NUMERIC);
1294
-			$this->_o=true;
1292
+		if (!$this->_o) {
1293
+			ksort($this->_d, SORT_NUMERIC);
1294
+			$this->_o = true;
1295 1295
 		}
1296 1296
 	}
1297 1297
 	protected function flattenPriorities() {
1298
-		if(is_array($this->_fd))
1298
+		if (is_array($this->_fd))
1299 1299
 			return $this->_fd;
1300 1300
 		$this->sortPriorities();
1301
-		$this->_fd=array();
1302
-		foreach($this->_d as $priority => $itemsatpriority)
1303
-			$this->_fd=array_merge($this->_fd,$itemsatpriority);
1301
+		$this->_fd = array();
1302
+		foreach ($this->_d as $priority => $itemsatpriority)
1303
+			$this->_fd = array_merge($this->_fd, $itemsatpriority);
1304 1304
 		return $this->_fd;
1305 1305
 	}
1306 1306
 	public function itemAt($index)
1307 1307
 	{
1308
-		if($index>=0&&$index<$this->getCount()) {
1309
-			$arr=$this->flattenPriorities();
1308
+		if ($index >= 0 && $index < $this->getCount()) {
1309
+			$arr = $this->flattenPriorities();
1310 1310
 			return $arr[$index];
1311 1311
 		} else
1312
-			throw new TInvalidDataValueException('list_index_invalid',$index);
1312
+			throw new TInvalidDataValueException('list_index_invalid', $index);
1313 1313
 	}
1314
-	public function itemsAtPriority($priority=null)
1314
+	public function itemsAtPriority($priority = null)
1315 1315
 	{
1316
-		if($priority===null)
1317
-			$priority=$this->getDefaultPriority();
1318
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1319
-		return isset($this->_d[$priority])?$this->_d[$priority]:null;
1316
+		if ($priority === null)
1317
+			$priority = $this->getDefaultPriority();
1318
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
1319
+		return isset($this->_d[$priority]) ? $this->_d[$priority] : null;
1320 1320
 	}
1321
-	public function itemAtIndexInPriority($index,$priority=null)
1321
+	public function itemAtIndexInPriority($index, $priority = null)
1322 1322
 	{
1323
-		if($priority===null)
1324
-			$priority=$this->getDefaultPriority();
1325
-		$priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p);
1326
-		return !isset($this->_d[$priority])?false:(
1327
-				isset($this->_d[$priority][$index])?$this->_d[$priority][$index]:false
1323
+		if ($priority === null)
1324
+			$priority = $this->getDefaultPriority();
1325
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
1326
+		return !isset($this->_d[$priority]) ? false : (
1327
+				isset($this->_d[$priority][$index]) ? $this->_d[$priority][$index] : false
1328 1328
 			);
1329 1329
 	}
1330
-	public function add($item,$priority=null)
1330
+	public function add($item, $priority = null)
1331 1331
 	{
1332
-		if($this->getReadOnly())
1333
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1334
-		return $this->insertAtIndexInPriority($item,false,$priority,true);
1332
+		if ($this->getReadOnly())
1333
+			throw new TInvalidOperationException('list_readonly', get_class($this));
1334
+		return $this->insertAtIndexInPriority($item, false, $priority, true);
1335 1335
 	}
1336
-	public function insertAt($index,$item)
1336
+	public function insertAt($index, $item)
1337 1337
 	{
1338
-		if($this->getReadOnly())
1339
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1340
-		if(($priority=$this->priorityAt($index,true))!==false)
1341
-			$this->insertAtIndexInPriority($item,$priority[1],$priority[0]);
1338
+		if ($this->getReadOnly())
1339
+			throw new TInvalidOperationException('list_readonly', get_class($this));
1340
+		if (($priority = $this->priorityAt($index, true)) !== false)
1341
+			$this->insertAtIndexInPriority($item, $priority[1], $priority[0]);
1342 1342
 		else
1343
-			throw new TInvalidDataValueException('list_index_invalid',$index);
1343
+			throw new TInvalidDataValueException('list_index_invalid', $index);
1344 1344
 	}
1345
-	public function insertAtIndexInPriority($item,$index=false,$priority=null,$preserveCache=false)
1345
+	public function insertAtIndexInPriority($item, $index = false, $priority = null, $preserveCache = false)
1346 1346
 	{
1347
-		if($this->getReadOnly())
1348
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1349
-		if($priority===null)
1350
-			$priority=$this->getDefaultPriority();
1351
-		$priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p);
1352
-		if($preserveCache) {
1347
+		if ($this->getReadOnly())
1348
+			throw new TInvalidOperationException('list_readonly', get_class($this));
1349
+		if ($priority === null)
1350
+			$priority = $this->getDefaultPriority();
1351
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
1352
+		if ($preserveCache) {
1353 1353
 			$this->sortPriorities();
1354
-			$cc=0;
1355
-			foreach($this->_d as $prioritykey=>$items)
1356
-				if($prioritykey>=$priority)
1354
+			$cc = 0;
1355
+			foreach ($this->_d as $prioritykey=>$items)
1356
+				if ($prioritykey >= $priority)
1357 1357
 					break;
1358 1358
 				else
1359
-					$cc+=count($items);
1360
-			if($index===false&&isset($this->_d[$priority])) {
1361
-				$c=count($this->_d[$priority]);
1362
-				$c+=$cc;
1363
-				$this->_d[$priority][]=$item;
1364
-			} else if(isset($this->_d[$priority])) {
1365
-				$c=$index+$cc;
1366
-				array_splice($this->_d[$priority],$index,0,array($item));
1359
+					$cc += count($items);
1360
+			if ($index === false && isset($this->_d[$priority])) {
1361
+				$c = count($this->_d[$priority]);
1362
+				$c += $cc;
1363
+				$this->_d[$priority][] = $item;
1364
+			} else if (isset($this->_d[$priority])) {
1365
+				$c = $index + $cc;
1366
+				array_splice($this->_d[$priority], $index, 0, array($item));
1367 1367
 			} else {
1368 1368
 				$c = $cc;
1369 1369
 				$this->_o = false;
1370
-				$this->_d[$priority]=array($item);
1370
+				$this->_d[$priority] = array($item);
1371 1371
 			}
1372
-			if($this->_fd&&is_array($this->_fd)) 				array_splice($this->_fd,$c,0,array($item));
1372
+			if ($this->_fd && is_array($this->_fd)) 				array_splice($this->_fd, $c, 0, array($item));
1373 1373
 		} else {
1374
-			$c=null;
1375
-			if($index===false&&isset($this->_d[$priority])) {
1376
-				$cc=count($this->_d[$priority]);
1377
-				$this->_d[$priority][]=$item;
1378
-			} else if(isset($this->_d[$priority])) {
1379
-				$cc=$index;
1380
-				array_splice($this->_d[$priority],$index,0,array($item));
1374
+			$c = null;
1375
+			if ($index === false && isset($this->_d[$priority])) {
1376
+				$cc = count($this->_d[$priority]);
1377
+				$this->_d[$priority][] = $item;
1378
+			} else if (isset($this->_d[$priority])) {
1379
+				$cc = $index;
1380
+				array_splice($this->_d[$priority], $index, 0, array($item));
1381 1381
 			} else {
1382
-				$cc=0;
1383
-				$this->_o=false;
1384
-				$this->_d[$priority]=array($item);
1382
+				$cc = 0;
1383
+				$this->_o = false;
1384
+				$this->_d[$priority] = array($item);
1385 1385
 			}
1386
-			if($this->_fd&&is_array($this->_fd)&&count($this->_d)==1)
1387
-				array_splice($this->_fd,$cc,0,array($item));
1386
+			if ($this->_fd && is_array($this->_fd) && count($this->_d) == 1)
1387
+				array_splice($this->_fd, $cc, 0, array($item));
1388 1388
 			else
1389
-				$this->_fd=null;
1389
+				$this->_fd = null;
1390 1390
 		}
1391 1391
 		$this->_c++;
1392 1392
 		return $c;
1393 1393
 	}
1394
-	public function remove($item,$priority=false)
1394
+	public function remove($item, $priority = false)
1395 1395
 	{
1396
-		if($this->getReadOnly())
1397
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1398
-		if(($p=$this->priorityOf($item,true))!==false)
1396
+		if ($this->getReadOnly())
1397
+			throw new TInvalidOperationException('list_readonly', get_class($this));
1398
+		if (($p = $this->priorityOf($item, true)) !== false)
1399 1399
 		{
1400
-			if($priority!==false) {
1401
-				if($priority===null)
1402
-					$priority=$this->getDefaultPriority();
1403
-				$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1404
-				if($p[0]!=$priority)
1400
+			if ($priority !== false) {
1401
+				if ($priority === null)
1402
+					$priority = $this->getDefaultPriority();
1403
+				$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
1404
+				if ($p[0] != $priority)
1405 1405
 					throw new TInvalidDataValueException('list_item_inexistent');
1406 1406
 			}
1407
-			$this->removeAtIndexInPriority($p[1],$p[0]);
1407
+			$this->removeAtIndexInPriority($p[1], $p[0]);
1408 1408
 			return $p[2];
1409 1409
 		}
1410 1410
 		else
@@ -1412,97 +1412,97 @@  discard block
 block discarded – undo
1412 1412
 	}
1413 1413
 	public function removeAt($index)
1414 1414
 	{
1415
-		if($this->getReadOnly())
1416
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1417
-		if(($priority=$this->priorityAt($index, true))!==false)
1418
-			return $this->removeAtIndexInPriority($priority[1],$priority[0]);
1419
-		throw new TInvalidDataValueException('list_index_invalid',$index);
1415
+		if ($this->getReadOnly())
1416
+			throw new TInvalidOperationException('list_readonly', get_class($this));
1417
+		if (($priority = $this->priorityAt($index, true)) !== false)
1418
+			return $this->removeAtIndexInPriority($priority[1], $priority[0]);
1419
+		throw new TInvalidDataValueException('list_index_invalid', $index);
1420 1420
 	}
1421
-	public function removeAtIndexInPriority($index, $priority=null)
1421
+	public function removeAtIndexInPriority($index, $priority = null)
1422 1422
 	{
1423
-		if($this->getReadOnly())
1424
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1425
-		if($priority===null)
1426
-			$priority=$this->getDefaultPriority();
1427
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1428
-		if(!isset($this->_d[$priority])||$index<0||$index>=count($this->_d[$priority]))
1423
+		if ($this->getReadOnly())
1424
+			throw new TInvalidOperationException('list_readonly', get_class($this));
1425
+		if ($priority === null)
1426
+			$priority = $this->getDefaultPriority();
1427
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
1428
+		if (!isset($this->_d[$priority]) || $index < 0 || $index >= count($this->_d[$priority]))
1429 1429
 			throw new TInvalidDataValueException('list_item_inexistent');
1430
-				$value=array_splice($this->_d[$priority],$index,1);
1431
-		$value=$value[0];
1432
-		if(!count($this->_d[$priority]))
1430
+				$value = array_splice($this->_d[$priority], $index, 1);
1431
+		$value = $value[0];
1432
+		if (!count($this->_d[$priority]))
1433 1433
 			unset($this->_d[$priority]);
1434 1434
 		$this->_c--;
1435
-		$this->_fd=null;
1435
+		$this->_fd = null;
1436 1436
 		return $value;
1437 1437
 	}
1438 1438
 	public function clear()
1439 1439
 	{
1440
-		if($this->getReadOnly())
1441
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1442
-		$d=array_reverse($this->_d,true);
1443
-		foreach($this->_d as $priority=>$items) {
1444
-			for($index=count($items)-1;$index>=0;$index--)
1445
-				$this->removeAtIndexInPriority($index,$priority);
1440
+		if ($this->getReadOnly())
1441
+			throw new TInvalidOperationException('list_readonly', get_class($this));
1442
+		$d = array_reverse($this->_d, true);
1443
+		foreach ($this->_d as $priority=>$items) {
1444
+			for ($index = count($items) - 1; $index >= 0; $index--)
1445
+				$this->removeAtIndexInPriority($index, $priority);
1446 1446
 			unset($this->_d[$priority]);
1447 1447
 		}
1448 1448
 	}
1449 1449
 	public function contains($item)
1450 1450
 	{
1451
-		return $this->indexOf($item)>=0;
1451
+		return $this->indexOf($item) >= 0;
1452 1452
 	}
1453 1453
 	public function indexOf($item)
1454 1454
 	{
1455
-		if(($index=array_search($item,$this->flattenPriorities(),true))===false)
1455
+		if (($index = array_search($item, $this->flattenPriorities(), true)) === false)
1456 1456
 			return -1;
1457 1457
 		else
1458 1458
 			return $index;
1459 1459
 	}
1460
-	public function priorityOf($item,$withindex = false)
1460
+	public function priorityOf($item, $withindex = false)
1461 1461
 	{
1462 1462
 		$this->sortPriorities();
1463 1463
 		$absindex = 0;
1464
-		foreach($this->_d as $priority=>$items) {
1465
-			if(($index=array_search($item,$items,true))!==false) {
1466
-				$absindex+=$index;
1467
-				return $withindex?array($priority,$index,$absindex,
1468
-						'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority;
1464
+		foreach ($this->_d as $priority=>$items) {
1465
+			if (($index = array_search($item, $items, true)) !== false) {
1466
+				$absindex += $index;
1467
+				return $withindex ? array($priority, $index, $absindex,
1468
+						'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex) : $priority;
1469 1469
 			} else
1470
-				$absindex+=count($items);
1470
+				$absindex += count($items);
1471 1471
 		}
1472 1472
 		return false;
1473 1473
 	}
1474
-	public function priorityAt($index,$withindex = false)
1474
+	public function priorityAt($index, $withindex = false)
1475 1475
 	{
1476
-		if($index<0||$index>=$this->getCount())
1477
-			throw new TInvalidDataValueException('list_index_invalid',$index);
1478
-		$absindex=$index;
1476
+		if ($index < 0 || $index >= $this->getCount())
1477
+			throw new TInvalidDataValueException('list_index_invalid', $index);
1478
+		$absindex = $index;
1479 1479
 		$this->sortPriorities();
1480
-		foreach($this->_d as $priority=>$items) {
1481
-			if($index>=($c=count($items)))
1482
-				$index-=$c;
1480
+		foreach ($this->_d as $priority=>$items) {
1481
+			if ($index >= ($c = count($items)))
1482
+				$index -= $c;
1483 1483
 			else
1484
-				return $withindex?array($priority,$index,$absindex,
1485
-						'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority;
1484
+				return $withindex ? array($priority, $index, $absindex,
1485
+						'priority'=>$priority, 'index'=>$index, 'absindex'=>$absindex) : $priority;
1486 1486
 		}
1487 1487
 		return false;
1488 1488
 	}
1489 1489
 	public function insertBefore($indexitem, $item)
1490 1490
 	{
1491
-		if($this->getReadOnly())
1492
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1493
-		if(($priority=$this->priorityOf($indexitem,true))===false)
1491
+		if ($this->getReadOnly())
1492
+			throw new TInvalidOperationException('list_readonly', get_class($this));
1493
+		if (($priority = $this->priorityOf($indexitem, true)) === false)
1494 1494
 			throw new TInvalidDataValueException('list_item_inexistent');
1495
-		$this->insertAtIndexInPriority($item,$priority[1],$priority[0]);
1495
+		$this->insertAtIndexInPriority($item, $priority[1], $priority[0]);
1496 1496
 		return $priority[2];
1497 1497
 	}
1498 1498
 	public function insertAfter($indexitem, $item)
1499 1499
 	{
1500
-		if($this->getReadOnly())
1501
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1502
-		if(($priority=$this->priorityOf($indexitem,true))===false)
1500
+		if ($this->getReadOnly())
1501
+			throw new TInvalidOperationException('list_readonly', get_class($this));
1502
+		if (($priority = $this->priorityOf($indexitem, true)) === false)
1503 1503
 			throw new TInvalidDataValueException('list_item_inexistent');
1504
-		$this->insertAtIndexInPriority($item,$priority[1]+1,$priority[0]);
1505
-		return $priority[2]+1;
1504
+		$this->insertAtIndexInPriority($item, $priority[1] + 1, $priority[0]);
1505
+		return $priority[2] + 1;
1506 1506
 	}
1507 1507
 	public function toArray()
1508 1508
 	{
@@ -1513,100 +1513,100 @@  discard block
 block discarded – undo
1513 1513
 		$this->sortPriorities();
1514 1514
 		return $this->_d;
1515 1515
 	}
1516
-	public function toArrayBelowPriority($priority,$inclusive=false)
1516
+	public function toArrayBelowPriority($priority, $inclusive = false)
1517 1517
 	{
1518 1518
 		$this->sortPriorities();
1519
-		$items=array();
1520
-		foreach($this->_d as $itemspriority=>$itemsatpriority)
1519
+		$items = array();
1520
+		foreach ($this->_d as $itemspriority=>$itemsatpriority)
1521 1521
 		{
1522
-			if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority)
1522
+			if ((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority)
1523 1523
 				break;
1524
-			$items=array_merge($items,$itemsatpriority);
1524
+			$items = array_merge($items, $itemsatpriority);
1525 1525
 		}
1526 1526
 		return $items;
1527 1527
 	}
1528
-	public function toArrayAbovePriority($priority,$inclusive=true)
1528
+	public function toArrayAbovePriority($priority, $inclusive = true)
1529 1529
 	{
1530 1530
 		$this->sortPriorities();
1531
-		$items=array();
1532
-		foreach($this->_d as $itemspriority=>$itemsatpriority)
1531
+		$items = array();
1532
+		foreach ($this->_d as $itemspriority=>$itemsatpriority)
1533 1533
 		{
1534
-			if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority)
1534
+			if ((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority)
1535 1535
 				continue;
1536
-			$items=array_merge($items,$itemsatpriority);
1536
+			$items = array_merge($items, $itemsatpriority);
1537 1537
 		}
1538 1538
 		return $items;
1539 1539
 	}
1540 1540
 	public function copyFrom($data)
1541 1541
 	{
1542
-		if($data instanceof TPriorityList)
1542
+		if ($data instanceof TPriorityList)
1543 1543
 		{
1544
-			if($this->getCount()>0)
1544
+			if ($this->getCount() > 0)
1545 1545
 				$this->clear();
1546
-			foreach($data->getPriorities() as $priority)
1546
+			foreach ($data->getPriorities() as $priority)
1547 1547
 			{
1548
-				foreach($data->itemsAtPriority($priority) as $index=>$item)
1549
-					$this->insertAtIndexInPriority($item,$index,$priority);
1548
+				foreach ($data->itemsAtPriority($priority) as $index=>$item)
1549
+					$this->insertAtIndexInPriority($item, $index, $priority);
1550 1550
 			}
1551
-		} else if(is_array($data)||$data instanceof Traversable) {
1552
-			if($this->getCount()>0)
1551
+		} else if (is_array($data) || $data instanceof Traversable) {
1552
+			if ($this->getCount() > 0)
1553 1553
 				$this->clear();
1554
-			foreach($data as $key=>$item)
1554
+			foreach ($data as $key=>$item)
1555 1555
 				$this->add($item);
1556
-		} else if($data!==null)
1556
+		} else if ($data !== null)
1557 1557
 			throw new TInvalidDataTypeException('map_data_not_iterable');
1558 1558
 	}
1559 1559
 	public function mergeWith($data)
1560 1560
 	{
1561
-		if($data instanceof TPriorityList)
1561
+		if ($data instanceof TPriorityList)
1562 1562
 		{
1563
-			foreach($data->getPriorities() as $priority)
1563
+			foreach ($data->getPriorities() as $priority)
1564 1564
 			{
1565
-				foreach($data->itemsAtPriority($priority) as $index=>$item)
1566
-					$this->insertAtIndexInPriority($item,false,$priority);
1565
+				foreach ($data->itemsAtPriority($priority) as $index=>$item)
1566
+					$this->insertAtIndexInPriority($item, false, $priority);
1567 1567
 			}
1568 1568
 		}
1569
-		else if(is_array($data)||$data instanceof Traversable)
1569
+		else if (is_array($data) || $data instanceof Traversable)
1570 1570
 		{
1571
-			foreach($data as $priority=>$item)
1571
+			foreach ($data as $priority=>$item)
1572 1572
 				$this->add($item);
1573 1573
 		}
1574
-		else if($data!==null)
1574
+		else if ($data !== null)
1575 1575
 			throw new TInvalidDataTypeException('map_data_not_iterable');
1576 1576
 	}
1577 1577
 	public function offsetExists($offset)
1578 1578
 	{
1579
-		return ($offset>=0&&$offset<$this->getCount());
1579
+		return ($offset >= 0 && $offset < $this->getCount());
1580 1580
 	}
1581 1581
 	public function offsetGet($offset)
1582 1582
 	{
1583 1583
 		return $this->itemAt($offset);
1584 1584
 	}
1585
-	public function offsetSet($offset,$item)
1585
+	public function offsetSet($offset, $item)
1586 1586
 	{
1587
-		if($offset===null)
1587
+		if ($offset === null)
1588 1588
 			return $this->add($item);
1589
-		if($offset===$this->getCount()) {
1590
-			$priority=$this->priorityAt($offset-1,true);
1589
+		if ($offset === $this->getCount()) {
1590
+			$priority = $this->priorityAt($offset - 1, true);
1591 1591
 			$priority[1]++;
1592 1592
 		} else {
1593
-			$priority=$this->priorityAt($offset,true);
1594
-			$this->removeAtIndexInPriority($priority[1],$priority[0]);
1593
+			$priority = $this->priorityAt($offset, true);
1594
+			$this->removeAtIndexInPriority($priority[1], $priority[0]);
1595 1595
 		}
1596
-		$this->insertAtIndexInPriority($item,$priority[1],$priority[0]);
1596
+		$this->insertAtIndexInPriority($item, $priority[1], $priority[0]);
1597 1597
 	}
1598 1598
 	public function offsetUnset($offset)
1599 1599
 	{
1600 1600
 		$this->removeAt($offset);
1601 1601
 	}
1602 1602
 }
1603
-class TMap extends TComponent implements IteratorAggregate,ArrayAccess,Countable
1603
+class TMap extends TComponent implements IteratorAggregate, ArrayAccess, Countable
1604 1604
 {
1605
-	private $_d=array();
1606
-	private $_r=false;
1607
-	public function __construct($data=null,$readOnly=false)
1605
+	private $_d = array();
1606
+	private $_r = false;
1607
+	public function __construct($data = null, $readOnly = false)
1608 1608
 	{
1609
-		if($data!==null)
1609
+		if ($data !== null)
1610 1610
 			$this->copyFrom($data);
1611 1611
 		$this->setReadOnly($readOnly);
1612 1612
 	}
@@ -1616,11 +1616,11 @@  discard block
 block discarded – undo
1616 1616
 	}
1617 1617
 	protected function setReadOnly($value)
1618 1618
 	{
1619
-		$this->_r=TPropertyValue::ensureBoolean($value);
1619
+		$this->_r = TPropertyValue::ensureBoolean($value);
1620 1620
 	}
1621 1621
 	public function getIterator()
1622 1622
 	{
1623
-		return new ArrayIterator( $this->_d );
1623
+		return new ArrayIterator($this->_d);
1624 1624
 	}
1625 1625
 	public function count()
1626 1626
 	{
@@ -1638,20 +1638,20 @@  discard block
 block discarded – undo
1638 1638
 	{
1639 1639
 		return isset($this->_d[$key]) ? $this->_d[$key] : null;
1640 1640
 	}
1641
-	public function add($key,$value)
1641
+	public function add($key, $value)
1642 1642
 	{
1643
-		if(!$this->_r)
1644
-			$this->_d[$key]=$value;
1643
+		if (!$this->_r)
1644
+			$this->_d[$key] = $value;
1645 1645
 		else
1646
-			throw new TInvalidOperationException('map_readonly',get_class($this));
1646
+			throw new TInvalidOperationException('map_readonly', get_class($this));
1647 1647
 	}
1648 1648
 	public function remove($key)
1649 1649
 	{
1650
-		if(!$this->_r)
1650
+		if (!$this->_r)
1651 1651
 		{
1652
-			if(isset($this->_d[$key]) || array_key_exists($key,$this->_d))
1652
+			if (isset($this->_d[$key]) || array_key_exists($key, $this->_d))
1653 1653
 			{
1654
-				$value=$this->_d[$key];
1654
+				$value = $this->_d[$key];
1655 1655
 				unset($this->_d[$key]);
1656 1656
 				return $value;
1657 1657
 			}
@@ -1659,16 +1659,16 @@  discard block
 block discarded – undo
1659 1659
 				return null;
1660 1660
 		}
1661 1661
 		else
1662
-			throw new TInvalidOperationException('map_readonly',get_class($this));
1662
+			throw new TInvalidOperationException('map_readonly', get_class($this));
1663 1663
 	}
1664 1664
 	public function clear()
1665 1665
 	{
1666
-		foreach(array_keys($this->_d) as $key)
1666
+		foreach (array_keys($this->_d) as $key)
1667 1667
 			$this->remove($key);
1668 1668
 	}
1669 1669
 	public function contains($key)
1670 1670
 	{
1671
-		return isset($this->_d[$key]) || array_key_exists($key,$this->_d);
1671
+		return isset($this->_d[$key]) || array_key_exists($key, $this->_d);
1672 1672
 	}
1673 1673
 	public function toArray()
1674 1674
 	{
@@ -1676,24 +1676,24 @@  discard block
 block discarded – undo
1676 1676
 	}
1677 1677
 	public function copyFrom($data)
1678 1678
 	{
1679
-		if(is_array($data) || $data instanceof Traversable)
1679
+		if (is_array($data) || $data instanceof Traversable)
1680 1680
 		{
1681
-			if($this->getCount()>0)
1681
+			if ($this->getCount() > 0)
1682 1682
 				$this->clear();
1683
-			foreach($data as $key=>$value)
1684
-				$this->add($key,$value);
1683
+			foreach ($data as $key=>$value)
1684
+				$this->add($key, $value);
1685 1685
 		}
1686
-		else if($data!==null)
1686
+		else if ($data !== null)
1687 1687
 			throw new TInvalidDataTypeException('map_data_not_iterable');
1688 1688
 	}
1689 1689
 	public function mergeWith($data)
1690 1690
 	{
1691
-		if(is_array($data) || $data instanceof Traversable)
1691
+		if (is_array($data) || $data instanceof Traversable)
1692 1692
 		{
1693
-			foreach($data as $key=>$value)
1694
-				$this->add($key,$value);
1693
+			foreach ($data as $key=>$value)
1694
+				$this->add($key, $value);
1695 1695
 		}
1696
-		else if($data!==null)
1696
+		else if ($data !== null)
1697 1697
 			throw new TInvalidDataTypeException('map_data_not_iterable');
1698 1698
 	}
1699 1699
 	public function offsetExists($offset)
@@ -1704,9 +1704,9 @@  discard block
 block discarded – undo
1704 1704
 	{
1705 1705
 		return $this->itemAt($offset);
1706 1706
 	}
1707
-	public function offsetSet($offset,$item)
1707
+	public function offsetSet($offset, $item)
1708 1708
 	{
1709
-		$this->add($offset,$item);
1709
+		$this->add($offset, $item);
1710 1710
 	}
1711 1711
 	public function offsetUnset($offset)
1712 1712
 	{
@@ -1720,12 +1720,12 @@  discard block
 block discarded – undo
1720 1720
 	private $_key;
1721 1721
 	public function __construct(&$data)
1722 1722
 	{
1723
-		$this->_d=&$data;
1724
-		$this->_keys=array_keys($data);
1723
+		$this->_d = &$data;
1724
+		$this->_keys = array_keys($data);
1725 1725
 	}
1726 1726
 	public function rewind()
1727 1727
 	{
1728
-		$this->_key=reset($this->_keys);
1728
+		$this->_key = reset($this->_keys);
1729 1729
 	}
1730 1730
 	public function key()
1731 1731
 	{
@@ -1737,25 +1737,25 @@  discard block
 block discarded – undo
1737 1737
 	}
1738 1738
 	public function next()
1739 1739
 	{
1740
-		$this->_key=next($this->_keys);
1740
+		$this->_key = next($this->_keys);
1741 1741
 	}
1742 1742
 	public function valid()
1743 1743
 	{
1744
-		return $this->_key!==false;
1744
+		return $this->_key !== false;
1745 1745
 	}
1746 1746
 }
1747 1747
 class TPriorityMap extends TMap
1748 1748
 {
1749
-	private $_d=array();
1750
-	private $_r=false;
1751
-	private $_o=false;
1752
-	private $_fd=null;
1753
-	private $_c=0;
1754
-	private $_dp=10;
1755
-	private $_p=8;
1756
-	public function __construct($data=null,$readOnly=false,$defaultPriority=10,$precision=8)
1757
-	{
1758
-		if($data!==null)
1749
+	private $_d = array();
1750
+	private $_r = false;
1751
+	private $_o = false;
1752
+	private $_fd = null;
1753
+	private $_c = 0;
1754
+	private $_dp = 10;
1755
+	private $_p = 8;
1756
+	public function __construct($data = null, $readOnly = false, $defaultPriority = 10, $precision = 8)
1757
+	{
1758
+		if ($data !== null)
1759 1759
 			$this->copyFrom($data);
1760 1760
 		$this->setReadOnly($readOnly);
1761 1761
 		$this->setPrecision($precision);
@@ -1767,7 +1767,7 @@  discard block
 block discarded – undo
1767 1767
 	}
1768 1768
 	protected function setReadOnly($value)
1769 1769
 	{
1770
-		$this->_r=TPropertyValue::ensureBoolean($value);
1770
+		$this->_r = TPropertyValue::ensureBoolean($value);
1771 1771
 	}
1772 1772
 	public function getDefaultPriority()
1773 1773
 	{
@@ -1775,7 +1775,7 @@  discard block
 block discarded – undo
1775 1775
 	}
1776 1776
 	protected function setDefaultPriority($value)
1777 1777
 	{
1778
-		$this->_dp = (string)round(TPropertyValue::ensureFloat($value), $this->_p);
1778
+		$this->_dp = (string) round(TPropertyValue::ensureFloat($value), $this->_p);
1779 1779
 	}
1780 1780
 	public function getPrecision()
1781 1781
 	{
@@ -1783,24 +1783,24 @@  discard block
 block discarded – undo
1783 1783
 	}
1784 1784
 	protected function setPrecision($value)
1785 1785
 	{
1786
-		$this->_p=TPropertyValue::ensureInteger($value);
1786
+		$this->_p = TPropertyValue::ensureInteger($value);
1787 1787
 	}
1788 1788
 	public function getIterator()
1789 1789
 	{
1790 1790
 		return new ArrayIterator($this->flattenPriorities());
1791 1791
 	}
1792 1792
 	protected function sortPriorities() {
1793
-		if(!$this->_o) {
1793
+		if (!$this->_o) {
1794 1794
 			ksort($this->_d, SORT_NUMERIC);
1795
-			$this->_o=true;
1795
+			$this->_o = true;
1796 1796
 		}
1797 1797
 	}
1798 1798
 	protected function flattenPriorities() {
1799
-		if(is_array($this->_fd))
1799
+		if (is_array($this->_fd))
1800 1800
 			return $this->_fd;
1801 1801
 		$this->sortPriorities();
1802 1802
 		$this->_fd = array();
1803
-		foreach($this->_d as $priority => $itemsatpriority)
1803
+		foreach ($this->_d as $priority => $itemsatpriority)
1804 1804
 			$this->_fd = array_merge($this->_fd, $itemsatpriority);
1805 1805
 		return $this->_fd;
1806 1806
 	}
@@ -1812,12 +1812,12 @@  discard block
 block discarded – undo
1812 1812
 	{
1813 1813
 		return $this->_c;
1814 1814
 	}
1815
-	public function getPriorityCount($priority=null)
1815
+	public function getPriorityCount($priority = null)
1816 1816
 	{
1817
-		if($priority===null)
1818
-			$priority=$this->getDefaultPriority();
1819
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1820
-		if(!isset($this->_d[$priority])||!is_array($this->_d[$priority]))
1817
+		if ($priority === null)
1818
+			$priority = $this->getDefaultPriority();
1819
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
1820
+		if (!isset($this->_d[$priority]) || !is_array($this->_d[$priority]))
1821 1821
 			return false;
1822 1822
 		return count($this->_d[$priority]);
1823 1823
 	}
@@ -1830,119 +1830,119 @@  discard block
 block discarded – undo
1830 1830
 	{
1831 1831
 		return array_keys($this->flattenPriorities());
1832 1832
 	}
1833
-	public function itemAt($key,$priority=false)
1833
+	public function itemAt($key, $priority = false)
1834 1834
 	{
1835
-		if($priority===false){
1836
-			$map=$this->flattenPriorities();
1837
-			return isset($map[$key])?$map[$key]:null;
1835
+		if ($priority === false) {
1836
+			$map = $this->flattenPriorities();
1837
+			return isset($map[$key]) ? $map[$key] : null;
1838 1838
 		} else {
1839
-			if($priority===null)
1840
-				$priority=$this->getDefaultPriority();
1841
-			$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1842
-			return (isset($this->_d[$priority])&&isset($this->_d[$priority][$key]))?$this->_d[$priority][$key]:null;
1839
+			if ($priority === null)
1840
+				$priority = $this->getDefaultPriority();
1841
+			$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
1842
+			return (isset($this->_d[$priority]) && isset($this->_d[$priority][$key])) ? $this->_d[$priority][$key] : null;
1843 1843
 		}
1844 1844
 	}
1845
-	public function setPriorityAt($key,$priority=null)
1845
+	public function setPriorityAt($key, $priority = null)
1846 1846
 	{
1847
-		if($priority===null)
1848
-			$priority=$this->getDefaultPriority();
1849
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1850
-		$oldpriority=$this->priorityAt($key);
1851
-		if($oldpriority!==false&&$oldpriority!=$priority) {
1852
-			$value=$this->remove($key,$oldpriority);
1853
-			$this->add($key,$value,$priority);
1847
+		if ($priority === null)
1848
+			$priority = $this->getDefaultPriority();
1849
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
1850
+		$oldpriority = $this->priorityAt($key);
1851
+		if ($oldpriority !== false && $oldpriority != $priority) {
1852
+			$value = $this->remove($key, $oldpriority);
1853
+			$this->add($key, $value, $priority);
1854 1854
 		}
1855 1855
 		return $oldpriority;
1856 1856
 	}
1857
-	public function itemsAtPriority($priority=null)
1857
+	public function itemsAtPriority($priority = null)
1858 1858
 	{
1859
-		if($priority===null)
1860
-			$priority=$this->getDefaultPriority();
1861
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1862
-		return isset($this->_d[$priority])?$this->_d[$priority]:null;
1859
+		if ($priority === null)
1860
+			$priority = $this->getDefaultPriority();
1861
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
1862
+		return isset($this->_d[$priority]) ? $this->_d[$priority] : null;
1863 1863
 	}
1864 1864
 	public function priorityOf($item)
1865 1865
 	{
1866 1866
 		$this->sortPriorities();
1867
-		foreach($this->_d as $priority=>$items)
1868
-			if(($index=array_search($item,$items,true))!==false)
1867
+		foreach ($this->_d as $priority=>$items)
1868
+			if (($index = array_search($item, $items, true)) !== false)
1869 1869
 				return $priority;
1870 1870
 		return false;
1871 1871
 	}
1872 1872
 	public function priorityAt($key)
1873 1873
 	{
1874 1874
 		$this->sortPriorities();
1875
-		foreach($this->_d as $priority=>$items)
1876
-			if(array_key_exists($key,$items))
1875
+		foreach ($this->_d as $priority=>$items)
1876
+			if (array_key_exists($key, $items))
1877 1877
 				return $priority;
1878 1878
 		return false;
1879 1879
 	}
1880
-	public function add($key,$value,$priority=null)
1880
+	public function add($key, $value, $priority = null)
1881 1881
 	{
1882
-		if($priority===null)
1883
-			$priority=$this->getDefaultPriority();
1884
-		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1885
-		if(!$this->_r)
1882
+		if ($priority === null)
1883
+			$priority = $this->getDefaultPriority();
1884
+		$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
1885
+		if (!$this->_r)
1886 1886
 		{
1887
-			foreach($this->_d as $innerpriority=>$items)
1888
-				if(array_key_exists($key,$items))
1887
+			foreach ($this->_d as $innerpriority=>$items)
1888
+				if (array_key_exists($key, $items))
1889 1889
 				{
1890 1890
 					unset($this->_d[$innerpriority][$key]);
1891 1891
 					$this->_c--;
1892
-					if(count($this->_d[$innerpriority])===0)
1892
+					if (count($this->_d[$innerpriority]) === 0)
1893 1893
 						unset($this->_d[$innerpriority]);
1894 1894
 				}
1895
-			if(!isset($this->_d[$priority])) {
1896
-				$this->_d[$priority]=array($key=>$value);
1897
-				$this->_o=false;
1895
+			if (!isset($this->_d[$priority])) {
1896
+				$this->_d[$priority] = array($key=>$value);
1897
+				$this->_o = false;
1898 1898
 			}
1899 1899
 			else
1900
-				$this->_d[$priority][$key]=$value;
1900
+				$this->_d[$priority][$key] = $value;
1901 1901
 			$this->_c++;
1902
-			$this->_fd=null;
1902
+			$this->_fd = null;
1903 1903
 		}
1904 1904
 		else
1905
-			throw new TInvalidOperationException('map_readonly',get_class($this));
1905
+			throw new TInvalidOperationException('map_readonly', get_class($this));
1906 1906
 		return $priority;
1907 1907
 	}
1908
-	public function remove($key,$priority=false)
1908
+	public function remove($key, $priority = false)
1909 1909
 	{
1910
-		if(!$this->_r)
1910
+		if (!$this->_r)
1911 1911
 		{
1912
-			if($priority===null)
1913
-				$priority=$this->getDefaultPriority();
1914
-			if($priority===false)
1912
+			if ($priority === null)
1913
+				$priority = $this->getDefaultPriority();
1914
+			if ($priority === false)
1915 1915
 			{
1916 1916
 				$this->sortPriorities();
1917
-				foreach($this->_d as $priority=>$items)
1918
-					if(array_key_exists($key,$items))
1917
+				foreach ($this->_d as $priority=>$items)
1918
+					if (array_key_exists($key, $items))
1919 1919
 					{
1920
-						$value=$this->_d[$priority][$key];
1920
+						$value = $this->_d[$priority][$key];
1921 1921
 						unset($this->_d[$priority][$key]);
1922 1922
 						$this->_c--;
1923
-						if(count($this->_d[$priority])===0)
1923
+						if (count($this->_d[$priority]) === 0)
1924 1924
 						{
1925 1925
 							unset($this->_d[$priority]);
1926
-							$this->_o=false;
1926
+							$this->_o = false;
1927 1927
 						}
1928
-						$this->_fd=null;
1928
+						$this->_fd = null;
1929 1929
 						return $value;
1930 1930
 					}
1931 1931
 				return null;
1932 1932
 			}
1933 1933
 			else
1934 1934
 			{
1935
-				$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1936
-				if(isset($this->_d[$priority])&&(isset($this->_d[$priority][$key])||array_key_exists($key,$this->_d[$priority])))
1935
+				$priority = (string) round(TPropertyValue::ensureFloat($priority), $this->_p);
1936
+				if (isset($this->_d[$priority]) && (isset($this->_d[$priority][$key]) || array_key_exists($key, $this->_d[$priority])))
1937 1937
 				{
1938
-					$value=$this->_d[$priority][$key];
1938
+					$value = $this->_d[$priority][$key];
1939 1939
 					unset($this->_d[$priority][$key]);
1940 1940
 					$this->_c--;
1941
-					if(count($this->_d[$priority])===0) {
1941
+					if (count($this->_d[$priority]) === 0) {
1942 1942
 						unset($this->_d[$priority]);
1943
-						$this->_o=false;
1943
+						$this->_o = false;
1944 1944
 					}
1945
-					$this->_fd=null;
1945
+					$this->_fd = null;
1946 1946
 					return $value;
1947 1947
 				}
1948 1948
 				else
@@ -1950,85 +1950,85 @@  discard block
 block discarded – undo
1950 1950
 			}
1951 1951
 		}
1952 1952
 		else
1953
-			throw new TInvalidOperationException('map_readonly',get_class($this));
1953
+			throw new TInvalidOperationException('map_readonly', get_class($this));
1954 1954
 	}
1955 1955
 	public function clear()
1956 1956
 	{
1957
-		foreach($this->_d as $priority=>$items)
1958
-			foreach(array_keys($items) as $key)
1957
+		foreach ($this->_d as $priority=>$items)
1958
+			foreach (array_keys($items) as $key)
1959 1959
 				$this->remove($key);
1960 1960
 	}
1961 1961
 	public function contains($key)
1962 1962
 	{
1963
-		$map=$this->flattenPriorities();
1964
-		return isset($map[$key])||array_key_exists($key,$map);
1963
+		$map = $this->flattenPriorities();
1964
+		return isset($map[$key]) || array_key_exists($key, $map);
1965 1965
 	}
1966 1966
 	public function toArray()
1967 1967
 	{
1968 1968
 		return $this->flattenPriorities();
1969 1969
 	}
1970
-	public function toArrayBelowPriority($priority,$inclusive=false)
1970
+	public function toArrayBelowPriority($priority, $inclusive = false)
1971 1971
 	{
1972 1972
 		$this->sortPriorities();
1973
-		$items=array();
1974
-		foreach($this->_d as $itemspriority=>$itemsatpriority)
1973
+		$items = array();
1974
+		foreach ($this->_d as $itemspriority=>$itemsatpriority)
1975 1975
 		{
1976
-			if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority)
1976
+			if ((!$inclusive && $itemspriority >= $priority) || $itemspriority > $priority)
1977 1977
 				break;
1978
-			$items=array_merge($items,$itemsatpriority);
1978
+			$items = array_merge($items, $itemsatpriority);
1979 1979
 		}
1980 1980
 		return $items;
1981 1981
 	}
1982
-	public function toArrayAbovePriority($priority,$inclusive=true)
1982
+	public function toArrayAbovePriority($priority, $inclusive = true)
1983 1983
 	{
1984 1984
 		$this->sortPriorities();
1985
-		$items=array();
1986
-		foreach($this->_d as $itemspriority=>$itemsatpriority)
1985
+		$items = array();
1986
+		foreach ($this->_d as $itemspriority=>$itemsatpriority)
1987 1987
 		{
1988
-			if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority)
1988
+			if ((!$inclusive && $itemspriority <= $priority) || $itemspriority < $priority)
1989 1989
 				continue;
1990
-			$items=array_merge($items,$itemsatpriority);
1990
+			$items = array_merge($items, $itemsatpriority);
1991 1991
 		}
1992 1992
 		return $items;
1993 1993
 	}
1994 1994
 	public function copyFrom($data)
1995 1995
 	{
1996
-		if($data instanceof TPriorityMap)
1996
+		if ($data instanceof TPriorityMap)
1997 1997
 		{
1998
-			if($this->getCount()>0)
1998
+			if ($this->getCount() > 0)
1999 1999
 				$this->clear();
2000
-			foreach($data->getPriorities() as $priority) {
2001
-				foreach($data->itemsAtPriority($priority) as $key => $value) {
2002
-					$this->add($key,$value,$priority);
2000
+			foreach ($data->getPriorities() as $priority) {
2001
+				foreach ($data->itemsAtPriority($priority) as $key => $value) {
2002
+					$this->add($key, $value, $priority);
2003 2003
 				}
2004 2004
 			}
2005 2005
 		}
2006
-		else if(is_array($data)||$data instanceof Traversable)
2006
+		else if (is_array($data) || $data instanceof Traversable)
2007 2007
 		{
2008
-			if($this->getCount()>0)
2008
+			if ($this->getCount() > 0)
2009 2009
 				$this->clear();
2010
-			foreach($data as $key=>$value)
2011
-				$this->add($key,$value);
2010
+			foreach ($data as $key=>$value)
2011
+				$this->add($key, $value);
2012 2012
 		}
2013
-		else if($data!==null)
2013
+		else if ($data !== null)
2014 2014
 			throw new TInvalidDataTypeException('map_data_not_iterable');
2015 2015
 	}
2016 2016
 	public function mergeWith($data)
2017 2017
 	{
2018
-		if($data instanceof TPriorityMap)
2018
+		if ($data instanceof TPriorityMap)
2019 2019
 		{
2020
-			foreach($data->getPriorities() as $priority)
2020
+			foreach ($data->getPriorities() as $priority)
2021 2021
 			{
2022
-				foreach($data->itemsAtPriority($priority) as $key => $value)
2023
-					$this->add($key,$value,$priority);
2022
+				foreach ($data->itemsAtPriority($priority) as $key => $value)
2023
+					$this->add($key, $value, $priority);
2024 2024
 			}
2025 2025
 		}
2026
-		else if(is_array($data)||$data instanceof Traversable)
2026
+		else if (is_array($data) || $data instanceof Traversable)
2027 2027
 		{
2028
-			foreach($data as $key=>$value)
2029
-				$this->add($key,$value);
2028
+			foreach ($data as $key=>$value)
2029
+				$this->add($key, $value);
2030 2030
 		}
2031
-		else if($data!==null)
2031
+		else if ($data !== null)
2032 2032
 			throw new TInvalidDataTypeException('map_data_not_iterable');
2033 2033
 	}
2034 2034
 	public function offsetExists($offset)
@@ -2039,22 +2039,22 @@  discard block
 block discarded – undo
2039 2039
 	{
2040 2040
 		return $this->itemAt($offset);
2041 2041
 	}
2042
-	public function offsetSet($offset,$item)
2042
+	public function offsetSet($offset, $item)
2043 2043
 	{
2044
-		$this->add($offset,$item);
2044
+		$this->add($offset, $item);
2045 2045
 	}
2046 2046
 	public function offsetUnset($offset)
2047 2047
 	{
2048 2048
 		$this->remove($offset);
2049 2049
 	}
2050 2050
 }
2051
-class TStack extends TComponent implements IteratorAggregate,Countable
2051
+class TStack extends TComponent implements IteratorAggregate, Countable
2052 2052
 {
2053
-	private $_d=array();
2054
-	private $_c=0;
2055
-	public function __construct($data=null)
2053
+	private $_d = array();
2054
+	private $_c = 0;
2055
+	public function __construct($data = null)
2056 2056
 	{
2057
-		if($data!==null)
2057
+		if ($data !== null)
2058 2058
 			$this->copyFrom($data);
2059 2059
 	}
2060 2060
 	public function toArray()
@@ -2063,37 +2063,37 @@  discard block
 block discarded – undo
2063 2063
 	}
2064 2064
 	public function copyFrom($data)
2065 2065
 	{
2066
-		if(is_array($data) || ($data instanceof Traversable))
2066
+		if (is_array($data) || ($data instanceof Traversable))
2067 2067
 		{
2068 2068
 			$this->clear();
2069
-			foreach($data as $item)
2069
+			foreach ($data as $item)
2070 2070
 			{
2071
-				$this->_d[]=$item;
2071
+				$this->_d[] = $item;
2072 2072
 				++$this->_c;
2073 2073
 			}
2074 2074
 		}
2075
-		else if($data!==null)
2075
+		else if ($data !== null)
2076 2076
 			throw new TInvalidDataTypeException('stack_data_not_iterable');
2077 2077
 	}
2078 2078
 	public function clear()
2079 2079
 	{
2080
-		$this->_c=0;
2081
-		$this->_d=array();
2080
+		$this->_c = 0;
2081
+		$this->_d = array();
2082 2082
 	}
2083 2083
 	public function contains($item)
2084 2084
 	{
2085
-		return array_search($item,$this->_d,true)!==false;
2085
+		return array_search($item, $this->_d, true) !== false;
2086 2086
 	}
2087 2087
 	public function peek()
2088 2088
 	{
2089
-		if($this->_c===0)
2089
+		if ($this->_c === 0)
2090 2090
 			throw new TInvalidOperationException('stack_empty');
2091 2091
 		else
2092
-			return $this->_d[$this->_c-1];
2092
+			return $this->_d[$this->_c - 1];
2093 2093
 	}
2094 2094
 	public function pop()
2095 2095
 	{
2096
-		if($this->_c===0)
2096
+		if ($this->_c === 0)
2097 2097
 			throw new TInvalidOperationException('stack_empty');
2098 2098
 		else
2099 2099
 		{
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
 	}
2109 2109
 	public function getIterator()
2110 2110
 	{
2111
-		return new ArrayIterator( $this->_d );
2111
+		return new ArrayIterator($this->_d);
2112 2112
 	}
2113 2113
 	public function getCount()
2114 2114
 	{
@@ -2126,13 +2126,13 @@  discard block
 block discarded – undo
2126 2126
 	private $_c;
2127 2127
 	public function __construct(&$data)
2128 2128
 	{
2129
-		$this->_d=&$data;
2130
-		$this->_i=0;
2131
-		$this->_c=count($this->_d);
2129
+		$this->_d = &$data;
2130
+		$this->_i = 0;
2131
+		$this->_c = count($this->_d);
2132 2132
 	}
2133 2133
 	public function rewind()
2134 2134
 	{
2135
-		$this->_i=0;
2135
+		$this->_i = 0;
2136 2136
 	}
2137 2137
 	public function key()
2138 2138
 	{
@@ -2148,16 +2148,16 @@  discard block
 block discarded – undo
2148 2148
 	}
2149 2149
 	public function valid()
2150 2150
 	{
2151
-		return $this->_i<$this->_c;
2151
+		return $this->_i < $this->_c;
2152 2152
 	}
2153 2153
 }
2154 2154
 class TXmlElement extends TComponent
2155 2155
 {
2156
-	private $_parent=null;
2157
-	private $_tagName='unknown';
2158
-	private $_value='';
2159
-	private $_elements=null;
2160
-	private $_attributes=null;
2156
+	private $_parent = null;
2157
+	private $_tagName = 'unknown';
2158
+	private $_value = '';
2159
+	private $_elements = null;
2160
+	private $_attributes = null;
2161 2161
 	public function __construct($tagName)
2162 2162
 	{
2163 2163
 		$this->setTagName($tagName);
@@ -2168,7 +2168,7 @@  discard block
 block discarded – undo
2168 2168
 	}
2169 2169
 	public function setParent($parent)
2170 2170
 	{
2171
-		$this->_parent=$parent;
2171
+		$this->_parent = $parent;
2172 2172
 	}
2173 2173
 	public function getTagName()
2174 2174
 	{
@@ -2176,7 +2176,7 @@  discard block
 block discarded – undo
2176 2176
 	}
2177 2177
 	public function setTagName($tagName)
2178 2178
 	{
2179
-		$this->_tagName=$tagName;
2179
+		$this->_tagName = $tagName;
2180 2180
 	}
2181 2181
 	public function getValue()
2182 2182
 	{
@@ -2184,87 +2184,87 @@  discard block
 block discarded – undo
2184 2184
 	}
2185 2185
 	public function setValue($value)
2186 2186
 	{
2187
-		$this->_value=TPropertyValue::ensureString($value);
2187
+		$this->_value = TPropertyValue::ensureString($value);
2188 2188
 	}
2189 2189
 	public function getHasElement()
2190 2190
 	{
2191
-		return $this->_elements!==null && $this->_elements->getCount()>0;
2191
+		return $this->_elements !== null && $this->_elements->getCount() > 0;
2192 2192
 	}
2193 2193
 	public function getHasAttribute()
2194 2194
 	{
2195
-		return $this->_attributes!==null && $this->_attributes->getCount()>0;
2195
+		return $this->_attributes !== null && $this->_attributes->getCount() > 0;
2196 2196
 	}
2197 2197
 	public function getAttribute($name)
2198 2198
 	{
2199
-		if($this->_attributes!==null)
2199
+		if ($this->_attributes !== null)
2200 2200
 			return $this->_attributes->itemAt($name);
2201 2201
 		else
2202 2202
 			return null;
2203 2203
 	}
2204
-	public function setAttribute($name,$value)
2204
+	public function setAttribute($name, $value)
2205 2205
 	{
2206
-		$this->getAttributes()->add($name,TPropertyValue::ensureString($value));
2206
+		$this->getAttributes()->add($name, TPropertyValue::ensureString($value));
2207 2207
 	}
2208 2208
 	public function getElements()
2209 2209
 	{
2210
-		if(!$this->_elements)
2211
-			$this->_elements=new TXmlElementList($this);
2210
+		if (!$this->_elements)
2211
+			$this->_elements = new TXmlElementList($this);
2212 2212
 		return $this->_elements;
2213 2213
 	}
2214 2214
 	public function getAttributes()
2215 2215
 	{
2216
-		if(!$this->_attributes)
2217
-			$this->_attributes=new TMap;
2216
+		if (!$this->_attributes)
2217
+			$this->_attributes = new TMap;
2218 2218
 		return $this->_attributes;
2219 2219
 	}
2220 2220
 	public function getElementByTagName($tagName)
2221 2221
 	{
2222
-		if($this->_elements)
2222
+		if ($this->_elements)
2223 2223
 		{
2224
-			foreach($this->_elements as $element)
2225
-				if($element->_tagName===$tagName)
2224
+			foreach ($this->_elements as $element)
2225
+				if ($element->_tagName === $tagName)
2226 2226
 					return $element;
2227 2227
 		}
2228 2228
 		return null;
2229 2229
 	}
2230 2230
 	public function getElementsByTagName($tagName)
2231 2231
 	{
2232
-		$list=new TList;
2233
-		if($this->_elements)
2232
+		$list = new TList;
2233
+		if ($this->_elements)
2234 2234
 		{
2235
-			foreach($this->_elements as $element)
2236
-				if($element->_tagName===$tagName)
2235
+			foreach ($this->_elements as $element)
2236
+				if ($element->_tagName === $tagName)
2237 2237
 					$list->add($element);
2238 2238
 		}
2239 2239
 		return $list;
2240 2240
 	}
2241
-	public function toString($indent=0)
2241
+	public function toString($indent = 0)
2242 2242
 	{
2243
-		$attr='';
2244
-		if($this->_attributes!==null)
2243
+		$attr = '';
2244
+		if ($this->_attributes !== null)
2245 2245
 		{
2246
-			foreach($this->_attributes as $name=>$value)
2246
+			foreach ($this->_attributes as $name=>$value)
2247 2247
 			{
2248
-				$value=$this->xmlEncode($value);
2249
-				$attr.=" $name=\"$value\"";
2248
+				$value = $this->xmlEncode($value);
2249
+				$attr .= " $name=\"$value\"";
2250 2250
 			}
2251 2251
 		}
2252
-		$prefix=str_repeat(' ',$indent*4);
2253
-		if($this->getHasElement())
2252
+		$prefix = str_repeat(' ', $indent * 4);
2253
+		if ($this->getHasElement())
2254 2254
 		{
2255
-			$str=$prefix."<{$this->_tagName}$attr>\n";
2256
-			foreach($this->getElements() as $element)
2257
-				$str.=$element->toString($indent+1)."\n";
2258
-			$str.=$prefix."</{$this->_tagName}>";
2255
+			$str = $prefix . "<{$this->_tagName}$attr>\n";
2256
+			foreach ($this->getElements() as $element)
2257
+				$str .= $element->toString($indent + 1) . "\n";
2258
+			$str .= $prefix . "</{$this->_tagName}>";
2259 2259
 			return $str;
2260 2260
 		}
2261
-		else if(($value=$this->getValue())!=='')
2261
+		else if (($value = $this->getValue()) !== '')
2262 2262
 		{
2263
-			$value=$this->xmlEncode($value);
2264
-			return $prefix."<{$this->_tagName}$attr>$value</{$this->_tagName}>";
2263
+			$value = $this->xmlEncode($value);
2264
+			return $prefix . "<{$this->_tagName}$attr>$value</{$this->_tagName}>";
2265 2265
 		}
2266 2266
 		else
2267
-			return $prefix."<{$this->_tagName}$attr />";
2267
+			return $prefix . "<{$this->_tagName}$attr />";
2268 2268
 	}
2269 2269
 	public function __toString()
2270 2270
 	{
@@ -2272,7 +2272,7 @@  discard block
 block discarded – undo
2272 2272
 	}
2273 2273
 	private function xmlEncode($str)
2274 2274
 	{
2275
-		return strtr($str,array(
2275
+		return strtr($str, array(
2276 2276
 			'>'=>'&gt;',
2277 2277
 			'<'=>'&lt;',
2278 2278
 			'&'=>'&amp;',
@@ -2286,7 +2286,7 @@  discard block
 block discarded – undo
2286 2286
 {
2287 2287
 	private $_version;
2288 2288
 	private $_encoding;
2289
-	public function __construct($version='1.0',$encoding='')
2289
+	public function __construct($version = '1.0', $encoding = '')
2290 2290
 	{
2291 2291
 		parent::__construct('');
2292 2292
 		$this->setVersion($version);
@@ -2298,7 +2298,7 @@  discard block
 block discarded – undo
2298 2298
 	}
2299 2299
 	public function setVersion($version)
2300 2300
 	{
2301
-		$this->_version=$version;
2301
+		$this->_version = $version;
2302 2302
 	}
2303 2303
 	public function getEncoding()
2304 2304
 	{
@@ -2306,69 +2306,69 @@  discard block
 block discarded – undo
2306 2306
 	}
2307 2307
 	public function setEncoding($encoding)
2308 2308
 	{
2309
-		$this->_encoding=$encoding;
2309
+		$this->_encoding = $encoding;
2310 2310
 	}
2311 2311
 	public function loadFromFile($file)
2312 2312
 	{
2313
-		if(($str=@file_get_contents($file))!==false)
2313
+		if (($str = @file_get_contents($file)) !== false)
2314 2314
 			return $this->loadFromString($str);
2315 2315
 		else
2316
-			throw new TIOException('xmldocument_file_read_failed',$file);
2316
+			throw new TIOException('xmldocument_file_read_failed', $file);
2317 2317
 	}
2318 2318
 	public function loadFromString($string)
2319 2319
 	{
2320
-				$doc=new DOMDocument();
2321
-		if($doc->loadXML($string)===false)
2320
+				$doc = new DOMDocument();
2321
+		if ($doc->loadXML($string) === false)
2322 2322
 			return false;
2323 2323
 		$this->setEncoding($doc->encoding);
2324 2324
 		$this->setVersion($doc->version);
2325
-		$element=$doc->documentElement;
2325
+		$element = $doc->documentElement;
2326 2326
 		$this->setTagName($element->tagName);
2327 2327
 		$this->setValue($element->nodeValue);
2328
-		$elements=$this->getElements();
2329
-		$attributes=$this->getAttributes();
2328
+		$elements = $this->getElements();
2329
+		$attributes = $this->getAttributes();
2330 2330
 		$elements->clear();
2331 2331
 		$attributes->clear();
2332 2332
 		static $bSimpleXml;
2333
-		if($bSimpleXml === null)
2334
-			$bSimpleXml = (boolean)function_exists('simplexml_load_string');
2335
-		if($bSimpleXml)
2333
+		if ($bSimpleXml === null)
2334
+			$bSimpleXml = (boolean) function_exists('simplexml_load_string');
2335
+		if ($bSimpleXml)
2336 2336
 		{
2337 2337
 			$simpleDoc = simplexml_load_string($string);
2338 2338
 			$docNamespaces = $simpleDoc->getDocNamespaces(false);
2339 2339
 			$simpleDoc = null;
2340
-			foreach($docNamespaces as $prefix => $uri)
2340
+			foreach ($docNamespaces as $prefix => $uri)
2341 2341
 			{
2342
- 				if($prefix === '')
2342
+ 				if ($prefix === '')
2343 2343
    					$attributes->add('xmlns', $uri);
2344 2344
    				else
2345
-   					$attributes->add('xmlns:'.$prefix, $uri);
2345
+   					$attributes->add('xmlns:' . $prefix, $uri);
2346 2346
 			}
2347 2347
 		}
2348
-		foreach($element->attributes as $name=>$attr)
2349
-			$attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') .$name,$attr->value);
2350
-		foreach($element->childNodes as $child)
2348
+		foreach ($element->attributes as $name=>$attr)
2349
+			$attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name, $attr->value);
2350
+		foreach ($element->childNodes as $child)
2351 2351
 		{
2352
-			if($child instanceof DOMElement)
2352
+			if ($child instanceof DOMElement)
2353 2353
 				$elements->add($this->buildElement($child));
2354 2354
 		}
2355 2355
 		return true;
2356 2356
 	}
2357 2357
 	public function saveToFile($file)
2358 2358
 	{
2359
-		if(($fw=fopen($file,'w'))!==false)
2359
+		if (($fw = fopen($file, 'w')) !== false)
2360 2360
 		{
2361
-			fwrite($fw,$this->saveToString());
2361
+			fwrite($fw, $this->saveToString());
2362 2362
 			fclose($fw);
2363 2363
 		}
2364 2364
 		else
2365
-			throw new TIOException('xmldocument_file_write_failed',$file);
2365
+			throw new TIOException('xmldocument_file_write_failed', $file);
2366 2366
 	}
2367 2367
 	public function saveToString()
2368 2368
 	{
2369
-		$version=empty($this->_version)?' version="1.0"':' version="'.$this->_version.'"';
2370
-		$encoding=empty($this->_encoding)?'':' encoding="'.$this->_encoding.'"';
2371
-		return "<?xml{$version}{$encoding}?>\n".$this->toString(0);
2369
+		$version = empty($this->_version) ? ' version="1.0"' : ' version="' . $this->_version . '"';
2370
+		$encoding = empty($this->_encoding) ? '' : ' encoding="' . $this->_encoding . '"';
2371
+		return "<?xml{$version}{$encoding}?>\n" . $this->toString(0);
2372 2372
 	}
2373 2373
 	public function __toString()
2374 2374
 	{
@@ -2376,13 +2376,13 @@  discard block
 block discarded – undo
2376 2376
 	}
2377 2377
 	protected function buildElement($node)
2378 2378
 	{
2379
-		$element=new TXmlElement($node->tagName);
2379
+		$element = new TXmlElement($node->tagName);
2380 2380
 		$element->setValue($node->nodeValue);
2381
-		foreach($node->attributes as $name=>$attr)
2382
-			$element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name,$attr->value);
2383
-		foreach($node->childNodes as $child)
2381
+		foreach ($node->attributes as $name=>$attr)
2382
+			$element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name, $attr->value);
2383
+		foreach ($node->childNodes as $child)
2384 2384
 		{
2385
-			if($child instanceof DOMElement)
2385
+			if ($child instanceof DOMElement)
2386 2386
 				$element->getElements()->add($this->buildElement($child));
2387 2387
 		}
2388 2388
 		return $element;
@@ -2393,18 +2393,18 @@  discard block
 block discarded – undo
2393 2393
 	private $_o;
2394 2394
 	public function __construct(TXmlElement $owner)
2395 2395
 	{
2396
-		$this->_o=$owner;
2396
+		$this->_o = $owner;
2397 2397
 	}
2398 2398
 	protected function getOwner()
2399 2399
 	{
2400 2400
 		return $this->_o;
2401 2401
 	}
2402
-	public function insertAt($index,$item)
2402
+	public function insertAt($index, $item)
2403 2403
 	{
2404
-		if($item instanceof TXmlElement)
2404
+		if ($item instanceof TXmlElement)
2405 2405
 		{
2406
-			parent::insertAt($index,$item);
2407
-			if($item->getParent()!==null)
2406
+			parent::insertAt($index, $item);
2407
+			if ($item->getParent() !== null)
2408 2408
 				$item->getParent()->getElements()->remove($item);
2409 2409
 			$item->setParent($this->_o);
2410 2410
 		}
@@ -2413,8 +2413,8 @@  discard block
 block discarded – undo
2413 2413
 	}
2414 2414
 	public function removeAt($index)
2415 2415
 	{
2416
-		$item=parent::removeAt($index);
2417
-		if($item instanceof TXmlElement)
2416
+		$item = parent::removeAt($index);
2417
+		if ($item instanceof TXmlElement)
2418 2418
 			$item->setParent(null);
2419 2419
 		return $item;
2420 2420
 	}
@@ -2429,57 +2429,57 @@  discard block
 block discarded – undo
2429 2429
 	private $_everyone;
2430 2430
 	private $_guest;
2431 2431
 	private $_authenticated;
2432
-	public function __construct($action,$users,$roles,$verb='',$ipRules='')
2433
-	{
2434
-		$action=strtolower(trim($action));
2435
-		if($action==='allow' || $action==='deny')
2436
-			$this->_action=$action;
2437
-		else
2438
-			throw new TInvalidDataValueException('authorizationrule_action_invalid',$action);
2439
-		$this->_users=array();
2440
-		$this->_roles=array();
2441
-		$this->_ipRules=array();
2442
-		$this->_everyone=false;
2443
-		$this->_guest=false;
2444
-		$this->_authenticated=false;
2445
-		if(trim($users)==='')
2446
-			$users='*';
2447
-		foreach(explode(',',$users) as $user)
2448
-		{
2449
-			if(($user=trim(strtolower($user)))!=='')
2450
-			{
2451
-				if($user==='*')
2432
+	public function __construct($action, $users, $roles, $verb = '', $ipRules = '')
2433
+	{
2434
+		$action = strtolower(trim($action));
2435
+		if ($action === 'allow' || $action === 'deny')
2436
+			$this->_action = $action;
2437
+		else
2438
+			throw new TInvalidDataValueException('authorizationrule_action_invalid', $action);
2439
+		$this->_users = array();
2440
+		$this->_roles = array();
2441
+		$this->_ipRules = array();
2442
+		$this->_everyone = false;
2443
+		$this->_guest = false;
2444
+		$this->_authenticated = false;
2445
+		if (trim($users) === '')
2446
+			$users = '*';
2447
+		foreach (explode(',', $users) as $user)
2448
+		{
2449
+			if (($user = trim(strtolower($user))) !== '')
2450
+			{
2451
+				if ($user === '*')
2452 2452
 				{
2453
-					$this->_everyone=true;
2453
+					$this->_everyone = true;
2454 2454
 					break;
2455 2455
 				}
2456
-				else if($user==='?')
2457
-					$this->_guest=true;
2458
-				else if($user==='@')
2459
-					$this->_authenticated=true;
2456
+				else if ($user === '?')
2457
+					$this->_guest = true;
2458
+				else if ($user === '@')
2459
+					$this->_authenticated = true;
2460 2460
 				else
2461
-					$this->_users[]=$user;
2461
+					$this->_users[] = $user;
2462 2462
 			}
2463 2463
 		}
2464
-		if(trim($roles)==='')
2465
-			$roles='*';
2466
-		foreach(explode(',',$roles) as $role)
2464
+		if (trim($roles) === '')
2465
+			$roles = '*';
2466
+		foreach (explode(',', $roles) as $role)
2467 2467
 		{
2468
-			if(($role=trim(strtolower($role)))!=='')
2469
-				$this->_roles[]=$role;
2468
+			if (($role = trim(strtolower($role))) !== '')
2469
+				$this->_roles[] = $role;
2470 2470
 		}
2471
-		if(($verb=trim(strtolower($verb)))==='')
2472
-			$verb='*';
2473
-		if($verb==='*' || $verb==='get' || $verb==='post')
2474
-			$this->_verb=$verb;
2471
+		if (($verb = trim(strtolower($verb))) === '')
2472
+			$verb = '*';
2473
+		if ($verb === '*' || $verb === 'get' || $verb === 'post')
2474
+			$this->_verb = $verb;
2475 2475
 		else
2476
-			throw new TInvalidDataValueException('authorizationrule_verb_invalid',$verb);
2477
-		if(trim($ipRules)==='')
2478
-			$ipRules='*';
2479
-		foreach(explode(',',$ipRules) as $ipRule)
2476
+			throw new TInvalidDataValueException('authorizationrule_verb_invalid', $verb);
2477
+		if (trim($ipRules) === '')
2478
+			$ipRules = '*';
2479
+		foreach (explode(',', $ipRules) as $ipRule)
2480 2480
 		{
2481
-			if(($ipRule=trim($ipRule))!=='')
2482
-				$this->_ipRules[]=$ipRule;
2481
+			if (($ipRule = trim($ipRule)) !== '')
2482
+				$this->_ipRules[] = $ipRule;
2483 2483
 		}
2484 2484
 	}
2485 2485
 	public function getAction()
@@ -2514,63 +2514,63 @@  discard block
 block discarded – undo
2514 2514
 	{
2515 2515
 		return $this->_authenticated || $this->_everyone;
2516 2516
 	}
2517
-	public function isUserAllowed(IUser $user,$verb,$ip)
2517
+	public function isUserAllowed(IUser $user, $verb, $ip)
2518 2518
 	{
2519
-		if($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user))
2520
-			return ($this->_action==='allow')?1:-1;
2519
+		if ($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user))
2520
+			return ($this->_action === 'allow') ? 1 : -1;
2521 2521
 		else
2522 2522
 			return 0;
2523 2523
 	}
2524 2524
 	private function isIpMatched($ip)
2525 2525
 	{
2526
-		if(empty($this->_ipRules))
2526
+		if (empty($this->_ipRules))
2527 2527
 			return 1;
2528
-		foreach($this->_ipRules as $rule)
2528
+		foreach ($this->_ipRules as $rule)
2529 2529
 		{
2530
-			if($rule==='*' || $rule===$ip || (($pos=strpos($rule,'*'))!==false && strncmp($ip,$rule,$pos)===0))
2530
+			if ($rule === '*' || $rule === $ip || (($pos = strpos($rule, '*')) !== false && strncmp($ip, $rule, $pos) === 0))
2531 2531
 				return 1;
2532 2532
 		}
2533 2533
 		return 0;
2534 2534
 	}
2535 2535
 	private function isUserMatched($user)
2536 2536
 	{
2537
-		return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()),$this->_users));
2537
+		return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()), $this->_users));
2538 2538
 	}
2539 2539
 	private function isRoleMatched($user)
2540 2540
 	{
2541
-		foreach($this->_roles as $role)
2541
+		foreach ($this->_roles as $role)
2542 2542
 		{
2543
-			if($role==='*' || $user->isInRole($role))
2543
+			if ($role === '*' || $user->isInRole($role))
2544 2544
 				return true;
2545 2545
 		}
2546 2546
 		return false;
2547 2547
 	}
2548 2548
 	private function isVerbMatched($verb)
2549 2549
 	{
2550
-		return ($this->_verb==='*' || strcasecmp($verb,$this->_verb)===0);
2550
+		return ($this->_verb === '*' || strcasecmp($verb, $this->_verb) === 0);
2551 2551
 	}
2552 2552
 }
2553 2553
 class TAuthorizationRuleCollection extends TList
2554 2554
 {
2555
-	public function isUserAllowed($user,$verb,$ip)
2555
+	public function isUserAllowed($user, $verb, $ip)
2556 2556
 	{
2557
-		if($user instanceof IUser)
2557
+		if ($user instanceof IUser)
2558 2558
 		{
2559
-			$verb=strtolower(trim($verb));
2560
-			foreach($this as $rule)
2559
+			$verb = strtolower(trim($verb));
2560
+			foreach ($this as $rule)
2561 2561
 			{
2562
-				if(($decision=$rule->isUserAllowed($user,$verb,$ip))!==0)
2563
-					return ($decision>0);
2562
+				if (($decision = $rule->isUserAllowed($user, $verb, $ip)) !== 0)
2563
+					return ($decision > 0);
2564 2564
 			}
2565 2565
 			return true;
2566 2566
 		}
2567 2567
 		else
2568 2568
 			return false;
2569 2569
 	}
2570
-	public function insertAt($index,$item)
2570
+	public function insertAt($index, $item)
2571 2571
 	{
2572
-		if($item instanceof TAuthorizationRule)
2573
-			parent::insertAt($index,$item);
2572
+		if ($item instanceof TAuthorizationRule)
2573
+			parent::insertAt($index, $item);
2574 2574
 		else
2575 2575
 			throw new TInvalidDataTypeException('authorizationrulecollection_authorizationrule_required');
2576 2576
 	}
@@ -2586,17 +2586,17 @@  discard block
 block discarded – undo
2586 2586
 	private $_mbstring;
2587 2587
 	public function init($config)
2588 2588
 	{
2589
-		$this->_mbstring=extension_loaded('mbstring');
2589
+		$this->_mbstring = extension_loaded('mbstring');
2590 2590
 		$this->getApplication()->setSecurityManager($this);
2591 2591
 	}
2592 2592
 	protected function generateRandomKey()
2593 2593
 	{
2594
-		return sprintf('%08x%08x%08x%08x',mt_rand(),mt_rand(),mt_rand(),mt_rand());
2594
+		return sprintf('%08x%08x%08x%08x', mt_rand(), mt_rand(), mt_rand(), mt_rand());
2595 2595
 	}
2596 2596
 	public function getValidationKey()
2597 2597
 	{
2598
-		if(null === $this->_validationKey) {
2599
-			if(null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) {
2598
+		if (null === $this->_validationKey) {
2599
+			if (null === ($this->_validationKey = $this->getApplication()->getGlobalState(self::STATE_VALIDATION_KEY))) {
2600 2600
 				$this->_validationKey = $this->generateRandomKey();
2601 2601
 				$this->getApplication()->setGlobalState(self::STATE_VALIDATION_KEY, $this->_validationKey, null, true);
2602 2602
 			}
@@ -2605,14 +2605,14 @@  discard block
 block discarded – undo
2605 2605
 	}
2606 2606
 	public function setValidationKey($value)
2607 2607
 	{
2608
-		if('' === $value)
2608
+		if ('' === $value)
2609 2609
 			throw new TInvalidDataValueException('securitymanager_validationkey_invalid');
2610 2610
 		$this->_validationKey = $value;
2611 2611
 	}
2612 2612
 	public function getEncryptionKey()
2613 2613
 	{
2614
-		if(null === $this->_encryptionKey) {
2615
-			if(null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) {
2614
+		if (null === $this->_encryptionKey) {
2615
+			if (null === ($this->_encryptionKey = $this->getApplication()->getGlobalState(self::STATE_ENCRYPTION_KEY))) {
2616 2616
 				$this->_encryptionKey = $this->generateRandomKey();
2617 2617
 				$this->getApplication()->setGlobalState(self::STATE_ENCRYPTION_KEY, $this->_encryptionKey, null, true);
2618 2618
 			}
@@ -2621,7 +2621,7 @@  discard block
 block discarded – undo
2621 2621
 	}
2622 2622
 	public function setEncryptionKey($value)
2623 2623
 	{
2624
-		if('' === $value)
2624
+		if ('' === $value)
2625 2625
 			throw new TInvalidDataValueException('securitymanager_encryptionkey_invalid');
2626 2626
 		$this->_encryptionKey = $value;
2627 2627
 	}
@@ -2643,7 +2643,7 @@  discard block
 block discarded – undo
2643 2643
 	}
2644 2644
 	public function getEncryption()
2645 2645
 	{
2646
-		if(is_string($this->_cryptAlgorithm))
2646
+		if (is_string($this->_cryptAlgorithm))
2647 2647
 			return $this->_cryptAlgorithm;
2648 2648
 				return "3DES";
2649 2649
 	}
@@ -2661,19 +2661,19 @@  discard block
 block discarded – undo
2661 2661
 	}
2662 2662
 	public function encrypt($data)
2663 2663
 	{
2664
-		$module=$this->openCryptModule();
2664
+		$module = $this->openCryptModule();
2665 2665
 		$key = $this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module));
2666 2666
 		srand();
2667 2667
 		$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND);
2668 2668
 		mcrypt_generic_init($module, $key, $iv);
2669
-		$encrypted = $iv.mcrypt_generic($module, $data);
2669
+		$encrypted = $iv . mcrypt_generic($module, $data);
2670 2670
 		mcrypt_generic_deinit($module);
2671 2671
 		mcrypt_module_close($module);
2672 2672
 		return $encrypted;
2673 2673
 	}
2674 2674
 	public function decrypt($data)
2675 2675
 	{
2676
-		$module=$this->openCryptModule();
2676
+		$module = $this->openCryptModule();
2677 2677
 		$key = $this->substr(md5($this->getEncryptionKey()), 0, mcrypt_enc_get_key_size($module));
2678 2678
 		$ivSize = mcrypt_enc_get_iv_size($module);
2679 2679
 		$iv = $this->substr($data, 0, $ivSize);
@@ -2685,13 +2685,13 @@  discard block
 block discarded – undo
2685 2685
 	}
2686 2686
 	protected function openCryptModule()
2687 2687
 	{
2688
-		if(extension_loaded('mcrypt'))
2688
+		if (extension_loaded('mcrypt'))
2689 2689
 		{
2690
-			if(is_array($this->_cryptAlgorithm))
2691
-				$module=@call_user_func_array('mcrypt_module_open',$this->_cryptAlgorithm);
2690
+			if (is_array($this->_cryptAlgorithm))
2691
+				$module = @call_user_func_array('mcrypt_module_open', $this->_cryptAlgorithm);
2692 2692
 			else
2693
-				$module=@mcrypt_module_open($this->_cryptAlgorithm,'', MCRYPT_MODE_CBC,'');
2694
-			if($module===false)
2693
+				$module = @mcrypt_module_open($this->_cryptAlgorithm, '', MCRYPT_MODE_CBC, '');
2694
+			if ($module === false)
2695 2695
 				throw new TNotSupportedException('securitymanager_mcryptextension_initfailed');
2696 2696
 			return $module;
2697 2697
 		}
@@ -2701,23 +2701,23 @@  discard block
 block discarded – undo
2701 2701
 	public function hashData($data)
2702 2702
 	{
2703 2703
 		$hmac = $this->computeHMAC($data);
2704
-		return $hmac.$data;
2704
+		return $hmac . $data;
2705 2705
 	}
2706 2706
 	public function validateData($data)
2707 2707
 	{
2708
-		$len=$this->strlen($this->computeHMAC('test'));
2709
-		if($this->strlen($data) < $len)
2708
+		$len = $this->strlen($this->computeHMAC('test'));
2709
+		if ($this->strlen($data) < $len)
2710 2710
 			return false;
2711 2711
 		$hmac = $this->substr($data, 0, $len);
2712
-		$data2=$this->substr($data, $len, $this->strlen($data));
2712
+		$data2 = $this->substr($data, $len, $this->strlen($data));
2713 2713
 		return $hmac === $this->computeHMAC($data2) ? $data2 : false;
2714 2714
 	}
2715 2715
 	protected function computeHMAC($data)
2716 2716
 	{
2717 2717
 		$key = $this->getValidationKey();
2718
-		if(function_exists('hash_hmac'))
2718
+		if (function_exists('hash_hmac'))
2719 2719
 			return hash_hmac($this->_hashAlgorithm, $data, $key);
2720
-		if(!strcasecmp($this->_hashAlgorithm,'sha1'))
2720
+		if (!strcasecmp($this->_hashAlgorithm, 'sha1'))
2721 2721
 		{
2722 2722
 			$pack = 'H40';
2723 2723
 			$func = 'sha1';
@@ -2730,11 +2730,11 @@  discard block
 block discarded – undo
2730 2730
 	}
2731 2731
 	private function strlen($string)
2732 2732
 	{
2733
-		return $this->_mbstring ? mb_strlen($string,'8bit') : strlen($string);
2733
+		return $this->_mbstring ? mb_strlen($string, '8bit') : strlen($string);
2734 2734
 	}
2735
-	private function substr($string,$start,$length)
2735
+	private function substr($string, $start, $length)
2736 2736
 	{
2737
-		return $this->_mbstring ? mb_substr($string,$start,$length,'8bit') : substr($string,$start,$length);
2737
+		return $this->_mbstring ? mb_substr($string, $start, $length, '8bit') : substr($string, $start, $length);
2738 2738
 	}
2739 2739
 }
2740 2740
 class TSecurityManagerValidationMode extends TEnumerable
@@ -2744,46 +2744,46 @@  discard block
 block discarded – undo
2744 2744
 }
2745 2745
 class THttpUtility
2746 2746
 {
2747
-	private static $_encodeTable=array('<'=>'&lt;','>'=>'&gt;','"'=>'&quot;');
2748
-	private static $_decodeTable=array('&lt;'=>'<','&gt;'=>'>','&quot;'=>'"');
2749
-	private static $_stripTable=array('&lt;'=>'','&gt;'=>'','&quot;'=>'');
2747
+	private static $_encodeTable = array('<'=>'&lt;', '>'=>'&gt;', '"'=>'&quot;');
2748
+	private static $_decodeTable = array('&lt;'=>'<', '&gt;'=>'>', '&quot;'=>'"');
2749
+	private static $_stripTable = array('&lt;'=>'', '&gt;'=>'', '&quot;'=>'');
2750 2750
 	public static function htmlEncode($s)
2751 2751
 	{
2752
-		return strtr($s,self::$_encodeTable);
2752
+		return strtr($s, self::$_encodeTable);
2753 2753
 	}
2754 2754
 	public static function htmlDecode($s)
2755 2755
 	{
2756
-		return strtr($s,self::$_decodeTable);
2756
+		return strtr($s, self::$_decodeTable);
2757 2757
 	}
2758 2758
 	public static function htmlStrip($s)
2759 2759
 	{
2760
-		return strtr($s,self::$_stripTable);
2760
+		return strtr($s, self::$_stripTable);
2761 2761
 	}
2762 2762
 }
2763 2763
 class TJavaScript
2764 2764
 {
2765 2765
 	public static function renderScriptFiles($files)
2766 2766
 	{
2767
-		$str='';
2768
-		foreach($files as $file)
2769
-			$str.= self::renderScriptFile($file);
2767
+		$str = '';
2768
+		foreach ($files as $file)
2769
+			$str .= self::renderScriptFile($file);
2770 2770
 		return $str;
2771 2771
 	}
2772 2772
 	public static function renderScriptFile($file)
2773 2773
 	{
2774
-		return '<script type="text/javascript" src="'.THttpUtility::htmlEncode($file)."\"></script>\n";
2774
+		return '<script type="text/javascript" src="' . THttpUtility::htmlEncode($file) . "\"></script>\n";
2775 2775
 	}
2776 2776
 	public static function renderScriptBlocks($scripts)
2777 2777
 	{
2778
-		if(count($scripts))
2779
-			return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n".implode("\n",$scripts)."\n/*]]>*/\n</script>\n";
2778
+		if (count($scripts))
2779
+			return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n" . implode("\n", $scripts) . "\n/*]]>*/\n</script>\n";
2780 2780
 		else
2781 2781
 			return '';
2782 2782
 	}
2783 2783
 	public static function renderScriptBlocksCallback($scripts)
2784 2784
 	{
2785
-		if(count($scripts))
2786
-			return implode("\n",$scripts)."\n";
2785
+		if (count($scripts))
2786
+			return implode("\n", $scripts) . "\n";
2787 2787
 		else
2788 2788
 			return '';
2789 2789
 	}
@@ -2793,11 +2793,11 @@  discard block
 block discarded – undo
2793 2793
 	}
2794 2794
 	public static function quoteString($js)
2795 2795
 	{
2796
-		return self::jsonEncode($js,JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG);
2796
+		return self::jsonEncode($js, JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_TAG);
2797 2797
 	}
2798 2798
 	public static function quoteJsLiteral($js)
2799 2799
 	{
2800
-		if($js instanceof TJavaScriptLiteral)
2800
+		if ($js instanceof TJavaScriptLiteral)
2801 2801
 			return $js;
2802 2802
 		else
2803 2803
 			return new TJavaScriptLiteral($js);
@@ -2814,47 +2814,47 @@  discard block
 block discarded – undo
2814 2814
 	{
2815 2815
 		return self::isJsLiteral($js);
2816 2816
 	}
2817
-	public static function encode($value,$toMap=true,$encodeEmptyStrings=false)
2817
+	public static function encode($value, $toMap = true, $encodeEmptyStrings = false)
2818 2818
 	{
2819
-		if(is_string($value))
2819
+		if (is_string($value))
2820 2820
 			return self::quoteString($value);
2821
-		else if(is_bool($value))
2822
-			return $value?'true':'false';
2823
-		else if(is_array($value))
2821
+		else if (is_bool($value))
2822
+			return $value ? 'true' : 'false';
2823
+		else if (is_array($value))
2824 2824
 		{
2825
-			$results='';
2826
-			if(($n=count($value))>0 && array_keys($value)!==range(0,$n-1))
2825
+			$results = '';
2826
+			if (($n = count($value)) > 0 && array_keys($value) !== range(0, $n - 1))
2827 2827
 			{
2828
-				foreach($value as $k=>$v)
2828
+				foreach ($value as $k=>$v)
2829 2829
 				{
2830
-					if($v!=='' || $encodeEmptyStrings)
2830
+					if ($v !== '' || $encodeEmptyStrings)
2831 2831
 					{
2832
-						if($results!=='')
2833
-							$results.=',';
2834
-						$results.="'$k':".self::encode($v,$toMap,$encodeEmptyStrings);
2832
+						if ($results !== '')
2833
+							$results .= ',';
2834
+						$results .= "'$k':" . self::encode($v, $toMap, $encodeEmptyStrings);
2835 2835
 					}
2836 2836
 				}
2837
-				return '{'.$results.'}';
2837
+				return '{' . $results . '}';
2838 2838
 			}
2839 2839
 			else
2840 2840
 			{
2841
-				foreach($value as $v)
2841
+				foreach ($value as $v)
2842 2842
 				{
2843
-					if($v!=='' || $encodeEmptyStrings)
2843
+					if ($v !== '' || $encodeEmptyStrings)
2844 2844
 					{
2845
-						if($results!=='')
2846
-							$results.=',';
2847
-						$results.=self::encode($v,$toMap, $encodeEmptyStrings);
2845
+						if ($results !== '')
2846
+							$results .= ',';
2847
+						$results .= self::encode($v, $toMap, $encodeEmptyStrings);
2848 2848
 					}
2849 2849
 				}
2850
-				return '['.$results.']';
2850
+				return '[' . $results . ']';
2851 2851
 			}
2852 2852
 		}
2853
-		else if(is_integer($value))
2853
+		else if (is_integer($value))
2854 2854
 			return "$value";
2855
-		else if(is_float($value))
2855
+		else if (is_float($value))
2856 2856
 		{
2857
-			switch($value)
2857
+			switch ($value)
2858 2858
 			{
2859 2859
 				case -INF:
2860 2860
 					return 'Number.NEGATIVE_INFINITY';
@@ -2863,46 +2863,46 @@  discard block
 block discarded – undo
2863 2863
 					return 'Number.POSITIVE_INFINITY';
2864 2864
 					break;
2865 2865
 				default:
2866
-					$locale=localeConv();
2867
-					if($locale['decimal_point']=='.')
2866
+					$locale = localeConv();
2867
+					if ($locale['decimal_point'] == '.')
2868 2868
 						return "$value";
2869 2869
 					else
2870 2870
 						return str_replace($locale['decimal_point'], '.', "$value");
2871 2871
 					break;
2872 2872
 			}
2873 2873
 		}
2874
-		else if(is_object($value))
2874
+		else if (is_object($value))
2875 2875
 			if ($value instanceof TJavaScriptLiteral)
2876 2876
 				return $value->toJavaScriptLiteral();
2877 2877
 			else
2878
-				return self::encode(get_object_vars($value),$toMap);
2879
-		else if($value===null)
2878
+				return self::encode(get_object_vars($value), $toMap);
2879
+		else if ($value === null)
2880 2880
 			return 'null';
2881 2881
 		else
2882 2882
 			return '';
2883 2883
 	}
2884 2884
 	public static function jsonEncode($value, $options = 0)
2885 2885
 	{
2886
-		if (($g=Prado::getApplication()->getGlobalization(false))!==null &&
2887
-			strtoupper($enc=$g->getCharset())!='UTF-8') {
2886
+		if (($g = Prado::getApplication()->getGlobalization(false)) !== null &&
2887
+			strtoupper($enc = $g->getCharset()) != 'UTF-8') {
2888 2888
 			self::convertToUtf8($value, $enc);
2889 2889
 		}
2890
-		$s = @json_encode($value,$options);
2890
+		$s = @json_encode($value, $options);
2891 2891
 		self::checkJsonError();
2892 2892
 		return $s;
2893 2893
 	}
2894 2894
 	private static function convertToUtf8(&$value, $sourceEncoding) {
2895
-		if(is_string($value))
2896
-			$value=iconv($sourceEncoding, 'UTF-8', $value);
2895
+		if (is_string($value))
2896
+			$value = iconv($sourceEncoding, 'UTF-8', $value);
2897 2897
 		else if (is_array($value))
2898 2898
 		{
2899
-			foreach($value as &$element)
2899
+			foreach ($value as &$element)
2900 2900
 				self::convertToUtf8($element, $sourceEncoding);
2901 2901
 		}
2902 2902
 	}
2903 2903
 	public static function jsonDecode($value, $assoc = false, $depth = 512)
2904 2904
 	{
2905
-		$s= @json_decode($value, $assoc, $depth);
2905
+		$s = @json_decode($value, $assoc, $depth);
2906 2906
 		self::checkJsonError();
2907 2907
 		return $s;
2908 2908
 	}
@@ -2942,77 +2942,77 @@  discard block
 block discarded – undo
2942 2942
 }
2943 2943
 class TUrlManager extends TModule
2944 2944
 {
2945
-	public function constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems)
2945
+	public function constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems)
2946 2946
 	{
2947
-		$url=$serviceID.'='.urlencode($serviceParam);
2948
-		$amp=$encodeAmpersand?'&amp;':'&';
2949
-		$request=$this->getRequest();
2950
-		if(is_array($getItems) || $getItems instanceof Traversable)
2947
+		$url = $serviceID . '=' . urlencode($serviceParam);
2948
+		$amp = $encodeAmpersand ? '&amp;' : '&';
2949
+		$request = $this->getRequest();
2950
+		if (is_array($getItems) || $getItems instanceof Traversable)
2951 2951
 		{
2952
-			if($encodeGetItems)
2952
+			if ($encodeGetItems)
2953 2953
 			{
2954
-				foreach($getItems as $name=>$value)
2954
+				foreach ($getItems as $name=>$value)
2955 2955
 				{
2956
-					if(is_array($value))
2956
+					if (is_array($value))
2957 2957
 					{
2958
-						$name=urlencode($name.'[]');
2959
-						foreach($value as $v)
2960
-							$url.=$amp.$name.'='.urlencode($v);
2958
+						$name = urlencode($name . '[]');
2959
+						foreach ($value as $v)
2960
+							$url .= $amp . $name . '=' . urlencode($v);
2961 2961
 					}
2962 2962
 					else
2963
-						$url.=$amp.urlencode($name).'='.urlencode($value);
2963
+						$url .= $amp . urlencode($name) . '=' . urlencode($value);
2964 2964
 				}
2965 2965
 			}
2966 2966
 			else
2967 2967
 			{
2968
-				foreach($getItems as $name=>$value)
2968
+				foreach ($getItems as $name=>$value)
2969 2969
 				{
2970
-					if(is_array($value))
2970
+					if (is_array($value))
2971 2971
 					{
2972
-						foreach($value as $v)
2973
-							$url.=$amp.$name.'[]='.$v;
2972
+						foreach ($value as $v)
2973
+							$url .= $amp . $name . '[]=' . $v;
2974 2974
 					}
2975 2975
 					else
2976
-						$url.=$amp.$name.'='.$value;
2976
+						$url .= $amp . $name . '=' . $value;
2977 2977
 				}
2978 2978
 			}
2979 2979
 		}
2980
-		switch($request->getUrlFormat())
2980
+		switch ($request->getUrlFormat())
2981 2981
 		{
2982 2982
 			case THttpRequestUrlFormat::Path:
2983
-				return $request->getApplicationUrl().'/'.strtr($url,array($amp=>'/','?'=>'/','='=>$request->getUrlParamSeparator()));
2983
+				return $request->getApplicationUrl() . '/' . strtr($url, array($amp=>'/', '?'=>'/', '='=>$request->getUrlParamSeparator()));
2984 2984
 			case THttpRequestUrlFormat::HiddenPath:
2985
-				return rtrim(dirname($request->getApplicationUrl()), '/').'/'.strtr($url,array($amp=>'/','?'=>'/','='=>$request->getUrlParamSeparator()));
2985
+				return rtrim(dirname($request->getApplicationUrl()), '/') . '/' . strtr($url, array($amp=>'/', '?'=>'/', '='=>$request->getUrlParamSeparator()));
2986 2986
 			default:
2987
-				return $request->getApplicationUrl().'?'.$url;
2987
+				return $request->getApplicationUrl() . '?' . $url;
2988 2988
 		}
2989 2989
 	}
2990 2990
 	public function parseUrl()
2991 2991
 	{
2992
-		$request=$this->getRequest();
2993
-		$pathInfo=trim($request->getPathInfo(),'/');
2994
-		if(($request->getUrlFormat()===THttpRequestUrlFormat::Path ||
2995
-			$request->getUrlFormat()===THttpRequestUrlFormat::HiddenPath) &&
2996
-			$pathInfo!=='')
2992
+		$request = $this->getRequest();
2993
+		$pathInfo = trim($request->getPathInfo(), '/');
2994
+		if (($request->getUrlFormat() === THttpRequestUrlFormat::Path ||
2995
+			$request->getUrlFormat() === THttpRequestUrlFormat::HiddenPath) &&
2996
+			$pathInfo !== '')
2997 2997
 		{
2998
-			$separator=$request->getUrlParamSeparator();
2999
-			$paths=explode('/',$pathInfo);
3000
-			$getVariables=array();
3001
-			foreach($paths as $path)
2998
+			$separator = $request->getUrlParamSeparator();
2999
+			$paths = explode('/', $pathInfo);
3000
+			$getVariables = array();
3001
+			foreach ($paths as $path)
3002 3002
 			{
3003
-				if(($path=trim($path))!=='')
3003
+				if (($path = trim($path)) !== '')
3004 3004
 				{
3005
-					if(($pos=strpos($path,$separator))!==false)
3005
+					if (($pos = strpos($path, $separator)) !== false)
3006 3006
 					{
3007
-						$name=substr($path,0,$pos);
3008
-						$value=substr($path,$pos+1);
3009
-						if(($pos=strpos($name,'[]'))!==false)
3010
-							$getVariables[substr($name,0,$pos)][]=$value;
3007
+						$name = substr($path, 0, $pos);
3008
+						$value = substr($path, $pos + 1);
3009
+						if (($pos = strpos($name, '[]')) !== false)
3010
+							$getVariables[substr($name, 0, $pos)][] = $value;
3011 3011
 						else
3012
-							$getVariables[$name]=$value;
3012
+							$getVariables[$name] = $value;
3013 3013
 					}
3014 3014
 					else
3015
-						$getVariables[$path]='';
3015
+						$getVariables[$path] = '';
3016 3016
 				}
3017 3017
 			}
3018 3018
 			return $getVariables;
@@ -3021,91 +3021,91 @@  discard block
 block discarded – undo
3021 3021
 			return array();
3022 3022
 	}
3023 3023
 }
3024
-class THttpRequest extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule
3024
+class THttpRequest extends TApplicationComponent implements IteratorAggregate, ArrayAccess, Countable, IModule
3025 3025
 {
3026
-	const CGIFIX__PATH_INFO		= 1;
3027
-	const CGIFIX__SCRIPT_NAME	= 2;
3028
-	private $_urlManager=null;
3029
-	private $_urlManagerID='';
3030
-	private $_separator=',';
3031
-	private $_serviceID=null;
3032
-	private $_serviceParam=null;
3033
-	private $_cookies=null;
3026
+	const CGIFIX__PATH_INFO = 1;
3027
+	const CGIFIX__SCRIPT_NAME = 2;
3028
+	private $_urlManager = null;
3029
+	private $_urlManagerID = '';
3030
+	private $_separator = ',';
3031
+	private $_serviceID = null;
3032
+	private $_serviceParam = null;
3033
+	private $_cookies = null;
3034 3034
 	private $_requestUri;
3035 3035
 	private $_pathInfo;
3036
-	private $_cookieOnly=null;
3037
-	private $_urlFormat=THttpRequestUrlFormat::Get;
3036
+	private $_cookieOnly = null;
3037
+	private $_urlFormat = THttpRequestUrlFormat::Get;
3038 3038
 	private $_services;
3039
-	private $_requestResolved=false;
3040
-	private $_enableCookieValidation=false;
3041
-	private $_cgiFix=0;
3042
-	private $_enableCache=false;
3043
-	private $_url=null;
3039
+	private $_requestResolved = false;
3040
+	private $_enableCookieValidation = false;
3041
+	private $_cgiFix = 0;
3042
+	private $_enableCache = false;
3043
+	private $_url = null;
3044 3044
 	private $_id;
3045
-	private $_items=array();
3045
+	private $_items = array();
3046 3046
 	public function getID()
3047 3047
 	{
3048 3048
 		return $this->_id;
3049 3049
 	}
3050 3050
 	public function setID($value)
3051 3051
 	{
3052
-		$this->_id=$value;
3052
+		$this->_id = $value;
3053 3053
 	}
3054 3054
 	public function init($config)
3055 3055
 	{
3056
-				if(php_sapi_name()==='cli')
3057
-		{
3058
-			$_SERVER['REMOTE_ADDR']='127.0.0.1';
3059
-			$_SERVER['REQUEST_METHOD']='GET';
3060
-			$_SERVER['SERVER_NAME']='localhost';
3061
-			$_SERVER['SERVER_PORT']=80;
3062
-			$_SERVER['HTTP_USER_AGENT']='';
3063
-		}
3064
-														if(isset($_SERVER['REQUEST_URI']))
3065
-			$this->_requestUri=$_SERVER['REQUEST_URI'];
3066
-		else  			$this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING'])?'':'?'.$_SERVER['QUERY_STRING']);
3067
-		if($this->_cgiFix&self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO']))
3068
-			$this->_pathInfo=substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME']));
3069
-		elseif(isset($_SERVER['PATH_INFO']))
3070
-			$this->_pathInfo=$_SERVER['PATH_INFO'];
3071
-		else if(strpos($_SERVER['PHP_SELF'],$_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME'])
3072
-			$this->_pathInfo=substr($_SERVER['PHP_SELF'],strlen($_SERVER['SCRIPT_NAME']));
3073
-		else
3074
-			$this->_pathInfo='';
3075
-		if(get_magic_quotes_gpc())
3076
-		{
3077
-			if(isset($_GET))
3078
-				$_GET=$this->stripSlashes($_GET);
3079
-			if(isset($_POST))
3080
-				$_POST=$this->stripSlashes($_POST);
3081
-			if(isset($_REQUEST))
3082
-				$_REQUEST=$this->stripSlashes($_REQUEST);
3083
-			if(isset($_COOKIE))
3084
-				$_COOKIE=$this->stripSlashes($_COOKIE);
3056
+				if (php_sapi_name() === 'cli')
3057
+		{
3058
+			$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
3059
+			$_SERVER['REQUEST_METHOD'] = 'GET';
3060
+			$_SERVER['SERVER_NAME'] = 'localhost';
3061
+			$_SERVER['SERVER_PORT'] = 80;
3062
+			$_SERVER['HTTP_USER_AGENT'] = '';
3063
+		}
3064
+														if (isset($_SERVER['REQUEST_URI']))
3065
+			$this->_requestUri = $_SERVER['REQUEST_URI'];
3066
+		else  			$this->_requestUri = $_SERVER['SCRIPT_NAME'] . (empty($_SERVER['QUERY_STRING']) ? '' : '?' . $_SERVER['QUERY_STRING']);
3067
+		if ($this->_cgiFix & self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO']))
3068
+			$this->_pathInfo = substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME']));
3069
+		elseif (isset($_SERVER['PATH_INFO']))
3070
+			$this->_pathInfo = $_SERVER['PATH_INFO'];
3071
+		else if (strpos($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME']) === 0 && $_SERVER['PHP_SELF'] !== $_SERVER['SCRIPT_NAME'])
3072
+			$this->_pathInfo = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME']));
3073
+		else
3074
+			$this->_pathInfo = '';
3075
+		if (get_magic_quotes_gpc())
3076
+		{
3077
+			if (isset($_GET))
3078
+				$_GET = $this->stripSlashes($_GET);
3079
+			if (isset($_POST))
3080
+				$_POST = $this->stripSlashes($_POST);
3081
+			if (isset($_REQUEST))
3082
+				$_REQUEST = $this->stripSlashes($_REQUEST);
3083
+			if (isset($_COOKIE))
3084
+				$_COOKIE = $this->stripSlashes($_COOKIE);
3085 3085
 		}
3086 3086
 		$this->getApplication()->setRequest($this);
3087 3087
 	}
3088 3088
 	public function stripSlashes(&$data)
3089 3089
 	{
3090
-		return is_array($data)?array_map(array($this,'stripSlashes'),$data):stripslashes($data);
3090
+		return is_array($data) ? array_map(array($this, 'stripSlashes'), $data) : stripslashes($data);
3091 3091
 	}
3092 3092
 	public function getUrl()
3093 3093
 	{
3094
-		if($this->_url===null)
3094
+		if ($this->_url === null)
3095 3095
 		{
3096
-			$secure=$this->getIsSecureConnection();
3097
-			$url=$secure?'https://':'http://';
3098
-			if(empty($_SERVER['HTTP_HOST']))
3096
+			$secure = $this->getIsSecureConnection();
3097
+			$url = $secure ? 'https://' : 'http://';
3098
+			if (empty($_SERVER['HTTP_HOST']))
3099 3099
 			{
3100
-				$url.=$_SERVER['SERVER_NAME'];
3101
-				$port=$_SERVER['SERVER_PORT'];
3102
-				if(($port!=80 && !$secure) || ($port!=443 && $secure))
3103
-					$url.=':'.$port;
3100
+				$url .= $_SERVER['SERVER_NAME'];
3101
+				$port = $_SERVER['SERVER_PORT'];
3102
+				if (($port != 80 && !$secure) || ($port != 443 && $secure))
3103
+					$url .= ':' . $port;
3104 3104
 			}
3105 3105
 			else
3106
-				$url.=$_SERVER['HTTP_HOST'];
3107
-			$url.=$this->getRequestUri();
3108
-			$this->_url=new TUri($url);
3106
+				$url .= $_SERVER['HTTP_HOST'];
3107
+			$url .= $this->getRequestUri();
3108
+			$this->_url = new TUri($url);
3109 3109
 		}
3110 3110
 		return $this->_url;
3111 3111
 	}
@@ -3123,16 +3123,16 @@  discard block
 block discarded – undo
3123 3123
 	}
3124 3124
 	protected function cacheUrlManager($manager)
3125 3125
 	{
3126
-		if($this->getEnableCache())
3126
+		if ($this->getEnableCache())
3127 3127
 		{
3128 3128
 			$cache = $this->getApplication()->getCache();
3129
-			if($cache !== null)
3129
+			if ($cache !== null)
3130 3130
 			{
3131 3131
 				$dependencies = null;
3132
-				if($this->getApplication()->getMode() !== TApplicationMode::Performance)
3132
+				if ($this->getApplication()->getMode() !== TApplicationMode::Performance)
3133 3133
 					if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile())
3134 3134
 					{
3135
-						$fn = Prado::getPathOfNamespace($fn,$this->getApplication()->getConfigurationFileExt());
3135
+						$fn = Prado::getPathOfNamespace($fn, $this->getApplication()->getConfigurationFileExt());
3136 3136
 						$dependencies = new TFileCacheDependency($fn);
3137 3137
 					}
3138 3138
 				return $cache->set($this->getCacheKey(), $manager, 0, $dependencies);
@@ -3142,13 +3142,13 @@  discard block
 block discarded – undo
3142 3142
 	}
3143 3143
 	protected function loadCachedUrlManager()
3144 3144
 	{
3145
-		if($this->getEnableCache())
3145
+		if ($this->getEnableCache())
3146 3146
 		{
3147 3147
 			$cache = $this->getApplication()->getCache();
3148
-			if($cache !== null)
3148
+			if ($cache !== null)
3149 3149
 			{
3150 3150
 				$manager = $cache->get($this->getCacheKey());
3151
-				if($manager instanceof TUrlManager)
3151
+				if ($manager instanceof TUrlManager)
3152 3152
 					return $manager;
3153 3153
 			}
3154 3154
 		}
@@ -3160,26 +3160,26 @@  discard block
 block discarded – undo
3160 3160
 	}
3161 3161
 	public function setUrlManager($value)
3162 3162
 	{
3163
-		$this->_urlManagerID=$value;
3163
+		$this->_urlManagerID = $value;
3164 3164
 	}
3165 3165
 	public function getUrlManagerModule()
3166 3166
 	{
3167
-		if($this->_urlManager===null)
3167
+		if ($this->_urlManager === null)
3168 3168
 		{
3169
-			if(($this->_urlManager = $this->loadCachedUrlManager())===null)
3169
+			if (($this->_urlManager = $this->loadCachedUrlManager()) === null)
3170 3170
 			{
3171
-				if(empty($this->_urlManagerID))
3171
+				if (empty($this->_urlManagerID))
3172 3172
 				{
3173
-					$this->_urlManager=new TUrlManager;
3173
+					$this->_urlManager = new TUrlManager;
3174 3174
 					$this->_urlManager->init(null);
3175 3175
 				}
3176 3176
 				else
3177 3177
 				{
3178
-					$this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID);
3179
-					if($this->_urlManager===null)
3180
-						throw new TConfigurationException('httprequest_urlmanager_inexist',$this->_urlManagerID);
3181
-					if(!($this->_urlManager instanceof TUrlManager))
3182
-						throw new TConfigurationException('httprequest_urlmanager_invalid',$this->_urlManagerID);
3178
+					$this->_urlManager = $this->getApplication()->getModule($this->_urlManagerID);
3179
+					if ($this->_urlManager === null)
3180
+						throw new TConfigurationException('httprequest_urlmanager_inexist', $this->_urlManagerID);
3181
+					if (!($this->_urlManager instanceof TUrlManager))
3182
+						throw new TConfigurationException('httprequest_urlmanager_invalid', $this->_urlManagerID);
3183 3183
 				}
3184 3184
 				$this->cacheUrlManager($this->_urlManager);
3185 3185
 			}
@@ -3192,7 +3192,7 @@  discard block
 block discarded – undo
3192 3192
 	}
3193 3193
 	public function setUrlFormat($value)
3194 3194
 	{
3195
-		$this->_urlFormat=TPropertyValue::ensureEnum($value,'THttpRequestUrlFormat');
3195
+		$this->_urlFormat = TPropertyValue::ensureEnum($value, 'THttpRequestUrlFormat');
3196 3196
 	}
3197 3197
 	public function getUrlParamSeparator()
3198 3198
 	{
@@ -3200,26 +3200,26 @@  discard block
 block discarded – undo
3200 3200
 	}
3201 3201
 	public function setUrlParamSeparator($value)
3202 3202
 	{
3203
-		if(strlen($value)===1)
3204
-			$this->_separator=$value;
3203
+		if (strlen($value) === 1)
3204
+			$this->_separator = $value;
3205 3205
 		else
3206 3206
 			throw new TInvalidDataValueException('httprequest_separator_invalid');
3207 3207
 	}
3208 3208
 	public function getRequestType()
3209 3209
 	{
3210
-		return isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:null;
3210
+		return isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null;
3211 3211
 	}
3212 3212
 	public function getContentType($mimetypeOnly = true)
3213 3213
 	{
3214
-		if(!isset($_SERVER['CONTENT_TYPE']))
3214
+		if (!isset($_SERVER['CONTENT_TYPE']))
3215 3215
 			return null;
3216
-		if($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false)
3216
+		if ($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false)
3217 3217
 			return substr($_SERVER['CONTENT_TYPE'], 0, $_pos);
3218 3218
 		return $_SERVER['CONTENT_TYPE'];
3219 3219
 	}
3220 3220
 	public function getIsSecureConnection()
3221 3221
 	{
3222
-			return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'],'off');
3222
+			return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'off');
3223 3223
 	}
3224 3224
 	public function getPathInfo()
3225 3225
 	{
@@ -3227,27 +3227,27 @@  discard block
 block discarded – undo
3227 3227
 	}
3228 3228
 	public function getQueryString()
3229 3229
 	{
3230
-		return isset($_SERVER['QUERY_STRING'])?$_SERVER['QUERY_STRING']:null;
3230
+		return isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null;
3231 3231
 	}
3232 3232
 	public function getHttpProtocolVersion()
3233 3233
 	{
3234
-		return isset($_SERVER['SERVER_PROTOCOL'])?$_SERVER['SERVER_PROTOCOL']:null;
3234
+		return isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : null;
3235 3235
 	}
3236
-	public function getHeaders($case=null)
3236
+	public function getHeaders($case = null)
3237 3237
 	{
3238 3238
 		static $result;
3239
-		if($result === null && function_exists('apache_request_headers')) {
3239
+		if ($result === null && function_exists('apache_request_headers')) {
3240 3240
 			$result = apache_request_headers();
3241 3241
 		}
3242
-		elseif($result === null) {
3242
+		elseif ($result === null) {
3243 3243
 			$result = array();
3244
-			foreach($_SERVER as $key=>$value) {
3245
-				if(strncasecmp($key, 'HTTP_', 5) !== 0) continue;
3246
-					$key = str_replace(' ','-', ucwords(strtolower(str_replace('_',' ', substr($key, 5)))));
3244
+			foreach ($_SERVER as $key=>$value) {
3245
+				if (strncasecmp($key, 'HTTP_', 5) !== 0) continue;
3246
+					$key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
3247 3247
 					$result[$key] = $value;
3248 3248
 			}
3249 3249
 		}
3250
-		if($case !== null)
3250
+		if ($case !== null)
3251 3251
 			return array_change_key_case($result, $case);
3252 3252
 		return $result;
3253 3253
 	}
@@ -3255,39 +3255,39 @@  discard block
 block discarded – undo
3255 3255
 	{
3256 3256
 		return $this->_requestUri;
3257 3257
 	}
3258
-	public function getBaseUrl($forceSecureConnection=null)
3258
+	public function getBaseUrl($forceSecureConnection = null)
3259 3259
 	{
3260
-		$url=$this->getUrl();
3261
-		$scheme=($forceSecureConnection)?"https": (($forceSecureConnection === null)?$url->getScheme():'http');
3262
-		$host=$url->getHost();
3263
-		if (($port=$url->getPort())) $host.=':'.$port;
3264
-		return $scheme.'://'.$host;
3260
+		$url = $this->getUrl();
3261
+		$scheme = ($forceSecureConnection) ? "https" : (($forceSecureConnection === null) ? $url->getScheme() : 'http');
3262
+		$host = $url->getHost();
3263
+		if (($port = $url->getPort())) $host .= ':' . $port;
3264
+		return $scheme . '://' . $host;
3265 3265
 	}
3266 3266
 	public function getApplicationUrl()
3267 3267
 	{
3268
-		if($this->_cgiFix&self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME']))
3268
+		if ($this->_cgiFix & self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME']))
3269 3269
 			return $_SERVER['ORIG_SCRIPT_NAME'];
3270
-		return isset($_SERVER['SCRIPT_NAME'])?$_SERVER['SCRIPT_NAME']:null;
3270
+		return isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : null;
3271 3271
 	}
3272
-	public function getAbsoluteApplicationUrl($forceSecureConnection=null)
3272
+	public function getAbsoluteApplicationUrl($forceSecureConnection = null)
3273 3273
 	{
3274 3274
 		return $this->getBaseUrl($forceSecureConnection) . $this->getApplicationUrl();
3275 3275
 	}
3276 3276
 	public function getApplicationFilePath()
3277 3277
 	{
3278
-		return realpath(isset($_SERVER['SCRIPT_FILENAME'])?$_SERVER['SCRIPT_FILENAME']:null);
3278
+		return realpath(isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : null);
3279 3279
 	}
3280 3280
 	public function getServerName()
3281 3281
 	{
3282
-		return isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:null;
3282
+		return isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : null;
3283 3283
 	}
3284 3284
 	public function getServerPort()
3285 3285
 	{
3286
-		return isset($_SERVER['SERVER_PORT'])?$_SERVER['SERVER_PORT']:null;
3286
+		return isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : null;
3287 3287
 	}
3288 3288
 	public function getUrlReferrer()
3289 3289
 	{
3290
-		return isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:null;
3290
+		return isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
3291 3291
 	}
3292 3292
 	public function getBrowser()
3293 3293
 	{
@@ -3295,26 +3295,26 @@  discard block
 block discarded – undo
3295 3295
 		{
3296 3296
 			return get_browser();
3297 3297
 		}
3298
-		catch(TPhpErrorException $e)
3298
+		catch (TPhpErrorException $e)
3299 3299
 		{
3300 3300
 			throw new TConfigurationException('httprequest_browscap_required');
3301 3301
 		}
3302 3302
 	}
3303 3303
 	public function getUserAgent()
3304 3304
 	{
3305
-		return isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:null;
3305
+		return isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
3306 3306
 	}
3307 3307
 	public function getUserHostAddress()
3308 3308
 	{
3309
-		return isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:null;
3309
+		return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
3310 3310
 	}
3311 3311
 	public function getUserHost()
3312 3312
 	{
3313
-		return isset($_SERVER['REMOTE_HOST'])?$_SERVER['REMOTE_HOST']:null;
3313
+		return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null;
3314 3314
 	}
3315 3315
 	public function getAcceptTypes()
3316 3316
 	{
3317
-				return isset($_SERVER['HTTP_ACCEPT'])?$_SERVER['HTTP_ACCEPT']:null;
3317
+				return isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null;
3318 3318
 	}
3319 3319
 	public function getUserLanguages()
3320 3320
 	{
@@ -3326,7 +3326,7 @@  discard block
 block discarded – undo
3326 3326
 	}
3327 3327
 	public function setEnableCookieValidation($value)
3328 3328
 	{
3329
-		$this->_enableCookieValidation=TPropertyValue::ensureBoolean($value);
3329
+		$this->_enableCookieValidation = TPropertyValue::ensureBoolean($value);
3330 3330
 	}
3331 3331
 	public function getCgiFix()
3332 3332
 	{
@@ -3334,26 +3334,26 @@  discard block
 block discarded – undo
3334 3334
 	}
3335 3335
 	public function setCgiFix($value)
3336 3336
 	{
3337
-		$this->_cgiFix=TPropertyValue::ensureInteger($value);
3337
+		$this->_cgiFix = TPropertyValue::ensureInteger($value);
3338 3338
 	}
3339 3339
 	public function getCookies()
3340 3340
 	{
3341
-		if($this->_cookies===null)
3341
+		if ($this->_cookies === null)
3342 3342
 		{
3343
-			$this->_cookies=new THttpCookieCollection;
3344
-			if($this->getEnableCookieValidation())
3343
+			$this->_cookies = new THttpCookieCollection;
3344
+			if ($this->getEnableCookieValidation())
3345 3345
 			{
3346
-				$sm=$this->getApplication()->getSecurityManager();
3347
-				foreach($_COOKIE as $key=>$value)
3346
+				$sm = $this->getApplication()->getSecurityManager();
3347
+				foreach ($_COOKIE as $key=>$value)
3348 3348
 				{
3349
-					if(($value=$sm->validateData($value))!==false)
3350
-						$this->_cookies->add(new THttpCookie($key,$value));
3349
+					if (($value = $sm->validateData($value)) !== false)
3350
+						$this->_cookies->add(new THttpCookie($key, $value));
3351 3351
 				}
3352 3352
 			}
3353 3353
 			else
3354 3354
 			{
3355
-				foreach($_COOKIE as $key=>$value)
3356
-					$this->_cookies->add(new THttpCookie($key,$value));
3355
+				foreach ($_COOKIE as $key=>$value)
3356
+					$this->_cookies->add(new THttpCookie($key, $value));
3357 3357
 			}
3358 3358
 		}
3359 3359
 		return $this->_cookies;
@@ -3370,13 +3370,13 @@  discard block
 block discarded – undo
3370 3370
 	{
3371 3371
 		return $_ENV;
3372 3372
 	}
3373
-	public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=true,$encodeGetItems=true)
3373
+	public function constructUrl($serviceID, $serviceParam, $getItems = null, $encodeAmpersand = true, $encodeGetItems = true)
3374 3374
 	{
3375
-		if ($this->_cookieOnly===null)
3376
-				$this->_cookieOnly=(int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies');
3377
-		$url=$this->getUrlManagerModule()->constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems);
3378
-		if(defined('SID') && SID != '' && !$this->_cookieOnly)
3379
-			return $url . (strpos($url,'?')===false? '?' : ($encodeAmpersand?'&amp;':'&')) . SID;
3375
+		if ($this->_cookieOnly === null)
3376
+				$this->_cookieOnly = (int) ini_get('session.use_cookies') && (int) ini_get('session.use_only_cookies');
3377
+		$url = $this->getUrlManagerModule()->constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems);
3378
+		if (defined('SID') && SID != '' && !$this->_cookieOnly)
3379
+			return $url . (strpos($url, '?') === false ? '?' : ($encodeAmpersand ? '&amp;' : '&')) . SID;
3380 3380
 		else
3381 3381
 			return $url;
3382 3382
 	}
@@ -3386,14 +3386,14 @@  discard block
 block discarded – undo
3386 3386
 	}
3387 3387
 	public function resolveRequest($serviceIDs)
3388 3388
 	{
3389
-		$getParams=$this->parseUrl();
3390
-		foreach($getParams as $name=>$value)
3391
-			$_GET[$name]=$value;
3392
-		$this->_items=array_merge($_GET,$_POST);
3393
-		$this->_requestResolved=true;
3394
-		foreach($serviceIDs as $serviceID)
3389
+		$getParams = $this->parseUrl();
3390
+		foreach ($getParams as $name=>$value)
3391
+			$_GET[$name] = $value;
3392
+		$this->_items = array_merge($_GET, $_POST);
3393
+		$this->_requestResolved = true;
3394
+		foreach ($serviceIDs as $serviceID)
3395 3395
 		{
3396
-			if($this->contains($serviceID))
3396
+			if ($this->contains($serviceID))
3397 3397
 			{
3398 3398
 				$this->setServiceID($serviceID);
3399 3399
 				$this->setServiceParameter($this->itemAt($serviceID));
@@ -3412,7 +3412,7 @@  discard block
 block discarded – undo
3412 3412
 	}
3413 3413
 	public function setServiceID($value)
3414 3414
 	{
3415
-		$this->_serviceID=$value;
3415
+		$this->_serviceID = $value;
3416 3416
 	}
3417 3417
 	public function getServiceParameter()
3418 3418
 	{
@@ -3420,7 +3420,7 @@  discard block
 block discarded – undo
3420 3420
 	}
3421 3421
 	public function setServiceParameter($value)
3422 3422
 	{
3423
-		$this->_serviceParam=$value;
3423
+		$this->_serviceParam = $value;
3424 3424
 	}
3425 3425
 	public function getIterator()
3426 3426
 	{
@@ -3442,15 +3442,15 @@  discard block
 block discarded – undo
3442 3442
 	{
3443 3443
 		return isset($this->_items[$key]) ? $this->_items[$key] : null;
3444 3444
 	}
3445
-	public function add($key,$value)
3445
+	public function add($key, $value)
3446 3446
 	{
3447
-		$this->_items[$key]=$value;
3447
+		$this->_items[$key] = $value;
3448 3448
 	}
3449 3449
 	public function remove($key)
3450 3450
 	{
3451
-		if(isset($this->_items[$key]) || array_key_exists($key,$this->_items))
3451
+		if (isset($this->_items[$key]) || array_key_exists($key, $this->_items))
3452 3452
 		{
3453
-			$value=$this->_items[$key];
3453
+			$value = $this->_items[$key];
3454 3454
 			unset($this->_items[$key]);
3455 3455
 			return $value;
3456 3456
 		}
@@ -3459,12 +3459,12 @@  discard block
 block discarded – undo
3459 3459
 	}
3460 3460
 	public function clear()
3461 3461
 	{
3462
-		foreach(array_keys($this->_items) as $key)
3462
+		foreach (array_keys($this->_items) as $key)
3463 3463
 			$this->remove($key);
3464 3464
 	}
3465 3465
 	public function contains($key)
3466 3466
 	{
3467
-		return isset($this->_items[$key]) || array_key_exists($key,$this->_items);
3467
+		return isset($this->_items[$key]) || array_key_exists($key, $this->_items);
3468 3468
 	}
3469 3469
 	public function toArray()
3470 3470
 	{
@@ -3478,9 +3478,9 @@  discard block
 block discarded – undo
3478 3478
 	{
3479 3479
 		return $this->itemAt($offset);
3480 3480
 	}
3481
-	public function offsetSet($offset,$item)
3481
+	public function offsetSet($offset, $item)
3482 3482
 	{
3483
-		$this->add($offset,$item);
3483
+		$this->add($offset, $item);
3484 3484
 	}
3485 3485
 	public function offsetUnset($offset)
3486 3486
 	{
@@ -3490,16 +3490,16 @@  discard block
 block discarded – undo
3490 3490
 class THttpCookieCollection extends TList
3491 3491
 {
3492 3492
 	private $_o;
3493
-	public function __construct($owner=null)
3493
+	public function __construct($owner = null)
3494 3494
 	{
3495
-		$this->_o=$owner;
3495
+		$this->_o = $owner;
3496 3496
 	}
3497
-	public function insertAt($index,$item)
3497
+	public function insertAt($index, $item)
3498 3498
 	{
3499
-		if($item instanceof THttpCookie)
3499
+		if ($item instanceof THttpCookie)
3500 3500
 		{
3501
-			parent::insertAt($index,$item);
3502
-			if($this->_o instanceof THttpResponse)
3501
+			parent::insertAt($index, $item);
3502
+			if ($this->_o instanceof THttpResponse)
3503 3503
 				$this->_o->addCookie($item);
3504 3504
 		}
3505 3505
 		else
@@ -3507,39 +3507,39 @@  discard block
 block discarded – undo
3507 3507
 	}
3508 3508
 	public function removeAt($index)
3509 3509
 	{
3510
-		$item=parent::removeAt($index);
3511
-		if($this->_o instanceof THttpResponse)
3510
+		$item = parent::removeAt($index);
3511
+		if ($this->_o instanceof THttpResponse)
3512 3512
 			$this->_o->removeCookie($item);
3513 3513
 		return $item;
3514 3514
 	}
3515 3515
 	public function itemAt($index)
3516 3516
 	{
3517
-		if(is_integer($index))
3517
+		if (is_integer($index))
3518 3518
 			return parent::itemAt($index);
3519 3519
 		else
3520 3520
 			return $this->findCookieByName($index);
3521 3521
 	}
3522 3522
 	public function findCookieByName($name)
3523 3523
 	{
3524
-		foreach($this as $cookie)
3525
-			if($cookie->getName()===$name)
3524
+		foreach ($this as $cookie)
3525
+			if ($cookie->getName() === $name)
3526 3526
 				return $cookie;
3527 3527
 		return null;
3528 3528
 	}
3529 3529
 }
3530 3530
 class THttpCookie extends TComponent
3531 3531
 {
3532
-	private $_domain='';
3532
+	private $_domain = '';
3533 3533
 	private $_name;
3534
-	private $_value='';
3535
-	private $_expire=0;
3536
-	private $_path='/';
3537
-	private $_secure=false;
3538
-	private $_httpOnly=false;
3539
-	public function __construct($name,$value)
3534
+	private $_value = '';
3535
+	private $_expire = 0;
3536
+	private $_path = '/';
3537
+	private $_secure = false;
3538
+	private $_httpOnly = false;
3539
+	public function __construct($name, $value)
3540 3540
 	{
3541
-		$this->_name=$name;
3542
-		$this->_value=$value;
3541
+		$this->_name = $name;
3542
+		$this->_value = $value;
3543 3543
 	}
3544 3544
 	public function getDomain()
3545 3545
 	{
@@ -3547,7 +3547,7 @@  discard block
 block discarded – undo
3547 3547
 	}
3548 3548
 	public function setDomain($value)
3549 3549
 	{
3550
-		$this->_domain=$value;
3550
+		$this->_domain = $value;
3551 3551
 	}
3552 3552
 	public function getExpire()
3553 3553
 	{
@@ -3555,7 +3555,7 @@  discard block
 block discarded – undo
3555 3555
 	}
3556 3556
 	public function setExpire($value)
3557 3557
 	{
3558
-		$this->_expire=TPropertyValue::ensureInteger($value);
3558
+		$this->_expire = TPropertyValue::ensureInteger($value);
3559 3559
 	}
3560 3560
 	public function getHttpOnly()
3561 3561
 	{
@@ -3571,7 +3571,7 @@  discard block
 block discarded – undo
3571 3571
 	}
3572 3572
 	public function setName($value)
3573 3573
 	{
3574
-		$this->_name=$value;
3574
+		$this->_name = $value;
3575 3575
 	}
3576 3576
 	public function getValue()
3577 3577
 	{
@@ -3579,7 +3579,7 @@  discard block
 block discarded – undo
3579 3579
 	}
3580 3580
 	public function setValue($value)
3581 3581
 	{
3582
-		$this->_value=$value;
3582
+		$this->_value = $value;
3583 3583
 	}
3584 3584
 	public function getPath()
3585 3585
 	{
@@ -3587,7 +3587,7 @@  discard block
 block discarded – undo
3587 3587
 	}
3588 3588
 	public function setPath($value)
3589 3589
 	{
3590
-		$this->_path=$value;
3590
+		$this->_path = $value;
3591 3591
 	}
3592 3592
 	public function getSecure()
3593 3593
 	{
@@ -3595,12 +3595,12 @@  discard block
 block discarded – undo
3595 3595
 	}
3596 3596
 	public function setSecure($value)
3597 3597
 	{
3598
-		$this->_secure=TPropertyValue::ensureBoolean($value);
3598
+		$this->_secure = TPropertyValue::ensureBoolean($value);
3599 3599
 	}
3600 3600
 }
3601 3601
 class TUri extends TComponent
3602 3602
 {
3603
-	private static $_defaultPort=array(
3603
+	private static $_defaultPort = array(
3604 3604
 		'ftp'=>21,
3605 3605
 		'gopher'=>70,
3606 3606
 		'http'=>80,
@@ -3621,21 +3621,21 @@  discard block
 block discarded – undo
3621 3621
 	private $_uri;
3622 3622
 	public function __construct($uri)
3623 3623
 	{
3624
-		if(($ret=@parse_url($uri))!==false)
3624
+		if (($ret = @parse_url($uri)) !== false)
3625 3625
 		{
3626
-						$this->_scheme=isset($ret['scheme'])?$ret['scheme']:'';
3627
-			$this->_host=isset($ret['host'])?$ret['host']:'';
3628
-			$this->_port=isset($ret['port'])?$ret['port']:'';
3629
-			$this->_user=isset($ret['user'])?$ret['user']:'';
3630
-			$this->_pass=isset($ret['pass'])?$ret['pass']:'';
3631
-			$this->_path=isset($ret['path'])?$ret['path']:'';
3632
-			$this->_query=isset($ret['query'])?$ret['query']:'';
3633
-			$this->_fragment=isset($ret['fragment'])?$ret['fragment']:'';
3634
-			$this->_uri=$uri;
3626
+						$this->_scheme = isset($ret['scheme']) ? $ret['scheme'] : '';
3627
+			$this->_host = isset($ret['host']) ? $ret['host'] : '';
3628
+			$this->_port = isset($ret['port']) ? $ret['port'] : '';
3629
+			$this->_user = isset($ret['user']) ? $ret['user'] : '';
3630
+			$this->_pass = isset($ret['pass']) ? $ret['pass'] : '';
3631
+			$this->_path = isset($ret['path']) ? $ret['path'] : '';
3632
+			$this->_query = isset($ret['query']) ? $ret['query'] : '';
3633
+			$this->_fragment = isset($ret['fragment']) ? $ret['fragment'] : '';
3634
+			$this->_uri = $uri;
3635 3635
 		}
3636 3636
 		else
3637 3637
 		{
3638
-			throw new TInvalidDataValueException('uri_format_invalid',$uri);
3638
+			throw new TInvalidDataValueException('uri_format_invalid', $uri);
3639 3639
 		}
3640 3640
 	}
3641 3641
 	public function getUri()
@@ -3677,16 +3677,16 @@  discard block
 block discarded – undo
3677 3677
 }
3678 3678
 class THttpRequestUrlFormat extends TEnumerable
3679 3679
 {
3680
-	const Get='Get';
3681
-	const Path='Path';
3682
-	const HiddenPath='HiddenPath';
3680
+	const Get = 'Get';
3681
+	const Path = 'Path';
3682
+	const HiddenPath = 'HiddenPath';
3683 3683
 }
3684 3684
 class THttpResponseAdapter extends TApplicationComponent
3685 3685
 {
3686 3686
 	private $_response;
3687 3687
 	public function __construct($response)
3688 3688
 	{
3689
-		$this->_response=$response;
3689
+		$this->_response = $response;
3690 3690
 	}
3691 3691
 	public function getResponse()
3692 3692
 	{
@@ -3702,13 +3702,13 @@  discard block
 block discarded – undo
3702 3702
 	}
3703 3703
 	public function createNewHtmlWriter($type, $writer)
3704 3704
 	{
3705
-		return $this->_response->createNewHtmlWriter($type,$writer);
3705
+		return $this->_response->createNewHtmlWriter($type, $writer);
3706 3706
 	}
3707 3707
 }
3708 3708
 class THttpResponse extends TModule implements ITextWriter
3709 3709
 {
3710
-	const DEFAULT_CONTENTTYPE	= 'text/html';
3711
-	const DEFAULT_CHARSET		= 'UTF-8';
3710
+	const DEFAULT_CONTENTTYPE = 'text/html';
3711
+	const DEFAULT_CHARSET = 'UTF-8';
3712 3712
 	private static $HTTP_STATUS_CODES = array(
3713 3713
 		100 => 'Continue', 101 => 'Switching Protocols',
3714 3714
 		200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content',
@@ -3716,14 +3716,14 @@  discard block
 block discarded – undo
3716 3716
 		400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed',
3717 3717
 		500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported'
3718 3718
 	);
3719
-	private $_bufferOutput=true;
3720
-	private $_initialized=false;
3721
-	private $_cookies=null;
3722
-	private $_status=200;
3723
-	private $_reason='OK';
3724
-	private $_htmlWriterType='System.Web.UI.THtmlWriter';
3725
-	private $_contentType=null;
3726
-	private $_charset='';
3719
+	private $_bufferOutput = true;
3720
+	private $_initialized = false;
3721
+	private $_cookies = null;
3722
+	private $_status = 200;
3723
+	private $_reason = 'OK';
3724
+	private $_htmlWriterType = 'System.Web.UI.THtmlWriter';
3725
+	private $_contentType = null;
3726
+	private $_charset = '';
3727 3727
 	private $_adapter;
3728 3728
 	private $_httpHeaderSent;
3729 3729
 	private $_contentTypeHeaderSent;
@@ -3732,7 +3732,7 @@  discard block
 block discarded – undo
3732 3732
 					}
3733 3733
 	public function setAdapter(THttpResponseAdapter $adapter)
3734 3734
 	{
3735
-		$this->_adapter=$adapter;
3735
+		$this->_adapter = $adapter;
3736 3736
 	}
3737 3737
 	public function getAdapter()
3738 3738
 	{
@@ -3740,13 +3740,13 @@  discard block
 block discarded – undo
3740 3740
 	}
3741 3741
 	public function getHasAdapter()
3742 3742
 	{
3743
-		return $this->_adapter!==null;
3743
+		return $this->_adapter !== null;
3744 3744
 	}
3745 3745
 	public function init($config)
3746 3746
 	{
3747
-		if($this->_bufferOutput)
3747
+		if ($this->_bufferOutput)
3748 3748
 			ob_start();
3749
-		$this->_initialized=true;
3749
+		$this->_initialized = true;
3750 3750
 		$this->getApplication()->setResponse($this);
3751 3751
 	}
3752 3752
 	public function getCacheExpire()
@@ -3763,7 +3763,7 @@  discard block
 block discarded – undo
3763 3763
 	}
3764 3764
 	public function setCacheControl($value)
3765 3765
 	{
3766
-		session_cache_limiter(TPropertyValue::ensureEnum($value,array('none','nocache','private','private_no_expire','public')));
3766
+		session_cache_limiter(TPropertyValue::ensureEnum($value, array('none', 'nocache', 'private', 'private_no_expire', 'public')));
3767 3767
 	}
3768 3768
 	public function setContentType($type)
3769 3769
 	{
@@ -3781,7 +3781,7 @@  discard block
 block discarded – undo
3781 3781
 	}
3782 3782
 	public function setCharset($charset)
3783 3783
 	{
3784
-		$this->_charset = (strToLower($charset) === 'false') ? false : (string)$charset;
3784
+		$this->_charset = (strToLower($charset) === 'false') ? false : (string) $charset;
3785 3785
 	}
3786 3786
 	public function getBufferOutput()
3787 3787
 	{
@@ -3789,41 +3789,41 @@  discard block
 block discarded – undo
3789 3789
 	}
3790 3790
 	public function setBufferOutput($value)
3791 3791
 	{
3792
-		if($this->_initialized)
3792
+		if ($this->_initialized)
3793 3793
 			throw new TInvalidOperationException('httpresponse_bufferoutput_unchangeable');
3794 3794
 		else
3795
-			$this->_bufferOutput=TPropertyValue::ensureBoolean($value);
3795
+			$this->_bufferOutput = TPropertyValue::ensureBoolean($value);
3796 3796
 	}
3797 3797
 	public function getStatusCode()
3798 3798
 	{
3799 3799
 		return $this->_status;
3800 3800
 	}
3801
-	public function setStatusCode($status, $reason=null)
3801
+	public function setStatusCode($status, $reason = null)
3802 3802
 	{
3803 3803
 		if ($this->_httpHeaderSent)
3804 3804
 			throw new Exception('Unable to alter response as HTTP header already sent');
3805
-		$status=TPropertyValue::ensureInteger($status);
3806
-		if(isset(self::$HTTP_STATUS_CODES[$status])) {
3807
-			$this->_reason=self::$HTTP_STATUS_CODES[$status];
3808
-		}else{
3809
-			if($reason===null || $reason==='') {
3805
+		$status = TPropertyValue::ensureInteger($status);
3806
+		if (isset(self::$HTTP_STATUS_CODES[$status])) {
3807
+			$this->_reason = self::$HTTP_STATUS_CODES[$status];
3808
+		} else {
3809
+			if ($reason === null || $reason === '') {
3810 3810
 				throw new TInvalidDataValueException("response_status_reason_missing");
3811 3811
 			}
3812
-			$reason=TPropertyValue::ensureString($reason);
3813
-			if(strpos($reason, "\r")!=false || strpos($reason, "\n")!=false) {
3812
+			$reason = TPropertyValue::ensureString($reason);
3813
+			if (strpos($reason, "\r") != false || strpos($reason, "\n") != false) {
3814 3814
 				throw new TInvalidDataValueException("response_status_reason_barchars");
3815 3815
 			}
3816
-			$this->_reason=$reason;
3816
+			$this->_reason = $reason;
3817 3817
 		}
3818
-		$this->_status=$status;
3818
+		$this->_status = $status;
3819 3819
 	}
3820 3820
 	public function getStatusReason() {
3821 3821
 		return $this->_reason;
3822 3822
 	}
3823 3823
 	public function getCookies()
3824 3824
 	{
3825
-		if($this->_cookies===null)
3826
-			$this->_cookies=new THttpCookieCollection($this);
3825
+		if ($this->_cookies === null)
3826
+			$this->_cookies = new THttpCookieCollection($this);
3827 3827
 		return $this->_cookies;
3828 3828
 	}
3829 3829
 	public function write($str)
@@ -3832,9 +3832,9 @@  discard block
 block discarded – undo
3832 3832
 			$this->ensureHeadersSent();
3833 3833
 		echo $str;
3834 3834
 	}
3835
-	public function writeFile($fileName,$content=null,$mimeType=null,$headers=null,$forceDownload=true,$clientFileName=null,$fileSize=null)
3835
+	public function writeFile($fileName, $content = null, $mimeType = null, $headers = null, $forceDownload = true, $clientFileName = null, $fileSize = null)
3836 3836
 	{
3837
-		static $defaultMimeTypes=array(
3837
+		static $defaultMimeTypes = array(
3838 3838
 			'css'=>'text/css',
3839 3839
 			'gif'=>'image/gif',
3840 3840
 			'png'=>'image/png',
@@ -3846,28 +3846,28 @@  discard block
 block discarded – undo
3846 3846
 			'pdf'=>'application/pdf',
3847 3847
 			'xls'=>'application/vnd.ms-excel',
3848 3848
 		);
3849
-		if($mimeType===null)
3849
+		if ($mimeType === null)
3850 3850
 		{
3851
-			$mimeType='text/plain';
3852
-			if(function_exists('mime_content_type'))
3853
-				$mimeType=mime_content_type($fileName);
3854
-			else if(($ext=strrchr($fileName,'.'))!==false)
3851
+			$mimeType = 'text/plain';
3852
+			if (function_exists('mime_content_type'))
3853
+				$mimeType = mime_content_type($fileName);
3854
+			else if (($ext = strrchr($fileName, '.')) !== false)
3855 3855
 			{
3856
-				$ext=substr($ext,1);
3857
-				if(isset($defaultMimeTypes[$ext]))
3858
-					$mimeType=$defaultMimeTypes[$ext];
3856
+				$ext = substr($ext, 1);
3857
+				if (isset($defaultMimeTypes[$ext]))
3858
+					$mimeType = $defaultMimeTypes[$ext];
3859 3859
 			}
3860 3860
 		}
3861
-		if($clientFileName===null)
3862
-			$clientFileName=basename($fileName);
3861
+		if ($clientFileName === null)
3862
+			$clientFileName = basename($fileName);
3863 3863
 		else
3864
-			$clientFileName=basename($clientFileName);
3865
-		if($fileSize===null || $fileSize < 0)
3866
-			$fileSize = ($content===null?filesize($fileName):strlen($content));
3864
+			$clientFileName = basename($clientFileName);
3865
+		if ($fileSize === null || $fileSize < 0)
3866
+			$fileSize = ($content === null ? filesize($fileName) : strlen($content));
3867 3867
 		$this->sendHttpHeader();
3868
-		if(is_array($headers))
3868
+		if (is_array($headers))
3869 3869
 		{
3870
-			foreach($headers as $h)
3870
+			foreach ($headers as $h)
3871 3871
 				header($h);
3872 3872
 		}
3873 3873
 		else
@@ -3878,17 +3878,17 @@  discard block
 block discarded – undo
3878 3878
 			header("Content-Type: $mimeType");
3879 3879
 			$this->_contentTypeHeaderSent = true;
3880 3880
 		}
3881
-		header('Content-Length: '.$fileSize);
3881
+		header('Content-Length: ' . $fileSize);
3882 3882
 		header("Content-Disposition: " . ($forceDownload ? 'attachment' : 'inline') . "; filename=\"$clientFileName\"");
3883 3883
 		header('Content-Transfer-Encoding: binary');
3884
-		if($content===null)
3884
+		if ($content === null)
3885 3885
 			readfile($fileName);
3886 3886
 		else
3887 3887
 			echo $content;
3888 3888
 	}
3889 3889
 	public function redirect($url)
3890 3890
 	{
3891
-		if($this->getHasAdapter())
3891
+		if ($this->getHasAdapter())
3892 3892
 			$this->_adapter->httpRedirect($url);
3893 3893
 		else
3894 3894
 			$this->httpRedirect($url);
@@ -3896,13 +3896,13 @@  discard block
 block discarded – undo
3896 3896
 	public function httpRedirect($url)
3897 3897
 	{
3898 3898
 		$this->ensureHeadersSent();
3899
-		if($url[0]==='/')
3900
-			$url=$this->getRequest()->getBaseUrl().$url;
3899
+		if ($url[0] === '/')
3900
+			$url = $this->getRequest()->getBaseUrl() . $url;
3901 3901
 		if ($this->_status >= 300 && $this->_status < 400)
3902
-						header('Location: '.str_replace('&amp;','&',$url), true, $this->_status);
3902
+						header('Location: ' . str_replace('&amp;', '&', $url), true, $this->_status);
3903 3903
 		else
3904
-			header('Location: '.str_replace('&amp;','&',$url));
3905
-		if(!$this->getApplication()->getRequestCompleted())
3904
+			header('Location: ' . str_replace('&amp;', '&', $url));
3905
+		if (!$this->getApplication()->getRequestCompleted())
3906 3906
 			$this->getApplication()->onEndRequest();
3907 3907
 		exit();
3908 3908
 	}
@@ -3912,7 +3912,7 @@  discard block
 block discarded – undo
3912 3912
 	}
3913 3913
 	public function flush($continueBuffering = true)
3914 3914
 	{
3915
-		if($this->getHasAdapter())
3915
+		if ($this->getHasAdapter())
3916 3916
 			$this->_adapter->flushContent($continueBuffering);
3917 3917
 		else
3918 3918
 			$this->flushContent($continueBuffering);
@@ -3925,9 +3925,9 @@  discard block
 block discarded – undo
3925 3925
 	public function flushContent($continueBuffering = true)
3926 3926
 	{
3927 3927
 		$this->ensureHeadersSent();
3928
-		if($this->_bufferOutput)
3928
+		if ($this->_bufferOutput)
3929 3929
 		{
3930
-						if (ob_get_length()>0)
3930
+						if (ob_get_length() > 0)
3931 3931
 			{
3932 3932
 				if (!$continueBuffering)
3933 3933
 				{
@@ -3949,12 +3949,12 @@  discard block
 block discarded – undo
3949 3949
 	}
3950 3950
 	protected function sendHttpHeader()
3951 3951
 	{
3952
-		$protocol=$this->getRequest()->getHttpProtocolVersion();
3953
-		if($this->getRequest()->getHttpProtocolVersion() === null)
3954
-			$protocol='HTTP/1.1';
3952
+		$protocol = $this->getRequest()->getHttpProtocolVersion();
3953
+		if ($this->getRequest()->getHttpProtocolVersion() === null)
3954
+			$protocol = 'HTTP/1.1';
3955 3955
 		$phpSapiName = substr(php_sapi_name(), 0, 3);
3956 3956
 		$cgi = $phpSapiName == 'cgi' || $phpSapiName == 'fpm';
3957
-		header(($cgi ? 'Status:' : $protocol).' '.$this->_status.' '.$this->_reason, true, TPropertyValue::ensureInteger($this->_status));
3957
+		header(($cgi ? 'Status:' : $protocol) . ' ' . $this->_status . ' ' . $this->_reason, true, TPropertyValue::ensureInteger($this->_status));
3958 3958
 		$this->_httpHeaderSent = true;
3959 3959
 	}
3960 3960
 	protected function ensureContentTypeHeaderSent()
@@ -3964,58 +3964,58 @@  discard block
 block discarded – undo
3964 3964
 	}
3965 3965
 	protected function sendContentTypeHeader()
3966 3966
 	{
3967
-		$contentType=$this->_contentType===null?self::DEFAULT_CONTENTTYPE:$this->_contentType;
3968
-		$charset=$this->getCharset();
3969
-		if($charset === false) {
3970
-			$this->appendHeader('Content-Type: '.$contentType);
3967
+		$contentType = $this->_contentType === null ? self::DEFAULT_CONTENTTYPE : $this->_contentType;
3968
+		$charset = $this->getCharset();
3969
+		if ($charset === false) {
3970
+			$this->appendHeader('Content-Type: ' . $contentType);
3971 3971
 			return;
3972 3972
 		}
3973
-		if($charset==='' && ($globalization=$this->getApplication()->getGlobalization(false))!==null)
3974
-			$charset=$globalization->getCharset();
3975
-		if($charset==='') $charset = self::DEFAULT_CHARSET;
3976
-		$this->appendHeader('Content-Type: '.$contentType.';charset='.$charset);
3973
+		if ($charset === '' && ($globalization = $this->getApplication()->getGlobalization(false)) !== null)
3974
+			$charset = $globalization->getCharset();
3975
+		if ($charset === '') $charset = self::DEFAULT_CHARSET;
3976
+		$this->appendHeader('Content-Type: ' . $contentType . ';charset=' . $charset);
3977 3977
 		$this->_contentTypeHeaderSent = true;
3978 3978
 	}
3979 3979
 	public function getContents()
3980 3980
 	{
3981
-		return $this->_bufferOutput?ob_get_contents():'';
3981
+		return $this->_bufferOutput ? ob_get_contents() : '';
3982 3982
 	}
3983 3983
 	public function clear()
3984 3984
 	{
3985
-		if($this->_bufferOutput)
3985
+		if ($this->_bufferOutput)
3986 3986
 			ob_clean();
3987 3987
 	}
3988
-	public function getHeaders($case=null)
3988
+	public function getHeaders($case = null)
3989 3989
 	{
3990 3990
 		$result = array();
3991 3991
 		$headers = headers_list();
3992
-		foreach($headers as $header) {
3992
+		foreach ($headers as $header) {
3993 3993
 			$tmp = explode(':', $header);
3994 3994
 			$key = trim(array_shift($tmp));
3995 3995
 			$value = trim(implode(':', $tmp));
3996
-			if(isset($result[$key]))
3996
+			if (isset($result[$key]))
3997 3997
 				$result[$key] .= ', ' . $value;
3998 3998
 			else
3999 3999
 				$result[$key] = $value;
4000 4000
 		}
4001
-		if($case !== null)
4001
+		if ($case !== null)
4002 4002
 			return array_change_key_case($result, $case);
4003 4003
 		return $result;
4004 4004
 	}
4005
-	public function appendHeader($value, $replace=true)
4005
+	public function appendHeader($value, $replace = true)
4006 4006
 	{
4007 4007
 		header($value, $replace);
4008 4008
 	}
4009
-	public function appendLog($message,$messageType=0,$destination='',$extraHeaders='')
4009
+	public function appendLog($message, $messageType = 0, $destination = '', $extraHeaders = '')
4010 4010
 	{
4011
-		error_log($message,$messageType,$destination,$extraHeaders);
4011
+		error_log($message, $messageType, $destination, $extraHeaders);
4012 4012
 	}
4013 4013
 	public function addCookie($cookie)
4014 4014
 	{
4015
-		$request=$this->getRequest();
4016
-		if($request->getEnableCookieValidation())
4015
+		$request = $this->getRequest();
4016
+		if ($request->getEnableCookieValidation())
4017 4017
 		{
4018
-			$value=$this->getApplication()->getSecurityManager()->hashData($cookie->getValue());
4018
+			$value = $this->getApplication()->getSecurityManager()->hashData($cookie->getValue());
4019 4019
 			setcookie(
4020 4020
 				$cookie->getName(),
4021 4021
 				$value,
@@ -4056,13 +4056,13 @@  discard block
 block discarded – undo
4056 4056
 	}
4057 4057
 	public function setHtmlWriterType($value)
4058 4058
 	{
4059
-		$this->_htmlWriterType=$value;
4059
+		$this->_htmlWriterType = $value;
4060 4060
 	}
4061
-	public function createHtmlWriter($type=null)
4061
+	public function createHtmlWriter($type = null)
4062 4062
 	{
4063
-		if($type===null)
4064
-			$type=$this->getHtmlWriterType();
4065
-		if($this->getHasAdapter())
4063
+		if ($type === null)
4064
+			$type = $this->getHtmlWriterType();
4065
+		if ($this->getHasAdapter())
4066 4066
 			return $this->_adapter->createNewHtmlWriter($type, $this);
4067 4067
 		else
4068 4068
 			return $this->createNewHtmlWriter($type, $this);
@@ -4072,60 +4072,60 @@  discard block
 block discarded – undo
4072 4072
 		return Prado::createComponent($type, $writer);
4073 4073
 	}
4074 4074
 }
4075
-class THttpSession extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule
4075
+class THttpSession extends TApplicationComponent implements IteratorAggregate, ArrayAccess, Countable, IModule
4076 4076
 {
4077
-	private $_initialized=false;
4078
-	private $_started=false;
4079
-	private $_autoStart=false;
4080
-	private $_cookie=null;
4077
+	private $_initialized = false;
4078
+	private $_started = false;
4079
+	private $_autoStart = false;
4080
+	private $_cookie = null;
4081 4081
 	private $_id;
4082
-	private $_customStorage=false;
4082
+	private $_customStorage = false;
4083 4083
 	public function getID()
4084 4084
 	{
4085 4085
 		return $this->_id;
4086 4086
 	}
4087 4087
 	public function setID($value)
4088 4088
 	{
4089
-		$this->_id=$value;
4089
+		$this->_id = $value;
4090 4090
 	}
4091 4091
 	public function init($config)
4092 4092
 	{
4093
-		if($this->_autoStart)
4093
+		if ($this->_autoStart)
4094 4094
 			$this->open();
4095
-		$this->_initialized=true;
4095
+		$this->_initialized = true;
4096 4096
 		$this->getApplication()->setSession($this);
4097 4097
 		register_shutdown_function(array($this, "close"));
4098 4098
 	}
4099 4099
 	public function open()
4100 4100
 	{
4101
-		if(!$this->_started)
4101
+		if (!$this->_started)
4102 4102
 		{
4103
-			if($this->_customStorage)
4104
-				session_set_save_handler(array($this,'_open'),array($this,'_close'),array($this,'_read'),array($this,'_write'),array($this,'_destroy'),array($this,'_gc'));
4105
-			if($this->_cookie!==null)
4106
-				session_set_cookie_params($this->_cookie->getExpire(),$this->_cookie->getPath(),$this->_cookie->getDomain(),$this->_cookie->getSecure(),$this->_cookie->getHttpOnly());
4107
-			if(ini_get('session.auto_start')!=='1')
4103
+			if ($this->_customStorage)
4104
+				session_set_save_handler(array($this, '_open'), array($this, '_close'), array($this, '_read'), array($this, '_write'), array($this, '_destroy'), array($this, '_gc'));
4105
+			if ($this->_cookie !== null)
4106
+				session_set_cookie_params($this->_cookie->getExpire(), $this->_cookie->getPath(), $this->_cookie->getDomain(), $this->_cookie->getSecure(), $this->_cookie->getHttpOnly());
4107
+			if (ini_get('session.auto_start') !== '1')
4108 4108
 				session_start();
4109
-			$this->_started=true;
4109
+			$this->_started = true;
4110 4110
 		}
4111 4111
 	}
4112 4112
 	public function close()
4113 4113
 	{
4114
-		if($this->_started)
4114
+		if ($this->_started)
4115 4115
 		{
4116 4116
 			session_write_close();
4117
-			$this->_started=false;
4117
+			$this->_started = false;
4118 4118
 		}
4119 4119
 	}
4120 4120
 	public function destroy()
4121 4121
 	{
4122
-		if($this->_started)
4122
+		if ($this->_started)
4123 4123
 		{
4124 4124
 			session_destroy();
4125
-			$this->_started=false;
4125
+			$this->_started = false;
4126 4126
 		}
4127 4127
 	}
4128
-	public function regenerate($deleteOld=false)
4128
+	public function regenerate($deleteOld = false)
4129 4129
 	{
4130 4130
 		$old = $this->getSessionID();
4131 4131
 		session_regenerate_id($deleteOld);
@@ -4141,7 +4141,7 @@  discard block
 block discarded – undo
4141 4141
 	}
4142 4142
 	public function setSessionID($value)
4143 4143
 	{
4144
-		if($this->_started)
4144
+		if ($this->_started)
4145 4145
 			throw new TInvalidOperationException('httpsession_sessionid_unchangeable');
4146 4146
 		else
4147 4147
 			session_id($value);
@@ -4152,12 +4152,12 @@  discard block
 block discarded – undo
4152 4152
 	}
4153 4153
 	public function setSessionName($value)
4154 4154
 	{
4155
-		if($this->_started)
4155
+		if ($this->_started)
4156 4156
 			throw new TInvalidOperationException('httpsession_sessionname_unchangeable');
4157
-		else if(ctype_alnum($value))
4157
+		else if (ctype_alnum($value))
4158 4158
 			session_name($value);
4159 4159
 		else
4160
-			throw new TInvalidDataValueException('httpsession_sessionname_invalid',$value);
4160
+			throw new TInvalidDataValueException('httpsession_sessionname_invalid', $value);
4161 4161
 	}
4162 4162
 	public function getSavePath()
4163 4163
 	{
@@ -4165,12 +4165,12 @@  discard block
 block discarded – undo
4165 4165
 	}
4166 4166
 	public function setSavePath($value)
4167 4167
 	{
4168
-		if($this->_started)
4168
+		if ($this->_started)
4169 4169
 			throw new TInvalidOperationException('httpsession_savepath_unchangeable');
4170
-		else if(is_dir($value))
4170
+		else if (is_dir($value))
4171 4171
 			session_save_path($value);
4172 4172
 		else
4173
-			throw new TInvalidDataValueException('httpsession_savepath_invalid',$value);
4173
+			throw new TInvalidDataValueException('httpsession_savepath_invalid', $value);
4174 4174
 	}
4175 4175
 	public function getUseCustomStorage()
4176 4176
 	{
@@ -4178,44 +4178,44 @@  discard block
 block discarded – undo
4178 4178
 	}
4179 4179
 	public function setUseCustomStorage($value)
4180 4180
 	{
4181
-		$this->_customStorage=TPropertyValue::ensureBoolean($value);
4181
+		$this->_customStorage = TPropertyValue::ensureBoolean($value);
4182 4182
 	}
4183 4183
 	public function getCookie()
4184 4184
 	{
4185
-		if($this->_cookie===null)
4186
-			$this->_cookie=new THttpCookie($this->getSessionName(),$this->getSessionID());
4185
+		if ($this->_cookie === null)
4186
+			$this->_cookie = new THttpCookie($this->getSessionName(), $this->getSessionID());
4187 4187
 		return $this->_cookie;
4188 4188
 	}
4189 4189
 	public function getCookieMode()
4190 4190
 	{
4191
-		if(ini_get('session.use_cookies')==='0')
4191
+		if (ini_get('session.use_cookies') === '0')
4192 4192
 			return THttpSessionCookieMode::None;
4193
-		else if(ini_get('session.use_only_cookies')==='0')
4193
+		else if (ini_get('session.use_only_cookies') === '0')
4194 4194
 			return THttpSessionCookieMode::Allow;
4195 4195
 		else
4196 4196
 			return THttpSessionCookieMode::Only;
4197 4197
 	}
4198 4198
 	public function setCookieMode($value)
4199 4199
 	{
4200
-		if($this->_started)
4200
+		if ($this->_started)
4201 4201
 			throw new TInvalidOperationException('httpsession_cookiemode_unchangeable');
4202 4202
 		else
4203 4203
 		{
4204
-			$value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode');
4205
-			if($value===THttpSessionCookieMode::None) 
4204
+			$value = TPropertyValue::ensureEnum($value, 'THttpSessionCookieMode');
4205
+			if ($value === THttpSessionCookieMode::None) 
4206 4206
       {
4207
-				ini_set('session.use_cookies','0');
4208
-			  ini_set('session.use_only_cookies','0');
4207
+				ini_set('session.use_cookies', '0');
4208
+			  ini_set('session.use_only_cookies', '0');
4209 4209
       }
4210
-			else if($value===THttpSessionCookieMode::Allow)
4210
+			else if ($value === THttpSessionCookieMode::Allow)
4211 4211
 			{
4212
-				ini_set('session.use_cookies','1');
4213
-				ini_set('session.use_only_cookies','0');
4212
+				ini_set('session.use_cookies', '1');
4213
+				ini_set('session.use_only_cookies', '0');
4214 4214
 			}
4215 4215
 			else
4216 4216
 			{
4217
-				ini_set('session.use_cookies','1');
4218
-				ini_set('session.use_only_cookies','1');
4217
+				ini_set('session.use_cookies', '1');
4218
+				ini_set('session.use_only_cookies', '1');
4219 4219
 				ini_set('session.use_trans_sid', 0);
4220 4220
 			}
4221 4221
 		}
@@ -4226,10 +4226,10 @@  discard block
 block discarded – undo
4226 4226
 	}
4227 4227
 	public function setAutoStart($value)
4228 4228
 	{
4229
-		if($this->_initialized)
4229
+		if ($this->_initialized)
4230 4230
 			throw new TInvalidOperationException('httpsession_autostart_unchangeable');
4231 4231
 		else
4232
-			$this->_autoStart=TPropertyValue::ensureBoolean($value);
4232
+			$this->_autoStart = TPropertyValue::ensureBoolean($value);
4233 4233
 	}
4234 4234
 	public function getGCProbability()
4235 4235
 	{
@@ -4237,34 +4237,34 @@  discard block
 block discarded – undo
4237 4237
 	}
4238 4238
 	public function setGCProbability($value)
4239 4239
 	{
4240
-		if($this->_started)
4240
+		if ($this->_started)
4241 4241
 			throw new TInvalidOperationException('httpsession_gcprobability_unchangeable');
4242 4242
 		else
4243 4243
 		{
4244
-			$value=TPropertyValue::ensureInteger($value);
4245
-			if($value>=0 && $value<=100)
4244
+			$value = TPropertyValue::ensureInteger($value);
4245
+			if ($value >= 0 && $value <= 100)
4246 4246
 			{
4247
-				ini_set('session.gc_probability',$value);
4248
-				ini_set('session.gc_divisor','100');
4247
+				ini_set('session.gc_probability', $value);
4248
+				ini_set('session.gc_divisor', '100');
4249 4249
 			}
4250 4250
 			else
4251
-				throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value);
4251
+				throw new TInvalidDataValueException('httpsession_gcprobability_invalid', $value);
4252 4252
 		}
4253 4253
 	}
4254 4254
 	public function getUseTransparentSessionID()
4255 4255
 	{
4256
-		return ini_get('session.use_trans_sid')==='1';
4256
+		return ini_get('session.use_trans_sid') === '1';
4257 4257
 	}
4258 4258
 	public function setUseTransparentSessionID($value)
4259 4259
 	{
4260
-		if($this->_started)
4260
+		if ($this->_started)
4261 4261
 			throw new TInvalidOperationException('httpsession_transid_unchangeable');
4262 4262
 		else
4263 4263
 		{
4264
-			$value=TPropertyValue::ensureBoolean($value);
4265
-			if ($value && $this->getCookieMode()==THttpSessionCookieMode::Only)
4264
+			$value = TPropertyValue::ensureBoolean($value);
4265
+			if ($value && $this->getCookieMode() == THttpSessionCookieMode::Only)
4266 4266
 					throw new TInvalidOperationException('httpsession_transid_cookieonly');
4267
-			ini_set('session.use_trans_sid',$value?'1':'0');
4267
+			ini_set('session.use_trans_sid', $value ? '1' : '0');
4268 4268
 		}
4269 4269
 	}
4270 4270
 	public function getTimeout()
@@ -4273,12 +4273,12 @@  discard block
 block discarded – undo
4273 4273
 	}
4274 4274
 	public function setTimeout($value)
4275 4275
 	{
4276
-		if($this->_started)
4276
+		if ($this->_started)
4277 4277
 			throw new TInvalidOperationException('httpsession_maxlifetime_unchangeable');
4278 4278
 		else
4279
-			ini_set('session.gc_maxlifetime',$value);
4279
+			ini_set('session.gc_maxlifetime', $value);
4280 4280
 	}
4281
-	public function _open($savePath,$sessionName)
4281
+	public function _open($savePath, $sessionName)
4282 4282
 	{
4283 4283
 		return true;
4284 4284
 	}
@@ -4290,7 +4290,7 @@  discard block
 block discarded – undo
4290 4290
 	{
4291 4291
 		return '';
4292 4292
 	}
4293
-	public function _write($id,$data)
4293
+	public function _write($id, $data)
4294 4294
 	{
4295 4295
 		return true;
4296 4296
 	}
@@ -4322,15 +4322,15 @@  discard block
 block discarded – undo
4322 4322
 	{
4323 4323
 		return isset($_SESSION[$key]) ? $_SESSION[$key] : null;
4324 4324
 	}
4325
-	public function add($key,$value)
4325
+	public function add($key, $value)
4326 4326
 	{
4327
-		$_SESSION[$key]=$value;
4327
+		$_SESSION[$key] = $value;
4328 4328
 	}
4329 4329
 	public function remove($key)
4330 4330
 	{
4331
-		if(isset($_SESSION[$key]))
4331
+		if (isset($_SESSION[$key]))
4332 4332
 		{
4333
-			$value=$_SESSION[$key];
4333
+			$value = $_SESSION[$key];
4334 4334
 			unset($_SESSION[$key]);
4335 4335
 			return $value;
4336 4336
 		}
@@ -4339,7 +4339,7 @@  discard block
 block discarded – undo
4339 4339
 	}
4340 4340
 	public function clear()
4341 4341
 	{
4342
-		foreach(array_keys($_SESSION) as $key)
4342
+		foreach (array_keys($_SESSION) as $key)
4343 4343
 			unset($_SESSION[$key]);
4344 4344
 	}
4345 4345
 	public function contains($key)
@@ -4358,9 +4358,9 @@  discard block
 block discarded – undo
4358 4358
 	{
4359 4359
 		return isset($_SESSION[$offset]) ? $_SESSION[$offset] : null;
4360 4360
 	}
4361
-	public function offsetSet($offset,$item)
4361
+	public function offsetSet($offset, $item)
4362 4362
 	{
4363
-		$_SESSION[$offset]=$item;
4363
+		$_SESSION[$offset] = $item;
4364 4364
 	}
4365 4365
 	public function offsetUnset($offset)
4366 4366
 	{
@@ -4373,11 +4373,11 @@  discard block
 block discarded – undo
4373 4373
 	private $_key;
4374 4374
 	public function __construct()
4375 4375
 	{
4376
-		$this->_keys=array_keys($_SESSION);
4376
+		$this->_keys = array_keys($_SESSION);
4377 4377
 	}
4378 4378
 	public function rewind()
4379 4379
 	{
4380
-		$this->_key=reset($this->_keys);
4380
+		$this->_key = reset($this->_keys);
4381 4381
 	}
4382 4382
 	public function key()
4383 4383
 	{
@@ -4385,38 +4385,38 @@  discard block
 block discarded – undo
4385 4385
 	}
4386 4386
 	public function current()
4387 4387
 	{
4388
-		return isset($_SESSION[$this->_key])?$_SESSION[$this->_key]:null;
4388
+		return isset($_SESSION[$this->_key]) ? $_SESSION[$this->_key] : null;
4389 4389
 	}
4390 4390
 	public function next()
4391 4391
 	{
4392 4392
 		do
4393 4393
 		{
4394
-			$this->_key=next($this->_keys);
4394
+			$this->_key = next($this->_keys);
4395 4395
 		}
4396
-		while(!isset($_SESSION[$this->_key]) && $this->_key!==false);
4396
+		while (!isset($_SESSION[$this->_key]) && $this->_key !== false);
4397 4397
 	}
4398 4398
 	public function valid()
4399 4399
 	{
4400
-		return $this->_key!==false;
4400
+		return $this->_key !== false;
4401 4401
 	}
4402 4402
 }
4403 4403
 class THttpSessionCookieMode extends TEnumerable
4404 4404
 {
4405
-	const None='None';
4406
-	const Allow='Allow';
4407
-	const Only='Only';
4405
+	const None = 'None';
4406
+	const Allow = 'Allow';
4407
+	const Only = 'Only';
4408 4408
 }
4409 4409
 Prado::using('System.Web.UI.WebControls.*');
4410 4410
 class TAttributeCollection extends TMap
4411 4411
 {
4412
-	private $_caseSensitive=false;
4412
+	private $_caseSensitive = false;
4413 4413
 	public function __get($name)
4414 4414
 	{
4415
-		return $this->contains($name)?$this->itemAt($name):parent::__get($name);
4415
+		return $this->contains($name) ? $this->itemAt($name) : parent::__get($name);
4416 4416
 	}
4417
-	public function __set($name,$value)
4417
+	public function __set($name, $value)
4418 4418
 	{
4419
-		$this->add($name,$value);
4419
+		$this->add($name, $value);
4420 4420
 	}
4421 4421
 	public function getCaseSensitive()
4422 4422
 	{
@@ -4424,23 +4424,23 @@  discard block
 block discarded – undo
4424 4424
 	}
4425 4425
 	public function setCaseSensitive($value)
4426 4426
 	{
4427
-		$this->_caseSensitive=TPropertyValue::ensureBoolean($value);
4427
+		$this->_caseSensitive = TPropertyValue::ensureBoolean($value);
4428 4428
 	}
4429 4429
 	public function itemAt($key)
4430 4430
 	{
4431
-		return parent::itemAt($this->_caseSensitive?$key:strtolower($key));
4431
+		return parent::itemAt($this->_caseSensitive ? $key : strtolower($key));
4432 4432
 	}
4433
-	public function add($key,$value)
4433
+	public function add($key, $value)
4434 4434
 	{
4435
-		parent::add($this->_caseSensitive?$key:strtolower($key),$value);
4435
+		parent::add($this->_caseSensitive ? $key : strtolower($key), $value);
4436 4436
 	}
4437 4437
 	public function remove($key)
4438 4438
 	{
4439
-		return parent::remove($this->_caseSensitive?$key:strtolower($key));
4439
+		return parent::remove($this->_caseSensitive ? $key : strtolower($key));
4440 4440
 	}
4441 4441
 	public function contains($key)
4442 4442
 	{
4443
-		return parent::contains($this->_caseSensitive?$key:strtolower($key));
4443
+		return parent::contains($this->_caseSensitive ? $key : strtolower($key));
4444 4444
 	}
4445 4445
 	public function hasProperty($name)
4446 4446
 	{
@@ -4460,7 +4460,7 @@  discard block
 block discarded – undo
4460 4460
 	protected $_control;
4461 4461
 	public function __construct($control)
4462 4462
 	{
4463
-		$this->_control=$control;
4463
+		$this->_control = $control;
4464 4464
 	}
4465 4465
 	public function getControl()
4466 4466
 	{
@@ -4468,7 +4468,7 @@  discard block
 block discarded – undo
4468 4468
 	}
4469 4469
 	public function getPage()
4470 4470
 	{
4471
-		return $this->_control?$this->_control->getPage():null;
4471
+		return $this->_control ? $this->_control->getPage() : null;
4472 4472
 	}
4473 4473
 	public function createChildControls()
4474 4474
 	{
@@ -4509,39 +4509,39 @@  discard block
 block discarded – undo
4509 4509
 }
4510 4510
 class TControl extends TApplicationComponent implements IRenderable, IBindable
4511 4511
 {
4512
-	const ID_FORMAT='/^[a-zA-Z_]\\w*$/';
4513
-	const ID_SEPARATOR='$';
4514
-	const CLIENT_ID_SEPARATOR='_';
4515
-	const AUTOMATIC_ID_PREFIX='ctl';
4516
-	const CS_CONSTRUCTED=0;
4517
-	const CS_CHILD_INITIALIZED=1;
4518
-	const CS_INITIALIZED=2;
4519
-	const CS_STATE_LOADED=3;
4520
-	const CS_LOADED=4;
4521
-	const CS_PRERENDERED=5;
4522
-	const IS_ID_SET=0x01;
4523
-	const IS_DISABLE_VIEWSTATE=0x02;
4524
-	const IS_SKIN_APPLIED=0x04;
4525
-	const IS_STYLESHEET_APPLIED=0x08;
4526
-	const IS_DISABLE_THEMING=0x10;
4527
-	const IS_CHILD_CREATED=0x20;
4528
-	const IS_CREATING_CHILD=0x40;
4529
-	const RF_CONTROLS=0;				const RF_CHILD_STATE=1;				const RF_NAMED_CONTROLS=2;			const RF_NAMED_CONTROLS_ID=3;		const RF_SKIN_ID=4;					const RF_DATA_BINDINGS=5;			const RF_EVENTS=6;					const RF_CONTROLSTATE=7;			const RF_NAMED_OBJECTS=8;			const RF_ADAPTER=9;					const RF_AUTO_BINDINGS=10;		
4530
-	private $_id='';
4512
+	const ID_FORMAT = '/^[a-zA-Z_]\\w*$/';
4513
+	const ID_SEPARATOR = '$';
4514
+	const CLIENT_ID_SEPARATOR = '_';
4515
+	const AUTOMATIC_ID_PREFIX = 'ctl';
4516
+	const CS_CONSTRUCTED = 0;
4517
+	const CS_CHILD_INITIALIZED = 1;
4518
+	const CS_INITIALIZED = 2;
4519
+	const CS_STATE_LOADED = 3;
4520
+	const CS_LOADED = 4;
4521
+	const CS_PRERENDERED = 5;
4522
+	const IS_ID_SET = 0x01;
4523
+	const IS_DISABLE_VIEWSTATE = 0x02;
4524
+	const IS_SKIN_APPLIED = 0x04;
4525
+	const IS_STYLESHEET_APPLIED = 0x08;
4526
+	const IS_DISABLE_THEMING = 0x10;
4527
+	const IS_CHILD_CREATED = 0x20;
4528
+	const IS_CREATING_CHILD = 0x40;
4529
+	const RF_CONTROLS = 0; const RF_CHILD_STATE = 1; const RF_NAMED_CONTROLS = 2; const RF_NAMED_CONTROLS_ID = 3; const RF_SKIN_ID = 4; const RF_DATA_BINDINGS = 5; const RF_EVENTS = 6; const RF_CONTROLSTATE = 7; const RF_NAMED_OBJECTS = 8; const RF_ADAPTER = 9; const RF_AUTO_BINDINGS = 10;		
4530
+	private $_id = '';
4531 4531
 	private $_uid;
4532 4532
 	private $_parent;
4533 4533
 	private $_page;
4534 4534
 	private $_namingContainer;
4535 4535
 	private $_tplControl;
4536
-	private $_viewState=array();
4537
-	private $_tempState=array();
4538
-	private $_trackViewState=true;
4539
-	private $_stage=0;
4540
-	private $_flags=0;
4541
-	private $_rf=array();
4536
+	private $_viewState = array();
4537
+	private $_tempState = array();
4538
+	private $_trackViewState = true;
4539
+	private $_stage = 0;
4540
+	private $_flags = 0;
4541
+	private $_rf = array();
4542 4542
 	public function __get($name)
4543 4543
 	{
4544
-		if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name]))
4544
+		if (isset($this->_rf[self::RF_NAMED_OBJECTS][$name]))
4545 4545
 			return $this->_rf[self::RF_NAMED_OBJECTS][$name];
4546 4546
 		else
4547 4547
 			return parent::__get($name);
@@ -4552,11 +4552,11 @@  discard block
 block discarded – undo
4552 4552
 	}
4553 4553
 	public function getAdapter()
4554 4554
 	{
4555
-		return isset($this->_rf[self::RF_ADAPTER])?$this->_rf[self::RF_ADAPTER]:null;
4555
+		return isset($this->_rf[self::RF_ADAPTER]) ? $this->_rf[self::RF_ADAPTER] : null;
4556 4556
 	}
4557 4557
 	public function setAdapter(TControlAdapter $adapter)
4558 4558
 	{
4559
-		$this->_rf[self::RF_ADAPTER]=$adapter;
4559
+		$this->_rf[self::RF_ADAPTER] = $adapter;
4560 4560
 	}
4561 4561
 	public function getParent()
4562 4562
 	{
@@ -4564,46 +4564,46 @@  discard block
 block discarded – undo
4564 4564
 	}
4565 4565
 	public function getNamingContainer()
4566 4566
 	{
4567
-		if(!$this->_namingContainer && $this->_parent)
4567
+		if (!$this->_namingContainer && $this->_parent)
4568 4568
 		{
4569
-			if($this->_parent instanceof INamingContainer)
4570
-				$this->_namingContainer=$this->_parent;
4569
+			if ($this->_parent instanceof INamingContainer)
4570
+				$this->_namingContainer = $this->_parent;
4571 4571
 			else
4572
-				$this->_namingContainer=$this->_parent->getNamingContainer();
4572
+				$this->_namingContainer = $this->_parent->getNamingContainer();
4573 4573
 		}
4574 4574
 		return $this->_namingContainer;
4575 4575
 	}
4576 4576
 	public function getPage()
4577 4577
 	{
4578
-		if(!$this->_page)
4578
+		if (!$this->_page)
4579 4579
 		{
4580
-			if($this->_parent)
4581
-				$this->_page=$this->_parent->getPage();
4582
-			else if($this->_tplControl)
4583
-				$this->_page=$this->_tplControl->getPage();
4580
+			if ($this->_parent)
4581
+				$this->_page = $this->_parent->getPage();
4582
+			else if ($this->_tplControl)
4583
+				$this->_page = $this->_tplControl->getPage();
4584 4584
 		}
4585 4585
 		return $this->_page;
4586 4586
 	}
4587 4587
 	public function setPage($page)
4588 4588
 	{
4589
-		$this->_page=$page;
4589
+		$this->_page = $page;
4590 4590
 	}
4591 4591
 	public function setTemplateControl($control)
4592 4592
 	{
4593
-		$this->_tplControl=$control;
4593
+		$this->_tplControl = $control;
4594 4594
 	}
4595 4595
 	public function getTemplateControl()
4596 4596
 	{
4597
-		if(!$this->_tplControl && $this->_parent)
4598
-			$this->_tplControl=$this->_parent->getTemplateControl();
4597
+		if (!$this->_tplControl && $this->_parent)
4598
+			$this->_tplControl = $this->_parent->getTemplateControl();
4599 4599
 		return $this->_tplControl;
4600 4600
 	}
4601 4601
 	public function getSourceTemplateControl()
4602 4602
 	{
4603
-		$control=$this;
4604
-		while(($control instanceof TControl) && ($control=$control->getTemplateControl())!==null)
4603
+		$control = $this;
4604
+		while (($control instanceof TControl) && ($control = $control->getTemplateControl()) !== null)
4605 4605
 		{
4606
-			if(($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl())
4606
+			if (($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl())
4607 4607
 				return $control;
4608 4608
 		}
4609 4609
 		return $this->getPage();
@@ -4614,36 +4614,36 @@  discard block
 block discarded – undo
4614 4614
 	}
4615 4615
 	protected function setControlStage($value)
4616 4616
 	{
4617
-		$this->_stage=$value;
4617
+		$this->_stage = $value;
4618 4618
 	}
4619
-	public function getID($hideAutoID=true)
4619
+	public function getID($hideAutoID = true)
4620 4620
 	{
4621
-		if($hideAutoID)
4621
+		if ($hideAutoID)
4622 4622
 			return ($this->_flags & self::IS_ID_SET) ? $this->_id : '';
4623 4623
 		else
4624 4624
 			return $this->_id;
4625 4625
 	}
4626 4626
 	public function setID($id)
4627 4627
 	{
4628
-		if(!preg_match(self::ID_FORMAT,$id))
4629
-			throw new TInvalidDataValueException('control_id_invalid',get_class($this),$id);
4630
-		$this->_id=$id;
4628
+		if (!preg_match(self::ID_FORMAT, $id))
4629
+			throw new TInvalidDataValueException('control_id_invalid', get_class($this), $id);
4630
+		$this->_id = $id;
4631 4631
 		$this->_flags |= self::IS_ID_SET;
4632 4632
 		$this->clearCachedUniqueID($this instanceof INamingContainer);
4633
-		if($this->_namingContainer)
4633
+		if ($this->_namingContainer)
4634 4634
 			$this->_namingContainer->clearNameTable();
4635 4635
 	}
4636 4636
 	public function getUniqueID()
4637 4637
 	{
4638
-		if($this->_uid==='' || $this->_uid===null)			{
4639
-			$this->_uid='';  			if($namingContainer=$this->getNamingContainer())
4638
+		if ($this->_uid === '' || $this->_uid === null) {
4639
+			$this->_uid = ''; if ($namingContainer = $this->getNamingContainer())
4640 4640
 			{
4641
-				if($this->getPage()===$namingContainer)
4642
-					return ($this->_uid=$this->_id);
4643
-				else if(($prefix=$namingContainer->getUniqueID())==='')
4641
+				if ($this->getPage() === $namingContainer)
4642
+					return ($this->_uid = $this->_id);
4643
+				else if (($prefix = $namingContainer->getUniqueID()) === '')
4644 4644
 					return $this->_id;
4645 4645
 				else
4646
-					return ($this->_uid=$prefix.self::ID_SEPARATOR.$this->_id);
4646
+					return ($this->_uid = $prefix . self::ID_SEPARATOR . $this->_id);
4647 4647
 			}
4648 4648
 			else					return $this->_id;
4649 4649
 		}
@@ -4656,22 +4656,22 @@  discard block
 block discarded – undo
4656 4656
 	}
4657 4657
 	public function getClientID()
4658 4658
 	{
4659
-		return strtr($this->getUniqueID(),self::ID_SEPARATOR,self::CLIENT_ID_SEPARATOR);
4659
+		return strtr($this->getUniqueID(), self::ID_SEPARATOR, self::CLIENT_ID_SEPARATOR);
4660 4660
 	}
4661 4661
 	public static function convertUniqueIdToClientId($uniqueID)
4662 4662
 	{
4663
-		return strtr($uniqueID,self::ID_SEPARATOR,self::CLIENT_ID_SEPARATOR);
4663
+		return strtr($uniqueID, self::ID_SEPARATOR, self::CLIENT_ID_SEPARATOR);
4664 4664
 	}
4665 4665
 	public function getSkinID()
4666 4666
 	{
4667
-		return isset($this->_rf[self::RF_SKIN_ID])?$this->_rf[self::RF_SKIN_ID]:'';
4667
+		return isset($this->_rf[self::RF_SKIN_ID]) ? $this->_rf[self::RF_SKIN_ID] : '';
4668 4668
 	}
4669 4669
 	public function setSkinID($value)
4670 4670
 	{
4671
-		if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage>=self::CS_CHILD_INITIALIZED)
4672
-			throw new TInvalidOperationException('control_skinid_unchangeable',get_class($this));
4671
+		if (($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage >= self::CS_CHILD_INITIALIZED)
4672
+			throw new TInvalidOperationException('control_skinid_unchangeable', get_class($this));
4673 4673
 		else
4674
-			$this->_rf[self::RF_SKIN_ID]=$value;
4674
+			$this->_rf[self::RF_SKIN_ID] = $value;
4675 4675
 	}
4676 4676
 	public function getIsSkinApplied()
4677 4677
 	{
@@ -4679,123 +4679,123 @@  discard block
 block discarded – undo
4679 4679
 	}
4680 4680
 	public function getEnableTheming()
4681 4681
 	{
4682
-		if($this->_flags & self::IS_DISABLE_THEMING)
4682
+		if ($this->_flags & self::IS_DISABLE_THEMING)
4683 4683
 			return false;
4684 4684
 		else
4685
-			return $this->_parent?$this->_parent->getEnableTheming():true;
4685
+			return $this->_parent ? $this->_parent->getEnableTheming() : true;
4686 4686
 	}
4687 4687
 	public function setEnableTheming($value)
4688 4688
 	{
4689
-		if($this->_stage>=self::CS_CHILD_INITIALIZED)
4690
-			throw new TInvalidOperationException('control_enabletheming_unchangeable',get_class($this),$this->getUniqueID());
4691
-		else if(TPropertyValue::ensureBoolean($value))
4689
+		if ($this->_stage >= self::CS_CHILD_INITIALIZED)
4690
+			throw new TInvalidOperationException('control_enabletheming_unchangeable', get_class($this), $this->getUniqueID());
4691
+		else if (TPropertyValue::ensureBoolean($value))
4692 4692
 			$this->_flags &= ~self::IS_DISABLE_THEMING;
4693 4693
 		else
4694 4694
 			$this->_flags |= self::IS_DISABLE_THEMING;
4695 4695
 	}
4696 4696
 	public function getCustomData()
4697 4697
 	{
4698
-		return $this->getViewState('CustomData',null);
4698
+		return $this->getViewState('CustomData', null);
4699 4699
 	}
4700 4700
 	public function setCustomData($value)
4701 4701
 	{
4702
-		$this->setViewState('CustomData',$value,null);
4702
+		$this->setViewState('CustomData', $value, null);
4703 4703
 	}
4704 4704
 	public function getHasControls()
4705 4705
 	{
4706
-		return isset($this->_rf[self::RF_CONTROLS]) && $this->_rf[self::RF_CONTROLS]->getCount()>0;
4706
+		return isset($this->_rf[self::RF_CONTROLS]) && $this->_rf[self::RF_CONTROLS]->getCount() > 0;
4707 4707
 	}
4708 4708
 	public function getControls()
4709 4709
 	{
4710
-		if(!isset($this->_rf[self::RF_CONTROLS]))
4711
-			$this->_rf[self::RF_CONTROLS]=$this->createControlCollection();
4710
+		if (!isset($this->_rf[self::RF_CONTROLS]))
4711
+			$this->_rf[self::RF_CONTROLS] = $this->createControlCollection();
4712 4712
 		return $this->_rf[self::RF_CONTROLS];
4713 4713
 	}
4714 4714
 	protected function createControlCollection()
4715 4715
 	{
4716
-		return $this->getAllowChildControls()?new TControlCollection($this):new TEmptyControlCollection($this);
4716
+		return $this->getAllowChildControls() ? new TControlCollection($this) : new TEmptyControlCollection($this);
4717 4717
 	}
4718
-	public function getVisible($checkParents=true)
4718
+	public function getVisible($checkParents = true)
4719 4719
 	{
4720
-		if($checkParents)
4720
+		if ($checkParents)
4721 4721
 		{
4722
-			for($control=$this;$control;$control=$control->_parent)
4723
-				if(!$control->getVisible(false))
4722
+			for ($control = $this; $control; $control = $control->_parent)
4723
+				if (!$control->getVisible(false))
4724 4724
 					return false;
4725 4725
 			return true;
4726 4726
 		}
4727 4727
 		else
4728
-			return $this->getViewState('Visible',true);
4728
+			return $this->getViewState('Visible', true);
4729 4729
 	}
4730 4730
 	public function setVisible($value)
4731 4731
 	{
4732
-		$this->setViewState('Visible',TPropertyValue::ensureBoolean($value),true);
4732
+		$this->setViewState('Visible', TPropertyValue::ensureBoolean($value), true);
4733 4733
 	}
4734
-	public function getEnabled($checkParents=false)
4734
+	public function getEnabled($checkParents = false)
4735 4735
 	{
4736
-		if($checkParents)
4736
+		if ($checkParents)
4737 4737
 		{
4738
-			for($control=$this;$control;$control=$control->_parent)
4739
-				if(!$control->getViewState('Enabled',true))
4738
+			for ($control = $this; $control; $control = $control->_parent)
4739
+				if (!$control->getViewState('Enabled', true))
4740 4740
 					return false;
4741 4741
 			return true;
4742 4742
 		}
4743 4743
 		else
4744
-			return $this->getViewState('Enabled',true);
4744
+			return $this->getViewState('Enabled', true);
4745 4745
 	}
4746 4746
 	public function setEnabled($value)
4747 4747
 	{
4748
-		$this->setViewState('Enabled',TPropertyValue::ensureBoolean($value),true);
4748
+		$this->setViewState('Enabled', TPropertyValue::ensureBoolean($value), true);
4749 4749
 	}
4750 4750
 	public function getHasAttributes()
4751 4751
 	{
4752
-		if($attributes=$this->getViewState('Attributes',null))
4753
-			return $attributes->getCount()>0;
4752
+		if ($attributes = $this->getViewState('Attributes', null))
4753
+			return $attributes->getCount() > 0;
4754 4754
 		else
4755 4755
 			return false;
4756 4756
 	}
4757 4757
 	public function getAttributes()
4758 4758
 	{
4759
-		if($attributes=$this->getViewState('Attributes',null))
4759
+		if ($attributes = $this->getViewState('Attributes', null))
4760 4760
 			return $attributes;
4761 4761
 		else
4762 4762
 		{
4763
-			$attributes=new TAttributeCollection;
4764
-			$this->setViewState('Attributes',$attributes,null);
4763
+			$attributes = new TAttributeCollection;
4764
+			$this->setViewState('Attributes', $attributes, null);
4765 4765
 			return $attributes;
4766 4766
 		}
4767 4767
 	}
4768 4768
 	public function hasAttribute($name)
4769 4769
 	{
4770
-		if($attributes=$this->getViewState('Attributes',null))
4770
+		if ($attributes = $this->getViewState('Attributes', null))
4771 4771
 			return $attributes->contains($name);
4772 4772
 		else
4773 4773
 			return false;
4774 4774
 	}
4775 4775
 	public function getAttribute($name)
4776 4776
 	{
4777
-		if($attributes=$this->getViewState('Attributes',null))
4777
+		if ($attributes = $this->getViewState('Attributes', null))
4778 4778
 			return $attributes->itemAt($name);
4779 4779
 		else
4780 4780
 			return null;
4781 4781
 	}
4782
-	public function setAttribute($name,$value)
4782
+	public function setAttribute($name, $value)
4783 4783
 	{
4784
-		$this->getAttributes()->add($name,$value);
4784
+		$this->getAttributes()->add($name, $value);
4785 4785
 	}
4786 4786
 	public function removeAttribute($name)
4787 4787
 	{
4788
-		if($attributes=$this->getViewState('Attributes',null))
4788
+		if ($attributes = $this->getViewState('Attributes', null))
4789 4789
 			return $attributes->remove($name);
4790 4790
 		else
4791 4791
 			return null;
4792 4792
 	}
4793
-	public function getEnableViewState($checkParents=false)
4793
+	public function getEnableViewState($checkParents = false)
4794 4794
 	{
4795
-		if($checkParents)
4795
+		if ($checkParents)
4796 4796
 		{
4797
-			for($control=$this;$control!==null;$control=$control->getParent())
4798
-				if($control->_flags & self::IS_DISABLE_VIEWSTATE)
4797
+			for ($control = $this; $control !== null; $control = $control->getParent())
4798
+				if ($control->_flags & self::IS_DISABLE_VIEWSTATE)
4799 4799
 					return false;
4800 4800
 			return true;
4801 4801
 		}
@@ -4804,21 +4804,21 @@  discard block
 block discarded – undo
4804 4804
 	}
4805 4805
 	public function setEnableViewState($value)
4806 4806
 	{
4807
-		if(TPropertyValue::ensureBoolean($value))
4807
+		if (TPropertyValue::ensureBoolean($value))
4808 4808
 			$this->_flags &= ~self::IS_DISABLE_VIEWSTATE;
4809 4809
 		else
4810 4810
 			$this->_flags |= self::IS_DISABLE_VIEWSTATE;
4811 4811
 	}
4812
-	protected function getControlState($key,$defaultValue=null)
4812
+	protected function getControlState($key, $defaultValue = null)
4813 4813
 	{
4814
-		return isset($this->_rf[self::RF_CONTROLSTATE][$key])?$this->_rf[self::RF_CONTROLSTATE][$key]:$defaultValue;
4814
+		return isset($this->_rf[self::RF_CONTROLSTATE][$key]) ? $this->_rf[self::RF_CONTROLSTATE][$key] : $defaultValue;
4815 4815
 	}
4816
-	protected function setControlState($key,$value,$defaultValue=null)
4816
+	protected function setControlState($key, $value, $defaultValue = null)
4817 4817
 	{
4818
-		if($value===$defaultValue)
4818
+		if ($value === $defaultValue)
4819 4819
 			unset($this->_rf[self::RF_CONTROLSTATE][$key]);
4820 4820
 		else
4821
-			$this->_rf[self::RF_CONTROLSTATE][$key]=$value;
4821
+			$this->_rf[self::RF_CONTROLSTATE][$key] = $value;
4822 4822
 	}
4823 4823
 	protected function clearControlState($key)
4824 4824
 	{
@@ -4826,32 +4826,32 @@  discard block
 block discarded – undo
4826 4826
 	}
4827 4827
 	public function trackViewState($enabled)
4828 4828
 	{
4829
-		$this->_trackViewState=TPropertyValue::ensureBoolean($enabled);
4829
+		$this->_trackViewState = TPropertyValue::ensureBoolean($enabled);
4830 4830
 	}
4831
-	public function getViewState($key,$defaultValue=null)
4831
+	public function getViewState($key, $defaultValue = null)
4832 4832
 	{
4833
-		if(isset($this->_viewState[$key]))
4834
-			return $this->_viewState[$key]!==null?$this->_viewState[$key]:$defaultValue;
4835
-		else if(isset($this->_tempState[$key]))
4833
+		if (isset($this->_viewState[$key]))
4834
+			return $this->_viewState[$key] !== null ? $this->_viewState[$key] : $defaultValue;
4835
+		else if (isset($this->_tempState[$key]))
4836 4836
 		{
4837
-			if(is_object($this->_tempState[$key]) && $this->_trackViewState)
4838
-				$this->_viewState[$key]=$this->_tempState[$key];
4837
+			if (is_object($this->_tempState[$key]) && $this->_trackViewState)
4838
+				$this->_viewState[$key] = $this->_tempState[$key];
4839 4839
 			return $this->_tempState[$key];
4840 4840
 		}
4841 4841
 		else
4842 4842
 			return $defaultValue;
4843 4843
 	}
4844
-	public function setViewState($key,$value,$defaultValue=null)
4844
+	public function setViewState($key, $value, $defaultValue = null)
4845 4845
 	{
4846
-		if($this->_trackViewState)
4846
+		if ($this->_trackViewState)
4847 4847
 		{
4848
-			$this->_viewState[$key]=$value;
4848
+			$this->_viewState[$key] = $value;
4849 4849
 			unset($this->_tempState[$key]);
4850 4850
 		}
4851 4851
 		else
4852 4852
 		{
4853 4853
 			unset($this->_viewState[$key]);
4854
-			$this->_tempState[$key]=$value;
4854
+			$this->_tempState[$key] = $value;
4855 4855
 		}
4856 4856
 	}
4857 4857
 	public function clearViewState($key)
@@ -4859,17 +4859,17 @@  discard block
 block discarded – undo
4859 4859
 		unset($this->_viewState[$key]);
4860 4860
 		unset($this->_tempState[$key]);
4861 4861
 	}
4862
-	public function bindProperty($name,$expression)
4862
+	public function bindProperty($name, $expression)
4863 4863
 	{
4864
-		$this->_rf[self::RF_DATA_BINDINGS][$name]=$expression;
4864
+		$this->_rf[self::RF_DATA_BINDINGS][$name] = $expression;
4865 4865
 	}
4866 4866
 	public function unbindProperty($name)
4867 4867
 	{
4868 4868
 		unset($this->_rf[self::RF_DATA_BINDINGS][$name]);
4869 4869
 	}
4870
-	public function autoBindProperty($name,$expression)
4870
+	public function autoBindProperty($name, $expression)
4871 4871
 	{
4872
-		$this->_rf[self::RF_AUTO_BINDINGS][$name]=$expression;
4872
+		$this->_rf[self::RF_AUTO_BINDINGS][$name] = $expression;
4873 4873
 	}
4874 4874
 	public function dataBind()
4875 4875
 	{
@@ -4879,63 +4879,63 @@  discard block
 block discarded – undo
4879 4879
 	}
4880 4880
 	protected function dataBindProperties()
4881 4881
 	{
4882
-		if(isset($this->_rf[self::RF_DATA_BINDINGS]))
4882
+		if (isset($this->_rf[self::RF_DATA_BINDINGS]))
4883 4883
 		{
4884
-			if(($context=$this->getTemplateControl())===null)
4885
-				$context=$this;
4886
-			foreach($this->_rf[self::RF_DATA_BINDINGS] as $property=>$expression)
4887
-				$this->setSubProperty($property,$context->evaluateExpression($expression));
4884
+			if (($context = $this->getTemplateControl()) === null)
4885
+				$context = $this;
4886
+			foreach ($this->_rf[self::RF_DATA_BINDINGS] as $property=>$expression)
4887
+				$this->setSubProperty($property, $context->evaluateExpression($expression));
4888 4888
 		}
4889 4889
 	}
4890 4890
 	protected function autoDataBindProperties()
4891 4891
 	{
4892
-		if(isset($this->_rf[self::RF_AUTO_BINDINGS]))
4892
+		if (isset($this->_rf[self::RF_AUTO_BINDINGS]))
4893 4893
 		{
4894
-			if(($context=$this->getTemplateControl())===null)
4895
-				$context=$this;
4896
-			foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property=>$expression)
4897
-				$this->setSubProperty($property,$context->evaluateExpression($expression));
4894
+			if (($context = $this->getTemplateControl()) === null)
4895
+				$context = $this;
4896
+			foreach ($this->_rf[self::RF_AUTO_BINDINGS] as $property=>$expression)
4897
+				$this->setSubProperty($property, $context->evaluateExpression($expression));
4898 4898
 		}
4899 4899
 	}
4900 4900
 	protected function dataBindChildren()
4901 4901
 	{
4902
-		if(isset($this->_rf[self::RF_CONTROLS]))
4902
+		if (isset($this->_rf[self::RF_CONTROLS]))
4903 4903
 		{
4904
-			foreach($this->_rf[self::RF_CONTROLS] as $control)
4905
-				if($control instanceof IBindable)
4904
+			foreach ($this->_rf[self::RF_CONTROLS] as $control)
4905
+				if ($control instanceof IBindable)
4906 4906
 					$control->dataBind();
4907 4907
 		}
4908 4908
 	}
4909 4909
 	final protected function getChildControlsCreated()
4910 4910
 	{
4911
-		return ($this->_flags & self::IS_CHILD_CREATED)!==0;
4911
+		return ($this->_flags & self::IS_CHILD_CREATED) !== 0;
4912 4912
 	}
4913 4913
 	final protected function setChildControlsCreated($value)
4914 4914
 	{
4915
-		if($value)
4915
+		if ($value)
4916 4916
 			$this->_flags |= self::IS_CHILD_CREATED;
4917 4917
 		else
4918 4918
 		{
4919
-			if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED))
4919
+			if ($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED))
4920 4920
 				$this->getControls()->clear();
4921 4921
 			$this->_flags &= ~self::IS_CHILD_CREATED;
4922 4922
 		}
4923 4923
 	}
4924 4924
 	public function ensureChildControls()
4925 4925
 	{
4926
-		if(!($this->_flags & self::IS_CHILD_CREATED) && !($this->_flags & self::IS_CREATING_CHILD))
4926
+		if (!($this->_flags & self::IS_CHILD_CREATED) && !($this->_flags & self::IS_CREATING_CHILD))
4927 4927
 		{
4928 4928
 			try
4929 4929
 			{
4930 4930
 				$this->_flags |= self::IS_CREATING_CHILD;
4931
-				if(isset($this->_rf[self::RF_ADAPTER]))
4931
+				if (isset($this->_rf[self::RF_ADAPTER]))
4932 4932
 					$this->_rf[self::RF_ADAPTER]->createChildControls();
4933 4933
 				else
4934 4934
 					$this->createChildControls();
4935 4935
 				$this->_flags &= ~self::IS_CREATING_CHILD;
4936 4936
 				$this->_flags |= self::IS_CHILD_CREATED;
4937 4937
 			}
4938
-			catch(Exception $e)
4938
+			catch (Exception $e)
4939 4939
 			{
4940 4940
 				$this->_flags &= ~self::IS_CREATING_CHILD;
4941 4941
 				$this->_flags |= self::IS_CHILD_CREATED;
@@ -4948,54 +4948,54 @@  discard block
 block discarded – undo
4948 4948
 	}
4949 4949
 	public function findControl($id)
4950 4950
 	{
4951
-		$id=strtr($id,'.',self::ID_SEPARATOR);
4952
-		$container=($this instanceof INamingContainer)?$this:$this->getNamingContainer();
4953
-		if(!$container || !$container->getHasControls())
4951
+		$id = strtr($id, '.', self::ID_SEPARATOR);
4952
+		$container = ($this instanceof INamingContainer) ? $this : $this->getNamingContainer();
4953
+		if (!$container || !$container->getHasControls())
4954 4954
 			return null;
4955
-		if(!isset($container->_rf[self::RF_NAMED_CONTROLS]))
4955
+		if (!isset($container->_rf[self::RF_NAMED_CONTROLS]))
4956 4956
 		{
4957
-			$container->_rf[self::RF_NAMED_CONTROLS]=array();
4958
-			$container->fillNameTable($container,$container->_rf[self::RF_CONTROLS]);
4957
+			$container->_rf[self::RF_NAMED_CONTROLS] = array();
4958
+			$container->fillNameTable($container, $container->_rf[self::RF_CONTROLS]);
4959 4959
 		}
4960
-		if(($pos=strpos($id,self::ID_SEPARATOR))===false)
4961
-			return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null;
4960
+		if (($pos = strpos($id, self::ID_SEPARATOR)) === false)
4961
+			return isset($container->_rf[self::RF_NAMED_CONTROLS][$id]) ? $container->_rf[self::RF_NAMED_CONTROLS][$id] : null;
4962 4962
 		else
4963 4963
 		{
4964
-			$cid=substr($id,0,$pos);
4965
-			$sid=substr($id,$pos+1);
4966
-			if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid]))
4964
+			$cid = substr($id, 0, $pos);
4965
+			$sid = substr($id, $pos + 1);
4966
+			if (isset($container->_rf[self::RF_NAMED_CONTROLS][$cid]))
4967 4967
 				return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid);
4968 4968
 			else
4969 4969
 				return null;
4970 4970
 		}
4971 4971
 	}
4972
-	public function findControlsByType($type,$strict=true)
4972
+	public function findControlsByType($type, $strict = true)
4973 4973
 	{
4974
-		$controls=array();
4975
-		if($this->getHasControls())
4974
+		$controls = array();
4975
+		if ($this->getHasControls())
4976 4976
 		{
4977
-			foreach($this->_rf[self::RF_CONTROLS] as $control)
4977
+			foreach ($this->_rf[self::RF_CONTROLS] as $control)
4978 4978
 			{
4979
-				if(is_object($control) && (get_class($control)===$type || (!$strict && ($control instanceof $type))))
4980
-					$controls[]=$control;
4981
-				if(($control instanceof TControl) && $control->getHasControls())
4982
-					$controls=array_merge($controls,$control->findControlsByType($type,$strict));
4979
+				if (is_object($control) && (get_class($control) === $type || (!$strict && ($control instanceof $type))))
4980
+					$controls[] = $control;
4981
+				if (($control instanceof TControl) && $control->getHasControls())
4982
+					$controls = array_merge($controls, $control->findControlsByType($type, $strict));
4983 4983
 			}
4984 4984
 		}
4985 4985
 		return $controls;
4986 4986
 	}
4987 4987
 	public function findControlsByID($id)
4988 4988
 	{
4989
-		$controls=array();
4990
-		if($this->getHasControls())
4989
+		$controls = array();
4990
+		if ($this->getHasControls())
4991 4991
 		{
4992
-			foreach($this->_rf[self::RF_CONTROLS] as $control)
4992
+			foreach ($this->_rf[self::RF_CONTROLS] as $control)
4993 4993
 			{
4994
-				if($control instanceof TControl)
4994
+				if ($control instanceof TControl)
4995 4995
 				{
4996
-					if($control->_id===$id)
4997
-						$controls[]=$control;
4998
-					$controls=array_merge($controls,$control->findControlsByID($id));
4996
+					if ($control->_id === $id)
4997
+						$controls[] = $control;
4998
+					$controls = array_merge($controls, $control->findControlsByID($id));
4999 4999
 				}
5000 5000
 			}
5001 5001
 		}
@@ -5006,11 +5006,11 @@  discard block
 block discarded – undo
5006 5006
 		unset($this->_rf[self::RF_NAMED_CONTROLS_ID]);
5007 5007
 		$this->clearNameTable();
5008 5008
 	}
5009
-	public function registerObject($name,$object)
5009
+	public function registerObject($name, $object)
5010 5010
 	{
5011
-		if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name]))
5012
-			throw new TInvalidOperationException('control_object_reregistered',$name);
5013
-		$this->_rf[self::RF_NAMED_OBJECTS][$name]=$object;
5011
+		if (isset($this->_rf[self::RF_NAMED_OBJECTS][$name]))
5012
+			throw new TInvalidOperationException('control_object_reregistered', $name);
5013
+		$this->_rf[self::RF_NAMED_OBJECTS][$name] = $object;
5014 5014
 	}
5015 5015
 	public function unregisterObject($name)
5016 5016
 	{
@@ -5042,7 +5042,7 @@  discard block
 block discarded – undo
5042 5042
 	}
5043 5043
 	public function getRegisteredObject($name)
5044 5044
 	{
5045
-		return isset($this->_rf[self::RF_NAMED_OBJECTS][$name])?$this->_rf[self::RF_NAMED_OBJECTS][$name]:null;
5045
+		return isset($this->_rf[self::RF_NAMED_OBJECTS][$name]) ? $this->_rf[self::RF_NAMED_OBJECTS][$name] : null;
5046 5046
 	}
5047 5047
 	public function getAllowChildControls()
5048 5048
 	{
@@ -5058,44 +5058,44 @@  discard block
 block discarded – undo
5058 5058
 	}
5059 5059
 	final protected function isDescendentOf($ancestor)
5060 5060
 	{
5061
-		$control=$this;
5062
-		while($control!==$ancestor && $control->_parent)
5063
-			$control=$control->_parent;
5064
-		return $control===$ancestor;
5061
+		$control = $this;
5062
+		while ($control !== $ancestor && $control->_parent)
5063
+			$control = $control->_parent;
5064
+		return $control === $ancestor;
5065 5065
 	}
5066 5066
 	public function addedControl($control)
5067 5067
 	{
5068
-		if($control->_parent)
5068
+		if ($control->_parent)
5069 5069
 			$control->_parent->getControls()->remove($control);
5070
-		$control->_parent=$this;
5071
-		$control->_page=$this->getPage();
5072
-		$namingContainer=($this instanceof INamingContainer)?$this:$this->_namingContainer;
5073
-		if($namingContainer)
5070
+		$control->_parent = $this;
5071
+		$control->_page = $this->getPage();
5072
+		$namingContainer = ($this instanceof INamingContainer) ? $this : $this->_namingContainer;
5073
+		if ($namingContainer)
5074 5074
 		{
5075
-			$control->_namingContainer=$namingContainer;
5076
-			if($control->_id==='')
5075
+			$control->_namingContainer = $namingContainer;
5076
+			if ($control->_id === '')
5077 5077
 				$control->generateAutomaticID();
5078 5078
 			else
5079 5079
 				$namingContainer->clearNameTable();
5080 5080
 			$control->clearCachedUniqueID($control instanceof INamingContainer);
5081 5081
 		}
5082
-		if($this->_stage>=self::CS_CHILD_INITIALIZED)
5082
+		if ($this->_stage >= self::CS_CHILD_INITIALIZED)
5083 5083
 		{
5084 5084
 			$control->initRecursive($namingContainer);
5085
-			if($this->_stage>=self::CS_STATE_LOADED)
5085
+			if ($this->_stage >= self::CS_STATE_LOADED)
5086 5086
 			{
5087
-				if(isset($this->_rf[self::RF_CHILD_STATE][$control->_id]))
5087
+				if (isset($this->_rf[self::RF_CHILD_STATE][$control->_id]))
5088 5088
 				{
5089
-					$state=$this->_rf[self::RF_CHILD_STATE][$control->_id];
5089
+					$state = $this->_rf[self::RF_CHILD_STATE][$control->_id];
5090 5090
 					unset($this->_rf[self::RF_CHILD_STATE][$control->_id]);
5091 5091
 				}
5092 5092
 				else
5093
-					$state=null;
5094
-				$control->loadStateRecursive($state,!($this->_flags & self::IS_DISABLE_VIEWSTATE));
5095
-				if($this->_stage>=self::CS_LOADED)
5093
+					$state = null;
5094
+				$control->loadStateRecursive($state, !($this->_flags & self::IS_DISABLE_VIEWSTATE));
5095
+				if ($this->_stage >= self::CS_LOADED)
5096 5096
 				{
5097 5097
 					$control->loadRecursive();
5098
-					if($this->_stage>=self::CS_PRERENDERED)
5098
+					if ($this->_stage >= self::CS_PRERENDERED)
5099 5099
 						$control->preRenderRecursive();
5100 5100
 				}
5101 5101
 			}
@@ -5103,186 +5103,186 @@  discard block
 block discarded – undo
5103 5103
 	}
5104 5104
 	public function removedControl($control)
5105 5105
 	{
5106
-		if($this->_namingContainer)
5106
+		if ($this->_namingContainer)
5107 5107
 			$this->_namingContainer->clearNameTable();
5108 5108
 		$control->unloadRecursive();
5109
-		$control->_parent=null;
5110
-		$control->_page=null;
5111
-		$control->_namingContainer=null;
5112
-		$control->_tplControl=null;
5113
-				if(!($control->_flags & self::IS_ID_SET))
5114
-			$control->_id='';
5109
+		$control->_parent = null;
5110
+		$control->_page = null;
5111
+		$control->_namingContainer = null;
5112
+		$control->_tplControl = null;
5113
+				if (!($control->_flags & self::IS_ID_SET))
5114
+			$control->_id = '';
5115 5115
 		else
5116 5116
 			unset($this->_rf[self::RF_NAMED_OBJECTS][$control->_id]);
5117 5117
 		$control->clearCachedUniqueID(true);
5118 5118
 	}
5119
-	protected function initRecursive($namingContainer=null)
5119
+	protected function initRecursive($namingContainer = null)
5120 5120
 	{
5121 5121
 		$this->ensureChildControls();
5122
-		if($this->getHasControls())
5122
+		if ($this->getHasControls())
5123 5123
 		{
5124
-			if($this instanceof INamingContainer)
5125
-				$namingContainer=$this;
5126
-			$page=$this->getPage();
5127
-			foreach($this->_rf[self::RF_CONTROLS] as $control)
5124
+			if ($this instanceof INamingContainer)
5125
+				$namingContainer = $this;
5126
+			$page = $this->getPage();
5127
+			foreach ($this->_rf[self::RF_CONTROLS] as $control)
5128 5128
 			{
5129
-				if($control instanceof TControl)
5129
+				if ($control instanceof TControl)
5130 5130
 				{
5131
-					$control->_namingContainer=$namingContainer;
5132
-					$control->_page=$page;
5133
-					if($control->_id==='' && $namingContainer)
5131
+					$control->_namingContainer = $namingContainer;
5132
+					$control->_page = $page;
5133
+					if ($control->_id === '' && $namingContainer)
5134 5134
 						$control->generateAutomaticID();
5135 5135
 					$control->initRecursive($namingContainer);
5136 5136
 				}
5137 5137
 			}
5138 5138
 		}
5139
-		if($this->_stage<self::CS_INITIALIZED)
5139
+		if ($this->_stage < self::CS_INITIALIZED)
5140 5140
 		{
5141
-			$this->_stage=self::CS_CHILD_INITIALIZED;
5142
-			if(($page=$this->getPage()) && $this->getEnableTheming() && !($this->_flags & self::IS_SKIN_APPLIED))
5141
+			$this->_stage = self::CS_CHILD_INITIALIZED;
5142
+			if (($page = $this->getPage()) && $this->getEnableTheming() && !($this->_flags & self::IS_SKIN_APPLIED))
5143 5143
 			{
5144 5144
 				$page->applyControlSkin($this);
5145 5145
 				$this->_flags |= self::IS_SKIN_APPLIED;
5146 5146
 			}
5147
-			if(isset($this->_rf[self::RF_ADAPTER]))
5147
+			if (isset($this->_rf[self::RF_ADAPTER]))
5148 5148
 				$this->_rf[self::RF_ADAPTER]->onInit(null);
5149 5149
 			else
5150 5150
 				$this->onInit(null);
5151
-			$this->_stage=self::CS_INITIALIZED;
5151
+			$this->_stage = self::CS_INITIALIZED;
5152 5152
 		}
5153 5153
 	}
5154 5154
 	protected function loadRecursive()
5155 5155
 	{
5156
-		if($this->_stage<self::CS_LOADED)
5156
+		if ($this->_stage < self::CS_LOADED)
5157 5157
 		{
5158
-			if(isset($this->_rf[self::RF_ADAPTER]))
5158
+			if (isset($this->_rf[self::RF_ADAPTER]))
5159 5159
 				$this->_rf[self::RF_ADAPTER]->onLoad(null);
5160 5160
 			else
5161 5161
 				$this->onLoad(null);
5162 5162
 		}
5163
-		if($this->getHasControls())
5163
+		if ($this->getHasControls())
5164 5164
 		{
5165
-			foreach($this->_rf[self::RF_CONTROLS] as $control)
5165
+			foreach ($this->_rf[self::RF_CONTROLS] as $control)
5166 5166
 			{
5167
-				if($control instanceof TControl)
5167
+				if ($control instanceof TControl)
5168 5168
 					$control->loadRecursive();
5169 5169
 			}
5170 5170
 		}
5171
-		if($this->_stage<self::CS_LOADED)
5172
-			$this->_stage=self::CS_LOADED;
5171
+		if ($this->_stage < self::CS_LOADED)
5172
+			$this->_stage = self::CS_LOADED;
5173 5173
 	}
5174 5174
 	protected function preRenderRecursive()
5175 5175
 	{
5176 5176
 		$this->autoDataBindProperties();
5177
-		if($this->getVisible(false))
5177
+		if ($this->getVisible(false))
5178 5178
 		{
5179
-			if(isset($this->_rf[self::RF_ADAPTER]))
5179
+			if (isset($this->_rf[self::RF_ADAPTER]))
5180 5180
 				$this->_rf[self::RF_ADAPTER]->onPreRender(null);
5181 5181
 			else
5182 5182
 				$this->onPreRender(null);
5183
-			if($this->getHasControls())
5183
+			if ($this->getHasControls())
5184 5184
 			{
5185
-				foreach($this->_rf[self::RF_CONTROLS] as $control)
5185
+				foreach ($this->_rf[self::RF_CONTROLS] as $control)
5186 5186
 				{
5187
-					if($control instanceof TControl)
5187
+					if ($control instanceof TControl)
5188 5188
 						$control->preRenderRecursive();
5189
-					else if($control instanceof TCompositeLiteral)
5189
+					else if ($control instanceof TCompositeLiteral)
5190 5190
 						$control->evaluateDynamicContent();
5191 5191
 				}
5192 5192
 			}
5193 5193
 		}
5194
-		$this->_stage=self::CS_PRERENDERED;
5194
+		$this->_stage = self::CS_PRERENDERED;
5195 5195
 	}
5196 5196
 	protected function unloadRecursive()
5197 5197
 	{
5198
-		if(!($this->_flags & self::IS_ID_SET))
5199
-			$this->_id='';
5200
-		if($this->getHasControls())
5198
+		if (!($this->_flags & self::IS_ID_SET))
5199
+			$this->_id = '';
5200
+		if ($this->getHasControls())
5201 5201
 		{
5202
-			foreach($this->_rf[self::RF_CONTROLS] as $control)
5203
-				if($control instanceof TControl)
5202
+			foreach ($this->_rf[self::RF_CONTROLS] as $control)
5203
+				if ($control instanceof TControl)
5204 5204
 					$control->unloadRecursive();
5205 5205
 		}
5206
-		if(isset($this->_rf[self::RF_ADAPTER]))
5206
+		if (isset($this->_rf[self::RF_ADAPTER]))
5207 5207
 			$this->_rf[self::RF_ADAPTER]->onUnload(null);
5208 5208
 		else
5209 5209
 			$this->onUnload(null);
5210 5210
 	}
5211 5211
 	public function onInit($param)
5212 5212
 	{
5213
-		$this->raiseEvent('OnInit',$this,$param);
5213
+		$this->raiseEvent('OnInit', $this, $param);
5214 5214
 	}
5215 5215
 	public function onLoad($param)
5216 5216
 	{
5217
-		$this->raiseEvent('OnLoad',$this,$param);
5217
+		$this->raiseEvent('OnLoad', $this, $param);
5218 5218
 	}
5219 5219
 	public function onDataBinding($param)
5220 5220
 	{
5221
-		$this->raiseEvent('OnDataBinding',$this,$param);
5221
+		$this->raiseEvent('OnDataBinding', $this, $param);
5222 5222
 	}
5223 5223
 	public function onUnload($param)
5224 5224
 	{
5225
-		$this->raiseEvent('OnUnload',$this,$param);
5225
+		$this->raiseEvent('OnUnload', $this, $param);
5226 5226
 	}
5227 5227
 	public function onPreRender($param)
5228 5228
 	{
5229
-		$this->raiseEvent('OnPreRender',$this,$param);
5229
+		$this->raiseEvent('OnPreRender', $this, $param);
5230 5230
 	}
5231
-	protected function raiseBubbleEvent($sender,$param)
5231
+	protected function raiseBubbleEvent($sender, $param)
5232 5232
 	{
5233
-		$control=$this;
5234
-		while($control=$control->_parent)
5233
+		$control = $this;
5234
+		while ($control = $control->_parent)
5235 5235
 		{
5236
-			if($control->bubbleEvent($sender,$param))
5236
+			if ($control->bubbleEvent($sender, $param))
5237 5237
 				break;
5238 5238
 		}
5239 5239
 	}
5240
-	public function bubbleEvent($sender,$param)
5240
+	public function bubbleEvent($sender, $param)
5241 5241
 	{
5242 5242
 		return false;
5243 5243
 	}
5244
-	public function broadcastEvent($name,$sender,$param)
5244
+	public function broadcastEvent($name, $sender, $param)
5245 5245
 	{
5246
-		$rootControl=(($page=$this->getPage())===null)?$this:$page;
5247
-		$rootControl->broadcastEventInternal($name,$sender,new TBroadcastEventParameter($name,$param));
5246
+		$rootControl = (($page = $this->getPage()) === null) ? $this : $page;
5247
+		$rootControl->broadcastEventInternal($name, $sender, new TBroadcastEventParameter($name, $param));
5248 5248
 	}
5249
-	private function broadcastEventInternal($name,$sender,$param)
5249
+	private function broadcastEventInternal($name, $sender, $param)
5250 5250
 	{
5251
-		if($this->hasEvent($name))
5252
-			$this->raiseEvent($name,$sender,$param->getParameter());
5253
-		if($this instanceof IBroadcastEventReceiver)
5254
-			$this->broadcastEventReceived($sender,$param);
5255
-		if($this->getHasControls())
5251
+		if ($this->hasEvent($name))
5252
+			$this->raiseEvent($name, $sender, $param->getParameter());
5253
+		if ($this instanceof IBroadcastEventReceiver)
5254
+			$this->broadcastEventReceived($sender, $param);
5255
+		if ($this->getHasControls())
5256 5256
 		{
5257
-			foreach($this->_rf[self::RF_CONTROLS] as $control)
5257
+			foreach ($this->_rf[self::RF_CONTROLS] as $control)
5258 5258
 			{
5259
-				if($control instanceof TControl)
5260
-					$control->broadcastEventInternal($name,$sender,$param);
5259
+				if ($control instanceof TControl)
5260
+					$control->broadcastEventInternal($name, $sender, $param);
5261 5261
 			}
5262 5262
 		}
5263 5263
 	}
5264
-	protected function traverseChildControls($param,$preCallback=null,$postCallback=null)
5264
+	protected function traverseChildControls($param, $preCallback = null, $postCallback = null)
5265 5265
 	{
5266
-		if($preCallback!==null)
5267
-			call_user_func($preCallback,$this,$param);
5268
-		if($this->getHasControls())
5266
+		if ($preCallback !== null)
5267
+			call_user_func($preCallback, $this, $param);
5268
+		if ($this->getHasControls())
5269 5269
 		{
5270
-			foreach($this->_rf[self::RF_CONTROLS] as $control)
5270
+			foreach ($this->_rf[self::RF_CONTROLS] as $control)
5271 5271
 			{
5272
-				if($control instanceof TControl)
5272
+				if ($control instanceof TControl)
5273 5273
 				{
5274
-					$control->traverseChildControls($param,$preCallback,$postCallback);
5274
+					$control->traverseChildControls($param, $preCallback, $postCallback);
5275 5275
 				}
5276 5276
 			}
5277 5277
 		}
5278
-		if($postCallback!==null)
5279
-			call_user_func($postCallback,$this,$param);
5278
+		if ($postCallback !== null)
5279
+			call_user_func($postCallback, $this, $param);
5280 5280
 	}
5281 5281
 	public function renderControl($writer)
5282 5282
 	{
5283
-		if($this instanceof IActiveControl || $this->getVisible(false))
5283
+		if ($this instanceof IActiveControl || $this->getVisible(false))
5284 5284
 		{
5285
-			if(isset($this->_rf[self::RF_ADAPTER]))
5285
+			if (isset($this->_rf[self::RF_ADAPTER]))
5286 5286
 				$this->_rf[self::RF_ADAPTER]->render($writer);
5287 5287
 			else
5288 5288
 				$this->render($writer);
@@ -5294,15 +5294,15 @@  discard block
 block discarded – undo
5294 5294
 	}
5295 5295
 	public function renderChildren($writer)
5296 5296
 	{
5297
-		if($this->getHasControls())
5297
+		if ($this->getHasControls())
5298 5298
 		{
5299
-			foreach($this->_rf[self::RF_CONTROLS] as $control)
5299
+			foreach ($this->_rf[self::RF_CONTROLS] as $control)
5300 5300
 			{
5301
-				if(is_string($control))
5301
+				if (is_string($control))
5302 5302
 					$writer->write($control);
5303
-				else if($control instanceof TControl)
5303
+				else if ($control instanceof TControl)
5304 5304
 					$control->renderControl($writer);
5305
-				else if($control instanceof IRenderable)
5305
+				else if ($control instanceof IRenderable)
5306 5306
 					$control->render($writer);
5307 5307
 			}
5308 5308
 		}
@@ -5313,119 +5313,119 @@  discard block
 block discarded – undo
5313 5313
 	public function loadState()
5314 5314
 	{
5315 5315
 	}
5316
-	protected function loadStateRecursive(&$state,$needViewState=true)
5316
+	protected function loadStateRecursive(&$state, $needViewState = true)
5317 5317
 	{
5318
-		if(is_array($state))
5318
+		if (is_array($state))
5319 5319
 		{
5320
-									$needViewState=($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE));
5321
-			if(isset($state[1]))
5320
+									$needViewState = ($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE));
5321
+			if (isset($state[1]))
5322 5322
 			{
5323
-				$this->_rf[self::RF_CONTROLSTATE]=&$state[1];
5323
+				$this->_rf[self::RF_CONTROLSTATE] = &$state[1];
5324 5324
 				unset($state[1]);
5325 5325
 			}
5326 5326
 			else
5327 5327
 				unset($this->_rf[self::RF_CONTROLSTATE]);
5328
-			if($needViewState)
5328
+			if ($needViewState)
5329 5329
 			{
5330
-				if(isset($state[0]))
5331
-					$this->_viewState=&$state[0];
5330
+				if (isset($state[0]))
5331
+					$this->_viewState = &$state[0];
5332 5332
 				else
5333
-					$this->_viewState=array();
5333
+					$this->_viewState = array();
5334 5334
 			}
5335 5335
 			unset($state[0]);
5336
-			if($this->getHasControls())
5336
+			if ($this->getHasControls())
5337 5337
 			{
5338
-				foreach($this->_rf[self::RF_CONTROLS] as $control)
5338
+				foreach ($this->_rf[self::RF_CONTROLS] as $control)
5339 5339
 				{
5340
-					if($control instanceof TControl)
5340
+					if ($control instanceof TControl)
5341 5341
 					{
5342
-						if(isset($state[$control->_id]))
5342
+						if (isset($state[$control->_id]))
5343 5343
 						{
5344
-							$control->loadStateRecursive($state[$control->_id],$needViewState);
5344
+							$control->loadStateRecursive($state[$control->_id], $needViewState);
5345 5345
 							unset($state[$control->_id]);
5346 5346
 						}
5347 5347
 					}
5348 5348
 				}
5349 5349
 			}
5350
-			if(!empty($state))
5351
-				$this->_rf[self::RF_CHILD_STATE]=&$state;
5350
+			if (!empty($state))
5351
+				$this->_rf[self::RF_CHILD_STATE] = &$state;
5352 5352
 		}
5353
-		$this->_stage=self::CS_STATE_LOADED;
5354
-		if(isset($this->_rf[self::RF_ADAPTER]))
5353
+		$this->_stage = self::CS_STATE_LOADED;
5354
+		if (isset($this->_rf[self::RF_ADAPTER]))
5355 5355
 			$this->_rf[self::RF_ADAPTER]->loadState();
5356 5356
 		else
5357 5357
 			$this->loadState();
5358 5358
 	}
5359
-	protected function &saveStateRecursive($needViewState=true)
5359
+	protected function &saveStateRecursive($needViewState = true)
5360 5360
 	{
5361
-		if(isset($this->_rf[self::RF_ADAPTER]))
5361
+		if (isset($this->_rf[self::RF_ADAPTER]))
5362 5362
 			$this->_rf[self::RF_ADAPTER]->saveState();
5363 5363
 		else
5364 5364
 			$this->saveState();
5365
-		$needViewState=($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE));
5366
-		$state=array();
5367
-		if($this->getHasControls())
5365
+		$needViewState = ($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE));
5366
+		$state = array();
5367
+		if ($this->getHasControls())
5368 5368
 		{
5369
-			foreach($this->_rf[self::RF_CONTROLS] as $control)
5369
+			foreach ($this->_rf[self::RF_CONTROLS] as $control)
5370 5370
 			{
5371
-				if($control instanceof TControl)
5372
-					$state[$control->_id]=&$control->saveStateRecursive($needViewState);
5371
+				if ($control instanceof TControl)
5372
+					$state[$control->_id] = &$control->saveStateRecursive($needViewState);
5373 5373
 			}
5374 5374
 		}
5375
-		if($needViewState && !empty($this->_viewState))
5376
-			$state[0]=&$this->_viewState;
5377
-		if(isset($this->_rf[self::RF_CONTROLSTATE]))
5378
-			$state[1]=&$this->_rf[self::RF_CONTROLSTATE];
5375
+		if ($needViewState && !empty($this->_viewState))
5376
+			$state[0] = &$this->_viewState;
5377
+		if (isset($this->_rf[self::RF_CONTROLSTATE]))
5378
+			$state[1] = &$this->_rf[self::RF_CONTROLSTATE];
5379 5379
 		return $state;
5380 5380
 	}
5381 5381
 	public function applyStyleSheetSkin($page)
5382 5382
 	{
5383
-		if($page && !($this->_flags & self::IS_STYLESHEET_APPLIED))
5383
+		if ($page && !($this->_flags & self::IS_STYLESHEET_APPLIED))
5384 5384
 		{
5385 5385
 			$page->applyControlStyleSheet($this);
5386 5386
 			$this->_flags |= self::IS_STYLESHEET_APPLIED;
5387 5387
 		}
5388
-		else if($this->_flags & self::IS_STYLESHEET_APPLIED)
5389
-			throw new TInvalidOperationException('control_stylesheet_applied',get_class($this));
5388
+		else if ($this->_flags & self::IS_STYLESHEET_APPLIED)
5389
+			throw new TInvalidOperationException('control_stylesheet_applied', get_class($this));
5390 5390
 	}
5391 5391
 	private function clearCachedUniqueID($recursive)
5392 5392
 	{
5393
-		if($recursive && $this->_uid!==null && isset($this->_rf[self::RF_CONTROLS]))
5393
+		if ($recursive && $this->_uid !== null && isset($this->_rf[self::RF_CONTROLS]))
5394 5394
 		{
5395
-			foreach($this->_rf[self::RF_CONTROLS] as $control)
5396
-				if($control instanceof TControl)
5395
+			foreach ($this->_rf[self::RF_CONTROLS] as $control)
5396
+				if ($control instanceof TControl)
5397 5397
 					$control->clearCachedUniqueID($recursive);
5398 5398
 		}
5399
-		$this->_uid=null;
5399
+		$this->_uid = null;
5400 5400
 	}
5401 5401
 	private function generateAutomaticID()
5402 5402
 	{
5403 5403
 		$this->_flags &= ~self::IS_ID_SET;
5404
-		if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]))
5405
-			$this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]=0;
5406
-		$id=$this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]++;
5407
-		$this->_id=self::AUTOMATIC_ID_PREFIX . $id;
5404
+		if (!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]))
5405
+			$this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID] = 0;
5406
+		$id = $this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]++;
5407
+		$this->_id = self::AUTOMATIC_ID_PREFIX . $id;
5408 5408
 		$this->_namingContainer->clearNameTable();
5409 5409
 	}
5410 5410
 	private function clearNameTable()
5411 5411
 	{
5412 5412
 		unset($this->_rf[self::RF_NAMED_CONTROLS]);
5413 5413
 	}
5414
-	private function fillNameTable($container,$controls)
5414
+	private function fillNameTable($container, $controls)
5415 5415
 	{
5416
-		foreach($controls as $control)
5416
+		foreach ($controls as $control)
5417 5417
 		{
5418
-			if($control instanceof TControl)
5418
+			if ($control instanceof TControl)
5419 5419
 			{
5420
-				if($control->_id!=='')
5420
+				if ($control->_id !== '')
5421 5421
 				{
5422
-					if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id]))
5423
-						throw new TInvalidDataValueException('control_id_nonunique',get_class($control),$control->_id);
5422
+					if (isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id]))
5423
+						throw new TInvalidDataValueException('control_id_nonunique', get_class($control), $control->_id);
5424 5424
 					else
5425
-						$container->_rf[self::RF_NAMED_CONTROLS][$control->_id]=$control;
5425
+						$container->_rf[self::RF_NAMED_CONTROLS][$control->_id] = $control;
5426 5426
 				}
5427
-				if(!($control instanceof INamingContainer) && $control->getHasControls())
5428
-					$this->fillNameTable($container,$control->_rf[self::RF_CONTROLS]);
5427
+				if (!($control instanceof INamingContainer) && $control->getHasControls())
5428
+					$this->fillNameTable($container, $control->_rf[self::RF_CONTROLS]);
5429 5429
 			}
5430 5430
 		}
5431 5431
 	}
@@ -5433,38 +5433,38 @@  discard block
 block discarded – undo
5433 5433
 class TControlCollection extends TList
5434 5434
 {
5435 5435
 	private $_o;
5436
-	public function __construct(TControl $owner,$readOnly=false)
5436
+	public function __construct(TControl $owner, $readOnly = false)
5437 5437
 	{
5438
-		$this->_o=$owner;
5439
-		parent::__construct(null,$readOnly);
5438
+		$this->_o = $owner;
5439
+		parent::__construct(null, $readOnly);
5440 5440
 	}
5441 5441
 	protected function getOwner()
5442 5442
 	{
5443 5443
 		return $this->_o;
5444 5444
 	}
5445
-	public function insertAt($index,$item)
5445
+	public function insertAt($index, $item)
5446 5446
 	{
5447
-		if($item instanceof TControl)
5447
+		if ($item instanceof TControl)
5448 5448
 		{
5449
-			parent::insertAt($index,$item);
5449
+			parent::insertAt($index, $item);
5450 5450
 			$this->_o->addedControl($item);
5451 5451
 		}
5452
-		else if(is_string($item) || ($item instanceof IRenderable))
5453
-			parent::insertAt($index,$item);
5452
+		else if (is_string($item) || ($item instanceof IRenderable))
5453
+			parent::insertAt($index, $item);
5454 5454
 		else
5455 5455
 			throw new TInvalidDataTypeException('controlcollection_control_required');
5456 5456
 	}
5457 5457
 	public function removeAt($index)
5458 5458
 	{
5459
-		$item=parent::removeAt($index);
5460
-		if($item instanceof TControl)
5459
+		$item = parent::removeAt($index);
5460
+		if ($item instanceof TControl)
5461 5461
 			$this->_o->removedControl($item);
5462 5462
 		return $item;
5463 5463
 	}
5464 5464
 	public function clear()
5465 5465
 	{
5466 5466
 		parent::clear();
5467
-		if($this->_o instanceof INamingContainer)
5467
+		if ($this->_o instanceof INamingContainer)
5468 5468
 			$this->_o->clearNamingContainer();
5469 5469
 	}
5470 5470
 }
@@ -5472,11 +5472,11 @@  discard block
 block discarded – undo
5472 5472
 {
5473 5473
 	public function __construct(TControl $owner)
5474 5474
 	{
5475
-		parent::__construct($owner,true);
5475
+		parent::__construct($owner, true);
5476 5476
 	}
5477
-	public function insertAt($index,$item)
5477
+	public function insertAt($index, $item)
5478 5478
 	{
5479
-		if(!is_string($item))  			parent::insertAt($index,$item);  	}
5479
+		if (!is_string($item))  			parent::insertAt($index, $item); }
5480 5480
 }
5481 5481
 interface INamingContainer
5482 5482
 {
@@ -5487,7 +5487,7 @@  discard block
 block discarded – undo
5487 5487
 }
5488 5488
 interface IPostBackDataHandler
5489 5489
 {
5490
-	public function loadPostData($key,$values);
5490
+	public function loadPostData($key, $values);
5491 5491
 	public function raisePostDataChangedEvent();
5492 5492
 	public function getDataChanged();
5493 5493
 }
@@ -5507,7 +5507,7 @@  discard block
 block discarded – undo
5507 5507
 }
5508 5508
 interface IBroadcastEventReceiver
5509 5509
 {
5510
-	public function broadcastEventReceived($sender,$param);
5510
+	public function broadcastEventReceived($sender, $param);
5511 5511
 }
5512 5512
 interface ITheme
5513 5513
 {
@@ -5543,10 +5543,10 @@  discard block
 block discarded – undo
5543 5543
 {
5544 5544
 	private $_name;
5545 5545
 	private $_param;
5546
-	public function __construct($name='',$parameter=null)
5546
+	public function __construct($name = '', $parameter = null)
5547 5547
 	{
5548
-		$this->_name=$name;
5549
-		$this->_param=$parameter;
5548
+		$this->_name = $name;
5549
+		$this->_param = $parameter;
5550 5550
 	}
5551 5551
 	public function getName()
5552 5552
 	{
@@ -5554,7 +5554,7 @@  discard block
 block discarded – undo
5554 5554
 	}
5555 5555
 	public function setName($value)
5556 5556
 	{
5557
-		$this->_name=$value;
5557
+		$this->_name = $value;
5558 5558
 	}
5559 5559
 	public function getParameter()
5560 5560
 	{
@@ -5562,17 +5562,17 @@  discard block
 block discarded – undo
5562 5562
 	}
5563 5563
 	public function setParameter($value)
5564 5564
 	{
5565
-		$this->_param=$value;
5565
+		$this->_param = $value;
5566 5566
 	}
5567 5567
 }
5568 5568
 class TCommandEventParameter extends TEventParameter
5569 5569
 {
5570 5570
 	private $_name;
5571 5571
 	private $_param;
5572
-	public function __construct($name='',$parameter='')
5572
+	public function __construct($name = '', $parameter = '')
5573 5573
 	{
5574
-		$this->_name=$name;
5575
-		$this->_param=$parameter;
5574
+		$this->_name = $name;
5575
+		$this->_param = $parameter;
5576 5576
 	}
5577 5577
 	public function getCommandName()
5578 5578
 	{
@@ -5585,33 +5585,33 @@  discard block
 block discarded – undo
5585 5585
 }
5586 5586
 class TCompositeLiteral extends TComponent implements IRenderable, IBindable
5587 5587
 {
5588
-	const TYPE_EXPRESSION=0;
5589
-	const TYPE_STATEMENTS=1;
5590
-	const TYPE_DATABINDING=2;
5591
-	private $_container=null;
5592
-	private $_items=array();
5593
-	private $_expressions=array();
5594
-	private $_statements=array();
5595
-	private $_bindings=array();
5588
+	const TYPE_EXPRESSION = 0;
5589
+	const TYPE_STATEMENTS = 1;
5590
+	const TYPE_DATABINDING = 2;
5591
+	private $_container = null;
5592
+	private $_items = array();
5593
+	private $_expressions = array();
5594
+	private $_statements = array();
5595
+	private $_bindings = array();
5596 5596
 	public function __construct($items)
5597 5597
 	{
5598
-		$this->_items=array();
5599
-		$this->_expressions=array();
5600
-		$this->_statements=array();
5601
-		foreach($items as $id=>$item)
5598
+		$this->_items = array();
5599
+		$this->_expressions = array();
5600
+		$this->_statements = array();
5601
+		foreach ($items as $id=>$item)
5602 5602
 		{
5603
-			if(is_array($item))
5603
+			if (is_array($item))
5604 5604
 			{
5605
-				if($item[0]===self::TYPE_EXPRESSION)
5606
-					$this->_expressions[$id]=$item[1];
5607
-				else if($item[0]===self::TYPE_STATEMENTS)
5608
-					$this->_statements[$id]=$item[1];
5609
-				else if($item[0]===self::TYPE_DATABINDING)
5610
-					$this->_bindings[$id]=$item[1];
5611
-				$this->_items[$id]='';
5605
+				if ($item[0] === self::TYPE_EXPRESSION)
5606
+					$this->_expressions[$id] = $item[1];
5607
+				else if ($item[0] === self::TYPE_STATEMENTS)
5608
+					$this->_statements[$id] = $item[1];
5609
+				else if ($item[0] === self::TYPE_DATABINDING)
5610
+					$this->_bindings[$id] = $item[1];
5611
+				$this->_items[$id] = '';
5612 5612
 			}
5613 5613
 			else
5614
-				$this->_items[$id]=$item;
5614
+				$this->_items[$id] = $item;
5615 5615
 		}
5616 5616
 	}
5617 5617
 	public function getContainer()
@@ -5620,76 +5620,76 @@  discard block
 block discarded – undo
5620 5620
 	}
5621 5621
 	public function setContainer(TComponent $value)
5622 5622
 	{
5623
-		$this->_container=$value;
5623
+		$this->_container = $value;
5624 5624
 	}
5625 5625
 	public function evaluateDynamicContent()
5626 5626
 	{
5627
-		$context=$this->_container===null?$this:$this->_container;
5628
-		foreach($this->_expressions as $id=>$expression)
5629
-			$this->_items[$id]=$context->evaluateExpression($expression);
5630
-		foreach($this->_statements as $id=>$statement)
5631
-			$this->_items[$id]=$context->evaluateStatements($statement);
5627
+		$context = $this->_container === null ? $this : $this->_container;
5628
+		foreach ($this->_expressions as $id=>$expression)
5629
+			$this->_items[$id] = $context->evaluateExpression($expression);
5630
+		foreach ($this->_statements as $id=>$statement)
5631
+			$this->_items[$id] = $context->evaluateStatements($statement);
5632 5632
 	}
5633 5633
 	public function dataBind()
5634 5634
 	{
5635
-		$context=$this->_container===null?$this:$this->_container;
5636
-		foreach($this->_bindings as $id=>$binding)
5637
-			$this->_items[$id]=$context->evaluateExpression($binding);
5635
+		$context = $this->_container === null ? $this : $this->_container;
5636
+		foreach ($this->_bindings as $id=>$binding)
5637
+			$this->_items[$id] = $context->evaluateExpression($binding);
5638 5638
 	}
5639 5639
 	public function render($writer)
5640 5640
 	{
5641
-		$writer->write(implode('',$this->_items));
5641
+		$writer->write(implode('', $this->_items));
5642 5642
 	}
5643 5643
 }
5644 5644
 class TFont extends TComponent
5645 5645
 {
5646
-	const IS_BOLD=0x01;
5647
-	const IS_ITALIC=0x02;
5648
-	const IS_OVERLINE=0x04;
5649
-	const IS_STRIKEOUT=0x08;
5650
-	const IS_UNDERLINE=0x10;
5651
-	const IS_SET_BOLD=0x01000;
5652
-	const IS_SET_ITALIC=0x02000;
5653
-	const IS_SET_OVERLINE=0x04000;
5654
-	const IS_SET_STRIKEOUT=0x08000;
5655
-	const IS_SET_UNDERLINE=0x10000;
5656
-	const IS_SET_SIZE=0x20000;
5657
-	const IS_SET_NAME=0x40000;
5658
-	private $_flags=0;
5659
-	private $_name='';
5660
-	private $_size='';
5646
+	const IS_BOLD = 0x01;
5647
+	const IS_ITALIC = 0x02;
5648
+	const IS_OVERLINE = 0x04;
5649
+	const IS_STRIKEOUT = 0x08;
5650
+	const IS_UNDERLINE = 0x10;
5651
+	const IS_SET_BOLD = 0x01000;
5652
+	const IS_SET_ITALIC = 0x02000;
5653
+	const IS_SET_OVERLINE = 0x04000;
5654
+	const IS_SET_STRIKEOUT = 0x08000;
5655
+	const IS_SET_UNDERLINE = 0x10000;
5656
+	const IS_SET_SIZE = 0x20000;
5657
+	const IS_SET_NAME = 0x40000;
5658
+	private $_flags = 0;
5659
+	private $_name = '';
5660
+	private $_size = '';
5661 5661
 	public function getBold()
5662 5662
 	{
5663
-		return ($this->_flags & self::IS_BOLD)!==0;
5663
+		return ($this->_flags & self::IS_BOLD) !== 0;
5664 5664
 	}
5665 5665
 	public function setBold($value)
5666 5666
 	{
5667 5667
 		$this->_flags |= self::IS_SET_BOLD;
5668
-		if(TPropertyValue::ensureBoolean($value))
5668
+		if (TPropertyValue::ensureBoolean($value))
5669 5669
 			$this->_flags |= self::IS_BOLD;
5670 5670
 		else
5671 5671
 			$this->_flags &= ~self::IS_BOLD;
5672 5672
 	}
5673 5673
 	public function getItalic()
5674 5674
 	{
5675
-		return ($this->_flags & self::IS_ITALIC)!==0;
5675
+		return ($this->_flags & self::IS_ITALIC) !== 0;
5676 5676
 	}
5677 5677
 	public function setItalic($value)
5678 5678
 	{
5679 5679
 		$this->_flags |= self::IS_SET_ITALIC;
5680
-		if(TPropertyValue::ensureBoolean($value))
5680
+		if (TPropertyValue::ensureBoolean($value))
5681 5681
 			$this->_flags |= self::IS_ITALIC;
5682 5682
 		else
5683 5683
 			$this->_flags &= ~self::IS_ITALIC;
5684 5684
 	}
5685 5685
 	public function getOverline()
5686 5686
 	{
5687
-		return ($this->_flags & self::IS_OVERLINE)!==0;
5687
+		return ($this->_flags & self::IS_OVERLINE) !== 0;
5688 5688
 	}
5689 5689
 	public function setOverline($value)
5690 5690
 	{
5691 5691
 		$this->_flags |= self::IS_SET_OVERLINE;
5692
-		if(TPropertyValue::ensureBoolean($value))
5692
+		if (TPropertyValue::ensureBoolean($value))
5693 5693
 			$this->_flags |= self::IS_OVERLINE;
5694 5694
 		else
5695 5695
 			$this->_flags &= ~self::IS_OVERLINE;
@@ -5701,28 +5701,28 @@  discard block
 block discarded – undo
5701 5701
 	public function setSize($value)
5702 5702
 	{
5703 5703
 		$this->_flags |= self::IS_SET_SIZE;
5704
-		$this->_size=$value;
5704
+		$this->_size = $value;
5705 5705
 	}
5706 5706
 	public function getStrikeout()
5707 5707
 	{
5708
-		return ($this->_flags & self::IS_STRIKEOUT)!==0;
5708
+		return ($this->_flags & self::IS_STRIKEOUT) !== 0;
5709 5709
 	}
5710 5710
 	public function setStrikeout($value)
5711 5711
 	{
5712 5712
 		$this->_flags |= self::IS_SET_STRIKEOUT;
5713
-		if(TPropertyValue::ensureBoolean($value))
5713
+		if (TPropertyValue::ensureBoolean($value))
5714 5714
 			$this->_flags |= self::IS_STRIKEOUT;
5715 5715
 		else
5716 5716
 			$this->_flags &= ~self::IS_STRIKEOUT;
5717 5717
 	}
5718 5718
 	public function getUnderline()
5719 5719
 	{
5720
-		return ($this->_flags & self::IS_UNDERLINE)!==0;
5720
+		return ($this->_flags & self::IS_UNDERLINE) !== 0;
5721 5721
 	}
5722 5722
 	public function setUnderline($value)
5723 5723
 	{
5724 5724
 		$this->_flags |= self::IS_SET_UNDERLINE;
5725
-		if(TPropertyValue::ensureBoolean($value))
5725
+		if (TPropertyValue::ensureBoolean($value))
5726 5726
 			$this->_flags |= self::IS_UNDERLINE;
5727 5727
 		else
5728 5728
 			$this->_flags &= ~self::IS_UNDERLINE;
@@ -5734,7 +5734,7 @@  discard block
 block discarded – undo
5734 5734
 	public function setName($value)
5735 5735
 	{
5736 5736
 		$this->_flags |= self::IS_SET_NAME;
5737
-		$this->_name=$value;
5737
+		$this->_name = $value;
5738 5738
 	}
5739 5739
 	public function getIsEmpty()
5740 5740
 	{
@@ -5742,174 +5742,174 @@  discard block
 block discarded – undo
5742 5742
 	}
5743 5743
 	public function reset()
5744 5744
 	{
5745
-		$this->_flags=0;
5746
-		$this->_name='';
5747
-		$this->_size='';
5745
+		$this->_flags = 0;
5746
+		$this->_name = '';
5747
+		$this->_size = '';
5748 5748
 	}
5749 5749
 	public function mergeWith($font)
5750 5750
 	{
5751
-		if($font===null || $font->_flags===0)
5751
+		if ($font === null || $font->_flags === 0)
5752 5752
 			return;
5753
-		if(!($this->_flags & self::IS_SET_BOLD) && ($font->_flags & self::IS_SET_BOLD))
5753
+		if (!($this->_flags & self::IS_SET_BOLD) && ($font->_flags & self::IS_SET_BOLD))
5754 5754
 			$this->setBold($font->getBold());
5755
-		if(!($this->_flags & self::IS_SET_ITALIC) && ($font->_flags & self::IS_SET_ITALIC))
5755
+		if (!($this->_flags & self::IS_SET_ITALIC) && ($font->_flags & self::IS_SET_ITALIC))
5756 5756
 			$this->setItalic($font->getItalic());
5757
-		if(!($this->_flags & self::IS_SET_OVERLINE) && ($font->_flags & self::IS_SET_OVERLINE))
5757
+		if (!($this->_flags & self::IS_SET_OVERLINE) && ($font->_flags & self::IS_SET_OVERLINE))
5758 5758
 			$this->setOverline($font->getOverline());
5759
-		if(!($this->_flags & self::IS_SET_STRIKEOUT) && ($font->_flags & self::IS_SET_STRIKEOUT))
5759
+		if (!($this->_flags & self::IS_SET_STRIKEOUT) && ($font->_flags & self::IS_SET_STRIKEOUT))
5760 5760
 			$this->setStrikeout($font->getStrikeout());
5761
-		if(!($this->_flags & self::IS_SET_UNDERLINE) && ($font->_flags & self::IS_SET_UNDERLINE))
5761
+		if (!($this->_flags & self::IS_SET_UNDERLINE) && ($font->_flags & self::IS_SET_UNDERLINE))
5762 5762
 			$this->setUnderline($font->getUnderline());
5763
-		if(!($this->_flags & self::IS_SET_SIZE) && ($font->_flags & self::IS_SET_SIZE))
5763
+		if (!($this->_flags & self::IS_SET_SIZE) && ($font->_flags & self::IS_SET_SIZE))
5764 5764
 			$this->setSize($font->getSize());
5765
-		if(!($this->_flags & self::IS_SET_NAME) && ($font->_flags & self::IS_SET_NAME))
5765
+		if (!($this->_flags & self::IS_SET_NAME) && ($font->_flags & self::IS_SET_NAME))
5766 5766
 			$this->setName($font->getName());
5767 5767
 	}
5768 5768
 	public function copyFrom($font)
5769 5769
 	{
5770
-		if($font===null || $font->_flags===0)
5770
+		if ($font === null || $font->_flags === 0)
5771 5771
 			return;
5772
-		if($font->_flags & self::IS_SET_BOLD)
5772
+		if ($font->_flags & self::IS_SET_BOLD)
5773 5773
 			$this->setBold($font->getBold());
5774
-		if($font->_flags & self::IS_SET_ITALIC)
5774
+		if ($font->_flags & self::IS_SET_ITALIC)
5775 5775
 			$this->setItalic($font->getItalic());
5776
-		if($font->_flags & self::IS_SET_OVERLINE)
5776
+		if ($font->_flags & self::IS_SET_OVERLINE)
5777 5777
 			$this->setOverline($font->getOverline());
5778
-		if($font->_flags & self::IS_SET_STRIKEOUT)
5778
+		if ($font->_flags & self::IS_SET_STRIKEOUT)
5779 5779
 			$this->setStrikeout($font->getStrikeout());
5780
-		if($font->_flags & self::IS_SET_UNDERLINE)
5780
+		if ($font->_flags & self::IS_SET_UNDERLINE)
5781 5781
 			$this->setUnderline($font->getUnderline());
5782
-		if($font->_flags & self::IS_SET_SIZE)
5782
+		if ($font->_flags & self::IS_SET_SIZE)
5783 5783
 			$this->setSize($font->getSize());
5784
-		if($font->_flags & self::IS_SET_NAME)
5784
+		if ($font->_flags & self::IS_SET_NAME)
5785 5785
 			$this->setName($font->getName());
5786 5786
 	}
5787 5787
 	public function toString()
5788 5788
 	{
5789
-		if($this->_flags===0)
5789
+		if ($this->_flags === 0)
5790 5790
 			return '';
5791
-		$str='';
5792
-		if($this->_flags & self::IS_SET_BOLD)
5793
-			$str.='font-weight:'.(($this->_flags & self::IS_BOLD)?'bold;':'normal;');
5794
-		if($this->_flags & self::IS_SET_ITALIC)
5795
-			$str.='font-style:'.(($this->_flags & self::IS_ITALIC)?'italic;':'normal;');
5796
-		$textDec='';
5797
-		if($this->_flags & self::IS_UNDERLINE)
5798
-			$textDec.='underline';
5799
-		if($this->_flags & self::IS_OVERLINE)
5800
-			$textDec.=' overline';
5801
-		if($this->_flags & self::IS_STRIKEOUT)
5802
-			$textDec.=' line-through';
5803
-		$textDec=ltrim($textDec);
5804
-		if($textDec!=='')
5805
-			$str.='text-decoration:'.$textDec.';';
5806
-		if($this->_size!=='')
5807
-			$str.='font-size:'.$this->_size.';';
5808
-		if($this->_name!=='')
5809
-			$str.='font-family:'.$this->_name.';';
5791
+		$str = '';
5792
+		if ($this->_flags & self::IS_SET_BOLD)
5793
+			$str .= 'font-weight:' . (($this->_flags & self::IS_BOLD) ? 'bold;' : 'normal;');
5794
+		if ($this->_flags & self::IS_SET_ITALIC)
5795
+			$str .= 'font-style:' . (($this->_flags & self::IS_ITALIC) ? 'italic;' : 'normal;');
5796
+		$textDec = '';
5797
+		if ($this->_flags & self::IS_UNDERLINE)
5798
+			$textDec .= 'underline';
5799
+		if ($this->_flags & self::IS_OVERLINE)
5800
+			$textDec .= ' overline';
5801
+		if ($this->_flags & self::IS_STRIKEOUT)
5802
+			$textDec .= ' line-through';
5803
+		$textDec = ltrim($textDec);
5804
+		if ($textDec !== '')
5805
+			$str .= 'text-decoration:' . $textDec . ';';
5806
+		if ($this->_size !== '')
5807
+			$str .= 'font-size:' . $this->_size . ';';
5808
+		if ($this->_name !== '')
5809
+			$str .= 'font-family:' . $this->_name . ';';
5810 5810
 		return $str;
5811 5811
 	}
5812 5812
 	public function addAttributesToRender($writer)
5813 5813
 	{
5814
-		if($this->_flags===0)
5814
+		if ($this->_flags === 0)
5815 5815
 			return;
5816
-		if($this->_flags & self::IS_SET_BOLD)
5817
-			$writer->addStyleAttribute('font-weight',(($this->_flags & self::IS_BOLD)?'bold':'normal'));
5818
-		if($this->_flags & self::IS_SET_ITALIC)
5819
-			$writer->addStyleAttribute('font-style',(($this->_flags & self::IS_ITALIC)?'italic':'normal'));
5820
-		$textDec='';
5821
-		if($this->_flags & self::IS_UNDERLINE)
5822
-			$textDec.='underline';
5823
-		if($this->_flags & self::IS_OVERLINE)
5824
-			$textDec.=' overline';
5825
-		if($this->_flags & self::IS_STRIKEOUT)
5826
-			$textDec.=' line-through';
5827
-		$textDec=ltrim($textDec);
5828
-		if($textDec!=='')
5829
-			$writer->addStyleAttribute('text-decoration',$textDec);
5830
-		if($this->_size!=='')
5831
-			$writer->addStyleAttribute('font-size',$this->_size);
5832
-		if($this->_name!=='')
5833
-			$writer->addStyleAttribute('font-family',$this->_name);
5816
+		if ($this->_flags & self::IS_SET_BOLD)
5817
+			$writer->addStyleAttribute('font-weight', (($this->_flags & self::IS_BOLD) ? 'bold' : 'normal'));
5818
+		if ($this->_flags & self::IS_SET_ITALIC)
5819
+			$writer->addStyleAttribute('font-style', (($this->_flags & self::IS_ITALIC) ? 'italic' : 'normal'));
5820
+		$textDec = '';
5821
+		if ($this->_flags & self::IS_UNDERLINE)
5822
+			$textDec .= 'underline';
5823
+		if ($this->_flags & self::IS_OVERLINE)
5824
+			$textDec .= ' overline';
5825
+		if ($this->_flags & self::IS_STRIKEOUT)
5826
+			$textDec .= ' line-through';
5827
+		$textDec = ltrim($textDec);
5828
+		if ($textDec !== '')
5829
+			$writer->addStyleAttribute('text-decoration', $textDec);
5830
+		if ($this->_size !== '')
5831
+			$writer->addStyleAttribute('font-size', $this->_size);
5832
+		if ($this->_name !== '')
5833
+			$writer->addStyleAttribute('font-family', $this->_name);
5834 5834
 	}
5835 5835
 }
5836 5836
 class TStyle extends TComponent
5837 5837
 {
5838
-	private $_fields=array();
5839
-	private $_font=null;
5840
-	private $_class=null;
5841
-	private $_customStyle=null;
5842
-	private $_displayStyle='Fixed';
5843
-	public function __construct($style=null)
5844
-	{
5845
-		if($style!==null)
5838
+	private $_fields = array();
5839
+	private $_font = null;
5840
+	private $_class = null;
5841
+	private $_customStyle = null;
5842
+	private $_displayStyle = 'Fixed';
5843
+	public function __construct($style = null)
5844
+	{
5845
+		if ($style !== null)
5846 5846
 			$this->copyFrom($style);
5847 5847
 	}
5848 5848
 	public function __clone()
5849 5849
 	{
5850
-		if($this->_font!==null)
5850
+		if ($this->_font !== null)
5851 5851
 			$this->_font = clone($this->_font);
5852 5852
 	}
5853 5853
 	public function getBackColor()
5854 5854
 	{
5855
-		return isset($this->_fields['background-color'])?$this->_fields['background-color']:'';
5855
+		return isset($this->_fields['background-color']) ? $this->_fields['background-color'] : '';
5856 5856
 	}
5857 5857
 	public function setBackColor($value)
5858 5858
 	{
5859
-		if(trim($value)==='')
5859
+		if (trim($value) === '')
5860 5860
 			unset($this->_fields['background-color']);
5861 5861
 		else
5862
-			$this->_fields['background-color']=$value;
5862
+			$this->_fields['background-color'] = $value;
5863 5863
 	}
5864 5864
 	public function getBorderColor()
5865 5865
 	{
5866
-		return isset($this->_fields['border-color'])?$this->_fields['border-color']:'';
5866
+		return isset($this->_fields['border-color']) ? $this->_fields['border-color'] : '';
5867 5867
 	}
5868 5868
 	public function setBorderColor($value)
5869 5869
 	{
5870
-		if(trim($value)==='')
5870
+		if (trim($value) === '')
5871 5871
 			unset($this->_fields['border-color']);
5872 5872
 		else
5873
-			$this->_fields['border-color']=$value;
5873
+			$this->_fields['border-color'] = $value;
5874 5874
 	}
5875 5875
 	public function getBorderStyle()
5876 5876
 	{
5877
-		return isset($this->_fields['border-style'])?$this->_fields['border-style']:'';
5877
+		return isset($this->_fields['border-style']) ? $this->_fields['border-style'] : '';
5878 5878
 	}
5879 5879
 	public function setBorderStyle($value)
5880 5880
 	{
5881
-		if(trim($value)==='')
5881
+		if (trim($value) === '')
5882 5882
 			unset($this->_fields['border-style']);
5883 5883
 		else
5884
-			$this->_fields['border-style']=$value;
5884
+			$this->_fields['border-style'] = $value;
5885 5885
 	}
5886 5886
 	public function getBorderWidth()
5887 5887
 	{
5888
-		return isset($this->_fields['border-width'])?$this->_fields['border-width']:'';
5888
+		return isset($this->_fields['border-width']) ? $this->_fields['border-width'] : '';
5889 5889
 	}
5890 5890
 	public function setBorderWidth($value)
5891 5891
 	{
5892
-		if(trim($value)==='')
5892
+		if (trim($value) === '')
5893 5893
 			unset($this->_fields['border-width']);
5894 5894
 		else
5895
-			$this->_fields['border-width']=$value;
5895
+			$this->_fields['border-width'] = $value;
5896 5896
 	}
5897 5897
 	public function getCssClass()
5898 5898
 	{
5899
-		return $this->_class===null?'':$this->_class;
5899
+		return $this->_class === null ? '' : $this->_class;
5900 5900
 	}
5901 5901
 	public function hasCssClass()
5902 5902
 	{
5903
-		return ($this->_class!==null);
5903
+		return ($this->_class !== null);
5904 5904
 	}
5905 5905
 	public function setCssClass($value)
5906 5906
 	{
5907
-		$this->_class=$value;
5907
+		$this->_class = $value;
5908 5908
 	}
5909 5909
 	public function getFont()
5910 5910
 	{
5911
-		if($this->_font===null)
5912
-			$this->_font=new TFont;
5911
+		if ($this->_font === null)
5912
+			$this->_font = new TFont;
5913 5913
 		return $this->_font;
5914 5914
 	}
5915 5915
 	public function hasFont()
@@ -5919,13 +5919,13 @@  discard block
 block discarded – undo
5919 5919
 	public function setDisplayStyle($value)
5920 5920
 	{
5921 5921
 		$this->_displayStyle = TPropertyValue::ensureEnum($value, 'TDisplayStyle');
5922
-		switch($this->_displayStyle)
5922
+		switch ($this->_displayStyle)
5923 5923
 		{
5924 5924
 			case TDisplayStyle::None:
5925 5925
 				$this->_fields['display'] = 'none';
5926 5926
 				break;
5927 5927
 			case TDisplayStyle::Dynamic:
5928
-				$this->_fields['display'] = ''; 				break;
5928
+				$this->_fields['display'] = ''; break;
5929 5929
 			case TDisplayStyle::Fixed:
5930 5930
 				$this->_fields['visibility'] = 'visible';
5931 5931
 				break;
@@ -5940,41 +5940,41 @@  discard block
 block discarded – undo
5940 5940
 	}
5941 5941
 	public function getForeColor()
5942 5942
 	{
5943
-		return isset($this->_fields['color'])?$this->_fields['color']:'';
5943
+		return isset($this->_fields['color']) ? $this->_fields['color'] : '';
5944 5944
 	}
5945 5945
 	public function setForeColor($value)
5946 5946
 	{
5947
-		if(trim($value)==='')
5947
+		if (trim($value) === '')
5948 5948
 			unset($this->_fields['color']);
5949 5949
 		else
5950
-			$this->_fields['color']=$value;
5950
+			$this->_fields['color'] = $value;
5951 5951
 	}
5952 5952
 	public function getHeight()
5953 5953
 	{
5954
-		return isset($this->_fields['height'])?$this->_fields['height']:'';
5954
+		return isset($this->_fields['height']) ? $this->_fields['height'] : '';
5955 5955
 	}
5956 5956
 	public function setHeight($value)
5957 5957
 	{
5958
-		if(trim($value)==='')
5958
+		if (trim($value) === '')
5959 5959
 			unset($this->_fields['height']);
5960 5960
 		else
5961
-			$this->_fields['height']=$value;
5961
+			$this->_fields['height'] = $value;
5962 5962
 	}
5963 5963
 	public function getCustomStyle()
5964 5964
 	{
5965
-		return $this->_customStyle===null?'':$this->_customStyle;
5965
+		return $this->_customStyle === null ? '' : $this->_customStyle;
5966 5966
 	}
5967 5967
 	public function setCustomStyle($value)
5968 5968
 	{
5969
-		$this->_customStyle=$value;
5969
+		$this->_customStyle = $value;
5970 5970
 	}
5971 5971
 	public function getStyleField($name)
5972 5972
 	{
5973
-		return isset($this->_fields[$name])?$this->_fields[$name]:'';
5973
+		return isset($this->_fields[$name]) ? $this->_fields[$name] : '';
5974 5974
 	}
5975
-	public function setStyleField($name,$value)
5975
+	public function setStyleField($name, $value)
5976 5976
 	{
5977
-		$this->_fields[$name]=$value;
5977
+		$this->_fields[$name] = $value;
5978 5978
 	}
5979 5979
 	public function clearStyleField($name)
5980 5980
 	{
@@ -5986,61 +5986,61 @@  discard block
 block discarded – undo
5986 5986
 	}
5987 5987
 	public function getWidth()
5988 5988
 	{
5989
-		return isset($this->_fields['width'])?$this->_fields['width']:'';
5989
+		return isset($this->_fields['width']) ? $this->_fields['width'] : '';
5990 5990
 	}
5991 5991
 	public function setWidth($value)
5992 5992
 	{
5993
-		$this->_fields['width']=$value;
5993
+		$this->_fields['width'] = $value;
5994 5994
 	}
5995 5995
 	public function reset()
5996 5996
 	{
5997
-		$this->_fields=array();
5998
-		$this->_font=null;
5999
-		$this->_class=null;
6000
-		$this->_customStyle=null;
5997
+		$this->_fields = array();
5998
+		$this->_font = null;
5999
+		$this->_class = null;
6000
+		$this->_customStyle = null;
6001 6001
 	}
6002 6002
 	public function copyFrom($style)
6003 6003
 	{
6004
-		if($style instanceof TStyle)
6004
+		if ($style instanceof TStyle)
6005 6005
 		{
6006
-			$this->_fields=array_merge($this->_fields,$style->_fields);
6007
-			if($style->_class!==null)
6008
-				$this->_class=$style->_class;
6009
-			if($style->_customStyle!==null)
6010
-				$this->_customStyle=$style->_customStyle;
6011
-			if($style->_font!==null)
6006
+			$this->_fields = array_merge($this->_fields, $style->_fields);
6007
+			if ($style->_class !== null)
6008
+				$this->_class = $style->_class;
6009
+			if ($style->_customStyle !== null)
6010
+				$this->_customStyle = $style->_customStyle;
6011
+			if ($style->_font !== null)
6012 6012
 				$this->getFont()->copyFrom($style->_font);
6013 6013
 		}
6014 6014
 	}
6015 6015
 	public function mergeWith($style)
6016 6016
 	{
6017
-		if($style instanceof TStyle)
6017
+		if ($style instanceof TStyle)
6018 6018
 		{
6019
-			$this->_fields=array_merge($style->_fields,$this->_fields);
6020
-			if($this->_class===null)
6021
-				$this->_class=$style->_class;
6022
-			if($this->_customStyle===null)
6023
-				$this->_customStyle=$style->_customStyle;
6024
-			if($style->_font!==null)
6019
+			$this->_fields = array_merge($style->_fields, $this->_fields);
6020
+			if ($this->_class === null)
6021
+				$this->_class = $style->_class;
6022
+			if ($this->_customStyle === null)
6023
+				$this->_customStyle = $style->_customStyle;
6024
+			if ($style->_font !== null)
6025 6025
 				$this->getFont()->mergeWith($style->_font);
6026 6026
 		}
6027 6027
 	}
6028 6028
 	public function addAttributesToRender($writer)
6029 6029
 	{
6030
-		if($this->_customStyle!==null)
6030
+		if ($this->_customStyle !== null)
6031 6031
 		{
6032
-			foreach(explode(';',$this->_customStyle) as $style)
6032
+			foreach (explode(';', $this->_customStyle) as $style)
6033 6033
 			{
6034
-				$arr=explode(':',$style,2);
6035
-				if(isset($arr[1]) && trim($arr[0])!=='')
6036
-					$writer->addStyleAttribute(trim($arr[0]),trim($arr[1]));
6034
+				$arr = explode(':', $style, 2);
6035
+				if (isset($arr[1]) && trim($arr[0]) !== '')
6036
+					$writer->addStyleAttribute(trim($arr[0]), trim($arr[1]));
6037 6037
 			}
6038 6038
 		}
6039 6039
 		$writer->addStyleAttributes($this->_fields);
6040
-		if($this->_font!==null)
6040
+		if ($this->_font !== null)
6041 6041
 			$this->_font->addAttributesToRender($writer);
6042
-		if($this->_class!==null)
6043
-			$writer->addAttribute('class',$this->_class);
6042
+		if ($this->_class !== null)
6043
+			$writer->addAttribute('class', $this->_class);
6044 6044
 	}
6045 6045
 	public function getStyleFields()
6046 6046
 	{
@@ -6049,231 +6049,231 @@  discard block
 block discarded – undo
6049 6049
 }
6050 6050
 class TDisplayStyle extends TEnumerable
6051 6051
 {
6052
-	const None='None';
6053
-	const Dynamic='Dynamic';
6054
-	const Fixed='Fixed';
6055
-	const Hidden='Hidden';
6052
+	const None = 'None';
6053
+	const Dynamic = 'Dynamic';
6054
+	const Fixed = 'Fixed';
6055
+	const Hidden = 'Hidden';
6056 6056
 }
6057 6057
 class TTableStyle extends TStyle
6058 6058
 {
6059
-	private $_backImageUrl=null;
6060
-	private $_horizontalAlign=null;
6061
-	private $_cellPadding=null;
6062
-	private $_cellSpacing=null;
6063
-	private $_gridLines=null;
6064
-	private $_borderCollapse=null;
6059
+	private $_backImageUrl = null;
6060
+	private $_horizontalAlign = null;
6061
+	private $_cellPadding = null;
6062
+	private $_cellSpacing = null;
6063
+	private $_gridLines = null;
6064
+	private $_borderCollapse = null;
6065 6065
 	public function reset()
6066 6066
 	{
6067
-		$this->_backImageUrl=null;
6068
-		$this->_horizontalAlign=null;
6069
-		$this->_cellPadding=null;
6070
-		$this->_cellSpacing=null;
6071
-		$this->_gridLines=null;
6072
-		$this->_borderCollapse=null;
6067
+		$this->_backImageUrl = null;
6068
+		$this->_horizontalAlign = null;
6069
+		$this->_cellPadding = null;
6070
+		$this->_cellSpacing = null;
6071
+		$this->_gridLines = null;
6072
+		$this->_borderCollapse = null;
6073 6073
 	}
6074 6074
 	public function copyFrom($style)
6075 6075
 	{
6076 6076
 		parent::copyFrom($style);
6077
-		if($style instanceof TTableStyle)
6078
-		{
6079
-			if($style->_backImageUrl!==null)
6080
-				$this->_backImageUrl=$style->_backImageUrl;
6081
-			if($style->_horizontalAlign!==null)
6082
-				$this->_horizontalAlign=$style->_horizontalAlign;
6083
-			if($style->_cellPadding!==null)
6084
-				$this->_cellPadding=$style->_cellPadding;
6085
-			if($style->_cellSpacing!==null)
6086
-				$this->_cellSpacing=$style->_cellSpacing;
6087
-			if($style->_gridLines!==null)
6088
-				$this->_gridLines=$style->_gridLines;
6089
-			if($style->_borderCollapse!==null)
6090
-				$this->_borderCollapse=$style->_borderCollapse;
6077
+		if ($style instanceof TTableStyle)
6078
+		{
6079
+			if ($style->_backImageUrl !== null)
6080
+				$this->_backImageUrl = $style->_backImageUrl;
6081
+			if ($style->_horizontalAlign !== null)
6082
+				$this->_horizontalAlign = $style->_horizontalAlign;
6083
+			if ($style->_cellPadding !== null)
6084
+				$this->_cellPadding = $style->_cellPadding;
6085
+			if ($style->_cellSpacing !== null)
6086
+				$this->_cellSpacing = $style->_cellSpacing;
6087
+			if ($style->_gridLines !== null)
6088
+				$this->_gridLines = $style->_gridLines;
6089
+			if ($style->_borderCollapse !== null)
6090
+				$this->_borderCollapse = $style->_borderCollapse;
6091 6091
 		}
6092 6092
 	}
6093 6093
 	public function mergeWith($style)
6094 6094
 	{
6095 6095
 		parent::mergeWith($style);
6096
-		if($style instanceof TTableStyle)
6097
-		{
6098
-			if($this->_backImageUrl===null && $style->_backImageUrl!==null)
6099
-				$this->_backImageUrl=$style->_backImageUrl;
6100
-			if($this->_horizontalAlign===null && $style->_horizontalAlign!==null)
6101
-				$this->_horizontalAlign=$style->_horizontalAlign;
6102
-			if($this->_cellPadding===null && $style->_cellPadding!==null)
6103
-				$this->_cellPadding=$style->_cellPadding;
6104
-			if($this->_cellSpacing===null && $style->_cellSpacing!==null)
6105
-				$this->_cellSpacing=$style->_cellSpacing;
6106
-			if($this->_gridLines===null && $style->_gridLines!==null)
6107
-				$this->_gridLines=$style->_gridLines;
6108
-			if($this->_borderCollapse===null && $style->_borderCollapse!==null)
6109
-				$this->_borderCollapse=$style->_borderCollapse;
6096
+		if ($style instanceof TTableStyle)
6097
+		{
6098
+			if ($this->_backImageUrl === null && $style->_backImageUrl !== null)
6099
+				$this->_backImageUrl = $style->_backImageUrl;
6100
+			if ($this->_horizontalAlign === null && $style->_horizontalAlign !== null)
6101
+				$this->_horizontalAlign = $style->_horizontalAlign;
6102
+			if ($this->_cellPadding === null && $style->_cellPadding !== null)
6103
+				$this->_cellPadding = $style->_cellPadding;
6104
+			if ($this->_cellSpacing === null && $style->_cellSpacing !== null)
6105
+				$this->_cellSpacing = $style->_cellSpacing;
6106
+			if ($this->_gridLines === null && $style->_gridLines !== null)
6107
+				$this->_gridLines = $style->_gridLines;
6108
+			if ($this->_borderCollapse === null && $style->_borderCollapse !== null)
6109
+				$this->_borderCollapse = $style->_borderCollapse;
6110 6110
 		}
6111 6111
 	}
6112 6112
 	public function addAttributesToRender($writer)
6113 6113
 	{
6114
-		if(($url=trim($this->getBackImageUrl()))!=='')
6115
-			$writer->addStyleAttribute('background-image','url('.$url.')');
6116
-		if(($horizontalAlign=$this->getHorizontalAlign())!==THorizontalAlign::NotSet)
6117
-			$writer->addStyleAttribute('text-align',strtolower($horizontalAlign));
6118
-		if(($cellPadding=$this->getCellPadding())>=0)
6119
-			$writer->addAttribute('cellpadding',"$cellPadding");
6120
-		if(($cellSpacing=$this->getCellSpacing())>=0)
6121
-			$writer->addAttribute('cellspacing',"$cellSpacing");
6122
-		if($this->getBorderCollapse())
6123
-			$writer->addStyleAttribute('border-collapse','collapse');
6124
-		switch($this->getGridLines())
6125
-		{
6126
-			case TTableGridLines::Horizontal : $writer->addAttribute('rules','rows'); break;
6127
-			case TTableGridLines::Vertical : $writer->addAttribute('rules','cols'); break;
6128
-			case TTableGridLines::Both : $writer->addAttribute('rules','all'); break;
6114
+		if (($url = trim($this->getBackImageUrl())) !== '')
6115
+			$writer->addStyleAttribute('background-image', 'url(' . $url . ')');
6116
+		if (($horizontalAlign = $this->getHorizontalAlign()) !== THorizontalAlign::NotSet)
6117
+			$writer->addStyleAttribute('text-align', strtolower($horizontalAlign));
6118
+		if (($cellPadding = $this->getCellPadding()) >= 0)
6119
+			$writer->addAttribute('cellpadding', "$cellPadding");
6120
+		if (($cellSpacing = $this->getCellSpacing()) >= 0)
6121
+			$writer->addAttribute('cellspacing', "$cellSpacing");
6122
+		if ($this->getBorderCollapse())
6123
+			$writer->addStyleAttribute('border-collapse', 'collapse');
6124
+		switch ($this->getGridLines())
6125
+		{
6126
+			case TTableGridLines::Horizontal : $writer->addAttribute('rules', 'rows'); break;
6127
+			case TTableGridLines::Vertical : $writer->addAttribute('rules', 'cols'); break;
6128
+			case TTableGridLines::Both : $writer->addAttribute('rules', 'all'); break;
6129 6129
 		}
6130 6130
 		parent::addAttributesToRender($writer);
6131 6131
 	}
6132 6132
 	public function getBackImageUrl()
6133 6133
 	{
6134
-		return $this->_backImageUrl===null?'':$this->_backImageUrl;
6134
+		return $this->_backImageUrl === null ? '' : $this->_backImageUrl;
6135 6135
 	}
6136 6136
 	public function setBackImageUrl($value)
6137 6137
 	{
6138
-		$this->_backImageUrl=$value;
6138
+		$this->_backImageUrl = $value;
6139 6139
 	}
6140 6140
 	public function getHorizontalAlign()
6141 6141
 	{
6142
-		return $this->_horizontalAlign===null?THorizontalAlign::NotSet:$this->_horizontalAlign;
6142
+		return $this->_horizontalAlign === null ? THorizontalAlign::NotSet : $this->_horizontalAlign;
6143 6143
 	}
6144 6144
 	public function setHorizontalAlign($value)
6145 6145
 	{
6146
-		$this->_horizontalAlign=TPropertyValue::ensureEnum($value,'THorizontalAlign');
6146
+		$this->_horizontalAlign = TPropertyValue::ensureEnum($value, 'THorizontalAlign');
6147 6147
 	}
6148 6148
 	public function getCellPadding()
6149 6149
 	{
6150
-		return $this->_cellPadding===null?-1:$this->_cellPadding;
6150
+		return $this->_cellPadding === null ?-1 : $this->_cellPadding;
6151 6151
 	}
6152 6152
 	public function setCellPadding($value)
6153 6153
 	{
6154
-		if(($this->_cellPadding=TPropertyValue::ensureInteger($value))<-1)
6154
+		if (($this->_cellPadding = TPropertyValue::ensureInteger($value)) < -1)
6155 6155
 			throw new TInvalidDataValueException('tablestyle_cellpadding_invalid');
6156 6156
 	}
6157 6157
 	public function getCellSpacing()
6158 6158
 	{
6159
-		return $this->_cellSpacing===null?-1:$this->_cellSpacing;
6159
+		return $this->_cellSpacing === null ?-1 : $this->_cellSpacing;
6160 6160
 	}
6161 6161
 	public function setCellSpacing($value)
6162 6162
 	{
6163
-		if(($this->_cellSpacing=TPropertyValue::ensureInteger($value))<-1)
6163
+		if (($this->_cellSpacing = TPropertyValue::ensureInteger($value)) < -1)
6164 6164
 			throw new TInvalidDataValueException('tablestyle_cellspacing_invalid');
6165 6165
 	}
6166 6166
 	public function getGridLines()
6167 6167
 	{
6168
-		return $this->_gridLines===null?TTableGridLines::None:$this->_gridLines;
6168
+		return $this->_gridLines === null ? TTableGridLines::None : $this->_gridLines;
6169 6169
 	}
6170 6170
 	public function setGridLines($value)
6171 6171
 	{
6172
-		$this->_gridLines=TPropertyValue::ensureEnum($value,'TTableGridLines');
6172
+		$this->_gridLines = TPropertyValue::ensureEnum($value, 'TTableGridLines');
6173 6173
 	}
6174 6174
 	public function getBorderCollapse()
6175 6175
 	{
6176
-		return $this->_borderCollapse===null?false:$this->_borderCollapse;
6176
+		return $this->_borderCollapse === null ? false : $this->_borderCollapse;
6177 6177
 	}
6178 6178
 	public function setBorderCollapse($value)
6179 6179
 	{
6180
-		$this->_borderCollapse=TPropertyValue::ensureBoolean($value);
6180
+		$this->_borderCollapse = TPropertyValue::ensureBoolean($value);
6181 6181
 	}
6182 6182
 }
6183 6183
 class TTableItemStyle extends TStyle
6184 6184
 {
6185
-	private $_horizontalAlign=null;
6186
-	private $_verticalAlign=null;
6187
-	private $_wrap=null;
6185
+	private $_horizontalAlign = null;
6186
+	private $_verticalAlign = null;
6187
+	private $_wrap = null;
6188 6188
 	public function reset()
6189 6189
 	{
6190 6190
 		parent::reset();
6191
-		$this->_verticalAlign=null;
6192
-		$this->_horizontalAlign=null;
6193
-		$this->_wrap=null;
6191
+		$this->_verticalAlign = null;
6192
+		$this->_horizontalAlign = null;
6193
+		$this->_wrap = null;
6194 6194
 	}
6195 6195
 	public function copyFrom($style)
6196 6196
 	{
6197 6197
 		parent::copyFrom($style);
6198
-		if($style instanceof TTableItemStyle)
6198
+		if ($style instanceof TTableItemStyle)
6199 6199
 		{
6200
-			if($this->_verticalAlign===null && $style->_verticalAlign!==null)
6201
-				$this->_verticalAlign=$style->_verticalAlign;
6202
-			if($this->_horizontalAlign===null && $style->_horizontalAlign!==null)
6203
-				$this->_horizontalAlign=$style->_horizontalAlign;
6204
-			if($this->_wrap===null && $style->_wrap!==null)
6205
-				$this->_wrap=$style->_wrap;
6200
+			if ($this->_verticalAlign === null && $style->_verticalAlign !== null)
6201
+				$this->_verticalAlign = $style->_verticalAlign;
6202
+			if ($this->_horizontalAlign === null && $style->_horizontalAlign !== null)
6203
+				$this->_horizontalAlign = $style->_horizontalAlign;
6204
+			if ($this->_wrap === null && $style->_wrap !== null)
6205
+				$this->_wrap = $style->_wrap;
6206 6206
 		}
6207 6207
 	}
6208 6208
 	public function mergeWith($style)
6209 6209
 	{
6210 6210
 		parent::mergeWith($style);
6211
-		if($style instanceof TTableItemStyle)
6211
+		if ($style instanceof TTableItemStyle)
6212 6212
 		{
6213
-			if($style->_verticalAlign!==null)
6214
-				$this->_verticalAlign=$style->_verticalAlign;
6215
-			if($style->_horizontalAlign!==null)
6216
-				$this->_horizontalAlign=$style->_horizontalAlign;
6217
-			if($style->_wrap!==null)
6218
-				$this->_wrap=$style->_wrap;
6213
+			if ($style->_verticalAlign !== null)
6214
+				$this->_verticalAlign = $style->_verticalAlign;
6215
+			if ($style->_horizontalAlign !== null)
6216
+				$this->_horizontalAlign = $style->_horizontalAlign;
6217
+			if ($style->_wrap !== null)
6218
+				$this->_wrap = $style->_wrap;
6219 6219
 		}
6220 6220
 	}
6221 6221
 	public function addAttributesToRender($writer)
6222 6222
 	{
6223
-		if(!$this->getWrap())
6224
-			$writer->addStyleAttribute('white-space','nowrap');
6225
-		if(($horizontalAlign=$this->getHorizontalAlign())!==THorizontalAlign::NotSet)
6226
-			$writer->addAttribute('align',strtolower($horizontalAlign));
6227
-		if(($verticalAlign=$this->getVerticalAlign())!==TVerticalAlign::NotSet)
6228
-			$writer->addAttribute('valign',strtolower($verticalAlign));
6223
+		if (!$this->getWrap())
6224
+			$writer->addStyleAttribute('white-space', 'nowrap');
6225
+		if (($horizontalAlign = $this->getHorizontalAlign()) !== THorizontalAlign::NotSet)
6226
+			$writer->addAttribute('align', strtolower($horizontalAlign));
6227
+		if (($verticalAlign = $this->getVerticalAlign()) !== TVerticalAlign::NotSet)
6228
+			$writer->addAttribute('valign', strtolower($verticalAlign));
6229 6229
 		parent::addAttributesToRender($writer);
6230 6230
 	}
6231 6231
 	public function getHorizontalAlign()
6232 6232
 	{
6233
-		return $this->_horizontalAlign===null?THorizontalAlign::NotSet:$this->_horizontalAlign;
6233
+		return $this->_horizontalAlign === null ? THorizontalAlign::NotSet : $this->_horizontalAlign;
6234 6234
 	}
6235 6235
 	public function setHorizontalAlign($value)
6236 6236
 	{
6237
-		$this->_horizontalAlign=TPropertyValue::ensureEnum($value,'THorizontalAlign');
6237
+		$this->_horizontalAlign = TPropertyValue::ensureEnum($value, 'THorizontalAlign');
6238 6238
 	}
6239 6239
 	public function getVerticalAlign()
6240 6240
 	{
6241
-		return $this->_verticalAlign===null?TVerticalAlign::NotSet:$this->_verticalAlign;
6241
+		return $this->_verticalAlign === null ? TVerticalAlign::NotSet : $this->_verticalAlign;
6242 6242
 	}
6243 6243
 	public function setVerticalAlign($value)
6244 6244
 	{
6245
-		$this->_verticalAlign=TPropertyValue::ensureEnum($value,'TVerticalAlign');
6245
+		$this->_verticalAlign = TPropertyValue::ensureEnum($value, 'TVerticalAlign');
6246 6246
 	}
6247 6247
 	public function getWrap()
6248 6248
 	{
6249
-		return $this->_wrap===null?true:$this->_wrap;
6249
+		return $this->_wrap === null ? true : $this->_wrap;
6250 6250
 	}
6251 6251
 	public function setWrap($value)
6252 6252
 	{
6253
-		$this->_wrap=TPropertyValue::ensureBoolean($value);
6253
+		$this->_wrap = TPropertyValue::ensureBoolean($value);
6254 6254
 	}
6255 6255
 }
6256 6256
 class THorizontalAlign extends TEnumerable
6257 6257
 {
6258
-	const NotSet='NotSet';
6259
-	const Left='Left';
6260
-	const Right='Right';
6261
-	const Center='Center';
6262
-	const Justify='Justify';
6258
+	const NotSet = 'NotSet';
6259
+	const Left = 'Left';
6260
+	const Right = 'Right';
6261
+	const Center = 'Center';
6262
+	const Justify = 'Justify';
6263 6263
 }
6264 6264
 class TVerticalAlign extends TEnumerable
6265 6265
 {
6266
-	const NotSet='NotSet';
6267
-	const Top='Top';
6268
-	const Bottom='Bottom';
6269
-	const Middle='Middle';
6266
+	const NotSet = 'NotSet';
6267
+	const Top = 'Top';
6268
+	const Bottom = 'Bottom';
6269
+	const Middle = 'Middle';
6270 6270
 }
6271 6271
 class TTableGridLines extends TEnumerable
6272 6272
 {
6273
-	const None='None';
6274
-	const Horizontal='Horizontal';
6275
-	const Vertical='Vertical';
6276
-	const Both='Both';
6273
+	const None = 'None';
6274
+	const Horizontal = 'Horizontal';
6275
+	const Vertical = 'Vertical';
6276
+	const Both = 'Both';
6277 6277
 }
6278 6278
 class TWebControlAdapter extends TControlAdapter
6279 6279
 {
@@ -6301,7 +6301,7 @@  discard block
 block discarded – undo
6301 6301
 	private $_usestate = false;
6302 6302
 	private $_control;
6303 6303
 	private $_outercontrol;
6304
-	private $_addedTemplateDecoration=false;
6304
+	private $_addedTemplateDecoration = false;
6305 6305
 	private $_pretagtext = '';
6306 6306
 	private $_precontentstext = '';
6307 6307
 	private $_postcontentstext = '';
@@ -6326,97 +6326,97 @@  discard block
 block discarded – undo
6326 6326
 		return $this->_pretagtext;
6327 6327
 	}
6328 6328
 	public function setPreTagText($value) {
6329
-		if(!$this->_internalonly && !$this->_control->getIsSkinApplied())
6329
+		if (!$this->_internalonly && !$this->_control->getIsSkinApplied())
6330 6330
 			$this->_pretagtext = TPropertyValue::ensureString($value);
6331 6331
 	}
6332 6332
 	public function getPreContentsText() {
6333 6333
 		return $this->_precontentstext;
6334 6334
 	}
6335 6335
 	public function setPreContentsText($value) {
6336
-		if(!$this->_control->getIsSkinApplied())
6336
+		if (!$this->_control->getIsSkinApplied())
6337 6337
 			$this->_precontentstext = TPropertyValue::ensureString($value);
6338 6338
 	}
6339 6339
 	public function getPostContentsText() {
6340 6340
 		return $this->_postcontentstext;
6341 6341
 	}
6342 6342
 	public function setPostContentsText($value) {
6343
-		if(!$this->_control->getIsSkinApplied())
6343
+		if (!$this->_control->getIsSkinApplied())
6344 6344
 			$this->_postcontentstext = TPropertyValue::ensureString($value);
6345 6345
 	}
6346 6346
 	public function getPostTagText() {
6347 6347
 		return $this->_posttagtext;
6348 6348
 	}
6349 6349
 	public function setPostTagText($value) {
6350
-		if(!$this->_internalonly && !$this->_control->getIsSkinApplied())
6350
+		if (!$this->_internalonly && !$this->_control->getIsSkinApplied())
6351 6351
 			$this->_posttagtext = TPropertyValue::ensureString($value);
6352 6352
 	}
6353 6353
 	public function getPreTagTemplate() {
6354 6354
 		return $this->_pretagtemplate;
6355 6355
 	}
6356 6356
 	public function setPreTagTemplate($value) {
6357
-		if(!$this->_internalonly && !$this->_control->getIsSkinApplied())
6357
+		if (!$this->_internalonly && !$this->_control->getIsSkinApplied())
6358 6358
 			$this->_pretagtemplate = $value;
6359 6359
 	}
6360 6360
 	public function getPreContentsTemplate() {
6361 6361
 		return $this->_precontentstemplate;
6362 6362
 	}
6363 6363
 	public function setPreContentsTemplate($value) {
6364
-		if(!$this->_control->getIsSkinApplied())
6364
+		if (!$this->_control->getIsSkinApplied())
6365 6365
 			$this->_precontentstemplate = $value;
6366 6366
 	}
6367 6367
 	public function getPostContentsTemplate() {
6368 6368
 		return $this->_postcontentstemplate;
6369 6369
 	}
6370 6370
 	public function setPostContentsTemplate($value) {
6371
-		if(!$this->_control->getIsSkinApplied())
6371
+		if (!$this->_control->getIsSkinApplied())
6372 6372
 			$this->_postcontentstemplate = $value;
6373 6373
 	}
6374 6374
 	public function getPostTagTemplate() {
6375 6375
 		return $this->_posttagtemplate;
6376 6376
 	}
6377 6377
 	public function setPostTagTemplate($value) {
6378
-		if(!$this->_internalonly && !$this->_control->getIsSkinApplied())
6378
+		if (!$this->_internalonly && !$this->_control->getIsSkinApplied())
6379 6379
 			$this->_posttagtemplate = $value;
6380 6380
 	}
6381 6381
 	public function instantiate($outercontrol = null) {
6382
-		if($this->getPreTagTemplate() || $this->getPreContentsTemplate() ||
6382
+		if ($this->getPreTagTemplate() || $this->getPreContentsTemplate() ||
6383 6383
 			$this->getPostContentsTemplate() || $this->getPostTagTemplate()) {
6384 6384
 			$this->_outercontrol = $outercontrol;
6385
-			if($this->getUseState())
6385
+			if ($this->getUseState())
6386 6386
 				$this->ensureTemplateDecoration();
6387 6387
 			else
6388 6388
 				$this->_control->getPage()->onSaveStateComplete[] = array($this, 'ensureTemplateDecoration');
6389 6389
 		}
6390 6390
 	}
6391
-	public function ensureTemplateDecoration($sender=null, $param=null) {
6391
+	public function ensureTemplateDecoration($sender = null, $param = null) {
6392 6392
 		$control = $this->_control;
6393 6393
 		$outercontrol = $this->_outercontrol;
6394
-		if($outercontrol === null)
6394
+		if ($outercontrol === null)
6395 6395
 			$outercontrol = $control;
6396
-		if($this->_addedTemplateDecoration)
6396
+		if ($this->_addedTemplateDecoration)
6397 6397
 			return $this->_addedTemplateDecoration;
6398 6398
 		$this->_addedTemplateDecoration = true;
6399
-		if($this->getPreContentsTemplate())
6399
+		if ($this->getPreContentsTemplate())
6400 6400
 		{
6401 6401
 			$precontents = Prado::createComponent('TCompositeControl');
6402 6402
 			$this->getPreContentsTemplate()->instantiateIn($precontents);
6403 6403
 			$control->getControls()->insertAt(0, $precontents);
6404 6404
 		}
6405
-		if($this->getPostContentsTemplate())
6405
+		if ($this->getPostContentsTemplate())
6406 6406
 		{
6407 6407
 			$postcontents = Prado::createComponent('TCompositeControl');
6408 6408
 			$this->getPostContentsTemplate()->instantiateIn($postcontents);
6409 6409
 			$control->getControls()->add($postcontents);
6410 6410
 		}
6411
-		if(!$outercontrol->getParent())
6411
+		if (!$outercontrol->getParent())
6412 6412
 			return $this->_addedTemplateDecoration;
6413
-		if($this->getPreTagTemplate())
6413
+		if ($this->getPreTagTemplate())
6414 6414
 		{
6415 6415
 			$pretag = Prado::createComponent('TCompositeControl');
6416 6416
 			$this->getPreTagTemplate()->instantiateIn($pretag);
6417 6417
 			$outercontrol->getParent()->getControls()->insertBefore($outercontrol, $pretag);
6418 6418
 		}
6419
-		if($this->getPostTagTemplate())
6419
+		if ($this->getPostTagTemplate())
6420 6420
 		{
6421 6421
 			$posttag = Prado::createComponent('TCompositeControl');
6422 6422
 			$this->getPostTagTemplate()->instantiateIn($posttag);
@@ -6439,7 +6439,7 @@  discard block
 block discarded – undo
6439 6439
 }
6440 6440
 class TWebControl extends TControl implements IStyleable
6441 6441
 {
6442
-	private $_ensureid=false;
6442
+	private $_ensureid = false;
6443 6443
 	protected $_decorator;
6444 6444
 	public function setEnsureId($value)
6445 6445
 	{
@@ -6449,9 +6449,9 @@  discard block
 block discarded – undo
6449 6449
 	{
6450 6450
 		return $this->_ensureid;
6451 6451
 	}
6452
-	public function getDecorator($create=true)
6452
+	public function getDecorator($create = true)
6453 6453
 	{
6454
-		if($create && !$this->_decorator)
6454
+		if ($create && !$this->_decorator)
6455 6455
 			$this->_decorator = Prado::createComponent('TWebControlDecorator', $this);
6456 6456
 		return $this->_decorator;
6457 6457
 	}
@@ -6460,24 +6460,24 @@  discard block
 block discarded – undo
6460 6460
 		$this->setAccessKey($control->getAccessKey());
6461 6461
 		$this->setToolTip($control->getToolTip());
6462 6462
 		$this->setTabIndex($control->getTabIndex());
6463
-		if(!$control->getEnabled())
6463
+		if (!$control->getEnabled())
6464 6464
 			$this->setEnabled(false);
6465
-		if($control->getHasAttributes())
6465
+		if ($control->getHasAttributes())
6466 6466
 			$this->getAttributes()->copyFrom($control->getAttributes());
6467 6467
 	}
6468 6468
 	public function getAccessKey()
6469 6469
 	{
6470
-		return $this->getViewState('AccessKey','');
6470
+		return $this->getViewState('AccessKey', '');
6471 6471
 	}
6472 6472
 	public function setAccessKey($value)
6473 6473
 	{
6474
-		if(strlen($value)>1)
6475
-			throw new TInvalidDataValueException('webcontrol_accesskey_invalid',get_class($this),$value);
6476
-		$this->setViewState('AccessKey',$value,'');
6474
+		if (strlen($value) > 1)
6475
+			throw new TInvalidDataValueException('webcontrol_accesskey_invalid', get_class($this), $value);
6476
+		$this->setViewState('AccessKey', $value, '');
6477 6477
 	}
6478 6478
 	public function getBackColor()
6479 6479
 	{
6480
-		if($style=$this->getViewState('Style',null))
6480
+		if ($style = $this->getViewState('Style', null))
6481 6481
 			return $style->getBackColor();
6482 6482
 		else
6483 6483
 			return '';
@@ -6488,7 +6488,7 @@  discard block
 block discarded – undo
6488 6488
 	}
6489 6489
 	public function getBorderColor()
6490 6490
 	{
6491
-		if($style=$this->getViewState('Style',null))
6491
+		if ($style = $this->getViewState('Style', null))
6492 6492
 			return $style->getBorderColor();
6493 6493
 		else
6494 6494
 			return '';
@@ -6499,7 +6499,7 @@  discard block
 block discarded – undo
6499 6499
 	}
6500 6500
 	public function getBorderStyle()
6501 6501
 	{
6502
-		if($style=$this->getViewState('Style',null))
6502
+		if ($style = $this->getViewState('Style', null))
6503 6503
 			return $style->getBorderStyle();
6504 6504
 		else
6505 6505
 			return '';
@@ -6510,7 +6510,7 @@  discard block
 block discarded – undo
6510 6510
 	}
6511 6511
 	public function getBorderWidth()
6512 6512
 	{
6513
-		if($style=$this->getViewState('Style',null))
6513
+		if ($style = $this->getViewState('Style', null))
6514 6514
 			return $style->getBorderWidth();
6515 6515
 		else
6516 6516
 			return '';
@@ -6525,7 +6525,7 @@  discard block
 block discarded – undo
6525 6525
 	}
6526 6526
 	public function getForeColor()
6527 6527
 	{
6528
-		if($style=$this->getViewState('Style',null))
6528
+		if ($style = $this->getViewState('Style', null))
6529 6529
 			return $style->getForeColor();
6530 6530
 		else
6531 6531
 			return '';
@@ -6536,7 +6536,7 @@  discard block
 block discarded – undo
6536 6536
 	}
6537 6537
 	public function getHeight()
6538 6538
 	{
6539
-		if($style=$this->getViewState('Style',null))
6539
+		if ($style = $this->getViewState('Style', null))
6540 6540
 			return $style->getHeight();
6541 6541
 		else
6542 6542
 			return '';
@@ -6555,7 +6555,7 @@  discard block
 block discarded – undo
6555 6555
 	}
6556 6556
 	public function getCssClass()
6557 6557
 	{
6558
-		if($style=$this->getViewState('Style',null))
6558
+		if ($style = $this->getViewState('Style', null))
6559 6559
 			return $style->getCssClass();
6560 6560
 		else
6561 6561
 			return '';
@@ -6566,7 +6566,7 @@  discard block
 block discarded – undo
6566 6566
 	}
6567 6567
 	public function getHasStyle()
6568 6568
 	{
6569
-		return $this->getViewState('Style',null)!==null;
6569
+		return $this->getViewState('Style', null) !== null;
6570 6570
 	}
6571 6571
 	protected function createStyle()
6572 6572
 	{
@@ -6574,21 +6574,21 @@  discard block
 block discarded – undo
6574 6574
 	}
6575 6575
 	public function getStyle()
6576 6576
 	{
6577
-		if($style=$this->getViewState('Style',null))
6577
+		if ($style = $this->getViewState('Style', null))
6578 6578
 			return $style;
6579 6579
 		else
6580 6580
 		{
6581
-			$style=$this->createStyle();
6582
-			$this->setViewState('Style',$style,null);
6581
+			$style = $this->createStyle();
6582
+			$this->setViewState('Style', $style, null);
6583 6583
 			return $style;
6584 6584
 		}
6585 6585
 	}
6586 6586
 	public function setStyle($value)
6587 6587
 	{
6588
-		if(is_string($value))
6588
+		if (is_string($value))
6589 6589
 			$this->getStyle()->setCustomStyle($value);
6590 6590
 		else
6591
-			throw new TInvalidDataValueException('webcontrol_style_invalid',get_class($this));
6591
+			throw new TInvalidDataValueException('webcontrol_style_invalid', get_class($this));
6592 6592
 	}
6593 6593
 	public function clearStyle()
6594 6594
 	{
@@ -6596,11 +6596,11 @@  discard block
 block discarded – undo
6596 6596
 	}
6597 6597
 	public function getTabIndex()
6598 6598
 	{
6599
-		return $this->getViewState('TabIndex',0);
6599
+		return $this->getViewState('TabIndex', 0);
6600 6600
 	}
6601 6601
 	public function setTabIndex($value)
6602 6602
 	{
6603
-		$this->setViewState('TabIndex',TPropertyValue::ensureInteger($value),0);
6603
+		$this->setViewState('TabIndex', TPropertyValue::ensureInteger($value), 0);
6604 6604
 	}
6605 6605
 	protected function getTagName()
6606 6606
 	{
@@ -6608,15 +6608,15 @@  discard block
 block discarded – undo
6608 6608
 	}
6609 6609
 	public function getToolTip()
6610 6610
 	{
6611
-		return $this->getViewState('ToolTip','');
6611
+		return $this->getViewState('ToolTip', '');
6612 6612
 	}
6613 6613
 	public function setToolTip($value)
6614 6614
 	{
6615
-		$this->setViewState('ToolTip',$value,'');
6615
+		$this->setViewState('ToolTip', $value, '');
6616 6616
 	}
6617 6617
 	public function getWidth()
6618 6618
 	{
6619
-		if($style=$this->getViewState('Style',null))
6619
+		if ($style = $this->getViewState('Style', null))
6620 6620
 			return $style->getWidth();
6621 6621
 		else
6622 6622
 			return '';
@@ -6626,28 +6626,28 @@  discard block
 block discarded – undo
6626 6626
 		$this->getStyle()->setWidth($value);
6627 6627
 	}
6628 6628
 	public function onPreRender($param) {
6629
-		if($decorator = $this->getDecorator(false))
6629
+		if ($decorator = $this->getDecorator(false))
6630 6630
 			$decorator->instantiate();
6631 6631
 		parent::onPreRender($param);
6632 6632
 	}
6633 6633
 	protected function addAttributesToRender($writer)
6634 6634
 	{
6635
-		if($this->getID()!=='' || $this->getEnsureId())
6636
-			$writer->addAttribute('id',$this->getClientID());
6637
-		if(($accessKey=$this->getAccessKey())!=='')
6638
-			$writer->addAttribute('accesskey',$accessKey);
6639
-		if(!$this->getEnabled())
6640
-			$writer->addAttribute('disabled','disabled');
6641
-		if(($tabIndex=$this->getTabIndex())>0)
6642
-			$writer->addAttribute('tabindex',"$tabIndex");
6643
-		if(($toolTip=$this->getToolTip())!=='')
6644
-			$writer->addAttribute('title',$toolTip);
6645
-		if($style=$this->getViewState('Style',null))
6635
+		if ($this->getID() !== '' || $this->getEnsureId())
6636
+			$writer->addAttribute('id', $this->getClientID());
6637
+		if (($accessKey = $this->getAccessKey()) !== '')
6638
+			$writer->addAttribute('accesskey', $accessKey);
6639
+		if (!$this->getEnabled())
6640
+			$writer->addAttribute('disabled', 'disabled');
6641
+		if (($tabIndex = $this->getTabIndex()) > 0)
6642
+			$writer->addAttribute('tabindex', "$tabIndex");
6643
+		if (($toolTip = $this->getToolTip()) !== '')
6644
+			$writer->addAttribute('title', $toolTip);
6645
+		if ($style = $this->getViewState('Style', null))
6646 6646
 			$style->addAttributesToRender($writer);
6647
-		if($this->getHasAttributes())
6647
+		if ($this->getHasAttributes())
6648 6648
 		{
6649
-			foreach($this->getAttributes() as $name=>$value)
6650
-				$writer->addAttribute($name,$value);
6649
+			foreach ($this->getAttributes() as $name=>$value)
6650
+				$writer->addAttribute($name, $value);
6651 6651
 		}
6652 6652
 	}
6653 6653
 	public function render($writer)
@@ -6658,7 +6658,7 @@  discard block
 block discarded – undo
6658 6658
 	}
6659 6659
 	public function renderBeginTag($writer)
6660 6660
 	{
6661
-		if($decorator = $this->getDecorator(false)) {
6661
+		if ($decorator = $this->getDecorator(false)) {
6662 6662
 			$decorator->renderPreTagText($writer);
6663 6663
 			$this->addAttributesToRender($writer);
6664 6664
 			$writer->renderBeginTag($this->getTagName());
@@ -6674,7 +6674,7 @@  discard block
 block discarded – undo
6674 6674
 	}
6675 6675
 	public function renderEndTag($writer)
6676 6676
 	{
6677
-		if($decorator = $this->getDecorator(false)) {
6677
+		if ($decorator = $this->getDecorator(false)) {
6678 6678
 			$decorator->renderPostContentsText($writer);
6679 6679
 			$writer->renderEndTag();
6680 6680
 			$decorator->renderPostTagText($writer);
@@ -6684,7 +6684,7 @@  discard block
 block discarded – undo
6684 6684
 }
6685 6685
 class TCompositeControl extends TControl implements INamingContainer
6686 6686
 {
6687
-	protected function initRecursive($namingContainer=null)
6687
+	protected function initRecursive($namingContainer = null)
6688 6688
 	{
6689 6689
 		$this->ensureChildControls();
6690 6690
 		parent::initRecursive($namingContainer);
@@ -6692,20 +6692,20 @@  discard block
 block discarded – undo
6692 6692
 }
6693 6693
 class TTemplateControl extends TCompositeControl
6694 6694
 {
6695
-	const EXT_TEMPLATE='.tpl';
6696
-	private static $_template=array();
6697
-	private $_localTemplate=null;
6698
-	private $_master=null;
6699
-	private $_masterClass='';
6700
-	private $_contents=array();
6701
-	private $_placeholders=array();
6695
+	const EXT_TEMPLATE = '.tpl';
6696
+	private static $_template = array();
6697
+	private $_localTemplate = null;
6698
+	private $_master = null;
6699
+	private $_masterClass = '';
6700
+	private $_contents = array();
6701
+	private $_placeholders = array();
6702 6702
 	public function getTemplate()
6703 6703
 	{
6704
-		if($this->_localTemplate===null)
6704
+		if ($this->_localTemplate === null)
6705 6705
 		{
6706
-			$class=get_class($this);
6707
-			if(!isset(self::$_template[$class]))
6708
-				self::$_template[$class]=$this->loadTemplate();
6706
+			$class = get_class($this);
6707
+			if (!isset(self::$_template[$class]))
6708
+				self::$_template[$class] = $this->loadTemplate();
6709 6709
 			return self::$_template[$class];
6710 6710
 		}
6711 6711
 		else
@@ -6713,54 +6713,54 @@  discard block
 block discarded – undo
6713 6713
 	}
6714 6714
 	public function setTemplate($value)
6715 6715
 	{
6716
-		$this->_localTemplate=$value;
6716
+		$this->_localTemplate = $value;
6717 6717
 	}
6718 6718
 	public function getIsSourceTemplateControl()
6719 6719
 	{
6720
-		if(($template=$this->getTemplate())!==null)
6720
+		if (($template = $this->getTemplate()) !== null)
6721 6721
 			return $template->getIsSourceTemplate();
6722 6722
 		else
6723 6723
 			return false;
6724 6724
 	}
6725 6725
 	public function getTemplateDirectory()
6726 6726
 	{
6727
-		if(($template=$this->getTemplate())!==null)
6727
+		if (($template = $this->getTemplate()) !== null)
6728 6728
 			return $template->getContextPath();
6729 6729
 		else
6730 6730
 			return '';
6731 6731
 	}
6732 6732
 	protected function loadTemplate()
6733 6733
 	{
6734
-		$template=$this->getService()->getTemplateManager()->getTemplateByClassName(get_class($this));
6734
+		$template = $this->getService()->getTemplateManager()->getTemplateByClassName(get_class($this));
6735 6735
 		return $template;
6736 6736
 	}
6737 6737
 	public function createChildControls()
6738 6738
 	{
6739
-		if($tpl=$this->getTemplate())
6739
+		if ($tpl = $this->getTemplate())
6740 6740
 		{
6741
-			foreach($tpl->getDirective() as $name=>$value)
6741
+			foreach ($tpl->getDirective() as $name=>$value)
6742 6742
 			{
6743
-				if(is_string($value))
6744
-					$this->setSubProperty($name,$value);
6743
+				if (is_string($value))
6744
+					$this->setSubProperty($name, $value);
6745 6745
 				else
6746
-					throw new TConfigurationException('templatecontrol_directive_invalid',get_class($this),$name);
6746
+					throw new TConfigurationException('templatecontrol_directive_invalid', get_class($this), $name);
6747 6747
 			}
6748 6748
 			$tpl->instantiateIn($this);
6749 6749
 		}
6750 6750
 	}
6751
-	public function registerContent($id,TContent $object)
6751
+	public function registerContent($id, TContent $object)
6752 6752
 	{
6753
-		if(isset($this->_contents[$id]))
6754
-			throw new TConfigurationException('templatecontrol_contentid_duplicated',$id);
6753
+		if (isset($this->_contents[$id]))
6754
+			throw new TConfigurationException('templatecontrol_contentid_duplicated', $id);
6755 6755
 		else
6756
-			$this->_contents[$id]=$object;
6756
+			$this->_contents[$id] = $object;
6757 6757
 	}
6758
-	public function registerContentPlaceHolder($id,TContentPlaceHolder $object)
6758
+	public function registerContentPlaceHolder($id, TContentPlaceHolder $object)
6759 6759
 	{
6760
-		if(isset($this->_placeholders[$id]))
6761
-			throw new TConfigurationException('templatecontrol_placeholderid_duplicated',$id);
6760
+		if (isset($this->_placeholders[$id]))
6761
+			throw new TConfigurationException('templatecontrol_placeholderid_duplicated', $id);
6762 6762
 		else
6763
-			$this->_placeholders[$id]=$object;
6763
+			$this->_placeholders[$id] = $object;
6764 6764
 	}
6765 6765
 	public function getMasterClass()
6766 6766
 	{
@@ -6768,41 +6768,41 @@  discard block
 block discarded – undo
6768 6768
 	}
6769 6769
 	public function setMasterClass($value)
6770 6770
 	{
6771
-		$this->_masterClass=$value;
6771
+		$this->_masterClass = $value;
6772 6772
 	}
6773 6773
 	public function getMaster()
6774 6774
 	{
6775 6775
 		return $this->_master;
6776 6776
 	}
6777
-	public function injectContent($id,$content)
6777
+	public function injectContent($id, $content)
6778 6778
 	{
6779
-		if(isset($this->_placeholders[$id]))
6779
+		if (isset($this->_placeholders[$id]))
6780 6780
 		{
6781
-			$placeholder=$this->_placeholders[$id];
6782
-			$controls=$placeholder->getParent()->getControls();
6783
-			$loc=$controls->remove($placeholder);
6784
-			$controls->insertAt($loc,$content);
6781
+			$placeholder = $this->_placeholders[$id];
6782
+			$controls = $placeholder->getParent()->getControls();
6783
+			$loc = $controls->remove($placeholder);
6784
+			$controls->insertAt($loc, $content);
6785 6785
 		}
6786 6786
 		else
6787
-			throw new TConfigurationException('templatecontrol_placeholder_inexistent',$id);
6787
+			throw new TConfigurationException('templatecontrol_placeholder_inexistent', $id);
6788 6788
 	}
6789
-	protected function initRecursive($namingContainer=null)
6789
+	protected function initRecursive($namingContainer = null)
6790 6790
 	{
6791 6791
 		$this->ensureChildControls();
6792
-		if($this->_masterClass!=='')
6792
+		if ($this->_masterClass !== '')
6793 6793
 		{
6794
-			$master=Prado::createComponent($this->_masterClass);
6795
-			if(!($master instanceof TTemplateControl))
6794
+			$master = Prado::createComponent($this->_masterClass);
6795
+			if (!($master instanceof TTemplateControl))
6796 6796
 				throw new TInvalidDataValueException('templatecontrol_mastercontrol_invalid');
6797
-			$this->_master=$master;
6797
+			$this->_master = $master;
6798 6798
 			$this->getControls()->clear();
6799 6799
 			$this->getControls()->add($master);
6800 6800
 			$master->ensureChildControls();
6801
-			foreach($this->_contents as $id=>$content)
6802
-				$master->injectContent($id,$content);
6801
+			foreach ($this->_contents as $id=>$content)
6802
+				$master->injectContent($id, $content);
6803 6803
 		}
6804
-		else if(!empty($this->_contents))
6805
-			throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this));
6804
+		else if (!empty($this->_contents))
6805
+			throw new TConfigurationException('templatecontrol_mastercontrol_required', get_class($this));
6806 6806
 		parent::initRecursive($namingContainer);
6807 6807
 	}
6808 6808
         public function tryToUpdateView($arObj, $throwExceptions = false)
@@ -6886,30 +6886,30 @@  discard block
 block discarded – undo
6886 6886
 	}
6887 6887
 	protected function addAttributesToRender($writer)
6888 6888
 	{
6889
-		$writer->addAttribute('id',$this->getClientID());
6890
-		$writer->addAttribute('method',$this->getMethod());
6891
-		$uri=$this->getRequest()->getRequestURI();
6892
-		$writer->addAttribute('action',str_replace('&','&amp;',str_replace('&amp;','&',$uri)));
6893
-		if(($enctype=$this->getEnctype())!=='')
6894
-			$writer->addAttribute('enctype',$enctype);
6895
-		$attributes=$this->getAttributes();
6889
+		$writer->addAttribute('id', $this->getClientID());
6890
+		$writer->addAttribute('method', $this->getMethod());
6891
+		$uri = $this->getRequest()->getRequestURI();
6892
+		$writer->addAttribute('action', str_replace('&', '&amp;', str_replace('&amp;', '&', $uri)));
6893
+		if (($enctype = $this->getEnctype()) !== '')
6894
+			$writer->addAttribute('enctype', $enctype);
6895
+		$attributes = $this->getAttributes();
6896 6896
 		$attributes->remove('action');
6897 6897
 		$writer->addAttributes($attributes);
6898
-		if(($butt=$this->getDefaultButton())!=='')
6898
+		if (($butt = $this->getDefaultButton()) !== '')
6899 6899
 		{
6900
-			if(($button=$this->findControl($butt))!==null)
6900
+			if (($button = $this->findControl($butt)) !== null)
6901 6901
 				$this->getPage()->getClientScript()->registerDefaultButton($this, $button);
6902 6902
 			else
6903
-				throw new TInvalidDataValueException('form_defaultbutton_invalid',$butt);
6903
+				throw new TInvalidDataValueException('form_defaultbutton_invalid', $butt);
6904 6904
 		}
6905 6905
 	}
6906 6906
 	public function render($writer)
6907 6907
 	{
6908
-		$page=$this->getPage();
6908
+		$page = $this->getPage();
6909 6909
 		$this->addAttributesToRender($writer);
6910 6910
 		$writer->renderBeginTag('form');
6911
-		$cs=$page->getClientScript();
6912
-		if($page->getClientSupportsJavaScript())
6911
+		$cs = $page->getClientScript();
6912
+		if ($page->getClientSupportsJavaScript())
6913 6913
 		{
6914 6914
 			$cs->renderHiddenFieldsBegin($writer);
6915 6915
 			$cs->renderScriptFilesBegin($writer);
@@ -6933,27 +6933,27 @@  discard block
 block discarded – undo
6933 6933
 	}
6934 6934
 	public function getDefaultButton()
6935 6935
 	{
6936
-		return $this->getViewState('DefaultButton','');
6936
+		return $this->getViewState('DefaultButton', '');
6937 6937
 	}
6938 6938
 	public function setDefaultButton($value)
6939 6939
 	{
6940
-		$this->setViewState('DefaultButton',$value,'');
6940
+		$this->setViewState('DefaultButton', $value, '');
6941 6941
 	}
6942 6942
 	public function getMethod()
6943 6943
 	{
6944
-		return $this->getViewState('Method','post');
6944
+		return $this->getViewState('Method', 'post');
6945 6945
 	}
6946 6946
 	public function setMethod($value)
6947 6947
 	{
6948
-		$this->setViewState('Method',TPropertyValue::ensureEnum($value,'post','get'),'post');
6948
+		$this->setViewState('Method', TPropertyValue::ensureEnum($value, 'post', 'get'), 'post');
6949 6949
 	}
6950 6950
 	public function getEnctype()
6951 6951
 	{
6952
-		return $this->getViewState('Enctype','');
6952
+		return $this->getViewState('Enctype', '');
6953 6953
 	}
6954 6954
 	public function setEnctype($value)
6955 6955
 	{
6956
-		$this->setViewState('Enctype',$value,'');
6956
+		$this->setViewState('Enctype', $value, '');
6957 6957
 	}
6958 6958
 	public function getName()
6959 6959
 	{
@@ -6962,26 +6962,26 @@  discard block
 block discarded – undo
6962 6962
 }
6963 6963
 class TClientScriptManager extends TApplicationComponent
6964 6964
 {
6965
-	const SCRIPT_PATH='Web/Javascripts/source';
6966
-	const PACKAGES_FILE='Web/Javascripts/packages.php';
6965
+	const SCRIPT_PATH = 'Web/Javascripts/source';
6966
+	const PACKAGES_FILE = 'Web/Javascripts/packages.php';
6967 6967
 	private $_page;
6968
-	private $_hiddenFields=array();
6969
-	private $_beginScripts=array();
6970
-	private $_endScripts=array();
6971
-	private $_scriptFiles=array();
6972
-	private $_headScriptFiles=array();
6973
-	private $_headScripts=array();
6974
-	private $_styleSheetFiles=array();
6975
-	private $_styleSheets=array();
6976
-	private $_registeredPradoScripts=array();
6968
+	private $_hiddenFields = array();
6969
+	private $_beginScripts = array();
6970
+	private $_endScripts = array();
6971
+	private $_scriptFiles = array();
6972
+	private $_headScriptFiles = array();
6973
+	private $_headScripts = array();
6974
+	private $_styleSheetFiles = array();
6975
+	private $_styleSheets = array();
6976
+	private $_registeredPradoScripts = array();
6977 6977
 	private static $_pradoScripts;
6978 6978
 	private static $_pradoPackages;
6979 6979
 	private $_renderedHiddenFields;
6980
-	private $_renderedScriptFiles=array();
6980
+	private $_renderedScriptFiles = array();
6981 6981
 	private $_expandedPradoScripts;
6982 6982
 	public function __construct(TPage $owner)
6983 6983
 	{
6984
-		$this->_page=$owner;
6984
+		$this->_page = $owner;
6985 6985
 	}
6986 6986
 	public function getRequiresHead()
6987 6987
 	{
@@ -6999,30 +6999,30 @@  discard block
 block discarded – undo
6999 6999
 	public function registerPradoScript($name)
7000 7000
 	{
7001 7001
 		$this->registerPradoScriptInternal($name);
7002
-		$params=func_get_args();
7003
-		$this->_page->registerCachingAction('Page.ClientScript','registerPradoScript',$params);
7002
+		$params = func_get_args();
7003
+		$this->_page->registerCachingAction('Page.ClientScript', 'registerPradoScript', $params);
7004 7004
 	}
7005 7005
 	protected function registerPradoScriptInternal($name)
7006 7006
 	{
7007
-				if(!isset($this->_registeredPradoScripts[$name]))
7007
+				if (!isset($this->_registeredPradoScripts[$name]))
7008 7008
 		{
7009
-			if(self::$_pradoScripts === null)
7009
+			if (self::$_pradoScripts === null)
7010 7010
 			{
7011
-				$packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::PACKAGES_FILE;
7012
-				list($packages,$deps)= include($packageFile);
7011
+				$packageFile = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::PACKAGES_FILE;
7012
+				list($packages, $deps) = include($packageFile);
7013 7013
 				self::$_pradoScripts = $deps;
7014 7014
 				self::$_pradoPackages = $packages;
7015 7015
 			}
7016 7016
 			if (isset(self::$_pradoScripts[$name]))
7017
-				$this->_registeredPradoScripts[$name]=true;
7017
+				$this->_registeredPradoScripts[$name] = true;
7018 7018
 			else
7019
-				throw new TInvalidOperationException('csmanager_pradoscript_invalid',$name);
7020
-			if(($packages=array_keys($this->_registeredPradoScripts))!==array())
7019
+				throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name);
7020
+			if (($packages = array_keys($this->_registeredPradoScripts)) !== array())
7021 7021
 			{
7022
-				$base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH;
7023
-				list($path,$baseUrl)=$this->getPackagePathUrl($base);
7024
-				$packagesUrl=array();
7025
-				$isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug;
7022
+				$base = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::SCRIPT_PATH;
7023
+				list($path, $baseUrl) = $this->getPackagePathUrl($base);
7024
+				$packagesUrl = array();
7025
+				$isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug;
7026 7026
 				foreach ($packages as $p)
7027 7027
 				{
7028 7028
 					foreach (self::$_pradoScripts[$p] as $dep)
@@ -7031,35 +7031,35 @@  discard block
 block discarded – undo
7031 7031
 						if (!isset($this->_expandedPradoScripts[$script]))
7032 7032
 						{
7033 7033
 							$this->_expandedPradoScripts[$script] = true;
7034
-							if($isDebug)
7034
+							if ($isDebug)
7035 7035
 							{
7036
-								if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl))
7037
-									$packagesUrl[]=$url;
7036
+								if (!in_array($url = $baseUrl . '/' . $script, $packagesUrl))
7037
+									$packagesUrl[] = $url;
7038 7038
 							} else {
7039
-								if (!in_array($url=$baseUrl.'/min/'.$script,$packagesUrl))
7039
+								if (!in_array($url = $baseUrl . '/min/' . $script, $packagesUrl))
7040 7040
 								{
7041
-									if(!is_file($filePath=$path.'/min/'.$script))
7041
+									if (!is_file($filePath = $path . '/min/' . $script))
7042 7042
 									{
7043
-										$dirPath=dirname($filePath);
7044
-										if(!is_dir($dirPath))
7043
+										$dirPath = dirname($filePath);
7044
+										if (!is_dir($dirPath))
7045 7045
 											mkdir($dirPath, PRADO_CHMOD, true);
7046
-										file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base.'/'.$script)));
7046
+										file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base . '/' . $script)));
7047 7047
 										chmod($filePath, PRADO_CHMOD);
7048 7048
 									}
7049
-									$packagesUrl[]=$url;
7049
+									$packagesUrl[] = $url;
7050 7050
 								}
7051 7051
 							}
7052 7052
 						}
7053 7053
 					}
7054 7054
 				}
7055
-				foreach($packagesUrl as $url)
7056
-					$this->registerScriptFile($url,$url);
7055
+				foreach ($packagesUrl as $url)
7056
+					$this->registerScriptFile($url, $url);
7057 7057
 			}
7058 7058
 		}
7059 7059
 	}
7060 7060
 	public function getPradoScriptAssetUrl()
7061 7061
 	{
7062
-		$base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH;
7062
+		$base = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::SCRIPT_PATH;
7063 7063
 		$assets = Prado::getApplication()->getAssetManager();
7064 7064
 		return $assets->getPublishedUrl($base);
7065 7065
 	}
@@ -7073,19 +7073,19 @@  discard block
 block discarded – undo
7073 7073
 	protected function getPackagePathUrl($base)
7074 7074
 	{
7075 7075
 		$assets = Prado::getApplication()->getAssetManager();
7076
-		if(strpos($base, $assets->getBaseUrl())===false)
7076
+		if (strpos($base, $assets->getBaseUrl()) === false)
7077 7077
 		{
7078
-			if(($dir = Prado::getPathOfNameSpace($base)) !== null) {
7078
+			if (($dir = Prado::getPathOfNameSpace($base)) !== null) {
7079 7079
 				$base = $dir;
7080 7080
 			}
7081 7081
 			return array($assets->getPublishedPath($base), $assets->publishFilePath($base));
7082 7082
 		}
7083 7083
 		else
7084 7084
 		{
7085
-			return array($assets->getBasePath().str_replace($assets->getBaseUrl(),'',$base), $base);
7085
+			return array($assets->getBasePath() . str_replace($assets->getBaseUrl(), '', $base), $base);
7086 7086
 		}
7087 7087
 	}
7088
-	public function getCallbackReference(ICallbackEventHandler $callbackHandler, $options=null)
7088
+	public function getCallbackReference(ICallbackEventHandler $callbackHandler, $options = null)
7089 7089
 	{
7090 7090
 		$options = !is_array($options) ? array() : $options;
7091 7091
 		$class = new ReflectionClass($callbackHandler);
@@ -7098,43 +7098,43 @@  discard block
 block discarded – undo
7098 7098
 	}
7099 7099
 	public function registerCallbackControl($class, $options)
7100 7100
 	{
7101
-		$optionString=TJavaScript::encode($options);
7102
-		$code="new {$class}({$optionString});";
7103
-		$this->_endScripts[sprintf('%08X', crc32($code))]=$code;
7101
+		$optionString = TJavaScript::encode($options);
7102
+		$code = "new {$class}({$optionString});";
7103
+		$this->_endScripts[sprintf('%08X', crc32($code))] = $code;
7104 7104
 		$this->registerPradoScriptInternal('ajax');
7105
-		$params=func_get_args();
7106
-		$this->_page->registerCachingAction('Page.ClientScript','registerCallbackControl',$params);
7105
+		$params = func_get_args();
7106
+		$this->_page->registerCachingAction('Page.ClientScript', 'registerCallbackControl', $params);
7107 7107
 	}
7108
-	public function registerPostBackControl($class,$options)
7108
+	public function registerPostBackControl($class, $options)
7109 7109
 	{
7110
-		if($class === null) {
7110
+		if ($class === null) {
7111 7111
 			return;
7112 7112
 		}
7113
-		if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null)
7114
-			$options['FormID']=$form->getClientID();
7115
-		$optionString=TJavaScript::encode($options);
7116
-		$code="new {$class}({$optionString});";
7117
-		$this->_endScripts[sprintf('%08X', crc32($code))]=$code;
7113
+		if (!isset($options['FormID']) && ($form = $this->_page->getForm()) !== null)
7114
+			$options['FormID'] = $form->getClientID();
7115
+		$optionString = TJavaScript::encode($options);
7116
+		$code = "new {$class}({$optionString});";
7117
+		$this->_endScripts[sprintf('%08X', crc32($code))] = $code;
7118 7118
 		$this->registerPradoScriptInternal('prado');
7119
-		$params=func_get_args();
7120
-		$this->_page->registerCachingAction('Page.ClientScript','registerPostBackControl',$params);
7119
+		$params = func_get_args();
7120
+		$this->_page->registerCachingAction('Page.ClientScript', 'registerPostBackControl', $params);
7121 7121
 	}
7122 7122
 	public function registerDefaultButton($panel, $button)
7123 7123
 	{
7124
-		$panelID=is_string($panel)?$panel:$panel->getUniqueID();
7125
-		if(is_string($button))
7126
-			$buttonID=$button;
7124
+		$panelID = is_string($panel) ? $panel : $panel->getUniqueID();
7125
+		if (is_string($button))
7126
+			$buttonID = $button;
7127 7127
 		else
7128 7128
 		{
7129 7129
 			$button->setIsDefaultButton(true);
7130
-			$buttonID=$button->getUniqueID();
7130
+			$buttonID = $button->getUniqueID();
7131 7131
 		}
7132 7132
 		$options = TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID));
7133 7133
 		$code = "new Prado.WebUI.DefaultButton($options);";
7134
-		$this->_endScripts['prado:'.$panelID]=$code;
7134
+		$this->_endScripts['prado:' . $panelID] = $code;
7135 7135
 		$this->registerPradoScriptInternal('prado');
7136
-		$params=array($panelID,$buttonID);
7137
-		$this->_page->registerCachingAction('Page.ClientScript','registerDefaultButton',$params);
7136
+		$params = array($panelID, $buttonID);
7137
+		$this->_page->registerCachingAction('Page.ClientScript', 'registerDefaultButton', $params);
7138 7138
 	}
7139 7139
 	protected function getDefaultButtonOptions($panelID, $buttonID)
7140 7140
 	{
@@ -7148,26 +7148,26 @@  discard block
 block discarded – undo
7148 7148
 	public function registerFocusControl($target)
7149 7149
 	{
7150 7150
 		$this->registerPradoScriptInternal('jquery');
7151
-		if($target instanceof TControl)
7152
-			$target=$target->getClientID();
7153
-		$this->_endScripts['prado:focus'] = 'jQuery(\'#'.$target.'\').focus();';
7154
-		$params=func_get_args();
7155
-		$this->_page->registerCachingAction('Page.ClientScript','registerFocusControl',$params);
7151
+		if ($target instanceof TControl)
7152
+			$target = $target->getClientID();
7153
+		$this->_endScripts['prado:focus'] = 'jQuery(\'#' . $target . '\').focus();';
7154
+		$params = func_get_args();
7155
+		$this->_page->registerCachingAction('Page.ClientScript', 'registerFocusControl', $params);
7156 7156
 	}
7157
-	public function registerStyleSheetFile($key,$url,$media='')
7157
+	public function registerStyleSheetFile($key, $url, $media = '')
7158 7158
 	{
7159
-		if($media==='')
7160
-			$this->_styleSheetFiles[$key]=$url;
7159
+		if ($media === '')
7160
+			$this->_styleSheetFiles[$key] = $url;
7161 7161
 		else
7162
-			$this->_styleSheetFiles[$key]=array($url,$media);
7163
-		$params=func_get_args();
7164
-		$this->_page->registerCachingAction('Page.ClientScript','registerStyleSheetFile',$params);
7162
+			$this->_styleSheetFiles[$key] = array($url, $media);
7163
+		$params = func_get_args();
7164
+		$this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheetFile', $params);
7165 7165
 	}
7166
-	public function registerStyleSheet($key,$css,$media='')
7166
+	public function registerStyleSheet($key, $css, $media = '')
7167 7167
 	{
7168
-		$this->_styleSheets[$key]=$css;
7169
-		$params=func_get_args();
7170
-		$this->_page->registerCachingAction('Page.ClientScript','registerStyleSheet',$params);
7168
+		$this->_styleSheets[$key] = $css;
7169
+		$params = func_get_args();
7170
+		$this->_page->registerCachingAction('Page.ClientScript', 'registerStyleSheet', $params);
7171 7171
 	}
7172 7172
 	public function getStyleSheetUrls()
7173 7173
 	{
@@ -7176,8 +7176,8 @@  discard block
 block discarded – undo
7176 7176
 				create_function('$e', 'return is_array($e) ? $e[0] : $e;'),
7177 7177
 				$this->_styleSheetFiles)
7178 7178
 		);
7179
-		foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url)
7180
-			if (substr($url,strlen($url)-4)=='.css')
7179
+		foreach (Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url)
7180
+			if (substr($url, strlen($url) - 4) == '.css')
7181 7181
 				$stylesheets[] = $url;
7182 7182
 		$stylesheets = array_unique($stylesheets);
7183 7183
 		return $stylesheets;
@@ -7186,44 +7186,44 @@  discard block
 block discarded – undo
7186 7186
 	{
7187 7187
 		return array_unique(array_values($this->_styleSheets));
7188 7188
 	}
7189
-	public function registerHeadScriptFile($key,$url)
7189
+	public function registerHeadScriptFile($key, $url)
7190 7190
 	{
7191 7191
 		$this->checkIfNotInRender();
7192
-		$this->_headScriptFiles[$key]=$url;
7193
-		$params=func_get_args();
7194
-		$this->_page->registerCachingAction('Page.ClientScript','registerHeadScriptFile',$params);
7192
+		$this->_headScriptFiles[$key] = $url;
7193
+		$params = func_get_args();
7194
+		$this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScriptFile', $params);
7195 7195
 	}
7196
-	public function registerHeadScript($key,$script)
7196
+	public function registerHeadScript($key, $script)
7197 7197
 	{
7198 7198
 		$this->checkIfNotInRender();
7199
-		$this->_headScripts[$key]=$script;
7200
-		$params=func_get_args();
7201
-		$this->_page->registerCachingAction('Page.ClientScript','registerHeadScript',$params);
7199
+		$this->_headScripts[$key] = $script;
7200
+		$params = func_get_args();
7201
+		$this->_page->registerCachingAction('Page.ClientScript', 'registerHeadScript', $params);
7202 7202
 	}
7203 7203
 	public function registerScriptFile($key, $url)
7204 7204
 	{
7205
-		$this->_scriptFiles[$key]=$url;
7206
-		$params=func_get_args();
7207
-		$this->_page->registerCachingAction('Page.ClientScript','registerScriptFile',$params);
7205
+		$this->_scriptFiles[$key] = $url;
7206
+		$params = func_get_args();
7207
+		$this->_page->registerCachingAction('Page.ClientScript', 'registerScriptFile', $params);
7208 7208
 	}
7209
-	public function registerBeginScript($key,$script)
7209
+	public function registerBeginScript($key, $script)
7210 7210
 	{
7211 7211
 		$this->checkIfNotInRender();
7212
-		$this->_beginScripts[$key]=$script;
7213
-		$params=func_get_args();
7214
-		$this->_page->registerCachingAction('Page.ClientScript','registerBeginScript',$params);
7212
+		$this->_beginScripts[$key] = $script;
7213
+		$params = func_get_args();
7214
+		$this->_page->registerCachingAction('Page.ClientScript', 'registerBeginScript', $params);
7215 7215
 	}
7216
-	public function registerEndScript($key,$script)
7216
+	public function registerEndScript($key, $script)
7217 7217
 	{
7218
-		$this->_endScripts[$key]=$script;
7219
-		$params=func_get_args();
7220
-		$this->_page->registerCachingAction('Page.ClientScript','registerEndScript',$params);
7218
+		$this->_endScripts[$key] = $script;
7219
+		$params = func_get_args();
7220
+		$this->_page->registerCachingAction('Page.ClientScript', 'registerEndScript', $params);
7221 7221
 	}
7222
-	public function registerHiddenField($name,$value)
7222
+	public function registerHiddenField($name, $value)
7223 7223
 	{
7224
-		$this->_hiddenFields[$name]=$value;
7225
-		$params=func_get_args();
7226
-		$this->_page->registerCachingAction('Page.ClientScript','registerHiddenField',$params);
7224
+		$this->_hiddenFields[$name] = $value;
7225
+		$params = func_get_args();
7226
+		$this->_page->registerCachingAction('Page.ClientScript', 'registerHiddenField', $params);
7227 7227
 	}
7228 7228
 	public function isStyleSheetFileRegistered($key)
7229 7229
 	{
@@ -7267,24 +7267,24 @@  discard block
 block discarded – undo
7267 7267
 	}
7268 7268
 	public function renderStyleSheetFiles($writer)
7269 7269
 	{
7270
-		$str='';
7271
-		foreach($this->_styleSheetFiles as $url)
7270
+		$str = '';
7271
+		foreach ($this->_styleSheetFiles as $url)
7272 7272
 		{
7273
-			if(is_array($url))
7274
-				$str.="<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"".THttpUtility::htmlEncode($url[0])."\" />\n";
7273
+			if (is_array($url))
7274
+				$str .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"" . THttpUtility::htmlEncode($url[0]) . "\" />\n";
7275 7275
 			else
7276
-				$str.="<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n";
7276
+				$str .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . THttpUtility::htmlEncode($url) . "\" />\n";
7277 7277
 		}
7278 7278
 		$writer->write($str);
7279 7279
 	}
7280 7280
 	public function renderStyleSheets($writer)
7281 7281
 	{
7282
-		if(count($this->_styleSheets))
7283
-			$writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n",$this->_styleSheets)."\n/*]]>*/\n</style>\n");
7282
+		if (count($this->_styleSheets))
7283
+			$writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n" . implode("\n", $this->_styleSheets) . "\n/*]]>*/\n</style>\n");
7284 7284
 	}
7285 7285
 	public function renderHeadScriptFiles($writer)
7286 7286
 	{
7287
-		$this->renderScriptFiles($writer,$this->_headScriptFiles);
7287
+		$this->renderScriptFiles($writer, $this->_headScriptFiles);
7288 7288
 	}
7289 7289
 	public function renderHeadScripts($writer)
7290 7290
 	{
@@ -7301,12 +7301,12 @@  discard block
 block discarded – undo
7301 7301
 	public function markScriptFileAsRendered($url)
7302 7302
 	{
7303 7303
 		$this->_renderedScriptFiles[$url] = $url;
7304
-		$params=func_get_args();
7305
-		$this->_page->registerCachingAction('Page.ClientScript','markScriptFileAsRendered',$params);
7304
+		$params = func_get_args();
7305
+		$this->_page->registerCachingAction('Page.ClientScript', 'markScriptFileAsRendered', $params);
7306 7306
 	}
7307 7307
 	protected function renderScriptFiles($writer, Array $scripts)
7308 7308
 	{
7309
-		foreach($scripts as $script)
7309
+		foreach ($scripts as $script)
7310 7310
 		{
7311 7311
 			$writer->write(TJavaScript::renderScriptFile($script));
7312 7312
 			$this->markScriptFileAsRendered($script);
@@ -7318,10 +7318,10 @@  discard block
 block discarded – undo
7318 7318
 	}
7319 7319
 	public function renderAllPendingScriptFiles($writer)
7320 7320
 	{
7321
-		if(!empty($this->_scriptFiles))
7321
+		if (!empty($this->_scriptFiles))
7322 7322
 		{
7323
-			$addedScripts = array_diff($this->_scriptFiles,$this->getRenderedScriptFiles());
7324
-			$this->renderScriptFiles($writer,$addedScripts);
7323
+			$addedScripts = array_diff($this->_scriptFiles, $this->getRenderedScriptFiles());
7324
+			$this->renderScriptFiles($writer, $addedScripts);
7325 7325
 		}
7326 7326
 	}
7327 7327
 	public function renderBeginScripts($writer)
@@ -7342,15 +7342,15 @@  discard block
 block discarded – undo
7342 7342
 	}
7343 7343
 	public function renderHiddenFieldsBegin($writer)
7344 7344
 	{
7345
-		$this->renderHiddenFieldsInt($writer,true);
7345
+		$this->renderHiddenFieldsInt($writer, true);
7346 7346
 	}
7347 7347
 	public function renderHiddenFieldsEnd($writer)
7348 7348
 	{
7349
-		$this->renderHiddenFieldsInt($writer,false);
7349
+		$this->renderHiddenFieldsInt($writer, false);
7350 7350
 	}
7351
-	public function flushScriptFiles($writer, $control=null)
7351
+	public function flushScriptFiles($writer, $control = null)
7352 7352
 	{
7353
-		if(!$this->_page->getIsCallback())
7353
+		if (!$this->_page->getIsCallback())
7354 7354
 		{
7355 7355
 			$this->_page->ensureRenderInForm($control);
7356 7356
 			$this->renderAllPendingScriptFiles($writer);
@@ -7359,24 +7359,24 @@  discard block
 block discarded – undo
7359 7359
 	protected function renderHiddenFieldsInt($writer, $initial)
7360 7360
  	{
7361 7361
 		if ($initial) $this->_renderedHiddenFields = array();
7362
-		$str='';
7363
-		foreach($this->_hiddenFields as $name=>$value)
7362
+		$str = '';
7363
+		foreach ($this->_hiddenFields as $name=>$value)
7364 7364
 		{
7365
-			if (in_array($name,$this->_renderedHiddenFields)) continue;
7366
-			$id=strtr($name,':','_');
7367
-			if(is_array($value))
7365
+			if (in_array($name, $this->_renderedHiddenFields)) continue;
7366
+			$id = strtr($name, ':', '_');
7367
+			if (is_array($value))
7368 7368
 			{
7369
-				foreach($value as $v)
7370
-					$str.='<input type="hidden" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n";
7369
+				foreach ($value as $v)
7370
+					$str .= '<input type="hidden" name="' . $name . '[]" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n";
7371 7371
 			}
7372 7372
 			else
7373 7373
 			{
7374
-				$str.='<input type="hidden" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n";
7374
+				$str .= '<input type="hidden" name="' . $name . '" id="' . $id . '" value="' . THttpUtility::htmlEncode($value) . "\" />\n";
7375 7375
 			}
7376 7376
 			$this->_renderedHiddenFields[] = $name;
7377 7377
 		}
7378
-		if($str!=='')
7379
-			$writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n");
7378
+		if ($str !== '')
7379
+			$writer->write("<div style=\"visibility:hidden;\">\n" . $str . "</div>\n");
7380 7380
 	}
7381 7381
 	public function getHiddenFields()
7382 7382
 	{
@@ -7393,7 +7393,7 @@  discard block
 block discarded – undo
7393 7393
 	private $_options;
7394 7394
 	protected function setFunction($name, $code)
7395 7395
 	{
7396
-		if(!TJavaScript::isJsLiteral($code))
7396
+		if (!TJavaScript::isJsLiteral($code))
7397 7397
 			$code = TJavaScript::quoteJsLiteral($this->ensureFunction($code));
7398 7398
 		$this->setOption($name, $code);
7399 7399
 	}
@@ -7421,13 +7421,13 @@  discard block
 block discarded – undo
7421 7421
 }
7422 7422
 class TPage extends TTemplateControl
7423 7423
 {
7424
-	const FIELD_POSTBACK_TARGET='PRADO_POSTBACK_TARGET';
7425
-	const FIELD_POSTBACK_PARAMETER='PRADO_POSTBACK_PARAMETER';
7426
-	const FIELD_LASTFOCUS='PRADO_LASTFOCUS';
7427
-	const FIELD_PAGESTATE='PRADO_PAGESTATE';
7428
-	const FIELD_CALLBACK_TARGET='PRADO_CALLBACK_TARGET';
7429
-	const FIELD_CALLBACK_PARAMETER='PRADO_CALLBACK_PARAMETER';
7430
-	private static $_systemPostFields=array(
7424
+	const FIELD_POSTBACK_TARGET = 'PRADO_POSTBACK_TARGET';
7425
+	const FIELD_POSTBACK_PARAMETER = 'PRADO_POSTBACK_PARAMETER';
7426
+	const FIELD_LASTFOCUS = 'PRADO_LASTFOCUS';
7427
+	const FIELD_PAGESTATE = 'PRADO_PAGESTATE';
7428
+	const FIELD_CALLBACK_TARGET = 'PRADO_CALLBACK_TARGET';
7429
+	const FIELD_CALLBACK_PARAMETER = 'PRADO_CALLBACK_PARAMETER';
7430
+	private static $_systemPostFields = array(
7431 7431
 		'PRADO_POSTBACK_TARGET'=>true,
7432 7432
 		'PRADO_POSTBACK_PARAMETER'=>true,
7433 7433
 		'PRADO_LASTFOCUS'=>true,
@@ -7437,32 +7437,32 @@  discard block
 block discarded – undo
7437 7437
 	);
7438 7438
 	private $_form;
7439 7439
 	private $_head;
7440
-	private $_validators=array();
7441
-	private $_validated=false;
7440
+	private $_validators = array();
7441
+	private $_validated = false;
7442 7442
 	private $_theme;
7443 7443
 	private $_title;
7444 7444
 	private $_styleSheet;
7445 7445
 	private $_clientScript;
7446 7446
 	protected $_postData;
7447 7447
 	protected $_restPostData;
7448
-	protected $_controlsPostDataChanged=array();
7449
-	protected $_controlsRequiringPostData=array();
7450
-	protected $_controlsRegisteredForPostData=array();
7448
+	protected $_controlsPostDataChanged = array();
7449
+	protected $_controlsRequiringPostData = array();
7450
+	protected $_controlsRegisteredForPostData = array();
7451 7451
 	private $_postBackEventTarget;
7452 7452
 	private $_postBackEventParameter;
7453
-	protected $_formRendered=false;
7454
-	protected $_inFormRender=false;
7453
+	protected $_formRendered = false;
7454
+	protected $_inFormRender = false;
7455 7455
 	private $_focus;
7456
-	private $_pagePath='';
7457
-	private $_enableStateValidation=true;
7458
-	private $_enableStateEncryption=false;
7459
-	private $_enableStateCompression=true;
7460
-	private $_statePersisterClass='System.Web.UI.TPageStatePersister';
7456
+	private $_pagePath = '';
7457
+	private $_enableStateValidation = true;
7458
+	private $_enableStateEncryption = false;
7459
+	private $_enableStateCompression = true;
7460
+	private $_statePersisterClass = 'System.Web.UI.TPageStatePersister';
7461 7461
 	private $_statePersister;
7462 7462
 	private $_cachingStack;
7463
-	private $_clientState='';
7464
-	protected $_isLoadingPostData=false;
7465
-	private $_enableJavaScript=true;
7463
+	private $_clientState = '';
7464
+	protected $_isLoadingPostData = false;
7465
+	private $_enableJavaScript = true;
7466 7466
 	private $_writer;
7467 7467
 	public function __construct()
7468 7468
 	{
@@ -7472,9 +7472,9 @@  discard block
 block discarded – undo
7472 7472
 	{
7473 7473
 		$this->_writer = $writer;
7474 7474
 		$this->determinePostBackMode();
7475
-		if($this->getIsPostBack())
7475
+		if ($this->getIsPostBack())
7476 7476
 		{
7477
-			if($this->getIsCallback())
7477
+			if ($this->getIsCallback())
7478 7478
 				$this->processCallbackRequest($writer);
7479 7479
 			else
7480 7480
 				$this->processPostBackRequest($writer);
@@ -7503,12 +7503,12 @@  discard block
 block discarded – undo
7503 7503
 		$this->onPreInit(null);
7504 7504
 		$this->initRecursive();
7505 7505
 		$this->onInitComplete(null);
7506
-		$this->_restPostData=new TMap;
7506
+		$this->_restPostData = new TMap;
7507 7507
 		$this->loadPageState();
7508
-		$this->processPostData($this->_postData,true);
7508
+		$this->processPostData($this->_postData, true);
7509 7509
 		$this->onPreLoad(null);
7510 7510
 		$this->loadRecursive();
7511
-		$this->processPostData($this->_restPostData,false);
7511
+		$this->processPostData($this->_restPostData, false);
7512 7512
 		$this->raiseChangedEvents();
7513 7513
 		$this->raisePostBackEvent();
7514 7514
 		$this->onLoadComplete(null);
@@ -7521,13 +7521,13 @@  discard block
 block discarded – undo
7521 7521
 	}
7522 7522
 	protected static function decodeUTF8($data, $enc)
7523 7523
 	{
7524
-		if(is_array($data))
7524
+		if (is_array($data))
7525 7525
 		{
7526
-			foreach($data as $k=>$v)
7527
-				$data[$k]=self::decodeUTF8($v, $enc);
7526
+			foreach ($data as $k=>$v)
7527
+				$data[$k] = self::decodeUTF8($v, $enc);
7528 7528
 			return $data;
7529
-		} elseif(is_string($data)) {
7530
-			return iconv('UTF-8',$enc.'//IGNORE',$data);
7529
+		} elseif (is_string($data)) {
7530
+			return iconv('UTF-8', $enc . '//IGNORE', $data);
7531 7531
 		} else {
7532 7532
 			return $data;
7533 7533
 		}
@@ -7537,21 +7537,21 @@  discard block
 block discarded – undo
7537 7537
 		Prado::using('System.Web.UI.ActiveControls.TActivePageAdapter');
7538 7538
 		$this->setAdapter(new TActivePageAdapter($this));
7539 7539
         $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER);
7540
-        if(strlen($callbackEventParameter) > 0)
7541
-            $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter);
7542
-                if (($g=$this->getApplication()->getGlobalization(false))!==null &&
7543
-            strtoupper($enc=$g->getCharset())!='UTF-8')
7540
+        if (strlen($callbackEventParameter) > 0)
7541
+            $this->_postData[TPage::FIELD_CALLBACK_PARAMETER] = TJavaScript::jsonDecode((string) $callbackEventParameter);
7542
+                if (($g = $this->getApplication()->getGlobalization(false)) !== null &&
7543
+            strtoupper($enc = $g->getCharset()) != 'UTF-8')
7544 7544
                 foreach ($this->_postData as $k=>$v)
7545
-                	$this->_postData[$k]=self::decodeUTF8($v, $enc);
7545
+                	$this->_postData[$k] = self::decodeUTF8($v, $enc);
7546 7546
 		$this->onPreInit(null);
7547 7547
 		$this->initRecursive();
7548 7548
 		$this->onInitComplete(null);
7549
-		$this->_restPostData=new TMap;
7549
+		$this->_restPostData = new TMap;
7550 7550
 		$this->loadPageState();
7551
-		$this->processPostData($this->_postData,true);
7551
+		$this->processPostData($this->_postData, true);
7552 7552
 		$this->onPreLoad(null);
7553 7553
 		$this->loadRecursive();
7554
-		$this->processPostData($this->_restPostData,false);
7554
+		$this->processPostData($this->_restPostData, false);
7555 7555
 		$this->raiseChangedEvents();
7556 7556
 		$this->getAdapter()->processCallbackEvent($writer);
7557 7557
 		$this->onLoadComplete(null);
@@ -7564,7 +7564,7 @@  discard block
 block discarded – undo
7564 7564
 	}
7565 7565
 	public function getCallbackClient()
7566 7566
 	{
7567
-		if($this->getAdapter() !== null)
7567
+		if ($this->getAdapter() !== null)
7568 7568
 			return $this->getAdapter()->getCallbackClientHandler();
7569 7569
 		else
7570 7570
 			return new TCallbackClientScript();
@@ -7595,41 +7595,41 @@  discard block
 block discarded – undo
7595 7595
 	}
7596 7596
 	public function setForm(TForm $form)
7597 7597
 	{
7598
-		if($this->_form===null)
7599
-			$this->_form=$form;
7598
+		if ($this->_form === null)
7599
+			$this->_form = $form;
7600 7600
 		else
7601 7601
 			throw new TInvalidOperationException('page_form_duplicated');
7602 7602
 	}
7603
-	public function getValidators($validationGroup=null)
7603
+	public function getValidators($validationGroup = null)
7604 7604
 	{
7605
-		if(!$this->_validators)
7606
-			$this->_validators=new TList;
7607
-		if(empty($validationGroup) === true)
7605
+		if (!$this->_validators)
7606
+			$this->_validators = new TList;
7607
+		if (empty($validationGroup) === true)
7608 7608
 			return $this->_validators;
7609 7609
 		else
7610 7610
 		{
7611
-			$list=new TList;
7612
-			foreach($this->_validators as $validator)
7613
-				if($validator->getValidationGroup()===$validationGroup)
7611
+			$list = new TList;
7612
+			foreach ($this->_validators as $validator)
7613
+				if ($validator->getValidationGroup() === $validationGroup)
7614 7614
 					$list->add($validator);
7615 7615
 			return $list;
7616 7616
 		}
7617 7617
 	}
7618
-	public function validate($validationGroup=null)
7618
+	public function validate($validationGroup = null)
7619 7619
 	{
7620
-		$this->_validated=true;
7621
-		if($this->_validators && $this->_validators->getCount())
7620
+		$this->_validated = true;
7621
+		if ($this->_validators && $this->_validators->getCount())
7622 7622
 		{
7623
-			if($validationGroup===null)
7623
+			if ($validationGroup === null)
7624 7624
 			{
7625
-				foreach($this->_validators as $validator)
7625
+				foreach ($this->_validators as $validator)
7626 7626
 					$validator->validate();
7627 7627
 			}
7628 7628
 			else
7629 7629
 			{
7630
-				foreach($this->_validators as $validator)
7630
+				foreach ($this->_validators as $validator)
7631 7631
 				{
7632
-					if($validator->getValidationGroup()===$validationGroup)
7632
+					if ($validator->getValidationGroup() === $validationGroup)
7633 7633
 						$validator->validate();
7634 7634
 				}
7635 7635
 			}
@@ -7637,12 +7637,12 @@  discard block
 block discarded – undo
7637 7637
 	}
7638 7638
 	public function getIsValid()
7639 7639
 	{
7640
-		if($this->_validated)
7640
+		if ($this->_validated)
7641 7641
 		{
7642
-			if($this->_validators && $this->_validators->getCount())
7642
+			if ($this->_validators && $this->_validators->getCount())
7643 7643
 			{
7644
-				foreach($this->_validators as $validator)
7645
-					if(!$validator->getIsValid())
7644
+				foreach ($this->_validators as $validator)
7645
+					if (!$validator->getIsValid())
7646 7646
 						return false;
7647 7647
 			}
7648 7648
 			return true;
@@ -7652,107 +7652,107 @@  discard block
 block discarded – undo
7652 7652
 	}
7653 7653
 	public function getTheme()
7654 7654
 	{
7655
-		if(is_string($this->_theme))
7656
-			$this->_theme=$this->getService()->getThemeManager()->getTheme($this->_theme);
7655
+		if (is_string($this->_theme))
7656
+			$this->_theme = $this->getService()->getThemeManager()->getTheme($this->_theme);
7657 7657
 		return $this->_theme;
7658 7658
 	}
7659 7659
 	public function setTheme($value)
7660 7660
 	{
7661
-		$this->_theme=empty($value)?null:$value;
7661
+		$this->_theme = empty($value) ? null : $value;
7662 7662
 	}
7663 7663
 	public function getStyleSheetTheme()
7664 7664
 	{
7665
-		if(is_string($this->_styleSheet))
7666
-			$this->_styleSheet=$this->getService()->getThemeManager()->getTheme($this->_styleSheet);
7665
+		if (is_string($this->_styleSheet))
7666
+			$this->_styleSheet = $this->getService()->getThemeManager()->getTheme($this->_styleSheet);
7667 7667
 		return $this->_styleSheet;
7668 7668
 	}
7669 7669
 	public function setStyleSheetTheme($value)
7670 7670
 	{
7671
-		$this->_styleSheet=empty($value)?null:$value;
7671
+		$this->_styleSheet = empty($value) ? null : $value;
7672 7672
 	}
7673 7673
 	public function applyControlSkin($control)
7674 7674
 	{
7675
-		if(($theme=$this->getTheme())!==null)
7675
+		if (($theme = $this->getTheme()) !== null)
7676 7676
 			$theme->applySkin($control);
7677 7677
 	}
7678 7678
 	public function applyControlStyleSheet($control)
7679 7679
 	{
7680
-		if(($theme=$this->getStyleSheetTheme())!==null)
7680
+		if (($theme = $this->getStyleSheetTheme()) !== null)
7681 7681
 			$theme->applySkin($control);
7682 7682
 	}
7683 7683
 	public function getClientScript()
7684 7684
 	{
7685
-		if(!$this->_clientScript) {
7685
+		if (!$this->_clientScript) {
7686 7686
 			$className = $classPath = $this->getService()->getClientScriptManagerClass();
7687 7687
 			Prado::using($className);
7688
-			if(($pos=strrpos($className,'.'))!==false)
7689
-				$className=substr($className,$pos+1);
7690
- 			if(!class_exists($className,false) || ($className!=='TClientScriptManager' && !is_subclass_of($className,'TClientScriptManager')))
7691
-				throw new THttpException(404,'page_csmanagerclass_invalid',$classPath);
7692
-			$this->_clientScript=new $className($this);
7688
+			if (($pos = strrpos($className, '.')) !== false)
7689
+				$className = substr($className, $pos + 1);
7690
+ 			if (!class_exists($className, false) || ($className !== 'TClientScriptManager' && !is_subclass_of($className, 'TClientScriptManager')))
7691
+				throw new THttpException(404, 'page_csmanagerclass_invalid', $classPath);
7692
+			$this->_clientScript = new $className($this);
7693 7693
 		}
7694 7694
 		return $this->_clientScript;
7695 7695
 	}
7696 7696
 	public function onPreInit($param)
7697 7697
 	{
7698
-		$this->raiseEvent('OnPreInit',$this,$param);
7698
+		$this->raiseEvent('OnPreInit', $this, $param);
7699 7699
 	}
7700 7700
 	public function onInitComplete($param)
7701 7701
 	{
7702
-		$this->raiseEvent('OnInitComplete',$this,$param);
7702
+		$this->raiseEvent('OnInitComplete', $this, $param);
7703 7703
 	}
7704 7704
 	public function onPreLoad($param)
7705 7705
 	{
7706
-		$this->raiseEvent('OnPreLoad',$this,$param);
7706
+		$this->raiseEvent('OnPreLoad', $this, $param);
7707 7707
 	}
7708 7708
 	public function onLoadComplete($param)
7709 7709
 	{
7710
-		$this->raiseEvent('OnLoadComplete',$this,$param);
7710
+		$this->raiseEvent('OnLoadComplete', $this, $param);
7711 7711
 	}
7712 7712
 	public function onPreRenderComplete($param)
7713 7713
 	{
7714
-		$this->raiseEvent('OnPreRenderComplete',$this,$param);
7715
-		$cs=$this->getClientScript();
7716
-		$theme=$this->getTheme();
7717
-		if($theme instanceof ITheme)
7714
+		$this->raiseEvent('OnPreRenderComplete', $this, $param);
7715
+		$cs = $this->getClientScript();
7716
+		$theme = $this->getTheme();
7717
+		if ($theme instanceof ITheme)
7718 7718
 		{
7719
-			foreach($theme->getStyleSheetFiles() as $url)
7720
-				$cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url));
7721
-			foreach($theme->getJavaScriptFiles() as $url)
7722
-				$cs->registerHeadScriptFile($url,$url);
7719
+			foreach ($theme->getStyleSheetFiles() as $url)
7720
+				$cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url));
7721
+			foreach ($theme->getJavaScriptFiles() as $url)
7722
+				$cs->registerHeadScriptFile($url, $url);
7723 7723
 		}
7724
-		$styleSheet=$this->getStyleSheetTheme();
7725
-		if($styleSheet instanceof ITheme)
7724
+		$styleSheet = $this->getStyleSheetTheme();
7725
+		if ($styleSheet instanceof ITheme)
7726 7726
 		{
7727
-			foreach($styleSheet->getStyleSheetFiles() as $url)
7728
-				$cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url));
7729
-			foreach($styleSheet->getJavaScriptFiles() as $url)
7730
-				$cs->registerHeadScriptFile($url,$url);
7727
+			foreach ($styleSheet->getStyleSheetFiles() as $url)
7728
+				$cs->registerStyleSheetFile($url, $url, $this->getCssMediaType($url));
7729
+			foreach ($styleSheet->getJavaScriptFiles() as $url)
7730
+				$cs->registerHeadScriptFile($url, $url);
7731 7731
 		}
7732
-		if($cs->getRequiresHead() && $this->getHead()===null)
7732
+		if ($cs->getRequiresHead() && $this->getHead() === null)
7733 7733
 			throw new TConfigurationException('page_head_required');
7734 7734
 	}
7735 7735
 	private function getCssMediaType($url)
7736 7736
 	{
7737
-		$segs=explode('.',basename($url));
7738
-		if(isset($segs[2]))
7739
-			return $segs[count($segs)-2];
7737
+		$segs = explode('.', basename($url));
7738
+		if (isset($segs[2]))
7739
+			return $segs[count($segs) - 2];
7740 7740
 		else
7741 7741
 			return '';
7742 7742
 	}
7743 7743
 	public function onSaveStateComplete($param)
7744 7744
 	{
7745
-		$this->raiseEvent('OnSaveStateComplete',$this,$param);
7745
+		$this->raiseEvent('OnSaveStateComplete', $this, $param);
7746 7746
 	}
7747 7747
 	private function determinePostBackMode()
7748 7748
 	{
7749
-		$postData=$this->getRequest();
7750
-		if($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET))
7751
-			$this->_postData=$postData;
7749
+		$postData = $this->getRequest();
7750
+		if ($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET))
7751
+			$this->_postData = $postData;
7752 7752
 	}
7753 7753
 	public function getIsPostBack()
7754 7754
 	{
7755
-		return $this->_postData!==null;
7755
+		return $this->_postData !== null;
7756 7756
 	}
7757 7757
 	public function getIsCallback()
7758 7758
 	{
@@ -7761,21 +7761,21 @@  discard block
 block discarded – undo
7761 7761
 	public function saveState()
7762 7762
 	{
7763 7763
 		parent::saveState();
7764
-		$this->setViewState('ControlsRequiringPostBack',$this->_controlsRegisteredForPostData,array());
7764
+		$this->setViewState('ControlsRequiringPostBack', $this->_controlsRegisteredForPostData, array());
7765 7765
 	}
7766 7766
 	public function loadState()
7767 7767
 	{
7768 7768
 		parent::loadState();
7769
-		$this->_controlsRequiringPostData=$this->getViewState('ControlsRequiringPostBack',array());
7769
+		$this->_controlsRequiringPostData = $this->getViewState('ControlsRequiringPostBack', array());
7770 7770
 	}
7771 7771
 	protected function loadPageState()
7772 7772
 	{
7773
-		$state=$this->getStatePersister()->load();
7774
-		$this->loadStateRecursive($state,$this->getEnableViewState());
7773
+		$state = $this->getStatePersister()->load();
7774
+		$this->loadStateRecursive($state, $this->getEnableViewState());
7775 7775
 	}
7776 7776
 	protected function savePageState()
7777 7777
 	{
7778
-		$state=&$this->saveStateRecursive($this->getEnableViewState());
7778
+		$state = &$this->saveStateRecursive($this->getEnableViewState());
7779 7779
 		$this->getStatePersister()->save($state);
7780 7780
 	}
7781 7781
 	protected function isSystemPostField($field)
@@ -7784,79 +7784,79 @@  discard block
 block discarded – undo
7784 7784
 	}
7785 7785
 	public function registerRequiresPostData($control)
7786 7786
 	{
7787
-		$id=is_string($control)?$control:$control->getUniqueID();
7788
-		$this->_controlsRegisteredForPostData[$id]=true;
7789
-		$params=func_get_args();
7790
-		foreach($this->getCachingStack() as $item)
7791
-			$item->registerAction('Page','registerRequiresPostData',array($id));
7787
+		$id = is_string($control) ? $control : $control->getUniqueID();
7788
+		$this->_controlsRegisteredForPostData[$id] = true;
7789
+		$params = func_get_args();
7790
+		foreach ($this->getCachingStack() as $item)
7791
+			$item->registerAction('Page', 'registerRequiresPostData', array($id));
7792 7792
 	}
7793 7793
 	public function getPostBackEventTarget()
7794 7794
 	{
7795
-		if($this->_postBackEventTarget===null && $this->_postData!==null)
7795
+		if ($this->_postBackEventTarget === null && $this->_postData !== null)
7796 7796
 		{
7797
-			$eventTarget=$this->_postData->itemAt(self::FIELD_POSTBACK_TARGET);
7798
-			if(!empty($eventTarget))
7799
-				$this->_postBackEventTarget=$this->findControl($eventTarget);
7797
+			$eventTarget = $this->_postData->itemAt(self::FIELD_POSTBACK_TARGET);
7798
+			if (!empty($eventTarget))
7799
+				$this->_postBackEventTarget = $this->findControl($eventTarget);
7800 7800
 		}
7801 7801
 		return $this->_postBackEventTarget;
7802 7802
 	}
7803 7803
 	public function setPostBackEventTarget(TControl $control)
7804 7804
 	{
7805
-		$this->_postBackEventTarget=$control;
7805
+		$this->_postBackEventTarget = $control;
7806 7806
 	}
7807 7807
 	public function getPostBackEventParameter()
7808 7808
 	{
7809
-		if($this->_postBackEventParameter===null && $this->_postData!==null)
7809
+		if ($this->_postBackEventParameter === null && $this->_postData !== null)
7810 7810
 		{
7811
-			if(($this->_postBackEventParameter=$this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER))===null)
7812
-				$this->_postBackEventParameter='';
7811
+			if (($this->_postBackEventParameter = $this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER)) === null)
7812
+				$this->_postBackEventParameter = '';
7813 7813
 		}
7814 7814
 		return $this->_postBackEventParameter;
7815 7815
 	}
7816 7816
 	public function setPostBackEventParameter($value)
7817 7817
 	{
7818
-		$this->_postBackEventParameter=$value;
7818
+		$this->_postBackEventParameter = $value;
7819 7819
 	}
7820
-	protected function processPostData($postData,$beforeLoad)
7820
+	protected function processPostData($postData, $beforeLoad)
7821 7821
 	{
7822
-		$this->_isLoadingPostData=true;
7823
-		if($beforeLoad)
7824
-			$this->_restPostData=new TMap;
7825
-		foreach($postData as $key=>$value)
7822
+		$this->_isLoadingPostData = true;
7823
+		if ($beforeLoad)
7824
+			$this->_restPostData = new TMap;
7825
+		foreach ($postData as $key=>$value)
7826 7826
 		{
7827
-			if($this->isSystemPostField($key))
7827
+			if ($this->isSystemPostField($key))
7828 7828
 				continue;
7829
-			else if($control=$this->findControl($key))
7829
+			else if ($control = $this->findControl($key))
7830 7830
 			{
7831
-				if($control instanceof IPostBackDataHandler)
7831
+				if ($control instanceof IPostBackDataHandler)
7832 7832
 				{
7833
-					if($control->loadPostData($key,$postData))
7834
-						$this->_controlsPostDataChanged[]=$control;
7833
+					if ($control->loadPostData($key, $postData))
7834
+						$this->_controlsPostDataChanged[] = $control;
7835 7835
 				}
7836
-				else if($control instanceof IPostBackEventHandler &&
7836
+				else if ($control instanceof IPostBackEventHandler &&
7837 7837
 					empty($this->_postData[self::FIELD_POSTBACK_TARGET]))
7838 7838
 				{
7839
-					$this->_postData->add(self::FIELD_POSTBACK_TARGET,$key);  				}
7839
+					$this->_postData->add(self::FIELD_POSTBACK_TARGET, $key); }
7840 7840
 				unset($this->_controlsRequiringPostData[$key]);
7841 7841
 			}
7842
-			else if($beforeLoad)
7843
-				$this->_restPostData->add($key,$value);
7842
+			else if ($beforeLoad)
7843
+				$this->_restPostData->add($key, $value);
7844 7844
 		}
7845
-		foreach($this->_controlsRequiringPostData as $key=>$value)
7845
+		foreach ($this->_controlsRequiringPostData as $key=>$value)
7846 7846
 		{
7847
-			if($control=$this->findControl($key))
7847
+			if ($control = $this->findControl($key))
7848 7848
 			{
7849
-				if($control instanceof IPostBackDataHandler)
7849
+				if ($control instanceof IPostBackDataHandler)
7850 7850
 				{
7851
-					if($control->loadPostData($key,$this->_postData))
7852
-						$this->_controlsPostDataChanged[]=$control;
7851
+					if ($control->loadPostData($key, $this->_postData))
7852
+						$this->_controlsPostDataChanged[] = $control;
7853 7853
 				}
7854 7854
 				else
7855
-					throw new TInvalidDataValueException('page_postbackcontrol_invalid',$key);
7855
+					throw new TInvalidDataValueException('page_postbackcontrol_invalid', $key);
7856 7856
 				unset($this->_controlsRequiringPostData[$key]);
7857 7857
 			}
7858 7858
 		}
7859
-		$this->_isLoadingPostData=false;
7859
+		$this->_isLoadingPostData = false;
7860 7860
 	}
7861 7861
 	public function getIsLoadingPostData()
7862 7862
 	{
@@ -7864,14 +7864,14 @@  discard block
 block discarded – undo
7864 7864
 	}
7865 7865
 	protected function raiseChangedEvents()
7866 7866
 	{
7867
-		foreach($this->_controlsPostDataChanged as $control)
7867
+		foreach ($this->_controlsPostDataChanged as $control)
7868 7868
 			$control->raisePostDataChangedEvent();
7869 7869
 	}
7870 7870
 	protected function raisePostBackEvent()
7871 7871
 	{
7872
-		if(($postBackHandler=$this->getPostBackEventTarget())===null)
7872
+		if (($postBackHandler = $this->getPostBackEventTarget()) === null)
7873 7873
 			$this->validate();
7874
-		else if($postBackHandler instanceof IPostBackEventHandler)
7874
+		else if ($postBackHandler instanceof IPostBackEventHandler)
7875 7875
 			$postBackHandler->raisePostBackEvent($this->getPostBackEventParameter());
7876 7876
 	}
7877 7877
 	public function getInFormRender()
@@ -7880,34 +7880,34 @@  discard block
 block discarded – undo
7880 7880
 	}
7881 7881
 	public function ensureRenderInForm($control)
7882 7882
 	{
7883
-		if(!$this->getIsCallback() && !$this->_inFormRender)
7884
-			throw new TConfigurationException('page_control_outofform',get_class($control), $control ? $control->getUniqueID() : null);
7883
+		if (!$this->getIsCallback() && !$this->_inFormRender)
7884
+			throw new TConfigurationException('page_control_outofform', get_class($control), $control ? $control->getUniqueID() : null);
7885 7885
 	}
7886 7886
 	public function beginFormRender($writer)
7887 7887
 	{
7888
-		if($this->_formRendered)
7888
+		if ($this->_formRendered)
7889 7889
 			throw new TConfigurationException('page_form_duplicated');
7890
-		$this->_formRendered=true;
7891
-		$this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE,$this->getClientState());
7892
-		$this->_inFormRender=true;
7890
+		$this->_formRendered = true;
7891
+		$this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE, $this->getClientState());
7892
+		$this->_inFormRender = true;
7893 7893
 	}
7894 7894
 	public function endFormRender($writer)
7895 7895
 	{
7896
-		if($this->_focus)
7896
+		if ($this->_focus)
7897 7897
 		{
7898
-			if(($this->_focus instanceof TControl) && $this->_focus->getVisible(true))
7899
-				$focus=$this->_focus->getClientID();
7898
+			if (($this->_focus instanceof TControl) && $this->_focus->getVisible(true))
7899
+				$focus = $this->_focus->getClientID();
7900 7900
 			else
7901
-				$focus=$this->_focus;
7901
+				$focus = $this->_focus;
7902 7902
 			$this->getClientScript()->registerFocusControl($focus);
7903 7903
 		}
7904
-		else if($this->_postData && ($lastFocus=$this->_postData->itemAt(self::FIELD_LASTFOCUS))!==null)
7904
+		else if ($this->_postData && ($lastFocus = $this->_postData->itemAt(self::FIELD_LASTFOCUS)) !== null)
7905 7905
 			$this->getClientScript()->registerFocusControl($lastFocus);
7906
-		$this->_inFormRender=false;
7906
+		$this->_inFormRender = false;
7907 7907
 	}
7908 7908
 	public function setFocus($value)
7909 7909
 	{
7910
-		$this->_focus=$value;
7910
+		$this->_focus = $value;
7911 7911
 	}
7912 7912
 	public function getClientSupportsJavaScript()
7913 7913
 	{
@@ -7915,7 +7915,7 @@  discard block
 block discarded – undo
7915 7915
 	}
7916 7916
 	public function setClientSupportsJavaScript($value)
7917 7917
 	{
7918
-		$this->_enableJavaScript=TPropertyValue::ensureBoolean($value);
7918
+		$this->_enableJavaScript = TPropertyValue::ensureBoolean($value);
7919 7919
 	}
7920 7920
 	public function getHead()
7921 7921
 	{
@@ -7923,28 +7923,28 @@  discard block
 block discarded – undo
7923 7923
 	}
7924 7924
 	public function setHead(THead $value)
7925 7925
 	{
7926
-		if($this->_head)
7926
+		if ($this->_head)
7927 7927
 			throw new TInvalidOperationException('page_head_duplicated');
7928
-		$this->_head=$value;
7929
-		if($this->_title!==null)
7928
+		$this->_head = $value;
7929
+		if ($this->_title !== null)
7930 7930
 		{
7931 7931
 			$this->_head->setTitle($this->_title);
7932
-			$this->_title=null;
7932
+			$this->_title = null;
7933 7933
 		}
7934 7934
 	}
7935 7935
 	public function getTitle()
7936 7936
 	{
7937
-		if($this->_head)
7937
+		if ($this->_head)
7938 7938
 			return $this->_head->getTitle();
7939 7939
 		else
7940
-			return $this->_title===null ? '' : $this->_title;
7940
+			return $this->_title === null ? '' : $this->_title;
7941 7941
 	}
7942 7942
 	public function setTitle($value)
7943 7943
 	{
7944
-		if($this->_head)
7944
+		if ($this->_head)
7945 7945
 			$this->_head->setTitle($value);
7946 7946
 		else
7947
-			$this->_title=$value;
7947
+			$this->_title = $value;
7948 7948
 	}
7949 7949
 	public function getClientState()
7950 7950
 	{
@@ -7952,7 +7952,7 @@  discard block
 block discarded – undo
7952 7952
 	}
7953 7953
 	public function setClientState($state)
7954 7954
 	{
7955
-		$this->_clientState=$state;
7955
+		$this->_clientState = $state;
7956 7956
 	}
7957 7957
 	public function getRequestClientState()
7958 7958
 	{
@@ -7964,14 +7964,14 @@  discard block
 block discarded – undo
7964 7964
 	}
7965 7965
 	public function setStatePersisterClass($value)
7966 7966
 	{
7967
-		$this->_statePersisterClass=$value;
7967
+		$this->_statePersisterClass = $value;
7968 7968
 	}
7969 7969
 	public function getStatePersister()
7970 7970
 	{
7971
-		if($this->_statePersister===null)
7971
+		if ($this->_statePersister === null)
7972 7972
 		{
7973
-			$this->_statePersister=Prado::createComponent($this->_statePersisterClass);
7974
-			if(!($this->_statePersister instanceof IPageStatePersister))
7973
+			$this->_statePersister = Prado::createComponent($this->_statePersisterClass);
7974
+			if (!($this->_statePersister instanceof IPageStatePersister))
7975 7975
 				throw new TInvalidDataTypeException('page_statepersister_invalid');
7976 7976
 			$this->_statePersister->setPage($this);
7977 7977
 		}
@@ -7983,7 +7983,7 @@  discard block
 block discarded – undo
7983 7983
 	}
7984 7984
 	public function setEnableStateValidation($value)
7985 7985
 	{
7986
-		$this->_enableStateValidation=TPropertyValue::ensureBoolean($value);
7986
+		$this->_enableStateValidation = TPropertyValue::ensureBoolean($value);
7987 7987
 	}
7988 7988
 	public function getEnableStateEncryption()
7989 7989
 	{
@@ -7991,7 +7991,7 @@  discard block
 block discarded – undo
7991 7991
 	}
7992 7992
 	public function setEnableStateEncryption($value)
7993 7993
 	{
7994
-		$this->_enableStateEncryption=TPropertyValue::ensureBoolean($value);
7994
+		$this->_enableStateEncryption = TPropertyValue::ensureBoolean($value);
7995 7995
 	}
7996 7996
 	public function getEnableStateCompression()
7997 7997
 	{
@@ -7999,7 +7999,7 @@  discard block
 block discarded – undo
7999 7999
 	}
8000 8000
 	public function setEnableStateCompression($value)
8001 8001
 	{
8002
-		$this->_enableStateCompression=TPropertyValue::ensureBoolean($value);
8002
+		$this->_enableStateCompression = TPropertyValue::ensureBoolean($value);
8003 8003
 	}
8004 8004
 	public function getPagePath()
8005 8005
 	{
@@ -8007,20 +8007,20 @@  discard block
 block discarded – undo
8007 8007
 	}
8008 8008
 	public function setPagePath($value)
8009 8009
 	{
8010
-		$this->_pagePath=$value;
8010
+		$this->_pagePath = $value;
8011 8011
 	}
8012
-	public function registerCachingAction($context,$funcName,$funcParams)
8012
+	public function registerCachingAction($context, $funcName, $funcParams)
8013 8013
 	{
8014
-		if($this->_cachingStack)
8014
+		if ($this->_cachingStack)
8015 8015
 		{
8016
-			foreach($this->_cachingStack as $cache)
8017
-				$cache->registerAction($context,$funcName,$funcParams);
8016
+			foreach ($this->_cachingStack as $cache)
8017
+				$cache->registerAction($context, $funcName, $funcParams);
8018 8018
 		}
8019 8019
 	}
8020 8020
 	public function getCachingStack()
8021 8021
 	{
8022
-		if(!$this->_cachingStack)
8023
-			$this->_cachingStack=new TStack;
8022
+		if (!$this->_cachingStack)
8023
+			$this->_cachingStack = new TStack;
8024 8024
 		return $this->_cachingStack;
8025 8025
 	}
8026 8026
 	public function flushWriter()
@@ -8038,34 +8038,34 @@  discard block
 block discarded – undo
8038 8038
 }
8039 8039
 class TPageStateFormatter
8040 8040
 {
8041
-	public static function serialize($page,$data)
8041
+	public static function serialize($page, $data)
8042 8042
 	{
8043
-		$sm=$page->getApplication()->getSecurityManager();
8044
-		if($page->getEnableStateValidation())
8045
-			$str=$sm->hashData(serialize($data));
8043
+		$sm = $page->getApplication()->getSecurityManager();
8044
+		if ($page->getEnableStateValidation())
8045
+			$str = $sm->hashData(serialize($data));
8046 8046
 		else
8047
-			$str=serialize($data);
8048
-		if($page->getEnableStateCompression() && extension_loaded('zlib'))
8049
-			$str=gzcompress($str);
8050
-		if($page->getEnableStateEncryption())
8051
-			$str=$sm->encrypt($str);
8047
+			$str = serialize($data);
8048
+		if ($page->getEnableStateCompression() && extension_loaded('zlib'))
8049
+			$str = gzcompress($str);
8050
+		if ($page->getEnableStateEncryption())
8051
+			$str = $sm->encrypt($str);
8052 8052
 		return base64_encode($str);
8053 8053
 	}
8054
-	public static function unserialize($page,$data)
8054
+	public static function unserialize($page, $data)
8055 8055
 	{
8056
-		$str=base64_decode($data);
8057
-		if($str==='')
8056
+		$str = base64_decode($data);
8057
+		if ($str === '')
8058 8058
 			return null;
8059
-		if($str!==false)
8059
+		if ($str !== false)
8060 8060
 		{
8061
-			$sm=$page->getApplication()->getSecurityManager();
8062
-			if($page->getEnableStateEncryption())
8063
-				$str=$sm->decrypt($str);
8064
-			if($page->getEnableStateCompression() && extension_loaded('zlib'))
8065
-				$str=@gzuncompress($str);
8066
-			if($page->getEnableStateValidation())
8061
+			$sm = $page->getApplication()->getSecurityManager();
8062
+			if ($page->getEnableStateEncryption())
8063
+				$str = $sm->decrypt($str);
8064
+			if ($page->getEnableStateCompression() && extension_loaded('zlib'))
8065
+				$str = @gzuncompress($str);
8066
+			if ($page->getEnableStateValidation())
8067 8067
 			{
8068
-				if(($str=$sm->validateData($str))!==false)
8068
+				if (($str = $sm->validateData($str)) !== false)
8069 8069
 					return unserialize($str);
8070 8070
 			}
8071 8071
 			else
@@ -8076,22 +8076,22 @@  discard block
 block discarded – undo
8076 8076
 }
8077 8077
 class TOutputCache extends TControl implements INamingContainer
8078 8078
 {
8079
-	const CACHE_ID_PREFIX='prado:outputcache';
8080
-	private $_cacheModuleID='';
8081
-	private $_dataCached=false;
8082
-	private $_cacheAvailable=false;
8083
-	private $_cacheChecked=false;
8084
-	private $_cacheKey=null;
8085
-	private $_duration=60;
8086
-	private $_cache=null;
8079
+	const CACHE_ID_PREFIX = 'prado:outputcache';
8080
+	private $_cacheModuleID = '';
8081
+	private $_dataCached = false;
8082
+	private $_cacheAvailable = false;
8083
+	private $_cacheChecked = false;
8084
+	private $_cacheKey = null;
8085
+	private $_duration = 60;
8086
+	private $_cache = null;
8087 8087
 	private $_contents;
8088 8088
 	private $_state;
8089
-	private $_actions=array();
8090
-	private $_varyByParam='';
8091
-	private $_keyPrefix='';
8092
-	private $_varyBySession=false;
8093
-	private $_cachePostBack=false;
8094
-	private $_cacheTime=0;
8089
+	private $_actions = array();
8090
+	private $_varyByParam = '';
8091
+	private $_keyPrefix = '';
8092
+	private $_varyBySession = false;
8093
+	private $_cachePostBack = false;
8094
+	private $_cacheTime = 0;
8095 8095
 	public function getAllowChildControls()
8096 8096
 	{
8097 8097
 		$this->determineCacheability();
@@ -8099,43 +8099,43 @@  discard block
 block discarded – undo
8099 8099
 	}
8100 8100
 	private function determineCacheability()
8101 8101
 	{
8102
-		if(!$this->_cacheChecked)
8102
+		if (!$this->_cacheChecked)
8103 8103
 		{
8104
-			$this->_cacheChecked=true;
8105
-			if($this->_duration>0 && ($this->_cachePostBack || !$this->getPage()->getIsPostBack()))
8104
+			$this->_cacheChecked = true;
8105
+			if ($this->_duration > 0 && ($this->_cachePostBack || !$this->getPage()->getIsPostBack()))
8106 8106
 			{
8107
-				if($this->_cacheModuleID!=='')
8107
+				if ($this->_cacheModuleID !== '')
8108 8108
 				{
8109
-					$this->_cache=$this->getApplication()->getModule($this->_cacheModuleID);
8110
-					if(!($this->_cache instanceof ICache))
8111
-						throw new TConfigurationException('outputcache_cachemoduleid_invalid',$this->_cacheModuleID);
8109
+					$this->_cache = $this->getApplication()->getModule($this->_cacheModuleID);
8110
+					if (!($this->_cache instanceof ICache))
8111
+						throw new TConfigurationException('outputcache_cachemoduleid_invalid', $this->_cacheModuleID);
8112 8112
 				}
8113 8113
 				else
8114
-					$this->_cache=$this->getApplication()->getCache();
8115
-				if($this->_cache!==null)
8114
+					$this->_cache = $this->getApplication()->getCache();
8115
+				if ($this->_cache !== null)
8116 8116
 				{
8117
-					$this->_cacheAvailable=true;
8118
-					$data=$this->_cache->get($this->getCacheKey());
8119
-					if(is_array($data))
8117
+					$this->_cacheAvailable = true;
8118
+					$data = $this->_cache->get($this->getCacheKey());
8119
+					if (is_array($data))
8120 8120
 					{
8121
-						$param=new TOutputCacheCheckDependencyEventParameter;
8122
-						$param->setCacheTime(isset($data[3])?$data[3]:0);
8121
+						$param = new TOutputCacheCheckDependencyEventParameter;
8122
+						$param->setCacheTime(isset($data[3]) ? $data[3] : 0);
8123 8123
 						$this->onCheckDependency($param);
8124
-						$this->_dataCached=$param->getIsValid();
8124
+						$this->_dataCached = $param->getIsValid();
8125 8125
 					}
8126 8126
 					else
8127
-						$this->_dataCached=false;
8128
-					if($this->_dataCached)
8129
-						list($this->_contents,$this->_state,$this->_actions,$this->_cacheTime)=$data;
8127
+						$this->_dataCached = false;
8128
+					if ($this->_dataCached)
8129
+						list($this->_contents, $this->_state, $this->_actions, $this->_cacheTime) = $data;
8130 8130
 				}
8131 8131
 			}
8132 8132
 		}
8133 8133
 	}
8134
-	protected function initRecursive($namingContainer=null)
8134
+	protected function initRecursive($namingContainer = null)
8135 8135
 	{
8136
-		if($this->_cacheAvailable && !$this->_dataCached)
8136
+		if ($this->_cacheAvailable && !$this->_dataCached)
8137 8137
 		{
8138
-			$stack=$this->getPage()->getCachingStack();
8138
+			$stack = $this->getPage()->getCachingStack();
8139 8139
 			$stack->push($this);
8140 8140
 			parent::initRecursive($namingContainer);
8141 8141
 			$stack->pop();
@@ -8145,39 +8145,39 @@  discard block
 block discarded – undo
8145 8145
 	}
8146 8146
 	protected function loadRecursive()
8147 8147
 	{
8148
-		if($this->_cacheAvailable && !$this->_dataCached)
8148
+		if ($this->_cacheAvailable && !$this->_dataCached)
8149 8149
 		{
8150
-			$stack=$this->getPage()->getCachingStack();
8150
+			$stack = $this->getPage()->getCachingStack();
8151 8151
 			$stack->push($this);
8152 8152
 			parent::loadRecursive();
8153 8153
 			$stack->pop();
8154 8154
 		}
8155 8155
 		else
8156 8156
 		{
8157
-			if($this->_dataCached)
8157
+			if ($this->_dataCached)
8158 8158
 				$this->performActions();
8159 8159
 			parent::loadRecursive();
8160 8160
 		}
8161 8161
 	}
8162 8162
 	private function performActions()
8163 8163
 	{
8164
-		$page=$this->getPage();
8165
-		$cs=$page->getClientScript();
8166
-		foreach($this->_actions as $action)
8164
+		$page = $this->getPage();
8165
+		$cs = $page->getClientScript();
8166
+		foreach ($this->_actions as $action)
8167 8167
 		{
8168
-			if($action[0]==='Page.ClientScript')
8169
-				call_user_func_array(array($cs,$action[1]),$action[2]);
8170
-			else if($action[0]==='Page')
8171
-				call_user_func_array(array($page,$action[1]),$action[2]);
8168
+			if ($action[0] === 'Page.ClientScript')
8169
+				call_user_func_array(array($cs, $action[1]), $action[2]);
8170
+			else if ($action[0] === 'Page')
8171
+				call_user_func_array(array($page, $action[1]), $action[2]);
8172 8172
 			else
8173
-				call_user_func_array(array($this->getSubProperty($action[0]),$action[1]),$action[2]);
8173
+				call_user_func_array(array($this->getSubProperty($action[0]), $action[1]), $action[2]);
8174 8174
 		}
8175 8175
 	}
8176 8176
 	protected function preRenderRecursive()
8177 8177
 	{
8178
-		if($this->_cacheAvailable && !$this->_dataCached)
8178
+		if ($this->_cacheAvailable && !$this->_dataCached)
8179 8179
 		{
8180
-			$stack=$this->getPage()->getCachingStack();
8180
+			$stack = $this->getPage()->getCachingStack();
8181 8181
 			$stack->push($this);
8182 8182
 			parent::preRenderRecursive();
8183 8183
 			$stack->pop();
@@ -8185,56 +8185,56 @@  discard block
 block discarded – undo
8185 8185
 		else
8186 8186
 			parent::preRenderRecursive();
8187 8187
 	}
8188
-	protected function loadStateRecursive(&$state,$needViewState=true)
8188
+	protected function loadStateRecursive(&$state, $needViewState = true)
8189 8189
 	{
8190
-		$st=unserialize($state);
8191
-		parent::loadStateRecursive($st,$needViewState);
8190
+		$st = unserialize($state);
8191
+		parent::loadStateRecursive($st, $needViewState);
8192 8192
 	}
8193
-	protected function &saveStateRecursive($needViewState=true)
8193
+	protected function &saveStateRecursive($needViewState = true)
8194 8194
 	{
8195
-		if($this->_dataCached)
8195
+		if ($this->_dataCached)
8196 8196
 			return $this->_state;
8197 8197
 		else
8198 8198
 		{
8199
-			$st=parent::saveStateRecursive($needViewState);
8200
-						$this->_state=serialize($st);
8199
+			$st = parent::saveStateRecursive($needViewState);
8200
+						$this->_state = serialize($st);
8201 8201
 			return $this->_state;
8202 8202
 		}
8203 8203
 	}
8204
-	public function registerAction($context,$funcName,$funcParams)
8204
+	public function registerAction($context, $funcName, $funcParams)
8205 8205
 	{
8206
-		$this->_actions[]=array($context,$funcName,$funcParams);
8206
+		$this->_actions[] = array($context, $funcName, $funcParams);
8207 8207
 	}
8208 8208
 	public function getCacheKey()
8209 8209
 	{
8210
-		if($this->_cacheKey===null)
8211
-			$this->_cacheKey=$this->calculateCacheKey();
8210
+		if ($this->_cacheKey === null)
8211
+			$this->_cacheKey = $this->calculateCacheKey();
8212 8212
 		return $this->_cacheKey;
8213 8213
 	}
8214 8214
 	protected function calculateCacheKey()
8215 8215
 	{
8216
-		$key=$this->getBaseCacheKey();
8217
-		if($this->_varyBySession)
8218
-			$key.=$this->getSession()->getSessionID();
8219
-		if($this->_varyByParam!=='')
8216
+		$key = $this->getBaseCacheKey();
8217
+		if ($this->_varyBySession)
8218
+			$key .= $this->getSession()->getSessionID();
8219
+		if ($this->_varyByParam !== '')
8220 8220
 		{
8221
-			$params=array();
8222
-			$request=$this->getRequest();
8223
-			foreach(explode(',',$this->_varyByParam) as $name)
8221
+			$params = array();
8222
+			$request = $this->getRequest();
8223
+			foreach (explode(',', $this->_varyByParam) as $name)
8224 8224
 			{
8225
-				$name=trim($name);
8226
-				$params[$name]=$request->itemAt($name);
8225
+				$name = trim($name);
8226
+				$params[$name] = $request->itemAt($name);
8227 8227
 			}
8228
-			$key.=serialize($params);
8228
+			$key .= serialize($params);
8229 8229
 		}
8230
-		$param=new TOutputCacheCalculateKeyEventParameter;
8230
+		$param = new TOutputCacheCalculateKeyEventParameter;
8231 8231
 		$this->onCalculateKey($param);
8232
-		$key.=$param->getCacheKey();
8232
+		$key .= $param->getCacheKey();
8233 8233
 		return $key;
8234 8234
 	}
8235 8235
 	protected function getBaseCacheKey()
8236 8236
 	{
8237
-		return self::CACHE_ID_PREFIX.$this->_keyPrefix.$this->getPage()->getPagePath().$this->getUniqueID();
8237
+		return self::CACHE_ID_PREFIX . $this->_keyPrefix . $this->getPage()->getPagePath() . $this->getUniqueID();
8238 8238
 	}
8239 8239
 	public function getCacheModuleID()
8240 8240
 	{
@@ -8242,11 +8242,11 @@  discard block
 block discarded – undo
8242 8242
 	}
8243 8243
 	public function setCacheModuleID($value)
8244 8244
 	{
8245
-		$this->_cacheModuleID=$value;
8245
+		$this->_cacheModuleID = $value;
8246 8246
 	}
8247 8247
 	public function setCacheKeyPrefix($value)
8248 8248
 	{
8249
-		$this->_keyPrefix=$value;
8249
+		$this->_keyPrefix = $value;
8250 8250
 	}
8251 8251
 	public function getCacheTime()
8252 8252
 	{
@@ -8266,9 +8266,9 @@  discard block
 block discarded – undo
8266 8266
 	}
8267 8267
 	public function setDuration($value)
8268 8268
 	{
8269
-		if(($value=TPropertyValue::ensureInteger($value))<0)
8270
-			throw new TInvalidDataValueException('outputcache_duration_invalid',get_class($this));
8271
-		$this->_duration=$value;
8269
+		if (($value = TPropertyValue::ensureInteger($value)) < 0)
8270
+			throw new TInvalidDataValueException('outputcache_duration_invalid', get_class($this));
8271
+		$this->_duration = $value;
8272 8272
 	}
8273 8273
 	public function getVaryByParam()
8274 8274
 	{
@@ -8276,7 +8276,7 @@  discard block
 block discarded – undo
8276 8276
 	}
8277 8277
 	public function setVaryByParam($value)
8278 8278
 	{
8279
-		$this->_varyByParam=trim($value);
8279
+		$this->_varyByParam = trim($value);
8280 8280
 	}
8281 8281
 	public function getVaryBySession()
8282 8282
 	{
@@ -8284,7 +8284,7 @@  discard block
 block discarded – undo
8284 8284
 	}
8285 8285
 	public function setVaryBySession($value)
8286 8286
 	{
8287
-		$this->_varyBySession=TPropertyValue::ensureBoolean($value);
8287
+		$this->_varyBySession = TPropertyValue::ensureBoolean($value);
8288 8288
 	}
8289 8289
 	public function getCachingPostBack()
8290 8290
 	{
@@ -8292,32 +8292,32 @@  discard block
 block discarded – undo
8292 8292
 	}
8293 8293
 	public function setCachingPostBack($value)
8294 8294
 	{
8295
-		$this->_cachePostBack=TPropertyValue::ensureBoolean($value);
8295
+		$this->_cachePostBack = TPropertyValue::ensureBoolean($value);
8296 8296
 	}
8297 8297
 	public function onCheckDependency($param)
8298 8298
 	{
8299
-		$this->raiseEvent('OnCheckDependency',$this,$param);
8299
+		$this->raiseEvent('OnCheckDependency', $this, $param);
8300 8300
 	}
8301 8301
 	public function onCalculateKey($param)
8302 8302
 	{
8303
-		$this->raiseEvent('OnCalculateKey',$this,$param);
8303
+		$this->raiseEvent('OnCalculateKey', $this, $param);
8304 8304
 	}
8305 8305
 	public function render($writer)
8306 8306
 	{
8307
-		if($this->_dataCached)
8307
+		if ($this->_dataCached)
8308 8308
 			$writer->write($this->_contents);
8309
-		else if($this->_cacheAvailable)
8309
+		else if ($this->_cacheAvailable)
8310 8310
 		{
8311 8311
 			$textwriter = new TTextWriter();
8312
-			$multiwriter = new TOutputCacheTextWriterMulti(array($writer->getWriter(),$textwriter));
8312
+			$multiwriter = new TOutputCacheTextWriterMulti(array($writer->getWriter(), $textwriter));
8313 8313
 			$htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), $multiwriter);
8314
-			$stack=$this->getPage()->getCachingStack();
8314
+			$stack = $this->getPage()->getCachingStack();
8315 8315
 			$stack->push($this);
8316 8316
 			parent::render($htmlWriter);
8317 8317
 			$stack->pop();
8318
-			$content=$textwriter->flush();
8319
-			$data=array($content,$this->_state,$this->_actions,time());
8320
-			$this->_cache->set($this->getCacheKey(),$data,$this->getDuration(),$this->getCacheDependency());
8318
+			$content = $textwriter->flush();
8319
+			$data = array($content, $this->_state, $this->_actions, time());
8320
+			$this->_cache->set($this->getCacheKey(), $data, $this->getDuration(), $this->getCacheDependency());
8321 8321
 		}
8322 8322
 		else
8323 8323
 			parent::render($writer);
@@ -8325,15 +8325,15 @@  discard block
 block discarded – undo
8325 8325
 }
8326 8326
 class TOutputCacheCheckDependencyEventParameter extends TEventParameter
8327 8327
 {
8328
-	private $_isValid=true;
8329
-	private $_cacheTime=0;
8328
+	private $_isValid = true;
8329
+	private $_cacheTime = 0;
8330 8330
 	public function getIsValid()
8331 8331
 	{
8332 8332
 		return $this->_isValid;
8333 8333
 	}
8334 8334
 	public function setIsValid($value)
8335 8335
 	{
8336
-		$this->_isValid=TPropertyValue::ensureBoolean($value);
8336
+		$this->_isValid = TPropertyValue::ensureBoolean($value);
8337 8337
 	}
8338 8338
 	public function getCacheTime()
8339 8339
 	{
@@ -8341,19 +8341,19 @@  discard block
 block discarded – undo
8341 8341
 	}
8342 8342
 	public function setCacheTime($value)
8343 8343
 	{
8344
-		$this->_cacheTime=TPropertyValue::ensureInteger($value);
8344
+		$this->_cacheTime = TPropertyValue::ensureInteger($value);
8345 8345
 	}
8346 8346
 }
8347 8347
 class TOutputCacheCalculateKeyEventParameter extends TEventParameter
8348 8348
 {
8349
-	private $_cacheKey='';
8349
+	private $_cacheKey = '';
8350 8350
 	public function getCacheKey()
8351 8351
 	{
8352 8352
 		return $this->_cacheKey;
8353 8353
 	}
8354 8354
 	public function setCacheKey($value)
8355 8355
 	{
8356
-		$this->_cacheKey=TPropertyValue::ensureString($value);
8356
+		$this->_cacheKey = TPropertyValue::ensureString($value);
8357 8357
 	}
8358 8358
 }
8359 8359
 class TOutputCacheTextWriterMulti extends TTextWriter
@@ -8365,63 +8365,63 @@  discard block
 block discarded – undo
8365 8365
 	}
8366 8366
 	public function write($s)
8367 8367
 	{
8368
-		foreach($this->_writers as $writer)
8368
+		foreach ($this->_writers as $writer)
8369 8369
 			$writer->write($s);
8370 8370
 	}
8371 8371
 	public function flush()
8372 8372
 	{
8373
-		foreach($this->_writers as $writer)
8373
+		foreach ($this->_writers as $writer)
8374 8374
 			$s = $writer->flush();
8375 8375
 		return $s;
8376 8376
 	}
8377 8377
 }
8378 8378
 class TTemplateManager extends TModule
8379 8379
 {
8380
-	const TEMPLATE_FILE_EXT='.tpl';
8381
-	const TEMPLATE_CACHE_PREFIX='prado:template:';
8380
+	const TEMPLATE_FILE_EXT = '.tpl';
8381
+	const TEMPLATE_CACHE_PREFIX = 'prado:template:';
8382 8382
 	public function init($config)
8383 8383
 	{
8384 8384
 		$this->getService()->setTemplateManager($this);
8385 8385
 	}
8386 8386
 	public function getTemplateByClassName($className)
8387 8387
 	{
8388
-		$class=new ReflectionClass($className);
8389
-		$tplFile=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$className.self::TEMPLATE_FILE_EXT;
8388
+		$class = new ReflectionClass($className);
8389
+		$tplFile = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $className . self::TEMPLATE_FILE_EXT;
8390 8390
 		return $this->getTemplateByFileName($tplFile);
8391 8391
 	}
8392 8392
 	public function getTemplateByFileName($fileName)
8393 8393
 	{
8394
-		if(($fileName=$this->getLocalizedTemplate($fileName))!==null)
8394
+		if (($fileName = $this->getLocalizedTemplate($fileName)) !== null)
8395 8395
 		{
8396
-			if(($cache=$this->getApplication()->getCache())===null)
8397
-				return new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName);
8396
+			if (($cache = $this->getApplication()->getCache()) === null)
8397
+				return new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName);
8398 8398
 			else
8399 8399
 			{
8400
-				$array=$cache->get(self::TEMPLATE_CACHE_PREFIX.$fileName);
8401
-				if(is_array($array))
8400
+				$array = $cache->get(self::TEMPLATE_CACHE_PREFIX . $fileName);
8401
+				if (is_array($array))
8402 8402
 				{
8403
-					list($template,$timestamps)=$array;
8404
-					if($this->getApplication()->getMode()===TApplicationMode::Performance)
8403
+					list($template, $timestamps) = $array;
8404
+					if ($this->getApplication()->getMode() === TApplicationMode::Performance)
8405 8405
 						return $template;
8406
-					$cacheValid=true;
8407
-					foreach($timestamps as $tplFile=>$timestamp)
8406
+					$cacheValid = true;
8407
+					foreach ($timestamps as $tplFile=>$timestamp)
8408 8408
 					{
8409
-						if(!is_file($tplFile) || filemtime($tplFile)>$timestamp)
8409
+						if (!is_file($tplFile) || filemtime($tplFile) > $timestamp)
8410 8410
 						{
8411
-							$cacheValid=false;
8411
+							$cacheValid = false;
8412 8412
 							break;
8413 8413
 						}
8414 8414
 					}
8415
-					if($cacheValid)
8415
+					if ($cacheValid)
8416 8416
 						return $template;
8417 8417
 				}
8418
-				$template=new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName);
8419
-				$includedFiles=$template->getIncludedFiles();
8420
-				$timestamps=array();
8421
-				$timestamps[$fileName]=filemtime($fileName);
8422
-				foreach($includedFiles as $includedFile)
8423
-					$timestamps[$includedFile]=filemtime($includedFile);
8424
-				$cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName,array($template,$timestamps));
8418
+				$template = new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName);
8419
+				$includedFiles = $template->getIncludedFiles();
8420
+				$timestamps = array();
8421
+				$timestamps[$fileName] = filemtime($fileName);
8422
+				foreach ($includedFiles as $includedFile)
8423
+					$timestamps[$includedFile] = filemtime($includedFile);
8424
+				$cache->set(self::TEMPLATE_CACHE_PREFIX . $fileName, array($template, $timestamps));
8425 8425
 				return $template;
8426 8426
 			}
8427 8427
 		}
@@ -8430,11 +8430,11 @@  discard block
 block discarded – undo
8430 8430
 	}
8431 8431
 	protected function getLocalizedTemplate($filename)
8432 8432
 	{
8433
-		if(($app=$this->getApplication()->getGlobalization(false))===null)
8434
-			return is_file($filename)?$filename:null;
8435
-		foreach($app->getLocalizedResource($filename) as $file)
8433
+		if (($app = $this->getApplication()->getGlobalization(false)) === null)
8434
+			return is_file($filename) ? $filename : null;
8435
+		foreach ($app->getLocalizedResource($filename) as $file)
8436 8436
 		{
8437
-			if(($file=realpath($file))!==false && is_file($file))
8437
+			if (($file = realpath($file)) !== false && is_file($file))
8438 8438
 				return $file;
8439 8439
 		}
8440 8440
 		return null;
@@ -8442,35 +8442,35 @@  discard block
 block discarded – undo
8442 8442
 }
8443 8443
 class TTemplate extends TApplicationComponent implements ITemplate
8444 8444
 {
8445
-	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';
8446
-	const CONFIG_DATABIND=0;
8447
-	const CONFIG_EXPRESSION=1;
8448
-	const CONFIG_ASSET=2;
8449
-	const CONFIG_PARAMETER=3;
8450
-	const CONFIG_LOCALIZATION=4;
8451
-	const CONFIG_TEMPLATE=5;
8452
-	private $_tpl=array();
8453
-	private $_directive=array();
8445
+	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';
8446
+	const CONFIG_DATABIND = 0;
8447
+	const CONFIG_EXPRESSION = 1;
8448
+	const CONFIG_ASSET = 2;
8449
+	const CONFIG_PARAMETER = 3;
8450
+	const CONFIG_LOCALIZATION = 4;
8451
+	const CONFIG_TEMPLATE = 5;
8452
+	private $_tpl = array();
8453
+	private $_directive = array();
8454 8454
 	private $_contextPath;
8455
-	private $_tplFile=null;
8456
-	private $_startingLine=0;
8455
+	private $_tplFile = null;
8456
+	private $_startingLine = 0;
8457 8457
 	private $_content;
8458
-	private $_sourceTemplate=true;
8459
-	private $_hashCode='';
8460
-	private $_tplControl=null;
8461
-	private $_includedFiles=array();
8462
-	private $_includeAtLine=array();
8463
-	private $_includeLines=array();
8464
-	public function __construct($template,$contextPath,$tplFile=null,$startingLine=0,$sourceTemplate=true)
8465
-	{
8466
-		$this->_sourceTemplate=$sourceTemplate;
8467
-		$this->_contextPath=$contextPath;
8468
-		$this->_tplFile=$tplFile;
8469
-		$this->_startingLine=$startingLine;
8470
-		$this->_content=$template;
8471
-		$this->_hashCode=md5($template);
8458
+	private $_sourceTemplate = true;
8459
+	private $_hashCode = '';
8460
+	private $_tplControl = null;
8461
+	private $_includedFiles = array();
8462
+	private $_includeAtLine = array();
8463
+	private $_includeLines = array();
8464
+	public function __construct($template, $contextPath, $tplFile = null, $startingLine = 0, $sourceTemplate = true)
8465
+	{
8466
+		$this->_sourceTemplate = $sourceTemplate;
8467
+		$this->_contextPath = $contextPath;
8468
+		$this->_tplFile = $tplFile;
8469
+		$this->_startingLine = $startingLine;
8470
+		$this->_content = $template;
8471
+		$this->_hashCode = md5($template);
8472 8472
 		$this->parse($template);
8473
-		$this->_content=null; 	}
8473
+		$this->_content = null; }
8474 8474
 	public function getTemplateFile()
8475 8475
 	{
8476 8476
 		return $this->_tplFile;
@@ -8495,40 +8495,40 @@  discard block
 block discarded – undo
8495 8495
 	{
8496 8496
 		return $this->_tpl;
8497 8497
 	}
8498
-	public function instantiateIn($tplControl,$parentControl=null)
8499
-	{
8500
-		$this->_tplControl=$tplControl;
8501
-		if($parentControl===null)
8502
-			$parentControl=$tplControl;
8503
-		if(($page=$tplControl->getPage())===null)
8504
-			$page=$this->getService()->getRequestedPage();
8505
-		$controls=array();
8506
-		$directChildren=array();
8507
-		foreach($this->_tpl as $key=>$object)
8508
-		{
8509
-			if($object[0]===-1)
8510
-				$parent=$parentControl;
8511
-			else if(isset($controls[$object[0]]))
8512
-				$parent=$controls[$object[0]];
8498
+	public function instantiateIn($tplControl, $parentControl = null)
8499
+	{
8500
+		$this->_tplControl = $tplControl;
8501
+		if ($parentControl === null)
8502
+			$parentControl = $tplControl;
8503
+		if (($page = $tplControl->getPage()) === null)
8504
+			$page = $this->getService()->getRequestedPage();
8505
+		$controls = array();
8506
+		$directChildren = array();
8507
+		foreach ($this->_tpl as $key=>$object)
8508
+		{
8509
+			if ($object[0] === -1)
8510
+				$parent = $parentControl;
8511
+			else if (isset($controls[$object[0]]))
8512
+				$parent = $controls[$object[0]];
8513 8513
 			else
8514 8514
 				continue;
8515
-			if(isset($object[2]))				{
8516
-				$component=Prado::createComponent($object[1]);
8517
-				$properties=&$object[2];
8518
-				if($component instanceof TControl)
8515
+			if (isset($object[2])) {
8516
+				$component = Prado::createComponent($object[1]);
8517
+				$properties = &$object[2];
8518
+				if ($component instanceof TControl)
8519 8519
 				{
8520
-					if($component instanceof TOutputCache)
8521
-						$component->setCacheKeyPrefix($this->_hashCode.$key);
8520
+					if ($component instanceof TOutputCache)
8521
+						$component->setCacheKeyPrefix($this->_hashCode . $key);
8522 8522
 					$component->setTemplateControl($tplControl);
8523
-					if(isset($properties['id']))
8523
+					if (isset($properties['id']))
8524 8524
 					{
8525
-						if(is_array($properties['id']))
8526
-							$properties['id']=$component->evaluateExpression($properties['id'][1]);
8527
-						$tplControl->registerObject($properties['id'],$component);
8525
+						if (is_array($properties['id']))
8526
+							$properties['id'] = $component->evaluateExpression($properties['id'][1]);
8527
+						$tplControl->registerObject($properties['id'], $component);
8528 8528
 					}
8529
-					if(isset($properties['skinid']))
8529
+					if (isset($properties['skinid']))
8530 8530
 					{
8531
-						if(is_array($properties['skinid']))
8531
+						if (is_array($properties['skinid']))
8532 8532
 							$component->setSkinID($component->evaluateExpression($properties['skinid'][1]));
8533 8533
 						else
8534 8534
 							$component->setSkinID($properties['skinid']);
@@ -8536,558 +8536,558 @@  discard block
 block discarded – undo
8536 8536
 					}
8537 8537
 					$component->trackViewState(false);
8538 8538
 					$component->applyStyleSheetSkin($page);
8539
-					foreach($properties as $name=>$value)
8540
-						$this->configureControl($component,$name,$value);
8539
+					foreach ($properties as $name=>$value)
8540
+						$this->configureControl($component, $name, $value);
8541 8541
 					$component->trackViewState(true);
8542
-					if($parent===$parentControl)
8543
-						$directChildren[]=$component;
8542
+					if ($parent === $parentControl)
8543
+						$directChildren[] = $component;
8544 8544
 					else
8545 8545
 						$component->createdOnTemplate($parent);
8546
-					if($component->getAllowChildControls())
8547
-						$controls[$key]=$component;
8546
+					if ($component->getAllowChildControls())
8547
+						$controls[$key] = $component;
8548 8548
 				}
8549
-				else if($component instanceof TComponent)
8549
+				else if ($component instanceof TComponent)
8550 8550
 				{
8551
-					$controls[$key]=$component;
8552
-					if(isset($properties['id']))
8551
+					$controls[$key] = $component;
8552
+					if (isset($properties['id']))
8553 8553
 					{
8554
-						if(is_array($properties['id']))
8555
-							$properties['id']=$component->evaluateExpression($properties['id'][1]);
8556
-						$tplControl->registerObject($properties['id'],$component);
8557
-						if(!$component->hasProperty('id'))
8554
+						if (is_array($properties['id']))
8555
+							$properties['id'] = $component->evaluateExpression($properties['id'][1]);
8556
+						$tplControl->registerObject($properties['id'], $component);
8557
+						if (!$component->hasProperty('id'))
8558 8558
 							unset($properties['id']);
8559 8559
 					}
8560
-					foreach($properties as $name=>$value)
8561
-						$this->configureComponent($component,$name,$value);
8562
-					if($parent===$parentControl)
8563
-						$directChildren[]=$component;
8560
+					foreach ($properties as $name=>$value)
8561
+						$this->configureComponent($component, $name, $value);
8562
+					if ($parent === $parentControl)
8563
+						$directChildren[] = $component;
8564 8564
 					else
8565 8565
 						$component->createdOnTemplate($parent);
8566 8566
 				}
8567 8567
 			}
8568 8568
 			else
8569 8569
 			{
8570
-				if($object[1] instanceof TCompositeLiteral)
8570
+				if ($object[1] instanceof TCompositeLiteral)
8571 8571
 				{
8572
-										$o=clone $object[1];
8572
+										$o = clone $object[1];
8573 8573
 					$o->setContainer($tplControl);
8574
-					if($parent===$parentControl)
8575
-						$directChildren[]=$o;
8574
+					if ($parent === $parentControl)
8575
+						$directChildren[] = $o;
8576 8576
 					else
8577 8577
 						$parent->addParsedObject($o);
8578 8578
 				}
8579 8579
 				else
8580 8580
 				{
8581
-					if($parent===$parentControl)
8582
-						$directChildren[]=$object[1];
8581
+					if ($parent === $parentControl)
8582
+						$directChildren[] = $object[1];
8583 8583
 					else
8584 8584
 						$parent->addParsedObject($object[1]);
8585 8585
 				}
8586 8586
 			}
8587 8587
 		}
8588
-								foreach($directChildren as $control)
8588
+								foreach ($directChildren as $control)
8589 8589
 		{
8590
-			if($control instanceof TComponent)
8590
+			if ($control instanceof TComponent)
8591 8591
 				$control->createdOnTemplate($parentControl);
8592 8592
 			else
8593 8593
 				$parentControl->addParsedObject($control);
8594 8594
 		}
8595 8595
 	}
8596
-	protected function configureControl($control,$name,$value)
8596
+	protected function configureControl($control, $name, $value)
8597 8597
 	{
8598
-		if(strncasecmp($name,'on',2)===0)					$this->configureEvent($control,$name,$value,$control);
8599
-		else if(($pos=strrpos($name,'.'))===false)				$this->configureProperty($control,$name,$value);
8600
-		else				$this->configureSubProperty($control,$name,$value);
8598
+		if (strncasecmp($name, 'on', 2) === 0)					$this->configureEvent($control, $name, $value, $control);
8599
+		else if (($pos = strrpos($name, '.')) === false)				$this->configureProperty($control, $name, $value);
8600
+		else				$this->configureSubProperty($control, $name, $value);
8601 8601
 	}
8602
-	protected function configureComponent($component,$name,$value)
8602
+	protected function configureComponent($component, $name, $value)
8603 8603
 	{
8604
-		if(strpos($name,'.')===false)				$this->configureProperty($component,$name,$value);
8605
-		else				$this->configureSubProperty($component,$name,$value);
8604
+		if (strpos($name, '.') === false)				$this->configureProperty($component, $name, $value);
8605
+		else				$this->configureSubProperty($component, $name, $value);
8606 8606
 	}
8607
-	protected function configureEvent($control,$name,$value,$contextControl)
8607
+	protected function configureEvent($control, $name, $value, $contextControl)
8608 8608
 	{
8609
-		if(strpos($value,'.')===false)
8610
-			$control->attachEventHandler($name,array($contextControl,'TemplateControl.'.$value));
8609
+		if (strpos($value, '.') === false)
8610
+			$control->attachEventHandler($name, array($contextControl, 'TemplateControl.' . $value));
8611 8611
 		else
8612
-			$control->attachEventHandler($name,array($contextControl,$value));
8612
+			$control->attachEventHandler($name, array($contextControl, $value));
8613 8613
 	}
8614
-	protected function configureProperty($component,$name,$value)
8614
+	protected function configureProperty($component, $name, $value)
8615 8615
 	{
8616
-		if(is_array($value))
8616
+		if (is_array($value))
8617 8617
 		{
8618
-			switch($value[0])
8618
+			switch ($value[0])
8619 8619
 			{
8620 8620
 				case self::CONFIG_DATABIND:
8621
-					$component->bindProperty($name,$value[1]);
8621
+					$component->bindProperty($name, $value[1]);
8622 8622
 					break;
8623 8623
 				case self::CONFIG_EXPRESSION:
8624
-					if($component instanceof TControl)
8625
-						$component->autoBindProperty($name,$value[1]);
8624
+					if ($component instanceof TControl)
8625
+						$component->autoBindProperty($name, $value[1]);
8626 8626
 					else
8627 8627
 					{
8628
-						$setter='set'.$name;
8628
+						$setter = 'set' . $name;
8629 8629
 						$component->$setter($this->_tplControl->evaluateExpression($value[1]));
8630 8630
 					}
8631 8631
 					break;
8632 8632
 				case self::CONFIG_TEMPLATE:
8633
-					$setter='set'.$name;
8633
+					$setter = 'set' . $name;
8634 8634
 					$component->$setter($value[1]);
8635 8635
 					break;
8636
-				case self::CONFIG_ASSET:							$setter='set'.$name;
8637
-					$url=$this->publishFilePath($this->_contextPath.DIRECTORY_SEPARATOR.$value[1]);
8636
+				case self::CONFIG_ASSET:							$setter = 'set' . $name;
8637
+					$url = $this->publishFilePath($this->_contextPath . DIRECTORY_SEPARATOR . $value[1]);
8638 8638
 					$component->$setter($url);
8639 8639
 					break;
8640
-				case self::CONFIG_PARAMETER:							$setter='set'.$name;
8640
+				case self::CONFIG_PARAMETER:							$setter = 'set' . $name;
8641 8641
 					$component->$setter($this->getApplication()->getParameters()->itemAt($value[1]));
8642 8642
 					break;
8643 8643
 				case self::CONFIG_LOCALIZATION:
8644
-					$setter='set'.$name;
8644
+					$setter = 'set' . $name;
8645 8645
 					$component->$setter(Prado::localize($value[1]));
8646 8646
 					break;
8647
-				default:						throw new TConfigurationException('template_tag_unexpected',$name,$value[1]);
8647
+				default:						throw new TConfigurationException('template_tag_unexpected', $name, $value[1]);
8648 8648
 					break;
8649 8649
 			}
8650 8650
 		}
8651 8651
 		else
8652 8652
 		{
8653
-			if (substr($name,0,2)=='js')
8653
+			if (substr($name, 0, 2) == 'js')
8654 8654
 				if ($value and !($value instanceof TJavaScriptLiteral))
8655 8655
 					$value = new TJavaScriptLiteral($value);
8656
-			$setter='set'.$name;
8656
+			$setter = 'set' . $name;
8657 8657
 			$component->$setter($value);
8658 8658
 		}
8659 8659
 	}
8660
-	protected function configureSubProperty($component,$name,$value)
8660
+	protected function configureSubProperty($component, $name, $value)
8661 8661
 	{
8662
-		if(is_array($value))
8662
+		if (is_array($value))
8663 8663
 		{
8664
-			switch($value[0])
8664
+			switch ($value[0])
8665 8665
 			{
8666
-				case self::CONFIG_DATABIND:							$component->bindProperty($name,$value[1]);
8666
+				case self::CONFIG_DATABIND:							$component->bindProperty($name, $value[1]);
8667 8667
 					break;
8668
-				case self::CONFIG_EXPRESSION:							if($component instanceof TControl)
8669
-						$component->autoBindProperty($name,$value[1]);
8668
+				case self::CONFIG_EXPRESSION:							if ($component instanceof TControl)
8669
+						$component->autoBindProperty($name, $value[1]);
8670 8670
 					else
8671
-						$component->setSubProperty($name,$this->_tplControl->evaluateExpression($value[1]));
8671
+						$component->setSubProperty($name, $this->_tplControl->evaluateExpression($value[1]));
8672 8672
 					break;
8673 8673
 				case self::CONFIG_TEMPLATE:
8674
-					$component->setSubProperty($name,$value[1]);
8674
+					$component->setSubProperty($name, $value[1]);
8675 8675
 					break;
8676
-				case self::CONFIG_ASSET:							$url=$this->publishFilePath($this->_contextPath.DIRECTORY_SEPARATOR.$value[1]);
8677
-					$component->setSubProperty($name,$url);
8676
+				case self::CONFIG_ASSET:							$url = $this->publishFilePath($this->_contextPath . DIRECTORY_SEPARATOR . $value[1]);
8677
+					$component->setSubProperty($name, $url);
8678 8678
 					break;
8679
-				case self::CONFIG_PARAMETER:							$component->setSubProperty($name,$this->getApplication()->getParameters()->itemAt($value[1]));
8679
+				case self::CONFIG_PARAMETER:							$component->setSubProperty($name, $this->getApplication()->getParameters()->itemAt($value[1]));
8680 8680
 					break;
8681 8681
 				case self::CONFIG_LOCALIZATION:
8682
-					$component->setSubProperty($name,Prado::localize($value[1]));
8682
+					$component->setSubProperty($name, Prado::localize($value[1]));
8683 8683
 					break;
8684
-				default:						throw new TConfigurationException('template_tag_unexpected',$name,$value[1]);
8684
+				default:						throw new TConfigurationException('template_tag_unexpected', $name, $value[1]);
8685 8685
 					break;
8686 8686
 			}
8687 8687
 		}
8688 8688
 		else
8689
-			$component->setSubProperty($name,$value);
8689
+			$component->setSubProperty($name, $value);
8690 8690
 	}
8691 8691
 	protected function parse($input)
8692 8692
 	{
8693
-		$input=$this->preprocess($input);
8694
-		$tpl=&$this->_tpl;
8695
-		$n=preg_match_all(self::REGEX_RULES,$input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
8696
-		$expectPropEnd=false;
8697
-		$textStart=0;
8698
-				$stack=array();
8699
-		$container=-1;
8700
-		$matchEnd=0;
8701
-		$c=0;
8702
-		$this->_directive=null;
8693
+		$input = $this->preprocess($input);
8694
+		$tpl = &$this->_tpl;
8695
+		$n = preg_match_all(self::REGEX_RULES, $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
8696
+		$expectPropEnd = false;
8697
+		$textStart = 0;
8698
+				$stack = array();
8699
+		$container = -1;
8700
+		$matchEnd = 0;
8701
+		$c = 0;
8702
+		$this->_directive = null;
8703 8703
 		try
8704 8704
 		{
8705
-			for($i=0;$i<$n;++$i)
8705
+			for ($i = 0; $i < $n; ++$i)
8706 8706
 			{
8707
-				$match=&$matches[$i];
8708
-				$str=$match[0][0];
8709
-				$matchStart=$match[0][1];
8710
-				$matchEnd=$matchStart+strlen($str)-1;
8711
-				if(strpos($str,'<com:')===0)					{
8712
-					if($expectPropEnd)
8707
+				$match = &$matches[$i];
8708
+				$str = $match[0][0];
8709
+				$matchStart = $match[0][1];
8710
+				$matchEnd = $matchStart + strlen($str) - 1;
8711
+				if (strpos($str, '<com:') === 0) {
8712
+					if ($expectPropEnd)
8713 8713
 						continue;
8714
-					if($matchStart>$textStart)
8715
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
8716
-					$textStart=$matchEnd+1;
8717
-					$type=$match[1][0];
8718
-					$attributes=$this->parseAttributes($match[2][0],$match[2][1]);
8719
-					$this->validateAttributes($type,$attributes);
8720
-					$tpl[$c++]=array($container,$type,$attributes);
8721
-					if($str[strlen($str)-2]!=='/')  					{
8714
+					if ($matchStart > $textStart)
8715
+						$tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart));
8716
+					$textStart = $matchEnd + 1;
8717
+					$type = $match[1][0];
8718
+					$attributes = $this->parseAttributes($match[2][0], $match[2][1]);
8719
+					$this->validateAttributes($type, $attributes);
8720
+					$tpl[$c++] = array($container, $type, $attributes);
8721
+					if ($str[strlen($str) - 2] !== '/') {
8722 8722
 						$stack[] = $type;
8723
-						$container=$c-1;
8723
+						$container = $c - 1;
8724 8724
 					}
8725 8725
 				}
8726
-				else if(strpos($str,'</com:')===0)					{
8727
-					if($expectPropEnd)
8726
+				else if (strpos($str, '</com:') === 0) {
8727
+					if ($expectPropEnd)
8728 8728
 						continue;
8729
-					if($matchStart>$textStart)
8730
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
8731
-					$textStart=$matchEnd+1;
8732
-					$type=$match[1][0];
8733
-					if(empty($stack))
8734
-						throw new TConfigurationException('template_closingtag_unexpected',"</com:$type>");
8735
-					$name=array_pop($stack);
8736
-					if($name!==$type)
8729
+					if ($matchStart > $textStart)
8730
+						$tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart));
8731
+					$textStart = $matchEnd + 1;
8732
+					$type = $match[1][0];
8733
+					if (empty($stack))
8734
+						throw new TConfigurationException('template_closingtag_unexpected', "</com:$type>");
8735
+					$name = array_pop($stack);
8736
+					if ($name !== $type)
8737 8737
 					{
8738
-						$tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>";
8739
-						throw new TConfigurationException('template_closingtag_expected',$tag);
8738
+						$tag = $name[0] === '@' ? '</prop:' . substr($name, 1) . '>' : "</com:$name>";
8739
+						throw new TConfigurationException('template_closingtag_expected', $tag);
8740 8740
 					}
8741
-					$container=$tpl[$container][0];
8741
+					$container = $tpl[$container][0];
8742 8742
 				}
8743
-				else if(strpos($str,'<%@')===0)					{
8744
-					if($expectPropEnd)
8743
+				else if (strpos($str, '<%@') === 0) {
8744
+					if ($expectPropEnd)
8745 8745
 						continue;
8746
-					if($matchStart>$textStart)
8747
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
8748
-					$textStart=$matchEnd+1;
8749
-					if(isset($tpl[0]) || $this->_directive!==null)
8746
+					if ($matchStart > $textStart)
8747
+						$tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart));
8748
+					$textStart = $matchEnd + 1;
8749
+					if (isset($tpl[0]) || $this->_directive !== null)
8750 8750
 						throw new TConfigurationException('template_directive_nonunique');
8751
-					$this->_directive=$this->parseAttributes($match[4][0],$match[4][1]);
8751
+					$this->_directive = $this->parseAttributes($match[4][0], $match[4][1]);
8752 8752
 				}
8753
-				else if(strpos($str,'<%')===0)					{
8754
-					if($expectPropEnd)
8753
+				else if (strpos($str, '<%') === 0) {
8754
+					if ($expectPropEnd)
8755 8755
 						continue;
8756
-					if($matchStart>$textStart)
8757
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
8758
-					$textStart=$matchEnd+1;
8759
-					$literal=trim($match[5][0]);
8760
-					if($str[2]==='=')							$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,$literal));
8761
-					else if($str[2]==='%')  						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_STATEMENTS,$literal));
8762
-					else if($str[2]==='#')
8763
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_DATABINDING,$literal));
8764
-					else if($str[2]==='$')
8765
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')"));
8766
-					else if($str[2]==='~')
8767
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')"));
8768
-					else if($str[2]==='/')
8769
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'"));
8770
-					else if($str[2]==='[')
8756
+					if ($matchStart > $textStart)
8757
+						$tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart));
8758
+					$textStart = $matchEnd + 1;
8759
+					$literal = trim($match[5][0]);
8760
+					if ($str[2] === '=')							$tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, $literal));
8761
+					else if ($str[2] === '%')  						$tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_STATEMENTS, $literal));
8762
+					else if ($str[2] === '#')
8763
+						$tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_DATABINDING, $literal));
8764
+					else if ($str[2] === '$')
8765
+						$tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "\$this->getApplication()->getParameters()->itemAt('$literal')"));
8766
+					else if ($str[2] === '~')
8767
+						$tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "\$this->publishFilePath('$this->_contextPath/$literal')"));
8768
+					else if ($str[2] === '/')
8769
+						$tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'"));
8770
+					else if ($str[2] === '[')
8771 8771
 					{
8772
-						$literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\"));
8773
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')"));
8772
+						$literal = strtr(trim(substr($literal, 0, strlen($literal) - 1)), array("'"=>"\'", "\\"=>"\\\\"));
8773
+						$tpl[$c++] = array($container, array(TCompositeLiteral::TYPE_EXPRESSION, "Prado::localize('$literal')"));
8774 8774
 					}
8775 8775
 				}
8776
-				else if(strpos($str,'<prop:')===0)					{
8777
-					if(strrpos($str,'/>')===strlen($str)-2)  					{
8778
-						if($expectPropEnd)
8776
+				else if (strpos($str, '<prop:') === 0) {
8777
+					if (strrpos($str, '/>') === strlen($str) - 2) {
8778
+						if ($expectPropEnd)
8779 8779
 							continue;
8780
-						if($matchStart>$textStart)
8781
-							$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
8782
-						$textStart=$matchEnd+1;
8783
-						$prop=strtolower($match[6][0]);
8784
-						$attrs=$this->parseAttributes($match[7][0],$match[7][1]);
8785
-						$attributes=array();
8786
-						foreach($attrs as $name=>$value)
8787
-							$attributes[$prop.'.'.$name]=$value;
8788
-						$type=$tpl[$container][1];
8789
-						$this->validateAttributes($type,$attributes);
8790
-						foreach($attributes as $name=>$value)
8780
+						if ($matchStart > $textStart)
8781
+							$tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart));
8782
+						$textStart = $matchEnd + 1;
8783
+						$prop = strtolower($match[6][0]);
8784
+						$attrs = $this->parseAttributes($match[7][0], $match[7][1]);
8785
+						$attributes = array();
8786
+						foreach ($attrs as $name=>$value)
8787
+							$attributes[$prop . '.' . $name] = $value;
8788
+						$type = $tpl[$container][1];
8789
+						$this->validateAttributes($type, $attributes);
8790
+						foreach ($attributes as $name=>$value)
8791 8791
 						{
8792
-							if(isset($tpl[$container][2][$name]))
8793
-								throw new TConfigurationException('template_property_duplicated',$name);
8794
-							$tpl[$container][2][$name]=$value;
8792
+							if (isset($tpl[$container][2][$name]))
8793
+								throw new TConfigurationException('template_property_duplicated', $name);
8794
+							$tpl[$container][2][$name] = $value;
8795 8795
 						}
8796 8796
 					}
8797
-					else  					{
8798
-						$prop=strtolower($match[3][0]);
8799
-						$stack[] = '@'.$prop;
8800
-						if(!$expectPropEnd)
8797
+					else {
8798
+						$prop = strtolower($match[3][0]);
8799
+						$stack[] = '@' . $prop;
8800
+						if (!$expectPropEnd)
8801 8801
 						{
8802
-							if($matchStart>$textStart)
8803
-								$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
8804
-							$textStart=$matchEnd+1;
8805
-							$expectPropEnd=true;
8802
+							if ($matchStart > $textStart)
8803
+								$tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart));
8804
+							$textStart = $matchEnd + 1;
8805
+							$expectPropEnd = true;
8806 8806
 						}
8807 8807
 					}
8808 8808
 				}
8809
-				else if(strpos($str,'</prop:')===0)					{
8810
-					$prop=strtolower($match[3][0]);
8811
-					if(empty($stack))
8812
-						throw new TConfigurationException('template_closingtag_unexpected',"</prop:$prop>");
8813
-					$name=array_pop($stack);
8814
-					if($name!=='@'.$prop)
8809
+				else if (strpos($str, '</prop:') === 0) {
8810
+					$prop = strtolower($match[3][0]);
8811
+					if (empty($stack))
8812
+						throw new TConfigurationException('template_closingtag_unexpected', "</prop:$prop>");
8813
+					$name = array_pop($stack);
8814
+					if ($name !== '@' . $prop)
8815 8815
 					{
8816
-						$tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>";
8817
-						throw new TConfigurationException('template_closingtag_expected',$tag);
8816
+						$tag = $name[0] === '@' ? '</prop:' . substr($name, 1) . '>' : "</com:$name>";
8817
+						throw new TConfigurationException('template_closingtag_expected', $tag);
8818 8818
 					}
8819
-					if(($last=count($stack))<1 || $stack[$last-1][0]!=='@')
8819
+					if (($last = count($stack)) < 1 || $stack[$last - 1][0] !== '@')
8820 8820
 					{
8821
-						if($matchStart>$textStart)
8821
+						if ($matchStart > $textStart)
8822 8822
 						{
8823
-							$value=substr($input,$textStart,$matchStart-$textStart);
8824
-							if(substr($prop,-8,8)==='template')
8825
-								$value=$this->parseTemplateProperty($value,$textStart);
8823
+							$value = substr($input, $textStart, $matchStart - $textStart);
8824
+							if (substr($prop, -8, 8) === 'template')
8825
+								$value = $this->parseTemplateProperty($value, $textStart);
8826 8826
 							else
8827
-								$value=$this->parseAttribute($value);
8828
-							if($container>=0)
8827
+								$value = $this->parseAttribute($value);
8828
+							if ($container >= 0)
8829 8829
 							{
8830
-								$type=$tpl[$container][1];
8831
-								$this->validateAttributes($type,array($prop=>$value));
8832
-								if(isset($tpl[$container][2][$prop]))
8833
-									throw new TConfigurationException('template_property_duplicated',$prop);
8834
-								$tpl[$container][2][$prop]=$value;
8830
+								$type = $tpl[$container][1];
8831
+								$this->validateAttributes($type, array($prop=>$value));
8832
+								if (isset($tpl[$container][2][$prop]))
8833
+									throw new TConfigurationException('template_property_duplicated', $prop);
8834
+								$tpl[$container][2][$prop] = $value;
8835 8835
 							}
8836
-							else									$this->_directive[$prop]=$value;
8837
-							$textStart=$matchEnd+1;
8836
+							else									$this->_directive[$prop] = $value;
8837
+							$textStart = $matchEnd + 1;
8838 8838
 						}
8839
-						$expectPropEnd=false;
8839
+						$expectPropEnd = false;
8840 8840
 					}
8841 8841
 				}
8842
-				else if(strpos($str,'<!--')===0)					{
8843
-					if($expectPropEnd)
8842
+				else if (strpos($str, '<!--') === 0) {
8843
+					if ($expectPropEnd)
8844 8844
 						throw new TConfigurationException('template_comments_forbidden');
8845
-					if($matchStart>$textStart)
8846
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
8847
-					$textStart=$matchEnd+1;
8845
+					if ($matchStart > $textStart)
8846
+						$tpl[$c++] = array($container, substr($input, $textStart, $matchStart - $textStart));
8847
+					$textStart = $matchEnd + 1;
8848 8848
 				}
8849 8849
 				else
8850
-					throw new TConfigurationException('template_matching_unexpected',$match);
8850
+					throw new TConfigurationException('template_matching_unexpected', $match);
8851 8851
 			}
8852
-			if(!empty($stack))
8852
+			if (!empty($stack))
8853 8853
 			{
8854
-				$name=array_pop($stack);
8855
-				$tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>";
8856
-				throw new TConfigurationException('template_closingtag_expected',$tag);
8854
+				$name = array_pop($stack);
8855
+				$tag = $name[0] === '@' ? '</prop:' . substr($name, 1) . '>' : "</com:$name>";
8856
+				throw new TConfigurationException('template_closingtag_expected', $tag);
8857 8857
 			}
8858
-			if($textStart<strlen($input))
8859
-				$tpl[$c++]=array($container,substr($input,$textStart));
8858
+			if ($textStart < strlen($input))
8859
+				$tpl[$c++] = array($container, substr($input, $textStart));
8860 8860
 		}
8861
-		catch(Exception $e)
8861
+		catch (Exception $e)
8862 8862
 		{
8863
-			if(($e instanceof TException) && ($e instanceof TTemplateException))
8863
+			if (($e instanceof TException) && ($e instanceof TTemplateException))
8864 8864
 				throw $e;
8865
-			if($matchEnd===0)
8866
-				$line=$this->_startingLine+1;
8865
+			if ($matchEnd === 0)
8866
+				$line = $this->_startingLine + 1;
8867 8867
 			else
8868
-				$line=$this->_startingLine+count(explode("\n",substr($input,0,$matchEnd+1)));
8869
-			$this->handleException($e,$line,$input);
8868
+				$line = $this->_startingLine + count(explode("\n", substr($input, 0, $matchEnd + 1)));
8869
+			$this->handleException($e, $line, $input);
8870 8870
 		}
8871
-		if($this->_directive===null)
8872
-			$this->_directive=array();
8873
-				$objects=array();
8874
-		$parent=null;
8875
-		$merged=array();
8876
-		foreach($tpl as $id=>$object)
8871
+		if ($this->_directive === null)
8872
+			$this->_directive = array();
8873
+				$objects = array();
8874
+		$parent = null;
8875
+		$merged = array();
8876
+		foreach ($tpl as $id=>$object)
8877 8877
 		{
8878
-			if(isset($object[2]) || $object[0]!==$parent)
8878
+			if (isset($object[2]) || $object[0] !== $parent)
8879 8879
 			{
8880
-				if($parent!==null)
8880
+				if ($parent !== null)
8881 8881
 				{
8882
-					if(count($merged[1])===1 && is_string($merged[1][0]))
8883
-						$objects[$id-1]=array($merged[0],$merged[1][0]);
8882
+					if (count($merged[1]) === 1 && is_string($merged[1][0]))
8883
+						$objects[$id - 1] = array($merged[0], $merged[1][0]);
8884 8884
 					else
8885
-						$objects[$id-1]=array($merged[0],new TCompositeLiteral($merged[1]));
8885
+						$objects[$id - 1] = array($merged[0], new TCompositeLiteral($merged[1]));
8886 8886
 				}
8887
-				if(isset($object[2]))
8887
+				if (isset($object[2]))
8888 8888
 				{
8889
-					$parent=null;
8890
-					$objects[$id]=$object;
8889
+					$parent = null;
8890
+					$objects[$id] = $object;
8891 8891
 				}
8892 8892
 				else
8893 8893
 				{
8894
-					$parent=$object[0];
8895
-					$merged=array($parent,array($object[1]));
8894
+					$parent = $object[0];
8895
+					$merged = array($parent, array($object[1]));
8896 8896
 				}
8897 8897
 			}
8898 8898
 			else
8899
-				$merged[1][]=$object[1];
8899
+				$merged[1][] = $object[1];
8900 8900
 		}
8901
-		if($parent!==null)
8901
+		if ($parent !== null)
8902 8902
 		{
8903
-			if(count($merged[1])===1 && is_string($merged[1][0]))
8904
-				$objects[$id]=array($merged[0],$merged[1][0]);
8903
+			if (count($merged[1]) === 1 && is_string($merged[1][0]))
8904
+				$objects[$id] = array($merged[0], $merged[1][0]);
8905 8905
 			else
8906
-				$objects[$id]=array($merged[0],new TCompositeLiteral($merged[1]));
8906
+				$objects[$id] = array($merged[0], new TCompositeLiteral($merged[1]));
8907 8907
 		}
8908
-		$tpl=$objects;
8908
+		$tpl = $objects;
8909 8909
 		return $objects;
8910 8910
 	}
8911
-	protected function parseAttributes($str,$offset)
8911
+	protected function parseAttributes($str, $offset)
8912 8912
 	{
8913
-		if($str==='')
8913
+		if ($str === '')
8914 8914
 			return array();
8915
-		$pattern='/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS';
8916
-		$attributes=array();
8917
-		$n=preg_match_all($pattern,$str,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
8918
-		for($i=0;$i<$n;++$i)
8919
-		{
8920
-			$match=&$matches[$i];
8921
-			$name=strtolower($match[1][0]);
8922
-			if(isset($attributes[$name]))
8923
-				throw new TConfigurationException('template_property_duplicated',$name);
8924
-			$value=$match[2][0];
8925
-			if(substr($name,-8,8)==='template')
8926
-			{
8927
-				if($value[0]==='\'' || $value[0]==='"')
8928
-					$attributes[$name]=$this->parseTemplateProperty(substr($value,1,strlen($value)-2),$match[2][1]+1);
8915
+		$pattern = '/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS';
8916
+		$attributes = array();
8917
+		$n = preg_match_all($pattern, $str, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
8918
+		for ($i = 0; $i < $n; ++$i)
8919
+		{
8920
+			$match = &$matches[$i];
8921
+			$name = strtolower($match[1][0]);
8922
+			if (isset($attributes[$name]))
8923
+				throw new TConfigurationException('template_property_duplicated', $name);
8924
+			$value = $match[2][0];
8925
+			if (substr($name, -8, 8) === 'template')
8926
+			{
8927
+				if ($value[0] === '\'' || $value[0] === '"')
8928
+					$attributes[$name] = $this->parseTemplateProperty(substr($value, 1, strlen($value) - 2), $match[2][1] + 1);
8929 8929
 				else
8930
-					$attributes[$name]=$this->parseTemplateProperty($value,$match[2][1]);
8930
+					$attributes[$name] = $this->parseTemplateProperty($value, $match[2][1]);
8931 8931
 			}
8932 8932
 			else
8933 8933
 			{
8934
-				if($value[0]==='\'' || $value[0]==='"')
8935
-					$attributes[$name]=$this->parseAttribute(substr($value,1,strlen($value)-2));
8934
+				if ($value[0] === '\'' || $value[0] === '"')
8935
+					$attributes[$name] = $this->parseAttribute(substr($value, 1, strlen($value) - 2));
8936 8936
 				else
8937
-					$attributes[$name]=$this->parseAttribute($value);
8937
+					$attributes[$name] = $this->parseAttribute($value);
8938 8938
 			}
8939 8939
 		}
8940 8940
 		return $attributes;
8941 8941
 	}
8942
-	protected function parseTemplateProperty($content,$offset)
8942
+	protected function parseTemplateProperty($content, $offset)
8943 8943
 	{
8944
-		$line=$this->_startingLine+count(explode("\n",substr($this->_content,0,$offset)))-1;
8945
-		return array(self::CONFIG_TEMPLATE,new TTemplate($content,$this->_contextPath,$this->_tplFile,$line,false));
8944
+		$line = $this->_startingLine + count(explode("\n", substr($this->_content, 0, $offset))) - 1;
8945
+		return array(self::CONFIG_TEMPLATE, new TTemplate($content, $this->_contextPath, $this->_tplFile, $line, false));
8946 8946
 	}
8947 8947
 	protected function parseAttribute($value)
8948 8948
 	{
8949
-		if(($n=preg_match_all('/<%[#=].*?%>/msS',$value,$matches,PREG_OFFSET_CAPTURE))>0)
8950
-		{
8951
-			$isDataBind=false;
8952
-			$textStart=0;
8953
-			$expr='';
8954
-			for($i=0;$i<$n;++$i)
8955
-			{
8956
-				$match=$matches[0][$i];
8957
-				$token=$match[0];
8958
-				$offset=$match[1];
8959
-				$length=strlen($token);
8960
-				if($token[2]==='#')
8961
-					$isDataBind=true;
8962
-				if($offset>$textStart)
8963
-					$expr.=".'".strtr(substr($value,$textStart,$offset-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'";
8964
-				$expr.='.('.substr($token,3,$length-5).')';
8965
-				$textStart=$offset+$length;
8966
-			}
8967
-			$length=strlen($value);
8968
-			if($length>$textStart)
8969
-				$expr.=".'".strtr(substr($value,$textStart,$length-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'";
8970
-			if($isDataBind)
8971
-				return array(self::CONFIG_DATABIND,ltrim($expr,'.'));
8949
+		if (($n = preg_match_all('/<%[#=].*?%>/msS', $value, $matches, PREG_OFFSET_CAPTURE)) > 0)
8950
+		{
8951
+			$isDataBind = false;
8952
+			$textStart = 0;
8953
+			$expr = '';
8954
+			for ($i = 0; $i < $n; ++$i)
8955
+			{
8956
+				$match = $matches[0][$i];
8957
+				$token = $match[0];
8958
+				$offset = $match[1];
8959
+				$length = strlen($token);
8960
+				if ($token[2] === '#')
8961
+					$isDataBind = true;
8962
+				if ($offset > $textStart)
8963
+					$expr .= ".'" . strtr(substr($value, $textStart, $offset - $textStart), array("'"=>"\\'", "\\"=>"\\\\")) . "'";
8964
+				$expr .= '.(' . substr($token, 3, $length - 5) . ')';
8965
+				$textStart = $offset + $length;
8966
+			}
8967
+			$length = strlen($value);
8968
+			if ($length > $textStart)
8969
+				$expr .= ".'" . strtr(substr($value, $textStart, $length - $textStart), array("'"=>"\\'", "\\"=>"\\\\")) . "'";
8970
+			if ($isDataBind)
8971
+				return array(self::CONFIG_DATABIND, ltrim($expr, '.'));
8972 8972
 			else
8973
-				return array(self::CONFIG_EXPRESSION,ltrim($expr,'.'));
8973
+				return array(self::CONFIG_EXPRESSION, ltrim($expr, '.'));
8974 8974
 		}
8975
-		else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value)
8975
+		else if (preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS', $value, $matches) && $matches[0] === $value)
8976 8976
 		{
8977
-			$value=$matches[1];
8978
-			if($value[2]==='~')
8979
-				return array(self::CONFIG_ASSET,trim(substr($value,3,strlen($value)-5)));
8980
-			elseif($value[2]==='[')
8981
-				return array(self::CONFIG_LOCALIZATION,trim(substr($value,3,strlen($value)-6)));
8982
-			elseif($value[2]==='$')
8983
-				return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5)));
8984
-			elseif($value[2]==='/') {
8985
-				$literal = trim(substr($value,3,strlen($value)-5));
8986
-				return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'");
8977
+			$value = $matches[1];
8978
+			if ($value[2] === '~')
8979
+				return array(self::CONFIG_ASSET, trim(substr($value, 3, strlen($value) - 5)));
8980
+			elseif ($value[2] === '[')
8981
+				return array(self::CONFIG_LOCALIZATION, trim(substr($value, 3, strlen($value) - 6)));
8982
+			elseif ($value[2] === '$')
8983
+				return array(self::CONFIG_PARAMETER, trim(substr($value, 3, strlen($value) - 5)));
8984
+			elseif ($value[2] === '/') {
8985
+				$literal = trim(substr($value, 3, strlen($value) - 5));
8986
+				return array(self::CONFIG_EXPRESSION, "rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'");
8987 8987
 			}
8988 8988
 		}
8989 8989
 		else
8990 8990
 			return $value;
8991 8991
 	}
8992
-	protected function validateAttributes($type,$attributes)
8992
+	protected function validateAttributes($type, $attributes)
8993 8993
 	{
8994 8994
 		Prado::using($type);
8995
-		if(($pos=strrpos($type,'.'))!==false)
8996
-			$className=substr($type,$pos+1);
8995
+		if (($pos = strrpos($type, '.')) !== false)
8996
+			$className = substr($type, $pos + 1);
8997 8997
 		else
8998
-			$className=$type;
8999
-		$class=new ReflectionClass($className);
9000
-		if(is_subclass_of($className,'TControl') || $className==='TControl')
8998
+			$className = $type;
8999
+		$class = new ReflectionClass($className);
9000
+		if (is_subclass_of($className, 'TControl') || $className === 'TControl')
9001 9001
 		{
9002
-			foreach($attributes as $name=>$att)
9002
+			foreach ($attributes as $name=>$att)
9003 9003
 			{
9004
-				if(($pos=strpos($name,'.'))!==false)
9004
+				if (($pos = strpos($name, '.')) !== false)
9005 9005
 				{
9006
-										$subname=substr($name,0,$pos);
9007
-					if(!$class->hasMethod('get'.$subname))
9008
-						throw new TConfigurationException('template_property_unknown',$type,$subname);
9006
+										$subname = substr($name, 0, $pos);
9007
+					if (!$class->hasMethod('get' . $subname))
9008
+						throw new TConfigurationException('template_property_unknown', $type, $subname);
9009 9009
 				}
9010
-				else if(strncasecmp($name,'on',2)===0)
9010
+				else if (strncasecmp($name, 'on', 2) === 0)
9011 9011
 				{
9012
-										if(!$class->hasMethod($name))
9013
-						throw new TConfigurationException('template_event_unknown',$type,$name);
9014
-					else if(!is_string($att))
9015
-						throw new TConfigurationException('template_eventhandler_invalid',$type,$name);
9012
+										if (!$class->hasMethod($name))
9013
+						throw new TConfigurationException('template_event_unknown', $type, $name);
9014
+					else if (!is_string($att))
9015
+						throw new TConfigurationException('template_eventhandler_invalid', $type, $name);
9016 9016
 				}
9017 9017
 				else
9018 9018
 				{
9019
-										if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)) )
9019
+										if (!($class->hasMethod('set' . $name) || $class->hasMethod('setjs' . $name) || $this->isClassBehaviorMethod($class, 'set' . $name)))
9020 9020
 					{
9021
-						if ($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name))
9022
-							throw new TConfigurationException('template_property_readonly',$type,$name);
9021
+						if ($class->hasMethod('get' . $name) || $class->hasMethod('getjs' . $name))
9022
+							throw new TConfigurationException('template_property_readonly', $type, $name);
9023 9023
 						else
9024
-							throw new TConfigurationException('template_property_unknown',$type,$name);
9024
+							throw new TConfigurationException('template_property_unknown', $type, $name);
9025 9025
 					}
9026
-					else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION)
9026
+					else if (is_array($att) && $att[0] !== self::CONFIG_EXPRESSION)
9027 9027
 					{
9028
-						if(strcasecmp($name,'id')===0)
9029
-							throw new TConfigurationException('template_controlid_invalid',$type);
9030
-						else if(strcasecmp($name,'skinid')===0)
9031
-							throw new TConfigurationException('template_controlskinid_invalid',$type);
9028
+						if (strcasecmp($name, 'id') === 0)
9029
+							throw new TConfigurationException('template_controlid_invalid', $type);
9030
+						else if (strcasecmp($name, 'skinid') === 0)
9031
+							throw new TConfigurationException('template_controlskinid_invalid', $type);
9032 9032
 					}
9033 9033
 				}
9034 9034
 			}
9035 9035
 		}
9036
-		else if(is_subclass_of($className,'TComponent') || $className==='TComponent')
9036
+		else if (is_subclass_of($className, 'TComponent') || $className === 'TComponent')
9037 9037
 		{
9038
-			foreach($attributes as $name=>$att)
9038
+			foreach ($attributes as $name=>$att)
9039 9039
 			{
9040
-				if(is_array($att) && ($att[0]===self::CONFIG_DATABIND))
9041
-					throw new TConfigurationException('template_databind_forbidden',$type,$name);
9042
-				if(($pos=strpos($name,'.'))!==false)
9040
+				if (is_array($att) && ($att[0] === self::CONFIG_DATABIND))
9041
+					throw new TConfigurationException('template_databind_forbidden', $type, $name);
9042
+				if (($pos = strpos($name, '.')) !== false)
9043 9043
 				{
9044
-										$subname=substr($name,0,$pos);
9045
-					if(!$class->hasMethod('get'.$subname))
9046
-						throw new TConfigurationException('template_property_unknown',$type,$subname);
9044
+										$subname = substr($name, 0, $pos);
9045
+					if (!$class->hasMethod('get' . $subname))
9046
+						throw new TConfigurationException('template_property_unknown', $type, $subname);
9047 9047
 				}
9048
-				else if(strncasecmp($name,'on',2)===0)
9049
-					throw new TConfigurationException('template_event_forbidden',$type,$name);
9048
+				else if (strncasecmp($name, 'on', 2) === 0)
9049
+					throw new TConfigurationException('template_event_forbidden', $type, $name);
9050 9050
 				else
9051 9051
 				{
9052
-										if(strcasecmp($name,'id')!==0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)))
9052
+										if (strcasecmp($name, 'id') !== 0 && !($class->hasMethod('set' . $name) || $this->isClassBehaviorMethod($class, 'set' . $name)))
9053 9053
 					{
9054
-						if($class->hasMethod('get'.$name))
9055
-							throw new TConfigurationException('template_property_readonly',$type,$name);
9054
+						if ($class->hasMethod('get' . $name))
9055
+							throw new TConfigurationException('template_property_readonly', $type, $name);
9056 9056
 						else
9057
-							throw new TConfigurationException('template_property_unknown',$type,$name);
9057
+							throw new TConfigurationException('template_property_unknown', $type, $name);
9058 9058
 					}
9059 9059
 				}
9060 9060
 			}
9061 9061
 		}
9062 9062
 		else
9063
-			throw new TConfigurationException('template_component_required',$type);
9063
+			throw new TConfigurationException('template_component_required', $type);
9064 9064
 	}
9065 9065
 	public function getIncludedFiles()
9066 9066
 	{
9067 9067
 		return $this->_includedFiles;
9068 9068
 	}
9069
-	protected function handleException($e,$line,$input=null)
9069
+	protected function handleException($e, $line, $input = null)
9070 9070
 	{
9071
-		$srcFile=$this->_tplFile;
9072
-		if(($n=count($this->_includedFiles))>0) 		{
9073
-			for($i=$n-1;$i>=0;--$i)
9071
+		$srcFile = $this->_tplFile;
9072
+		if (($n = count($this->_includedFiles)) > 0) {
9073
+			for ($i = $n - 1; $i >= 0; --$i)
9074 9074
 			{
9075
-				if($this->_includeAtLine[$i]<=$line)
9075
+				if ($this->_includeAtLine[$i] <= $line)
9076 9076
 				{
9077
-					if($line<$this->_includeAtLine[$i]+$this->_includeLines[$i])
9077
+					if ($line < $this->_includeAtLine[$i] + $this->_includeLines[$i])
9078 9078
 					{
9079
-						$line=$line-$this->_includeAtLine[$i]+1;
9080
-						$srcFile=$this->_includedFiles[$i];
9079
+						$line = $line - $this->_includeAtLine[$i] + 1;
9080
+						$srcFile = $this->_includedFiles[$i];
9081 9081
 						break;
9082 9082
 					}
9083 9083
 					else
9084
-						$line=$line-$this->_includeLines[$i]+1;
9084
+						$line = $line - $this->_includeLines[$i] + 1;
9085 9085
 				}
9086 9086
 			}
9087 9087
 		}
9088
-		$exception=new TTemplateException('template_format_invalid',$e->getMessage());
9088
+		$exception = new TTemplateException('template_format_invalid', $e->getMessage());
9089 9089
 		$exception->setLineNumber($line);
9090
-		if(!empty($srcFile))
9090
+		if (!empty($srcFile))
9091 9091
 			$exception->setTemplateFile($srcFile);
9092 9092
 		else
9093 9093
 			$exception->setTemplateSource($input);
@@ -9095,45 +9095,45 @@  discard block
 block discarded – undo
9095 9095
 	}
9096 9096
 	protected function preprocess($input)
9097 9097
 	{
9098
-		if($n=preg_match_all('/<%include(.*?)%>/',$input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE))
9098
+		if ($n = preg_match_all('/<%include(.*?)%>/', $input, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
9099 9099
 		{
9100
-			for($i=0;$i<$n;++$i)
9100
+			for ($i = 0; $i < $n; ++$i)
9101 9101
 			{
9102
-				$filePath=Prado::getPathOfNamespace(trim($matches[$i][1][0]),TTemplateManager::TEMPLATE_FILE_EXT);
9103
-				if($filePath!==null && is_file($filePath))
9104
-					$this->_includedFiles[]=$filePath;
9102
+				$filePath = Prado::getPathOfNamespace(trim($matches[$i][1][0]), TTemplateManager::TEMPLATE_FILE_EXT);
9103
+				if ($filePath !== null && is_file($filePath))
9104
+					$this->_includedFiles[] = $filePath;
9105 9105
 				else
9106 9106
 				{
9107
-					$errorLine=count(explode("\n",substr($input,0,$matches[$i][0][1]+1)));
9108
-					$this->handleException(new TConfigurationException('template_include_invalid',trim($matches[$i][1][0])),$errorLine,$input);
9107
+					$errorLine = count(explode("\n", substr($input, 0, $matches[$i][0][1] + 1)));
9108
+					$this->handleException(new TConfigurationException('template_include_invalid', trim($matches[$i][1][0])), $errorLine, $input);
9109 9109
 				}
9110 9110
 			}
9111
-			$base=0;
9112
-			for($i=0;$i<$n;++$i)
9111
+			$base = 0;
9112
+			for ($i = 0; $i < $n; ++$i)
9113 9113
 			{
9114
-				$ext=file_get_contents($this->_includedFiles[$i]);
9115
-				$length=strlen($matches[$i][0][0]);
9116
-				$offset=$base+$matches[$i][0][1];
9117
-				$this->_includeAtLine[$i]=count(explode("\n",substr($input,0,$offset)));
9118
-				$this->_includeLines[$i]=count(explode("\n",$ext));
9119
-				$input=substr_replace($input,$ext,$offset,$length);
9120
-				$base+=strlen($ext)-$length;
9114
+				$ext = file_get_contents($this->_includedFiles[$i]);
9115
+				$length = strlen($matches[$i][0][0]);
9116
+				$offset = $base + $matches[$i][0][1];
9117
+				$this->_includeAtLine[$i] = count(explode("\n", substr($input, 0, $offset)));
9118
+				$this->_includeLines[$i] = count(explode("\n", $ext));
9119
+				$input = substr_replace($input, $ext, $offset, $length);
9120
+				$base += strlen($ext) - $length;
9121 9121
 			}
9122 9122
 		}
9123 9123
 		return $input;
9124 9124
 	}
9125
-	protected function isClassBehaviorMethod(ReflectionClass $class,$method)
9125
+	protected function isClassBehaviorMethod(ReflectionClass $class, $method)
9126 9126
 	{
9127
-	  $component=new ReflectionClass('TComponent');
9128
-	  $behaviors=$component->getStaticProperties();
9129
-	  if(!isset($behaviors['_um']))
9127
+	  $component = new ReflectionClass('TComponent');
9128
+	  $behaviors = $component->getStaticProperties();
9129
+	  if (!isset($behaviors['_um']))
9130 9130
 	    return false;
9131
-	  foreach($behaviors['_um'] as $name=>$list)
9131
+	  foreach ($behaviors['_um'] as $name=>$list)
9132 9132
 	  {
9133
-	    if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue;
9134
-	    foreach($list as $param)
9133
+	    if (strtolower($class->getShortName()) !== $name && !$class->isSubclassOf($name)) continue;
9134
+	    foreach ($list as $param)
9135 9135
 	    {
9136
-	      if(method_exists($param->getBehavior(),$method))
9136
+	      if (method_exists($param->getBehavior(), $method))
9137 9137
 	        return true;
9138 9138
 	    }
9139 9139
 	  }
@@ -9142,177 +9142,177 @@  discard block
 block discarded – undo
9142 9142
 }
9143 9143
 class TThemeManager extends TModule
9144 9144
 {
9145
-	const DEFAULT_BASEPATH='themes';
9145
+	const DEFAULT_BASEPATH = 'themes';
9146 9146
 	const DEFAULT_THEMECLASS = 'TTheme';
9147
-	private $_themeClass=self::DEFAULT_THEMECLASS;
9148
-	private $_initialized=false;
9149
-	private $_basePath=null;
9150
-	private $_baseUrl=null;
9147
+	private $_themeClass = self::DEFAULT_THEMECLASS;
9148
+	private $_initialized = false;
9149
+	private $_basePath = null;
9150
+	private $_baseUrl = null;
9151 9151
 	public function init($config)
9152 9152
 	{
9153
-		$this->_initialized=true;
9154
-		$service=$this->getService();
9155
-		if($service instanceof TPageService)
9153
+		$this->_initialized = true;
9154
+		$service = $this->getService();
9155
+		if ($service instanceof TPageService)
9156 9156
 			$service->setThemeManager($this);
9157 9157
 		else
9158 9158
 			throw new TConfigurationException('thememanager_service_unavailable');
9159 9159
 	}
9160 9160
 	public function getTheme($name)
9161 9161
 	{
9162
-		$themePath=$this->getBasePath().DIRECTORY_SEPARATOR.$name;
9163
-		$themeUrl=rtrim($this->getBaseUrl(),'/').'/'.$name;
9162
+		$themePath = $this->getBasePath() . DIRECTORY_SEPARATOR . $name;
9163
+		$themeUrl = rtrim($this->getBaseUrl(), '/') . '/' . $name;
9164 9164
 		return Prado::createComponent($this->getThemeClass(), $themePath, $themeUrl);
9165 9165
 	}
9166 9166
 	public function setThemeClass($class) {
9167
-		$this->_themeClass = $class===null ? self::DEFAULT_THEMECLASS : (string)$class;
9167
+		$this->_themeClass = $class === null ? self::DEFAULT_THEMECLASS : (string) $class;
9168 9168
 	}
9169 9169
 	public function getThemeClass() {
9170 9170
 		return $this->_themeClass;
9171 9171
 	}
9172 9172
 	public function getAvailableThemes()
9173 9173
 	{
9174
-		$themes=array();
9175
-		$basePath=$this->getBasePath();
9176
-		$folder=@opendir($basePath);
9177
-		while($file=@readdir($folder))
9174
+		$themes = array();
9175
+		$basePath = $this->getBasePath();
9176
+		$folder = @opendir($basePath);
9177
+		while ($file = @readdir($folder))
9178 9178
 		{
9179
-			if($file!=='.' && $file!=='..' && $file!=='.svn' && is_dir($basePath.DIRECTORY_SEPARATOR.$file))
9180
-				$themes[]=$file;
9179
+			if ($file !== '.' && $file !== '..' && $file !== '.svn' && is_dir($basePath . DIRECTORY_SEPARATOR . $file))
9180
+				$themes[] = $file;
9181 9181
 		}
9182 9182
 		closedir($folder);
9183 9183
 		return $themes;
9184 9184
 	}
9185 9185
 	public function getBasePath()
9186 9186
 	{
9187
-		if($this->_basePath===null)
9187
+		if ($this->_basePath === null)
9188 9188
 		{
9189
-			$this->_basePath=dirname($this->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH;
9190
-			if(($basePath=realpath($this->_basePath))===false || !is_dir($basePath))
9191
-				throw new TConfigurationException('thememanager_basepath_invalid2',$this->_basePath);
9192
-			$this->_basePath=$basePath;
9189
+			$this->_basePath = dirname($this->getRequest()->getApplicationFilePath()) . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH;
9190
+			if (($basePath = realpath($this->_basePath)) === false || !is_dir($basePath))
9191
+				throw new TConfigurationException('thememanager_basepath_invalid2', $this->_basePath);
9192
+			$this->_basePath = $basePath;
9193 9193
 		}
9194 9194
 		return $this->_basePath;
9195 9195
 	}
9196 9196
 	public function setBasePath($value)
9197 9197
 	{
9198
-		if($this->_initialized)
9198
+		if ($this->_initialized)
9199 9199
 			throw new TInvalidOperationException('thememanager_basepath_unchangeable');
9200 9200
 		else
9201 9201
 		{
9202
-			$this->_basePath=Prado::getPathOfNamespace($value);
9203
-			if($this->_basePath===null || !is_dir($this->_basePath))
9204
-				throw new TInvalidDataValueException('thememanager_basepath_invalid',$value);
9202
+			$this->_basePath = Prado::getPathOfNamespace($value);
9203
+			if ($this->_basePath === null || !is_dir($this->_basePath))
9204
+				throw new TInvalidDataValueException('thememanager_basepath_invalid', $value);
9205 9205
 		}
9206 9206
 	}
9207 9207
 	public function getBaseUrl()
9208 9208
 	{
9209
-		if($this->_baseUrl===null)
9209
+		if ($this->_baseUrl === null)
9210 9210
 		{
9211
-			$appPath=dirname($this->getRequest()->getApplicationFilePath());
9212
-			$basePath=$this->getBasePath();
9213
-			if(strpos($basePath,$appPath)===false)
9211
+			$appPath = dirname($this->getRequest()->getApplicationFilePath());
9212
+			$basePath = $this->getBasePath();
9213
+			if (strpos($basePath, $appPath) === false)
9214 9214
 				throw new TConfigurationException('thememanager_baseurl_required');
9215
-			$appUrl=rtrim(dirname($this->getRequest()->getApplicationUrl()),'/\\');
9216
-			$this->_baseUrl=$appUrl.strtr(substr($basePath,strlen($appPath)),'\\','/');
9215
+			$appUrl = rtrim(dirname($this->getRequest()->getApplicationUrl()), '/\\');
9216
+			$this->_baseUrl = $appUrl . strtr(substr($basePath, strlen($appPath)), '\\', '/');
9217 9217
 		}
9218 9218
 		return $this->_baseUrl;
9219 9219
 	}
9220 9220
 	public function setBaseUrl($value)
9221 9221
 	{
9222
-		$this->_baseUrl=rtrim($value,'/');
9222
+		$this->_baseUrl = rtrim($value, '/');
9223 9223
 	}
9224 9224
 }
9225 9225
 class TTheme extends TApplicationComponent implements ITheme
9226 9226
 {
9227
-	const THEME_CACHE_PREFIX='prado:theme:';
9228
-	const SKIN_FILE_EXT='.skin';
9227
+	const THEME_CACHE_PREFIX = 'prado:theme:';
9228
+	const SKIN_FILE_EXT = '.skin';
9229 9229
 	private $_themePath;
9230 9230
 	private $_themeUrl;
9231
-	private $_skins=null;
9232
-	private $_name='';
9233
-	private $_cssFiles=array();
9234
-	private $_jsFiles=array();
9235
-	public function __construct($themePath,$themeUrl)
9236
-	{
9237
-		$this->_themeUrl=$themeUrl;
9238
-		$this->_themePath=realpath($themePath);
9239
-		$this->_name=basename($themePath);
9240
-		$cacheValid=false;
9241
-				if(($cache=$this->getApplication()->getCache())!==null)
9242
-		{
9243
-			$array=$cache->get(self::THEME_CACHE_PREFIX.$themePath);
9244
-			if(is_array($array))
9245
-			{
9246
-				list($skins,$cssFiles,$jsFiles,$timestamp)=$array;
9247
-				if($this->getApplication()->getMode()!==TApplicationMode::Performance)
9231
+	private $_skins = null;
9232
+	private $_name = '';
9233
+	private $_cssFiles = array();
9234
+	private $_jsFiles = array();
9235
+	public function __construct($themePath, $themeUrl)
9236
+	{
9237
+		$this->_themeUrl = $themeUrl;
9238
+		$this->_themePath = realpath($themePath);
9239
+		$this->_name = basename($themePath);
9240
+		$cacheValid = false;
9241
+				if (($cache = $this->getApplication()->getCache()) !== null)
9242
+		{
9243
+			$array = $cache->get(self::THEME_CACHE_PREFIX . $themePath);
9244
+			if (is_array($array))
9245
+			{
9246
+				list($skins, $cssFiles, $jsFiles, $timestamp) = $array;
9247
+				if ($this->getApplication()->getMode() !== TApplicationMode::Performance)
9248 9248
 				{
9249
-					if(($dir=opendir($themePath))===false)
9250
-						throw new TIOException('theme_path_inexistent',$themePath);
9251
-					$cacheValid=true;
9252
-					while(($file=readdir($dir))!==false)
9249
+					if (($dir = opendir($themePath)) === false)
9250
+						throw new TIOException('theme_path_inexistent', $themePath);
9251
+					$cacheValid = true;
9252
+					while (($file = readdir($dir)) !== false)
9253 9253
 					{
9254
-						if($file==='.' || $file==='..')
9254
+						if ($file === '.' || $file === '..')
9255 9255
 							continue;
9256
-						else if(basename($file,'.css')!==$file)
9257
-							$this->_cssFiles[]=$themeUrl.'/'.$file;
9258
-						else if(basename($file,'.js')!==$file)
9259
-							$this->_jsFiles[]=$themeUrl.'/'.$file;
9260
-						else if(basename($file,self::SKIN_FILE_EXT)!==$file && filemtime($themePath.DIRECTORY_SEPARATOR.$file)>$timestamp)
9256
+						else if (basename($file, '.css') !== $file)
9257
+							$this->_cssFiles[] = $themeUrl . '/' . $file;
9258
+						else if (basename($file, '.js') !== $file)
9259
+							$this->_jsFiles[] = $themeUrl . '/' . $file;
9260
+						else if (basename($file, self::SKIN_FILE_EXT) !== $file && filemtime($themePath . DIRECTORY_SEPARATOR . $file) > $timestamp)
9261 9261
 						{
9262
-							$cacheValid=false;
9262
+							$cacheValid = false;
9263 9263
 							break;
9264 9264
 						}
9265 9265
 					}
9266 9266
 					closedir($dir);
9267
-					if($cacheValid)
9268
-						$this->_skins=$skins;
9267
+					if ($cacheValid)
9268
+						$this->_skins = $skins;
9269 9269
 				}
9270 9270
 				else
9271 9271
 				{
9272
-					$cacheValid=true;
9273
-					$this->_cssFiles=$cssFiles;
9274
-					$this->_jsFiles=$jsFiles;
9275
-					$this->_skins=$skins;
9272
+					$cacheValid = true;
9273
+					$this->_cssFiles = $cssFiles;
9274
+					$this->_jsFiles = $jsFiles;
9275
+					$this->_skins = $skins;
9276 9276
 				}
9277 9277
 			}
9278 9278
 		}
9279
-		if(!$cacheValid)
9279
+		if (!$cacheValid)
9280 9280
 		{
9281
-			$this->_cssFiles=array();
9282
-			$this->_jsFiles=array();
9283
-			$this->_skins=array();
9284
-			if(($dir=opendir($themePath))===false)
9285
-				throw new TIOException('theme_path_inexistent',$themePath);
9286
-			while(($file=readdir($dir))!==false)
9281
+			$this->_cssFiles = array();
9282
+			$this->_jsFiles = array();
9283
+			$this->_skins = array();
9284
+			if (($dir = opendir($themePath)) === false)
9285
+				throw new TIOException('theme_path_inexistent', $themePath);
9286
+			while (($file = readdir($dir)) !== false)
9287 9287
 			{
9288
-				if($file==='.' || $file==='..')
9288
+				if ($file === '.' || $file === '..')
9289 9289
 					continue;
9290
-				else if(basename($file,'.css')!==$file)
9291
-					$this->_cssFiles[]=$themeUrl.'/'.$file;
9292
-				else if(basename($file,'.js')!==$file)
9293
-					$this->_jsFiles[]=$themeUrl.'/'.$file;
9294
-				else if(basename($file,self::SKIN_FILE_EXT)!==$file)
9290
+				else if (basename($file, '.css') !== $file)
9291
+					$this->_cssFiles[] = $themeUrl . '/' . $file;
9292
+				else if (basename($file, '.js') !== $file)
9293
+					$this->_jsFiles[] = $themeUrl . '/' . $file;
9294
+				else if (basename($file, self::SKIN_FILE_EXT) !== $file)
9295 9295
 				{
9296
-					$template=new TTemplate(file_get_contents($themePath.'/'.$file),$themePath,$themePath.'/'.$file);
9297
-					foreach($template->getItems() as $skin)
9296
+					$template = new TTemplate(file_get_contents($themePath . '/' . $file), $themePath, $themePath . '/' . $file);
9297
+					foreach ($template->getItems() as $skin)
9298 9298
 					{
9299
-						if(!isset($skin[2]))  							continue;
9300
-						else if($skin[0]!==-1)
9301
-							throw new TConfigurationException('theme_control_nested',$skin[1],dirname($themePath));
9302
-						$type=$skin[1];
9303
-						$id=isset($skin[2]['skinid'])?$skin[2]['skinid']:0;
9299
+						if (!isset($skin[2]))  							continue;
9300
+						else if ($skin[0] !== -1)
9301
+							throw new TConfigurationException('theme_control_nested', $skin[1], dirname($themePath));
9302
+						$type = $skin[1];
9303
+						$id = isset($skin[2]['skinid']) ? $skin[2]['skinid'] : 0;
9304 9304
 						unset($skin[2]['skinid']);
9305
-						if(isset($this->_skins[$type][$id]))
9306
-							throw new TConfigurationException('theme_skinid_duplicated',$type,$id,dirname($themePath));
9307
-						$this->_skins[$type][$id]=$skin[2];
9305
+						if (isset($this->_skins[$type][$id]))
9306
+							throw new TConfigurationException('theme_skinid_duplicated', $type, $id, dirname($themePath));
9307
+						$this->_skins[$type][$id] = $skin[2];
9308 9308
 					}
9309 9309
 				}
9310 9310
 			}
9311 9311
 			closedir($dir);
9312 9312
 			sort($this->_cssFiles);
9313 9313
 			sort($this->_jsFiles);
9314
-			if($cache!==null)
9315
-				$cache->set(self::THEME_CACHE_PREFIX.$themePath,array($this->_skins,$this->_cssFiles,$this->_jsFiles,time()));
9314
+			if ($cache !== null)
9315
+				$cache->set(self::THEME_CACHE_PREFIX . $themePath, array($this->_skins, $this->_cssFiles, $this->_jsFiles, time()));
9316 9316
 		}
9317 9317
 	}
9318 9318
 	public function getName()
@@ -9329,7 +9329,7 @@  discard block
 block discarded – undo
9329 9329
 	}
9330 9330
 	protected function setBaseUrl($value)
9331 9331
 	{
9332
-		$this->_themeUrl=rtrim($value,'/');
9332
+		$this->_themeUrl = rtrim($value, '/');
9333 9333
 	}
9334 9334
 	public function getBasePath()
9335 9335
 	{
@@ -9337,7 +9337,7 @@  discard block
 block discarded – undo
9337 9337
 	}
9338 9338
 	protected function setBasePath($value)
9339 9339
 	{
9340
-		$this->_themePath=$value;
9340
+		$this->_themePath = $value;
9341 9341
 	}
9342 9342
 	public function getSkins()
9343 9343
 	{
@@ -9349,57 +9349,57 @@  discard block
 block discarded – undo
9349 9349
 	}
9350 9350
 	public function applySkin($control)
9351 9351
 	{
9352
-		$type=get_class($control);
9353
-		if(($id=$control->getSkinID())==='')
9354
-			$id=0;
9355
-		if(isset($this->_skins[$type][$id]))
9352
+		$type = get_class($control);
9353
+		if (($id = $control->getSkinID()) === '')
9354
+			$id = 0;
9355
+		if (isset($this->_skins[$type][$id]))
9356 9356
 		{
9357
-			foreach($this->_skins[$type][$id] as $name=>$value)
9357
+			foreach ($this->_skins[$type][$id] as $name=>$value)
9358 9358
 			{
9359
-				if(is_array($value))
9359
+				if (is_array($value))
9360 9360
 				{
9361
-					switch($value[0])
9361
+					switch ($value[0])
9362 9362
 					{
9363 9363
 						case TTemplate::CONFIG_EXPRESSION:
9364
-							$value=$this->evaluateExpression($value[1]);
9364
+							$value = $this->evaluateExpression($value[1]);
9365 9365
 							break;
9366 9366
 						case TTemplate::CONFIG_ASSET:
9367
-							$value=$this->_themeUrl.'/'.ltrim($value[1],'/');
9367
+							$value = $this->_themeUrl . '/' . ltrim($value[1], '/');
9368 9368
 							break;
9369 9369
 						case TTemplate::CONFIG_DATABIND:
9370
-							$control->bindProperty($name,$value[1]);
9370
+							$control->bindProperty($name, $value[1]);
9371 9371
 							break;
9372 9372
 						case TTemplate::CONFIG_PARAMETER:
9373
-							$control->setSubProperty($name,$this->getApplication()->getParameters()->itemAt($value[1]));
9373
+							$control->setSubProperty($name, $this->getApplication()->getParameters()->itemAt($value[1]));
9374 9374
 							break;
9375 9375
 						case TTemplate::CONFIG_TEMPLATE:
9376
-							$control->setSubProperty($name,$value[1]);
9376
+							$control->setSubProperty($name, $value[1]);
9377 9377
 							break;
9378 9378
 						case TTemplate::CONFIG_LOCALIZATION:
9379
-							$control->setSubProperty($name,Prado::localize($value[1]));
9379
+							$control->setSubProperty($name, Prado::localize($value[1]));
9380 9380
 							break;
9381 9381
 						default:
9382
-							throw new TConfigurationException('theme_tag_unexpected',$name,$value[0]);
9382
+							throw new TConfigurationException('theme_tag_unexpected', $name, $value[0]);
9383 9383
 							break;
9384 9384
 					}
9385 9385
 				}
9386
-				if(!is_array($value))
9386
+				if (!is_array($value))
9387 9387
 				{
9388
-					if(strpos($name,'.')===false)						{
9389
-						if($control->hasProperty($name))
9388
+					if (strpos($name, '.') === false) {
9389
+						if ($control->hasProperty($name))
9390 9390
 						{
9391
-							if($control->canSetProperty($name))
9391
+							if ($control->canSetProperty($name))
9392 9392
 							{
9393
-								$setter='set'.$name;
9393
+								$setter = 'set' . $name;
9394 9394
 								$control->$setter($value);
9395 9395
 							}
9396 9396
 							else
9397
-								throw new TConfigurationException('theme_property_readonly',$type,$name);
9397
+								throw new TConfigurationException('theme_property_readonly', $type, $name);
9398 9398
 						}
9399 9399
 						else
9400
-							throw new TConfigurationException('theme_property_undefined',$type,$name);
9400
+							throw new TConfigurationException('theme_property_undefined', $type, $name);
9401 9401
 					}
9402
-					else							$control->setSubProperty($name,$value);
9402
+					else							$control->setSubProperty($name, $value);
9403 9403
 				}
9404 9404
 			}
9405 9405
 			return true;
@@ -9413,7 +9413,7 @@  discard block
 block discarded – undo
9413 9413
 	}
9414 9414
 	protected function setStyleSheetFiles($value)
9415 9415
 	{
9416
-		$this->_cssFiles=$value;
9416
+		$this->_cssFiles = $value;
9417 9417
 	}
9418 9418
 	public function getJavaScriptFiles()
9419 9419
 	{
@@ -9421,176 +9421,176 @@  discard block
 block discarded – undo
9421 9421
 	}
9422 9422
 	protected function setJavaScriptFiles($value)
9423 9423
 	{
9424
-		$this->_jsFiles=$value;
9424
+		$this->_jsFiles = $value;
9425 9425
 	}
9426 9426
 }
9427 9427
 class TPageService extends TService
9428 9428
 {
9429
-	const CONFIG_FILE_XML='config.xml';
9430
-	const CONFIG_FILE_PHP='config.php';
9431
-	const DEFAULT_BASEPATH='Pages';
9432
-	const FALLBACK_BASEPATH='pages';
9433
-	const CONFIG_CACHE_PREFIX='prado:pageservice:';
9434
-	const PAGE_FILE_EXT='.page';
9435
-	private $_basePath=null;
9436
-	private $_basePageClass='TPage';
9437
-	private $_clientScriptManagerClass='System.Web.UI.TClientScriptManager';
9438
-	private $_defaultPage='Home';
9439
-	private $_pagePath=null;
9440
-	private $_page=null;
9441
-	private $_properties=array();
9442
-	private $_initialized=false;
9443
-	private $_themeManager=null;
9444
-	private $_templateManager=null;
9429
+	const CONFIG_FILE_XML = 'config.xml';
9430
+	const CONFIG_FILE_PHP = 'config.php';
9431
+	const DEFAULT_BASEPATH = 'Pages';
9432
+	const FALLBACK_BASEPATH = 'pages';
9433
+	const CONFIG_CACHE_PREFIX = 'prado:pageservice:';
9434
+	const PAGE_FILE_EXT = '.page';
9435
+	private $_basePath = null;
9436
+	private $_basePageClass = 'TPage';
9437
+	private $_clientScriptManagerClass = 'System.Web.UI.TClientScriptManager';
9438
+	private $_defaultPage = 'Home';
9439
+	private $_pagePath = null;
9440
+	private $_page = null;
9441
+	private $_properties = array();
9442
+	private $_initialized = false;
9443
+	private $_themeManager = null;
9444
+	private $_templateManager = null;
9445 9445
 	public function init($config)
9446 9446
 	{
9447
-		$pageConfig=$this->loadPageConfig($config);
9447
+		$pageConfig = $this->loadPageConfig($config);
9448 9448
 		$this->initPageContext($pageConfig);
9449
-		$this->_initialized=true;
9449
+		$this->_initialized = true;
9450 9450
 	}
9451 9451
 	protected function initPageContext($pageConfig)
9452 9452
 	{
9453
-		$application=$this->getApplication();
9454
-		foreach($pageConfig->getApplicationConfigurations() as $appConfig)
9453
+		$application = $this->getApplication();
9454
+		foreach ($pageConfig->getApplicationConfigurations() as $appConfig)
9455 9455
 			$application->applyConfiguration($appConfig);
9456 9456
 		$this->applyConfiguration($pageConfig);
9457 9457
 	}
9458 9458
 	protected function applyConfiguration($config)
9459 9459
 	{
9460
-				$this->_properties=array_merge($this->_properties, $config->getProperties());
9460
+				$this->_properties = array_merge($this->_properties, $config->getProperties());
9461 9461
 		$this->getApplication()->getAuthorizationRules()->mergeWith($config->getRules());
9462
-		$pagePath=$this->getRequestedPagePath();
9463
-				foreach($config->getExternalConfigurations() as $filePath=>$params)
9464
-		{
9465
-			list($configPagePath,$condition)=$params;
9466
-			if($condition!==true)
9467
-				$condition=$this->evaluateExpression($condition);
9468
-			if($condition)
9469
-			{
9470
-				if(($path=Prado::getPathOfNamespace($filePath,Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path))
9471
-					throw new TConfigurationException('pageservice_includefile_invalid',$filePath);
9472
-				$c=new TPageConfiguration($pagePath);
9473
-				$c->loadFromFile($path,$configPagePath);
9462
+		$pagePath = $this->getRequestedPagePath();
9463
+				foreach ($config->getExternalConfigurations() as $filePath=>$params)
9464
+		{
9465
+			list($configPagePath, $condition) = $params;
9466
+			if ($condition !== true)
9467
+				$condition = $this->evaluateExpression($condition);
9468
+			if ($condition)
9469
+			{
9470
+				if (($path = Prado::getPathOfNamespace($filePath, Prado::getApplication()->getConfigurationFileExt())) === null || !is_file($path))
9471
+					throw new TConfigurationException('pageservice_includefile_invalid', $filePath);
9472
+				$c = new TPageConfiguration($pagePath);
9473
+				$c->loadFromFile($path, $configPagePath);
9474 9474
 				$this->applyConfiguration($c);
9475 9475
 			}
9476 9476
 		}
9477 9477
 	}
9478 9478
 	protected function determineRequestedPagePath()
9479 9479
 	{
9480
-		$pagePath=$this->getRequest()->getServiceParameter();
9481
-		if(empty($pagePath))
9482
-			$pagePath=$this->getDefaultPage();
9480
+		$pagePath = $this->getRequest()->getServiceParameter();
9481
+		if (empty($pagePath))
9482
+			$pagePath = $this->getDefaultPage();
9483 9483
 		return $pagePath;
9484 9484
 	}
9485 9485
 	protected function loadPageConfig($config)
9486 9486
 	{
9487
-		$application=$this->getApplication();
9488
-		$pagePath=$this->getRequestedPagePath();
9489
-		if(($cache=$application->getCache())===null)
9487
+		$application = $this->getApplication();
9488
+		$pagePath = $this->getRequestedPagePath();
9489
+		if (($cache = $application->getCache()) === null)
9490 9490
 		{
9491
-			$pageConfig=new TPageConfiguration($pagePath);
9492
-			if($config!==null)
9491
+			$pageConfig = new TPageConfiguration($pagePath);
9492
+			if ($config !== null)
9493 9493
 			{
9494
-				if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
9495
-					$pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),'');
9494
+				if ($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
9495
+					$pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
9496 9496
 				else
9497
-					$pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),'');
9497
+					$pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
9498 9498
 			}
9499 9499
 			$pageConfig->loadFromFiles($this->getBasePath());
9500 9500
 		}
9501 9501
 		else
9502 9502
 		{
9503
-			$configCached=true;
9504
-			$currentTimestamp=array();
9505
-			$arr=$cache->get(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath);
9506
-			if(is_array($arr))
9503
+			$configCached = true;
9504
+			$currentTimestamp = array();
9505
+			$arr = $cache->get(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath);
9506
+			if (is_array($arr))
9507 9507
 			{
9508
-				list($pageConfig,$timestamps)=$arr;
9509
-				if($application->getMode()!==TApplicationMode::Performance)
9508
+				list($pageConfig, $timestamps) = $arr;
9509
+				if ($application->getMode() !== TApplicationMode::Performance)
9510 9510
 				{
9511
-					foreach($timestamps as $fileName=>$timestamp)
9511
+					foreach ($timestamps as $fileName=>$timestamp)
9512 9512
 					{
9513
-						if($fileName===0) 						{
9514
-							$appConfigFile=$application->getConfigurationFile();
9515
-							$currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile);
9516
-							if($currentTimestamp[0]>$timestamp || ($timestamp>0 && !$currentTimestamp[0]))
9517
-								$configCached=false;
9513
+						if ($fileName === 0) {
9514
+							$appConfigFile = $application->getConfigurationFile();
9515
+							$currentTimestamp[0] = $appConfigFile === null ? 0 : @filemtime($appConfigFile);
9516
+							if ($currentTimestamp[0] > $timestamp || ($timestamp > 0 && !$currentTimestamp[0]))
9517
+								$configCached = false;
9518 9518
 						}
9519 9519
 						else
9520 9520
 						{
9521
-							$currentTimestamp[$fileName]=@filemtime($fileName);
9522
-							if($currentTimestamp[$fileName]>$timestamp || ($timestamp>0 && !$currentTimestamp[$fileName]))
9523
-								$configCached=false;
9521
+							$currentTimestamp[$fileName] = @filemtime($fileName);
9522
+							if ($currentTimestamp[$fileName] > $timestamp || ($timestamp > 0 && !$currentTimestamp[$fileName]))
9523
+								$configCached = false;
9524 9524
 						}
9525 9525
 					}
9526 9526
 				}
9527 9527
 			}
9528 9528
 			else
9529 9529
 			{
9530
-				$configCached=false;
9531
-				$paths=explode('.',$pagePath);
9532
-				$configPath=$this->getBasePath();
9533
-				$fileName = $this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP
9530
+				$configCached = false;
9531
+				$paths = explode('.', $pagePath);
9532
+				$configPath = $this->getBasePath();
9533
+				$fileName = $this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP
9534 9534
 					? self::CONFIG_FILE_PHP
9535 9535
 					: self::CONFIG_FILE_XML;
9536
-				foreach($paths as $path)
9536
+				foreach ($paths as $path)
9537 9537
 				{
9538
-					$configFile=$configPath.DIRECTORY_SEPARATOR.$fileName;
9539
-					$currentTimestamp[$configFile]=@filemtime($configFile);
9540
-					$configPath.=DIRECTORY_SEPARATOR.$path;
9538
+					$configFile = $configPath . DIRECTORY_SEPARATOR . $fileName;
9539
+					$currentTimestamp[$configFile] = @filemtime($configFile);
9540
+					$configPath .= DIRECTORY_SEPARATOR . $path;
9541 9541
 				}
9542
-				$appConfigFile=$application->getConfigurationFile();
9543
-				$currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile);
9542
+				$appConfigFile = $application->getConfigurationFile();
9543
+				$currentTimestamp[0] = $appConfigFile === null ? 0 : @filemtime($appConfigFile);
9544 9544
 			}
9545
-			if(!$configCached)
9545
+			if (!$configCached)
9546 9546
 			{
9547
-				$pageConfig=new TPageConfiguration($pagePath);
9548
-				if($config!==null)
9547
+				$pageConfig = new TPageConfiguration($pagePath);
9548
+				if ($config !== null)
9549 9549
 				{
9550
-					if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
9551
-						$pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),'');
9550
+					if ($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
9551
+						$pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
9552 9552
 					else
9553
-						$pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),'');
9553
+						$pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
9554 9554
 				}
9555 9555
 				$pageConfig->loadFromFiles($this->getBasePath());
9556
-				$cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath,array($pageConfig,$currentTimestamp));
9556
+				$cache->set(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath, array($pageConfig, $currentTimestamp));
9557 9557
 			}
9558 9558
 		}
9559 9559
 		return $pageConfig;
9560 9560
 	}
9561 9561
 	public function getTemplateManager()
9562 9562
 	{
9563
-		if(!$this->_templateManager)
9563
+		if (!$this->_templateManager)
9564 9564
 		{
9565
-			$this->_templateManager=new TTemplateManager;
9565
+			$this->_templateManager = new TTemplateManager;
9566 9566
 			$this->_templateManager->init(null);
9567 9567
 		}
9568 9568
 		return $this->_templateManager;
9569 9569
 	}
9570 9570
 	public function setTemplateManager(TTemplateManager $value)
9571 9571
 	{
9572
-		$this->_templateManager=$value;
9572
+		$this->_templateManager = $value;
9573 9573
 	}
9574 9574
 	public function getThemeManager()
9575 9575
 	{
9576
-		if(!$this->_themeManager)
9576
+		if (!$this->_themeManager)
9577 9577
 		{
9578
-			$this->_themeManager=new TThemeManager;
9578
+			$this->_themeManager = new TThemeManager;
9579 9579
 			$this->_themeManager->init(null);
9580 9580
 		}
9581 9581
 		return $this->_themeManager;
9582 9582
 	}
9583 9583
 	public function setThemeManager(TThemeManager $value)
9584 9584
 	{
9585
-		$this->_themeManager=$value;
9585
+		$this->_themeManager = $value;
9586 9586
 	}
9587 9587
 	public function getRequestedPagePath()
9588 9588
 	{
9589
-		if($this->_pagePath===null)
9589
+		if ($this->_pagePath === null)
9590 9590
 		{
9591
-			$this->_pagePath=strtr($this->determineRequestedPagePath(),'/\\','..');
9592
-			if(empty($this->_pagePath))
9593
-				throw new THttpException(404,'pageservice_page_required');
9591
+			$this->_pagePath = strtr($this->determineRequestedPagePath(), '/\\', '..');
9592
+			if (empty($this->_pagePath))
9593
+				throw new THttpException(404, 'pageservice_page_required');
9594 9594
 		}
9595 9595
 		return $this->_pagePath;
9596 9596
 	}
@@ -9604,10 +9604,10 @@  discard block
 block discarded – undo
9604 9604
 	}
9605 9605
 	public function setDefaultPage($value)
9606 9606
 	{
9607
-		if($this->_initialized)
9607
+		if ($this->_initialized)
9608 9608
 			throw new TInvalidOperationException('pageservice_defaultpage_unchangeable');
9609 9609
 		else
9610
-			$this->_defaultPage=$value;
9610
+			$this->_defaultPage = $value;
9611 9611
 	}
9612 9612
 	public function getDefaultPageUrl()
9613 9613
 	{
@@ -9615,29 +9615,29 @@  discard block
 block discarded – undo
9615 9615
 	}
9616 9616
 	public function getBasePath()
9617 9617
 	{
9618
-		if($this->_basePath===null)
9618
+		if ($this->_basePath === null)
9619 9619
 		{
9620
-			$basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH;
9621
-			if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath))
9620
+			$basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH;
9621
+			if (($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath))
9622 9622
 			{
9623
-				$basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::FALLBACK_BASEPATH;
9624
-				if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath))
9625
-					throw new TConfigurationException('pageservice_basepath_invalid',$basePath);
9623
+				$basePath = $this->getApplication()->getBasePath() . DIRECTORY_SEPARATOR . self::FALLBACK_BASEPATH;
9624
+				if (($this->_basePath = realpath($basePath)) === false || !is_dir($this->_basePath))
9625
+					throw new TConfigurationException('pageservice_basepath_invalid', $basePath);
9626 9626
 			}
9627 9627
 		}
9628 9628
 		return $this->_basePath;
9629 9629
 	}
9630 9630
 	public function setBasePath($value)
9631 9631
 	{
9632
-		if($this->_initialized)
9632
+		if ($this->_initialized)
9633 9633
 			throw new TInvalidOperationException('pageservice_basepath_unchangeable');
9634
-		else if(($path=Prado::getPathOfNamespace($value))===null || !is_dir($path))
9635
-			throw new TConfigurationException('pageservice_basepath_invalid',$value);
9636
-		$this->_basePath=realpath($path);
9634
+		else if (($path = Prado::getPathOfNamespace($value)) === null || !is_dir($path))
9635
+			throw new TConfigurationException('pageservice_basepath_invalid', $value);
9636
+		$this->_basePath = realpath($path);
9637 9637
 	}
9638 9638
 	public function setBasePageClass($value)
9639 9639
 	{
9640
-		$this->_basePageClass=$value;
9640
+		$this->_basePageClass = $value;
9641 9641
 	}
9642 9642
 	public function getBasePageClass()
9643 9643
 	{
@@ -9645,7 +9645,7 @@  discard block
 block discarded – undo
9645 9645
 	}
9646 9646
 	public function setClientScriptManagerClass($value)
9647 9647
 	{
9648
-		$this->_clientScriptManagerClass=$value;
9648
+		$this->_clientScriptManagerClass = $value;
9649 9649
 	}
9650 9650
 	public function getClientScriptManagerClass()
9651 9651
 	{
@@ -9653,58 +9653,58 @@  discard block
 block discarded – undo
9653 9653
 	}
9654 9654
 	public function run()
9655 9655
 	{
9656
-		$this->_page=$this->createPage($this->getRequestedPagePath());
9657
-		$this->runPage($this->_page,$this->_properties);
9656
+		$this->_page = $this->createPage($this->getRequestedPagePath());
9657
+		$this->runPage($this->_page, $this->_properties);
9658 9658
 	}
9659 9659
 	protected function createPage($pagePath)
9660 9660
 	{
9661
-		$path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath,'.',DIRECTORY_SEPARATOR);
9662
-		$hasTemplateFile=is_file($path.self::PAGE_FILE_EXT);
9663
-		$hasClassFile=is_file($path.Prado::CLASS_FILE_EXT);
9664
-		if(!$hasTemplateFile && !$hasClassFile)
9665
-			throw new THttpException(404,'pageservice_page_unknown',$pagePath);
9666
-		if($hasClassFile)
9661
+		$path = $this->getBasePath() . DIRECTORY_SEPARATOR . strtr($pagePath, '.', DIRECTORY_SEPARATOR);
9662
+		$hasTemplateFile = is_file($path . self::PAGE_FILE_EXT);
9663
+		$hasClassFile = is_file($path . Prado::CLASS_FILE_EXT);
9664
+		if (!$hasTemplateFile && !$hasClassFile)
9665
+			throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
9666
+		if ($hasClassFile)
9667 9667
 		{
9668
-			$className=basename($path);
9669
-			if(!class_exists($className,false))
9670
-				include_once($path.Prado::CLASS_FILE_EXT);
9668
+			$className = basename($path);
9669
+			if (!class_exists($className, false))
9670
+				include_once($path . Prado::CLASS_FILE_EXT);
9671 9671
 		}
9672 9672
 		else
9673 9673
 		{
9674
-			$className=$this->getBasePageClass();
9674
+			$className = $this->getBasePageClass();
9675 9675
 			Prado::using($className);
9676
-			if(($pos=strrpos($className,'.'))!==false)
9677
-				$className=substr($className,$pos+1);
9676
+			if (($pos = strrpos($className, '.')) !== false)
9677
+				$className = substr($className, $pos + 1);
9678 9678
 		}
9679
- 		if(!class_exists($className,false) || ($className!=='TPage' && !is_subclass_of($className,'TPage')))
9680
-			throw new THttpException(404,'pageservice_page_unknown',$pagePath);
9681
-		$page=Prado::createComponent($className);
9679
+ 		if (!class_exists($className, false) || ($className !== 'TPage' && !is_subclass_of($className, 'TPage')))
9680
+			throw new THttpException(404, 'pageservice_page_unknown', $pagePath);
9681
+		$page = Prado::createComponent($className);
9682 9682
 		$page->setPagePath($pagePath);
9683
-		if($hasTemplateFile)
9684
-			$page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path.self::PAGE_FILE_EXT));
9683
+		if ($hasTemplateFile)
9684
+			$page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path . self::PAGE_FILE_EXT));
9685 9685
 		return $page;
9686 9686
 	}
9687
-	protected function runPage($page,$properties)
9687
+	protected function runPage($page, $properties)
9688 9688
 	{
9689
-		foreach($properties as $name=>$value)
9690
-			$page->setSubProperty($name,$value);
9689
+		foreach ($properties as $name=>$value)
9690
+			$page->setSubProperty($name, $value);
9691 9691
 		$page->run($this->getResponse()->createHtmlWriter());
9692 9692
 	}
9693
-	public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true)
9693
+	public function constructUrl($pagePath, $getParams = null, $encodeAmpersand = true, $encodeGetItems = true)
9694 9694
 	{
9695
-		return $this->getRequest()->constructUrl($this->getID(),$pagePath,$getParams,$encodeAmpersand,$encodeGetItems);
9695
+		return $this->getRequest()->constructUrl($this->getID(), $pagePath, $getParams, $encodeAmpersand, $encodeGetItems);
9696 9696
 	}
9697 9697
 }
9698 9698
 class TPageConfiguration extends TComponent
9699 9699
 {
9700
-	private $_appConfigs=array();
9701
-	private $_properties=array();
9702
-	private $_rules=array();
9703
-	private $_includes=array();
9704
-	private $_pagePath='';
9700
+	private $_appConfigs = array();
9701
+	private $_properties = array();
9702
+	private $_rules = array();
9703
+	private $_includes = array();
9704
+	private $_pagePath = '';
9705 9705
 	public function __construct($pagePath)
9706 9706
 	{
9707
-		$this->_pagePath=$pagePath;
9707
+		$this->_pagePath = $pagePath;
9708 9708
 	}
9709 9709
 	public function getExternalConfigurations()
9710 9710
 	{
@@ -9724,236 +9724,236 @@  discard block
 block discarded – undo
9724 9724
 	}
9725 9725
 	public function loadFromFiles($basePath)
9726 9726
 	{
9727
-		$paths=explode('.',$this->_pagePath);
9728
-		$page=array_pop($paths);
9729
-		$path=$basePath;
9730
-		$configPagePath='';
9731
-		$fileName = Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP
9727
+		$paths = explode('.', $this->_pagePath);
9728
+		$page = array_pop($paths);
9729
+		$path = $basePath;
9730
+		$configPagePath = '';
9731
+		$fileName = Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP
9732 9732
 			? TPageService::CONFIG_FILE_PHP
9733 9733
 			: TPageService::CONFIG_FILE_XML;
9734
-		foreach($paths as $p)
9734
+		foreach ($paths as $p)
9735 9735
 		{
9736
-			$this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath);
9737
-			$path.=DIRECTORY_SEPARATOR.$p;
9738
-			if($configPagePath==='')
9739
-				$configPagePath=$p;
9736
+			$this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath);
9737
+			$path .= DIRECTORY_SEPARATOR . $p;
9738
+			if ($configPagePath === '')
9739
+				$configPagePath = $p;
9740 9740
 			else
9741
-				$configPagePath.='.'.$p;
9741
+				$configPagePath .= '.' . $p;
9742 9742
 		}
9743
-		$this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath);
9744
-		$this->_rules=new TAuthorizationRuleCollection($this->_rules);
9743
+		$this->loadFromFile($path . DIRECTORY_SEPARATOR . $fileName, $configPagePath);
9744
+		$this->_rules = new TAuthorizationRuleCollection($this->_rules);
9745 9745
 	}
9746
-	public function loadFromFile($fname,$configPagePath)
9746
+	public function loadFromFile($fname, $configPagePath)
9747 9747
 	{
9748
-		if(empty($fname) || !is_file($fname))
9748
+		if (empty($fname) || !is_file($fname))
9749 9749
 			return;
9750
-		if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
9750
+		if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
9751 9751
 		{
9752 9752
 			$fcontent = include $fname;
9753
-			$this->loadFromPhp($fcontent,dirname($fname),$configPagePath);
9753
+			$this->loadFromPhp($fcontent, dirname($fname), $configPagePath);
9754 9754
 		}
9755 9755
 		else
9756 9756
 		{
9757
-			$dom=new TXmlDocument;
9758
-			if($dom->loadFromFile($fname))
9759
-				$this->loadFromXml($dom,dirname($fname),$configPagePath);
9757
+			$dom = new TXmlDocument;
9758
+			if ($dom->loadFromFile($fname))
9759
+				$this->loadFromXml($dom, dirname($fname), $configPagePath);
9760 9760
 			else
9761
-				throw new TConfigurationException('pageserviceconf_file_invalid',$fname);
9761
+				throw new TConfigurationException('pageserviceconf_file_invalid', $fname);
9762 9762
 		}
9763 9763
 	}
9764
-	public function loadFromPhp($config,$configPath,$configPagePath)
9764
+	public function loadFromPhp($config, $configPath, $configPagePath)
9765 9765
 	{
9766
-		$this->loadApplicationConfigurationFromPhp($config,$configPath);
9767
-		$this->loadPageConfigurationFromPhp($config,$configPath,$configPagePath);
9766
+		$this->loadApplicationConfigurationFromPhp($config, $configPath);
9767
+		$this->loadPageConfigurationFromPhp($config, $configPath, $configPagePath);
9768 9768
 	}
9769
-	public function loadFromXml($dom,$configPath,$configPagePath)
9769
+	public function loadFromXml($dom, $configPath, $configPagePath)
9770 9770
 	{
9771
-		$this->loadApplicationConfigurationFromXml($dom,$configPath);
9772
-		$this->loadPageConfigurationFromXml($dom,$configPath,$configPagePath);
9771
+		$this->loadApplicationConfigurationFromXml($dom, $configPath);
9772
+		$this->loadPageConfigurationFromXml($dom, $configPath, $configPagePath);
9773 9773
 	}
9774
-	public function loadApplicationConfigurationFromPhp($config,$configPath)
9774
+	public function loadApplicationConfigurationFromPhp($config, $configPath)
9775 9775
 	{
9776
-		$appConfig=new TApplicationConfiguration;
9777
-		$appConfig->loadFromPhp($config,$configPath);
9778
-		$this->_appConfigs[]=$appConfig;
9776
+		$appConfig = new TApplicationConfiguration;
9777
+		$appConfig->loadFromPhp($config, $configPath);
9778
+		$this->_appConfigs[] = $appConfig;
9779 9779
 	}
9780
-	public function loadApplicationConfigurationFromXml($dom,$configPath)
9780
+	public function loadApplicationConfigurationFromXml($dom, $configPath)
9781 9781
 	{
9782
-		$appConfig=new TApplicationConfiguration;
9783
-		$appConfig->loadFromXml($dom,$configPath);
9784
-		$this->_appConfigs[]=$appConfig;
9782
+		$appConfig = new TApplicationConfiguration;
9783
+		$appConfig->loadFromXml($dom, $configPath);
9784
+		$this->_appConfigs[] = $appConfig;
9785 9785
 	}
9786 9786
 	public function loadPageConfigurationFromPhp($config, $configPath, $configPagePath)
9787 9787
 	{
9788
-				if(isset($config['authorization']) && is_array($config['authorization']))
9788
+				if (isset($config['authorization']) && is_array($config['authorization']))
9789 9789
 		{
9790 9790
 			$rules = array();
9791
-			foreach($config['authorization'] as $authorization)
9791
+			foreach ($config['authorization'] as $authorization)
9792 9792
 			{
9793
-				$patterns=isset($authorization['pages'])?$authorization['pages']:'';
9794
-				$ruleApplies=false;
9795
-				if(empty($patterns) || trim($patterns)==='*') 					$ruleApplies=true;
9793
+				$patterns = isset($authorization['pages']) ? $authorization['pages'] : '';
9794
+				$ruleApplies = false;
9795
+				if (empty($patterns) || trim($patterns) === '*') 					$ruleApplies = true;
9796 9796
 				else
9797 9797
 				{
9798
-					foreach(explode(',',$patterns) as $pattern)
9798
+					foreach (explode(',', $patterns) as $pattern)
9799 9799
 					{
9800
-						if(($pattern=trim($pattern))!=='')
9800
+						if (($pattern = trim($pattern)) !== '')
9801 9801
 						{
9802
-														if($configPagePath!=='')  								$pattern=$configPagePath.'.'.$pattern;
9803
-							if(strcasecmp($pattern,$this->_pagePath)===0)
9802
+														if ($configPagePath !== '')  								$pattern = $configPagePath . '.' . $pattern;
9803
+							if (strcasecmp($pattern, $this->_pagePath) === 0)
9804 9804
 							{
9805
-								$ruleApplies=true;
9805
+								$ruleApplies = true;
9806 9806
 								break;
9807 9807
 							}
9808
-							if($pattern[strlen($pattern)-1]==='*') 							{
9809
-								if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0)
9808
+							if ($pattern[strlen($pattern) - 1] === '*') {
9809
+								if (strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0)
9810 9810
 								{
9811
-									$ruleApplies=true;
9811
+									$ruleApplies = true;
9812 9812
 									break;
9813 9813
 								}
9814 9814
 							}
9815 9815
 						}
9816 9816
 					}
9817 9817
 				}
9818
-				if($ruleApplies)
9818
+				if ($ruleApplies)
9819 9819
 				{
9820
-					$action = isset($authorization['action'])?$authorization['action']:'';
9821
-					$users = isset($authorization['users'])?$authorization['users']:'';
9822
-					$roles = isset($authorization['roles'])?$authorization['roles']:'';
9823
-					$verb = isset($authorization['verb'])?$authorization['verb']:'';
9824
-					$ips = isset($authorization['ips'])?$authorization['ips']:'';
9825
-					$rules[]=new TAuthorizationRule($action,$users,$roles,$verb,$ips);
9820
+					$action = isset($authorization['action']) ? $authorization['action'] : '';
9821
+					$users = isset($authorization['users']) ? $authorization['users'] : '';
9822
+					$roles = isset($authorization['roles']) ? $authorization['roles'] : '';
9823
+					$verb = isset($authorization['verb']) ? $authorization['verb'] : '';
9824
+					$ips = isset($authorization['ips']) ? $authorization['ips'] : '';
9825
+					$rules[] = new TAuthorizationRule($action, $users, $roles, $verb, $ips);
9826 9826
 				}
9827 9827
 			}
9828
-			$this->_rules=array_merge($rules,$this->_rules);
9828
+			$this->_rules = array_merge($rules, $this->_rules);
9829 9829
 		}
9830
-				if(isset($config['pages']) && is_array($config['pages']))
9830
+				if (isset($config['pages']) && is_array($config['pages']))
9831 9831
 		{
9832
-			if(isset($config['pages']['properties']))
9832
+			if (isset($config['pages']['properties']))
9833 9833
 			{
9834 9834
 				$this->_properties = array_merge($this->_properties, $config['pages']['properties']);
9835 9835
 				unset($config['pages']['properties']);
9836 9836
 			}
9837
-			foreach($config['pages'] as $id => $page)
9837
+			foreach ($config['pages'] as $id => $page)
9838 9838
 			{
9839 9839
 				$properties = array();
9840
-				if(isset($page['properties']))
9840
+				if (isset($page['properties']))
9841 9841
 				{
9842
-					$properties=$page['properties'];
9842
+					$properties = $page['properties'];
9843 9843
 					unset($page['properties']);
9844 9844
 				}
9845
-				$matching=false;
9846
-				$id=($configPagePath==='')?$id:$configPagePath.'.'.$id;
9847
-				if(strcasecmp($id,$this->_pagePath)===0)
9848
-					$matching=true;
9849
-				else if($id[strlen($id)-1]==='*') 					$matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0;
9850
-				if($matching)
9851
-					$this->_properties=array_merge($this->_properties,$properties);
9845
+				$matching = false;
9846
+				$id = ($configPagePath === '') ? $id : $configPagePath . '.' . $id;
9847
+				if (strcasecmp($id, $this->_pagePath) === 0)
9848
+					$matching = true;
9849
+				else if ($id[strlen($id) - 1] === '*') 					$matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0;
9850
+				if ($matching)
9851
+					$this->_properties = array_merge($this->_properties, $properties);
9852 9852
 			}
9853 9853
 		}
9854
-				if(isset($config['includes']) && is_array($config['includes']))
9854
+				if (isset($config['includes']) && is_array($config['includes']))
9855 9855
 		{
9856
-			foreach($config['includes'] as $include)
9856
+			foreach ($config['includes'] as $include)
9857 9857
 			{
9858
-				$when = isset($include['when'])?true:false;
9859
-				if(!isset($include['file']))
9858
+				$when = isset($include['when']) ? true : false;
9859
+				if (!isset($include['file']))
9860 9860
 					throw new TConfigurationException('pageserviceconf_includefile_required');
9861 9861
 				$filePath = $include['file'];
9862
-				if(isset($this->_includes[$filePath]))
9863
-					$this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')');
9862
+				if (isset($this->_includes[$filePath]))
9863
+					$this->_includes[$filePath] = array($configPagePath, '(' . $this->_includes[$filePath][1] . ') || (' . $when . ')');
9864 9864
 				else
9865
-					$this->_includes[$filePath]=array($configPagePath,$when);
9865
+					$this->_includes[$filePath] = array($configPagePath, $when);
9866 9866
 			}
9867 9867
 		}
9868 9868
 	}
9869
-	public function loadPageConfigurationFromXml($dom,$configPath,$configPagePath)
9869
+	public function loadPageConfigurationFromXml($dom, $configPath, $configPagePath)
9870 9870
 	{
9871
-				if(($authorizationNode=$dom->getElementByTagName('authorization'))!==null)
9871
+				if (($authorizationNode = $dom->getElementByTagName('authorization')) !== null)
9872 9872
 		{
9873
-			$rules=array();
9874
-			foreach($authorizationNode->getElements() as $node)
9873
+			$rules = array();
9874
+			foreach ($authorizationNode->getElements() as $node)
9875 9875
 			{
9876
-				$patterns=$node->getAttribute('pages');
9877
-				$ruleApplies=false;
9878
-				if(empty($patterns) || trim($patterns)==='*') 					$ruleApplies=true;
9876
+				$patterns = $node->getAttribute('pages');
9877
+				$ruleApplies = false;
9878
+				if (empty($patterns) || trim($patterns) === '*') 					$ruleApplies = true;
9879 9879
 				else
9880 9880
 				{
9881
-					foreach(explode(',',$patterns) as $pattern)
9881
+					foreach (explode(',', $patterns) as $pattern)
9882 9882
 					{
9883
-						if(($pattern=trim($pattern))!=='')
9883
+						if (($pattern = trim($pattern)) !== '')
9884 9884
 						{
9885
-														if($configPagePath!=='')  								$pattern=$configPagePath.'.'.$pattern;
9886
-							if(strcasecmp($pattern,$this->_pagePath)===0)
9885
+														if ($configPagePath !== '')  								$pattern = $configPagePath . '.' . $pattern;
9886
+							if (strcasecmp($pattern, $this->_pagePath) === 0)
9887 9887
 							{
9888
-								$ruleApplies=true;
9888
+								$ruleApplies = true;
9889 9889
 								break;
9890 9890
 							}
9891
-							if($pattern[strlen($pattern)-1]==='*') 							{
9892
-								if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0)
9891
+							if ($pattern[strlen($pattern) - 1] === '*') {
9892
+								if (strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0)
9893 9893
 								{
9894
-									$ruleApplies=true;
9894
+									$ruleApplies = true;
9895 9895
 									break;
9896 9896
 								}
9897 9897
 							}
9898 9898
 						}
9899 9899
 					}
9900 9900
 				}
9901
-				if($ruleApplies)
9902
-					$rules[]=new TAuthorizationRule($node->getTagName(),$node->getAttribute('users'),$node->getAttribute('roles'),$node->getAttribute('verb'),$node->getAttribute('ips'));
9901
+				if ($ruleApplies)
9902
+					$rules[] = new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips'));
9903 9903
 			}
9904
-			$this->_rules=array_merge($rules,$this->_rules);
9904
+			$this->_rules = array_merge($rules, $this->_rules);
9905 9905
 		}
9906
-				if(($pagesNode=$dom->getElementByTagName('pages'))!==null)
9906
+				if (($pagesNode = $dom->getElementByTagName('pages')) !== null)
9907 9907
 		{
9908
-			$this->_properties=array_merge($this->_properties,$pagesNode->getAttributes()->toArray());
9909
-						foreach($pagesNode->getElementsByTagName('page') as $node)
9908
+			$this->_properties = array_merge($this->_properties, $pagesNode->getAttributes()->toArray());
9909
+						foreach ($pagesNode->getElementsByTagName('page') as $node)
9910 9910
 			{
9911
-				$properties=$node->getAttributes();
9912
-				$id=$properties->remove('id');
9913
-				if(empty($id))
9914
-					throw new TConfigurationException('pageserviceconf_page_invalid',$configPath);
9915
-				$matching=false;
9916
-				$id=($configPagePath==='')?$id:$configPagePath.'.'.$id;
9917
-				if(strcasecmp($id,$this->_pagePath)===0)
9918
-					$matching=true;
9919
-				else if($id[strlen($id)-1]==='*') 					$matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0;
9920
-				if($matching)
9921
-					$this->_properties=array_merge($this->_properties,$properties->toArray());
9911
+				$properties = $node->getAttributes();
9912
+				$id = $properties->remove('id');
9913
+				if (empty($id))
9914
+					throw new TConfigurationException('pageserviceconf_page_invalid', $configPath);
9915
+				$matching = false;
9916
+				$id = ($configPagePath === '') ? $id : $configPagePath . '.' . $id;
9917
+				if (strcasecmp($id, $this->_pagePath) === 0)
9918
+					$matching = true;
9919
+				else if ($id[strlen($id) - 1] === '*') 					$matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0;
9920
+				if ($matching)
9921
+					$this->_properties = array_merge($this->_properties, $properties->toArray());
9922 9922
 			}
9923 9923
 		}
9924
-				foreach($dom->getElementsByTagName('include') as $node)
9924
+				foreach ($dom->getElementsByTagName('include') as $node)
9925 9925
 		{
9926
-			if(($when=$node->getAttribute('when'))===null)
9927
-				$when=true;
9928
-			if(($filePath=$node->getAttribute('file'))===null)
9926
+			if (($when = $node->getAttribute('when')) === null)
9927
+				$when = true;
9928
+			if (($filePath = $node->getAttribute('file')) === null)
9929 9929
 				throw new TConfigurationException('pageserviceconf_includefile_required');
9930
-			if(isset($this->_includes[$filePath]))
9931
-				$this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')');
9930
+			if (isset($this->_includes[$filePath]))
9931
+				$this->_includes[$filePath] = array($configPagePath, '(' . $this->_includes[$filePath][1] . ') || (' . $when . ')');
9932 9932
 			else
9933
-				$this->_includes[$filePath]=array($configPagePath,$when);
9933
+				$this->_includes[$filePath] = array($configPagePath, $when);
9934 9934
 		}
9935 9935
 	}
9936 9936
 }
9937 9937
 class TAssetManager extends TModule
9938 9938
 {
9939
-	const DEFAULT_BASEPATH='assets';
9940
-	private $_basePath=null;
9941
-	private $_baseUrl=null;
9942
-	private $_checkTimestamp=false;
9939
+	const DEFAULT_BASEPATH = 'assets';
9940
+	private $_basePath = null;
9941
+	private $_baseUrl = null;
9942
+	private $_checkTimestamp = false;
9943 9943
 	private $_application;
9944
-	private $_published=array();
9945
-	private $_initialized=false;
9944
+	private $_published = array();
9945
+	private $_initialized = false;
9946 9946
 	public function init($config)
9947 9947
 	{
9948
-		$application=$this->getApplication();
9949
-		if($this->_basePath===null)
9950
-			$this->_basePath=dirname($application->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH;
9951
-		if(!is_writable($this->_basePath) || !is_dir($this->_basePath))
9952
-			throw new TConfigurationException('assetmanager_basepath_invalid',$this->_basePath);
9953
-		if($this->_baseUrl===null)
9954
-			$this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()),'/\\').'/'.self::DEFAULT_BASEPATH;
9948
+		$application = $this->getApplication();
9949
+		if ($this->_basePath === null)
9950
+			$this->_basePath = dirname($application->getRequest()->getApplicationFilePath()) . DIRECTORY_SEPARATOR . self::DEFAULT_BASEPATH;
9951
+		if (!is_writable($this->_basePath) || !is_dir($this->_basePath))
9952
+			throw new TConfigurationException('assetmanager_basepath_invalid', $this->_basePath);
9953
+		if ($this->_baseUrl === null)
9954
+			$this->_baseUrl = rtrim(dirname($application->getRequest()->getApplicationUrl()), '/\\') . '/' . self::DEFAULT_BASEPATH;
9955 9955
 		$application->setAssetManager($this);
9956
-		$this->_initialized=true;
9956
+		$this->_initialized = true;
9957 9957
 	}
9958 9958
 	public function getBasePath()
9959 9959
 	{
@@ -9961,13 +9961,13 @@  discard block
 block discarded – undo
9961 9961
 	}
9962 9962
 	public function setBasePath($value)
9963 9963
 	{
9964
-		if($this->_initialized)
9964
+		if ($this->_initialized)
9965 9965
 			throw new TInvalidOperationException('assetmanager_basepath_unchangeable');
9966 9966
 		else
9967 9967
 		{
9968
-			$this->_basePath=Prado::getPathOfNamespace($value);
9969
-			if($this->_basePath===null || !is_dir($this->_basePath) || !is_writable($this->_basePath))
9970
-				throw new TInvalidDataValueException('assetmanager_basepath_invalid',$value);
9968
+			$this->_basePath = Prado::getPathOfNamespace($value);
9969
+			if ($this->_basePath === null || !is_dir($this->_basePath) || !is_writable($this->_basePath))
9970
+				throw new TInvalidDataValueException('assetmanager_basepath_invalid', $value);
9971 9971
 		}
9972 9972
 	}
9973 9973
 	public function getBaseUrl()
@@ -9976,132 +9976,132 @@  discard block
 block discarded – undo
9976 9976
 	}
9977 9977
 	public function setBaseUrl($value)
9978 9978
 	{
9979
-		if($this->_initialized)
9979
+		if ($this->_initialized)
9980 9980
 			throw new TInvalidOperationException('assetmanager_baseurl_unchangeable');
9981 9981
 		else
9982
-			$this->_baseUrl=rtrim($value,'/');
9982
+			$this->_baseUrl = rtrim($value, '/');
9983 9983
 	}
9984
-	public function publishFilePath($path,$checkTimestamp=false)
9984
+	public function publishFilePath($path, $checkTimestamp = false)
9985 9985
 	{
9986
-		if(isset($this->_published[$path]))
9986
+		if (isset($this->_published[$path]))
9987 9987
 			return $this->_published[$path];
9988
-		else if(empty($path) || ($fullpath=realpath($path))===false)
9989
-			throw new TInvalidDataValueException('assetmanager_filepath_invalid',$path);
9990
-		else if(is_file($fullpath))
9988
+		else if (empty($path) || ($fullpath = realpath($path)) === false)
9989
+			throw new TInvalidDataValueException('assetmanager_filepath_invalid', $path);
9990
+		else if (is_file($fullpath))
9991 9991
 		{
9992
-			$dir=$this->hash(dirname($fullpath));
9993
-			$fileName=basename($fullpath);
9994
-			$dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir;
9995
-			if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance)
9996
-				$this->copyFile($fullpath,$dst);
9997
-			return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName;
9992
+			$dir = $this->hash(dirname($fullpath));
9993
+			$fileName = basename($fullpath);
9994
+			$dst = $this->_basePath . DIRECTORY_SEPARATOR . $dir;
9995
+			if (!is_file($dst . DIRECTORY_SEPARATOR . $fileName) || $checkTimestamp || $this->getApplication()->getMode() !== TApplicationMode::Performance)
9996
+				$this->copyFile($fullpath, $dst);
9997
+			return $this->_published[$path] = $this->_baseUrl . '/' . $dir . '/' . $fileName;
9998 9998
 		}
9999 9999
 		else
10000 10000
 		{
10001
-			$dir=$this->hash($fullpath);
10002
-			if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance)
10001
+			$dir = $this->hash($fullpath);
10002
+			if (!is_dir($this->_basePath . DIRECTORY_SEPARATOR . $dir) || $checkTimestamp || $this->getApplication()->getMode() !== TApplicationMode::Performance)
10003 10003
 			{
10004
-				$this->copyDirectory($fullpath,$this->_basePath.DIRECTORY_SEPARATOR.$dir);
10004
+				$this->copyDirectory($fullpath, $this->_basePath . DIRECTORY_SEPARATOR . $dir);
10005 10005
 			}
10006
-			return $this->_published[$path]=$this->_baseUrl.'/'.$dir;
10006
+			return $this->_published[$path] = $this->_baseUrl . '/' . $dir;
10007 10007
 		}
10008 10008
 	}
10009 10009
 	public function getPublished()
10010 10010
 	{
10011 10011
 		return $this->_published;
10012 10012
 	}
10013
-	protected function setPublished($values=array())
10013
+	protected function setPublished($values = array())
10014 10014
 	{
10015 10015
 		$this->_published = $values;
10016 10016
 	}
10017 10017
 	public function getPublishedPath($path)
10018 10018
 	{
10019
-		$path=realpath($path);
10020
-		if(is_file($path))
10021
-			return $this->_basePath.DIRECTORY_SEPARATOR.$this->hash(dirname($path)).DIRECTORY_SEPARATOR.basename($path);
10019
+		$path = realpath($path);
10020
+		if (is_file($path))
10021
+			return $this->_basePath . DIRECTORY_SEPARATOR . $this->hash(dirname($path)) . DIRECTORY_SEPARATOR . basename($path);
10022 10022
 		else
10023
-			return $this->_basePath.DIRECTORY_SEPARATOR.$this->hash($path);
10023
+			return $this->_basePath . DIRECTORY_SEPARATOR . $this->hash($path);
10024 10024
 	}
10025 10025
 	public function getPublishedUrl($path)
10026 10026
 	{
10027
-		$path=realpath($path);
10028
-		if(is_file($path))
10029
-			return $this->_baseUrl.'/'.$this->hash(dirname($path)).'/'.basename($path);
10027
+		$path = realpath($path);
10028
+		if (is_file($path))
10029
+			return $this->_baseUrl . '/' . $this->hash(dirname($path)) . '/' . basename($path);
10030 10030
 		else
10031
-			return $this->_baseUrl.'/'.$this->hash($path);
10031
+			return $this->_baseUrl . '/' . $this->hash($path);
10032 10032
 	}
10033 10033
 	protected function hash($dir)
10034 10034
 	{
10035
-		return sprintf('%x',crc32($dir.Prado::getVersion()));
10035
+		return sprintf('%x', crc32($dir . Prado::getVersion()));
10036 10036
 	}
10037
-	protected function copyFile($src,$dst)
10037
+	protected function copyFile($src, $dst)
10038 10038
 	{
10039
-		if(!is_dir($dst))
10039
+		if (!is_dir($dst))
10040 10040
 		{
10041 10041
 			@mkdir($dst);
10042 10042
 			@chmod($dst, PRADO_CHMOD);
10043 10043
 		}
10044
-		$dstFile=$dst.DIRECTORY_SEPARATOR.basename($src);
10045
-		if(@filemtime($dstFile)<@filemtime($src))
10044
+		$dstFile = $dst . DIRECTORY_SEPARATOR . basename($src);
10045
+		if (@filemtime($dstFile) < @filemtime($src))
10046 10046
 		{
10047
-			@copy($src,$dstFile);
10047
+			@copy($src, $dstFile);
10048 10048
 		}
10049 10049
 	}
10050
-	public function copyDirectory($src,$dst)
10050
+	public function copyDirectory($src, $dst)
10051 10051
 	{
10052
-		if(!is_dir($dst))
10052
+		if (!is_dir($dst))
10053 10053
 		{
10054 10054
 			@mkdir($dst);
10055 10055
 			@chmod($dst, PRADO_CHMOD);
10056 10056
 		}
10057
-		if($folder=@opendir($src))
10057
+		if ($folder = @opendir($src))
10058 10058
 		{
10059
-			while($file=@readdir($folder))
10059
+			while ($file = @readdir($folder))
10060 10060
 			{
10061
-				if($file==='.' || $file==='..' || $file==='.svn')
10061
+				if ($file === '.' || $file === '..' || $file === '.svn')
10062 10062
 					continue;
10063
-				else if(is_file($src.DIRECTORY_SEPARATOR.$file))
10063
+				else if (is_file($src . DIRECTORY_SEPARATOR . $file))
10064 10064
 				{
10065
-					if(@filemtime($dst.DIRECTORY_SEPARATOR.$file)<@filemtime($src.DIRECTORY_SEPARATOR.$file))
10065
+					if (@filemtime($dst . DIRECTORY_SEPARATOR . $file) < @filemtime($src . DIRECTORY_SEPARATOR . $file))
10066 10066
 					{
10067
-						@copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file);
10068
-						@chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD);
10067
+						@copy($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file);
10068
+						@chmod($dst . DIRECTORY_SEPARATOR . $file, PRADO_CHMOD);
10069 10069
 					}
10070 10070
 				}
10071 10071
 				else
10072
-					$this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file);
10072
+					$this->copyDirectory($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file);
10073 10073
 			}
10074 10074
 			closedir($folder);
10075 10075
 		} else {
10076 10076
 			throw new TInvalidDataValueException('assetmanager_source_directory_invalid', $src);
10077 10077
 		}
10078 10078
 	}
10079
-	public function publishTarFile($tarfile, $md5sum, $checkTimestamp=false)
10079
+	public function publishTarFile($tarfile, $md5sum, $checkTimestamp = false)
10080 10080
 	{
10081
-		if(isset($this->_published[$md5sum]))
10081
+		if (isset($this->_published[$md5sum]))
10082 10082
 			return $this->_published[$md5sum];
10083
-		else if(($fullpath=realpath($md5sum))===false || !is_file($fullpath))
10084
-			throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid',$md5sum);
10083
+		else if (($fullpath = realpath($md5sum)) === false || !is_file($fullpath))
10084
+			throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid', $md5sum);
10085 10085
 		else
10086 10086
 		{
10087
-			$dir=$this->hash(dirname($fullpath));
10088
-			$fileName=basename($fullpath);
10089
-			$dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir;
10090
-			if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance)
10087
+			$dir = $this->hash(dirname($fullpath));
10088
+			$fileName = basename($fullpath);
10089
+			$dst = $this->_basePath . DIRECTORY_SEPARATOR . $dir;
10090
+			if (!is_file($dst . DIRECTORY_SEPARATOR . $fileName) || $checkTimestamp || $this->getApplication()->getMode() !== TApplicationMode::Performance)
10091 10091
 			{
10092
-				if(@filemtime($dst.DIRECTORY_SEPARATOR.$fileName)<@filemtime($fullpath))
10092
+				if (@filemtime($dst . DIRECTORY_SEPARATOR . $fileName) < @filemtime($fullpath))
10093 10093
 				{
10094
-					$this->copyFile($fullpath,$dst);
10095
-					$this->deployTarFile($tarfile,$dst);
10094
+					$this->copyFile($fullpath, $dst);
10095
+					$this->deployTarFile($tarfile, $dst);
10096 10096
 				}
10097 10097
 			}
10098
-			return $this->_published[$md5sum]=$this->_baseUrl.'/'.$dir;
10098
+			return $this->_published[$md5sum] = $this->_baseUrl . '/' . $dir;
10099 10099
 		}
10100 10100
 	}
10101
-	protected function deployTarFile($path,$destination)
10101
+	protected function deployTarFile($path, $destination)
10102 10102
 	{
10103
-		if(($fullpath=realpath($path))===false || !is_file($fullpath))
10104
-			throw new TIOException('assetmanager_tarfile_invalid',$path);
10103
+		if (($fullpath = realpath($path)) === false || !is_file($fullpath))
10104
+			throw new TIOException('assetmanager_tarfile_invalid', $path);
10105 10105
 		else
10106 10106
 		{
10107 10107
 			Prado::using('System.IO.TTarFileExtractor');
@@ -10114,26 +10114,26 @@  discard block
 block discarded – undo
10114 10114
 {
10115 10115
 	private $_defaultCharset = 'UTF-8';
10116 10116
 	private $_defaultCulture = 'en';
10117
-	private $_charset=null;
10118
-	private $_culture=null;
10117
+	private $_charset = null;
10118
+	private $_culture = null;
10119 10119
 	private $_translation;
10120
-	private $_translateDefaultCulture=true;
10120
+	private $_translateDefaultCulture = true;
10121 10121
 	public function init($config)
10122 10122
 	{
10123
-		if($this->_charset===null)
10124
-			$this->_charset=$this->getDefaultCharset();
10125
-		if($this->_culture===null)
10126
-			$this->_culture=$this->getDefaultCulture();
10127
-		if($config!==null)
10123
+		if ($this->_charset === null)
10124
+			$this->_charset = $this->getDefaultCharset();
10125
+		if ($this->_culture === null)
10126
+			$this->_culture = $this->getDefaultCulture();
10127
+		if ($config !== null)
10128 10128
 		{
10129
-			if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
10130
-				$translation = isset($config['translate'])?$config['translate']:null;
10129
+			if ($this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
10130
+				$translation = isset($config['translate']) ? $config['translate'] : null;
10131 10131
 			else
10132 10132
 			{
10133 10133
 				$t = $config->getElementByTagName('translation');
10134
-				$translation = ($t)?$t->getAttributes():null;
10134
+				$translation = ($t) ? $t->getAttributes() : null;
10135 10135
 			}
10136
-			if($translation)
10136
+			if ($translation)
10137 10137
 				$this->setTranslationConfiguration($translation);
10138 10138
 		}
10139 10139
 		$this->getApplication()->setGlobalization($this);
@@ -10152,7 +10152,7 @@  discard block
 block discarded – undo
10152 10152
 	}
10153 10153
 	public function setDefaultCulture($culture)
10154 10154
 	{
10155
-		$this->_defaultCulture = str_replace('-','_',$culture);
10155
+		$this->_defaultCulture = str_replace('-', '_', $culture);
10156 10156
 	}
10157 10157
 	public function getDefaultCharset()
10158 10158
 	{
@@ -10168,7 +10168,7 @@  discard block
 block discarded – undo
10168 10168
 	}
10169 10169
 	public function setCulture($culture)
10170 10170
 	{
10171
-		$this->_culture = str_replace('-','_',$culture);
10171
+		$this->_culture = str_replace('-', '_', $culture);
10172 10172
 	}
10173 10173
 	public function getCharset()
10174 10174
 	{
@@ -10186,32 +10186,32 @@  discard block
 block discarded – undo
10186 10186
 	}
10187 10187
 	protected function setTranslationConfiguration($config)
10188 10188
 	{
10189
-		if($config['type'] == 'XLIFF' || $config['type'] == 'gettext')
10189
+		if ($config['type'] == 'XLIFF' || $config['type'] == 'gettext')
10190 10190
 		{
10191
-			if($config['source'])
10191
+			if ($config['source'])
10192 10192
 			{
10193 10193
 				$config['source'] = Prado::getPathOfNamespace($config['source']);
10194
-				if(!is_dir($config['source']))
10194
+				if (!is_dir($config['source']))
10195 10195
 				{
10196
-					if(@mkdir($config['source'])===false)
10196
+					if (@mkdir($config['source']) === false)
10197 10197
 					throw new TConfigurationException('globalization_source_path_failed',
10198 10198
 						$config['source']);
10199
-					chmod($config['source'], PRADO_CHMOD); 				}
10199
+					chmod($config['source'], PRADO_CHMOD); }
10200 10200
 			}
10201 10201
 			else
10202 10202
 			{
10203 10203
 				throw new TConfigurationException("invalid source dir '{$config['source']}'");
10204 10204
 			}
10205 10205
 		}
10206
-		if($config['cache'])
10206
+		if ($config['cache'])
10207 10207
 		{
10208
-			$config['cache'] = $this->getApplication()->getRunTimePath().'/i18n';
10209
-			if(!is_dir($config['cache']))
10208
+			$config['cache'] = $this->getApplication()->getRunTimePath() . '/i18n';
10209
+			if (!is_dir($config['cache']))
10210 10210
 			{
10211
-				if(@mkdir($config['cache'])===false)
10211
+				if (@mkdir($config['cache']) === false)
10212 10212
 					throw new TConfigurationException('globalization_cache_path_failed',
10213 10213
 						$config['cache']);
10214
-				chmod($config['cache'], PRADO_CHMOD); 			}
10214
+				chmod($config['cache'], PRADO_CHMOD); }
10215 10215
 		}
10216 10216
 		$this->_translation = $config;
10217 10217
 	}
@@ -10223,46 +10223,46 @@  discard block
 block discarded – undo
10223 10223
 	{
10224 10224
 		$this->_translation['catalogue'] = $value;
10225 10225
 	}
10226
-	public function getCultureVariants($culture=null)
10226
+	public function getCultureVariants($culture = null)
10227 10227
 	{
10228
-		if($culture===null) $culture = $this->getCulture();
10228
+		if ($culture === null) $culture = $this->getCulture();
10229 10229
 		$variants = explode('_', $culture);
10230 10230
 		$result = array();
10231
-		for(; count($variants) > 0; array_pop($variants))
10231
+		for (; count($variants) > 0; array_pop($variants))
10232 10232
 			$result[] = implode('_', $variants);
10233 10233
 		return $result;
10234 10234
 	}
10235
-	public function getLocalizedResource($file,$culture=null)
10235
+	public function getLocalizedResource($file, $culture = null)
10236 10236
 	{
10237 10237
 		$files = array();
10238 10238
 		$variants = $this->getCultureVariants($culture);
10239 10239
 		$path = pathinfo($file);
10240
-		foreach($variants as $variant)
10241
-			$files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename'];
10242
-		$filename = substr($path['basename'],0,strrpos($path['basename'],'.'));
10243
-		foreach($variants as $variant)
10244
-			$files[] = $path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension'];
10240
+		foreach ($variants as $variant)
10241
+			$files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $variant . DIRECTORY_SEPARATOR . $path['basename'];
10242
+		$filename = substr($path['basename'], 0, strrpos($path['basename'], '.'));
10243
+		foreach ($variants as $variant)
10244
+			$files[] = $path['dirname'] . DIRECTORY_SEPARATOR . $filename . '.' . $variant . '.' . $path['extension'];
10245 10245
 		$files[] = $file;
10246 10246
 		return $files;
10247 10247
 	}
10248 10248
 }
10249 10249
 class TApplication extends TComponent
10250 10250
 {
10251
-	const STATE_OFF='Off';
10252
-	const STATE_DEBUG='Debug';
10253
-	const STATE_NORMAL='Normal';
10254
-	const STATE_PERFORMANCE='Performance';
10255
-	const PAGE_SERVICE_ID='page';
10256
-	const CONFIG_FILE_XML='application.xml';
10257
-	const CONFIG_FILE_EXT_XML='.xml';
10251
+	const STATE_OFF = 'Off';
10252
+	const STATE_DEBUG = 'Debug';
10253
+	const STATE_NORMAL = 'Normal';
10254
+	const STATE_PERFORMANCE = 'Performance';
10255
+	const PAGE_SERVICE_ID = 'page';
10256
+	const CONFIG_FILE_XML = 'application.xml';
10257
+	const CONFIG_FILE_EXT_XML = '.xml';
10258 10258
 	const CONFIG_TYPE_XML = 'xml';
10259
-	const CONFIG_FILE_PHP='application.php';
10260
-	const CONFIG_FILE_EXT_PHP='.php';
10259
+	const CONFIG_FILE_PHP = 'application.php';
10260
+	const CONFIG_FILE_EXT_PHP = '.php';
10261 10261
 	const CONFIG_TYPE_PHP = 'php';
10262
-	const RUNTIME_PATH='runtime';
10263
-	const CONFIGCACHE_FILE='config.cache';
10264
-	const GLOBAL_FILE='global.cache';
10265
-	private static $_steps=array(
10262
+	const RUNTIME_PATH = 'runtime';
10263
+	const CONFIGCACHE_FILE = 'config.cache';
10264
+	const GLOBAL_FILE = 'global.cache';
10265
+	private static $_steps = array(
10266 10266
 		'onBeginRequest',
10267 10267
 		'onLoadState',
10268 10268
 		'onLoadStateComplete',
@@ -10279,20 +10279,20 @@  discard block
 block discarded – undo
10279 10279
 	);
10280 10280
 	private $_id;
10281 10281
 	private $_uniqueID;
10282
-	private $_requestCompleted=false;
10282
+	private $_requestCompleted = false;
10283 10283
 	private $_step;
10284 10284
 	private $_services;
10285 10285
 	private $_service;
10286
-	private $_modules=array();
10287
-	private $_lazyModules=array();
10286
+	private $_modules = array();
10287
+	private $_lazyModules = array();
10288 10288
 	private $_parameters;
10289 10289
 	private $_configFile;
10290 10290
 	private $_configFileExt;
10291 10291
 	private $_configType;
10292 10292
 	private $_basePath;
10293 10293
 	private $_runtimePath;
10294
-	private $_stateChanged=false;
10295
-	private $_globals=array();
10294
+	private $_stateChanged = false;
10295
+	private $_globals = array();
10296 10296
 	private $_cacheFile;
10297 10297
 	private $_errorHandler;
10298 10298
 	private $_request;
@@ -10305,72 +10305,72 @@  discard block
 block discarded – undo
10305 10305
 	private $_security;
10306 10306
 	private $_assetManager;
10307 10307
 	private $_authRules;
10308
-	private $_mode=TApplicationMode::Debug;
10308
+	private $_mode = TApplicationMode::Debug;
10309 10309
 	private $_pageServiceID = self::PAGE_SERVICE_ID;
10310
-	public function __construct($basePath='protected',$cacheConfig=true, $configType=self::CONFIG_TYPE_XML)
10310
+	public function __construct($basePath = 'protected', $cacheConfig = true, $configType = self::CONFIG_TYPE_XML)
10311 10311
 	{
10312 10312
 				Prado::setApplication($this);
10313 10313
 		$this->setConfigurationType($configType);
10314 10314
 		$this->resolvePaths($basePath);
10315
-		if($cacheConfig)
10316
-			$this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE;
10317
-				$this->_uniqueID=md5($this->_runtimePath);
10318
-		$this->_parameters=new TMap;
10319
-		$this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null));
10320
-		Prado::setPathOfAlias('Application',$this->_basePath);
10315
+		if ($cacheConfig)
10316
+			$this->_cacheFile = $this->_runtimePath . DIRECTORY_SEPARATOR . self::CONFIGCACHE_FILE;
10317
+				$this->_uniqueID = md5($this->_runtimePath);
10318
+		$this->_parameters = new TMap;
10319
+		$this->_services = array($this->getPageServiceID()=>array('TPageService', array(), null));
10320
+		Prado::setPathOfAlias('Application', $this->_basePath);
10321 10321
 	}
10322 10322
 	protected function resolvePaths($basePath)
10323 10323
 	{
10324
-				if(empty($basePath) || ($basePath=realpath($basePath))===false)
10325
-			throw new TConfigurationException('application_basepath_invalid',$basePath);
10326
-		if(is_dir($basePath) && is_file($basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName()))
10327
-			$configFile=$basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName();
10328
-		else if(is_file($basePath))
10324
+				if (empty($basePath) || ($basePath = realpath($basePath)) === false)
10325
+			throw new TConfigurationException('application_basepath_invalid', $basePath);
10326
+		if (is_dir($basePath) && is_file($basePath . DIRECTORY_SEPARATOR . $this->getConfigurationFileName()))
10327
+			$configFile = $basePath . DIRECTORY_SEPARATOR . $this->getConfigurationFileName();
10328
+		else if (is_file($basePath))
10329 10329
 		{
10330
-			$configFile=$basePath;
10331
-			$basePath=dirname($configFile);
10330
+			$configFile = $basePath;
10331
+			$basePath = dirname($configFile);
10332 10332
 		}
10333 10333
 		else
10334
-			$configFile=null;
10335
-				$runtimePath=$basePath.DIRECTORY_SEPARATOR.self::RUNTIME_PATH;
10336
-		if(is_writable($runtimePath))
10334
+			$configFile = null;
10335
+				$runtimePath = $basePath . DIRECTORY_SEPARATOR . self::RUNTIME_PATH;
10336
+		if (is_writable($runtimePath))
10337 10337
 		{
10338
-			if($configFile!==null)
10338
+			if ($configFile !== null)
10339 10339
 			{
10340
-				$runtimePath.=DIRECTORY_SEPARATOR.basename($configFile).'-'.Prado::getVersion();
10341
-				if(!is_dir($runtimePath))
10340
+				$runtimePath .= DIRECTORY_SEPARATOR . basename($configFile) . '-' . Prado::getVersion();
10341
+				if (!is_dir($runtimePath))
10342 10342
 				{
10343
-					if(@mkdir($runtimePath)===false)
10344
-						throw new TConfigurationException('application_runtimepath_failed',$runtimePath);
10345
-					@chmod($runtimePath, PRADO_CHMOD); 				}
10343
+					if (@mkdir($runtimePath) === false)
10344
+						throw new TConfigurationException('application_runtimepath_failed', $runtimePath);
10345
+					@chmod($runtimePath, PRADO_CHMOD); }
10346 10346
 				$this->setConfigurationFile($configFile);
10347 10347
 			}
10348 10348
 			$this->setBasePath($basePath);
10349 10349
 			$this->setRuntimePath($runtimePath);
10350 10350
 		}
10351 10351
 		else
10352
-			throw new TConfigurationException('application_runtimepath_invalid',$runtimePath);
10352
+			throw new TConfigurationException('application_runtimepath_invalid', $runtimePath);
10353 10353
 	}
10354 10354
 	public function run()
10355 10355
 	{
10356 10356
 		try
10357 10357
 		{
10358 10358
 			$this->initApplication();
10359
-			$n=count(self::$_steps);
10360
-			$this->_step=0;
10361
-			$this->_requestCompleted=false;
10362
-			while($this->_step<$n)
10363
-			{
10364
-				if($this->_mode===self::STATE_OFF)
10365
-					throw new THttpException(503,'application_unavailable');
10366
-				if($this->_requestCompleted)
10359
+			$n = count(self::$_steps);
10360
+			$this->_step = 0;
10361
+			$this->_requestCompleted = false;
10362
+			while ($this->_step < $n)
10363
+			{
10364
+				if ($this->_mode === self::STATE_OFF)
10365
+					throw new THttpException(503, 'application_unavailable');
10366
+				if ($this->_requestCompleted)
10367 10367
 					break;
10368
-				$method=self::$_steps[$this->_step];
10368
+				$method = self::$_steps[$this->_step];
10369 10369
 				$this->$method();
10370 10370
 				$this->_step++;
10371 10371
 			}
10372 10372
 		}
10373
-		catch(Exception $e)
10373
+		catch (Exception $e)
10374 10374
 		{
10375 10375
 			$this->onError($e);
10376 10376
 		}
@@ -10378,40 +10378,40 @@  discard block
 block discarded – undo
10378 10378
 	}
10379 10379
 	public function completeRequest()
10380 10380
 	{
10381
-		$this->_requestCompleted=true;
10381
+		$this->_requestCompleted = true;
10382 10382
 	}
10383 10383
 	public function getRequestCompleted()
10384 10384
 	{
10385 10385
 		return $this->_requestCompleted;
10386 10386
 	}
10387
-	public function getGlobalState($key,$defaultValue=null)
10387
+	public function getGlobalState($key, $defaultValue = null)
10388 10388
 	{
10389
-		return isset($this->_globals[$key])?$this->_globals[$key]:$defaultValue;
10389
+		return isset($this->_globals[$key]) ? $this->_globals[$key] : $defaultValue;
10390 10390
 	}
10391
-	public function setGlobalState($key,$value,$defaultValue=null,$forceSave=false)
10391
+	public function setGlobalState($key, $value, $defaultValue = null, $forceSave = false)
10392 10392
 	{
10393
-		$this->_stateChanged=true;
10394
-		if($value===$defaultValue)
10393
+		$this->_stateChanged = true;
10394
+		if ($value === $defaultValue)
10395 10395
 			unset($this->_globals[$key]);
10396 10396
 		else
10397
-			$this->_globals[$key]=$value;
10398
-		if($forceSave)
10397
+			$this->_globals[$key] = $value;
10398
+		if ($forceSave)
10399 10399
 			$this->saveGlobals();
10400 10400
 	}
10401 10401
 	public function clearGlobalState($key)
10402 10402
 	{
10403
-		$this->_stateChanged=true;
10403
+		$this->_stateChanged = true;
10404 10404
 		unset($this->_globals[$key]);
10405 10405
 	}
10406 10406
 	protected function loadGlobals()
10407 10407
 	{
10408
-		$this->_globals=$this->getApplicationStatePersister()->load();
10408
+		$this->_globals = $this->getApplicationStatePersister()->load();
10409 10409
 	}
10410 10410
 	protected function saveGlobals()
10411 10411
 	{
10412
-		if($this->_stateChanged)
10412
+		if ($this->_stateChanged)
10413 10413
 		{
10414
-			$this->_stateChanged=false;
10414
+			$this->_stateChanged = false;
10415 10415
 			$this->getApplicationStatePersister()->save($this->_globals);
10416 10416
 		}
10417 10417
 	}
@@ -10421,7 +10421,7 @@  discard block
 block discarded – undo
10421 10421
 	}
10422 10422
 	public function setID($value)
10423 10423
 	{
10424
-		$this->_id=$value;
10424
+		$this->_id = $value;
10425 10425
 	}
10426 10426
 	public function getPageServiceID()
10427 10427
 	{
@@ -10429,7 +10429,7 @@  discard block
 block discarded – undo
10429 10429
 	}
10430 10430
 	public function setPageServiceID($value)
10431 10431
 	{
10432
-		$this->_pageServiceID=$value;
10432
+		$this->_pageServiceID = $value;
10433 10433
 	}
10434 10434
 	public function getUniqueID()
10435 10435
 	{
@@ -10441,7 +10441,7 @@  discard block
 block discarded – undo
10441 10441
 	}
10442 10442
 	public function setMode($value)
10443 10443
 	{
10444
-		$this->_mode=TPropertyValue::ensureEnum($value,'TApplicationMode');
10444
+		$this->_mode = TPropertyValue::ensureEnum($value, 'TApplicationMode');
10445 10445
 	}
10446 10446
 	public function getBasePath()
10447 10447
 	{
@@ -10449,7 +10449,7 @@  discard block
 block discarded – undo
10449 10449
 	}
10450 10450
 	public function setBasePath($value)
10451 10451
 	{
10452
-		$this->_basePath=$value;
10452
+		$this->_basePath = $value;
10453 10453
 	}
10454 10454
 	public function getConfigurationFile()
10455 10455
 	{
@@ -10457,7 +10457,7 @@  discard block
 block discarded – undo
10457 10457
 	}
10458 10458
 	public function setConfigurationFile($value)
10459 10459
 	{
10460
-		$this->_configFile=$value;
10460
+		$this->_configFile = $value;
10461 10461
 	}
10462 10462
 	public function getConfigurationType()
10463 10463
 	{
@@ -10469,9 +10469,9 @@  discard block
 block discarded – undo
10469 10469
 	}
10470 10470
 	public function getConfigurationFileExt()
10471 10471
 	{
10472
-		if($this->_configFileExt===null)
10472
+		if ($this->_configFileExt === null)
10473 10473
 		{
10474
-			switch($this->_configType)
10474
+			switch ($this->_configType)
10475 10475
 			{
10476 10476
 				case TApplication::CONFIG_TYPE_PHP:
10477 10477
 					$this->_configFileExt = TApplication::CONFIG_FILE_EXT_PHP;
@@ -10485,9 +10485,9 @@  discard block
 block discarded – undo
10485 10485
 	public function getConfigurationFileName()
10486 10486
 	{
10487 10487
 		static $fileName;
10488
-		if($fileName == null)
10488
+		if ($fileName == null)
10489 10489
 		{
10490
-			switch($this->_configType)
10490
+			switch ($this->_configType)
10491 10491
 			{
10492 10492
 				case TApplication::CONFIG_TYPE_PHP:
10493 10493
 					$fileName = TApplication::CONFIG_FILE_PHP;
@@ -10504,10 +10504,10 @@  discard block
 block discarded – undo
10504 10504
 	}
10505 10505
 	public function setRuntimePath($value)
10506 10506
 	{
10507
-		$this->_runtimePath=$value;
10508
-		if($this->_cacheFile)
10509
-			$this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE;
10510
-				$this->_uniqueID=md5($this->_runtimePath);
10507
+		$this->_runtimePath = $value;
10508
+		if ($this->_cacheFile)
10509
+			$this->_cacheFile = $this->_runtimePath . DIRECTORY_SEPARATOR . self::CONFIGCACHE_FILE;
10510
+				$this->_uniqueID = md5($this->_runtimePath);
10511 10511
 	}
10512 10512
 	public function getService()
10513 10513
 	{
@@ -10515,20 +10515,20 @@  discard block
 block discarded – undo
10515 10515
 	}
10516 10516
 	public function setService($value)
10517 10517
 	{
10518
-		$this->_service=$value;
10518
+		$this->_service = $value;
10519 10519
 	}
10520
-	public function setModule($id,IModule $module=null)
10520
+	public function setModule($id, IModule $module = null)
10521 10521
 	{
10522
-		if(isset($this->_modules[$id]))
10523
-			throw new TConfigurationException('application_moduleid_duplicated',$id);
10522
+		if (isset($this->_modules[$id]))
10523
+			throw new TConfigurationException('application_moduleid_duplicated', $id);
10524 10524
 		else
10525
-			$this->_modules[$id]=$module;
10525
+			$this->_modules[$id] = $module;
10526 10526
 	}
10527 10527
 	public function getModule($id)
10528 10528
 	{
10529
-		if(!array_key_exists($id, $this->_modules))
10529
+		if (!array_key_exists($id, $this->_modules))
10530 10530
 			return null;
10531
-				if($this->_modules[$id]===null)
10531
+				if ($this->_modules[$id] === null)
10532 10532
 		{
10533 10533
 			$module = $this->internalLoadModule($id, true);
10534 10534
 			$module[0]->init($module[1]);
@@ -10545,94 +10545,94 @@  discard block
 block discarded – undo
10545 10545
 	}
10546 10546
 	public function getRequest()
10547 10547
 	{
10548
-		if(!$this->_request)
10548
+		if (!$this->_request)
10549 10549
 		{
10550
-			$this->_request=new THttpRequest;
10550
+			$this->_request = new THttpRequest;
10551 10551
 			$this->_request->init(null);
10552 10552
 		}
10553 10553
 		return $this->_request;
10554 10554
 	}
10555 10555
 	public function setRequest(THttpRequest $request)
10556 10556
 	{
10557
-		$this->_request=$request;
10557
+		$this->_request = $request;
10558 10558
 	}
10559 10559
 	public function getResponse()
10560 10560
 	{
10561
-		if(!$this->_response)
10561
+		if (!$this->_response)
10562 10562
 		{
10563
-			$this->_response=new THttpResponse;
10563
+			$this->_response = new THttpResponse;
10564 10564
 			$this->_response->init(null);
10565 10565
 		}
10566 10566
 		return $this->_response;
10567 10567
 	}
10568 10568
 	public function setResponse(THttpResponse $response)
10569 10569
 	{
10570
-		$this->_response=$response;
10570
+		$this->_response = $response;
10571 10571
 	}
10572 10572
 	public function getSession()
10573 10573
 	{
10574
-		if(!$this->_session)
10574
+		if (!$this->_session)
10575 10575
 		{
10576
-			$this->_session=new THttpSession;
10576
+			$this->_session = new THttpSession;
10577 10577
 			$this->_session->init(null);
10578 10578
 		}
10579 10579
 		return $this->_session;
10580 10580
 	}
10581 10581
 	public function setSession(THttpSession $session)
10582 10582
 	{
10583
-		$this->_session=$session;
10583
+		$this->_session = $session;
10584 10584
 	}
10585 10585
 	public function getErrorHandler()
10586 10586
 	{
10587
-		if(!$this->_errorHandler)
10587
+		if (!$this->_errorHandler)
10588 10588
 		{
10589
-			$this->_errorHandler=new TErrorHandler;
10589
+			$this->_errorHandler = new TErrorHandler;
10590 10590
 			$this->_errorHandler->init(null);
10591 10591
 		}
10592 10592
 		return $this->_errorHandler;
10593 10593
 	}
10594 10594
 	public function setErrorHandler(TErrorHandler $handler)
10595 10595
 	{
10596
-		$this->_errorHandler=$handler;
10596
+		$this->_errorHandler = $handler;
10597 10597
 	}
10598 10598
 	public function getSecurityManager()
10599 10599
 	{
10600
-		if(!$this->_security)
10600
+		if (!$this->_security)
10601 10601
 		{
10602
-			$this->_security=new TSecurityManager;
10602
+			$this->_security = new TSecurityManager;
10603 10603
 			$this->_security->init(null);
10604 10604
 		}
10605 10605
 		return $this->_security;
10606 10606
 	}
10607 10607
 	public function setSecurityManager(TSecurityManager $sm)
10608 10608
 	{
10609
-		$this->_security=$sm;
10609
+		$this->_security = $sm;
10610 10610
 	}
10611 10611
 	public function getAssetManager()
10612 10612
 	{
10613
-		if(!$this->_assetManager)
10613
+		if (!$this->_assetManager)
10614 10614
 		{
10615
-			$this->_assetManager=new TAssetManager;
10615
+			$this->_assetManager = new TAssetManager;
10616 10616
 			$this->_assetManager->init(null);
10617 10617
 		}
10618 10618
 		return $this->_assetManager;
10619 10619
 	}
10620 10620
 	public function setAssetManager(TAssetManager $value)
10621 10621
 	{
10622
-		$this->_assetManager=$value;
10622
+		$this->_assetManager = $value;
10623 10623
 	}
10624 10624
 	public function getApplicationStatePersister()
10625 10625
 	{
10626
-		if(!$this->_statePersister)
10626
+		if (!$this->_statePersister)
10627 10627
 		{
10628
-			$this->_statePersister=new TApplicationStatePersister;
10628
+			$this->_statePersister = new TApplicationStatePersister;
10629 10629
 			$this->_statePersister->init(null);
10630 10630
 		}
10631 10631
 		return $this->_statePersister;
10632 10632
 	}
10633 10633
 	public function setApplicationStatePersister(IStatePersister $persister)
10634 10634
 	{
10635
-		$this->_statePersister=$persister;
10635
+		$this->_statePersister = $persister;
10636 10636
 	}
10637 10637
 	public function getCache()
10638 10638
 	{
@@ -10640,7 +10640,7 @@  discard block
 block discarded – undo
10640 10640
 	}
10641 10641
 	public function setCache(ICache $cache)
10642 10642
 	{
10643
-		$this->_cache=$cache;
10643
+		$this->_cache = $cache;
10644 10644
 	}
10645 10645
 	public function getUser()
10646 10646
 	{
@@ -10648,207 +10648,207 @@  discard block
 block discarded – undo
10648 10648
 	}
10649 10649
 	public function setUser(IUser $user)
10650 10650
 	{
10651
-		$this->_user=$user;
10651
+		$this->_user = $user;
10652 10652
 	}
10653
-	public function getGlobalization($createIfNotExists=true)
10653
+	public function getGlobalization($createIfNotExists = true)
10654 10654
 	{
10655
-		if($this->_globalization===null && $createIfNotExists)
10655
+		if ($this->_globalization === null && $createIfNotExists)
10656 10656
 		{
10657
-			$this->_globalization=new TGlobalization;
10657
+			$this->_globalization = new TGlobalization;
10658 10658
 			$this->_globalization->init(null);
10659 10659
 		}
10660 10660
 		return $this->_globalization;
10661 10661
 	}
10662 10662
 	public function setGlobalization(TGlobalization $glob)
10663 10663
 	{
10664
-		$this->_globalization=$glob;
10664
+		$this->_globalization = $glob;
10665 10665
 	}
10666 10666
 	public function getAuthorizationRules()
10667 10667
 	{
10668
-		if($this->_authRules===null)
10669
-			$this->_authRules=new TAuthorizationRuleCollection;
10668
+		if ($this->_authRules === null)
10669
+			$this->_authRules = new TAuthorizationRuleCollection;
10670 10670
 		return $this->_authRules;
10671 10671
 	}
10672 10672
 	protected function getApplicationConfigurationClass()
10673 10673
 	{
10674 10674
 		return 'TApplicationConfiguration';
10675 10675
 	}
10676
-	protected function internalLoadModule($id, $force=false)
10676
+	protected function internalLoadModule($id, $force = false)
10677 10677
 	{
10678
-		list($moduleClass, $initProperties, $configElement)=$this->_lazyModules[$id];
10679
-		if(isset($initProperties['lazy']) && $initProperties['lazy'] && !$force)
10678
+		list($moduleClass, $initProperties, $configElement) = $this->_lazyModules[$id];
10679
+		if (isset($initProperties['lazy']) && $initProperties['lazy'] && !$force)
10680 10680
 		{
10681 10681
 			$this->setModule($id, null);
10682 10682
 			return null;
10683 10683
 		}
10684
-		$module=Prado::createComponent($moduleClass);
10685
-		foreach($initProperties as $name=>$value)
10684
+		$module = Prado::createComponent($moduleClass);
10685
+		foreach ($initProperties as $name=>$value)
10686 10686
 		{
10687
-			if($name==='lazy') continue;
10688
-			$module->setSubProperty($name,$value);
10687
+			if ($name === 'lazy') continue;
10688
+			$module->setSubProperty($name, $value);
10689 10689
 		}
10690
-		$this->setModule($id,$module);
10691
-				$this->_lazyModules[$id]=null;
10692
-		return array($module,$configElement);
10690
+		$this->setModule($id, $module);
10691
+				$this->_lazyModules[$id] = null;
10692
+		return array($module, $configElement);
10693 10693
 	}
10694
-	public function applyConfiguration($config,$withinService=false)
10694
+	public function applyConfiguration($config, $withinService = false)
10695 10695
 	{
10696
-		if($config->getIsEmpty())
10696
+		if ($config->getIsEmpty())
10697 10697
 			return;
10698
-				foreach($config->getAliases() as $alias=>$path)
10699
-			Prado::setPathOfAlias($alias,$path);
10700
-		foreach($config->getUsings() as $using)
10698
+				foreach ($config->getAliases() as $alias=>$path)
10699
+			Prado::setPathOfAlias($alias, $path);
10700
+		foreach ($config->getUsings() as $using)
10701 10701
 			Prado::using($using);
10702
-				if(!$withinService)
10702
+				if (!$withinService)
10703 10703
 		{
10704
-			foreach($config->getProperties() as $name=>$value)
10705
-				$this->setSubProperty($name,$value);
10704
+			foreach ($config->getProperties() as $name=>$value)
10705
+				$this->setSubProperty($name, $value);
10706 10706
 		}
10707
-		if(empty($this->_services))
10708
-			$this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null));
10709
-				foreach($config->getParameters() as $id=>$parameter)
10707
+		if (empty($this->_services))
10708
+			$this->_services = array($this->getPageServiceID()=>array('TPageService', array(), null));
10709
+				foreach ($config->getParameters() as $id=>$parameter)
10710 10710
 		{
10711
-			if(is_array($parameter))
10711
+			if (is_array($parameter))
10712 10712
 			{
10713
-				$component=Prado::createComponent($parameter[0]);
10714
-				foreach($parameter[1] as $name=>$value)
10715
-					$component->setSubProperty($name,$value);
10716
-				$this->_parameters->add($id,$component);
10713
+				$component = Prado::createComponent($parameter[0]);
10714
+				foreach ($parameter[1] as $name=>$value)
10715
+					$component->setSubProperty($name, $value);
10716
+				$this->_parameters->add($id, $component);
10717 10717
 			}
10718 10718
 			else
10719
-				$this->_parameters->add($id,$parameter);
10719
+				$this->_parameters->add($id, $parameter);
10720 10720
 		}
10721
-				$modules=array();
10722
-		foreach($config->getModules() as $id=>$moduleConfig)
10721
+				$modules = array();
10722
+		foreach ($config->getModules() as $id=>$moduleConfig)
10723 10723
 		{
10724
-			if(!is_string($id))
10725
-				$id='_module'.count($this->_lazyModules);
10726
-			$this->_lazyModules[$id]=$moduleConfig;
10727
-			if($module = $this->internalLoadModule($id))
10728
-				$modules[]=$module;
10724
+			if (!is_string($id))
10725
+				$id = '_module' . count($this->_lazyModules);
10726
+			$this->_lazyModules[$id] = $moduleConfig;
10727
+			if ($module = $this->internalLoadModule($id))
10728
+				$modules[] = $module;
10729 10729
 		}
10730
-		foreach($modules as $module)
10730
+		foreach ($modules as $module)
10731 10731
 			$module[0]->init($module[1]);
10732
-				foreach($config->getServices() as $serviceID=>$serviceConfig)
10733
-			$this->_services[$serviceID]=$serviceConfig;
10734
-				foreach($config->getExternalConfigurations() as $filePath=>$condition)
10735
-		{
10736
-			if($condition!==true)
10737
-				$condition=$this->evaluateExpression($condition);
10738
-			if($condition)
10739
-			{
10740
-				if(($path=Prado::getPathOfNamespace($filePath,$this->getConfigurationFileExt()))===null || !is_file($path))
10741
-					throw new TConfigurationException('application_includefile_invalid',$filePath);
10742
-				$cn=$this->getApplicationConfigurationClass();
10743
-				$c=new $cn;
10732
+				foreach ($config->getServices() as $serviceID=>$serviceConfig)
10733
+			$this->_services[$serviceID] = $serviceConfig;
10734
+				foreach ($config->getExternalConfigurations() as $filePath=>$condition)
10735
+		{
10736
+			if ($condition !== true)
10737
+				$condition = $this->evaluateExpression($condition);
10738
+			if ($condition)
10739
+			{
10740
+				if (($path = Prado::getPathOfNamespace($filePath, $this->getConfigurationFileExt())) === null || !is_file($path))
10741
+					throw new TConfigurationException('application_includefile_invalid', $filePath);
10742
+				$cn = $this->getApplicationConfigurationClass();
10743
+				$c = new $cn;
10744 10744
 				$c->loadFromFile($path);
10745
-				$this->applyConfiguration($c,$withinService);
10745
+				$this->applyConfiguration($c, $withinService);
10746 10746
 			}
10747 10747
 		}
10748 10748
 	}
10749 10749
 	protected function initApplication()
10750 10750
 	{
10751
-		if($this->_configFile!==null)
10751
+		if ($this->_configFile !== null)
10752 10752
 		{
10753
-			if($this->_cacheFile===null || @filemtime($this->_cacheFile)<filemtime($this->_configFile))
10753
+			if ($this->_cacheFile === null || @filemtime($this->_cacheFile) < filemtime($this->_configFile))
10754 10754
 			{
10755
-				$config=new TApplicationConfiguration;
10755
+				$config = new TApplicationConfiguration;
10756 10756
 				$config->loadFromFile($this->_configFile);
10757
-				if($this->_cacheFile!==null)
10758
-					file_put_contents($this->_cacheFile,serialize($config),LOCK_EX);
10757
+				if ($this->_cacheFile !== null)
10758
+					file_put_contents($this->_cacheFile, serialize($config), LOCK_EX);
10759 10759
 			}
10760 10760
 			else
10761
-				$config=unserialize(file_get_contents($this->_cacheFile));
10762
-			$this->applyConfiguration($config,false);
10761
+				$config = unserialize(file_get_contents($this->_cacheFile));
10762
+			$this->applyConfiguration($config, false);
10763 10763
 		}
10764
-		if(($serviceID=$this->getRequest()->resolveRequest(array_keys($this->_services)))===null)
10765
-			$serviceID=$this->getPageServiceID();
10764
+		if (($serviceID = $this->getRequest()->resolveRequest(array_keys($this->_services))) === null)
10765
+			$serviceID = $this->getPageServiceID();
10766 10766
 		$this->startService($serviceID);
10767 10767
 	}
10768 10768
 	public function startService($serviceID)
10769 10769
 	{
10770
-		if(isset($this->_services[$serviceID]))
10770
+		if (isset($this->_services[$serviceID]))
10771 10771
 		{
10772
-			list($serviceClass,$initProperties,$configElement)=$this->_services[$serviceID];
10773
-			$service=Prado::createComponent($serviceClass);
10774
-			if(!($service instanceof IService))
10775
-				throw new THttpException(500,'application_service_invalid',$serviceClass);
10776
-			if(!$service->getEnabled())
10777
-				throw new THttpException(500,'application_service_unavailable',$serviceClass);
10772
+			list($serviceClass, $initProperties, $configElement) = $this->_services[$serviceID];
10773
+			$service = Prado::createComponent($serviceClass);
10774
+			if (!($service instanceof IService))
10775
+				throw new THttpException(500, 'application_service_invalid', $serviceClass);
10776
+			if (!$service->getEnabled())
10777
+				throw new THttpException(500, 'application_service_unavailable', $serviceClass);
10778 10778
 			$service->setID($serviceID);
10779 10779
 			$this->setService($service);
10780
-			foreach($initProperties as $name=>$value)
10781
-				$service->setSubProperty($name,$value);
10782
-			if($configElement!==null)
10780
+			foreach ($initProperties as $name=>$value)
10781
+				$service->setSubProperty($name, $value);
10782
+			if ($configElement !== null)
10783 10783
 			{
10784
-				$config=new TApplicationConfiguration;
10785
-				if($this->getConfigurationType()==self::CONFIG_TYPE_PHP)
10786
-					$config->loadFromPhp($configElement,$this->getBasePath());
10784
+				$config = new TApplicationConfiguration;
10785
+				if ($this->getConfigurationType() == self::CONFIG_TYPE_PHP)
10786
+					$config->loadFromPhp($configElement, $this->getBasePath());
10787 10787
 				else
10788
-					$config->loadFromXml($configElement,$this->getBasePath());
10789
-				$this->applyConfiguration($config,true);
10788
+					$config->loadFromXml($configElement, $this->getBasePath());
10789
+				$this->applyConfiguration($config, true);
10790 10790
 			}
10791 10791
 			$service->init($configElement);
10792 10792
 		}
10793 10793
 		else
10794
-			throw new THttpException(500,'application_service_unknown',$serviceID);
10794
+			throw new THttpException(500, 'application_service_unknown', $serviceID);
10795 10795
 	}
10796 10796
 	public function onError($param)
10797 10797
 	{
10798
-		Prado::log($param->getMessage(),TLogger::ERROR,'System.TApplication');
10799
-		$this->raiseEvent('OnError',$this,$param);
10800
-		$this->getErrorHandler()->handleError($this,$param);
10798
+		Prado::log($param->getMessage(), TLogger::ERROR, 'System.TApplication');
10799
+		$this->raiseEvent('OnError', $this, $param);
10800
+		$this->getErrorHandler()->handleError($this, $param);
10801 10801
 	}
10802 10802
 	public function onBeginRequest()
10803 10803
 	{
10804
-		$this->raiseEvent('OnBeginRequest',$this,null);
10804
+		$this->raiseEvent('OnBeginRequest', $this, null);
10805 10805
 	}
10806 10806
 	public function onAuthentication()
10807 10807
 	{
10808
-		$this->raiseEvent('OnAuthentication',$this,null);
10808
+		$this->raiseEvent('OnAuthentication', $this, null);
10809 10809
 	}
10810 10810
 	public function onAuthenticationComplete()
10811 10811
 	{
10812
-		$this->raiseEvent('OnAuthenticationComplete',$this,null);
10812
+		$this->raiseEvent('OnAuthenticationComplete', $this, null);
10813 10813
 	}
10814 10814
 	public function onAuthorization()
10815 10815
 	{
10816
-		$this->raiseEvent('OnAuthorization',$this,null);
10816
+		$this->raiseEvent('OnAuthorization', $this, null);
10817 10817
 	}
10818 10818
 	public function onAuthorizationComplete()
10819 10819
 	{
10820
-		$this->raiseEvent('OnAuthorizationComplete',$this,null);
10820
+		$this->raiseEvent('OnAuthorizationComplete', $this, null);
10821 10821
 	}
10822 10822
 	public function onLoadState()
10823 10823
 	{
10824 10824
 		$this->loadGlobals();
10825
-		$this->raiseEvent('OnLoadState',$this,null);
10825
+		$this->raiseEvent('OnLoadState', $this, null);
10826 10826
 	}
10827 10827
 	public function onLoadStateComplete()
10828 10828
 	{
10829
-		$this->raiseEvent('OnLoadStateComplete',$this,null);
10829
+		$this->raiseEvent('OnLoadStateComplete', $this, null);
10830 10830
 	}
10831 10831
 	public function onPreRunService()
10832 10832
 	{
10833
-		$this->raiseEvent('OnPreRunService',$this,null);
10833
+		$this->raiseEvent('OnPreRunService', $this, null);
10834 10834
 	}
10835 10835
 	public function runService()
10836 10836
 	{
10837
-		if($this->_service)
10837
+		if ($this->_service)
10838 10838
 			$this->_service->run();
10839 10839
 	}
10840 10840
 	public function onSaveState()
10841 10841
 	{
10842
-		$this->raiseEvent('OnSaveState',$this,null);
10842
+		$this->raiseEvent('OnSaveState', $this, null);
10843 10843
 		$this->saveGlobals();
10844 10844
 	}
10845 10845
 	public function onSaveStateComplete()
10846 10846
 	{
10847
-		$this->raiseEvent('OnSaveStateComplete',$this,null);
10847
+		$this->raiseEvent('OnSaveStateComplete', $this, null);
10848 10848
 	}
10849 10849
 	public function onPreFlushOutput()
10850 10850
 	{
10851
-		$this->raiseEvent('OnPreFlushOutput',$this,null);
10851
+		$this->raiseEvent('OnPreFlushOutput', $this, null);
10852 10852
 	}
10853 10853
 	public function flushOutput($continueBuffering = true)
10854 10854
 	{
@@ -10856,38 +10856,38 @@  discard block
 block discarded – undo
10856 10856
 	}
10857 10857
 	public function onEndRequest()
10858 10858
 	{
10859
-		$this->flushOutput(false); 		$this->saveGlobals();  		$this->raiseEvent('OnEndRequest',$this,null);
10859
+		$this->flushOutput(false); $this->saveGlobals(); $this->raiseEvent('OnEndRequest', $this, null);
10860 10860
 	}
10861 10861
 }
10862 10862
 class TApplicationMode extends TEnumerable
10863 10863
 {
10864
-	const Off='Off';
10865
-	const Debug='Debug';
10866
-	const Normal='Normal';
10867
-	const Performance='Performance';
10864
+	const Off = 'Off';
10865
+	const Debug = 'Debug';
10866
+	const Normal = 'Normal';
10867
+	const Performance = 'Performance';
10868 10868
 }
10869 10869
 class TApplicationConfiguration extends TComponent
10870 10870
 {
10871
-	private $_properties=array();
10872
-	private $_usings=array();
10873
-	private $_aliases=array();
10874
-	private $_modules=array();
10875
-	private $_services=array();
10876
-	private $_parameters=array();
10877
-	private $_includes=array();
10878
-	private $_empty=true;
10871
+	private $_properties = array();
10872
+	private $_usings = array();
10873
+	private $_aliases = array();
10874
+	private $_modules = array();
10875
+	private $_services = array();
10876
+	private $_parameters = array();
10877
+	private $_includes = array();
10878
+	private $_empty = true;
10879 10879
 	public function loadFromFile($fname)
10880 10880
 	{
10881
-		if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
10881
+		if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP)
10882 10882
 		{
10883 10883
 			$fcontent = include $fname;
10884
-			$this->loadFromPhp($fcontent,dirname($fname));
10884
+			$this->loadFromPhp($fcontent, dirname($fname));
10885 10885
 		}
10886 10886
 		else
10887 10887
 		{
10888
-			$dom=new TXmlDocument;
10888
+			$dom = new TXmlDocument;
10889 10889
 			$dom->loadFromFile($fname);
10890
-			$this->loadFromXml($dom,dirname($fname));
10890
+			$this->loadFromXml($dom, dirname($fname));
10891 10891
 		}
10892 10892
 	}
10893 10893
 	public function getIsEmpty()
@@ -10896,50 +10896,50 @@  discard block
 block discarded – undo
10896 10896
 	}
10897 10897
 	public function loadFromPhp($config, $configPath)
10898 10898
 	{
10899
-				if(isset($config['application']))
10899
+				if (isset($config['application']))
10900 10900
 		{
10901
-			foreach($config['application'] as $name=>$value)
10901
+			foreach ($config['application'] as $name=>$value)
10902 10902
 			{
10903
-				$this->_properties[$name]=$value;
10903
+				$this->_properties[$name] = $value;
10904 10904
 			}
10905 10905
 			$this->_empty = false;
10906 10906
 		}
10907
-		if(isset($config['paths']) && is_array($config['paths']))
10908
-			$this->loadPathsPhp($config['paths'],$configPath);
10909
-		if(isset($config['modules']) && is_array($config['modules']))
10910
-			$this->loadModulesPhp($config['modules'],$configPath);
10911
-		if(isset($config['services']) && is_array($config['services']))
10912
-			$this->loadServicesPhp($config['services'],$configPath);
10913
-		if(isset($config['parameters']) && is_array($config['parameters']))
10907
+		if (isset($config['paths']) && is_array($config['paths']))
10908
+			$this->loadPathsPhp($config['paths'], $configPath);
10909
+		if (isset($config['modules']) && is_array($config['modules']))
10910
+			$this->loadModulesPhp($config['modules'], $configPath);
10911
+		if (isset($config['services']) && is_array($config['services']))
10912
+			$this->loadServicesPhp($config['services'], $configPath);
10913
+		if (isset($config['parameters']) && is_array($config['parameters']))
10914 10914
 			$this->loadParametersPhp($config['parameters'], $configPath);
10915
-		if(isset($config['includes']) && is_array($config['includes']))
10916
-			$this->loadExternalXml($config['includes'],$configPath);
10915
+		if (isset($config['includes']) && is_array($config['includes']))
10916
+			$this->loadExternalXml($config['includes'], $configPath);
10917 10917
 	}
10918
-	public function loadFromXml($dom,$configPath)
10918
+	public function loadFromXml($dom, $configPath)
10919 10919
 	{
10920
-				foreach($dom->getAttributes() as $name=>$value)
10920
+				foreach ($dom->getAttributes() as $name=>$value)
10921 10921
 		{
10922
-			$this->_properties[$name]=$value;
10923
-			$this->_empty=false;
10922
+			$this->_properties[$name] = $value;
10923
+			$this->_empty = false;
10924 10924
 		}
10925
-		foreach($dom->getElements() as $element)
10925
+		foreach ($dom->getElements() as $element)
10926 10926
 		{
10927
-			switch($element->getTagName())
10927
+			switch ($element->getTagName())
10928 10928
 			{
10929 10929
 				case 'paths':
10930
-					$this->loadPathsXml($element,$configPath);
10930
+					$this->loadPathsXml($element, $configPath);
10931 10931
 					break;
10932 10932
 				case 'modules':
10933
-					$this->loadModulesXml($element,$configPath);
10933
+					$this->loadModulesXml($element, $configPath);
10934 10934
 					break;
10935 10935
 				case 'services':
10936
-					$this->loadServicesXml($element,$configPath);
10936
+					$this->loadServicesXml($element, $configPath);
10937 10937
 					break;
10938 10938
 				case 'parameters':
10939
-					$this->loadParametersXml($element,$configPath);
10939
+					$this->loadParametersXml($element, $configPath);
10940 10940
 					break;
10941 10941
 				case 'include':
10942
-					$this->loadExternalXml($element,$configPath);
10942
+					$this->loadExternalXml($element, $configPath);
10943 10943
 					break;
10944 10944
 				default:
10945 10945
 										break;
@@ -10948,155 +10948,155 @@  discard block
 block discarded – undo
10948 10948
 	}
10949 10949
 	protected function loadPathsPhp($pathsNode, $configPath)
10950 10950
 	{
10951
-		if(isset($pathsNode['aliases']) && is_array($pathsNode['aliases']))
10951
+		if (isset($pathsNode['aliases']) && is_array($pathsNode['aliases']))
10952 10952
 		{
10953
-			foreach($pathsNode['aliases'] as $id=>$path)
10953
+			foreach ($pathsNode['aliases'] as $id=>$path)
10954 10954
 			{
10955
-				$path=str_replace('\\','/',$path);
10956
-				if(preg_match('/^\\/|.:\\/|.:\\\\/',$path))						$p=realpath($path);
10955
+				$path = str_replace('\\', '/', $path);
10956
+				if (preg_match('/^\\/|.:\\/|.:\\\\/', $path))						$p = realpath($path);
10957 10957
 				else
10958
-					$p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
10959
-				if($p===false || !is_dir($p))
10960
-					throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path);
10961
-				if(isset($this->_aliases[$id]))
10962
-					throw new TConfigurationException('appconfig_alias_redefined',$id);
10963
-				$this->_aliases[$id]=$p;
10958
+					$p = realpath($configPath . DIRECTORY_SEPARATOR . $path);
10959
+				if ($p === false || !is_dir($p))
10960
+					throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path);
10961
+				if (isset($this->_aliases[$id]))
10962
+					throw new TConfigurationException('appconfig_alias_redefined', $id);
10963
+				$this->_aliases[$id] = $p;
10964 10964
 			}
10965 10965
 		}
10966
-		if(isset($pathsNode['using']) && is_array($pathsNode['using']))
10966
+		if (isset($pathsNode['using']) && is_array($pathsNode['using']))
10967 10967
 		{
10968
-			foreach($pathsNode['using'] as $namespace)
10968
+			foreach ($pathsNode['using'] as $namespace)
10969 10969
 			{
10970 10970
 				$this->_usings[] = $namespace;
10971 10971
 			}
10972 10972
 		}
10973 10973
 	}
10974
-	protected function loadPathsXml($pathsNode,$configPath)
10974
+	protected function loadPathsXml($pathsNode, $configPath)
10975 10975
 	{
10976
-		foreach($pathsNode->getElements() as $element)
10976
+		foreach ($pathsNode->getElements() as $element)
10977 10977
 		{
10978
-			switch($element->getTagName())
10978
+			switch ($element->getTagName())
10979 10979
 			{
10980 10980
 				case 'alias':
10981 10981
 				{
10982
-					if(($id=$element->getAttribute('id'))!==null && ($path=$element->getAttribute('path'))!==null)
10982
+					if (($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null)
10983 10983
 					{
10984
-						$path=str_replace('\\','/',$path);
10985
-						if(preg_match('/^\\/|.:\\/|.:\\\\/',$path))								$p=realpath($path);
10984
+						$path = str_replace('\\', '/', $path);
10985
+						if (preg_match('/^\\/|.:\\/|.:\\\\/', $path))								$p = realpath($path);
10986 10986
 						else
10987
-							$p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
10988
-						if($p===false || !is_dir($p))
10989
-							throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path);
10990
-						if(isset($this->_aliases[$id]))
10991
-							throw new TConfigurationException('appconfig_alias_redefined',$id);
10992
-						$this->_aliases[$id]=$p;
10987
+							$p = realpath($configPath . DIRECTORY_SEPARATOR . $path);
10988
+						if ($p === false || !is_dir($p))
10989
+							throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path);
10990
+						if (isset($this->_aliases[$id]))
10991
+							throw new TConfigurationException('appconfig_alias_redefined', $id);
10992
+						$this->_aliases[$id] = $p;
10993 10993
 					}
10994 10994
 					else
10995 10995
 						throw new TConfigurationException('appconfig_alias_invalid');
10996
-					$this->_empty=false;
10996
+					$this->_empty = false;
10997 10997
 					break;
10998 10998
 				}
10999 10999
 				case 'using':
11000 11000
 				{
11001
-					if(($namespace=$element->getAttribute('namespace'))!==null)
11002
-						$this->_usings[]=$namespace;
11001
+					if (($namespace = $element->getAttribute('namespace')) !== null)
11002
+						$this->_usings[] = $namespace;
11003 11003
 					else
11004 11004
 						throw new TConfigurationException('appconfig_using_invalid');
11005
-					$this->_empty=false;
11005
+					$this->_empty = false;
11006 11006
 					break;
11007 11007
 				}
11008 11008
 				default:
11009
-					throw new TConfigurationException('appconfig_paths_invalid',$element->getTagName());
11009
+					throw new TConfigurationException('appconfig_paths_invalid', $element->getTagName());
11010 11010
 			}
11011 11011
 		}
11012 11012
 	}
11013 11013
 	protected function loadModulesPhp($modulesNode, $configPath)
11014 11014
 	{
11015
-		foreach($modulesNode as $id=>$module)
11015
+		foreach ($modulesNode as $id=>$module)
11016 11016
 		{
11017
-			if(!isset($module['class']))
11018
-				throw new TConfigurationException('appconfig_moduletype_required',$id);
11017
+			if (!isset($module['class']))
11018
+				throw new TConfigurationException('appconfig_moduletype_required', $id);
11019 11019
 			$type = $module['class'];
11020 11020
 			unset($module['class']);
11021 11021
 			$properties = array();
11022
-			if(isset($module['properties']))
11022
+			if (isset($module['properties']))
11023 11023
 			{
11024 11024
 				$properties = $module['properties'];
11025 11025
 				unset($module['properties']);
11026 11026
 			}
11027 11027
 			$properties['id'] = $id;
11028
-			$this->_modules[$id]=array($type,$properties,$module);
11029
-			$this->_empty=false;
11028
+			$this->_modules[$id] = array($type, $properties, $module);
11029
+			$this->_empty = false;
11030 11030
 		}
11031 11031
 	}
11032
-	protected function loadModulesXml($modulesNode,$configPath)
11032
+	protected function loadModulesXml($modulesNode, $configPath)
11033 11033
 	{
11034
-		foreach($modulesNode->getElements() as $element)
11034
+		foreach ($modulesNode->getElements() as $element)
11035 11035
 		{
11036
-			if($element->getTagName()==='module')
11036
+			if ($element->getTagName() === 'module')
11037 11037
 			{
11038
-				$properties=$element->getAttributes();
11039
-				$id=$properties->itemAt('id');
11040
-				$type=$properties->remove('class');
11041
-				if($type===null)
11042
-					throw new TConfigurationException('appconfig_moduletype_required',$id);
11038
+				$properties = $element->getAttributes();
11039
+				$id = $properties->itemAt('id');
11040
+				$type = $properties->remove('class');
11041
+				if ($type === null)
11042
+					throw new TConfigurationException('appconfig_moduletype_required', $id);
11043 11043
 				$element->setParent(null);
11044
-				if($id===null)
11045
-					$this->_modules[]=array($type,$properties->toArray(),$element);
11044
+				if ($id === null)
11045
+					$this->_modules[] = array($type, $properties->toArray(), $element);
11046 11046
 				else
11047
-					$this->_modules[$id]=array($type,$properties->toArray(),$element);
11048
-				$this->_empty=false;
11047
+					$this->_modules[$id] = array($type, $properties->toArray(), $element);
11048
+				$this->_empty = false;
11049 11049
 			}
11050 11050
 			else
11051
-				throw new TConfigurationException('appconfig_modules_invalid',$element->getTagName());
11051
+				throw new TConfigurationException('appconfig_modules_invalid', $element->getTagName());
11052 11052
 		}
11053 11053
 	}
11054
-	protected function loadServicesPhp($servicesNode,$configPath)
11054
+	protected function loadServicesPhp($servicesNode, $configPath)
11055 11055
 	{
11056
-		foreach($servicesNode as $id => $service)
11056
+		foreach ($servicesNode as $id => $service)
11057 11057
 		{
11058
-			if(!isset($service['class']))
11058
+			if (!isset($service['class']))
11059 11059
 				throw new TConfigurationException('appconfig_servicetype_required');
11060 11060
 			$type = $service['class'];
11061 11061
 			$properties = isset($service['properties']) ? $service['properties'] : array();
11062 11062
 			unset($service['properties']);
11063 11063
 			$properties['id'] = $id;
11064
-			$this->_services[$id] = array($type,$properties,$service);
11064
+			$this->_services[$id] = array($type, $properties, $service);
11065 11065
 			$this->_empty = false;
11066 11066
 		}
11067 11067
 	}
11068
-	protected function loadServicesXml($servicesNode,$configPath)
11068
+	protected function loadServicesXml($servicesNode, $configPath)
11069 11069
 	{
11070
-		foreach($servicesNode->getElements() as $element)
11070
+		foreach ($servicesNode->getElements() as $element)
11071 11071
 		{
11072
-			if($element->getTagName()==='service')
11072
+			if ($element->getTagName() === 'service')
11073 11073
 			{
11074
-				$properties=$element->getAttributes();
11075
-				if(($id=$properties->itemAt('id'))===null)
11074
+				$properties = $element->getAttributes();
11075
+				if (($id = $properties->itemAt('id')) === null)
11076 11076
 					throw new TConfigurationException('appconfig_serviceid_required');
11077
-				if(($type=$properties->remove('class'))===null)
11078
-					throw new TConfigurationException('appconfig_servicetype_required',$id);
11077
+				if (($type = $properties->remove('class')) === null)
11078
+					throw new TConfigurationException('appconfig_servicetype_required', $id);
11079 11079
 				$element->setParent(null);
11080
-				$this->_services[$id]=array($type,$properties->toArray(),$element);
11081
-				$this->_empty=false;
11080
+				$this->_services[$id] = array($type, $properties->toArray(), $element);
11081
+				$this->_empty = false;
11082 11082
 			}
11083 11083
 			else
11084
-				throw new TConfigurationException('appconfig_services_invalid',$element->getTagName());
11084
+				throw new TConfigurationException('appconfig_services_invalid', $element->getTagName());
11085 11085
 		}
11086 11086
 	}
11087
-	protected function loadParametersPhp($parametersNode,$configPath)
11087
+	protected function loadParametersPhp($parametersNode, $configPath)
11088 11088
 	{
11089
-		foreach($parametersNode as $id => $parameter)
11089
+		foreach ($parametersNode as $id => $parameter)
11090 11090
 		{
11091
-			if(is_array($parameter))
11091
+			if (is_array($parameter))
11092 11092
 			{
11093
-				if(isset($parameter['class']))
11093
+				if (isset($parameter['class']))
11094 11094
 				{
11095 11095
 					$type = $parameter['class'];
11096 11096
 					unset($parameter['class']);
11097 11097
 					$properties = isset($service['properties']) ? $service['properties'] : array();
11098 11098
 					$properties['id'] = $id;
11099
-					$this->_parameters[$id] = array($type,$properties);
11099
+					$this->_parameters[$id] = array($type, $properties);
11100 11100
 				}
11101 11101
 			}
11102 11102
 			else
@@ -11105,56 +11105,56 @@  discard block
 block discarded – undo
11105 11105
 			}
11106 11106
 		}
11107 11107
 	}
11108
-	protected function loadParametersXml($parametersNode,$configPath)
11108
+	protected function loadParametersXml($parametersNode, $configPath)
11109 11109
 	{
11110
-		foreach($parametersNode->getElements() as $element)
11110
+		foreach ($parametersNode->getElements() as $element)
11111 11111
 		{
11112
-			if($element->getTagName()==='parameter')
11112
+			if ($element->getTagName() === 'parameter')
11113 11113
 			{
11114
-				$properties=$element->getAttributes();
11115
-				if(($id=$properties->remove('id'))===null)
11114
+				$properties = $element->getAttributes();
11115
+				if (($id = $properties->remove('id')) === null)
11116 11116
 					throw new TConfigurationException('appconfig_parameterid_required');
11117
-				if(($type=$properties->remove('class'))===null)
11117
+				if (($type = $properties->remove('class')) === null)
11118 11118
 				{
11119
-					if(($value=$properties->remove('value'))===null)
11120
-						$this->_parameters[$id]=$element;
11119
+					if (($value = $properties->remove('value')) === null)
11120
+						$this->_parameters[$id] = $element;
11121 11121
 					else
11122
-						$this->_parameters[$id]=$value;
11122
+						$this->_parameters[$id] = $value;
11123 11123
 				}
11124 11124
 				else
11125
-					$this->_parameters[$id]=array($type,$properties->toArray());
11126
-				$this->_empty=false;
11125
+					$this->_parameters[$id] = array($type, $properties->toArray());
11126
+				$this->_empty = false;
11127 11127
 			}
11128 11128
 			else
11129
-				throw new TConfigurationException('appconfig_parameters_invalid',$element->getTagName());
11129
+				throw new TConfigurationException('appconfig_parameters_invalid', $element->getTagName());
11130 11130
 		}
11131 11131
 	}
11132
-	protected function loadExternalPhp($includeNode,$configPath)
11132
+	protected function loadExternalPhp($includeNode, $configPath)
11133 11133
 	{
11134
-		foreach($includeNode as $include)
11134
+		foreach ($includeNode as $include)
11135 11135
 		{
11136
-			$when = isset($include['when'])?true:false;
11137
-			if(!isset($include['file']))
11136
+			$when = isset($include['when']) ? true : false;
11137
+			if (!isset($include['file']))
11138 11138
 				throw new TConfigurationException('appconfig_includefile_required');
11139 11139
 			$filePath = $include['file'];
11140
-			if(isset($this->_includes[$filePath]))
11141
-				$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
11140
+			if (isset($this->_includes[$filePath]))
11141
+				$this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')';
11142 11142
 			else
11143
-				$$this->_includes[$filePath]=$when;
11144
-			$this->_empty=false;
11143
+				$$this->_includes[$filePath] = $when;
11144
+			$this->_empty = false;
11145 11145
 		}
11146 11146
 	}
11147
-	protected function loadExternalXml($includeNode,$configPath)
11147
+	protected function loadExternalXml($includeNode, $configPath)
11148 11148
 	{
11149
-		if(($when=$includeNode->getAttribute('when'))===null)
11150
-			$when=true;
11151
-		if(($filePath=$includeNode->getAttribute('file'))===null)
11149
+		if (($when = $includeNode->getAttribute('when')) === null)
11150
+			$when = true;
11151
+		if (($filePath = $includeNode->getAttribute('file')) === null)
11152 11152
 			throw new TConfigurationException('appconfig_includefile_required');
11153
-		if(isset($this->_includes[$filePath]))
11154
-			$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
11153
+		if (isset($this->_includes[$filePath]))
11154
+			$this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')';
11155 11155
 		else
11156
-			$this->_includes[$filePath]=$when;
11157
-		$this->_empty=false;
11156
+			$this->_includes[$filePath] = $when;
11157
+		$this->_empty = false;
11158 11158
 	}
11159 11159
 	public function getProperties()
11160 11160
 	{
@@ -11187,22 +11187,22 @@  discard block
 block discarded – undo
11187 11187
 }
11188 11188
 class TApplicationStatePersister extends TModule implements IStatePersister
11189 11189
 {
11190
-	const CACHE_NAME='prado:appstate';
11190
+	const CACHE_NAME = 'prado:appstate';
11191 11191
 	public function init($config)
11192 11192
 	{
11193 11193
 		$this->getApplication()->setApplicationStatePersister($this);
11194 11194
 	}
11195 11195
 	protected function getStateFilePath()
11196 11196
 	{
11197
-		return $this->getApplication()->getRuntimePath().'/global.cache';
11197
+		return $this->getApplication()->getRuntimePath() . '/global.cache';
11198 11198
 	}
11199 11199
 	public function load()
11200 11200
 	{
11201
-		if(($cache=$this->getApplication()->getCache())!==null && ($value=$cache->get(self::CACHE_NAME))!==false)
11201
+		if (($cache = $this->getApplication()->getCache()) !== null && ($value = $cache->get(self::CACHE_NAME)) !== false)
11202 11202
 			return unserialize($value);
11203 11203
 		else
11204 11204
 		{
11205
-			if(($content=@file_get_contents($this->getStateFilePath()))!==false)
11205
+			if (($content = @file_get_contents($this->getStateFilePath())) !== false)
11206 11206
 				return unserialize($content);
11207 11207
 			else
11208 11208
 				return null;
@@ -11210,19 +11210,19 @@  discard block
 block discarded – undo
11210 11210
 	}
11211 11211
 	public function save($state)
11212 11212
 	{
11213
-		$content=serialize($state);
11214
-		$saveFile=true;
11215
-		if(($cache=$this->getApplication()->getCache())!==null)
11213
+		$content = serialize($state);
11214
+		$saveFile = true;
11215
+		if (($cache = $this->getApplication()->getCache()) !== null)
11216 11216
 		{
11217
-			if($cache->get(self::CACHE_NAME)===$content)
11218
-				$saveFile=false;
11217
+			if ($cache->get(self::CACHE_NAME) === $content)
11218
+				$saveFile = false;
11219 11219
 			else
11220
-				$cache->set(self::CACHE_NAME,$content);
11220
+				$cache->set(self::CACHE_NAME, $content);
11221 11221
 		}
11222
-		if($saveFile)
11222
+		if ($saveFile)
11223 11223
 		{
11224
-			$fileName=$this->getStateFilePath();
11225
-			file_put_contents($fileName,$content,LOCK_EX);
11224
+			$fileName = $this->getStateFilePath();
11225
+			file_put_contents($fileName, $content, LOCK_EX);
11226 11226
 		}
11227 11227
 	}
11228 11228
 }
Please login to merge, or discard this patch.
Braces   +3076 added lines, -2362 removed lines patch added patch discarded remove patch
@@ -11,10 +11,12 @@  discard block
 block discarded – undo
11 11
  * Do not modify this file manually.
12 12
  */
13 13
 
14
-if(!defined('PRADO_DIR'))
14
+if(!defined('PRADO_DIR')) {
15 15
 	define('PRADO_DIR',dirname(__FILE__));
16
-if(!defined('PRADO_CHMOD'))
16
+}
17
+if(!defined('PRADO_CHMOD')) {
17 18
 	define('PRADO_CHMOD',0777);
19
+}
18 20
 class PradoBase
19 21
 {
20 22
 	const CLASS_FILE_EXT='.php';
@@ -35,8 +37,9 @@  discard block
 block discarded – undo
35 37
 	public static function autoload($className)
36 38
 	{
37 39
 		include_once($className.self::CLASS_FILE_EXT);
38
-		if(!class_exists($className,false) && !interface_exists($className,false))
39
-			self::fatalError("Class file for '$className' cannot be found.");
40
+		if(!class_exists($className,false) && !interface_exists($className,false)) {
41
+					self::fatalError("Class file for '$className' cannot be found.");
42
+		}
40 43
 	}
41 44
 	public static function poweredByPrado($logoType=0)
42 45
 	{
@@ -45,23 +48,23 @@  discard block
 block discarded – undo
45 48
 		{
46 49
 			$am=self::$_application->getAssetManager();
47 50
 			$url=$am->publishFilePath(self::getPathOfNamespace('System.'.$logoName,'.gif'));
51
+		} else {
52
+					$url='http://pradosoft.github.io/docs/'.$logoName.'.gif';
48 53
 		}
49
-		else
50
-			$url='http://pradosoft.github.io/docs/'.$logoName.'.gif';
51 54
 		return '<a title="Powered by PRADO" href="https://github.com/pradosoft/prado" target="_blank"><img src="'.$url.'" style="border-width:0px;" alt="Powered by PRADO" /></a>';
52 55
 	}
53 56
 	public static function phpErrorHandler($errno,$errstr,$errfile,$errline)
54 57
 	{
55
-		if(error_reporting() & $errno)
56
-			throw new TPhpErrorException($errno,$errstr,$errfile,$errline);
58
+		if(error_reporting() & $errno) {
59
+					throw new TPhpErrorException($errno,$errstr,$errfile,$errline);
60
+		}
57 61
 	}
58 62
 	public static function exceptionHandler($exception)
59 63
 	{
60 64
 		if(self::$_application!==null && ($errorHandler=self::$_application->getErrorHandler())!==null)
61 65
 		{
62 66
 			$errorHandler->handleError(null,$exception);
63
-		}
64
-		else
67
+		} else
65 68
 		{
66 69
 			echo $exception;
67 70
 		}
@@ -69,8 +72,9 @@  discard block
 block discarded – undo
69 72
 	}
70 73
 	public static function setApplication($application)
71 74
 	{
72
-		if(self::$_application!==null && !defined('PRADO_TEST_RUN'))
73
-			throw new TInvalidOperationException('prado_application_singleton_required');
75
+		if(self::$_application!==null && !defined('PRADO_TEST_RUN')) {
76
+					throw new TInvalidOperationException('prado_application_singleton_required');
77
+		}
74 78
 		self::$_application=$application;
75 79
 	}
76 80
 	public static function getApplication()
@@ -83,14 +87,16 @@  discard block
 block discarded – undo
83 87
 	}
84 88
 	public static function createComponent($type)
85 89
 	{
86
-		if(!isset(self::$classExists[$type]))
87
-			self::$classExists[$type] = class_exists($type, false);
90
+		if(!isset(self::$classExists[$type])) {
91
+					self::$classExists[$type] = class_exists($type, false);
92
+		}
88 93
 		if( !isset(self::$_usings[$type]) && !self::$classExists[$type]) {
89 94
 			self::using($type);
90 95
 			self::$classExists[$type] = class_exists($type, false);
91 96
 		}
92
-		if( ($pos = strrpos($type, '.')) !== false)
93
-			$type = substr($type,$pos+1);
97
+		if( ($pos = strrpos($type, '.')) !== false) {
98
+					$type = substr($type,$pos+1);
99
+		}
94 100
 		if(($n=func_num_args())>1)
95 101
 		{
96 102
 			$args = func_get_args();
@@ -109,74 +115,77 @@  discard block
 block discarded – undo
109 115
 				break;
110 116
 				default:
111 117
 					$s='$args[1]';
112
-					for($i=2;$i<$n;++$i)
113
-						$s.=",\$args[$i]";
118
+					for($i=2;$i<$n;++$i) {
119
+											$s.=",\$args[$i]";
120
+					}
114 121
 					eval("\$component=new $type($s);");
115 122
 					return $component;
116 123
 				break;
117 124
 			}
125
+		} else {
126
+					return new $type;
118 127
 		}
119
-		else
120
-			return new $type;
121 128
 	}
122 129
 	public static function using($namespace,$checkClassExistence=true)
123 130
 	{
124
-		if(isset(self::$_usings[$namespace]) || class_exists($namespace,false))
125
-			return;
131
+		if(isset(self::$_usings[$namespace]) || class_exists($namespace,false)) {
132
+					return;
133
+		}
126 134
 		if(($pos=strrpos($namespace,'.'))===false)  		{
127 135
 			try
128 136
 			{
129 137
 				include_once($namespace.self::CLASS_FILE_EXT);
130
-			}
131
-			catch(Exception $e)
138
+			} catch(Exception $e)
132 139
 			{
133
-				if($checkClassExistence && !class_exists($namespace,false))
134
-					throw new TInvalidOperationException('prado_component_unknown',$namespace,$e->getMessage());
135
-				else
136
-					throw $e;
140
+				if($checkClassExistence && !class_exists($namespace,false)) {
141
+									throw new TInvalidOperationException('prado_component_unknown',$namespace,$e->getMessage());
142
+				} else {
143
+									throw $e;
144
+				}
137 145
 			}
138
-		}
139
-		else if(($path=self::getPathOfNamespace($namespace,self::CLASS_FILE_EXT))!==null)
146
+		} else if(($path=self::getPathOfNamespace($namespace,self::CLASS_FILE_EXT))!==null)
140 147
 		{
141 148
 			$className=substr($namespace,$pos+1);
142 149
 			if($className==='*')  			{
143 150
 				self::$_usings[$namespace]=$path;
144 151
 				set_include_path(get_include_path().PATH_SEPARATOR.$path);
145
-			}
146
-			else  			{
152
+			} else  			{
147 153
 				self::$_usings[$namespace]=$path;
148 154
 				if(!$checkClassExistence || !class_exists($className,false))
149 155
 				{
150 156
 					try
151 157
 					{
152 158
 						include_once($path);
153
-					}
154
-					catch(Exception $e)
159
+					} catch(Exception $e)
155 160
 					{
156
-						if($checkClassExistence && !class_exists($className,false))
157
-							throw new TInvalidOperationException('prado_component_unknown',$className,$e->getMessage());
158
-						else
159
-							throw $e;
161
+						if($checkClassExistence && !class_exists($className,false)) {
162
+													throw new TInvalidOperationException('prado_component_unknown',$className,$e->getMessage());
163
+						} else {
164
+													throw $e;
165
+						}
160 166
 					}
161 167
 				}
162 168
 			}
169
+		} else {
170
+					throw new TInvalidDataValueException('prado_using_invalid',$namespace);
163 171
 		}
164
-		else
165
-			throw new TInvalidDataValueException('prado_using_invalid',$namespace);
166 172
 	}
167 173
 	public static function getPathOfNamespace($namespace, $ext='')
168 174
 	{
169 175
 		if(self::CLASS_FILE_EXT === $ext || empty($ext))
170 176
 		{
171
-			if(isset(self::$_usings[$namespace]))
172
-				return self::$_usings[$namespace];
173
-			if(isset(self::$_aliases[$namespace]))
174
-				return self::$_aliases[$namespace];
177
+			if(isset(self::$_usings[$namespace])) {
178
+							return self::$_usings[$namespace];
179
+			}
180
+			if(isset(self::$_aliases[$namespace])) {
181
+							return self::$_aliases[$namespace];
182
+			}
175 183
 		}
176 184
 		$segs = explode('.',$namespace);
177 185
 		$alias = array_shift($segs);
178
-		if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias)))
179
-			return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR ,$segs),'/\\').(($file === '*') ? '' : DIRECTORY_SEPARATOR.$file.$ext);
186
+		if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias))) {
187
+					return rtrim($root.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR ,$segs),'/\\').(($file === '*') ? '' : DIRECTORY_SEPARATOR.$file.$ext);
188
+		}
180 189
 		return null;
181 190
 	}
182 191
 	public static function getPathOfAlias($alias)
@@ -189,39 +198,45 @@  discard block
 block discarded – undo
189 198
 	}
190 199
 	public static function setPathOfAlias($alias,$path)
191 200
 	{
192
-		if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN'))
193
-			throw new TInvalidOperationException('prado_alias_redefined',$alias);
194
-		else if(($rp=realpath($path))!==false && is_dir($rp))
201
+		if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN')) {
202
+					throw new TInvalidOperationException('prado_alias_redefined',$alias);
203
+		} else if(($rp=realpath($path))!==false && is_dir($rp))
195 204
 		{
196
-			if(strpos($alias,'.')===false)
197
-				self::$_aliases[$alias]=$rp;
198
-			else
199
-				throw new TInvalidDataValueException('prado_aliasname_invalid',$alias);
205
+			if(strpos($alias,'.')===false) {
206
+							self::$_aliases[$alias]=$rp;
207
+			} else {
208
+							throw new TInvalidDataValueException('prado_aliasname_invalid',$alias);
209
+			}
210
+		} else {
211
+					throw new TInvalidDataValueException('prado_alias_invalid',$alias,$path);
200 212
 		}
201
-		else
202
-			throw new TInvalidDataValueException('prado_alias_invalid',$alias,$path);
203 213
 	}
204 214
 	public static function fatalError($msg)
205 215
 	{
206 216
 		echo '<h1>Fatal Error</h1>';
207 217
 		echo '<p>'.$msg.'</p>';
208
-		if(!function_exists('debug_backtrace'))
209
-			return;
218
+		if(!function_exists('debug_backtrace')) {
219
+					return;
220
+		}
210 221
 		echo '<h2>Debug Backtrace</h2>';
211 222
 		echo '<pre>';
212 223
 		$index=-1;
213 224
 		foreach(debug_backtrace() as $t)
214 225
 		{
215 226
 			$index++;
216
-			if($index==0)  				continue;
227
+			if($index==0) {
228
+				continue;
229
+			}
217 230
 			echo '#'.$index.' ';
218
-			if(isset($t['file']))
219
-				echo basename($t['file']) . ':' . $t['line'];
220
-			else
221
-				 echo '<PHP inner-code>';
231
+			if(isset($t['file'])) {
232
+							echo basename($t['file']) . ':' . $t['line'];
233
+			} else {
234
+							 echo '<PHP inner-code>';
235
+			}
222 236
 			echo ' -- ';
223
-			if(isset($t['class']))
224
-				echo $t['class'] . $t['type'];
237
+			if(isset($t['class'])) {
238
+							echo $t['class'] . $t['type'];
239
+			}
225 240
 			echo $t['function'] . '(';
226 241
 			if(isset($t['args']) && sizeof($t['args']) > 0)
227 242
 			{
@@ -231,26 +246,28 @@  discard block
 block discarded – undo
231 246
 					if(is_string($item))
232 247
 					{
233 248
 						$str=htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES);
234
-						if (strlen($item) > 70)
235
-							echo "'". substr($str, 0, 70) . "...'";
236
-						else
237
-							echo "'" . $str . "'";
249
+						if (strlen($item) > 70) {
250
+													echo "'". substr($str, 0, 70) . "...'";
251
+						} else {
252
+													echo "'" . $str . "'";
253
+						}
254
+					} else if (is_int($item) || is_float($item)) {
255
+											echo $item;
256
+					} else if (is_object($item)) {
257
+											echo get_class($item);
258
+					} else if (is_array($item)) {
259
+											echo 'array(' . count($item) . ')';
260
+					} else if (is_bool($item)) {
261
+											echo $item ? 'true' : 'false';
262
+					} else if ($item === null) {
263
+											echo 'NULL';
264
+					} else if (is_resource($item)) {
265
+											echo get_resource_type($item);
238 266
 					}
239
-					else if (is_int($item) || is_float($item))
240
-						echo $item;
241
-					else if (is_object($item))
242
-						echo get_class($item);
243
-					else if (is_array($item))
244
-						echo 'array(' . count($item) . ')';
245
-					else if (is_bool($item))
246
-						echo $item ? 'true' : 'false';
247
-					else if ($item === null)
248
-						echo 'NULL';
249
-					else if (is_resource($item))
250
-						echo get_resource_type($item);
251 267
 					$count++;
252
-					if (count($t['args']) > $count)
253
-						echo ', ';
268
+					if (count($t['args']) > $count) {
269
+											echo ', ';
270
+					}
254 271
 				}
255 272
 			}
256 273
 			echo ")\n";
@@ -263,9 +280,9 @@  discard block
 block discarded – undo
263 280
 		static $languages=null;
264 281
 		if($languages===null)
265 282
 		{
266
-			if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
267
-				$languages[0]='en';
268
-			else
283
+			if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
284
+							$languages[0]='en';
285
+			} else
269 286
 			{
270 287
 				$languages=array();
271 288
 				foreach(explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language)
@@ -275,8 +292,9 @@  discard block
 block discarded – undo
275 292
 				}
276 293
 				arsort($languages);
277 294
 				$languages=array_keys($languages);
278
-				if(empty($languages))
279
-					$languages[0]='en';
295
+				if(empty($languages)) {
296
+									$languages[0]='en';
297
+				}
280 298
 			}
281 299
 		}
282 300
 		return $languages;
@@ -288,38 +306,43 @@  discard block
 block discarded – undo
288 306
 		{
289 307
 			$langs=Prado::getUserLanguages();
290 308
 			$lang=explode('-',$langs[0]);
291
-			if(empty($lang[0]) || !ctype_alpha($lang[0]))
292
-				$language='en';
293
-			else
294
-				$language=$lang[0];
309
+			if(empty($lang[0]) || !ctype_alpha($lang[0])) {
310
+							$language='en';
311
+			} else {
312
+							$language=$lang[0];
313
+			}
295 314
 		}
296 315
 		return $language;
297 316
 	}
298 317
 	public static function trace($msg,$category='Uncategorized',$ctl=null)
299 318
 	{
300
-		if(self::$_application && self::$_application->getMode()===TApplicationMode::Performance)
301
-			return;
319
+		if(self::$_application && self::$_application->getMode()===TApplicationMode::Performance) {
320
+					return;
321
+		}
302 322
 		if(!self::$_application || self::$_application->getMode()===TApplicationMode::Debug)
303 323
 		{
304 324
 			$trace=debug_backtrace();
305
-			if(isset($trace[0]['file']) && isset($trace[0]['line']))
306
-				$msg.=" (line {$trace[0]['line']}, {$trace[0]['file']})";
325
+			if(isset($trace[0]['file']) && isset($trace[0]['line'])) {
326
+							$msg.=" (line {$trace[0]['line']}, {$trace[0]['file']})";
327
+			}
307 328
 			$level=TLogger::DEBUG;
329
+		} else {
330
+					$level=TLogger::INFO;
308 331
 		}
309
-		else
310
-			$level=TLogger::INFO;
311 332
 		self::log($msg,$level,$category,$ctl);
312 333
 	}
313 334
 	public static function log($msg,$level=TLogger::INFO,$category='Uncategorized',$ctl=null)
314 335
 	{
315
-		if(self::$_logger===null)
316
-			self::$_logger=new TLogger;
336
+		if(self::$_logger===null) {
337
+					self::$_logger=new TLogger;
338
+		}
317 339
 		self::$_logger->log($msg,$level,$category,$ctl);
318 340
 	}
319 341
 	public static function getLogger()
320 342
 	{
321
-		if(self::$_logger===null)
322
-			self::$_logger=new TLogger;
343
+		if(self::$_logger===null) {
344
+					self::$_logger=new TLogger;
345
+		}
323 346
 		return self::$_logger;
324 347
 	}
325 348
 	public static function varDump($var,$depth=10,$highlight=false)
@@ -332,17 +355,24 @@  discard block
 block discarded – undo
332 355
 		Prado::using('System.I18N.Translation');
333 356
 		$app = Prado::getApplication()->getGlobalization(false);
334 357
 		$params = array();
335
-		foreach($parameters as $key => $value)
336
-			$params['{'.$key.'}'] = $value;
337
-				if($app===null || ($config = $app->getTranslationConfiguration())===null)
338
-			return strtr($text, $params);
339
-		if ($catalogue===null)
340
-			$catalogue=isset($config['catalogue'])?$config['catalogue']:'messages';
358
+		foreach($parameters as $key => $value) {
359
+					$params['{'.$key.'}'] = $value;
360
+		}
361
+				if($app===null || ($config = $app->getTranslationConfiguration())===null) {
362
+							return strtr($text, $params);
363
+				}
364
+		if ($catalogue===null) {
365
+					$catalogue=isset($config['catalogue'])?$config['catalogue']:'messages';
366
+		}
341 367
 		Translation::init($catalogue);
342 368
 				$appCharset = $app===null ? '' : $app->getCharset();
343 369
 				$defaultCharset = ($app===null) ? 'UTF-8' : $app->getDefaultCharset();
344
-				if(empty($charset)) $charset = $appCharset;
345
-		if(empty($charset)) $charset = $defaultCharset;
370
+				if(empty($charset)) {
371
+					$charset = $appCharset;
372
+				}
373
+		if(empty($charset)) {
374
+			$charset = $defaultCharset;
375
+		}
346 376
 		return Translation::formatter($catalogue)->format($text,$params,$catalogue,$charset);
347 377
 	}
348 378
 }
@@ -461,8 +491,9 @@  discard block
 block discarded – undo
461 491
 	}
462 492
 	public function publishAsset($assetPath,$className=null)
463 493
 	{
464
-		if($className===null)
465
-			$className=get_class($this);
494
+		if($className===null) {
495
+					$className=get_class($this);
496
+		}
466 497
 		$class=new ReflectionClass($className);
467 498
 		$fullPath=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$assetPath;
468 499
 		return $this->publishFilePath($fullPath);
@@ -526,37 +557,42 @@  discard block
 block discarded – undo
526 557
 	}
527 558
 	public function getErrorTemplatePath()
528 559
 	{
529
-		if($this->_templatePath===null)
530
-			$this->_templatePath=Prado::getFrameworkPath().'/Exceptions/templates';
560
+		if($this->_templatePath===null) {
561
+					$this->_templatePath=Prado::getFrameworkPath().'/Exceptions/templates';
562
+		}
531 563
 		return $this->_templatePath;
532 564
 	}
533 565
 	public function setErrorTemplatePath($value)
534 566
 	{
535
-		if(($templatePath=Prado::getPathOfNamespace($value))!==null && is_dir($templatePath))
536
-			$this->_templatePath=$templatePath;
537
-		else
538
-			throw new TConfigurationException('errorhandler_errortemplatepath_invalid',$value);
567
+		if(($templatePath=Prado::getPathOfNamespace($value))!==null && is_dir($templatePath)) {
568
+					$this->_templatePath=$templatePath;
569
+		} else {
570
+					throw new TConfigurationException('errorhandler_errortemplatepath_invalid',$value);
571
+		}
539 572
 	}
540 573
 	public function handleError($sender,$param)
541 574
 	{
542 575
 		static $handling=false;
543 576
 								restore_error_handler();
544 577
 		restore_exception_handler();
545
-				if($handling)
546
-			$this->handleRecursiveError($param);
547
-		else
578
+				if($handling) {
579
+							$this->handleRecursiveError($param);
580
+				} else
548 581
 		{
549 582
 			$handling=true;
550
-			if(($response=$this->getResponse())!==null)
551
-				$response->clear();
552
-			if(!headers_sent())
553
-				header('Content-Type: text/html; charset=UTF-8');
554
-			if($param instanceof THttpException)
555
-				$this->handleExternalError($param->getStatusCode(),$param);
556
-			else if($this->getApplication()->getMode()===TApplicationMode::Debug)
557
-				$this->displayException($param);
558
-			else
559
-				$this->handleExternalError(500,$param);
583
+			if(($response=$this->getResponse())!==null) {
584
+							$response->clear();
585
+			}
586
+			if(!headers_sent()) {
587
+							header('Content-Type: text/html; charset=UTF-8');
588
+			}
589
+			if($param instanceof THttpException) {
590
+							$this->handleExternalError($param->getStatusCode(),$param);
591
+			} else if($this->getApplication()->getMode()===TApplicationMode::Debug) {
592
+							$this->displayException($param);
593
+			} else {
594
+							$this->handleExternalError(500,$param);
595
+			}
560 596
 		}
561 597
 	}
562 598
 	protected static function hideSecurityRelated($value, $exception=null)
@@ -567,28 +603,32 @@  discard block
 block discarded – undo
567 603
 			$aTrace = $exception->getTrace();
568 604
 			foreach($aTrace as $item)
569 605
 			{
570
-				if(isset($item['file']))
571
-					$aRpl[dirname($item['file']) . DIRECTORY_SEPARATOR] = '<hidden>' . DIRECTORY_SEPARATOR;
606
+				if(isset($item['file'])) {
607
+									$aRpl[dirname($item['file']) . DIRECTORY_SEPARATOR] = '<hidden>' . DIRECTORY_SEPARATOR;
608
+				}
572 609
 			}
573 610
 		}
574 611
 		$aRpl[$_SERVER['DOCUMENT_ROOT']] = '${DocumentRoot}';
575 612
 		$aRpl[str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT'])] = '${DocumentRoot}';
576 613
 		$aRpl[PRADO_DIR . DIRECTORY_SEPARATOR] = '${PradoFramework}' . DIRECTORY_SEPARATOR;
577
-		if(isset($aRpl[DIRECTORY_SEPARATOR])) unset($aRpl[DIRECTORY_SEPARATOR]);
614
+		if(isset($aRpl[DIRECTORY_SEPARATOR])) {
615
+			unset($aRpl[DIRECTORY_SEPARATOR]);
616
+		}
578 617
 		$aRpl = array_reverse($aRpl, true);
579 618
 		return str_replace(array_keys($aRpl), $aRpl, $value);
580 619
 	}
581 620
 	protected function handleExternalError($statusCode,$exception)
582 621
 	{
583
-		if(!($exception instanceof THttpException))
584
-			error_log($exception->__toString());
622
+		if(!($exception instanceof THttpException)) {
623
+					error_log($exception->__toString());
624
+		}
585 625
 		$content=$this->getErrorTemplate($statusCode,$exception);
586 626
 		$serverAdmin=isset($_SERVER['SERVER_ADMIN'])?$_SERVER['SERVER_ADMIN']:'';
587 627
 		$isDebug = $this->getApplication()->getMode()===TApplicationMode::Debug;
588 628
 		$errorMessage = $exception->getMessage();
589
-		if($isDebug)
590
-			$version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion();
591
-		else
629
+		if($isDebug) {
630
+					$version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion();
631
+		} else
592 632
 		{
593 633
 			$version='';
594 634
 			$errorMessage = self::hideSecurityRelated($errorMessage, $exception);
@@ -611,8 +651,7 @@  discard block
 block discarded – undo
611 651
 			echo "<body><h1>Recursive Error</h1>\n";
612 652
 			echo "<pre>".$exception->__toString()."</pre>\n";
613 653
 			echo "</body></html>";
614
-		}
615
-		else
654
+		} else
616 655
 		{
617 656
 			error_log("Error happened while processing an existing error:\n".$exception->__toString());
618 657
 			header('HTTP/1.0 500 Internal Error');
@@ -631,28 +670,28 @@  discard block
 block discarded – undo
631 670
 			$fileName=$exception->getTemplateFile();
632 671
 			$lines=empty($fileName)?explode("\n",$exception->getTemplateSource()):@file($fileName);
633 672
 			$source=$this->getSourceCode($lines,$exception->getLineNumber());
634
-			if($fileName==='')
635
-				$fileName='---embedded template---';
673
+			if($fileName==='') {
674
+							$fileName='---embedded template---';
675
+			}
636 676
 			$errorLine=$exception->getLineNumber();
637
-		}
638
-		else
677
+		} else
639 678
 		{
640 679
 			if(($trace=$this->getExactTrace($exception))!==null)
641 680
 			{
642 681
 				$fileName=$trace['file'];
643 682
 				$errorLine=$trace['line'];
644
-			}
645
-			else
683
+			} else
646 684
 			{
647 685
 				$fileName=$exception->getFile();
648 686
 				$errorLine=$exception->getLine();
649 687
 			}
650 688
 			$source=$this->getSourceCode(@file($fileName),$errorLine);
651 689
 		}
652
-		if($this->getApplication()->getMode()===TApplicationMode::Debug)
653
-			$version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion();
654
-		else
655
-			$version='';
690
+		if($this->getApplication()->getMode()===TApplicationMode::Debug) {
691
+					$version=$_SERVER['SERVER_SOFTWARE'].' <a href="https://github.com/pradosoft/prado">PRADO</a>/'.Prado::getVersion();
692
+		} else {
693
+					$version='';
694
+		}
656 695
 		$tokens=array(
657 696
 			'%%ErrorType%%' => get_class($exception),
658 697
 			'%%ErrorMessage%%' => $this->addLink(htmlspecialchars($exception->getMessage())),
@@ -669,41 +708,47 @@  discard block
 block discarded – undo
669 708
 	{
670 709
 		$lang=Prado::getPreferredLanguage();
671 710
 		$exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'-'.$lang.'.html';
672
-		if(!is_file($exceptionFile))
673
-			$exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'.html';
674
-		if(($content=@file_get_contents($exceptionFile))===false)
675
-			die("Unable to open exception template file '$exceptionFile'.");
711
+		if(!is_file($exceptionFile)) {
712
+					$exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'.html';
713
+		}
714
+		if(($content=@file_get_contents($exceptionFile))===false) {
715
+					die("Unable to open exception template file '$exceptionFile'.");
716
+		}
676 717
 		return $content;
677 718
 	}
678 719
 	protected function getErrorTemplate($statusCode,$exception)
679 720
 	{
680 721
 		$base=$this->getErrorTemplatePath().DIRECTORY_SEPARATOR.self::ERROR_FILE_NAME;
681 722
 		$lang=Prado::getPreferredLanguage();
682
-		if(is_file("$base$statusCode-$lang.html"))
683
-			$errorFile="$base$statusCode-$lang.html";
684
-		else if(is_file("$base$statusCode.html"))
685
-			$errorFile="$base$statusCode.html";
686
-		else if(is_file("$base-$lang.html"))
687
-			$errorFile="$base-$lang.html";
688
-		else
689
-			$errorFile="$base.html";
690
-		if(($content=@file_get_contents($errorFile))===false)
691
-			die("Unable to open error template file '$errorFile'.");
723
+		if(is_file("$base$statusCode-$lang.html")) {
724
+					$errorFile="$base$statusCode-$lang.html";
725
+		} else if(is_file("$base$statusCode.html")) {
726
+					$errorFile="$base$statusCode.html";
727
+		} else if(is_file("$base-$lang.html")) {
728
+					$errorFile="$base-$lang.html";
729
+		} else {
730
+					$errorFile="$base.html";
731
+		}
732
+		if(($content=@file_get_contents($errorFile))===false) {
733
+					die("Unable to open error template file '$errorFile'.");
734
+		}
692 735
 		return $content;
693 736
 	}
694 737
 	private function getExactTrace($exception)
695 738
 	{
696 739
 		$trace=$exception->getTrace();
697 740
 		$result=null;
698
-						if($exception instanceof TPhpErrorException)
699
-			$result=isset($trace[0]['file'])?$trace[0]:$trace[1];
700
-		else if($exception instanceof TInvalidOperationException)
741
+						if($exception instanceof TPhpErrorException) {
742
+									$result=isset($trace[0]['file'])?$trace[0]:$trace[1];
743
+						} else if($exception instanceof TInvalidOperationException)
701 744
 		{
702
-						if(($result=$this->getPropertyAccessTrace($trace,'__get'))===null)
703
-				$result=$this->getPropertyAccessTrace($trace,'__set');
745
+						if(($result=$this->getPropertyAccessTrace($trace,'__get'))===null) {
746
+										$result=$this->getPropertyAccessTrace($trace,'__set');
747
+						}
748
+		}
749
+		if($result!==null && strpos($result['file'],': eval()\'d code')!==false) {
750
+					return null;
704 751
 		}
705
-		if($result!==null && strpos($result['file'],': eval()\'d code')!==false)
706
-			return null;
707 752
 		return $result;
708 753
 	}
709 754
 	private function getPropertyAccessTrace($trace,$pattern)
@@ -711,10 +756,11 @@  discard block
 block discarded – undo
711 756
 		$result=null;
712 757
 		foreach($trace as $t)
713 758
 		{
714
-			if(isset($t['function']) && $t['function']===$pattern)
715
-				$result=$t;
716
-			else
717
-				break;
759
+			if(isset($t['function']) && $t['function']===$pattern) {
760
+							$result=$t;
761
+			} else {
762
+							break;
763
+			}
718 764
 		}
719 765
 		return $result;
720 766
 	}
@@ -729,9 +775,9 @@  discard block
 block discarded – undo
729 775
 			{
730 776
 				$line=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",'    ',$lines[$i])));
731 777
 				$source.="<div class=\"error\">".$line."</div>";
778
+			} else {
779
+							$source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",'    ',$lines[$i])));
732 780
 			}
733
-			else
734
-				$source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",'    ',$lines[$i])));
735 781
 		}
736 782
 		return $source;
737 783
 	}
@@ -748,8 +794,9 @@  discard block
 block discarded – undo
748 794
 	private $_r=false;
749 795
 	public function __construct($data=null,$readOnly=false)
750 796
 	{
751
-		if($data!==null)
752
-			$this->copyFrom($data);
797
+		if($data!==null) {
798
+					$this->copyFrom($data);
799
+		}
753 800
 		$this->setReadOnly($readOnly);
754 801
 	}
755 802
 	public function getReadOnly()
@@ -774,10 +821,11 @@  discard block
 block discarded – undo
774 821
 	}
775 822
 	public function itemAt($index)
776 823
 	{
777
-		if($index>=0 && $index<$this->_c)
778
-			return $this->_d[$index];
779
-		else
780
-			throw new TInvalidDataValueException('list_index_invalid',$index);
824
+		if($index>=0 && $index<$this->_c) {
825
+					return $this->_d[$index];
826
+		} else {
827
+					throw new TInvalidDataValueException('list_index_invalid',$index);
828
+		}
781 829
 	}
782 830
 	public function add($item)
783 831
 	{
@@ -788,18 +836,18 @@  discard block
 block discarded – undo
788 836
 	{
789 837
 		if(!$this->_r)
790 838
 		{
791
-			if($index===$this->_c)
792
-				$this->_d[$this->_c++]=$item;
793
-			else if($index>=0 && $index<$this->_c)
839
+			if($index===$this->_c) {
840
+							$this->_d[$this->_c++]=$item;
841
+			} else if($index>=0 && $index<$this->_c)
794 842
 			{
795 843
 				array_splice($this->_d,$index,0,array($item));
796 844
 				$this->_c++;
845
+			} else {
846
+							throw new TInvalidDataValueException('list_index_invalid',$index);
797 847
 			}
798
-			else
799
-				throw new TInvalidDataValueException('list_index_invalid',$index);
848
+		} else {
849
+					throw new TInvalidOperationException('list_readonly',get_class($this));
800 850
 		}
801
-		else
802
-			throw new TInvalidOperationException('list_readonly',get_class($this));
803 851
 	}
804 852
 	public function remove($item)
805 853
 	{
@@ -809,12 +857,12 @@  discard block
 block discarded – undo
809 857
 			{
810 858
 				$this->removeAt($index);
811 859
 				return $index;
860
+			} else {
861
+							throw new TInvalidDataValueException('list_item_inexistent');
812 862
 			}
813
-			else
814
-				throw new TInvalidDataValueException('list_item_inexistent');
863
+		} else {
864
+					throw new TInvalidOperationException('list_readonly',get_class($this));
815 865
 		}
816
-		else
817
-			throw new TInvalidOperationException('list_readonly',get_class($this));
818 866
 	}
819 867
 	public function removeAt($index)
820 868
 	{
@@ -823,25 +871,26 @@  discard block
 block discarded – undo
823 871
 			if($index>=0 && $index<$this->_c)
824 872
 			{
825 873
 				$this->_c--;
826
-				if($index===$this->_c)
827
-					return array_pop($this->_d);
828
-				else
874
+				if($index===$this->_c) {
875
+									return array_pop($this->_d);
876
+				} else
829 877
 				{
830 878
 					$item=$this->_d[$index];
831 879
 					array_splice($this->_d,$index,1);
832 880
 					return $item;
833 881
 				}
882
+			} else {
883
+							throw new TInvalidDataValueException('list_index_invalid',$index);
834 884
 			}
835
-			else
836
-				throw new TInvalidDataValueException('list_index_invalid',$index);
885
+		} else {
886
+					throw new TInvalidOperationException('list_readonly',get_class($this));
837 887
 		}
838
-		else
839
-			throw new TInvalidOperationException('list_readonly',get_class($this));
840 888
 	}
841 889
 	public function clear()
842 890
 	{
843
-		for($i=$this->_c-1;$i>=0;--$i)
844
-			$this->removeAt($i);
891
+		for($i=$this->_c-1;$i>=0;--$i) {
892
+					$this->removeAt($i);
893
+		}
845 894
 	}
846 895
 	public function contains($item)
847 896
 	{
@@ -849,34 +898,37 @@  discard block
 block discarded – undo
849 898
 	}
850 899
 	public function indexOf($item)
851 900
 	{
852
-		if(($index=array_search($item,$this->_d,true))===false)
853
-			return -1;
854
-		else
855
-			return $index;
901
+		if(($index=array_search($item,$this->_d,true))===false) {
902
+					return -1;
903
+		} else {
904
+					return $index;
905
+		}
856 906
 	}
857 907
 	public function insertBefore($baseitem, $item)
858 908
 	{
859 909
 		if(!$this->_r)
860 910
 		{
861
-			if(($index = $this->indexOf($baseitem)) == -1)
862
-				throw new TInvalidDataValueException('list_item_inexistent');
911
+			if(($index = $this->indexOf($baseitem)) == -1) {
912
+							throw new TInvalidDataValueException('list_item_inexistent');
913
+			}
863 914
 			$this->insertAt($index, $item);
864 915
 			return $index;
916
+		} else {
917
+					throw new TInvalidOperationException('list_readonly',get_class($this));
865 918
 		}
866
-		else
867
-			throw new TInvalidOperationException('list_readonly',get_class($this));
868 919
 	}
869 920
 	public function insertAfter($baseitem, $item)
870 921
 	{
871 922
 		if(!$this->_r)
872 923
 		{
873
-			if(($index = $this->indexOf($baseitem)) == -1)
874
-				throw new TInvalidDataValueException('list_item_inexistent');
924
+			if(($index = $this->indexOf($baseitem)) == -1) {
925
+							throw new TInvalidDataValueException('list_item_inexistent');
926
+			}
875 927
 			$this->insertAt($index + 1, $item);
876 928
 			return $index + 1;
929
+		} else {
930
+					throw new TInvalidOperationException('list_readonly',get_class($this));
877 931
 		}
878
-		else
879
-			throw new TInvalidOperationException('list_readonly',get_class($this));
880 932
 	}
881 933
 	public function toArray()
882 934
 	{
@@ -886,23 +938,26 @@  discard block
 block discarded – undo
886 938
 	{
887 939
 		if(is_array($data) || ($data instanceof Traversable))
888 940
 		{
889
-			if($this->_c>0)
890
-				$this->clear();
891
-			foreach($data as $item)
892
-				$this->add($item);
941
+			if($this->_c>0) {
942
+							$this->clear();
943
+			}
944
+			foreach($data as $item) {
945
+							$this->add($item);
946
+			}
947
+		} else if($data!==null) {
948
+					throw new TInvalidDataTypeException('list_data_not_iterable');
893 949
 		}
894
-		else if($data!==null)
895
-			throw new TInvalidDataTypeException('list_data_not_iterable');
896 950
 	}
897 951
 	public function mergeWith($data)
898 952
 	{
899 953
 		if(is_array($data) || ($data instanceof Traversable))
900 954
 		{
901
-			foreach($data as $item)
902
-				$this->add($item);
955
+			foreach($data as $item) {
956
+							$this->add($item);
957
+			}
958
+		} else if($data!==null) {
959
+					throw new TInvalidDataTypeException('list_data_not_iterable');
903 960
 		}
904
-		else if($data!==null)
905
-			throw new TInvalidDataTypeException('list_data_not_iterable');
906 961
 	}
907 962
 	public function offsetExists($offset)
908 963
 	{
@@ -914,9 +969,9 @@  discard block
 block discarded – undo
914 969
 	}
915 970
 	public function offsetSet($offset,$item)
916 971
 	{
917
-		if($offset===null || $offset===$this->_c)
918
-			$this->insertAt($this->_c,$item);
919
-		else
972
+		if($offset===null || $offset===$this->_c) {
973
+					$this->insertAt($this->_c,$item);
974
+		} else
920 975
 		{
921 976
 			$this->removeAt($offset);
922 977
 			$this->insertAt($offset,$item);
@@ -965,14 +1020,16 @@  discard block
 block discarded – undo
965 1020
 	private $_primary=true;
966 1021
 	public function init($config)
967 1022
 	{
968
-		if($this->_prefix===null)
969
-			$this->_prefix=$this->getApplication()->getUniqueID();
1023
+		if($this->_prefix===null) {
1024
+					$this->_prefix=$this->getApplication()->getUniqueID();
1025
+		}
970 1026
 		if($this->_primary)
971 1027
 		{
972
-			if($this->getApplication()->getCache()===null)
973
-				$this->getApplication()->setCache($this);
974
-			else
975
-				throw new TConfigurationException('cache_primary_duplicated',get_class($this));
1028
+			if($this->getApplication()->getCache()===null) {
1029
+							$this->getApplication()->setCache($this);
1030
+			} else {
1031
+							throw new TConfigurationException('cache_primary_duplicated',get_class($this));
1032
+			}
976 1033
 		}
977 1034
 	}
978 1035
 	public function getPrimaryCache()
@@ -999,18 +1056,20 @@  discard block
 block discarded – undo
999 1056
 	{
1000 1057
 		if(($data=$this->getValue($this->generateUniqueKey($id)))!==false)
1001 1058
 		{
1002
-			if(!is_array($data))
1003
-				return false;
1004
-			if(!($data[1] instanceof ICacheDependency) || !$data[1]->getHasChanged())
1005
-				return $data[0];
1059
+			if(!is_array($data)) {
1060
+							return false;
1061
+			}
1062
+			if(!($data[1] instanceof ICacheDependency) || !$data[1]->getHasChanged()) {
1063
+							return $data[0];
1064
+			}
1006 1065
 		}
1007 1066
 		return false;
1008 1067
 	}
1009 1068
 	public function set($id,$value,$expire=0,$dependency=null)
1010 1069
 	{
1011
-		if(empty($value) && $expire === 0)
1012
-			$this->delete($id);
1013
-		else
1070
+		if(empty($value) && $expire === 0) {
1071
+					$this->delete($id);
1072
+		} else
1014 1073
 		{
1015 1074
 			$data=array($value,$dependency);
1016 1075
 			return $this->setValue($this->generateUniqueKey($id),$data,$expire);
@@ -1018,8 +1077,9 @@  discard block
 block discarded – undo
1018 1077
 	}
1019 1078
 	public function add($id,$value,$expire=0,$dependency=null)
1020 1079
 	{
1021
-		if(empty($value) && $expire === 0)
1022
-			return false;
1080
+		if(empty($value) && $expire === 0) {
1081
+					return false;
1082
+		}
1023 1083
 		$data=array($value,$dependency);
1024 1084
 		return $this->addValue($this->generateUniqueKey($id),$data,$expire);
1025 1085
 	}
@@ -1097,8 +1157,9 @@  discard block
 block discarded – undo
1097 1157
 	}
1098 1158
 	public function setDirectory($directory)
1099 1159
 	{
1100
-		if(($path=realpath($directory))===false || !is_dir($path))
1101
-			throw new TInvalidDataValueException('directorycachedependency_directory_invalid',$directory);
1160
+		if(($path=realpath($directory))===false || !is_dir($path)) {
1161
+					throw new TInvalidDataValueException('directorycachedependency_directory_invalid',$directory);
1162
+		}
1102 1163
 		$this->_directory=$path;
1103 1164
 		$this->_timestamps=$this->generateTimestamps($path);
1104 1165
 	}
@@ -1132,21 +1193,23 @@  discard block
 block discarded – undo
1132 1193
 	}
1133 1194
 	protected function generateTimestamps($directory,$level=0)
1134 1195
 	{
1135
-		if(($dir=opendir($directory))===false)
1136
-			throw new TIOException('directorycachedependency_directory_invalid',$directory);
1196
+		if(($dir=opendir($directory))===false) {
1197
+					throw new TIOException('directorycachedependency_directory_invalid',$directory);
1198
+		}
1137 1199
 		$timestamps=array();
1138 1200
 		while(($file=readdir($dir))!==false)
1139 1201
 		{
1140 1202
 			$path=$directory.DIRECTORY_SEPARATOR.$file;
1141
-			if($file==='.' || $file==='..')
1142
-				continue;
1143
-			else if(is_dir($path))
1203
+			if($file==='.' || $file==='..') {
1204
+							continue;
1205
+			} else if(is_dir($path))
1144 1206
 			{
1145
-				if(($this->_recursiveLevel<0 || $level<$this->_recursiveLevel) && $this->validateDirectory($path))
1146
-					$timestamps=array_merge($this->generateTimestamps($path,$level+1));
1207
+				if(($this->_recursiveLevel<0 || $level<$this->_recursiveLevel) && $this->validateDirectory($path)) {
1208
+									$timestamps=array_merge($this->generateTimestamps($path,$level+1));
1209
+				}
1210
+			} else if($this->validateFile($path)) {
1211
+							$timestamps[$path]=filemtime($path);
1147 1212
 			}
1148
-			else if($this->validateFile($path))
1149
-				$timestamps[$path]=filemtime($path);
1150 1213
 		}
1151 1214
 		closedir($dir);
1152 1215
 		return $timestamps;
@@ -1179,17 +1242,19 @@  discard block
 block discarded – undo
1179 1242
 	private $_dependencies=null;
1180 1243
 	public function getDependencies()
1181 1244
 	{
1182
-		if($this->_dependencies===null)
1183
-			$this->_dependencies=new TCacheDependencyList;
1245
+		if($this->_dependencies===null) {
1246
+					$this->_dependencies=new TCacheDependencyList;
1247
+		}
1184 1248
 		return $this->_dependencies;
1185 1249
 	}
1186 1250
 	public function getHasChanged()
1187 1251
 	{
1188 1252
 		if($this->_dependencies!==null)
1189 1253
 		{
1190
-			foreach($this->_dependencies as $dependency)
1191
-				if($dependency->getHasChanged())
1254
+			foreach($this->_dependencies as $dependency) {
1255
+							if($dependency->getHasChanged())
1192 1256
 					return true;
1257
+			}
1193 1258
 		}
1194 1259
 		return false;
1195 1260
 	}
@@ -1205,10 +1270,11 @@  discard block
 block discarded – undo
1205 1270
 {
1206 1271
 	public function insertAt($index,$item)
1207 1272
 	{
1208
-		if($item instanceof ICacheDependency)
1209
-			parent::insertAt($index,$item);
1210
-		else
1211
-			throw new TInvalidDataTypeException('cachedependencylist_cachedependency_required');
1273
+		if($item instanceof ICacheDependency) {
1274
+					parent::insertAt($index,$item);
1275
+		} else {
1276
+					throw new TInvalidDataTypeException('cachedependencylist_cachedependency_required');
1277
+		}
1212 1278
 	}
1213 1279
 }
1214 1280
 class TTextWriter extends TComponent implements ITextWriter
@@ -1240,8 +1306,9 @@  discard block
 block discarded – undo
1240 1306
 	public function __construct($data=null,$readOnly=false,$defaultPriority=10,$precision=8)
1241 1307
 	{
1242 1308
 		parent::__construct();
1243
-		if($data!==null)
1244
-			$this->copyFrom($data);
1309
+		if($data!==null) {
1310
+					$this->copyFrom($data);
1311
+		}
1245 1312
 		$this->setReadOnly($readOnly);
1246 1313
 		$this->setPrecision($precision);
1247 1314
 		$this->setDefaultPriority($defaultPriority);
@@ -1256,11 +1323,13 @@  discard block
 block discarded – undo
1256 1323
 	}
1257 1324
 	public function getPriorityCount($priority=null)
1258 1325
 	{
1259
-		if($priority===null)
1260
-			$priority=$this->getDefaultPriority();
1326
+		if($priority===null) {
1327
+					$priority=$this->getDefaultPriority();
1328
+		}
1261 1329
 		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1262
-		if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority]))
1263
-			return false;
1330
+		if(!isset($this->_d[$priority]) || !is_array($this->_d[$priority])) {
1331
+					return false;
1332
+		}
1264 1333
 		return count($this->_d[$priority]);
1265 1334
 	}
1266 1335
 	public function getDefaultPriority()
@@ -1295,12 +1364,14 @@  discard block
 block discarded – undo
1295 1364
 		}
1296 1365
 	}
1297 1366
 	protected function flattenPriorities() {
1298
-		if(is_array($this->_fd))
1299
-			return $this->_fd;
1367
+		if(is_array($this->_fd)) {
1368
+					return $this->_fd;
1369
+		}
1300 1370
 		$this->sortPriorities();
1301 1371
 		$this->_fd=array();
1302
-		foreach($this->_d as $priority => $itemsatpriority)
1303
-			$this->_fd=array_merge($this->_fd,$itemsatpriority);
1372
+		foreach($this->_d as $priority => $itemsatpriority) {
1373
+					$this->_fd=array_merge($this->_fd,$itemsatpriority);
1374
+		}
1304 1375
 		return $this->_fd;
1305 1376
 	}
1306 1377
 	public function itemAt($index)
@@ -1308,20 +1379,23 @@  discard block
 block discarded – undo
1308 1379
 		if($index>=0&&$index<$this->getCount()) {
1309 1380
 			$arr=$this->flattenPriorities();
1310 1381
 			return $arr[$index];
1311
-		} else
1312
-			throw new TInvalidDataValueException('list_index_invalid',$index);
1382
+		} else {
1383
+					throw new TInvalidDataValueException('list_index_invalid',$index);
1384
+		}
1313 1385
 	}
1314 1386
 	public function itemsAtPriority($priority=null)
1315 1387
 	{
1316
-		if($priority===null)
1317
-			$priority=$this->getDefaultPriority();
1388
+		if($priority===null) {
1389
+					$priority=$this->getDefaultPriority();
1390
+		}
1318 1391
 		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1319 1392
 		return isset($this->_d[$priority])?$this->_d[$priority]:null;
1320 1393
 	}
1321 1394
 	public function itemAtIndexInPriority($index,$priority=null)
1322 1395
 	{
1323
-		if($priority===null)
1324
-			$priority=$this->getDefaultPriority();
1396
+		if($priority===null) {
1397
+					$priority=$this->getDefaultPriority();
1398
+		}
1325 1399
 		$priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p);
1326 1400
 		return !isset($this->_d[$priority])?false:(
1327 1401
 				isset($this->_d[$priority][$index])?$this->_d[$priority][$index]:false
@@ -1329,34 +1403,41 @@  discard block
 block discarded – undo
1329 1403
 	}
1330 1404
 	public function add($item,$priority=null)
1331 1405
 	{
1332
-		if($this->getReadOnly())
1333
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1406
+		if($this->getReadOnly()) {
1407
+					throw new TInvalidOperationException('list_readonly',get_class($this));
1408
+		}
1334 1409
 		return $this->insertAtIndexInPriority($item,false,$priority,true);
1335 1410
 	}
1336 1411
 	public function insertAt($index,$item)
1337 1412
 	{
1338
-		if($this->getReadOnly())
1339
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1340
-		if(($priority=$this->priorityAt($index,true))!==false)
1341
-			$this->insertAtIndexInPriority($item,$priority[1],$priority[0]);
1342
-		else
1343
-			throw new TInvalidDataValueException('list_index_invalid',$index);
1413
+		if($this->getReadOnly()) {
1414
+					throw new TInvalidOperationException('list_readonly',get_class($this));
1415
+		}
1416
+		if(($priority=$this->priorityAt($index,true))!==false) {
1417
+					$this->insertAtIndexInPriority($item,$priority[1],$priority[0]);
1418
+		} else {
1419
+					throw new TInvalidDataValueException('list_index_invalid',$index);
1420
+		}
1344 1421
 	}
1345 1422
 	public function insertAtIndexInPriority($item,$index=false,$priority=null,$preserveCache=false)
1346 1423
 	{
1347
-		if($this->getReadOnly())
1348
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1349
-		if($priority===null)
1350
-			$priority=$this->getDefaultPriority();
1424
+		if($this->getReadOnly()) {
1425
+					throw new TInvalidOperationException('list_readonly',get_class($this));
1426
+		}
1427
+		if($priority===null) {
1428
+					$priority=$this->getDefaultPriority();
1429
+		}
1351 1430
 		$priority=(string)round(TPropertyValue::ensureFloat($priority), $this->_p);
1352 1431
 		if($preserveCache) {
1353 1432
 			$this->sortPriorities();
1354 1433
 			$cc=0;
1355
-			foreach($this->_d as $prioritykey=>$items)
1356
-				if($prioritykey>=$priority)
1434
+			foreach($this->_d as $prioritykey=>$items) {
1435
+							if($prioritykey>=$priority)
1357 1436
 					break;
1358
-				else
1359
-					$cc+=count($items);
1437
+			}
1438
+				else {
1439
+									$cc+=count($items);
1440
+				}
1360 1441
 			if($index===false&&isset($this->_d[$priority])) {
1361 1442
 				$c=count($this->_d[$priority]);
1362 1443
 				$c+=$cc;
@@ -1369,7 +1450,9 @@  discard block
 block discarded – undo
1369 1450
 				$this->_o = false;
1370 1451
 				$this->_d[$priority]=array($item);
1371 1452
 			}
1372
-			if($this->_fd&&is_array($this->_fd)) 				array_splice($this->_fd,$c,0,array($item));
1453
+			if($this->_fd&&is_array($this->_fd)) {
1454
+				array_splice($this->_fd,$c,0,array($item));
1455
+			}
1373 1456
 		} else {
1374 1457
 			$c=null;
1375 1458
 			if($index===false&&isset($this->_d[$priority])) {
@@ -1383,66 +1466,78 @@  discard block
 block discarded – undo
1383 1466
 				$this->_o=false;
1384 1467
 				$this->_d[$priority]=array($item);
1385 1468
 			}
1386
-			if($this->_fd&&is_array($this->_fd)&&count($this->_d)==1)
1387
-				array_splice($this->_fd,$cc,0,array($item));
1388
-			else
1389
-				$this->_fd=null;
1469
+			if($this->_fd&&is_array($this->_fd)&&count($this->_d)==1) {
1470
+							array_splice($this->_fd,$cc,0,array($item));
1471
+			} else {
1472
+							$this->_fd=null;
1473
+			}
1390 1474
 		}
1391 1475
 		$this->_c++;
1392 1476
 		return $c;
1393 1477
 	}
1394 1478
 	public function remove($item,$priority=false)
1395 1479
 	{
1396
-		if($this->getReadOnly())
1397
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1480
+		if($this->getReadOnly()) {
1481
+					throw new TInvalidOperationException('list_readonly',get_class($this));
1482
+		}
1398 1483
 		if(($p=$this->priorityOf($item,true))!==false)
1399 1484
 		{
1400 1485
 			if($priority!==false) {
1401
-				if($priority===null)
1402
-					$priority=$this->getDefaultPriority();
1486
+				if($priority===null) {
1487
+									$priority=$this->getDefaultPriority();
1488
+				}
1403 1489
 				$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1404
-				if($p[0]!=$priority)
1405
-					throw new TInvalidDataValueException('list_item_inexistent');
1490
+				if($p[0]!=$priority) {
1491
+									throw new TInvalidDataValueException('list_item_inexistent');
1492
+				}
1406 1493
 			}
1407 1494
 			$this->removeAtIndexInPriority($p[1],$p[0]);
1408 1495
 			return $p[2];
1496
+		} else {
1497
+					throw new TInvalidDataValueException('list_item_inexistent');
1409 1498
 		}
1410
-		else
1411
-			throw new TInvalidDataValueException('list_item_inexistent');
1412 1499
 	}
1413 1500
 	public function removeAt($index)
1414 1501
 	{
1415
-		if($this->getReadOnly())
1416
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1417
-		if(($priority=$this->priorityAt($index, true))!==false)
1418
-			return $this->removeAtIndexInPriority($priority[1],$priority[0]);
1502
+		if($this->getReadOnly()) {
1503
+					throw new TInvalidOperationException('list_readonly',get_class($this));
1504
+		}
1505
+		if(($priority=$this->priorityAt($index, true))!==false) {
1506
+					return $this->removeAtIndexInPriority($priority[1],$priority[0]);
1507
+		}
1419 1508
 		throw new TInvalidDataValueException('list_index_invalid',$index);
1420 1509
 	}
1421 1510
 	public function removeAtIndexInPriority($index, $priority=null)
1422 1511
 	{
1423
-		if($this->getReadOnly())
1424
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1425
-		if($priority===null)
1426
-			$priority=$this->getDefaultPriority();
1512
+		if($this->getReadOnly()) {
1513
+					throw new TInvalidOperationException('list_readonly',get_class($this));
1514
+		}
1515
+		if($priority===null) {
1516
+					$priority=$this->getDefaultPriority();
1517
+		}
1427 1518
 		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1428
-		if(!isset($this->_d[$priority])||$index<0||$index>=count($this->_d[$priority]))
1429
-			throw new TInvalidDataValueException('list_item_inexistent');
1519
+		if(!isset($this->_d[$priority])||$index<0||$index>=count($this->_d[$priority])) {
1520
+					throw new TInvalidDataValueException('list_item_inexistent');
1521
+		}
1430 1522
 				$value=array_splice($this->_d[$priority],$index,1);
1431 1523
 		$value=$value[0];
1432
-		if(!count($this->_d[$priority]))
1433
-			unset($this->_d[$priority]);
1524
+		if(!count($this->_d[$priority])) {
1525
+					unset($this->_d[$priority]);
1526
+		}
1434 1527
 		$this->_c--;
1435 1528
 		$this->_fd=null;
1436 1529
 		return $value;
1437 1530
 	}
1438 1531
 	public function clear()
1439 1532
 	{
1440
-		if($this->getReadOnly())
1441
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1533
+		if($this->getReadOnly()) {
1534
+					throw new TInvalidOperationException('list_readonly',get_class($this));
1535
+		}
1442 1536
 		$d=array_reverse($this->_d,true);
1443 1537
 		foreach($this->_d as $priority=>$items) {
1444
-			for($index=count($items)-1;$index>=0;$index--)
1445
-				$this->removeAtIndexInPriority($index,$priority);
1538
+			for($index=count($items)-1;$index>=0;$index--) {
1539
+							$this->removeAtIndexInPriority($index,$priority);
1540
+			}
1446 1541
 			unset($this->_d[$priority]);
1447 1542
 		}
1448 1543
 	}
@@ -1452,10 +1547,11 @@  discard block
 block discarded – undo
1452 1547
 	}
1453 1548
 	public function indexOf($item)
1454 1549
 	{
1455
-		if(($index=array_search($item,$this->flattenPriorities(),true))===false)
1456
-			return -1;
1457
-		else
1458
-			return $index;
1550
+		if(($index=array_search($item,$this->flattenPriorities(),true))===false) {
1551
+					return -1;
1552
+		} else {
1553
+					return $index;
1554
+		}
1459 1555
 	}
1460 1556
 	public function priorityOf($item,$withindex = false)
1461 1557
 	{
@@ -1466,41 +1562,48 @@  discard block
 block discarded – undo
1466 1562
 				$absindex+=$index;
1467 1563
 				return $withindex?array($priority,$index,$absindex,
1468 1564
 						'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority;
1469
-			} else
1470
-				$absindex+=count($items);
1565
+			} else {
1566
+							$absindex+=count($items);
1567
+			}
1471 1568
 		}
1472 1569
 		return false;
1473 1570
 	}
1474 1571
 	public function priorityAt($index,$withindex = false)
1475 1572
 	{
1476
-		if($index<0||$index>=$this->getCount())
1477
-			throw new TInvalidDataValueException('list_index_invalid',$index);
1573
+		if($index<0||$index>=$this->getCount()) {
1574
+					throw new TInvalidDataValueException('list_index_invalid',$index);
1575
+		}
1478 1576
 		$absindex=$index;
1479 1577
 		$this->sortPriorities();
1480 1578
 		foreach($this->_d as $priority=>$items) {
1481
-			if($index>=($c=count($items)))
1482
-				$index-=$c;
1483
-			else
1484
-				return $withindex?array($priority,$index,$absindex,
1579
+			if($index>=($c=count($items))) {
1580
+							$index-=$c;
1581
+			} else {
1582
+							return $withindex?array($priority,$index,$absindex,
1485 1583
 						'priority'=>$priority,'index'=>$index,'absindex'=>$absindex):$priority;
1584
+			}
1486 1585
 		}
1487 1586
 		return false;
1488 1587
 	}
1489 1588
 	public function insertBefore($indexitem, $item)
1490 1589
 	{
1491
-		if($this->getReadOnly())
1492
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1493
-		if(($priority=$this->priorityOf($indexitem,true))===false)
1494
-			throw new TInvalidDataValueException('list_item_inexistent');
1590
+		if($this->getReadOnly()) {
1591
+					throw new TInvalidOperationException('list_readonly',get_class($this));
1592
+		}
1593
+		if(($priority=$this->priorityOf($indexitem,true))===false) {
1594
+					throw new TInvalidDataValueException('list_item_inexistent');
1595
+		}
1495 1596
 		$this->insertAtIndexInPriority($item,$priority[1],$priority[0]);
1496 1597
 		return $priority[2];
1497 1598
 	}
1498 1599
 	public function insertAfter($indexitem, $item)
1499 1600
 	{
1500
-		if($this->getReadOnly())
1501
-			throw new TInvalidOperationException('list_readonly',get_class($this));
1502
-		if(($priority=$this->priorityOf($indexitem,true))===false)
1503
-			throw new TInvalidDataValueException('list_item_inexistent');
1601
+		if($this->getReadOnly()) {
1602
+					throw new TInvalidOperationException('list_readonly',get_class($this));
1603
+		}
1604
+		if(($priority=$this->priorityOf($indexitem,true))===false) {
1605
+					throw new TInvalidDataValueException('list_item_inexistent');
1606
+		}
1504 1607
 		$this->insertAtIndexInPriority($item,$priority[1]+1,$priority[0]);
1505 1608
 		return $priority[2]+1;
1506 1609
 	}
@@ -1519,8 +1622,9 @@  discard block
 block discarded – undo
1519 1622
 		$items=array();
1520 1623
 		foreach($this->_d as $itemspriority=>$itemsatpriority)
1521 1624
 		{
1522
-			if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority)
1523
-				break;
1625
+			if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority) {
1626
+							break;
1627
+			}
1524 1628
 			$items=array_merge($items,$itemsatpriority);
1525 1629
 		}
1526 1630
 		return $items;
@@ -1531,8 +1635,9 @@  discard block
 block discarded – undo
1531 1635
 		$items=array();
1532 1636
 		foreach($this->_d as $itemspriority=>$itemsatpriority)
1533 1637
 		{
1534
-			if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority)
1535
-				continue;
1638
+			if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority) {
1639
+							continue;
1640
+			}
1536 1641
 			$items=array_merge($items,$itemsatpriority);
1537 1642
 		}
1538 1643
 		return $items;
@@ -1541,20 +1646,25 @@  discard block
 block discarded – undo
1541 1646
 	{
1542 1647
 		if($data instanceof TPriorityList)
1543 1648
 		{
1544
-			if($this->getCount()>0)
1545
-				$this->clear();
1649
+			if($this->getCount()>0) {
1650
+							$this->clear();
1651
+			}
1546 1652
 			foreach($data->getPriorities() as $priority)
1547 1653
 			{
1548
-				foreach($data->itemsAtPriority($priority) as $index=>$item)
1549
-					$this->insertAtIndexInPriority($item,$index,$priority);
1654
+				foreach($data->itemsAtPriority($priority) as $index=>$item) {
1655
+									$this->insertAtIndexInPriority($item,$index,$priority);
1656
+				}
1550 1657
 			}
1551 1658
 		} else if(is_array($data)||$data instanceof Traversable) {
1552
-			if($this->getCount()>0)
1553
-				$this->clear();
1554
-			foreach($data as $key=>$item)
1555
-				$this->add($item);
1556
-		} else if($data!==null)
1557
-			throw new TInvalidDataTypeException('map_data_not_iterable');
1659
+			if($this->getCount()>0) {
1660
+							$this->clear();
1661
+			}
1662
+			foreach($data as $key=>$item) {
1663
+							$this->add($item);
1664
+			}
1665
+		} else if($data!==null) {
1666
+					throw new TInvalidDataTypeException('map_data_not_iterable');
1667
+		}
1558 1668
 	}
1559 1669
 	public function mergeWith($data)
1560 1670
 	{
@@ -1562,17 +1672,18 @@  discard block
 block discarded – undo
1562 1672
 		{
1563 1673
 			foreach($data->getPriorities() as $priority)
1564 1674
 			{
1565
-				foreach($data->itemsAtPriority($priority) as $index=>$item)
1566
-					$this->insertAtIndexInPriority($item,false,$priority);
1675
+				foreach($data->itemsAtPriority($priority) as $index=>$item) {
1676
+									$this->insertAtIndexInPriority($item,false,$priority);
1677
+				}
1567 1678
 			}
1568
-		}
1569
-		else if(is_array($data)||$data instanceof Traversable)
1679
+		} else if(is_array($data)||$data instanceof Traversable)
1570 1680
 		{
1571
-			foreach($data as $priority=>$item)
1572
-				$this->add($item);
1681
+			foreach($data as $priority=>$item) {
1682
+							$this->add($item);
1683
+			}
1684
+		} else if($data!==null) {
1685
+					throw new TInvalidDataTypeException('map_data_not_iterable');
1573 1686
 		}
1574
-		else if($data!==null)
1575
-			throw new TInvalidDataTypeException('map_data_not_iterable');
1576 1687
 	}
1577 1688
 	public function offsetExists($offset)
1578 1689
 	{
@@ -1584,8 +1695,9 @@  discard block
 block discarded – undo
1584 1695
 	}
1585 1696
 	public function offsetSet($offset,$item)
1586 1697
 	{
1587
-		if($offset===null)
1588
-			return $this->add($item);
1698
+		if($offset===null) {
1699
+					return $this->add($item);
1700
+		}
1589 1701
 		if($offset===$this->getCount()) {
1590 1702
 			$priority=$this->priorityAt($offset-1,true);
1591 1703
 			$priority[1]++;
@@ -1606,8 +1718,9 @@  discard block
 block discarded – undo
1606 1718
 	private $_r=false;
1607 1719
 	public function __construct($data=null,$readOnly=false)
1608 1720
 	{
1609
-		if($data!==null)
1610
-			$this->copyFrom($data);
1721
+		if($data!==null) {
1722
+					$this->copyFrom($data);
1723
+		}
1611 1724
 		$this->setReadOnly($readOnly);
1612 1725
 	}
1613 1726
 	public function getReadOnly()
@@ -1640,10 +1753,11 @@  discard block
 block discarded – undo
1640 1753
 	}
1641 1754
 	public function add($key,$value)
1642 1755
 	{
1643
-		if(!$this->_r)
1644
-			$this->_d[$key]=$value;
1645
-		else
1646
-			throw new TInvalidOperationException('map_readonly',get_class($this));
1756
+		if(!$this->_r) {
1757
+					$this->_d[$key]=$value;
1758
+		} else {
1759
+					throw new TInvalidOperationException('map_readonly',get_class($this));
1760
+		}
1647 1761
 	}
1648 1762
 	public function remove($key)
1649 1763
 	{
@@ -1654,17 +1768,18 @@  discard block
 block discarded – undo
1654 1768
 				$value=$this->_d[$key];
1655 1769
 				unset($this->_d[$key]);
1656 1770
 				return $value;
1771
+			} else {
1772
+							return null;
1657 1773
 			}
1658
-			else
1659
-				return null;
1774
+		} else {
1775
+					throw new TInvalidOperationException('map_readonly',get_class($this));
1660 1776
 		}
1661
-		else
1662
-			throw new TInvalidOperationException('map_readonly',get_class($this));
1663 1777
 	}
1664 1778
 	public function clear()
1665 1779
 	{
1666
-		foreach(array_keys($this->_d) as $key)
1667
-			$this->remove($key);
1780
+		foreach(array_keys($this->_d) as $key) {
1781
+					$this->remove($key);
1782
+		}
1668 1783
 	}
1669 1784
 	public function contains($key)
1670 1785
 	{
@@ -1678,23 +1793,26 @@  discard block
 block discarded – undo
1678 1793
 	{
1679 1794
 		if(is_array($data) || $data instanceof Traversable)
1680 1795
 		{
1681
-			if($this->getCount()>0)
1682
-				$this->clear();
1683
-			foreach($data as $key=>$value)
1684
-				$this->add($key,$value);
1796
+			if($this->getCount()>0) {
1797
+							$this->clear();
1798
+			}
1799
+			foreach($data as $key=>$value) {
1800
+							$this->add($key,$value);
1801
+			}
1802
+		} else if($data!==null) {
1803
+					throw new TInvalidDataTypeException('map_data_not_iterable');
1685 1804
 		}
1686
-		else if($data!==null)
1687
-			throw new TInvalidDataTypeException('map_data_not_iterable');
1688 1805
 	}
1689 1806
 	public function mergeWith($data)
1690 1807
 	{
1691 1808
 		if(is_array($data) || $data instanceof Traversable)
1692 1809
 		{
1693
-			foreach($data as $key=>$value)
1694
-				$this->add($key,$value);
1810
+			foreach($data as $key=>$value) {
1811
+							$this->add($key,$value);
1812
+			}
1813
+		} else if($data!==null) {
1814
+					throw new TInvalidDataTypeException('map_data_not_iterable');
1695 1815
 		}
1696
-		else if($data!==null)
1697
-			throw new TInvalidDataTypeException('map_data_not_iterable');
1698 1816
 	}
1699 1817
 	public function offsetExists($offset)
1700 1818
 	{
@@ -1755,8 +1873,9 @@  discard block
 block discarded – undo
1755 1873
 	private $_p=8;
1756 1874
 	public function __construct($data=null,$readOnly=false,$defaultPriority=10,$precision=8)
1757 1875
 	{
1758
-		if($data!==null)
1759
-			$this->copyFrom($data);
1876
+		if($data!==null) {
1877
+					$this->copyFrom($data);
1878
+		}
1760 1879
 		$this->setReadOnly($readOnly);
1761 1880
 		$this->setPrecision($precision);
1762 1881
 		$this->setDefaultPriority($defaultPriority);
@@ -1796,12 +1915,14 @@  discard block
 block discarded – undo
1796 1915
 		}
1797 1916
 	}
1798 1917
 	protected function flattenPriorities() {
1799
-		if(is_array($this->_fd))
1800
-			return $this->_fd;
1918
+		if(is_array($this->_fd)) {
1919
+					return $this->_fd;
1920
+		}
1801 1921
 		$this->sortPriorities();
1802 1922
 		$this->_fd = array();
1803
-		foreach($this->_d as $priority => $itemsatpriority)
1804
-			$this->_fd = array_merge($this->_fd, $itemsatpriority);
1923
+		foreach($this->_d as $priority => $itemsatpriority) {
1924
+					$this->_fd = array_merge($this->_fd, $itemsatpriority);
1925
+		}
1805 1926
 		return $this->_fd;
1806 1927
 	}
1807 1928
 	public function count()
@@ -1814,11 +1935,13 @@  discard block
 block discarded – undo
1814 1935
 	}
1815 1936
 	public function getPriorityCount($priority=null)
1816 1937
 	{
1817
-		if($priority===null)
1818
-			$priority=$this->getDefaultPriority();
1938
+		if($priority===null) {
1939
+					$priority=$this->getDefaultPriority();
1940
+		}
1819 1941
 		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1820
-		if(!isset($this->_d[$priority])||!is_array($this->_d[$priority]))
1821
-			return false;
1942
+		if(!isset($this->_d[$priority])||!is_array($this->_d[$priority])) {
1943
+					return false;
1944
+		}
1822 1945
 		return count($this->_d[$priority]);
1823 1946
 	}
1824 1947
 	public function getPriorities()
@@ -1836,16 +1959,18 @@  discard block
 block discarded – undo
1836 1959
 			$map=$this->flattenPriorities();
1837 1960
 			return isset($map[$key])?$map[$key]:null;
1838 1961
 		} else {
1839
-			if($priority===null)
1840
-				$priority=$this->getDefaultPriority();
1962
+			if($priority===null) {
1963
+							$priority=$this->getDefaultPriority();
1964
+			}
1841 1965
 			$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1842 1966
 			return (isset($this->_d[$priority])&&isset($this->_d[$priority][$key]))?$this->_d[$priority][$key]:null;
1843 1967
 		}
1844 1968
 	}
1845 1969
 	public function setPriorityAt($key,$priority=null)
1846 1970
 	{
1847
-		if($priority===null)
1848
-			$priority=$this->getDefaultPriority();
1971
+		if($priority===null) {
1972
+					$priority=$this->getDefaultPriority();
1973
+		}
1849 1974
 		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1850 1975
 		$oldpriority=$this->priorityAt($key);
1851 1976
 		if($oldpriority!==false&&$oldpriority!=$priority) {
@@ -1856,68 +1981,76 @@  discard block
 block discarded – undo
1856 1981
 	}
1857 1982
 	public function itemsAtPriority($priority=null)
1858 1983
 	{
1859
-		if($priority===null)
1860
-			$priority=$this->getDefaultPriority();
1984
+		if($priority===null) {
1985
+					$priority=$this->getDefaultPriority();
1986
+		}
1861 1987
 		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1862 1988
 		return isset($this->_d[$priority])?$this->_d[$priority]:null;
1863 1989
 	}
1864 1990
 	public function priorityOf($item)
1865 1991
 	{
1866 1992
 		$this->sortPriorities();
1867
-		foreach($this->_d as $priority=>$items)
1868
-			if(($index=array_search($item,$items,true))!==false)
1993
+		foreach($this->_d as $priority=>$items) {
1994
+					if(($index=array_search($item,$items,true))!==false)
1869 1995
 				return $priority;
1996
+		}
1870 1997
 		return false;
1871 1998
 	}
1872 1999
 	public function priorityAt($key)
1873 2000
 	{
1874 2001
 		$this->sortPriorities();
1875
-		foreach($this->_d as $priority=>$items)
1876
-			if(array_key_exists($key,$items))
2002
+		foreach($this->_d as $priority=>$items) {
2003
+					if(array_key_exists($key,$items))
1877 2004
 				return $priority;
2005
+		}
1878 2006
 		return false;
1879 2007
 	}
1880 2008
 	public function add($key,$value,$priority=null)
1881 2009
 	{
1882
-		if($priority===null)
1883
-			$priority=$this->getDefaultPriority();
2010
+		if($priority===null) {
2011
+					$priority=$this->getDefaultPriority();
2012
+		}
1884 2013
 		$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1885 2014
 		if(!$this->_r)
1886 2015
 		{
1887
-			foreach($this->_d as $innerpriority=>$items)
1888
-				if(array_key_exists($key,$items))
2016
+			foreach($this->_d as $innerpriority=>$items) {
2017
+							if(array_key_exists($key,$items))
1889 2018
 				{
1890 2019
 					unset($this->_d[$innerpriority][$key]);
2020
+			}
1891 2021
 					$this->_c--;
1892
-					if(count($this->_d[$innerpriority])===0)
1893
-						unset($this->_d[$innerpriority]);
2022
+					if(count($this->_d[$innerpriority])===0) {
2023
+											unset($this->_d[$innerpriority]);
2024
+					}
1894 2025
 				}
1895 2026
 			if(!isset($this->_d[$priority])) {
1896 2027
 				$this->_d[$priority]=array($key=>$value);
1897 2028
 				$this->_o=false;
2029
+			} else {
2030
+							$this->_d[$priority][$key]=$value;
1898 2031
 			}
1899
-			else
1900
-				$this->_d[$priority][$key]=$value;
1901 2032
 			$this->_c++;
1902 2033
 			$this->_fd=null;
2034
+		} else {
2035
+					throw new TInvalidOperationException('map_readonly',get_class($this));
1903 2036
 		}
1904
-		else
1905
-			throw new TInvalidOperationException('map_readonly',get_class($this));
1906 2037
 		return $priority;
1907 2038
 	}
1908 2039
 	public function remove($key,$priority=false)
1909 2040
 	{
1910 2041
 		if(!$this->_r)
1911 2042
 		{
1912
-			if($priority===null)
1913
-				$priority=$this->getDefaultPriority();
2043
+			if($priority===null) {
2044
+							$priority=$this->getDefaultPriority();
2045
+			}
1914 2046
 			if($priority===false)
1915 2047
 			{
1916 2048
 				$this->sortPriorities();
1917
-				foreach($this->_d as $priority=>$items)
1918
-					if(array_key_exists($key,$items))
2049
+				foreach($this->_d as $priority=>$items) {
2050
+									if(array_key_exists($key,$items))
1919 2051
 					{
1920 2052
 						$value=$this->_d[$priority][$key];
2053
+				}
1921 2054
 						unset($this->_d[$priority][$key]);
1922 2055
 						$this->_c--;
1923 2056
 						if(count($this->_d[$priority])===0)
@@ -1929,8 +2062,7 @@  discard block
 block discarded – undo
1929 2062
 						return $value;
1930 2063
 					}
1931 2064
 				return null;
1932
-			}
1933
-			else
2065
+			} else
1934 2066
 			{
1935 2067
 				$priority=(string)round(TPropertyValue::ensureFloat($priority),$this->_p);
1936 2068
 				if(isset($this->_d[$priority])&&(isset($this->_d[$priority][$key])||array_key_exists($key,$this->_d[$priority])))
@@ -1944,19 +2076,20 @@  discard block
 block discarded – undo
1944 2076
 					}
1945 2077
 					$this->_fd=null;
1946 2078
 					return $value;
2079
+				} else {
2080
+									return null;
1947 2081
 				}
1948
-				else
1949
-					return null;
1950 2082
 			}
2083
+		} else {
2084
+					throw new TInvalidOperationException('map_readonly',get_class($this));
1951 2085
 		}
1952
-		else
1953
-			throw new TInvalidOperationException('map_readonly',get_class($this));
1954 2086
 	}
1955 2087
 	public function clear()
1956 2088
 	{
1957
-		foreach($this->_d as $priority=>$items)
1958
-			foreach(array_keys($items) as $key)
2089
+		foreach($this->_d as $priority=>$items) {
2090
+					foreach(array_keys($items) as $key)
1959 2091
 				$this->remove($key);
2092
+		}
1960 2093
 	}
1961 2094
 	public function contains($key)
1962 2095
 	{
@@ -1973,8 +2106,9 @@  discard block
 block discarded – undo
1973 2106
 		$items=array();
1974 2107
 		foreach($this->_d as $itemspriority=>$itemsatpriority)
1975 2108
 		{
1976
-			if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority)
1977
-				break;
2109
+			if((!$inclusive&&$itemspriority>=$priority)||$itemspriority>$priority) {
2110
+							break;
2111
+			}
1978 2112
 			$items=array_merge($items,$itemsatpriority);
1979 2113
 		}
1980 2114
 		return $items;
@@ -1985,8 +2119,9 @@  discard block
 block discarded – undo
1985 2119
 		$items=array();
1986 2120
 		foreach($this->_d as $itemspriority=>$itemsatpriority)
1987 2121
 		{
1988
-			if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority)
1989
-				continue;
2122
+			if((!$inclusive&&$itemspriority<=$priority)||$itemspriority<$priority) {
2123
+							continue;
2124
+			}
1990 2125
 			$items=array_merge($items,$itemsatpriority);
1991 2126
 		}
1992 2127
 		return $items;
@@ -1995,23 +2130,25 @@  discard block
 block discarded – undo
1995 2130
 	{
1996 2131
 		if($data instanceof TPriorityMap)
1997 2132
 		{
1998
-			if($this->getCount()>0)
1999
-				$this->clear();
2133
+			if($this->getCount()>0) {
2134
+							$this->clear();
2135
+			}
2000 2136
 			foreach($data->getPriorities() as $priority) {
2001 2137
 				foreach($data->itemsAtPriority($priority) as $key => $value) {
2002 2138
 					$this->add($key,$value,$priority);
2003 2139
 				}
2004 2140
 			}
2005
-		}
2006
-		else if(is_array($data)||$data instanceof Traversable)
2141
+		} else if(is_array($data)||$data instanceof Traversable)
2007 2142
 		{
2008
-			if($this->getCount()>0)
2009
-				$this->clear();
2010
-			foreach($data as $key=>$value)
2011
-				$this->add($key,$value);
2143
+			if($this->getCount()>0) {
2144
+							$this->clear();
2145
+			}
2146
+			foreach($data as $key=>$value) {
2147
+							$this->add($key,$value);
2148
+			}
2149
+		} else if($data!==null) {
2150
+					throw new TInvalidDataTypeException('map_data_not_iterable');
2012 2151
 		}
2013
-		else if($data!==null)
2014
-			throw new TInvalidDataTypeException('map_data_not_iterable');
2015 2152
 	}
2016 2153
 	public function mergeWith($data)
2017 2154
 	{
@@ -2019,17 +2156,18 @@  discard block
 block discarded – undo
2019 2156
 		{
2020 2157
 			foreach($data->getPriorities() as $priority)
2021 2158
 			{
2022
-				foreach($data->itemsAtPriority($priority) as $key => $value)
2023
-					$this->add($key,$value,$priority);
2159
+				foreach($data->itemsAtPriority($priority) as $key => $value) {
2160
+									$this->add($key,$value,$priority);
2161
+				}
2024 2162
 			}
2025
-		}
2026
-		else if(is_array($data)||$data instanceof Traversable)
2163
+		} else if(is_array($data)||$data instanceof Traversable)
2027 2164
 		{
2028
-			foreach($data as $key=>$value)
2029
-				$this->add($key,$value);
2165
+			foreach($data as $key=>$value) {
2166
+							$this->add($key,$value);
2167
+			}
2168
+		} else if($data!==null) {
2169
+					throw new TInvalidDataTypeException('map_data_not_iterable');
2030 2170
 		}
2031
-		else if($data!==null)
2032
-			throw new TInvalidDataTypeException('map_data_not_iterable');
2033 2171
 	}
2034 2172
 	public function offsetExists($offset)
2035 2173
 	{
@@ -2054,8 +2192,9 @@  discard block
 block discarded – undo
2054 2192
 	private $_c=0;
2055 2193
 	public function __construct($data=null)
2056 2194
 	{
2057
-		if($data!==null)
2058
-			$this->copyFrom($data);
2195
+		if($data!==null) {
2196
+					$this->copyFrom($data);
2197
+		}
2059 2198
 	}
2060 2199
 	public function toArray()
2061 2200
 	{
@@ -2071,9 +2210,9 @@  discard block
 block discarded – undo
2071 2210
 				$this->_d[]=$item;
2072 2211
 				++$this->_c;
2073 2212
 			}
2213
+		} else if($data!==null) {
2214
+					throw new TInvalidDataTypeException('stack_data_not_iterable');
2074 2215
 		}
2075
-		else if($data!==null)
2076
-			throw new TInvalidDataTypeException('stack_data_not_iterable');
2077 2216
 	}
2078 2217
 	public function clear()
2079 2218
 	{
@@ -2086,16 +2225,17 @@  discard block
 block discarded – undo
2086 2225
 	}
2087 2226
 	public function peek()
2088 2227
 	{
2089
-		if($this->_c===0)
2090
-			throw new TInvalidOperationException('stack_empty');
2091
-		else
2092
-			return $this->_d[$this->_c-1];
2228
+		if($this->_c===0) {
2229
+					throw new TInvalidOperationException('stack_empty');
2230
+		} else {
2231
+					return $this->_d[$this->_c-1];
2232
+		}
2093 2233
 	}
2094 2234
 	public function pop()
2095 2235
 	{
2096
-		if($this->_c===0)
2097
-			throw new TInvalidOperationException('stack_empty');
2098
-		else
2236
+		if($this->_c===0) {
2237
+					throw new TInvalidOperationException('stack_empty');
2238
+		} else
2099 2239
 		{
2100 2240
 			--$this->_c;
2101 2241
 			return array_pop($this->_d);
@@ -2196,10 +2336,11 @@  discard block
 block discarded – undo
2196 2336
 	}
2197 2337
 	public function getAttribute($name)
2198 2338
 	{
2199
-		if($this->_attributes!==null)
2200
-			return $this->_attributes->itemAt($name);
2201
-		else
2202
-			return null;
2339
+		if($this->_attributes!==null) {
2340
+					return $this->_attributes->itemAt($name);
2341
+		} else {
2342
+					return null;
2343
+		}
2203 2344
 	}
2204 2345
 	public function setAttribute($name,$value)
2205 2346
 	{
@@ -2207,23 +2348,26 @@  discard block
 block discarded – undo
2207 2348
 	}
2208 2349
 	public function getElements()
2209 2350
 	{
2210
-		if(!$this->_elements)
2211
-			$this->_elements=new TXmlElementList($this);
2351
+		if(!$this->_elements) {
2352
+					$this->_elements=new TXmlElementList($this);
2353
+		}
2212 2354
 		return $this->_elements;
2213 2355
 	}
2214 2356
 	public function getAttributes()
2215 2357
 	{
2216
-		if(!$this->_attributes)
2217
-			$this->_attributes=new TMap;
2358
+		if(!$this->_attributes) {
2359
+					$this->_attributes=new TMap;
2360
+		}
2218 2361
 		return $this->_attributes;
2219 2362
 	}
2220 2363
 	public function getElementByTagName($tagName)
2221 2364
 	{
2222 2365
 		if($this->_elements)
2223 2366
 		{
2224
-			foreach($this->_elements as $element)
2225
-				if($element->_tagName===$tagName)
2367
+			foreach($this->_elements as $element) {
2368
+							if($element->_tagName===$tagName)
2226 2369
 					return $element;
2370
+			}
2227 2371
 		}
2228 2372
 		return null;
2229 2373
 	}
@@ -2232,9 +2376,10 @@  discard block
 block discarded – undo
2232 2376
 		$list=new TList;
2233 2377
 		if($this->_elements)
2234 2378
 		{
2235
-			foreach($this->_elements as $element)
2236
-				if($element->_tagName===$tagName)
2379
+			foreach($this->_elements as $element) {
2380
+							if($element->_tagName===$tagName)
2237 2381
 					$list->add($element);
2382
+			}
2238 2383
 		}
2239 2384
 		return $list;
2240 2385
 	}
@@ -2253,18 +2398,18 @@  discard block
 block discarded – undo
2253 2398
 		if($this->getHasElement())
2254 2399
 		{
2255 2400
 			$str=$prefix."<{$this->_tagName}$attr>\n";
2256
-			foreach($this->getElements() as $element)
2257
-				$str.=$element->toString($indent+1)."\n";
2401
+			foreach($this->getElements() as $element) {
2402
+							$str.=$element->toString($indent+1)."\n";
2403
+			}
2258 2404
 			$str.=$prefix."</{$this->_tagName}>";
2259 2405
 			return $str;
2260
-		}
2261
-		else if(($value=$this->getValue())!=='')
2406
+		} else if(($value=$this->getValue())!=='')
2262 2407
 		{
2263 2408
 			$value=$this->xmlEncode($value);
2264 2409
 			return $prefix."<{$this->_tagName}$attr>$value</{$this->_tagName}>";
2410
+		} else {
2411
+					return $prefix."<{$this->_tagName}$attr />";
2265 2412
 		}
2266
-		else
2267
-			return $prefix."<{$this->_tagName}$attr />";
2268 2413
 	}
2269 2414
 	public function __toString()
2270 2415
 	{
@@ -2310,16 +2455,18 @@  discard block
 block discarded – undo
2310 2455
 	}
2311 2456
 	public function loadFromFile($file)
2312 2457
 	{
2313
-		if(($str=@file_get_contents($file))!==false)
2314
-			return $this->loadFromString($str);
2315
-		else
2316
-			throw new TIOException('xmldocument_file_read_failed',$file);
2458
+		if(($str=@file_get_contents($file))!==false) {
2459
+					return $this->loadFromString($str);
2460
+		} else {
2461
+					throw new TIOException('xmldocument_file_read_failed',$file);
2462
+		}
2317 2463
 	}
2318 2464
 	public function loadFromString($string)
2319 2465
 	{
2320 2466
 				$doc=new DOMDocument();
2321
-		if($doc->loadXML($string)===false)
2322
-			return false;
2467
+		if($doc->loadXML($string)===false) {
2468
+					return false;
2469
+		}
2323 2470
 		$this->setEncoding($doc->encoding);
2324 2471
 		$this->setVersion($doc->version);
2325 2472
 		$element=$doc->documentElement;
@@ -2330,8 +2477,9 @@  discard block
 block discarded – undo
2330 2477
 		$elements->clear();
2331 2478
 		$attributes->clear();
2332 2479
 		static $bSimpleXml;
2333
-		if($bSimpleXml === null)
2334
-			$bSimpleXml = (boolean)function_exists('simplexml_load_string');
2480
+		if($bSimpleXml === null) {
2481
+					$bSimpleXml = (boolean)function_exists('simplexml_load_string');
2482
+		}
2335 2483
 		if($bSimpleXml)
2336 2484
 		{
2337 2485
 			$simpleDoc = simplexml_load_string($string);
@@ -2339,18 +2487,21 @@  discard block
 block discarded – undo
2339 2487
 			$simpleDoc = null;
2340 2488
 			foreach($docNamespaces as $prefix => $uri)
2341 2489
 			{
2342
- 				if($prefix === '')
2343
-   					$attributes->add('xmlns', $uri);
2344
-   				else
2345
-   					$attributes->add('xmlns:'.$prefix, $uri);
2490
+ 				if($prefix === '') {
2491
+ 				   					$attributes->add('xmlns', $uri);
2492
+ 				} else {
2493
+   				   					$attributes->add('xmlns:'.$prefix, $uri);
2494
+   				}
2346 2495
 			}
2347 2496
 		}
2348
-		foreach($element->attributes as $name=>$attr)
2349
-			$attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') .$name,$attr->value);
2497
+		foreach($element->attributes as $name=>$attr) {
2498
+					$attributes->add(($attr->prefix === '' ? '' : $attr->prefix . ':') .$name,$attr->value);
2499
+		}
2350 2500
 		foreach($element->childNodes as $child)
2351 2501
 		{
2352
-			if($child instanceof DOMElement)
2353
-				$elements->add($this->buildElement($child));
2502
+			if($child instanceof DOMElement) {
2503
+							$elements->add($this->buildElement($child));
2504
+			}
2354 2505
 		}
2355 2506
 		return true;
2356 2507
 	}
@@ -2360,9 +2511,9 @@  discard block
 block discarded – undo
2360 2511
 		{
2361 2512
 			fwrite($fw,$this->saveToString());
2362 2513
 			fclose($fw);
2514
+		} else {
2515
+					throw new TIOException('xmldocument_file_write_failed',$file);
2363 2516
 		}
2364
-		else
2365
-			throw new TIOException('xmldocument_file_write_failed',$file);
2366 2517
 	}
2367 2518
 	public function saveToString()
2368 2519
 	{
@@ -2378,12 +2529,14 @@  discard block
 block discarded – undo
2378 2529
 	{
2379 2530
 		$element=new TXmlElement($node->tagName);
2380 2531
 		$element->setValue($node->nodeValue);
2381
-		foreach($node->attributes as $name=>$attr)
2382
-			$element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name,$attr->value);
2532
+		foreach($node->attributes as $name=>$attr) {
2533
+					$element->getAttributes()->add(($attr->prefix === '' ? '' : $attr->prefix . ':') . $name,$attr->value);
2534
+		}
2383 2535
 		foreach($node->childNodes as $child)
2384 2536
 		{
2385
-			if($child instanceof DOMElement)
2386
-				$element->getElements()->add($this->buildElement($child));
2537
+			if($child instanceof DOMElement) {
2538
+							$element->getElements()->add($this->buildElement($child));
2539
+			}
2387 2540
 		}
2388 2541
 		return $element;
2389 2542
 	}
@@ -2404,18 +2557,20 @@  discard block
 block discarded – undo
2404 2557
 		if($item instanceof TXmlElement)
2405 2558
 		{
2406 2559
 			parent::insertAt($index,$item);
2407
-			if($item->getParent()!==null)
2408
-				$item->getParent()->getElements()->remove($item);
2560
+			if($item->getParent()!==null) {
2561
+							$item->getParent()->getElements()->remove($item);
2562
+			}
2409 2563
 			$item->setParent($this->_o);
2564
+		} else {
2565
+					throw new TInvalidDataTypeException('xmlelementlist_xmlelement_required');
2410 2566
 		}
2411
-		else
2412
-			throw new TInvalidDataTypeException('xmlelementlist_xmlelement_required');
2413 2567
 	}
2414 2568
 	public function removeAt($index)
2415 2569
 	{
2416 2570
 		$item=parent::removeAt($index);
2417
-		if($item instanceof TXmlElement)
2418
-			$item->setParent(null);
2571
+		if($item instanceof TXmlElement) {
2572
+					$item->setParent(null);
2573
+		}
2419 2574
 		return $item;
2420 2575
 	}
2421 2576
 }
@@ -2432,18 +2587,20 @@  discard block
 block discarded – undo
2432 2587
 	public function __construct($action,$users,$roles,$verb='',$ipRules='')
2433 2588
 	{
2434 2589
 		$action=strtolower(trim($action));
2435
-		if($action==='allow' || $action==='deny')
2436
-			$this->_action=$action;
2437
-		else
2438
-			throw new TInvalidDataValueException('authorizationrule_action_invalid',$action);
2590
+		if($action==='allow' || $action==='deny') {
2591
+					$this->_action=$action;
2592
+		} else {
2593
+					throw new TInvalidDataValueException('authorizationrule_action_invalid',$action);
2594
+		}
2439 2595
 		$this->_users=array();
2440 2596
 		$this->_roles=array();
2441 2597
 		$this->_ipRules=array();
2442 2598
 		$this->_everyone=false;
2443 2599
 		$this->_guest=false;
2444 2600
 		$this->_authenticated=false;
2445
-		if(trim($users)==='')
2446
-			$users='*';
2601
+		if(trim($users)==='') {
2602
+					$users='*';
2603
+		}
2447 2604
 		foreach(explode(',',$users) as $user)
2448 2605
 		{
2449 2606
 			if(($user=trim(strtolower($user)))!=='')
@@ -2452,34 +2609,40 @@  discard block
 block discarded – undo
2452 2609
 				{
2453 2610
 					$this->_everyone=true;
2454 2611
 					break;
2612
+				} else if($user==='?') {
2613
+									$this->_guest=true;
2614
+				} else if($user==='@') {
2615
+									$this->_authenticated=true;
2616
+				} else {
2617
+									$this->_users[]=$user;
2455 2618
 				}
2456
-				else if($user==='?')
2457
-					$this->_guest=true;
2458
-				else if($user==='@')
2459
-					$this->_authenticated=true;
2460
-				else
2461
-					$this->_users[]=$user;
2462 2619
 			}
2463 2620
 		}
2464
-		if(trim($roles)==='')
2465
-			$roles='*';
2621
+		if(trim($roles)==='') {
2622
+					$roles='*';
2623
+		}
2466 2624
 		foreach(explode(',',$roles) as $role)
2467 2625
 		{
2468
-			if(($role=trim(strtolower($role)))!=='')
2469
-				$this->_roles[]=$role;
2470
-		}
2471
-		if(($verb=trim(strtolower($verb)))==='')
2472
-			$verb='*';
2473
-		if($verb==='*' || $verb==='get' || $verb==='post')
2474
-			$this->_verb=$verb;
2475
-		else
2476
-			throw new TInvalidDataValueException('authorizationrule_verb_invalid',$verb);
2477
-		if(trim($ipRules)==='')
2478
-			$ipRules='*';
2626
+			if(($role=trim(strtolower($role)))!=='') {
2627
+							$this->_roles[]=$role;
2628
+			}
2629
+		}
2630
+		if(($verb=trim(strtolower($verb)))==='') {
2631
+					$verb='*';
2632
+		}
2633
+		if($verb==='*' || $verb==='get' || $verb==='post') {
2634
+					$this->_verb=$verb;
2635
+		} else {
2636
+					throw new TInvalidDataValueException('authorizationrule_verb_invalid',$verb);
2637
+		}
2638
+		if(trim($ipRules)==='') {
2639
+					$ipRules='*';
2640
+		}
2479 2641
 		foreach(explode(',',$ipRules) as $ipRule)
2480 2642
 		{
2481
-			if(($ipRule=trim($ipRule))!=='')
2482
-				$this->_ipRules[]=$ipRule;
2643
+			if(($ipRule=trim($ipRule))!=='') {
2644
+							$this->_ipRules[]=$ipRule;
2645
+			}
2483 2646
 		}
2484 2647
 	}
2485 2648
 	public function getAction()
@@ -2516,19 +2679,22 @@  discard block
 block discarded – undo
2516 2679
 	}
2517 2680
 	public function isUserAllowed(IUser $user,$verb,$ip)
2518 2681
 	{
2519
-		if($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user))
2520
-			return ($this->_action==='allow')?1:-1;
2521
-		else
2522
-			return 0;
2682
+		if($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user)) {
2683
+					return ($this->_action==='allow')?1:-1;
2684
+		} else {
2685
+					return 0;
2686
+		}
2523 2687
 	}
2524 2688
 	private function isIpMatched($ip)
2525 2689
 	{
2526
-		if(empty($this->_ipRules))
2527
-			return 1;
2690
+		if(empty($this->_ipRules)) {
2691
+					return 1;
2692
+		}
2528 2693
 		foreach($this->_ipRules as $rule)
2529 2694
 		{
2530
-			if($rule==='*' || $rule===$ip || (($pos=strpos($rule,'*'))!==false && strncmp($ip,$rule,$pos)===0))
2531
-				return 1;
2695
+			if($rule==='*' || $rule===$ip || (($pos=strpos($rule,'*'))!==false && strncmp($ip,$rule,$pos)===0)) {
2696
+							return 1;
2697
+			}
2532 2698
 		}
2533 2699
 		return 0;
2534 2700
 	}
@@ -2540,8 +2706,9 @@  discard block
 block discarded – undo
2540 2706
 	{
2541 2707
 		foreach($this->_roles as $role)
2542 2708
 		{
2543
-			if($role==='*' || $user->isInRole($role))
2544
-				return true;
2709
+			if($role==='*' || $user->isInRole($role)) {
2710
+							return true;
2711
+			}
2545 2712
 		}
2546 2713
 		return false;
2547 2714
 	}
@@ -2559,20 +2726,22 @@  discard block
 block discarded – undo
2559 2726
 			$verb=strtolower(trim($verb));
2560 2727
 			foreach($this as $rule)
2561 2728
 			{
2562
-				if(($decision=$rule->isUserAllowed($user,$verb,$ip))!==0)
2563
-					return ($decision>0);
2729
+				if(($decision=$rule->isUserAllowed($user,$verb,$ip))!==0) {
2730
+									return ($decision>0);
2731
+				}
2564 2732
 			}
2565 2733
 			return true;
2734
+		} else {
2735
+					return false;
2566 2736
 		}
2567
-		else
2568
-			return false;
2569 2737
 	}
2570 2738
 	public function insertAt($index,$item)
2571 2739
 	{
2572
-		if($item instanceof TAuthorizationRule)
2573
-			parent::insertAt($index,$item);
2574
-		else
2575
-			throw new TInvalidDataTypeException('authorizationrulecollection_authorizationrule_required');
2740
+		if($item instanceof TAuthorizationRule) {
2741
+					parent::insertAt($index,$item);
2742
+		} else {
2743
+					throw new TInvalidDataTypeException('authorizationrulecollection_authorizationrule_required');
2744
+		}
2576 2745
 	}
2577 2746
 }
2578 2747
 class TSecurityManager extends TModule
@@ -2605,8 +2774,9 @@  discard block
 block discarded – undo
2605 2774
 	}
2606 2775
 	public function setValidationKey($value)
2607 2776
 	{
2608
-		if('' === $value)
2609
-			throw new TInvalidDataValueException('securitymanager_validationkey_invalid');
2777
+		if('' === $value) {
2778
+					throw new TInvalidDataValueException('securitymanager_validationkey_invalid');
2779
+		}
2610 2780
 		$this->_validationKey = $value;
2611 2781
 	}
2612 2782
 	public function getEncryptionKey()
@@ -2621,8 +2791,9 @@  discard block
 block discarded – undo
2621 2791
 	}
2622 2792
 	public function setEncryptionKey($value)
2623 2793
 	{
2624
-		if('' === $value)
2625
-			throw new TInvalidDataValueException('securitymanager_encryptionkey_invalid');
2794
+		if('' === $value) {
2795
+					throw new TInvalidDataValueException('securitymanager_encryptionkey_invalid');
2796
+		}
2626 2797
 		$this->_encryptionKey = $value;
2627 2798
 	}
2628 2799
 	public function getValidation()
@@ -2643,8 +2814,9 @@  discard block
 block discarded – undo
2643 2814
 	}
2644 2815
 	public function getEncryption()
2645 2816
 	{
2646
-		if(is_string($this->_cryptAlgorithm))
2647
-			return $this->_cryptAlgorithm;
2817
+		if(is_string($this->_cryptAlgorithm)) {
2818
+					return $this->_cryptAlgorithm;
2819
+		}
2648 2820
 				return "3DES";
2649 2821
 	}
2650 2822
 	public function setEncryption($value)
@@ -2687,16 +2859,18 @@  discard block
 block discarded – undo
2687 2859
 	{
2688 2860
 		if(extension_loaded('mcrypt'))
2689 2861
 		{
2690
-			if(is_array($this->_cryptAlgorithm))
2691
-				$module=@call_user_func_array('mcrypt_module_open',$this->_cryptAlgorithm);
2692
-			else
2693
-				$module=@mcrypt_module_open($this->_cryptAlgorithm,'', MCRYPT_MODE_CBC,'');
2694
-			if($module===false)
2695
-				throw new TNotSupportedException('securitymanager_mcryptextension_initfailed');
2862
+			if(is_array($this->_cryptAlgorithm)) {
2863
+							$module=@call_user_func_array('mcrypt_module_open',$this->_cryptAlgorithm);
2864
+			} else {
2865
+							$module=@mcrypt_module_open($this->_cryptAlgorithm,'', MCRYPT_MODE_CBC,'');
2866
+			}
2867
+			if($module===false) {
2868
+							throw new TNotSupportedException('securitymanager_mcryptextension_initfailed');
2869
+			}
2696 2870
 			return $module;
2871
+		} else {
2872
+					throw new TNotSupportedException('securitymanager_mcryptextension_required');
2697 2873
 		}
2698
-		else
2699
-			throw new TNotSupportedException('securitymanager_mcryptextension_required');
2700 2874
 	}
2701 2875
 	public function hashData($data)
2702 2876
 	{
@@ -2706,8 +2880,9 @@  discard block
 block discarded – undo
2706 2880
 	public function validateData($data)
2707 2881
 	{
2708 2882
 		$len=$this->strlen($this->computeHMAC('test'));
2709
-		if($this->strlen($data) < $len)
2710
-			return false;
2883
+		if($this->strlen($data) < $len) {
2884
+					return false;
2885
+		}
2711 2886
 		$hmac = $this->substr($data, 0, $len);
2712 2887
 		$data2=$this->substr($data, $len, $this->strlen($data));
2713 2888
 		return $hmac === $this->computeHMAC($data2) ? $data2 : false;
@@ -2715,8 +2890,9 @@  discard block
 block discarded – undo
2715 2890
 	protected function computeHMAC($data)
2716 2891
 	{
2717 2892
 		$key = $this->getValidationKey();
2718
-		if(function_exists('hash_hmac'))
2719
-			return hash_hmac($this->_hashAlgorithm, $data, $key);
2893
+		if(function_exists('hash_hmac')) {
2894
+					return hash_hmac($this->_hashAlgorithm, $data, $key);
2895
+		}
2720 2896
 		if(!strcasecmp($this->_hashAlgorithm,'sha1'))
2721 2897
 		{
2722 2898
 			$pack = 'H40';
@@ -2765,8 +2941,9 @@  discard block
 block discarded – undo
2765 2941
 	public static function renderScriptFiles($files)
2766 2942
 	{
2767 2943
 		$str='';
2768
-		foreach($files as $file)
2769
-			$str.= self::renderScriptFile($file);
2944
+		foreach($files as $file) {
2945
+					$str.= self::renderScriptFile($file);
2946
+		}
2770 2947
 		return $str;
2771 2948
 	}
2772 2949
 	public static function renderScriptFile($file)
@@ -2775,17 +2952,19 @@  discard block
 block discarded – undo
2775 2952
 	}
2776 2953
 	public static function renderScriptBlocks($scripts)
2777 2954
 	{
2778
-		if(count($scripts))
2779
-			return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n".implode("\n",$scripts)."\n/*]]>*/\n</script>\n";
2780
-		else
2781
-			return '';
2955
+		if(count($scripts)) {
2956
+					return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n".implode("\n",$scripts)."\n/*]]>*/\n</script>\n";
2957
+		} else {
2958
+					return '';
2959
+		}
2782 2960
 	}
2783 2961
 	public static function renderScriptBlocksCallback($scripts)
2784 2962
 	{
2785
-		if(count($scripts))
2786
-			return implode("\n",$scripts)."\n";
2787
-		else
2788
-			return '';
2963
+		if(count($scripts)) {
2964
+					return implode("\n",$scripts)."\n";
2965
+		} else {
2966
+					return '';
2967
+		}
2789 2968
 	}
2790 2969
 	public static function renderScriptBlock($script)
2791 2970
 	{
@@ -2797,10 +2976,11 @@  discard block
 block discarded – undo
2797 2976
 	}
2798 2977
 	public static function quoteJsLiteral($js)
2799 2978
 	{
2800
-		if($js instanceof TJavaScriptLiteral)
2801
-			return $js;
2802
-		else
2803
-			return new TJavaScriptLiteral($js);
2979
+		if($js instanceof TJavaScriptLiteral) {
2980
+					return $js;
2981
+		} else {
2982
+					return new TJavaScriptLiteral($js);
2983
+		}
2804 2984
 	}
2805 2985
 	public static function quoteFunction($js)
2806 2986
 	{
@@ -2816,11 +2996,11 @@  discard block
 block discarded – undo
2816 2996
 	}
2817 2997
 	public static function encode($value,$toMap=true,$encodeEmptyStrings=false)
2818 2998
 	{
2819
-		if(is_string($value))
2820
-			return self::quoteString($value);
2821
-		else if(is_bool($value))
2822
-			return $value?'true':'false';
2823
-		else if(is_array($value))
2999
+		if(is_string($value)) {
3000
+					return self::quoteString($value);
3001
+		} else if(is_bool($value)) {
3002
+					return $value?'true':'false';
3003
+		} else if(is_array($value))
2824 3004
 		{
2825 3005
 			$results='';
2826 3006
 			if(($n=count($value))>0 && array_keys($value)!==range(0,$n-1))
@@ -2829,30 +3009,30 @@  discard block
 block discarded – undo
2829 3009
 				{
2830 3010
 					if($v!=='' || $encodeEmptyStrings)
2831 3011
 					{
2832
-						if($results!=='')
2833
-							$results.=',';
3012
+						if($results!=='') {
3013
+													$results.=',';
3014
+						}
2834 3015
 						$results.="'$k':".self::encode($v,$toMap,$encodeEmptyStrings);
2835 3016
 					}
2836 3017
 				}
2837 3018
 				return '{'.$results.'}';
2838
-			}
2839
-			else
3019
+			} else
2840 3020
 			{
2841 3021
 				foreach($value as $v)
2842 3022
 				{
2843 3023
 					if($v!=='' || $encodeEmptyStrings)
2844 3024
 					{
2845
-						if($results!=='')
2846
-							$results.=',';
3025
+						if($results!=='') {
3026
+													$results.=',';
3027
+						}
2847 3028
 						$results.=self::encode($v,$toMap, $encodeEmptyStrings);
2848 3029
 					}
2849 3030
 				}
2850 3031
 				return '['.$results.']';
2851 3032
 			}
2852
-		}
2853
-		else if(is_integer($value))
2854
-			return "$value";
2855
-		else if(is_float($value))
3033
+		} else if(is_integer($value)) {
3034
+					return "$value";
3035
+		} else if(is_float($value))
2856 3036
 		{
2857 3037
 			switch($value)
2858 3038
 			{
@@ -2864,22 +3044,24 @@  discard block
 block discarded – undo
2864 3044
 					break;
2865 3045
 				default:
2866 3046
 					$locale=localeConv();
2867
-					if($locale['decimal_point']=='.')
2868
-						return "$value";
2869
-					else
2870
-						return str_replace($locale['decimal_point'], '.', "$value");
3047
+					if($locale['decimal_point']=='.') {
3048
+											return "$value";
3049
+					} else {
3050
+											return str_replace($locale['decimal_point'], '.', "$value");
3051
+					}
2871 3052
 					break;
2872 3053
 			}
2873
-		}
2874
-		else if(is_object($value))
2875
-			if ($value instanceof TJavaScriptLiteral)
3054
+		} else if(is_object($value)) {
3055
+					if ($value instanceof TJavaScriptLiteral)
2876 3056
 				return $value->toJavaScriptLiteral();
2877
-			else
2878
-				return self::encode(get_object_vars($value),$toMap);
2879
-		else if($value===null)
2880
-			return 'null';
2881
-		else
2882
-			return '';
3057
+		} else {
3058
+							return self::encode(get_object_vars($value),$toMap);
3059
+			}
3060
+		else if($value===null) {
3061
+					return 'null';
3062
+		} else {
3063
+					return '';
3064
+		}
2883 3065
 	}
2884 3066
 	public static function jsonEncode($value, $options = 0)
2885 3067
 	{
@@ -2892,12 +3074,13 @@  discard block
 block discarded – undo
2892 3074
 		return $s;
2893 3075
 	}
2894 3076
 	private static function convertToUtf8(&$value, $sourceEncoding) {
2895
-		if(is_string($value))
2896
-			$value=iconv($sourceEncoding, 'UTF-8', $value);
2897
-		else if (is_array($value))
3077
+		if(is_string($value)) {
3078
+					$value=iconv($sourceEncoding, 'UTF-8', $value);
3079
+		} else if (is_array($value))
2898 3080
 		{
2899
-			foreach($value as &$element)
2900
-				self::convertToUtf8($element, $sourceEncoding);
3081
+			foreach($value as &$element) {
3082
+							self::convertToUtf8($element, $sourceEncoding);
3083
+			}
2901 3084
 		}
2902 3085
 	}
2903 3086
 	public static function jsonDecode($value, $assoc = false, $depth = 512)
@@ -2956,24 +3139,25 @@  discard block
 block discarded – undo
2956 3139
 					if(is_array($value))
2957 3140
 					{
2958 3141
 						$name=urlencode($name.'[]');
2959
-						foreach($value as $v)
2960
-							$url.=$amp.$name.'='.urlencode($v);
3142
+						foreach($value as $v) {
3143
+													$url.=$amp.$name.'='.urlencode($v);
3144
+						}
3145
+					} else {
3146
+											$url.=$amp.urlencode($name).'='.urlencode($value);
2961 3147
 					}
2962
-					else
2963
-						$url.=$amp.urlencode($name).'='.urlencode($value);
2964 3148
 				}
2965
-			}
2966
-			else
3149
+			} else
2967 3150
 			{
2968 3151
 				foreach($getItems as $name=>$value)
2969 3152
 				{
2970 3153
 					if(is_array($value))
2971 3154
 					{
2972
-						foreach($value as $v)
2973
-							$url.=$amp.$name.'[]='.$v;
3155
+						foreach($value as $v) {
3156
+													$url.=$amp.$name.'[]='.$v;
3157
+						}
3158
+					} else {
3159
+											$url.=$amp.$name.'='.$value;
2974 3160
 					}
2975
-					else
2976
-						$url.=$amp.$name.'='.$value;
2977 3161
 				}
2978 3162
 			}
2979 3163
 		}
@@ -3006,19 +3190,20 @@  discard block
 block discarded – undo
3006 3190
 					{
3007 3191
 						$name=substr($path,0,$pos);
3008 3192
 						$value=substr($path,$pos+1);
3009
-						if(($pos=strpos($name,'[]'))!==false)
3010
-							$getVariables[substr($name,0,$pos)][]=$value;
3011
-						else
3012
-							$getVariables[$name]=$value;
3193
+						if(($pos=strpos($name,'[]'))!==false) {
3194
+													$getVariables[substr($name,0,$pos)][]=$value;
3195
+						} else {
3196
+													$getVariables[$name]=$value;
3197
+						}
3198
+					} else {
3199
+											$getVariables[$path]='';
3013 3200
 					}
3014
-					else
3015
-						$getVariables[$path]='';
3016 3201
 				}
3017 3202
 			}
3018 3203
 			return $getVariables;
3204
+		} else {
3205
+					return array();
3019 3206
 		}
3020
-		else
3021
-			return array();
3022 3207
 	}
3023 3208
 }
3024 3209
 class THttpRequest extends TApplicationComponent implements IteratorAggregate,ArrayAccess,Countable,IModule
@@ -3061,27 +3246,34 @@  discard block
 block discarded – undo
3061 3246
 			$_SERVER['SERVER_PORT']=80;
3062 3247
 			$_SERVER['HTTP_USER_AGENT']='';
3063 3248
 		}
3064
-														if(isset($_SERVER['REQUEST_URI']))
3065
-			$this->_requestUri=$_SERVER['REQUEST_URI'];
3066
-		else  			$this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING'])?'':'?'.$_SERVER['QUERY_STRING']);
3067
-		if($this->_cgiFix&self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO']))
3068
-			$this->_pathInfo=substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME']));
3069
-		elseif(isset($_SERVER['PATH_INFO']))
3070
-			$this->_pathInfo=$_SERVER['PATH_INFO'];
3071
-		else if(strpos($_SERVER['PHP_SELF'],$_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME'])
3072
-			$this->_pathInfo=substr($_SERVER['PHP_SELF'],strlen($_SERVER['SCRIPT_NAME']));
3073
-		else
3074
-			$this->_pathInfo='';
3249
+														if(isset($_SERVER['REQUEST_URI'])) {
3250
+																	$this->_requestUri=$_SERVER['REQUEST_URI'];
3251
+														} else {
3252
+			$this->_requestUri=$_SERVER['SCRIPT_NAME'].(empty($_SERVER['QUERY_STRING'])?'':'?'.$_SERVER['QUERY_STRING']);
3253
+		}
3254
+		if($this->_cgiFix&self::CGIFIX__PATH_INFO && isset($_SERVER['ORIG_PATH_INFO'])) {
3255
+					$this->_pathInfo=substr($_SERVER['ORIG_PATH_INFO'], strlen($_SERVER['SCRIPT_NAME']));
3256
+		} elseif(isset($_SERVER['PATH_INFO'])) {
3257
+					$this->_pathInfo=$_SERVER['PATH_INFO'];
3258
+		} else if(strpos($_SERVER['PHP_SELF'],$_SERVER['SCRIPT_NAME'])===0 && $_SERVER['PHP_SELF']!==$_SERVER['SCRIPT_NAME']) {
3259
+					$this->_pathInfo=substr($_SERVER['PHP_SELF'],strlen($_SERVER['SCRIPT_NAME']));
3260
+		} else {
3261
+					$this->_pathInfo='';
3262
+		}
3075 3263
 		if(get_magic_quotes_gpc())
3076 3264
 		{
3077
-			if(isset($_GET))
3078
-				$_GET=$this->stripSlashes($_GET);
3079
-			if(isset($_POST))
3080
-				$_POST=$this->stripSlashes($_POST);
3081
-			if(isset($_REQUEST))
3082
-				$_REQUEST=$this->stripSlashes($_REQUEST);
3083
-			if(isset($_COOKIE))
3084
-				$_COOKIE=$this->stripSlashes($_COOKIE);
3265
+			if(isset($_GET)) {
3266
+							$_GET=$this->stripSlashes($_GET);
3267
+			}
3268
+			if(isset($_POST)) {
3269
+							$_POST=$this->stripSlashes($_POST);
3270
+			}
3271
+			if(isset($_REQUEST)) {
3272
+							$_REQUEST=$this->stripSlashes($_REQUEST);
3273
+			}
3274
+			if(isset($_COOKIE)) {
3275
+							$_COOKIE=$this->stripSlashes($_COOKIE);
3276
+			}
3085 3277
 		}
3086 3278
 		$this->getApplication()->setRequest($this);
3087 3279
 	}
@@ -3099,11 +3291,12 @@  discard block
 block discarded – undo
3099 3291
 			{
3100 3292
 				$url.=$_SERVER['SERVER_NAME'];
3101 3293
 				$port=$_SERVER['SERVER_PORT'];
3102
-				if(($port!=80 && !$secure) || ($port!=443 && $secure))
3103
-					$url.=':'.$port;
3294
+				if(($port!=80 && !$secure) || ($port!=443 && $secure)) {
3295
+									$url.=':'.$port;
3296
+				}
3297
+			} else {
3298
+							$url.=$_SERVER['HTTP_HOST'];
3104 3299
 			}
3105
-			else
3106
-				$url.=$_SERVER['HTTP_HOST'];
3107 3300
 			$url.=$this->getRequestUri();
3108 3301
 			$this->_url=new TUri($url);
3109 3302
 		}
@@ -3129,10 +3322,11 @@  discard block
 block discarded – undo
3129 3322
 			if($cache !== null)
3130 3323
 			{
3131 3324
 				$dependencies = null;
3132
-				if($this->getApplication()->getMode() !== TApplicationMode::Performance)
3133
-					if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile())
3325
+				if($this->getApplication()->getMode() !== TApplicationMode::Performance) {
3326
+									if ($manager instanceof TUrlMapping && $fn = $manager->getConfigFile())
3134 3327
 					{
3135 3328
 						$fn = Prado::getPathOfNamespace($fn,$this->getApplication()->getConfigurationFileExt());
3329
+				}
3136 3330
 						$dependencies = new TFileCacheDependency($fn);
3137 3331
 					}
3138 3332
 				return $cache->set($this->getCacheKey(), $manager, 0, $dependencies);
@@ -3148,8 +3342,9 @@  discard block
 block discarded – undo
3148 3342
 			if($cache !== null)
3149 3343
 			{
3150 3344
 				$manager = $cache->get($this->getCacheKey());
3151
-				if($manager instanceof TUrlManager)
3152
-					return $manager;
3345
+				if($manager instanceof TUrlManager) {
3346
+									return $manager;
3347
+				}
3153 3348
 			}
3154 3349
 		}
3155 3350
 		return null;
@@ -3172,14 +3367,15 @@  discard block
 block discarded – undo
3172 3367
 				{
3173 3368
 					$this->_urlManager=new TUrlManager;
3174 3369
 					$this->_urlManager->init(null);
3175
-				}
3176
-				else
3370
+				} else
3177 3371
 				{
3178 3372
 					$this->_urlManager=$this->getApplication()->getModule($this->_urlManagerID);
3179
-					if($this->_urlManager===null)
3180
-						throw new TConfigurationException('httprequest_urlmanager_inexist',$this->_urlManagerID);
3181
-					if(!($this->_urlManager instanceof TUrlManager))
3182
-						throw new TConfigurationException('httprequest_urlmanager_invalid',$this->_urlManagerID);
3373
+					if($this->_urlManager===null) {
3374
+											throw new TConfigurationException('httprequest_urlmanager_inexist',$this->_urlManagerID);
3375
+					}
3376
+					if(!($this->_urlManager instanceof TUrlManager)) {
3377
+											throw new TConfigurationException('httprequest_urlmanager_invalid',$this->_urlManagerID);
3378
+					}
3183 3379
 				}
3184 3380
 				$this->cacheUrlManager($this->_urlManager);
3185 3381
 			}
@@ -3200,10 +3396,11 @@  discard block
 block discarded – undo
3200 3396
 	}
3201 3397
 	public function setUrlParamSeparator($value)
3202 3398
 	{
3203
-		if(strlen($value)===1)
3204
-			$this->_separator=$value;
3205
-		else
3206
-			throw new TInvalidDataValueException('httprequest_separator_invalid');
3399
+		if(strlen($value)===1) {
3400
+					$this->_separator=$value;
3401
+		} else {
3402
+					throw new TInvalidDataValueException('httprequest_separator_invalid');
3403
+		}
3207 3404
 	}
3208 3405
 	public function getRequestType()
3209 3406
 	{
@@ -3211,10 +3408,12 @@  discard block
 block discarded – undo
3211 3408
 	}
3212 3409
 	public function getContentType($mimetypeOnly = true)
3213 3410
 	{
3214
-		if(!isset($_SERVER['CONTENT_TYPE']))
3215
-			return null;
3216
-		if($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false)
3217
-			return substr($_SERVER['CONTENT_TYPE'], 0, $_pos);
3411
+		if(!isset($_SERVER['CONTENT_TYPE'])) {
3412
+					return null;
3413
+		}
3414
+		if($mimetypeOnly === true && ($_pos = strpos(';', $_SERVER['CONTENT_TYPE'])) !== false) {
3415
+					return substr($_SERVER['CONTENT_TYPE'], 0, $_pos);
3416
+		}
3218 3417
 		return $_SERVER['CONTENT_TYPE'];
3219 3418
 	}
3220 3419
 	public function getIsSecureConnection()
@@ -3238,17 +3437,19 @@  discard block
 block discarded – undo
3238 3437
 		static $result;
3239 3438
 		if($result === null && function_exists('apache_request_headers')) {
3240 3439
 			$result = apache_request_headers();
3241
-		}
3242
-		elseif($result === null) {
3440
+		} elseif($result === null) {
3243 3441
 			$result = array();
3244 3442
 			foreach($_SERVER as $key=>$value) {
3245
-				if(strncasecmp($key, 'HTTP_', 5) !== 0) continue;
3443
+				if(strncasecmp($key, 'HTTP_', 5) !== 0) {
3444
+					continue;
3445
+				}
3246 3446
 					$key = str_replace(' ','-', ucwords(strtolower(str_replace('_',' ', substr($key, 5)))));
3247 3447
 					$result[$key] = $value;
3248 3448
 			}
3249 3449
 		}
3250
-		if($case !== null)
3251
-			return array_change_key_case($result, $case);
3450
+		if($case !== null) {
3451
+					return array_change_key_case($result, $case);
3452
+		}
3252 3453
 		return $result;
3253 3454
 	}
3254 3455
 	public function getRequestUri()
@@ -3260,13 +3461,16 @@  discard block
 block discarded – undo
3260 3461
 		$url=$this->getUrl();
3261 3462
 		$scheme=($forceSecureConnection)?"https": (($forceSecureConnection === null)?$url->getScheme():'http');
3262 3463
 		$host=$url->getHost();
3263
-		if (($port=$url->getPort())) $host.=':'.$port;
3464
+		if (($port=$url->getPort())) {
3465
+			$host.=':'.$port;
3466
+		}
3264 3467
 		return $scheme.'://'.$host;
3265 3468
 	}
3266 3469
 	public function getApplicationUrl()
3267 3470
 	{
3268
-		if($this->_cgiFix&self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME']))
3269
-			return $_SERVER['ORIG_SCRIPT_NAME'];
3471
+		if($this->_cgiFix&self::CGIFIX__SCRIPT_NAME && isset($_SERVER['ORIG_SCRIPT_NAME'])) {
3472
+					return $_SERVER['ORIG_SCRIPT_NAME'];
3473
+		}
3270 3474
 		return isset($_SERVER['SCRIPT_NAME'])?$_SERVER['SCRIPT_NAME']:null;
3271 3475
 	}
3272 3476
 	public function getAbsoluteApplicationUrl($forceSecureConnection=null)
@@ -3294,8 +3498,7 @@  discard block
 block discarded – undo
3294 3498
 		try
3295 3499
 		{
3296 3500
 			return get_browser();
3297
-		}
3298
-		catch(TPhpErrorException $e)
3501
+		} catch(TPhpErrorException $e)
3299 3502
 		{
3300 3503
 			throw new TConfigurationException('httprequest_browscap_required');
3301 3504
 		}
@@ -3346,14 +3549,15 @@  discard block
 block discarded – undo
3346 3549
 				$sm=$this->getApplication()->getSecurityManager();
3347 3550
 				foreach($_COOKIE as $key=>$value)
3348 3551
 				{
3349
-					if(($value=$sm->validateData($value))!==false)
3350
-						$this->_cookies->add(new THttpCookie($key,$value));
3552
+					if(($value=$sm->validateData($value))!==false) {
3553
+											$this->_cookies->add(new THttpCookie($key,$value));
3554
+					}
3351 3555
 				}
3352
-			}
3353
-			else
3556
+			} else
3354 3557
 			{
3355
-				foreach($_COOKIE as $key=>$value)
3356
-					$this->_cookies->add(new THttpCookie($key,$value));
3558
+				foreach($_COOKIE as $key=>$value) {
3559
+									$this->_cookies->add(new THttpCookie($key,$value));
3560
+				}
3357 3561
 			}
3358 3562
 		}
3359 3563
 		return $this->_cookies;
@@ -3372,13 +3576,15 @@  discard block
 block discarded – undo
3372 3576
 	}
3373 3577
 	public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=true,$encodeGetItems=true)
3374 3578
 	{
3375
-		if ($this->_cookieOnly===null)
3376
-				$this->_cookieOnly=(int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies');
3579
+		if ($this->_cookieOnly===null) {
3580
+						$this->_cookieOnly=(int)ini_get('session.use_cookies') && (int)ini_get('session.use_only_cookies');
3581
+		}
3377 3582
 		$url=$this->getUrlManagerModule()->constructUrl($serviceID,$serviceParam,$getItems,$encodeAmpersand,$encodeGetItems);
3378
-		if(defined('SID') && SID != '' && !$this->_cookieOnly)
3379
-			return $url . (strpos($url,'?')===false? '?' : ($encodeAmpersand?'&amp;':'&')) . SID;
3380
-		else
3381
-			return $url;
3583
+		if(defined('SID') && SID != '' && !$this->_cookieOnly) {
3584
+					return $url . (strpos($url,'?')===false? '?' : ($encodeAmpersand?'&amp;':'&')) . SID;
3585
+		} else {
3586
+					return $url;
3587
+		}
3382 3588
 	}
3383 3589
 	protected function parseUrl()
3384 3590
 	{
@@ -3387,8 +3593,9 @@  discard block
 block discarded – undo
3387 3593
 	public function resolveRequest($serviceIDs)
3388 3594
 	{
3389 3595
 		$getParams=$this->parseUrl();
3390
-		foreach($getParams as $name=>$value)
3391
-			$_GET[$name]=$value;
3596
+		foreach($getParams as $name=>$value) {
3597
+					$_GET[$name]=$value;
3598
+		}
3392 3599
 		$this->_items=array_merge($_GET,$_POST);
3393 3600
 		$this->_requestResolved=true;
3394 3601
 		foreach($serviceIDs as $serviceID)
@@ -3453,14 +3660,15 @@  discard block
 block discarded – undo
3453 3660
 			$value=$this->_items[$key];
3454 3661
 			unset($this->_items[$key]);
3455 3662
 			return $value;
3663
+		} else {
3664
+					return null;
3456 3665
 		}
3457
-		else
3458
-			return null;
3459 3666
 	}
3460 3667
 	public function clear()
3461 3668
 	{
3462
-		foreach(array_keys($this->_items) as $key)
3463
-			$this->remove($key);
3669
+		foreach(array_keys($this->_items) as $key) {
3670
+					$this->remove($key);
3671
+		}
3464 3672
 	}
3465 3673
 	public function contains($key)
3466 3674
 	{
@@ -3499,31 +3707,35 @@  discard block
 block discarded – undo
3499 3707
 		if($item instanceof THttpCookie)
3500 3708
 		{
3501 3709
 			parent::insertAt($index,$item);
3502
-			if($this->_o instanceof THttpResponse)
3503
-				$this->_o->addCookie($item);
3710
+			if($this->_o instanceof THttpResponse) {
3711
+							$this->_o->addCookie($item);
3712
+			}
3713
+		} else {
3714
+					throw new TInvalidDataTypeException('httpcookiecollection_httpcookie_required');
3504 3715
 		}
3505
-		else
3506
-			throw new TInvalidDataTypeException('httpcookiecollection_httpcookie_required');
3507 3716
 	}
3508 3717
 	public function removeAt($index)
3509 3718
 	{
3510 3719
 		$item=parent::removeAt($index);
3511
-		if($this->_o instanceof THttpResponse)
3512
-			$this->_o->removeCookie($item);
3720
+		if($this->_o instanceof THttpResponse) {
3721
+					$this->_o->removeCookie($item);
3722
+		}
3513 3723
 		return $item;
3514 3724
 	}
3515 3725
 	public function itemAt($index)
3516 3726
 	{
3517
-		if(is_integer($index))
3518
-			return parent::itemAt($index);
3519
-		else
3520
-			return $this->findCookieByName($index);
3727
+		if(is_integer($index)) {
3728
+					return parent::itemAt($index);
3729
+		} else {
3730
+					return $this->findCookieByName($index);
3731
+		}
3521 3732
 	}
3522 3733
 	public function findCookieByName($name)
3523 3734
 	{
3524
-		foreach($this as $cookie)
3525
-			if($cookie->getName()===$name)
3735
+		foreach($this as $cookie) {
3736
+					if($cookie->getName()===$name)
3526 3737
 				return $cookie;
3738
+		}
3527 3739
 		return null;
3528 3740
 	}
3529 3741
 }
@@ -3632,8 +3844,7 @@  discard block
 block discarded – undo
3632 3844
 			$this->_query=isset($ret['query'])?$ret['query']:'';
3633 3845
 			$this->_fragment=isset($ret['fragment'])?$ret['fragment']:'';
3634 3846
 			$this->_uri=$uri;
3635
-		}
3636
-		else
3847
+		} else
3637 3848
 		{
3638 3849
 			throw new TInvalidDataValueException('uri_format_invalid',$uri);
3639 3850
 		}
@@ -3744,8 +3955,9 @@  discard block
 block discarded – undo
3744 3955
 	}
3745 3956
 	public function init($config)
3746 3957
 	{
3747
-		if($this->_bufferOutput)
3748
-			ob_start();
3958
+		if($this->_bufferOutput) {
3959
+					ob_start();
3960
+		}
3749 3961
 		$this->_initialized=true;
3750 3962
 		$this->getApplication()->setResponse($this);
3751 3963
 	}
@@ -3767,8 +3979,9 @@  discard block
 block discarded – undo
3767 3979
 	}
3768 3980
 	public function setContentType($type)
3769 3981
 	{
3770
-		if ($this->_contentTypeHeaderSent)
3771
-			throw new Exception('Unable to alter content-type as it has been already sent');
3982
+		if ($this->_contentTypeHeaderSent) {
3983
+					throw new Exception('Unable to alter content-type as it has been already sent');
3984
+		}
3772 3985
 		$this->_contentType = $type;
3773 3986
 	}
3774 3987
 	public function getContentType()
@@ -3789,10 +4002,11 @@  discard block
 block discarded – undo
3789 4002
 	}
3790 4003
 	public function setBufferOutput($value)
3791 4004
 	{
3792
-		if($this->_initialized)
3793
-			throw new TInvalidOperationException('httpresponse_bufferoutput_unchangeable');
3794
-		else
3795
-			$this->_bufferOutput=TPropertyValue::ensureBoolean($value);
4005
+		if($this->_initialized) {
4006
+					throw new TInvalidOperationException('httpresponse_bufferoutput_unchangeable');
4007
+		} else {
4008
+					$this->_bufferOutput=TPropertyValue::ensureBoolean($value);
4009
+		}
3796 4010
 	}
3797 4011
 	public function getStatusCode()
3798 4012
 	{
@@ -3800,12 +4014,13 @@  discard block
 block discarded – undo
3800 4014
 	}
3801 4015
 	public function setStatusCode($status, $reason=null)
3802 4016
 	{
3803
-		if ($this->_httpHeaderSent)
3804
-			throw new Exception('Unable to alter response as HTTP header already sent');
4017
+		if ($this->_httpHeaderSent) {
4018
+					throw new Exception('Unable to alter response as HTTP header already sent');
4019
+		}
3805 4020
 		$status=TPropertyValue::ensureInteger($status);
3806 4021
 		if(isset(self::$HTTP_STATUS_CODES[$status])) {
3807 4022
 			$this->_reason=self::$HTTP_STATUS_CODES[$status];
3808
-		}else{
4023
+		} else{
3809 4024
 			if($reason===null || $reason==='') {
3810 4025
 				throw new TInvalidDataValueException("response_status_reason_missing");
3811 4026
 			}
@@ -3822,14 +4037,16 @@  discard block
 block discarded – undo
3822 4037
 	}
3823 4038
 	public function getCookies()
3824 4039
 	{
3825
-		if($this->_cookies===null)
3826
-			$this->_cookies=new THttpCookieCollection($this);
4040
+		if($this->_cookies===null) {
4041
+					$this->_cookies=new THttpCookieCollection($this);
4042
+		}
3827 4043
 		return $this->_cookies;
3828 4044
 	}
3829 4045
 	public function write($str)
3830 4046
 	{
3831
-				if (!$this->_bufferOutput and !$this->_httpHeaderSent)
3832
-			$this->ensureHeadersSent();
4047
+				if (!$this->_bufferOutput and !$this->_httpHeaderSent) {
4048
+							$this->ensureHeadersSent();
4049
+				}
3833 4050
 		echo $str;
3834 4051
 	}
3835 4052
 	public function writeFile($fileName,$content=null,$mimeType=null,$headers=null,$forceDownload=true,$clientFileName=null,$fileSize=null)
@@ -3849,28 +4066,31 @@  discard block
 block discarded – undo
3849 4066
 		if($mimeType===null)
3850 4067
 		{
3851 4068
 			$mimeType='text/plain';
3852
-			if(function_exists('mime_content_type'))
3853
-				$mimeType=mime_content_type($fileName);
3854
-			else if(($ext=strrchr($fileName,'.'))!==false)
4069
+			if(function_exists('mime_content_type')) {
4070
+							$mimeType=mime_content_type($fileName);
4071
+			} else if(($ext=strrchr($fileName,'.'))!==false)
3855 4072
 			{
3856 4073
 				$ext=substr($ext,1);
3857
-				if(isset($defaultMimeTypes[$ext]))
3858
-					$mimeType=$defaultMimeTypes[$ext];
4074
+				if(isset($defaultMimeTypes[$ext])) {
4075
+									$mimeType=$defaultMimeTypes[$ext];
4076
+				}
3859 4077
 			}
3860 4078
 		}
3861
-		if($clientFileName===null)
3862
-			$clientFileName=basename($fileName);
3863
-		else
3864
-			$clientFileName=basename($clientFileName);
3865
-		if($fileSize===null || $fileSize < 0)
3866
-			$fileSize = ($content===null?filesize($fileName):strlen($content));
4079
+		if($clientFileName===null) {
4080
+					$clientFileName=basename($fileName);
4081
+		} else {
4082
+					$clientFileName=basename($clientFileName);
4083
+		}
4084
+		if($fileSize===null || $fileSize < 0) {
4085
+					$fileSize = ($content===null?filesize($fileName):strlen($content));
4086
+		}
3867 4087
 		$this->sendHttpHeader();
3868 4088
 		if(is_array($headers))
3869 4089
 		{
3870
-			foreach($headers as $h)
3871
-				header($h);
3872
-		}
3873
-		else
4090
+			foreach($headers as $h) {
4091
+							header($h);
4092
+			}
4093
+		} else
3874 4094
 		{
3875 4095
 			header('Pragma: public');
3876 4096
 			header('Expires: 0');
@@ -3881,29 +4101,34 @@  discard block
 block discarded – undo
3881 4101
 		header('Content-Length: '.$fileSize);
3882 4102
 		header("Content-Disposition: " . ($forceDownload ? 'attachment' : 'inline') . "; filename=\"$clientFileName\"");
3883 4103
 		header('Content-Transfer-Encoding: binary');
3884
-		if($content===null)
3885
-			readfile($fileName);
3886
-		else
3887
-			echo $content;
4104
+		if($content===null) {
4105
+					readfile($fileName);
4106
+		} else {
4107
+					echo $content;
4108
+		}
3888 4109
 	}
3889 4110
 	public function redirect($url)
3890 4111
 	{
3891
-		if($this->getHasAdapter())
3892
-			$this->_adapter->httpRedirect($url);
3893
-		else
3894
-			$this->httpRedirect($url);
4112
+		if($this->getHasAdapter()) {
4113
+					$this->_adapter->httpRedirect($url);
4114
+		} else {
4115
+					$this->httpRedirect($url);
4116
+		}
3895 4117
 	}
3896 4118
 	public function httpRedirect($url)
3897 4119
 	{
3898 4120
 		$this->ensureHeadersSent();
3899
-		if($url[0]==='/')
3900
-			$url=$this->getRequest()->getBaseUrl().$url;
3901
-		if ($this->_status >= 300 && $this->_status < 400)
3902
-						header('Location: '.str_replace('&amp;','&',$url), true, $this->_status);
3903
-		else
3904
-			header('Location: '.str_replace('&amp;','&',$url));
3905
-		if(!$this->getApplication()->getRequestCompleted())
3906
-			$this->getApplication()->onEndRequest();
4121
+		if($url[0]==='/') {
4122
+					$url=$this->getRequest()->getBaseUrl().$url;
4123
+		}
4124
+		if ($this->_status >= 300 && $this->_status < 400) {
4125
+								header('Location: '.str_replace('&amp;','&',$url), true, $this->_status);
4126
+		} else {
4127
+					header('Location: '.str_replace('&amp;','&',$url));
4128
+		}
4129
+		if(!$this->getApplication()->getRequestCompleted()) {
4130
+					$this->getApplication()->onEndRequest();
4131
+		}
3907 4132
 		exit();
3908 4133
 	}
3909 4134
 	public function reload()
@@ -3912,10 +4137,11 @@  discard block
 block discarded – undo
3912 4137
 	}
3913 4138
 	public function flush($continueBuffering = true)
3914 4139
 	{
3915
-		if($this->getHasAdapter())
3916
-			$this->_adapter->flushContent($continueBuffering);
3917
-		else
3918
-			$this->flushContent($continueBuffering);
4140
+		if($this->getHasAdapter()) {
4141
+					$this->_adapter->flushContent($continueBuffering);
4142
+		} else {
4143
+					$this->flushContent($continueBuffering);
4144
+		}
3919 4145
 	}
3920 4146
 	public function ensureHeadersSent()
3921 4147
 	{
@@ -3933,25 +4159,27 @@  discard block
 block discarded – undo
3933 4159
 				{
3934 4160
 					$this->_bufferOutput = false;
3935 4161
 					ob_end_flush();
4162
+				} else {
4163
+									ob_flush();
3936 4164
 				}
3937
-				else
3938
-					ob_flush();
3939 4165
 				flush();
3940 4166
 			}
4167
+		} else {
4168
+					flush();
3941 4169
 		}
3942
-		else
3943
-			flush();
3944 4170
 	}
3945 4171
 	protected function ensureHttpHeaderSent()
3946 4172
 	{
3947
-		if (!$this->_httpHeaderSent)
3948
-			$this->sendHttpHeader();
4173
+		if (!$this->_httpHeaderSent) {
4174
+					$this->sendHttpHeader();
4175
+		}
3949 4176
 	}
3950 4177
 	protected function sendHttpHeader()
3951 4178
 	{
3952 4179
 		$protocol=$this->getRequest()->getHttpProtocolVersion();
3953
-		if($this->getRequest()->getHttpProtocolVersion() === null)
3954
-			$protocol='HTTP/1.1';
4180
+		if($this->getRequest()->getHttpProtocolVersion() === null) {
4181
+					$protocol='HTTP/1.1';
4182
+		}
3955 4183
 		$phpSapiName = substr(php_sapi_name(), 0, 3);
3956 4184
 		$cgi = $phpSapiName == 'cgi' || $phpSapiName == 'fpm';
3957 4185
 		header(($cgi ? 'Status:' : $protocol).' '.$this->_status.' '.$this->_reason, true, TPropertyValue::ensureInteger($this->_status));
@@ -3959,8 +4187,9 @@  discard block
 block discarded – undo
3959 4187
 	}
3960 4188
 	protected function ensureContentTypeHeaderSent()
3961 4189
 	{
3962
-		if (!$this->_contentTypeHeaderSent)
3963
-			$this->sendContentTypeHeader();
4190
+		if (!$this->_contentTypeHeaderSent) {
4191
+					$this->sendContentTypeHeader();
4192
+		}
3964 4193
 	}
3965 4194
 	protected function sendContentTypeHeader()
3966 4195
 	{
@@ -3970,9 +4199,12 @@  discard block
 block discarded – undo
3970 4199
 			$this->appendHeader('Content-Type: '.$contentType);
3971 4200
 			return;
3972 4201
 		}
3973
-		if($charset==='' && ($globalization=$this->getApplication()->getGlobalization(false))!==null)
3974
-			$charset=$globalization->getCharset();
3975
-		if($charset==='') $charset = self::DEFAULT_CHARSET;
4202
+		if($charset==='' && ($globalization=$this->getApplication()->getGlobalization(false))!==null) {
4203
+					$charset=$globalization->getCharset();
4204
+		}
4205
+		if($charset==='') {
4206
+			$charset = self::DEFAULT_CHARSET;
4207
+		}
3976 4208
 		$this->appendHeader('Content-Type: '.$contentType.';charset='.$charset);
3977 4209
 		$this->_contentTypeHeaderSent = true;
3978 4210
 	}
@@ -3982,8 +4214,9 @@  discard block
 block discarded – undo
3982 4214
 	}
3983 4215
 	public function clear()
3984 4216
 	{
3985
-		if($this->_bufferOutput)
3986
-			ob_clean();
4217
+		if($this->_bufferOutput) {
4218
+					ob_clean();
4219
+		}
3987 4220
 	}
3988 4221
 	public function getHeaders($case=null)
3989 4222
 	{
@@ -3993,13 +4226,15 @@  discard block
 block discarded – undo
3993 4226
 			$tmp = explode(':', $header);
3994 4227
 			$key = trim(array_shift($tmp));
3995 4228
 			$value = trim(implode(':', $tmp));
3996
-			if(isset($result[$key]))
3997
-				$result[$key] .= ', ' . $value;
3998
-			else
3999
-				$result[$key] = $value;
4229
+			if(isset($result[$key])) {
4230
+							$result[$key] .= ', ' . $value;
4231
+			} else {
4232
+							$result[$key] = $value;
4233
+			}
4234
+		}
4235
+		if($case !== null) {
4236
+					return array_change_key_case($result, $case);
4000 4237
 		}
4001
-		if($case !== null)
4002
-			return array_change_key_case($result, $case);
4003 4238
 		return $result;
4004 4239
 	}
4005 4240
 	public function appendHeader($value, $replace=true)
@@ -4025,8 +4260,7 @@  discard block
 block discarded – undo
4025 4260
 				$cookie->getSecure(),
4026 4261
 				$cookie->getHttpOnly()
4027 4262
 			);
4028
-		}
4029
-		else {
4263
+		} else {
4030 4264
 			setcookie(
4031 4265
 				$cookie->getName(),
4032 4266
 				$cookie->getValue(),
@@ -4060,12 +4294,14 @@  discard block
 block discarded – undo
4060 4294
 	}
4061 4295
 	public function createHtmlWriter($type=null)
4062 4296
 	{
4063
-		if($type===null)
4064
-			$type=$this->getHtmlWriterType();
4065
-		if($this->getHasAdapter())
4066
-			return $this->_adapter->createNewHtmlWriter($type, $this);
4067
-		else
4068
-			return $this->createNewHtmlWriter($type, $this);
4297
+		if($type===null) {
4298
+					$type=$this->getHtmlWriterType();
4299
+		}
4300
+		if($this->getHasAdapter()) {
4301
+					return $this->_adapter->createNewHtmlWriter($type, $this);
4302
+		} else {
4303
+					return $this->createNewHtmlWriter($type, $this);
4304
+		}
4069 4305
 	}
4070 4306
 	public function createNewHtmlWriter($type, $writer)
4071 4307
 	{
@@ -4090,8 +4326,9 @@  discard block
 block discarded – undo
4090 4326
 	}
4091 4327
 	public function init($config)
4092 4328
 	{
4093
-		if($this->_autoStart)
4094
-			$this->open();
4329
+		if($this->_autoStart) {
4330
+					$this->open();
4331
+		}
4095 4332
 		$this->_initialized=true;
4096 4333
 		$this->getApplication()->setSession($this);
4097 4334
 		register_shutdown_function(array($this, "close"));
@@ -4100,12 +4337,15 @@  discard block
 block discarded – undo
4100 4337
 	{
4101 4338
 		if(!$this->_started)
4102 4339
 		{
4103
-			if($this->_customStorage)
4104
-				session_set_save_handler(array($this,'_open'),array($this,'_close'),array($this,'_read'),array($this,'_write'),array($this,'_destroy'),array($this,'_gc'));
4105
-			if($this->_cookie!==null)
4106
-				session_set_cookie_params($this->_cookie->getExpire(),$this->_cookie->getPath(),$this->_cookie->getDomain(),$this->_cookie->getSecure(),$this->_cookie->getHttpOnly());
4107
-			if(ini_get('session.auto_start')!=='1')
4108
-				session_start();
4340
+			if($this->_customStorage) {
4341
+							session_set_save_handler(array($this,'_open'),array($this,'_close'),array($this,'_read'),array($this,'_write'),array($this,'_destroy'),array($this,'_gc'));
4342
+			}
4343
+			if($this->_cookie!==null) {
4344
+							session_set_cookie_params($this->_cookie->getExpire(),$this->_cookie->getPath(),$this->_cookie->getDomain(),$this->_cookie->getSecure(),$this->_cookie->getHttpOnly());
4345
+			}
4346
+			if(ini_get('session.auto_start')!=='1') {
4347
+							session_start();
4348
+			}
4109 4349
 			$this->_started=true;
4110 4350
 		}
4111 4351
 	}
@@ -4141,10 +4381,11 @@  discard block
 block discarded – undo
4141 4381
 	}
4142 4382
 	public function setSessionID($value)
4143 4383
 	{
4144
-		if($this->_started)
4145
-			throw new TInvalidOperationException('httpsession_sessionid_unchangeable');
4146
-		else
4147
-			session_id($value);
4384
+		if($this->_started) {
4385
+					throw new TInvalidOperationException('httpsession_sessionid_unchangeable');
4386
+		} else {
4387
+					session_id($value);
4388
+		}
4148 4389
 	}
4149 4390
 	public function getSessionName()
4150 4391
 	{
@@ -4152,12 +4393,13 @@  discard block
 block discarded – undo
4152 4393
 	}
4153 4394
 	public function setSessionName($value)
4154 4395
 	{
4155
-		if($this->_started)
4156
-			throw new TInvalidOperationException('httpsession_sessionname_unchangeable');
4157
-		else if(ctype_alnum($value))
4158
-			session_name($value);
4159
-		else
4160
-			throw new TInvalidDataValueException('httpsession_sessionname_invalid',$value);
4396
+		if($this->_started) {
4397
+					throw new TInvalidOperationException('httpsession_sessionname_unchangeable');
4398
+		} else if(ctype_alnum($value)) {
4399
+					session_name($value);
4400
+		} else {
4401
+					throw new TInvalidDataValueException('httpsession_sessionname_invalid',$value);
4402
+		}
4161 4403
 	}
4162 4404
 	public function getSavePath()
4163 4405
 	{
@@ -4165,12 +4407,13 @@  discard block
 block discarded – undo
4165 4407
 	}
4166 4408
 	public function setSavePath($value)
4167 4409
 	{
4168
-		if($this->_started)
4169
-			throw new TInvalidOperationException('httpsession_savepath_unchangeable');
4170
-		else if(is_dir($value))
4171
-			session_save_path($value);
4172
-		else
4173
-			throw new TInvalidDataValueException('httpsession_savepath_invalid',$value);
4410
+		if($this->_started) {
4411
+					throw new TInvalidOperationException('httpsession_savepath_unchangeable');
4412
+		} else if(is_dir($value)) {
4413
+					session_save_path($value);
4414
+		} else {
4415
+					throw new TInvalidDataValueException('httpsession_savepath_invalid',$value);
4416
+		}
4174 4417
 	}
4175 4418
 	public function getUseCustomStorage()
4176 4419
 	{
@@ -4182,37 +4425,37 @@  discard block
 block discarded – undo
4182 4425
 	}
4183 4426
 	public function getCookie()
4184 4427
 	{
4185
-		if($this->_cookie===null)
4186
-			$this->_cookie=new THttpCookie($this->getSessionName(),$this->getSessionID());
4428
+		if($this->_cookie===null) {
4429
+					$this->_cookie=new THttpCookie($this->getSessionName(),$this->getSessionID());
4430
+		}
4187 4431
 		return $this->_cookie;
4188 4432
 	}
4189 4433
 	public function getCookieMode()
4190 4434
 	{
4191
-		if(ini_get('session.use_cookies')==='0')
4192
-			return THttpSessionCookieMode::None;
4193
-		else if(ini_get('session.use_only_cookies')==='0')
4194
-			return THttpSessionCookieMode::Allow;
4195
-		else
4196
-			return THttpSessionCookieMode::Only;
4435
+		if(ini_get('session.use_cookies')==='0') {
4436
+					return THttpSessionCookieMode::None;
4437
+		} else if(ini_get('session.use_only_cookies')==='0') {
4438
+					return THttpSessionCookieMode::Allow;
4439
+		} else {
4440
+					return THttpSessionCookieMode::Only;
4441
+		}
4197 4442
 	}
4198 4443
 	public function setCookieMode($value)
4199 4444
 	{
4200
-		if($this->_started)
4201
-			throw new TInvalidOperationException('httpsession_cookiemode_unchangeable');
4202
-		else
4445
+		if($this->_started) {
4446
+					throw new TInvalidOperationException('httpsession_cookiemode_unchangeable');
4447
+		} else
4203 4448
 		{
4204 4449
 			$value=TPropertyValue::ensureEnum($value,'THttpSessionCookieMode');
4205 4450
 			if($value===THttpSessionCookieMode::None) 
4206 4451
       {
4207 4452
 				ini_set('session.use_cookies','0');
4208 4453
 			  ini_set('session.use_only_cookies','0');
4209
-      }
4210
-			else if($value===THttpSessionCookieMode::Allow)
4454
+      } else if($value===THttpSessionCookieMode::Allow)
4211 4455
 			{
4212 4456
 				ini_set('session.use_cookies','1');
4213 4457
 				ini_set('session.use_only_cookies','0');
4214
-			}
4215
-			else
4458
+			} else
4216 4459
 			{
4217 4460
 				ini_set('session.use_cookies','1');
4218 4461
 				ini_set('session.use_only_cookies','1');
@@ -4226,10 +4469,11 @@  discard block
 block discarded – undo
4226 4469
 	}
4227 4470
 	public function setAutoStart($value)
4228 4471
 	{
4229
-		if($this->_initialized)
4230
-			throw new TInvalidOperationException('httpsession_autostart_unchangeable');
4231
-		else
4232
-			$this->_autoStart=TPropertyValue::ensureBoolean($value);
4472
+		if($this->_initialized) {
4473
+					throw new TInvalidOperationException('httpsession_autostart_unchangeable');
4474
+		} else {
4475
+					$this->_autoStart=TPropertyValue::ensureBoolean($value);
4476
+		}
4233 4477
 	}
4234 4478
 	public function getGCProbability()
4235 4479
 	{
@@ -4237,18 +4481,18 @@  discard block
 block discarded – undo
4237 4481
 	}
4238 4482
 	public function setGCProbability($value)
4239 4483
 	{
4240
-		if($this->_started)
4241
-			throw new TInvalidOperationException('httpsession_gcprobability_unchangeable');
4242
-		else
4484
+		if($this->_started) {
4485
+					throw new TInvalidOperationException('httpsession_gcprobability_unchangeable');
4486
+		} else
4243 4487
 		{
4244 4488
 			$value=TPropertyValue::ensureInteger($value);
4245 4489
 			if($value>=0 && $value<=100)
4246 4490
 			{
4247 4491
 				ini_set('session.gc_probability',$value);
4248 4492
 				ini_set('session.gc_divisor','100');
4493
+			} else {
4494
+							throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value);
4249 4495
 			}
4250
-			else
4251
-				throw new TInvalidDataValueException('httpsession_gcprobability_invalid',$value);
4252 4496
 		}
4253 4497
 	}
4254 4498
 	public function getUseTransparentSessionID()
@@ -4257,13 +4501,14 @@  discard block
 block discarded – undo
4257 4501
 	}
4258 4502
 	public function setUseTransparentSessionID($value)
4259 4503
 	{
4260
-		if($this->_started)
4261
-			throw new TInvalidOperationException('httpsession_transid_unchangeable');
4262
-		else
4504
+		if($this->_started) {
4505
+					throw new TInvalidOperationException('httpsession_transid_unchangeable');
4506
+		} else
4263 4507
 		{
4264 4508
 			$value=TPropertyValue::ensureBoolean($value);
4265
-			if ($value && $this->getCookieMode()==THttpSessionCookieMode::Only)
4266
-					throw new TInvalidOperationException('httpsession_transid_cookieonly');
4509
+			if ($value && $this->getCookieMode()==THttpSessionCookieMode::Only) {
4510
+								throw new TInvalidOperationException('httpsession_transid_cookieonly');
4511
+			}
4267 4512
 			ini_set('session.use_trans_sid',$value?'1':'0');
4268 4513
 		}
4269 4514
 	}
@@ -4273,10 +4518,11 @@  discard block
 block discarded – undo
4273 4518
 	}
4274 4519
 	public function setTimeout($value)
4275 4520
 	{
4276
-		if($this->_started)
4277
-			throw new TInvalidOperationException('httpsession_maxlifetime_unchangeable');
4278
-		else
4279
-			ini_set('session.gc_maxlifetime',$value);
4521
+		if($this->_started) {
4522
+					throw new TInvalidOperationException('httpsession_maxlifetime_unchangeable');
4523
+		} else {
4524
+					ini_set('session.gc_maxlifetime',$value);
4525
+		}
4280 4526
 	}
4281 4527
 	public function _open($savePath,$sessionName)
4282 4528
 	{
@@ -4333,14 +4579,15 @@  discard block
 block discarded – undo
4333 4579
 			$value=$_SESSION[$key];
4334 4580
 			unset($_SESSION[$key]);
4335 4581
 			return $value;
4582
+		} else {
4583
+					return null;
4336 4584
 		}
4337
-		else
4338
-			return null;
4339 4585
 	}
4340 4586
 	public function clear()
4341 4587
 	{
4342
-		foreach(array_keys($_SESSION) as $key)
4343
-			unset($_SESSION[$key]);
4588
+		foreach(array_keys($_SESSION) as $key) {
4589
+					unset($_SESSION[$key]);
4590
+		}
4344 4591
 	}
4345 4592
 	public function contains($key)
4346 4593
 	{
@@ -4541,10 +4788,11 @@  discard block
 block discarded – undo
4541 4788
 	private $_rf=array();
4542 4789
 	public function __get($name)
4543 4790
 	{
4544
-		if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name]))
4545
-			return $this->_rf[self::RF_NAMED_OBJECTS][$name];
4546
-		else
4547
-			return parent::__get($name);
4791
+		if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) {
4792
+					return $this->_rf[self::RF_NAMED_OBJECTS][$name];
4793
+		} else {
4794
+					return parent::__get($name);
4795
+		}
4548 4796
 	}
4549 4797
 	public function getHasAdapter()
4550 4798
 	{
@@ -4566,10 +4814,11 @@  discard block
 block discarded – undo
4566 4814
 	{
4567 4815
 		if(!$this->_namingContainer && $this->_parent)
4568 4816
 		{
4569
-			if($this->_parent instanceof INamingContainer)
4570
-				$this->_namingContainer=$this->_parent;
4571
-			else
4572
-				$this->_namingContainer=$this->_parent->getNamingContainer();
4817
+			if($this->_parent instanceof INamingContainer) {
4818
+							$this->_namingContainer=$this->_parent;
4819
+			} else {
4820
+							$this->_namingContainer=$this->_parent->getNamingContainer();
4821
+			}
4573 4822
 		}
4574 4823
 		return $this->_namingContainer;
4575 4824
 	}
@@ -4577,10 +4826,11 @@  discard block
 block discarded – undo
4577 4826
 	{
4578 4827
 		if(!$this->_page)
4579 4828
 		{
4580
-			if($this->_parent)
4581
-				$this->_page=$this->_parent->getPage();
4582
-			else if($this->_tplControl)
4583
-				$this->_page=$this->_tplControl->getPage();
4829
+			if($this->_parent) {
4830
+							$this->_page=$this->_parent->getPage();
4831
+			} else if($this->_tplControl) {
4832
+							$this->_page=$this->_tplControl->getPage();
4833
+			}
4584 4834
 		}
4585 4835
 		return $this->_page;
4586 4836
 	}
@@ -4594,8 +4844,9 @@  discard block
 block discarded – undo
4594 4844
 	}
4595 4845
 	public function getTemplateControl()
4596 4846
 	{
4597
-		if(!$this->_tplControl && $this->_parent)
4598
-			$this->_tplControl=$this->_parent->getTemplateControl();
4847
+		if(!$this->_tplControl && $this->_parent) {
4848
+					$this->_tplControl=$this->_parent->getTemplateControl();
4849
+		}
4599 4850
 		return $this->_tplControl;
4600 4851
 	}
4601 4852
 	public function getSourceTemplateControl()
@@ -4603,8 +4854,9 @@  discard block
 block discarded – undo
4603 4854
 		$control=$this;
4604 4855
 		while(($control instanceof TControl) && ($control=$control->getTemplateControl())!==null)
4605 4856
 		{
4606
-			if(($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl())
4607
-				return $control;
4857
+			if(($control instanceof TTemplateControl) && $control->getIsSourceTemplateControl()) {
4858
+							return $control;
4859
+			}
4608 4860
 		}
4609 4861
 		return $this->getPage();
4610 4862
 	}
@@ -4618,37 +4870,42 @@  discard block
 block discarded – undo
4618 4870
 	}
4619 4871
 	public function getID($hideAutoID=true)
4620 4872
 	{
4621
-		if($hideAutoID)
4622
-			return ($this->_flags & self::IS_ID_SET) ? $this->_id : '';
4623
-		else
4624
-			return $this->_id;
4873
+		if($hideAutoID) {
4874
+					return ($this->_flags & self::IS_ID_SET) ? $this->_id : '';
4875
+		} else {
4876
+					return $this->_id;
4877
+		}
4625 4878
 	}
4626 4879
 	public function setID($id)
4627 4880
 	{
4628
-		if(!preg_match(self::ID_FORMAT,$id))
4629
-			throw new TInvalidDataValueException('control_id_invalid',get_class($this),$id);
4881
+		if(!preg_match(self::ID_FORMAT,$id)) {
4882
+					throw new TInvalidDataValueException('control_id_invalid',get_class($this),$id);
4883
+		}
4630 4884
 		$this->_id=$id;
4631 4885
 		$this->_flags |= self::IS_ID_SET;
4632 4886
 		$this->clearCachedUniqueID($this instanceof INamingContainer);
4633
-		if($this->_namingContainer)
4634
-			$this->_namingContainer->clearNameTable();
4887
+		if($this->_namingContainer) {
4888
+					$this->_namingContainer->clearNameTable();
4889
+		}
4635 4890
 	}
4636 4891
 	public function getUniqueID()
4637 4892
 	{
4638 4893
 		if($this->_uid==='' || $this->_uid===null)			{
4639 4894
 			$this->_uid='';  			if($namingContainer=$this->getNamingContainer())
4640 4895
 			{
4641
-				if($this->getPage()===$namingContainer)
4642
-					return ($this->_uid=$this->_id);
4643
-				else if(($prefix=$namingContainer->getUniqueID())==='')
4644
-					return $this->_id;
4645
-				else
4646
-					return ($this->_uid=$prefix.self::ID_SEPARATOR.$this->_id);
4896
+				if($this->getPage()===$namingContainer) {
4897
+									return ($this->_uid=$this->_id);
4898
+				} else if(($prefix=$namingContainer->getUniqueID())==='') {
4899
+									return $this->_id;
4900
+				} else {
4901
+									return ($this->_uid=$prefix.self::ID_SEPARATOR.$this->_id);
4902
+				}
4903
+			} else {
4904
+				return $this->_id;
4647 4905
 			}
4648
-			else					return $this->_id;
4906
+		} else {
4907
+					return $this->_uid;
4649 4908
 		}
4650
-		else
4651
-			return $this->_uid;
4652 4909
 	}
4653 4910
 	public function focus()
4654 4911
 	{
@@ -4668,10 +4925,11 @@  discard block
 block discarded – undo
4668 4925
 	}
4669 4926
 	public function setSkinID($value)
4670 4927
 	{
4671
-		if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage>=self::CS_CHILD_INITIALIZED)
4672
-			throw new TInvalidOperationException('control_skinid_unchangeable',get_class($this));
4673
-		else
4674
-			$this->_rf[self::RF_SKIN_ID]=$value;
4928
+		if(($this->_flags & self::IS_SKIN_APPLIED) || $this->_stage>=self::CS_CHILD_INITIALIZED) {
4929
+					throw new TInvalidOperationException('control_skinid_unchangeable',get_class($this));
4930
+		} else {
4931
+					$this->_rf[self::RF_SKIN_ID]=$value;
4932
+		}
4675 4933
 	}
4676 4934
 	public function getIsSkinApplied()
4677 4935
 	{
@@ -4679,19 +4937,21 @@  discard block
 block discarded – undo
4679 4937
 	}
4680 4938
 	public function getEnableTheming()
4681 4939
 	{
4682
-		if($this->_flags & self::IS_DISABLE_THEMING)
4683
-			return false;
4684
-		else
4685
-			return $this->_parent?$this->_parent->getEnableTheming():true;
4940
+		if($this->_flags & self::IS_DISABLE_THEMING) {
4941
+					return false;
4942
+		} else {
4943
+					return $this->_parent?$this->_parent->getEnableTheming():true;
4944
+		}
4686 4945
 	}
4687 4946
 	public function setEnableTheming($value)
4688 4947
 	{
4689
-		if($this->_stage>=self::CS_CHILD_INITIALIZED)
4690
-			throw new TInvalidOperationException('control_enabletheming_unchangeable',get_class($this),$this->getUniqueID());
4691
-		else if(TPropertyValue::ensureBoolean($value))
4692
-			$this->_flags &= ~self::IS_DISABLE_THEMING;
4693
-		else
4694
-			$this->_flags |= self::IS_DISABLE_THEMING;
4948
+		if($this->_stage>=self::CS_CHILD_INITIALIZED) {
4949
+					throw new TInvalidOperationException('control_enabletheming_unchangeable',get_class($this),$this->getUniqueID());
4950
+		} else if(TPropertyValue::ensureBoolean($value)) {
4951
+					$this->_flags &= ~self::IS_DISABLE_THEMING;
4952
+		} else {
4953
+					$this->_flags |= self::IS_DISABLE_THEMING;
4954
+		}
4695 4955
 	}
4696 4956
 	public function getCustomData()
4697 4957
 	{
@@ -4707,8 +4967,9 @@  discard block
 block discarded – undo
4707 4967
 	}
4708 4968
 	public function getControls()
4709 4969
 	{
4710
-		if(!isset($this->_rf[self::RF_CONTROLS]))
4711
-			$this->_rf[self::RF_CONTROLS]=$this->createControlCollection();
4970
+		if(!isset($this->_rf[self::RF_CONTROLS])) {
4971
+					$this->_rf[self::RF_CONTROLS]=$this->createControlCollection();
4972
+		}
4712 4973
 		return $this->_rf[self::RF_CONTROLS];
4713 4974
 	}
4714 4975
 	protected function createControlCollection()
@@ -4719,13 +4980,14 @@  discard block
 block discarded – undo
4719 4980
 	{
4720 4981
 		if($checkParents)
4721 4982
 		{
4722
-			for($control=$this;$control;$control=$control->_parent)
4723
-				if(!$control->getVisible(false))
4983
+			for($control=$this;$control;$control=$control->_parent) {
4984
+							if(!$control->getVisible(false))
4724 4985
 					return false;
4986
+			}
4725 4987
 			return true;
4988
+		} else {
4989
+					return $this->getViewState('Visible',true);
4726 4990
 		}
4727
-		else
4728
-			return $this->getViewState('Visible',true);
4729 4991
 	}
4730 4992
 	public function setVisible($value)
4731 4993
 	{
@@ -4735,13 +4997,14 @@  discard block
 block discarded – undo
4735 4997
 	{
4736 4998
 		if($checkParents)
4737 4999
 		{
4738
-			for($control=$this;$control;$control=$control->_parent)
4739
-				if(!$control->getViewState('Enabled',true))
5000
+			for($control=$this;$control;$control=$control->_parent) {
5001
+							if(!$control->getViewState('Enabled',true))
4740 5002
 					return false;
5003
+			}
4741 5004
 			return true;
5005
+		} else {
5006
+					return $this->getViewState('Enabled',true);
4742 5007
 		}
4743
-		else
4744
-			return $this->getViewState('Enabled',true);
4745 5008
 	}
4746 5009
 	public function setEnabled($value)
4747 5010
 	{
@@ -4749,16 +5012,17 @@  discard block
 block discarded – undo
4749 5012
 	}
4750 5013
 	public function getHasAttributes()
4751 5014
 	{
4752
-		if($attributes=$this->getViewState('Attributes',null))
4753
-			return $attributes->getCount()>0;
4754
-		else
4755
-			return false;
5015
+		if($attributes=$this->getViewState('Attributes',null)) {
5016
+					return $attributes->getCount()>0;
5017
+		} else {
5018
+					return false;
5019
+		}
4756 5020
 	}
4757 5021
 	public function getAttributes()
4758 5022
 	{
4759
-		if($attributes=$this->getViewState('Attributes',null))
4760
-			return $attributes;
4761
-		else
5023
+		if($attributes=$this->getViewState('Attributes',null)) {
5024
+					return $attributes;
5025
+		} else
4762 5026
 		{
4763 5027
 			$attributes=new TAttributeCollection;
4764 5028
 			$this->setViewState('Attributes',$attributes,null);
@@ -4767,17 +5031,19 @@  discard block
 block discarded – undo
4767 5031
 	}
4768 5032
 	public function hasAttribute($name)
4769 5033
 	{
4770
-		if($attributes=$this->getViewState('Attributes',null))
4771
-			return $attributes->contains($name);
4772
-		else
4773
-			return false;
5034
+		if($attributes=$this->getViewState('Attributes',null)) {
5035
+					return $attributes->contains($name);
5036
+		} else {
5037
+					return false;
5038
+		}
4774 5039
 	}
4775 5040
 	public function getAttribute($name)
4776 5041
 	{
4777
-		if($attributes=$this->getViewState('Attributes',null))
4778
-			return $attributes->itemAt($name);
4779
-		else
4780
-			return null;
5042
+		if($attributes=$this->getViewState('Attributes',null)) {
5043
+					return $attributes->itemAt($name);
5044
+		} else {
5045
+					return null;
5046
+		}
4781 5047
 	}
4782 5048
 	public function setAttribute($name,$value)
4783 5049
 	{
@@ -4785,29 +5051,32 @@  discard block
 block discarded – undo
4785 5051
 	}
4786 5052
 	public function removeAttribute($name)
4787 5053
 	{
4788
-		if($attributes=$this->getViewState('Attributes',null))
4789
-			return $attributes->remove($name);
4790
-		else
4791
-			return null;
5054
+		if($attributes=$this->getViewState('Attributes',null)) {
5055
+					return $attributes->remove($name);
5056
+		} else {
5057
+					return null;
5058
+		}
4792 5059
 	}
4793 5060
 	public function getEnableViewState($checkParents=false)
4794 5061
 	{
4795 5062
 		if($checkParents)
4796 5063
 		{
4797
-			for($control=$this;$control!==null;$control=$control->getParent())
4798
-				if($control->_flags & self::IS_DISABLE_VIEWSTATE)
5064
+			for($control=$this;$control!==null;$control=$control->getParent()) {
5065
+							if($control->_flags & self::IS_DISABLE_VIEWSTATE)
4799 5066
 					return false;
5067
+			}
4800 5068
 			return true;
5069
+		} else {
5070
+					return !($this->_flags & self::IS_DISABLE_VIEWSTATE);
4801 5071
 		}
4802
-		else
4803
-			return !($this->_flags & self::IS_DISABLE_VIEWSTATE);
4804 5072
 	}
4805 5073
 	public function setEnableViewState($value)
4806 5074
 	{
4807
-		if(TPropertyValue::ensureBoolean($value))
4808
-			$this->_flags &= ~self::IS_DISABLE_VIEWSTATE;
4809
-		else
4810
-			$this->_flags |= self::IS_DISABLE_VIEWSTATE;
5075
+		if(TPropertyValue::ensureBoolean($value)) {
5076
+					$this->_flags &= ~self::IS_DISABLE_VIEWSTATE;
5077
+		} else {
5078
+					$this->_flags |= self::IS_DISABLE_VIEWSTATE;
5079
+		}
4811 5080
 	}
4812 5081
 	protected function getControlState($key,$defaultValue=null)
4813 5082
 	{
@@ -4815,10 +5084,11 @@  discard block
 block discarded – undo
4815 5084
 	}
4816 5085
 	protected function setControlState($key,$value,$defaultValue=null)
4817 5086
 	{
4818
-		if($value===$defaultValue)
4819
-			unset($this->_rf[self::RF_CONTROLSTATE][$key]);
4820
-		else
4821
-			$this->_rf[self::RF_CONTROLSTATE][$key]=$value;
5087
+		if($value===$defaultValue) {
5088
+					unset($this->_rf[self::RF_CONTROLSTATE][$key]);
5089
+		} else {
5090
+					$this->_rf[self::RF_CONTROLSTATE][$key]=$value;
5091
+		}
4822 5092
 	}
4823 5093
 	protected function clearControlState($key)
4824 5094
 	{
@@ -4830,16 +5100,17 @@  discard block
 block discarded – undo
4830 5100
 	}
4831 5101
 	public function getViewState($key,$defaultValue=null)
4832 5102
 	{
4833
-		if(isset($this->_viewState[$key]))
4834
-			return $this->_viewState[$key]!==null?$this->_viewState[$key]:$defaultValue;
4835
-		else if(isset($this->_tempState[$key]))
5103
+		if(isset($this->_viewState[$key])) {
5104
+					return $this->_viewState[$key]!==null?$this->_viewState[$key]:$defaultValue;
5105
+		} else if(isset($this->_tempState[$key]))
4836 5106
 		{
4837
-			if(is_object($this->_tempState[$key]) && $this->_trackViewState)
4838
-				$this->_viewState[$key]=$this->_tempState[$key];
5107
+			if(is_object($this->_tempState[$key]) && $this->_trackViewState) {
5108
+							$this->_viewState[$key]=$this->_tempState[$key];
5109
+			}
4839 5110
 			return $this->_tempState[$key];
5111
+		} else {
5112
+					return $defaultValue;
4840 5113
 		}
4841
-		else
4842
-			return $defaultValue;
4843 5114
 	}
4844 5115
 	public function setViewState($key,$value,$defaultValue=null)
4845 5116
 	{
@@ -4847,8 +5118,7 @@  discard block
 block discarded – undo
4847 5118
 		{
4848 5119
 			$this->_viewState[$key]=$value;
4849 5120
 			unset($this->_tempState[$key]);
4850
-		}
4851
-		else
5121
+		} else
4852 5122
 		{
4853 5123
 			unset($this->_viewState[$key]);
4854 5124
 			$this->_tempState[$key]=$value;
@@ -4881,29 +5151,34 @@  discard block
 block discarded – undo
4881 5151
 	{
4882 5152
 		if(isset($this->_rf[self::RF_DATA_BINDINGS]))
4883 5153
 		{
4884
-			if(($context=$this->getTemplateControl())===null)
4885
-				$context=$this;
4886
-			foreach($this->_rf[self::RF_DATA_BINDINGS] as $property=>$expression)
4887
-				$this->setSubProperty($property,$context->evaluateExpression($expression));
5154
+			if(($context=$this->getTemplateControl())===null) {
5155
+							$context=$this;
5156
+			}
5157
+			foreach($this->_rf[self::RF_DATA_BINDINGS] as $property=>$expression) {
5158
+							$this->setSubProperty($property,$context->evaluateExpression($expression));
5159
+			}
4888 5160
 		}
4889 5161
 	}
4890 5162
 	protected function autoDataBindProperties()
4891 5163
 	{
4892 5164
 		if(isset($this->_rf[self::RF_AUTO_BINDINGS]))
4893 5165
 		{
4894
-			if(($context=$this->getTemplateControl())===null)
4895
-				$context=$this;
4896
-			foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property=>$expression)
4897
-				$this->setSubProperty($property,$context->evaluateExpression($expression));
5166
+			if(($context=$this->getTemplateControl())===null) {
5167
+							$context=$this;
5168
+			}
5169
+			foreach($this->_rf[self::RF_AUTO_BINDINGS] as $property=>$expression) {
5170
+							$this->setSubProperty($property,$context->evaluateExpression($expression));
5171
+			}
4898 5172
 		}
4899 5173
 	}
4900 5174
 	protected function dataBindChildren()
4901 5175
 	{
4902 5176
 		if(isset($this->_rf[self::RF_CONTROLS]))
4903 5177
 		{
4904
-			foreach($this->_rf[self::RF_CONTROLS] as $control)
4905
-				if($control instanceof IBindable)
5178
+			foreach($this->_rf[self::RF_CONTROLS] as $control) {
5179
+							if($control instanceof IBindable)
4906 5180
 					$control->dataBind();
5181
+			}
4907 5182
 		}
4908 5183
 	}
4909 5184
 	final protected function getChildControlsCreated()
@@ -4912,12 +5187,13 @@  discard block
 block discarded – undo
4912 5187
 	}
4913 5188
 	final protected function setChildControlsCreated($value)
4914 5189
 	{
4915
-		if($value)
4916
-			$this->_flags |= self::IS_CHILD_CREATED;
4917
-		else
5190
+		if($value) {
5191
+					$this->_flags |= self::IS_CHILD_CREATED;
5192
+		} else
4918 5193
 		{
4919
-			if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED))
4920
-				$this->getControls()->clear();
5194
+			if($this->getHasControls() && ($this->_flags & self::IS_CHILD_CREATED)) {
5195
+							$this->getControls()->clear();
5196
+			}
4921 5197
 			$this->_flags &= ~self::IS_CHILD_CREATED;
4922 5198
 		}
4923 5199
 	}
@@ -4928,14 +5204,14 @@  discard block
 block discarded – undo
4928 5204
 			try
4929 5205
 			{
4930 5206
 				$this->_flags |= self::IS_CREATING_CHILD;
4931
-				if(isset($this->_rf[self::RF_ADAPTER]))
4932
-					$this->_rf[self::RF_ADAPTER]->createChildControls();
4933
-				else
4934
-					$this->createChildControls();
5207
+				if(isset($this->_rf[self::RF_ADAPTER])) {
5208
+									$this->_rf[self::RF_ADAPTER]->createChildControls();
5209
+				} else {
5210
+									$this->createChildControls();
5211
+				}
4935 5212
 				$this->_flags &= ~self::IS_CREATING_CHILD;
4936 5213
 				$this->_flags |= self::IS_CHILD_CREATED;
4937
-			}
4938
-			catch(Exception $e)
5214
+			} catch(Exception $e)
4939 5215
 			{
4940 5216
 				$this->_flags &= ~self::IS_CREATING_CHILD;
4941 5217
 				$this->_flags |= self::IS_CHILD_CREATED;
@@ -4950,23 +5226,25 @@  discard block
 block discarded – undo
4950 5226
 	{
4951 5227
 		$id=strtr($id,'.',self::ID_SEPARATOR);
4952 5228
 		$container=($this instanceof INamingContainer)?$this:$this->getNamingContainer();
4953
-		if(!$container || !$container->getHasControls())
4954
-			return null;
5229
+		if(!$container || !$container->getHasControls()) {
5230
+					return null;
5231
+		}
4955 5232
 		if(!isset($container->_rf[self::RF_NAMED_CONTROLS]))
4956 5233
 		{
4957 5234
 			$container->_rf[self::RF_NAMED_CONTROLS]=array();
4958 5235
 			$container->fillNameTable($container,$container->_rf[self::RF_CONTROLS]);
4959 5236
 		}
4960
-		if(($pos=strpos($id,self::ID_SEPARATOR))===false)
4961
-			return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null;
4962
-		else
5237
+		if(($pos=strpos($id,self::ID_SEPARATOR))===false) {
5238
+					return isset($container->_rf[self::RF_NAMED_CONTROLS][$id])?$container->_rf[self::RF_NAMED_CONTROLS][$id]:null;
5239
+		} else
4963 5240
 		{
4964 5241
 			$cid=substr($id,0,$pos);
4965 5242
 			$sid=substr($id,$pos+1);
4966
-			if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid]))
4967
-				return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid);
4968
-			else
4969
-				return null;
5243
+			if(isset($container->_rf[self::RF_NAMED_CONTROLS][$cid])) {
5244
+							return $container->_rf[self::RF_NAMED_CONTROLS][$cid]->findControl($sid);
5245
+			} else {
5246
+							return null;
5247
+			}
4970 5248
 		}
4971 5249
 	}
4972 5250
 	public function findControlsByType($type,$strict=true)
@@ -4976,10 +5254,12 @@  discard block
 block discarded – undo
4976 5254
 		{
4977 5255
 			foreach($this->_rf[self::RF_CONTROLS] as $control)
4978 5256
 			{
4979
-				if(is_object($control) && (get_class($control)===$type || (!$strict && ($control instanceof $type))))
4980
-					$controls[]=$control;
4981
-				if(($control instanceof TControl) && $control->getHasControls())
4982
-					$controls=array_merge($controls,$control->findControlsByType($type,$strict));
5257
+				if(is_object($control) && (get_class($control)===$type || (!$strict && ($control instanceof $type)))) {
5258
+									$controls[]=$control;
5259
+				}
5260
+				if(($control instanceof TControl) && $control->getHasControls()) {
5261
+									$controls=array_merge($controls,$control->findControlsByType($type,$strict));
5262
+				}
4983 5263
 			}
4984 5264
 		}
4985 5265
 		return $controls;
@@ -4993,8 +5273,9 @@  discard block
 block discarded – undo
4993 5273
 			{
4994 5274
 				if($control instanceof TControl)
4995 5275
 				{
4996
-					if($control->_id===$id)
4997
-						$controls[]=$control;
5276
+					if($control->_id===$id) {
5277
+											$controls[]=$control;
5278
+					}
4998 5279
 					$controls=array_merge($controls,$control->findControlsByID($id));
4999 5280
 				}
5000 5281
 			}
@@ -5008,8 +5289,9 @@  discard block
 block discarded – undo
5008 5289
 	}
5009 5290
 	public function registerObject($name,$object)
5010 5291
 	{
5011
-		if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name]))
5012
-			throw new TInvalidOperationException('control_object_reregistered',$name);
5292
+		if(isset($this->_rf[self::RF_NAMED_OBJECTS][$name])) {
5293
+					throw new TInvalidOperationException('control_object_reregistered',$name);
5294
+		}
5013 5295
 		$this->_rf[self::RF_NAMED_OBJECTS][$name]=$object;
5014 5296
 	}
5015 5297
 	public function unregisterObject($name)
@@ -5059,24 +5341,27 @@  discard block
 block discarded – undo
5059 5341
 	final protected function isDescendentOf($ancestor)
5060 5342
 	{
5061 5343
 		$control=$this;
5062
-		while($control!==$ancestor && $control->_parent)
5063
-			$control=$control->_parent;
5344
+		while($control!==$ancestor && $control->_parent) {
5345
+					$control=$control->_parent;
5346
+		}
5064 5347
 		return $control===$ancestor;
5065 5348
 	}
5066 5349
 	public function addedControl($control)
5067 5350
 	{
5068
-		if($control->_parent)
5069
-			$control->_parent->getControls()->remove($control);
5351
+		if($control->_parent) {
5352
+					$control->_parent->getControls()->remove($control);
5353
+		}
5070 5354
 		$control->_parent=$this;
5071 5355
 		$control->_page=$this->getPage();
5072 5356
 		$namingContainer=($this instanceof INamingContainer)?$this:$this->_namingContainer;
5073 5357
 		if($namingContainer)
5074 5358
 		{
5075 5359
 			$control->_namingContainer=$namingContainer;
5076
-			if($control->_id==='')
5077
-				$control->generateAutomaticID();
5078
-			else
5079
-				$namingContainer->clearNameTable();
5360
+			if($control->_id==='') {
5361
+							$control->generateAutomaticID();
5362
+			} else {
5363
+							$namingContainer->clearNameTable();
5364
+			}
5080 5365
 			$control->clearCachedUniqueID($control instanceof INamingContainer);
5081 5366
 		}
5082 5367
 		if($this->_stage>=self::CS_CHILD_INITIALIZED)
@@ -5088,32 +5373,35 @@  discard block
 block discarded – undo
5088 5373
 				{
5089 5374
 					$state=$this->_rf[self::RF_CHILD_STATE][$control->_id];
5090 5375
 					unset($this->_rf[self::RF_CHILD_STATE][$control->_id]);
5376
+				} else {
5377
+									$state=null;
5091 5378
 				}
5092
-				else
5093
-					$state=null;
5094 5379
 				$control->loadStateRecursive($state,!($this->_flags & self::IS_DISABLE_VIEWSTATE));
5095 5380
 				if($this->_stage>=self::CS_LOADED)
5096 5381
 				{
5097 5382
 					$control->loadRecursive();
5098
-					if($this->_stage>=self::CS_PRERENDERED)
5099
-						$control->preRenderRecursive();
5383
+					if($this->_stage>=self::CS_PRERENDERED) {
5384
+											$control->preRenderRecursive();
5385
+					}
5100 5386
 				}
5101 5387
 			}
5102 5388
 		}
5103 5389
 	}
5104 5390
 	public function removedControl($control)
5105 5391
 	{
5106
-		if($this->_namingContainer)
5107
-			$this->_namingContainer->clearNameTable();
5392
+		if($this->_namingContainer) {
5393
+					$this->_namingContainer->clearNameTable();
5394
+		}
5108 5395
 		$control->unloadRecursive();
5109 5396
 		$control->_parent=null;
5110 5397
 		$control->_page=null;
5111 5398
 		$control->_namingContainer=null;
5112 5399
 		$control->_tplControl=null;
5113
-				if(!($control->_flags & self::IS_ID_SET))
5114
-			$control->_id='';
5115
-		else
5116
-			unset($this->_rf[self::RF_NAMED_OBJECTS][$control->_id]);
5400
+				if(!($control->_flags & self::IS_ID_SET)) {
5401
+							$control->_id='';
5402
+				} else {
5403
+					unset($this->_rf[self::RF_NAMED_OBJECTS][$control->_id]);
5404
+		}
5117 5405
 		$control->clearCachedUniqueID(true);
5118 5406
 	}
5119 5407
 	protected function initRecursive($namingContainer=null)
@@ -5121,8 +5409,9 @@  discard block
 block discarded – undo
5121 5409
 		$this->ensureChildControls();
5122 5410
 		if($this->getHasControls())
5123 5411
 		{
5124
-			if($this instanceof INamingContainer)
5125
-				$namingContainer=$this;
5412
+			if($this instanceof INamingContainer) {
5413
+							$namingContainer=$this;
5414
+			}
5126 5415
 			$page=$this->getPage();
5127 5416
 			foreach($this->_rf[self::RF_CONTROLS] as $control)
5128 5417
 			{
@@ -5130,8 +5419,9 @@  discard block
 block discarded – undo
5130 5419
 				{
5131 5420
 					$control->_namingContainer=$namingContainer;
5132 5421
 					$control->_page=$page;
5133
-					if($control->_id==='' && $namingContainer)
5134
-						$control->generateAutomaticID();
5422
+					if($control->_id==='' && $namingContainer) {
5423
+											$control->generateAutomaticID();
5424
+					}
5135 5425
 					$control->initRecursive($namingContainer);
5136 5426
 				}
5137 5427
 			}
@@ -5144,10 +5434,11 @@  discard block
 block discarded – undo
5144 5434
 				$page->applyControlSkin($this);
5145 5435
 				$this->_flags |= self::IS_SKIN_APPLIED;
5146 5436
 			}
5147
-			if(isset($this->_rf[self::RF_ADAPTER]))
5148
-				$this->_rf[self::RF_ADAPTER]->onInit(null);
5149
-			else
5150
-				$this->onInit(null);
5437
+			if(isset($this->_rf[self::RF_ADAPTER])) {
5438
+							$this->_rf[self::RF_ADAPTER]->onInit(null);
5439
+			} else {
5440
+							$this->onInit(null);
5441
+			}
5151 5442
 			$this->_stage=self::CS_INITIALIZED;
5152 5443
 		}
5153 5444
 	}
@@ -5155,39 +5446,44 @@  discard block
 block discarded – undo
5155 5446
 	{
5156 5447
 		if($this->_stage<self::CS_LOADED)
5157 5448
 		{
5158
-			if(isset($this->_rf[self::RF_ADAPTER]))
5159
-				$this->_rf[self::RF_ADAPTER]->onLoad(null);
5160
-			else
5161
-				$this->onLoad(null);
5449
+			if(isset($this->_rf[self::RF_ADAPTER])) {
5450
+							$this->_rf[self::RF_ADAPTER]->onLoad(null);
5451
+			} else {
5452
+							$this->onLoad(null);
5453
+			}
5162 5454
 		}
5163 5455
 		if($this->getHasControls())
5164 5456
 		{
5165 5457
 			foreach($this->_rf[self::RF_CONTROLS] as $control)
5166 5458
 			{
5167
-				if($control instanceof TControl)
5168
-					$control->loadRecursive();
5459
+				if($control instanceof TControl) {
5460
+									$control->loadRecursive();
5461
+				}
5169 5462
 			}
5170 5463
 		}
5171
-		if($this->_stage<self::CS_LOADED)
5172
-			$this->_stage=self::CS_LOADED;
5464
+		if($this->_stage<self::CS_LOADED) {
5465
+					$this->_stage=self::CS_LOADED;
5466
+		}
5173 5467
 	}
5174 5468
 	protected function preRenderRecursive()
5175 5469
 	{
5176 5470
 		$this->autoDataBindProperties();
5177 5471
 		if($this->getVisible(false))
5178 5472
 		{
5179
-			if(isset($this->_rf[self::RF_ADAPTER]))
5180
-				$this->_rf[self::RF_ADAPTER]->onPreRender(null);
5181
-			else
5182
-				$this->onPreRender(null);
5473
+			if(isset($this->_rf[self::RF_ADAPTER])) {
5474
+							$this->_rf[self::RF_ADAPTER]->onPreRender(null);
5475
+			} else {
5476
+							$this->onPreRender(null);
5477
+			}
5183 5478
 			if($this->getHasControls())
5184 5479
 			{
5185 5480
 				foreach($this->_rf[self::RF_CONTROLS] as $control)
5186 5481
 				{
5187
-					if($control instanceof TControl)
5188
-						$control->preRenderRecursive();
5189
-					else if($control instanceof TCompositeLiteral)
5190
-						$control->evaluateDynamicContent();
5482
+					if($control instanceof TControl) {
5483
+											$control->preRenderRecursive();
5484
+					} else if($control instanceof TCompositeLiteral) {
5485
+											$control->evaluateDynamicContent();
5486
+					}
5191 5487
 				}
5192 5488
 			}
5193 5489
 		}
@@ -5195,18 +5491,21 @@  discard block
 block discarded – undo
5195 5491
 	}
5196 5492
 	protected function unloadRecursive()
5197 5493
 	{
5198
-		if(!($this->_flags & self::IS_ID_SET))
5199
-			$this->_id='';
5494
+		if(!($this->_flags & self::IS_ID_SET)) {
5495
+					$this->_id='';
5496
+		}
5200 5497
 		if($this->getHasControls())
5201 5498
 		{
5202
-			foreach($this->_rf[self::RF_CONTROLS] as $control)
5203
-				if($control instanceof TControl)
5499
+			foreach($this->_rf[self::RF_CONTROLS] as $control) {
5500
+							if($control instanceof TControl)
5204 5501
 					$control->unloadRecursive();
5502
+			}
5503
+		}
5504
+		if(isset($this->_rf[self::RF_ADAPTER])) {
5505
+					$this->_rf[self::RF_ADAPTER]->onUnload(null);
5506
+		} else {
5507
+					$this->onUnload(null);
5205 5508
 		}
5206
-		if(isset($this->_rf[self::RF_ADAPTER]))
5207
-			$this->_rf[self::RF_ADAPTER]->onUnload(null);
5208
-		else
5209
-			$this->onUnload(null);
5210 5509
 	}
5211 5510
 	public function onInit($param)
5212 5511
 	{
@@ -5233,8 +5532,9 @@  discard block
 block discarded – undo
5233 5532
 		$control=$this;
5234 5533
 		while($control=$control->_parent)
5235 5534
 		{
5236
-			if($control->bubbleEvent($sender,$param))
5237
-				break;
5535
+			if($control->bubbleEvent($sender,$param)) {
5536
+							break;
5537
+			}
5238 5538
 		}
5239 5539
 	}
5240 5540
 	public function bubbleEvent($sender,$param)
@@ -5248,23 +5548,27 @@  discard block
 block discarded – undo
5248 5548
 	}
5249 5549
 	private function broadcastEventInternal($name,$sender,$param)
5250 5550
 	{
5251
-		if($this->hasEvent($name))
5252
-			$this->raiseEvent($name,$sender,$param->getParameter());
5253
-		if($this instanceof IBroadcastEventReceiver)
5254
-			$this->broadcastEventReceived($sender,$param);
5551
+		if($this->hasEvent($name)) {
5552
+					$this->raiseEvent($name,$sender,$param->getParameter());
5553
+		}
5554
+		if($this instanceof IBroadcastEventReceiver) {
5555
+					$this->broadcastEventReceived($sender,$param);
5556
+		}
5255 5557
 		if($this->getHasControls())
5256 5558
 		{
5257 5559
 			foreach($this->_rf[self::RF_CONTROLS] as $control)
5258 5560
 			{
5259
-				if($control instanceof TControl)
5260
-					$control->broadcastEventInternal($name,$sender,$param);
5561
+				if($control instanceof TControl) {
5562
+									$control->broadcastEventInternal($name,$sender,$param);
5563
+				}
5261 5564
 			}
5262 5565
 		}
5263 5566
 	}
5264 5567
 	protected function traverseChildControls($param,$preCallback=null,$postCallback=null)
5265 5568
 	{
5266
-		if($preCallback!==null)
5267
-			call_user_func($preCallback,$this,$param);
5569
+		if($preCallback!==null) {
5570
+					call_user_func($preCallback,$this,$param);
5571
+		}
5268 5572
 		if($this->getHasControls())
5269 5573
 		{
5270 5574
 			foreach($this->_rf[self::RF_CONTROLS] as $control)
@@ -5275,17 +5579,19 @@  discard block
 block discarded – undo
5275 5579
 				}
5276 5580
 			}
5277 5581
 		}
5278
-		if($postCallback!==null)
5279
-			call_user_func($postCallback,$this,$param);
5582
+		if($postCallback!==null) {
5583
+					call_user_func($postCallback,$this,$param);
5584
+		}
5280 5585
 	}
5281 5586
 	public function renderControl($writer)
5282 5587
 	{
5283 5588
 		if($this instanceof IActiveControl || $this->getVisible(false))
5284 5589
 		{
5285
-			if(isset($this->_rf[self::RF_ADAPTER]))
5286
-				$this->_rf[self::RF_ADAPTER]->render($writer);
5287
-			else
5288
-				$this->render($writer);
5590
+			if(isset($this->_rf[self::RF_ADAPTER])) {
5591
+							$this->_rf[self::RF_ADAPTER]->render($writer);
5592
+			} else {
5593
+							$this->render($writer);
5594
+			}
5289 5595
 		}
5290 5596
 	}
5291 5597
 	public function render($writer)
@@ -5298,12 +5604,13 @@  discard block
 block discarded – undo
5298 5604
 		{
5299 5605
 			foreach($this->_rf[self::RF_CONTROLS] as $control)
5300 5606
 			{
5301
-				if(is_string($control))
5302
-					$writer->write($control);
5303
-				else if($control instanceof TControl)
5304
-					$control->renderControl($writer);
5305
-				else if($control instanceof IRenderable)
5306
-					$control->render($writer);
5607
+				if(is_string($control)) {
5608
+									$writer->write($control);
5609
+				} else if($control instanceof TControl) {
5610
+									$control->renderControl($writer);
5611
+				} else if($control instanceof IRenderable) {
5612
+									$control->render($writer);
5613
+				}
5307 5614
 			}
5308 5615
 		}
5309 5616
 	}
@@ -5322,15 +5629,16 @@  discard block
 block discarded – undo
5322 5629
 			{
5323 5630
 				$this->_rf[self::RF_CONTROLSTATE]=&$state[1];
5324 5631
 				unset($state[1]);
5632
+			} else {
5633
+							unset($this->_rf[self::RF_CONTROLSTATE]);
5325 5634
 			}
5326
-			else
5327
-				unset($this->_rf[self::RF_CONTROLSTATE]);
5328 5635
 			if($needViewState)
5329 5636
 			{
5330
-				if(isset($state[0]))
5331
-					$this->_viewState=&$state[0];
5332
-				else
5333
-					$this->_viewState=array();
5637
+				if(isset($state[0])) {
5638
+									$this->_viewState=&$state[0];
5639
+				} else {
5640
+									$this->_viewState=array();
5641
+				}
5334 5642
 			}
5335 5643
 			unset($state[0]);
5336 5644
 			if($this->getHasControls())
@@ -5347,35 +5655,41 @@  discard block
 block discarded – undo
5347 5655
 					}
5348 5656
 				}
5349 5657
 			}
5350
-			if(!empty($state))
5351
-				$this->_rf[self::RF_CHILD_STATE]=&$state;
5658
+			if(!empty($state)) {
5659
+							$this->_rf[self::RF_CHILD_STATE]=&$state;
5660
+			}
5352 5661
 		}
5353 5662
 		$this->_stage=self::CS_STATE_LOADED;
5354
-		if(isset($this->_rf[self::RF_ADAPTER]))
5355
-			$this->_rf[self::RF_ADAPTER]->loadState();
5356
-		else
5357
-			$this->loadState();
5663
+		if(isset($this->_rf[self::RF_ADAPTER])) {
5664
+					$this->_rf[self::RF_ADAPTER]->loadState();
5665
+		} else {
5666
+					$this->loadState();
5667
+		}
5358 5668
 	}
5359 5669
 	protected function &saveStateRecursive($needViewState=true)
5360 5670
 	{
5361
-		if(isset($this->_rf[self::RF_ADAPTER]))
5362
-			$this->_rf[self::RF_ADAPTER]->saveState();
5363
-		else
5364
-			$this->saveState();
5671
+		if(isset($this->_rf[self::RF_ADAPTER])) {
5672
+					$this->_rf[self::RF_ADAPTER]->saveState();
5673
+		} else {
5674
+					$this->saveState();
5675
+		}
5365 5676
 		$needViewState=($needViewState && !($this->_flags & self::IS_DISABLE_VIEWSTATE));
5366 5677
 		$state=array();
5367 5678
 		if($this->getHasControls())
5368 5679
 		{
5369 5680
 			foreach($this->_rf[self::RF_CONTROLS] as $control)
5370 5681
 			{
5371
-				if($control instanceof TControl)
5372
-					$state[$control->_id]=&$control->saveStateRecursive($needViewState);
5682
+				if($control instanceof TControl) {
5683
+									$state[$control->_id]=&$control->saveStateRecursive($needViewState);
5684
+				}
5373 5685
 			}
5374 5686
 		}
5375
-		if($needViewState && !empty($this->_viewState))
5376
-			$state[0]=&$this->_viewState;
5377
-		if(isset($this->_rf[self::RF_CONTROLSTATE]))
5378
-			$state[1]=&$this->_rf[self::RF_CONTROLSTATE];
5687
+		if($needViewState && !empty($this->_viewState)) {
5688
+					$state[0]=&$this->_viewState;
5689
+		}
5690
+		if(isset($this->_rf[self::RF_CONTROLSTATE])) {
5691
+					$state[1]=&$this->_rf[self::RF_CONTROLSTATE];
5692
+		}
5379 5693
 		return $state;
5380 5694
 	}
5381 5695
 	public function applyStyleSheetSkin($page)
@@ -5384,25 +5698,27 @@  discard block
 block discarded – undo
5384 5698
 		{
5385 5699
 			$page->applyControlStyleSheet($this);
5386 5700
 			$this->_flags |= self::IS_STYLESHEET_APPLIED;
5701
+		} else if($this->_flags & self::IS_STYLESHEET_APPLIED) {
5702
+					throw new TInvalidOperationException('control_stylesheet_applied',get_class($this));
5387 5703
 		}
5388
-		else if($this->_flags & self::IS_STYLESHEET_APPLIED)
5389
-			throw new TInvalidOperationException('control_stylesheet_applied',get_class($this));
5390 5704
 	}
5391 5705
 	private function clearCachedUniqueID($recursive)
5392 5706
 	{
5393 5707
 		if($recursive && $this->_uid!==null && isset($this->_rf[self::RF_CONTROLS]))
5394 5708
 		{
5395
-			foreach($this->_rf[self::RF_CONTROLS] as $control)
5396
-				if($control instanceof TControl)
5709
+			foreach($this->_rf[self::RF_CONTROLS] as $control) {
5710
+							if($control instanceof TControl)
5397 5711
 					$control->clearCachedUniqueID($recursive);
5712
+			}
5398 5713
 		}
5399 5714
 		$this->_uid=null;
5400 5715
 	}
5401 5716
 	private function generateAutomaticID()
5402 5717
 	{
5403 5718
 		$this->_flags &= ~self::IS_ID_SET;
5404
-		if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]))
5405
-			$this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]=0;
5719
+		if(!isset($this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID])) {
5720
+					$this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]=0;
5721
+		}
5406 5722
 		$id=$this->_namingContainer->_rf[self::RF_NAMED_CONTROLS_ID]++;
5407 5723
 		$this->_id=self::AUTOMATIC_ID_PREFIX . $id;
5408 5724
 		$this->_namingContainer->clearNameTable();
@@ -5419,13 +5735,15 @@  discard block
 block discarded – undo
5419 5735
 			{
5420 5736
 				if($control->_id!=='')
5421 5737
 				{
5422
-					if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id]))
5423
-						throw new TInvalidDataValueException('control_id_nonunique',get_class($control),$control->_id);
5424
-					else
5425
-						$container->_rf[self::RF_NAMED_CONTROLS][$control->_id]=$control;
5738
+					if(isset($container->_rf[self::RF_NAMED_CONTROLS][$control->_id])) {
5739
+											throw new TInvalidDataValueException('control_id_nonunique',get_class($control),$control->_id);
5740
+					} else {
5741
+											$container->_rf[self::RF_NAMED_CONTROLS][$control->_id]=$control;
5742
+					}
5743
+				}
5744
+				if(!($control instanceof INamingContainer) && $control->getHasControls()) {
5745
+									$this->fillNameTable($container,$control->_rf[self::RF_CONTROLS]);
5426 5746
 				}
5427
-				if(!($control instanceof INamingContainer) && $control->getHasControls())
5428
-					$this->fillNameTable($container,$control->_rf[self::RF_CONTROLS]);
5429 5747
 			}
5430 5748
 		}
5431 5749
 	}
@@ -5448,24 +5766,26 @@  discard block
 block discarded – undo
5448 5766
 		{
5449 5767
 			parent::insertAt($index,$item);
5450 5768
 			$this->_o->addedControl($item);
5769
+		} else if(is_string($item) || ($item instanceof IRenderable)) {
5770
+					parent::insertAt($index,$item);
5771
+		} else {
5772
+					throw new TInvalidDataTypeException('controlcollection_control_required');
5451 5773
 		}
5452
-		else if(is_string($item) || ($item instanceof IRenderable))
5453
-			parent::insertAt($index,$item);
5454
-		else
5455
-			throw new TInvalidDataTypeException('controlcollection_control_required');
5456 5774
 	}
5457 5775
 	public function removeAt($index)
5458 5776
 	{
5459 5777
 		$item=parent::removeAt($index);
5460
-		if($item instanceof TControl)
5461
-			$this->_o->removedControl($item);
5778
+		if($item instanceof TControl) {
5779
+					$this->_o->removedControl($item);
5780
+		}
5462 5781
 		return $item;
5463 5782
 	}
5464 5783
 	public function clear()
5465 5784
 	{
5466 5785
 		parent::clear();
5467
-		if($this->_o instanceof INamingContainer)
5468
-			$this->_o->clearNamingContainer();
5786
+		if($this->_o instanceof INamingContainer) {
5787
+					$this->_o->clearNamingContainer();
5788
+		}
5469 5789
 	}
5470 5790
 }
5471 5791
 class TEmptyControlCollection extends TControlCollection
@@ -5476,7 +5796,10 @@  discard block
 block discarded – undo
5476 5796
 	}
5477 5797
 	public function insertAt($index,$item)
5478 5798
 	{
5479
-		if(!is_string($item))  			parent::insertAt($index,$item);  	}
5799
+		if(!is_string($item)) {
5800
+			parent::insertAt($index,$item);
5801
+		}
5802
+		}
5480 5803
 }
5481 5804
 interface INamingContainer
5482 5805
 {
@@ -5602,16 +5925,17 @@  discard block
 block discarded – undo
5602 5925
 		{
5603 5926
 			if(is_array($item))
5604 5927
 			{
5605
-				if($item[0]===self::TYPE_EXPRESSION)
5606
-					$this->_expressions[$id]=$item[1];
5607
-				else if($item[0]===self::TYPE_STATEMENTS)
5608
-					$this->_statements[$id]=$item[1];
5609
-				else if($item[0]===self::TYPE_DATABINDING)
5610
-					$this->_bindings[$id]=$item[1];
5928
+				if($item[0]===self::TYPE_EXPRESSION) {
5929
+									$this->_expressions[$id]=$item[1];
5930
+				} else if($item[0]===self::TYPE_STATEMENTS) {
5931
+									$this->_statements[$id]=$item[1];
5932
+				} else if($item[0]===self::TYPE_DATABINDING) {
5933
+									$this->_bindings[$id]=$item[1];
5934
+				}
5611 5935
 				$this->_items[$id]='';
5936
+			} else {
5937
+							$this->_items[$id]=$item;
5612 5938
 			}
5613
-			else
5614
-				$this->_items[$id]=$item;
5615 5939
 		}
5616 5940
 	}
5617 5941
 	public function getContainer()
@@ -5625,16 +5949,19 @@  discard block
 block discarded – undo
5625 5949
 	public function evaluateDynamicContent()
5626 5950
 	{
5627 5951
 		$context=$this->_container===null?$this:$this->_container;
5628
-		foreach($this->_expressions as $id=>$expression)
5629
-			$this->_items[$id]=$context->evaluateExpression($expression);
5630
-		foreach($this->_statements as $id=>$statement)
5631
-			$this->_items[$id]=$context->evaluateStatements($statement);
5952
+		foreach($this->_expressions as $id=>$expression) {
5953
+					$this->_items[$id]=$context->evaluateExpression($expression);
5954
+		}
5955
+		foreach($this->_statements as $id=>$statement) {
5956
+					$this->_items[$id]=$context->evaluateStatements($statement);
5957
+		}
5632 5958
 	}
5633 5959
 	public function dataBind()
5634 5960
 	{
5635 5961
 		$context=$this->_container===null?$this:$this->_container;
5636
-		foreach($this->_bindings as $id=>$binding)
5637
-			$this->_items[$id]=$context->evaluateExpression($binding);
5962
+		foreach($this->_bindings as $id=>$binding) {
5963
+					$this->_items[$id]=$context->evaluateExpression($binding);
5964
+		}
5638 5965
 	}
5639 5966
 	public function render($writer)
5640 5967
 	{
@@ -5665,10 +5992,11 @@  discard block
 block discarded – undo
5665 5992
 	public function setBold($value)
5666 5993
 	{
5667 5994
 		$this->_flags |= self::IS_SET_BOLD;
5668
-		if(TPropertyValue::ensureBoolean($value))
5669
-			$this->_flags |= self::IS_BOLD;
5670
-		else
5671
-			$this->_flags &= ~self::IS_BOLD;
5995
+		if(TPropertyValue::ensureBoolean($value)) {
5996
+					$this->_flags |= self::IS_BOLD;
5997
+		} else {
5998
+					$this->_flags &= ~self::IS_BOLD;
5999
+		}
5672 6000
 	}
5673 6001
 	public function getItalic()
5674 6002
 	{
@@ -5677,10 +6005,11 @@  discard block
 block discarded – undo
5677 6005
 	public function setItalic($value)
5678 6006
 	{
5679 6007
 		$this->_flags |= self::IS_SET_ITALIC;
5680
-		if(TPropertyValue::ensureBoolean($value))
5681
-			$this->_flags |= self::IS_ITALIC;
5682
-		else
5683
-			$this->_flags &= ~self::IS_ITALIC;
6008
+		if(TPropertyValue::ensureBoolean($value)) {
6009
+					$this->_flags |= self::IS_ITALIC;
6010
+		} else {
6011
+					$this->_flags &= ~self::IS_ITALIC;
6012
+		}
5684 6013
 	}
5685 6014
 	public function getOverline()
5686 6015
 	{
@@ -5689,10 +6018,11 @@  discard block
 block discarded – undo
5689 6018
 	public function setOverline($value)
5690 6019
 	{
5691 6020
 		$this->_flags |= self::IS_SET_OVERLINE;
5692
-		if(TPropertyValue::ensureBoolean($value))
5693
-			$this->_flags |= self::IS_OVERLINE;
5694
-		else
5695
-			$this->_flags &= ~self::IS_OVERLINE;
6021
+		if(TPropertyValue::ensureBoolean($value)) {
6022
+					$this->_flags |= self::IS_OVERLINE;
6023
+		} else {
6024
+					$this->_flags &= ~self::IS_OVERLINE;
6025
+		}
5696 6026
 	}
5697 6027
 	public function getSize()
5698 6028
 	{
@@ -5710,10 +6040,11 @@  discard block
 block discarded – undo
5710 6040
 	public function setStrikeout($value)
5711 6041
 	{
5712 6042
 		$this->_flags |= self::IS_SET_STRIKEOUT;
5713
-		if(TPropertyValue::ensureBoolean($value))
5714
-			$this->_flags |= self::IS_STRIKEOUT;
5715
-		else
5716
-			$this->_flags &= ~self::IS_STRIKEOUT;
6043
+		if(TPropertyValue::ensureBoolean($value)) {
6044
+					$this->_flags |= self::IS_STRIKEOUT;
6045
+		} else {
6046
+					$this->_flags &= ~self::IS_STRIKEOUT;
6047
+		}
5717 6048
 	}
5718 6049
 	public function getUnderline()
5719 6050
 	{
@@ -5722,10 +6053,11 @@  discard block
 block discarded – undo
5722 6053
 	public function setUnderline($value)
5723 6054
 	{
5724 6055
 		$this->_flags |= self::IS_SET_UNDERLINE;
5725
-		if(TPropertyValue::ensureBoolean($value))
5726
-			$this->_flags |= self::IS_UNDERLINE;
5727
-		else
5728
-			$this->_flags &= ~self::IS_UNDERLINE;
6056
+		if(TPropertyValue::ensureBoolean($value)) {
6057
+					$this->_flags |= self::IS_UNDERLINE;
6058
+		} else {
6059
+					$this->_flags &= ~self::IS_UNDERLINE;
6060
+		}
5729 6061
 	}
5730 6062
 	public function getName()
5731 6063
 	{
@@ -5748,89 +6080,123 @@  discard block
 block discarded – undo
5748 6080
 	}
5749 6081
 	public function mergeWith($font)
5750 6082
 	{
5751
-		if($font===null || $font->_flags===0)
5752
-			return;
5753
-		if(!($this->_flags & self::IS_SET_BOLD) && ($font->_flags & self::IS_SET_BOLD))
5754
-			$this->setBold($font->getBold());
5755
-		if(!($this->_flags & self::IS_SET_ITALIC) && ($font->_flags & self::IS_SET_ITALIC))
5756
-			$this->setItalic($font->getItalic());
5757
-		if(!($this->_flags & self::IS_SET_OVERLINE) && ($font->_flags & self::IS_SET_OVERLINE))
5758
-			$this->setOverline($font->getOverline());
5759
-		if(!($this->_flags & self::IS_SET_STRIKEOUT) && ($font->_flags & self::IS_SET_STRIKEOUT))
5760
-			$this->setStrikeout($font->getStrikeout());
5761
-		if(!($this->_flags & self::IS_SET_UNDERLINE) && ($font->_flags & self::IS_SET_UNDERLINE))
5762
-			$this->setUnderline($font->getUnderline());
5763
-		if(!($this->_flags & self::IS_SET_SIZE) && ($font->_flags & self::IS_SET_SIZE))
5764
-			$this->setSize($font->getSize());
5765
-		if(!($this->_flags & self::IS_SET_NAME) && ($font->_flags & self::IS_SET_NAME))
5766
-			$this->setName($font->getName());
6083
+		if($font===null || $font->_flags===0) {
6084
+					return;
6085
+		}
6086
+		if(!($this->_flags & self::IS_SET_BOLD) && ($font->_flags & self::IS_SET_BOLD)) {
6087
+					$this->setBold($font->getBold());
6088
+		}
6089
+		if(!($this->_flags & self::IS_SET_ITALIC) && ($font->_flags & self::IS_SET_ITALIC)) {
6090
+					$this->setItalic($font->getItalic());
6091
+		}
6092
+		if(!($this->_flags & self::IS_SET_OVERLINE) && ($font->_flags & self::IS_SET_OVERLINE)) {
6093
+					$this->setOverline($font->getOverline());
6094
+		}
6095
+		if(!($this->_flags & self::IS_SET_STRIKEOUT) && ($font->_flags & self::IS_SET_STRIKEOUT)) {
6096
+					$this->setStrikeout($font->getStrikeout());
6097
+		}
6098
+		if(!($this->_flags & self::IS_SET_UNDERLINE) && ($font->_flags & self::IS_SET_UNDERLINE)) {
6099
+					$this->setUnderline($font->getUnderline());
6100
+		}
6101
+		if(!($this->_flags & self::IS_SET_SIZE) && ($font->_flags & self::IS_SET_SIZE)) {
6102
+					$this->setSize($font->getSize());
6103
+		}
6104
+		if(!($this->_flags & self::IS_SET_NAME) && ($font->_flags & self::IS_SET_NAME)) {
6105
+					$this->setName($font->getName());
6106
+		}
5767 6107
 	}
5768 6108
 	public function copyFrom($font)
5769 6109
 	{
5770
-		if($font===null || $font->_flags===0)
5771
-			return;
5772
-		if($font->_flags & self::IS_SET_BOLD)
5773
-			$this->setBold($font->getBold());
5774
-		if($font->_flags & self::IS_SET_ITALIC)
5775
-			$this->setItalic($font->getItalic());
5776
-		if($font->_flags & self::IS_SET_OVERLINE)
5777
-			$this->setOverline($font->getOverline());
5778
-		if($font->_flags & self::IS_SET_STRIKEOUT)
5779
-			$this->setStrikeout($font->getStrikeout());
5780
-		if($font->_flags & self::IS_SET_UNDERLINE)
5781
-			$this->setUnderline($font->getUnderline());
5782
-		if($font->_flags & self::IS_SET_SIZE)
5783
-			$this->setSize($font->getSize());
5784
-		if($font->_flags & self::IS_SET_NAME)
5785
-			$this->setName($font->getName());
6110
+		if($font===null || $font->_flags===0) {
6111
+					return;
6112
+		}
6113
+		if($font->_flags & self::IS_SET_BOLD) {
6114
+					$this->setBold($font->getBold());
6115
+		}
6116
+		if($font->_flags & self::IS_SET_ITALIC) {
6117
+					$this->setItalic($font->getItalic());
6118
+		}
6119
+		if($font->_flags & self::IS_SET_OVERLINE) {
6120
+					$this->setOverline($font->getOverline());
6121
+		}
6122
+		if($font->_flags & self::IS_SET_STRIKEOUT) {
6123
+					$this->setStrikeout($font->getStrikeout());
6124
+		}
6125
+		if($font->_flags & self::IS_SET_UNDERLINE) {
6126
+					$this->setUnderline($font->getUnderline());
6127
+		}
6128
+		if($font->_flags & self::IS_SET_SIZE) {
6129
+					$this->setSize($font->getSize());
6130
+		}
6131
+		if($font->_flags & self::IS_SET_NAME) {
6132
+					$this->setName($font->getName());
6133
+		}
5786 6134
 	}
5787 6135
 	public function toString()
5788 6136
 	{
5789
-		if($this->_flags===0)
5790
-			return '';
6137
+		if($this->_flags===0) {
6138
+					return '';
6139
+		}
5791 6140
 		$str='';
5792
-		if($this->_flags & self::IS_SET_BOLD)
5793
-			$str.='font-weight:'.(($this->_flags & self::IS_BOLD)?'bold;':'normal;');
5794
-		if($this->_flags & self::IS_SET_ITALIC)
5795
-			$str.='font-style:'.(($this->_flags & self::IS_ITALIC)?'italic;':'normal;');
6141
+		if($this->_flags & self::IS_SET_BOLD) {
6142
+					$str.='font-weight:'.(($this->_flags & self::IS_BOLD)?'bold;':'normal;');
6143
+		}
6144
+		if($this->_flags & self::IS_SET_ITALIC) {
6145
+					$str.='font-style:'.(($this->_flags & self::IS_ITALIC)?'italic;':'normal;');
6146
+		}
5796 6147
 		$textDec='';
5797
-		if($this->_flags & self::IS_UNDERLINE)
5798
-			$textDec.='underline';
5799
-		if($this->_flags & self::IS_OVERLINE)
5800
-			$textDec.=' overline';
5801
-		if($this->_flags & self::IS_STRIKEOUT)
5802
-			$textDec.=' line-through';
6148
+		if($this->_flags & self::IS_UNDERLINE) {
6149
+					$textDec.='underline';
6150
+		}
6151
+		if($this->_flags & self::IS_OVERLINE) {
6152
+					$textDec.=' overline';
6153
+		}
6154
+		if($this->_flags & self::IS_STRIKEOUT) {
6155
+					$textDec.=' line-through';
6156
+		}
5803 6157
 		$textDec=ltrim($textDec);
5804
-		if($textDec!=='')
5805
-			$str.='text-decoration:'.$textDec.';';
5806
-		if($this->_size!=='')
5807
-			$str.='font-size:'.$this->_size.';';
5808
-		if($this->_name!=='')
5809
-			$str.='font-family:'.$this->_name.';';
6158
+		if($textDec!=='') {
6159
+					$str.='text-decoration:'.$textDec.';';
6160
+		}
6161
+		if($this->_size!=='') {
6162
+					$str.='font-size:'.$this->_size.';';
6163
+		}
6164
+		if($this->_name!=='') {
6165
+					$str.='font-family:'.$this->_name.';';
6166
+		}
5810 6167
 		return $str;
5811 6168
 	}
5812 6169
 	public function addAttributesToRender($writer)
5813 6170
 	{
5814
-		if($this->_flags===0)
5815
-			return;
5816
-		if($this->_flags & self::IS_SET_BOLD)
5817
-			$writer->addStyleAttribute('font-weight',(($this->_flags & self::IS_BOLD)?'bold':'normal'));
5818
-		if($this->_flags & self::IS_SET_ITALIC)
5819
-			$writer->addStyleAttribute('font-style',(($this->_flags & self::IS_ITALIC)?'italic':'normal'));
6171
+		if($this->_flags===0) {
6172
+					return;
6173
+		}
6174
+		if($this->_flags & self::IS_SET_BOLD) {
6175
+					$writer->addStyleAttribute('font-weight',(($this->_flags & self::IS_BOLD)?'bold':'normal'));
6176
+		}
6177
+		if($this->_flags & self::IS_SET_ITALIC) {
6178
+					$writer->addStyleAttribute('font-style',(($this->_flags & self::IS_ITALIC)?'italic':'normal'));
6179
+		}
5820 6180
 		$textDec='';
5821
-		if($this->_flags & self::IS_UNDERLINE)
5822
-			$textDec.='underline';
5823
-		if($this->_flags & self::IS_OVERLINE)
5824
-			$textDec.=' overline';
5825
-		if($this->_flags & self::IS_STRIKEOUT)
5826
-			$textDec.=' line-through';
6181
+		if($this->_flags & self::IS_UNDERLINE) {
6182
+					$textDec.='underline';
6183
+		}
6184
+		if($this->_flags & self::IS_OVERLINE) {
6185
+					$textDec.=' overline';
6186
+		}
6187
+		if($this->_flags & self::IS_STRIKEOUT) {
6188
+					$textDec.=' line-through';
6189
+		}
5827 6190
 		$textDec=ltrim($textDec);
5828
-		if($textDec!=='')
5829
-			$writer->addStyleAttribute('text-decoration',$textDec);
5830
-		if($this->_size!=='')
5831
-			$writer->addStyleAttribute('font-size',$this->_size);
5832
-		if($this->_name!=='')
5833
-			$writer->addStyleAttribute('font-family',$this->_name);
6191
+		if($textDec!=='') {
6192
+					$writer->addStyleAttribute('text-decoration',$textDec);
6193
+		}
6194
+		if($this->_size!=='') {
6195
+					$writer->addStyleAttribute('font-size',$this->_size);
6196
+		}
6197
+		if($this->_name!=='') {
6198
+					$writer->addStyleAttribute('font-family',$this->_name);
6199
+		}
5834 6200
 	}
5835 6201
 }
5836 6202
 class TStyle extends TComponent
@@ -5842,13 +6208,15 @@  discard block
 block discarded – undo
5842 6208
 	private $_displayStyle='Fixed';
5843 6209
 	public function __construct($style=null)
5844 6210
 	{
5845
-		if($style!==null)
5846
-			$this->copyFrom($style);
6211
+		if($style!==null) {
6212
+					$this->copyFrom($style);
6213
+		}
5847 6214
 	}
5848 6215
 	public function __clone()
5849 6216
 	{
5850
-		if($this->_font!==null)
5851
-			$this->_font = clone($this->_font);
6217
+		if($this->_font!==null) {
6218
+					$this->_font = clone($this->_font);
6219
+		}
5852 6220
 	}
5853 6221
 	public function getBackColor()
5854 6222
 	{
@@ -5856,10 +6224,11 @@  discard block
 block discarded – undo
5856 6224
 	}
5857 6225
 	public function setBackColor($value)
5858 6226
 	{
5859
-		if(trim($value)==='')
5860
-			unset($this->_fields['background-color']);
5861
-		else
5862
-			$this->_fields['background-color']=$value;
6227
+		if(trim($value)==='') {
6228
+					unset($this->_fields['background-color']);
6229
+		} else {
6230
+					$this->_fields['background-color']=$value;
6231
+		}
5863 6232
 	}
5864 6233
 	public function getBorderColor()
5865 6234
 	{
@@ -5867,10 +6236,11 @@  discard block
 block discarded – undo
5867 6236
 	}
5868 6237
 	public function setBorderColor($value)
5869 6238
 	{
5870
-		if(trim($value)==='')
5871
-			unset($this->_fields['border-color']);
5872
-		else
5873
-			$this->_fields['border-color']=$value;
6239
+		if(trim($value)==='') {
6240
+					unset($this->_fields['border-color']);
6241
+		} else {
6242
+					$this->_fields['border-color']=$value;
6243
+		}
5874 6244
 	}
5875 6245
 	public function getBorderStyle()
5876 6246
 	{
@@ -5878,10 +6248,11 @@  discard block
 block discarded – undo
5878 6248
 	}
5879 6249
 	public function setBorderStyle($value)
5880 6250
 	{
5881
-		if(trim($value)==='')
5882
-			unset($this->_fields['border-style']);
5883
-		else
5884
-			$this->_fields['border-style']=$value;
6251
+		if(trim($value)==='') {
6252
+					unset($this->_fields['border-style']);
6253
+		} else {
6254
+					$this->_fields['border-style']=$value;
6255
+		}
5885 6256
 	}
5886 6257
 	public function getBorderWidth()
5887 6258
 	{
@@ -5889,10 +6260,11 @@  discard block
 block discarded – undo
5889 6260
 	}
5890 6261
 	public function setBorderWidth($value)
5891 6262
 	{
5892
-		if(trim($value)==='')
5893
-			unset($this->_fields['border-width']);
5894
-		else
5895
-			$this->_fields['border-width']=$value;
6263
+		if(trim($value)==='') {
6264
+					unset($this->_fields['border-width']);
6265
+		} else {
6266
+					$this->_fields['border-width']=$value;
6267
+		}
5896 6268
 	}
5897 6269
 	public function getCssClass()
5898 6270
 	{
@@ -5908,8 +6280,9 @@  discard block
 block discarded – undo
5908 6280
 	}
5909 6281
 	public function getFont()
5910 6282
 	{
5911
-		if($this->_font===null)
5912
-			$this->_font=new TFont;
6283
+		if($this->_font===null) {
6284
+					$this->_font=new TFont;
6285
+		}
5913 6286
 		return $this->_font;
5914 6287
 	}
5915 6288
 	public function hasFont()
@@ -5944,10 +6317,11 @@  discard block
 block discarded – undo
5944 6317
 	}
5945 6318
 	public function setForeColor($value)
5946 6319
 	{
5947
-		if(trim($value)==='')
5948
-			unset($this->_fields['color']);
5949
-		else
5950
-			$this->_fields['color']=$value;
6320
+		if(trim($value)==='') {
6321
+					unset($this->_fields['color']);
6322
+		} else {
6323
+					$this->_fields['color']=$value;
6324
+		}
5951 6325
 	}
5952 6326
 	public function getHeight()
5953 6327
 	{
@@ -5955,10 +6329,11 @@  discard block
 block discarded – undo
5955 6329
 	}
5956 6330
 	public function setHeight($value)
5957 6331
 	{
5958
-		if(trim($value)==='')
5959
-			unset($this->_fields['height']);
5960
-		else
5961
-			$this->_fields['height']=$value;
6332
+		if(trim($value)==='') {
6333
+					unset($this->_fields['height']);
6334
+		} else {
6335
+					$this->_fields['height']=$value;
6336
+		}
5962 6337
 	}
5963 6338
 	public function getCustomStyle()
5964 6339
 	{
@@ -6004,12 +6379,15 @@  discard block
 block discarded – undo
6004 6379
 		if($style instanceof TStyle)
6005 6380
 		{
6006 6381
 			$this->_fields=array_merge($this->_fields,$style->_fields);
6007
-			if($style->_class!==null)
6008
-				$this->_class=$style->_class;
6009
-			if($style->_customStyle!==null)
6010
-				$this->_customStyle=$style->_customStyle;
6011
-			if($style->_font!==null)
6012
-				$this->getFont()->copyFrom($style->_font);
6382
+			if($style->_class!==null) {
6383
+							$this->_class=$style->_class;
6384
+			}
6385
+			if($style->_customStyle!==null) {
6386
+							$this->_customStyle=$style->_customStyle;
6387
+			}
6388
+			if($style->_font!==null) {
6389
+							$this->getFont()->copyFrom($style->_font);
6390
+			}
6013 6391
 		}
6014 6392
 	}
6015 6393
 	public function mergeWith($style)
@@ -6017,12 +6395,15 @@  discard block
 block discarded – undo
6017 6395
 		if($style instanceof TStyle)
6018 6396
 		{
6019 6397
 			$this->_fields=array_merge($style->_fields,$this->_fields);
6020
-			if($this->_class===null)
6021
-				$this->_class=$style->_class;
6022
-			if($this->_customStyle===null)
6023
-				$this->_customStyle=$style->_customStyle;
6024
-			if($style->_font!==null)
6025
-				$this->getFont()->mergeWith($style->_font);
6398
+			if($this->_class===null) {
6399
+							$this->_class=$style->_class;
6400
+			}
6401
+			if($this->_customStyle===null) {
6402
+							$this->_customStyle=$style->_customStyle;
6403
+			}
6404
+			if($style->_font!==null) {
6405
+							$this->getFont()->mergeWith($style->_font);
6406
+			}
6026 6407
 		}
6027 6408
 	}
6028 6409
 	public function addAttributesToRender($writer)
@@ -6032,15 +6413,18 @@  discard block
 block discarded – undo
6032 6413
 			foreach(explode(';',$this->_customStyle) as $style)
6033 6414
 			{
6034 6415
 				$arr=explode(':',$style,2);
6035
-				if(isset($arr[1]) && trim($arr[0])!=='')
6036
-					$writer->addStyleAttribute(trim($arr[0]),trim($arr[1]));
6416
+				if(isset($arr[1]) && trim($arr[0])!=='') {
6417
+									$writer->addStyleAttribute(trim($arr[0]),trim($arr[1]));
6418
+				}
6037 6419
 			}
6038 6420
 		}
6039 6421
 		$writer->addStyleAttributes($this->_fields);
6040
-		if($this->_font!==null)
6041
-			$this->_font->addAttributesToRender($writer);
6042
-		if($this->_class!==null)
6043
-			$writer->addAttribute('class',$this->_class);
6422
+		if($this->_font!==null) {
6423
+					$this->_font->addAttributesToRender($writer);
6424
+		}
6425
+		if($this->_class!==null) {
6426
+					$writer->addAttribute('class',$this->_class);
6427
+		}
6044 6428
 	}
6045 6429
 	public function getStyleFields()
6046 6430
 	{
@@ -6076,18 +6460,24 @@  discard block
 block discarded – undo
6076 6460
 		parent::copyFrom($style);
6077 6461
 		if($style instanceof TTableStyle)
6078 6462
 		{
6079
-			if($style->_backImageUrl!==null)
6080
-				$this->_backImageUrl=$style->_backImageUrl;
6081
-			if($style->_horizontalAlign!==null)
6082
-				$this->_horizontalAlign=$style->_horizontalAlign;
6083
-			if($style->_cellPadding!==null)
6084
-				$this->_cellPadding=$style->_cellPadding;
6085
-			if($style->_cellSpacing!==null)
6086
-				$this->_cellSpacing=$style->_cellSpacing;
6087
-			if($style->_gridLines!==null)
6088
-				$this->_gridLines=$style->_gridLines;
6089
-			if($style->_borderCollapse!==null)
6090
-				$this->_borderCollapse=$style->_borderCollapse;
6463
+			if($style->_backImageUrl!==null) {
6464
+							$this->_backImageUrl=$style->_backImageUrl;
6465
+			}
6466
+			if($style->_horizontalAlign!==null) {
6467
+							$this->_horizontalAlign=$style->_horizontalAlign;
6468
+			}
6469
+			if($style->_cellPadding!==null) {
6470
+							$this->_cellPadding=$style->_cellPadding;
6471
+			}
6472
+			if($style->_cellSpacing!==null) {
6473
+							$this->_cellSpacing=$style->_cellSpacing;
6474
+			}
6475
+			if($style->_gridLines!==null) {
6476
+							$this->_gridLines=$style->_gridLines;
6477
+			}
6478
+			if($style->_borderCollapse!==null) {
6479
+							$this->_borderCollapse=$style->_borderCollapse;
6480
+			}
6091 6481
 		}
6092 6482
 	}
6093 6483
 	public function mergeWith($style)
@@ -6095,32 +6485,43 @@  discard block
 block discarded – undo
6095 6485
 		parent::mergeWith($style);
6096 6486
 		if($style instanceof TTableStyle)
6097 6487
 		{
6098
-			if($this->_backImageUrl===null && $style->_backImageUrl!==null)
6099
-				$this->_backImageUrl=$style->_backImageUrl;
6100
-			if($this->_horizontalAlign===null && $style->_horizontalAlign!==null)
6101
-				$this->_horizontalAlign=$style->_horizontalAlign;
6102
-			if($this->_cellPadding===null && $style->_cellPadding!==null)
6103
-				$this->_cellPadding=$style->_cellPadding;
6104
-			if($this->_cellSpacing===null && $style->_cellSpacing!==null)
6105
-				$this->_cellSpacing=$style->_cellSpacing;
6106
-			if($this->_gridLines===null && $style->_gridLines!==null)
6107
-				$this->_gridLines=$style->_gridLines;
6108
-			if($this->_borderCollapse===null && $style->_borderCollapse!==null)
6109
-				$this->_borderCollapse=$style->_borderCollapse;
6488
+			if($this->_backImageUrl===null && $style->_backImageUrl!==null) {
6489
+							$this->_backImageUrl=$style->_backImageUrl;
6490
+			}
6491
+			if($this->_horizontalAlign===null && $style->_horizontalAlign!==null) {
6492
+							$this->_horizontalAlign=$style->_horizontalAlign;
6493
+			}
6494
+			if($this->_cellPadding===null && $style->_cellPadding!==null) {
6495
+							$this->_cellPadding=$style->_cellPadding;
6496
+			}
6497
+			if($this->_cellSpacing===null && $style->_cellSpacing!==null) {
6498
+							$this->_cellSpacing=$style->_cellSpacing;
6499
+			}
6500
+			if($this->_gridLines===null && $style->_gridLines!==null) {
6501
+							$this->_gridLines=$style->_gridLines;
6502
+			}
6503
+			if($this->_borderCollapse===null && $style->_borderCollapse!==null) {
6504
+							$this->_borderCollapse=$style->_borderCollapse;
6505
+			}
6110 6506
 		}
6111 6507
 	}
6112 6508
 	public function addAttributesToRender($writer)
6113 6509
 	{
6114
-		if(($url=trim($this->getBackImageUrl()))!=='')
6115
-			$writer->addStyleAttribute('background-image','url('.$url.')');
6116
-		if(($horizontalAlign=$this->getHorizontalAlign())!==THorizontalAlign::NotSet)
6117
-			$writer->addStyleAttribute('text-align',strtolower($horizontalAlign));
6118
-		if(($cellPadding=$this->getCellPadding())>=0)
6119
-			$writer->addAttribute('cellpadding',"$cellPadding");
6120
-		if(($cellSpacing=$this->getCellSpacing())>=0)
6121
-			$writer->addAttribute('cellspacing',"$cellSpacing");
6122
-		if($this->getBorderCollapse())
6123
-			$writer->addStyleAttribute('border-collapse','collapse');
6510
+		if(($url=trim($this->getBackImageUrl()))!=='') {
6511
+					$writer->addStyleAttribute('background-image','url('.$url.')');
6512
+		}
6513
+		if(($horizontalAlign=$this->getHorizontalAlign())!==THorizontalAlign::NotSet) {
6514
+					$writer->addStyleAttribute('text-align',strtolower($horizontalAlign));
6515
+		}
6516
+		if(($cellPadding=$this->getCellPadding())>=0) {
6517
+					$writer->addAttribute('cellpadding',"$cellPadding");
6518
+		}
6519
+		if(($cellSpacing=$this->getCellSpacing())>=0) {
6520
+					$writer->addAttribute('cellspacing',"$cellSpacing");
6521
+		}
6522
+		if($this->getBorderCollapse()) {
6523
+					$writer->addStyleAttribute('border-collapse','collapse');
6524
+		}
6124 6525
 		switch($this->getGridLines())
6125 6526
 		{
6126 6527
 			case TTableGridLines::Horizontal : $writer->addAttribute('rules','rows'); break;
@@ -6151,8 +6552,9 @@  discard block
 block discarded – undo
6151 6552
 	}
6152 6553
 	public function setCellPadding($value)
6153 6554
 	{
6154
-		if(($this->_cellPadding=TPropertyValue::ensureInteger($value))<-1)
6155
-			throw new TInvalidDataValueException('tablestyle_cellpadding_invalid');
6555
+		if(($this->_cellPadding=TPropertyValue::ensureInteger($value))<-1) {
6556
+					throw new TInvalidDataValueException('tablestyle_cellpadding_invalid');
6557
+		}
6156 6558
 	}
6157 6559
 	public function getCellSpacing()
6158 6560
 	{
@@ -6160,8 +6562,9 @@  discard block
 block discarded – undo
6160 6562
 	}
6161 6563
 	public function setCellSpacing($value)
6162 6564
 	{
6163
-		if(($this->_cellSpacing=TPropertyValue::ensureInteger($value))<-1)
6164
-			throw new TInvalidDataValueException('tablestyle_cellspacing_invalid');
6565
+		if(($this->_cellSpacing=TPropertyValue::ensureInteger($value))<-1) {
6566
+					throw new TInvalidDataValueException('tablestyle_cellspacing_invalid');
6567
+		}
6165 6568
 	}
6166 6569
 	public function getGridLines()
6167 6570
 	{
@@ -6197,12 +6600,15 @@  discard block
 block discarded – undo
6197 6600
 		parent::copyFrom($style);
6198 6601
 		if($style instanceof TTableItemStyle)
6199 6602
 		{
6200
-			if($this->_verticalAlign===null && $style->_verticalAlign!==null)
6201
-				$this->_verticalAlign=$style->_verticalAlign;
6202
-			if($this->_horizontalAlign===null && $style->_horizontalAlign!==null)
6203
-				$this->_horizontalAlign=$style->_horizontalAlign;
6204
-			if($this->_wrap===null && $style->_wrap!==null)
6205
-				$this->_wrap=$style->_wrap;
6603
+			if($this->_verticalAlign===null && $style->_verticalAlign!==null) {
6604
+							$this->_verticalAlign=$style->_verticalAlign;
6605
+			}
6606
+			if($this->_horizontalAlign===null && $style->_horizontalAlign!==null) {
6607
+							$this->_horizontalAlign=$style->_horizontalAlign;
6608
+			}
6609
+			if($this->_wrap===null && $style->_wrap!==null) {
6610
+							$this->_wrap=$style->_wrap;
6611
+			}
6206 6612
 		}
6207 6613
 	}
6208 6614
 	public function mergeWith($style)
@@ -6210,22 +6616,28 @@  discard block
 block discarded – undo
6210 6616
 		parent::mergeWith($style);
6211 6617
 		if($style instanceof TTableItemStyle)
6212 6618
 		{
6213
-			if($style->_verticalAlign!==null)
6214
-				$this->_verticalAlign=$style->_verticalAlign;
6215
-			if($style->_horizontalAlign!==null)
6216
-				$this->_horizontalAlign=$style->_horizontalAlign;
6217
-			if($style->_wrap!==null)
6218
-				$this->_wrap=$style->_wrap;
6619
+			if($style->_verticalAlign!==null) {
6620
+							$this->_verticalAlign=$style->_verticalAlign;
6621
+			}
6622
+			if($style->_horizontalAlign!==null) {
6623
+							$this->_horizontalAlign=$style->_horizontalAlign;
6624
+			}
6625
+			if($style->_wrap!==null) {
6626
+							$this->_wrap=$style->_wrap;
6627
+			}
6219 6628
 		}
6220 6629
 	}
6221 6630
 	public function addAttributesToRender($writer)
6222 6631
 	{
6223
-		if(!$this->getWrap())
6224
-			$writer->addStyleAttribute('white-space','nowrap');
6225
-		if(($horizontalAlign=$this->getHorizontalAlign())!==THorizontalAlign::NotSet)
6226
-			$writer->addAttribute('align',strtolower($horizontalAlign));
6227
-		if(($verticalAlign=$this->getVerticalAlign())!==TVerticalAlign::NotSet)
6228
-			$writer->addAttribute('valign',strtolower($verticalAlign));
6632
+		if(!$this->getWrap()) {
6633
+					$writer->addStyleAttribute('white-space','nowrap');
6634
+		}
6635
+		if(($horizontalAlign=$this->getHorizontalAlign())!==THorizontalAlign::NotSet) {
6636
+					$writer->addAttribute('align',strtolower($horizontalAlign));
6637
+		}
6638
+		if(($verticalAlign=$this->getVerticalAlign())!==TVerticalAlign::NotSet) {
6639
+					$writer->addAttribute('valign',strtolower($verticalAlign));
6640
+		}
6229 6641
 		parent::addAttributesToRender($writer);
6230 6642
 	}
6231 6643
 	public function getHorizontalAlign()
@@ -6326,75 +6738,86 @@  discard block
 block discarded – undo
6326 6738
 		return $this->_pretagtext;
6327 6739
 	}
6328 6740
 	public function setPreTagText($value) {
6329
-		if(!$this->_internalonly && !$this->_control->getIsSkinApplied())
6330
-			$this->_pretagtext = TPropertyValue::ensureString($value);
6741
+		if(!$this->_internalonly && !$this->_control->getIsSkinApplied()) {
6742
+					$this->_pretagtext = TPropertyValue::ensureString($value);
6743
+		}
6331 6744
 	}
6332 6745
 	public function getPreContentsText() {
6333 6746
 		return $this->_precontentstext;
6334 6747
 	}
6335 6748
 	public function setPreContentsText($value) {
6336
-		if(!$this->_control->getIsSkinApplied())
6337
-			$this->_precontentstext = TPropertyValue::ensureString($value);
6749
+		if(!$this->_control->getIsSkinApplied()) {
6750
+					$this->_precontentstext = TPropertyValue::ensureString($value);
6751
+		}
6338 6752
 	}
6339 6753
 	public function getPostContentsText() {
6340 6754
 		return $this->_postcontentstext;
6341 6755
 	}
6342 6756
 	public function setPostContentsText($value) {
6343
-		if(!$this->_control->getIsSkinApplied())
6344
-			$this->_postcontentstext = TPropertyValue::ensureString($value);
6757
+		if(!$this->_control->getIsSkinApplied()) {
6758
+					$this->_postcontentstext = TPropertyValue::ensureString($value);
6759
+		}
6345 6760
 	}
6346 6761
 	public function getPostTagText() {
6347 6762
 		return $this->_posttagtext;
6348 6763
 	}
6349 6764
 	public function setPostTagText($value) {
6350
-		if(!$this->_internalonly && !$this->_control->getIsSkinApplied())
6351
-			$this->_posttagtext = TPropertyValue::ensureString($value);
6765
+		if(!$this->_internalonly && !$this->_control->getIsSkinApplied()) {
6766
+					$this->_posttagtext = TPropertyValue::ensureString($value);
6767
+		}
6352 6768
 	}
6353 6769
 	public function getPreTagTemplate() {
6354 6770
 		return $this->_pretagtemplate;
6355 6771
 	}
6356 6772
 	public function setPreTagTemplate($value) {
6357
-		if(!$this->_internalonly && !$this->_control->getIsSkinApplied())
6358
-			$this->_pretagtemplate = $value;
6773
+		if(!$this->_internalonly && !$this->_control->getIsSkinApplied()) {
6774
+					$this->_pretagtemplate = $value;
6775
+		}
6359 6776
 	}
6360 6777
 	public function getPreContentsTemplate() {
6361 6778
 		return $this->_precontentstemplate;
6362 6779
 	}
6363 6780
 	public function setPreContentsTemplate($value) {
6364
-		if(!$this->_control->getIsSkinApplied())
6365
-			$this->_precontentstemplate = $value;
6781
+		if(!$this->_control->getIsSkinApplied()) {
6782
+					$this->_precontentstemplate = $value;
6783
+		}
6366 6784
 	}
6367 6785
 	public function getPostContentsTemplate() {
6368 6786
 		return $this->_postcontentstemplate;
6369 6787
 	}
6370 6788
 	public function setPostContentsTemplate($value) {
6371
-		if(!$this->_control->getIsSkinApplied())
6372
-			$this->_postcontentstemplate = $value;
6789
+		if(!$this->_control->getIsSkinApplied()) {
6790
+					$this->_postcontentstemplate = $value;
6791
+		}
6373 6792
 	}
6374 6793
 	public function getPostTagTemplate() {
6375 6794
 		return $this->_posttagtemplate;
6376 6795
 	}
6377 6796
 	public function setPostTagTemplate($value) {
6378
-		if(!$this->_internalonly && !$this->_control->getIsSkinApplied())
6379
-			$this->_posttagtemplate = $value;
6797
+		if(!$this->_internalonly && !$this->_control->getIsSkinApplied()) {
6798
+					$this->_posttagtemplate = $value;
6799
+		}
6380 6800
 	}
6381 6801
 	public function instantiate($outercontrol = null) {
6382 6802
 		if($this->getPreTagTemplate() || $this->getPreContentsTemplate() ||
6383 6803
 			$this->getPostContentsTemplate() || $this->getPostTagTemplate()) {
6384 6804
 			$this->_outercontrol = $outercontrol;
6385
-			if($this->getUseState())
6386
-				$this->ensureTemplateDecoration();
6387
-			else
6388
-				$this->_control->getPage()->onSaveStateComplete[] = array($this, 'ensureTemplateDecoration');
6805
+			if($this->getUseState()) {
6806
+							$this->ensureTemplateDecoration();
6807
+			} else {
6808
+							$this->_control->getPage()->onSaveStateComplete[] = array($this, 'ensureTemplateDecoration');
6809
+			}
6389 6810
 		}
6390 6811
 	}
6391 6812
 	public function ensureTemplateDecoration($sender=null, $param=null) {
6392 6813
 		$control = $this->_control;
6393 6814
 		$outercontrol = $this->_outercontrol;
6394
-		if($outercontrol === null)
6395
-			$outercontrol = $control;
6396
-		if($this->_addedTemplateDecoration)
6397
-			return $this->_addedTemplateDecoration;
6815
+		if($outercontrol === null) {
6816
+					$outercontrol = $control;
6817
+		}
6818
+		if($this->_addedTemplateDecoration) {
6819
+					return $this->_addedTemplateDecoration;
6820
+		}
6398 6821
 		$this->_addedTemplateDecoration = true;
6399 6822
 		if($this->getPreContentsTemplate())
6400 6823
 		{
@@ -6408,8 +6831,9 @@  discard block
 block discarded – undo
6408 6831
 			$this->getPostContentsTemplate()->instantiateIn($postcontents);
6409 6832
 			$control->getControls()->add($postcontents);
6410 6833
 		}
6411
-		if(!$outercontrol->getParent())
6412
-			return $this->_addedTemplateDecoration;
6834
+		if(!$outercontrol->getParent()) {
6835
+					return $this->_addedTemplateDecoration;
6836
+		}
6413 6837
 		if($this->getPreTagTemplate())
6414 6838
 		{
6415 6839
 			$pretag = Prado::createComponent('TCompositeControl');
@@ -6451,8 +6875,9 @@  discard block
 block discarded – undo
6451 6875
 	}
6452 6876
 	public function getDecorator($create=true)
6453 6877
 	{
6454
-		if($create && !$this->_decorator)
6455
-			$this->_decorator = Prado::createComponent('TWebControlDecorator', $this);
6878
+		if($create && !$this->_decorator) {
6879
+					$this->_decorator = Prado::createComponent('TWebControlDecorator', $this);
6880
+		}
6456 6881
 		return $this->_decorator;
6457 6882
 	}
6458 6883
 	public function copyBaseAttributes(TWebControl $control)
@@ -6460,10 +6885,12 @@  discard block
 block discarded – undo
6460 6885
 		$this->setAccessKey($control->getAccessKey());
6461 6886
 		$this->setToolTip($control->getToolTip());
6462 6887
 		$this->setTabIndex($control->getTabIndex());
6463
-		if(!$control->getEnabled())
6464
-			$this->setEnabled(false);
6465
-		if($control->getHasAttributes())
6466
-			$this->getAttributes()->copyFrom($control->getAttributes());
6888
+		if(!$control->getEnabled()) {
6889
+					$this->setEnabled(false);
6890
+		}
6891
+		if($control->getHasAttributes()) {
6892
+					$this->getAttributes()->copyFrom($control->getAttributes());
6893
+		}
6467 6894
 	}
6468 6895
 	public function getAccessKey()
6469 6896
 	{
@@ -6471,16 +6898,18 @@  discard block
 block discarded – undo
6471 6898
 	}
6472 6899
 	public function setAccessKey($value)
6473 6900
 	{
6474
-		if(strlen($value)>1)
6475
-			throw new TInvalidDataValueException('webcontrol_accesskey_invalid',get_class($this),$value);
6901
+		if(strlen($value)>1) {
6902
+					throw new TInvalidDataValueException('webcontrol_accesskey_invalid',get_class($this),$value);
6903
+		}
6476 6904
 		$this->setViewState('AccessKey',$value,'');
6477 6905
 	}
6478 6906
 	public function getBackColor()
6479 6907
 	{
6480
-		if($style=$this->getViewState('Style',null))
6481
-			return $style->getBackColor();
6482
-		else
6483
-			return '';
6908
+		if($style=$this->getViewState('Style',null)) {
6909
+					return $style->getBackColor();
6910
+		} else {
6911
+					return '';
6912
+		}
6484 6913
 	}
6485 6914
 	public function setBackColor($value)
6486 6915
 	{
@@ -6488,10 +6917,11 @@  discard block
 block discarded – undo
6488 6917
 	}
6489 6918
 	public function getBorderColor()
6490 6919
 	{
6491
-		if($style=$this->getViewState('Style',null))
6492
-			return $style->getBorderColor();
6493
-		else
6494
-			return '';
6920
+		if($style=$this->getViewState('Style',null)) {
6921
+					return $style->getBorderColor();
6922
+		} else {
6923
+					return '';
6924
+		}
6495 6925
 	}
6496 6926
 	public function setBorderColor($value)
6497 6927
 	{
@@ -6499,10 +6929,11 @@  discard block
 block discarded – undo
6499 6929
 	}
6500 6930
 	public function getBorderStyle()
6501 6931
 	{
6502
-		if($style=$this->getViewState('Style',null))
6503
-			return $style->getBorderStyle();
6504
-		else
6505
-			return '';
6932
+		if($style=$this->getViewState('Style',null)) {
6933
+					return $style->getBorderStyle();
6934
+		} else {
6935
+					return '';
6936
+		}
6506 6937
 	}
6507 6938
 	public function setBorderStyle($value)
6508 6939
 	{
@@ -6510,10 +6941,11 @@  discard block
 block discarded – undo
6510 6941
 	}
6511 6942
 	public function getBorderWidth()
6512 6943
 	{
6513
-		if($style=$this->getViewState('Style',null))
6514
-			return $style->getBorderWidth();
6515
-		else
6516
-			return '';
6944
+		if($style=$this->getViewState('Style',null)) {
6945
+					return $style->getBorderWidth();
6946
+		} else {
6947
+					return '';
6948
+		}
6517 6949
 	}
6518 6950
 	public function setBorderWidth($value)
6519 6951
 	{
@@ -6525,10 +6957,11 @@  discard block
 block discarded – undo
6525 6957
 	}
6526 6958
 	public function getForeColor()
6527 6959
 	{
6528
-		if($style=$this->getViewState('Style',null))
6529
-			return $style->getForeColor();
6530
-		else
6531
-			return '';
6960
+		if($style=$this->getViewState('Style',null)) {
6961
+					return $style->getForeColor();
6962
+		} else {
6963
+					return '';
6964
+		}
6532 6965
 	}
6533 6966
 	public function setForeColor($value)
6534 6967
 	{
@@ -6536,10 +6969,11 @@  discard block
 block discarded – undo
6536 6969
 	}
6537 6970
 	public function getHeight()
6538 6971
 	{
6539
-		if($style=$this->getViewState('Style',null))
6540
-			return $style->getHeight();
6541
-		else
6542
-			return '';
6972
+		if($style=$this->getViewState('Style',null)) {
6973
+					return $style->getHeight();
6974
+		} else {
6975
+					return '';
6976
+		}
6543 6977
 	}
6544 6978
 	public function setDisplay($value)
6545 6979
 	{
@@ -6555,10 +6989,11 @@  discard block
 block discarded – undo
6555 6989
 	}
6556 6990
 	public function getCssClass()
6557 6991
 	{
6558
-		if($style=$this->getViewState('Style',null))
6559
-			return $style->getCssClass();
6560
-		else
6561
-			return '';
6992
+		if($style=$this->getViewState('Style',null)) {
6993
+					return $style->getCssClass();
6994
+		} else {
6995
+					return '';
6996
+		}
6562 6997
 	}
6563 6998
 	public function setHeight($value)
6564 6999
 	{
@@ -6574,9 +7009,9 @@  discard block
 block discarded – undo
6574 7009
 	}
6575 7010
 	public function getStyle()
6576 7011
 	{
6577
-		if($style=$this->getViewState('Style',null))
6578
-			return $style;
6579
-		else
7012
+		if($style=$this->getViewState('Style',null)) {
7013
+					return $style;
7014
+		} else
6580 7015
 		{
6581 7016
 			$style=$this->createStyle();
6582 7017
 			$this->setViewState('Style',$style,null);
@@ -6585,10 +7020,11 @@  discard block
 block discarded – undo
6585 7020
 	}
6586 7021
 	public function setStyle($value)
6587 7022
 	{
6588
-		if(is_string($value))
6589
-			$this->getStyle()->setCustomStyle($value);
6590
-		else
6591
-			throw new TInvalidDataValueException('webcontrol_style_invalid',get_class($this));
7023
+		if(is_string($value)) {
7024
+					$this->getStyle()->setCustomStyle($value);
7025
+		} else {
7026
+					throw new TInvalidDataValueException('webcontrol_style_invalid',get_class($this));
7027
+		}
6592 7028
 	}
6593 7029
 	public function clearStyle()
6594 7030
 	{
@@ -6616,38 +7052,47 @@  discard block
 block discarded – undo
6616 7052
 	}
6617 7053
 	public function getWidth()
6618 7054
 	{
6619
-		if($style=$this->getViewState('Style',null))
6620
-			return $style->getWidth();
6621
-		else
6622
-			return '';
7055
+		if($style=$this->getViewState('Style',null)) {
7056
+					return $style->getWidth();
7057
+		} else {
7058
+					return '';
7059
+		}
6623 7060
 	}
6624 7061
 	public function setWidth($value)
6625 7062
 	{
6626 7063
 		$this->getStyle()->setWidth($value);
6627 7064
 	}
6628 7065
 	public function onPreRender($param) {
6629
-		if($decorator = $this->getDecorator(false))
6630
-			$decorator->instantiate();
7066
+		if($decorator = $this->getDecorator(false)) {
7067
+					$decorator->instantiate();
7068
+		}
6631 7069
 		parent::onPreRender($param);
6632 7070
 	}
6633 7071
 	protected function addAttributesToRender($writer)
6634 7072
 	{
6635
-		if($this->getID()!=='' || $this->getEnsureId())
6636
-			$writer->addAttribute('id',$this->getClientID());
6637
-		if(($accessKey=$this->getAccessKey())!=='')
6638
-			$writer->addAttribute('accesskey',$accessKey);
6639
-		if(!$this->getEnabled())
6640
-			$writer->addAttribute('disabled','disabled');
6641
-		if(($tabIndex=$this->getTabIndex())>0)
6642
-			$writer->addAttribute('tabindex',"$tabIndex");
6643
-		if(($toolTip=$this->getToolTip())!=='')
6644
-			$writer->addAttribute('title',$toolTip);
6645
-		if($style=$this->getViewState('Style',null))
6646
-			$style->addAttributesToRender($writer);
7073
+		if($this->getID()!=='' || $this->getEnsureId()) {
7074
+					$writer->addAttribute('id',$this->getClientID());
7075
+		}
7076
+		if(($accessKey=$this->getAccessKey())!=='') {
7077
+					$writer->addAttribute('accesskey',$accessKey);
7078
+		}
7079
+		if(!$this->getEnabled()) {
7080
+					$writer->addAttribute('disabled','disabled');
7081
+		}
7082
+		if(($tabIndex=$this->getTabIndex())>0) {
7083
+					$writer->addAttribute('tabindex',"$tabIndex");
7084
+		}
7085
+		if(($toolTip=$this->getToolTip())!=='') {
7086
+					$writer->addAttribute('title',$toolTip);
7087
+		}
7088
+		if($style=$this->getViewState('Style',null)) {
7089
+					$style->addAttributesToRender($writer);
7090
+		}
6647 7091
 		if($this->getHasAttributes())
6648 7092
 		{
6649
-			foreach($this->getAttributes() as $name=>$value)
6650
-				$writer->addAttribute($name,$value);
7093
+			foreach($this->getAttributes() as $name=>$value) {
7094
+							$writer->addAttribute($name,$value);
7095
+			}
6651 7096
 		}
6652 7097
 	}
6653 7098
 	public function render($writer)
@@ -6678,8 +7123,9 @@  discard block
 block discarded – undo
6678 7123
 			$decorator->renderPostContentsText($writer);
6679 7124
 			$writer->renderEndTag();
6680 7125
 			$decorator->renderPostTagText($writer);
6681
-		} else
6682
-			$writer->renderEndTag($writer);
7126
+		} else {
7127
+					$writer->renderEndTag($writer);
7128
+		}
6683 7129
 	}
6684 7130
 }
6685 7131
 class TCompositeControl extends TControl implements INamingContainer
@@ -6704,12 +7150,13 @@  discard block
 block discarded – undo
6704 7150
 		if($this->_localTemplate===null)
6705 7151
 		{
6706 7152
 			$class=get_class($this);
6707
-			if(!isset(self::$_template[$class]))
6708
-				self::$_template[$class]=$this->loadTemplate();
7153
+			if(!isset(self::$_template[$class])) {
7154
+							self::$_template[$class]=$this->loadTemplate();
7155
+			}
6709 7156
 			return self::$_template[$class];
7157
+		} else {
7158
+					return $this->_localTemplate;
6710 7159
 		}
6711
-		else
6712
-			return $this->_localTemplate;
6713 7160
 	}
6714 7161
 	public function setTemplate($value)
6715 7162
 	{
@@ -6717,17 +7164,19 @@  discard block
 block discarded – undo
6717 7164
 	}
6718 7165
 	public function getIsSourceTemplateControl()
6719 7166
 	{
6720
-		if(($template=$this->getTemplate())!==null)
6721
-			return $template->getIsSourceTemplate();
6722
-		else
6723
-			return false;
7167
+		if(($template=$this->getTemplate())!==null) {
7168
+					return $template->getIsSourceTemplate();
7169
+		} else {
7170
+					return false;
7171
+		}
6724 7172
 	}
6725 7173
 	public function getTemplateDirectory()
6726 7174
 	{
6727
-		if(($template=$this->getTemplate())!==null)
6728
-			return $template->getContextPath();
6729
-		else
6730
-			return '';
7175
+		if(($template=$this->getTemplate())!==null) {
7176
+					return $template->getContextPath();
7177
+		} else {
7178
+					return '';
7179
+		}
6731 7180
 	}
6732 7181
 	protected function loadTemplate()
6733 7182
 	{
@@ -6740,27 +7189,30 @@  discard block
 block discarded – undo
6740 7189
 		{
6741 7190
 			foreach($tpl->getDirective() as $name=>$value)
6742 7191
 			{
6743
-				if(is_string($value))
6744
-					$this->setSubProperty($name,$value);
6745
-				else
6746
-					throw new TConfigurationException('templatecontrol_directive_invalid',get_class($this),$name);
7192
+				if(is_string($value)) {
7193
+									$this->setSubProperty($name,$value);
7194
+				} else {
7195
+									throw new TConfigurationException('templatecontrol_directive_invalid',get_class($this),$name);
7196
+				}
6747 7197
 			}
6748 7198
 			$tpl->instantiateIn($this);
6749 7199
 		}
6750 7200
 	}
6751 7201
 	public function registerContent($id,TContent $object)
6752 7202
 	{
6753
-		if(isset($this->_contents[$id]))
6754
-			throw new TConfigurationException('templatecontrol_contentid_duplicated',$id);
6755
-		else
6756
-			$this->_contents[$id]=$object;
7203
+		if(isset($this->_contents[$id])) {
7204
+					throw new TConfigurationException('templatecontrol_contentid_duplicated',$id);
7205
+		} else {
7206
+					$this->_contents[$id]=$object;
7207
+		}
6757 7208
 	}
6758 7209
 	public function registerContentPlaceHolder($id,TContentPlaceHolder $object)
6759 7210
 	{
6760
-		if(isset($this->_placeholders[$id]))
6761
-			throw new TConfigurationException('templatecontrol_placeholderid_duplicated',$id);
6762
-		else
6763
-			$this->_placeholders[$id]=$object;
7211
+		if(isset($this->_placeholders[$id])) {
7212
+					throw new TConfigurationException('templatecontrol_placeholderid_duplicated',$id);
7213
+		} else {
7214
+					$this->_placeholders[$id]=$object;
7215
+		}
6764 7216
 	}
6765 7217
 	public function getMasterClass()
6766 7218
 	{
@@ -6782,9 +7234,9 @@  discard block
 block discarded – undo
6782 7234
 			$controls=$placeholder->getParent()->getControls();
6783 7235
 			$loc=$controls->remove($placeholder);
6784 7236
 			$controls->insertAt($loc,$content);
7237
+		} else {
7238
+					throw new TConfigurationException('templatecontrol_placeholder_inexistent',$id);
6785 7239
 		}
6786
-		else
6787
-			throw new TConfigurationException('templatecontrol_placeholder_inexistent',$id);
6788 7240
 	}
6789 7241
 	protected function initRecursive($namingContainer=null)
6790 7242
 	{
@@ -6792,17 +7244,19 @@  discard block
 block discarded – undo
6792 7244
 		if($this->_masterClass!=='')
6793 7245
 		{
6794 7246
 			$master=Prado::createComponent($this->_masterClass);
6795
-			if(!($master instanceof TTemplateControl))
6796
-				throw new TInvalidDataValueException('templatecontrol_mastercontrol_invalid');
7247
+			if(!($master instanceof TTemplateControl)) {
7248
+							throw new TInvalidDataValueException('templatecontrol_mastercontrol_invalid');
7249
+			}
6797 7250
 			$this->_master=$master;
6798 7251
 			$this->getControls()->clear();
6799 7252
 			$this->getControls()->add($master);
6800 7253
 			$master->ensureChildControls();
6801
-			foreach($this->_contents as $id=>$content)
6802
-				$master->injectContent($id,$content);
7254
+			foreach($this->_contents as $id=>$content) {
7255
+							$master->injectContent($id,$content);
7256
+			}
7257
+		} else if(!empty($this->_contents)) {
7258
+					throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this));
6803 7259
 		}
6804
-		else if(!empty($this->_contents))
6805
-			throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this));
6806 7260
 		parent::initRecursive($namingContainer);
6807 7261
 	}
6808 7262
         public function tryToUpdateView($arObj, $throwExceptions = false)
@@ -6815,14 +7269,14 @@  discard block
 block discarded – undo
6815 7269
                                 if ($key != "RELATIONS")
6816 7270
                                 {
6817 7271
                                         $control = $this->{$key};
6818
-                                        if ($control instanceof TTextBox)
6819
-                                                $control->Text = $arObj->{$key};
6820
-                                        elseif ($control instanceof TCheckBox)
6821
-                                                $control->Checked = (boolean) $arObj->{$key};
6822
-                                        elseif ($control instanceof TDatePicker)
6823
-                                                $control->Date = $arObj->{$key};
6824
-                                }
6825
-                                else
7272
+                                        if ($control instanceof TTextBox) {
7273
+                                                                                        $control->Text = $arObj->{$key};
7274
+                                        } elseif ($control instanceof TCheckBox) {
7275
+                                                                                        $control->Checked = (boolean) $arObj->{$key};
7276
+                                        } elseif ($control instanceof TDatePicker) {
7277
+                                                                                        $control->Date = $arObj->{$key};
7278
+                                        }
7279
+                                } else
6826 7280
                                 {
6827 7281
                                         foreach ($objAttrs["RELATIONS"] as $relKey => $relValues)
6828 7282
                                         {
@@ -6844,11 +7298,11 @@  discard block
 block discarded – undo
6844 7298
                                         }
6845 7299
                                         break;
6846 7300
                                 }
6847
-                        } 
6848
-                        catch (Exception $ex)
7301
+                        } catch (Exception $ex)
6849 7302
                         {
6850
-                                if ($throwExceptions)
6851
-                                        throw $ex;
7303
+                                if ($throwExceptions) {
7304
+                                                                        throw $ex;
7305
+                                }
6852 7306
                         }
6853 7307
                 }
6854 7308
         }
@@ -6859,20 +7313,22 @@  discard block
 block discarded – undo
6859 7313
                 {
6860 7314
                         try
6861 7315
                         {
6862
-                                if ($key == "RELATIONS")
6863
-                                        break;
7316
+                                if ($key == "RELATIONS") {
7317
+                                                                        break;
7318
+                                }
6864 7319
                                 $control = $this->{$key};
6865
-                                if ($control instanceof TTextBox)
6866
-                                        $arObj->{$key} = $control->Text;
6867
-                                elseif ($control instanceof TCheckBox)
6868
-                                        $arObj->{$key} = $control->Checked;
6869
-                                elseif ($control instanceof TDatePicker)
6870
-                                        $arObj->{$key} = $control->Date;
6871
-                        } 
6872
-                        catch (Exception $ex)
7320
+                                if ($control instanceof TTextBox) {
7321
+                                                                        $arObj->{$key} = $control->Text;
7322
+                                } elseif ($control instanceof TCheckBox) {
7323
+                                                                        $arObj->{$key} = $control->Checked;
7324
+                                } elseif ($control instanceof TDatePicker) {
7325
+                                                                        $arObj->{$key} = $control->Date;
7326
+                                }
7327
+                        } catch (Exception $ex)
6873 7328
                         {
6874
-                                if ($throwExceptions)
6875
-                                        throw $ex;
7329
+                                if ($throwExceptions) {
7330
+                                                                        throw $ex;
7331
+                                }
6876 7332
                         }
6877 7333
                 }
6878 7334
         }
@@ -6890,17 +7346,19 @@  discard block
 block discarded – undo
6890 7346
 		$writer->addAttribute('method',$this->getMethod());
6891 7347
 		$uri=$this->getRequest()->getRequestURI();
6892 7348
 		$writer->addAttribute('action',str_replace('&','&amp;',str_replace('&amp;','&',$uri)));
6893
-		if(($enctype=$this->getEnctype())!=='')
6894
-			$writer->addAttribute('enctype',$enctype);
7349
+		if(($enctype=$this->getEnctype())!=='') {
7350
+					$writer->addAttribute('enctype',$enctype);
7351
+		}
6895 7352
 		$attributes=$this->getAttributes();
6896 7353
 		$attributes->remove('action');
6897 7354
 		$writer->addAttributes($attributes);
6898 7355
 		if(($butt=$this->getDefaultButton())!=='')
6899 7356
 		{
6900
-			if(($button=$this->findControl($butt))!==null)
6901
-				$this->getPage()->getClientScript()->registerDefaultButton($this, $button);
6902
-			else
6903
-				throw new TInvalidDataValueException('form_defaultbutton_invalid',$butt);
7357
+			if(($button=$this->findControl($butt))!==null) {
7358
+							$this->getPage()->getClientScript()->registerDefaultButton($this, $button);
7359
+			} else {
7360
+							throw new TInvalidDataValueException('form_defaultbutton_invalid',$butt);
7361
+			}
6904 7362
 		}
6905 7363
 	}
6906 7364
 	public function render($writer)
@@ -6920,8 +7378,7 @@  discard block
 block discarded – undo
6920 7378
  			$page->endFormRender($writer);
6921 7379
 			$cs->renderScriptFilesEnd($writer);
6922 7380
 			$cs->renderEndScripts($writer);
6923
-		}
6924
-		else
7381
+		} else
6925 7382
 		{
6926 7383
 			$cs->renderHiddenFieldsBegin($writer);
6927 7384
 			$page->beginFormRender($writer);
@@ -7013,10 +7470,11 @@  discard block
 block discarded – undo
7013 7470
 				self::$_pradoScripts = $deps;
7014 7471
 				self::$_pradoPackages = $packages;
7015 7472
 			}
7016
-			if (isset(self::$_pradoScripts[$name]))
7017
-				$this->_registeredPradoScripts[$name]=true;
7018
-			else
7019
-				throw new TInvalidOperationException('csmanager_pradoscript_invalid',$name);
7473
+			if (isset(self::$_pradoScripts[$name])) {
7474
+							$this->_registeredPradoScripts[$name]=true;
7475
+			} else {
7476
+							throw new TInvalidOperationException('csmanager_pradoscript_invalid',$name);
7477
+			}
7020 7478
 			if(($packages=array_keys($this->_registeredPradoScripts))!==array())
7021 7479
 			{
7022 7480
 				$base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH;
@@ -7027,22 +7485,25 @@  discard block
 block discarded – undo
7027 7485
 				{
7028 7486
 					foreach (self::$_pradoScripts[$p] as $dep)
7029 7487
 					{
7030
-						foreach (self::$_pradoPackages[$dep] as $script)
7031
-						if (!isset($this->_expandedPradoScripts[$script]))
7488
+						foreach (self::$_pradoPackages[$dep] as $script) {
7489
+												if (!isset($this->_expandedPradoScripts[$script]))
7032 7490
 						{
7033 7491
 							$this->_expandedPradoScripts[$script] = true;
7492
+						}
7034 7493
 							if($isDebug)
7035 7494
 							{
7036
-								if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl))
7037
-									$packagesUrl[]=$url;
7495
+								if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl)) {
7496
+																	$packagesUrl[]=$url;
7497
+								}
7038 7498
 							} else {
7039 7499
 								if (!in_array($url=$baseUrl.'/min/'.$script,$packagesUrl))
7040 7500
 								{
7041 7501
 									if(!is_file($filePath=$path.'/min/'.$script))
7042 7502
 									{
7043 7503
 										$dirPath=dirname($filePath);
7044
-										if(!is_dir($dirPath))
7045
-											mkdir($dirPath, PRADO_CHMOD, true);
7504
+										if(!is_dir($dirPath)) {
7505
+																					mkdir($dirPath, PRADO_CHMOD, true);
7506
+										}
7046 7507
 										file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base.'/'.$script)));
7047 7508
 										chmod($filePath, PRADO_CHMOD);
7048 7509
 									}
@@ -7052,8 +7513,9 @@  discard block
 block discarded – undo
7052 7513
 						}
7053 7514
 					}
7054 7515
 				}
7055
-				foreach($packagesUrl as $url)
7056
-					$this->registerScriptFile($url,$url);
7516
+				foreach($packagesUrl as $url) {
7517
+									$this->registerScriptFile($url,$url);
7518
+				}
7057 7519
 			}
7058 7520
 		}
7059 7521
 	}
@@ -7079,8 +7541,7 @@  discard block
 block discarded – undo
7079 7541
 				$base = $dir;
7080 7542
 			}
7081 7543
 			return array($assets->getPublishedPath($base), $assets->publishFilePath($base));
7082
-		}
7083
-		else
7544
+		} else
7084 7545
 		{
7085 7546
 			return array($assets->getBasePath().str_replace($assets->getBaseUrl(),'',$base), $base);
7086 7547
 		}
@@ -7110,8 +7571,9 @@  discard block
 block discarded – undo
7110 7571
 		if($class === null) {
7111 7572
 			return;
7112 7573
 		}
7113
-		if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null)
7114
-			$options['FormID']=$form->getClientID();
7574
+		if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null) {
7575
+					$options['FormID']=$form->getClientID();
7576
+		}
7115 7577
 		$optionString=TJavaScript::encode($options);
7116 7578
 		$code="new {$class}({$optionString});";
7117 7579
 		$this->_endScripts[sprintf('%08X', crc32($code))]=$code;
@@ -7122,9 +7584,9 @@  discard block
 block discarded – undo
7122 7584
 	public function registerDefaultButton($panel, $button)
7123 7585
 	{
7124 7586
 		$panelID=is_string($panel)?$panel:$panel->getUniqueID();
7125
-		if(is_string($button))
7126
-			$buttonID=$button;
7127
-		else
7587
+		if(is_string($button)) {
7588
+					$buttonID=$button;
7589
+		} else
7128 7590
 		{
7129 7591
 			$button->setIsDefaultButton(true);
7130 7592
 			$buttonID=$button->getUniqueID();
@@ -7148,18 +7610,20 @@  discard block
 block discarded – undo
7148 7610
 	public function registerFocusControl($target)
7149 7611
 	{
7150 7612
 		$this->registerPradoScriptInternal('jquery');
7151
-		if($target instanceof TControl)
7152
-			$target=$target->getClientID();
7613
+		if($target instanceof TControl) {
7614
+					$target=$target->getClientID();
7615
+		}
7153 7616
 		$this->_endScripts['prado:focus'] = 'jQuery(\'#'.$target.'\').focus();';
7154 7617
 		$params=func_get_args();
7155 7618
 		$this->_page->registerCachingAction('Page.ClientScript','registerFocusControl',$params);
7156 7619
 	}
7157 7620
 	public function registerStyleSheetFile($key,$url,$media='')
7158 7621
 	{
7159
-		if($media==='')
7160
-			$this->_styleSheetFiles[$key]=$url;
7161
-		else
7162
-			$this->_styleSheetFiles[$key]=array($url,$media);
7622
+		if($media==='') {
7623
+					$this->_styleSheetFiles[$key]=$url;
7624
+		} else {
7625
+					$this->_styleSheetFiles[$key]=array($url,$media);
7626
+		}
7163 7627
 		$params=func_get_args();
7164 7628
 		$this->_page->registerCachingAction('Page.ClientScript','registerStyleSheetFile',$params);
7165 7629
 	}
@@ -7176,9 +7640,10 @@  discard block
 block discarded – undo
7176 7640
 				create_function('$e', 'return is_array($e) ? $e[0] : $e;'),
7177 7641
 				$this->_styleSheetFiles)
7178 7642
 		);
7179
-		foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url)
7180
-			if (substr($url,strlen($url)-4)=='.css')
7643
+		foreach(Prado::getApplication()->getAssetManager()->getPublished() as $path=>$url) {
7644
+					if (substr($url,strlen($url)-4)=='.css')
7181 7645
 				$stylesheets[] = $url;
7646
+		}
7182 7647
 		$stylesheets = array_unique($stylesheets);
7183 7648
 		return $stylesheets;
7184 7649
 	}
@@ -7270,17 +7735,19 @@  discard block
 block discarded – undo
7270 7735
 		$str='';
7271 7736
 		foreach($this->_styleSheetFiles as $url)
7272 7737
 		{
7273
-			if(is_array($url))
7274
-				$str.="<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"".THttpUtility::htmlEncode($url[0])."\" />\n";
7275
-			else
7276
-				$str.="<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n";
7738
+			if(is_array($url)) {
7739
+							$str.="<link rel=\"stylesheet\" type=\"text/css\" media=\"{$url[1]}\" href=\"".THttpUtility::htmlEncode($url[0])."\" />\n";
7740
+			} else {
7741
+							$str.="<link rel=\"stylesheet\" type=\"text/css\" href=\"".THttpUtility::htmlEncode($url)."\" />\n";
7742
+			}
7277 7743
 		}
7278 7744
 		$writer->write($str);
7279 7745
 	}
7280 7746
 	public function renderStyleSheets($writer)
7281 7747
 	{
7282
-		if(count($this->_styleSheets))
7283
-			$writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n",$this->_styleSheets)."\n/*]]>*/\n</style>\n");
7748
+		if(count($this->_styleSheets)) {
7749
+					$writer->write("<style type=\"text/css\">\n/*<![CDATA[*/\n".implode("\n",$this->_styleSheets)."\n/*]]>*/\n</style>\n");
7750
+		}
7284 7751
 	}
7285 7752
 	public function renderHeadScriptFiles($writer)
7286 7753
 	{
@@ -7358,25 +7825,30 @@  discard block
 block discarded – undo
7358 7825
 	}
7359 7826
 	protected function renderHiddenFieldsInt($writer, $initial)
7360 7827
  	{
7361
-		if ($initial) $this->_renderedHiddenFields = array();
7828
+		if ($initial) {
7829
+			$this->_renderedHiddenFields = array();
7830
+		}
7362 7831
 		$str='';
7363 7832
 		foreach($this->_hiddenFields as $name=>$value)
7364 7833
 		{
7365
-			if (in_array($name,$this->_renderedHiddenFields)) continue;
7834
+			if (in_array($name,$this->_renderedHiddenFields)) {
7835
+				continue;
7836
+			}
7366 7837
 			$id=strtr($name,':','_');
7367 7838
 			if(is_array($value))
7368 7839
 			{
7369
-				foreach($value as $v)
7370
-					$str.='<input type="hidden" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n";
7371
-			}
7372
-			else
7840
+				foreach($value as $v) {
7841
+									$str.='<input type="hidden" name="'.$name.'[]" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n";
7842
+				}
7843
+			} else
7373 7844
 			{
7374 7845
 				$str.='<input type="hidden" name="'.$name.'" id="'.$id.'" value="'.THttpUtility::htmlEncode($value)."\" />\n";
7375 7846
 			}
7376 7847
 			$this->_renderedHiddenFields[] = $name;
7377 7848
 		}
7378
-		if($str!=='')
7379
-			$writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n");
7849
+		if($str!=='') {
7850
+					$writer->write("<div style=\"visibility:hidden;\">\n".$str."</div>\n");
7851
+		}
7380 7852
 	}
7381 7853
 	public function getHiddenFields()
7382 7854
 	{
@@ -7384,8 +7856,9 @@  discard block
 block discarded – undo
7384 7856
 	}
7385 7857
 	protected function checkIfNotInRender()
7386 7858
 	{
7387
-		if ($form = $this->_page->InFormRender)
7388
-			throw new Exception('Operation invalid when page is already rendering');
7859
+		if ($form = $this->_page->InFormRender) {
7860
+					throw new Exception('Operation invalid when page is already rendering');
7861
+		}
7389 7862
 	}
7390 7863
 }
7391 7864
 abstract class TClientSideOptions extends TComponent
@@ -7393,16 +7866,18 @@  discard block
 block discarded – undo
7393 7866
 	private $_options;
7394 7867
 	protected function setFunction($name, $code)
7395 7868
 	{
7396
-		if(!TJavaScript::isJsLiteral($code))
7397
-			$code = TJavaScript::quoteJsLiteral($this->ensureFunction($code));
7869
+		if(!TJavaScript::isJsLiteral($code)) {
7870
+					$code = TJavaScript::quoteJsLiteral($this->ensureFunction($code));
7871
+		}
7398 7872
 		$this->setOption($name, $code);
7399 7873
 	}
7400 7874
 	protected function getOption($name)
7401 7875
 	{
7402
-		if ($this->_options)
7403
-			return $this->_options->itemAt($name);
7404
-		else
7405
-			return null;
7876
+		if ($this->_options) {
7877
+					return $this->_options->itemAt($name);
7878
+		} else {
7879
+					return null;
7880
+		}
7406 7881
 	}
7407 7882
 	protected function setOption($name, $value)
7408 7883
 	{
@@ -7410,8 +7885,9 @@  discard block
 block discarded – undo
7410 7885
 	}
7411 7886
 	public function getOptions()
7412 7887
 	{
7413
-		if (!$this->_options)
7414
-			$this->_options = Prado::createComponent('System.Collections.TMap');
7888
+		if (!$this->_options) {
7889
+					$this->_options = Prado::createComponent('System.Collections.TMap');
7890
+		}
7415 7891
 		return $this->_options;
7416 7892
 	}
7417 7893
 	protected function ensureFunction($javascript)
@@ -7474,13 +7950,14 @@  discard block
 block discarded – undo
7474 7950
 		$this->determinePostBackMode();
7475 7951
 		if($this->getIsPostBack())
7476 7952
 		{
7477
-			if($this->getIsCallback())
7478
-				$this->processCallbackRequest($writer);
7479
-			else
7480
-				$this->processPostBackRequest($writer);
7953
+			if($this->getIsCallback()) {
7954
+							$this->processCallbackRequest($writer);
7955
+			} else {
7956
+							$this->processPostBackRequest($writer);
7957
+			}
7958
+		} else {
7959
+					$this->processNormalRequest($writer);
7481 7960
 		}
7482
-		else
7483
-			$this->processNormalRequest($writer);
7484 7961
 		$this->_writer = null;
7485 7962
 	}
7486 7963
 	protected function processNormalRequest($writer)
@@ -7523,8 +8000,9 @@  discard block
 block discarded – undo
7523 8000
 	{
7524 8001
 		if(is_array($data))
7525 8002
 		{
7526
-			foreach($data as $k=>$v)
7527
-				$data[$k]=self::decodeUTF8($v, $enc);
8003
+			foreach($data as $k=>$v) {
8004
+							$data[$k]=self::decodeUTF8($v, $enc);
8005
+			}
7528 8006
 			return $data;
7529 8007
 		} elseif(is_string($data)) {
7530 8008
 			return iconv('UTF-8',$enc.'//IGNORE',$data);
@@ -7537,12 +8015,14 @@  discard block
 block discarded – undo
7537 8015
 		Prado::using('System.Web.UI.ActiveControls.TActivePageAdapter');
7538 8016
 		$this->setAdapter(new TActivePageAdapter($this));
7539 8017
         $callbackEventParameter = $this->getRequest()->itemAt(TPage::FIELD_CALLBACK_PARAMETER);
7540
-        if(strlen($callbackEventParameter) > 0)
7541
-            $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter);
8018
+        if(strlen($callbackEventParameter) > 0) {
8019
+                    $this->_postData[TPage::FIELD_CALLBACK_PARAMETER]=TJavaScript::jsonDecode((string)$callbackEventParameter);
8020
+        }
7542 8021
                 if (($g=$this->getApplication()->getGlobalization(false))!==null &&
7543
-            strtoupper($enc=$g->getCharset())!='UTF-8')
7544
-                foreach ($this->_postData as $k=>$v)
8022
+            strtoupper($enc=$g->getCharset())!='UTF-8') {
8023
+                                foreach ($this->_postData as $k=>$v)
7545 8024
                 	$this->_postData[$k]=self::decodeUTF8($v, $enc);
8025
+                }
7546 8026
 		$this->onPreInit(null);
7547 8027
 		$this->initRecursive();
7548 8028
 		$this->onInitComplete(null);
@@ -7564,10 +8044,11 @@  discard block
 block discarded – undo
7564 8044
 	}
7565 8045
 	public function getCallbackClient()
7566 8046
 	{
7567
-		if($this->getAdapter() !== null)
7568
-			return $this->getAdapter()->getCallbackClientHandler();
7569
-		else
7570
-			return new TCallbackClientScript();
8047
+		if($this->getAdapter() !== null) {
8048
+					return $this->getAdapter()->getCallbackClientHandler();
8049
+		} else {
8050
+					return new TCallbackClientScript();
8051
+		}
7571 8052
 	}
7572 8053
 	public function setCallbackClient($client)
7573 8054
 	{
@@ -7595,23 +8076,26 @@  discard block
 block discarded – undo
7595 8076
 	}
7596 8077
 	public function setForm(TForm $form)
7597 8078
 	{
7598
-		if($this->_form===null)
7599
-			$this->_form=$form;
7600
-		else
7601
-			throw new TInvalidOperationException('page_form_duplicated');
8079
+		if($this->_form===null) {
8080
+					$this->_form=$form;
8081
+		} else {
8082
+					throw new TInvalidOperationException('page_form_duplicated');
8083
+		}
7602 8084
 	}
7603 8085
 	public function getValidators($validationGroup=null)
7604 8086
 	{
7605
-		if(!$this->_validators)
7606
-			$this->_validators=new TList;
7607
-		if(empty($validationGroup) === true)
7608
-			return $this->_validators;
7609
-		else
8087
+		if(!$this->_validators) {
8088
+					$this->_validators=new TList;
8089
+		}
8090
+		if(empty($validationGroup) === true) {
8091
+					return $this->_validators;
8092
+		} else
7610 8093
 		{
7611 8094
 			$list=new TList;
7612
-			foreach($this->_validators as $validator)
7613
-				if($validator->getValidationGroup()===$validationGroup)
8095
+			foreach($this->_validators as $validator) {
8096
+							if($validator->getValidationGroup()===$validationGroup)
7614 8097
 					$list->add($validator);
8098
+			}
7615 8099
 			return $list;
7616 8100
 		}
7617 8101
 	}
@@ -7622,15 +8106,16 @@  discard block
 block discarded – undo
7622 8106
 		{
7623 8107
 			if($validationGroup===null)
7624 8108
 			{
7625
-				foreach($this->_validators as $validator)
7626
-					$validator->validate();
7627
-			}
7628
-			else
8109
+				foreach($this->_validators as $validator) {
8110
+									$validator->validate();
8111
+				}
8112
+			} else
7629 8113
 			{
7630 8114
 				foreach($this->_validators as $validator)
7631 8115
 				{
7632
-					if($validator->getValidationGroup()===$validationGroup)
7633
-						$validator->validate();
8116
+					if($validator->getValidationGroup()===$validationGroup) {
8117
+											$validator->validate();
8118
+					}
7634 8119
 				}
7635 8120
 			}
7636 8121
 		}
@@ -7641,19 +8126,21 @@  discard block
 block discarded – undo
7641 8126
 		{
7642 8127
 			if($this->_validators && $this->_validators->getCount())
7643 8128
 			{
7644
-				foreach($this->_validators as $validator)
7645
-					if(!$validator->getIsValid())
8129
+				foreach($this->_validators as $validator) {
8130
+									if(!$validator->getIsValid())
7646 8131
 						return false;
8132
+				}
7647 8133
 			}
7648 8134
 			return true;
8135
+		} else {
8136
+					throw new TInvalidOperationException('page_isvalid_unknown');
7649 8137
 		}
7650
-		else
7651
-			throw new TInvalidOperationException('page_isvalid_unknown');
7652 8138
 	}
7653 8139
 	public function getTheme()
7654 8140
 	{
7655
-		if(is_string($this->_theme))
7656
-			$this->_theme=$this->getService()->getThemeManager()->getTheme($this->_theme);
8141
+		if(is_string($this->_theme)) {
8142
+					$this->_theme=$this->getService()->getThemeManager()->getTheme($this->_theme);
8143
+		}
7657 8144
 		return $this->_theme;
7658 8145
 	}
7659 8146
 	public function setTheme($value)
@@ -7662,8 +8149,9 @@  discard block
 block discarded – undo
7662 8149
 	}
7663 8150
 	public function getStyleSheetTheme()
7664 8151
 	{
7665
-		if(is_string($this->_styleSheet))
7666
-			$this->_styleSheet=$this->getService()->getThemeManager()->getTheme($this->_styleSheet);
8152
+		if(is_string($this->_styleSheet)) {
8153
+					$this->_styleSheet=$this->getService()->getThemeManager()->getTheme($this->_styleSheet);
8154
+		}
7667 8155
 		return $this->_styleSheet;
7668 8156
 	}
7669 8157
 	public function setStyleSheetTheme($value)
@@ -7672,23 +8160,27 @@  discard block
 block discarded – undo
7672 8160
 	}
7673 8161
 	public function applyControlSkin($control)
7674 8162
 	{
7675
-		if(($theme=$this->getTheme())!==null)
7676
-			$theme->applySkin($control);
8163
+		if(($theme=$this->getTheme())!==null) {
8164
+					$theme->applySkin($control);
8165
+		}
7677 8166
 	}
7678 8167
 	public function applyControlStyleSheet($control)
7679 8168
 	{
7680
-		if(($theme=$this->getStyleSheetTheme())!==null)
7681
-			$theme->applySkin($control);
8169
+		if(($theme=$this->getStyleSheetTheme())!==null) {
8170
+					$theme->applySkin($control);
8171
+		}
7682 8172
 	}
7683 8173
 	public function getClientScript()
7684 8174
 	{
7685 8175
 		if(!$this->_clientScript) {
7686 8176
 			$className = $classPath = $this->getService()->getClientScriptManagerClass();
7687 8177
 			Prado::using($className);
7688
-			if(($pos=strrpos($className,'.'))!==false)
7689
-				$className=substr($className,$pos+1);
7690
- 			if(!class_exists($className,false) || ($className!=='TClientScriptManager' && !is_subclass_of($className,'TClientScriptManager')))
7691
-				throw new THttpException(404,'page_csmanagerclass_invalid',$classPath);
8178
+			if(($pos=strrpos($className,'.'))!==false) {
8179
+							$className=substr($className,$pos+1);
8180
+			}
8181
+ 			if(!class_exists($className,false) || ($className!=='TClientScriptManager' && !is_subclass_of($className,'TClientScriptManager'))) {
8182
+ 							throw new THttpException(404,'page_csmanagerclass_invalid',$classPath);
8183
+ 			}
7692 8184
 			$this->_clientScript=new $className($this);
7693 8185
 		}
7694 8186
 		return $this->_clientScript;
@@ -7716,29 +8208,35 @@  discard block
 block discarded – undo
7716 8208
 		$theme=$this->getTheme();
7717 8209
 		if($theme instanceof ITheme)
7718 8210
 		{
7719
-			foreach($theme->getStyleSheetFiles() as $url)
7720
-				$cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url));
7721
-			foreach($theme->getJavaScriptFiles() as $url)
7722
-				$cs->registerHeadScriptFile($url,$url);
8211
+			foreach($theme->getStyleSheetFiles() as $url) {
8212
+							$cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url));
8213
+			}
8214
+			foreach($theme->getJavaScriptFiles() as $url) {
8215
+							$cs->registerHeadScriptFile($url,$url);
8216
+			}
7723 8217
 		}
7724 8218
 		$styleSheet=$this->getStyleSheetTheme();
7725 8219
 		if($styleSheet instanceof ITheme)
7726 8220
 		{
7727
-			foreach($styleSheet->getStyleSheetFiles() as $url)
7728
-				$cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url));
7729
-			foreach($styleSheet->getJavaScriptFiles() as $url)
7730
-				$cs->registerHeadScriptFile($url,$url);
8221
+			foreach($styleSheet->getStyleSheetFiles() as $url) {
8222
+							$cs->registerStyleSheetFile($url,$url,$this->getCssMediaType($url));
8223
+			}
8224
+			foreach($styleSheet->getJavaScriptFiles() as $url) {
8225
+							$cs->registerHeadScriptFile($url,$url);
8226
+			}
8227
+		}
8228
+		if($cs->getRequiresHead() && $this->getHead()===null) {
8229
+					throw new TConfigurationException('page_head_required');
7731 8230
 		}
7732
-		if($cs->getRequiresHead() && $this->getHead()===null)
7733
-			throw new TConfigurationException('page_head_required');
7734 8231
 	}
7735 8232
 	private function getCssMediaType($url)
7736 8233
 	{
7737 8234
 		$segs=explode('.',basename($url));
7738
-		if(isset($segs[2]))
7739
-			return $segs[count($segs)-2];
7740
-		else
7741
-			return '';
8235
+		if(isset($segs[2])) {
8236
+					return $segs[count($segs)-2];
8237
+		} else {
8238
+					return '';
8239
+		}
7742 8240
 	}
7743 8241
 	public function onSaveStateComplete($param)
7744 8242
 	{
@@ -7747,8 +8245,9 @@  discard block
 block discarded – undo
7747 8245
 	private function determinePostBackMode()
7748 8246
 	{
7749 8247
 		$postData=$this->getRequest();
7750
-		if($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET))
7751
-			$this->_postData=$postData;
8248
+		if($postData->contains(self::FIELD_PAGESTATE) || $postData->contains(self::FIELD_POSTBACK_TARGET)) {
8249
+					$this->_postData=$postData;
8250
+		}
7752 8251
 	}
7753 8252
 	public function getIsPostBack()
7754 8253
 	{
@@ -7787,16 +8286,18 @@  discard block
 block discarded – undo
7787 8286
 		$id=is_string($control)?$control:$control->getUniqueID();
7788 8287
 		$this->_controlsRegisteredForPostData[$id]=true;
7789 8288
 		$params=func_get_args();
7790
-		foreach($this->getCachingStack() as $item)
7791
-			$item->registerAction('Page','registerRequiresPostData',array($id));
8289
+		foreach($this->getCachingStack() as $item) {
8290
+					$item->registerAction('Page','registerRequiresPostData',array($id));
8291
+		}
7792 8292
 	}
7793 8293
 	public function getPostBackEventTarget()
7794 8294
 	{
7795 8295
 		if($this->_postBackEventTarget===null && $this->_postData!==null)
7796 8296
 		{
7797 8297
 			$eventTarget=$this->_postData->itemAt(self::FIELD_POSTBACK_TARGET);
7798
-			if(!empty($eventTarget))
7799
-				$this->_postBackEventTarget=$this->findControl($eventTarget);
8298
+			if(!empty($eventTarget)) {
8299
+							$this->_postBackEventTarget=$this->findControl($eventTarget);
8300
+			}
7800 8301
 		}
7801 8302
 		return $this->_postBackEventTarget;
7802 8303
 	}
@@ -7808,8 +8309,9 @@  discard block
 block discarded – undo
7808 8309
 	{
7809 8310
 		if($this->_postBackEventParameter===null && $this->_postData!==null)
7810 8311
 		{
7811
-			if(($this->_postBackEventParameter=$this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER))===null)
7812
-				$this->_postBackEventParameter='';
8312
+			if(($this->_postBackEventParameter=$this->_postData->itemAt(self::FIELD_POSTBACK_PARAMETER))===null) {
8313
+							$this->_postBackEventParameter='';
8314
+			}
7813 8315
 		}
7814 8316
 		return $this->_postBackEventParameter;
7815 8317
 	}
@@ -7820,27 +8322,28 @@  discard block
 block discarded – undo
7820 8322
 	protected function processPostData($postData,$beforeLoad)
7821 8323
 	{
7822 8324
 		$this->_isLoadingPostData=true;
7823
-		if($beforeLoad)
7824
-			$this->_restPostData=new TMap;
8325
+		if($beforeLoad) {
8326
+					$this->_restPostData=new TMap;
8327
+		}
7825 8328
 		foreach($postData as $key=>$value)
7826 8329
 		{
7827
-			if($this->isSystemPostField($key))
7828
-				continue;
7829
-			else if($control=$this->findControl($key))
8330
+			if($this->isSystemPostField($key)) {
8331
+							continue;
8332
+			} else if($control=$this->findControl($key))
7830 8333
 			{
7831 8334
 				if($control instanceof IPostBackDataHandler)
7832 8335
 				{
7833
-					if($control->loadPostData($key,$postData))
7834
-						$this->_controlsPostDataChanged[]=$control;
7835
-				}
7836
-				else if($control instanceof IPostBackEventHandler &&
8336
+					if($control->loadPostData($key,$postData)) {
8337
+											$this->_controlsPostDataChanged[]=$control;
8338
+					}
8339
+				} else if($control instanceof IPostBackEventHandler &&
7837 8340
 					empty($this->_postData[self::FIELD_POSTBACK_TARGET]))
7838 8341
 				{
7839 8342
 					$this->_postData->add(self::FIELD_POSTBACK_TARGET,$key);  				}
7840 8343
 				unset($this->_controlsRequiringPostData[$key]);
8344
+			} else if($beforeLoad) {
8345
+							$this->_restPostData->add($key,$value);
7841 8346
 			}
7842
-			else if($beforeLoad)
7843
-				$this->_restPostData->add($key,$value);
7844 8347
 		}
7845 8348
 		foreach($this->_controlsRequiringPostData as $key=>$value)
7846 8349
 		{
@@ -7848,11 +8351,12 @@  discard block
 block discarded – undo
7848 8351
 			{
7849 8352
 				if($control instanceof IPostBackDataHandler)
7850 8353
 				{
7851
-					if($control->loadPostData($key,$this->_postData))
7852
-						$this->_controlsPostDataChanged[]=$control;
8354
+					if($control->loadPostData($key,$this->_postData)) {
8355
+											$this->_controlsPostDataChanged[]=$control;
8356
+					}
8357
+				} else {
8358
+									throw new TInvalidDataValueException('page_postbackcontrol_invalid',$key);
7853 8359
 				}
7854
-				else
7855
-					throw new TInvalidDataValueException('page_postbackcontrol_invalid',$key);
7856 8360
 				unset($this->_controlsRequiringPostData[$key]);
7857 8361
 			}
7858 8362
 		}
@@ -7864,15 +8368,17 @@  discard block
 block discarded – undo
7864 8368
 	}
7865 8369
 	protected function raiseChangedEvents()
7866 8370
 	{
7867
-		foreach($this->_controlsPostDataChanged as $control)
7868
-			$control->raisePostDataChangedEvent();
8371
+		foreach($this->_controlsPostDataChanged as $control) {
8372
+					$control->raisePostDataChangedEvent();
8373
+		}
7869 8374
 	}
7870 8375
 	protected function raisePostBackEvent()
7871 8376
 	{
7872
-		if(($postBackHandler=$this->getPostBackEventTarget())===null)
7873
-			$this->validate();
7874
-		else if($postBackHandler instanceof IPostBackEventHandler)
7875
-			$postBackHandler->raisePostBackEvent($this->getPostBackEventParameter());
8377
+		if(($postBackHandler=$this->getPostBackEventTarget())===null) {
8378
+					$this->validate();
8379
+		} else if($postBackHandler instanceof IPostBackEventHandler) {
8380
+					$postBackHandler->raisePostBackEvent($this->getPostBackEventParameter());
8381
+		}
7876 8382
 	}
7877 8383
 	public function getInFormRender()
7878 8384
 	{
@@ -7880,13 +8386,15 @@  discard block
 block discarded – undo
7880 8386
 	}
7881 8387
 	public function ensureRenderInForm($control)
7882 8388
 	{
7883
-		if(!$this->getIsCallback() && !$this->_inFormRender)
7884
-			throw new TConfigurationException('page_control_outofform',get_class($control), $control ? $control->getUniqueID() : null);
8389
+		if(!$this->getIsCallback() && !$this->_inFormRender) {
8390
+					throw new TConfigurationException('page_control_outofform',get_class($control), $control ? $control->getUniqueID() : null);
8391
+		}
7885 8392
 	}
7886 8393
 	public function beginFormRender($writer)
7887 8394
 	{
7888
-		if($this->_formRendered)
7889
-			throw new TConfigurationException('page_form_duplicated');
8395
+		if($this->_formRendered) {
8396
+					throw new TConfigurationException('page_form_duplicated');
8397
+		}
7890 8398
 		$this->_formRendered=true;
7891 8399
 		$this->getClientScript()->registerHiddenField(self::FIELD_PAGESTATE,$this->getClientState());
7892 8400
 		$this->_inFormRender=true;
@@ -7895,14 +8403,15 @@  discard block
 block discarded – undo
7895 8403
 	{
7896 8404
 		if($this->_focus)
7897 8405
 		{
7898
-			if(($this->_focus instanceof TControl) && $this->_focus->getVisible(true))
7899
-				$focus=$this->_focus->getClientID();
7900
-			else
7901
-				$focus=$this->_focus;
8406
+			if(($this->_focus instanceof TControl) && $this->_focus->getVisible(true)) {
8407
+							$focus=$this->_focus->getClientID();
8408
+			} else {
8409
+							$focus=$this->_focus;
8410
+			}
7902 8411
 			$this->getClientScript()->registerFocusControl($focus);
8412
+		} else if($this->_postData && ($lastFocus=$this->_postData->itemAt(self::FIELD_LASTFOCUS))!==null) {
8413
+					$this->getClientScript()->registerFocusControl($lastFocus);
7903 8414
 		}
7904
-		else if($this->_postData && ($lastFocus=$this->_postData->itemAt(self::FIELD_LASTFOCUS))!==null)
7905
-			$this->getClientScript()->registerFocusControl($lastFocus);
7906 8415
 		$this->_inFormRender=false;
7907 8416
 	}
7908 8417
 	public function setFocus($value)
@@ -7923,8 +8432,9 @@  discard block
 block discarded – undo
7923 8432
 	}
7924 8433
 	public function setHead(THead $value)
7925 8434
 	{
7926
-		if($this->_head)
7927
-			throw new TInvalidOperationException('page_head_duplicated');
8435
+		if($this->_head) {
8436
+					throw new TInvalidOperationException('page_head_duplicated');
8437
+		}
7928 8438
 		$this->_head=$value;
7929 8439
 		if($this->_title!==null)
7930 8440
 		{
@@ -7934,17 +8444,19 @@  discard block
 block discarded – undo
7934 8444
 	}
7935 8445
 	public function getTitle()
7936 8446
 	{
7937
-		if($this->_head)
7938
-			return $this->_head->getTitle();
7939
-		else
7940
-			return $this->_title===null ? '' : $this->_title;
8447
+		if($this->_head) {
8448
+					return $this->_head->getTitle();
8449
+		} else {
8450
+					return $this->_title===null ? '' : $this->_title;
8451
+		}
7941 8452
 	}
7942 8453
 	public function setTitle($value)
7943 8454
 	{
7944
-		if($this->_head)
7945
-			$this->_head->setTitle($value);
7946
-		else
7947
-			$this->_title=$value;
8455
+		if($this->_head) {
8456
+					$this->_head->setTitle($value);
8457
+		} else {
8458
+					$this->_title=$value;
8459
+		}
7948 8460
 	}
7949 8461
 	public function getClientState()
7950 8462
 	{
@@ -7971,8 +8483,9 @@  discard block
 block discarded – undo
7971 8483
 		if($this->_statePersister===null)
7972 8484
 		{
7973 8485
 			$this->_statePersister=Prado::createComponent($this->_statePersisterClass);
7974
-			if(!($this->_statePersister instanceof IPageStatePersister))
7975
-				throw new TInvalidDataTypeException('page_statepersister_invalid');
8486
+			if(!($this->_statePersister instanceof IPageStatePersister)) {
8487
+							throw new TInvalidDataTypeException('page_statepersister_invalid');
8488
+			}
7976 8489
 			$this->_statePersister->setPage($this);
7977 8490
 		}
7978 8491
 		return $this->_statePersister;
@@ -8013,20 +8526,23 @@  discard block
 block discarded – undo
8013 8526
 	{
8014 8527
 		if($this->_cachingStack)
8015 8528
 		{
8016
-			foreach($this->_cachingStack as $cache)
8017
-				$cache->registerAction($context,$funcName,$funcParams);
8529
+			foreach($this->_cachingStack as $cache) {
8530
+							$cache->registerAction($context,$funcName,$funcParams);
8531
+			}
8018 8532
 		}
8019 8533
 	}
8020 8534
 	public function getCachingStack()
8021 8535
 	{
8022
-		if(!$this->_cachingStack)
8023
-			$this->_cachingStack=new TStack;
8536
+		if(!$this->_cachingStack) {
8537
+					$this->_cachingStack=new TStack;
8538
+		}
8024 8539
 		return $this->_cachingStack;
8025 8540
 	}
8026 8541
 	public function flushWriter()
8027 8542
 	{
8028
-		if ($this->_writer)
8029
-			$this->Response->write($this->_writer->flush());
8543
+		if ($this->_writer) {
8544
+					$this->Response->write($this->_writer->flush());
8545
+		}
8030 8546
 	}
8031 8547
 }
8032 8548
 interface IPageStatePersister
@@ -8041,35 +8557,42 @@  discard block
 block discarded – undo
8041 8557
 	public static function serialize($page,$data)
8042 8558
 	{
8043 8559
 		$sm=$page->getApplication()->getSecurityManager();
8044
-		if($page->getEnableStateValidation())
8045
-			$str=$sm->hashData(serialize($data));
8046
-		else
8047
-			$str=serialize($data);
8048
-		if($page->getEnableStateCompression() && extension_loaded('zlib'))
8049
-			$str=gzcompress($str);
8050
-		if($page->getEnableStateEncryption())
8051
-			$str=$sm->encrypt($str);
8560
+		if($page->getEnableStateValidation()) {
8561
+					$str=$sm->hashData(serialize($data));
8562
+		} else {
8563
+					$str=serialize($data);
8564
+		}
8565
+		if($page->getEnableStateCompression() && extension_loaded('zlib')) {
8566
+					$str=gzcompress($str);
8567
+		}
8568
+		if($page->getEnableStateEncryption()) {
8569
+					$str=$sm->encrypt($str);
8570
+		}
8052 8571
 		return base64_encode($str);
8053 8572
 	}
8054 8573
 	public static function unserialize($page,$data)
8055 8574
 	{
8056 8575
 		$str=base64_decode($data);
8057
-		if($str==='')
8058
-			return null;
8576
+		if($str==='') {
8577
+					return null;
8578
+		}
8059 8579
 		if($str!==false)
8060 8580
 		{
8061 8581
 			$sm=$page->getApplication()->getSecurityManager();
8062
-			if($page->getEnableStateEncryption())
8063
-				$str=$sm->decrypt($str);
8064
-			if($page->getEnableStateCompression() && extension_loaded('zlib'))
8065
-				$str=@gzuncompress($str);
8582
+			if($page->getEnableStateEncryption()) {
8583
+							$str=$sm->decrypt($str);
8584
+			}
8585
+			if($page->getEnableStateCompression() && extension_loaded('zlib')) {
8586
+							$str=@gzuncompress($str);
8587
+			}
8066 8588
 			if($page->getEnableStateValidation())
8067 8589
 			{
8068
-				if(($str=$sm->validateData($str))!==false)
8069
-					return unserialize($str);
8590
+				if(($str=$sm->validateData($str))!==false) {
8591
+									return unserialize($str);
8592
+				}
8593
+			} else {
8594
+							return unserialize($str);
8070 8595
 			}
8071
-			else
8072
-				return unserialize($str);
8073 8596
 		}
8074 8597
 		return null;
8075 8598
 	}
@@ -8107,11 +8630,12 @@  discard block
 block discarded – undo
8107 8630
 				if($this->_cacheModuleID!=='')
8108 8631
 				{
8109 8632
 					$this->_cache=$this->getApplication()->getModule($this->_cacheModuleID);
8110
-					if(!($this->_cache instanceof ICache))
8111
-						throw new TConfigurationException('outputcache_cachemoduleid_invalid',$this->_cacheModuleID);
8633
+					if(!($this->_cache instanceof ICache)) {
8634
+											throw new TConfigurationException('outputcache_cachemoduleid_invalid',$this->_cacheModuleID);
8635
+					}
8636
+				} else {
8637
+									$this->_cache=$this->getApplication()->getCache();
8112 8638
 				}
8113
-				else
8114
-					$this->_cache=$this->getApplication()->getCache();
8115 8639
 				if($this->_cache!==null)
8116 8640
 				{
8117 8641
 					$this->_cacheAvailable=true;
@@ -8122,11 +8646,12 @@  discard block
 block discarded – undo
8122 8646
 						$param->setCacheTime(isset($data[3])?$data[3]:0);
8123 8647
 						$this->onCheckDependency($param);
8124 8648
 						$this->_dataCached=$param->getIsValid();
8649
+					} else {
8650
+											$this->_dataCached=false;
8651
+					}
8652
+					if($this->_dataCached) {
8653
+											list($this->_contents,$this->_state,$this->_actions,$this->_cacheTime)=$data;
8125 8654
 					}
8126
-					else
8127
-						$this->_dataCached=false;
8128
-					if($this->_dataCached)
8129
-						list($this->_contents,$this->_state,$this->_actions,$this->_cacheTime)=$data;
8130 8655
 				}
8131 8656
 			}
8132 8657
 		}
@@ -8139,9 +8664,9 @@  discard block
 block discarded – undo
8139 8664
 			$stack->push($this);
8140 8665
 			parent::initRecursive($namingContainer);
8141 8666
 			$stack->pop();
8667
+		} else {
8668
+					parent::initRecursive($namingContainer);
8142 8669
 		}
8143
-		else
8144
-			parent::initRecursive($namingContainer);
8145 8670
 	}
8146 8671
 	protected function loadRecursive()
8147 8672
 	{
@@ -8151,11 +8676,11 @@  discard block
 block discarded – undo
8151 8676
 			$stack->push($this);
8152 8677
 			parent::loadRecursive();
8153 8678
 			$stack->pop();
8154
-		}
8155
-		else
8679
+		} else
8156 8680
 		{
8157
-			if($this->_dataCached)
8158
-				$this->performActions();
8681
+			if($this->_dataCached) {
8682
+							$this->performActions();
8683
+			}
8159 8684
 			parent::loadRecursive();
8160 8685
 		}
8161 8686
 	}
@@ -8165,12 +8690,13 @@  discard block
 block discarded – undo
8165 8690
 		$cs=$page->getClientScript();
8166 8691
 		foreach($this->_actions as $action)
8167 8692
 		{
8168
-			if($action[0]==='Page.ClientScript')
8169
-				call_user_func_array(array($cs,$action[1]),$action[2]);
8170
-			else if($action[0]==='Page')
8171
-				call_user_func_array(array($page,$action[1]),$action[2]);
8172
-			else
8173
-				call_user_func_array(array($this->getSubProperty($action[0]),$action[1]),$action[2]);
8693
+			if($action[0]==='Page.ClientScript') {
8694
+							call_user_func_array(array($cs,$action[1]),$action[2]);
8695
+			} else if($action[0]==='Page') {
8696
+							call_user_func_array(array($page,$action[1]),$action[2]);
8697
+			} else {
8698
+							call_user_func_array(array($this->getSubProperty($action[0]),$action[1]),$action[2]);
8699
+			}
8174 8700
 		}
8175 8701
 	}
8176 8702
 	protected function preRenderRecursive()
@@ -8181,9 +8707,9 @@  discard block
 block discarded – undo
8181 8707
 			$stack->push($this);
8182 8708
 			parent::preRenderRecursive();
8183 8709
 			$stack->pop();
8710
+		} else {
8711
+					parent::preRenderRecursive();
8184 8712
 		}
8185
-		else
8186
-			parent::preRenderRecursive();
8187 8713
 	}
8188 8714
 	protected function loadStateRecursive(&$state,$needViewState=true)
8189 8715
 	{
@@ -8192,9 +8718,9 @@  discard block
 block discarded – undo
8192 8718
 	}
8193 8719
 	protected function &saveStateRecursive($needViewState=true)
8194 8720
 	{
8195
-		if($this->_dataCached)
8196
-			return $this->_state;
8197
-		else
8721
+		if($this->_dataCached) {
8722
+					return $this->_state;
8723
+		} else
8198 8724
 		{
8199 8725
 			$st=parent::saveStateRecursive($needViewState);
8200 8726
 						$this->_state=serialize($st);
@@ -8207,15 +8733,17 @@  discard block
 block discarded – undo
8207 8733
 	}
8208 8734
 	public function getCacheKey()
8209 8735
 	{
8210
-		if($this->_cacheKey===null)
8211
-			$this->_cacheKey=$this->calculateCacheKey();
8736
+		if($this->_cacheKey===null) {
8737
+					$this->_cacheKey=$this->calculateCacheKey();
8738
+		}
8212 8739
 		return $this->_cacheKey;
8213 8740
 	}
8214 8741
 	protected function calculateCacheKey()
8215 8742
 	{
8216 8743
 		$key=$this->getBaseCacheKey();
8217
-		if($this->_varyBySession)
8218
-			$key.=$this->getSession()->getSessionID();
8744
+		if($this->_varyBySession) {
8745
+					$key.=$this->getSession()->getSessionID();
8746
+		}
8219 8747
 		if($this->_varyByParam!=='')
8220 8748
 		{
8221 8749
 			$params=array();
@@ -8266,8 +8794,9 @@  discard block
 block discarded – undo
8266 8794
 	}
8267 8795
 	public function setDuration($value)
8268 8796
 	{
8269
-		if(($value=TPropertyValue::ensureInteger($value))<0)
8270
-			throw new TInvalidDataValueException('outputcache_duration_invalid',get_class($this));
8797
+		if(($value=TPropertyValue::ensureInteger($value))<0) {
8798
+					throw new TInvalidDataValueException('outputcache_duration_invalid',get_class($this));
8799
+		}
8271 8800
 		$this->_duration=$value;
8272 8801
 	}
8273 8802
 	public function getVaryByParam()
@@ -8304,9 +8833,9 @@  discard block
 block discarded – undo
8304 8833
 	}
8305 8834
 	public function render($writer)
8306 8835
 	{
8307
-		if($this->_dataCached)
8308
-			$writer->write($this->_contents);
8309
-		else if($this->_cacheAvailable)
8836
+		if($this->_dataCached) {
8837
+					$writer->write($this->_contents);
8838
+		} else if($this->_cacheAvailable)
8310 8839
 		{
8311 8840
 			$textwriter = new TTextWriter();
8312 8841
 			$multiwriter = new TOutputCacheTextWriterMulti(array($writer->getWriter(),$textwriter));
@@ -8318,9 +8847,9 @@  discard block
 block discarded – undo
8318 8847
 			$content=$textwriter->flush();
8319 8848
 			$data=array($content,$this->_state,$this->_actions,time());
8320 8849
 			$this->_cache->set($this->getCacheKey(),$data,$this->getDuration(),$this->getCacheDependency());
8850
+		} else {
8851
+					parent::render($writer);
8321 8852
 		}
8322
-		else
8323
-			parent::render($writer);
8324 8853
 	}
8325 8854
 }
8326 8855
 class TOutputCacheCheckDependencyEventParameter extends TEventParameter
@@ -8365,13 +8894,15 @@  discard block
 block discarded – undo
8365 8894
 	}
8366 8895
 	public function write($s)
8367 8896
 	{
8368
-		foreach($this->_writers as $writer)
8369
-			$writer->write($s);
8897
+		foreach($this->_writers as $writer) {
8898
+					$writer->write($s);
8899
+		}
8370 8900
 	}
8371 8901
 	public function flush()
8372 8902
 	{
8373
-		foreach($this->_writers as $writer)
8374
-			$s = $writer->flush();
8903
+		foreach($this->_writers as $writer) {
8904
+					$s = $writer->flush();
8905
+		}
8375 8906
 		return $s;
8376 8907
 	}
8377 8908
 }
@@ -8393,16 +8924,17 @@  discard block
 block discarded – undo
8393 8924
 	{
8394 8925
 		if(($fileName=$this->getLocalizedTemplate($fileName))!==null)
8395 8926
 		{
8396
-			if(($cache=$this->getApplication()->getCache())===null)
8397
-				return new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName);
8398
-			else
8927
+			if(($cache=$this->getApplication()->getCache())===null) {
8928
+							return new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName);
8929
+			} else
8399 8930
 			{
8400 8931
 				$array=$cache->get(self::TEMPLATE_CACHE_PREFIX.$fileName);
8401 8932
 				if(is_array($array))
8402 8933
 				{
8403 8934
 					list($template,$timestamps)=$array;
8404
-					if($this->getApplication()->getMode()===TApplicationMode::Performance)
8405
-						return $template;
8935
+					if($this->getApplication()->getMode()===TApplicationMode::Performance) {
8936
+											return $template;
8937
+					}
8406 8938
 					$cacheValid=true;
8407 8939
 					foreach($timestamps as $tplFile=>$timestamp)
8408 8940
 					{
@@ -8412,30 +8944,34 @@  discard block
 block discarded – undo
8412 8944
 							break;
8413 8945
 						}
8414 8946
 					}
8415
-					if($cacheValid)
8416
-						return $template;
8947
+					if($cacheValid) {
8948
+											return $template;
8949
+					}
8417 8950
 				}
8418 8951
 				$template=new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName);
8419 8952
 				$includedFiles=$template->getIncludedFiles();
8420 8953
 				$timestamps=array();
8421 8954
 				$timestamps[$fileName]=filemtime($fileName);
8422
-				foreach($includedFiles as $includedFile)
8423
-					$timestamps[$includedFile]=filemtime($includedFile);
8955
+				foreach($includedFiles as $includedFile) {
8956
+									$timestamps[$includedFile]=filemtime($includedFile);
8957
+				}
8424 8958
 				$cache->set(self::TEMPLATE_CACHE_PREFIX.$fileName,array($template,$timestamps));
8425 8959
 				return $template;
8426 8960
 			}
8961
+		} else {
8962
+					return null;
8427 8963
 		}
8428
-		else
8429
-			return null;
8430 8964
 	}
8431 8965
 	protected function getLocalizedTemplate($filename)
8432 8966
 	{
8433
-		if(($app=$this->getApplication()->getGlobalization(false))===null)
8434
-			return is_file($filename)?$filename:null;
8967
+		if(($app=$this->getApplication()->getGlobalization(false))===null) {
8968
+					return is_file($filename)?$filename:null;
8969
+		}
8435 8970
 		foreach($app->getLocalizedResource($filename) as $file)
8436 8971
 		{
8437
-			if(($file=realpath($file))!==false && is_file($file))
8438
-				return $file;
8972
+			if(($file=realpath($file))!==false && is_file($file)) {
8973
+							return $file;
8974
+			}
8439 8975
 		}
8440 8976
 		return null;
8441 8977
 	}
@@ -8498,118 +9034,139 @@  discard block
 block discarded – undo
8498 9034
 	public function instantiateIn($tplControl,$parentControl=null)
8499 9035
 	{
8500 9036
 		$this->_tplControl=$tplControl;
8501
-		if($parentControl===null)
8502
-			$parentControl=$tplControl;
8503
-		if(($page=$tplControl->getPage())===null)
8504
-			$page=$this->getService()->getRequestedPage();
9037
+		if($parentControl===null) {
9038
+					$parentControl=$tplControl;
9039
+		}
9040
+		if(($page=$tplControl->getPage())===null) {
9041
+					$page=$this->getService()->getRequestedPage();
9042
+		}
8505 9043
 		$controls=array();
8506 9044
 		$directChildren=array();
8507 9045
 		foreach($this->_tpl as $key=>$object)
8508 9046
 		{
8509
-			if($object[0]===-1)
8510
-				$parent=$parentControl;
8511
-			else if(isset($controls[$object[0]]))
8512
-				$parent=$controls[$object[0]];
8513
-			else
8514
-				continue;
9047
+			if($object[0]===-1) {
9048
+							$parent=$parentControl;
9049
+			} else if(isset($controls[$object[0]])) {
9050
+							$parent=$controls[$object[0]];
9051
+			} else {
9052
+							continue;
9053
+			}
8515 9054
 			if(isset($object[2]))				{
8516 9055
 				$component=Prado::createComponent($object[1]);
8517 9056
 				$properties=&$object[2];
8518 9057
 				if($component instanceof TControl)
8519 9058
 				{
8520
-					if($component instanceof TOutputCache)
8521
-						$component->setCacheKeyPrefix($this->_hashCode.$key);
9059
+					if($component instanceof TOutputCache) {
9060
+											$component->setCacheKeyPrefix($this->_hashCode.$key);
9061
+					}
8522 9062
 					$component->setTemplateControl($tplControl);
8523 9063
 					if(isset($properties['id']))
8524 9064
 					{
8525
-						if(is_array($properties['id']))
8526
-							$properties['id']=$component->evaluateExpression($properties['id'][1]);
9065
+						if(is_array($properties['id'])) {
9066
+													$properties['id']=$component->evaluateExpression($properties['id'][1]);
9067
+						}
8527 9068
 						$tplControl->registerObject($properties['id'],$component);
8528 9069
 					}
8529 9070
 					if(isset($properties['skinid']))
8530 9071
 					{
8531
-						if(is_array($properties['skinid']))
8532
-							$component->setSkinID($component->evaluateExpression($properties['skinid'][1]));
8533
-						else
8534
-							$component->setSkinID($properties['skinid']);
9072
+						if(is_array($properties['skinid'])) {
9073
+													$component->setSkinID($component->evaluateExpression($properties['skinid'][1]));
9074
+						} else {
9075
+													$component->setSkinID($properties['skinid']);
9076
+						}
8535 9077
 						unset($properties['skinid']);
8536 9078
 					}
8537 9079
 					$component->trackViewState(false);
8538 9080
 					$component->applyStyleSheetSkin($page);
8539
-					foreach($properties as $name=>$value)
8540
-						$this->configureControl($component,$name,$value);
9081
+					foreach($properties as $name=>$value) {
9082
+											$this->configureControl($component,$name,$value);
9083
+					}
8541 9084
 					$component->trackViewState(true);
8542
-					if($parent===$parentControl)
8543
-						$directChildren[]=$component;
8544
-					else
8545
-						$component->createdOnTemplate($parent);
8546
-					if($component->getAllowChildControls())
8547
-						$controls[$key]=$component;
8548
-				}
8549
-				else if($component instanceof TComponent)
9085
+					if($parent===$parentControl) {
9086
+											$directChildren[]=$component;
9087
+					} else {
9088
+											$component->createdOnTemplate($parent);
9089
+					}
9090
+					if($component->getAllowChildControls()) {
9091
+											$controls[$key]=$component;
9092
+					}
9093
+				} else if($component instanceof TComponent)
8550 9094
 				{
8551 9095
 					$controls[$key]=$component;
8552 9096
 					if(isset($properties['id']))
8553 9097
 					{
8554
-						if(is_array($properties['id']))
8555
-							$properties['id']=$component->evaluateExpression($properties['id'][1]);
9098
+						if(is_array($properties['id'])) {
9099
+													$properties['id']=$component->evaluateExpression($properties['id'][1]);
9100
+						}
8556 9101
 						$tplControl->registerObject($properties['id'],$component);
8557
-						if(!$component->hasProperty('id'))
8558
-							unset($properties['id']);
9102
+						if(!$component->hasProperty('id')) {
9103
+													unset($properties['id']);
9104
+						}
9105
+					}
9106
+					foreach($properties as $name=>$value) {
9107
+											$this->configureComponent($component,$name,$value);
9108
+					}
9109
+					if($parent===$parentControl) {
9110
+											$directChildren[]=$component;
9111
+					} else {
9112
+											$component->createdOnTemplate($parent);
8559 9113
 					}
8560
-					foreach($properties as $name=>$value)
8561
-						$this->configureComponent($component,$name,$value);
8562
-					if($parent===$parentControl)
8563
-						$directChildren[]=$component;
8564
-					else
8565
-						$component->createdOnTemplate($parent);
8566 9114
 				}
8567
-			}
8568
-			else
9115
+			} else
8569 9116
 			{
8570 9117
 				if($object[1] instanceof TCompositeLiteral)
8571 9118
 				{
8572 9119
 										$o=clone $object[1];
8573 9120
 					$o->setContainer($tplControl);
8574
-					if($parent===$parentControl)
8575
-						$directChildren[]=$o;
8576
-					else
8577
-						$parent->addParsedObject($o);
8578
-				}
8579
-				else
9121
+					if($parent===$parentControl) {
9122
+											$directChildren[]=$o;
9123
+					} else {
9124
+											$parent->addParsedObject($o);
9125
+					}
9126
+				} else
8580 9127
 				{
8581
-					if($parent===$parentControl)
8582
-						$directChildren[]=$object[1];
8583
-					else
8584
-						$parent->addParsedObject($object[1]);
9128
+					if($parent===$parentControl) {
9129
+											$directChildren[]=$object[1];
9130
+					} else {
9131
+											$parent->addParsedObject($object[1]);
9132
+					}
8585 9133
 				}
8586 9134
 			}
8587 9135
 		}
8588 9136
 								foreach($directChildren as $control)
8589 9137
 		{
8590
-			if($control instanceof TComponent)
8591
-				$control->createdOnTemplate($parentControl);
8592
-			else
8593
-				$parentControl->addParsedObject($control);
9138
+			if($control instanceof TComponent) {
9139
+							$control->createdOnTemplate($parentControl);
9140
+			} else {
9141
+							$parentControl->addParsedObject($control);
9142
+			}
8594 9143
 		}
8595 9144
 	}
8596 9145
 	protected function configureControl($control,$name,$value)
8597 9146
 	{
8598
-		if(strncasecmp($name,'on',2)===0)					$this->configureEvent($control,$name,$value,$control);
8599
-		else if(($pos=strrpos($name,'.'))===false)				$this->configureProperty($control,$name,$value);
8600
-		else				$this->configureSubProperty($control,$name,$value);
9147
+		if(strncasecmp($name,'on',2)===0) {
9148
+			$this->configureEvent($control,$name,$value,$control);
9149
+		} else if(($pos=strrpos($name,'.'))===false) {
9150
+			$this->configureProperty($control,$name,$value);
9151
+		} else {
9152
+			$this->configureSubProperty($control,$name,$value);
9153
+		}
8601 9154
 	}
8602 9155
 	protected function configureComponent($component,$name,$value)
8603 9156
 	{
8604
-		if(strpos($name,'.')===false)				$this->configureProperty($component,$name,$value);
8605
-		else				$this->configureSubProperty($component,$name,$value);
9157
+		if(strpos($name,'.')===false) {
9158
+			$this->configureProperty($component,$name,$value);
9159
+		} else {
9160
+			$this->configureSubProperty($component,$name,$value);
9161
+		}
8606 9162
 	}
8607 9163
 	protected function configureEvent($control,$name,$value,$contextControl)
8608 9164
 	{
8609
-		if(strpos($value,'.')===false)
8610
-			$control->attachEventHandler($name,array($contextControl,'TemplateControl.'.$value));
8611
-		else
8612
-			$control->attachEventHandler($name,array($contextControl,$value));
9165
+		if(strpos($value,'.')===false) {
9166
+					$control->attachEventHandler($name,array($contextControl,'TemplateControl.'.$value));
9167
+		} else {
9168
+					$control->attachEventHandler($name,array($contextControl,$value));
9169
+		}
8613 9170
 	}
8614 9171
 	protected function configureProperty($component,$name,$value)
8615 9172
 	{
@@ -8621,9 +9178,9 @@  discard block
 block discarded – undo
8621 9178
 					$component->bindProperty($name,$value[1]);
8622 9179
 					break;
8623 9180
 				case self::CONFIG_EXPRESSION:
8624
-					if($component instanceof TControl)
8625
-						$component->autoBindProperty($name,$value[1]);
8626
-					else
9181
+					if($component instanceof TControl) {
9182
+											$component->autoBindProperty($name,$value[1]);
9183
+					} else
8627 9184
 					{
8628 9185
 						$setter='set'.$name;
8629 9186
 						$component->$setter($this->_tplControl->evaluateExpression($value[1]));
@@ -8647,12 +9204,12 @@  discard block
 block discarded – undo
8647 9204
 				default:						throw new TConfigurationException('template_tag_unexpected',$name,$value[1]);
8648 9205
 					break;
8649 9206
 			}
8650
-		}
8651
-		else
9207
+		} else
8652 9208
 		{
8653
-			if (substr($name,0,2)=='js')
8654
-				if ($value and !($value instanceof TJavaScriptLiteral))
9209
+			if (substr($name,0,2)=='js') {
9210
+							if ($value and !($value instanceof TJavaScriptLiteral))
8655 9211
 					$value = new TJavaScriptLiteral($value);
9212
+			}
8656 9213
 			$setter='set'.$name;
8657 9214
 			$component->$setter($value);
8658 9215
 		}
@@ -8665,10 +9222,11 @@  discard block
 block discarded – undo
8665 9222
 			{
8666 9223
 				case self::CONFIG_DATABIND:							$component->bindProperty($name,$value[1]);
8667 9224
 					break;
8668
-				case self::CONFIG_EXPRESSION:							if($component instanceof TControl)
8669
-						$component->autoBindProperty($name,$value[1]);
8670
-					else
8671
-						$component->setSubProperty($name,$this->_tplControl->evaluateExpression($value[1]));
9225
+				case self::CONFIG_EXPRESSION:							if($component instanceof TControl) {
9226
+										$component->autoBindProperty($name,$value[1]);
9227
+				} else {
9228
+											$component->setSubProperty($name,$this->_tplControl->evaluateExpression($value[1]));
9229
+					}
8672 9230
 					break;
8673 9231
 				case self::CONFIG_TEMPLATE:
8674 9232
 					$component->setSubProperty($name,$value[1]);
@@ -8684,9 +9242,9 @@  discard block
 block discarded – undo
8684 9242
 				default:						throw new TConfigurationException('template_tag_unexpected',$name,$value[1]);
8685 9243
 					break;
8686 9244
 			}
9245
+		} else {
9246
+					$component->setSubProperty($name,$value);
8687 9247
 		}
8688
-		else
8689
-			$component->setSubProperty($name,$value);
8690 9248
 	}
8691 9249
 	protected function parse($input)
8692 9250
 	{
@@ -8709,10 +9267,12 @@  discard block
 block discarded – undo
8709 9267
 				$matchStart=$match[0][1];
8710 9268
 				$matchEnd=$matchStart+strlen($str)-1;
8711 9269
 				if(strpos($str,'<com:')===0)					{
8712
-					if($expectPropEnd)
8713
-						continue;
8714
-					if($matchStart>$textStart)
8715
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
9270
+					if($expectPropEnd) {
9271
+											continue;
9272
+					}
9273
+					if($matchStart>$textStart) {
9274
+											$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
9275
+					}
8716 9276
 					$textStart=$matchEnd+1;
8717 9277
 					$type=$match[1][0];
8718 9278
 					$attributes=$this->parseAttributes($match[2][0],$match[2][1]);
@@ -8722,16 +9282,18 @@  discard block
 block discarded – undo
8722 9282
 						$stack[] = $type;
8723 9283
 						$container=$c-1;
8724 9284
 					}
8725
-				}
8726
-				else if(strpos($str,'</com:')===0)					{
8727
-					if($expectPropEnd)
8728
-						continue;
8729
-					if($matchStart>$textStart)
8730
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
9285
+				} else if(strpos($str,'</com:')===0)					{
9286
+					if($expectPropEnd) {
9287
+											continue;
9288
+					}
9289
+					if($matchStart>$textStart) {
9290
+											$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
9291
+					}
8731 9292
 					$textStart=$matchEnd+1;
8732 9293
 					$type=$match[1][0];
8733
-					if(empty($stack))
8734
-						throw new TConfigurationException('template_closingtag_unexpected',"</com:$type>");
9294
+					if(empty($stack)) {
9295
+											throw new TConfigurationException('template_closingtag_unexpected',"</com:$type>");
9296
+					}
8735 9297
 					$name=array_pop($stack);
8736 9298
 					if($name!==$type)
8737 9299
 					{
@@ -8739,77 +9301,85 @@  discard block
 block discarded – undo
8739 9301
 						throw new TConfigurationException('template_closingtag_expected',$tag);
8740 9302
 					}
8741 9303
 					$container=$tpl[$container][0];
8742
-				}
8743
-				else if(strpos($str,'<%@')===0)					{
8744
-					if($expectPropEnd)
8745
-						continue;
8746
-					if($matchStart>$textStart)
8747
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
9304
+				} else if(strpos($str,'<%@')===0)					{
9305
+					if($expectPropEnd) {
9306
+											continue;
9307
+					}
9308
+					if($matchStart>$textStart) {
9309
+											$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
9310
+					}
8748 9311
 					$textStart=$matchEnd+1;
8749
-					if(isset($tpl[0]) || $this->_directive!==null)
8750
-						throw new TConfigurationException('template_directive_nonunique');
9312
+					if(isset($tpl[0]) || $this->_directive!==null) {
9313
+											throw new TConfigurationException('template_directive_nonunique');
9314
+					}
8751 9315
 					$this->_directive=$this->parseAttributes($match[4][0],$match[4][1]);
8752
-				}
8753
-				else if(strpos($str,'<%')===0)					{
8754
-					if($expectPropEnd)
8755
-						continue;
8756
-					if($matchStart>$textStart)
8757
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
9316
+				} else if(strpos($str,'<%')===0)					{
9317
+					if($expectPropEnd) {
9318
+											continue;
9319
+					}
9320
+					if($matchStart>$textStart) {
9321
+											$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
9322
+					}
8758 9323
 					$textStart=$matchEnd+1;
8759 9324
 					$literal=trim($match[5][0]);
8760
-					if($str[2]==='=')							$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,$literal));
8761
-					else if($str[2]==='%')  						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_STATEMENTS,$literal));
8762
-					else if($str[2]==='#')
8763
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_DATABINDING,$literal));
8764
-					else if($str[2]==='$')
8765
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')"));
8766
-					else if($str[2]==='~')
8767
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')"));
8768
-					else if($str[2]==='/')
8769
-						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'"));
8770
-					else if($str[2]==='[')
9325
+					if($str[2]==='=') {
9326
+						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,$literal));
9327
+					} else if($str[2]==='%') {
9328
+						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_STATEMENTS,$literal));
9329
+					} else if($str[2]==='#') {
9330
+											$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_DATABINDING,$literal));
9331
+					} else if($str[2]==='$') {
9332
+											$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->getApplication()->getParameters()->itemAt('$literal')"));
9333
+					} else if($str[2]==='~') {
9334
+											$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"\$this->publishFilePath('$this->_contextPath/$literal')"));
9335
+					} else if($str[2]==='/') {
9336
+											$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'"));
9337
+					} else if($str[2]==='[')
8771 9338
 					{
8772 9339
 						$literal=strtr(trim(substr($literal,0,strlen($literal)-1)),array("'"=>"\'","\\"=>"\\\\"));
8773 9340
 						$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,"Prado::localize('$literal')"));
8774 9341
 					}
8775
-				}
8776
-				else if(strpos($str,'<prop:')===0)					{
9342
+				} else if(strpos($str,'<prop:')===0)					{
8777 9343
 					if(strrpos($str,'/>')===strlen($str)-2)  					{
8778
-						if($expectPropEnd)
8779
-							continue;
8780
-						if($matchStart>$textStart)
8781
-							$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
9344
+						if($expectPropEnd) {
9345
+													continue;
9346
+						}
9347
+						if($matchStart>$textStart) {
9348
+													$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
9349
+						}
8782 9350
 						$textStart=$matchEnd+1;
8783 9351
 						$prop=strtolower($match[6][0]);
8784 9352
 						$attrs=$this->parseAttributes($match[7][0],$match[7][1]);
8785 9353
 						$attributes=array();
8786
-						foreach($attrs as $name=>$value)
8787
-							$attributes[$prop.'.'.$name]=$value;
9354
+						foreach($attrs as $name=>$value) {
9355
+													$attributes[$prop.'.'.$name]=$value;
9356
+						}
8788 9357
 						$type=$tpl[$container][1];
8789 9358
 						$this->validateAttributes($type,$attributes);
8790 9359
 						foreach($attributes as $name=>$value)
8791 9360
 						{
8792
-							if(isset($tpl[$container][2][$name]))
8793
-								throw new TConfigurationException('template_property_duplicated',$name);
9361
+							if(isset($tpl[$container][2][$name])) {
9362
+															throw new TConfigurationException('template_property_duplicated',$name);
9363
+							}
8794 9364
 							$tpl[$container][2][$name]=$value;
8795 9365
 						}
8796
-					}
8797
-					else  					{
9366
+					} else  					{
8798 9367
 						$prop=strtolower($match[3][0]);
8799 9368
 						$stack[] = '@'.$prop;
8800 9369
 						if(!$expectPropEnd)
8801 9370
 						{
8802
-							if($matchStart>$textStart)
8803
-								$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
9371
+							if($matchStart>$textStart) {
9372
+															$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
9373
+							}
8804 9374
 							$textStart=$matchEnd+1;
8805 9375
 							$expectPropEnd=true;
8806 9376
 						}
8807 9377
 					}
8808
-				}
8809
-				else if(strpos($str,'</prop:')===0)					{
9378
+				} else if(strpos($str,'</prop:')===0)					{
8810 9379
 					$prop=strtolower($match[3][0]);
8811
-					if(empty($stack))
8812
-						throw new TConfigurationException('template_closingtag_unexpected',"</prop:$prop>");
9380
+					if(empty($stack)) {
9381
+											throw new TConfigurationException('template_closingtag_unexpected',"</prop:$prop>");
9382
+					}
8813 9383
 					$name=array_pop($stack);
8814 9384
 					if($name!=='@'.$prop)
8815 9385
 					{
@@ -8821,33 +9391,37 @@  discard block
 block discarded – undo
8821 9391
 						if($matchStart>$textStart)
8822 9392
 						{
8823 9393
 							$value=substr($input,$textStart,$matchStart-$textStart);
8824
-							if(substr($prop,-8,8)==='template')
8825
-								$value=$this->parseTemplateProperty($value,$textStart);
8826
-							else
8827
-								$value=$this->parseAttribute($value);
9394
+							if(substr($prop,-8,8)==='template') {
9395
+															$value=$this->parseTemplateProperty($value,$textStart);
9396
+							} else {
9397
+															$value=$this->parseAttribute($value);
9398
+							}
8828 9399
 							if($container>=0)
8829 9400
 							{
8830 9401
 								$type=$tpl[$container][1];
8831 9402
 								$this->validateAttributes($type,array($prop=>$value));
8832
-								if(isset($tpl[$container][2][$prop]))
8833
-									throw new TConfigurationException('template_property_duplicated',$prop);
9403
+								if(isset($tpl[$container][2][$prop])) {
9404
+																	throw new TConfigurationException('template_property_duplicated',$prop);
9405
+								}
8834 9406
 								$tpl[$container][2][$prop]=$value;
9407
+							} else {
9408
+								$this->_directive[$prop]=$value;
8835 9409
 							}
8836
-							else									$this->_directive[$prop]=$value;
8837 9410
 							$textStart=$matchEnd+1;
8838 9411
 						}
8839 9412
 						$expectPropEnd=false;
8840 9413
 					}
8841
-				}
8842
-				else if(strpos($str,'<!--')===0)					{
8843
-					if($expectPropEnd)
8844
-						throw new TConfigurationException('template_comments_forbidden');
8845
-					if($matchStart>$textStart)
8846
-						$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
9414
+				} else if(strpos($str,'<!--')===0)					{
9415
+					if($expectPropEnd) {
9416
+											throw new TConfigurationException('template_comments_forbidden');
9417
+					}
9418
+					if($matchStart>$textStart) {
9419
+											$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
9420
+					}
8847 9421
 					$textStart=$matchEnd+1;
9422
+				} else {
9423
+									throw new TConfigurationException('template_matching_unexpected',$match);
8848 9424
 				}
8849
-				else
8850
-					throw new TConfigurationException('template_matching_unexpected',$match);
8851 9425
 			}
8852 9426
 			if(!empty($stack))
8853 9427
 			{
@@ -8855,21 +9429,24 @@  discard block
 block discarded – undo
8855 9429
 				$tag=$name[0]==='@' ? '</prop:'.substr($name,1).'>' : "</com:$name>";
8856 9430
 				throw new TConfigurationException('template_closingtag_expected',$tag);
8857 9431
 			}
8858
-			if($textStart<strlen($input))
8859
-				$tpl[$c++]=array($container,substr($input,$textStart));
8860
-		}
8861
-		catch(Exception $e)
9432
+			if($textStart<strlen($input)) {
9433
+							$tpl[$c++]=array($container,substr($input,$textStart));
9434
+			}
9435
+		} catch(Exception $e)
8862 9436
 		{
8863
-			if(($e instanceof TException) && ($e instanceof TTemplateException))
8864
-				throw $e;
8865
-			if($matchEnd===0)
8866
-				$line=$this->_startingLine+1;
8867
-			else
8868
-				$line=$this->_startingLine+count(explode("\n",substr($input,0,$matchEnd+1)));
9437
+			if(($e instanceof TException) && ($e instanceof TTemplateException)) {
9438
+							throw $e;
9439
+			}
9440
+			if($matchEnd===0) {
9441
+							$line=$this->_startingLine+1;
9442
+			} else {
9443
+							$line=$this->_startingLine+count(explode("\n",substr($input,0,$matchEnd+1)));
9444
+			}
8869 9445
 			$this->handleException($e,$line,$input);
8870 9446
 		}
8871
-		if($this->_directive===null)
8872
-			$this->_directive=array();
9447
+		if($this->_directive===null) {
9448
+					$this->_directive=array();
9449
+		}
8873 9450
 				$objects=array();
8874 9451
 		$parent=null;
8875 9452
 		$merged=array();
@@ -8879,39 +9456,41 @@  discard block
 block discarded – undo
8879 9456
 			{
8880 9457
 				if($parent!==null)
8881 9458
 				{
8882
-					if(count($merged[1])===1 && is_string($merged[1][0]))
8883
-						$objects[$id-1]=array($merged[0],$merged[1][0]);
8884
-					else
8885
-						$objects[$id-1]=array($merged[0],new TCompositeLiteral($merged[1]));
9459
+					if(count($merged[1])===1 && is_string($merged[1][0])) {
9460
+											$objects[$id-1]=array($merged[0],$merged[1][0]);
9461
+					} else {
9462
+											$objects[$id-1]=array($merged[0],new TCompositeLiteral($merged[1]));
9463
+					}
8886 9464
 				}
8887 9465
 				if(isset($object[2]))
8888 9466
 				{
8889 9467
 					$parent=null;
8890 9468
 					$objects[$id]=$object;
8891
-				}
8892
-				else
9469
+				} else
8893 9470
 				{
8894 9471
 					$parent=$object[0];
8895 9472
 					$merged=array($parent,array($object[1]));
8896 9473
 				}
9474
+			} else {
9475
+							$merged[1][]=$object[1];
8897 9476
 			}
8898
-			else
8899
-				$merged[1][]=$object[1];
8900 9477
 		}
8901 9478
 		if($parent!==null)
8902 9479
 		{
8903
-			if(count($merged[1])===1 && is_string($merged[1][0]))
8904
-				$objects[$id]=array($merged[0],$merged[1][0]);
8905
-			else
8906
-				$objects[$id]=array($merged[0],new TCompositeLiteral($merged[1]));
9480
+			if(count($merged[1])===1 && is_string($merged[1][0])) {
9481
+							$objects[$id]=array($merged[0],$merged[1][0]);
9482
+			} else {
9483
+							$objects[$id]=array($merged[0],new TCompositeLiteral($merged[1]));
9484
+			}
8907 9485
 		}
8908 9486
 		$tpl=$objects;
8909 9487
 		return $objects;
8910 9488
 	}
8911 9489
 	protected function parseAttributes($str,$offset)
8912 9490
 	{
8913
-		if($str==='')
8914
-			return array();
9491
+		if($str==='') {
9492
+					return array();
9493
+		}
8915 9494
 		$pattern='/([\w\.\-]+)\s*=\s*(\'.*?\'|".*?"|<%.*?%>)/msS';
8916 9495
 		$attributes=array();
8917 9496
 		$n=preg_match_all($pattern,$str,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
@@ -8919,22 +9498,24 @@  discard block
 block discarded – undo
8919 9498
 		{
8920 9499
 			$match=&$matches[$i];
8921 9500
 			$name=strtolower($match[1][0]);
8922
-			if(isset($attributes[$name]))
8923
-				throw new TConfigurationException('template_property_duplicated',$name);
9501
+			if(isset($attributes[$name])) {
9502
+							throw new TConfigurationException('template_property_duplicated',$name);
9503
+			}
8924 9504
 			$value=$match[2][0];
8925 9505
 			if(substr($name,-8,8)==='template')
8926 9506
 			{
8927
-				if($value[0]==='\'' || $value[0]==='"')
8928
-					$attributes[$name]=$this->parseTemplateProperty(substr($value,1,strlen($value)-2),$match[2][1]+1);
8929
-				else
8930
-					$attributes[$name]=$this->parseTemplateProperty($value,$match[2][1]);
8931
-			}
8932
-			else
9507
+				if($value[0]==='\'' || $value[0]==='"') {
9508
+									$attributes[$name]=$this->parseTemplateProperty(substr($value,1,strlen($value)-2),$match[2][1]+1);
9509
+				} else {
9510
+									$attributes[$name]=$this->parseTemplateProperty($value,$match[2][1]);
9511
+				}
9512
+			} else
8933 9513
 			{
8934
-				if($value[0]==='\'' || $value[0]==='"')
8935
-					$attributes[$name]=$this->parseAttribute(substr($value,1,strlen($value)-2));
8936
-				else
8937
-					$attributes[$name]=$this->parseAttribute($value);
9514
+				if($value[0]==='\'' || $value[0]==='"') {
9515
+									$attributes[$name]=$this->parseAttribute(substr($value,1,strlen($value)-2));
9516
+				} else {
9517
+									$attributes[$name]=$this->parseAttribute($value);
9518
+				}
8938 9519
 			}
8939 9520
 		}
8940 9521
 		return $attributes;
@@ -8957,45 +9538,49 @@  discard block
 block discarded – undo
8957 9538
 				$token=$match[0];
8958 9539
 				$offset=$match[1];
8959 9540
 				$length=strlen($token);
8960
-				if($token[2]==='#')
8961
-					$isDataBind=true;
8962
-				if($offset>$textStart)
8963
-					$expr.=".'".strtr(substr($value,$textStart,$offset-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'";
9541
+				if($token[2]==='#') {
9542
+									$isDataBind=true;
9543
+				}
9544
+				if($offset>$textStart) {
9545
+									$expr.=".'".strtr(substr($value,$textStart,$offset-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'";
9546
+				}
8964 9547
 				$expr.='.('.substr($token,3,$length-5).')';
8965 9548
 				$textStart=$offset+$length;
8966 9549
 			}
8967 9550
 			$length=strlen($value);
8968
-			if($length>$textStart)
8969
-				$expr.=".'".strtr(substr($value,$textStart,$length-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'";
8970
-			if($isDataBind)
8971
-				return array(self::CONFIG_DATABIND,ltrim($expr,'.'));
8972
-			else
8973
-				return array(self::CONFIG_EXPRESSION,ltrim($expr,'.'));
8974
-		}
8975
-		else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value)
9551
+			if($length>$textStart) {
9552
+							$expr.=".'".strtr(substr($value,$textStart,$length-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'";
9553
+			}
9554
+			if($isDataBind) {
9555
+							return array(self::CONFIG_DATABIND,ltrim($expr,'.'));
9556
+			} else {
9557
+							return array(self::CONFIG_EXPRESSION,ltrim($expr,'.'));
9558
+			}
9559
+		} else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>|<%\/.*?%>)\\s*/msS',$value,$matches) && $matches[0]===$value)
8976 9560
 		{
8977 9561
 			$value=$matches[1];
8978
-			if($value[2]==='~')
8979
-				return array(self::CONFIG_ASSET,trim(substr($value,3,strlen($value)-5)));
8980
-			elseif($value[2]==='[')
8981
-				return array(self::CONFIG_LOCALIZATION,trim(substr($value,3,strlen($value)-6)));
8982
-			elseif($value[2]==='$')
8983
-				return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5)));
8984
-			elseif($value[2]==='/') {
9562
+			if($value[2]==='~') {
9563
+							return array(self::CONFIG_ASSET,trim(substr($value,3,strlen($value)-5)));
9564
+			} elseif($value[2]==='[') {
9565
+							return array(self::CONFIG_LOCALIZATION,trim(substr($value,3,strlen($value)-6)));
9566
+			} elseif($value[2]==='$') {
9567
+							return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5)));
9568
+			} elseif($value[2]==='/') {
8985 9569
 				$literal = trim(substr($value,3,strlen($value)-5));
8986 9570
 				return array(self::CONFIG_EXPRESSION,"rtrim(dirname(\$this->getApplication()->getRequest()->getApplicationUrl()), '/').'/$literal'");
8987 9571
 			}
9572
+		} else {
9573
+					return $value;
8988 9574
 		}
8989
-		else
8990
-			return $value;
8991 9575
 	}
8992 9576
 	protected function validateAttributes($type,$attributes)
8993 9577
 	{
8994 9578
 		Prado::using($type);
8995
-		if(($pos=strrpos($type,'.'))!==false)
8996
-			$className=substr($type,$pos+1);
8997
-		else
8998
-			$className=$type;
9579
+		if(($pos=strrpos($type,'.'))!==false) {
9580
+					$className=substr($type,$pos+1);
9581
+		} else {
9582
+					$className=$type;
9583
+		}
8999 9584
 		$class=new ReflectionClass($className);
9000 9585
 		if(is_subclass_of($className,'TControl') || $className==='TControl')
9001 9586
 		{
@@ -9004,63 +9589,65 @@  discard block
 block discarded – undo
9004 9589
 				if(($pos=strpos($name,'.'))!==false)
9005 9590
 				{
9006 9591
 										$subname=substr($name,0,$pos);
9007
-					if(!$class->hasMethod('get'.$subname))
9008
-						throw new TConfigurationException('template_property_unknown',$type,$subname);
9009
-				}
9010
-				else if(strncasecmp($name,'on',2)===0)
9592
+					if(!$class->hasMethod('get'.$subname)) {
9593
+											throw new TConfigurationException('template_property_unknown',$type,$subname);
9594
+					}
9595
+				} else if(strncasecmp($name,'on',2)===0)
9011 9596
 				{
9012
-										if(!$class->hasMethod($name))
9013
-						throw new TConfigurationException('template_event_unknown',$type,$name);
9014
-					else if(!is_string($att))
9015
-						throw new TConfigurationException('template_eventhandler_invalid',$type,$name);
9016
-				}
9017
-				else
9597
+										if(!$class->hasMethod($name)) {
9598
+																throw new TConfigurationException('template_event_unknown',$type,$name);
9599
+										} else if(!is_string($att)) {
9600
+											throw new TConfigurationException('template_eventhandler_invalid',$type,$name);
9601
+					}
9602
+				} else
9018 9603
 				{
9019 9604
 										if (! ($class->hasMethod('set'.$name) || $class->hasMethod('setjs'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)) )
9020 9605
 					{
9021
-						if ($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name))
9022
-							throw new TConfigurationException('template_property_readonly',$type,$name);
9023
-						else
9024
-							throw new TConfigurationException('template_property_unknown',$type,$name);
9025
-					}
9026
-					else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION)
9606
+						if ($class->hasMethod('get'.$name) || $class->hasMethod('getjs'.$name)) {
9607
+													throw new TConfigurationException('template_property_readonly',$type,$name);
9608
+						} else {
9609
+													throw new TConfigurationException('template_property_unknown',$type,$name);
9610
+						}
9611
+					} else if(is_array($att) && $att[0]!==self::CONFIG_EXPRESSION)
9027 9612
 					{
9028
-						if(strcasecmp($name,'id')===0)
9029
-							throw new TConfigurationException('template_controlid_invalid',$type);
9030
-						else if(strcasecmp($name,'skinid')===0)
9031
-							throw new TConfigurationException('template_controlskinid_invalid',$type);
9613
+						if(strcasecmp($name,'id')===0) {
9614
+													throw new TConfigurationException('template_controlid_invalid',$type);
9615
+						} else if(strcasecmp($name,'skinid')===0) {
9616
+													throw new TConfigurationException('template_controlskinid_invalid',$type);
9617
+						}
9032 9618
 					}
9033 9619
 				}
9034 9620
 			}
9035
-		}
9036
-		else if(is_subclass_of($className,'TComponent') || $className==='TComponent')
9621
+		} else if(is_subclass_of($className,'TComponent') || $className==='TComponent')
9037 9622
 		{
9038 9623
 			foreach($attributes as $name=>$att)
9039 9624
 			{
9040
-				if(is_array($att) && ($att[0]===self::CONFIG_DATABIND))
9041
-					throw new TConfigurationException('template_databind_forbidden',$type,$name);
9625
+				if(is_array($att) && ($att[0]===self::CONFIG_DATABIND)) {
9626
+									throw new TConfigurationException('template_databind_forbidden',$type,$name);
9627
+				}
9042 9628
 				if(($pos=strpos($name,'.'))!==false)
9043 9629
 				{
9044 9630
 										$subname=substr($name,0,$pos);
9045
-					if(!$class->hasMethod('get'.$subname))
9046
-						throw new TConfigurationException('template_property_unknown',$type,$subname);
9047
-				}
9048
-				else if(strncasecmp($name,'on',2)===0)
9049
-					throw new TConfigurationException('template_event_forbidden',$type,$name);
9050
-				else
9631
+					if(!$class->hasMethod('get'.$subname)) {
9632
+											throw new TConfigurationException('template_property_unknown',$type,$subname);
9633
+					}
9634
+				} else if(strncasecmp($name,'on',2)===0) {
9635
+									throw new TConfigurationException('template_event_forbidden',$type,$name);
9636
+				} else
9051 9637
 				{
9052 9638
 										if(strcasecmp($name,'id')!==0 && !($class->hasMethod('set'.$name) || $this->isClassBehaviorMethod($class,'set'.$name)))
9053 9639
 					{
9054
-						if($class->hasMethod('get'.$name))
9055
-							throw new TConfigurationException('template_property_readonly',$type,$name);
9056
-						else
9057
-							throw new TConfigurationException('template_property_unknown',$type,$name);
9640
+						if($class->hasMethod('get'.$name)) {
9641
+													throw new TConfigurationException('template_property_readonly',$type,$name);
9642
+						} else {
9643
+													throw new TConfigurationException('template_property_unknown',$type,$name);
9644
+						}
9058 9645
 					}
9059 9646
 				}
9060 9647
 			}
9648
+		} else {
9649
+					throw new TConfigurationException('template_component_required',$type);
9061 9650
 		}
9062
-		else
9063
-			throw new TConfigurationException('template_component_required',$type);
9064 9651
 	}
9065 9652
 	public function getIncludedFiles()
9066 9653
 	{
@@ -9079,18 +9666,19 @@  discard block
 block discarded – undo
9079 9666
 						$line=$line-$this->_includeAtLine[$i]+1;
9080 9667
 						$srcFile=$this->_includedFiles[$i];
9081 9668
 						break;
9669
+					} else {
9670
+											$line=$line-$this->_includeLines[$i]+1;
9082 9671
 					}
9083
-					else
9084
-						$line=$line-$this->_includeLines[$i]+1;
9085 9672
 				}
9086 9673
 			}
9087 9674
 		}
9088 9675
 		$exception=new TTemplateException('template_format_invalid',$e->getMessage());
9089 9676
 		$exception->setLineNumber($line);
9090
-		if(!empty($srcFile))
9091
-			$exception->setTemplateFile($srcFile);
9092
-		else
9093
-			$exception->setTemplateSource($input);
9677
+		if(!empty($srcFile)) {
9678
+					$exception->setTemplateFile($srcFile);
9679
+		} else {
9680
+					$exception->setTemplateSource($input);
9681
+		}
9094 9682
 		throw $exception;
9095 9683
 	}
9096 9684
 	protected function preprocess($input)
@@ -9100,9 +9688,9 @@  discard block
 block discarded – undo
9100 9688
 			for($i=0;$i<$n;++$i)
9101 9689
 			{
9102 9690
 				$filePath=Prado::getPathOfNamespace(trim($matches[$i][1][0]),TTemplateManager::TEMPLATE_FILE_EXT);
9103
-				if($filePath!==null && is_file($filePath))
9104
-					$this->_includedFiles[]=$filePath;
9105
-				else
9691
+				if($filePath!==null && is_file($filePath)) {
9692
+									$this->_includedFiles[]=$filePath;
9693
+				} else
9106 9694
 				{
9107 9695
 					$errorLine=count(explode("\n",substr($input,0,$matches[$i][0][1]+1)));
9108 9696
 					$this->handleException(new TConfigurationException('template_include_invalid',trim($matches[$i][1][0])),$errorLine,$input);
@@ -9126,15 +9714,19 @@  discard block
 block discarded – undo
9126 9714
 	{
9127 9715
 	  $component=new ReflectionClass('TComponent');
9128 9716
 	  $behaviors=$component->getStaticProperties();
9129
-	  if(!isset($behaviors['_um']))
9130
-	    return false;
9717
+	  if(!isset($behaviors['_um'])) {
9718
+	  	    return false;
9719
+	  }
9131 9720
 	  foreach($behaviors['_um'] as $name=>$list)
9132 9721
 	  {
9133
-	    if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) continue;
9722
+	    if(strtolower($class->getShortName())!==$name && !$class->isSubclassOf($name)) {
9723
+	    	continue;
9724
+	    }
9134 9725
 	    foreach($list as $param)
9135 9726
 	    {
9136
-	      if(method_exists($param->getBehavior(),$method))
9137
-	        return true;
9727
+	      if(method_exists($param->getBehavior(),$method)) {
9728
+	      	        return true;
9729
+	      }
9138 9730
 	    }
9139 9731
 	  }
9140 9732
 	  return false;
@@ -9152,10 +9744,11 @@  discard block
 block discarded – undo
9152 9744
 	{
9153 9745
 		$this->_initialized=true;
9154 9746
 		$service=$this->getService();
9155
-		if($service instanceof TPageService)
9156
-			$service->setThemeManager($this);
9157
-		else
9158
-			throw new TConfigurationException('thememanager_service_unavailable');
9747
+		if($service instanceof TPageService) {
9748
+					$service->setThemeManager($this);
9749
+		} else {
9750
+					throw new TConfigurationException('thememanager_service_unavailable');
9751
+		}
9159 9752
 	}
9160 9753
 	public function getTheme($name)
9161 9754
 	{
@@ -9176,8 +9769,9 @@  discard block
 block discarded – undo
9176 9769
 		$folder=@opendir($basePath);
9177 9770
 		while($file=@readdir($folder))
9178 9771
 		{
9179
-			if($file!=='.' && $file!=='..' && $file!=='.svn' && is_dir($basePath.DIRECTORY_SEPARATOR.$file))
9180
-				$themes[]=$file;
9772
+			if($file!=='.' && $file!=='..' && $file!=='.svn' && is_dir($basePath.DIRECTORY_SEPARATOR.$file)) {
9773
+							$themes[]=$file;
9774
+			}
9181 9775
 		}
9182 9776
 		closedir($folder);
9183 9777
 		return $themes;
@@ -9187,21 +9781,23 @@  discard block
 block discarded – undo
9187 9781
 		if($this->_basePath===null)
9188 9782
 		{
9189 9783
 			$this->_basePath=dirname($this->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH;
9190
-			if(($basePath=realpath($this->_basePath))===false || !is_dir($basePath))
9191
-				throw new TConfigurationException('thememanager_basepath_invalid2',$this->_basePath);
9784
+			if(($basePath=realpath($this->_basePath))===false || !is_dir($basePath)) {
9785
+							throw new TConfigurationException('thememanager_basepath_invalid2',$this->_basePath);
9786
+			}
9192 9787
 			$this->_basePath=$basePath;
9193 9788
 		}
9194 9789
 		return $this->_basePath;
9195 9790
 	}
9196 9791
 	public function setBasePath($value)
9197 9792
 	{
9198
-		if($this->_initialized)
9199
-			throw new TInvalidOperationException('thememanager_basepath_unchangeable');
9200
-		else
9793
+		if($this->_initialized) {
9794
+					throw new TInvalidOperationException('thememanager_basepath_unchangeable');
9795
+		} else
9201 9796
 		{
9202 9797
 			$this->_basePath=Prado::getPathOfNamespace($value);
9203
-			if($this->_basePath===null || !is_dir($this->_basePath))
9204
-				throw new TInvalidDataValueException('thememanager_basepath_invalid',$value);
9798
+			if($this->_basePath===null || !is_dir($this->_basePath)) {
9799
+							throw new TInvalidDataValueException('thememanager_basepath_invalid',$value);
9800
+			}
9205 9801
 		}
9206 9802
 	}
9207 9803
 	public function getBaseUrl()
@@ -9210,8 +9806,9 @@  discard block
 block discarded – undo
9210 9806
 		{
9211 9807
 			$appPath=dirname($this->getRequest()->getApplicationFilePath());
9212 9808
 			$basePath=$this->getBasePath();
9213
-			if(strpos($basePath,$appPath)===false)
9214
-				throw new TConfigurationException('thememanager_baseurl_required');
9809
+			if(strpos($basePath,$appPath)===false) {
9810
+							throw new TConfigurationException('thememanager_baseurl_required');
9811
+			}
9215 9812
 			$appUrl=rtrim(dirname($this->getRequest()->getApplicationUrl()),'/\\');
9216 9813
 			$this->_baseUrl=$appUrl.strtr(substr($basePath,strlen($appPath)),'\\','/');
9217 9814
 		}
@@ -9246,28 +9843,29 @@  discard block
 block discarded – undo
9246 9843
 				list($skins,$cssFiles,$jsFiles,$timestamp)=$array;
9247 9844
 				if($this->getApplication()->getMode()!==TApplicationMode::Performance)
9248 9845
 				{
9249
-					if(($dir=opendir($themePath))===false)
9250
-						throw new TIOException('theme_path_inexistent',$themePath);
9846
+					if(($dir=opendir($themePath))===false) {
9847
+											throw new TIOException('theme_path_inexistent',$themePath);
9848
+					}
9251 9849
 					$cacheValid=true;
9252 9850
 					while(($file=readdir($dir))!==false)
9253 9851
 					{
9254
-						if($file==='.' || $file==='..')
9255
-							continue;
9256
-						else if(basename($file,'.css')!==$file)
9257
-							$this->_cssFiles[]=$themeUrl.'/'.$file;
9258
-						else if(basename($file,'.js')!==$file)
9259
-							$this->_jsFiles[]=$themeUrl.'/'.$file;
9260
-						else if(basename($file,self::SKIN_FILE_EXT)!==$file && filemtime($themePath.DIRECTORY_SEPARATOR.$file)>$timestamp)
9852
+						if($file==='.' || $file==='..') {
9853
+													continue;
9854
+						} else if(basename($file,'.css')!==$file) {
9855
+													$this->_cssFiles[]=$themeUrl.'/'.$file;
9856
+						} else if(basename($file,'.js')!==$file) {
9857
+													$this->_jsFiles[]=$themeUrl.'/'.$file;
9858
+						} else if(basename($file,self::SKIN_FILE_EXT)!==$file && filemtime($themePath.DIRECTORY_SEPARATOR.$file)>$timestamp)
9261 9859
 						{
9262 9860
 							$cacheValid=false;
9263 9861
 							break;
9264 9862
 						}
9265 9863
 					}
9266 9864
 					closedir($dir);
9267
-					if($cacheValid)
9268
-						$this->_skins=$skins;
9269
-				}
9270
-				else
9865
+					if($cacheValid) {
9866
+											$this->_skins=$skins;
9867
+					}
9868
+				} else
9271 9869
 				{
9272 9870
 					$cacheValid=true;
9273 9871
 					$this->_cssFiles=$cssFiles;
@@ -9281,29 +9879,33 @@  discard block
 block discarded – undo
9281 9879
 			$this->_cssFiles=array();
9282 9880
 			$this->_jsFiles=array();
9283 9881
 			$this->_skins=array();
9284
-			if(($dir=opendir($themePath))===false)
9285
-				throw new TIOException('theme_path_inexistent',$themePath);
9882
+			if(($dir=opendir($themePath))===false) {
9883
+							throw new TIOException('theme_path_inexistent',$themePath);
9884
+			}
9286 9885
 			while(($file=readdir($dir))!==false)
9287 9886
 			{
9288
-				if($file==='.' || $file==='..')
9289
-					continue;
9290
-				else if(basename($file,'.css')!==$file)
9291
-					$this->_cssFiles[]=$themeUrl.'/'.$file;
9292
-				else if(basename($file,'.js')!==$file)
9293
-					$this->_jsFiles[]=$themeUrl.'/'.$file;
9294
-				else if(basename($file,self::SKIN_FILE_EXT)!==$file)
9887
+				if($file==='.' || $file==='..') {
9888
+									continue;
9889
+				} else if(basename($file,'.css')!==$file) {
9890
+									$this->_cssFiles[]=$themeUrl.'/'.$file;
9891
+				} else if(basename($file,'.js')!==$file) {
9892
+									$this->_jsFiles[]=$themeUrl.'/'.$file;
9893
+				} else if(basename($file,self::SKIN_FILE_EXT)!==$file)
9295 9894
 				{
9296 9895
 					$template=new TTemplate(file_get_contents($themePath.'/'.$file),$themePath,$themePath.'/'.$file);
9297 9896
 					foreach($template->getItems() as $skin)
9298 9897
 					{
9299
-						if(!isset($skin[2]))  							continue;
9300
-						else if($skin[0]!==-1)
9301
-							throw new TConfigurationException('theme_control_nested',$skin[1],dirname($themePath));
9898
+						if(!isset($skin[2])) {
9899
+							continue;
9900
+						} else if($skin[0]!==-1) {
9901
+													throw new TConfigurationException('theme_control_nested',$skin[1],dirname($themePath));
9902
+						}
9302 9903
 						$type=$skin[1];
9303 9904
 						$id=isset($skin[2]['skinid'])?$skin[2]['skinid']:0;
9304 9905
 						unset($skin[2]['skinid']);
9305
-						if(isset($this->_skins[$type][$id]))
9306
-							throw new TConfigurationException('theme_skinid_duplicated',$type,$id,dirname($themePath));
9906
+						if(isset($this->_skins[$type][$id])) {
9907
+													throw new TConfigurationException('theme_skinid_duplicated',$type,$id,dirname($themePath));
9908
+						}
9307 9909
 						$this->_skins[$type][$id]=$skin[2];
9308 9910
 					}
9309 9911
 				}
@@ -9311,8 +9913,9 @@  discard block
 block discarded – undo
9311 9913
 			closedir($dir);
9312 9914
 			sort($this->_cssFiles);
9313 9915
 			sort($this->_jsFiles);
9314
-			if($cache!==null)
9315
-				$cache->set(self::THEME_CACHE_PREFIX.$themePath,array($this->_skins,$this->_cssFiles,$this->_jsFiles,time()));
9916
+			if($cache!==null) {
9917
+							$cache->set(self::THEME_CACHE_PREFIX.$themePath,array($this->_skins,$this->_cssFiles,$this->_jsFiles,time()));
9918
+			}
9316 9919
 		}
9317 9920
 	}
9318 9921
 	public function getName()
@@ -9350,8 +9953,9 @@  discard block
 block discarded – undo
9350 9953
 	public function applySkin($control)
9351 9954
 	{
9352 9955
 		$type=get_class($control);
9353
-		if(($id=$control->getSkinID())==='')
9354
-			$id=0;
9956
+		if(($id=$control->getSkinID())==='') {
9957
+					$id=0;
9958
+		}
9355 9959
 		if(isset($this->_skins[$type][$id]))
9356 9960
 		{
9357 9961
 			foreach($this->_skins[$type][$id] as $name=>$value)
@@ -9392,20 +9996,21 @@  discard block
 block discarded – undo
9392 9996
 							{
9393 9997
 								$setter='set'.$name;
9394 9998
 								$control->$setter($value);
9999
+							} else {
10000
+															throw new TConfigurationException('theme_property_readonly',$type,$name);
9395 10001
 							}
9396
-							else
9397
-								throw new TConfigurationException('theme_property_readonly',$type,$name);
10002
+						} else {
10003
+													throw new TConfigurationException('theme_property_undefined',$type,$name);
9398 10004
 						}
9399
-						else
9400
-							throw new TConfigurationException('theme_property_undefined',$type,$name);
10005
+					} else {
10006
+						$control->setSubProperty($name,$value);
9401 10007
 					}
9402
-					else							$control->setSubProperty($name,$value);
9403 10008
 				}
9404 10009
 			}
9405 10010
 			return true;
10011
+		} else {
10012
+					return false;
9406 10013
 		}
9407
-		else
9408
-			return false;
9409 10014
 	}
9410 10015
 	public function getStyleSheetFiles()
9411 10016
 	{
@@ -9451,8 +10056,9 @@  discard block
 block discarded – undo
9451 10056
 	protected function initPageContext($pageConfig)
9452 10057
 	{
9453 10058
 		$application=$this->getApplication();
9454
-		foreach($pageConfig->getApplicationConfigurations() as $appConfig)
9455
-			$application->applyConfiguration($appConfig);
10059
+		foreach($pageConfig->getApplicationConfigurations() as $appConfig) {
10060
+					$application->applyConfiguration($appConfig);
10061
+		}
9456 10062
 		$this->applyConfiguration($pageConfig);
9457 10063
 	}
9458 10064
 	protected function applyConfiguration($config)
@@ -9463,12 +10069,14 @@  discard block
 block discarded – undo
9463 10069
 				foreach($config->getExternalConfigurations() as $filePath=>$params)
9464 10070
 		{
9465 10071
 			list($configPagePath,$condition)=$params;
9466
-			if($condition!==true)
9467
-				$condition=$this->evaluateExpression($condition);
10072
+			if($condition!==true) {
10073
+							$condition=$this->evaluateExpression($condition);
10074
+			}
9468 10075
 			if($condition)
9469 10076
 			{
9470
-				if(($path=Prado::getPathOfNamespace($filePath,Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path))
9471
-					throw new TConfigurationException('pageservice_includefile_invalid',$filePath);
10077
+				if(($path=Prado::getPathOfNamespace($filePath,Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path)) {
10078
+									throw new TConfigurationException('pageservice_includefile_invalid',$filePath);
10079
+				}
9472 10080
 				$c=new TPageConfiguration($pagePath);
9473 10081
 				$c->loadFromFile($path,$configPagePath);
9474 10082
 				$this->applyConfiguration($c);
@@ -9478,8 +10086,9 @@  discard block
 block discarded – undo
9478 10086
 	protected function determineRequestedPagePath()
9479 10087
 	{
9480 10088
 		$pagePath=$this->getRequest()->getServiceParameter();
9481
-		if(empty($pagePath))
9482
-			$pagePath=$this->getDefaultPage();
10089
+		if(empty($pagePath)) {
10090
+					$pagePath=$this->getDefaultPage();
10091
+		}
9483 10092
 		return $pagePath;
9484 10093
 	}
9485 10094
 	protected function loadPageConfig($config)
@@ -9491,14 +10100,14 @@  discard block
 block discarded – undo
9491 10100
 			$pageConfig=new TPageConfiguration($pagePath);
9492 10101
 			if($config!==null)
9493 10102
 			{
9494
-				if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
9495
-					$pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),'');
9496
-				else
9497
-					$pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),'');
10103
+				if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) {
10104
+									$pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),'');
10105
+				} else {
10106
+									$pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),'');
10107
+				}
9498 10108
 			}
9499 10109
 			$pageConfig->loadFromFiles($this->getBasePath());
9500
-		}
9501
-		else
10110
+		} else
9502 10111
 		{
9503 10112
 			$configCached=true;
9504 10113
 			$currentTimestamp=array();
@@ -9513,19 +10122,19 @@  discard block
 block discarded – undo
9513 10122
 						if($fileName===0) 						{
9514 10123
 							$appConfigFile=$application->getConfigurationFile();
9515 10124
 							$currentTimestamp[0]=$appConfigFile===null?0:@filemtime($appConfigFile);
9516
-							if($currentTimestamp[0]>$timestamp || ($timestamp>0 && !$currentTimestamp[0]))
9517
-								$configCached=false;
9518
-						}
9519
-						else
10125
+							if($currentTimestamp[0]>$timestamp || ($timestamp>0 && !$currentTimestamp[0])) {
10126
+															$configCached=false;
10127
+							}
10128
+						} else
9520 10129
 						{
9521 10130
 							$currentTimestamp[$fileName]=@filemtime($fileName);
9522
-							if($currentTimestamp[$fileName]>$timestamp || ($timestamp>0 && !$currentTimestamp[$fileName]))
9523
-								$configCached=false;
10131
+							if($currentTimestamp[$fileName]>$timestamp || ($timestamp>0 && !$currentTimestamp[$fileName])) {
10132
+															$configCached=false;
10133
+							}
9524 10134
 						}
9525 10135
 					}
9526 10136
 				}
9527
-			}
9528
-			else
10137
+			} else
9529 10138
 			{
9530 10139
 				$configCached=false;
9531 10140
 				$paths=explode('.',$pagePath);
@@ -9547,10 +10156,11 @@  discard block
 block discarded – undo
9547 10156
 				$pageConfig=new TPageConfiguration($pagePath);
9548 10157
 				if($config!==null)
9549 10158
 				{
9550
-					if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
9551
-						$pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),'');
9552
-					else
9553
-						$pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),'');
10159
+					if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) {
10160
+											$pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),'');
10161
+					} else {
10162
+											$pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),'');
10163
+					}
9554 10164
 				}
9555 10165
 				$pageConfig->loadFromFiles($this->getBasePath());
9556 10166
 				$cache->set(self::CONFIG_CACHE_PREFIX.$this->getID().$pagePath,array($pageConfig,$currentTimestamp));
@@ -9589,8 +10199,9 @@  discard block
 block discarded – undo
9589 10199
 		if($this->_pagePath===null)
9590 10200
 		{
9591 10201
 			$this->_pagePath=strtr($this->determineRequestedPagePath(),'/\\','..');
9592
-			if(empty($this->_pagePath))
9593
-				throw new THttpException(404,'pageservice_page_required');
10202
+			if(empty($this->_pagePath)) {
10203
+							throw new THttpException(404,'pageservice_page_required');
10204
+			}
9594 10205
 		}
9595 10206
 		return $this->_pagePath;
9596 10207
 	}
@@ -9604,10 +10215,11 @@  discard block
 block discarded – undo
9604 10215
 	}
9605 10216
 	public function setDefaultPage($value)
9606 10217
 	{
9607
-		if($this->_initialized)
9608
-			throw new TInvalidOperationException('pageservice_defaultpage_unchangeable');
9609
-		else
9610
-			$this->_defaultPage=$value;
10218
+		if($this->_initialized) {
10219
+					throw new TInvalidOperationException('pageservice_defaultpage_unchangeable');
10220
+		} else {
10221
+					$this->_defaultPage=$value;
10222
+		}
9611 10223
 	}
9612 10224
 	public function getDefaultPageUrl()
9613 10225
 	{
@@ -9621,18 +10233,20 @@  discard block
 block discarded – undo
9621 10233
 			if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath))
9622 10234
 			{
9623 10235
 				$basePath=$this->getApplication()->getBasePath().DIRECTORY_SEPARATOR.self::FALLBACK_BASEPATH;
9624
-				if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath))
9625
-					throw new TConfigurationException('pageservice_basepath_invalid',$basePath);
10236
+				if(($this->_basePath=realpath($basePath))===false || !is_dir($this->_basePath)) {
10237
+									throw new TConfigurationException('pageservice_basepath_invalid',$basePath);
10238
+				}
9626 10239
 			}
9627 10240
 		}
9628 10241
 		return $this->_basePath;
9629 10242
 	}
9630 10243
 	public function setBasePath($value)
9631 10244
 	{
9632
-		if($this->_initialized)
9633
-			throw new TInvalidOperationException('pageservice_basepath_unchangeable');
9634
-		else if(($path=Prado::getPathOfNamespace($value))===null || !is_dir($path))
9635
-			throw new TConfigurationException('pageservice_basepath_invalid',$value);
10245
+		if($this->_initialized) {
10246
+					throw new TInvalidOperationException('pageservice_basepath_unchangeable');
10247
+		} else if(($path=Prado::getPathOfNamespace($value))===null || !is_dir($path)) {
10248
+					throw new TConfigurationException('pageservice_basepath_invalid',$value);
10249
+		}
9636 10250
 		$this->_basePath=realpath($path);
9637 10251
 	}
9638 10252
 	public function setBasePageClass($value)
@@ -9661,33 +10275,38 @@  discard block
 block discarded – undo
9661 10275
 		$path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath,'.',DIRECTORY_SEPARATOR);
9662 10276
 		$hasTemplateFile=is_file($path.self::PAGE_FILE_EXT);
9663 10277
 		$hasClassFile=is_file($path.Prado::CLASS_FILE_EXT);
9664
-		if(!$hasTemplateFile && !$hasClassFile)
9665
-			throw new THttpException(404,'pageservice_page_unknown',$pagePath);
10278
+		if(!$hasTemplateFile && !$hasClassFile) {
10279
+					throw new THttpException(404,'pageservice_page_unknown',$pagePath);
10280
+		}
9666 10281
 		if($hasClassFile)
9667 10282
 		{
9668 10283
 			$className=basename($path);
9669
-			if(!class_exists($className,false))
9670
-				include_once($path.Prado::CLASS_FILE_EXT);
9671
-		}
9672
-		else
10284
+			if(!class_exists($className,false)) {
10285
+							include_once($path.Prado::CLASS_FILE_EXT);
10286
+			}
10287
+		} else
9673 10288
 		{
9674 10289
 			$className=$this->getBasePageClass();
9675 10290
 			Prado::using($className);
9676
-			if(($pos=strrpos($className,'.'))!==false)
9677
-				$className=substr($className,$pos+1);
10291
+			if(($pos=strrpos($className,'.'))!==false) {
10292
+							$className=substr($className,$pos+1);
10293
+			}
9678 10294
 		}
9679
- 		if(!class_exists($className,false) || ($className!=='TPage' && !is_subclass_of($className,'TPage')))
9680
-			throw new THttpException(404,'pageservice_page_unknown',$pagePath);
10295
+ 		if(!class_exists($className,false) || ($className!=='TPage' && !is_subclass_of($className,'TPage'))) {
10296
+ 					throw new THttpException(404,'pageservice_page_unknown',$pagePath);
10297
+ 		}
9681 10298
 		$page=Prado::createComponent($className);
9682 10299
 		$page->setPagePath($pagePath);
9683
-		if($hasTemplateFile)
9684
-			$page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path.self::PAGE_FILE_EXT));
10300
+		if($hasTemplateFile) {
10301
+					$page->setTemplate($this->getTemplateManager()->getTemplateByFileName($path.self::PAGE_FILE_EXT));
10302
+		}
9685 10303
 		return $page;
9686 10304
 	}
9687 10305
 	protected function runPage($page,$properties)
9688 10306
 	{
9689
-		foreach($properties as $name=>$value)
9690
-			$page->setSubProperty($name,$value);
10307
+		foreach($properties as $name=>$value) {
10308
+					$page->setSubProperty($name,$value);
10309
+		}
9691 10310
 		$page->run($this->getResponse()->createHtmlWriter());
9692 10311
 	}
9693 10312
 	public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=true,$encodeGetItems=true)
@@ -9735,30 +10354,32 @@  discard block
 block discarded – undo
9735 10354
 		{
9736 10355
 			$this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath);
9737 10356
 			$path.=DIRECTORY_SEPARATOR.$p;
9738
-			if($configPagePath==='')
9739
-				$configPagePath=$p;
9740
-			else
9741
-				$configPagePath.='.'.$p;
10357
+			if($configPagePath==='') {
10358
+							$configPagePath=$p;
10359
+			} else {
10360
+							$configPagePath.='.'.$p;
10361
+			}
9742 10362
 		}
9743 10363
 		$this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath);
9744 10364
 		$this->_rules=new TAuthorizationRuleCollection($this->_rules);
9745 10365
 	}
9746 10366
 	public function loadFromFile($fname,$configPagePath)
9747 10367
 	{
9748
-		if(empty($fname) || !is_file($fname))
9749
-			return;
10368
+		if(empty($fname) || !is_file($fname)) {
10369
+					return;
10370
+		}
9750 10371
 		if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
9751 10372
 		{
9752 10373
 			$fcontent = include $fname;
9753 10374
 			$this->loadFromPhp($fcontent,dirname($fname),$configPagePath);
9754
-		}
9755
-		else
10375
+		} else
9756 10376
 		{
9757 10377
 			$dom=new TXmlDocument;
9758
-			if($dom->loadFromFile($fname))
9759
-				$this->loadFromXml($dom,dirname($fname),$configPagePath);
9760
-			else
9761
-				throw new TConfigurationException('pageserviceconf_file_invalid',$fname);
10378
+			if($dom->loadFromFile($fname)) {
10379
+							$this->loadFromXml($dom,dirname($fname),$configPagePath);
10380
+			} else {
10381
+							throw new TConfigurationException('pageserviceconf_file_invalid',$fname);
10382
+			}
9762 10383
 		}
9763 10384
 	}
9764 10385
 	public function loadFromPhp($config,$configPath,$configPagePath)
@@ -9792,14 +10413,17 @@  discard block
 block discarded – undo
9792 10413
 			{
9793 10414
 				$patterns=isset($authorization['pages'])?$authorization['pages']:'';
9794 10415
 				$ruleApplies=false;
9795
-				if(empty($patterns) || trim($patterns)==='*') 					$ruleApplies=true;
9796
-				else
10416
+				if(empty($patterns) || trim($patterns)==='*') {
10417
+					$ruleApplies=true;
10418
+				} else
9797 10419
 				{
9798 10420
 					foreach(explode(',',$patterns) as $pattern)
9799 10421
 					{
9800 10422
 						if(($pattern=trim($pattern))!=='')
9801 10423
 						{
9802
-														if($configPagePath!=='')  								$pattern=$configPagePath.'.'.$pattern;
10424
+														if($configPagePath!=='') {
10425
+															$pattern=$configPagePath.'.'.$pattern;
10426
+														}
9803 10427
 							if(strcasecmp($pattern,$this->_pagePath)===0)
9804 10428
 							{
9805 10429
 								$ruleApplies=true;
@@ -9844,11 +10468,14 @@  discard block
 block discarded – undo
9844 10468
 				}
9845 10469
 				$matching=false;
9846 10470
 				$id=($configPagePath==='')?$id:$configPagePath.'.'.$id;
9847
-				if(strcasecmp($id,$this->_pagePath)===0)
9848
-					$matching=true;
9849
-				else if($id[strlen($id)-1]==='*') 					$matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0;
9850
-				if($matching)
9851
-					$this->_properties=array_merge($this->_properties,$properties);
10471
+				if(strcasecmp($id,$this->_pagePath)===0) {
10472
+									$matching=true;
10473
+				} else if($id[strlen($id)-1]==='*') {
10474
+					$matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0;
10475
+				}
10476
+				if($matching) {
10477
+									$this->_properties=array_merge($this->_properties,$properties);
10478
+				}
9852 10479
 			}
9853 10480
 		}
9854 10481
 				if(isset($config['includes']) && is_array($config['includes']))
@@ -9856,13 +10483,15 @@  discard block
 block discarded – undo
9856 10483
 			foreach($config['includes'] as $include)
9857 10484
 			{
9858 10485
 				$when = isset($include['when'])?true:false;
9859
-				if(!isset($include['file']))
9860
-					throw new TConfigurationException('pageserviceconf_includefile_required');
10486
+				if(!isset($include['file'])) {
10487
+									throw new TConfigurationException('pageserviceconf_includefile_required');
10488
+				}
9861 10489
 				$filePath = $include['file'];
9862
-				if(isset($this->_includes[$filePath]))
9863
-					$this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')');
9864
-				else
9865
-					$this->_includes[$filePath]=array($configPagePath,$when);
10490
+				if(isset($this->_includes[$filePath])) {
10491
+									$this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')');
10492
+				} else {
10493
+									$this->_includes[$filePath]=array($configPagePath,$when);
10494
+				}
9866 10495
 			}
9867 10496
 		}
9868 10497
 	}
@@ -9875,14 +10504,17 @@  discard block
 block discarded – undo
9875 10504
 			{
9876 10505
 				$patterns=$node->getAttribute('pages');
9877 10506
 				$ruleApplies=false;
9878
-				if(empty($patterns) || trim($patterns)==='*') 					$ruleApplies=true;
9879
-				else
10507
+				if(empty($patterns) || trim($patterns)==='*') {
10508
+					$ruleApplies=true;
10509
+				} else
9880 10510
 				{
9881 10511
 					foreach(explode(',',$patterns) as $pattern)
9882 10512
 					{
9883 10513
 						if(($pattern=trim($pattern))!=='')
9884 10514
 						{
9885
-														if($configPagePath!=='')  								$pattern=$configPagePath.'.'.$pattern;
10515
+														if($configPagePath!=='') {
10516
+															$pattern=$configPagePath.'.'.$pattern;
10517
+														}
9886 10518
 							if(strcasecmp($pattern,$this->_pagePath)===0)
9887 10519
 							{
9888 10520
 								$ruleApplies=true;
@@ -9898,8 +10530,9 @@  discard block
 block discarded – undo
9898 10530
 						}
9899 10531
 					}
9900 10532
 				}
9901
-				if($ruleApplies)
9902
-					$rules[]=new TAuthorizationRule($node->getTagName(),$node->getAttribute('users'),$node->getAttribute('roles'),$node->getAttribute('verb'),$node->getAttribute('ips'));
10533
+				if($ruleApplies) {
10534
+									$rules[]=new TAuthorizationRule($node->getTagName(),$node->getAttribute('users'),$node->getAttribute('roles'),$node->getAttribute('verb'),$node->getAttribute('ips'));
10535
+				}
9903 10536
 			}
9904 10537
 			$this->_rules=array_merge($rules,$this->_rules);
9905 10538
 		}
@@ -9910,27 +10543,34 @@  discard block
 block discarded – undo
9910 10543
 			{
9911 10544
 				$properties=$node->getAttributes();
9912 10545
 				$id=$properties->remove('id');
9913
-				if(empty($id))
9914
-					throw new TConfigurationException('pageserviceconf_page_invalid',$configPath);
10546
+				if(empty($id)) {
10547
+									throw new TConfigurationException('pageserviceconf_page_invalid',$configPath);
10548
+				}
9915 10549
 				$matching=false;
9916 10550
 				$id=($configPagePath==='')?$id:$configPagePath.'.'.$id;
9917
-				if(strcasecmp($id,$this->_pagePath)===0)
9918
-					$matching=true;
9919
-				else if($id[strlen($id)-1]==='*') 					$matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0;
9920
-				if($matching)
9921
-					$this->_properties=array_merge($this->_properties,$properties->toArray());
10551
+				if(strcasecmp($id,$this->_pagePath)===0) {
10552
+									$matching=true;
10553
+				} else if($id[strlen($id)-1]==='*') {
10554
+					$matching=strncasecmp($this->_pagePath,$id,strlen($id)-1)===0;
10555
+				}
10556
+				if($matching) {
10557
+									$this->_properties=array_merge($this->_properties,$properties->toArray());
10558
+				}
9922 10559
 			}
9923 10560
 		}
9924 10561
 				foreach($dom->getElementsByTagName('include') as $node)
9925 10562
 		{
9926
-			if(($when=$node->getAttribute('when'))===null)
9927
-				$when=true;
9928
-			if(($filePath=$node->getAttribute('file'))===null)
9929
-				throw new TConfigurationException('pageserviceconf_includefile_required');
9930
-			if(isset($this->_includes[$filePath]))
9931
-				$this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')');
9932
-			else
9933
-				$this->_includes[$filePath]=array($configPagePath,$when);
10563
+			if(($when=$node->getAttribute('when'))===null) {
10564
+							$when=true;
10565
+			}
10566
+			if(($filePath=$node->getAttribute('file'))===null) {
10567
+							throw new TConfigurationException('pageserviceconf_includefile_required');
10568
+			}
10569
+			if(isset($this->_includes[$filePath])) {
10570
+							$this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')');
10571
+			} else {
10572
+							$this->_includes[$filePath]=array($configPagePath,$when);
10573
+			}
9934 10574
 		}
9935 10575
 	}
9936 10576
 }
@@ -9946,12 +10586,15 @@  discard block
 block discarded – undo
9946 10586
 	public function init($config)
9947 10587
 	{
9948 10588
 		$application=$this->getApplication();
9949
-		if($this->_basePath===null)
9950
-			$this->_basePath=dirname($application->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH;
9951
-		if(!is_writable($this->_basePath) || !is_dir($this->_basePath))
9952
-			throw new TConfigurationException('assetmanager_basepath_invalid',$this->_basePath);
9953
-		if($this->_baseUrl===null)
9954
-			$this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()),'/\\').'/'.self::DEFAULT_BASEPATH;
10589
+		if($this->_basePath===null) {
10590
+					$this->_basePath=dirname($application->getRequest()->getApplicationFilePath()).DIRECTORY_SEPARATOR.self::DEFAULT_BASEPATH;
10591
+		}
10592
+		if(!is_writable($this->_basePath) || !is_dir($this->_basePath)) {
10593
+					throw new TConfigurationException('assetmanager_basepath_invalid',$this->_basePath);
10594
+		}
10595
+		if($this->_baseUrl===null) {
10596
+					$this->_baseUrl=rtrim(dirname($application->getRequest()->getApplicationUrl()),'/\\').'/'.self::DEFAULT_BASEPATH;
10597
+		}
9955 10598
 		$application->setAssetManager($this);
9956 10599
 		$this->_initialized=true;
9957 10600
 	}
@@ -9961,13 +10604,14 @@  discard block
 block discarded – undo
9961 10604
 	}
9962 10605
 	public function setBasePath($value)
9963 10606
 	{
9964
-		if($this->_initialized)
9965
-			throw new TInvalidOperationException('assetmanager_basepath_unchangeable');
9966
-		else
10607
+		if($this->_initialized) {
10608
+					throw new TInvalidOperationException('assetmanager_basepath_unchangeable');
10609
+		} else
9967 10610
 		{
9968 10611
 			$this->_basePath=Prado::getPathOfNamespace($value);
9969
-			if($this->_basePath===null || !is_dir($this->_basePath) || !is_writable($this->_basePath))
9970
-				throw new TInvalidDataValueException('assetmanager_basepath_invalid',$value);
10612
+			if($this->_basePath===null || !is_dir($this->_basePath) || !is_writable($this->_basePath)) {
10613
+							throw new TInvalidDataValueException('assetmanager_basepath_invalid',$value);
10614
+			}
9971 10615
 		}
9972 10616
 	}
9973 10617
 	public function getBaseUrl()
@@ -9976,27 +10620,28 @@  discard block
 block discarded – undo
9976 10620
 	}
9977 10621
 	public function setBaseUrl($value)
9978 10622
 	{
9979
-		if($this->_initialized)
9980
-			throw new TInvalidOperationException('assetmanager_baseurl_unchangeable');
9981
-		else
9982
-			$this->_baseUrl=rtrim($value,'/');
10623
+		if($this->_initialized) {
10624
+					throw new TInvalidOperationException('assetmanager_baseurl_unchangeable');
10625
+		} else {
10626
+					$this->_baseUrl=rtrim($value,'/');
10627
+		}
9983 10628
 	}
9984 10629
 	public function publishFilePath($path,$checkTimestamp=false)
9985 10630
 	{
9986
-		if(isset($this->_published[$path]))
9987
-			return $this->_published[$path];
9988
-		else if(empty($path) || ($fullpath=realpath($path))===false)
9989
-			throw new TInvalidDataValueException('assetmanager_filepath_invalid',$path);
9990
-		else if(is_file($fullpath))
10631
+		if(isset($this->_published[$path])) {
10632
+					return $this->_published[$path];
10633
+		} else if(empty($path) || ($fullpath=realpath($path))===false) {
10634
+					throw new TInvalidDataValueException('assetmanager_filepath_invalid',$path);
10635
+		} else if(is_file($fullpath))
9991 10636
 		{
9992 10637
 			$dir=$this->hash(dirname($fullpath));
9993 10638
 			$fileName=basename($fullpath);
9994 10639
 			$dst=$this->_basePath.DIRECTORY_SEPARATOR.$dir;
9995
-			if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance)
9996
-				$this->copyFile($fullpath,$dst);
10640
+			if(!is_file($dst.DIRECTORY_SEPARATOR.$fileName) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance) {
10641
+							$this->copyFile($fullpath,$dst);
10642
+			}
9997 10643
 			return $this->_published[$path]=$this->_baseUrl.'/'.$dir.'/'.$fileName;
9998
-		}
9999
-		else
10644
+		} else
10000 10645
 		{
10001 10646
 			$dir=$this->hash($fullpath);
10002 10647
 			if(!is_dir($this->_basePath.DIRECTORY_SEPARATOR.$dir) || $checkTimestamp || $this->getApplication()->getMode()!==TApplicationMode::Performance)
@@ -10017,18 +10662,20 @@  discard block
 block discarded – undo
10017 10662
 	public function getPublishedPath($path)
10018 10663
 	{
10019 10664
 		$path=realpath($path);
10020
-		if(is_file($path))
10021
-			return $this->_basePath.DIRECTORY_SEPARATOR.$this->hash(dirname($path)).DIRECTORY_SEPARATOR.basename($path);
10022
-		else
10023
-			return $this->_basePath.DIRECTORY_SEPARATOR.$this->hash($path);
10665
+		if(is_file($path)) {
10666
+					return $this->_basePath.DIRECTORY_SEPARATOR.$this->hash(dirname($path)).DIRECTORY_SEPARATOR.basename($path);
10667
+		} else {
10668
+					return $this->_basePath.DIRECTORY_SEPARATOR.$this->hash($path);
10669
+		}
10024 10670
 	}
10025 10671
 	public function getPublishedUrl($path)
10026 10672
 	{
10027 10673
 		$path=realpath($path);
10028
-		if(is_file($path))
10029
-			return $this->_baseUrl.'/'.$this->hash(dirname($path)).'/'.basename($path);
10030
-		else
10031
-			return $this->_baseUrl.'/'.$this->hash($path);
10674
+		if(is_file($path)) {
10675
+					return $this->_baseUrl.'/'.$this->hash(dirname($path)).'/'.basename($path);
10676
+		} else {
10677
+					return $this->_baseUrl.'/'.$this->hash($path);
10678
+		}
10032 10679
 	}
10033 10680
 	protected function hash($dir)
10034 10681
 	{
@@ -10058,18 +10705,18 @@  discard block
 block discarded – undo
10058 10705
 		{
10059 10706
 			while($file=@readdir($folder))
10060 10707
 			{
10061
-				if($file==='.' || $file==='..' || $file==='.svn')
10062
-					continue;
10063
-				else if(is_file($src.DIRECTORY_SEPARATOR.$file))
10708
+				if($file==='.' || $file==='..' || $file==='.svn') {
10709
+									continue;
10710
+				} else if(is_file($src.DIRECTORY_SEPARATOR.$file))
10064 10711
 				{
10065 10712
 					if(@filemtime($dst.DIRECTORY_SEPARATOR.$file)<@filemtime($src.DIRECTORY_SEPARATOR.$file))
10066 10713
 					{
10067 10714
 						@copy($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file);
10068 10715
 						@chmod($dst.DIRECTORY_SEPARATOR.$file, PRADO_CHMOD);
10069 10716
 					}
10717
+				} else {
10718
+									$this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file);
10070 10719
 				}
10071
-				else
10072
-					$this->copyDirectory($src.DIRECTORY_SEPARATOR.$file,$dst.DIRECTORY_SEPARATOR.$file);
10073 10720
 			}
10074 10721
 			closedir($folder);
10075 10722
 		} else {
@@ -10078,11 +10725,11 @@  discard block
 block discarded – undo
10078 10725
 	}
10079 10726
 	public function publishTarFile($tarfile, $md5sum, $checkTimestamp=false)
10080 10727
 	{
10081
-		if(isset($this->_published[$md5sum]))
10082
-			return $this->_published[$md5sum];
10083
-		else if(($fullpath=realpath($md5sum))===false || !is_file($fullpath))
10084
-			throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid',$md5sum);
10085
-		else
10728
+		if(isset($this->_published[$md5sum])) {
10729
+					return $this->_published[$md5sum];
10730
+		} else if(($fullpath=realpath($md5sum))===false || !is_file($fullpath)) {
10731
+					throw new TInvalidDataValueException('assetmanager_tarchecksum_invalid',$md5sum);
10732
+		} else
10086 10733
 		{
10087 10734
 			$dir=$this->hash(dirname($fullpath));
10088 10735
 			$fileName=basename($fullpath);
@@ -10100,9 +10747,9 @@  discard block
 block discarded – undo
10100 10747
 	}
10101 10748
 	protected function deployTarFile($path,$destination)
10102 10749
 	{
10103
-		if(($fullpath=realpath($path))===false || !is_file($fullpath))
10104
-			throw new TIOException('assetmanager_tarfile_invalid',$path);
10105
-		else
10750
+		if(($fullpath=realpath($path))===false || !is_file($fullpath)) {
10751
+					throw new TIOException('assetmanager_tarfile_invalid',$path);
10752
+		} else
10106 10753
 		{
10107 10754
 			Prado::using('System.IO.TTarFileExtractor');
10108 10755
 			$tar = new TTarFileExtractor($fullpath);
@@ -10120,21 +10767,24 @@  discard block
 block discarded – undo
10120 10767
 	private $_translateDefaultCulture=true;
10121 10768
 	public function init($config)
10122 10769
 	{
10123
-		if($this->_charset===null)
10124
-			$this->_charset=$this->getDefaultCharset();
10125
-		if($this->_culture===null)
10126
-			$this->_culture=$this->getDefaultCulture();
10770
+		if($this->_charset===null) {
10771
+					$this->_charset=$this->getDefaultCharset();
10772
+		}
10773
+		if($this->_culture===null) {
10774
+					$this->_culture=$this->getDefaultCulture();
10775
+		}
10127 10776
 		if($config!==null)
10128 10777
 		{
10129
-			if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
10130
-				$translation = isset($config['translate'])?$config['translate']:null;
10131
-			else
10778
+			if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP) {
10779
+							$translation = isset($config['translate'])?$config['translate']:null;
10780
+			} else
10132 10781
 			{
10133 10782
 				$t = $config->getElementByTagName('translation');
10134 10783
 				$translation = ($t)?$t->getAttributes():null;
10135 10784
 			}
10136
-			if($translation)
10137
-				$this->setTranslationConfiguration($translation);
10785
+			if($translation) {
10786
+							$this->setTranslationConfiguration($translation);
10787
+			}
10138 10788
 		}
10139 10789
 		$this->getApplication()->setGlobalization($this);
10140 10790
 	}
@@ -10193,12 +10843,12 @@  discard block
 block discarded – undo
10193 10843
 				$config['source'] = Prado::getPathOfNamespace($config['source']);
10194 10844
 				if(!is_dir($config['source']))
10195 10845
 				{
10196
-					if(@mkdir($config['source'])===false)
10197
-					throw new TConfigurationException('globalization_source_path_failed',
10846
+					if(@mkdir($config['source'])===false) {
10847
+										throw new TConfigurationException('globalization_source_path_failed',
10198 10848
 						$config['source']);
10849
+					}
10199 10850
 					chmod($config['source'], PRADO_CHMOD); 				}
10200
-			}
10201
-			else
10851
+			} else
10202 10852
 			{
10203 10853
 				throw new TConfigurationException("invalid source dir '{$config['source']}'");
10204 10854
 			}
@@ -10208,9 +10858,10 @@  discard block
 block discarded – undo
10208 10858
 			$config['cache'] = $this->getApplication()->getRunTimePath().'/i18n';
10209 10859
 			if(!is_dir($config['cache']))
10210 10860
 			{
10211
-				if(@mkdir($config['cache'])===false)
10212
-					throw new TConfigurationException('globalization_cache_path_failed',
10861
+				if(@mkdir($config['cache'])===false) {
10862
+									throw new TConfigurationException('globalization_cache_path_failed',
10213 10863
 						$config['cache']);
10864
+				}
10214 10865
 				chmod($config['cache'], PRADO_CHMOD); 			}
10215 10866
 		}
10216 10867
 		$this->_translation = $config;
@@ -10225,11 +10876,14 @@  discard block
 block discarded – undo
10225 10876
 	}
10226 10877
 	public function getCultureVariants($culture=null)
10227 10878
 	{
10228
-		if($culture===null) $culture = $this->getCulture();
10879
+		if($culture===null) {
10880
+			$culture = $this->getCulture();
10881
+		}
10229 10882
 		$variants = explode('_', $culture);
10230 10883
 		$result = array();
10231
-		for(; count($variants) > 0; array_pop($variants))
10232
-			$result[] = implode('_', $variants);
10884
+		for(; count($variants) > 0; array_pop($variants)) {
10885
+					$result[] = implode('_', $variants);
10886
+		}
10233 10887
 		return $result;
10234 10888
 	}
10235 10889
 	public function getLocalizedResource($file,$culture=null)
@@ -10237,11 +10891,13 @@  discard block
 block discarded – undo
10237 10891
 		$files = array();
10238 10892
 		$variants = $this->getCultureVariants($culture);
10239 10893
 		$path = pathinfo($file);
10240
-		foreach($variants as $variant)
10241
-			$files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename'];
10894
+		foreach($variants as $variant) {
10895
+					$files[] = $path['dirname'].DIRECTORY_SEPARATOR.$variant.DIRECTORY_SEPARATOR.$path['basename'];
10896
+		}
10242 10897
 		$filename = substr($path['basename'],0,strrpos($path['basename'],'.'));
10243
-		foreach($variants as $variant)
10244
-			$files[] = $path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension'];
10898
+		foreach($variants as $variant) {
10899
+					$files[] = $path['dirname'].DIRECTORY_SEPARATOR.$filename.'.'.$variant.'.'.$path['extension'];
10900
+		}
10245 10901
 		$files[] = $file;
10246 10902
 		return $files;
10247 10903
 	}
@@ -10312,8 +10968,9 @@  discard block
 block discarded – undo
10312 10968
 				Prado::setApplication($this);
10313 10969
 		$this->setConfigurationType($configType);
10314 10970
 		$this->resolvePaths($basePath);
10315
-		if($cacheConfig)
10316
-			$this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE;
10971
+		if($cacheConfig) {
10972
+					$this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE;
10973
+		}
10317 10974
 				$this->_uniqueID=md5($this->_runtimePath);
10318 10975
 		$this->_parameters=new TMap;
10319 10976
 		$this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null));
@@ -10321,17 +10978,18 @@  discard block
 block discarded – undo
10321 10978
 	}
10322 10979
 	protected function resolvePaths($basePath)
10323 10980
 	{
10324
-				if(empty($basePath) || ($basePath=realpath($basePath))===false)
10325
-			throw new TConfigurationException('application_basepath_invalid',$basePath);
10326
-		if(is_dir($basePath) && is_file($basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName()))
10327
-			$configFile=$basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName();
10328
-		else if(is_file($basePath))
10981
+				if(empty($basePath) || ($basePath=realpath($basePath))===false) {
10982
+							throw new TConfigurationException('application_basepath_invalid',$basePath);
10983
+				}
10984
+		if(is_dir($basePath) && is_file($basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName())) {
10985
+					$configFile=$basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName();
10986
+		} else if(is_file($basePath))
10329 10987
 		{
10330 10988
 			$configFile=$basePath;
10331 10989
 			$basePath=dirname($configFile);
10990
+		} else {
10991
+					$configFile=null;
10332 10992
 		}
10333
-		else
10334
-			$configFile=null;
10335 10993
 				$runtimePath=$basePath.DIRECTORY_SEPARATOR.self::RUNTIME_PATH;
10336 10994
 		if(is_writable($runtimePath))
10337 10995
 		{
@@ -10340,16 +10998,17 @@  discard block
 block discarded – undo
10340 10998
 				$runtimePath.=DIRECTORY_SEPARATOR.basename($configFile).'-'.Prado::getVersion();
10341 10999
 				if(!is_dir($runtimePath))
10342 11000
 				{
10343
-					if(@mkdir($runtimePath)===false)
10344
-						throw new TConfigurationException('application_runtimepath_failed',$runtimePath);
11001
+					if(@mkdir($runtimePath)===false) {
11002
+											throw new TConfigurationException('application_runtimepath_failed',$runtimePath);
11003
+					}
10345 11004
 					@chmod($runtimePath, PRADO_CHMOD); 				}
10346 11005
 				$this->setConfigurationFile($configFile);
10347 11006
 			}
10348 11007
 			$this->setBasePath($basePath);
10349 11008
 			$this->setRuntimePath($runtimePath);
11009
+		} else {
11010
+					throw new TConfigurationException('application_runtimepath_invalid',$runtimePath);
10350 11011
 		}
10351
-		else
10352
-			throw new TConfigurationException('application_runtimepath_invalid',$runtimePath);
10353 11012
 	}
10354 11013
 	public function run()
10355 11014
 	{
@@ -10361,16 +11020,17 @@  discard block
 block discarded – undo
10361 11020
 			$this->_requestCompleted=false;
10362 11021
 			while($this->_step<$n)
10363 11022
 			{
10364
-				if($this->_mode===self::STATE_OFF)
10365
-					throw new THttpException(503,'application_unavailable');
10366
-				if($this->_requestCompleted)
10367
-					break;
11023
+				if($this->_mode===self::STATE_OFF) {
11024
+									throw new THttpException(503,'application_unavailable');
11025
+				}
11026
+				if($this->_requestCompleted) {
11027
+									break;
11028
+				}
10368 11029
 				$method=self::$_steps[$this->_step];
10369 11030
 				$this->$method();
10370 11031
 				$this->_step++;
10371 11032
 			}
10372
-		}
10373
-		catch(Exception $e)
11033
+		} catch(Exception $e)
10374 11034
 		{
10375 11035
 			$this->onError($e);
10376 11036
 		}
@@ -10391,12 +11051,14 @@  discard block
 block discarded – undo
10391 11051
 	public function setGlobalState($key,$value,$defaultValue=null,$forceSave=false)
10392 11052
 	{
10393 11053
 		$this->_stateChanged=true;
10394
-		if($value===$defaultValue)
10395
-			unset($this->_globals[$key]);
10396
-		else
10397
-			$this->_globals[$key]=$value;
10398
-		if($forceSave)
10399
-			$this->saveGlobals();
11054
+		if($value===$defaultValue) {
11055
+					unset($this->_globals[$key]);
11056
+		} else {
11057
+					$this->_globals[$key]=$value;
11058
+		}
11059
+		if($forceSave) {
11060
+					$this->saveGlobals();
11061
+		}
10400 11062
 	}
10401 11063
 	public function clearGlobalState($key)
10402 11064
 	{
@@ -10505,8 +11167,9 @@  discard block
 block discarded – undo
10505 11167
 	public function setRuntimePath($value)
10506 11168
 	{
10507 11169
 		$this->_runtimePath=$value;
10508
-		if($this->_cacheFile)
10509
-			$this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE;
11170
+		if($this->_cacheFile) {
11171
+					$this->_cacheFile=$this->_runtimePath.DIRECTORY_SEPARATOR.self::CONFIGCACHE_FILE;
11172
+		}
10510 11173
 				$this->_uniqueID=md5($this->_runtimePath);
10511 11174
 	}
10512 11175
 	public function getService()
@@ -10519,15 +11182,17 @@  discard block
 block discarded – undo
10519 11182
 	}
10520 11183
 	public function setModule($id,IModule $module=null)
10521 11184
 	{
10522
-		if(isset($this->_modules[$id]))
10523
-			throw new TConfigurationException('application_moduleid_duplicated',$id);
10524
-		else
10525
-			$this->_modules[$id]=$module;
11185
+		if(isset($this->_modules[$id])) {
11186
+					throw new TConfigurationException('application_moduleid_duplicated',$id);
11187
+		} else {
11188
+					$this->_modules[$id]=$module;
11189
+		}
10526 11190
 	}
10527 11191
 	public function getModule($id)
10528 11192
 	{
10529
-		if(!array_key_exists($id, $this->_modules))
10530
-			return null;
11193
+		if(!array_key_exists($id, $this->_modules)) {
11194
+					return null;
11195
+		}
10531 11196
 				if($this->_modules[$id]===null)
10532 11197
 		{
10533 11198
 			$module = $this->internalLoadModule($id, true);
@@ -10665,8 +11330,9 @@  discard block
 block discarded – undo
10665 11330
 	}
10666 11331
 	public function getAuthorizationRules()
10667 11332
 	{
10668
-		if($this->_authRules===null)
10669
-			$this->_authRules=new TAuthorizationRuleCollection;
11333
+		if($this->_authRules===null) {
11334
+					$this->_authRules=new TAuthorizationRuleCollection;
11335
+		}
10670 11336
 		return $this->_authRules;
10671 11337
 	}
10672 11338
 	protected function getApplicationConfigurationClass()
@@ -10684,7 +11350,9 @@  discard block
 block discarded – undo
10684 11350
 		$module=Prado::createComponent($moduleClass);
10685 11351
 		foreach($initProperties as $name=>$value)
10686 11352
 		{
10687
-			if($name==='lazy') continue;
11353
+			if($name==='lazy') {
11354
+				continue;
11355
+			}
10688 11356
 			$module->setSubProperty($name,$value);
10689 11357
 		}
10690 11358
 		$this->setModule($id,$module);
@@ -10693,52 +11361,64 @@  discard block
 block discarded – undo
10693 11361
 	}
10694 11362
 	public function applyConfiguration($config,$withinService=false)
10695 11363
 	{
10696
-		if($config->getIsEmpty())
10697
-			return;
10698
-				foreach($config->getAliases() as $alias=>$path)
10699
-			Prado::setPathOfAlias($alias,$path);
10700
-		foreach($config->getUsings() as $using)
10701
-			Prado::using($using);
11364
+		if($config->getIsEmpty()) {
11365
+					return;
11366
+		}
11367
+				foreach($config->getAliases() as $alias=>$path) {
11368
+							Prado::setPathOfAlias($alias,$path);
11369
+				}
11370
+		foreach($config->getUsings() as $using) {
11371
+					Prado::using($using);
11372
+		}
10702 11373
 				if(!$withinService)
10703 11374
 		{
10704
-			foreach($config->getProperties() as $name=>$value)
10705
-				$this->setSubProperty($name,$value);
11375
+			foreach($config->getProperties() as $name=>$value) {
11376
+							$this->setSubProperty($name,$value);
11377
+			}
11378
+		}
11379
+		if(empty($this->_services)) {
11380
+					$this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null));
10706 11381
 		}
10707
-		if(empty($this->_services))
10708
-			$this->_services=array($this->getPageServiceID()=>array('TPageService',array(),null));
10709 11382
 				foreach($config->getParameters() as $id=>$parameter)
10710 11383
 		{
10711 11384
 			if(is_array($parameter))
10712 11385
 			{
10713 11386
 				$component=Prado::createComponent($parameter[0]);
10714
-				foreach($parameter[1] as $name=>$value)
10715
-					$component->setSubProperty($name,$value);
11387
+				foreach($parameter[1] as $name=>$value) {
11388
+									$component->setSubProperty($name,$value);
11389
+				}
10716 11390
 				$this->_parameters->add($id,$component);
11391
+			} else {
11392
+							$this->_parameters->add($id,$parameter);
10717 11393
 			}
10718
-			else
10719
-				$this->_parameters->add($id,$parameter);
10720 11394
 		}
10721 11395
 				$modules=array();
10722 11396
 		foreach($config->getModules() as $id=>$moduleConfig)
10723 11397
 		{
10724
-			if(!is_string($id))
10725
-				$id='_module'.count($this->_lazyModules);
11398
+			if(!is_string($id)) {
11399
+							$id='_module'.count($this->_lazyModules);
11400
+			}
10726 11401
 			$this->_lazyModules[$id]=$moduleConfig;
10727
-			if($module = $this->internalLoadModule($id))
10728
-				$modules[]=$module;
11402
+			if($module = $this->internalLoadModule($id)) {
11403
+							$modules[]=$module;
11404
+			}
10729 11405
 		}
10730
-		foreach($modules as $module)
10731
-			$module[0]->init($module[1]);
10732
-				foreach($config->getServices() as $serviceID=>$serviceConfig)
10733
-			$this->_services[$serviceID]=$serviceConfig;
11406
+		foreach($modules as $module) {
11407
+					$module[0]->init($module[1]);
11408
+		}
11409
+				foreach($config->getServices() as $serviceID=>$serviceConfig) {
11410
+							$this->_services[$serviceID]=$serviceConfig;
11411
+				}
10734 11412
 				foreach($config->getExternalConfigurations() as $filePath=>$condition)
10735 11413
 		{
10736
-			if($condition!==true)
10737
-				$condition=$this->evaluateExpression($condition);
11414
+			if($condition!==true) {
11415
+							$condition=$this->evaluateExpression($condition);
11416
+			}
10738 11417
 			if($condition)
10739 11418
 			{
10740
-				if(($path=Prado::getPathOfNamespace($filePath,$this->getConfigurationFileExt()))===null || !is_file($path))
10741
-					throw new TConfigurationException('application_includefile_invalid',$filePath);
11419
+				if(($path=Prado::getPathOfNamespace($filePath,$this->getConfigurationFileExt()))===null || !is_file($path)) {
11420
+									throw new TConfigurationException('application_includefile_invalid',$filePath);
11421
+				}
10742 11422
 				$cn=$this->getApplicationConfigurationClass();
10743 11423
 				$c=new $cn;
10744 11424
 				$c->loadFromFile($path);
@@ -10754,15 +11434,17 @@  discard block
 block discarded – undo
10754 11434
 			{
10755 11435
 				$config=new TApplicationConfiguration;
10756 11436
 				$config->loadFromFile($this->_configFile);
10757
-				if($this->_cacheFile!==null)
10758
-					file_put_contents($this->_cacheFile,serialize($config),LOCK_EX);
11437
+				if($this->_cacheFile!==null) {
11438
+									file_put_contents($this->_cacheFile,serialize($config),LOCK_EX);
11439
+				}
11440
+			} else {
11441
+							$config=unserialize(file_get_contents($this->_cacheFile));
10759 11442
 			}
10760
-			else
10761
-				$config=unserialize(file_get_contents($this->_cacheFile));
10762 11443
 			$this->applyConfiguration($config,false);
10763 11444
 		}
10764
-		if(($serviceID=$this->getRequest()->resolveRequest(array_keys($this->_services)))===null)
10765
-			$serviceID=$this->getPageServiceID();
11445
+		if(($serviceID=$this->getRequest()->resolveRequest(array_keys($this->_services)))===null) {
11446
+					$serviceID=$this->getPageServiceID();
11447
+		}
10766 11448
 		$this->startService($serviceID);
10767 11449
 	}
10768 11450
 	public function startService($serviceID)
@@ -10771,27 +11453,31 @@  discard block
 block discarded – undo
10771 11453
 		{
10772 11454
 			list($serviceClass,$initProperties,$configElement)=$this->_services[$serviceID];
10773 11455
 			$service=Prado::createComponent($serviceClass);
10774
-			if(!($service instanceof IService))
10775
-				throw new THttpException(500,'application_service_invalid',$serviceClass);
10776
-			if(!$service->getEnabled())
10777
-				throw new THttpException(500,'application_service_unavailable',$serviceClass);
11456
+			if(!($service instanceof IService)) {
11457
+							throw new THttpException(500,'application_service_invalid',$serviceClass);
11458
+			}
11459
+			if(!$service->getEnabled()) {
11460
+							throw new THttpException(500,'application_service_unavailable',$serviceClass);
11461
+			}
10778 11462
 			$service->setID($serviceID);
10779 11463
 			$this->setService($service);
10780
-			foreach($initProperties as $name=>$value)
10781
-				$service->setSubProperty($name,$value);
11464
+			foreach($initProperties as $name=>$value) {
11465
+							$service->setSubProperty($name,$value);
11466
+			}
10782 11467
 			if($configElement!==null)
10783 11468
 			{
10784 11469
 				$config=new TApplicationConfiguration;
10785
-				if($this->getConfigurationType()==self::CONFIG_TYPE_PHP)
10786
-					$config->loadFromPhp($configElement,$this->getBasePath());
10787
-				else
10788
-					$config->loadFromXml($configElement,$this->getBasePath());
11470
+				if($this->getConfigurationType()==self::CONFIG_TYPE_PHP) {
11471
+									$config->loadFromPhp($configElement,$this->getBasePath());
11472
+				} else {
11473
+									$config->loadFromXml($configElement,$this->getBasePath());
11474
+				}
10789 11475
 				$this->applyConfiguration($config,true);
10790 11476
 			}
10791 11477
 			$service->init($configElement);
11478
+		} else {
11479
+					throw new THttpException(500,'application_service_unknown',$serviceID);
10792 11480
 		}
10793
-		else
10794
-			throw new THttpException(500,'application_service_unknown',$serviceID);
10795 11481
 	}
10796 11482
 	public function onError($param)
10797 11483
 	{
@@ -10834,8 +11520,9 @@  discard block
 block discarded – undo
10834 11520
 	}
10835 11521
 	public function runService()
10836 11522
 	{
10837
-		if($this->_service)
10838
-			$this->_service->run();
11523
+		if($this->_service) {
11524
+					$this->_service->run();
11525
+		}
10839 11526
 	}
10840 11527
 	public function onSaveState()
10841 11528
 	{
@@ -10882,8 +11569,7 @@  discard block
 block discarded – undo
10882 11569
 		{
10883 11570
 			$fcontent = include $fname;
10884 11571
 			$this->loadFromPhp($fcontent,dirname($fname));
10885
-		}
10886
-		else
11572
+		} else
10887 11573
 		{
10888 11574
 			$dom=new TXmlDocument;
10889 11575
 			$dom->loadFromFile($fname);
@@ -10904,16 +11590,21 @@  discard block
 block discarded – undo
10904 11590
 			}
10905 11591
 			$this->_empty = false;
10906 11592
 		}
10907
-		if(isset($config['paths']) && is_array($config['paths']))
10908
-			$this->loadPathsPhp($config['paths'],$configPath);
10909
-		if(isset($config['modules']) && is_array($config['modules']))
10910
-			$this->loadModulesPhp($config['modules'],$configPath);
10911
-		if(isset($config['services']) && is_array($config['services']))
10912
-			$this->loadServicesPhp($config['services'],$configPath);
10913
-		if(isset($config['parameters']) && is_array($config['parameters']))
10914
-			$this->loadParametersPhp($config['parameters'], $configPath);
10915
-		if(isset($config['includes']) && is_array($config['includes']))
10916
-			$this->loadExternalXml($config['includes'],$configPath);
11593
+		if(isset($config['paths']) && is_array($config['paths'])) {
11594
+					$this->loadPathsPhp($config['paths'],$configPath);
11595
+		}
11596
+		if(isset($config['modules']) && is_array($config['modules'])) {
11597
+					$this->loadModulesPhp($config['modules'],$configPath);
11598
+		}
11599
+		if(isset($config['services']) && is_array($config['services'])) {
11600
+					$this->loadServicesPhp($config['services'],$configPath);
11601
+		}
11602
+		if(isset($config['parameters']) && is_array($config['parameters'])) {
11603
+					$this->loadParametersPhp($config['parameters'], $configPath);
11604
+		}
11605
+		if(isset($config['includes']) && is_array($config['includes'])) {
11606
+					$this->loadExternalXml($config['includes'],$configPath);
11607
+		}
10917 11608
 	}
10918 11609
 	public function loadFromXml($dom,$configPath)
10919 11610
 	{
@@ -10953,13 +11644,17 @@  discard block
 block discarded – undo
10953 11644
 			foreach($pathsNode['aliases'] as $id=>$path)
10954 11645
 			{
10955 11646
 				$path=str_replace('\\','/',$path);
10956
-				if(preg_match('/^\\/|.:\\/|.:\\\\/',$path))						$p=realpath($path);
10957
-				else
10958
-					$p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
10959
-				if($p===false || !is_dir($p))
10960
-					throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path);
10961
-				if(isset($this->_aliases[$id]))
10962
-					throw new TConfigurationException('appconfig_alias_redefined',$id);
11647
+				if(preg_match('/^\\/|.:\\/|.:\\\\/',$path)) {
11648
+					$p=realpath($path);
11649
+				} else {
11650
+									$p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
11651
+				}
11652
+				if($p===false || !is_dir($p)) {
11653
+									throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path);
11654
+				}
11655
+				if(isset($this->_aliases[$id])) {
11656
+									throw new TConfigurationException('appconfig_alias_redefined',$id);
11657
+				}
10963 11658
 				$this->_aliases[$id]=$p;
10964 11659
 			}
10965 11660
 		}
@@ -10982,26 +11677,31 @@  discard block
 block discarded – undo
10982 11677
 					if(($id=$element->getAttribute('id'))!==null && ($path=$element->getAttribute('path'))!==null)
10983 11678
 					{
10984 11679
 						$path=str_replace('\\','/',$path);
10985
-						if(preg_match('/^\\/|.:\\/|.:\\\\/',$path))								$p=realpath($path);
10986
-						else
10987
-							$p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
10988
-						if($p===false || !is_dir($p))
10989
-							throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path);
10990
-						if(isset($this->_aliases[$id]))
10991
-							throw new TConfigurationException('appconfig_alias_redefined',$id);
11680
+						if(preg_match('/^\\/|.:\\/|.:\\\\/',$path)) {
11681
+							$p=realpath($path);
11682
+						} else {
11683
+													$p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
11684
+						}
11685
+						if($p===false || !is_dir($p)) {
11686
+													throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path);
11687
+						}
11688
+						if(isset($this->_aliases[$id])) {
11689
+													throw new TConfigurationException('appconfig_alias_redefined',$id);
11690
+						}
10992 11691
 						$this->_aliases[$id]=$p;
11692
+					} else {
11693
+											throw new TConfigurationException('appconfig_alias_invalid');
10993 11694
 					}
10994
-					else
10995
-						throw new TConfigurationException('appconfig_alias_invalid');
10996 11695
 					$this->_empty=false;
10997 11696
 					break;
10998 11697
 				}
10999 11698
 				case 'using':
11000 11699
 				{
11001
-					if(($namespace=$element->getAttribute('namespace'))!==null)
11002
-						$this->_usings[]=$namespace;
11003
-					else
11004
-						throw new TConfigurationException('appconfig_using_invalid');
11700
+					if(($namespace=$element->getAttribute('namespace'))!==null) {
11701
+											$this->_usings[]=$namespace;
11702
+					} else {
11703
+											throw new TConfigurationException('appconfig_using_invalid');
11704
+					}
11005 11705
 					$this->_empty=false;
11006 11706
 					break;
11007 11707
 				}
@@ -11014,8 +11714,9 @@  discard block
 block discarded – undo
11014 11714
 	{
11015 11715
 		foreach($modulesNode as $id=>$module)
11016 11716
 		{
11017
-			if(!isset($module['class']))
11018
-				throw new TConfigurationException('appconfig_moduletype_required',$id);
11717
+			if(!isset($module['class'])) {
11718
+							throw new TConfigurationException('appconfig_moduletype_required',$id);
11719
+			}
11019 11720
 			$type = $module['class'];
11020 11721
 			unset($module['class']);
11021 11722
 			$properties = array();
@@ -11038,25 +11739,28 @@  discard block
 block discarded – undo
11038 11739
 				$properties=$element->getAttributes();
11039 11740
 				$id=$properties->itemAt('id');
11040 11741
 				$type=$properties->remove('class');
11041
-				if($type===null)
11042
-					throw new TConfigurationException('appconfig_moduletype_required',$id);
11742
+				if($type===null) {
11743
+									throw new TConfigurationException('appconfig_moduletype_required',$id);
11744
+				}
11043 11745
 				$element->setParent(null);
11044
-				if($id===null)
11045
-					$this->_modules[]=array($type,$properties->toArray(),$element);
11046
-				else
11047
-					$this->_modules[$id]=array($type,$properties->toArray(),$element);
11746
+				if($id===null) {
11747
+									$this->_modules[]=array($type,$properties->toArray(),$element);
11748
+				} else {
11749
+									$this->_modules[$id]=array($type,$properties->toArray(),$element);
11750
+				}
11048 11751
 				$this->_empty=false;
11752
+			} else {
11753
+							throw new TConfigurationException('appconfig_modules_invalid',$element->getTagName());
11049 11754
 			}
11050
-			else
11051
-				throw new TConfigurationException('appconfig_modules_invalid',$element->getTagName());
11052 11755
 		}
11053 11756
 	}
11054 11757
 	protected function loadServicesPhp($servicesNode,$configPath)
11055 11758
 	{
11056 11759
 		foreach($servicesNode as $id => $service)
11057 11760
 		{
11058
-			if(!isset($service['class']))
11059
-				throw new TConfigurationException('appconfig_servicetype_required');
11761
+			if(!isset($service['class'])) {
11762
+							throw new TConfigurationException('appconfig_servicetype_required');
11763
+			}
11060 11764
 			$type = $service['class'];
11061 11765
 			$properties = isset($service['properties']) ? $service['properties'] : array();
11062 11766
 			unset($service['properties']);
@@ -11072,16 +11776,18 @@  discard block
 block discarded – undo
11072 11776
 			if($element->getTagName()==='service')
11073 11777
 			{
11074 11778
 				$properties=$element->getAttributes();
11075
-				if(($id=$properties->itemAt('id'))===null)
11076
-					throw new TConfigurationException('appconfig_serviceid_required');
11077
-				if(($type=$properties->remove('class'))===null)
11078
-					throw new TConfigurationException('appconfig_servicetype_required',$id);
11779
+				if(($id=$properties->itemAt('id'))===null) {
11780
+									throw new TConfigurationException('appconfig_serviceid_required');
11781
+				}
11782
+				if(($type=$properties->remove('class'))===null) {
11783
+									throw new TConfigurationException('appconfig_servicetype_required',$id);
11784
+				}
11079 11785
 				$element->setParent(null);
11080 11786
 				$this->_services[$id]=array($type,$properties->toArray(),$element);
11081 11787
 				$this->_empty=false;
11788
+			} else {
11789
+							throw new TConfigurationException('appconfig_services_invalid',$element->getTagName());
11082 11790
 			}
11083
-			else
11084
-				throw new TConfigurationException('appconfig_services_invalid',$element->getTagName());
11085 11791
 		}
11086 11792
 	}
11087 11793
 	protected function loadParametersPhp($parametersNode,$configPath)
@@ -11098,8 +11804,7 @@  discard block
 block discarded – undo
11098 11804
 					$properties['id'] = $id;
11099 11805
 					$this->_parameters[$id] = array($type,$properties);
11100 11806
 				}
11101
-			}
11102
-			else
11807
+			} else
11103 11808
 			{
11104 11809
 				$this->_parameters[$id] = $parameter;
11105 11810
 			}
@@ -11112,21 +11817,23 @@  discard block
 block discarded – undo
11112 11817
 			if($element->getTagName()==='parameter')
11113 11818
 			{
11114 11819
 				$properties=$element->getAttributes();
11115
-				if(($id=$properties->remove('id'))===null)
11116
-					throw new TConfigurationException('appconfig_parameterid_required');
11820
+				if(($id=$properties->remove('id'))===null) {
11821
+									throw new TConfigurationException('appconfig_parameterid_required');
11822
+				}
11117 11823
 				if(($type=$properties->remove('class'))===null)
11118 11824
 				{
11119
-					if(($value=$properties->remove('value'))===null)
11120
-						$this->_parameters[$id]=$element;
11121
-					else
11122
-						$this->_parameters[$id]=$value;
11825
+					if(($value=$properties->remove('value'))===null) {
11826
+											$this->_parameters[$id]=$element;
11827
+					} else {
11828
+											$this->_parameters[$id]=$value;
11829
+					}
11830
+				} else {
11831
+									$this->_parameters[$id]=array($type,$properties->toArray());
11123 11832
 				}
11124
-				else
11125
-					$this->_parameters[$id]=array($type,$properties->toArray());
11126 11833
 				$this->_empty=false;
11834
+			} else {
11835
+							throw new TConfigurationException('appconfig_parameters_invalid',$element->getTagName());
11127 11836
 			}
11128
-			else
11129
-				throw new TConfigurationException('appconfig_parameters_invalid',$element->getTagName());
11130 11837
 		}
11131 11838
 	}
11132 11839
 	protected function loadExternalPhp($includeNode,$configPath)
@@ -11134,26 +11841,31 @@  discard block
 block discarded – undo
11134 11841
 		foreach($includeNode as $include)
11135 11842
 		{
11136 11843
 			$when = isset($include['when'])?true:false;
11137
-			if(!isset($include['file']))
11138
-				throw new TConfigurationException('appconfig_includefile_required');
11844
+			if(!isset($include['file'])) {
11845
+							throw new TConfigurationException('appconfig_includefile_required');
11846
+			}
11139 11847
 			$filePath = $include['file'];
11140
-			if(isset($this->_includes[$filePath]))
11141
-				$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
11142
-			else
11143
-				$$this->_includes[$filePath]=$when;
11848
+			if(isset($this->_includes[$filePath])) {
11849
+							$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
11850
+			} else {
11851
+							$$this->_includes[$filePath]=$when;
11852
+			}
11144 11853
 			$this->_empty=false;
11145 11854
 		}
11146 11855
 	}
11147 11856
 	protected function loadExternalXml($includeNode,$configPath)
11148 11857
 	{
11149
-		if(($when=$includeNode->getAttribute('when'))===null)
11150
-			$when=true;
11151
-		if(($filePath=$includeNode->getAttribute('file'))===null)
11152
-			throw new TConfigurationException('appconfig_includefile_required');
11153
-		if(isset($this->_includes[$filePath]))
11154
-			$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
11155
-		else
11156
-			$this->_includes[$filePath]=$when;
11858
+		if(($when=$includeNode->getAttribute('when'))===null) {
11859
+					$when=true;
11860
+		}
11861
+		if(($filePath=$includeNode->getAttribute('file'))===null) {
11862
+					throw new TConfigurationException('appconfig_includefile_required');
11863
+		}
11864
+		if(isset($this->_includes[$filePath])) {
11865
+					$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
11866
+		} else {
11867
+					$this->_includes[$filePath]=$when;
11868
+		}
11157 11869
 		$this->_empty=false;
11158 11870
 	}
11159 11871
 	public function getProperties()
@@ -11198,14 +11910,15 @@  discard block
 block discarded – undo
11198 11910
 	}
11199 11911
 	public function load()
11200 11912
 	{
11201
-		if(($cache=$this->getApplication()->getCache())!==null && ($value=$cache->get(self::CACHE_NAME))!==false)
11202
-			return unserialize($value);
11203
-		else
11913
+		if(($cache=$this->getApplication()->getCache())!==null && ($value=$cache->get(self::CACHE_NAME))!==false) {
11914
+					return unserialize($value);
11915
+		} else
11204 11916
 		{
11205
-			if(($content=@file_get_contents($this->getStateFilePath()))!==false)
11206
-				return unserialize($content);
11207
-			else
11208
-				return null;
11917
+			if(($content=@file_get_contents($this->getStateFilePath()))!==false) {
11918
+							return unserialize($content);
11919
+			} else {
11920
+							return null;
11921
+			}
11209 11922
 		}
11210 11923
 	}
11211 11924
 	public function save($state)
@@ -11214,10 +11927,11 @@  discard block
 block discarded – undo
11214 11927
 		$saveFile=true;
11215 11928
 		if(($cache=$this->getApplication()->getCache())!==null)
11216 11929
 		{
11217
-			if($cache->get(self::CACHE_NAME)===$content)
11218
-				$saveFile=false;
11219
-			else
11220
-				$cache->set(self::CACHE_NAME,$content);
11930
+			if($cache->get(self::CACHE_NAME)===$content) {
11931
+							$saveFile=false;
11932
+			} else {
11933
+							$cache->set(self::CACHE_NAME,$content);
11934
+			}
11221 11935
 		}
11222 11936
 		if($saveFile)
11223 11937
 		{
Please login to merge, or discard this patch.
framework/Security/IUserManager.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -35,6 +35,7 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * Returns a user instance according to auth data stored in a cookie.
37 37
 	 * @param THttpCookie the cookie storing user authentication information
38
+	 * @param THttpCookie $cookie
38 39
 	 * @return TUser the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data.
39 40
 	 * @since 3.1.1
40 41
 	 */
@@ -42,7 +43,9 @@  discard block
 block discarded – undo
42 43
 	/**
43 44
 	 * Saves user auth data into a cookie.
44 45
 	 * @param THttpCookie the cookie to receive the user auth data.
46
+	 * @param THttpCookie $cookie
45 47
 	 * @since 3.1.1
48
+	 * @return void
46 49
 	 */
47 50
 	public function saveUserToCookie($cookie);
48 51
 	/**
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
- * IUserManager interface 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.Security
10
- */
3
+	 * IUserManager interface 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.Security
10
+	 */
11 11
 
12 12
 /**
13 13
  * IUserManager interface
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param string user name, null if it is a guest.
32 32
 	 * @return TUser the user instance, null if the specified username is not in the user database.
33 33
 	 */
34
-	public function getUser($username=null);
34
+	public function getUser($username = null);
35 35
 	/**
36 36
 	 * Returns a user instance according to auth data stored in a cookie.
37 37
 	 * @param THttpCookie the cookie storing user authentication information
@@ -51,6 +51,6 @@  discard block
 block discarded – undo
51 51
 	 * @param string password
52 52
 	 * @return boolean true if validation is successful, false otherwise.
53 53
 	 */
54
-	public function validateUser($username,$password);
54
+	public function validateUser($username, $password);
55 55
 }
56 56
 
Please login to merge, or discard this patch.
framework/Security/TAuthManager.php 4 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -115,6 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
 	/**
117 117
 	 * @param string|IUserManager the user manager module ID or the user manager object
118
+	 * @param string $provider
118 119
 	 * @throws TInvalidOperationException if the module has been initialized or the user manager object is not IUserManager
119 120
 	 */
120 121
 	public function setUserManager($provider)
@@ -138,6 +139,7 @@  discard block
 block discarded – undo
138 139
 	 * Sets the login page that the client browser will be redirected to if login is needed.
139 140
 	 * Login page should be specified in the format of page path.
140 141
 	 * @param string path of login page should login is required
142
+	 * @param string $pagePath
141 143
 	 * @see TPageService
142 144
 	 */
143 145
 	public function setLoginPage($pagePath)
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -289,7 +289,7 @@
 block discarded – undo
289 289
 
290 290
 		// check for authentication expiration
291 291
 		$isAuthExpired = $this->_authExpire>0 && !$user->getIsGuest() &&
292
-        ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime<time();
292
+		($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime<time();
293 293
 
294 294
 		// try authenticating through cookie if possible
295 295
 		if($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired))
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 	/**
45 45
 	 * GET variable name for return url
46 46
 	 */
47
-	const RETURN_URL_VAR='ReturnUrl';
47
+	const RETURN_URL_VAR = 'ReturnUrl';
48 48
 	/**
49 49
 	 * @var boolean if the module has been initialized
50 50
 	 */
51
-	private $_initialized=false;
51
+	private $_initialized = false;
52 52
 	/**
53 53
 	 * @var IUserManager user manager instance
54 54
 	 */
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	/**
61 61
 	 * @var boolean whether authorization should be skipped
62 62
 	 */
63
-	private $_skipAuthorization=false;
63
+	private $_skipAuthorization = false;
64 64
 	/**
65 65
 	 * @var string the session var name for storing return URL
66 66
 	 */
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	/**
69 69
 	 * @var boolean whether to allow auto login (using cookie)
70 70
 	 */
71
-	private $_allowAutoLogin=false;
71
+	private $_allowAutoLogin = false;
72 72
 	/**
73 73
 	 * @var string variable name used to store user session or cookie
74 74
 	 */
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	/**
77 77
 	 * @var integer authentication expiration time in seconds. Defaults to zero (no expiration)
78 78
 	 */
79
-	private $_authExpire=0;
79
+	private $_authExpire = 0;
80 80
 
81 81
 	/**
82 82
 	 * Initializes this module.
@@ -86,23 +86,23 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function init($config)
88 88
 	{
89
-		if($this->_userManager===null)
89
+		if ($this->_userManager === null)
90 90
 			throw new TConfigurationException('authmanager_usermanager_required');
91
-		if($this->_returnUrlVarName===null)
92
-			$this->_returnUrlVarName=$this->getApplication()->getID().':'.self::RETURN_URL_VAR;
93
-		$application=$this->getApplication();
94
-		if(is_string($this->_userManager))
91
+		if ($this->_returnUrlVarName === null)
92
+			$this->_returnUrlVarName = $this->getApplication()->getID() . ':' . self::RETURN_URL_VAR;
93
+		$application = $this->getApplication();
94
+		if (is_string($this->_userManager))
95 95
 		{
96
-			if(($users=$application->getModule($this->_userManager))===null)
97
-				throw new TConfigurationException('authmanager_usermanager_inexistent',$this->_userManager);
98
-			if(!($users instanceof IUserManager))
99
-				throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager);
100
-			$this->_userManager=$users;
96
+			if (($users = $application->getModule($this->_userManager)) === null)
97
+				throw new TConfigurationException('authmanager_usermanager_inexistent', $this->_userManager);
98
+			if (!($users instanceof IUserManager))
99
+				throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager);
100
+			$this->_userManager = $users;
101 101
 		}
102
-		$application->attachEventHandler('OnAuthentication',array($this,'doAuthentication'));
103
-		$application->attachEventHandler('OnEndRequest',array($this,'leave'));
104
-		$application->attachEventHandler('OnAuthorization',array($this,'doAuthorization'));
105
-		$this->_initialized=true;
102
+		$application->attachEventHandler('OnAuthentication', array($this, 'doAuthentication'));
103
+		$application->attachEventHandler('OnEndRequest', array($this, 'leave'));
104
+		$application->attachEventHandler('OnAuthorization', array($this, 'doAuthorization'));
105
+		$this->_initialized = true;
106 106
 	}
107 107
 
108 108
 	/**
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function setUserManager($provider)
121 121
 	{
122
-		if($this->_initialized)
122
+		if ($this->_initialized)
123 123
 			throw new TInvalidOperationException('authmanager_usermanager_unchangeable');
124
-		if(!is_string($provider) && !($provider instanceof IUserManager))
125
-			throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager);
126
-		$this->_userManager=$provider;
124
+		if (!is_string($provider) && !($provider instanceof IUserManager))
125
+			throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager);
126
+		$this->_userManager = $provider;
127 127
 	}
128 128
 
129 129
 	/**
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	public function setLoginPage($pagePath)
144 144
 	{
145
-		$this->_loginPage=$pagePath;
145
+		$this->_loginPage = $pagePath;
146 146
 	}
147 147
 
148 148
 	/**
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
 	 * @param mixed sender of the Authentication event
153 153
 	 * @param mixed event parameter
154 154
 	 */
155
-	public function doAuthentication($sender,$param)
155
+	public function doAuthentication($sender, $param)
156 156
 	{
157 157
 		$this->onAuthenticate($param);
158 158
 
159
-		$service=$this->getService();
160
-		if(($service instanceof TPageService) && $service->getRequestedPagePath()===$this->getLoginPage())
161
-			$this->_skipAuthorization=true;
159
+		$service = $this->getService();
160
+		if (($service instanceof TPageService) && $service->getRequestedPagePath() === $this->getLoginPage())
161
+			$this->_skipAuthorization = true;
162 162
 	}
163 163
 
164 164
 	/**
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 	 * @param mixed sender of the Authorization event
169 169
 	 * @param mixed event parameter
170 170
 	 */
171
-	public function doAuthorization($sender,$param)
171
+	public function doAuthorization($sender, $param)
172 172
 	{
173
-		if(!$this->_skipAuthorization)
173
+		if (!$this->_skipAuthorization)
174 174
 		{
175 175
 			$this->onAuthorize($param);
176 176
 		}
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
 	 * @param mixed sender of the event
184 184
 	 * @param mixed event parameter
185 185
 	 */
186
-	public function leave($sender,$param)
186
+	public function leave($sender, $param)
187 187
 	{
188
-		$application=$this->getApplication();
189
-		if($application->getResponse()->getStatusCode()===401)
188
+		$application = $this->getApplication();
189
+		if ($application->getResponse()->getStatusCode() === 401)
190 190
 		{
191
-			$service=$application->getService();
192
-			if($service instanceof TPageService)
191
+			$service = $application->getService();
192
+			if ($service instanceof TPageService)
193 193
 			{
194
-				$returnUrl=$application->getRequest()->getRequestUri();
194
+				$returnUrl = $application->getRequest()->getRequestUri();
195 195
 				$this->setReturnUrl($returnUrl);
196
-				$url=$service->constructUrl($this->getLoginPage());
196
+				$url = $service->constructUrl($this->getLoginPage());
197 197
 				$application->getResponse()->redirect($url);
198 198
 			}
199 199
 		}
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	public function setReturnUrlVarName($value)
214 214
 	{
215
-		$this->_returnUrlVarName=$value;
215
+		$this->_returnUrlVarName = $value;
216 216
 	}
217 217
 
218 218
 	/**
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	public function setReturnUrl($value)
231 231
 	{
232
-		$this->getSession()->add($this->getReturnUrlVarName(),$value);
232
+		$this->getSession()->add($this->getReturnUrlVarName(), $value);
233 233
 	}
234 234
 
235 235
 	/**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	 */
248 248
 	public function setAllowAutoLogin($value)
249 249
 	{
250
-		$this->_allowAutoLogin=TPropertyValue::ensureBoolean($value);
250
+		$this->_allowAutoLogin = TPropertyValue::ensureBoolean($value);
251 251
 	}
252 252
 
253 253
 	/**
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 	 */
266 266
 	public function setAuthExpire($value)
267 267
 	{
268
-		$this->_authExpire=TPropertyValue::ensureInteger($value);
268
+		$this->_authExpire = TPropertyValue::ensureInteger($value);
269 269
 	}
270 270
 
271 271
 	/**
@@ -278,28 +278,28 @@  discard block
 block discarded – undo
278 278
 	 */
279 279
 	public function onAuthenticate($param)
280 280
 	{
281
-		$application=$this->getApplication();
281
+		$application = $this->getApplication();
282 282
 
283 283
 		// restoring user info from session
284
-		if(($session=$application->getSession())===null)
284
+		if (($session = $application->getSession()) === null)
285 285
 			throw new TConfigurationException('authmanager_session_required');
286 286
 		$session->open();
287
-		$sessionInfo=$session->itemAt($this->getUserKey());
288
-		$user=$this->_userManager->getUser(null)->loadFromString($sessionInfo);
287
+		$sessionInfo = $session->itemAt($this->getUserKey());
288
+		$user = $this->_userManager->getUser(null)->loadFromString($sessionInfo);
289 289
 
290 290
 		// check for authentication expiration
291
-		$isAuthExpired = $this->_authExpire>0 && !$user->getIsGuest() &&
292
-        ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime<time();
291
+		$isAuthExpired = $this->_authExpire > 0 && !$user->getIsGuest() &&
292
+        ($expiretime = $session->itemAt('AuthExpireTime')) && $expiretime < time();
293 293
 
294 294
 		// try authenticating through cookie if possible
295
-		if($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired))
295
+		if ($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired))
296 296
 		{
297
-			$cookie=$this->getRequest()->getCookies()->itemAt($this->getUserKey());
298
-			if($cookie instanceof THttpCookie)
297
+			$cookie = $this->getRequest()->getCookies()->itemAt($this->getUserKey());
298
+			if ($cookie instanceof THttpCookie)
299 299
 			{
300
-				if(($user2=$this->_userManager->getUserFromCookie($cookie))!==null)
300
+				if (($user2 = $this->_userManager->getUserFromCookie($cookie)) !== null)
301 301
 				{
302
-					$user=$user2;
302
+					$user = $user2;
303 303
 					$this->updateSessionUser($user);
304 304
 					// user is restored from cookie, auth may not expire
305 305
 					$isAuthExpired = false;
@@ -310,14 +310,14 @@  discard block
 block discarded – undo
310 310
 		$application->setUser($user);
311 311
 
312 312
 		// handle authentication expiration or update expiration time
313
-		if($isAuthExpired)
313
+		if ($isAuthExpired)
314 314
 			$this->onAuthExpire($param);
315 315
 		else
316 316
 			$session->add('AuthExpireTime', time() + $this->_authExpire);
317 317
 
318 318
 		// event handler gets a chance to do further auth work
319
-		if($this->hasEventHandler('OnAuthenticate'))
320
-			$this->raiseEvent('OnAuthenticate',$this,$application);
319
+		if ($this->hasEventHandler('OnAuthenticate'))
320
+			$this->raiseEvent('OnAuthenticate', $this, $application);
321 321
 	}
322 322
 
323 323
 	/**
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
 	public function onAuthExpire($param)
329 329
 	{
330 330
 		$this->logout();
331
-		if($this->hasEventHandler('OnAuthExpire'))
332
-			$this->raiseEvent('OnAuthExpire',$this,$param);
331
+		if ($this->hasEventHandler('OnAuthExpire'))
332
+			$this->raiseEvent('OnAuthExpire', $this, $param);
333 333
 	}
334 334
 
335 335
 	/**
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
 	 */
342 342
 	public function onAuthorize($param)
343 343
 	{
344
-		$application=$this->getApplication();
345
-		if($this->hasEventHandler('OnAuthorize'))
346
-			$this->raiseEvent('OnAuthorize',$this,$application);
347
-		if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(),$application->getRequest()->getRequestType(),$application->getRequest()->getUserHostAddress()))
344
+		$application = $this->getApplication();
345
+		if ($this->hasEventHandler('OnAuthorize'))
346
+			$this->raiseEvent('OnAuthorize', $this, $application);
347
+		if (!$application->getAuthorizationRules()->isUserAllowed($application->getUser(), $application->getRequest()->getRequestType(), $application->getRequest()->getUserHostAddress()))
348 348
 		{
349 349
 			$application->getResponse()->setStatusCode(401);
350 350
 			$application->completeRequest();
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
 	 */
358 358
 	public function getUserKey()
359 359
 	{
360
-		if($this->_userKey===null)
361
-			$this->_userKey=$this->generateUserKey();
360
+		if ($this->_userKey === null)
361
+			$this->_userKey = $this->generateUserKey();
362 362
 		return $this->_userKey;
363 363
 	}
364 364
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 */
369 369
 	protected function generateUserKey()
370 370
 	{
371
-		return md5($this->getApplication()->getUniqueID().'prado:user');
371
+		return md5($this->getApplication()->getUniqueID() . 'prado:user');
372 372
 	}
373 373
 
374 374
 	/**
@@ -378,12 +378,12 @@  discard block
 block discarded – undo
378 378
 	 */
379 379
 	public function updateSessionUser($user)
380 380
 	{
381
-		if(!$user->getIsGuest())
381
+		if (!$user->getIsGuest())
382 382
 		{
383
-			if(($session=$this->getSession())===null)
383
+			if (($session = $this->getSession()) === null)
384 384
 				throw new TConfigurationException('authmanager_session_required');
385 385
 			else
386
-				$session->add($this->getUserKey(),$user->saveToString());
386
+				$session->add($this->getUserKey(), $user->saveToString());
387 387
 		}
388 388
 	}
389 389
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	 */
396 396
 	public function switchUser($username)
397 397
 	{
398
-		if(($user=$this->_userManager->getUser($username))===null)
398
+		if (($user = $this->_userManager->getUser($username)) === null)
399 399
 			return false;
400 400
 		$this->updateSessionUser($user);
401 401
 		$this->getApplication()->setUser($user);
@@ -411,19 +411,19 @@  discard block
 block discarded – undo
411 411
 	 * @param integer number of seconds that automatic login will remain effective. If 0, it means user logs out when session ends. This parameter is added since 3.1.1.
412 412
 	 * @return boolean if login is successful
413 413
 	 */
414
-	public function login($username,$password,$expire=0)
414
+	public function login($username, $password, $expire = 0)
415 415
 	{
416
-		if($this->_userManager->validateUser($username,$password))
416
+		if ($this->_userManager->validateUser($username, $password))
417 417
 		{
418
-			if(($user=$this->_userManager->getUser($username))===null)
418
+			if (($user = $this->_userManager->getUser($username)) === null)
419 419
 				return false;
420 420
 			$this->updateSessionUser($user);
421 421
 			$this->getApplication()->setUser($user);
422 422
 
423
-			if($expire>0)
423
+			if ($expire > 0)
424 424
 			{
425
-				$cookie=new THttpCookie($this->getUserKey(),'');
426
-				$cookie->setExpire(time()+$expire);
425
+				$cookie = new THttpCookie($this->getUserKey(), '');
426
+				$cookie->setExpire(time() + $expire);
427 427
 				$this->_userManager->saveUserToCookie($cookie);
428 428
 				$this->getResponse()->getCookies()->add($cookie);
429 429
 			}
@@ -440,13 +440,13 @@  discard block
 block discarded – undo
440 440
 	 */
441 441
 	public function logout()
442 442
 	{
443
-		if(($session=$this->getSession())===null)
443
+		if (($session = $this->getSession()) === null)
444 444
 			throw new TConfigurationException('authmanager_session_required');
445 445
 		$this->getApplication()->getUser()->setIsGuest(true);
446 446
 		$session->destroy();
447
-		if($this->getAllowAutoLogin())
447
+		if ($this->getAllowAutoLogin())
448 448
 		{
449
-			$cookie=new THttpCookie($this->getUserKey(),'');
449
+			$cookie = new THttpCookie($this->getUserKey(), '');
450 450
 			$this->getResponse()->getCookies()->add($cookie);
451 451
 		}
452 452
 	}
Please login to merge, or discard this patch.
Braces   +57 added lines, -40 removed lines patch added patch discarded remove patch
@@ -86,17 +86,21 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function init($config)
88 88
 	{
89
-		if($this->_userManager===null)
90
-			throw new TConfigurationException('authmanager_usermanager_required');
91
-		if($this->_returnUrlVarName===null)
92
-			$this->_returnUrlVarName=$this->getApplication()->getID().':'.self::RETURN_URL_VAR;
89
+		if($this->_userManager===null) {
90
+					throw new TConfigurationException('authmanager_usermanager_required');
91
+		}
92
+		if($this->_returnUrlVarName===null) {
93
+					$this->_returnUrlVarName=$this->getApplication()->getID().':'.self::RETURN_URL_VAR;
94
+		}
93 95
 		$application=$this->getApplication();
94 96
 		if(is_string($this->_userManager))
95 97
 		{
96
-			if(($users=$application->getModule($this->_userManager))===null)
97
-				throw new TConfigurationException('authmanager_usermanager_inexistent',$this->_userManager);
98
-			if(!($users instanceof IUserManager))
99
-				throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager);
98
+			if(($users=$application->getModule($this->_userManager))===null) {
99
+							throw new TConfigurationException('authmanager_usermanager_inexistent',$this->_userManager);
100
+			}
101
+			if(!($users instanceof IUserManager)) {
102
+							throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager);
103
+			}
100 104
 			$this->_userManager=$users;
101 105
 		}
102 106
 		$application->attachEventHandler('OnAuthentication',array($this,'doAuthentication'));
@@ -119,10 +123,12 @@  discard block
 block discarded – undo
119 123
 	 */
120 124
 	public function setUserManager($provider)
121 125
 	{
122
-		if($this->_initialized)
123
-			throw new TInvalidOperationException('authmanager_usermanager_unchangeable');
124
-		if(!is_string($provider) && !($provider instanceof IUserManager))
125
-			throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager);
126
+		if($this->_initialized) {
127
+					throw new TInvalidOperationException('authmanager_usermanager_unchangeable');
128
+		}
129
+		if(!is_string($provider) && !($provider instanceof IUserManager)) {
130
+					throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager);
131
+		}
126 132
 		$this->_userManager=$provider;
127 133
 	}
128 134
 
@@ -157,8 +163,9 @@  discard block
 block discarded – undo
157 163
 		$this->onAuthenticate($param);
158 164
 
159 165
 		$service=$this->getService();
160
-		if(($service instanceof TPageService) && $service->getRequestedPagePath()===$this->getLoginPage())
161
-			$this->_skipAuthorization=true;
166
+		if(($service instanceof TPageService) && $service->getRequestedPagePath()===$this->getLoginPage()) {
167
+					$this->_skipAuthorization=true;
168
+		}
162 169
 	}
163 170
 
164 171
 	/**
@@ -281,8 +288,9 @@  discard block
 block discarded – undo
281 288
 		$application=$this->getApplication();
282 289
 
283 290
 		// restoring user info from session
284
-		if(($session=$application->getSession())===null)
285
-			throw new TConfigurationException('authmanager_session_required');
291
+		if(($session=$application->getSession())===null) {
292
+					throw new TConfigurationException('authmanager_session_required');
293
+		}
286 294
 		$session->open();
287 295
 		$sessionInfo=$session->itemAt($this->getUserKey());
288 296
 		$user=$this->_userManager->getUser(null)->loadFromString($sessionInfo);
@@ -310,14 +318,16 @@  discard block
 block discarded – undo
310 318
 		$application->setUser($user);
311 319
 
312 320
 		// handle authentication expiration or update expiration time
313
-		if($isAuthExpired)
314
-			$this->onAuthExpire($param);
315
-		else
316
-			$session->add('AuthExpireTime', time() + $this->_authExpire);
321
+		if($isAuthExpired) {
322
+					$this->onAuthExpire($param);
323
+		} else {
324
+					$session->add('AuthExpireTime', time() + $this->_authExpire);
325
+		}
317 326
 
318 327
 		// event handler gets a chance to do further auth work
319
-		if($this->hasEventHandler('OnAuthenticate'))
320
-			$this->raiseEvent('OnAuthenticate',$this,$application);
328
+		if($this->hasEventHandler('OnAuthenticate')) {
329
+					$this->raiseEvent('OnAuthenticate',$this,$application);
330
+		}
321 331
 	}
322 332
 
323 333
 	/**
@@ -328,8 +338,9 @@  discard block
 block discarded – undo
328 338
 	public function onAuthExpire($param)
329 339
 	{
330 340
 		$this->logout();
331
-		if($this->hasEventHandler('OnAuthExpire'))
332
-			$this->raiseEvent('OnAuthExpire',$this,$param);
341
+		if($this->hasEventHandler('OnAuthExpire')) {
342
+					$this->raiseEvent('OnAuthExpire',$this,$param);
343
+		}
333 344
 	}
334 345
 
335 346
 	/**
@@ -342,8 +353,9 @@  discard block
 block discarded – undo
342 353
 	public function onAuthorize($param)
343 354
 	{
344 355
 		$application=$this->getApplication();
345
-		if($this->hasEventHandler('OnAuthorize'))
346
-			$this->raiseEvent('OnAuthorize',$this,$application);
356
+		if($this->hasEventHandler('OnAuthorize')) {
357
+					$this->raiseEvent('OnAuthorize',$this,$application);
358
+		}
347 359
 		if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(),$application->getRequest()->getRequestType(),$application->getRequest()->getUserHostAddress()))
348 360
 		{
349 361
 			$application->getResponse()->setStatusCode(401);
@@ -357,8 +369,9 @@  discard block
 block discarded – undo
357 369
 	 */
358 370
 	public function getUserKey()
359 371
 	{
360
-		if($this->_userKey===null)
361
-			$this->_userKey=$this->generateUserKey();
372
+		if($this->_userKey===null) {
373
+					$this->_userKey=$this->generateUserKey();
374
+		}
362 375
 		return $this->_userKey;
363 376
 	}
364 377
 
@@ -380,10 +393,11 @@  discard block
 block discarded – undo
380 393
 	{
381 394
 		if(!$user->getIsGuest())
382 395
 		{
383
-			if(($session=$this->getSession())===null)
384
-				throw new TConfigurationException('authmanager_session_required');
385
-			else
386
-				$session->add($this->getUserKey(),$user->saveToString());
396
+			if(($session=$this->getSession())===null) {
397
+							throw new TConfigurationException('authmanager_session_required');
398
+			} else {
399
+							$session->add($this->getUserKey(),$user->saveToString());
400
+			}
387 401
 		}
388 402
 	}
389 403
 
@@ -395,8 +409,9 @@  discard block
 block discarded – undo
395 409
 	 */
396 410
 	public function switchUser($username)
397 411
 	{
398
-		if(($user=$this->_userManager->getUser($username))===null)
399
-			return false;
412
+		if(($user=$this->_userManager->getUser($username))===null) {
413
+					return false;
414
+		}
400 415
 		$this->updateSessionUser($user);
401 416
 		$this->getApplication()->setUser($user);
402 417
 		return true;
@@ -415,8 +430,9 @@  discard block
 block discarded – undo
415 430
 	{
416 431
 		if($this->_userManager->validateUser($username,$password))
417 432
 		{
418
-			if(($user=$this->_userManager->getUser($username))===null)
419
-				return false;
433
+			if(($user=$this->_userManager->getUser($username))===null) {
434
+							return false;
435
+			}
420 436
 			$this->updateSessionUser($user);
421 437
 			$this->getApplication()->setUser($user);
422 438
 
@@ -428,9 +444,9 @@  discard block
 block discarded – undo
428 444
 				$this->getResponse()->getCookies()->add($cookie);
429 445
 			}
430 446
 			return true;
447
+		} else {
448
+					return false;
431 449
 		}
432
-		else
433
-			return false;
434 450
 	}
435 451
 
436 452
 	/**
@@ -440,8 +456,9 @@  discard block
 block discarded – undo
440 456
 	 */
441 457
 	public function logout()
442 458
 	{
443
-		if(($session=$this->getSession())===null)
444
-			throw new TConfigurationException('authmanager_session_required');
459
+		if(($session=$this->getSession())===null) {
460
+					throw new TConfigurationException('authmanager_session_required');
461
+		}
445 462
 		$this->getApplication()->getUser()->setIsGuest(true);
446 463
 		$session->destroy();
447 464
 		if($this->getAllowAutoLogin())
Please login to merge, or discard this patch.
framework/Security/TAuthorizationRule.php 3 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -219,11 +219,17 @@  discard block
 block discarded – undo
219 219
 		return 0;
220 220
 	}
221 221
 
222
+	/**
223
+	 * @param IUser $user
224
+	 */
222 225
 	private function isUserMatched($user)
223 226
 	{
224 227
 		return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()),$this->_users));
225 228
 	}
226 229
 
230
+	/**
231
+	 * @param IUser $user
232
+	 */
227 233
 	private function isRoleMatched($user)
228 234
 	{
229 235
 		foreach($this->_roles as $role)
@@ -256,6 +262,9 @@  discard block
 block discarded – undo
256 262
 	 * @param IUser the user to be authorized
257 263
 	 * @param string verb, can be empty, 'post' or 'get'.
258 264
 	 * @param string the request IP address
265
+	 * @param IUser $user
266
+	 * @param string $verb
267
+	 * @param string $ip
259 268
 	 * @return boolean whether the user is allowed
260 269
 	 */
261 270
 	public function isUserAllowed($user,$verb,$ip)
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -70,61 +70,61 @@  discard block
 block discarded – undo
70 70
 	 * @param string verb, can be empty, 'get', or 'post'
71 71
 	 * @param string IP rules (separated by comma, can contain wild card *)
72 72
 	 */
73
-	public function __construct($action,$users,$roles,$verb='',$ipRules='')
73
+	public function __construct($action, $users, $roles, $verb = '', $ipRules = '')
74 74
 	{
75
-		$action=strtolower(trim($action));
76
-		if($action==='allow' || $action==='deny')
77
-			$this->_action=$action;
75
+		$action = strtolower(trim($action));
76
+		if ($action === 'allow' || $action === 'deny')
77
+			$this->_action = $action;
78 78
 		else
79
-			throw new TInvalidDataValueException('authorizationrule_action_invalid',$action);
80
-		$this->_users=array();
81
-		$this->_roles=array();
82
-		$this->_ipRules=array();
83
-		$this->_everyone=false;
84
-		$this->_guest=false;
85
-		$this->_authenticated=false;
79
+			throw new TInvalidDataValueException('authorizationrule_action_invalid', $action);
80
+		$this->_users = array();
81
+		$this->_roles = array();
82
+		$this->_ipRules = array();
83
+		$this->_everyone = false;
84
+		$this->_guest = false;
85
+		$this->_authenticated = false;
86 86
 
87
-		if(trim($users)==='')
88
-			$users='*';
89
-		foreach(explode(',',$users) as $user)
87
+		if (trim($users) === '')
88
+			$users = '*';
89
+		foreach (explode(',', $users) as $user)
90 90
 		{
91
-			if(($user=trim(strtolower($user)))!=='')
91
+			if (($user = trim(strtolower($user))) !== '')
92 92
 			{
93
-				if($user==='*')
93
+				if ($user === '*')
94 94
 				{
95
-					$this->_everyone=true;
95
+					$this->_everyone = true;
96 96
 					break;
97 97
 				}
98
-				else if($user==='?')
99
-					$this->_guest=true;
100
-				else if($user==='@')
101
-					$this->_authenticated=true;
98
+				else if ($user === '?')
99
+					$this->_guest = true;
100
+				else if ($user === '@')
101
+					$this->_authenticated = true;
102 102
 				else
103
-					$this->_users[]=$user;
103
+					$this->_users[] = $user;
104 104
 			}
105 105
 		}
106 106
 
107
-		if(trim($roles)==='')
108
-			$roles='*';
109
-		foreach(explode(',',$roles) as $role)
107
+		if (trim($roles) === '')
108
+			$roles = '*';
109
+		foreach (explode(',', $roles) as $role)
110 110
 		{
111
-			if(($role=trim(strtolower($role)))!=='')
112
-				$this->_roles[]=$role;
111
+			if (($role = trim(strtolower($role))) !== '')
112
+				$this->_roles[] = $role;
113 113
 		}
114 114
 
115
-		if(($verb=trim(strtolower($verb)))==='')
116
-			$verb='*';
117
-		if($verb==='*' || $verb==='get' || $verb==='post')
118
-			$this->_verb=$verb;
115
+		if (($verb = trim(strtolower($verb))) === '')
116
+			$verb = '*';
117
+		if ($verb === '*' || $verb === 'get' || $verb === 'post')
118
+			$this->_verb = $verb;
119 119
 		else
120
-			throw new TInvalidDataValueException('authorizationrule_verb_invalid',$verb);
120
+			throw new TInvalidDataValueException('authorizationrule_verb_invalid', $verb);
121 121
 
122
-		if(trim($ipRules)==='')
123
-			$ipRules='*';
124
-		foreach(explode(',',$ipRules) as $ipRule)
122
+		if (trim($ipRules) === '')
123
+			$ipRules = '*';
124
+		foreach (explode(',', $ipRules) as $ipRule)
125 125
 		{
126
-			if(($ipRule=trim($ipRule))!=='')
127
-				$this->_ipRules[]=$ipRule;
126
+			if (($ipRule = trim($ipRule)) !== '')
127
+				$this->_ipRules[] = $ipRule;
128 128
 		}
129 129
 	}
130 130
 
@@ -199,21 +199,21 @@  discard block
 block discarded – undo
199 199
 	 * @param string the request IP address
200 200
 	 * @return integer 1 if the user is allowed, -1 if the user is denied, 0 if the rule does not apply to the user
201 201
 	 */
202
-	public function isUserAllowed(IUser $user,$verb,$ip)
202
+	public function isUserAllowed(IUser $user, $verb, $ip)
203 203
 	{
204
-		if($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user))
205
-			return ($this->_action==='allow')?1:-1;
204
+		if ($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user))
205
+			return ($this->_action === 'allow') ? 1 : -1;
206 206
 		else
207 207
 			return 0;
208 208
 	}
209 209
 
210 210
 	private function isIpMatched($ip)
211 211
 	{
212
-		if(empty($this->_ipRules))
212
+		if (empty($this->_ipRules))
213 213
 			return 1;
214
-		foreach($this->_ipRules as $rule)
214
+		foreach ($this->_ipRules as $rule)
215 215
 		{
216
-			if($rule==='*' || $rule===$ip || (($pos=strpos($rule,'*'))!==false && strncmp($ip,$rule,$pos)===0))
216
+			if ($rule === '*' || $rule === $ip || (($pos = strpos($rule, '*')) !== false && strncmp($ip, $rule, $pos) === 0))
217 217
 				return 1;
218 218
 		}
219 219
 		return 0;
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
 
222 222
 	private function isUserMatched($user)
223 223
 	{
224
-		return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()),$this->_users));
224
+		return ($this->_everyone || ($this->_guest && $user->getIsGuest()) || ($this->_authenticated && !$user->getIsGuest()) || in_array(strtolower($user->getName()), $this->_users));
225 225
 	}
226 226
 
227 227
 	private function isRoleMatched($user)
228 228
 	{
229
-		foreach($this->_roles as $role)
229
+		foreach ($this->_roles as $role)
230 230
 		{
231
-			if($role==='*' || $user->isInRole($role))
231
+			if ($role === '*' || $user->isInRole($role))
232 232
 				return true;
233 233
 		}
234 234
 		return false;
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
 	private function isVerbMatched($verb)
238 238
 	{
239
-		return ($this->_verb==='*' || strcasecmp($verb,$this->_verb)===0);
239
+		return ($this->_verb === '*' || strcasecmp($verb, $this->_verb) === 0);
240 240
 	}
241 241
 }
242 242
 
@@ -258,15 +258,15 @@  discard block
 block discarded – undo
258 258
 	 * @param string the request IP address
259 259
 	 * @return boolean whether the user is allowed
260 260
 	 */
261
-	public function isUserAllowed($user,$verb,$ip)
261
+	public function isUserAllowed($user, $verb, $ip)
262 262
 	{
263
-		if($user instanceof IUser)
263
+		if ($user instanceof IUser)
264 264
 		{
265
-			$verb=strtolower(trim($verb));
266
-			foreach($this as $rule)
265
+			$verb = strtolower(trim($verb));
266
+			foreach ($this as $rule)
267 267
 			{
268
-				if(($decision=$rule->isUserAllowed($user,$verb,$ip))!==0)
269
-					return ($decision>0);
268
+				if (($decision = $rule->isUserAllowed($user, $verb, $ip)) !== 0)
269
+					return ($decision > 0);
270 270
 			}
271 271
 			return true;
272 272
 		}
@@ -282,10 +282,10 @@  discard block
 block discarded – undo
282 282
 	 * @param mixed new item
283 283
 	 * @throws TInvalidDataTypeException if the item to be inserted is not a TAuthorizationRule object.
284 284
 	 */
285
-	public function insertAt($index,$item)
285
+	public function insertAt($index, $item)
286 286
 	{
287
-		if($item instanceof TAuthorizationRule)
288
-			parent::insertAt($index,$item);
287
+		if ($item instanceof TAuthorizationRule)
288
+			parent::insertAt($index, $item);
289 289
 		else
290 290
 			throw new TInvalidDataTypeException('authorizationrulecollection_authorizationrule_required');
291 291
 	}
Please login to merge, or discard this patch.
Braces   +58 added lines, -44 removed lines patch added patch discarded remove patch
@@ -73,10 +73,11 @@  discard block
 block discarded – undo
73 73
 	public function __construct($action,$users,$roles,$verb='',$ipRules='')
74 74
 	{
75 75
 		$action=strtolower(trim($action));
76
-		if($action==='allow' || $action==='deny')
77
-			$this->_action=$action;
78
-		else
79
-			throw new TInvalidDataValueException('authorizationrule_action_invalid',$action);
76
+		if($action==='allow' || $action==='deny') {
77
+					$this->_action=$action;
78
+		} else {
79
+					throw new TInvalidDataValueException('authorizationrule_action_invalid',$action);
80
+		}
80 81
 		$this->_users=array();
81 82
 		$this->_roles=array();
82 83
 		$this->_ipRules=array();
@@ -84,8 +85,9 @@  discard block
 block discarded – undo
84 85
 		$this->_guest=false;
85 86
 		$this->_authenticated=false;
86 87
 
87
-		if(trim($users)==='')
88
-			$users='*';
88
+		if(trim($users)==='') {
89
+					$users='*';
90
+		}
89 91
 		foreach(explode(',',$users) as $user)
90 92
 		{
91 93
 			if(($user=trim(strtolower($user)))!=='')
@@ -94,37 +96,43 @@  discard block
 block discarded – undo
94 96
 				{
95 97
 					$this->_everyone=true;
96 98
 					break;
99
+				} else if($user==='?') {
100
+									$this->_guest=true;
101
+				} else if($user==='@') {
102
+									$this->_authenticated=true;
103
+				} else {
104
+									$this->_users[]=$user;
97 105
 				}
98
-				else if($user==='?')
99
-					$this->_guest=true;
100
-				else if($user==='@')
101
-					$this->_authenticated=true;
102
-				else
103
-					$this->_users[]=$user;
104 106
 			}
105 107
 		}
106 108
 
107
-		if(trim($roles)==='')
108
-			$roles='*';
109
+		if(trim($roles)==='') {
110
+					$roles='*';
111
+		}
109 112
 		foreach(explode(',',$roles) as $role)
110 113
 		{
111
-			if(($role=trim(strtolower($role)))!=='')
112
-				$this->_roles[]=$role;
114
+			if(($role=trim(strtolower($role)))!=='') {
115
+							$this->_roles[]=$role;
116
+			}
113 117
 		}
114 118
 
115
-		if(($verb=trim(strtolower($verb)))==='')
116
-			$verb='*';
117
-		if($verb==='*' || $verb==='get' || $verb==='post')
118
-			$this->_verb=$verb;
119
-		else
120
-			throw new TInvalidDataValueException('authorizationrule_verb_invalid',$verb);
119
+		if(($verb=trim(strtolower($verb)))==='') {
120
+					$verb='*';
121
+		}
122
+		if($verb==='*' || $verb==='get' || $verb==='post') {
123
+					$this->_verb=$verb;
124
+		} else {
125
+					throw new TInvalidDataValueException('authorizationrule_verb_invalid',$verb);
126
+		}
121 127
 
122
-		if(trim($ipRules)==='')
123
-			$ipRules='*';
128
+		if(trim($ipRules)==='') {
129
+					$ipRules='*';
130
+		}
124 131
 		foreach(explode(',',$ipRules) as $ipRule)
125 132
 		{
126
-			if(($ipRule=trim($ipRule))!=='')
127
-				$this->_ipRules[]=$ipRule;
133
+			if(($ipRule=trim($ipRule))!=='') {
134
+							$this->_ipRules[]=$ipRule;
135
+			}
128 136
 		}
129 137
 	}
130 138
 
@@ -201,20 +209,23 @@  discard block
 block discarded – undo
201 209
 	 */
202 210
 	public function isUserAllowed(IUser $user,$verb,$ip)
203 211
 	{
204
-		if($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user))
205
-			return ($this->_action==='allow')?1:-1;
206
-		else
207
-			return 0;
212
+		if($this->isVerbMatched($verb) && $this->isIpMatched($ip) && $this->isUserMatched($user) && $this->isRoleMatched($user)) {
213
+					return ($this->_action==='allow')?1:-1;
214
+		} else {
215
+					return 0;
216
+		}
208 217
 	}
209 218
 
210 219
 	private function isIpMatched($ip)
211 220
 	{
212
-		if(empty($this->_ipRules))
213
-			return 1;
221
+		if(empty($this->_ipRules)) {
222
+					return 1;
223
+		}
214 224
 		foreach($this->_ipRules as $rule)
215 225
 		{
216
-			if($rule==='*' || $rule===$ip || (($pos=strpos($rule,'*'))!==false && strncmp($ip,$rule,$pos)===0))
217
-				return 1;
226
+			if($rule==='*' || $rule===$ip || (($pos=strpos($rule,'*'))!==false && strncmp($ip,$rule,$pos)===0)) {
227
+							return 1;
228
+			}
218 229
 		}
219 230
 		return 0;
220 231
 	}
@@ -228,8 +239,9 @@  discard block
 block discarded – undo
228 239
 	{
229 240
 		foreach($this->_roles as $role)
230 241
 		{
231
-			if($role==='*' || $user->isInRole($role))
232
-				return true;
242
+			if($role==='*' || $user->isInRole($role)) {
243
+							return true;
244
+			}
233 245
 		}
234 246
 		return false;
235 247
 	}
@@ -265,13 +277,14 @@  discard block
 block discarded – undo
265 277
 			$verb=strtolower(trim($verb));
266 278
 			foreach($this as $rule)
267 279
 			{
268
-				if(($decision=$rule->isUserAllowed($user,$verb,$ip))!==0)
269
-					return ($decision>0);
280
+				if(($decision=$rule->isUserAllowed($user,$verb,$ip))!==0) {
281
+									return ($decision>0);
282
+				}
270 283
 			}
271 284
 			return true;
285
+		} else {
286
+					return false;
272 287
 		}
273
-		else
274
-			return false;
275 288
 	}
276 289
 
277 290
 	/**
@@ -284,10 +297,11 @@  discard block
 block discarded – undo
284 297
 	 */
285 298
 	public function insertAt($index,$item)
286 299
 	{
287
-		if($item instanceof TAuthorizationRule)
288
-			parent::insertAt($index,$item);
289
-		else
290
-			throw new TInvalidDataTypeException('authorizationrulecollection_authorizationrule_required');
300
+		if($item instanceof TAuthorizationRule) {
301
+					parent::insertAt($index,$item);
302
+		} else {
303
+					throw new TInvalidDataTypeException('authorizationrulecollection_authorizationrule_required');
304
+		}
291 305
 	}
292 306
 }
293 307
 
Please login to merge, or discard this patch.