X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=blobdiff_plain;f=includes%2FMagicWord.php;h=4420d1d32790228cdc516c6763d1dc2c84590355;hb=495331ff0705dd93239ec6ab449921d84f33a6c9;hp=a193c9fda9e58ceed9ee7fb0921870e4cee95af8;hpb=925c20a9ca669c67cc44f4468d0e0f3b33b94213;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/MagicWord.php b/includes/MagicWord.php index a193c9fda9..4420d1d327 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(); + } } /** @@ -166,9 +175,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 +494,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; } }