mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 01:30:15 +00:00
868190bbf6
- Adds global "$wgEchoMentionStatusNotifications" to activate mention status notifications. (must be set before extension is loaded) - Adds notification types and icon for some basic mention failures. - Adds failure and stats for anonymous IP. - Adds check for links to user subpages. - Adds config var for max mention notifications allowed. - Bundles notifications. - Refactors test for the event generation and adds tests for unknown users, user links with subpages and failures for too many mentions. Bug: T136326 Change-Id: I388bdc3714feb9a2865a5ad10dbeabb0a6a09a4f
99 lines
2.6 KiB
PHP
99 lines
2.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Presenter for 'mention-failure' notifications
|
|
*
|
|
* @author Christoph Fischer <christoph.fischer@wikimedia.de>
|
|
*
|
|
* @license GNU GPL v2+
|
|
*/
|
|
class EchoMentionFailurePresentationModel extends EchoEventPresentationModel {
|
|
use EchoPresentationModelSectionTrait;
|
|
|
|
public function getIconType() {
|
|
return 'mention-failure';
|
|
}
|
|
|
|
public function getHeaderMessage() {
|
|
if ( $this->isTooManyMentionsFailure() ) {
|
|
$msg = $this->getMessageWithAgent( 'notification-header-mention-failure-too-many' );
|
|
$msg->numParams( $this->getMaxMentions() );
|
|
return $msg;
|
|
}
|
|
|
|
if ( $this->isBundled() ) {
|
|
$msg = $this->getMessageWithAgent( 'notification-header-mention-failure-bundle' );
|
|
$msg->numParams( $this->getBundleCount() );
|
|
$msg->params( $this->getTruncatedTitleText( $this->event->getTitle() ) );
|
|
return $msg;
|
|
}
|
|
|
|
// Messages that can be used here:
|
|
// * notification-header-mention-failure-user-unknown
|
|
// * notification-header-mention-failure-user-anonymous
|
|
$msg = $this->getMessageWithAgent( 'notification-header-mention-failure-' . $this->getFailureType() );
|
|
$msg->params( $this->getSubjectName() );
|
|
|
|
return $msg;
|
|
}
|
|
|
|
public function getCompactHeaderMessage() {
|
|
// Messages that can be used here:
|
|
// * notification-compact-header-mention-failure-user-unknown
|
|
// * notification-compact-header-mention-failure-user-anonymous
|
|
$msg = $this->msg( 'notification-compact-header-mention-failure-' . $this->getFailureType() );
|
|
$msg->params( $this->getSubjectName() );
|
|
|
|
return $msg;
|
|
}
|
|
|
|
public function getPrimaryLink() {
|
|
return array(
|
|
// Need FullURL so the section is included
|
|
'url' => $this->getTitleWithSection()->getFullURL(),
|
|
'label' => $this->msg( 'notification-link-text-view-mention-failure' )
|
|
->numParams( $this->getBundleCount() )
|
|
->text()
|
|
);
|
|
}
|
|
|
|
public function getSecondaryLinks() {
|
|
if ( $this->isBundled() ) {
|
|
$viewMentionsLink = array_merge(
|
|
$this->getPrimaryLink(),
|
|
array(
|
|
'icon' => 'speechBubbles',
|
|
'prioritized' => true
|
|
)
|
|
);
|
|
|
|
return array( $viewMentionsLink );
|
|
}
|
|
|
|
$talkPageLink = $this->getPageLink(
|
|
$this->getTitleWithSection(),
|
|
'',
|
|
true
|
|
);
|
|
|
|
return array( $talkPageLink );
|
|
}
|
|
|
|
private function getSubjectName() {
|
|
return $this->event->getExtraParam( 'subject-name', '' );
|
|
}
|
|
|
|
private function getFailureType() {
|
|
return $this->event->getExtraParam( 'failure-type', 'user-unknown' );
|
|
}
|
|
|
|
private function isTooManyMentionsFailure() {
|
|
return $this->getType() === 'mention-too-many';
|
|
}
|
|
|
|
private function getMaxMentions() {
|
|
global $wgEchoMaxMentionsCount;
|
|
return $this->event->getExtraParam( 'max-mentions', $wgEchoMaxMentionsCount );
|
|
}
|
|
}
|