Comments/includes/CommentsLogFormatter.php

41 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2017-09-27 17:53:26 +02:00
<?php
/**
* Logging formatter for Comments' log entries.
*
* @file
* @date 28 July 2013
*/
class CommentsLogFormatter extends WikitextLogFormatter {
2017-09-27 17:53:26 +02:00
/**
* Formats parameters intented for action message from
* array of all parameters. There are three hardcoded
* parameters (array is zero-indexed, this list not):
* - 1: user name with premade link
* - 2: usable for gender magic function
* - 3: target page with premade link
* @return array
*/
protected function getMessageParameters() {
if ( isset( $this->parsedParameters ) ) {
return $this->parsedParameters;
}
$entry = $this->entry;
$params = $this->extractParameters();
$commentId = $params[3]; // = $4, because array numbering starts from 0
$params[0] = Message::rawParam( $this->getPerformerElement() );
$params[1] = $this->canView( LogPage::DELETED_USER ) ? $entry->getPerformer()->getName() : '';
$title = $entry->getTarget();
if ( $title instanceof Title ) { // healthy paranoia
$title->setFragment( '#comment-' . $commentId );
}
$params[2] = Message::rawParam( $this->makePageLink( $title ) );
// Bad things happens if the numbers are not in correct order
ksort( $params );
return $this->parsedParameters = $params;
}
}