Merge "tiny optimization Title::isValidRedirectTarget()"
[lhc/web/wiklou.git] / includes / Linker.php
index a9c26c6..bb65cdf 100644 (file)
@@ -77,7 +77,7 @@ class Linker {
                wfDeprecated( __METHOD__, '1.25' );
 
                $title = urldecode( $title );
-               $title = str_replace( '_', ' ', $title );
+               $title = strtr( $title, '_', ' ' );
                return self::getLinkAttributesInternal( $title, $class );
        }
 
@@ -1414,10 +1414,9 @@ class Linker {
 
                                # fix up urlencoded title texts (copied from Parser::replaceInternalLinks)
                                if ( strpos( $match[1], '%' ) !== false ) {
-                                       $match[1] = str_replace(
-                                               array( '<', '>' ),
-                                               array( '&lt;', '&gt;' ),
-                                               rawurldecode( $match[1] )
+                                       $match[1] = strtr(
+                                               rawurldecode( $match[1] ),
+                                               array( '<' => '&lt;', '>' => '&gt;' )
                                        );
                                }
 
@@ -1709,9 +1708,10 @@ class Linker {
         * Currently unused.
         *
         * @param array $tree Return value of ParserOutput::getSections()
+        * @param string|Language|bool $lang Language for the toc title, defaults to user language
         * @return string HTML fragment
         */
-       public static function generateTOC( $tree ) {
+       public static function generateTOC( $tree, $lang = false ) {
                $toc = '';
                $lastLevel = 0;
                foreach ( $tree as $section ) {
@@ -1730,7 +1730,7 @@ class Linker {
                        $lastLevel = $section['toclevel'];
                }
                $toc .= self::tocLineEnd();
-               return self::tocList( $toc );
+               return self::tocList( $toc, $lang );
        }
 
        /**
@@ -1752,17 +1752,6 @@ class Linker {
                $link, $legacyAnchor = false
        ) {
                $ret = "<h$level$attribs"
-                       . Html::element( 'a',
-                               array(
-                                       'href' => '#' . $anchor,
-                                       'class' => 'mw-headline-anchor',
-                                       // Hide from screen readers, as it is inside a heading (the programs use headings to
-                                       // navigate, so the symbol is being read during navigation). Pending T13555 being fixed.
-                                       'aria-hidden' => 'true',
-                                       'title' => wfMessage( 'headline-anchor-title' )->text()
-                               ),
-                               wfMessage( 'section-symbol' )->text()
-                       )
                        . "<span class=\"mw-headline\" id=\"$anchor\">$html</span>"
                        . $link
                        . "</h$level>";