diff --git a/includes/DiscussionParser.php b/includes/DiscussionParser.php index 2dbcc9202..ce64b9106 100644 --- a/includes/DiscussionParser.php +++ b/includes/DiscussionParser.php @@ -81,6 +81,7 @@ abstract class EchoDiscussionParser { * @param Title $title */ public static function detectSectionTitleAndText( array $interpretation, Title $title = null ) { + global $wgLang; $header = $snippet = ''; $found = false; @@ -88,11 +89,17 @@ abstract class EchoDiscussionParser { switch( $action['type'] ) { case 'add-comment': $header = self::extractHeader( $action['full-section'] ); - $snippet = self::getTextSnippet( self::stripSignature( self::stripHeader( $action['content'] ), $title ), 150 ); + $snippet = self::getTextSnippet( + self::stripSignature( self::stripHeader( $action['content'] ), $title ), + $wgLang, + 150 ); break; case 'new-section-with-comment': $header = self::extractHeader( $action['content'] ); - $snippet = self::getTextSnippet( self::stripSignature( self::stripHeader( $action['content'] ), $title ), 150 ); + $snippet = self::getTextSnippet( + self::stripSignature( self::stripHeader( $action['content'] ), $title ), + $wgLang, + 150 ); break; } if ( $header ) { @@ -815,12 +822,11 @@ abstract class EchoDiscussionParser { * This function returns plain text snippet, it also removes html tag, * template from text content * @param $text string + * @param Language $lang * @param $length int default 150 * @return string */ - static function getTextSnippet( $text, $length = 150 ) { - global $wgLang; - + static function getTextSnippet( $text, Language $lang, $length = 150 ) { $text = strip_tags( $text ); $attempt = 0; @@ -849,7 +855,7 @@ abstract class EchoDiscussionParser { $text = trim( strip_tags( htmlspecialchars_decode( $text ) ) ); // strip out non-useful data for snippet $text = str_replace( array( '{', '}' ), '', $text ); - $text = $wgLang->truncate( $text, $length ); + $text = $lang->truncate( $text, $length ); // Return empty string if there is undecoded char left if ( strpos( $text, '&#' ) !== false ) { diff --git a/includes/formatters/BasicFormatter.php b/includes/formatters/BasicFormatter.php index 94efb9541..651a92ac6 100644 --- a/includes/formatters/BasicFormatter.php +++ b/includes/formatters/BasicFormatter.php @@ -405,7 +405,7 @@ class EchoBasicFormatter extends EchoNotificationFormatter { $content = EchoDiscussionParser::stripHeader( $extra['content'] ); $content = EchoDiscussionParser::stripSignature( $content ); $content = EchoDiscussionParser::stripIndents( $content ); - return EchoDiscussionParser::getTextSnippet( $content, 200 ); + return EchoDiscussionParser::getTextSnippet( $content, $this->getLanguage(), 200 ); } /** diff --git a/includes/formatters/EditFormatter.php b/includes/formatters/EditFormatter.php index f2826ef23..39b2c7236 100644 --- a/includes/formatters/EditFormatter.php +++ b/includes/formatters/EditFormatter.php @@ -64,7 +64,11 @@ class EchoEditFormatter extends EchoBasicFormatter { if ( !empty( $extra['section-title'] ) ) { if ( $event->userCan( Revision::DELETED_TEXT, $user ) ) { - return EchoDiscussionParser::getTextSnippet( $extra['section-title'], 30 ); + return EchoDiscussionParser::getTextSnippet( + $extra['section-title'], + $this->getLanguage(), + 30 + ); } else { return $this->getMessage( 'echo-rev-deleted-text-view' )->text(); }