You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.2 KiB
PHTML

5 years ago
<?php
namespace Isekai\AIReview;
use LogFormatter as GlobalLogFormatter;
2 years ago
use MediaWiki\MediaWikiServices;
use MediaWiki\SpecialPage\SpecialPage;
use MediaWiki\Message\Message;
use MediaWiki\Linker\Linker;
use MediaWiki\Title\Title;
5 years ago
class LogFormatter extends GlobalLogFormatter {
2 years ago
/**
* @param array $params
* @return array
* @throws \MWException
*/
public function buildBaseParams(array $params): array {
$services = MediaWikiServices::getInstance();
$linkRenderer = $this->getLinkRenderer();
$entryParams = $this->entry->getParameters();
$modId = $entryParams['modid'];
$user = $services->getUserFactory()->newFromId($entryParams['moduser']);
$userLink = Linker::userLink($user->getId(), $user->getName());
$params[3] = Message::rawParam($userLink);
$link = $linkRenderer->makeKnownLink(
SpecialPage::getTitleFor('Moderation'),
$this->msg('moderation-log-change')->params($modId)->text(),
['title' => $this->msg('tooltip-moderation-rejected-change')->plain()],
['modaction' => 'show', 'modid' => $modId]
);
$params[4] = Message::rawParam($link);
return $params;
}
5 years ago
public function getMessageParameters(){
$params = parent::getMessageParameters();
$entryParams = $this->entry->getParameters();
2 years ago
$type = $this->entry->getSubtype();
5 years ago
switch($type){
case 'approve':
2 years ago
$params = $this->buildBaseParams($params);
5 years ago
break;
case 'reject':
2 years ago
$params = $this->buildBaseParams($params);
5 years ago
$params[5] = Utils::getReadableReason($entryParams['reason']);
break;
}
return $params;
}
public function getPreloadTitles() {
2 years ago
$services = MediaWikiServices::getInstance();
5 years ago
$type = $this->entry->getSubtype();
$params = $this->entry->getParameters();
$titles = [];
if ( $params['moduser'] ) { # Not anonymous
2 years ago
$user = $services->getUserFactory()->newFromId($params['moduser']);
5 years ago
$titles[] = Title::makeTitle( NS_USER, $user->getName() );
}
return $titles;
}
}