Merge "Add .pipeline/ with dev image variant"
[lhc/web/wiklou.git] / includes / installer / WebInstaller.php
index 0a6be86..d9cd6de 100644 (file)
@@ -124,6 +124,13 @@ class WebInstaller extends Installer {
         */
        protected $tabIndex = 1;
 
+       /**
+        * Numeric index of the help box
+        *
+        * @var int
+        */
+       protected $helpBoxId = 1;
+
        /**
         * Name of the page we're on
         *
@@ -138,11 +145,6 @@ class WebInstaller extends Installer {
                parent::__construct();
                $this->output = new WebInstallerOutput( $this );
                $this->request = $request;
-
-               // Add parser hooks
-               $parser = MediaWikiServices::getInstance()->getParser();
-               $parser->setHook( 'downloadlink', [ $this, 'downloadLinkHook' ] );
-               $parser->setHook( 'doclink', [ $this, 'docLink' ] );
        }
 
        /**
@@ -186,7 +188,9 @@ class WebInstaller extends Installer {
 
                # Special case for Creative Commons partner chooser box.
                if ( $this->request->getVal( 'SubmitCC' ) ) {
+                       /** @var WebInstallerOptions $page */
                        $page = $this->getPageByName( 'Options' );
+                       '@phan-var WebInstallerOptions $page';
                        $this->output->useShortHeader();
                        $this->output->allowFrames();
                        $page->submitCC();
@@ -195,7 +199,9 @@ class WebInstaller extends Installer {
                }
 
                if ( $this->request->getVal( 'ShowCC' ) ) {
+                       /** @var WebInstallerOptions $page */
                        $page = $this->getPageByName( 'Options' );
+                       '@phan-var WebInstallerOptions $page';
                        $this->output->useShortHeader();
                        $this->output->allowFrames();
                        $this->output->addHTML( $page->getCCDoneBox() );
@@ -384,7 +390,8 @@ class WebInstaller extends Installer {
                        );
                }
                $text = $msg->useDatabase( false )->plain();
-               $this->output->addHTML( $this->getErrorBox( $text ) );
+               $box = Html::errorBox( $text, '', 'config-error-box' );
+               $this->output->addHTML( $box );
        }
 
        /**
@@ -631,42 +638,49 @@ class WebInstaller extends Installer {
        /**
         * Get HTML for an error box with an icon.
         *
+        * @deprecated since 1.34 Use Html::errorBox() instead.
         * @param string $text Wikitext, get this with wfMessage()->plain()
         *
         * @return string
         */
        public function getErrorBox( $text ) {
+               wfDeprecated( __METHOD__, '1.34' );
                return $this->getInfoBox( $text, 'critical-32.png', 'config-error-box' );
        }
 
        /**
         * Get HTML for a warning box with an icon.
         *
+        * @deprecated since 1.34 Use Html::warningBox() instead.
         * @param string $text Wikitext, get this with wfMessage()->plain()
         *
         * @return string
         */
        public function getWarningBox( $text ) {
+               wfDeprecated( __METHOD__, '1.34' );
                return $this->getInfoBox( $text, 'warning-32.png', 'config-warning-box' );
        }
 
        /**
-        * Get HTML for an info box with an icon.
+        * Get HTML for an information message box with an icon.
         *
-        * @param string $text Wikitext, get this with wfMessage()->plain()
+        * @deprecated since 1.34.
+        * @param string|HtmlArmor $text Wikitext to be parsed (from Message::plain) or raw HTML.
         * @param string|bool $icon Icon name, file in mw-config/images. Default: false
         * @param string|bool $class Additional class name to add to the wrapper div. Default: false.
-        *
-        * @return string
+        * @return string HTML
         */
        public function getInfoBox( $text, $icon = false, $class = false ) {
-               $text = $this->parse( $text, true );
+               wfDeprecated( __METHOD__, '1.34' );
+               $html = ( $text instanceof HtmlArmor ) ?
+                       HtmlArmor::getHtml( $text ) :
+                       $this->parse( $text, true );
                $icon = ( $icon == false ) ?
                        'images/info-32.png' :
                        'images/' . $icon;
                $alt = wfMessage( 'config-information' )->text();
 
-               return Html::infoBox( $text, $icon, $alt, $class );
+               return Html::infoBox( $html, $icon, $alt, $class );
        }
 
        /**
@@ -680,11 +694,13 @@ class WebInstaller extends Installer {
                $args = array_map( 'htmlspecialchars', $args );
                $text = wfMessage( $msg, $args )->useDatabase( false )->plain();
                $html = $this->parse( $text, true );
+               $id = 'helpBox-' . $this->helpBoxId++;
 
                return "<div class=\"config-help-field-container\">\n" .
-                       "<span class=\"config-help-field-hint\" title=\"" .
+                       "<input type=\"checkbox\" class=\"config-help-field-checkbox\" id=\"$id\" />" .
+                       "<label class=\"config-help-field-hint\" for=\"$id\" title=\"" .
                        wfMessage( 'config-help-tooltip' )->escaped() . "\">" .
-                       wfMessage( 'config-help' )->escaped() . "</span>\n" .
+                       wfMessage( 'config-help' )->escaped() . "</label>\n" .
                        "<div class=\"config-help-field-data\">" . $html . "</div>\n" .
                        "</div>\n";
        }
@@ -1037,9 +1053,9 @@ class WebInstaller extends Installer {
                        $text = $status->getWikiText();
 
                        if ( $status->isOK() ) {
-                               $box = $this->getWarningBox( $text );
+                               $box = Html::warningBox( $text, 'config-warning-box' );
                        } else {
-                               $box = $this->getErrorBox( $text );
+                               $box = Html::errorBox( $text, '', 'config-error-box' );
                        }
 
                        $this->output->addHTML( $box );
@@ -1081,13 +1097,13 @@ class WebInstaller extends Installer {
        }
 
        /**
-        * Helper for Installer::docLink()
+        * Helper for WebInstallerOutput
         *
+        * @internal For use by WebInstallerOutput
         * @param string $page
-        *
         * @return string
         */
