diff --git a/i18n/en.json b/i18n/en.json index ab944588..975ec965 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -34,6 +34,7 @@ "echo-category-title-edit-thank": "Thanks", "notification-thanks-diff-link": "your edit", "notification-header-rev-thank": "$1 {{GENDER:$2|thanked}} {{GENDER:$4|you}} for your edit on $3.", + "notification-header-creation-thank": "$1 {{GENDER:$2|thanked}} {{GENDER:$4|you}} for your creation of $3.", "notification-header-log-thank": "$1 {{GENDER:$2|thanked}} {{GENDER:$4|you}} for your action relating to $3.", "notification-compact-header-edit-thank": "$1 {{GENDER:$2|thanked}} {{GENDER:$3|you}}.", "notification-bundle-header-rev-thank": "{{PLURAL:$1|One person|$1 people|100=99+ people}} thanked {{GENDER:$3|you}} for your edit on $2.", diff --git a/i18n/qqq.json b/i18n/qqq.json index b274070b..cbc10177 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -45,6 +45,7 @@ "echo-category-title-edit-thank": "{{doc-echo-category-title|tooltip=Echo-pref-tooltip-edit-thank}}\n{{Identical|Thank}}", "notification-thanks-diff-link": "The text of a link to the user's edit.\n\nUsed for $2 in {{msg-mw|Notification-thanks}}. Should have capitalization appropriate for the middle of a sentence.\n\nThis is an object in a sentence so it should be in object case in languages where there is a special object form for words.", "notification-header-rev-thank": "Header text for a notification when a user is thanked for their edit. Parameters:\n* $1 is the username of the user sending the thanks (not suitable for GENDER).\n* $2 is the thanking user's name for use in GENDER.\n* $3 is the title of the page the thanked user edited.\n* $4 is the username of the user being thanked, for use in GENDER.", + "notification-header-creation-thank": "Header text for a notification when a user is thanked for their creation of a page. Parameters:\n* $1 is the username of the user sending the thanks (not suitable for GENDER).\n* $2 is the thanking user's name for use in GENDER.\n* $3 is the title of the page the thanked user created.\n* $4 is the username of the user being thanked, for use in GENDER.", "notification-header-log-thank": "Header text for a notification when a user is thanked for a log entry. Parameters:\n* $1 is the username of the user sending the thanks (not suitable for GENDER).\n* $2 is the thanking user's name for use in GENDER.\n* $3 is the title of the page that is the target of the log entry.\n* $4 is the username of the user being thanked, for use in GENDER.", "notification-compact-header-edit-thank": "Compact header text for a notification when a user is thanked for their edit. Parameters:\n* $1 is the username of the user sending the thanks (not suitable for GENDER).\n* $2 is the thanking user's name for use in GENDER.\n* $3 is the username of the user being thanked, for use in GENDER.", "notification-bundle-header-rev-thank": "Bundle header text for a notification when a user is thanked for their edit. Parameters:\n* $1 is the number of users who sent thanks for the same edit. When used with PLURAL, the value 100 represents more than 99.\n* $2 is the title of the page the thanked user edited.\n* $3 is the username of the user being thanked, for use in GENDER.\n{{Related|Notification-bundle}}", diff --git a/includes/ApiCoreThank.php b/includes/ApiCoreThank.php index 838f7233..38ac6c52 100644 --- a/includes/ApiCoreThank.php +++ b/includes/ApiCoreThank.php @@ -16,6 +16,7 @@ class ApiCoreThank extends ApiThank { $user = $this->getUser(); $this->dieOnBadUser( $user ); $params = $this->extractRequestParams(); + $revcreation = false; $this->requireOnlyOneParameter( $params, 'rev', 'log' ); @@ -50,6 +51,11 @@ class ApiCoreThank extends ApiThank { $title = $this->getTitleFromRevision( $revision ); $recipient = $this->getUserFromRevision( $revision ); $recipientUsername = $revision->getUserText(); + + // If there is no parent revid of this revision, it's a page creation. + if ( !(bool)$revision->getPrevious() ) { + $revcreation = true; + } } // Send thanks. @@ -64,7 +70,8 @@ class ApiCoreThank extends ApiThank { $excerpt, $recipient, $this->getSourceFromParams( $params ), - $title + $title, + $revcreation ); } } @@ -170,9 +177,10 @@ class ApiCoreThank extends ApiThank { * @param User $recipient The recipient of the thanks. * @param string $source Where the thanks was given. * @param Title $title The title of the page for which thanks is given. + * @param bool $revcreation True if the linked revision is a page creation. */ protected function sendThanks( - User $user, $type, $id, $excerpt, User $recipient, $source, Title $title + User $user, $type, $id, $excerpt, User $recipient, $source, Title $title, $revcreation ) { $uniqueId = $type . '-' . $id; // Do one last check to make sure we haven't sent Thanks before @@ -191,6 +199,7 @@ class ApiCoreThank extends ApiThank { 'thanked-user-id' => $recipient->getId(), 'source' => $source, 'excerpt' => $excerpt, + 'revcreation' => $revcreation, ], 'agent' => $user, ] ); diff --git a/includes/EchoCoreThanksPresentationModel.php b/includes/EchoCoreThanksPresentationModel.php index 2b334351..514b14a8 100644 --- a/includes/EchoCoreThanksPresentationModel.php +++ b/includes/EchoCoreThanksPresentationModel.php @@ -27,8 +27,13 @@ class EchoCoreThanksPresentationModel extends EchoEventPresentationModel { $msg->params( $this->getViewingUserForGender() ); return $msg; } else { - // Message is either notification-header-rev-thank or notification-header-log-thank. - $msg = $this->getMessageWithAgent( "notification-header-$type-thank" ); + if ( $this->event->getExtraParam( 'revcreation', null ) ) { + // This is a thank on a page creation revision. + $msg = $this->getMessageWithAgent( "notification-header-creation-thank" ); + } else { + // Message is either notification-header-rev-thank or notification-header-log-thank. + $msg = $this->getMessageWithAgent( "notification-header-$type-thank" ); + } $msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) ); $msg->params( $this->getViewingUserForGender() ); return $msg;