| Index: trunk/phase3/includes/api/ApiQueryInfo.php |
| — | — | @@ -397,6 +397,7 @@ |
| 398 | 398 | * Get information about protections and put it in $protections |
| 399 | 399 | */ |
| 400 | 400 | private function getProtectionInfo() { |
| | 401 | + global $wgContLang; |
| 401 | 402 | $this->protections = array(); |
| 402 | 403 | $db = $this->getDB(); |
| 403 | 404 | |
| — | — | @@ -415,7 +416,7 @@ |
| 416 | 417 | $a = array( |
| 417 | 418 | 'type' => $row->pr_type, |
| 418 | 419 | 'level' => $row->pr_level, |
| 419 | | - 'expiry' => Block::decodeExpiry( $row->pr_expiry, TS_ISO_8601 ) |
| | 420 | + 'expiry' => $wgContLang->formatExpiry( $row->pr_expiry, TS_ISO_8601 ) |
| 420 | 421 | ); |
| 421 | 422 | if ( $row->pr_cascade ) { |
| 422 | 423 | $a['cascade'] = ''; |
| — | — | @@ -472,7 +473,7 @@ |
| 473 | 474 | $this->protections[$row->pt_namespace][$row->pt_title][] = array( |
| 474 | 475 | 'type' => 'create', |
| 475 | 476 | 'level' => $row->pt_create_perm, |
| 476 | | - 'expiry' => Block::decodeExpiry( $row->pt_expiry, TS_ISO_8601 ) |
| | 477 | + 'expiry' => $wgContLang->formatExpiry( $row->pt_expiry, TS_ISO_8601 ) |
| 477 | 478 | ); |
| 478 | 479 | } |
| 479 | 480 | } |
| — | — | @@ -506,7 +507,7 @@ |
| 507 | 508 | $this->protections[$row->tl_namespace][$row->tl_title][] = array( |
| 508 | 509 | 'type' => $row->pr_type, |
| 509 | 510 | 'level' => $row->pr_level, |
| 510 | | - 'expiry' => Block::decodeExpiry( $row->pr_expiry, TS_ISO_8601 ), |
| | 511 | + 'expiry' => $wgContLang->formatExpiry( $row->pr_expiry, TS_ISO_8601 ), |
| 511 | 512 | 'source' => $source->getPrefixedText() |
| 512 | 513 | ); |
| 513 | 514 | } |
| — | — | @@ -529,7 +530,7 @@ |
| 530 | 531 | $this->protections[NS_FILE][$row->il_to][] = array( |
| 531 | 532 | 'type' => $row->pr_type, |
| 532 | 533 | 'level' => $row->pr_level, |
| 533 | | - 'expiry' => Block::decodeExpiry( $row->pr_expiry, TS_ISO_8601 ), |
| | 534 | + 'expiry' => $wgContLang->formatExpiry( $row->pr_expiry, TS_ISO_8601 ), |
| 534 | 535 | 'source' => $source->getPrefixedText() |
| 535 | 536 | ); |
| 536 | 537 | } |
| Index: trunk/phase3/includes/api/ApiQueryBlocks.php |
| — | — | @@ -46,7 +46,7 @@ |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function execute() { |
| 50 | | - global $wgUser; |
| | 50 | + global $wgUser, $wgContLang; |
| 51 | 51 | |
| 52 | 52 | $params = $this->extractRequestParams(); |
| 53 | 53 | if ( isset( $params['users'] ) && isset( $params['ip'] ) ) { |
| — | — | @@ -170,7 +170,7 @@ |
| 171 | 171 | $block['timestamp'] = wfTimestamp( TS_ISO_8601, $row->ipb_timestamp ); |
| 172 | 172 | } |
| 173 | 173 | if ( $fld_expiry ) { |
| 174 | | - $block['expiry'] = Block::decodeExpiry( $row->ipb_expiry, TS_ISO_8601 ); |
| | 174 | + $block['expiry'] = $wgContLang->formatExpiry( $row->ipb_expiry, TS_ISO_8601 ); |
| 175 | 175 | } |
| 176 | 176 | if ( $fld_reason ) { |
| 177 | 177 | $block['reason'] = $row->ipb_reason; |
| Index: trunk/phase3/includes/api/ApiQueryProtectedTitles.php |
| — | — | @@ -117,7 +117,8 @@ |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | if ( isset( $prop['expiry'] ) ) { |
| 121 | | - $vals['expiry'] = Block::decodeExpiry( $row->pt_expiry, TS_ISO_8601 ); |
| | 121 | + global $wgContLang; |
| | 122 | + $vals['expiry'] = $wgContLang->formatExpiry( $row->pt_expiry, TS_ISO_8601 ); |
| 122 | 123 | } |
| 123 | 124 | |
| 124 | 125 | if ( isset( $prop['level'] ) ) { |
| Index: trunk/phase3/includes/Title.php |
| — | — | @@ -1566,20 +1566,7 @@ |
| 1567 | 1567 | $blockExpiry = $user->mBlock->mExpiry; |
| 1568 | 1568 | $blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $user->mBlock->mTimestamp ), true ); |
| 1569 | 1569 | if ( $blockExpiry == 'infinity' ) { |
| 1570 | | - // Entry in database (table ipblocks) is 'infinity' but 'ipboptions' uses 'infinite' or 'indefinite' |
| 1571 | | - $scBlockExpiryOptions = wfMsg( 'ipboptions' ); |
| 1572 | | - |
| 1573 | | - foreach ( explode( ',', $scBlockExpiryOptions ) as $option ) { |
| 1574 | | - if ( !strpos( $option, ':' ) ) |
| 1575 | | - continue; |
| 1576 | | - |
| 1577 | | - list( $show, $value ) = explode( ':', $option ); |
| 1578 | | - |
| 1579 | | - if ( $value == 'infinite' || $value == 'indefinite' ) { |
| 1580 | | - $blockExpiry = $show; |
| 1581 | | - break; |
| 1582 | | - } |
| 1583 | | - } |
| | 1570 | + $blockExpiry = wfMessage( 'infiniteblock' ); |
| 1584 | 1571 | } else { |
| 1585 | 1572 | $blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true ); |
| 1586 | 1573 | } |
| — | — | @@ -1680,10 +1667,10 @@ |
| 1681 | 1668 | |
| 1682 | 1669 | $dbw = wfGetDB( DB_MASTER ); |
| 1683 | 1670 | |
| 1684 | | - $encodedExpiry = Block::encodeExpiry( $expiry, $dbw ); |
| | 1671 | + $encodedExpiry = $dbw->encodeExpiry( $expiry ); |
| 1685 | 1672 | |
| 1686 | 1673 | $expiry_description = ''; |
| 1687 | | - if ( $encodedExpiry != 'infinity' ) { |
| | 1674 | + if ( $encodedExpiry != $dbw->getInfinity() ) { |
| 1688 | 1675 | $expiry_description = ' (' . wfMsgForContent( 'protect-expiring', $wgContLang->timeanddate( $expiry ), |
| 1689 | 1676 | $wgContLang->date( $expiry ) , $wgContLang->time( $expiry ) ) . ')'; |
| 1690 | 1677 | } else { |
| — | — | @@ -1696,7 +1683,7 @@ |
| 1697 | 1684 | 'pt_namespace' => $namespace, |
| 1698 | 1685 | 'pt_title' => $title, |
| 1699 | 1686 | 'pt_create_perm' => $create_perm, |
| 1700 | | - 'pt_timestamp' => Block::encodeExpiry( wfTimestampNow(), $dbw ), |
| | 1687 | + 'pt_timestamp' => $dbw->encodeExpiry( wfTimestampNow() ), |
| 1701 | 1688 | 'pt_expiry' => $encodedExpiry, |
| 1702 | 1689 | 'pt_user' => $wgUser->getId(), |
| 1703 | 1690 | 'pt_reason' => $reason, |
| — | — | @@ -2037,6 +2024,7 @@ |
| 2038 | 2025 | * contains a array of unique groups. |
| 2039 | 2026 | */ |
| 2040 | 2027 | public function getCascadeProtectionSources( $getPages = true ) { |
| | 2028 | + global $wgContLang; |
| 2041 | 2029 | $pagerestrictions = array(); |
| 2042 | 2030 | |
| 2043 | 2031 | if ( isset( $this->mCascadeSources ) && $getPages ) { |
| — | — | @@ -2082,7 +2070,7 @@ |
| 2083 | 2071 | $purgeExpired = false; |
| 2084 | 2072 | |
| 2085 | 2073 | foreach ( $res as $row ) { |
| 2086 | | - $expiry = Block::decodeExpiry( $row->pr_expiry ); |
| | 2074 | + $expiry = $wgContLang->formatExpiry( $row->pr_expiry, TS_MW ); |
| 2087 | 2075 | if ( $expiry > $now ) { |
| 2088 | 2076 | if ( $getPages ) { |
| 2089 | 2077 | $page_id = $row->pr_page; |
| — | — | @@ -2163,13 +2151,14 @@ |
| 2164 | 2152 | * restrictions from page table (pre 1.10) |
| 2165 | 2153 | */ |
| 2166 | 2154 | public function loadRestrictionsFromRows( $rows, $oldFashionedRestrictions = null ) { |
| | 2155 | + global $wgContLang; |
| 2167 | 2156 | $dbr = wfGetDB( DB_SLAVE ); |
| 2168 | 2157 | |
| 2169 | 2158 | $restrictionTypes = $this->getRestrictionTypes(); |
| 2170 | 2159 | |
| 2171 | 2160 | foreach ( $restrictionTypes as $type ) { |
| 2172 | 2161 | $this->mRestrictions[$type] = array(); |
| 2173 | | - $this->mRestrictionsExpiry[$type] = Block::decodeExpiry( '' ); |
| | 2162 | + $this->mRestrictionsExpiry[$type] = $wgContLang->formatExpiry( '', TS_MW ); |
| 2174 | 2163 | } |
| 2175 | 2164 | |
| 2176 | 2165 | $this->mCascadeRestriction = false; |
| — | — | @@ -2212,7 +2201,7 @@ |
| 2213 | 2202 | |
| 2214 | 2203 | // This code should be refactored, now that it's being used more generally, |
| 2215 | 2204 | // But I don't really see any harm in leaving it in Block for now -werdna |
| 2216 | | - $expiry = Block::decodeExpiry( $row->pr_expiry ); |
| | 2205 | + $expiry = $wgContLang->formatExpiry( $row->pr_expiry, TS_MW ); |
| 2217 | 2206 | |
| 2218 | 2207 | // Only apply the restrictions if they haven't expired! |
| 2219 | 2208 | if ( !$expiry || $expiry > $now ) { |
| — | — | @@ -2241,12 +2230,17 @@ |
| 2242 | 2231 | * restrictions from page table (pre 1.10) |
| 2243 | 2232 | */ |
| 2244 | 2233 | public function loadRestrictions( $oldFashionedRestrictions = null ) { |
| | 2234 | + global $wgContLang; |
| 2245 | 2235 | if ( !$this->mRestrictionsLoaded ) { |
| 2246 | 2236 | if ( $this->exists() ) { |
| 2247 | 2237 | $dbr = wfGetDB( DB_SLAVE ); |
| 2248 | 2238 | |
| 2249 | | - $res = $dbr->select( 'page_restrictions', '*', |
| 2250 | | - array( 'pr_page' => $this->getArticleId() ), __METHOD__ ); |
| | 2239 | + $res = $dbr->select( |
| | 2240 | + 'page_restrictions', |
| | 2241 | + '*', |
| | 2242 | + array( 'pr_page' => $this->getArticleId() ), |
| | 2243 | + __METHOD__ |
| | 2244 | + ); |
| 2251 | 2245 | |
| 2252 | 2246 | $this->loadRestrictionsFromResultWrapper( $res, $oldFashionedRestrictions ); |
| 2253 | 2247 | } else { |
| — | — | @@ -2254,7 +2248,7 @@ |
| 2255 | 2249 | |
| 2256 | 2250 | if ( $title_protection ) { |
| 2257 | 2251 | $now = wfTimestampNow(); |
| 2258 | | - $expiry = Block::decodeExpiry( $title_protection['pt_expiry'] ); |
| | 2252 | + $expiry = $wgContLang->formatExpiry( $title_protection['pt_expiry'], TS_MW ); |
| 2259 | 2253 | |
| 2260 | 2254 | if ( !$expiry || $expiry > $now ) { |
| 2261 | 2255 | // Apply the restrictions |
| — | — | @@ -2265,7 +2259,7 @@ |
| 2266 | 2260 | $this->mTitleProtection = false; |
| 2267 | 2261 | } |
| 2268 | 2262 | } else { |
| 2269 | | - $this->mRestrictionsExpiry['create'] = Block::decodeExpiry( '' ); |
| | 2263 | + $this->mRestrictionsExpiry['create'] = $wgContLang->formatExpiry( '', TS_MW ); |
| 2270 | 2264 | } |
| 2271 | 2265 | $this->mRestrictionsLoaded = true; |
| 2272 | 2266 | } |
| Index: trunk/phase3/includes/Block.php |
| — | — | @@ -45,7 +45,7 @@ |
| 46 | 46 | $this->mAuto = $auto; |
| 47 | 47 | $this->mAnonOnly = $anonOnly; |
| 48 | 48 | $this->mCreateAccount = $createAccount; |
| 49 | | - $this->mExpiry = self::decodeExpiry( $expiry ); |
| | 49 | + $this->mExpiry = $expiry; |
| 50 | 50 | $this->mEnableAutoblock = $enableAutoblock; |
| 51 | 51 | $this->mHideName = $hideName; |
| 52 | 52 | $this->mBlockEmail = $blockEmail; |
| — | — | @@ -342,7 +342,7 @@ |
| 343 | 343 | $this->mAllowUsertalk = $row->ipb_allow_usertalk; |
| 344 | 344 | $this->mHideName = $row->ipb_deleted; |
| 345 | 345 | $this->mId = $row->ipb_id; |
| 346 | | - $this->mExpiry = self::decodeExpiry( $row->ipb_expiry ); |
| | 346 | + $this->mExpiry = $row->ipb_expiry; |
| 347 | 347 | |
| 348 | 348 | if ( isset( $row->user_name ) ) { |
| 349 | 349 | $this->mByName = $row->user_name; |
| — | — | @@ -420,7 +420,7 @@ |
| 421 | 421 | 'ipb_anon_only' => $this->mAnonOnly, |
| 422 | 422 | 'ipb_create_account' => $this->mCreateAccount, |
| 423 | 423 | 'ipb_enable_autoblock' => $this->mEnableAutoblock, |
| 424 | | - 'ipb_expiry' => self::encodeExpiry( $this->mExpiry, $dbw ), |
| | 424 | + 'ipb_expiry' => $dbw->encodeExpiry( $this->mExpiry ), |
| 425 | 425 | 'ipb_range_start' => $this->mRangeStart, |
| 426 | 426 | 'ipb_range_end' => $this->mRangeEnd, |
| 427 | 427 | 'ipb_deleted' => intval( $this->mHideName ), // typecast required for SQLite |
| — | — | @@ -460,7 +460,7 @@ |
| 461 | 461 | 'ipb_anon_only' => $this->mAnonOnly, |
| 462 | 462 | 'ipb_create_account' => $this->mCreateAccount, |
| 463 | 463 | 'ipb_enable_autoblock' => $this->mEnableAutoblock, |
| 464 | | - 'ipb_expiry' => self::encodeExpiry( $this->mExpiry, $dbw ), |
| | 464 | + 'ipb_expiry' => $dbw->encodeExpiry( $this->mExpiry ), |
| 465 | 465 | 'ipb_range_start' => $this->mRangeStart, |
| 466 | 466 | 'ipb_range_end' => $this->mRangeEnd, |
| 467 | 467 | 'ipb_deleted' => $this->mHideName, |
| — | — | @@ -778,6 +778,7 @@ |
| 779 | 779 | * @param $expiry String: timestamp for expiry, or |
| 780 | 780 | * @param $db Database object |
| 781 | 781 | * @return String |
| | 782 | + * @deprecated since 1.18; use $dbw->encodeExpiry() instead |
| 782 | 783 | */ |
| 783 | 784 | public static function encodeExpiry( $expiry, $db ) { |
| 784 | 785 | if ( $expiry == '' || $expiry == Block::infinity() ) { |
| — | — | @@ -793,13 +794,11 @@ |
| 794 | 795 | * @param $expiry String: Database expiry format |
| 795 | 796 | * @param $timestampType Requested timestamp format |
| 796 | 797 | * @return String |
| | 798 | + * @deprecated since 1.18; use $wgLang->decodeExpiry() instead |
| 797 | 799 | */ |
| 798 | 800 | public static function decodeExpiry( $expiry, $timestampType = TS_MW ) { |
| 799 | | - if ( $expiry == '' || $expiry == Block::infinity() ) { |
| 800 | | - return Block::infinity(); |
| 801 | | - } else { |
| 802 | | - return wfTimestamp( $timestampType, $expiry ); |
| 803 | | - } |
| | 801 | + global $wgContLang; |
| | 802 | + return $wgContLang->formatExpiry( $expiry, $timestampType ); |
| 804 | 803 | } |
| 805 | 804 | |
| 806 | 805 | /** |
| — | — | @@ -872,8 +871,10 @@ |
| 873 | 872 | * |
| 874 | 873 | * @param $encoded_expiry String: Database encoded expiry time |
| 875 | 874 | * @return Html-escaped String |
| | 875 | + * @deprecated since 1.18; use $wgLang->formatExpiry() instead |
| 876 | 876 | */ |
| 877 | 877 | public static function formatExpiry( $encoded_expiry ) { |
| | 878 | + global $wgContLang; |
| 878 | 879 | static $msg = null; |
| 879 | 880 | |
| 880 | 881 | if ( is_null( $msg ) ) { |
| — | — | @@ -885,7 +886,7 @@ |
| 886 | 887 | } |
| 887 | 888 | } |
| 888 | 889 | |
| 889 | | - $expiry = self::decodeExpiry( $encoded_expiry ); |
| | 890 | + $expiry = $wgContLang->formatExpiry( $encoded_expiry, TS_MW ); |
| 890 | 891 | if ( $expiry == self::infinity() ) { |
| 891 | 892 | $expirystr = $msg['infiniteblock']; |
| 892 | 893 | } else { |
| Index: trunk/phase3/includes/db/Database.php |
| — | — | @@ -2748,6 +2748,20 @@ |
| 2749 | 2749 | } |
| 2750 | 2750 | |
| 2751 | 2751 | /** |
| | 2752 | + * Encode an expiry time |
| | 2753 | + * |
| | 2754 | + * @param $expiry String: timestamp for expiry, or the 'infinity' string |
| | 2755 | + * @return String |
| | 2756 | + */ |
| | 2757 | + public function encodeExpiry( $expiry ) { |
| | 2758 | + if ( $expiry == '' || $expiry == $this->getInfinity() ) { |
| | 2759 | + return $this->getInfinity(); |
| | 2760 | + } else { |
| | 2761 | + return $this->timestamp( $expiry ); |
| | 2762 | + } |
| | 2763 | + } |
| | 2764 | + |
| | 2765 | + /** |
| 2752 | 2766 | * Allow or deny "big selects" for this session only. This is done by setting |
| 2753 | 2767 | * the sql_big_selects session variable. |
| 2754 | 2768 | * |
| Index: trunk/phase3/includes/OutputPage.php |
| — | — | @@ -1910,20 +1910,8 @@ |
| 1911 | 1911 | $blockid = $wgUser->mBlock->mId; |
| 1912 | 1912 | |
| 1913 | 1913 | $blockExpiry = $wgUser->mBlock->mExpiry; |
| 1914 | | - if ( $blockExpiry == 'infinity' ) { |
| 1915 | | - // Entry in database (table ipblocks) is 'infinity' but 'ipboptions' uses 'infinite' or 'indefinite' |
| 1916 | | - // Search for localization in 'ipboptions' |
| 1917 | | - $scBlockExpiryOptions = wfMsg( 'ipboptions' ); |
| 1918 | | - foreach ( explode( ',', $scBlockExpiryOptions ) as $option ) { |
| 1919 | | - if ( strpos( $option, ':' ) === false ) { |
| 1920 | | - continue; |
| 1921 | | - } |
| 1922 | | - list( $show, $value ) = explode( ':', $option ); |
| 1923 | | - if ( $value == 'infinite' || $value == 'indefinite' ) { |
| 1924 | | - $blockExpiry = $show; |
| 1925 | | - break; |
| 1926 | | - } |
| 1927 | | - } |
| | 1914 | + if ( $blockExpiry == Block::infinity() ) { |
| | 1915 | + $blockExpiry = wfMessage( 'infiniteblock' ); |
| 1928 | 1916 | } else { |
| 1929 | 1917 | $blockExpiry = $wgLang->timeanddate( |
| 1930 | 1918 | wfTimestamp( TS_MW, $blockExpiry ), |
| Index: trunk/phase3/includes/Article.php |
| — | — | @@ -2617,7 +2617,7 @@ |
| 2618 | 2618 | if ( !isset( $expiry[$action] ) ) |
| 2619 | 2619 | $expiry[$action] = Block::infinity(); |
| 2620 | 2620 | |
| 2621 | | - $encodedExpiry[$action] = Block::encodeExpiry( $expiry[$action], $dbw ); |
| | 2621 | + $encodedExpiry[$action] = $dbw->encodeExpiry( $expiry[$action] ); |
| 2622 | 2622 | if ( $restrictions != '' ) { |
| 2623 | 2623 | $protect_description .= "[$action=$restrictions] ("; |
| 2624 | 2624 | if ( $encodedExpiry[$action] != 'infinity' ) { |
| Index: trunk/phase3/includes/specials/SpecialProtectedtitles.php |
| — | — | @@ -93,7 +93,7 @@ |
| 94 | 94 | $stxt = ''; |
| 95 | 95 | |
| 96 | 96 | if ( $row->pt_expiry != 'infinity' && strlen($row->pt_expiry) ) { |
| 97 | | - $expiry = Block::decodeExpiry( $row->pt_expiry ); |
| | 97 | + $expiry = $wgLang->formatExpiry( $row->pt_expiry ); |
| 98 | 98 | |
| 99 | 99 | $expiry_description = wfMsg( 'protect-expiring', $wgLang->timeanddate( $expiry ) , $wgLang->date( $expiry ) , $wgLang->time( $expiry ) ); |
| 100 | 100 | |
| Index: trunk/phase3/includes/specials/SpecialProtectedpages.php |
| — | — | @@ -80,10 +80,12 @@ |
| 81 | 81 | |
| 82 | 82 | wfProfileIn( __METHOD__ ); |
| 83 | 83 | |
| 84 | | - static $skin=null; |
| | 84 | + static $skin = null, $dbr = null; |
| 85 | 85 | |
| 86 | | - if( is_null( $skin ) ) |
| | 86 | + if( is_null( $skin ) ){ |
| 87 | 87 | $skin = $wgUser->getSkin(); |
| | 88 | + $dbr = wfGetDB( DB_READ ); |
| | 89 | + } |
| 88 | 90 | |
| 89 | 91 | $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); |
| 90 | 92 | $link = $skin->link( $title ); |
| — | — | @@ -100,11 +102,15 @@ |
| 101 | 103 | |
| 102 | 104 | $stxt = ''; |
| 103 | 105 | |
| 104 | | - if( $row->pr_expiry != 'infinity' && strlen($row->pr_expiry) ) { |
| 105 | | - $expiry = Block::decodeExpiry( $row->pr_expiry ); |
| | 106 | + $expiry = $wgLang->formatExpiry( $row->pr_expiry, TS_MW ); |
| | 107 | + if( $expiry != $dbr->getInfinity() ) { |
| 106 | 108 | |
| 107 | | - $expiry_description = wfMsg( 'protect-expiring' , $wgLang->timeanddate( $expiry ) , |
| 108 | | - $wgLang->date( $expiry ) , $wgLang->time( $expiry ) ); |
| | 109 | + $expiry_description = wfMsg( |
| | 110 | + 'protect-expiring', |
| | 111 | + $wgLang->timeanddate( $expiry ), |
| | 112 | + $wgLang->date( $expiry ), |
| | 113 | + $wgLang->time( $expiry ) |
| | 114 | + ); |
| 109 | 115 | |
| 110 | 116 | $description_items[] = htmlspecialchars($expiry_description); |
| 111 | 117 | } |
| Index: trunk/phase3/languages/Language.php |
| — | — | @@ -2970,6 +2970,37 @@ |
| 2971 | 2971 | return array( $wikiUpperChars, $wikiLowerChars ); |
| 2972 | 2972 | } |
| 2973 | 2973 | |
| | 2974 | + /** |
| | 2975 | + * Decode an expiry (block, protection, etc) which has come from the DB |
| | 2976 | + * |
| | 2977 | + * @param $expiry String: Database expiry String |
| | 2978 | + * @param $format Bool|Int true to process using language functions, or TS_ constant |
| | 2979 | + * to return the expiry in a given timestamp |
| | 2980 | + * @return String |
| | 2981 | + */ |
| | 2982 | + public function formatExpiry( $expiry, $format = true ) { |
| | 2983 | + static $dbr, $msg; |
| | 2984 | + if( !$dbr ){ |
| | 2985 | + $dbr = wfGetDB( DB_SLAVE ); |
| | 2986 | + $msg = wfMessage( 'infiniteblock' ); |
| | 2987 | + } |
| | 2988 | + |
| | 2989 | + if ( $expiry == '' || $expiry == $dbr->getInfinity() ) { |
| | 2990 | + return $format === true |
| | 2991 | + ? $msg |
| | 2992 | + : $dbr->getInfinity(); |
| | 2993 | + } else { |
| | 2994 | + return $format === true |
| | 2995 | + ? $this->timeanddate( $expiry ) |
| | 2996 | + : wfTimestamp( $format, $expiry ); |
| | 2997 | + } |
| | 2998 | + } |
| | 2999 | + |
| | 3000 | + /** |
| | 3001 | + * @todo Document |
| | 3002 | + * @param $seconds String |
| | 3003 | + * @return string |
| | 3004 | + */ |
| 2974 | 3005 | function formatTimePeriod( $seconds ) { |
| 2975 | 3006 | if ( round( $seconds * 10 ) < 100 ) { |
| 2976 | 3007 | return $this->formatNum( sprintf( "%.1f", round( $seconds * 10 ) / 10 ) ) . $this->getMessageFromDB( 'seconds-abbrev' ); |
| Index: trunk/extensions/GlobalBlocking/GlobalBlocking.class.php |
| — | — | @@ -25,6 +25,7 @@ |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | static function getUserBlockErrors( $user, $ip ) { |
| | 29 | + global $wgLang; |
| 29 | 30 | static $result = null; |
| 30 | 31 | |
| 31 | 32 | // Instance cache |
| — | — | @@ -43,7 +44,17 @@ |
| 44 | 45 | return $result = array(); |
| 45 | 46 | } |
| 46 | 47 | |
| 47 | | - $expiry = Block::formatExpiry( $block->gb_expiry ); |
| | 48 | + # Messy B/C until $wgLang->formatExpiry() is well embedded |
| | 49 | + if( Block::decodeExpiry( $block->gb_expiry ) == 'infinity' ){ |
| | 50 | + $expiry = wfMsgExt( 'infiniteblock', 'parseinline' ); |
| | 51 | + } else { |
| | 52 | + $expiry = Block::decodeExpiry( $block->gb_expiry ); |
| | 53 | + $expiry = wfMsgExt( |
| | 54 | + 'expiringblock', |
| | 55 | + $wgLang->date( $expiry ), |
| | 56 | + $wgLang->time( $expiry ) |
| | 57 | + ); |
| | 58 | + } |
| 48 | 59 | |
| 49 | 60 | $display_wiki = self::getWikiName( $block->gb_by_wiki ); |
| 50 | 61 | $user_display = self::maybeLinkUserpage( $block->gb_by_wiki, $block->gb_by ); |
| Index: trunk/extensions/GlobalBlocking/SpecialGlobalBlockList.php |
| — | — | @@ -135,8 +135,17 @@ |
| 136 | 136 | $expiry = $row->gb_expiry; |
| 137 | 137 | $options = array(); |
| 138 | 138 | |
| 139 | | - ## Options to display |
| 140 | | - $options[] = Block::formatExpiry( $expiry ); |
| | 139 | + # Messy B/C until $wgLang->formatExpiry() is well embedded |
| | 140 | + if( Block::decodeExpiry( $expiry ) == 'infinity' ){ |
| | 141 | + $options[] = wfMsgExt( 'infiniteblock', 'parseinline' ); |
| | 142 | + } else { |
| | 143 | + $expiry = Block::decodeExpiry( $expiry ); |
| | 144 | + $options[] = wfMsgExt( |
| | 145 | + 'expiringblock', |
| | 146 | + $wgLang->date( $expiry ), |
| | 147 | + $wgLang->time( $expiry ) |
| | 148 | + ); |
| | 149 | + } |
| 141 | 150 | |
| 142 | 151 | # Check for whitelisting. |
| 143 | 152 | $wlinfo = GlobalBlocking::getWhitelistInfo( $row->gb_id ); |