X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=languages%2FLanguage.php;h=51ff8d5b1b19488ed2fff9b00b3d1726b970ebf5;hb=c1ec8b95ab218e0b62d5e7a71855dff241b53f15;hp=539bdf4547664d3438cd0eb4438452749a076b2a;hpb=baa3105f63b0de50138b8011ad9faeb9415a15b8;p=lhc%2Fweb%2Fwiklou.git diff --git a/languages/Language.php b/languages/Language.php index 539bdf4547..51ff8d5b1b 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -27,6 +27,7 @@ */ use CLDRPluralRuleParser\Evaluator; +use MediaWiki\MediaWikiServices; use Wikimedia\Assert\Assert; /** @@ -54,13 +55,15 @@ class Language { const SUPPORTED = 'mwfile'; /** - * @var LanguageConverter + * @var LanguageConverter|FakeConverter */ public $mConverter; public $mVariants, $mCode, $mLoaded = false; public $mMagicExtensions = []; - private $mHtmlCode = null, $mParentLanguage = false; + private $mHtmlCode = null; + /** @var Language|false */ + private $mParentLanguage = false; public $dateFormatStrings = []; public $mExtendedSpecialPageAliases; @@ -466,6 +469,7 @@ class Language { /** * Reduce memory usage + * @suppress PhanTypeSuspiciousNonTraversableForeach */ function __destruct() { foreach ( $this as $name => $value ) { @@ -506,7 +510,8 @@ class Language { if ( is_null( $this->namespaceNames ) ) { global $wgMetaNamespace, $wgMetaNamespaceTalk, $wgExtraNamespaces; - $validNamespaces = MWNamespace::getCanonicalNamespaces(); + $validNamespaces = MediaWikiServices::getInstance()->getNamespaceInfo()-> + getCanonicalNamespaces(); $this->namespaceNames = $wgExtraNamespaces + self::$dataCache->getItem( $this->mCode, 'namespaceNames' ); @@ -744,7 +749,8 @@ class Language { */ public function getNsIndex( $text ) { $lctext = $this->lc( $text ); - $ns = MWNamespace::getCanonicalIndex( $lctext ); + $ns = MediaWikiServices::getInstance()->getNamespaceInfo()-> + getCanonicalIndex( $lctext ); if ( $ns !== null ) { return $ns; } @@ -811,7 +817,8 @@ class Language { * @return array */ public function getExtraUserToggles() { - return (array)self::$dataCache->getItem( $this->mCode, 'extraUserToggles' ); + wfDeprecated( __METHOD__, '1.34' ); + return []; } /** @@ -2963,8 +2970,8 @@ class Language { } /** - * @param array $termsArray - * @return array + * @param string[] $termsArray + * @return string[] */ function convertForSearchResult( $termsArray ) { # some languages, e.g. Chinese, need to do a conversion @@ -3030,34 +3037,6 @@ class Language { } } - /** - * @deprecated No-op since 1.28 - */ - function initEncoding() { - wfDeprecated( __METHOD__, '1.28' ); - // No-op. - } - - /** - * @param string $s - * @return string - * @deprecated No-op since 1.28 - */ - function recodeForEdit( $s ) { - wfDeprecated( __METHOD__, '1.28' ); - return $s; - } - - /** - * @param string $s - * @return string - * @deprecated No-op since 1.28 - */ - function recodeInput( $s ) { - wfDeprecated( __METHOD__, '1.28' ); - return $s; - } - /** * Convert a UTF-8 string to normal form C. In Malayalam and Arabic, this * also cleans up certain backwards-compatible sequences, converting them @@ -4561,7 +4540,7 @@ class Language { * * @since 1.22 * @param string $code Language code - * @return array Array( fallbacks, site fallbacks ) + * @return array [ fallbacks, site fallbacks ] */ public static function getFallbacksIncludingSiteLanguage( $code ) { global $wgLanguageCode; @@ -4683,6 +4662,7 @@ class Language { * * @param int|float $seconds * @param array $format An optional argument that formats the returned string in different ways: + * If $format['avoid'] === 'avoidhours': don't show hours, just show days * If $format['avoid'] === 'avoidseconds': don't show seconds if $seconds >= 1 hour, * If $format['avoid'] === 'avoidminutes': don't show seconds/minutes if $seconds > 48 hours, * If $format['noabbrevs'] is true: use 'seconds' and friends instead of 'seconds-abbrev' @@ -4741,12 +4721,19 @@ class Language { $s = $hoursMsg->params( $this->formatNum( $hours ) )->text(); $s .= ' '; $s .= $minutesMsg->params( $this->formatNum( $minutes ) )->text(); - if ( !in_array( $format['avoid'], [ 'avoidseconds', 'avoidminutes' ] ) ) { + if ( !in_array( $format['avoid'], [ 'avoidseconds', 'avoidminutes', 'avoidhours' ] ) ) { $s .= ' ' . $secondsMsg->params( $this->formatNum( $secondsPart ) )->text(); } } else { $days = floor( $seconds / 86400 ); - if ( $format['avoid'] === 'avoidminutes' ) { + if ( $format['avoid'] === 'avoidhours' ) { + $hours = round( ( $seconds - $days * 86400 ) / 3600 ); + if ( $hours == 24 ) { + $hours = 0; + $days++; + } + $s = $daysMsg->params( $this->formatNum( $days ) )->text(); + } elseif ( $format['avoid'] === 'avoidminutes' ) { $hours = round( ( $seconds - $days * 86400 ) / 3600 ); if ( $hours == 24 ) { $hours = 0; @@ -4873,12 +4860,13 @@ class Language { * @param array $query Optional URL query parameter string * @param bool $atend Optional param for specified if this is the last page * @return string - * @deprecated since 1.33, use SpecialPage::viewPrevNext() + * @deprecated since 1.34, use PrevNextNavigationRenderer::buildPrevNextNavigation() * instead. */ public function viewPrevNext( Title $title, $offset, $limit, array $query = [], $atend = false ) { + wfDeprecated( __METHOD__, '1.34' ); // @todo FIXME: Why on earth this needs one message for the text and another one for tooltip? # Make 'previous' link