Installer: Make short header and normal header of WebInstaller equivalent
[lhc/web/wiklou.git] / includes / installer / WebInstallerOutput.php
index 6c1f2ec..914a69e 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup Deployment
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Output class modelled on OutputPage.
  *
@@ -31,6 +33,7 @@
  *
  * @ingroup Deployment
  * @since 1.17
+ * @private
  */
 class WebInstallerOutput {
 
@@ -146,7 +149,7 @@ class WebInstallerOutput {
                        'mediawiki.skinning.interface',
                ];
 
-               $resourceLoader = new ResourceLoader();
+               $resourceLoader = MediaWikiServices::getInstance()->getResourceLoader();
 
                if ( file_exists( "$wgStyleDirectory/Vector/skin.json" ) ) {
                        // Force loading Vector skin if available as a fallback skin
@@ -166,7 +169,7 @@ class WebInstallerOutput {
 
                $rlContext = new ResourceLoaderContext( $resourceLoader, new FauxRequest( [
                                'debug' => 'true',
-                               'lang' => $this->getLanguageCode(),
+                               'lang' => $this->getLanguage()->getCode(),
                                'only' => 'styles',
                ] ) );
 
@@ -197,7 +200,7 @@ class WebInstallerOutput {
         * @return string
         */
        private function getCssUrl() {
-               return Html::linkedStyle( $_SERVER['PHP_SELF'] . '?css=1' );
+               return Html::linkedStyle( $this->parent->getUrl( [ 'css' => 1 ] ) );
        }
 
        public function useShortHeader( $use = true ) {
@@ -220,21 +223,13 @@ class WebInstallerOutput {
        }
 
        /**
-        * @return string
-        */
-       public function getDir() {
-               global $wgLang;
-
-               return is_object( $wgLang ) ? $wgLang->getDir() : 'ltr';
-       }
-
-       /**
-        * @return string
+        * @since 1.33
+        * @return Language
         */
-       public function getLanguageCode() {
+       private function getLanguage() {
                global $wgLang;
 
-               return is_object( $wgLang ) ? $wgLang->getCode() : 'en';
+               return is_object( $wgLang ) ? $wgLang : Language::factory( 'en' );
        }
 
        /**
@@ -242,8 +237,8 @@ class WebInstallerOutput {
         */
        public function getHeadAttribs() {
                return [
-                       'dir' => $this->getDir(),
-                       'lang' => LanguageCode::bcp47( $this->getLanguageCode() ),
+                       'dir' => $this->getLanguage()->getDir(),
+                       'lang' => $this->getLanguage()->getHtmlCode(),
                ];
        }
 
@@ -287,7 +282,7 @@ class WebInstallerOutput {
        <?php echo Html::linkedScript( 'config.js' ) . "\n"; ?>
 </head>
 
-<?php echo Html::openElement( 'body', [ 'class' => $this->getDir() ] ) . "\n"; ?>
+<?php echo Html::openElement( 'body', [ 'class' => $this->getLanguage()->getDir() ] ) . "\n"; ?>
 <div id="mw-page-base"></div>
 <div id="mw-head-base"></div>
 <div id="content" class="mw-body">
@@ -309,9 +304,7 @@ class WebInstallerOutput {
 
 <div id="mw-panel">
        <div class="portal" id="p-logo">
-               <a style="background-image: url(images/installer-logo.png);"
-                       href="https://www.mediawiki.org/"
-                       title="Main Page"></a>
+               <a href="https://www.mediawiki.org/" title="Main Page"></a>
        </div>
 <?php
        $message = wfMessage( 'config-sidebar' )->plain();
@@ -330,13 +323,14 @@ class WebInstallerOutput {
        public function outputShortHeader() {
 ?>
 <?php echo Html::htmlHeader( $this->getHeadAttribs() ); ?>
+
 <head>
-       <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <meta name="robots" content="noindex, nofollow" />
+       <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <title><?php $this->outputTitle(); ?></title>
        <?php echo $this->getCssUrl() . "\n"; ?>
-       <?php echo $this->getJQuery(); ?>
-       <?php echo Html::linkedScript( 'config.js' ); ?>
+       <?php echo $this->getJQuery() . "\n"; ?>
+       <?php echo Html::linkedScript( 'config.js' ) . "\n"; ?>
 </head>
 
 <body style="background-image: none">