Merge "Fix FOUC for floated collapsible elements outside the content area"
[lhc/web/wiklou.git] / includes / Linker.php
index b807ecc..08a5724 100644 (file)
@@ -184,14 +184,13 @@ class Linker {
         * @return string
         */
        public static function getInvalidTitleDescription( IContextSource $context, $namespace, $title ) {
-               global $wgContLang;
-
                // First we check whether the namespace exists or not.
                if ( MWNamespace::exists( $namespace ) ) {
                        if ( $namespace == NS_MAIN ) {
                                $name = $context->msg( 'blanknamespace' )->text();
                        } else {
-                               $name = $wgContLang->getFormattedNsText( $namespace );
+                               $name = MediaWikiServices::getInstance()->getContentLanguage()->
+                                       getFormattedNsText( $namespace );
                        }
                        return $context->msg( 'invalidtitle-knownnamespace', $namespace, $name, $title )->text();
                } else {
@@ -206,7 +205,8 @@ class Linker {
         */
        public static function normaliseSpecialPage( LinkTarget $target ) {
                if ( $target->getNamespace() == NS_SPECIAL && !$target->isExternal() ) {
-                       list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $target->getDBkey() );
+                       list( $name, $subpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
+                               resolveAlias( $target->getDBkey() );
                        if ( !$name ) {
                                return $target;
                        }
@@ -1227,10 +1227,11 @@ class Linker {
                                ([^[]*) # 3. link trail (the text up until the next link)
                        /x',
                        function ( $match ) use ( $title, $local, $wikiId ) {
-                               global $wgContLang;
-
                                $medians = '(?:' . preg_quote( MWNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
-                               $medians .= preg_quote( $wgContLang->getNsText( NS_MEDIA ), '/' ) . '):';
+                               $medians .= preg_quote(
+                                       MediaWikiServices::getInstance()->getContentLanguage()->getNsText( NS_MEDIA ),
+                                       '/'
+                               ) . '):';
 
                                $comment = $match[0];
 
@@ -1264,7 +1265,11 @@ class Linker {
                                                $match[1] = substr( $match[1], 1 );
                                        }
                                        if ( $match[1] !== false && $match[1] !== '' ) {
-                                               if ( preg_match( $wgContLang->linkTrail(), $match[3], $submatch ) ) {
+                                               if ( preg_match(
+                                                       MediaWikiServices::getInstance()->getContentLanguage()->linkTrail(),
+                                                       $match[3],
+                                                       $submatch
+                                               ) ) {
                                                        $trail = $submatch[1];
                                                } else {
                                                        $trail = "";
@@ -1496,7 +1501,7 @@ class Linker {
         * @return string
         */
        public static function tocIndent() {
-               return "\n<ul>";
+               return "\n<ul>\n";
        }
 
        /**
@@ -1527,9 +1532,9 @@ class Linker {
                        $classes .= " tocsection-$sectionIndex";
                }
 
-               // \n<li class="$classes"><a href="#$anchor"><span class="tocnumber">
+               // <li class="$classes"><a href="#$anchor"><span class="tocnumber">
                // $tocnumber</span> <span class="toctext">$tocline</span></a>
-               return "\n" . Html::openElement( 'li', [ 'class' => $classes ] )
+               return Html::openElement( 'li', [ 'class' => $classes ] )
                        . Html::rawElement( 'a',
                                [ 'href' => "#$anchor" ],
                                Html::element( 'span', [ 'class' => 'tocnumber' ], $tocnumber )
@@ -1562,12 +1567,25 @@ class Linker {
                $title = wfMessage( 'toc' )->inLanguage( $lang )->escaped();
 
                return '<div id="toc" class="toc">'
+                       . Html::element( 'input', [
+                               'type' => 'checkbox',
+                               'role' => 'button',
+                               'id' => 'toctogglecheckbox',
+                               'class' => 'toctogglecheckbox',
+                               'style' => 'display:none',
+                       ] )
                        . Html::openElement( 'div', [
                                'class' => 'toctitle',
                                'lang' => $lang->getHtmlCode(),
                                'dir' => $lang->getDir(),
                        ] )
-                       . '<h2>' . $title . "</h2></div>\n"
+                       . "<h2>$title</h2>"
+                       . '<span class="toctogglespan">'
+                       . Html::label( '', 'toctogglecheckbox', [
+                               'class' => 'toctogglelabel',
+                       ] )
+                       . '</span>'
+                       . "</div>\n"
                        . $toc
                        . "</ul>\n</div>\n";
        }
@@ -1642,8 +1660,7 @@ class Linker {
         * @return array
         */
        static function splitTrail( $trail ) {
-               global $wgContLang;
-               $regex = $wgContLang->linkTrail();
+               $regex = MediaWikiServices::getInstance()->getContentLanguage()->linkTrail();
                $inside = '';
                if ( $trail !== '' ) {
                        $m = [];