X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FMagicWord.php;h=3c77234336c20c92c3c3132953d242c589110328;hp=a193c9fda9e58ceed9ee7fb0921870e4cee95af8;hb=4226fada45a83ad56e91ce7638d17d12fecec8ca;hpb=5189333c3915e08fb5676be637b9c0fb588d1823 diff --git a/includes/MagicWord.php b/includes/MagicWord.php index a193c9fda9..3c77234336 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -90,6 +90,9 @@ class MagicWord { /** @var bool */ private $mFound = false; + /** @var Language */ + private $contLang; + /**#@-*/ /** @@ -100,11 +103,17 @@ class MagicWord { * @param string|null $id The internal name of the magic word * @param string[]|string $syn synonyms for the magic word * @param bool $cs If magic word is case sensitive + * @param Language|null $contLang Content language */ - public function __construct( $id = null, $syn = [], $cs = false ) { + public function __construct( $id = null, $syn = [], $cs = false, Language $contLang = null ) { $this->mId = $id; $this->mSynonyms = (array)$syn; $this->mCaseSensitive = $cs; + $this->contLang = $contLang; + + if ( !$contLang ) { + $this->contLang = MediaWikiServices::getInstance()->getContentLanguage(); + } } /** @@ -116,6 +125,7 @@ class MagicWord { * @deprecated since 1.32, use MagicWordFactory::get */ public static function get( $id ) { + wfDeprecated( __METHOD__, '1.32' ); return MediaWikiServices::getInstance()->getMagicWordFactory()->get( $id ); } @@ -126,6 +136,7 @@ class MagicWord { * @deprecated since 1.32, use MagicWordFactory::getVariableIDs */ public static function getVariableIDs() { + wfDeprecated( __METHOD__, '1.32' ); return MediaWikiServices::getInstance()->getMagicWordFactory()->getVariableIDs(); } @@ -135,6 +146,7 @@ class MagicWord { * @deprecated since 1.32, use MagicWordFactory::getSubstIDs */ public static function getSubstIDs() { + wfDeprecated( __METHOD__, '1.32' ); return MediaWikiServices::getInstance()->getMagicWordFactory()->getSubstIDs(); } @@ -146,6 +158,7 @@ class MagicWord { * @deprecated since 1.32, use MagicWordFactory::getCacheTTL */ public static function getCacheTTL( $id ) { + wfDeprecated( __METHOD__, '1.32' ); return MediaWikiServices::getInstance()->getMagicWordFactory()->getCacheTTL( $id ); } @@ -156,6 +169,7 @@ class MagicWord { * @deprecated since 1.32, use MagicWordFactory::getDoubleUnderscoreArray */ public static function getDoubleUnderscoreArray() { + wfDeprecated( __METHOD__, '1.32' ); return MediaWikiServices::getInstance()->getMagicWordFactory()->getDoubleUnderscoreArray(); } @@ -166,9 +180,8 @@ class MagicWord { * @throws MWException */ public function load( $id ) { - global $wgContLang; $this->mId = $id; - $wgContLang->getMagic( $this ); + $this->contLang->getMagic( $this ); if ( !$this->mSynonyms ) { $this->mSynonyms = [ 'brionmademeputthishere' ]; throw new MWException( "Error: invalid magic word '$id'" ); @@ -486,9 +499,8 @@ class MagicWord { * @param string $value */ public function addToArray( &$array, $value ) { - global $wgContLang; foreach ( $this->mSynonyms as $syn ) { - $array[$wgContLang->lc( $syn )] = $value; + $array[$this->contLang->lc( $syn )] = $value; } }