r36466 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36465‎ | r36466 | r36467 >
Date:16:14, 19 June 2008
Author:minuteelectron
Status:old
Tags:
Comment:
* Correct fix, remove if that should have been replaced.
Modified paths:
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/Language.php
@@ -574,227 +574,225 @@
575575 $code .= $format[++$p];
576576 }
577577
578 - if ( ( $code === 'xi' || $code == 'xj' || $code == 'xk' ) && $p < strlen( $format ) - 1 ) {
579 - if ( ( $code === 'xi' || $code == 'xj' || $code == 'xk' || $code == 'xm' ) && $p < strlen( $format ) - 1 ) {
580 - $code .= $format[++$p];
581 - }
 578+ if ( ( $code === 'xi' || $code == 'xj' || $code == 'xk' || $code == 'xm' ) && $p < strlen( $format ) - 1 ) {
 579+ $code .= $format[++$p];
 580+ }
582581
583 - switch ( $code ) {
584 - case 'xx':
585 - $s .= 'x';
586 - break;
587 - case 'xn':
588 - $raw = true;
589 - break;
590 - case 'xN':
591 - $rawToggle = !$rawToggle;
592 - break;
593 - case 'xr':
594 - $roman = true;
595 - break;
596 - case 'xh':
597 - $hebrewNum = true;
598 - break;
599 - case 'xg':
600 - $s .= $this->getMonthNameGen( substr( $ts, 4, 2 ) );
601 - break;
602 - case 'xjx':
603 - if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
604 - $s .= $this->getHebrewCalendarMonthNameGen( $hebrew[1] );
605 - break;
606 - case 'd':
607 - $num = substr( $ts, 6, 2 );
608 - break;
609 - case 'D':
610 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
611 - $s .= $this->getWeekdayAbbreviation( gmdate( 'w', $unix ) + 1 );
612 - break;
613 - case 'j':
614 - $num = intval( substr( $ts, 6, 2 ) );
615 - break;
616 - case 'xij':
617 - if ( !$iranian ) $iranian = self::tsToIranian( $ts );
618 - $num = $iranian[2];
619 - break;
620 - case 'xmj':
621 - if ( !$hijri ) $hijri = self::tsToHijri( $ts );
622 - $num = $hijri[2];
623 - break;
624 - case 'xjj':
625 - if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
626 - $num = $hebrew[2];
627 - break;
628 - case 'l':
629 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
630 - $s .= $this->getWeekdayName( gmdate( 'w', $unix ) + 1 );
631 - break;
632 - case 'N':
633 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
634 - $w = gmdate( 'w', $unix );
635 - $num = $w ? $w : 7;
636 - break;
637 - case 'w':
638 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
639 - $num = gmdate( 'w', $unix );
640 - break;
641 - case 'z':
642 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
643 - $num = gmdate( 'z', $unix );
644 - break;
645 - case 'W':
646 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
647 - $num = gmdate( 'W', $unix );
648 - break;
649 - case 'F':
650 - $s .= $this->getMonthName( substr( $ts, 4, 2 ) );
651 - break;
652 - case 'xiF':
653 - if ( !$iranian ) $iranian = self::tsToIranian( $ts );
654 - $s .= $this->getIranianCalendarMonthName( $iranian[1] );
655 - break;
656 - case 'xmF':
657 - if ( !$hijri ) $hijri = self::tsToHijri( $ts );
658 - $s .= $this->getHijriCalendarMonthName( $hijri[1] );
659 - break;
660 - case 'xjF':
661 - if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
662 - $s .= $this->getHebrewCalendarMonthName( $hebrew[1] );
663 - break;
664 - case 'm':
665 - $num = substr( $ts, 4, 2 );
666 - break;
667 - case 'M':
668 - $s .= $this->getMonthAbbreviation( substr( $ts, 4, 2 ) );
669 - break;
670 - case 'n':
671 - $num = intval( substr( $ts, 4, 2 ) );
672 - break;
673 - case 'xin':
674 - if ( !$iranian ) $iranian = self::tsToIranian( $ts );
675 - $num = $iranian[1];
676 - break;
677 - case 'xmn':
678 - if ( !$hijri ) $hijri = self::tsToHijri ( $ts );
679 - $num = $hijri[1];
680 - break;
681 - case 'xjn':
682 - if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
683 - $num = $hebrew[1];
684 - break;
685 - case 't':
686 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
687 - $num = gmdate( 't', $unix );
688 - break;
689 - case 'xjt':
690 - if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
691 - $num = $hebrew[3];
692 - break;
693 - case 'L':
694 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
695 - $num = gmdate( 'L', $unix );
696 - break;
697 - case 'Y':
698 - $num = substr( $ts, 0, 4 );
699 - break;
700 - case 'xiY':
701 - if ( !$iranian ) $iranian = self::tsToIranian( $ts );
702 - $num = $iranian[0];
703 - break;
704 - case 'xmY':
705 - if ( !$hijri ) $hijri = self::tsToHijri( $ts );
706 - $num = $hijri[0];
707 - break;
708 - case 'xjY':
709 - if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
710 - $num = $hebrew[0];
711 - break;
712 - case 'xkY':
713 - if ( !$thai ) $thai = self::tsToThai( $ts );
714 - $num = $thai[0];
715 - break;
716 - case 'y':
717 - $num = substr( $ts, 2, 2 );
718 - break;
719 - case 'a':
720 - $s .= intval( substr( $ts, 8, 2 ) ) < 12 ? 'am' : 'pm';
721 - break;
722 - case 'A':
723 - $s .= intval( substr( $ts, 8, 2 ) ) < 12 ? 'AM' : 'PM';
724 - break;
725 - case 'g':
726 - $h = substr( $ts, 8, 2 );
727 - $num = $h % 12 ? $h % 12 : 12;
728 - break;
729 - case 'G':
730 - $num = intval( substr( $ts, 8, 2 ) );
731 - break;
732 - case 'h':
733 - $h = substr( $ts, 8, 2 );
734 - $num = sprintf( '%02d', $h % 12 ? $h % 12 : 12 );
735 - break;
736 - case 'H':
737 - $num = substr( $ts, 8, 2 );
738 - break;
739 - case 'i':
740 - $num = substr( $ts, 10, 2 );
741 - break;
742 - case 's':
743 - $num = substr( $ts, 12, 2 );
744 - break;
745 - case 'c':
746 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
747 - $s .= gmdate( 'c', $unix );
748 - break;
749 - case 'r':
750 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
751 - $s .= gmdate( 'r', $unix );
752 - break;
753 - case 'U':
754 - if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
755 - $num = $unix;
756 - break;
757 - case '\\':
758 - # Backslash escaping
759 - if ( $p < strlen( $format ) - 1 ) {
760 - $s .= $format[++$p];
 582+ switch ( $code ) {
 583+ case 'xx':
 584+ $s .= 'x';
 585+ break;
 586+ case 'xn':
 587+ $raw = true;
 588+ break;
 589+ case 'xN':
 590+ $rawToggle = !$rawToggle;
 591+ break;
 592+ case 'xr':
 593+ $roman = true;
 594+ break;
 595+ case 'xh':
 596+ $hebrewNum = true;
 597+ break;
 598+ case 'xg':
 599+ $s .= $this->getMonthNameGen( substr( $ts, 4, 2 ) );
 600+ break;
 601+ case 'xjx':
 602+ if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
 603+ $s .= $this->getHebrewCalendarMonthNameGen( $hebrew[1] );
 604+ break;
 605+ case 'd':
 606+ $num = substr( $ts, 6, 2 );
 607+ break;
 608+ case 'D':
 609+ if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 610+ $s .= $this->getWeekdayAbbreviation( gmdate( 'w', $unix ) + 1 );
 611+ break;
 612+ case 'j':
 613+ $num = intval( substr( $ts, 6, 2 ) );
 614+ break;
 615+ case 'xij':
 616+ if ( !$iranian ) $iranian = self::tsToIranian( $ts );
 617+ $num = $iranian[2];
 618+ break;
 619+ case 'xmj':
 620+ if ( !$hijri ) $hijri = self::tsToHijri( $ts );
 621+ $num = $hijri[2];
 622+ break;
 623+ case 'xjj':
 624+ if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
 625+ $num = $hebrew[2];
 626+ break;
 627+ case 'l':
 628+ if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 629+ $s .= $this->getWeekdayName( gmdate( 'w', $unix ) + 1 );
 630+ break;
 631+ case 'N':
 632+ if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 633+ $w = gmdate( 'w', $unix );
 634+ $num = $w ? $w : 7;
 635+ break;
 636+ case 'w':
 637+ if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 638+ $num = gmdate( 'w', $unix );
 639+ break;
 640+ case 'z':
 641+ if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 642+ $num = gmdate( 'z', $unix );
 643+ break;
 644+ case 'W':
 645+ if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 646+ $num = gmdate( 'W', $unix );
 647+ break;
 648+ case 'F':
 649+ $s .= $this->getMonthName( substr( $ts, 4, 2 ) );
 650+ break;
 651+ case 'xiF':
 652+ if ( !$iranian ) $iranian = self::tsToIranian( $ts );
 653+ $s .= $this->getIranianCalendarMonthName( $iranian[1] );
 654+ break;
 655+ case 'xmF':
 656+ if ( !$hijri ) $hijri = self::tsToHijri( $ts );
 657+ $s .= $this->getHijriCalendarMonthName( $hijri[1] );
 658+ break;
 659+ case 'xjF':
 660+ if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
 661+ $s .= $this->getHebrewCalendarMonthName( $hebrew[1] );
 662+ break;
 663+ case 'm':
 664+ $num = substr( $ts, 4, 2 );
 665+ break;
 666+ case 'M':
 667+ $s .= $this->getMonthAbbreviation( substr( $ts, 4, 2 ) );
 668+ break;
 669+ case 'n':
 670+ $num = intval( substr( $ts, 4, 2 ) );
 671+ break;
 672+ case 'xin':
 673+ if ( !$iranian ) $iranian = self::tsToIranian( $ts );
 674+ $num = $iranian[1];
 675+ break;
 676+ case 'xmn':
 677+ if ( !$hijri ) $hijri = self::tsToHijri ( $ts );
 678+ $num = $hijri[1];
 679+ break;
 680+ case 'xjn':
 681+ if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
 682+ $num = $hebrew[1];
 683+ break;
 684+ case 't':
 685+ if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 686+ $num = gmdate( 't', $unix );
 687+ break;
 688+ case 'xjt':
 689+ if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
 690+ $num = $hebrew[3];
 691+ break;
 692+ case 'L':
 693+ if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 694+ $num = gmdate( 'L', $unix );
 695+ break;
 696+ case 'Y':
 697+ $num = substr( $ts, 0, 4 );
 698+ break;
 699+ case 'xiY':
 700+ if ( !$iranian ) $iranian = self::tsToIranian( $ts );
 701+ $num = $iranian[0];
 702+ break;
 703+ case 'xmY':
 704+ if ( !$hijri ) $hijri = self::tsToHijri( $ts );
 705+ $num = $hijri[0];
 706+ break;
 707+ case 'xjY':
 708+ if ( !$hebrew ) $hebrew = self::tsToHebrew( $ts );
 709+ $num = $hebrew[0];
 710+ break;
 711+ case 'xkY':
 712+ if ( !$thai ) $thai = self::tsToThai( $ts );
 713+ $num = $thai[0];
 714+ break;
 715+ case 'y':
 716+ $num = substr( $ts, 2, 2 );
 717+ break;
 718+ case 'a':
 719+ $s .= intval( substr( $ts, 8, 2 ) ) < 12 ? 'am' : 'pm';
 720+ break;
 721+ case 'A':
 722+ $s .= intval( substr( $ts, 8, 2 ) ) < 12 ? 'AM' : 'PM';
 723+ break;
 724+ case 'g':
 725+ $h = substr( $ts, 8, 2 );
 726+ $num = $h % 12 ? $h % 12 : 12;
 727+ break;
 728+ case 'G':
 729+ $num = intval( substr( $ts, 8, 2 ) );
 730+ break;
 731+ case 'h':
 732+ $h = substr( $ts, 8, 2 );
 733+ $num = sprintf( '%02d', $h % 12 ? $h % 12 : 12 );
 734+ break;
 735+ case 'H':
 736+ $num = substr( $ts, 8, 2 );
 737+ break;
 738+ case 'i':
 739+ $num = substr( $ts, 10, 2 );
 740+ break;
 741+ case 's':
 742+ $num = substr( $ts, 12, 2 );
 743+ break;
 744+ case 'c':
 745+ if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 746+ $s .= gmdate( 'c', $unix );
 747+ break;
 748+ case 'r':
 749+ if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 750+ $s .= gmdate( 'r', $unix );
 751+ break;
 752+ case 'U':
 753+ if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
 754+ $num = $unix;
 755+ break;
 756+ case '\\':
 757+ # Backslash escaping
 758+ if ( $p < strlen( $format ) - 1 ) {
 759+ $s .= $format[++$p];
 760+ } else {
 761+ $s .= '\\';
 762+ }
 763+ break;
 764+ case '"':
 765+ # Quoted literal
 766+ if ( $p < strlen( $format ) - 1 ) {
 767+ $endQuote = strpos( $format, '"', $p + 1 );
 768+ if ( $endQuote === false ) {
 769+ # No terminating quote, assume literal "
 770+ $s .= '"';
761771 } else {
762 - $s .= '\\';
 772+ $s .= substr( $format, $p + 1, $endQuote - $p - 1 );
 773+ $p = $endQuote;
763774 }
764 - break;
765 - case '"':
766 - # Quoted literal
767 - if ( $p < strlen( $format ) - 1 ) {
768 - $endQuote = strpos( $format, '"', $p + 1 );
769 - if ( $endQuote === false ) {
770 - # No terminating quote, assume literal "
771 - $s .= '"';
772 - } else {
773 - $s .= substr( $format, $p + 1, $endQuote - $p - 1 );
774 - $p = $endQuote;
775 - }
776 - } else {
777 - # Quote at end of string, assume literal "
778 - $s .= '"';
779 - }
780 - break;
781 - default:
782 - $s .= $format[$p];
783 - }
784 - if ( $num !== false ) {
785 - if ( $rawToggle || $raw ) {
786 - $s .= $num;
787 - $raw = false;
788 - } elseif ( $roman ) {
789 - $s .= self::romanNumeral( $num );
790 - $roman = false;
791 - } elseif( $hebrewNum ) {
792 - $s .= self::hebrewNumeral( $num );
793 - $hebrewNum = false;
794775 } else {
795 - $s .= $this->formatNum( $num, true );
 776+ # Quote at end of string, assume literal "
 777+ $s .= '"';
796778 }
797 - $num = false;
 779+ break;
 780+ default:
 781+ $s .= $format[$p];
 782+ }
 783+ if ( $num !== false ) {
 784+ if ( $rawToggle || $raw ) {
 785+ $s .= $num;
 786+ $raw = false;
 787+ } elseif ( $roman ) {
 788+ $s .= self::romanNumeral( $num );
 789+ $roman = false;
 790+ } elseif( $hebrewNum ) {
 791+ $s .= self::hebrewNumeral( $num );
 792+ $hebrewNum = false;
 793+ } else {
 794+ $s .= $this->formatNum( $num, true );
798795 }
 796+ $num = false;
799797 }
800798 }
801799 return $s;

Status & tagging log