Index: trunk/phase3/includes/UserMailer.php |
— | — | @@ -158,7 +158,7 @@ |
159 | 159 | global $wgEnotifMaxRecips, $wgAdditionalMailParams; |
160 | 160 | |
161 | 161 | $emails = ''; |
162 | | - wfDebug( __METHOD__ . ': sending mail to ' . implode( ',', array( $to->toString() ) ) . "\n" ); |
| 162 | + wfDebug( __METHOD__ . ': sending mail to ' . is_array( $to ) ? implode( ', ', $to ) : $to . "\n" ); |
163 | 163 | |
164 | 164 | $headers['From'] = $from->toString(); |
165 | 165 | $headers['Return-Path'] = $from->toString(); |
— | — | @@ -571,8 +571,14 @@ |
572 | 572 | $keys = array(); |
573 | 573 | |
574 | 574 | if ( $this->oldid ) { |
575 | | - $difflink = $this->title->getCanonicalUrl( 'diff=0&oldid=' . $this->oldid ); |
576 | | - $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastvisited', $difflink ); |
| 575 | + if ( $wgEnotifImpersonal ) { |
| 576 | + // For impersonal mail, show a diff link to the last revision. |
| 577 | + $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastdiff', |
| 578 | + $this->title->getCanonicalUrl( 'diff=next&oldid=' . $this->oldid ) ); |
| 579 | + } else { |
| 580 | + $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastvisited', |
| 581 | + $this->title->getCanonicalUrl( 'diff=0&oldid=' . $this->oldid ) ); |
| 582 | + } |
577 | 583 | $keys['$OLDID'] = $this->oldid; |
578 | 584 | $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'changed' ); |
579 | 585 | } else { |
— | — | @@ -582,15 +588,6 @@ |
583 | 589 | $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'created' ); |
584 | 590 | } |
585 | 591 | |
586 | | - if ( $wgEnotifImpersonal && $this->oldid ) { |
587 | | - /** |
588 | | - * For impersonal mail, show a diff link to the last |
589 | | - * revision. |
590 | | - */ |
591 | | - $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastdiff', |
592 | | - $this->title->getCanonicalUrl( "oldid={$this->oldid}&diff=next" ) ); |
593 | | - } |
594 | | - |
595 | 592 | $body = strtr( $body, $keys ); |
596 | 593 | $pagetitle = $this->title->getPrefixedText(); |
597 | 594 | $keys['$PAGETITLE'] = $pagetitle; |
— | — | @@ -691,22 +688,18 @@ |
692 | 689 | // Note: The to parameter cannot be an address in the form of "Something <someone@example.com>". |
693 | 690 | // The mail command will not parse this properly while talking with the MTA. |
694 | 691 | $to = new MailAddress( $watchingUser ); |
695 | | - $name = $wgEnotifUseRealName ? $watchingUser->getRealName() : $watchingUser->getName(); |
696 | | - $body = str_replace( '$WATCHINGUSERNAME', $name, $this->body ); |
697 | 692 | |
698 | | - $timecorrection = $watchingUser->getOption( 'timecorrection' ); |
699 | | - |
700 | 693 | # $PAGEEDITDATE is the time and date of the page change |
701 | 694 | # expressed in terms of individual local time of the notification |
702 | 695 | # recipient, i.e. watching user |
703 | 696 | $body = str_replace( |
704 | | - array( '$PAGEEDITDATEANDTIME', |
| 697 | + array( '$WATCHINGUSERNAME', |
705 | 698 | '$PAGEEDITDATE', |
706 | 699 | '$PAGEEDITTIME' ), |
707 | | - array( $wgContLang->timeanddate( $this->timestamp, true, false, $timecorrection ), |
708 | | - $wgContLang->date( $this->timestamp, true, false, $timecorrection ), |
709 | | - $wgContLang->time( $this->timestamp, true, false, $timecorrection ) ), |
710 | | - $body ); |
| 700 | + array( $wgEnotifUseRealName ? $watchingUser->getRealName() : $watchingUser->getName(), |
| 701 | + $wgContLang->userDate( $this->timestamp, $watchingUser ), |
| 702 | + $wgContLang->userTime( $this->timestamp, $watchingUser ) ), |
| 703 | + $this->body ); |
711 | 704 | |
712 | 705 | return UserMailer::send( $to, $this->from, $this->subject, $body, $this->replyto ); |
713 | 706 | } |
— | — | @@ -726,8 +719,8 @@ |
727 | 720 | '$PAGEEDITDATE', |
728 | 721 | '$PAGEEDITTIME' ), |
729 | 722 | array( wfMsgForContent( 'enotif_impersonal_salutation' ), |
730 | | - $wgContLang->date( $this->timestamp, true, false, false ), |
731 | | - $wgContLang->time( $this->timestamp, true, false, false ) ), |
| 723 | + $wgContLang->date( $this->timestamp, false, false ), |
| 724 | + $wgContLang->time( $this->timestamp, false, false ) ), |
732 | 725 | $this->body ); |
733 | 726 | |
734 | 727 | return UserMailer::send( $addresses, $this->from, $this->subject, $body, $this->replyto ); |
Index: trunk/phase3/includes/Preferences.php |
— | — | @@ -494,6 +494,7 @@ |
495 | 495 | $selectedSkin = $user->getOption( 'skin' ); |
496 | 496 | if ( in_array( $selectedSkin, array( 'cologneblue', 'standard' ) ) ) { |
497 | 497 | $settings = array_flip( $context->getLang()->getQuickbarSettings() ); |
| 498 | + |
498 | 499 | $defaultPreferences['quickbar'] = array( |
499 | 500 | 'type' => 'radio', |
500 | 501 | 'options' => $settings, |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -806,82 +806,6 @@ |
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
810 | | - * Used by date() and time() to adjust the time output. |
811 | | - * |
812 | | - * @param $ts Int the time in date('YmdHis') format |
813 | | - * @param $tz Mixed: adjust the time by this amount (default false, mean we |
814 | | - * get user timecorrection setting) |
815 | | - * @return int |
816 | | - */ |
817 | | - function userAdjust( $ts, $tz = false ) { |
818 | | - global $wgUser, $wgLocalTZoffset; |
819 | | - |
820 | | - if ( $tz === false ) { |
821 | | - $tz = $wgUser->getOption( 'timecorrection' ); |
822 | | - } |
823 | | - |
824 | | - $data = explode( '|', $tz, 3 ); |
825 | | - |
826 | | - if ( $data[0] == 'ZoneInfo' ) { |
827 | | - wfSuppressWarnings(); |
828 | | - $userTZ = timezone_open( $data[2] ); |
829 | | - wfRestoreWarnings(); |
830 | | - if ( $userTZ !== false ) { |
831 | | - $date = date_create( $ts, timezone_open( 'UTC' ) ); |
832 | | - date_timezone_set( $date, $userTZ ); |
833 | | - $date = date_format( $date, 'YmdHis' ); |
834 | | - return $date; |
835 | | - } |
836 | | - # Unrecognized timezone, default to 'Offset' with the stored offset. |
837 | | - $data[0] = 'Offset'; |
838 | | - } |
839 | | - |
840 | | - $minDiff = 0; |
841 | | - if ( $data[0] == 'System' || $tz == '' ) { |
842 | | - # Global offset in minutes. |
843 | | - if ( isset( $wgLocalTZoffset ) ) { |
844 | | - $minDiff = $wgLocalTZoffset; |
845 | | - } |
846 | | - } elseif ( $data[0] == 'Offset' ) { |
847 | | - $minDiff = intval( $data[1] ); |
848 | | - } else { |
849 | | - $data = explode( ':', $tz ); |
850 | | - if ( count( $data ) == 2 ) { |
851 | | - $data[0] = intval( $data[0] ); |
852 | | - $data[1] = intval( $data[1] ); |
853 | | - $minDiff = abs( $data[0] ) * 60 + $data[1]; |
854 | | - if ( $data[0] < 0 ) { |
855 | | - $minDiff = -$minDiff; |
856 | | - } |
857 | | - } else { |
858 | | - $minDiff = intval( $data[0] ) * 60; |
859 | | - } |
860 | | - } |
861 | | - |
862 | | - # No difference ? Return time unchanged |
863 | | - if ( 0 == $minDiff ) { |
864 | | - return $ts; |
865 | | - } |
866 | | - |
867 | | - wfSuppressWarnings(); // E_STRICT system time bitching |
868 | | - # Generate an adjusted date; take advantage of the fact that mktime |
869 | | - # will normalize out-of-range values so we don't have to split $minDiff |
870 | | - # into hours and minutes. |
871 | | - $t = mktime( ( |
872 | | - (int)substr( $ts, 8, 2 ) ), # Hours |
873 | | - (int)substr( $ts, 10, 2 ) + $minDiff, # Minutes |
874 | | - (int)substr( $ts, 12, 2 ), # Seconds |
875 | | - (int)substr( $ts, 4, 2 ), # Month |
876 | | - (int)substr( $ts, 6, 2 ), # Day |
877 | | - (int)substr( $ts, 0, 4 ) ); # Year |
878 | | - |
879 | | - $date = date( 'YmdHis', $t ); |
880 | | - wfRestoreWarnings(); |
881 | | - |
882 | | - return $date; |
883 | | - } |
884 | | - |
885 | | - /** |
886 | 810 | * This is a workalike of PHP's date() function, but with better |
887 | 811 | * internationalisation, a reduced set of format characters, and a better |
888 | 812 | * escaping format. |
— | — | @@ -1720,6 +1644,82 @@ |
1721 | 1645 | } |
1722 | 1646 | |
1723 | 1647 | /** |
| 1648 | + * Used by date() and time() to adjust the time output. |
| 1649 | + * |
| 1650 | + * @param $ts Int the time in date('YmdHis') format |
| 1651 | + * @param $tz Mixed: adjust the time by this amount (default false, mean we |
| 1652 | + * get user timecorrection setting) |
| 1653 | + * @return int |
| 1654 | + */ |
| 1655 | + function userAdjust( $ts, $tz = false ) { |
| 1656 | + global $wgUser, $wgLocalTZoffset; |
| 1657 | + |
| 1658 | + if ( $tz === false ) { |
| 1659 | + $tz = $wgUser->getOption( 'timecorrection' ); |
| 1660 | + } |
| 1661 | + |
| 1662 | + $data = explode( '|', $tz, 3 ); |
| 1663 | + |
| 1664 | + if ( $data[0] == 'ZoneInfo' ) { |
| 1665 | + wfSuppressWarnings(); |
| 1666 | + $userTZ = timezone_open( $data[2] ); |
| 1667 | + wfRestoreWarnings(); |
| 1668 | + if ( $userTZ !== false ) { |
| 1669 | + $date = date_create( $ts, timezone_open( 'UTC' ) ); |
| 1670 | + date_timezone_set( $date, $userTZ ); |
| 1671 | + $date = date_format( $date, 'YmdHis' ); |
| 1672 | + return $date; |
| 1673 | + } |
| 1674 | + # Unrecognized timezone, default to 'Offset' with the stored offset. |
| 1675 | + $data[0] = 'Offset'; |
| 1676 | + } |
| 1677 | + |
| 1678 | + $minDiff = 0; |
| 1679 | + if ( $data[0] == 'System' || $tz == '' ) { |
| 1680 | + # Global offset in minutes. |
| 1681 | + if ( isset( $wgLocalTZoffset ) ) { |
| 1682 | + $minDiff = $wgLocalTZoffset; |
| 1683 | + } |
| 1684 | + } elseif ( $data[0] == 'Offset' ) { |
| 1685 | + $minDiff = intval( $data[1] ); |
| 1686 | + } else { |
| 1687 | + $data = explode( ':', $tz ); |
| 1688 | + if ( count( $data ) == 2 ) { |
| 1689 | + $data[0] = intval( $data[0] ); |
| 1690 | + $data[1] = intval( $data[1] ); |
| 1691 | + $minDiff = abs( $data[0] ) * 60 + $data[1]; |
| 1692 | + if ( $data[0] < 0 ) { |
| 1693 | + $minDiff = -$minDiff; |
| 1694 | + } |
| 1695 | + } else { |
| 1696 | + $minDiff = intval( $data[0] ) * 60; |
| 1697 | + } |
| 1698 | + } |
| 1699 | + |
| 1700 | + # No difference ? Return time unchanged |
| 1701 | + if ( 0 == $minDiff ) { |
| 1702 | + return $ts; |
| 1703 | + } |
| 1704 | + |
| 1705 | + wfSuppressWarnings(); // E_STRICT system time bitching |
| 1706 | + # Generate an adjusted date; take advantage of the fact that mktime |
| 1707 | + # will normalize out-of-range values so we don't have to split $minDiff |
| 1708 | + # into hours and minutes. |
| 1709 | + $t = mktime( ( |
| 1710 | + (int)substr( $ts, 8, 2 ) ), # Hours |
| 1711 | + (int)substr( $ts, 10, 2 ) + $minDiff, # Minutes |
| 1712 | + (int)substr( $ts, 12, 2 ), # Seconds |
| 1713 | + (int)substr( $ts, 4, 2 ), # Month |
| 1714 | + (int)substr( $ts, 6, 2 ), # Day |
| 1715 | + (int)substr( $ts, 0, 4 ) ); # Year |
| 1716 | + |
| 1717 | + $date = date( 'YmdHis', $t ); |
| 1718 | + wfRestoreWarnings(); |
| 1719 | + |
| 1720 | + return $date; |
| 1721 | + } |
| 1722 | + |
| 1723 | + /** |
1724 | 1724 | * This is meant to be used by time(), date(), and timeanddate() to get |
1725 | 1725 | * the date preference they're supposed to use, it should be used in |
1726 | 1726 | * all children. |
— | — | @@ -1840,6 +1840,113 @@ |
1841 | 1841 | } |
1842 | 1842 | |
1843 | 1843 | /** |
| 1844 | + * Internal helper function for userDate(), userTime() and userTimeAndDate() |
| 1845 | + * |
| 1846 | + * @param $type String: can be 'date', 'time' or 'both' |
| 1847 | + * @param $ts Mixed: the time format which needs to be turned into a |
| 1848 | + * date('YmdHis') format with wfTimestamp(TS_MW,$ts) |
| 1849 | + * @param $user User object used to get preferences for timezone and format |
| 1850 | + * @param $options Array, can contain the following keys: |
| 1851 | + * - 'timecorrection': time correction, can have the following values: |
| 1852 | + * - true: use user's preference |
| 1853 | + * - false: don't use time correction |
| 1854 | + * - integer: value of time correction in minutes |
| 1855 | + * - 'format': format to use, can have the following values: |
| 1856 | + * - true: use user's preference |
| 1857 | + * - false: use default preference |
| 1858 | + * - string: format to use |
| 1859 | + * @return String |
| 1860 | + */ |
| 1861 | + private function internalUserTimeAndDate( $type, $ts, User $user, array $options ) { |
| 1862 | + $ts = wfTimestamp( TS_MW, $ts ); |
| 1863 | + $options += array( 'timecorrection' => true, 'format' => true ); |
| 1864 | + if ( $options['timecorrection'] !== false ) { |
| 1865 | + if ( $options['timecorrection'] === true ) { |
| 1866 | + $offset = $user->getOption( 'timecorrection' ); |
| 1867 | + } else { |
| 1868 | + $offset = $options['timecorrection']; |
| 1869 | + } |
| 1870 | + $ts = $this->userAdjust( $ts, $offset ); |
| 1871 | + } |
| 1872 | + if ( $options['format'] === true ) { |
| 1873 | + $format = $user->getDatePreference(); |
| 1874 | + } else { |
| 1875 | + $format = $options['format']; |
| 1876 | + } |
| 1877 | + $df = $this->getDateFormatString( $type, $this->dateFormat( $format ) ); |
| 1878 | + return $this->sprintfDate( $df, $ts ); |
| 1879 | + } |
| 1880 | + |
| 1881 | + /** |
| 1882 | + * Get the formatted date for the given timestamp and formatted for |
| 1883 | + * the given user. |
| 1884 | + * |
| 1885 | + * @param $type String: can be 'date', 'time' or 'both' |
| 1886 | + * @param $ts Mixed: the time format which needs to be turned into a |
| 1887 | + * date('YmdHis') format with wfTimestamp(TS_MW,$ts) |
| 1888 | + * @param $user User object used to get preferences for timezone and format |
| 1889 | + * @param $options Array, can contain the following keys: |
| 1890 | + * - 'timecorrection': time correction, can have the following values: |
| 1891 | + * - true: use user's preference |
| 1892 | + * - false: don't use time correction |
| 1893 | + * - integer: value of time correction in minutes |
| 1894 | + * - 'format': format to use, can have the following values: |
| 1895 | + * - true: use user's preference |
| 1896 | + * - false: use default preference |
| 1897 | + * - string: format to use |
| 1898 | + * @return String |
| 1899 | + */ |
| 1900 | + public function userDate( $ts, User $user, array $options = array() ) { |
| 1901 | + return $this->internalUserTimeAndDate( 'date', $ts, $user, $options ); |
| 1902 | + } |
| 1903 | + |
| 1904 | + /** |
| 1905 | + * Get the formatted time for the given timestamp and formatted for |
| 1906 | + * the given user. |
| 1907 | + * |
| 1908 | + * @param $type String: can be 'date', 'time' or 'both' |
| 1909 | + * @param $ts Mixed: the time format which needs to be turned into a |
| 1910 | + * date('YmdHis') format with wfTimestamp(TS_MW,$ts) |
| 1911 | + * @param $user User object used to get preferences for timezone and format |
| 1912 | + * @param $options Array, can contain the following keys: |
| 1913 | + * - 'timecorrection': time correction, can have the following values: |
| 1914 | + * - true: use user's preference |
| 1915 | + * - false: don't use time correction |
| 1916 | + * - integer: value of time correction in minutes |
| 1917 | + * - 'format': format to use, can have the following values: |
| 1918 | + * - true: use user's preference |
| 1919 | + * - false: use default preference |
| 1920 | + * - string: format to use |
| 1921 | + * @return String |
| 1922 | + */ |
| 1923 | + public function userTime( $ts, User $user, array $options = array() ) { |
| 1924 | + return $this->internalUserTimeAndDate( 'time', $ts, $user, $options ); |
| 1925 | + } |
| 1926 | + |
| 1927 | + /** |
| 1928 | + * Get the formatted date and time for the given timestamp and formatted for |
| 1929 | + * the given user. |
| 1930 | + * |
| 1931 | + * @param $type String: can be 'date', 'time' or 'both' |
| 1932 | + * @param $ts Mixed: the time format which needs to be turned into a |
| 1933 | + * date('YmdHis') format with wfTimestamp(TS_MW,$ts) |
| 1934 | + * @param $user User object used to get preferences for timezone and format |
| 1935 | + * @param $options Array, can contain the following keys: |
| 1936 | + * - 'timecorrection': time correction, can have the following values: |
| 1937 | + * - true: use user's preference |
| 1938 | + * - false: don't use time correction |
| 1939 | + * - integer: value of time correction in minutes |
| 1940 | + * - 'format': format to use, can have the following values: |
| 1941 | + * - true: use user's preference |
| 1942 | + * - false: use default preference |
| 1943 | + * - string: format to use |
| 1944 | + * @return String |
| 1945 | + */ |
| 1946 | + public function userTimeAndDate( $ts, User $user, array $options = array() ) { |
| 1947 | + return $this->internalUserTimeAndDate( 'both', $ts, $user, $options ); |
| 1948 | + } |
| 1949 | + |
| 1950 | + /** |
1844 | 1951 | * @param $key string |
1845 | 1952 | * @return array|null |
1846 | 1953 | */ |