Merge "Linker: Accept LinkTargets in makeCommentLink()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 13 Sep 2017 10:15:54 +0000 (10:15 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 13 Sep 2017 10:15:54 +0000 (10:15 +0000)
1  2 
includes/Linker.php

diff --combined includes/Linker.php
@@@ -1319,7 -1319,7 +1319,7 @@@ class Linker 
         *
         * @note This is only public for technical reasons. It's not intended for use outside Linker.
         *
-        * @param Title $title
+        * @param LinkTarget $linkTarget
         * @param string $text
         * @param string|null $wikiId Id of the wiki to link to (if not the local wiki),
         *  as used by WikiMap.
         * @return string HTML link
         */
        public static function makeCommentLink(
-               Title $title, $text, $wikiId = null, $options = []
+               LinkTarget $linkTarget, $text, $wikiId = null, $options = []
        ) {
-               if ( $wikiId !== null && !$title->isExternal() ) {
+               if ( $wikiId !== null && !$linkTarget->isExternal() ) {
                        $link = self::makeExternalLink(
                                WikiMap::getForeignURL(
                                        $wikiId,
-                                       $title->getNamespace() === 0
-                                               ? $title->getDBkey()
-                                               : MWNamespace::getCanonicalName( $title->getNamespace() ) . ':'
-                                                       . $title->getDBkey(),
-                                       $title->getFragment()
+                                       $linkTarget->getNamespace() === 0
+                                               ? $linkTarget->getDBkey()
+                                               : MWNamespace::getCanonicalName( $linkTarget->getNamespace() ) . ':'
+                                                       . $linkTarget->getDBkey(),
+                                       $linkTarget->getFragment()
                                ),
                                $text,
                                /* escape = */ false // Already escaped
                        );
                } else {
-                       $link = self::link( $title, $text, [], [], $options );
+                       $link = self::link( $linkTarget, $text, [], [], $options );
                }
  
                return $link;
                if ( $sectionIndex !== false ) {
                        $classes .= " tocsection-$sectionIndex";
                }
 -              return "\n<li class=\"$classes\"><a href=\"#" .
 -                      $anchor . '"><span class="tocnumber">' .
 -                      $tocnumber . '</span> <span class="toctext">' .
 -                      $tocline . '</span></a>';
 +
 +              // \n<li class="$classes"><a href="#$anchor"><span class="tocnumber">
 +              // $tocnumber</span> <span class="toctext">$tocline</span></a>
 +              return "\n" . Html::openElement( 'li', [ 'class' => $classes ] )
 +                      . Html::rawElement( 'a',
 +                              [ 'href' => "#$anchor" ],
 +                              Html::element( 'span', [ 'class' => 'tocnumber' ], $tocnumber )
 +                                      . ' '
 +                                      . Html::rawElement( 'span', [ 'class' => 'toctext' ], $tocline )
 +                      );
        }
  
        /**