-       protected function getDocUrl( $page ) {
+       public function getDocUrl( $page ) {
                $query = [ 'page' => $page ];
 
                if ( in_array( $this->currentPageName, $this->pageSequence ) ) {
@@ -1098,30 +1114,26 @@ class WebInstaller extends Installer {
        }
 
        /**
-        * Extension tag hook for a documentation link.
+        * Helper for sidebar links.
         *
+        * @internal For use in WebInstallerOutput class
+        * @param string $url
         * @param string $linkText
-        * @param string[] $attribs
-        * @param Parser $parser Unused
-        *
-        * @return string
+        * @return string HTML
         */
-       public function docLink( $linkText, $attribs, $parser ) {
-               $url = $this->getDocUrl( $attribs['href'] );
-
-               return Html::element( 'a', [ 'href' => $url ], $linkText );
+       public function makeLinkItem( $url, $linkText ) {
+               return Html::rawElement( 'li', [],
+                       Html::element( 'a', [ 'href' => $url ], $linkText )
+               );
        }
 
        /**
-        * Helper for "Download LocalSettings" link on WebInstall_Complete
-        *
-        * @param string $text Unused
-        * @param string[] $attribs Unused
-        * @param Parser $parser Unused
+        * Helper for "Download LocalSettings" link.
         *
+        * @internal For use in WebInstallerComplete class
         * @return string Html for download link
         */
-       public function downloadLinkHook( $text, $attribs, $parser ) {
+       public function makeDownloadLinkHtml() {
                $anchor = Html::rawElement( 'a',
                        [ 'href' => $this->getUrl( [ 'localsettings' => 1 ] ) ],
                        wfMessage( 'config-download-localsettings' )->parse()