2013-04-10 03:45:44 +00:00
|
|
|
<?php
|
2018-11-10 21:06:01 +00:00
|
|
|
|
2021-03-14 03:43:32 +00:00
|
|
|
namespace MediaWiki\Extension\Thanks;
|
|
|
|
|
2024-07-14 20:55:48 +00:00
|
|
|
use LogEntry;
|
2021-03-14 03:43:32 +00:00
|
|
|
use LogFormatter;
|
2024-06-10 20:00:10 +00:00
|
|
|
use MediaWiki\Message\Message;
|
2024-07-14 20:55:48 +00:00
|
|
|
use MediaWiki\Title\NamespaceInfo;
|
2024-01-04 21:22:56 +00:00
|
|
|
use MediaWiki\User\User;
|
2021-03-14 03:43:32 +00:00
|
|
|
|
2013-04-10 03:45:44 +00:00
|
|
|
/**
|
|
|
|
* This class formats log entries for thanks
|
|
|
|
*/
|
|
|
|
class ThanksLogFormatter extends LogFormatter {
|
2024-07-14 20:55:48 +00:00
|
|
|
private NamespaceInfo $namespaceInfo;
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
LogEntry $entry,
|
|
|
|
NamespaceInfo $namespaceInfo
|
|
|
|
) {
|
|
|
|
parent::__construct( $entry );
|
|
|
|
$this->namespaceInfo = $namespaceInfo;
|
|
|
|
}
|
|
|
|
|
2018-08-23 09:36:19 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2013-04-10 03:45:44 +00:00
|
|
|
protected function getMessageParameters() {
|
|
|
|
$params = parent::getMessageParameters();
|
|
|
|
// Convert target from a pageLink to a userLink since the target is
|
|
|
|
// actually a user, not a page.
|
|
|
|
$recipient = User::newFromName( $this->entry->getTarget()->getText(), false );
|
|
|
|
$params[2] = Message::rawParam( $this->makeUserLink( $recipient ) );
|
2013-08-20 23:23:37 +00:00
|
|
|
$params[3] = $recipient->getName();
|
2013-04-10 03:45:44 +00:00
|
|
|
return $params;
|
|
|
|
}
|
2016-04-22 20:13:56 +00:00
|
|
|
|
2013-04-10 03:45:44 +00:00
|
|
|
public function getPreloadTitles() {
|
|
|
|
// Add the recipient's user talk page to LinkBatch
|
2024-07-14 20:55:48 +00:00
|
|
|
return [ $this->namespaceInfo->getTalkPage( $this->entry->getTarget() ) ];
|
2013-04-10 03:45:44 +00:00
|
|
|
}
|
|
|
|
}
|