@@ -289,7 +289,7 @@ |
||
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)) |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | if(is_string($this->_userManager)) |
95 | 95 | { |
96 | 96 | if(($users=$application->getModule($this->_userManager))===null) |
97 | - throw new TConfigurationException('authmanager_usermanager_inexistent',$this->_userManager); |
|
97 | + throw new TConfigurationException('authmanager_usermanager_inexistent', $this->_userManager); |
|
98 | 98 | if(!($users instanceof IUserManager)) |
99 | - throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager); |
|
99 | + throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager); |
|
100 | 100 | $this->_userManager=$users; |
101 | 101 | } |
102 | - $application->attachEventHandler('OnAuthentication',array($this,'doAuthentication')); |
|
103 | - $application->attachEventHandler('OnEndRequest',array($this,'leave')); |
|
104 | - $application->attachEventHandler('OnAuthorization',array($this,'doAuthorization')); |
|
102 | + $application->attachEventHandler('OnAuthentication', array($this, 'doAuthentication')); |
|
103 | + $application->attachEventHandler('OnEndRequest', array($this, 'leave')); |
|
104 | + $application->attachEventHandler('OnAuthorization', array($this, 'doAuthorization')); |
|
105 | 105 | $this->_initialized=true; |
106 | 106 | } |
107 | 107 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | if($this->_initialized) |
123 | 123 | throw new TInvalidOperationException('authmanager_usermanager_unchangeable'); |
124 | 124 | if(!is_string($provider) && !($provider instanceof IUserManager)) |
125 | - throw new TConfigurationException('authmanager_usermanager_invalid',$this->_userManager); |
|
125 | + throw new TConfigurationException('authmanager_usermanager_invalid', $this->_userManager); |
|
126 | 126 | $this->_userManager=$provider; |
127 | 127 | } |
128 | 128 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param mixed sender of the Authentication event |
153 | 153 | * @param mixed event parameter |
154 | 154 | */ |
155 | - public function doAuthentication($sender,$param) |
|
155 | + public function doAuthentication($sender, $param) |
|
156 | 156 | { |
157 | 157 | $this->onAuthenticate($param); |
158 | 158 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param mixed sender of the Authorization event |
169 | 169 | * @param mixed event parameter |
170 | 170 | */ |
171 | - public function doAuthorization($sender,$param) |
|
171 | + public function doAuthorization($sender, $param) |
|
172 | 172 | { |
173 | 173 | if(!$this->_skipAuthorization) |
174 | 174 | { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @param mixed sender of the event |
184 | 184 | * @param mixed event parameter |
185 | 185 | */ |
186 | - public function leave($sender,$param) |
|
186 | + public function leave($sender, $param) |
|
187 | 187 | { |
188 | 188 | $application=$this->getApplication(); |
189 | 189 | if($application->getResponse()->getStatusCode()===401) |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function setReturnUrl($value) |
231 | 231 | { |
232 | - $this->getSession()->add($this->getReturnUrlVarName(),$value); |
|
232 | + $this->getSession()->add($this->getReturnUrlVarName(), $value); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -288,8 +288,8 @@ discard block |
||
288 | 288 | $user=$this->_userManager->getUser(null)->loadFromString($sessionInfo); |
289 | 289 | |
290 | 290 | // check for authentication expiration |
291 | - $isAuthExpired = $this->_authExpire>0 && !$user->getIsGuest() && |
|
292 | - ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime<time(); |
|
291 | + $isAuthExpired=$this->_authExpire > 0 && !$user->getIsGuest() && |
|
292 | + ($expiretime=$session->itemAt('AuthExpireTime')) && $expiretime < time(); |
|
293 | 293 | |
294 | 294 | // try authenticating through cookie if possible |
295 | 295 | if($this->getAllowAutoLogin() && ($user->getIsGuest() || $isAuthExpired)) |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | $user=$user2; |
303 | 303 | $this->updateSessionUser($user); |
304 | 304 | // user is restored from cookie, auth may not expire |
305 | - $isAuthExpired = false; |
|
305 | + $isAuthExpired=false; |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | |
318 | 318 | // event handler gets a chance to do further auth work |
319 | 319 | if($this->hasEventHandler('OnAuthenticate')) |
320 | - $this->raiseEvent('OnAuthenticate',$this,$application); |
|
320 | + $this->raiseEvent('OnAuthenticate', $this, $application); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | { |
330 | 330 | $this->logout(); |
331 | 331 | if($this->hasEventHandler('OnAuthExpire')) |
332 | - $this->raiseEvent('OnAuthExpire',$this,$param); |
|
332 | + $this->raiseEvent('OnAuthExpire', $this, $param); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | { |
344 | 344 | $application=$this->getApplication(); |
345 | 345 | if($this->hasEventHandler('OnAuthorize')) |
346 | - $this->raiseEvent('OnAuthorize',$this,$application); |
|
347 | - if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(),$application->getRequest()->getRequestType(),$application->getRequest()->getUserHostAddress())) |
|
346 | + $this->raiseEvent('OnAuthorize', $this, $application); |
|
347 | + if(!$application->getAuthorizationRules()->isUserAllowed($application->getUser(), $application->getRequest()->getRequestType(), $application->getRequest()->getUserHostAddress())) |
|
348 | 348 | { |
349 | 349 | $application->getResponse()->setStatusCode(401); |
350 | 350 | $application->completeRequest(); |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | if(($session=$this->getSession())===null) |
384 | 384 | throw new TConfigurationException('authmanager_session_required'); |
385 | 385 | else |
386 | - $session->add($this->getUserKey(),$user->saveToString()); |
|
386 | + $session->add($this->getUserKey(), $user->saveToString()); |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | |
@@ -411,19 +411,19 @@ discard block |
||
411 | 411 | * @param integer number of seconds that automatic login will remain effective. If 0, it means user logs out when session ends. This parameter is added since 3.1.1. |
412 | 412 | * @return boolean if login is successful |
413 | 413 | */ |
414 | - public function login($username,$password,$expire=0) |
|
414 | + public function login($username, $password, $expire=0) |
|
415 | 415 | { |
416 | - if($this->_userManager->validateUser($username,$password)) |
|
416 | + if($this->_userManager->validateUser($username, $password)) |
|
417 | 417 | { |
418 | 418 | if(($user=$this->_userManager->getUser($username))===null) |
419 | 419 | return false; |
420 | 420 | $this->updateSessionUser($user); |
421 | 421 | $this->getApplication()->setUser($user); |
422 | 422 | |
423 | - if($expire>0) |
|
423 | + if($expire > 0) |
|
424 | 424 | { |
425 | - $cookie=new THttpCookie($this->getUserKey(),''); |
|
426 | - $cookie->setExpire(time()+$expire); |
|
425 | + $cookie=new THttpCookie($this->getUserKey(), ''); |
|
426 | + $cookie->setExpire(time() + $expire); |
|
427 | 427 | $this->_userManager->saveUserToCookie($cookie); |
428 | 428 | $this->getResponse()->getCookies()->add($cookie); |
429 | 429 | } |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | $session->destroy(); |
447 | 447 | if($this->getAllowAutoLogin()) |
448 | 448 | { |
449 | - $cookie=new THttpCookie($this->getUserKey(),''); |
|
449 | + $cookie=new THttpCookie($this->getUserKey(), ''); |
|
450 | 450 | $this->getResponse()->getCookies()->add($cookie); |
451 | 451 | } |
452 | 452 | } |
@@ -79,7 +79,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -51,7 +51,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -149,46 +149,46 @@ discard block |
||
149 | 149 | * (invariant). |
150 | 150 | * @return DateTimeFormatInfo default DateTimeFormatInfo. |
151 | 151 | */ |
152 | - static function getInvariantInfo() |
|
153 | - { |
|
154 | - static $invariant; |
|
152 | + static function getInvariantInfo() |
|
153 | + { |
|
154 | + static $invariant; |
|
155 | 155 | if($invariant === null) |
156 | - { |
|
157 | - $culture = CultureInfo::getInvariantCulture(); |
|
158 | - $invariant = $culture->getDateTimeFormat(); |
|
159 | - } |
|
156 | + { |
|
157 | + $culture = CultureInfo::getInvariantCulture(); |
|
158 | + $invariant = $culture->getDateTimeFormat(); |
|
159 | + } |
|
160 | 160 | return $invariant; |
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Returns the DateTimeFormatInfo associated with the specified culture. |
|
165 | - * @param CultureInfo the culture that gets the DateTimeFormat property. |
|
166 | - * @return DateTimeFormatInfo DateTimeFormatInfo for the specified |
|
167 | - * culture. |
|
168 | - */ |
|
169 | - static function getInstance($culture=null) |
|
170 | - { |
|
171 | - |
|
172 | - if ($culture instanceof CultureInfo) |
|
173 | - return $culture->getDateTimeFormat(); |
|
174 | - else if(is_string($culture)) |
|
175 | - { |
|
176 | - $cultureInfo = CultureInfo::getInstance($culture); |
|
177 | - return $cultureInfo->getDateTimeFormat(); |
|
178 | - } |
|
179 | - else |
|
180 | - { |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Returns the DateTimeFormatInfo associated with the specified culture. |
|
165 | + * @param CultureInfo the culture that gets the DateTimeFormat property. |
|
166 | + * @return DateTimeFormatInfo DateTimeFormatInfo for the specified |
|
167 | + * culture. |
|
168 | + */ |
|
169 | + static function getInstance($culture=null) |
|
170 | + { |
|
171 | + |
|
172 | + if ($culture instanceof CultureInfo) |
|
173 | + return $culture->getDateTimeFormat(); |
|
174 | + else if(is_string($culture)) |
|
175 | + { |
|
176 | + $cultureInfo = CultureInfo::getInstance($culture); |
|
177 | + return $cultureInfo->getDateTimeFormat(); |
|
178 | + } |
|
179 | + else |
|
180 | + { |
|
181 | 181 | $cultureInfo = CultureInfo::getInvariantCulture(); |
182 | - return $cultureInfo->getDateTimeFormat(); |
|
183 | - } |
|
184 | - } |
|
182 | + return $cultureInfo->getDateTimeFormat(); |
|
183 | + } |
|
184 | + } |
|
185 | 185 | |
186 | 186 | /** |
187 | 187 | * A one-dimensional array of type String containing |
188 | 188 | * the culture-specific abbreviated names of the days |
189 | 189 | * of the week. The array for InvariantInfo contains |
190 | 190 | * "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", and "Sat". |
191 | - * @return array abbreviated day names |
|
191 | + * @return array abbreviated day names |
|
192 | 192 | */ |
193 | 193 | function getAbbreviatedDayNames() |
194 | 194 | { |
@@ -196,37 +196,37 @@ discard block |
||
196 | 196 | //return $this->data['dayNames/format/abbreviated']; |
197 | 197 | } |
198 | 198 | |
199 | - /** |
|
200 | - * Set the abbreviated day names. The value should be |
|
201 | - * an array of string starting with Sunday and ends in Saturady. |
|
202 | - * For example, |
|
203 | - * <code>array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");</code> |
|
204 | - * @param array abbreviated day names. |
|
205 | - */ |
|
206 | - function setAbbreviatedDayNames($value) |
|
207 | - { |
|
208 | - $this->data['dayNames']['format']['abbreviated'] = $value; |
|
209 | - } |
|
199 | + /** |
|
200 | + * Set the abbreviated day names. The value should be |
|
201 | + * an array of string starting with Sunday and ends in Saturady. |
|
202 | + * For example, |
|
203 | + * <code>array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");</code> |
|
204 | + * @param array abbreviated day names. |
|
205 | + */ |
|
206 | + function setAbbreviatedDayNames($value) |
|
207 | + { |
|
208 | + $this->data['dayNames']['format']['abbreviated'] = $value; |
|
209 | + } |
|
210 | 210 | |
211 | 211 | /** |
212 | 212 | * A one-dimensional array of type String containing |
213 | 213 | * the culture-specific narrow names of the days |
214 | 214 | * of the week. The array for InvariantInfo contains |
215 | 215 | * "S", "M", "T", "W", "T", "F", and "S". |
216 | - * @return array narrow day names |
|
216 | + * @return array narrow day names |
|
217 | 217 | */ |
218 | 218 | function getNarrowDayNames() |
219 | 219 | { |
220 | 220 | return $this->data['dayNames']['format']['narrow']; |
221 | 221 | } |
222 | 222 | |
223 | - /** |
|
224 | - * Set the narrow day names. The value should be |
|
225 | - * an array of string starting with Sunday and ends in Saturady. |
|
226 | - * For example, |
|
227 | - * <code>array("S", "M", "T", "W", "T", "F", "S");</code> |
|
228 | - * @param array narrow day names. |
|
229 | - */ |
|
223 | + /** |
|
224 | + * Set the narrow day names. The value should be |
|
225 | + * an array of string starting with Sunday and ends in Saturady. |
|
226 | + * For example, |
|
227 | + * <code>array("S", "M", "T", "W", "T", "F", "S");</code> |
|
228 | + * @param array narrow day names. |
|
229 | + */ |
|
230 | 230 | function setNarrowDayNames($value) |
231 | 231 | { |
232 | 232 | $this->data['dayNames']['format']['narrow'] = $value; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * culture-specific full names of the days of the week. |
238 | 238 | * The array for InvariantInfo contains "Sunday", "Monday", |
239 | 239 | * "Tuesday", "Wednesday", "Thursday", "Friday", and "Saturday". |
240 | - * @return array day names |
|
240 | + * @return array day names |
|
241 | 241 | */ |
242 | 242 | function getDayNames() |
243 | 243 | { |
@@ -245,14 +245,14 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | |
248 | - /** |
|
249 | - * Set the day names. The value should be |
|
250 | - * an array of string starting with Sunday and ends in Saturady. |
|
251 | - * For example, |
|
252 | - * <code>array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", |
|
253 | - * "Friday", "Saturday".);</code> |
|
254 | - * @param array day names. |
|
255 | - */ |
|
248 | + /** |
|
249 | + * Set the day names. The value should be |
|
250 | + * an array of string starting with Sunday and ends in Saturady. |
|
251 | + * For example, |
|
252 | + * <code>array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", |
|
253 | + * "Friday", "Saturday".);</code> |
|
254 | + * @param array day names. |
|
255 | + */ |
|
256 | 256 | function setDayNames($value) |
257 | 257 | { |
258 | 258 | $this->data['dayNames']['format']['wide'] = $value; |
@@ -270,17 +270,17 @@ discard block |
||
270 | 270 | return $this->data['monthNames']['format']['narrow']; |
271 | 271 | } |
272 | 272 | |
273 | - /** |
|
274 | - * Set the narrow month names. The value should be |
|
275 | - * an array of string starting with J and ends in D. |
|
276 | - * For example, |
|
277 | - * <code>array("J","F","M","A","M","J","J","A","S","O","N","D");</code> |
|
278 | - * @param array month names. |
|
279 | - */ |
|
280 | - function setNarrowMonthNames($value) |
|
281 | - { |
|
282 | - $this->data['monthNames']['format']['narrow'] = $value; |
|
283 | - } |
|
273 | + /** |
|
274 | + * Set the narrow month names. The value should be |
|
275 | + * an array of string starting with J and ends in D. |
|
276 | + * For example, |
|
277 | + * <code>array("J","F","M","A","M","J","J","A","S","O","N","D");</code> |
|
278 | + * @param array month names. |
|
279 | + */ |
|
280 | + function setNarrowMonthNames($value) |
|
281 | + { |
|
282 | + $this->data['monthNames']['format']['narrow'] = $value; |
|
283 | + } |
|
284 | 284 | |
285 | 285 | /** |
286 | 286 | * A one-dimensional array of type String containing the |
@@ -298,18 +298,18 @@ discard block |
||
298 | 298 | return $this->data['monthNames']['format']['wide']; |
299 | 299 | } |
300 | 300 | |
301 | - /** |
|
302 | - * Set the abbreviated month names. The value should be |
|
303 | - * an array of string starting with Jan and ends in Dec. |
|
304 | - * For example, |
|
305 | - * <code>array("Jan", "Feb", "Mar", "Apr", "May", "Jun", |
|
306 | - * "Jul", "Aug", "Sep","Oct","Nov","Dec");</code> |
|
307 | - * @param array month names. |
|
308 | - */ |
|
309 | - function setAbbreviatedMonthNames($value) |
|
310 | - { |
|
311 | - $this->data['monthNames']['format']['abbreviated'] = $value; |
|
312 | - } |
|
301 | + /** |
|
302 | + * Set the abbreviated month names. The value should be |
|
303 | + * an array of string starting with Jan and ends in Dec. |
|
304 | + * For example, |
|
305 | + * <code>array("Jan", "Feb", "Mar", "Apr", "May", "Jun", |
|
306 | + * "Jul", "Aug", "Sep","Oct","Nov","Dec");</code> |
|
307 | + * @param array month names. |
|
308 | + */ |
|
309 | + function setAbbreviatedMonthNames($value) |
|
310 | + { |
|
311 | + $this->data['monthNames']['format']['abbreviated'] = $value; |
|
312 | + } |
|
313 | 313 | |
314 | 314 | /** |
315 | 315 | * A one-dimensional array of type String containing the |
@@ -324,18 +324,18 @@ discard block |
||
324 | 324 | return $this->data['monthNames']['format']['wide']; |
325 | 325 | } |
326 | 326 | |
327 | - /** |
|
328 | - * Set the month names. The value should be |
|
329 | - * an array of string starting with Janurary and ends in December. |
|
330 | - * For example, |
|
331 | - * <code>array("January", "February", "March", "April", "May", "June", |
|
332 | - * "July", "August", "September","October","November","December");</code> |
|
333 | - * @param array month names. |
|
334 | - */ |
|
335 | - function setMonthNames($value) |
|
336 | - { |
|
337 | - $this->data['monthNames']['format']['wide'] = $value; |
|
338 | - } |
|
327 | + /** |
|
328 | + * Set the month names. The value should be |
|
329 | + * an array of string starting with Janurary and ends in December. |
|
330 | + * For example, |
|
331 | + * <code>array("January", "February", "March", "April", "May", "June", |
|
332 | + * "July", "August", "September","October","November","December");</code> |
|
333 | + * @param array month names. |
|
334 | + */ |
|
335 | + function setMonthNames($value) |
|
336 | + { |
|
337 | + $this->data['monthNames']['format']['wide'] = $value; |
|
338 | + } |
|
339 | 339 | |
340 | 340 | /** |
341 | 341 | * A string containing the name of the era. |
@@ -359,16 +359,16 @@ discard block |
||
359 | 359 | return $result[0]; |
360 | 360 | } |
361 | 361 | |
362 | - /** |
|
363 | - * Set the AM Designator. For example, 'AM'. |
|
364 | - * @param string AM designator. |
|
365 | - */ |
|
366 | - function setAMDesignator($value) |
|
367 | - { |
|
368 | - $markers = $this->getAMPMMarkers(); |
|
369 | - $markers[0] = $value; |
|
370 | - $this->setAMPMMarkers($markers); |
|
371 | - } |
|
362 | + /** |
|
363 | + * Set the AM Designator. For example, 'AM'. |
|
364 | + * @param string AM designator. |
|
365 | + */ |
|
366 | + function setAMDesignator($value) |
|
367 | + { |
|
368 | + $markers = $this->getAMPMMarkers(); |
|
369 | + $markers[0] = $value; |
|
370 | + $this->setAMPMMarkers($markers); |
|
371 | + } |
|
372 | 372 | |
373 | 373 | /** |
374 | 374 | * The string designator for hours that are "post meridiem" (after noon). |
@@ -381,41 +381,41 @@ discard block |
||
381 | 381 | return $result[1]; |
382 | 382 | } |
383 | 383 | |
384 | - /** |
|
385 | - * Set the PM Designator. For example, 'PM'. |
|
386 | - * @param string PM designator. |
|
387 | - */ |
|
388 | - function setPMDesignator($value) |
|
389 | - { |
|
390 | - $markers = $this->getAMPMMarkers(); |
|
391 | - $markers[1] = $value; |
|
392 | - $this->setAMPMMarkers($markers); |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * Get the AM and PM markers array. |
|
397 | - * Default InvariantInfo for AM and PM is <code>array('AM','PM');</code> |
|
398 | - * @return array AM and PM markers |
|
399 | - */ |
|
400 | - function getAMPMMarkers() |
|
384 | + /** |
|
385 | + * Set the PM Designator. For example, 'PM'. |
|
386 | + * @param string PM designator. |
|
387 | + */ |
|
388 | + function setPMDesignator($value) |
|
389 | + { |
|
390 | + $markers = $this->getAMPMMarkers(); |
|
391 | + $markers[1] = $value; |
|
392 | + $this->setAMPMMarkers($markers); |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * Get the AM and PM markers array. |
|
397 | + * Default InvariantInfo for AM and PM is <code>array('AM','PM');</code> |
|
398 | + * @return array AM and PM markers |
|
399 | + */ |
|
400 | + function getAMPMMarkers() |
|
401 | 401 | { |
402 | 402 | return $this->data['AmPmMarkers']; |
403 | 403 | } |
404 | 404 | |
405 | - /** |
|
406 | - * Set the AM and PM markers array. |
|
407 | - * For example <code>array('AM','PM');</code> |
|
408 | - * @param array AM and PM markers |
|
409 | - */ |
|
410 | - function setAMPMMarkers($value) |
|
411 | - { |
|
412 | - $this->data['AmPmMarkers'] = $value; |
|
413 | - } |
|
405 | + /** |
|
406 | + * Set the AM and PM markers array. |
|
407 | + * For example <code>array('AM','PM');</code> |
|
408 | + * @param array AM and PM markers |
|
409 | + */ |
|
410 | + function setAMPMMarkers($value) |
|
411 | + { |
|
412 | + $this->data['AmPmMarkers'] = $value; |
|
413 | + } |
|
414 | 414 | |
415 | 415 | /** |
416 | 416 | * Returns the full time pattern "HH:mm:ss z" (default). |
417 | - * This is culture sensitive. |
|
418 | - * @return string pattern "HH:mm:ss z". |
|
417 | + * This is culture sensitive. |
|
418 | + * @return string pattern "HH:mm:ss z". |
|
419 | 419 | */ |
420 | 420 | function getFullTimePattern() |
421 | 421 | { |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | |
425 | 425 | /** |
426 | 426 | * Returns the long time pattern "HH:mm:ss z" (default). |
427 | - * This is culture sensitive. |
|
428 | - * @return string pattern "HH:mm:ss z". |
|
427 | + * This is culture sensitive. |
|
428 | + * @return string pattern "HH:mm:ss z". |
|
429 | 429 | */ |
430 | 430 | function getLongTimePattern() |
431 | 431 | { |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | |
435 | 435 | /** |
436 | 436 | * Returns the medium time pattern "HH:mm:ss" (default). |
437 | - * This is culture sensitive. |
|
438 | - * @return string pattern "HH:mm:ss". |
|
437 | + * This is culture sensitive. |
|
438 | + * @return string pattern "HH:mm:ss". |
|
439 | 439 | */ |
440 | 440 | function getMediumTimePattern() |
441 | 441 | { |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | |
445 | 445 | /** |
446 | 446 | * Returns the short time pattern "HH:mm" (default). |
447 | - * This is culture sensitive. |
|
448 | - * @return string pattern "HH:mm". |
|
447 | + * This is culture sensitive. |
|
448 | + * @return string pattern "HH:mm". |
|
449 | 449 | */ |
450 | 450 | function getShortTimePattern() |
451 | 451 | { |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | |
455 | 455 | /** |
456 | 456 | * Returns the full date pattern "EEEE, yyyy MMMM dd" (default). |
457 | - * This is culture sensitive. |
|
458 | - * @return string pattern "EEEE, yyyy MMMM dd". |
|
457 | + * This is culture sensitive. |
|
458 | + * @return string pattern "EEEE, yyyy MMMM dd". |
|
459 | 459 | */ |
460 | 460 | function getFullDatePattern() |
461 | 461 | { |
@@ -464,8 +464,8 @@ discard block |
||
464 | 464 | |
465 | 465 | /** |
466 | 466 | * Returns the long date pattern "yyyy MMMM d" (default). |
467 | - * This is culture sensitive. |
|
468 | - * @return string pattern "yyyy MMMM d". |
|
467 | + * This is culture sensitive. |
|
468 | + * @return string pattern "yyyy MMMM d". |
|
469 | 469 | */ |
470 | 470 | function getLongDatePattern() |
471 | 471 | { |
@@ -474,8 +474,8 @@ discard block |
||
474 | 474 | |
475 | 475 | /** |
476 | 476 | * Returns the medium date pattern "yyyy MMMM d" (default). |
477 | - * This is culture sensitive. |
|
478 | - * @return string pattern "yyyy MMM d". |
|
477 | + * This is culture sensitive. |
|
478 | + * @return string pattern "yyyy MMM d". |
|
479 | 479 | */ |
480 | 480 | function getMediumDatePattern() |
481 | 481 | { |
@@ -484,28 +484,28 @@ discard block |
||
484 | 484 | |
485 | 485 | /** |
486 | 486 | * Returns the short date pattern "yy/MM/dd" (default). |
487 | - * This is culture sensitive. |
|
488 | - * @return string pattern "yy/MM/dd". |
|
487 | + * This is culture sensitive. |
|
488 | + * @return string pattern "yy/MM/dd". |
|
489 | 489 | */ |
490 | 490 | function getShortDatePattern() |
491 | 491 | { |
492 | 492 | return $this->data['DateTimePatterns'][7]; |
493 | 493 | } |
494 | 494 | |
495 | - /** |
|
496 | - * Returns the date time order pattern, "{1} {0}" (default). |
|
497 | - * This is culture sensitive. |
|
498 | - * @return string pattern "{1} {0}". |
|
499 | - */ |
|
500 | - function getDateTimeOrderPattern() |
|
501 | - { |
|
502 | - return $this->data['DateTimePatterns'][8]; |
|
503 | - } |
|
495 | + /** |
|
496 | + * Returns the date time order pattern, "{1} {0}" (default). |
|
497 | + * This is culture sensitive. |
|
498 | + * @return string pattern "{1} {0}". |
|
499 | + */ |
|
500 | + function getDateTimeOrderPattern() |
|
501 | + { |
|
502 | + return $this->data['DateTimePatterns'][8]; |
|
503 | + } |
|
504 | 504 | |
505 | 505 | /** |
506 | 506 | * Formats the date and time in a culture sensitive paterrn. |
507 | - * The default is "Date Time". |
|
508 | - * @return string date and time formated |
|
507 | + * The default is "Date Time". |
|
508 | + * @return string date and time formated |
|
509 | 509 | */ |
510 | 510 | function formatDateTime($date, $time) |
511 | 511 | { |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | * ICU date time formatting data. |
82 | 82 | * @var array |
83 | 83 | */ |
84 | - private $data = array(); |
|
84 | + private $data=array(); |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * A list of properties that are accessable/writable. |
88 | 88 | * @var array |
89 | 89 | */ |
90 | - protected $properties = array(); |
|
90 | + protected $properties=array(); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Allow functions that begins with 'set' to be called directly |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | function __get($name) |
98 | 98 | { |
99 | - $getProperty = 'get'.$name; |
|
99 | + $getProperty='get'.$name; |
|
100 | 100 | if(in_array($getProperty, $this->properties)) |
101 | 101 | return $this->$getProperty(); |
102 | 102 | else |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | function __set($name, $value) |
111 | 111 | { |
112 | - $setProperty = 'set'.$name; |
|
112 | + $setProperty='set'.$name; |
|
113 | 113 | if(in_array($setProperty, $this->properties)) |
114 | 114 | $this->$setProperty($value); |
115 | 115 | else |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | */ |
128 | 128 | function __construct($data=array()) |
129 | 129 | { |
130 | - $this->properties = get_class_methods($this); |
|
130 | + $this->properties=get_class_methods($this); |
|
131 | 131 | |
132 | 132 | if(empty($data)) |
133 | 133 | throw new Exception('Please provide the ICU data to initialize.'); |
134 | 134 | |
135 | - $this->data = $data; |
|
135 | + $this->data=$data; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | static function getInvariantInfo() |
153 | 153 | { |
154 | 154 | static $invariant; |
155 | - if($invariant === null) |
|
155 | + if($invariant===null) |
|
156 | 156 | { |
157 | - $culture = CultureInfo::getInvariantCulture(); |
|
158 | - $invariant = $culture->getDateTimeFormat(); |
|
157 | + $culture=CultureInfo::getInvariantCulture(); |
|
158 | + $invariant=$culture->getDateTimeFormat(); |
|
159 | 159 | } |
160 | 160 | return $invariant; |
161 | 161 | } |
@@ -169,16 +169,16 @@ discard block |
||
169 | 169 | static function getInstance($culture=null) |
170 | 170 | { |
171 | 171 | |
172 | - if ($culture instanceof CultureInfo) |
|
172 | + if($culture instanceof CultureInfo) |
|
173 | 173 | return $culture->getDateTimeFormat(); |
174 | 174 | else if(is_string($culture)) |
175 | 175 | { |
176 | - $cultureInfo = CultureInfo::getInstance($culture); |
|
176 | + $cultureInfo=CultureInfo::getInstance($culture); |
|
177 | 177 | return $cultureInfo->getDateTimeFormat(); |
178 | 178 | } |
179 | 179 | else |
180 | 180 | { |
181 | - $cultureInfo = CultureInfo::getInvariantCulture(); |
|
181 | + $cultureInfo=CultureInfo::getInvariantCulture(); |
|
182 | 182 | return $cultureInfo->getDateTimeFormat(); |
183 | 183 | } |
184 | 184 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | */ |
206 | 206 | function setAbbreviatedDayNames($value) |
207 | 207 | { |
208 | - $this->data['dayNames']['format']['abbreviated'] = $value; |
|
208 | + $this->data['dayNames']['format']['abbreviated']=$value; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | function setNarrowDayNames($value) |
231 | 231 | { |
232 | - $this->data['dayNames']['format']['narrow'] = $value; |
|
232 | + $this->data['dayNames']['format']['narrow']=$value; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | function setDayNames($value) |
257 | 257 | { |
258 | - $this->data['dayNames']['format']['wide'] = $value; |
|
258 | + $this->data['dayNames']['format']['wide']=$value; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | */ |
280 | 280 | function setNarrowMonthNames($value) |
281 | 281 | { |
282 | - $this->data['monthNames']['format']['narrow'] = $value; |
|
282 | + $this->data['monthNames']['format']['narrow']=$value; |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | function getAbbreviatedMonthNames() |
294 | 294 | { |
295 | - if (isset($this->data['monthNames']['format']['abbreviated'])) |
|
295 | + if(isset($this->data['monthNames']['format']['abbreviated'])) |
|
296 | 296 | return $this->data['monthNames']['format']['abbreviated']; |
297 | 297 | else |
298 | 298 | return $this->data['monthNames']['format']['wide']; |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | */ |
309 | 309 | function setAbbreviatedMonthNames($value) |
310 | 310 | { |
311 | - $this->data['monthNames']['format']['abbreviated'] = $value; |
|
311 | + $this->data['monthNames']['format']['abbreviated']=$value; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | */ |
335 | 335 | function setMonthNames($value) |
336 | 336 | { |
337 | - $this->data['monthNames']['format']['wide'] = $value; |
|
337 | + $this->data['monthNames']['format']['wide']=$value; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | */ |
345 | 345 | function getEra($era) |
346 | 346 | { |
347 | - $eraName = $this->data['eras']['abbreviated']; |
|
347 | + $eraName=$this->data['eras']['abbreviated']; |
|
348 | 348 | return $eraName[$era]; |
349 | 349 | } |
350 | 350 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | */ |
356 | 356 | function getAMDesignator() |
357 | 357 | { |
358 | - $result = $this->getAMPMMarkers(); |
|
358 | + $result=$this->getAMPMMarkers(); |
|
359 | 359 | return $result[0]; |
360 | 360 | } |
361 | 361 | |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | */ |
366 | 366 | function setAMDesignator($value) |
367 | 367 | { |
368 | - $markers = $this->getAMPMMarkers(); |
|
369 | - $markers[0] = $value; |
|
368 | + $markers=$this->getAMPMMarkers(); |
|
369 | + $markers[0]=$value; |
|
370 | 370 | $this->setAMPMMarkers($markers); |
371 | 371 | } |
372 | 372 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | */ |
378 | 378 | function getPMDesignator() |
379 | 379 | { |
380 | - $result = $this->getAMPMMarkers(); |
|
380 | + $result=$this->getAMPMMarkers(); |
|
381 | 381 | return $result[1]; |
382 | 382 | } |
383 | 383 | |
@@ -387,8 +387,8 @@ discard block |
||
387 | 387 | */ |
388 | 388 | function setPMDesignator($value) |
389 | 389 | { |
390 | - $markers = $this->getAMPMMarkers(); |
|
391 | - $markers[1] = $value; |
|
390 | + $markers=$this->getAMPMMarkers(); |
|
391 | + $markers[1]=$value; |
|
392 | 392 | $this->setAMPMMarkers($markers); |
393 | 393 | } |
394 | 394 | |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | */ |
410 | 410 | function setAMPMMarkers($value) |
411 | 411 | { |
412 | - $this->data['AmPmMarkers'] = $value; |
|
412 | + $this->data['AmPmMarkers']=$value; |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -509,8 +509,8 @@ discard block |
||
509 | 509 | */ |
510 | 510 | function formatDateTime($date, $time) |
511 | 511 | { |
512 | - $pattern = $this->getDateTimeOrderPattern(); |
|
513 | - return str_replace(array('{0}','{1}'), array($time, $date), $pattern); |
|
512 | + $pattern=$this->getDateTimeOrderPattern(); |
|
513 | + return str_replace(array('{0}', '{1}'), array($time, $date), $pattern); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | } |
@@ -76,7 +76,7 @@ discard block |
||
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 |
||
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 |
@@ -90,14 +90,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | /** |
123 | 123 | * Set the pattern for a specific number pattern. The validate patterns |
124 | 124 | * NumberFormatInfo::DECIMAL, NumberFormatInfo::CURRENCY, |
125 | - * NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC |
|
125 | + * NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC |
|
126 | 126 | * @param int pattern type. |
127 | 127 | */ |
128 | 128 | public function setPattern($type=NumberFormatInfo::DECIMAL) |
@@ -152,94 +152,94 @@ discard block |
||
152 | 152 | * (invariant). |
153 | 153 | * @return NumberFormatInfo default NumberFormatInfo. |
154 | 154 | */ |
155 | - public static function getInvariantInfo($type=NumberFormatInfo::DECIMAL) |
|
156 | - { |
|
157 | - static $invariant; |
|
155 | + public static function getInvariantInfo($type=NumberFormatInfo::DECIMAL) |
|
156 | + { |
|
157 | + static $invariant; |
|
158 | 158 | if($invariant === null) |
159 | - { |
|
160 | - $culture = CultureInfo::getInvariantCulture(); |
|
161 | - $invariant = $culture->NumberFormat; |
|
162 | - $invariant->setPattern($type); |
|
163 | - } |
|
159 | + { |
|
160 | + $culture = CultureInfo::getInvariantCulture(); |
|
161 | + $invariant = $culture->NumberFormat; |
|
162 | + $invariant->setPattern($type); |
|
163 | + } |
|
164 | 164 | return $invariant; |
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * Returns the NumberFormatInfo associated with the specified culture. |
|
169 | - * @param CultureInfo the culture that gets the NumberFormat property. |
|
170 | - * @param int the number formatting type, it should be |
|
171 | - * NumberFormatInfo::DECIMAL, NumberFormatInfo::CURRENCY, |
|
172 | - * NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC |
|
173 | - * @return NumberFormatInfo NumberFormatInfo for the specified |
|
174 | - * culture. |
|
175 | - * @see getCurrencyInstance(); |
|
176 | - * @see getPercentageInstance(); |
|
177 | - * @see getScientificInstance(); |
|
178 | - */ |
|
179 | - public static function getInstance($culture=null, |
|
180 | - $type=NumberFormatInfo::DECIMAL) |
|
181 | - { |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * Returns the NumberFormatInfo associated with the specified culture. |
|
169 | + * @param CultureInfo the culture that gets the NumberFormat property. |
|
170 | + * @param int the number formatting type, it should be |
|
171 | + * NumberFormatInfo::DECIMAL, NumberFormatInfo::CURRENCY, |
|
172 | + * NumberFormatInfo::PERCENTAGE, or NumberFormatInfo::SCIENTIFIC |
|
173 | + * @return NumberFormatInfo NumberFormatInfo for the specified |
|
174 | + * culture. |
|
175 | + * @see getCurrencyInstance(); |
|
176 | + * @see getPercentageInstance(); |
|
177 | + * @see getScientificInstance(); |
|
178 | + */ |
|
179 | + public static function getInstance($culture=null, |
|
180 | + $type=NumberFormatInfo::DECIMAL) |
|
181 | + { |
|
182 | 182 | if ($culture instanceof CultureInfo) |
183 | 183 | { |
184 | - $formatInfo = $culture->NumberFormat; |
|
185 | - $formatInfo->setPattern($type); |
|
186 | - return $formatInfo; |
|
184 | + $formatInfo = $culture->NumberFormat; |
|
185 | + $formatInfo->setPattern($type); |
|
186 | + return $formatInfo; |
|
187 | 187 | } |
188 | - else if(is_string($culture)) |
|
189 | - { |
|
190 | - $cultureInfo = new CultureInfo($culture); |
|
191 | - $formatInfo = $cultureInfo->NumberFormat; |
|
192 | - $formatInfo->setPattern($type); |
|
193 | - return $formatInfo; |
|
194 | - } |
|
195 | - else |
|
196 | - { |
|
197 | - $cultureInfo = new CultureInfo(); |
|
198 | - $formatInfo = $cultureInfo->NumberFormat; |
|
199 | - $formatInfo->setPattern($type); |
|
200 | - return $formatInfo; |
|
201 | - } |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Returns the currency format info associated with the specified culture. |
|
206 | - * @param CultureInfo the culture that gets the NumberFormat property. |
|
207 | - * @return NumberFormatInfo NumberFormatInfo for the specified |
|
208 | - * culture. |
|
209 | - */ |
|
210 | - public static function getCurrencyInstance($culture=null) |
|
211 | - { |
|
212 | - return self::getInstance($culture, self::CURRENCY); |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Returns the percentage format info associated with the specified culture. |
|
217 | - * @param CultureInfo the culture that gets the NumberFormat property. |
|
218 | - * @return NumberFormatInfo NumberFormatInfo for the specified |
|
219 | - * culture. |
|
220 | - */ |
|
221 | - public static function getPercentageInstance($culture=null) |
|
222 | - { |
|
223 | - return self::getInstance($culture, self::PERCENTAGE); |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * Returns the scientific format info associated with the specified culture. |
|
228 | - * @param CultureInfo the culture that gets the NumberFormat property. |
|
229 | - * @return NumberFormatInfo NumberFormatInfo for the specified |
|
230 | - * culture. |
|
231 | - */ |
|
232 | - public static function getScientificInstance($culture=null) |
|
233 | - { |
|
234 | - return self::getInstance($culture, self::SCIENTIFIC); |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * Parse the given pattern and return a list of known properties. |
|
239 | - * @param string a number pattern. |
|
240 | - * @return array list of pattern properties. |
|
241 | - */ |
|
242 | - protected function parsePattern($pattern) |
|
188 | + else if(is_string($culture)) |
|
189 | + { |
|
190 | + $cultureInfo = new CultureInfo($culture); |
|
191 | + $formatInfo = $cultureInfo->NumberFormat; |
|
192 | + $formatInfo->setPattern($type); |
|
193 | + return $formatInfo; |
|
194 | + } |
|
195 | + else |
|
196 | + { |
|
197 | + $cultureInfo = new CultureInfo(); |
|
198 | + $formatInfo = $cultureInfo->NumberFormat; |
|
199 | + $formatInfo->setPattern($type); |
|
200 | + return $formatInfo; |
|
201 | + } |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Returns the currency format info associated with the specified culture. |
|
206 | + * @param CultureInfo the culture that gets the NumberFormat property. |
|
207 | + * @return NumberFormatInfo NumberFormatInfo for the specified |
|
208 | + * culture. |
|
209 | + */ |
|
210 | + public static function getCurrencyInstance($culture=null) |
|
211 | + { |
|
212 | + return self::getInstance($culture, self::CURRENCY); |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Returns the percentage format info associated with the specified culture. |
|
217 | + * @param CultureInfo the culture that gets the NumberFormat property. |
|
218 | + * @return NumberFormatInfo NumberFormatInfo for the specified |
|
219 | + * culture. |
|
220 | + */ |
|
221 | + public static function getPercentageInstance($culture=null) |
|
222 | + { |
|
223 | + return self::getInstance($culture, self::PERCENTAGE); |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * Returns the scientific format info associated with the specified culture. |
|
228 | + * @param CultureInfo the culture that gets the NumberFormat property. |
|
229 | + * @return NumberFormatInfo NumberFormatInfo for the specified |
|
230 | + * culture. |
|
231 | + */ |
|
232 | + public static function getScientificInstance($culture=null) |
|
233 | + { |
|
234 | + return self::getInstance($culture, self::SCIENTIFIC); |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * Parse the given pattern and return a list of known properties. |
|
239 | + * @param string a number pattern. |
|
240 | + * @return array list of pattern properties. |
|
241 | + */ |
|
242 | + protected function parsePattern($pattern) |
|
243 | 243 | { |
244 | 244 | $pattern = explode(';',$pattern); |
245 | 245 | |
@@ -355,296 +355,296 @@ discard block |
||
355 | 355 | } |
356 | 356 | |
357 | 357 | |
358 | - /** |
|
359 | - * Indicates the number of decimal places. |
|
360 | - * @return int number of decimal places. |
|
361 | - */ |
|
362 | - function getDecimalDigits() |
|
363 | - { |
|
364 | - return $this->pattern['decimalPoints']; |
|
365 | - } |
|
366 | - |
|
367 | - /** |
|
368 | - * Set the number of decimal places. |
|
369 | - * @param int number of decimal places. |
|
370 | - */ |
|
371 | - function setDecimalDigits($value) |
|
372 | - { |
|
373 | - return $this->pattern['decimalPoints'] = $value; |
|
374 | - } |
|
375 | - |
|
376 | - function getDigitSize() |
|
377 | - { |
|
378 | - return $this->pattern['digitSize']; |
|
379 | - } |
|
380 | - |
|
381 | - function setDigitSize($value) |
|
382 | - { |
|
383 | - $this->pattern['digitSize'] = $value; |
|
384 | - } |
|
385 | - |
|
386 | - /** |
|
387 | - * Gets the string to use as the decimal separator. |
|
388 | - * @return string decimal separator. |
|
389 | - */ |
|
390 | - function getDecimalSeparator() |
|
391 | - { |
|
392 | - return $this->data['NumberElements'][0]; |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * Set the string to use as the decimal separator. |
|
397 | - * @param string the decimal point |
|
398 | - */ |
|
399 | - function setDecimalSeparator($value) |
|
400 | - { |
|
401 | - return $this->data['NumberElements'][0] = $value; |
|
402 | - } |
|
403 | - |
|
404 | - /** |
|
405 | - * Gets the string that separates groups of digits to the left |
|
406 | - * of the decimal in currency values. |
|
407 | - * @param parameter |
|
408 | - * @return string currency group separator. |
|
409 | - */ |
|
410 | - function getGroupSeparator() |
|
411 | - { |
|
412 | - return $this->data['NumberElements'][1]; |
|
413 | - } |
|
414 | - |
|
415 | - /** |
|
416 | - * Set the string to use as the group separator. |
|
417 | - * @param string the group separator. |
|
418 | - */ |
|
419 | - function setGroupSeparator($value) |
|
420 | - { |
|
421 | - return $this->data['NumberElements'][1] = $value; |
|
422 | - } |
|
423 | - |
|
424 | - /** |
|
425 | - * Gets the number of digits in each group to the left of the decimal |
|
426 | - * There can be two grouping sizes, this fucntion |
|
427 | - * returns <b>array(group1, group2)</b>, if there is only 1 grouping size, |
|
428 | - * group2 will be false. |
|
429 | - * @return array grouping size(s). |
|
430 | - */ |
|
431 | - function getGroupSizes() |
|
432 | - { |
|
433 | - $group1 = $this->pattern['groupSize1']; |
|
434 | - $group2 = $this->pattern['groupSize2']; |
|
435 | - |
|
436 | - return array($group1, $group2); |
|
437 | - } |
|
438 | - |
|
439 | - /** |
|
440 | - * Set the number of digits in each group to the left of the decimal. |
|
441 | - * There can be two grouping sizes, the value should |
|
442 | - * be an <b>array(group1, group2)</b>, if there is only 1 grouping size, |
|
443 | - * group2 should be false. |
|
444 | - * @param array grouping size(s). |
|
445 | - */ |
|
446 | - function setGroupSizes($groupSize) |
|
447 | - { |
|
358 | + /** |
|
359 | + * Indicates the number of decimal places. |
|
360 | + * @return int number of decimal places. |
|
361 | + */ |
|
362 | + function getDecimalDigits() |
|
363 | + { |
|
364 | + return $this->pattern['decimalPoints']; |
|
365 | + } |
|
366 | + |
|
367 | + /** |
|
368 | + * Set the number of decimal places. |
|
369 | + * @param int number of decimal places. |
|
370 | + */ |
|
371 | + function setDecimalDigits($value) |
|
372 | + { |
|
373 | + return $this->pattern['decimalPoints'] = $value; |
|
374 | + } |
|
375 | + |
|
376 | + function getDigitSize() |
|
377 | + { |
|
378 | + return $this->pattern['digitSize']; |
|
379 | + } |
|
380 | + |
|
381 | + function setDigitSize($value) |
|
382 | + { |
|
383 | + $this->pattern['digitSize'] = $value; |
|
384 | + } |
|
385 | + |
|
386 | + /** |
|
387 | + * Gets the string to use as the decimal separator. |
|
388 | + * @return string decimal separator. |
|
389 | + */ |
|
390 | + function getDecimalSeparator() |
|
391 | + { |
|
392 | + return $this->data['NumberElements'][0]; |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * Set the string to use as the decimal separator. |
|
397 | + * @param string the decimal point |
|
398 | + */ |
|
399 | + function setDecimalSeparator($value) |
|
400 | + { |
|
401 | + return $this->data['NumberElements'][0] = $value; |
|
402 | + } |
|
403 | + |
|
404 | + /** |
|
405 | + * Gets the string that separates groups of digits to the left |
|
406 | + * of the decimal in currency values. |
|
407 | + * @param parameter |
|
408 | + * @return string currency group separator. |
|
409 | + */ |
|
410 | + function getGroupSeparator() |
|
411 | + { |
|
412 | + return $this->data['NumberElements'][1]; |
|
413 | + } |
|
414 | + |
|
415 | + /** |
|
416 | + * Set the string to use as the group separator. |
|
417 | + * @param string the group separator. |
|
418 | + */ |
|
419 | + function setGroupSeparator($value) |
|
420 | + { |
|
421 | + return $this->data['NumberElements'][1] = $value; |
|
422 | + } |
|
423 | + |
|
424 | + /** |
|
425 | + * Gets the number of digits in each group to the left of the decimal |
|
426 | + * There can be two grouping sizes, this fucntion |
|
427 | + * returns <b>array(group1, group2)</b>, if there is only 1 grouping size, |
|
428 | + * group2 will be false. |
|
429 | + * @return array grouping size(s). |
|
430 | + */ |
|
431 | + function getGroupSizes() |
|
432 | + { |
|
433 | + $group1 = $this->pattern['groupSize1']; |
|
434 | + $group2 = $this->pattern['groupSize2']; |
|
435 | + |
|
436 | + return array($group1, $group2); |
|
437 | + } |
|
438 | + |
|
439 | + /** |
|
440 | + * Set the number of digits in each group to the left of the decimal. |
|
441 | + * There can be two grouping sizes, the value should |
|
442 | + * be an <b>array(group1, group2)</b>, if there is only 1 grouping size, |
|
443 | + * group2 should be false. |
|
444 | + * @param array grouping size(s). |
|
445 | + */ |
|
446 | + function setGroupSizes($groupSize) |
|
447 | + { |
|
448 | 448 | $this->pattern['groupSize1'] = $groupSize[0]; |
449 | 449 | $this->pattern['groupSize2'] = $groupSize[1]; |
450 | - } |
|
451 | - |
|
452 | - /** |
|
453 | - * Gets the format pattern for negative values. |
|
454 | - * The negative pattern is composed of a prefix, and postfix. |
|
455 | - * This function returns <b>array(prefix, postfix)</b>. |
|
456 | - * @return arary negative pattern. |
|
457 | - */ |
|
458 | - function getNegativePattern() |
|
459 | - { |
|
460 | - $prefix = $this->pattern['negPref']; |
|
461 | - $postfix = $this->pattern['negPost']; |
|
462 | - return array($prefix, $postfix); |
|
463 | - } |
|
464 | - |
|
465 | - /** |
|
466 | - * Set the format pattern for negative values. |
|
467 | - * The negative pattern is composed of a prefix, and postfix in the form |
|
468 | - * <b>array(prefix, postfix)</b>. |
|
469 | - * @param arary negative pattern. |
|
470 | - */ |
|
471 | - function setNegativePattern($pattern) |
|
472 | - { |
|
473 | - $this->pattern['negPref'] = $pattern[0]; |
|
474 | - $this->pattern['negPost'] = $pattern[1]; |
|
475 | - } |
|
476 | - |
|
477 | - /** |
|
478 | - * Gets the format pattern for positive values. |
|
479 | - * The positive pattern is composed of a prefix, and postfix. |
|
480 | - * This function returns <b>array(prefix, postfix)</b>. |
|
481 | - * @return arary positive pattern. |
|
482 | - */ |
|
483 | - function getPositivePattern() |
|
484 | - { |
|
485 | - $prefix = $this->pattern['posPref']; |
|
486 | - $postfix = $this->pattern['posPost']; |
|
487 | - return array($prefix, $postfix); |
|
488 | - } |
|
489 | - |
|
490 | - /** |
|
491 | - * Set the format pattern for positive values. |
|
492 | - * The positive pattern is composed of a prefix, and postfix in the form |
|
493 | - * <b>array(prefix, postfix)</b>. |
|
494 | - * @param arary positive pattern. |
|
495 | - */ |
|
496 | - function setPositivePattern($pattern) |
|
497 | - { |
|
498 | - $this->pattern['posPref'] = $pattern[0]; |
|
499 | - $this->pattern['posPost'] = $pattern[1]; |
|
500 | - } |
|
501 | - |
|
502 | - /** |
|
503 | - * Gets the string to use as the currency symbol. |
|
504 | - * @return string currency symbol. |
|
505 | - */ |
|
506 | - function getCurrencySymbol($currency='USD') |
|
507 | - { |
|
508 | - if(isset($this->pattern['symbol'])) |
|
450 | + } |
|
451 | + |
|
452 | + /** |
|
453 | + * Gets the format pattern for negative values. |
|
454 | + * The negative pattern is composed of a prefix, and postfix. |
|
455 | + * This function returns <b>array(prefix, postfix)</b>. |
|
456 | + * @return arary negative pattern. |
|
457 | + */ |
|
458 | + function getNegativePattern() |
|
459 | + { |
|
460 | + $prefix = $this->pattern['negPref']; |
|
461 | + $postfix = $this->pattern['negPost']; |
|
462 | + return array($prefix, $postfix); |
|
463 | + } |
|
464 | + |
|
465 | + /** |
|
466 | + * Set the format pattern for negative values. |
|
467 | + * The negative pattern is composed of a prefix, and postfix in the form |
|
468 | + * <b>array(prefix, postfix)</b>. |
|
469 | + * @param arary negative pattern. |
|
470 | + */ |
|
471 | + function setNegativePattern($pattern) |
|
472 | + { |
|
473 | + $this->pattern['negPref'] = $pattern[0]; |
|
474 | + $this->pattern['negPost'] = $pattern[1]; |
|
475 | + } |
|
476 | + |
|
477 | + /** |
|
478 | + * Gets the format pattern for positive values. |
|
479 | + * The positive pattern is composed of a prefix, and postfix. |
|
480 | + * This function returns <b>array(prefix, postfix)</b>. |
|
481 | + * @return arary positive pattern. |
|
482 | + */ |
|
483 | + function getPositivePattern() |
|
484 | + { |
|
485 | + $prefix = $this->pattern['posPref']; |
|
486 | + $postfix = $this->pattern['posPost']; |
|
487 | + return array($prefix, $postfix); |
|
488 | + } |
|
489 | + |
|
490 | + /** |
|
491 | + * Set the format pattern for positive values. |
|
492 | + * The positive pattern is composed of a prefix, and postfix in the form |
|
493 | + * <b>array(prefix, postfix)</b>. |
|
494 | + * @param arary positive pattern. |
|
495 | + */ |
|
496 | + function setPositivePattern($pattern) |
|
497 | + { |
|
498 | + $this->pattern['posPref'] = $pattern[0]; |
|
499 | + $this->pattern['posPost'] = $pattern[1]; |
|
500 | + } |
|
501 | + |
|
502 | + /** |
|
503 | + * Gets the string to use as the currency symbol. |
|
504 | + * @return string currency symbol. |
|
505 | + */ |
|
506 | + function getCurrencySymbol($currency='USD') |
|
507 | + { |
|
508 | + if(isset($this->pattern['symbol'])) |
|
509 | 509 | return $this->pattern['symbol']; |
510 | - else |
|
511 | - return $this->data['Currencies'][$currency][0]; |
|
512 | - } |
|
513 | - |
|
514 | - |
|
515 | - /** |
|
516 | - * Set the string to use as the currency symbol. |
|
517 | - * @param string currency symbol. |
|
518 | - */ |
|
519 | - function setCurrencySymbol($symbol) |
|
520 | - { |
|
521 | - $this->pattern['symbol'] = $symbol; |
|
522 | - } |
|
523 | - |
|
524 | - /** |
|
525 | - * Gets the string that represents negative infinity. |
|
526 | - * @return string negative infinity. |
|
527 | - */ |
|
528 | - function getNegativeInfinitySymbol() |
|
529 | - { |
|
510 | + else |
|
511 | + return $this->data['Currencies'][$currency][0]; |
|
512 | + } |
|
513 | + |
|
514 | + |
|
515 | + /** |
|
516 | + * Set the string to use as the currency symbol. |
|
517 | + * @param string currency symbol. |
|
518 | + */ |
|
519 | + function setCurrencySymbol($symbol) |
|
520 | + { |
|
521 | + $this->pattern['symbol'] = $symbol; |
|
522 | + } |
|
523 | + |
|
524 | + /** |
|
525 | + * Gets the string that represents negative infinity. |
|
526 | + * @return string negative infinity. |
|
527 | + */ |
|
528 | + function getNegativeInfinitySymbol() |
|
529 | + { |
|
530 | 530 | return $this->pattern['negInfty']; |
531 | - } |
|
532 | - |
|
533 | - /** |
|
534 | - * Set the string that represents negative infinity. |
|
535 | - * @param string negative infinity. |
|
536 | - */ |
|
537 | - function setNegativeInfinitySymbol($value) |
|
538 | - { |
|
531 | + } |
|
532 | + |
|
533 | + /** |
|
534 | + * Set the string that represents negative infinity. |
|
535 | + * @param string negative infinity. |
|
536 | + */ |
|
537 | + function setNegativeInfinitySymbol($value) |
|
538 | + { |
|
539 | 539 | $this->pattern['negInfty'] = $value; |
540 | - } |
|
541 | - |
|
542 | - /** |
|
543 | - * Gets the string that represents positive infinity. |
|
544 | - * @return string positive infinity. |
|
545 | - */ |
|
546 | - function getPositiveInfinitySymbol() |
|
547 | - { |
|
540 | + } |
|
541 | + |
|
542 | + /** |
|
543 | + * Gets the string that represents positive infinity. |
|
544 | + * @return string positive infinity. |
|
545 | + */ |
|
546 | + function getPositiveInfinitySymbol() |
|
547 | + { |
|
548 | 548 | return $this->pattern['posInfty']; |
549 | - } |
|
550 | - |
|
551 | - /** |
|
552 | - * Set the string that represents positive infinity. |
|
553 | - * @param string positive infinity. |
|
554 | - */ |
|
555 | - function setPositiveInfinitySymbol($value) |
|
556 | - { |
|
549 | + } |
|
550 | + |
|
551 | + /** |
|
552 | + * Set the string that represents positive infinity. |
|
553 | + * @param string positive infinity. |
|
554 | + */ |
|
555 | + function setPositiveInfinitySymbol($value) |
|
556 | + { |
|
557 | 557 | $this->pattern['posInfty'] = $value; |
558 | - } |
|
559 | - |
|
560 | - /** |
|
561 | - * Gets the string that denotes that the associated number is negative. |
|
562 | - * @return string negative sign. |
|
563 | - */ |
|
564 | - function getNegativeSign() |
|
565 | - { |
|
566 | - return $this->data['NumberElements'][6]; |
|
567 | - } |
|
568 | - |
|
569 | - /** |
|
570 | - * Set the string that denotes that the associated number is negative. |
|
571 | - * @param string negative sign. |
|
572 | - */ |
|
573 | - function setNegativeSign($value) |
|
574 | - { |
|
575 | - $this->data['NumberElements'][6] = $value; |
|
576 | - } |
|
577 | - |
|
578 | - /** |
|
579 | - * Gets the string that denotes that the associated number is positive. |
|
580 | - * @return string positive sign. |
|
581 | - */ |
|
582 | - function getPositiveSign() |
|
583 | - { |
|
584 | - return $this->data['NumberElements'][11]; |
|
585 | - } |
|
586 | - |
|
587 | - /** |
|
588 | - * Set the string that denotes that the associated number is positive. |
|
589 | - * @param string positive sign. |
|
590 | - */ |
|
591 | - function setPositiveSign($value) |
|
592 | - { |
|
593 | - $this->data['NumberElements'][11] = $value; |
|
594 | - } |
|
595 | - |
|
596 | - /** |
|
597 | - * Gets the string that represents the IEEE NaN (not a number) value. |
|
598 | - * @return string NaN symbol. |
|
599 | - */ |
|
600 | - function getNaNSymbol() |
|
601 | - { |
|
602 | - return $this->data['NumberElements'][10]; |
|
603 | - } |
|
604 | - |
|
605 | - /** |
|
606 | - * Set the string that represents the IEEE NaN (not a number) value. |
|
607 | - * @param string NaN symbol. |
|
608 | - */ |
|
609 | - function setNaNSymbol($value) |
|
610 | - { |
|
611 | - $this->data['NumberElements'][10] = $value; |
|
612 | - } |
|
613 | - |
|
614 | - /** |
|
615 | - * Gets the string to use as the percent symbol. |
|
616 | - * @return string percent symbol. |
|
617 | - */ |
|
618 | - function getPercentSymbol() |
|
619 | - { |
|
620 | - return $this->data['NumberElements'][3]; |
|
621 | - } |
|
622 | - |
|
623 | - /** |
|
624 | - * Set the string to use as the percent symbol. |
|
625 | - * @param string percent symbol. |
|
626 | - */ |
|
627 | - function setPercentSymbol($value) |
|
628 | - { |
|
629 | - $this->data['NumberElements'][3] = $value; |
|
630 | - } |
|
631 | - |
|
632 | - /** |
|
633 | - * Gets the string to use as the per mille symbol. |
|
634 | - * @return string percent symbol. |
|
635 | - */ |
|
636 | - function getPerMilleSymbol() |
|
637 | - { |
|
638 | - return $this->data['NumberElements'][8]; |
|
639 | - } |
|
640 | - |
|
641 | - /** |
|
642 | - * Set the string to use as the per mille symbol. |
|
643 | - * @param string percent symbol. |
|
644 | - */ |
|
645 | - function setPerMilleSymbol($value) |
|
646 | - { |
|
647 | - $this->data['NumberElements'][8] = $value; |
|
648 | - } |
|
558 | + } |
|
559 | + |
|
560 | + /** |
|
561 | + * Gets the string that denotes that the associated number is negative. |
|
562 | + * @return string negative sign. |
|
563 | + */ |
|
564 | + function getNegativeSign() |
|
565 | + { |
|
566 | + return $this->data['NumberElements'][6]; |
|
567 | + } |
|
568 | + |
|
569 | + /** |
|
570 | + * Set the string that denotes that the associated number is negative. |
|
571 | + * @param string negative sign. |
|
572 | + */ |
|
573 | + function setNegativeSign($value) |
|
574 | + { |
|
575 | + $this->data['NumberElements'][6] = $value; |
|
576 | + } |
|
577 | + |
|
578 | + /** |
|
579 | + * Gets the string that denotes that the associated number is positive. |
|
580 | + * @return string positive sign. |
|
581 | + */ |
|
582 | + function getPositiveSign() |
|
583 | + { |
|
584 | + return $this->data['NumberElements'][11]; |
|
585 | + } |
|
586 | + |
|
587 | + /** |
|
588 | + * Set the string that denotes that the associated number is positive. |
|
589 | + * @param string positive sign. |
|
590 | + */ |
|
591 | + function setPositiveSign($value) |
|
592 | + { |
|
593 | + $this->data['NumberElements'][11] = $value; |
|
594 | + } |
|
595 | + |
|
596 | + /** |
|
597 | + * Gets the string that represents the IEEE NaN (not a number) value. |
|
598 | + * @return string NaN symbol. |
|
599 | + */ |
|
600 | + function getNaNSymbol() |
|
601 | + { |
|
602 | + return $this->data['NumberElements'][10]; |
|
603 | + } |
|
604 | + |
|
605 | + /** |
|
606 | + * Set the string that represents the IEEE NaN (not a number) value. |
|
607 | + * @param string NaN symbol. |
|
608 | + */ |
|
609 | + function setNaNSymbol($value) |
|
610 | + { |
|
611 | + $this->data['NumberElements'][10] = $value; |
|
612 | + } |
|
613 | + |
|
614 | + /** |
|
615 | + * Gets the string to use as the percent symbol. |
|
616 | + * @return string percent symbol. |
|
617 | + */ |
|
618 | + function getPercentSymbol() |
|
619 | + { |
|
620 | + return $this->data['NumberElements'][3]; |
|
621 | + } |
|
622 | + |
|
623 | + /** |
|
624 | + * Set the string to use as the percent symbol. |
|
625 | + * @param string percent symbol. |
|
626 | + */ |
|
627 | + function setPercentSymbol($value) |
|
628 | + { |
|
629 | + $this->data['NumberElements'][3] = $value; |
|
630 | + } |
|
631 | + |
|
632 | + /** |
|
633 | + * Gets the string to use as the per mille symbol. |
|
634 | + * @return string percent symbol. |
|
635 | + */ |
|
636 | + function getPerMilleSymbol() |
|
637 | + { |
|
638 | + return $this->data['NumberElements'][8]; |
|
639 | + } |
|
640 | + |
|
641 | + /** |
|
642 | + * Set the string to use as the per mille symbol. |
|
643 | + * @param string percent symbol. |
|
644 | + */ |
|
645 | + function setPerMilleSymbol($value) |
|
646 | + { |
|
647 | + $this->data['NumberElements'][8] = $value; |
|
648 | + } |
|
649 | 649 | } |
650 | 650 |
@@ -52,24 +52,24 @@ discard block |
||
52 | 52 | * ICU number formatting data. |
53 | 53 | * @var array |
54 | 54 | */ |
55 | - private $data = array(); |
|
55 | + private $data=array(); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * A list of properties that are accessable/writable. |
59 | 59 | * @var array |
60 | 60 | */ |
61 | - protected $properties = array(); |
|
61 | + protected $properties=array(); |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * The number pattern. |
65 | 65 | * @var array |
66 | 66 | */ |
67 | - protected $pattern = array(); |
|
67 | + protected $pattern=array(); |
|
68 | 68 | |
69 | - const DECIMAL = 0; |
|
70 | - const CURRENCY = 1; |
|
71 | - const PERCENTAGE = 2; |
|
72 | - const SCIENTIFIC = 3; |
|
69 | + const DECIMAL=0; |
|
70 | + const CURRENCY=1; |
|
71 | + const PERCENTAGE=2; |
|
72 | + const SCIENTIFIC=3; |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * Allow functions that begins with 'set' to be called directly |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function __get($name) |
80 | 80 | { |
81 | - $getProperty = 'get'.$name; |
|
81 | + $getProperty='get'.$name; |
|
82 | 82 | if(in_array($getProperty, $this->properties)) |
83 | 83 | return $this->$getProperty(); |
84 | 84 | else |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function __set($name, $value) |
93 | 93 | { |
94 | - $setProperty = 'set'.$name; |
|
94 | + $setProperty='set'.$name; |
|
95 | 95 | if(in_array($setProperty, $this->properties)) |
96 | 96 | $this->$setProperty($value); |
97 | 97 | else |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function __construct($data=array(), $type=NumberFormatInfo::DECIMAL) |
111 | 111 | { |
112 | - $this->properties = get_class_methods($this); |
|
112 | + $this->properties=get_class_methods($this); |
|
113 | 113 | |
114 | 114 | if(empty($data)) |
115 | 115 | throw new Exception('Please provide the ICU data to initialize.'); |
116 | 116 | |
117 | - $this->data = $data; |
|
117 | + $this->data=$data; |
|
118 | 118 | |
119 | 119 | $this->setPattern($type); |
120 | 120 | } |
@@ -128,16 +128,16 @@ discard block |
||
128 | 128 | public function setPattern($type=NumberFormatInfo::DECIMAL) |
129 | 129 | { |
130 | 130 | if(is_int($type)) |
131 | - $this->pattern = |
|
131 | + $this->pattern= |
|
132 | 132 | $this->parsePattern($this->data['NumberPatterns'][$type]); |
133 | 133 | else |
134 | - $this->pattern = $this->parsePattern($type); |
|
134 | + $this->pattern=$this->parsePattern($type); |
|
135 | 135 | |
136 | - $this->pattern['negInfty'] = |
|
136 | + $this->pattern['negInfty']= |
|
137 | 137 | $this->data['NumberElements'][6]. |
138 | 138 | $this->data['NumberElements'][9]; |
139 | 139 | |
140 | - $this->pattern['posInfty'] = |
|
140 | + $this->pattern['posInfty']= |
|
141 | 141 | $this->data['NumberElements'][11]. |
142 | 142 | $this->data['NumberElements'][9]; |
143 | 143 | } |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | public static function getInvariantInfo($type=NumberFormatInfo::DECIMAL) |
156 | 156 | { |
157 | 157 | static $invariant; |
158 | - if($invariant === null) |
|
158 | + if($invariant===null) |
|
159 | 159 | { |
160 | - $culture = CultureInfo::getInvariantCulture(); |
|
161 | - $invariant = $culture->NumberFormat; |
|
160 | + $culture=CultureInfo::getInvariantCulture(); |
|
161 | + $invariant=$culture->NumberFormat; |
|
162 | 162 | $invariant->setPattern($type); |
163 | 163 | } |
164 | 164 | return $invariant; |
@@ -179,23 +179,23 @@ discard block |
||
179 | 179 | public static function getInstance($culture=null, |
180 | 180 | $type=NumberFormatInfo::DECIMAL) |
181 | 181 | { |
182 | - if ($culture instanceof CultureInfo) |
|
182 | + if($culture instanceof CultureInfo) |
|
183 | 183 | { |
184 | - $formatInfo = $culture->NumberFormat; |
|
184 | + $formatInfo=$culture->NumberFormat; |
|
185 | 185 | $formatInfo->setPattern($type); |
186 | 186 | return $formatInfo; |
187 | 187 | } |
188 | 188 | else if(is_string($culture)) |
189 | 189 | { |
190 | - $cultureInfo = new CultureInfo($culture); |
|
191 | - $formatInfo = $cultureInfo->NumberFormat; |
|
190 | + $cultureInfo=new CultureInfo($culture); |
|
191 | + $formatInfo=$cultureInfo->NumberFormat; |
|
192 | 192 | $formatInfo->setPattern($type); |
193 | 193 | return $formatInfo; |
194 | 194 | } |
195 | 195 | else |
196 | 196 | { |
197 | - $cultureInfo = new CultureInfo(); |
|
198 | - $formatInfo = $cultureInfo->NumberFormat; |
|
197 | + $cultureInfo=new CultureInfo(); |
|
198 | + $formatInfo=$cultureInfo->NumberFormat; |
|
199 | 199 | $formatInfo->setPattern($type); |
200 | 200 | return $formatInfo; |
201 | 201 | } |
@@ -241,67 +241,67 @@ discard block |
||
241 | 241 | */ |
242 | 242 | protected function parsePattern($pattern) |
243 | 243 | { |
244 | - $pattern = explode(';',$pattern); |
|
244 | + $pattern=explode(';', $pattern); |
|
245 | 245 | |
246 | - $negative = null; |
|
246 | + $negative=null; |
|
247 | 247 | if(count($pattern) > 1) |
248 | - $negative = $pattern[1]; |
|
249 | - $pattern = $pattern[0]; |
|
248 | + $negative=$pattern[1]; |
|
249 | + $pattern=$pattern[0]; |
|
250 | 250 | |
251 | - $comma = ','; |
|
252 | - $dot = '.'; |
|
253 | - $digit = '0'; |
|
254 | - $hash = '#'; |
|
251 | + $comma=','; |
|
252 | + $dot='.'; |
|
253 | + $digit='0'; |
|
254 | + $hash='#'; |
|
255 | 255 | |
256 | 256 | //find the first group point, and decimal point |
257 | - $groupPos1 = strrpos($pattern,$comma); |
|
258 | - $decimalPos = strrpos($pattern,$dot); |
|
257 | + $groupPos1=strrpos($pattern, $comma); |
|
258 | + $decimalPos=strrpos($pattern, $dot); |
|
259 | 259 | |
260 | - $groupPos2 = false; |
|
261 | - $groupSize1 = false; |
|
262 | - $groupSize2 = false; |
|
263 | - $decimalPoints = is_int($decimalPos)?-1:false; |
|
260 | + $groupPos2=false; |
|
261 | + $groupSize1=false; |
|
262 | + $groupSize2=false; |
|
263 | + $decimalPoints=is_int($decimalPos) ?-1 : false; |
|
264 | 264 | |
265 | - $info['negPref'] = $this->data['NumberElements'][6]; |
|
266 | - $info['negPost'] = ''; |
|
265 | + $info['negPref']=$this->data['NumberElements'][6]; |
|
266 | + $info['negPost']=''; |
|
267 | 267 | |
268 | - $info['negative'] = $negative; |
|
269 | - $info['positive'] = $pattern; |
|
268 | + $info['negative']=$negative; |
|
269 | + $info['positive']=$pattern; |
|
270 | 270 | |
271 | 271 | //find the negative prefix and postfix |
272 | 272 | if($negative) |
273 | 273 | { |
274 | - $prefixPostfix = $this->getPrePostfix($negative); |
|
275 | - $info['negPref'] = $prefixPostfix[0]; |
|
276 | - $info['negPost'] = $prefixPostfix[1]; |
|
274 | + $prefixPostfix=$this->getPrePostfix($negative); |
|
275 | + $info['negPref']=$prefixPostfix[0]; |
|
276 | + $info['negPost']=$prefixPostfix[1]; |
|
277 | 277 | } |
278 | 278 | |
279 | - $posfix = $this->getPrePostfix($pattern); |
|
280 | - $info['posPref'] = $posfix[0]; |
|
281 | - $info['posPost'] = $posfix[1]; |
|
279 | + $posfix=$this->getPrePostfix($pattern); |
|
280 | + $info['posPref']=$posfix[0]; |
|
281 | + $info['posPost']=$posfix[1]; |
|
282 | 282 | |
283 | 283 | //var_dump($pattern); |
284 | 284 | //var_dump($decimalPos); |
285 | 285 | if(is_int($groupPos1)) |
286 | 286 | { |
287 | 287 | //get the second group |
288 | - $groupPos2 = strrpos(substr($pattern,0,$groupPos1),$comma); |
|
288 | + $groupPos2=strrpos(substr($pattern, 0, $groupPos1), $comma); |
|
289 | 289 | |
290 | 290 | //get the number of decimal digits |
291 | 291 | if(is_int($decimalPos)) |
292 | 292 | { |
293 | - $groupSize1 = $decimalPos - $groupPos1-1; |
|
293 | + $groupSize1=$decimalPos - $groupPos1 - 1; |
|
294 | 294 | |
295 | 295 | } |
296 | 296 | else |
297 | 297 | { |
298 | 298 | //no decimal point, so traverse from the back |
299 | 299 | //to find the groupsize 1. |
300 | - for($i=strlen($pattern)-1; $i>=0; $i--) |
|
300 | + for($i=strlen($pattern) - 1; $i >= 0; $i--) |
|
301 | 301 | { |
302 | - if($pattern{$i} == $digit || $pattern{$i}==$hash) |
|
302 | + if($pattern{$i}==$digit || $pattern{$i}==$hash) |
|
303 | 303 | { |
304 | - $groupSize1 = $i - $groupPos1; |
|
304 | + $groupSize1=$i - $groupPos1; |
|
305 | 305 | break; |
306 | 306 | } |
307 | 307 | } |
@@ -309,36 +309,36 @@ discard block |
||
309 | 309 | |
310 | 310 | //get the second group size |
311 | 311 | if(is_int($groupPos2)) |
312 | - $groupSize2 = $groupPos1 - $groupPos2-1; |
|
312 | + $groupSize2=$groupPos1 - $groupPos2 - 1; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | if(is_int($decimalPos)) |
316 | 316 | { |
317 | - for($i=strlen($pattern)-1; $i>=0; $i--) |
|
317 | + for($i=strlen($pattern) - 1; $i >= 0; $i--) |
|
318 | 318 | { |
319 | - if($pattern{$i} == $dot) break; |
|
320 | - if($pattern{$i} == $digit) |
|
319 | + if($pattern{$i}==$dot) break; |
|
320 | + if($pattern{$i}==$digit) |
|
321 | 321 | { |
322 | - $decimalPoints = $i - $decimalPos; |
|
322 | + $decimalPoints=$i - $decimalPos; |
|
323 | 323 | break; |
324 | 324 | } |
325 | 325 | } |
326 | 326 | } |
327 | 327 | |
328 | 328 | if(is_int($decimalPos)) |
329 | - $digitPattern = substr($pattern,0,$decimalPos); |
|
329 | + $digitPattern=substr($pattern, 0, $decimalPos); |
|
330 | 330 | else |
331 | - $digitPattern = $pattern; |
|
331 | + $digitPattern=$pattern; |
|
332 | 332 | |
333 | - $digitPattern = preg_replace('/[^0]/','',$digitPattern); |
|
333 | + $digitPattern=preg_replace('/[^0]/', '', $digitPattern); |
|
334 | 334 | |
335 | - $info['groupPos1'] = $groupPos1; |
|
336 | - $info['groupSize1'] = $groupSize1; |
|
337 | - $info['groupPos2'] = $groupPos2; |
|
338 | - $info['groupSize2'] = $groupSize2; |
|
339 | - $info['decimalPos'] = $decimalPos; |
|
340 | - $info['decimalPoints'] = $decimalPoints; |
|
341 | - $info['digitSize'] = strlen($digitPattern); |
|
335 | + $info['groupPos1']=$groupPos1; |
|
336 | + $info['groupSize1']=$groupSize1; |
|
337 | + $info['groupPos2']=$groupPos2; |
|
338 | + $info['groupSize2']=$groupSize2; |
|
339 | + $info['decimalPos']=$decimalPos; |
|
340 | + $info['decimalPoints']=$decimalPoints; |
|
341 | + $info['digitSize']=strlen($digitPattern); |
|
342 | 342 | return $info; |
343 | 343 | } |
344 | 344 | |
@@ -349,9 +349,9 @@ discard block |
||
349 | 349 | */ |
350 | 350 | protected function getPrePostfix($pattern) |
351 | 351 | { |
352 | - $regexp = '/[#,\.0]+/'; |
|
353 | - $result = preg_split($regexp, $pattern); |
|
354 | - return array($result[0],$result[1]); |
|
352 | + $regexp='/[#,\.0]+/'; |
|
353 | + $result=preg_split($regexp, $pattern); |
|
354 | + return array($result[0], $result[1]); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | function setDecimalDigits($value) |
372 | 372 | { |
373 | - return $this->pattern['decimalPoints'] = $value; |
|
373 | + return $this->pattern['decimalPoints']=$value; |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | function getDigitSize() |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | |
381 | 381 | function setDigitSize($value) |
382 | 382 | { |
383 | - $this->pattern['digitSize'] = $value; |
|
383 | + $this->pattern['digitSize']=$value; |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | */ |
399 | 399 | function setDecimalSeparator($value) |
400 | 400 | { |
401 | - return $this->data['NumberElements'][0] = $value; |
|
401 | + return $this->data['NumberElements'][0]=$value; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | */ |
419 | 419 | function setGroupSeparator($value) |
420 | 420 | { |
421 | - return $this->data['NumberElements'][1] = $value; |
|
421 | + return $this->data['NumberElements'][1]=$value; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | */ |
431 | 431 | function getGroupSizes() |
432 | 432 | { |
433 | - $group1 = $this->pattern['groupSize1']; |
|
434 | - $group2 = $this->pattern['groupSize2']; |
|
433 | + $group1=$this->pattern['groupSize1']; |
|
434 | + $group2=$this->pattern['groupSize2']; |
|
435 | 435 | |
436 | 436 | return array($group1, $group2); |
437 | 437 | } |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | */ |
446 | 446 | function setGroupSizes($groupSize) |
447 | 447 | { |
448 | - $this->pattern['groupSize1'] = $groupSize[0]; |
|
449 | - $this->pattern['groupSize2'] = $groupSize[1]; |
|
448 | + $this->pattern['groupSize1']=$groupSize[0]; |
|
449 | + $this->pattern['groupSize2']=$groupSize[1]; |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | */ |
458 | 458 | function getNegativePattern() |
459 | 459 | { |
460 | - $prefix = $this->pattern['negPref']; |
|
461 | - $postfix = $this->pattern['negPost']; |
|
460 | + $prefix=$this->pattern['negPref']; |
|
461 | + $postfix=$this->pattern['negPost']; |
|
462 | 462 | return array($prefix, $postfix); |
463 | 463 | } |
464 | 464 | |
@@ -470,8 +470,8 @@ discard block |
||
470 | 470 | */ |
471 | 471 | function setNegativePattern($pattern) |
472 | 472 | { |
473 | - $this->pattern['negPref'] = $pattern[0]; |
|
474 | - $this->pattern['negPost'] = $pattern[1]; |
|
473 | + $this->pattern['negPref']=$pattern[0]; |
|
474 | + $this->pattern['negPost']=$pattern[1]; |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | /** |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | */ |
483 | 483 | function getPositivePattern() |
484 | 484 | { |
485 | - $prefix = $this->pattern['posPref']; |
|
486 | - $postfix = $this->pattern['posPost']; |
|
485 | + $prefix=$this->pattern['posPref']; |
|
486 | + $postfix=$this->pattern['posPost']; |
|
487 | 487 | return array($prefix, $postfix); |
488 | 488 | } |
489 | 489 | |
@@ -495,8 +495,8 @@ discard block |
||
495 | 495 | */ |
496 | 496 | function setPositivePattern($pattern) |
497 | 497 | { |
498 | - $this->pattern['posPref'] = $pattern[0]; |
|
499 | - $this->pattern['posPost'] = $pattern[1]; |
|
498 | + $this->pattern['posPref']=$pattern[0]; |
|
499 | + $this->pattern['posPost']=$pattern[1]; |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | /** |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | */ |
519 | 519 | function setCurrencySymbol($symbol) |
520 | 520 | { |
521 | - $this->pattern['symbol'] = $symbol; |
|
521 | + $this->pattern['symbol']=$symbol; |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | */ |
537 | 537 | function setNegativeInfinitySymbol($value) |
538 | 538 | { |
539 | - $this->pattern['negInfty'] = $value; |
|
539 | + $this->pattern['negInfty']=$value; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | */ |
555 | 555 | function setPositiveInfinitySymbol($value) |
556 | 556 | { |
557 | - $this->pattern['posInfty'] = $value; |
|
557 | + $this->pattern['posInfty']=$value; |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | */ |
573 | 573 | function setNegativeSign($value) |
574 | 574 | { |
575 | - $this->data['NumberElements'][6] = $value; |
|
575 | + $this->data['NumberElements'][6]=$value; |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | */ |
591 | 591 | function setPositiveSign($value) |
592 | 592 | { |
593 | - $this->data['NumberElements'][11] = $value; |
|
593 | + $this->data['NumberElements'][11]=$value; |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | /** |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | */ |
609 | 609 | function setNaNSymbol($value) |
610 | 610 | { |
611 | - $this->data['NumberElements'][10] = $value; |
|
611 | + $this->data['NumberElements'][10]=$value; |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | */ |
627 | 627 | function setPercentSymbol($value) |
628 | 628 | { |
629 | - $this->data['NumberElements'][3] = $value; |
|
629 | + $this->data['NumberElements'][3]=$value; |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | /** |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | */ |
645 | 645 | function setPerMilleSymbol($value) |
646 | 646 | { |
647 | - $this->data['NumberElements'][8] = $value; |
|
647 | + $this->data['NumberElements'][8]=$value; |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 |
@@ -290,7 +290,7 @@ |
||
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) { |
@@ -43,13 +43,13 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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"> |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $this->languages = array(); |
59 | 59 | |
60 | 60 | if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) |
61 | - return $this->languages; |
|
61 | + return $this->languages; |
|
62 | 62 | |
63 | 63 | //$basedir = CultureInfo::dataDir(); |
64 | 64 | //$ext = CultureInfo::fileExt(); |
@@ -66,18 +66,18 @@ discard block |
||
66 | 66 | |
67 | 67 | foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $lang) |
68 | 68 | { |
69 | - // Cut off any q-value that might come after a semi-colon |
|
70 | - if ($pos = strpos($lang, ';')) |
|
71 | - $lang = trim(substr($lang, 0, $pos)); |
|
69 | + // Cut off any q-value that might come after a semi-colon |
|
70 | + if ($pos = strpos($lang, ';')) |
|
71 | + $lang = trim(substr($lang, 0, $pos)); |
|
72 | 72 | |
73 | 73 | if (strstr($lang, '-')) |
74 | 74 | { |
75 | 75 | $codes = explode('-',$lang); |
76 | 76 | if($codes[0] == 'i') |
77 | 77 | { |
78 | - // Language not listed in ISO 639 that are not variants |
|
79 | - // of any listed language, which can be registerd with the |
|
80 | - // i-prefix, such as i-cherokee |
|
78 | + // Language not listed in ISO 639 that are not variants |
|
79 | + // of any listed language, which can be registerd with the |
|
80 | + // i-prefix, such as i-cherokee |
|
81 | 81 | if(count($codes)>1) |
82 | 82 | $lang = $codes[1]; |
83 | 83 | } |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | $lang .= '_'.strtoupper($codes[$i]); |
92 | 92 | } |
93 | 93 | } |
94 | - } |
|
94 | + } |
|
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | 98 | if($info->validCulture($lang)) |
99 | 99 | $this->languages[] = $lang; |
100 | - } |
|
100 | + } |
|
101 | 101 | |
102 | 102 | return $this->languages; |
103 | 103 | } |
@@ -108,20 +108,20 @@ discard block |
||
108 | 108 | */ |
109 | 109 | function getCharsets() |
110 | 110 | { |
111 | - if($this->charsets !== null) { |
|
111 | + if($this->charsets !== null) { |
|
112 | 112 | return $this->charsets; |
113 | 113 | } |
114 | 114 | |
115 | 115 | $this->charsets = array(); |
116 | 116 | |
117 | 117 | if (!isset($_SERVER['HTTP_ACCEPT_CHARSET'])) |
118 | - return $this->charsets; |
|
118 | + return $this->charsets; |
|
119 | 119 | |
120 | 120 | foreach (explode(',', $_SERVER['HTTP_ACCEPT_CHARSET']) as $charset) |
121 | 121 | { |
122 | - if (!empty($charset)) |
|
123 | - $this->charsets[] = preg_replace('/;.*/', '', $charset); |
|
124 | - } |
|
122 | + if (!empty($charset)) |
|
123 | + $this->charsets[] = preg_replace('/;.*/', '', $charset); |
|
124 | + } |
|
125 | 125 | |
126 | 126 | return $this->charsets; |
127 | 127 | } |
@@ -51,44 +51,44 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function getLanguages() |
53 | 53 | { |
54 | - if($this->languages !== null) { |
|
54 | + if($this->languages!==null) { |
|
55 | 55 | return $this->languages; |
56 | 56 | } |
57 | 57 | |
58 | - $this->languages = array(); |
|
58 | + $this->languages=array(); |
|
59 | 59 | |
60 | - if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) |
|
60 | + if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) |
|
61 | 61 | return $this->languages; |
62 | 62 | |
63 | 63 | //$basedir = CultureInfo::dataDir(); |
64 | 64 | //$ext = CultureInfo::fileExt(); |
65 | - $info = new CultureInfo(); |
|
65 | + $info=new CultureInfo(); |
|
66 | 66 | |
67 | 67 | foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $lang) |
68 | 68 | { |
69 | 69 | // Cut off any q-value that might come after a semi-colon |
70 | - if ($pos = strpos($lang, ';')) |
|
71 | - $lang = trim(substr($lang, 0, $pos)); |
|
70 | + if($pos=strpos($lang, ';')) |
|
71 | + $lang=trim(substr($lang, 0, $pos)); |
|
72 | 72 | |
73 | - if (strstr($lang, '-')) |
|
73 | + if(strstr($lang, '-')) |
|
74 | 74 | { |
75 | - $codes = explode('-',$lang); |
|
76 | - if($codes[0] == 'i') |
|
75 | + $codes=explode('-', $lang); |
|
76 | + if($codes[0]=='i') |
|
77 | 77 | { |
78 | 78 | // Language not listed in ISO 639 that are not variants |
79 | 79 | // of any listed language, which can be registerd with the |
80 | 80 | // i-prefix, such as i-cherokee |
81 | - if(count($codes)>1) |
|
82 | - $lang = $codes[1]; |
|
81 | + if(count($codes) > 1) |
|
82 | + $lang=$codes[1]; |
|
83 | 83 | } |
84 | 84 | else |
85 | 85 | { |
86 | - for($i = 0, $k = count($codes); $i<$k; ++$i) |
|
86 | + for($i=0, $k=count($codes); $i < $k; ++$i) |
|
87 | 87 | { |
88 | - if($i == 0) |
|
89 | - $lang = strtolower($codes[0]); |
|
88 | + if($i==0) |
|
89 | + $lang=strtolower($codes[0]); |
|
90 | 90 | else |
91 | - $lang .= '_'.strtoupper($codes[$i]); |
|
91 | + $lang.='_'.strtoupper($codes[$i]); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | |
98 | 98 | if($info->validCulture($lang)) |
99 | - $this->languages[] = $lang; |
|
99 | + $this->languages[]=$lang; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | return $this->languages; |
@@ -108,19 +108,19 @@ discard block |
||
108 | 108 | */ |
109 | 109 | function getCharsets() |
110 | 110 | { |
111 | - if($this->charsets !== null) { |
|
111 | + if($this->charsets!==null) { |
|
112 | 112 | return $this->charsets; |
113 | 113 | } |
114 | 114 | |
115 | - $this->charsets = array(); |
|
115 | + $this->charsets=array(); |
|
116 | 116 | |
117 | - if (!isset($_SERVER['HTTP_ACCEPT_CHARSET'])) |
|
117 | + if(!isset($_SERVER['HTTP_ACCEPT_CHARSET'])) |
|
118 | 118 | return $this->charsets; |
119 | 119 | |
120 | - foreach (explode(',', $_SERVER['HTTP_ACCEPT_CHARSET']) as $charset) |
|
120 | + foreach(explode(',', $_SERVER['HTTP_ACCEPT_CHARSET']) as $charset) |
|
121 | 121 | { |
122 | - if (!empty($charset)) |
|
123 | - $this->charsets[] = preg_replace('/;.*/', '', $charset); |
|
122 | + if(!empty($charset)) |
|
123 | + $this->charsets[]=preg_replace('/;.*/', '', $charset); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | return $this->charsets; |
@@ -199,9 +199,9 @@ |
||
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(); |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | * ICU data filename extension. |
52 | 52 | * @var string |
53 | 53 | */ |
54 | - private $dataFileExt = '.dat'; |
|
54 | + private $dataFileExt='.dat'; |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * The ICU data array. |
58 | 58 | * @var array |
59 | 59 | */ |
60 | - private $data = array(); |
|
60 | + private $data=array(); |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * The current culture. |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * A list of ICU date files loaded. |
76 | 76 | * @var array |
77 | 77 | */ |
78 | - private $dataFiles = array(); |
|
78 | + private $dataFiles=array(); |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * The current date time format info. |
@@ -93,28 +93,28 @@ discard block |
||
93 | 93 | * A list of properties that are accessable/writable. |
94 | 94 | * @var array |
95 | 95 | */ |
96 | - protected $properties = array(); |
|
96 | + protected $properties=array(); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Culture type, all. |
100 | 100 | * @see getCultures() |
101 | 101 | * @var int |
102 | 102 | */ |
103 | - const ALL = 0; |
|
103 | + const ALL=0; |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * Culture type, neutral. |
107 | 107 | * @see getCultures() |
108 | 108 | * @var int |
109 | 109 | */ |
110 | - const NEUTRAL = 1; |
|
110 | + const NEUTRAL=1; |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * Culture type, specific. |
114 | 114 | * @see getCultures() |
115 | 115 | * @var int |
116 | 116 | */ |
117 | - const SPECIFIC = 2; |
|
117 | + const SPECIFIC=2; |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Display the culture name. |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | function __get($name) |
136 | 136 | { |
137 | - $getProperty = 'get'.$name; |
|
137 | + $getProperty='get'.$name; |
|
138 | 138 | if(in_array($getProperty, $this->properties)) |
139 | 139 | return $this->$getProperty(); |
140 | 140 | else |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | function __set($name, $value) |
149 | 149 | { |
150 | - $setProperty = 'set'.$name; |
|
150 | + $setProperty='set'.$name; |
|
151 | 151 | if(in_array($setProperty, $this->properties)) |
152 | 152 | $this->$setProperty($value); |
153 | 153 | else |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | */ |
166 | 166 | function __construct($culture='en') |
167 | 167 | { |
168 | - $this->properties = get_class_methods($this); |
|
168 | + $this->properties=get_class_methods($this); |
|
169 | 169 | |
170 | 170 | if(empty($culture)) |
171 | - $culture = 'en'; |
|
171 | + $culture='en'; |
|
172 | 172 | |
173 | - $this->dataDir = $this->dataDir(); |
|
174 | - $this->dataFileExt = $this->fileExt(); |
|
173 | + $this->dataDir=$this->dataDir(); |
|
174 | + $this->dataFileExt=$this->fileExt(); |
|
175 | 175 | |
176 | 176 | $this->setCulture($culture); |
177 | 177 | |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public static function getInstance($culture) |
206 | 206 | { |
207 | - static $instances = array(); |
|
207 | + static $instances=array(); |
|
208 | 208 | if(!isset($instances[$culture])) |
209 | - $instances[$culture] = new CultureInfo($culture); |
|
209 | + $instances[$culture]=new CultureInfo($culture); |
|
210 | 210 | return $instances[$culture]; |
211 | 211 | } |
212 | 212 | |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | { |
234 | 234 | if(!empty($culture)) |
235 | 235 | { |
236 | - if (!preg_match('/^[_\\w]+$/', $culture)) |
|
237 | - throw new Exception('Invalid culture supplied: ' . $culture); |
|
236 | + if(!preg_match('/^[_\\w]+$/', $culture)) |
|
237 | + throw new Exception('Invalid culture supplied: '.$culture); |
|
238 | 238 | } |
239 | 239 | |
240 | - $this->culture = $culture; |
|
240 | + $this->culture=$culture; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -246,30 +246,30 @@ discard block |
||
246 | 246 | */ |
247 | 247 | protected function loadCultureData($culture) |
248 | 248 | { |
249 | - $file_parts = explode('_',$culture); |
|
250 | - $current_part = $file_parts[0]; |
|
249 | + $file_parts=explode('_', $culture); |
|
250 | + $current_part=$file_parts[0]; |
|
251 | 251 | |
252 | - $files = array($current_part); |
|
252 | + $files=array($current_part); |
|
253 | 253 | |
254 | - for($i = 1, $k = count($file_parts); $i < $k; ++$i) |
|
254 | + for($i=1, $k=count($file_parts); $i < $k; ++$i) |
|
255 | 255 | { |
256 | - $current_part .= '_'.$file_parts[$i]; |
|
257 | - $files[] = $current_part; |
|
256 | + $current_part.='_'.$file_parts[$i]; |
|
257 | + $files[]=$current_part; |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | foreach($files as $file) |
261 | 261 | { |
262 | - $filename = $this->dataDir.$file.$this->dataFileExt; |
|
262 | + $filename=$this->dataDir.$file.$this->dataFileExt; |
|
263 | 263 | |
264 | - if(is_file($filename) == false) |
|
264 | + if(is_file($filename)==false) |
|
265 | 265 | throw new Exception('Data file for "'.$file.'" was not found.'); |
266 | 266 | |
267 | - if(in_array($filename, $this->dataFiles) === false) |
|
267 | + if(in_array($filename, $this->dataFiles)===false) |
|
268 | 268 | { |
269 | 269 | array_unshift($this->dataFiles, $file); |
270 | 270 | |
271 | - $data = &$this->getData($filename); |
|
272 | - $this->data[$file] = &$data; |
|
271 | + $data=&$this->getData($filename); |
|
272 | + $this->data[$file]=&$data; |
|
273 | 273 | |
274 | 274 | if(isset($data['__ALIAS'])) |
275 | 275 | $this->loadCultureData($data['__ALIAS'][0]); |
@@ -287,13 +287,13 @@ discard block |
||
287 | 287 | */ |
288 | 288 | protected function &getData($filename) |
289 | 289 | { |
290 | - static $data = array(); |
|
291 | - static $files = array(); |
|
290 | + static $data=array(); |
|
291 | + static $files=array(); |
|
292 | 292 | |
293 | 293 | if(!in_array($filename, $files)) |
294 | 294 | { |
295 | - $data[$filename] = unserialize(file_get_contents($filename)); |
|
296 | - $files[] = $filename; |
|
295 | + $data[$filename]=unserialize(file_get_contents($filename)); |
|
296 | + $files[]=$filename; |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | return $data[$filename]; |
@@ -315,15 +315,15 @@ discard block |
||
315 | 315 | */ |
316 | 316 | protected function findInfo($path='/', $merge=false) |
317 | 317 | { |
318 | - $result = array(); |
|
318 | + $result=array(); |
|
319 | 319 | foreach($this->dataFiles as $section) |
320 | 320 | { |
321 | - $info = $this->searchArray($this->data[$section], $path); |
|
321 | + $info=$this->searchArray($this->data[$section], $path); |
|
322 | 322 | |
323 | 323 | if($info) |
324 | 324 | { |
325 | 325 | if($merge) |
326 | - $result = array_merge($info,$result); |
|
326 | + $result=array_merge($info, $result); |
|
327 | 327 | else |
328 | 328 | return $info; |
329 | 329 | } |
@@ -342,16 +342,16 @@ discard block |
||
342 | 342 | */ |
343 | 343 | private function searchArray($info, $path='/') |
344 | 344 | { |
345 | - $index = explode('/',$path); |
|
345 | + $index=explode('/', $path); |
|
346 | 346 | |
347 | - $array = $info; |
|
347 | + $array=$info; |
|
348 | 348 | |
349 | - for($i = 0, $k = count($index); $i < $k; ++$i) |
|
349 | + for($i=0, $k=count($index); $i < $k; ++$i) |
|
350 | 350 | { |
351 | - $value = $index[$i]; |
|
352 | - if($i < $k-1 && isset($array[$value])) |
|
353 | - $array = $array[$value]; |
|
354 | - else if ($i == $k-1 && isset($array[$value])) |
|
351 | + $value=$index[$i]; |
|
352 | + if($i < $k - 1 && isset($array[$value])) |
|
353 | + $array=$array[$value]; |
|
354 | + else if($i==$k - 1 && isset($array[$value])) |
|
355 | 355 | return $array[$value]; |
356 | 356 | } |
357 | 357 | } |
@@ -373,10 +373,10 @@ discard block |
||
373 | 373 | */ |
374 | 374 | function getDateTimeFormat() |
375 | 375 | { |
376 | - if($this->dateTimeFormat === null) |
|
376 | + if($this->dateTimeFormat===null) |
|
377 | 377 | { |
378 | - $calendar = $this->getCalendar(); |
|
379 | - $info = $this->findInfo("calendar/{$calendar}", true); |
|
378 | + $calendar=$this->getCalendar(); |
|
379 | + $info=$this->findInfo("calendar/{$calendar}", true); |
|
380 | 380 | $this->setDateTimeFormat(new DateTimeFormatInfo($info)); |
381 | 381 | } |
382 | 382 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | */ |
390 | 390 | function setDateTimeFormat($dateTimeFormat) |
391 | 391 | { |
392 | - $this->dateTimeFormat = $dateTimeFormat; |
|
392 | + $this->dateTimeFormat=$dateTimeFormat; |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | */ |
399 | 399 | function getCalendar() |
400 | 400 | { |
401 | - $info = $this->findInfo('calendar/default'); |
|
401 | + $info=$this->findInfo('calendar/default'); |
|
402 | 402 | return $info[0]; |
403 | 403 | } |
404 | 404 | |
@@ -410,10 +410,10 @@ discard block |
||
410 | 410 | */ |
411 | 411 | function getNativeName() |
412 | 412 | { |
413 | - $lang = substr($this->culture,0,2); |
|
414 | - $reg = substr($this->culture,3,2); |
|
415 | - $language = $this->findInfo("Languages/{$lang}"); |
|
416 | - $region = $this->findInfo("Countries/{$reg}"); |
|
413 | + $lang=substr($this->culture, 0, 2); |
|
414 | + $reg=substr($this->culture, 3, 2); |
|
415 | + $language=$this->findInfo("Languages/{$lang}"); |
|
416 | + $region=$this->findInfo("Countries/{$reg}"); |
|
417 | 417 | if($region) |
418 | 418 | return $language[0].' ('.$region[0].')'; |
419 | 419 | else |
@@ -428,15 +428,15 @@ discard block |
||
428 | 428 | */ |
429 | 429 | function getEnglishName() |
430 | 430 | { |
431 | - $lang = substr($this->culture,0,2); |
|
432 | - $reg = substr($this->culture,3,2); |
|
433 | - $culture = $this->getInvariantCulture(); |
|
431 | + $lang=substr($this->culture, 0, 2); |
|
432 | + $reg=substr($this->culture, 3, 2); |
|
433 | + $culture=$this->getInvariantCulture(); |
|
434 | 434 | |
435 | - $language = $culture->findInfo("Languages/{$lang}"); |
|
436 | - if(count($language) == 0) |
|
435 | + $language=$culture->findInfo("Languages/{$lang}"); |
|
436 | + if(count($language)==0) |
|
437 | 437 | return $this->culture; |
438 | 438 | |
439 | - $region = $culture->findInfo("Countries/{$reg}"); |
|
439 | + $region=$culture->findInfo("Countries/{$reg}"); |
|
440 | 440 | if($region) |
441 | 441 | return $language[0].' ('.$region[0].')'; |
442 | 442 | else |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | static function getInvariantCulture() |
454 | 454 | { |
455 | 455 | static $invariant; |
456 | - if($invariant === null) |
|
457 | - $invariant = new CultureInfo(); |
|
456 | + if($invariant===null) |
|
457 | + $invariant=new CultureInfo(); |
|
458 | 458 | return $invariant; |
459 | 459 | } |
460 | 460 | |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | */ |
467 | 467 | function getIsNeutralCulture() |
468 | 468 | { |
469 | - return strlen($this->culture) == 2; |
|
469 | + return strlen($this->culture)==2; |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | /** |
@@ -476,12 +476,12 @@ discard block |
||
476 | 476 | */ |
477 | 477 | function getNumberFormat() |
478 | 478 | { |
479 | - if($this->numberFormat === null) |
|
479 | + if($this->numberFormat===null) |
|
480 | 480 | { |
481 | - $elements = $this->findInfo('NumberElements'); |
|
482 | - $patterns = $this->findInfo('NumberPatterns'); |
|
483 | - $currencies = $this->getCurrencies(); |
|
484 | - $data = array( 'NumberElements'=>$elements, |
|
481 | + $elements=$this->findInfo('NumberElements'); |
|
482 | + $patterns=$this->findInfo('NumberPatterns'); |
|
483 | + $currencies=$this->getCurrencies(); |
|
484 | + $data=array('NumberElements'=>$elements, |
|
485 | 485 | 'NumberPatterns'=>$patterns, |
486 | 486 | 'Currencies' => $currencies); |
487 | 487 | |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | */ |
497 | 497 | function setNumberFormat($numberFormat) |
498 | 498 | { |
499 | - $this->numberFormat = $numberFormat; |
|
499 | + $this->numberFormat=$numberFormat; |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | /** |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | */ |
507 | 507 | function getParent() |
508 | 508 | { |
509 | - if(strlen($this->culture) == 2) |
|
509 | + if(strlen($this->culture)==2) |
|
510 | 510 | return $this->getInvariantCulture(); |
511 | 511 | |
512 | - $lang = substr($this->culture,0,2); |
|
512 | + $lang=substr($this->culture, 0, 2); |
|
513 | 513 | return new CultureInfo($lang); |
514 | 514 | } |
515 | 515 | |
@@ -524,24 +524,24 @@ discard block |
||
524 | 524 | */ |
525 | 525 | static function getCultures($type=CultureInfo::ALL) |
526 | 526 | { |
527 | - $dataDir = CultureInfo::dataDir(); |
|
528 | - $dataExt = CultureInfo::fileExt(); |
|
529 | - $dir = dir($dataDir); |
|
527 | + $dataDir=CultureInfo::dataDir(); |
|
528 | + $dataExt=CultureInfo::fileExt(); |
|
529 | + $dir=dir($dataDir); |
|
530 | 530 | |
531 | - $neutral = array(); |
|
532 | - $specific = array(); |
|
531 | + $neutral=array(); |
|
532 | + $specific=array(); |
|
533 | 533 | |
534 | - while (false !== ($entry = $dir->read())) |
|
534 | + while(false!==($entry=$dir->read())) |
|
535 | 535 | { |
536 | 536 | if(is_file($dataDir.$entry) |
537 | - && substr($entry,-4) == $dataExt |
|
538 | - && $entry != 'root'.$dataExt) |
|
537 | + && substr($entry, -4)==$dataExt |
|
538 | + && $entry!='root'.$dataExt) |
|
539 | 539 | { |
540 | - $culture = substr($entry,0,-4); |
|
541 | - if(strlen($culture) == 2) |
|
542 | - $neutral[] = $culture; |
|
540 | + $culture=substr($entry, 0, -4); |
|
541 | + if(strlen($culture)==2) |
|
542 | + $neutral[]=$culture; |
|
543 | 543 | else |
544 | - $specific[] = $culture; |
|
544 | + $specific[]=$culture; |
|
545 | 545 | } |
546 | 546 | } |
547 | 547 | $dir->close(); |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | switch($type) |
550 | 550 | { |
551 | 551 | case CultureInfo::ALL : |
552 | - $all = array_merge($neutral, $specific); |
|
552 | + $all=array_merge($neutral, $specific); |
|
553 | 553 | sort($all); |
554 | 554 | return $all; |
555 | 555 | break; |
@@ -571,12 +571,12 @@ discard block |
||
571 | 571 | */ |
572 | 572 | private function simplify($array) |
573 | 573 | { |
574 | - for($i = 0, $k = count($array); $i<$k; ++$i) |
|
574 | + for($i=0, $k=count($array); $i < $k; ++$i) |
|
575 | 575 | { |
576 | - $key = key($array); |
|
576 | + $key=key($array); |
|
577 | 577 | if(is_array($array[$key]) |
578 | - && count($array[$key]) == 1) |
|
579 | - $array[$key] = $array[$key][0]; |
|
578 | + && count($array[$key])==1) |
|
579 | + $array[$key]=$array[$key][0]; |
|
580 | 580 | next($array); |
581 | 581 | } |
582 | 582 | return $array; |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | */ |
589 | 589 | function getCountries() |
590 | 590 | { |
591 | - return $this->simplify($this->findInfo('Countries',true)); |
|
591 | + return $this->simplify($this->findInfo('Countries', true)); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | */ |
598 | 598 | function getCurrencies() |
599 | 599 | { |
600 | - return $this->findInfo('Currencies',true); |
|
600 | + return $this->findInfo('Currencies', true); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | /** |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | */ |
607 | 607 | function getLanguages() |
608 | 608 | { |
609 | - return $this->simplify($this->findInfo('Languages',true)); |
|
609 | + return $this->simplify($this->findInfo('Languages', true)); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | /** |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | */ |
616 | 616 | function getScripts() |
617 | 617 | { |
618 | - return $this->simplify($this->findInfo('Scripts',true)); |
|
618 | + return $this->simplify($this->findInfo('Scripts', true)); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | */ |
625 | 625 | function getTimeZones() |
626 | 626 | { |
627 | - return $this->simplify($this->findInfo('zoneStrings',true)); |
|
627 | + return $this->simplify($this->findInfo('zoneStrings', true)); |
|
628 | 628 | } |
629 | 629 | } |
630 | 630 |
@@ -58,229 +58,229 @@ |
||
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 | } |
@@ -66,7 +66,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |