mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-30 18:45:07 +00:00
Presentation model for edit-user-talk
Bug: T116843 Change-Id: Ia11f5b57747ed0be5d4b00c75925d5fcdde87c43
This commit is contained in:
parent
47fd3b5896
commit
04d4da2783
3
Echo.php
3
Echo.php
|
@ -311,6 +311,7 @@ $wgEchoNotifications = array(
|
||||||
'icon' => 'site',
|
'icon' => 'site',
|
||||||
),
|
),
|
||||||
'edit-user-talk' => array(
|
'edit-user-talk' => array(
|
||||||
|
'presentation-model' => 'EchoEditUserTalkPresentationModel',
|
||||||
'user-locators' => array(
|
'user-locators' => array(
|
||||||
'EchoUserLocator::locateTalkPageOwner',
|
'EchoUserLocator::locateTalkPageOwner',
|
||||||
),
|
),
|
||||||
|
@ -325,8 +326,6 @@ $wgEchoNotifications = array(
|
||||||
'title-params' => array( 'agent', 'user', 'subject-anchor' ),
|
'title-params' => array( 'agent', 'user', 'subject-anchor' ),
|
||||||
'bundle-message' => 'notification-edit-talk-page-bundle',
|
'bundle-message' => 'notification-edit-talk-page-bundle',
|
||||||
'bundle-params' => array( 'agent', 'user', 'agent-other-display', 'agent-other-count' ),
|
'bundle-params' => array( 'agent', 'user', 'agent-other-display', 'agent-other-count' ),
|
||||||
'flyout-message' => 'notification-edit-talk-page-flyout2',
|
|
||||||
'flyout-params' => array( 'agent', 'user', 'subject-anchor' ),
|
|
||||||
'email-subject-message' => 'notification-edit-talk-page-email-subject2',
|
'email-subject-message' => 'notification-edit-talk-page-email-subject2',
|
||||||
'email-subject-params' => array( 'agent' ),
|
'email-subject-params' => array( 'agent' ),
|
||||||
'email-body-batch-message' => 'notification-edit-talk-page-email-batch-body2',
|
'email-body-batch-message' => 'notification-edit-talk-page-email-batch-body2',
|
||||||
|
|
|
@ -38,6 +38,7 @@ $wgAutoloadClasses += array(
|
||||||
'EchoDiscussionParserTest' => __DIR__ . '/tests/phpunit/DiscussionParserTest.php',
|
'EchoDiscussionParserTest' => __DIR__ . '/tests/phpunit/DiscussionParserTest.php',
|
||||||
'EchoEditFormatter' => __DIR__ . '/includes/formatters/EditFormatter.php',
|
'EchoEditFormatter' => __DIR__ . '/includes/formatters/EditFormatter.php',
|
||||||
'EchoEditUserTalkFormatter' => __DIR__ . '/includes/formatters/EditUserTalkFormatter.php',
|
'EchoEditUserTalkFormatter' => __DIR__ . '/includes/formatters/EditUserTalkFormatter.php',
|
||||||
|
'EchoEditUserTalkPresentationModel' => __DIR__ . '/includes/formatters/EditUserTalkPresentationModel.php',
|
||||||
'EchoEmailDecorator' => __DIR__ . '/includes/EmailFormatter.php',
|
'EchoEmailDecorator' => __DIR__ . '/includes/EmailFormatter.php',
|
||||||
'EchoEmailDigest' => __DIR__ . '/includes/EmailFormatter.php',
|
'EchoEmailDigest' => __DIR__ . '/includes/EmailFormatter.php',
|
||||||
'EchoEmailFormatter' => __DIR__ . '/includes/EmailFormatter.php',
|
'EchoEmailFormatter' => __DIR__ . '/includes/EmailFormatter.php',
|
||||||
|
|
|
@ -60,8 +60,9 @@
|
||||||
"notification-link-text-view-edit": "View edit",
|
"notification-link-text-view-edit": "View edit",
|
||||||
"notification-edit-talk-page2": "[[User:$1|$1]] {{GENDER:$1|left}} a message on your [[User talk:$2#$3|talk page]].",
|
"notification-edit-talk-page2": "[[User:$1|$1]] {{GENDER:$1|left}} a message on your [[User talk:$2#$3|talk page]].",
|
||||||
"notification-edit-talk-page-with-section": "[[User:$1|$1]] {{GENDER:$1|left}} a message on your talk page in \"[[User talk:$2#$3|$4]]\".",
|
"notification-edit-talk-page-with-section": "[[User:$1|$1]] {{GENDER:$1|left}} a message on your talk page in \"[[User talk:$2#$3|$4]]\".",
|
||||||
"notification-edit-talk-page-flyout2": "$1 {{GENDER:$1|left}} a message on your [[User talk:$2#$3|talk page]].",
|
"notification-header-edit-user-talk": "$1 {{GENDER:$2|left}} a message on {{GENDER:$3|your}} talk page.",
|
||||||
"notification-edit-talk-page-flyout-with-section": "$1 {{GENDER:$1|left}} a message on your talk page in \"[[User talk:$2#$3|$4]]\".",
|
"notification-header-edit-user-talk-with-section": "$1 {{GENDER:$2|left}} a message on {{GENDER:$3|your}} talk page in \"$4\".",
|
||||||
|
"notification-body-edit-user-talk-with-section": "$1",
|
||||||
"notification-page-linked": "[[:$2]] was {{GENDER:$1|linked}} from [[:$3]]. [[Special:WhatLinksHere/$2|See all links to this page]].",
|
"notification-page-linked": "[[:$2]] was {{GENDER:$1|linked}} from [[:$3]]. [[Special:WhatLinksHere/$2|See all links to this page]].",
|
||||||
"notification-header-page-linked": "$3 was {{GENDER:$2|linked}} from $4.",
|
"notification-header-page-linked": "$3 was {{GENDER:$2|linked}} from $4.",
|
||||||
"notification-bundle-header-page-linked": "$3 was {{GENDER:$2|linked}} from $4 and $5 other {{PLURAL:$6|page|pages}}.",
|
"notification-bundle-header-page-linked": "$3 was {{GENDER:$2|linked}} from $4 and $5 other {{PLURAL:$6|page|pages}}.",
|
||||||
|
@ -116,6 +117,7 @@
|
||||||
"echo-date-yesterday": "Yesterday",
|
"echo-date-yesterday": "Yesterday",
|
||||||
"echo-load-more-error": "An error occurred while fetching more results.",
|
"echo-load-more-error": "An error occurred while fetching more results.",
|
||||||
"notification-edit-talk-page-bundle": "$1 and $3 {{PLURAL:$4|other|others}} {{GENDER:$1|left}} a message on your [[User talk:$2|talk page]].",
|
"notification-edit-talk-page-bundle": "$1 and $3 {{PLURAL:$4|other|others}} {{GENDER:$1|left}} a message on your [[User talk:$2|talk page]].",
|
||||||
|
"notification-bundle-header-edit-user-talk": "$1 and $4 {{PLURAL:$5|other|others}} {{GENDER:$2|left}} a message on {{GENDER:$3|your}} talk page.",
|
||||||
"notification-edit-user-talk-email-batch-bundle-body": "$1 and $2 {{PLURAL:$3|other|others}} {{GENDER:$1|left}} a message on your talk page.",
|
"notification-edit-user-talk-email-batch-bundle-body": "$1 and $2 {{PLURAL:$3|other|others}} {{GENDER:$1|left}} a message on your talk page.",
|
||||||
"notification-page-linked-email-batch-bundle-body": "$2 was {{GENDER:$1|linked}} from $3 and $4 other {{PLURAL:$5|page|pages}}.",
|
"notification-page-linked-email-batch-bundle-body": "$2 was {{GENDER:$1|linked}} from $3 and $4 other {{PLURAL:$5|page|pages}}.",
|
||||||
"echo-email-batch-separator": "--",
|
"echo-email-batch-separator": "--",
|
||||||
|
|
|
@ -81,8 +81,9 @@
|
||||||
"notification-link-text-view-edit": "Label for button that links to a \"diff\" view showing an edit made to a page. This is an alternative to the wording in {{msg-mw|notification-link-text-view-changes}}, which serves essentially the same function.",
|
"notification-link-text-view-edit": "Label for button that links to a \"diff\" view showing an edit made to a page. This is an alternative to the wording in {{msg-mw|notification-link-text-view-changes}}, which serves essentially the same function.",
|
||||||
"notification-edit-talk-page2": "Format for displaying notifications of a user talk page being edited. Parameters:\n* $1 - the username of the person who edited, plain text. Can be used for GENDER.\n* $2 - the current user's name, used in the link to their talk page\n* $3 - the section title of the discussion, if any, used in the link to their talk page\nSee also:\n* {{msg-mw|Notification-edit-talk-page-flyout2}}\n* {{msg-mw|Notification-add-talkpage-topic2}}\n* left is for verb left.",
|
"notification-edit-talk-page2": "Format for displaying notifications of a user talk page being edited. Parameters:\n* $1 - the username of the person who edited, plain text. Can be used for GENDER.\n* $2 - the current user's name, used in the link to their talk page\n* $3 - the section title of the discussion, if any, used in the link to their talk page\nSee also:\n* {{msg-mw|Notification-edit-talk-page-flyout2}}\n* {{msg-mw|Notification-add-talkpage-topic2}}\n* left is for verb left.",
|
||||||
"notification-edit-talk-page-with-section": "Format for displaying notifications of a user talk page being edited with a new section or new comment.\n\nParameters:\n* $1 - the username of the person who edited, plain text. Can be used for GENDER.\n* $2 - the username of current user, used in the link to their talk page\n* $3 - the section title of the discussion, if any, used in the link to their talk page\n* $4 - the raw section title text",
|
"notification-edit-talk-page-with-section": "Format for displaying notifications of a user talk page being edited with a new section or new comment.\n\nParameters:\n* $1 - the username of the person who edited, plain text. Can be used for GENDER.\n* $2 - the username of current user, used in the link to their talk page\n* $3 - the section title of the discussion, if any, used in the link to their talk page\n* $4 - the raw section title text",
|
||||||
"notification-edit-talk-page-flyout2": "Flyout-specific format for displaying notifications of a user talk page being edited.\n\nParameters:\n* $1 - the username of the person who edited, plain text. Can be used for GENDER.\n* $2 - the current user's name, used in the link to their talk page\n* $3 - the section title of the discussion, if any, used in the link to their talk page\nSee also:\n* {{msg-mw|Notification-edit-talk-page2}}\n* {{msg-mw|Notification-add-talkpage-topic2}}",
|
"notification-header-edit-user-talk": "Flyout-specific format for displaying notification header of a user talk page being edited.\n\nParameters:\n* $1 - the formatted username of the person who edited.\n* $2 - the username for GENDER\n* $3 - username of the current user, can be used for GENDER\nSee also:\n* {{msg-mw|Notification-edit-talk-page2}}\n* {{msg-mw|Notification-add-talkpage-topic2}}",
|
||||||
"notification-edit-talk-page-flyout-with-section": "Flyout-specific format for displaying notifications of a user talk page being edited with a new section or new comment.\n\nParameters:\n* $1 - the username of the person who edited, plain text. Can be used for GENDER.\n* $2 - the username of current user, used in the link to their talk page\n* $3 - the section title of the discussion, if any, used in the link to their talk page\n* $4 - the raw section title text",
|
"notification-header-edit-user-talk-with-section": "Flyout-specific format for displaying notification header of a user talk page being edited with a new section or new comment.\n\nParameters:\n* $1 - the formatted username of the person who edited.\n* $2 - the username for GENDER\n* $3 - username of the current user, can be used for GENDER\n* $4 - the raw section title text\nSee also:\n* {{msg-mw|Notification-edit-talk-page2}}\n* {{msg-mw|Notification-add-talkpage-topic2}}",
|
||||||
|
"notification-body-edit-user-talk-with-section": "Flyout-specific format for displaying notification body of a user talk page being edited with a new section or new comment.\n\nParameters:\n* $1 - comment left on the user talk page.\n* {{msg-mw|Notification-edit-talk-page2}}\n* {{msg-mw|Notification-add-talkpage-topic2}}",
|
||||||
"notification-page-linked": "Format for displaying notifications of articles being linked. Parameters:\n* $1 - the username of the person who linked the page, plain text. Can be used for GENDER.\n* $2 - the page being linked\n* $3 - the page linked from\nSee also:\n* {{msg-mw|Notification-page-linked-flyout}}\n* {{msg-mw|Notification-page-linked-email-batch-body}}\n* {{msg-mw|Notification-page-linked-email-subject}}",
|
"notification-page-linked": "Format for displaying notifications of articles being linked. Parameters:\n* $1 - the username of the person who linked the page, plain text. Can be used for GENDER.\n* $2 - the page being linked\n* $3 - the page linked from\nSee also:\n* {{msg-mw|Notification-page-linked-flyout}}\n* {{msg-mw|Notification-page-linked-email-batch-body}}\n* {{msg-mw|Notification-page-linked-email-subject}}",
|
||||||
"notification-header-page-linked": "Flyout-specific format for displaying notifications of articles being linked.\n\nParameters:\n* $1 - the formatted username of the person who linked the page. \n* $2 - the username for GENDER\n* $3 - the page being linked\n* $4 - the page linked from\nSee also:\n* {{msg-mw|Notification-page-linked}}\n* {{msg-mw|Notification-page-linked-email-batch-body}}\n* {{msg-mw|Notification-page-linked-email-subject}}",
|
"notification-header-page-linked": "Flyout-specific format for displaying notifications of articles being linked.\n\nParameters:\n* $1 - the formatted username of the person who linked the page. \n* $2 - the username for GENDER\n* $3 - the page being linked\n* $4 - the page linked from\nSee also:\n* {{msg-mw|Notification-page-linked}}\n* {{msg-mw|Notification-page-linked-email-batch-body}}\n* {{msg-mw|Notification-page-linked-email-subject}}",
|
||||||
"notification-bundle-header-page-linked": "Bundled message for page-linked notification. Parameters:\n* $1 - the formatted username of the person who linked the page. \n* $2 - the username for GENDER\n* $3 - the page title\n* $4 - the page linked from\n* $5 - the count of other action performers, could be number or {{msg-mw|Echo-notification-count}}. e.g. 7 or 99+\n* $6 - a number used for plural support (numeric version of $5)\nSee also:\n* {{msg-mw|Notification-page-linked}}\n* {{msg-mw|Notification-page-linked-flyout}}\n* {{msg-mw|Notification-page-linked-email-batch-body}}\n* {{msg-mw|Notification-page-linked-email-subject}}",
|
"notification-bundle-header-page-linked": "Bundled message for page-linked notification. Parameters:\n* $1 - the formatted username of the person who linked the page. \n* $2 - the username for GENDER\n* $3 - the page title\n* $4 - the page linked from\n* $5 - the count of other action performers, could be number or {{msg-mw|Echo-notification-count}}. e.g. 7 or 99+\n* $6 - a number used for plural support (numeric version of $5)\nSee also:\n* {{msg-mw|Notification-page-linked}}\n* {{msg-mw|Notification-page-linked-flyout}}\n* {{msg-mw|Notification-page-linked-email-batch-body}}\n* {{msg-mw|Notification-page-linked-email-subject}}",
|
||||||
|
@ -137,6 +138,7 @@
|
||||||
"echo-date-yesterday": "The header text for yesterday's notification section.\n{{Identical|Yesterday}}",
|
"echo-date-yesterday": "The header text for yesterday's notification section.\n{{Identical|Yesterday}}",
|
||||||
"echo-load-more-error": "Error message for errors in loading more notifications",
|
"echo-load-more-error": "Error message for errors in loading more notifications",
|
||||||
"notification-edit-talk-page-bundle": "Bundled message for edit-user-talk notification. Parameters:\n* $1 - the name of the user who performed the action, which can be used for gender support\n* $2 - the name of the user being addressed\n* $3 - the count of other action performers, could be a number or {{msg-mw|Echo-notification-count}}. e.g. \"7\" or \"99+\"\n* $4 - a number used for plural support relating to $3 (likely identical to $3 it that is a number, and 100 otherwise)\nSee also:\n* {{msg-mw|Notification-edit-talk-page2}}\n* {{msg-mw|Notification-edit-talk-page-email-batch-body2}}\n* {{msg-mw|Notification-edit-talk-page-email-subject2}}",
|
"notification-edit-talk-page-bundle": "Bundled message for edit-user-talk notification. Parameters:\n* $1 - the name of the user who performed the action, which can be used for gender support\n* $2 - the name of the user being addressed\n* $3 - the count of other action performers, could be a number or {{msg-mw|Echo-notification-count}}. e.g. \"7\" or \"99+\"\n* $4 - a number used for plural support relating to $3 (likely identical to $3 it that is a number, and 100 otherwise)\nSee also:\n* {{msg-mw|Notification-edit-talk-page2}}\n* {{msg-mw|Notification-edit-talk-page-email-batch-body2}}\n* {{msg-mw|Notification-edit-talk-page-email-subject2}}",
|
||||||
|
"notification-bundle-header-edit-user-talk": "Bundled flyout header message for edit-user-talk notification. Parameters:\n* $1 - the formatted name of the user who performed the action\n* $2 - the username for GENDER\n* $3 - the name of the user being addressed\n* $4 - the count of other action performers, could be a number or {{msg-mw|Echo-notification-count}}. e.g. \"7\" or \"99+\"\n* $5 - a number used for plural support relating to $4 (likely identical to $4 it that is a number, and 100 otherwise)\nSee also:\n* {{msg-mw|Notification-edit-talk-page2}}\n* {{msg-mw|Notification-edit-talk-page-email-batch-body2}}\n* {{msg-mw|Notification-edit-talk-page-email-subject2}}",
|
||||||
"notification-edit-user-talk-email-batch-bundle-body": "Bundled message for edit-user-talk email digest notification. Parameters:\n* $1 - the username who performs the action, which can be used for gender support\n* $2 - the count of other action performers, could be number or {{msg-mw|echo-notification-count}}\n* $3 - a number used for plural support\n\nSee also:\n* {{msg-mw|Notification-edit-talk-page2}}\n* {{msg-mw|Notification-edit-talk-page-flyout2}}\n* {{msg-mw|Notification-edit-talk-page-email-batch-body2}}\n* {{msg-mw|Notification-edit-talk-page-email-subject2}}",
|
"notification-edit-user-talk-email-batch-bundle-body": "Bundled message for edit-user-talk email digest notification. Parameters:\n* $1 - the username who performs the action, which can be used for gender support\n* $2 - the count of other action performers, could be number or {{msg-mw|echo-notification-count}}\n* $3 - a number used for plural support\n\nSee also:\n* {{msg-mw|Notification-edit-talk-page2}}\n* {{msg-mw|Notification-edit-talk-page-flyout2}}\n* {{msg-mw|Notification-edit-talk-page-email-batch-body2}}\n* {{msg-mw|Notification-edit-talk-page-email-subject2}}",
|
||||||
"notification-page-linked-email-batch-bundle-body": "Bundled message for page-linked email digest notification. Parameters:\n* $1 - the username who performs the action, which can be used for gender support\n* $2 - the link-to page title\n* $3 - the link-from page title\n* $4 - the count of other link-from page title, can be number or {{msg-mw|echo-notification-count}}\n* $5 - a number used for plural support (numeric version of $4)\n\nSee also:\n* {{msg-mw|Notification-page-linked}}\n* {{msg-mw|Notification-page-linked-flyout}}\n* {{msg-mw|Notification-page-linked-email-batch-body}}\n* {{msg-mw|Notification-page-linked-email-subject}}",
|
"notification-page-linked-email-batch-bundle-body": "Bundled message for page-linked email digest notification. Parameters:\n* $1 - the username who performs the action, which can be used for gender support\n* $2 - the link-to page title\n* $3 - the link-from page title\n* $4 - the count of other link-from page title, can be number or {{msg-mw|echo-notification-count}}\n* $5 - a number used for plural support (numeric version of $4)\n\nSee also:\n* {{msg-mw|Notification-page-linked}}\n* {{msg-mw|Notification-page-linked-flyout}}\n* {{msg-mw|Notification-page-linked-email-batch-body}}\n* {{msg-mw|Notification-page-linked-email-subject}}",
|
||||||
"echo-email-batch-separator": "{{optional}}\nEmail batch content separator",
|
"echo-email-batch-separator": "{{optional}}\nEmail batch content separator",
|
||||||
|
|
138
includes/formatters/EditUserTalkPresentationModel.php
Normal file
138
includes/formatters/EditUserTalkPresentationModel.php
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class EchoEditUserTalkPresentationModel extends EchoEventPresentationModel {
|
||||||
|
|
||||||
|
public function canRender() {
|
||||||
|
return (bool)$this->event->getTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIconType() {
|
||||||
|
return 'chat';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrimaryLink() {
|
||||||
|
$title = $this->event->getTitle();
|
||||||
|
if ( $this->hasSection() ) {
|
||||||
|
$title = Title::makeTitle(
|
||||||
|
$title->getNamespace(),
|
||||||
|
$title->getDBkey(),
|
||||||
|
$this->formatSubjectAnchor()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'url' => $title->getFullURL(),
|
||||||
|
'label' => $this->msg( 'notification-link-text-view-message' )->text()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSecondaryLinks() {
|
||||||
|
$diffLink = array(
|
||||||
|
'url' => $this->getDiffLinkUrl(),
|
||||||
|
'label' => $this->msg( 'notification-link-text-view-changes' )->text(),
|
||||||
|
'prioritized' => true
|
||||||
|
);
|
||||||
|
return array( $diffLink );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeaderMessage() {
|
||||||
|
if ( $this->getBundleCount( true, array( $this,'getEventUser' ) ) > 1 ) {
|
||||||
|
$msg = $this->getMessageWithAgent( "notification-bundle-header-{$this->type}" );
|
||||||
|
list( $formattedCount, $countForPlural ) =
|
||||||
|
$this->getNotificationCountForOutput( false, array( $this, 'getEventUser' ) );
|
||||||
|
$msg->params( $this->getViewingUserForGender() );
|
||||||
|
$msg->params( $formattedCount );
|
||||||
|
$msg->params( $countForPlural );
|
||||||
|
return $msg;
|
||||||
|
} elseif ( $this->hasSection() ) {
|
||||||
|
$msg = $this->getMessageWithAgent( "notification-header-{$this->type}-with-section" );
|
||||||
|
$msg->params( $this->getViewingUserForGender() );
|
||||||
|
$msg->params( $this->getSectionTitleSnippet() );
|
||||||
|
return $msg;
|
||||||
|
} else {
|
||||||
|
$msg = parent::getHeaderMessage();
|
||||||
|
$msg->params( $this->getViewingUserForGender() );
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBodyMessage() {
|
||||||
|
if ( $this->getBundleCount( true, array( $this,'getEventUser' ) ) === 1 && $this->hasSection() ) {
|
||||||
|
$msg = $this->msg( 'notification-body-edit-user-talk-with-section' );
|
||||||
|
$msg->params( $this->getRevisionSnippet() );
|
||||||
|
return $msg;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEventUser( EchoEvent $event ) {
|
||||||
|
$agent = $event->getAgent();
|
||||||
|
return $agent->isAnon() ? $agent->getName() : $agent->getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function hasSection() {
|
||||||
|
return (bool)$this->event->getExtraParam( 'section-title' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the section title for a talk page post
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getSectionTitleSnippet() {
|
||||||
|
if ( $this->userCan( Revision::DELETED_TEXT ) ) {
|
||||||
|
return EchoDiscussionParser::getTextSnippet(
|
||||||
|
$this->event->getExtraParam( 'section-title' ),
|
||||||
|
$this->language,
|
||||||
|
30
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return $this->msg( 'echo-rev-deleted-text-view' )->text();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getRevisionSnippet() {
|
||||||
|
$sectionText = $this->event->getExtraParam( 'section-text' );
|
||||||
|
if ( $sectionText === null || !$this->userCan( Revision::DELETED_TEXT ) ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return trim( $sectionText );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the subject anchor (linkable portion of the edited page) from
|
||||||
|
* the event.
|
||||||
|
*
|
||||||
|
* @return string The anchor on page, or an empty string
|
||||||
|
*/
|
||||||
|
private function formatSubjectAnchor() {
|
||||||
|
global $wgParser;
|
||||||
|
|
||||||
|
if ( !$this->userCan( Revision::DELETED_TEXT ) ) {
|
||||||
|
return $this->msg( 'echo-rev-deleted-text-view' )->text();
|
||||||
|
}
|
||||||
|
$sectionTitle = $this->event->getExtraParam( 'section-title' );
|
||||||
|
if ( $sectionTitle === null ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strip out #
|
||||||
|
return substr( $wgParser->guessLegacySectionNameFromWikiText( $sectionTitle ), 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDiffLinkUrl() {
|
||||||
|
$revId = $this->event->getExtraParam( 'revid' );
|
||||||
|
$oldId = $this->isBundled() ? $this->getRevBeforeFirstNotification() : 'prev';
|
||||||
|
$query = array(
|
||||||
|
'oldid' => $oldId,
|
||||||
|
'diff' => $revId,
|
||||||
|
);
|
||||||
|
return $this->event->getTitle()->getFullURL( $query );
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getRevBeforeFirstNotification() {
|
||||||
|
$firstNotificationRevId = end( $this->getBundledEvents() )->getExtraParam( 'revid' );
|
||||||
|
return $this->event->getTitle()->getPreviousRevisionID( $firstNotificationRevId );
|
||||||
|
}
|
||||||
|
}
|
|
@ -46,30 +46,6 @@ class EchoNotificationFormatterTest extends MediaWikiTestCase {
|
||||||
$this->assertEquals( '', $mainPageCached->getFragment() );
|
$this->assertEquals( '', $mainPageCached->getFragment() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provider_editUserTalk() {
|
|
||||||
return array(
|
|
||||||
// if there is a section-title, the message should be '[[User:user_name|user_name]] left a message on
|
|
||||||
// your talk page in '[[User talk:user_name#section_title|section_title]]'
|
|
||||||
array( '/[[User talk:[^#]+#moar_cowbell|moar_cowbell]]/', 'moar_cowbell', 'text' ),
|
|
||||||
array( '/#moar_cowbell/', 'moar_cowbell', 'html' ),
|
|
||||||
array( '/#moar_cowbell/', 'moar_cowbell', 'flyout' ),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider provider_editUserTalk
|
|
||||||
*/
|
|
||||||
public function testEditUserTalkFlyoutSectionLinkFragment( $pattern, $sectionTitle, $format ) {
|
|
||||||
// Required hack so parser doesnt turn the links into redlinks which contain no fragment
|
|
||||||
global $wgUser;
|
|
||||||
LinkCache::singleton()->addGoodLinkObj( 42, $wgUser->getTalkPage() );
|
|
||||||
|
|
||||||
$event = $this->mockEvent( 'edit-user-talk', array(
|
|
||||||
'section-title' => $sectionTitle,
|
|
||||||
) );
|
|
||||||
$this->assertRegExp( $pattern, $this->format( $event, $format ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provider_formatterDoesntFail() {
|
public function provider_formatterDoesntFail() {
|
||||||
// Remove events from this array once they have specific tests for their formatting
|
// Remove events from this array once they have specific tests for their formatting
|
||||||
$untested = array(
|
$untested = array(
|
||||||
|
|
Loading…
Reference in a new issue