Merge "Implement non-JS RollbackAction with form"
[lhc/web/wiklou.git] / includes / Linker.php
index 7d6b149..a02d57d 100644 (file)
@@ -112,7 +112,7 @@ class Linker {
                if ( $html !== null ) {
                        $text = new HtmlArmor( $html );
                } else {
-                       $text = $html; // null
+                       $text = null;
                }
 
                if ( in_array( 'known', $options, true ) ) {
@@ -823,13 +823,20 @@ class Linker {
 
        /**
         * Make an external link
+        *
         * @since 1.16.3. $title added in 1.21
         * @param string $url URL to link to
+        * @param-taint $url escapes_html
         * @param string $text Text of link
+        * @param-taint $text escapes_html
         * @param bool $escape Do we escape the link text?
+        * @param-taint $escape none
         * @param string $linktype Type of external link. Gets added to the classes
+        * @param-taint $linktype escapes_html
         * @param array $attribs Array of extra attributes to <a>
+        * @param-taint $attribs escapes_html
         * @param Title|null $title Title object used for title specific link attributes
+        * @param-taint $title none
         * @return string
         */
        public static function makeExternalLink( $url, $text, $escape = true,
@@ -1600,9 +1607,8 @@ class Linker {
         * @return string Full html of the TOC
         */
        public static function tocList( $toc, $lang = null ) {
-               global $wgLang;
-               $lang = $lang ?? $wgLang;
-               if ( !is_object( $lang ) ) {
+               $lang = $lang ?? RequestContext::getMain()->getLanguage();
+               if ( !$lang instanceof Language ) {
                        wfDeprecated( __METHOD__ . ' with type other than Language for $lang', '1.33' );
                        $lang = wfGetLangObj( $lang );
                }
@@ -1762,6 +1768,12 @@ class Linker {
                        $inner = $context->msg( 'brackets' )->rawParams( $inner )->escaped();
                }
 
+               if ( $context->getUser()->getBoolOption( 'showrollbackconfirmation' ) ) {
+                       $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
+                       $stats->increment( 'rollbackconfirmation.event.load' );
+                       $context->getOutput()->addModules( 'mediawiki.page.rollback.confirmation' );
+               }
+
                return '<span class="mw-rollback-link">' . $inner . '</span>';
        }
 
@@ -1855,20 +1867,25 @@ class Linker {
                }
 
                $title = $rev->getTitle();
+
                $query = [
                        'action' => 'rollback',
                        'from' => $rev->getUserText(),
                        'token' => $context->getUser()->getEditToken( 'rollback' ),
                ];
+
                $attrs = [
                        'data-mw' => 'interface',
                        'title' => $context->msg( 'tooltip-rollback' )->text(),
+                       'data-rollback-count' => (int)$editCount
                ];
+
                $options = [ 'known', 'noclasses' ];
 
                if ( $context->getRequest()->getBool( 'bot' ) ) {
+                       //T17999
+                       $query['hidediff'] = '1';
                        $query['bot'] = '1';
-                       $query['hidediff'] = '1'; // T17999
                }
 
                $disableRollbackEditCount = false;
@@ -1903,47 +1920,6 @@ class Linker {
                return self::link( $title, $html, $attrs, $query, $options );
        }
 
-       /**
-        * @deprecated since 1.28, use TemplatesOnThisPageFormatter directly
-        *
-        * Returns HTML for the "templates used on this page" list.
-        *
-        * Make an HTML list of templates, and then add a "More..." link at
-        * the bottom. If $more is null, do not add a "More..." link. If $more
-        * is a Title, make a link to that title and use it. If $more is a string,
-        * directly paste it in as the link (escaping needs to be done manually).
-        * Finally, if $more is a Message, call toString().
-        *
-        * @since 1.16.3. $more added in 1.21
-        * @param Title[] $templates Array of templates
-        * @param bool $preview Whether this is for a preview
-        * @param bool $section Whether this is for a section edit
-        * @param Title|Message|string|null $more An escaped link for "More..." of the templates
-        * @return string HTML output
-        */
-       public static function formatTemplates( $templates, $preview = false,
-               $section = false, $more = null
-       ) {
-               wfDeprecated( __METHOD__, '1.28' );
-
-               $type = false;
-               if ( $preview ) {
-                       $type = 'preview';
-               } elseif ( $section ) {
-                       $type = 'section';
-               }
-
-               if ( $more instanceof Message ) {
-                       $more = $more->toString();
-               }
-
-               $formatter = new TemplatesOnThisPageFormatter(
-                       RequestContext::getMain(),
-                       MediaWikiServices::getInstance()->getLinkRenderer()
-               );
-               return $formatter->format( $templates, $type, $more );
-       }
-
        /**
         * Returns HTML for the "hidden categories on this page" list.
         *
@@ -1971,23 +1947,6 @@ class Linker {
                return $outText;
        }
 
-       /**
-        * @deprecated since 1.28, use Language::formatSize() directly
-        *
-        * Format a size in bytes for output, using an appropriate
-        * unit (B, KB, MB or GB) according to the magnitude in question
-        *
-        * @since 1.16.3
-        * @param int $size Size to format
-        * @return string
-        */
-       public static function formatSize( $size ) {
-               wfDeprecated( __METHOD__, '1.28' );
-
-               global $wgLang;
-               return htmlspecialchars( $wgLang->formatSize( $size ) );
-       }
-
        /**
         * Given the id of an interface element, constructs the appropriate title
         * attribute from the system messages.  (Note, this is usually the id but