@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * @var boolean controls the use of a persistent connection. Default to true. |
106 | 106 | */ |
107 | - private $_persistence = true; |
|
107 | + private $_persistence=true; |
|
108 | 108 | /** |
109 | 109 | * @var integer number of buckets to create for this server which in turn control its |
110 | 110 | * probability of it being selected. The probability is relative to the total weight |
111 | 111 | * of all servers. |
112 | 112 | */ |
113 | - private $_weight = 1; |
|
113 | + private $_weight=1; |
|
114 | 114 | |
115 | - private $_timeout = 360; |
|
115 | + private $_timeout=360; |
|
116 | 116 | |
117 | - private $_retryInterval = 15; |
|
117 | + private $_retryInterval=15; |
|
118 | 118 | /** |
119 | 119 | * @var integer Controls the minimum value length before attempting to compress automatically. |
120 | 120 | */ |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | */ |
126 | 126 | private $_minSavings=0.0; |
127 | 127 | |
128 | - private $_status = true; |
|
128 | + private $_status=true; |
|
129 | 129 | |
130 | - private $_failureCallback = null; |
|
130 | + private $_failureCallback=null; |
|
131 | 131 | |
132 | 132 | /** |
133 | 133 | * @var boolean whether to use memcached or memcache as the underlying caching extension. |
@@ -168,26 +168,26 @@ discard block |
||
168 | 168 | if(!extension_loaded('memcached') && $this->_useMemcached) |
169 | 169 | throw new TConfigurationException('memcached_extension_required'); |
170 | 170 | |
171 | - $this->_cache = $this->_useMemcached ? new Memcached : new Memcache; |
|
171 | + $this->_cache=$this->_useMemcached ? new Memcached : new Memcache; |
|
172 | 172 | $this->loadConfig($config); |
173 | 173 | if(count($this->_servers)) |
174 | 174 | { |
175 | 175 | foreach($this->_servers as $server) |
176 | 176 | { |
177 | 177 | Prado::trace('Adding server '.$server['Host'].' from serverlist', 'System.Caching.TMemCache'); |
178 | - if($this->_cache->addServer($server['Host'],$server['Port'],$server['Persistent'], |
|
179 | - $server['Weight'],$server['Timeout'],$server['RetryInterval'])===false) |
|
180 | - throw new TConfigurationException('memcache_connection_failed',$server['Host'],$server['Port']); |
|
178 | + if($this->_cache->addServer($server['Host'], $server['Port'], $server['Persistent'], |
|
179 | + $server['Weight'], $server['Timeout'], $server['RetryInterval'])===false) |
|
180 | + throw new TConfigurationException('memcache_connection_failed', $server['Host'], $server['Port']); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | else |
184 | 184 | { |
185 | 185 | Prado::trace('Adding server '.$this->_host, 'System.Caching.TMemCache'); |
186 | - if($this->_cache->addServer($this->_host,$this->_port)===false) |
|
187 | - throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port); |
|
186 | + if($this->_cache->addServer($this->_host, $this->_port)===false) |
|
187 | + throw new TConfigurationException('memcache_connection_failed', $this->_host, $this->_port); |
|
188 | 188 | } |
189 | 189 | if($this->_threshold!==0) |
190 | - $this->_cache->setCompressThreshold($this->_threshold,$this->_minSavings); |
|
190 | + $this->_cache->setCompressThreshold($this->_threshold, $this->_minSavings); |
|
191 | 191 | $this->_initialized=true; |
192 | 192 | parent::init($config); |
193 | 193 | } |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | throw new TConfigurationException('memcache_serverport_required'); |
211 | 211 | if(!is_numeric($port)) |
212 | 212 | throw new TConfigurationException('memcache_serverport_invalid'); |
213 | - $server = array('Host'=>$host,'Port'=>$port,'Weight'=>1,'Timeout'=>1800,'RetryInterval'=>15,'Persistent'=>true); |
|
214 | - $checks = array( |
|
213 | + $server=array('Host'=>$host, 'Port'=>$port, 'Weight'=>1, 'Timeout'=>1800, 'RetryInterval'=>15, 'Persistent'=>true); |
|
214 | + $checks=array( |
|
215 | 215 | 'Weight'=>'memcache_serverweight_invalid', |
216 | 216 | 'Timeout'=>'memcache_servertimeout_invalid', |
217 | 217 | 'RetryInterval'=>'memcach_serverretryinterval_invalid' |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | else if($value!==null) |
225 | 225 | throw new TConfigurationException($exception); |
226 | 226 | } |
227 | - $server['Persistent']= TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
227 | + $server['Persistent']=TPropertyValue::ensureBoolean($properties->remove('Persistent')); |
|
228 | 228 | $this->_servers[]=$server; |
229 | 229 | } |
230 | 230 | } |
@@ -350,12 +350,12 @@ discard block |
||
350 | 350 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
351 | 351 | * @return boolean true if the value is successfully stored into cache, false otherwise |
352 | 352 | */ |
353 | - protected function setValue($key,$value,$expire) |
|
353 | + protected function setValue($key, $value, $expire) |
|
354 | 354 | { |
355 | 355 | if($this->_useMemcached) { |
356 | - return $this->_cache->set($key,$value,$expire); |
|
356 | + return $this->_cache->set($key, $value, $expire); |
|
357 | 357 | } else { |
358 | - return $this->_cache->set($key,$value,0,$expire); |
|
358 | + return $this->_cache->set($key, $value, 0, $expire); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
@@ -368,12 +368,12 @@ discard block |
||
368 | 368 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
369 | 369 | * @return boolean true if the value is successfully stored into cache, false otherwise |
370 | 370 | */ |
371 | - protected function addValue($key,$value,$expire) |
|
371 | + protected function addValue($key, $value, $expire) |
|
372 | 372 | { |
373 | 373 | if($this->_useMemcached) { |
374 | - $this->_cache->add($key,$value,$expire); |
|
374 | + $this->_cache->add($key, $value, $expire); |
|
375 | 375 | } else { |
376 | - return $this->_cache->add($key,$value,0,$expire); |
|
376 | + return $this->_cache->add($key, $value, 0, $expire); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | if(!function_exists('xcache_isset')) |
53 | 53 | throw new TConfigurationException('xcache_extension_required'); |
54 | 54 | |
55 | - $enabled = (int)ini_get('xcache.cacher') !== 0; |
|
56 | - $var_size = (int)ini_get('xcache.var_size'); |
|
55 | + $enabled=(int) ini_get('xcache.cacher')!==0; |
|
56 | + $var_size=(int) ini_get('xcache.var_size'); |
|
57 | 57 | |
58 | 58 | if(!($enabled && $var_size > 0)) |
59 | 59 | throw new TConfigurationException('xcache_extension_not_enabled'); |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
82 | 82 | * @return boolean true if the value is successfully stored into cache, false otherwise |
83 | 83 | */ |
84 | - protected function setValue($key,$value,$expire) |
|
84 | + protected function setValue($key, $value, $expire) |
|
85 | 85 | { |
86 | - return xcache_set($key,$value,$expire); |
|
86 | + return xcache_set($key, $value, $expire); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @param integer the number of seconds in which the cached value will expire. 0 means never expire. |
96 | 96 | * @return boolean true if the value is successfully stored into cache, false otherwise |
97 | 97 | */ |
98 | - protected function addValue($key,$value,$expire) |
|
98 | + protected function addValue($key, $value, $expire) |
|
99 | 99 | { |
100 | - return !xcache_isset($key) ? $this->setValue($key,$value,$expire) : false; |
|
100 | + return !xcache_isset($key) ? $this->setValue($key, $value, $expire) : false; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function flush() |
119 | 119 | { |
120 | - for($i=0, $max=xcache_count(XC_TYPE_VAR); $i<$max; $i++) |
|
120 | + for($i=0, $max=xcache_count(XC_TYPE_VAR); $i < $max; $i++) |
|
121 | 121 | { |
122 | 122 | if(xcache_clear_cache(XC_TYPE_VAR, $i)===false) |
123 | 123 | return false; |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | protected function __getZappableSleepProps(&$exprops) |
54 | 54 | { |
55 | 55 | parent::__getZappableSleepProps($exprops); |
56 | - if ($this->_caseSensitive===false) |
|
57 | - $exprops[] = "\0TAttributeCollection\0_caseSensitive"; |
|
56 | + if($this->_caseSensitive===false) |
|
57 | + $exprops[]="\0TAttributeCollection\0_caseSensitive"; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function __get($name) |
69 | 69 | { |
70 | - return $this->contains($name)?$this->itemAt($name):parent::__get($name); |
|
70 | + return $this->contains($name) ? $this->itemAt($name) : parent::__get($name); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * @param mixed the property value or event handler |
79 | 79 | * @throws TInvalidOperationException If the property is not defined or read-only. |
80 | 80 | */ |
81 | - public function __set($name,$value) |
|
81 | + public function __set($name, $value) |
|
82 | 82 | { |
83 | - $this->add($name,$value); |
|
83 | + $this->add($name, $value); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function itemAt($key) |
109 | 109 | { |
110 | - return parent::itemAt($this->_caseSensitive?$key:strtolower($key)); |
|
110 | + return parent::itemAt($this->_caseSensitive ? $key : strtolower($key)); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | * @param mixed key |
118 | 118 | * @param mixed value |
119 | 119 | */ |
120 | - public function add($key,$value) |
|
120 | + public function add($key, $value) |
|
121 | 121 | { |
122 | - parent::add($this->_caseSensitive?$key:strtolower($key),$value); |
|
122 | + parent::add($this->_caseSensitive ? $key : strtolower($key), $value); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function remove($key) |
132 | 132 | { |
133 | - return parent::remove($this->_caseSensitive?$key:strtolower($key)); |
|
133 | + return parent::remove($this->_caseSensitive ? $key : strtolower($key)); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function contains($key) |
143 | 143 | { |
144 | - return parent::contains($this->_caseSensitive?$key:strtolower($key)); |
|
144 | + return parent::contains($this->_caseSensitive ? $key : strtolower($key)); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | public function createListItem($index=-1) |
39 | 39 | { |
40 | 40 | $item=$this->createNewListItem(); |
41 | - if($index<0) |
|
41 | + if($index < 0) |
|
42 | 42 | $this->add($item); |
43 | 43 | else |
44 | - $this->insertAt($index,$item); |
|
44 | + $this->insertAt($index, $item); |
|
45 | 45 | return $item; |
46 | 46 | } |
47 | 47 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | protected function createNewListItem($text=null) |
52 | 52 | { |
53 | - $item = new TListItem; |
|
53 | + $item=new TListItem; |
|
54 | 54 | if($text!==null) |
55 | 55 | $item->setText($text); |
56 | 56 | return $item; |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | * @param TListItem the item to be inserted. |
64 | 64 | * @throws TInvalidDataTypeException if the item being inserted is neither a string nor TListItem |
65 | 65 | */ |
66 | - public function insertAt($index,$item) |
|
66 | + public function insertAt($index, $item) |
|
67 | 67 | { |
68 | 68 | if(is_string($item)) |
69 | - $item = $this->createNewListItem($item); |
|
69 | + $item=$this->createNewListItem($item); |
|
70 | 70 | if(!($item instanceof TListItem)) |
71 | - throw new TInvalidDataTypeException('listitemcollection_item_invalid',get_class($this)); |
|
72 | - parent::insertAt($index,$item); |
|
71 | + throw new TInvalidDataTypeException('listitemcollection_item_invalid', get_class($this)); |
|
72 | + parent::insertAt($index, $item); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param boolean whether to look for disabled items also |
79 | 79 | * @return integer the index of the item found, -1 if not found. |
80 | 80 | */ |
81 | - public function findIndexByValue($value,$includeDisabled=true) |
|
81 | + public function findIndexByValue($value, $includeDisabled=true) |
|
82 | 82 | { |
83 | 83 | $value=TPropertyValue::ensureString($value); |
84 | 84 | $index=0; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param boolean whether to look for disabled items also |
98 | 98 | * @return integer the index of the item found, -1 if not found. |
99 | 99 | */ |
100 | - public function findIndexByText($text,$includeDisabled=true) |
|
100 | + public function findIndexByText($text, $includeDisabled=true) |
|
101 | 101 | { |
102 | 102 | $text=TPropertyValue::ensureString($text); |
103 | 103 | $index=0; |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * @param boolean whether to look for disabled items also |
117 | 117 | * @return TListItem the item found, null if not found. |
118 | 118 | */ |
119 | - public function findItemByValue($value,$includeDisabled=true) |
|
119 | + public function findItemByValue($value, $includeDisabled=true) |
|
120 | 120 | { |
121 | - if(($index=$this->findIndexByValue($value,$includeDisabled))>=0) |
|
121 | + if(($index=$this->findIndexByValue($value, $includeDisabled)) >= 0) |
|
122 | 122 | return $this->itemAt($index); |
123 | 123 | else |
124 | 124 | return null; |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | * @param boolean whether to look for disabled items also |
131 | 131 | * @return TListItem the item found, null if not found. |
132 | 132 | */ |
133 | - public function findItemByText($text,$includeDisabled=true) |
|
133 | + public function findItemByText($text, $includeDisabled=true) |
|
134 | 134 | { |
135 | - if(($index=$this->findIndexByText($text,$includeDisabled))>=0) |
|
135 | + if(($index=$this->findIndexByText($text, $includeDisabled)) >= 0) |
|
136 | 136 | return $this->itemAt($index); |
137 | 137 | else |
138 | 138 | return null; |
@@ -157,6 +157,6 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function saveState() |
159 | 159 | { |
160 | - return ($this->getCount()>0) ? $this->toArray() : null; |
|
160 | + return ($this->getCount() > 0) ? $this->toArray() : null; |
|
161 | 161 | } |
162 | 162 | } |
@@ -94,7 +94,7 @@ |
||
94 | 94 | * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this). |
95 | 95 | * @return string URL to the asset path. |
96 | 96 | */ |
97 | - public function publishAsset($assetPath,$className=null) |
|
97 | + public function publishAsset($assetPath, $className=null) |
|
98 | 98 | { |
99 | 99 | if($className===null) |
100 | 100 | $className=get_class($this); |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | if(is_string($this->_userManager)) |
95 | 95 | { |
96 | 96 | if(($users=$application->getModule($this->_userManager))===null) |
97 | - throw new TConfigurationException('authmanager_usermanager_inexistent',$this->_userManager); |
|
97 | + throw new TConfigurationException('authmanager_usermanager_inexistent', $this->_userManager); |
|
98 | 98 | if(!($users instanceof IUserManager)) |
99 | - throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager); |
|
99 | + throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager); |
|
100 | 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')); |
|
102 | + $application->attachEventHandler('OnAuthentication', array($this, 'doAuthentication')); |
|
103 | + $application->attachEventHandler('OnEndRequest', array($this, 'leave')); |
|
104 | + $application->attachEventHandler('OnAuthorization', array($this, 'doAuthorization')); |
|
105 | 105 | $this->_initialized=true; |
106 | 106 | } |
107 | 107 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | if($this->_initialized) |
123 | 123 | throw new TInvalidOperationException('authmanager_usermanager_unchangeable'); |
124 | 124 | if(!is_string($provider) && !($provider instanceof IUserManager)) |
125 | - throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager); |
|
125 | + throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager); |
|
126 | 126 | $this->_userManager=$provider; |
127 | 127 | } |
128 | 128 | |
@@ -152,7 +152,7 @@ discard block |
||
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 | |
@@ -168,7 +168,7 @@ discard block |
||
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 | 173 | if(!$this->_skipAuthorization) |
174 | 174 | { |
@@ -183,7 +183,7 @@ discard block |
||
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 | 188 | $application=$this->getApplication(); |
189 | 189 | if($application->getResponse()->getStatusCode()===401) |
@@ -229,7 +229,7 @@ discard block |
||
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 | /** |
@@ -288,8 +288,8 @@ discard block |
||
288 | 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 | 295 | if($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired)) |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | $user=$user2; |
303 | 303 | $this->updateSessionUser($user); |
304 | 304 | // user is restored from cookie, auth may not expire |
305 | - $isAuthExpired = false; |
|
305 | + $isAuthExpired=false; |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | |
318 | 318 | // event handler gets a chance to do further auth work |
319 | 319 | if($this->hasEventHandler('OnAuthenticate')) |
320 | - $this->raiseEvent('OnAuthenticate',$this,$application); |
|
320 | + $this->raiseEvent('OnAuthenticate', $this, $application); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | { |
330 | 330 | $this->logout(); |
331 | 331 | if($this->hasEventHandler('OnAuthExpire')) |
332 | - $this->raiseEvent('OnAuthExpire',$this,$param); |
|
332 | + $this->raiseEvent('OnAuthExpire', $this, $param); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | { |
344 | 344 | $application=$this->getApplication(); |
345 | 345 | if($this->hasEventHandler('OnAuthorize')) |
346 | - $this->raiseEvent('OnAuthorize',$this,$application); |
|
347 | - if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(),$application->getRequest()->getRequestType(),$application->getRequest()->getUserHostAddress())) |
|
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(); |
@@ -383,7 +383,7 @@ discard block |
||
383 | 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 | |
@@ -411,19 +411,19 @@ discard block |
||
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 | 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 | } |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | $session->destroy(); |
447 | 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 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function getName() |
70 | 70 | { |
71 | - return $this->getState('Name',''); |
|
71 | + return $this->getState('Name', ''); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function setName($value) |
78 | 78 | { |
79 | - $this->setState('Name',$value,''); |
|
79 | + $this->setState('Name', $value, ''); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function getIsGuest() |
86 | 86 | { |
87 | - return $this->getState('IsGuest',true); |
|
87 | + return $this->getState('IsGuest', true); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $this->setName($this->_manager->getGuestName()); |
98 | 98 | $this->setRoles(array()); |
99 | 99 | } |
100 | - $this->setState('IsGuest',$isGuest); |
|
100 | + $this->setState('IsGuest', $isGuest); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function getRoles() |
107 | 107 | { |
108 | - return $this->getState('Roles',array()); |
|
108 | + return $this->getState('Roles', array()); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | public function setRoles($value) |
115 | 115 | { |
116 | 116 | if(is_array($value)) |
117 | - $this->setState('Roles',$value,array()); |
|
117 | + $this->setState('Roles', $value, array()); |
|
118 | 118 | else |
119 | 119 | { |
120 | 120 | $roles=array(); |
121 | - foreach(explode(',',$value) as $role) |
|
121 | + foreach(explode(',', $value) as $role) |
|
122 | 122 | { |
123 | 123 | if(($role=trim($role))!=='') |
124 | 124 | $roles[]=$role; |
125 | 125 | } |
126 | - $this->setState('Roles',$roles,array()); |
|
126 | + $this->setState('Roles', $roles, array()); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | public function isInRole($role) |
135 | 135 | { |
136 | 136 | foreach($this->getRoles() as $r) |
137 | - if(strcasecmp($role,$r)===0) |
|
137 | + if(strcasecmp($role, $r)===0) |
|
138 | 138 | return true; |
139 | 139 | return false; |
140 | 140 | } |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | * @return mixed the value of the variable. If it doesn't exist, the provided default value will be returned |
174 | 174 | * @see setState |
175 | 175 | */ |
176 | - protected function getState($key,$defaultValue=null) |
|
176 | + protected function getState($key, $defaultValue=null) |
|
177 | 177 | { |
178 | - return isset($this->_state[$key])?$this->_state[$key]:$defaultValue; |
|
178 | + return isset($this->_state[$key]) ? $this->_state[$key] : $defaultValue; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param mixed default value. If $value===$defaultValue, the variable will be removed from persistent storage. |
193 | 193 | * @see getState |
194 | 194 | */ |
195 | - protected function setState($key,$value,$defaultValue=null) |
|
195 | + protected function setState($key, $value, $defaultValue=null) |
|
196 | 196 | { |
197 | 197 | if($value===$defaultValue) |
198 | 198 | unset($this->_state[$key]); |
@@ -51,6 +51,6 @@ |
||
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 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * To trim or not to trim the contents. |
51 | 51 | * @var boolean |
52 | 52 | */ |
53 | - protected $trim = true; |
|
53 | + protected $trim=true; |
|
54 | 54 | |
55 | 55 | |
56 | 56 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function setKey($value) |
72 | 72 | { |
73 | - $this->key = $value; |
|
73 | + $this->key=$value; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function setTrim($value) |
81 | 81 | { |
82 | - $this->trim = TPropertyValue::ensureBoolean($value); |
|
82 | + $this->trim=TPropertyValue::ensureBoolean($value); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function getParameter() |
108 | 108 | { |
109 | - $value = $this->getValue(); |
|
109 | + $value=$this->getValue(); |
|
110 | 110 | if(strlen($value) > 0) |
111 | 111 | return $value; |
112 | - $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
|
112 | + $htmlWriter=Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
|
113 | 113 | $this->renderControl($htmlWriter); |
114 | 114 | return $this->getTrim() ? |
115 | 115 | trim($htmlWriter->flush()) : $htmlWriter->flush(); |