@@ -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 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function __construct($source) |
| 43 | 43 | { |
| 44 | - $this->_connID= (string)$source; |
|
| 44 | + $this->_connID=(string) $source; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | if($conn instanceof TDataSourceConfig) |
| 72 | 72 | return $conn->getDbConnection(); |
| 73 | 73 | else |
| 74 | - throw new TConfigurationException('messagesource_connectionid_invalid',$connectionID); |
|
| 74 | + throw new TConfigurationException('messagesource_connectionid_invalid', $connectionID); |
|
| 75 | 75 | } |
| 76 | 76 | else |
| 77 | 77 | throw new TConfigurationException('messagesource_connectionid_required'); |
@@ -91,13 +91,13 @@ discard block |
||
| 91 | 91 | WHERE c.cat_id = t.cat_id |
| 92 | 92 | AND c.name = :variant |
| 93 | 93 | ORDER BY id ASC'); |
| 94 | - $command->bindParameter(':variant',$variant,PDO::PARAM_STR); |
|
| 94 | + $command->bindParameter(':variant', $variant, PDO::PARAM_STR); |
|
| 95 | 95 | $dataReader=$command->query(); |
| 96 | 96 | |
| 97 | - $result = array(); |
|
| 97 | + $result=array(); |
|
| 98 | 98 | |
| 99 | - foreach ($dataReader as $row) |
|
| 100 | - $result[$row['source']] = array($row['target'],$row['id'],$row['comments']); |
|
| 99 | + foreach($dataReader as $row) |
|
| 100 | + $result[$row['source']]=array($row['target'], $row['id'], $row['comments']); |
|
| 101 | 101 | |
| 102 | 102 | return $result; |
| 103 | 103 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | { |
| 113 | 113 | $command=$this->getDBConnection()->createCommand( |
| 114 | 114 | 'SELECT date_modified FROM catalogue WHERE name = :source'); |
| 115 | - $command->bindParameter(':source',$source,PDO::PARAM_STR); |
|
| 115 | + $command->bindParameter(':source', $source, PDO::PARAM_STR); |
|
| 116 | 116 | $result=$command->queryScalar(); |
| 117 | 117 | return $result ? $result : 0; |
| 118 | 118 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | { |
| 129 | 129 | $command=$this->getDBConnection()->createCommand( |
| 130 | 130 | 'SELECT COUNT(*) FROM catalogue WHERE name = :variant'); |
| 131 | - $command->bindParameter(':variant',$variant,PDO::PARAM_STR); |
|
| 131 | + $command->bindParameter(':variant', $variant, PDO::PARAM_STR); |
|
| 132 | 132 | return $command->queryScalar()==1; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -139,18 +139,18 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | protected function getCatalogueList($catalogue) |
| 141 | 141 | { |
| 142 | - $variants = explode('_',$this->culture); |
|
| 142 | + $variants=explode('_', $this->culture); |
|
| 143 | 143 | |
| 144 | - $catalogues = array($catalogue); |
|
| 144 | + $catalogues=array($catalogue); |
|
| 145 | 145 | |
| 146 | - $variant = null; |
|
| 146 | + $variant=null; |
|
| 147 | 147 | |
| 148 | - for($i = 0, $k = count($variants); $i < $k; ++$i) |
|
| 148 | + for($i=0, $k=count($variants); $i < $k; ++$i) |
|
| 149 | 149 | { |
| 150 | 150 | if(isset($variants[$i]{0})) |
| 151 | 151 | { |
| 152 | - $variant .= ($variant)?'_'.$variants[$i]:$variants[$i]; |
|
| 153 | - $catalogues[] = $catalogue.'.'.$variant; |
|
| 152 | + $variant.=($variant) ? '_'.$variants[$i] : $variants[$i]; |
|
| 153 | + $catalogues[]=$catalogue.'.'.$variant; |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | return array_reverse($catalogues); |
@@ -164,20 +164,20 @@ discard block |
||
| 164 | 164 | private function getCatalogueDetails($catalogue='messages') |
| 165 | 165 | { |
| 166 | 166 | if(empty($catalogue)) |
| 167 | - $catalogue = 'messages'; |
|
| 167 | + $catalogue='messages'; |
|
| 168 | 168 | |
| 169 | - $variant = $catalogue.'.'.$this->culture; |
|
| 169 | + $variant=$catalogue.'.'.$this->culture; |
|
| 170 | 170 | |
| 171 | 171 | $command=$this->getDBConnection()->createCommand( |
| 172 | 172 | 'SELECT cat_id FROM catalogue WHERE name = :variant'); |
| 173 | - $command->bindParameter(':variant',$variant,PDO::PARAM_STR); |
|
| 173 | + $command->bindParameter(':variant', $variant, PDO::PARAM_STR); |
|
| 174 | 174 | $cat_id=$command->queryScalar(); |
| 175 | 175 | |
| 176 | - if ($cat_id===null) return false; |
|
| 176 | + if($cat_id===null) return false; |
|
| 177 | 177 | |
| 178 | 178 | $command=$this->getDBConnection()->createCommand( |
| 179 | 179 | 'SELECT COUNT(msg_id) FROM trans_unit WHERE cat_id = :catid '); |
| 180 | - $command->bindParameter(':catid',$cat_id,PDO::PARAM_INT); |
|
| 180 | + $command->bindParameter(':catid', $cat_id, PDO::PARAM_INT); |
|
| 181 | 181 | $count=$command->queryScalar(); |
| 182 | 182 | |
| 183 | 183 | return array($cat_id, $variant, $count); |
@@ -189,11 +189,11 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | private function updateCatalogueTime($cat_id, $variant) |
| 191 | 191 | { |
| 192 | - $time = time(); |
|
| 192 | + $time=time(); |
|
| 193 | 193 | $command=$this->getDBConnection()->createCommand( |
| 194 | 194 | 'UPDATE catalogue SET date_modified = :moddate WHERE cat_id = :catid'); |
| 195 | - $command->bindParameter(':moddate',$time,PDO::PARAM_INT); |
|
| 196 | - $command->bindParameter(':catid',$cat_id,PDO::PARAM_INT); |
|
| 195 | + $command->bindParameter(':moddate', $time, PDO::PARAM_INT); |
|
| 196 | + $command->bindParameter(':catid', $cat_id, PDO::PARAM_INT); |
|
| 197 | 197 | $result=$command->execute(); |
| 198 | 198 | |
| 199 | 199 | if(!empty($this->cache)) |
@@ -211,31 +211,31 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | function save($catalogue='messages') |
| 213 | 213 | { |
| 214 | - $messages = $this->untranslated; |
|
| 214 | + $messages=$this->untranslated; |
|
| 215 | 215 | |
| 216 | 216 | if(count($messages) <= 0) return false; |
| 217 | 217 | |
| 218 | - $details = $this->getCatalogueDetails($catalogue); |
|
| 218 | + $details=$this->getCatalogueDetails($catalogue); |
|
| 219 | 219 | |
| 220 | 220 | if($details) |
| 221 | - list($cat_id, $variant, $count) = $details; |
|
| 221 | + list($cat_id, $variant, $count)=$details; |
|
| 222 | 222 | else |
| 223 | 223 | return false; |
| 224 | 224 | |
| 225 | 225 | if($cat_id <= 0) return false; |
| 226 | - $inserted = 0; |
|
| 226 | + $inserted=0; |
|
| 227 | 227 | |
| 228 | - $time = time(); |
|
| 228 | + $time=time(); |
|
| 229 | 229 | |
| 230 | 230 | $command=$this->getDBConnection()->createCommand( |
| 231 | 231 | 'INSERT INTO trans_unit (cat_id,id,source,date_added) VALUES (:catid,:id,:source,:dateadded)'); |
| 232 | - $command->bindParameter(':catid',$cat_id,PDO::PARAM_INT); |
|
| 233 | - $command->bindParameter(':id',$count,PDO::PARAM_INT); |
|
| 234 | - $command->bindParameter(':source',$message,PDO::PARAM_STR); |
|
| 235 | - $command->bindParameter(':dateadded',$time,PDO::PARAM_INT); |
|
| 232 | + $command->bindParameter(':catid', $cat_id, PDO::PARAM_INT); |
|
| 233 | + $command->bindParameter(':id', $count, PDO::PARAM_INT); |
|
| 234 | + $command->bindParameter(':source', $message, PDO::PARAM_STR); |
|
| 235 | + $command->bindParameter(':dateadded', $time, PDO::PARAM_INT); |
|
| 236 | 236 | foreach($messages as $message) |
| 237 | 237 | { |
| 238 | - if (empty($message)) continue; |
|
| 238 | + if(empty($message)) continue; |
|
| 239 | 239 | $count++; $inserted++; |
| 240 | 240 | $command->execute(); |
| 241 | 241 | } |
@@ -253,16 +253,16 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | function delete($message, $catalogue='messages') |
| 255 | 255 | { |
| 256 | - $details = $this->getCatalogueDetails($catalogue); |
|
| 256 | + $details=$this->getCatalogueDetails($catalogue); |
|
| 257 | 257 | if($details) |
| 258 | - list($cat_id, $variant, $count) = $details; |
|
| 258 | + list($cat_id, $variant, $count)=$details; |
|
| 259 | 259 | else |
| 260 | 260 | return false; |
| 261 | 261 | |
| 262 | 262 | $command=$this->getDBConnection()->createCommand( |
| 263 | 263 | 'DELETE FROM trans_unit WHERE cat_id = :catid AND source = :message'); |
| 264 | - $command->bindParameter(':catid',$cat_id,PDO::PARAM_INT); |
|
| 265 | - $command->bindParameter(':message',$message,PDO::PARAM_STR); |
|
| 264 | + $command->bindParameter(':catid', $cat_id, PDO::PARAM_INT); |
|
| 265 | + $command->bindParameter(':message', $message, PDO::PARAM_STR); |
|
| 266 | 266 | |
| 267 | 267 | return ($command->execute()==1) ? $this->updateCatalogueTime($cat_id, $variant) : false; |
| 268 | 268 | |
@@ -278,21 +278,21 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | function update($text, $target, $comments, $catalogue='messages') |
| 280 | 280 | { |
| 281 | - $details = $this->getCatalogueDetails($catalogue); |
|
| 281 | + $details=$this->getCatalogueDetails($catalogue); |
|
| 282 | 282 | if($details) |
| 283 | - list($cat_id, $variant, $count) = $details; |
|
| 283 | + list($cat_id, $variant, $count)=$details; |
|
| 284 | 284 | else |
| 285 | 285 | return false; |
| 286 | 286 | |
| 287 | - $time = time(); |
|
| 287 | + $time=time(); |
|
| 288 | 288 | $command=$this->getDBConnection()->createCommand( |
| 289 | 289 | 'UPDATE trans_unit SET target = :target, comments = :comments, date_modified = :datemod |
| 290 | 290 | WHERE cat_id = :catid AND source = :source'); |
| 291 | - $command->bindParameter(':target',$target,PDO::PARAM_STR); |
|
| 292 | - $command->bindParameter(':comments',$comments,PDO::PARAM_STR); |
|
| 293 | - $command->bindParameter(':datemod',$time,PDO::PARAM_INT); |
|
| 294 | - $command->bindParameter(':catid',$cat_id,PDO::PARAM_INT); |
|
| 295 | - $command->bindParameter(':source',$text,PDO::PARAM_STR); |
|
| 291 | + $command->bindParameter(':target', $target, PDO::PARAM_STR); |
|
| 292 | + $command->bindParameter(':comments', $comments, PDO::PARAM_STR); |
|
| 293 | + $command->bindParameter(':datemod', $time, PDO::PARAM_INT); |
|
| 294 | + $command->bindParameter(':catid', $cat_id, PDO::PARAM_INT); |
|
| 295 | + $command->bindParameter(':source', $text, PDO::PARAM_STR); |
|
| 296 | 296 | |
| 297 | 297 | return ($command->execute()==1) ? $this->updateCatalogueTime($cat_id, $variant) : false; |
| 298 | 298 | } |
@@ -303,17 +303,17 @@ discard block |
||
| 303 | 303 | */ |
| 304 | 304 | function catalogues() |
| 305 | 305 | { |
| 306 | - $command=$this->getDBConnection()->createCommand( 'SELECT name FROM catalogue ORDER BY name'); |
|
| 306 | + $command=$this->getDBConnection()->createCommand('SELECT name FROM catalogue ORDER BY name'); |
|
| 307 | 307 | $dataReader=$command->query(); |
| 308 | 308 | |
| 309 | - $result = array(); |
|
| 309 | + $result=array(); |
|
| 310 | 310 | |
| 311 | - foreach ($dataReader as $row) |
|
| 311 | + foreach($dataReader as $row) |
|
| 312 | 312 | { |
| 313 | - $details = explode('.',$row[0]); |
|
| 314 | - if(!isset($details[1])) $details[1] = null; |
|
| 313 | + $details=explode('.', $row[0]); |
|
| 314 | + if(!isset($details[1])) $details[1]=null; |
|
| 315 | 315 | |
| 316 | - $result[] = $details; |
|
| 316 | + $result[]=$details; |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | return $result; |
@@ -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 | } |
@@ -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 | } |
@@ -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"> |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * Caceh life time, default is 1 year. |
| 30 | 30 | */ |
| 31 | - protected $lifetime = 3153600; |
|
| 31 | + protected $lifetime=3153600; |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function __construct($cacheDir) |
| 39 | 39 | { |
| 40 | - $cacheDir = $cacheDir.'/'; |
|
| 40 | + $cacheDir=$cacheDir.'/'; |
|
| 41 | 41 | |
| 42 | 42 | if(!is_dir($cacheDir)) |
| 43 | 43 | throw new Exception( |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | 'The cache directory '.$cacheDir.' must be writable '. |
| 49 | 49 | 'by the server.'); |
| 50 | 50 | |
| 51 | - $options = array( |
|
| 51 | + $options=array( |
|
| 52 | 52 | 'cacheDir' => $cacheDir, |
| 53 | 53 | 'lifeTime' => $this->getLifeTime(), |
| 54 | 54 | 'automaticSerialization' => true |
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | - $this->cache = new TCache_Lite($options); |
|
| 57 | + $this->cache=new TCache_Lite($options); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function setLifeTime($time) |
| 74 | 74 | { |
| 75 | - $this->lifetime = (int)$time; |
|
| 75 | + $this->lifetime=(int) $time; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -106,18 +106,18 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function get($catalogue, $culture, $lastmodified=0) |
| 108 | 108 | { |
| 109 | - $ID = $this->getID($catalogue, $culture); |
|
| 110 | - $group = $this->getGroup($catalogue, $culture); |
|
| 109 | + $ID=$this->getID($catalogue, $culture); |
|
| 110 | + $group=$this->getGroup($catalogue, $culture); |
|
| 111 | 111 | |
| 112 | 112 | $this->cache->_setFileName($ID, $group); |
| 113 | 113 | |
| 114 | - $cache = $this->cache->getCacheFile(); |
|
| 114 | + $cache=$this->cache->getCacheFile(); |
|
| 115 | 115 | |
| 116 | - if(is_file($cache) == false) |
|
| 116 | + if(is_file($cache)==false) |
|
| 117 | 117 | return false; |
| 118 | 118 | |
| 119 | 119 | |
| 120 | - $lastmodified = (int)$lastmodified; |
|
| 120 | + $lastmodified=(int) $lastmodified; |
|
| 121 | 121 | |
| 122 | 122 | if($lastmodified <= 0 || $lastmodified > filemtime($cache)) |
| 123 | 123 | return false; |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function save($data, $catalogue, $culture) |
| 138 | 138 | { |
| 139 | - $ID = $this->getID($catalogue, $culture); |
|
| 140 | - $group = $this->getGroup($catalogue, $culture); |
|
| 139 | + $ID=$this->getID($catalogue, $culture); |
|
| 140 | + $group=$this->getGroup($catalogue, $culture); |
|
| 141 | 141 | |
| 142 | 142 | //echo '## Cache save: "'.$ID.'" : "'.$group.'"'; |
| 143 | 143 | //echo "<br>\n"; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function clean($catalogue, $culture) |
| 154 | 154 | { |
| 155 | - $group = $this->getGroup($catalogue, $culture); |
|
| 155 | + $group=$this->getGroup($catalogue, $culture); |
|
| 156 | 156 | $this->cache->clean($group); |
| 157 | 157 | } |
| 158 | 158 | |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | function parseDSN($dsn) |
| 41 | 41 | { |
| 42 | - if (is_array($dsn)) { |
|
| 42 | + if(is_array($dsn)) { |
|
| 43 | 43 | return $dsn; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - $parsed = array( |
|
| 46 | + $parsed=array( |
|
| 47 | 47 | 'phptype' => false, |
| 48 | 48 | 'dbsyntax' => false, |
| 49 | 49 | 'username' => false, |
@@ -56,94 +56,94 @@ discard block |
||
| 56 | 56 | ); |
| 57 | 57 | |
| 58 | 58 | // Find phptype and dbsyntax |
| 59 | - if (($pos = strpos($dsn, '://')) !== false) { |
|
| 60 | - $str = substr($dsn, 0, $pos); |
|
| 61 | - $dsn = substr($dsn, $pos + 3); |
|
| 59 | + if(($pos=strpos($dsn, '://'))!==false) { |
|
| 60 | + $str=substr($dsn, 0, $pos); |
|
| 61 | + $dsn=substr($dsn, $pos + 3); |
|
| 62 | 62 | } else { |
| 63 | - $str = $dsn; |
|
| 64 | - $dsn = null; |
|
| 63 | + $str=$dsn; |
|
| 64 | + $dsn=null; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // Get phptype and dbsyntax |
| 68 | 68 | // $str => phptype(dbsyntax) |
| 69 | - if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { |
|
| 70 | - $parsed['phptype'] = $arr[1]; |
|
| 71 | - $parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2]; |
|
| 69 | + if(preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { |
|
| 70 | + $parsed['phptype']=$arr[1]; |
|
| 71 | + $parsed['dbsyntax']=(empty($arr[2])) ? $arr[1] : $arr[2]; |
|
| 72 | 72 | } else { |
| 73 | - $parsed['phptype'] = $str; |
|
| 74 | - $parsed['dbsyntax'] = $str; |
|
| 73 | + $parsed['phptype']=$str; |
|
| 74 | + $parsed['dbsyntax']=$str; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if (empty($dsn)) { |
|
| 77 | + if(empty($dsn)) { |
|
| 78 | 78 | return $parsed; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // Get (if found): username and password |
| 82 | 82 | // $dsn => username:password@protocol+hostspec/database |
| 83 | - if (($at = strrpos($dsn,'@')) !== false) { |
|
| 84 | - $str = substr($dsn, 0, $at); |
|
| 85 | - $dsn = substr($dsn, $at + 1); |
|
| 86 | - if (($pos = strpos($str, ':')) !== false) { |
|
| 87 | - $parsed['username'] = rawurldecode(substr($str, 0, $pos)); |
|
| 88 | - $parsed['password'] = rawurldecode(substr($str, $pos + 1)); |
|
| 83 | + if(($at=strrpos($dsn, '@'))!==false) { |
|
| 84 | + $str=substr($dsn, 0, $at); |
|
| 85 | + $dsn=substr($dsn, $at + 1); |
|
| 86 | + if(($pos=strpos($str, ':'))!==false) { |
|
| 87 | + $parsed['username']=rawurldecode(substr($str, 0, $pos)); |
|
| 88 | + $parsed['password']=rawurldecode(substr($str, $pos + 1)); |
|
| 89 | 89 | } else { |
| 90 | - $parsed['username'] = rawurldecode($str); |
|
| 90 | + $parsed['username']=rawurldecode($str); |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | // Find protocol and hostspec |
| 95 | 95 | |
| 96 | 96 | // $dsn => proto(proto_opts)/database |
| 97 | - if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) { |
|
| 98 | - $proto = $match[1]; |
|
| 99 | - $proto_opts = (!empty($match[2])) ? $match[2] : false; |
|
| 100 | - $dsn = $match[3]; |
|
| 97 | + if(preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) { |
|
| 98 | + $proto=$match[1]; |
|
| 99 | + $proto_opts=(!empty($match[2])) ? $match[2] : false; |
|
| 100 | + $dsn=$match[3]; |
|
| 101 | 101 | |
| 102 | 102 | // $dsn => protocol+hostspec/database (old format) |
| 103 | 103 | } else { |
| 104 | - if (strpos($dsn, '+') !== false) { |
|
| 105 | - list($proto, $dsn) = explode('+', $dsn, 2); |
|
| 104 | + if(strpos($dsn, '+')!==false) { |
|
| 105 | + list($proto, $dsn)=explode('+', $dsn, 2); |
|
| 106 | 106 | } |
| 107 | - if (strpos($dsn, '/') !== false) { |
|
| 108 | - list($proto_opts, $dsn) = explode('/', $dsn, 2); |
|
| 107 | + if(strpos($dsn, '/')!==false) { |
|
| 108 | + list($proto_opts, $dsn)=explode('/', $dsn, 2); |
|
| 109 | 109 | } else { |
| 110 | - $proto_opts = $dsn; |
|
| 111 | - $dsn = null; |
|
| 110 | + $proto_opts=$dsn; |
|
| 111 | + $dsn=null; |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // process the different protocol options |
| 116 | - $parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp'; |
|
| 117 | - $proto_opts = rawurldecode($proto_opts); |
|
| 118 | - if ($parsed['protocol'] == 'tcp') { |
|
| 119 | - if (strpos($proto_opts, ':') !== false) { |
|
| 120 | - list($parsed['hostspec'], $parsed['port']) = explode(':', $proto_opts); |
|
| 116 | + $parsed['protocol']=(!empty($proto)) ? $proto : 'tcp'; |
|
| 117 | + $proto_opts=rawurldecode($proto_opts); |
|
| 118 | + if($parsed['protocol']=='tcp') { |
|
| 119 | + if(strpos($proto_opts, ':')!==false) { |
|
| 120 | + list($parsed['hostspec'], $parsed['port'])=explode(':', $proto_opts); |
|
| 121 | 121 | } else { |
| 122 | - $parsed['hostspec'] = $proto_opts; |
|
| 122 | + $parsed['hostspec']=$proto_opts; |
|
| 123 | 123 | } |
| 124 | - } elseif ($parsed['protocol'] == 'unix') { |
|
| 125 | - $parsed['socket'] = $proto_opts; |
|
| 124 | + } elseif($parsed['protocol']=='unix') { |
|
| 125 | + $parsed['socket']=$proto_opts; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // Get dabase if any |
| 129 | 129 | // $dsn => database |
| 130 | - if (!empty($dsn)) { |
|
| 130 | + if(!empty($dsn)) { |
|
| 131 | 131 | // /database |
| 132 | - if (($pos = strpos($dsn, '?')) === false) { |
|
| 133 | - $parsed['database'] = $dsn; |
|
| 132 | + if(($pos=strpos($dsn, '?'))===false) { |
|
| 133 | + $parsed['database']=$dsn; |
|
| 134 | 134 | // /database?param1=value1¶m2=value2 |
| 135 | 135 | } else { |
| 136 | - $parsed['database'] = substr($dsn, 0, $pos); |
|
| 137 | - $dsn = substr($dsn, $pos + 1); |
|
| 138 | - if (strpos($dsn, '&') !== false) { |
|
| 139 | - $opts = explode('&', $dsn); |
|
| 136 | + $parsed['database']=substr($dsn, 0, $pos); |
|
| 137 | + $dsn=substr($dsn, $pos + 1); |
|
| 138 | + if(strpos($dsn, '&')!==false) { |
|
| 139 | + $opts=explode('&', $dsn); |
|
| 140 | 140 | } else { // database?param1=value1 |
| 141 | - $opts = array($dsn); |
|
| 141 | + $opts=array($dsn); |
|
| 142 | 142 | } |
| 143 | - foreach ($opts as $opt) { |
|
| 144 | - list($key, $value) = explode('=', $opt); |
|
| 145 | - if (!isset($parsed[$key])) { // don't allow params overwrite |
|
| 146 | - $parsed[$key] = rawurldecode($value); |
|
| 143 | + foreach($opts as $opt) { |
|
| 144 | + list($key, $value)=explode('=', $opt); |
|
| 145 | + if(!isset($parsed[$key])) { // don't allow params overwrite |
|
| 146 | + $parsed[$key]=rawurldecode($value); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -161,10 +161,10 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | function I18N_toUTF8($string, $from) |
| 163 | 163 | { |
| 164 | - if($from != 'UTF-8') |
|
| 164 | + if($from!='UTF-8') |
|
| 165 | 165 | { |
| 166 | - $s = iconv($from,'UTF-8',$string); //to UTF-8 |
|
| 167 | - return $s !== false ? $s : $string; //it could return false |
|
| 166 | + $s=iconv($from, 'UTF-8', $string); //to UTF-8 |
|
| 167 | + return $s!==false ? $s : $string; //it could return false |
|
| 168 | 168 | } |
| 169 | 169 | return $string; |
| 170 | 170 | } |
@@ -177,10 +177,10 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | function I18N_toEncoding($string, $to) |
| 179 | 179 | { |
| 180 | - if($to != 'UTF-8') |
|
| 180 | + if($to!='UTF-8') |
|
| 181 | 181 | { |
| 182 | - $s = iconv('UTF-8', $to, $string); |
|
| 183 | - return $s !== false ? $s : $string; |
|
| 182 | + $s=iconv('UTF-8', $to, $string); |
|
| 183 | + return $s!==false ? $s : $string; |
|
| 184 | 184 | } |
| 185 | 185 | return $string; |
| 186 | 186 | } |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | * @param string a catalogue to load |
| 48 | 48 | * @return boolean true if loaded, false otherwise. |
| 49 | 49 | */ |
| 50 | - function load($catalogue = 'messages'); |
|
| 50 | + function load($catalogue='messages'); |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Get the translation table. This includes all the loaded sections. |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | function __construct($source) |
| 67 | 67 | { |
| 68 | - $this->source = (string)$source; |
|
| 69 | - $this->dns = parseDSN($this->source); |
|
| 70 | - $this->db = $this->connect(); |
|
| 68 | + $this->source=(string) $source; |
|
| 69 | + $this->dns=parseDSN($this->source); |
|
| 70 | + $this->db=$this->connect(); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -90,38 +90,38 @@ discard block |
||
| 90 | 90 | if($conn!==null) |
| 91 | 91 | return $conn; |
| 92 | 92 | */ |
| 93 | - $dsninfo = $this->dns; |
|
| 93 | + $dsninfo=$this->dns; |
|
| 94 | 94 | |
| 95 | - if (isset($dsninfo['protocol']) && $dsninfo['protocol'] == 'unix') |
|
| 96 | - $dbhost = ':' . $dsninfo['socket']; |
|
| 95 | + if(isset($dsninfo['protocol']) && $dsninfo['protocol']=='unix') |
|
| 96 | + $dbhost=':'.$dsninfo['socket']; |
|
| 97 | 97 | else |
| 98 | 98 | { |
| 99 | - $dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost'; |
|
| 100 | - if (!empty($dsninfo['port'])) |
|
| 101 | - $dbhost .= ':' . $dsninfo['port']; |
|
| 99 | + $dbhost=$dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost'; |
|
| 100 | + if(!empty($dsninfo['port'])) |
|
| 101 | + $dbhost.=':'.$dsninfo['port']; |
|
| 102 | 102 | } |
| 103 | - $user = $dsninfo['username']; |
|
| 104 | - $pw = $dsninfo['password']; |
|
| 103 | + $user=$dsninfo['username']; |
|
| 104 | + $pw=$dsninfo['password']; |
|
| 105 | 105 | |
| 106 | - $connect_function = 'mysql_connect'; |
|
| 106 | + $connect_function='mysql_connect'; |
|
| 107 | 107 | |
| 108 | - if ($dbhost && $user && $pw) |
|
| 109 | - $conn = @$connect_function($dbhost, $user, $pw); |
|
| 110 | - elseif ($dbhost && $user) |
|
| 111 | - $conn = @$connect_function($dbhost, $user); |
|
| 112 | - elseif ($dbhost) |
|
| 113 | - $conn = @$connect_function($dbhost); |
|
| 108 | + if($dbhost && $user && $pw) |
|
| 109 | + $conn=@$connect_function($dbhost, $user, $pw); |
|
| 110 | + elseif($dbhost && $user) |
|
| 111 | + $conn=@$connect_function($dbhost, $user); |
|
| 112 | + elseif($dbhost) |
|
| 113 | + $conn=@$connect_function($dbhost); |
|
| 114 | 114 | else |
| 115 | - $conn = false; |
|
| 115 | + $conn=false; |
|
| 116 | 116 | |
| 117 | - if (empty($conn)) |
|
| 117 | + if(empty($conn)) |
|
| 118 | 118 | { |
| 119 | 119 | throw new Exception('Error in connecting to '.$dsninfo); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if ($dsninfo['database']) |
|
| 122 | + if($dsninfo['database']) |
|
| 123 | 123 | { |
| 124 | - if (!@mysql_select_db($dsninfo['database'], $conn)) |
|
| 124 | + if(!@mysql_select_db($dsninfo['database'], $conn)) |
|
| 125 | 125 | throw new Exception('Error in connecting database, dns:'. |
| 126 | 126 | $dsninfo); |
| 127 | 127 | } |
@@ -148,25 +148,25 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | protected function &loadData($variant) |
| 150 | 150 | { |
| 151 | - $variant = mysql_real_escape_string($variant); |
|
| 151 | + $variant=mysql_real_escape_string($variant); |
|
| 152 | 152 | |
| 153 | - $statement = |
|
| 153 | + $statement= |
|
| 154 | 154 | "SELECT t.id, t.source, t.target, t.comments |
| 155 | 155 | FROM trans_unit t, catalogue c |
| 156 | 156 | WHERE c.cat_id = t.cat_id |
| 157 | 157 | AND c.name = '{$variant}' |
| 158 | 158 | ORDER BY id ASC"; |
| 159 | 159 | |
| 160 | - $rs = mysql_query($statement,$this->db); |
|
| 160 | + $rs=mysql_query($statement, $this->db); |
|
| 161 | 161 | |
| 162 | - $result = array(); |
|
| 162 | + $result=array(); |
|
| 163 | 163 | |
| 164 | - while($row = mysql_fetch_array($rs,MYSQL_NUM)) |
|
| 164 | + while($row=mysql_fetch_array($rs, MYSQL_NUM)) |
|
| 165 | 165 | { |
| 166 | - $source = $row[1]; |
|
| 167 | - $result[$source][] = $row[2]; //target |
|
| 168 | - $result[$source][] = $row[0]; //id |
|
| 169 | - $result[$source][] = $row[3]; //comments |
|
| 166 | + $source=$row[1]; |
|
| 167 | + $result[$source][]=$row[2]; //target |
|
| 168 | + $result[$source][]=$row[0]; //id |
|
| 169 | + $result[$source][]=$row[3]; //comments |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | return $result; |
@@ -180,13 +180,13 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | protected function getLastModified($source) |
| 182 | 182 | { |
| 183 | - $source = mysql_real_escape_string($source); |
|
| 183 | + $source=mysql_real_escape_string($source); |
|
| 184 | 184 | |
| 185 | - $rs = mysql_query( |
|
| 185 | + $rs=mysql_query( |
|
| 186 | 186 | "SELECT date_modified FROM catalogue WHERE name = '{$source}'", |
| 187 | 187 | $this->db); |
| 188 | 188 | |
| 189 | - $result = $rs ? (int)mysql_result($rs,0) : 0; |
|
| 189 | + $result=$rs ? (int) mysql_result($rs, 0) : 0; |
|
| 190 | 190 | |
| 191 | 191 | return $result; |
| 192 | 192 | } |
@@ -199,15 +199,15 @@ discard block |
||
| 199 | 199 | */ |
| 200 | 200 | protected function isValidSource($variant) |
| 201 | 201 | { |
| 202 | - $variant = mysql_real_escape_string ($variant); |
|
| 202 | + $variant=mysql_real_escape_string($variant); |
|
| 203 | 203 | |
| 204 | - $rs = mysql_query( |
|
| 204 | + $rs=mysql_query( |
|
| 205 | 205 | "SELECT COUNT(*) FROM catalogue WHERE name = '{$variant}'", |
| 206 | 206 | $this->db); |
| 207 | 207 | |
| 208 | - $row = mysql_fetch_array($rs,MYSQL_NUM); |
|
| 208 | + $row=mysql_fetch_array($rs, MYSQL_NUM); |
|
| 209 | 209 | |
| 210 | - $result = $row && $row[0] == '1'; |
|
| 210 | + $result=$row && $row[0]=='1'; |
|
| 211 | 211 | |
| 212 | 212 | return $result; |
| 213 | 213 | } |
@@ -219,18 +219,18 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | protected function getCatalogueList($catalogue) |
| 221 | 221 | { |
| 222 | - $variants = explode('_',$this->culture); |
|
| 222 | + $variants=explode('_', $this->culture); |
|
| 223 | 223 | |
| 224 | - $catalogues = array($catalogue); |
|
| 224 | + $catalogues=array($catalogue); |
|
| 225 | 225 | |
| 226 | - $variant = null; |
|
| 226 | + $variant=null; |
|
| 227 | 227 | |
| 228 | - for($i = 0, $k = count($variants); $i < $k; ++$i) |
|
| 228 | + for($i=0, $k=count($variants); $i < $k; ++$i) |
|
| 229 | 229 | { |
| 230 | 230 | if(isset($variants[$i]{0})) |
| 231 | 231 | { |
| 232 | - $variant .= ($variant)?'_'.$variants[$i]:$variants[$i]; |
|
| 233 | - $catalogues[] = $catalogue.'.'.$variant; |
|
| 232 | + $variant.=($variant) ? '_'.$variants[$i] : $variants[$i]; |
|
| 233 | + $catalogues[]=$catalogue.'.'.$variant; |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | return array_reverse($catalogues); |
@@ -244,27 +244,27 @@ discard block |
||
| 244 | 244 | private function getCatalogueDetails($catalogue='messages') |
| 245 | 245 | { |
| 246 | 246 | if(empty($catalogue)) |
| 247 | - $catalogue = 'messages'; |
|
| 247 | + $catalogue='messages'; |
|
| 248 | 248 | |
| 249 | - $variant = $catalogue.'.'.$this->culture; |
|
| 249 | + $variant=$catalogue.'.'.$this->culture; |
|
| 250 | 250 | |
| 251 | - $name = mysql_real_escape_string($this->getSource($variant)); |
|
| 251 | + $name=mysql_real_escape_string($this->getSource($variant)); |
|
| 252 | 252 | |
| 253 | - $rs = mysql_query("SELECT cat_id |
|
| 253 | + $rs=mysql_query("SELECT cat_id |
|
| 254 | 254 | FROM catalogue WHERE name = '{$name}'", $this->db); |
| 255 | 255 | |
| 256 | - if(mysql_num_rows($rs) != 1) |
|
| 256 | + if(mysql_num_rows($rs)!=1) |
|
| 257 | 257 | return false; |
| 258 | 258 | |
| 259 | - $cat_id = (int)mysql_result($rs,0); |
|
| 259 | + $cat_id=(int) mysql_result($rs, 0); |
|
| 260 | 260 | |
| 261 | 261 | //first get the catalogue ID |
| 262 | - $rs = mysql_query( |
|
| 262 | + $rs=mysql_query( |
|
| 263 | 263 | "SELECT count(msg_id) |
| 264 | 264 | FROM trans_unit |
| 265 | 265 | WHERE cat_id = {$cat_id}", $this->db); |
| 266 | 266 | |
| 267 | - $count = (int)mysql_result($rs,0); |
|
| 267 | + $count=(int) mysql_result($rs, 0); |
|
| 268 | 268 | |
| 269 | 269 | return array($cat_id, $variant, $count); |
| 270 | 270 | } |
@@ -275,9 +275,9 @@ discard block |
||
| 275 | 275 | */ |
| 276 | 276 | private function updateCatalogueTime($cat_id, $variant) |
| 277 | 277 | { |
| 278 | - $time = time(); |
|
| 278 | + $time=time(); |
|
| 279 | 279 | |
| 280 | - $result = mysql_query("UPDATE catalogue |
|
| 280 | + $result=mysql_query("UPDATE catalogue |
|
| 281 | 281 | SET date_modified = {$time} |
| 282 | 282 | WHERE cat_id = {$cat_id}", $this->db); |
| 283 | 283 | |
@@ -296,27 +296,27 @@ discard block |
||
| 296 | 296 | */ |
| 297 | 297 | function save($catalogue='messages') |
| 298 | 298 | { |
| 299 | - $messages = $this->untranslated; |
|
| 299 | + $messages=$this->untranslated; |
|
| 300 | 300 | |
| 301 | 301 | if(count($messages) <= 0) return false; |
| 302 | 302 | |
| 303 | - $details = $this->getCatalogueDetails($catalogue); |
|
| 303 | + $details=$this->getCatalogueDetails($catalogue); |
|
| 304 | 304 | |
| 305 | 305 | if($details) |
| 306 | - list($cat_id, $variant, $count) = $details; |
|
| 306 | + list($cat_id, $variant, $count)=$details; |
|
| 307 | 307 | else |
| 308 | 308 | return false; |
| 309 | 309 | |
| 310 | 310 | if($cat_id <= 0) return false; |
| 311 | - $inserted = 0; |
|
| 311 | + $inserted=0; |
|
| 312 | 312 | |
| 313 | - $time = time(); |
|
| 313 | + $time=time(); |
|
| 314 | 314 | |
| 315 | 315 | foreach($messages as $message) |
| 316 | 316 | { |
| 317 | 317 | $count++; $inserted++; |
| 318 | - $message = mysql_real_escape_string($message); |
|
| 319 | - $statement = "INSERT INTO trans_unit |
|
| 318 | + $message=mysql_real_escape_string($message); |
|
| 319 | + $statement="INSERT INTO trans_unit |
|
| 320 | 320 | (cat_id,id,source,date_added) VALUES |
| 321 | 321 | ({$cat_id}, {$count},'{$message}',$time)"; |
| 322 | 322 | mysql_query($statement, $this->db); |
@@ -335,22 +335,22 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | function delete($message, $catalogue='messages') |
| 337 | 337 | { |
| 338 | - $details = $this->getCatalogueDetails($catalogue); |
|
| 338 | + $details=$this->getCatalogueDetails($catalogue); |
|
| 339 | 339 | if($details) |
| 340 | - list($cat_id, $variant, $count) = $details; |
|
| 340 | + list($cat_id, $variant, $count)=$details; |
|
| 341 | 341 | else |
| 342 | 342 | return false; |
| 343 | 343 | |
| 344 | - $text = mysql_real_escape_string($message); |
|
| 344 | + $text=mysql_real_escape_string($message); |
|
| 345 | 345 | |
| 346 | - $statement = "DELETE FROM trans_unit WHERE |
|
| 346 | + $statement="DELETE FROM trans_unit WHERE |
|
| 347 | 347 | cat_id = {$cat_id} AND source = '{$message}'"; |
| 348 | - $deleted = false; |
|
| 348 | + $deleted=false; |
|
| 349 | 349 | |
| 350 | 350 | mysql_query($statement, $this->db); |
| 351 | 351 | |
| 352 | - if(mysql_affected_rows($this->db) == 1) |
|
| 353 | - $deleted = $this->updateCatalogueTime($cat_id, $variant); |
|
| 352 | + if(mysql_affected_rows($this->db)==1) |
|
| 353 | + $deleted=$this->updateCatalogueTime($cat_id, $variant); |
|
| 354 | 354 | |
| 355 | 355 | return $deleted; |
| 356 | 356 | |
@@ -366,30 +366,30 @@ discard block |
||
| 366 | 366 | */ |
| 367 | 367 | function update($text, $target, $comments, $catalogue='messages') |
| 368 | 368 | { |
| 369 | - $details = $this->getCatalogueDetails($catalogue); |
|
| 369 | + $details=$this->getCatalogueDetails($catalogue); |
|
| 370 | 370 | if($details) |
| 371 | - list($cat_id, $variant, $count) = $details; |
|
| 371 | + list($cat_id, $variant, $count)=$details; |
|
| 372 | 372 | else |
| 373 | 373 | return false; |
| 374 | 374 | |
| 375 | - $comments = mysql_real_escape_string($comments); |
|
| 376 | - $target = mysql_real_escape_string($target); |
|
| 377 | - $text = mysql_real_escape_string($text); |
|
| 375 | + $comments=mysql_real_escape_string($comments); |
|
| 376 | + $target=mysql_real_escape_string($target); |
|
| 377 | + $text=mysql_real_escape_string($text); |
|
| 378 | 378 | |
| 379 | - $time = time(); |
|
| 379 | + $time=time(); |
|
| 380 | 380 | |
| 381 | - $statement = "UPDATE trans_unit SET |
|
| 381 | + $statement="UPDATE trans_unit SET |
|
| 382 | 382 | target = '{$target}', |
| 383 | 383 | comments = '{$comments}', |
| 384 | 384 | date_modified = '{$time}' |
| 385 | 385 | WHERE cat_id = {$cat_id} |
| 386 | 386 | AND source = '{$text}'"; |
| 387 | 387 | |
| 388 | - $updated = false; |
|
| 388 | + $updated=false; |
|
| 389 | 389 | |
| 390 | 390 | mysql_query($statement, $this->db); |
| 391 | - if(mysql_affected_rows($this->db) == 1) |
|
| 392 | - $updated = $this->updateCatalogueTime($cat_id, $variant); |
|
| 391 | + if(mysql_affected_rows($this->db)==1) |
|
| 392 | + $updated=$this->updateCatalogueTime($cat_id, $variant); |
|
| 393 | 393 | |
| 394 | 394 | return $updated; |
| 395 | 395 | } |
@@ -400,15 +400,15 @@ discard block |
||
| 400 | 400 | */ |
| 401 | 401 | function catalogues() |
| 402 | 402 | { |
| 403 | - $statement = 'SELECT name FROM catalogue ORDER BY name'; |
|
| 404 | - $rs = mysql_query($statement, $this->db); |
|
| 405 | - $result = array(); |
|
| 406 | - while($row = mysql_fetch_array($rs,MYSQL_NUM)) |
|
| 403 | + $statement='SELECT name FROM catalogue ORDER BY name'; |
|
| 404 | + $rs=mysql_query($statement, $this->db); |
|
| 405 | + $result=array(); |
|
| 406 | + while($row=mysql_fetch_array($rs, MYSQL_NUM)) |
|
| 407 | 407 | { |
| 408 | - $details = explode('.',$row[0]); |
|
| 409 | - if(!isset($details[1])) $details[1] = null; |
|
| 408 | + $details=explode('.', $row[0]); |
|
| 409 | + if(!isset($details[1])) $details[1]=null; |
|
| 410 | 410 | |
| 411 | - $result[] = $details; |
|
| 411 | + $result[]=$details; |
|
| 412 | 412 | } |
| 413 | 413 | return $result; |
| 414 | 414 | } |