mediawiki-extensions-Echo/formatters/MentionFormatter.php
theopolisme fc7e18ba8e Mention: notify correctly if there is no section title
If a user is mentioned in an area that does not have a section
title (for example, the lead section of a talk page), use the new
'notification-mention-nosection' message, to avoid an awkward and
incorrect "[[Page#|]]".

Bug: 52507
Change-Id: I40628b76c460c79008053222c9780bb23549731d
2013-11-22 21:31:45 -06:00

28 lines
878 B
PHP

<?php
class EchoMentionFormatter extends EchoCommentFormatter {
/**
* {@inheritDoc}
*/
protected function applyChangeBeforeFormatting( EchoEvent $event, User $user, $type ) {
parent::applyChangeBeforeFormatting( $event, $user, $type );
// If we can't find a section title for the mention,
// fall back to `notification-mention-nosection`.
if ( !$this->getSectionTitle( $event, $user ) ) {
$this->title = array(
'message' => 'notification-mention-nosection',
'params' => array( 'agent', 'main-title-text', 'title' )
);
$this->flyoutTitle = array(
'message' => 'notification-mention-nosection-flyout',
'params' => array( 'agent', 'main-title-text', 'title' )
);
$this->email['batch-body'] = array(
'message' => 'notification-mention-nosection-email-batch-body',
'params' => array( 'agent', 'main-title-text' )
);
}
}
}