Merge "Convert Special:DeletedContributions to use OOUI."
[lhc/web/wiklou.git] / includes / EditPage.php
index 85c14fc..f37ce34 100644 (file)
@@ -2326,9 +2326,12 @@ class EditPage {
        }
 
        function setHeaders() {
-               global $wgOut, $wgUser, $wgAjaxEditStash;
+               global $wgOut, $wgUser, $wgAjaxEditStash, $wgCookieSetOnAutoblock;
 
                $wgOut->addModules( 'mediawiki.action.edit' );
+               if ( $wgCookieSetOnAutoblock === true ) {
+                       $wgOut->addModules( 'mediawiki.user.blockcookie' );
+               }
                $wgOut->addModuleStyles( 'mediawiki.action.edit.styles' );
 
                if ( $wgUser->getOption( 'showtoolbar' ) ) {
@@ -2866,6 +2869,7 @@ class EditPage {
        }
 
        protected function showHeader() {
+               global $wgOut, $wgUser;
                global $wgAllowUserCss, $wgAllowUserJs;
 
                if ( $this->isConflict ) {
@@ -3217,44 +3221,9 @@ HTML
                global $wgOut, $wgUser;
 
                $wikitext = $this->safeUnicodeOutput( $text );
-               if ( strval( $wikitext ) !== '' ) {
-                       // Ensure there's a newline at the end, otherwise adding lines
-                       // is awkward.
-                       // But don't add a newline if the ext is empty, or Firefox in XHTML
-                       // mode will show an extra newline. A bit annoying.
-                       $wikitext .= "\n";
-               }
-
-               $attribs = $customAttribs + [
-                       'accesskey' => ',',
-                       'id' => $name,
-                       'cols' => $wgUser->getIntOption( 'cols' ),
-                       'rows' => $wgUser->getIntOption( 'rows' ),
-                       // Avoid PHP notices when appending preferences
-                       // (appending allows customAttribs['style'] to still work).
-                       'style' => ''
-               ];
-
-               // The following classes can be used here:
-               // * mw-editfont-default
-               // * mw-editfont-monospace
-               // * mw-editfont-sans-serif
-               // * mw-editfont-serif
-               $class = 'mw-editfont-' . $wgUser->getOption( 'editfont' );
-
-               if ( isset( $attribs['class'] ) ) {
-                       if ( is_string( $attribs['class'] ) ) {
-                               $attribs['class'] .= ' ' . $class;
-                       } elseif ( is_array( $attribs['class'] ) ) {
-                               $attribs['class'][] = $class;
-                       }
-               } else {
-                       $attribs['class'] = $class;
-               }
+               $wikitext = $this->addNewLineAtEnd( $wikitext );
 
-               $pageLang = $this->mTitle->getPageLanguage();
-               $attribs['lang'] = $pageLang->getHtmlCode();
-               $attribs['dir'] = $pageLang->getDir();
+               $attribs = $this->buildTextboxAttribs( $name, $customAttribs, $wgUser );
 
                $wgOut->addHTML( Html::textarea( $name, $wikitext, $attribs ) );
        }
@@ -3357,7 +3326,6 @@ HTML
                }
 
                if ( $newContent ) {
-                       ContentHandler::runLegacyHooks( 'EditPageGetDiffText', [ $this, &$newContent ], '1.21' );
                        Hooks::run( 'EditPageGetDiffContent', [ $this, &$newContent ] );
 
                        $popts = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang );
@@ -3441,6 +3409,7 @@ HTML
         *
         * @param Title $title
         * @param string $format Output format, valid values are any function of a Message object
+        * @param Language|string|null $langcode Language code or Language object.
         * @return string
         */
        public static function getCopyrightWarning( $title, $format = 'plain', $langcode = null ) {
@@ -3568,7 +3537,7 @@ HTML
                global $wgOut;
 
                if ( Hooks::run( 'EditPageBeforeConflictDiff', [ &$this, &$wgOut ] ) ) {
-                       $stats = $wgOut->getContext()->getStats();
+                       $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
                        $stats->increment( 'edit.failures.conflict' );
                        // Only include 'standard' namespaces to avoid creating unknown numbers of statsd metrics
                        if (
@@ -3707,7 +3676,7 @@ HTML
                global $wgOut, $wgRawHtml, $wgLang;
                global $wgAllowUserCss, $wgAllowUserJs;
 
-               $stats = $wgOut->getContext()->getStats();
+               $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
 
                if ( $wgRawHtml && !$this->mTokenOk ) {
                        // Could be an offsite preview attempt. This is very unsafe if
@@ -4101,7 +4070,7 @@ HTML
 
        /**
         * Returns an array of html code of the following buttons:
-        * save, diff, preview and live
+        * save, diff and preview
         *
         * @param int $tabindex Current tabindex
         *
@@ -4135,7 +4104,6 @@ HTML
                ] + Linker::tooltipAndAccesskeyAttribs( 'preview' );
                $buttons['preview'] = Html::submitButton( $this->context->msg( 'showpreview' )->text(),
                        $attribs );
-               $buttons['live'] = '';
 
                $attribs = [
                        'id' => 'wpDiff',
@@ -4436,10 +4404,69 @@ HTML
        }
 
        /**
-        * @param OutputPage &$out
+        * @param OutputPage $out
         * @since 1.29
         */
-       protected function addExplainConflictHeader( OutputPage &$out ) {
+       protected function addExplainConflictHeader( OutputPage $out ) {
                $out->wrapWikiMsg( "<div class='mw-explainconflict'>\n$1\n</div>", 'explainconflict' );
        }
+
+       /**
+        * @param string $name
+        * @param mixed[] $customAttribs
+        * @param User $user
+        * @return mixed[]
+        * @since 1.29
+        */
+       protected function buildTextboxAttribs( $name, array $customAttribs, User $user ) {
+               $attribs = $customAttribs + [
+                               'accesskey' => ',',
+                               'id' => $name,
+                               'cols' => $user->getIntOption( 'cols' ),
+                               'rows' => $user->getIntOption( 'rows' ),
+                               // Avoid PHP notices when appending preferences
+                               // (appending allows customAttribs['style'] to still work).
+                               'style' => ''
+                       ];
+
+               // The following classes can be used here:
+               // * mw-editfont-default
+               // * mw-editfont-monospace
+               // * mw-editfont-sans-serif
+               // * mw-editfont-serif
+               $class = 'mw-editfont-' . $user->getOption( 'editfont' );
+
+               if ( isset( $attribs['class'] ) ) {
+                       if ( is_string( $attribs['class'] ) ) {
+                               $attribs['class'] .= ' ' . $class;
+                       } elseif ( is_array( $attribs['class'] ) ) {
+                               $attribs['class'][] = $class;
+                       }
+               } else {
+                       $attribs['class'] = $class;
+               }
+
+               $pageLang = $this->mTitle->getPageLanguage();
+               $attribs['lang'] = $pageLang->getHtmlCode();
+               $attribs['dir'] = $pageLang->getDir();
+
+               return $attribs;
+       }
+
+       /**
+        * @param string $wikitext
+        * @return string
+        * @since 1.29
+        */
+       protected function addNewLineAtEnd( $wikitext ) {
+               if ( strval( $wikitext ) !== '' ) {
+                       // Ensure there's a newline at the end, otherwise adding lines
+                       // is awkward.
+                       // But don't add a newline if the text is empty, or Firefox in XHTML
+                       // mode will show an extra newline. A bit annoying.
+                       $wikitext .= "\n";
+                       return $wikitext;
+               }
+               return $wikitext;
+       }
 }