Merge "Omit 'external' changes from ChangesFeed"
[lhc/web/wiklou.git] / includes / Linker.php
index 7b7c21b..4a1aa87 100644 (file)
@@ -1251,7 +1251,6 @@ class Linker {
                        $userId = $rev->getUser( Revision::FOR_THIS_USER );
                        $userText = $rev->getUserText( Revision::FOR_THIS_USER );
                        $link = self::userLink( $userId, $userText )
-                               . wfMessage( 'word-separator' )->escaped()
                                . self::userToolLinks( $userId, $userText );
                } else {
                        $link = wfMessage( 'rev-deleted-user' )->escaped();
@@ -1385,9 +1384,13 @@ class Linker {
         * @param string $comment Text to format links in
         * @param Title|null $title An optional title object used to links to sections
         * @param bool $local Whether section links should refer to local page
+        * @param string|null $wikiId Id of the wiki to link to (if not the local wiki), as used by WikiMap
+        *
         * @return string
         */
-       public static function formatLinksInComment( $comment, $title = null, $local = false ) {
+       public static function formatLinksInComment(
+               $comment, $title = null, $local = false, $wikiId = null
+       ) {
                return preg_replace_callback(
                        '/
                                \[\[
@@ -1401,7 +1404,7 @@ class Linker {
                                \]\]
                                ([^[]*) # 3. link trail (the text up until the next link)
                        /x',
-                       function ( $match ) use ( $title, $local ) {
+                       function ( $match ) use ( $title, $local, $wikiId ) {
                                global $wgContLang;
 
                                $medians = '(?:' . preg_quote( MWNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
@@ -1457,11 +1460,22 @@ class Linker {
                                                        $newTarget = clone ( $title );
                                                        $newTarget->setFragment( '#' . $target->getFragment() );
                                                        $target = $newTarget;
+
                                                }
-                                               $thelink = Linker::link(
-                                                       $target,
-                                                       $linkText . $inside
-                                               ) . $trail;
+
+                                               if ( $wikiId !== null ) {
+                                                       $thelink = Linker::makeExternalLink(
+                                                               WikiMap::getForeignURL( $wikiId, $target->getFullText() ),
+                                                               $linkText . $inside,
+                                                               /* escape = */ false // Already escaped
+                                                       ) . $trail;
+                                               } else {
+                                                       $thelink = Linker::link(
+                                                               $target,
+                                                               $linkText . $inside
+                                                       ) . $trail;
+                                               }
+
                                        }
                                }
                                if ( $thelink ) {
@@ -1592,7 +1606,7 @@ class Linker {
         * @return string HTML fragment
         */
        public static function revComment( Revision $rev, $local = false, $isPublic = false ) {
-               if ( $rev->getRawComment() == "" ) {
+               if ( $rev->getComment( Revision::RAW ) == "" ) {
                        return "";
                }
                if ( $rev->isDeleted( Revision::DELETED_COMMENT ) && $isPublic ) {
@@ -1695,9 +1709,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 ) {
@@ -1716,7 +1731,7 @@ class Linker {
                        $lastLevel = $section['toclevel'];
                }
                $toc .= self::tocLineEnd();
-               return self::tocList( $toc );
+               return self::tocList( $toc, $lang );
        }
 
        /**
@@ -1857,7 +1872,7 @@ class Linker {
                $editCount = 0;
                $moreRevs = false;
                foreach ( $res as $row ) {
-                       if ( $rev->getRawUserText() != $row->rev_user_text ) {
+                       if ( $rev->getUserText( Revision::RAW ) != $row->rev_user_text ) {
                                if ( $verify &&
                                        ( $row->rev_deleted & Revision::DELETED_TEXT
                                                || $row->rev_deleted & Revision::DELETED_USER
@@ -2030,14 +2045,14 @@ class Linker {
                                if ( $titleObj->quickUserCan( 'edit' ) ) {
                                        $editLink = self::link(
                                                $titleObj,
-                                               wfMessage( 'editlink' )->text(),
+                                               wfMessage( 'editlink' )->escaped(),
                                                array(),
                                                array( 'action' => 'edit' )
                                        );
                                } else {
                                        $editLink = self::link(
                                                $titleObj,
-                                               wfMessage( 'viewsourcelink' )->text(),
+                                               wfMessage( 'viewsourcelink' )->escaped(),
                                                array(),
                                                array( 'action' => 'edit' )
                                        );
@@ -2313,7 +2328,6 @@ class Linker {
        ) {
                wfDeprecated( __METHOD__, '1.21' );
 
-
                if ( $text == '' ) {
                        $text = self::linkText( $title );
                }