Merge "Simplify HTMLTitleTextField::validate"
[lhc/web/wiklou.git] / includes / widget / search / SearchFormWidget.php
index 95875cd..7eb92fd 100644 (file)
@@ -4,6 +4,7 @@ namespace MediaWiki\Widget\Search;
 
 use Hooks;
 use Html;
+use MediaWiki\MediaWikiServices;
 use MediaWiki\Widget\SearchInputWidget;
 use MWNamespace;
 use SearchEngineConfig;
@@ -171,11 +172,10 @@ class SearchFormWidget {
         * @return bool
         */
        protected function startsWithImage( $term ) {
-               global $wgContLang;
-
                $parts = explode( ':', $term );
                return count( $parts ) > 1
-                       ? $wgContLang->getNsIndex( $parts[0] ) === NS_FILE
+                       ? MediaWikiServices::getInstance()->getContentLanguage()->getNsIndex( $parts[0] ) ===
+                               NS_FILE
                        : false;
        }
 
@@ -236,17 +236,16 @@ class SearchFormWidget {
         * @return string HTML
         */
        protected function powerSearchBox( $term, array $opts ) {
-               global $wgContLang;
-
                $rows = [];
                $activeNamespaces = $this->specialSearch->getNamespaces();
+               $langConverter = MediaWikiServices::getInstance()->getContentLanguage()->getConverter();
                foreach ( $this->searchConfig->searchableNamespaces() as $namespace => $name ) {
                        $subject = MWNamespace::getSubject( $namespace );
                        if ( !isset( $rows[$subject] ) ) {
                                $rows[$subject] = "";
                        }
 
-                       $name = $wgContLang->getConverter()->convertNamespace( $namespace );
+                       $name = $langConverter->convertNamespace( $namespace );
                        if ( $name === '' ) {
                                $name = $this->specialSearch->msg( 'blanknamespace' )->text();
                        }