Completed
Push — intl ( 51e284 )
by Fabio
06:51
created
framework/Security/TAuthManager.php 2 patches
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   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -94,14 +94,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 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
 
@@ -168,7 +168,7 @@  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 173
 		if(!$this->_skipAuthorization)
174 174
 		{
@@ -183,7 +183,7 @@  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 188
 		$application=$this->getApplication();
189 189
 		if($application->getResponse()->getStatusCode()===401)
@@ -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
 	/**
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 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 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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
framework/I18N/core/DateFormat.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
 	/**
81 81
 	 * The DateTimeFormatInfo, containing culture specific patterns and names.
82
- 	 * @var DateTimeFormatInfo
82
+	 * @var DateTimeFormatInfo
83 83
 	 */
84 84
 	protected $formatInfo;
85 85
 
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
 
309 309
 	/**
310 310
 	 * Get the year.
311
- 	 * "yy" will return the last two digits of year.
312
- 	 * "yyyy" will return the full integer year.
311
+	 * "yy" will return the last two digits of year.
312
+	 * "yyyy" will return the full integer year.
313 313
 	 * @param array getdate format.
314 314
 	 * @param string a pattern.
315 315
 	 * @return string year
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
 
331 331
 	/**
332 332
 	 * Get the month.
333
- 	 * "M" will return integer 1 through 12
334
- 	 * "MM" will return the narrow month name, e.g. "J"
335
- 	 * "MMM" will return the abrreviated month name, e.g. "Jan"
336
- 	 * "MMMM" will return the month name, e.g. "January"
333
+	 * "M" will return integer 1 through 12
334
+	 * "MM" will return the narrow month name, e.g. "J"
335
+	 * "MMM" will return the abrreviated month name, e.g. "Jan"
336
+	 * "MMMM" will return the month name, e.g. "January"
337 337
 	 * @param array getdate format.
338 338
 	 * @param string a pattern.
339 339
 	 * @return string month name
@@ -361,10 +361,10 @@  discard block
 block discarded – undo
361 361
 
362 362
 	/**
363 363
 	 * Get the day of the week.
364
- 	 * "E" will return integer 0 (for Sunday) through 6 (for Saturday).
365
- 	 * "EE" will return the narrow day of the week, e.g. "M"
366
- 	 * "EEE" will return the abrreviated day of the week, e.g. "Mon"
367
- 	 * "EEEE" will return the day of the week, e.g. "Monday"
364
+	 * "E" will return integer 0 (for Sunday) through 6 (for Saturday).
365
+	 * "EE" will return the narrow day of the week, e.g. "M"
366
+	 * "EEE" will return the abrreviated day of the week, e.g. "Mon"
367
+	 * "EEEE" will return the day of the week, e.g. "Monday"
368 368
 	 * @param array getdate format.
369 369
 	 * @param string a pattern.
370 370
 	 * @return string day of the week.
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 
395 395
 	/**
396 396
 	 * Get the day of the month.
397
- 	 * "d" for non-padding, "dd" will always return 2 characters.
397
+	 * "d" for non-padding, "dd" will always return 2 characters.
398 398
 	 * @param array getdate format.
399 399
 	 * @param string a pattern.
400 400
 	 * @return string day of the month
@@ -581,14 +581,14 @@  discard block
 block discarded – undo
581 581
 	protected function getDayInMonth($date, $pattern='FF')
582 582
 	{
583 583
 		switch ($pattern) {
584
-		    case 'F':
585
-		      return @date('j', @mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']));
586
-		      break;
587
-		    case 'FF':
588
-		      return @date('d', @mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']));
589
-		      break;
590
-		    default:
591
-		      throw new Exception('The pattern for day in month is "F" or "FF".');
584
+			case 'F':
585
+			  return @date('j', @mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']));
586
+			  break;
587
+			case 'FF':
588
+			  return @date('d', @mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']));
589
+			  break;
590
+			default:
591
+			  throw new Exception('The pattern for day in month is "F" or "FF".');
592 592
 		}
593 593
 	}
594 594
 
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * A list of tokens and their function call.
52 52
 	 * @var array
53 53
 	 */
54
-	protected $tokens = array(
54
+	protected $tokens=array(
55 55
 			'G'=>'Era',
56 56
 			'y'=>'Year',
57 57
 			'M'=>'Month',
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 * A list of methods, to be used by the token function calls.
76 76
 	 * @var array
77 77
 	 */
78
-	protected $methods = array();
78
+	protected $methods=array();
79 79
 
80 80
 	/**
81 81
 	 * The DateTimeFormatInfo, containing culture specific patterns and names.
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	function __construct($formatInfo=null)
93 93
 	{
94
-		if($formatInfo === null)
95
-			$this->formatInfo = DateTimeFormatInfo::getInvariantInfo();
94
+		if($formatInfo===null)
95
+			$this->formatInfo=DateTimeFormatInfo::getInvariantInfo();
96 96
 		else if($formatInfo instanceof CultureInfo)
97
-			$this->formatInfo = $formatInfo->DateTimeFormat;
97
+			$this->formatInfo=$formatInfo->DateTimeFormat;
98 98
 		else if($formatInfo instanceof DateTimeFormatInfo)
99
-			$this->formatInfo = $formatInfo;
99
+			$this->formatInfo=$formatInfo;
100 100
 		else
101
-			$this->formatInfo = DateTimeFormatInfo::getInstance($formatInfo);
101
+			$this->formatInfo=DateTimeFormatInfo::getInstance($formatInfo);
102 102
 
103
-		$this->methods = get_class_methods($this);
103
+		$this->methods=get_class_methods($this);
104 104
 	}
105 105
 
106 106
 	/**
@@ -110,45 +110,45 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public function format($time, $pattern='F', $charset='UTF-8')
112 112
 	{
113
-		if (is_numeric($time)) //assumes unix epoch
114
-			$time = floatval($time);
113
+		if(is_numeric($time)) //assumes unix epoch
114
+			$time=floatval($time);
115 115
 		else if(is_string($time))
116
-			$time = @strtotime($time);
116
+			$time=@strtotime($time);
117 117
 
118
-		if($pattern === null)
119
-			$pattern = 'F';
118
+		if($pattern===null)
119
+			$pattern='F';
120 120
 
121
-		$s = Prado::createComponent('System.Util.TDateTimeStamp');
121
+		$s=Prado::createComponent('System.Util.TDateTimeStamp');
122 122
 
123
-		$date = $s->getDate($time);
123
+		$date=$s->getDate($time);
124 124
 
125
-		$pattern = $this->getPattern($pattern);
125
+		$pattern=$this->getPattern($pattern);
126 126
 
127
-		$tokens = $this->getTokens($pattern);
127
+		$tokens=$this->getTokens($pattern);
128 128
 
129
-		for($i = 0, $k = count($tokens); $i<$k; ++$i)
129
+		for($i=0, $k=count($tokens); $i < $k; ++$i)
130 130
 		{
131
-			$pattern = $tokens[$i];
132
-			if($pattern{0} == "'"
133
-				&& $pattern{strlen($pattern)-1} == "'")
131
+			$pattern=$tokens[$i];
132
+			if($pattern{0}=="'"
133
+				&& $pattern{strlen($pattern) - 1}=="'")
134 134
 			{
135
-				$sub = preg_replace('/(^\')|(\'$)/','',$pattern);
136
-				$tokens[$i] =  str_replace('``````','\'',$sub);
135
+				$sub=preg_replace('/(^\')|(\'$)/', '', $pattern);
136
+				$tokens[$i]=str_replace('``````', '\'', $sub);
137 137
 			}
138
-			else if($pattern == '``````')
138
+			else if($pattern=='``````')
139 139
 			{
140
-				$tokens[$i] = '\'';
140
+				$tokens[$i]='\'';
141 141
 			}
142 142
 			else
143 143
 			{
144
-				$function = $this->getFunctionName($pattern);
145
-				if($function != null)
144
+				$function=$this->getFunctionName($pattern);
145
+				if($function!=null)
146 146
 				{
147
-					$fName = 'get'.$function;
147
+					$fName='get'.$function;
148 148
 					if(in_array($fName, $this->methods))
149 149
 					{
150
-						$rs = $this->$fName($date, $pattern);
151
-						$tokens[$i] = $rs;
150
+						$rs=$this->$fName($date, $pattern);
151
+						$tokens[$i]=$rs;
152 152
 					}
153 153
 					else
154 154
 						throw new
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 			}			
158 158
 		}
159 159
 
160
-		return I18N_toEncoding(implode('',$tokens), $charset);
160
+		return I18N_toEncoding(implode('', $tokens), $charset);
161 161
 	}
162 162
 
163 163
 	/**
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	 */
185 185
 	protected function getPattern($pattern)
186 186
 	{
187
-		if(is_array($pattern) && count($pattern) == 2)
187
+		if(is_array($pattern) && count($pattern)==2)
188 188
 		{
189 189
 			return $this->formatInfo->formatDateTime(
190 190
 							$this->getPattern($pattern[0]),
@@ -273,36 +273,36 @@  discard block
 block discarded – undo
273 273
 	 */
274 274
 	protected function getTokens($pattern)
275 275
 	{
276
-		$char = null;
277
-		$tokens = array();
278
-		$token = null;
276
+		$char=null;
277
+		$tokens=array();
278
+		$token=null;
279 279
 
280
-		$text = false;
281
-		$pattern = preg_replace("/''/", '``````', $pattern);
280
+		$text=false;
281
+		$pattern=preg_replace("/''/", '``````', $pattern);
282 282
 
283
-		for($i = 0; $i < strlen($pattern); $i++)
283
+		for($i=0; $i < strlen($pattern); $i++)
284 284
 		{
285
-			if($char==null || $pattern{$i} == $char || $text)
285
+			if($char==null || $pattern{$i}==$char || $text)
286 286
 			{
287
-				$token .= $pattern{$i};
287
+				$token.=$pattern{$i};
288 288
 			}
289 289
 			else
290 290
 			{
291
-				$tokens[] = str_replace("","'",$token);
292
-				$token = $pattern{$i};
291
+				$tokens[]=str_replace("", "'", $token);
292
+				$token=$pattern{$i};
293 293
 			}
294 294
 
295
-			if($pattern{$i} == "'" && $text == false)
296
-				$text = true;
297
-			else if($text && $pattern{$i} == "'" && $char == "'")
298
-				$text = true;
299
-			else if($text && $char != "'" && $pattern{$i} == "'")
300
-				$text = false;
295
+			if($pattern{$i}=="'" && $text==false)
296
+				$text=true;
297
+			else if($text && $pattern{$i}=="'" && $char=="'")
298
+				$text=true;
299
+			else if($text && $char!="'" && $pattern{$i}=="'")
300
+				$text=false;
301 301
 
302
-			$char = $pattern{$i};
302
+			$char=$pattern{$i};
303 303
 
304 304
 		}
305
-		$tokens[] = $token;
305
+		$tokens[]=$token;
306 306
 		return $tokens;
307 307
 	}
308 308
 
@@ -316,11 +316,11 @@  discard block
 block discarded – undo
316 316
 	 */
317 317
 	protected function getYear($date, $pattern='yyyy')
318 318
 	{
319
-		$year = $date['year'];
319
+		$year=$date['year'];
320 320
 		switch($pattern)
321 321
 		{
322 322
 			case 'yy':
323
-				return substr($year,2);
323
+				return substr($year, 2);
324 324
 			case 'yyyy':
325 325
 				return $year;
326 326
 			default:
@@ -340,19 +340,19 @@  discard block
 block discarded – undo
340 340
 	 */
341 341
 	protected function getMonth($date, $pattern='M')
342 342
 	{
343
-		$month = $date['mon'];
343
+		$month=$date['mon'];
344 344
 
345 345
 		switch($pattern)
346 346
 		{
347 347
 			case 'M':
348 348
 				return $month;
349 349
 			case 'MM':
350
-				return str_pad($month, 2,'0',STR_PAD_LEFT);
350
+				return str_pad($month, 2, '0', STR_PAD_LEFT);
351 351
 			case 'MMM':
352
-				return $this->formatInfo->AbbreviatedMonthNames[$month-1];
352
+				return $this->formatInfo->AbbreviatedMonthNames[$month - 1];
353 353
 				break;
354 354
 			case 'MMMM':
355
-				return $this->formatInfo->MonthNames[$month-1];
355
+				return $this->formatInfo->MonthNames[$month - 1];
356 356
 			default:
357 357
 				throw new Exception('The pattern for month '.
358 358
 						'is "M", "MM", "MMM", or "MMMM".');
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 */
372 372
 	protected function getDayInWeek($date, $pattern='EEEE')
373 373
 	{
374
-		$day = $date['wday'];
374
+		$day=$date['wday'];
375 375
 
376 376
 		switch($pattern)
377 377
 		{
@@ -401,14 +401,14 @@  discard block
 block discarded – undo
401 401
 	 */
402 402
 	protected function getDay($date, $pattern='d')
403 403
 	{
404
-		$day = $date['mday'];
404
+		$day=$date['mday'];
405 405
 
406 406
 		switch($pattern)
407 407
 		{
408 408
 			case 'd':
409 409
 				return $day;
410 410
 			case 'dd':
411
-				return str_pad($day, 2,'0',STR_PAD_LEFT);
411
+				return str_pad($day, 2, '0', STR_PAD_LEFT);
412 412
 			default:
413 413
 				throw new Exception('The pattern for day of '.
414 414
 						'the month is "d" or "dd".');
@@ -426,10 +426,10 @@  discard block
 block discarded – undo
426 426
 	protected function getEra($date, $pattern='G')
427 427
 	{
428 428
 
429
-		if($pattern != 'G')
429
+		if($pattern!='G')
430 430
 			throw new Exception('The pattern for era is "G".');
431 431
 
432
-		$year = $date['year'];
432
+		$year=$date['year'];
433 433
 		if($year > 0)
434 434
 			return $this->formatInfo->getEra(1);
435 435
 		else
@@ -445,14 +445,14 @@  discard block
 block discarded – undo
445 445
 	 */
446 446
 	protected function getHour24($date, $pattern='H')
447 447
 	{
448
-		$hour = $date['hours'];
448
+		$hour=$date['hours'];
449 449
 
450 450
 		switch($pattern)
451 451
 		{
452 452
 			case 'H':
453 453
 				return $hour;
454 454
 			case 'HH':
455
-				return str_pad($hour, 2,'0',STR_PAD_LEFT);
455
+				return str_pad($hour, 2, '0', STR_PAD_LEFT);
456 456
 			default:
457 457
 				throw new Exception('The pattern for 24 hour '.
458 458
 						'format is "H" or "HH".');
@@ -467,11 +467,11 @@  discard block
 block discarded – undo
467 467
 	 */
468 468
 	protected function getAMPM($date, $pattern='a')
469 469
 	{
470
-		if($pattern != 'a')
470
+		if($pattern!='a')
471 471
 			throw new Exception('The pattern for AM/PM marker is "a".');
472 472
 
473
-		$hour = $date['hours'];
474
-		$ampm = (int)($hour/12);
473
+		$hour=$date['hours'];
474
+		$ampm=(int) ($hour / 12);
475 475
 		return $this->formatInfo->AMPMMarkers[$ampm];
476 476
 	}
477 477
 
@@ -484,15 +484,15 @@  discard block
 block discarded – undo
484 484
 	 */
485 485
 	protected function getHour12($date, $pattern='h')
486 486
 	{
487
-		$hour = $date['hours'];
488
-		$hour = ($hour==12|$hour==0)?12:($hour)%12;
487
+		$hour=$date['hours'];
488
+		$hour=($hour==12 | $hour==0) ? 12 : ($hour) % 12;
489 489
 
490 490
 		switch($pattern)
491 491
 		{
492 492
 			case 'h':
493 493
 				return $hour;
494 494
 			case 'hh':
495
-				return str_pad($hour, 2,'0',STR_PAD_LEFT);
495
+				return str_pad($hour, 2, '0', STR_PAD_LEFT);
496 496
 			default:
497 497
 				throw new Exception('The pattern for 24 hour '.
498 498
 						'format is "H" or "HH".');
@@ -508,14 +508,14 @@  discard block
 block discarded – undo
508 508
 	 */
509 509
 	protected function getMinutes($date, $pattern='m')
510 510
 	{
511
-		$minutes = $date['minutes'];
511
+		$minutes=$date['minutes'];
512 512
 
513 513
 		switch($pattern)
514 514
 		{
515 515
 			case 'm':
516 516
 				return $minutes;
517 517
 			case 'mm':
518
-				return str_pad($minutes, 2,'0',STR_PAD_LEFT);
518
+				return str_pad($minutes, 2, '0', STR_PAD_LEFT);
519 519
 			default:
520 520
 			throw new Exception('The pattern for minutes is "m" or "mm".');
521 521
 		}
@@ -530,14 +530,14 @@  discard block
 block discarded – undo
530 530
 	 */
531 531
 	protected function getSeconds($date, $pattern='s')
532 532
 	{
533
-		$seconds = $date['seconds'];
533
+		$seconds=$date['seconds'];
534 534
 
535 535
 		switch($pattern)
536 536
 		{
537 537
 			case 's':
538 538
 				return $seconds;
539 539
 			case 'ss':
540
-				return str_pad($seconds, 2,'0',STR_PAD_LEFT);
540
+				return str_pad($seconds, 2, '0', STR_PAD_LEFT);
541 541
 			default:
542 542
 			throw new Exception('The pattern for seconds is "s" or "ss".');
543 543
 		}
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 	 */
553 553
 	protected function getTimeZone($date, $pattern='z')
554 554
 	{
555
-		if($pattern != 'z')
555
+		if($pattern!='z')
556 556
 			throw new Exception('The pattern for time zone is "z".');
557 557
 
558 558
 		return @date('T', @mktime($date['hours'], $date['minutes'], $date['seconds'], $date['mon'], $date['mday'], $date['year']));
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 */
567 567
 	protected function getDayInYear($date, $pattern='D')
568 568
 	{
569
-		if($pattern != 'D')
569
+		if($pattern!='D')
570 570
 			throw new Exception('The pattern for day in year is "D".');
571 571
 
572 572
 		return $date['yday'];
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 	 */
581 581
 	protected function getDayInMonth($date, $pattern='FF')
582 582
 	{
583
-		switch ($pattern) {
583
+		switch($pattern) {
584 584
 		    case 'F':
585 585
 		      return @date('j', @mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']));
586 586
 		      break;
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	 */
601 601
 	protected function getWeekInYear($date, $pattern='w')
602 602
 	{
603
-		if($pattern != 'w')
603
+		if($pattern!='w')
604 604
 			throw new Exception('The pattern for week in year is "w".');
605 605
 
606 606
 		return @date('W', @mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year']));
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 	 */
614 614
 	protected function getWeekInMonth($date, $pattern='W')
615 615
 	{
616
-		if($pattern != 'W')
616
+		if($pattern!='W')
617 617
 			throw new Exception('The pattern for week in month is "W".');
618 618
 
619 619
 		return @date('W', @mktime(0, 0, 0, $date['mon'], $date['mday'], $date['year'])) - date('W', mktime(0, 0, 0, $date['mon'], 1, $date['year']));
@@ -627,10 +627,10 @@  discard block
 block discarded – undo
627 627
 	 */
628 628
 	protected function getHourInDay($date, $pattern='k')
629 629
 	{
630
-		if($pattern != 'k')
630
+		if($pattern!='k')
631 631
 			throw new Exception('The pattern for hour in day is "k".');
632 632
 
633
-		return $date['hours']+1;
633
+		return $date['hours'] + 1;
634 634
 	}
635 635
 
636 636
 	/**
@@ -641,10 +641,10 @@  discard block
 block discarded – undo
641 641
 	 */
642 642
 	protected function getHourInAMPM($date, $pattern='K')
643 643
 	{
644
-		if($pattern != 'K')
644
+		if($pattern!='K')
645 645
 			throw new Exception('The pattern for hour in AM/PM is "K".');
646 646
 
647
-		return ($date['hours']+1)%12;
647
+		return ($date['hours'] + 1) % 12;
648 648
 	}
649 649
 
650 650
 }
Please login to merge, or discard this patch.
framework/I18N/core/NumberFormat.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 
77 77
 	/**
78 78
 	 * The DateTimeFormatInfo, containing culture specific patterns and names.
79
- 	 * @var DateTimeFormatInfo
79
+	 * @var DateTimeFormatInfo
80 80
 	 */
81 81
 	protected $formatInfo;
82 82
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	function format($number, $pattern='d', $currency='USD', $charset='UTF-8')
117 117
 	{
118 118
 		$oldLocale=setLocale(LC_NUMERIC, '0');
119
-	    setlocale(LC_NUMERIC, 'C');
119
+		setlocale(LC_NUMERIC, 'C');
120 120
 
121 121
 		$this->setPattern($pattern);
122 122
 
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	function __construct($formatInfo=null)
92 92
 	{
93
-		if($formatInfo === null)
94
-			$this->formatInfo = NumberFormatInfo::getInvariantInfo();
93
+		if($formatInfo===null)
94
+			$this->formatInfo=NumberFormatInfo::getInvariantInfo();
95 95
 		else if($formatInfo instanceof CultureInfo)
96
-			$this->formatInfo = $formatInfo->NumberFormat;
96
+			$this->formatInfo=$formatInfo->NumberFormat;
97 97
 		else if($formatInfo instanceof NumberFormatInfo)
98
-			$this->formatInfo = $formatInfo;
98
+			$this->formatInfo=$formatInfo;
99 99
 		else
100
-			$this->formatInfo =
100
+			$this->formatInfo=
101 101
 				NumberFormatInfo::getInstance($formatInfo);
102 102
 	}
103 103
 
@@ -120,37 +120,37 @@  discard block
 block discarded – undo
120 120
 
121 121
 		$this->setPattern($pattern);
122 122
 
123
-		if(strtolower($pattern) == 'p')
124
-			$number = $number * 100;
123
+		if(strtolower($pattern)=='p')
124
+			$number=$number * 100;
125 125
 
126
-		$string = (string)$number;
126
+		$string=(string) $number;
127 127
 
128
-		$decimal = $this->formatDecimal($string);
129
-		$integer = $this->formatInteger(abs($number));
128
+		$decimal=$this->formatDecimal($string);
129
+		$integer=$this->formatInteger(abs($number));
130 130
 
131
-		if(strlen($decimal)>0)
132
-			$result = $integer.$decimal;
131
+		if(strlen($decimal) > 0)
132
+			$result=$integer.$decimal;
133 133
 		else
134
-			$result = $integer;
134
+			$result=$integer;
135 135
 
136 136
 		//get the suffix
137 137
 		if($number >= 0)
138
-			$suffix = $this->formatInfo->PositivePattern;
138
+			$suffix=$this->formatInfo->PositivePattern;
139 139
 		else if($number < 0)
140
-			$suffix = $this->formatInfo->NegativePattern;
140
+			$suffix=$this->formatInfo->NegativePattern;
141 141
 		else
142
-			$suffix = array("","");
142
+			$suffix=array("", "");
143 143
 
144 144
 		//append and prepend suffix
145
-		$result = $suffix[0].$result.$suffix[1];
145
+		$result=$suffix[0].$result.$suffix[1];
146 146
 
147 147
 		//replace currency sign
148
-		$symbol = @$this->formatInfo->getCurrencySymbol($currency);
149
-		if($symbol === null) {
150
-			$symbol = $currency;
148
+		$symbol=@$this->formatInfo->getCurrencySymbol($currency);
149
+		if($symbol===null) {
150
+			$symbol=$currency;
151 151
 		}
152 152
 
153
-		$result = str_replace('¤',$symbol, $result);
153
+		$result=str_replace('¤', $symbol, $result);
154 154
 
155 155
 		setlocale(LC_NUMERIC, $oldLocale);
156 156
 
@@ -164,68 +164,68 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	protected function formatInteger($string)
166 166
 	{
167
-		$string = (string)$string;
167
+		$string=(string) $string;
168 168
 
169
-		$decimalDigits = $this->formatInfo->DecimalDigits;
169
+		$decimalDigits=$this->formatInfo->DecimalDigits;
170 170
 		//if not decimal digits, assume 0 decimal points.
171 171
 		if(is_int($decimalDigits) && $decimalDigits > 0)
172
-			$string = (string)round(floatval($string),$decimalDigits);
173
-		$dp = strpos($string, '.');
172
+			$string=(string) round(floatval($string), $decimalDigits);
173
+		$dp=strpos($string, '.');
174 174
 		if(is_int($dp))
175
-			$string = substr($string, 0, $dp);
176
-		$integer = '';
175
+			$string=substr($string, 0, $dp);
176
+		$integer='';
177 177
 
178
-		$digitSize = $this->formatInfo->getDigitSize();
178
+		$digitSize=$this->formatInfo->getDigitSize();
179 179
 
180
-		$string = str_pad($string, $digitSize, '0',STR_PAD_LEFT);
180
+		$string=str_pad($string, $digitSize, '0', STR_PAD_LEFT);
181 181
 
182
-		$len = strlen($string);
182
+		$len=strlen($string);
183 183
 
184
-		$groupSeparator = $this->formatInfo->GroupSeparator;
185
-		$groupSize = $this->formatInfo->GroupSizes;
184
+		$groupSeparator=$this->formatInfo->GroupSeparator;
185
+		$groupSize=$this->formatInfo->GroupSizes;
186 186
 
187 187
 
188
-		$firstGroup = true;
189
-		$multiGroup = is_int($groupSize[1]);
190
-		$count = 0;
188
+		$firstGroup=true;
189
+		$multiGroup=is_int($groupSize[1]);
190
+		$count=0;
191 191
 
192 192
 		if(is_int($groupSize[0]))
193 193
 		{
194 194
 			//now for the integer groupings
195
-			for($i=0; $i<$len; $i++)
195
+			for($i=0; $i < $len; $i++)
196 196
 			{
197
-				$char = $string{$len-$i-1};
197
+				$char=$string{$len - $i - 1};
198 198
 
199
-				if($multiGroup && $count == 0)
199
+				if($multiGroup && $count==0)
200 200
 				{
201
-					if($i != 0 && $i%$groupSize[0] == 0)
201
+					if($i!=0 && $i % $groupSize[0]==0)
202 202
 					{
203
-						$integer = $groupSeparator . $integer;
203
+						$integer=$groupSeparator.$integer;
204 204
 						$count++;
205 205
 					}
206 206
 				}
207 207
 				else if($multiGroup && $count >= 1)
208 208
 				{
209
-					if($i != 0 && ($i-$groupSize[0])%$groupSize[1] == 0)
209
+					if($i!=0 && ($i - $groupSize[0]) % $groupSize[1]==0)
210 210
 					{
211
-						$integer = $groupSeparator . $integer;
211
+						$integer=$groupSeparator.$integer;
212 212
 						$count++;
213 213
 					}
214 214
 				}
215 215
 				else
216 216
 				{
217
-					if($i != 0 && $i%$groupSize[0] == 0)
217
+					if($i!=0 && $i % $groupSize[0]==0)
218 218
 					{
219
-						$integer = $groupSeparator . $integer;
219
+						$integer=$groupSeparator.$integer;
220 220
 						$count++;
221 221
 					}
222 222
 				}
223 223
 
224
-				$integer = $char . $integer;
224
+				$integer=$char.$integer;
225 225
 			}
226 226
 		}
227 227
 		else
228
-			$integer = $string;
228
+			$integer=$string;
229 229
 
230 230
 		return $integer;
231 231
 	}
@@ -237,32 +237,32 @@  discard block
 block discarded – undo
237 237
 	 */
238 238
 	protected function formatDecimal($string)
239 239
 	{
240
-		$dp = strpos($string, '.');
241
-		$decimal = '';
240
+		$dp=strpos($string, '.');
241
+		$decimal='';
242 242
 
243
-		$decimalDigits = $this->formatInfo->DecimalDigits;
244
-		$decimalSeparator = $this->formatInfo->DecimalSeparator;
243
+		$decimalDigits=$this->formatInfo->DecimalDigits;
244
+		$decimalSeparator=$this->formatInfo->DecimalSeparator;
245 245
 
246 246
 		//do the correct rounding here
247 247
 		//$string = round(floatval($string), $decimalDigits);
248 248
 		if(is_int($dp))
249 249
 		{
250
-			if($decimalDigits == -1)
250
+			if($decimalDigits==-1)
251 251
 			{
252
-				$decimal = substr($string, $dp+1);
252
+				$decimal=substr($string, $dp + 1);
253 253
 			}
254 254
 			else if(is_int($decimalDigits))
255 255
 			{
256
-				$float = round((float)$string, $decimalDigits);
257
-				if(strpos((string)$float, '.') === false)
256
+				$float=round((float) $string, $decimalDigits);
257
+				if(strpos((string) $float, '.')===false)
258 258
 				{
259
-					$decimal = str_pad($decimal,$decimalDigits,'0');
259
+					$decimal=str_pad($decimal, $decimalDigits, '0');
260 260
 				}
261 261
 				else
262 262
 				{
263
-					$decimal = substr($float, strpos($float,'.')+1);
264
-					if(strlen($decimal)<$decimalDigits)
265
-						$decimal = str_pad($decimal,$decimalDigits,'0');
263
+					$decimal=substr($float, strpos($float, '.') + 1);
264
+					if(strlen($decimal) < $decimalDigits)
265
+						$decimal=str_pad($decimal, $decimalDigits, '0');
266 266
 				}
267 267
 			}
268 268
 			else
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 
271 271
 			return $decimalSeparator.$decimal;
272 272
 		}
273
-		else if ($decimalDigits > 0)
274
-			return $decimalSeparator.str_pad($decimal,$decimalDigits,'0');
273
+		else if($decimalDigits > 0)
274
+			return $decimalSeparator.str_pad($decimal, $decimalDigits, '0');
275 275
 
276 276
 		return $decimal;
277 277
 	}
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource_XLIFF.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -290,7 +290,7 @@
 block discarded – undo
290 290
 
291 291
 		//find the body element
292 292
 		$xpath = new DomXPath($dom);
293
-    	$body = $xpath->query('//body')->item(0);
293
+		$body = $xpath->query('//body')->item(0);
294 294
 
295 295
 		$lastNodes = $xpath->query('//trans-unit[last()]');
296 296
 		if(($last=$lastNodes->item(0))!==null) {
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 	 * Message data filename extension.
44 44
 	 * @var string
45 45
 	 */
46
-	protected $dataExt = '.xml';
46
+	protected $dataExt='.xml';
47 47
 
48 48
 	/**
49 49
 	 * Separator between culture name and source.
50 50
 	 * @var string
51 51
 	 */
52
-	protected $dataSeparator = '.';
52
+	protected $dataSeparator='.';
53 53
 
54 54
 	/**
55 55
 	 * Constructor.
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	function __construct($source)
60 60
 	{
61
-		$this->source = (string)$source;
61
+		$this->source=(string) $source;
62 62
 	}
63 63
 
64 64
 	/**
@@ -69,20 +69,20 @@  discard block
 block discarded – undo
69 69
 	protected function &loadData($filename)
70 70
 	{
71 71
 		//load it.
72
-		if(false === ($XML = simplexml_load_file($filename))) {
72
+		if(false===($XML=simplexml_load_file($filename))) {
73 73
 			return false;
74 74
 		}
75 75
 
76
-		$translationUnit = $XML->xpath('//trans-unit');
76
+		$translationUnit=$XML->xpath('//trans-unit');
77 77
 
78
-		$translations = array();
78
+		$translations=array();
79 79
 
80 80
 		foreach($translationUnit as $unit)
81 81
 		{
82
-			$source = (string)$unit->source;
83
-			$translations[$source][] = (string)$unit->target;
84
-			$translations[$source][] = (string)$unit['id'];
85
-			$translations[$source][] = (string)$unit->note;
82
+			$source=(string) $unit->source;
83
+			$translations[$source][]=(string) $unit->target;
84
+			$translations[$source][]=(string) $unit['id'];
85
+			$translations[$source][]=(string) $unit->note;
86 86
 		}
87 87
 
88 88
 		return $translations;
@@ -127,28 +127,28 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	protected function getCatalogueList($catalogue)
129 129
 	{
130
-		$variants = explode('_',$this->culture);
131
-		$source = $catalogue.$this->dataExt;
132
-		$catalogues = array($source);
133
-		$variant = null;
130
+		$variants=explode('_', $this->culture);
131
+		$source=$catalogue.$this->dataExt;
132
+		$catalogues=array($source);
133
+		$variant=null;
134 134
 
135
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
135
+		for($i=0, $k=count($variants); $i < $k; ++$i)
136 136
 		{
137 137
 			if(isset($variants[$i]{0}))
138 138
 			{
139
-				$variant .= ($variant)?'_'.$variants[$i]:$variants[$i];
140
-				$catalogues[] = $catalogue.$this->dataSeparator.$variant.$this->dataExt;
139
+				$variant.=($variant) ? '_'.$variants[$i] : $variants[$i];
140
+				$catalogues[]=$catalogue.$this->dataSeparator.$variant.$this->dataExt;
141 141
 			}
142 142
 		}
143 143
 
144
-		$byDir = $this->getCatalogueByDir($catalogue);
145
-		$catalogues = array_merge($byDir,array_reverse($catalogues));
146
-		$files = array();
144
+		$byDir=$this->getCatalogueByDir($catalogue);
145
+		$catalogues=array_merge($byDir, array_reverse($catalogues));
146
+		$files=array();
147 147
 
148 148
 		foreach($catalogues as $file)
149 149
 		{
150
-			$files[] = $file;
151
-			$files[] = preg_replace('/\.xml$/', '.xlf', $file);
150
+			$files[]=$file;
151
+			$files[]=preg_replace('/\.xml$/', '.xlf', $file);
152 152
 		}
153 153
 
154 154
 		return $files;
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	private function getCatalogueByDir($catalogue)
165 165
 	{
166
-		$variants = explode('_',$this->culture);
167
-		$catalogues = array();
168
-		$variant = null;
166
+		$variants=explode('_', $this->culture);
167
+		$catalogues=array();
168
+		$variant=null;
169 169
 
170
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
170
+		for($i=0, $k=count($variants); $i < $k; ++$i)
171 171
 		{
172 172
 			if(isset($variants[$i]{0}))
173 173
 			{
174
-				$variant .= ($variant)?'_'.$variants[$i]:$variants[$i];
175
-				$catalogues[] = $variant.'/'.$catalogue.$this->dataExt;
174
+				$variant.=($variant) ? '_'.$variants[$i] : $variants[$i];
175
+				$catalogues[]=$variant.'/'.$catalogue.$this->dataExt;
176 176
 			}
177 177
 		}
178 178
 
@@ -196,38 +196,38 @@  discard block
 block discarded – undo
196 196
 	 * E.g. array('messages','en_AU')
197 197
 	 * @return array list of catalogues
198 198
 	 */
199
-	protected function getCatalogues($dir=null,$variant=null)
199
+	protected function getCatalogues($dir=null, $variant=null)
200 200
 	{
201
-		$dir = $dir?$dir:$this->source;
202
-		$files = scandir($dir);
203
-		$catalogue = array();
201
+		$dir=$dir ? $dir : $this->source;
202
+		$files=scandir($dir);
203
+		$catalogue=array();
204 204
 
205 205
 		foreach($files as $file)
206 206
 		{
207
-			if(is_dir($dir.'/'.$file) && preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/',$file)) {
208
-				$catalogue = array_merge(
207
+			if(is_dir($dir.'/'.$file) && preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/', $file)) {
208
+				$catalogue=array_merge(
209 209
 					$catalogue,
210 210
 					$this->getCatalogues($dir.'/'.$file, $file)
211 211
 				);
212 212
 			}
213 213
 
214
-			$pos = strpos($file,$this->dataExt);
215
-			if($pos >0 && substr($file, -1*strlen($this->dataExt)) == $this->dataExt)
214
+			$pos=strpos($file, $this->dataExt);
215
+			if($pos > 0 && substr($file, -1 * strlen($this->dataExt))==$this->dataExt)
216 216
 			{
217
-				$name = substr($file,0,$pos);
218
-				$dot = strrpos($name,$this->dataSeparator);
219
-				$culture = $variant;
220
-				$cat = $name;
217
+				$name=substr($file, 0, $pos);
218
+				$dot=strrpos($name, $this->dataSeparator);
219
+				$culture=$variant;
220
+				$cat=$name;
221 221
 
222 222
 				if(is_int($dot))
223 223
 				{
224
-					$culture = substr($name, $dot+1, strlen($name));
225
-					$cat = substr($name, 0, $dot);
224
+					$culture=substr($name, $dot + 1, strlen($name));
225
+					$cat=substr($name, 0, $dot);
226 226
 				}
227 227
 
228
-				$details[0] = $cat;
229
-				$details[1] = $culture;
230
-				$catalogue[] = $details;
228
+				$details[0]=$cat;
229
+				$details[1]=$culture;
230
+				$catalogue[]=$details;
231 231
 			}
232 232
 		}
233 233
 		sort($catalogue);
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	private function getVariants($catalogue='messages')
246 246
 	{
247
-		if($catalogue === null) {
248
-			$catalogue = 'messages';
247
+		if($catalogue===null) {
248
+			$catalogue='messages';
249 249
 		}
250 250
 
251 251
 		foreach($this->getCatalogueList($catalogue) as $variant)
252 252
 		{
253
-			$file = $this->getSource($variant);
253
+			$file=$this->getSource($variant);
254 254
 			if(is_file($file)) {
255 255
 				return array($variant, $file);
256 256
 			}
@@ -267,48 +267,48 @@  discard block
 block discarded – undo
267 267
 	 */
268 268
 	public function save($catalogue='messages')
269 269
 	{
270
-		$messages = $this->untranslated;
270
+		$messages=$this->untranslated;
271 271
 		if(count($messages) <= 0) {
272 272
 			return false;
273 273
 		}
274 274
 
275
-		$variants = $this->getVariants($catalogue);
275
+		$variants=$this->getVariants($catalogue);
276 276
 
277 277
 		if($variants) {
278
-			list($variant, $filename) = $variants;
278
+			list($variant, $filename)=$variants;
279 279
 		} else {
280
-			list($variant, $filename) = $this->createMessageTemplate($catalogue);
280
+			list($variant, $filename)=$this->createMessageTemplate($catalogue);
281 281
 		}
282 282
 
283
-		if(is_writable($filename) == false) {
283
+		if(is_writable($filename)==false) {
284 284
 			throw new TIOException("Unable to save to file {$filename}, file must be writable.");
285 285
 		}
286 286
 
287 287
 		//create a new dom, import the existing xml
288
-		$dom = new DOMDocument();
288
+		$dom=new DOMDocument();
289 289
 		$dom->load($filename);
290 290
 
291 291
 		//find the body element
292
-		$xpath = new DomXPath($dom);
293
-    	$body = $xpath->query('//body')->item(0);
292
+		$xpath=new DomXPath($dom);
293
+    	$body=$xpath->query('//body')->item(0);
294 294
 
295
-		$lastNodes = $xpath->query('//trans-unit[last()]');
295
+		$lastNodes=$xpath->query('//trans-unit[last()]');
296 296
 		if(($last=$lastNodes->item(0))!==null) {
297
-			$count = (int)$last->getAttribute('id');
297
+			$count=(int) $last->getAttribute('id');
298 298
 		} else {
299
-			$count = 0;
299
+			$count=0;
300 300
 		}
301 301
 
302 302
 		//for each message add it to the XML file using DOM
303 303
 		foreach($messages as $message)
304 304
 		{
305
-			$unit = $dom->createElement('trans-unit');
306
-			$unit->setAttribute('id',++$count);
305
+			$unit=$dom->createElement('trans-unit');
306
+			$unit->setAttribute('id', ++$count);
307 307
 
308
-			$source = $dom->createElement('source');
308
+			$source=$dom->createElement('source');
309 309
 			$source->appendChild($dom->createCDATASection($message));
310 310
 
311
-			$target = $dom->createElement('target');
311
+			$target=$dom->createElement('target');
312 312
 			$target->appendChild($dom->createCDATASection(''));
313 313
 
314 314
 			$unit->appendChild($dom->createTextNode("\n"));
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		}
324 324
 
325 325
 
326
-		$fileNode = $xpath->query('//file')->item(0);
326
+		$fileNode=$xpath->query('//file')->item(0);
327 327
 		$fileNode->setAttribute('date', @date('Y-m-d\TH:i:s\Z'));
328 328
 
329 329
 		//save it and clear the cache for this variant
@@ -345,68 +345,68 @@  discard block
 block discarded – undo
345 345
 	 */
346 346
 	public function update($text, $target, $comments, $catalogue='messages')
347 347
 	{
348
-		$variants = $this->getVariants($catalogue);
348
+		$variants=$this->getVariants($catalogue);
349 349
 
350 350
 		if($variants) {
351
-			list($variant, $filename) = $variants;
351
+			list($variant, $filename)=$variants;
352 352
 		} else {
353 353
 			return false;
354 354
 		}
355 355
 
356
-		if(is_writable($filename) == false) {
356
+		if(is_writable($filename)==false) {
357 357
 			throw new TIOException("Unable to update file {$filename}, file must be writable.");
358 358
 		}
359 359
 
360 360
 		//create a new dom, import the existing xml
361
-		$dom = DOMDocument::load($filename);
361
+		$dom=DOMDocument::load($filename);
362 362
 
363 363
 		//find the body element
364
-		$xpath = new DomXPath($dom);
365
-		$units = $xpath->query('//trans-unit');
364
+		$xpath=new DomXPath($dom);
365
+		$units=$xpath->query('//trans-unit');
366 366
 
367 367
 		//for each of the existin units
368 368
 		foreach($units as $unit)
369 369
 		{
370
-			$found = false;
371
-			$targetted = false;
372
-			$commented = false;
370
+			$found=false;
371
+			$targetted=false;
372
+			$commented=false;
373 373
 
374 374
 			//in each unit, need to find the source, target and comment nodes
375 375
 			//it will assume that the source is before the target.
376 376
 			foreach($unit->childNodes as $node)
377 377
 			{
378 378
 				//source node
379
-				if($node->nodeName == 'source' && $node->firstChild->wholeText == $text) {
380
-					$found = true;
379
+				if($node->nodeName=='source' && $node->firstChild->wholeText==$text) {
380
+					$found=true;
381 381
 				}
382 382
 
383 383
 				//found source, get the target and notes
384 384
 				if($found)
385 385
 				{
386 386
 					//set the new translated string
387
-					if($node->nodeName == 'target')
387
+					if($node->nodeName=='target')
388 388
 					{
389
-						$node->nodeValue = $target;
390
-						$targetted = true;
389
+						$node->nodeValue=$target;
390
+						$targetted=true;
391 391
 					}
392 392
 
393 393
 					//set the notes
394
-					if(!empty($comments) && $node->nodeName == 'note')
394
+					if(!empty($comments) && $node->nodeName=='note')
395 395
 					{
396
-						$node->nodeValue = $comments;
397
-						$commented = true;
396
+						$node->nodeValue=$comments;
397
+						$commented=true;
398 398
 					}
399 399
 				}
400 400
 			}
401 401
 
402 402
 			//append a target
403 403
 			if($found && !$targetted) {
404
-				$unit->appendChild($dom->createElement('target',$target));
404
+				$unit->appendChild($dom->createElement('target', $target));
405 405
 			}
406 406
 
407 407
 			//append a note
408 408
 			if($found && !$commented && !empty($comments)) {
409
-				$unit->appendChild($dom->createElement('note',$comments));
409
+				$unit->appendChild($dom->createElement('note', $comments));
410 410
 			}
411 411
 
412 412
 			//finished searching
@@ -415,10 +415,10 @@  discard block
 block discarded – undo
415 415
 			}
416 416
 		}
417 417
 
418
-		$fileNode = $xpath->query('//file')->item(0);
418
+		$fileNode=$xpath->query('//file')->item(0);
419 419
 		$fileNode->setAttribute('date', @date('Y-m-d\TH:i:s\Z'));
420 420
 
421
-		if($dom->save($filename) >0)
421
+		if($dom->save($filename) > 0)
422 422
 		{
423 423
 			if(!empty($this->cache)) {
424 424
 				$this->cache->clean($variant, $this->culture);
@@ -438,23 +438,23 @@  discard block
 block discarded – undo
438 438
 	 */
439 439
 	public function delete($message, $catalogue='messages')
440 440
 	{
441
-		$variants = $this->getVariants($catalogue);
441
+		$variants=$this->getVariants($catalogue);
442 442
 		if($variants) {
443
-			list($variant, $filename) = $variants;
443
+			list($variant, $filename)=$variants;
444 444
 		} else {
445 445
 			return false;
446 446
 		}
447 447
 
448
-		if(is_writable($filename) == false) {
448
+		if(is_writable($filename)==false) {
449 449
 			throw new TIOException("Unable to modify file {$filename}, file must be writable.");
450 450
 		}
451 451
 
452 452
 		//create a new dom, import the existing xml
453
-		$dom = DOMDocument::load($filename);
453
+		$dom=DOMDocument::load($filename);
454 454
 
455 455
 		//find the body element
456
-		$xpath = new DomXPath($dom);
457
-		$units = $xpath->query('//trans-unit');
456
+		$xpath=new DomXPath($dom);
457
+		$units=$xpath->query('//trans-unit');
458 458
 
459 459
 		//for each of the existin units
460 460
 		foreach($units as $unit)
@@ -464,14 +464,14 @@  discard block
 block discarded – undo
464 464
 			foreach($unit->childNodes as $node)
465 465
 			{
466 466
 				//source node
467
-				if($node->nodeName == 'source' && $node->firstChild->wholeText == $message)
467
+				if($node->nodeName=='source' && $node->firstChild->wholeText==$message)
468 468
 				{
469 469
 					//we found it, remove and save the xml file.
470 470
 					$unit->parentNode->removeChild($unit);
471
-					$fileNode = $xpath->query('//file')->item(0);
471
+					$fileNode=$xpath->query('//file')->item(0);
472 472
 					$fileNode->setAttribute('date', @date('Y-m-d\TH:i:s\Z'));
473 473
 
474
-					if(false !== $dom->save($filename)) {
474
+					if(false!==$dom->save($filename)) {
475 475
 						if(!empty($this->cache)) {
476 476
 							$this->cache->clean($variant, $this->culture);
477 477
 						}
@@ -488,18 +488,18 @@  discard block
 block discarded – undo
488 488
 
489 489
 	protected function createMessageTemplate($catalogue)
490 490
 	{
491
-		if($catalogue === null) {
492
-			$catalogue = 'messages';
491
+		if($catalogue===null) {
492
+			$catalogue='messages';
493 493
 		}
494 494
 		
495
-		$variants = $this->getCatalogueList($catalogue);
496
-		$variant = array_shift($variants);
497
-		$file = $this->getSource($variant);
498
-		$dir = dirname($file);
495
+		$variants=$this->getCatalogueList($catalogue);
496
+		$variant=array_shift($variants);
497
+		$file=$this->getSource($variant);
498
+		$dir=dirname($file);
499 499
 
500 500
 		if(!is_dir($dir)) {
501 501
 			@mkdir($dir);
502
-			@chmod($dir,PRADO_CHMOD);
502
+			@chmod($dir, PRADO_CHMOD);
503 503
 		}
504 504
 
505 505
 		if(!is_dir($dir)) {
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
 
515 515
 	protected function getTemplate($catalogue)
516 516
 	{
517
-		$date = @date('c');
518
-		$xml = <<<EOD
517
+		$date=@date('c');
518
+		$xml=<<<EOD
519 519
 <?xml version="1.0" encoding="UTF-8"?>
520 520
 <xliff version="1.0">
521 521
  <file source-language="EN" target-language="{$this->culture}" datatype="plaintext" original="$catalogue" date="$date" product-name="$catalogue">
Please login to merge, or discard this patch.
framework/I18N/core/CultureInfo.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -199,9 +199,9 @@
 block discarded – undo
199 199
 	}
200 200
 
201 201
 	/**
202
-	* Gets the CultureInfo that for this culture string
203
-	* @return CultureInfo invariant culture info is "en".
204
-	*/
202
+	 * Gets the CultureInfo that for this culture string
203
+	 * @return CultureInfo invariant culture info is "en".
204
+	 */
205 205
 	public static function getInstance($culture)
206 206
 	{
207 207
 		static $instances = array();
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * The ICU data array.
57 57
 	 * @var array
58 58
 	 */
59
-	private $data = array();
59
+	private $data=array();
60 60
 
61 61
 	/**
62 62
 	 * The current culture.
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
 	 * A list of CLDR resource bundles loaded
69 69
 	 * @var array
70 70
 	 */
71
-	private $resourceBundles = array();
71
+	private $resourceBundles=array();
72 72
 
73 73
 	/**
74 74
 	 * A list of resource bundles keys
75 75
 	 * @var array
76 76
 	 */
77
-	protected static $bundleNames = array(
77
+	protected static $bundleNames=array(
78 78
 		'Core' => null,
79 79
 		'Currencies' => 'ICUDATA-curr',
80 80
 		'Languages' => 'ICUDATA-lang',
@@ -98,28 +98,28 @@  discard block
 block discarded – undo
98 98
 	 * A list of properties that are accessable/writable.
99 99
 	 * @var array
100 100
 	 */
101
-	protected $properties = array();
101
+	protected $properties=array();
102 102
 
103 103
 	/**
104 104
 	 * Culture type, all.
105 105
 	 * @see getCultures()
106 106
 	 * @var int
107 107
 	 */
108
-	const ALL = 0;
108
+	const ALL=0;
109 109
 
110 110
 	/**
111 111
 	 * Culture type, neutral.
112 112
 	 * @see getCultures()
113 113
 	 * @var int
114 114
 	 */
115
-	const NEUTRAL = 1;
115
+	const NEUTRAL=1;
116 116
 
117 117
 	/**
118 118
 	 * Culture type, specific.
119 119
 	 * @see getCultures()
120 120
 	 * @var int
121 121
 	 */
122
-	const SPECIFIC = 2;
122
+	const SPECIFIC=2;
123 123
 
124 124
 	/**
125 125
 	 * Display the culture name.
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	function __get($name)
141 141
 	{
142
-		$getProperty = 'get'.$name;
142
+		$getProperty='get'.$name;
143 143
 		if(in_array($getProperty, $this->properties))
144 144
 			return $this->$getProperty();
145 145
 		else
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	function __set($name, $value)
154 154
 	{
155
-		$setProperty = 'set'.$name;
155
+		$setProperty='set'.$name;
156 156
 		if(in_array($setProperty, $this->properties))
157 157
 			$this->$setProperty($value);
158 158
 		else
@@ -170,10 +170,10 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	function __construct($culture='en')
172 172
 	{
173
-		$this->properties = get_class_methods($this);
173
+		$this->properties=get_class_methods($this);
174 174
 
175 175
 		if(empty($culture))
176
-			$culture = 'en';
176
+			$culture='en';
177 177
 
178 178
 		$this->setCulture($culture);
179 179
 
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
 	*/
188 188
 	public static function getInstance($culture)
189 189
 	{
190
-		static $instances = array();
190
+		static $instances=array();
191 191
 		if(!isset($instances[$culture]))
192
-			$instances[$culture] = new CultureInfo($culture);
192
+			$instances[$culture]=new CultureInfo($culture);
193 193
 		return $instances[$culture];
194 194
 	}
195 195
 
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 	{
214 214
 		if(!empty($culture))
215 215
 		{
216
-			if (!preg_match('/^[_\\w]+$/', $culture))
217
-				throw new Exception('Invalid culture supplied: ' . $culture);
216
+			if(!preg_match('/^[_\\w]+$/', $culture))
217
+				throw new Exception('Invalid culture supplied: '.$culture);
218 218
 		}
219 219
 
220
-		$this->culture = $culture;
220
+		$this->culture=$culture;
221 221
 	}
222 222
 
223 223
 	/**
@@ -226,20 +226,20 @@  discard block
 block discarded – undo
226 226
 	 */
227 227
 	protected function loadCultureData($cultureName)
228 228
 	{
229
-		$culture_parts = explode('_', $cultureName);
230
-		$current_part = $culture_parts[0];
229
+		$culture_parts=explode('_', $cultureName);
230
+		$current_part=$culture_parts[0];
231 231
 
232
-		$culturesToLoad = array($current_part);
233
-		for($i = 1, $k = count($culture_parts); $i < $k; ++$i)
232
+		$culturesToLoad=array($current_part);
233
+		for($i=1, $k=count($culture_parts); $i < $k; ++$i)
234 234
 		{
235
-			$current_part .= '_'.$culture_parts[$i];
236
-			$culturesToLoad[] = $current_part;
235
+			$current_part.='_'.$culture_parts[$i];
236
+			$culturesToLoad[]=$current_part;
237 237
 		}
238 238
 
239 239
 		foreach(self::$bundleNames as $key => $bundleName)
240 240
 		{
241 241
 			if(!array_key_exists($key, $this->data))
242
-				$this->data[$key] = array();
242
+				$this->data[$key]=array();
243 243
 		}
244 244
 		foreach($culturesToLoad as $culture)
245 245
 		{
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 			array_unshift($this->resourceBundles, $culture);
250 250
 			foreach(self::$bundleNames as $key => $bundleName)
251 251
 			{
252
-				$this->data[$key][$culture] = \ResourceBundle::create($culture, $bundleName, false);
252
+				$this->data[$key][$culture]=\ResourceBundle::create($culture, $bundleName, false);
253 253
 			}
254 254
 		}
255 255
 	}
@@ -268,19 +268,19 @@  discard block
 block discarded – undo
268 268
 	 * @param boolean merge the data from its parents.
269 269
 	 * @return mixed the specific ICU data.
270 270
 	 */
271
-	public function findInfo($path='/', $merge=false, $key = null)
271
+	public function findInfo($path='/', $merge=false, $key=null)
272 272
 	{
273
-		$result = array();
273
+		$result=array();
274 274
 
275
-		if($key === null)
275
+		if($key===null)
276 276
 		{
277 277
 			// try to guess the bundle from the path. Always defaults to "Core".
278
-			$key = 'Core';
278
+			$key='Core';
279 279
 			foreach(self::$bundleNames as $bundleName => $icuBundleName)
280 280
 			{
281
-				if(strpos($path, $bundleName) === 0)
281
+				if(strpos($path, $bundleName)===0)
282 282
 				{
283
-					$key = $bundleName;
283
+					$key=$bundleName;
284 284
 					break;
285 285
 				}
286 286
 			}
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
 			return $result;
291 291
 		foreach($this->resourceBundles as $culture)
292 292
 		{
293
-			$res = $this->data[$key][$culture];
294
-			if($res === null)
293
+			$res=$this->data[$key][$culture];
294
+			if($res===null)
295 295
 				continue;
296
-			$info = $this->searchResources($res, $path);
296
+			$info=$this->searchResources($res, $path);
297 297
 			if($info)
298 298
 			{
299 299
 				if($merge)
300
-					$result = array_merge($result, $info);
300
+					$result=array_merge($result, $info);
301 301
 				else
302 302
 					return $info;
303 303
 			}
@@ -316,14 +316,14 @@  discard block
 block discarded – undo
316 316
 	 */
317 317
 	private function searchResources($info, $path='/')
318 318
 	{
319
-		$index = explode('/',$path);
319
+		$index=explode('/', $path);
320 320
 
321
-		$resource = $info;
322
-		for($i = 0, $k = count($index); $i < $k; ++$i)
321
+		$resource=$info;
322
+		for($i=0, $k=count($index); $i < $k; ++$i)
323 323
 		{
324 324
 
325
-			$resource = $resource->get($index[$i], false);
326
-			if($resource === null)
325
+			$resource=$resource->get($index[$i], false);
326
+			if($resource===null)
327 327
 				return null;
328 328
 		}
329 329
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 */
348 348
 	public function getDateTimeFormat()
349 349
 	{
350
-		if($this->dateTimeFormat === null)
350
+		if($this->dateTimeFormat===null)
351 351
 		{
352 352
 			$this->setDateTimeFormat(new DateTimeFormatInfo($this));
353 353
 		}
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	 */
362 362
 	public function setDateTimeFormat($dateTimeFormat)
363 363
 	{
364
-		$this->dateTimeFormat = $dateTimeFormat;
364
+		$this->dateTimeFormat=$dateTimeFormat;
365 365
 	}
366 366
 
367 367
 	/**
@@ -381,10 +381,10 @@  discard block
 block discarded – undo
381 381
 	 */
382 382
 	public function getNativeName()
383 383
 	{
384
-		$lang = substr($this->culture,0,2);
385
-		$reg = substr($this->culture,3,2);
386
-		$language = $this->findInfo("Languages/{$lang}");
387
-		$region = $this->findInfo("Countries/{$reg}");
384
+		$lang=substr($this->culture, 0, 2);
385
+		$reg=substr($this->culture, 3, 2);
386
+		$language=$this->findInfo("Languages/{$lang}");
387
+		$region=$this->findInfo("Countries/{$reg}");
388 388
 		if($region)
389 389
 			return $language.' ('.$region.')';
390 390
 		else
@@ -399,15 +399,15 @@  discard block
 block discarded – undo
399 399
 	 */
400 400
 	public function getEnglishName()
401 401
 	{
402
-		$lang = substr($this->culture,0,2);
403
-		$reg = substr($this->culture,3,2);
404
-		$culture = $this->getInvariantCulture();
402
+		$lang=substr($this->culture, 0, 2);
403
+		$reg=substr($this->culture, 3, 2);
404
+		$culture=$this->getInvariantCulture();
405 405
 
406
-		$language = $culture->findInfo("Languages/{$lang}");
407
-		if(count($language) == 0)
406
+		$language=$culture->findInfo("Languages/{$lang}");
407
+		if(count($language)==0)
408 408
 			return $this->culture;
409 409
 
410
-		$region = $culture->findInfo("Countries/{$reg}");
410
+		$region=$culture->findInfo("Countries/{$reg}");
411 411
 		if($region)
412 412
 			return $language.' ('.$region.')';
413 413
 		else
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
 	static public function getInvariantCulture()
425 425
 	{
426 426
 		static $invariant;
427
-		if($invariant === null)
428
-			$invariant = new CultureInfo();
427
+		if($invariant===null)
428
+			$invariant=new CultureInfo();
429 429
 		return $invariant;
430 430
 	}
431 431
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	 */
438 438
 	public function getIsNeutralCulture()
439 439
 	{
440
-		return strlen($this->culture) == 2;
440
+		return strlen($this->culture)==2;
441 441
 	}
442 442
 
443 443
 	/**
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 	 */
448 448
 	public function getNumberFormat()
449 449
 	{
450
-		if($this->numberFormat === null)
450
+		if($this->numberFormat===null)
451 451
 		{
452 452
 			$this->setNumberFormat(new NumberFormatInfo($this));
453 453
 		}
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 	 */
461 461
 	public function setNumberFormat($numberFormat)
462 462
 	{
463
-		$this->numberFormat = $numberFormat;
463
+		$this->numberFormat=$numberFormat;
464 464
 	}
465 465
 
466 466
 	/**
@@ -479,10 +479,10 @@  discard block
 block discarded – undo
479 479
 	 */
480 480
 	public function getParent()
481 481
 	{
482
-		if(strlen($this->culture) == 2)
482
+		if(strlen($this->culture)==2)
483 483
 			return $this->getInvariantCulture();
484 484
 
485
-		$lang = substr($this->culture,0,2);
485
+		$lang=substr($this->culture, 0, 2);
486 486
 			return new CultureInfo($lang);
487 487
 	}
488 488
 
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 	 */
498 498
 	static public function getCultures($type=CultureInfo::ALL)
499 499
 	{
500
-		$all = \ResourceBundle::getLocales('');
500
+		$all=\ResourceBundle::getLocales('');
501 501
 
502 502
 		switch($type)
503 503
 		{
@@ -506,14 +506,14 @@  discard block
 block discarded – undo
506 506
 			case CultureInfo::NEUTRAL :
507 507
 				foreach($all as $key => $culture)
508 508
 				{
509
-					if(strlen($culture) != 2)
509
+					if(strlen($culture)!=2)
510 510
 						unset($all[$key]);
511 511
 				}
512 512
 				return $all;
513 513
 			case CultureInfo::SPECIFIC :
514 514
 				foreach($all as $key => $culture)
515 515
 				{
516
-					if(strlen($culture) == 2)
516
+					if(strlen($culture)==2)
517 517
 						unset($all[$key]);
518 518
 				}
519 519
 				return $all;
@@ -532,19 +532,19 @@  discard block
 block discarded – undo
532 532
 		if(is_scalar($obj)) {
533 533
 			return $obj;
534 534
 		} elseif($obj instanceof \ResourceBundle) {
535
-			$array = array();
535
+			$array=array();
536 536
 			foreach($obj as $k => $v)
537
-				$array[$k] = $v;
537
+				$array[$k]=$v;
538 538
 		} else {
539
-			$array = $obj;
539
+			$array=$obj;
540 540
 		}
541 541
 
542
-		for($i = 0, $k = count($array); $i<$k; ++$i)
542
+		for($i=0, $k=count($array); $i < $k; ++$i)
543 543
 		{
544
-			$key = key($array);
544
+			$key=key($array);
545 545
 			if(is_array($array[$key])
546
-				&& count($array[$key]) == 1)
547
-				$array[$key] = $array[$key][0];
546
+				&& count($array[$key])==1)
547
+				$array[$key]=$array[$key][0];
548 548
 			next($array);
549 549
 		}
550 550
 		return $array;
@@ -566,11 +566,11 @@  discard block
 block discarded – undo
566 566
 	public function getCurrencies()
567 567
 	{
568 568
 		static $arr;
569
-		if($arr === null)
569
+		if($arr===null)
570 570
 		{
571
-			$arr = $this->findInfo('Currencies', true, 'Currencies');
571
+			$arr=$this->findInfo('Currencies', true, 'Currencies');
572 572
 			foreach($arr as $k => $v)
573
-				$arr[$k] = $this->simplify($v);
573
+				$arr[$k]=$this->simplify($v);
574 574
 		}
575 575
 		return $arr;
576 576
 	}
@@ -600,17 +600,17 @@  discard block
 block discarded – undo
600 600
 	public function getTimeZones()
601 601
 	{
602 602
 		static $arr;
603
-		if($arr === null)
603
+		if($arr===null)
604 604
 		{
605
-			$validPrefixes = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Etc', 'Europe', 'Indian', 'Pacific');
606
-			$tmp = $this->findInfo('zoneStrings', true, 'zoneStrings');
605
+			$validPrefixes=array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Etc', 'Europe', 'Indian', 'Pacific');
606
+			$tmp=$this->findInfo('zoneStrings', true, 'zoneStrings');
607 607
 			foreach($tmp as $k => $v)
608 608
 			{
609 609
 				foreach($validPrefixes as $prefix)
610 610
 				{
611
-					if(strpos($k, $prefix) === 0)
611
+					if(strpos($k, $prefix)===0)
612 612
 					{
613
-						$arr[] = str_replace(':', '/', $k);
613
+						$arr[]=str_replace(':', '/', $k);
614 614
 						break;
615 615
 					}
616 616
 				}
Please login to merge, or discard this patch.
framework/I18N/core/Gettext/TGettext.php 2 patches
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -58,229 +58,229 @@
 block discarded – undo
58 58
  */
59 59
 class TGettext
60 60
 {
61
-    /**
62
-     * strings
63
-     *
64
-     * associative array with all [msgid => msgstr] entries
65
-     *
66
-     * @access  protected
67
-     * @var     array
68
-    */
69
-    protected $strings = array();
61
+	/**
62
+	 * strings
63
+	 *
64
+	 * associative array with all [msgid => msgstr] entries
65
+	 *
66
+	 * @access  protected
67
+	 * @var     array
68
+	 */
69
+	protected $strings = array();
70 70
 
71
-    /**
72
-     * meta
73
-     *
74
-     * associative array containing meta
75
-     * information like project name or content type
76
-     *
77
-     * @access  protected
78
-     * @var     array
79
-     */
80
-    protected $meta = array();
71
+	/**
72
+	 * meta
73
+	 *
74
+	 * associative array containing meta
75
+	 * information like project name or content type
76
+	 *
77
+	 * @access  protected
78
+	 * @var     array
79
+	 */
80
+	protected $meta = array();
81 81
 
82
-    /**
83
-     * file path
84
-     *
85
-     * @access  protected
86
-     * @var     string
87
-     */
88
-    protected $file = '';
82
+	/**
83
+	 * file path
84
+	 *
85
+	 * @access  protected
86
+	 * @var     string
87
+	 */
88
+	protected $file = '';
89 89
 
90
-    /**
91
-     * Factory
92
-     *
93
-     * @static
94
-     * @access  public
95
-     * @return  object  Returns File_Gettext_PO or File_Gettext_MO on success
96
-     *                  or PEAR_Error on failure.
97
-     * @param   string  $format MO or PO
98
-     * @param   string  $file   path to GNU gettext file
99
-     */
100
-    static function factory($format, $file = '')
101
-    {
102
-        $format = strToUpper($format);
103
-        $filename = dirname(__FILE__).'/'.$format.'.php';
104
-        if(is_file($filename) == false)
105
-        	throw new Exception ("Class file $file not found");
90
+	/**
91
+	 * Factory
92
+	 *
93
+	 * @static
94
+	 * @access  public
95
+	 * @return  object  Returns File_Gettext_PO or File_Gettext_MO on success
96
+	 *                  or PEAR_Error on failure.
97
+	 * @param   string  $format MO or PO
98
+	 * @param   string  $file   path to GNU gettext file
99
+	 */
100
+	static function factory($format, $file = '')
101
+	{
102
+		$format = strToUpper($format);
103
+		$filename = dirname(__FILE__).'/'.$format.'.php';
104
+		if(is_file($filename) == false)
105
+			throw new Exception ("Class file $file not found");
106 106
 
107
-        include_once $filename;
108
-        $class = 'TGettext_' . $format;
107
+		include_once $filename;
108
+		$class = 'TGettext_' . $format;
109 109
 
110
-        return new $class($file);
111
-    }
110
+		return new $class($file);
111
+	}
112 112
 
113
-    /**
114
-     * poFile2moFile
115
-     *
116
-     * That's a simple fake of the 'msgfmt' console command.  It reads the
117
-     * contents of a GNU PO file and saves them to a GNU MO file.
118
-     *
119
-     * @static
120
-     * @access  public
121
-     * @return  mixed   Returns true on success or PEAR_Error on failure.
122
-     * @param   string  $pofile path to GNU PO file
123
-     * @param   string  $mofile path to GNU MO file
124
-     */
125
-    static function poFile2moFile($pofile, $mofile)
126
-    {
127
-        if (!is_file($pofile)) {
128
-            throw new Exception("File $pofile doesn't exist.");
129
-        }
113
+	/**
114
+	 * poFile2moFile
115
+	 *
116
+	 * That's a simple fake of the 'msgfmt' console command.  It reads the
117
+	 * contents of a GNU PO file and saves them to a GNU MO file.
118
+	 *
119
+	 * @static
120
+	 * @access  public
121
+	 * @return  mixed   Returns true on success or PEAR_Error on failure.
122
+	 * @param   string  $pofile path to GNU PO file
123
+	 * @param   string  $mofile path to GNU MO file
124
+	 */
125
+	static function poFile2moFile($pofile, $mofile)
126
+	{
127
+		if (!is_file($pofile)) {
128
+			throw new Exception("File $pofile doesn't exist.");
129
+		}
130 130
 
131
-        include_once dirname(__FILE__).'/PO.php';
131
+		include_once dirname(__FILE__).'/PO.php';
132 132
 
133
-        $PO = new TGettext_PO($pofile);
134
-        if (true !== ($e = $PO->load())) {
135
-            return $e;
136
-        }
133
+		$PO = new TGettext_PO($pofile);
134
+		if (true !== ($e = $PO->load())) {
135
+			return $e;
136
+		}
137 137
 
138
-        $MO = $PO->toMO();
139
-        if (true !== ($e = $MO->save($mofile))) {
140
-            return $e;
141
-        }
142
-        unset($PO, $MO);
138
+		$MO = $PO->toMO();
139
+		if (true !== ($e = $MO->save($mofile))) {
140
+			return $e;
141
+		}
142
+		unset($PO, $MO);
143 143
 
144
-        return true;
145
-    }
144
+		return true;
145
+	}
146 146
 
147
-    /**
148
-     * prepare
149
-     *
150
-     * @static
151
-     * @access  protected
152
-     * @return  string
153
-     * @param   string  $string
154
-     * @param   bool    $reverse
155
-     */
156
-    static function prepare($string, $reverse = false)
157
-    {
158
-        if ($reverse) {
159
-            $smap = array('"', "\n", "\t", "\r");
160
-            $rmap = array('\"', '\\n"' . "\n" . '"', '\\t', '\\r');
161
-            return (string) str_replace($smap, $rmap, $string);
162
-        } else {
163
-        	$string = preg_replace('/"\s+"/', '', $string);
164
-            $smap = array('\\n', '\\r', '\\t', '\"');
165
-            $rmap = array("\n", "\r", "\t", '"');
166
-            return (string) str_replace($smap, $rmap, $string);
167
-        }
168
-    }
147
+	/**
148
+	 * prepare
149
+	 *
150
+	 * @static
151
+	 * @access  protected
152
+	 * @return  string
153
+	 * @param   string  $string
154
+	 * @param   bool    $reverse
155
+	 */
156
+	static function prepare($string, $reverse = false)
157
+	{
158
+		if ($reverse) {
159
+			$smap = array('"', "\n", "\t", "\r");
160
+			$rmap = array('\"', '\\n"' . "\n" . '"', '\\t', '\\r');
161
+			return (string) str_replace($smap, $rmap, $string);
162
+		} else {
163
+			$string = preg_replace('/"\s+"/', '', $string);
164
+			$smap = array('\\n', '\\r', '\\t', '\"');
165
+			$rmap = array("\n", "\r", "\t", '"');
166
+			return (string) str_replace($smap, $rmap, $string);
167
+		}
168
+	}
169 169
 
170
-    /**
171
-     * meta2array
172
-     *
173
-     * @static
174
-     * @access  public
175
-     * @return  array
176
-     * @param   string  $meta
177
-     */
178
-    static function meta2array($meta)
179
-    {
180
-        $array = array();
181
-        foreach (explode("\n", $meta) as $info) {
182
-            if ($info = trim($info)) {
183
-                list($key, $value) = explode(':', $info, 2);
184
-                $array[trim($key)] = trim($value);
185
-            }
186
-        }
187
-        return $array;
188
-    }
170
+	/**
171
+	 * meta2array
172
+	 *
173
+	 * @static
174
+	 * @access  public
175
+	 * @return  array
176
+	 * @param   string  $meta
177
+	 */
178
+	static function meta2array($meta)
179
+	{
180
+		$array = array();
181
+		foreach (explode("\n", $meta) as $info) {
182
+			if ($info = trim($info)) {
183
+				list($key, $value) = explode(':', $info, 2);
184
+				$array[trim($key)] = trim($value);
185
+			}
186
+		}
187
+		return $array;
188
+	}
189 189
 
190
-    /**
191
-     * toArray
192
-     *
193
-     * Returns meta info and strings as an array of a structure like that:
194
-     * <code>
195
-     *   array(
196
-     *       'meta' => array(
197
-     *           'Content-Type'      => 'text/plain; charset=iso-8859-1',
198
-     *           'Last-Translator'   => 'Michael Wallner <[email protected]>',
199
-     *           'PO-Revision-Date'  => '2004-07-21 17:03+0200',
200
-     *           'Language-Team'     => 'German <[email protected]>',
201
-     *       ),
202
-     *       'strings' => array(
203
-     *           'All rights reserved'   => 'Alle Rechte vorbehalten',
204
-     *           'Welcome'               => 'Willkommen',
205
-     *           // ...
206
-     *       )
207
-     *   )
208
-     * </code>
209
-     *
210
-     * @see     fromArray()
211
-     * @access  protected
212
-     * @return  array
213
-     */
214
-    function toArray()
215
-    {
216
-    	return array('meta' => $this->meta, 'strings' => $this->strings);
217
-    }
190
+	/**
191
+	 * toArray
192
+	 *
193
+	 * Returns meta info and strings as an array of a structure like that:
194
+	 * <code>
195
+	 *   array(
196
+	 *       'meta' => array(
197
+	 *           'Content-Type'      => 'text/plain; charset=iso-8859-1',
198
+	 *           'Last-Translator'   => 'Michael Wallner <[email protected]>',
199
+	 *           'PO-Revision-Date'  => '2004-07-21 17:03+0200',
200
+	 *           'Language-Team'     => 'German <[email protected]>',
201
+	 *       ),
202
+	 *       'strings' => array(
203
+	 *           'All rights reserved'   => 'Alle Rechte vorbehalten',
204
+	 *           'Welcome'               => 'Willkommen',
205
+	 *           // ...
206
+	 *       )
207
+	 *   )
208
+	 * </code>
209
+	 *
210
+	 * @see     fromArray()
211
+	 * @access  protected
212
+	 * @return  array
213
+	 */
214
+	function toArray()
215
+	{
216
+		return array('meta' => $this->meta, 'strings' => $this->strings);
217
+	}
218 218
 
219
-    /**
220
-     * fromArray
221
-     *
222
-     * Assigns meta info and strings from an array of a structure like that:
223
-     * <code>
224
-     *   array(
225
-     *       'meta' => array(
226
-     *           'Content-Type'      => 'text/plain; charset=iso-8859-1',
227
-     *           'Last-Translator'   => 'Michael Wallner <[email protected]>',
228
-     *           'PO-Revision-Date'  => date('Y-m-d H:iO'),
229
-     *           'Language-Team'     => 'German <[email protected]>',
230
-     *       ),
231
-     *       'strings' => array(
232
-     *           'All rights reserved'   => 'Alle Rechte vorbehalten',
233
-     *           'Welcome'               => 'Willkommen',
234
-     *           // ...
235
-     *       )
236
-     *   )
237
-     * </code>
238
-     *
239
-     * @see     toArray()
240
-     * @access  protected
241
-     * @return  bool
242
-     * @param   array       $array
243
-     */
244
-    function fromArray($array)
245
-    {
246
-    	if (!array_key_exists('strings', $array)) {
247
-    	    if (count($array) != 2) {
248
-                return false;
249
-    	    } else {
250
-    	        list($this->meta, $this->strings) = $array;
251
-            }
252
-    	} else {
253
-            $this->meta = @$array['meta'];
254
-            $this->strings = @$array['strings'];
255
-        }
256
-        return true;
257
-    }
219
+	/**
220
+	 * fromArray
221
+	 *
222
+	 * Assigns meta info and strings from an array of a structure like that:
223
+	 * <code>
224
+	 *   array(
225
+	 *       'meta' => array(
226
+	 *           'Content-Type'      => 'text/plain; charset=iso-8859-1',
227
+	 *           'Last-Translator'   => 'Michael Wallner <[email protected]>',
228
+	 *           'PO-Revision-Date'  => date('Y-m-d H:iO'),
229
+	 *           'Language-Team'     => 'German <[email protected]>',
230
+	 *       ),
231
+	 *       'strings' => array(
232
+	 *           'All rights reserved'   => 'Alle Rechte vorbehalten',
233
+	 *           'Welcome'               => 'Willkommen',
234
+	 *           // ...
235
+	 *       )
236
+	 *   )
237
+	 * </code>
238
+	 *
239
+	 * @see     toArray()
240
+	 * @access  protected
241
+	 * @return  bool
242
+	 * @param   array       $array
243
+	 */
244
+	function fromArray($array)
245
+	{
246
+		if (!array_key_exists('strings', $array)) {
247
+			if (count($array) != 2) {
248
+				return false;
249
+			} else {
250
+				list($this->meta, $this->strings) = $array;
251
+			}
252
+		} else {
253
+			$this->meta = @$array['meta'];
254
+			$this->strings = @$array['strings'];
255
+		}
256
+		return true;
257
+	}
258 258
 
259
-    /**
260
-     * toMO
261
-     *
262
-     * @access  protected
263
-     * @return  object  File_Gettext_MO
264
-     */
265
-    function toMO()
266
-    {
267
-        include_once dirname(__FILE__).'/MO.php';
268
-        $MO = new TGettext_MO;
269
-        $MO->fromArray($this->toArray());
270
-        return $MO;
271
-    }
259
+	/**
260
+	 * toMO
261
+	 *
262
+	 * @access  protected
263
+	 * @return  object  File_Gettext_MO
264
+	 */
265
+	function toMO()
266
+	{
267
+		include_once dirname(__FILE__).'/MO.php';
268
+		$MO = new TGettext_MO;
269
+		$MO->fromArray($this->toArray());
270
+		return $MO;
271
+	}
272 272
 
273
-    /**
274
-     * toPO
275
-     *
276
-     * @access  protected
277
-     * @return  object      File_Gettext_PO
278
-     */
279
-    function toPO()
280
-    {
281
-        include_once dirname(__FILE__).'/PO.php';
282
-        $PO = new TGettext_PO;
283
-        $PO->fromArray($this->toArray());
284
-        return $PO;
285
-    }
273
+	/**
274
+	 * toPO
275
+	 *
276
+	 * @access  protected
277
+	 * @return  object      File_Gettext_PO
278
+	 */
279
+	function toPO()
280
+	{
281
+		include_once dirname(__FILE__).'/PO.php';
282
+		$PO = new TGettext_PO;
283
+		$PO->fromArray($this->toArray());
284
+		return $PO;
285
+	}
286 286
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      * @access  protected
67 67
      * @var     array
68 68
     */
69
-    protected $strings = array();
69
+    protected $strings=array();
70 70
 
71 71
     /**
72 72
      * meta
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      * @access  protected
78 78
      * @var     array
79 79
      */
80
-    protected $meta = array();
80
+    protected $meta=array();
81 81
 
82 82
     /**
83 83
      * file path
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      * @access  protected
86 86
      * @var     string
87 87
      */
88
-    protected $file = '';
88
+    protected $file='';
89 89
 
90 90
     /**
91 91
      * Factory
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
      * @param   string  $format MO or PO
98 98
      * @param   string  $file   path to GNU gettext file
99 99
      */
100
-    static function factory($format, $file = '')
100
+    static function factory($format, $file='')
101 101
     {
102
-        $format = strToUpper($format);
103
-        $filename = dirname(__FILE__).'/'.$format.'.php';
104
-        if(is_file($filename) == false)
105
-        	throw new Exception ("Class file $file not found");
102
+        $format=strToUpper($format);
103
+        $filename=dirname(__FILE__).'/'.$format.'.php';
104
+        if(is_file($filename)==false)
105
+        	throw new Exception("Class file $file not found");
106 106
 
107 107
         include_once $filename;
108
-        $class = 'TGettext_' . $format;
108
+        $class='TGettext_'.$format;
109 109
 
110 110
         return new $class($file);
111 111
     }
@@ -124,19 +124,19 @@  discard block
 block discarded – undo
124 124
      */
125 125
     static function poFile2moFile($pofile, $mofile)
126 126
     {
127
-        if (!is_file($pofile)) {
127
+        if(!is_file($pofile)) {
128 128
             throw new Exception("File $pofile doesn't exist.");
129 129
         }
130 130
 
131 131
         include_once dirname(__FILE__).'/PO.php';
132 132
 
133
-        $PO = new TGettext_PO($pofile);
134
-        if (true !== ($e = $PO->load())) {
133
+        $PO=new TGettext_PO($pofile);
134
+        if(true!==($e=$PO->load())) {
135 135
             return $e;
136 136
         }
137 137
 
138
-        $MO = $PO->toMO();
139
-        if (true !== ($e = $MO->save($mofile))) {
138
+        $MO=$PO->toMO();
139
+        if(true!==($e=$MO->save($mofile))) {
140 140
             return $e;
141 141
         }
142 142
         unset($PO, $MO);
@@ -153,16 +153,16 @@  discard block
 block discarded – undo
153 153
      * @param   string  $string
154 154
      * @param   bool    $reverse
155 155
      */
156
-    static function prepare($string, $reverse = false)
156
+    static function prepare($string, $reverse=false)
157 157
     {
158
-        if ($reverse) {
159
-            $smap = array('"', "\n", "\t", "\r");
160
-            $rmap = array('\"', '\\n"' . "\n" . '"', '\\t', '\\r');
158
+        if($reverse) {
159
+            $smap=array('"', "\n", "\t", "\r");
160
+            $rmap=array('\"', '\\n"'."\n".'"', '\\t', '\\r');
161 161
             return (string) str_replace($smap, $rmap, $string);
162 162
         } else {
163
-        	$string = preg_replace('/"\s+"/', '', $string);
164
-            $smap = array('\\n', '\\r', '\\t', '\"');
165
-            $rmap = array("\n", "\r", "\t", '"');
163
+        	$string=preg_replace('/"\s+"/', '', $string);
164
+            $smap=array('\\n', '\\r', '\\t', '\"');
165
+            $rmap=array("\n", "\r", "\t", '"');
166 166
             return (string) str_replace($smap, $rmap, $string);
167 167
         }
168 168
     }
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
      */
178 178
     static function meta2array($meta)
179 179
     {
180
-        $array = array();
181
-        foreach (explode("\n", $meta) as $info) {
182
-            if ($info = trim($info)) {
183
-                list($key, $value) = explode(':', $info, 2);
184
-                $array[trim($key)] = trim($value);
180
+        $array=array();
181
+        foreach(explode("\n", $meta) as $info) {
182
+            if($info=trim($info)) {
183
+                list($key, $value)=explode(':', $info, 2);
184
+                $array[trim($key)]=trim($value);
185 185
             }
186 186
         }
187 187
         return $array;
@@ -243,15 +243,15 @@  discard block
 block discarded – undo
243 243
      */
244 244
     function fromArray($array)
245 245
     {
246
-    	if (!array_key_exists('strings', $array)) {
247
-    	    if (count($array) != 2) {
246
+    	if(!array_key_exists('strings', $array)) {
247
+    	    if(count($array)!=2) {
248 248
                 return false;
249 249
     	    } else {
250
-    	        list($this->meta, $this->strings) = $array;
250
+    	        list($this->meta, $this->strings)=$array;
251 251
             }
252 252
     	} else {
253
-            $this->meta = @$array['meta'];
254
-            $this->strings = @$array['strings'];
253
+            $this->meta=@$array['meta'];
254
+            $this->strings=@$array['strings'];
255 255
         }
256 256
         return true;
257 257
     }
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
     function toMO()
266 266
     {
267 267
         include_once dirname(__FILE__).'/MO.php';
268
-        $MO = new TGettext_MO;
268
+        $MO=new TGettext_MO;
269 269
         $MO->fromArray($this->toArray());
270 270
         return $MO;
271 271
     }
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
     function toPO()
280 280
     {
281 281
         include_once dirname(__FILE__).'/PO.php';
282
-        $PO = new TGettext_PO;
282
+        $PO=new TGettext_PO;
283 283
         $PO->fromArray($this->toArray());
284 284
         return $PO;
285 285
     }
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource_MySQL.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -92,43 +92,43 @@
 block discarded – undo
92 92
 		*/
93 93
 		$dsninfo = $this->dns;
94 94
 
95
-     	if (isset($dsninfo['protocol']) && $dsninfo['protocol'] == 'unix')
96
-            $dbhost = ':' . $dsninfo['socket'];
97
-        else
98
-        {
95
+	 	if (isset($dsninfo['protocol']) && $dsninfo['protocol'] == 'unix')
96
+			$dbhost = ':' . $dsninfo['socket'];
97
+		else
98
+		{
99 99
 			$dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost';
100
-            if (!empty($dsninfo['port']))
101
-                $dbhost .= ':' . $dsninfo['port'];
102
-        }
103
-        $user = $dsninfo['username'];
104
-        $pw = $dsninfo['password'];
105
-
106
-        $connect_function = 'mysql_connect';
107
-
108
-        if ($dbhost && $user && $pw)
109
-            $conn = @$connect_function($dbhost, $user, $pw);
110
-        elseif ($dbhost && $user)
111
-            $conn = @$connect_function($dbhost, $user);
112
-        elseif ($dbhost)
113
-            $conn = @$connect_function($dbhost);
114
-        else
115
-            $conn = false;
116
-
117
-        if (empty($conn))
118
-        {
119
-        	throw new Exception('Error in connecting to '.$dsninfo);
120
-        }
121
-
122
-        if ($dsninfo['database'])
123
-        {
124
-        	if (!@mysql_select_db($dsninfo['database'], $conn))
125
-        		throw new Exception('Error in connecting database, dns:'.
126
-        							$dsninfo);
127
-        }
128
-        else
129
-        	throw new Exception('Please provide a database for message'.
130
-        						' translation.');
131
-       return $conn;
100
+			if (!empty($dsninfo['port']))
101
+				$dbhost .= ':' . $dsninfo['port'];
102
+		}
103
+		$user = $dsninfo['username'];
104
+		$pw = $dsninfo['password'];
105
+
106
+		$connect_function = 'mysql_connect';
107
+
108
+		if ($dbhost && $user && $pw)
109
+			$conn = @$connect_function($dbhost, $user, $pw);
110
+		elseif ($dbhost && $user)
111
+			$conn = @$connect_function($dbhost, $user);
112
+		elseif ($dbhost)
113
+			$conn = @$connect_function($dbhost);
114
+		else
115
+			$conn = false;
116
+
117
+		if (empty($conn))
118
+		{
119
+			throw new Exception('Error in connecting to '.$dsninfo);
120
+		}
121
+
122
+		if ($dsninfo['database'])
123
+		{
124
+			if (!@mysql_select_db($dsninfo['database'], $conn))
125
+				throw new Exception('Error in connecting database, dns:'.
126
+									$dsninfo);
127
+		}
128
+		else
129
+			throw new Exception('Please provide a database for message'.
130
+								' translation.');
131
+	   return $conn;
132 132
 	}
133 133
 
134 134
 	/**
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	function __construct($source)
67 67
 	{
68
-		$this->source = (string)$source;
69
-		$this->dns = parseDSN($this->source);
70
-		$this->db = $this->connect();
68
+		$this->source=(string) $source;
69
+		$this->dns=parseDSN($this->source);
70
+		$this->db=$this->connect();
71 71
 	}
72 72
 
73 73
 	/**
@@ -90,38 +90,38 @@  discard block
 block discarded – undo
90 90
 		if($conn!==null)
91 91
 			return $conn;
92 92
 		*/
93
-		$dsninfo = $this->dns;
93
+		$dsninfo=$this->dns;
94 94
 
95
-     	if (isset($dsninfo['protocol']) && $dsninfo['protocol'] == 'unix')
96
-            $dbhost = ':' . $dsninfo['socket'];
95
+     	if(isset($dsninfo['protocol']) && $dsninfo['protocol']=='unix')
96
+            $dbhost=':'.$dsninfo['socket'];
97 97
         else
98 98
         {
99
-			$dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost';
100
-            if (!empty($dsninfo['port']))
101
-                $dbhost .= ':' . $dsninfo['port'];
99
+			$dbhost=$dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost';
100
+            if(!empty($dsninfo['port']))
101
+                $dbhost.=':'.$dsninfo['port'];
102 102
         }
103
-        $user = $dsninfo['username'];
104
-        $pw = $dsninfo['password'];
103
+        $user=$dsninfo['username'];
104
+        $pw=$dsninfo['password'];
105 105
 
106
-        $connect_function = 'mysql_connect';
106
+        $connect_function='mysql_connect';
107 107
 
108
-        if ($dbhost && $user && $pw)
109
-            $conn = @$connect_function($dbhost, $user, $pw);
110
-        elseif ($dbhost && $user)
111
-            $conn = @$connect_function($dbhost, $user);
112
-        elseif ($dbhost)
113
-            $conn = @$connect_function($dbhost);
108
+        if($dbhost && $user && $pw)
109
+            $conn=@$connect_function($dbhost, $user, $pw);
110
+        elseif($dbhost && $user)
111
+            $conn=@$connect_function($dbhost, $user);
112
+        elseif($dbhost)
113
+            $conn=@$connect_function($dbhost);
114 114
         else
115
-            $conn = false;
115
+            $conn=false;
116 116
 
117
-        if (empty($conn))
117
+        if(empty($conn))
118 118
         {
119 119
         	throw new Exception('Error in connecting to '.$dsninfo);
120 120
         }
121 121
 
122
-        if ($dsninfo['database'])
122
+        if($dsninfo['database'])
123 123
         {
124
-        	if (!@mysql_select_db($dsninfo['database'], $conn))
124
+        	if(!@mysql_select_db($dsninfo['database'], $conn))
125 125
         		throw new Exception('Error in connecting database, dns:'.
126 126
         							$dsninfo);
127 127
         }
@@ -148,25 +148,25 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	protected function &loadData($variant)
150 150
 	{
151
-		$variant = mysql_real_escape_string($variant);
151
+		$variant=mysql_real_escape_string($variant);
152 152
 
153
-		$statement =
153
+		$statement=
154 154
 			"SELECT t.id, t.source, t.target, t.comments
155 155
 				FROM trans_unit t, catalogue c
156 156
  				WHERE c.cat_id =  t.cat_id
157 157
 					AND c.name = '{$variant}'
158 158
 				ORDER BY id ASC";
159 159
 
160
-		$rs = mysql_query($statement,$this->db);
160
+		$rs=mysql_query($statement, $this->db);
161 161
 
162
-		$result = array();
162
+		$result=array();
163 163
 
164
-		while($row = mysql_fetch_array($rs,MYSQL_NUM))
164
+		while($row=mysql_fetch_array($rs, MYSQL_NUM))
165 165
 		{
166
-			$source = $row[1];
167
-			$result[$source][] = $row[2]; //target
168
-			$result[$source][] = $row[0]; //id
169
-			$result[$source][] = $row[3]; //comments
166
+			$source=$row[1];
167
+			$result[$source][]=$row[2]; //target
168
+			$result[$source][]=$row[0]; //id
169
+			$result[$source][]=$row[3]; //comments
170 170
 		}
171 171
 
172 172
 		return $result;
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	protected function getLastModified($source)
182 182
 	{
183
-		$source = mysql_real_escape_string($source);
183
+		$source=mysql_real_escape_string($source);
184 184
 
185
-		$rs = mysql_query(
185
+		$rs=mysql_query(
186 186
 			"SELECT date_modified FROM catalogue WHERE name = '{$source}'",
187 187
 			$this->db);
188 188
 
189
-		$result = $rs ? (int)mysql_result($rs,0) : 0;
189
+		$result=$rs ? (int) mysql_result($rs, 0) : 0;
190 190
 
191 191
 		return $result;
192 192
 	}
@@ -199,15 +199,15 @@  discard block
 block discarded – undo
199 199
 	 */
200 200
 	protected function isValidSource($variant)
201 201
 	{
202
-		$variant = mysql_real_escape_string ($variant);
202
+		$variant=mysql_real_escape_string($variant);
203 203
 
204
-		$rs = mysql_query(
204
+		$rs=mysql_query(
205 205
 			"SELECT COUNT(*) FROM catalogue WHERE name = '{$variant}'",
206 206
 			$this->db);
207 207
 
208
-		$row = mysql_fetch_array($rs,MYSQL_NUM);
208
+		$row=mysql_fetch_array($rs, MYSQL_NUM);
209 209
 
210
-		$result = $row && $row[0] == '1';
210
+		$result=$row && $row[0]=='1';
211 211
 
212 212
 		return $result;
213 213
 	}
@@ -219,18 +219,18 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	protected function getCatalogueList($catalogue)
221 221
 	{
222
-		$variants = explode('_',$this->culture);
222
+		$variants=explode('_', $this->culture);
223 223
 
224
-		$catalogues = array($catalogue);
224
+		$catalogues=array($catalogue);
225 225
 
226
-		$variant = null;
226
+		$variant=null;
227 227
 
228
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
228
+		for($i=0, $k=count($variants); $i < $k; ++$i)
229 229
 		{
230 230
 			if(isset($variants[$i]{0}))
231 231
 			{
232
-				$variant .= ($variant)?'_'.$variants[$i]:$variants[$i];
233
-				$catalogues[] = $catalogue.'.'.$variant;
232
+				$variant.=($variant) ? '_'.$variants[$i] : $variants[$i];
233
+				$catalogues[]=$catalogue.'.'.$variant;
234 234
 			}
235 235
 		}
236 236
 		return array_reverse($catalogues);
@@ -244,27 +244,27 @@  discard block
 block discarded – undo
244 244
 	private function getCatalogueDetails($catalogue='messages')
245 245
 	{
246 246
 		if(empty($catalogue))
247
-			$catalogue = 'messages';
247
+			$catalogue='messages';
248 248
 
249
-		$variant = $catalogue.'.'.$this->culture;
249
+		$variant=$catalogue.'.'.$this->culture;
250 250
 
251
-		$name = mysql_real_escape_string($this->getSource($variant));
251
+		$name=mysql_real_escape_string($this->getSource($variant));
252 252
 
253
-		$rs = mysql_query("SELECT cat_id
253
+		$rs=mysql_query("SELECT cat_id
254 254
 					FROM catalogue WHERE name = '{$name}'", $this->db);
255 255
 
256
-		if(mysql_num_rows($rs) != 1)
256
+		if(mysql_num_rows($rs)!=1)
257 257
 			return false;
258 258
 
259
-		$cat_id = (int)mysql_result($rs,0);
259
+		$cat_id=(int) mysql_result($rs, 0);
260 260
 
261 261
 		//first get the catalogue ID
262
-		$rs = mysql_query(
262
+		$rs=mysql_query(
263 263
 			"SELECT count(msg_id)
264 264
 				FROM trans_unit
265 265
 				WHERE cat_id = {$cat_id}", $this->db);
266 266
 
267
-		$count = (int)mysql_result($rs,0);
267
+		$count=(int) mysql_result($rs, 0);
268 268
 
269 269
 		return array($cat_id, $variant, $count);
270 270
 	}
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 	 */
276 276
 	private function updateCatalogueTime($cat_id, $variant)
277 277
 	{
278
-		$time = time();
278
+		$time=time();
279 279
 
280
-		$result = mysql_query("UPDATE catalogue
280
+		$result=mysql_query("UPDATE catalogue
281 281
 							SET date_modified = {$time}
282 282
 							WHERE cat_id = {$cat_id}", $this->db);
283 283
 
@@ -296,27 +296,27 @@  discard block
 block discarded – undo
296 296
 	 */
297 297
 	function save($catalogue='messages')
298 298
 	{
299
-		$messages = $this->untranslated;
299
+		$messages=$this->untranslated;
300 300
 
301 301
 		if(count($messages) <= 0) return false;
302 302
 
303
-		$details = $this->getCatalogueDetails($catalogue);
303
+		$details=$this->getCatalogueDetails($catalogue);
304 304
 
305 305
 		if($details)
306
-			list($cat_id, $variant, $count) = $details;
306
+			list($cat_id, $variant, $count)=$details;
307 307
 		else
308 308
 			return false;
309 309
 
310 310
 		if($cat_id <= 0) return false;
311
-		$inserted = 0;
311
+		$inserted=0;
312 312
 
313
-		$time = time();
313
+		$time=time();
314 314
 
315 315
 		foreach($messages as $message)
316 316
 		{
317 317
 			$count++; $inserted++;
318
-			$message = mysql_real_escape_string($message);
319
-			$statement = "INSERT INTO trans_unit
318
+			$message=mysql_real_escape_string($message);
319
+			$statement="INSERT INTO trans_unit
320 320
 				(cat_id,id,source,date_added) VALUES
321 321
 				({$cat_id}, {$count},'{$message}',$time)";
322 322
 			mysql_query($statement, $this->db);
@@ -335,22 +335,22 @@  discard block
 block discarded – undo
335 335
 	 */
336 336
 	function delete($message, $catalogue='messages')
337 337
 	{
338
-		$details = $this->getCatalogueDetails($catalogue);
338
+		$details=$this->getCatalogueDetails($catalogue);
339 339
 		if($details)
340
-			list($cat_id, $variant, $count) = $details;
340
+			list($cat_id, $variant, $count)=$details;
341 341
 		else
342 342
 			return false;
343 343
 
344
-		$text = mysql_real_escape_string($message);
344
+		$text=mysql_real_escape_string($message);
345 345
 
346
-		$statement = "DELETE FROM trans_unit WHERE
346
+		$statement="DELETE FROM trans_unit WHERE
347 347
 						cat_id = {$cat_id} AND source = '{$message}'";
348
-		$deleted = false;
348
+		$deleted=false;
349 349
 
350 350
 		mysql_query($statement, $this->db);
351 351
 
352
-		if(mysql_affected_rows($this->db) == 1)
353
-			$deleted = $this->updateCatalogueTime($cat_id, $variant);
352
+		if(mysql_affected_rows($this->db)==1)
353
+			$deleted=$this->updateCatalogueTime($cat_id, $variant);
354 354
 
355 355
 		return $deleted;
356 356
 
@@ -366,30 +366,30 @@  discard block
 block discarded – undo
366 366
 	 */
367 367
 	function update($text, $target, $comments, $catalogue='messages')
368 368
 	{
369
-		$details = $this->getCatalogueDetails($catalogue);
369
+		$details=$this->getCatalogueDetails($catalogue);
370 370
 		if($details)
371
-			list($cat_id, $variant, $count) = $details;
371
+			list($cat_id, $variant, $count)=$details;
372 372
 		else
373 373
 			return false;
374 374
 
375
-		$comments = mysql_real_escape_string($comments);
376
-		$target = mysql_real_escape_string($target);
377
-		$text = mysql_real_escape_string($text);
375
+		$comments=mysql_real_escape_string($comments);
376
+		$target=mysql_real_escape_string($target);
377
+		$text=mysql_real_escape_string($text);
378 378
 
379
-		$time = time();
379
+		$time=time();
380 380
 
381
-		$statement = "UPDATE trans_unit SET
381
+		$statement="UPDATE trans_unit SET
382 382
 						target = '{$target}',
383 383
 						comments = '{$comments}',
384 384
 						date_modified = '{$time}'
385 385
 					WHERE cat_id = {$cat_id}
386 386
 						AND source = '{$text}'";
387 387
 
388
-		$updated = false;
388
+		$updated=false;
389 389
 
390 390
 		mysql_query($statement, $this->db);
391
-		if(mysql_affected_rows($this->db) == 1)
392
-			$updated = $this->updateCatalogueTime($cat_id, $variant);
391
+		if(mysql_affected_rows($this->db)==1)
392
+			$updated=$this->updateCatalogueTime($cat_id, $variant);
393 393
 
394 394
 		return $updated;
395 395
 	}
@@ -400,15 +400,15 @@  discard block
 block discarded – undo
400 400
 	 */
401 401
 	function catalogues()
402 402
 	{
403
-		$statement = 'SELECT name FROM catalogue ORDER BY name';
404
-		$rs = mysql_query($statement, $this->db);
405
-		$result = array();
406
-		while($row = mysql_fetch_array($rs,MYSQL_NUM))
403
+		$statement='SELECT name FROM catalogue ORDER BY name';
404
+		$rs=mysql_query($statement, $this->db);
405
+		$result=array();
406
+		while($row=mysql_fetch_array($rs, MYSQL_NUM))
407 407
 		{
408
-			$details = explode('.',$row[0]);
409
-			if(!isset($details[1])) $details[1] = null;
408
+			$details=explode('.', $row[0]);
409
+			if(!isset($details[1])) $details[1]=null;
410 410
 
411
-			$result[] = $details;
411
+			$result[]=$details;
412 412
 		}
413 413
 		return $result;
414 414
 	}
Please login to merge, or discard this patch.
framework/Util/TDataFieldAccessor.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
 
60 60
 				$tmp = $data;
61 61
 				foreach (explode(".", $field) as $f)
62
-				    $tmp = $tmp[$f];
62
+					$tmp = $tmp[$f];
63 63
 				return $tmp;
64 64
 			}
65 65
 			else if(is_object($data))
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @return mixed value at the specified field
49 49
 	 * @throws TInvalidDataValueException if field or data is invalid
50 50
 	 */
51
-	public static function getDataFieldValue($data,$field)
51
+	public static function getDataFieldValue($data, $field)
52 52
 	{
53 53
 		try
54 54
 		{
@@ -57,33 +57,33 @@  discard block
 block discarded – undo
57 57
 				if(isset($data[$field]))
58 58
 					return $data[$field];
59 59
 
60
-				$tmp = $data;
61
-				foreach (explode(".", $field) as $f)
62
-				    $tmp = $tmp[$f];
60
+				$tmp=$data;
61
+				foreach(explode(".", $field) as $f)
62
+				    $tmp=$tmp[$f];
63 63
 				return $tmp;
64 64
 			}
65 65
 			else if(is_object($data))
66 66
 			{
67
-				if(strpos($field,'.')===false)  // simple field
67
+				if(strpos($field, '.')===false)  // simple field
68 68
 				{
69 69
 					if(method_exists($data, 'get'.$field))
70
-						return call_user_func(array($data,'get'.$field));
70
+						return call_user_func(array($data, 'get'.$field));
71 71
 					else
72 72
 						return $data->{$field};
73 73
 				}
74 74
 				else // field in the format of xxx.yyy.zzz
75 75
 				{
76 76
 					$object=$data;
77
-					foreach(explode('.',$field) as $f)
78
-						$object = TDataFieldAccessor::getDataFieldValue($object, $f);
77
+					foreach(explode('.', $field) as $f)
78
+						$object=TDataFieldAccessor::getDataFieldValue($object, $f);
79 79
 					return $object;
80 80
 				}
81 81
 			}
82 82
 		}
83 83
 		catch(Exception $e)
84 84
 		{
85
-			throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid',$field,$e->getMessage());
85
+			throw new TInvalidDataValueException('datafieldaccessor_datafield_invalid', $field, $e->getMessage());
86 86
 		}
87
-		throw new TInvalidDataValueException('datafieldaccessor_data_invalid',$field);
87
+		throw new TInvalidDataValueException('datafieldaccessor_data_invalid', $field);
88 88
 	}
89 89
 }
Please login to merge, or discard this patch.
framework/Web/Services/TFeedService.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -139,9 +139,9 @@
 block discarded – undo
139 139
 			$feed->init($feedConfig);
140 140
 
141 141
 			$content=$feed->getFeedContent();
142
-		    //$this->getResponse()->setContentType('application/rss+xml');
143
-		    $this->getResponse()->setContentType($feed->getContentType());
144
-		    $this->getResponse()->write($content);
142
+			//$this->getResponse()->setContentType('application/rss+xml');
143
+			$this->getResponse()->setContentType($feed->getContentType());
144
+			$this->getResponse()->write($content);
145 145
 		}
146 146
 		else
147 147
 			throw new THttpException(404,'feedservice_feed_unknown',$id);
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			if(is_array($config))
78 78
 			{
79 79
 				foreach($config as $id => $feed)
80
-					$this->_feeds[$id] = $feed;
80
+					$this->_feeds[$id]=$feed;
81 81
 			}
82 82
 		}
83 83
 		else
@@ -110,20 +110,20 @@  discard block
 block discarded – undo
110 110
 		if(isset($this->_feeds[$id]))
111 111
 		{
112 112
 			$feedConfig=$this->_feeds[$id];
113
-			$properties = array();
114
-			$feed = null;
113
+			$properties=array();
114
+			$feed=null;
115 115
 			if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
116 116
 			{
117 117
 				if(isset($feedConfig['class']))
118 118
 				{
119 119
 					$feed=Prado::createComponent($feedConfig['class']);
120 120
 					if($service instanceof IFeedContentProvider)
121
-						$properties=isset($feedConfig['properties'])?$feedConfig['properties']:array();
121
+						$properties=isset($feedConfig['properties']) ? $feedConfig['properties'] : array();
122 122
 					else
123
-						throw new TConfigurationException('jsonservice_response_type_invalid',$id);
123
+						throw new TConfigurationException('jsonservice_response_type_invalid', $id);
124 124
 				}
125 125
 				else
126
-					throw new TConfigurationException('jsonservice_class_required',$id);
126
+					throw new TConfigurationException('jsonservice_class_required', $id);
127 127
 			}
128 128
 			else
129 129
 			{
@@ -132,15 +132,15 @@  discard block
 block discarded – undo
132 132
 				{
133 133
 					$feed=Prado::createComponent($class);
134 134
 					if(!($feed instanceof IFeedContentProvider))
135
-						throw new TConfigurationException('feedservice_feedtype_invalid',$id);
135
+						throw new TConfigurationException('feedservice_feedtype_invalid', $id);
136 136
 				}
137 137
 				else
138
-					throw new TConfigurationException('feedservice_class_required',$id);
138
+					throw new TConfigurationException('feedservice_class_required', $id);
139 139
 			}
140 140
 
141 141
 			// init feed properties
142 142
 			foreach($properties as $name=>$value)
143
-				$feed->setSubproperty($name,$value);
143
+				$feed->setSubproperty($name, $value);
144 144
 			$feed->init($feedConfig);
145 145
 
146 146
 			$content=$feed->getFeedContent();
@@ -149,6 +149,6 @@  discard block
 block discarded – undo
149 149
 		    $this->getResponse()->write($content);
150 150
 		}
151 151
 		else
152
-			throw new THttpException(404,'feedservice_feed_unknown',$id);
152
+			throw new THttpException(404, 'feedservice_feed_unknown', $id);
153 153
 	}
154 154
 }
155 155
\ No newline at end of file
Please login to merge, or discard this patch.