// is shown on the correct side of the tooltip text.
$durationTooltip = '‎' . htmlspecialchars( $params[4] );
$params[4] = Message::rawParam( "<span class='blockExpiry' title='$durationTooltip'>" .
- $this->context->getLanguage()->translateBlockExpiry( $params[4] ) . '</span>' );
+ $this->context->getLanguage()->translateBlockExpiry( $params[4],
+ $this->context->getUser() ) . '</span>' );
$params[5] = isset( $params[5] ) ?
self::formatBlockFlags( $params[5], $this->context->getLanguage() ) : '';
}
$title = $this->entry->getTarget();
// Preload user page for non-autoblocks
if ( substr( $title->getText(), 0, 1 ) !== '#' ) {
- return array( $title->getTalkPage() );
+ return [ $title->getTalkPage() ];
}
- return array();
+ return [];
}
public function getActionLinks() {
// Show unblock/change block link
$title = $this->entry->getTarget();
- $links = array(
+ $links = [
Linker::linkKnown(
SpecialPage::getTitleFor( 'Unblock', $title->getDBkey() ),
$this->msg( 'unblocklink' )->escaped()
SpecialPage::getTitleFor( 'Block', $title->getDBkey() ),
$this->msg( 'change-blocklink' )->escaped()
)
- );
+ ];
return $this->msg( 'parentheses' )->rawParams(
$this->context->getLanguage()->pipeList( $links ) )->escaped();
public static function formatBlockFlags( $flags, $lang ) {
$flags = trim( $flags );
if ( $flags === '' ) {
- return ''; //nothing to do
+ return ''; // nothing to do
}
$flags = explode( ',', $flags );
$flagsCount = count( $flags );
* @return string
*/
public static function formatBlockFlag( $flag, $lang ) {
- static $messages = array();
+ static $messages = [];
if ( !isset( $messages[$flag] ) ) {
$messages[$flag] = htmlspecialchars( $flag ); // Fallback
return $messages[$flag];
}
+
+ protected function getParametersForApi() {
+ $entry = $this->entry;
+ $params = $entry->getParameters();
+
+ static $map = [
+ // While this looks wrong to be starting at 5 rather than 4, it's
+ // because getMessageParameters uses $4 for its own purposes.
+ '5::duration',
+ '6:array:flags',
+ '6::flags' => '6:array:flags',
+ ];
+ foreach ( $map as $index => $key ) {
+ if ( isset( $params[$index] ) ) {
+ $params[$key] = $params[$index];
+ unset( $params[$index] );
+ }
+ }
+
+ $subtype = $entry->getSubtype();
+ if ( $subtype === 'block' || $subtype === 'reblock' ) {
+ // Defaults for old log entries missing some fields
+ $params += [
+ '5::duration' => 'infinite',
+ '6:array:flags' => [],
+ ];
+
+ if ( !is_array( $params['6:array:flags'] ) ) {
+ $params['6:array:flags'] = $params['6:array:flags'] === ''
+ ? []
+ : explode( ',', $params['6:array:flags'] );
+ }
+
+ if ( !wfIsInfinity( $params['5::duration'] ) ) {
+ $ts = wfTimestamp( TS_UNIX, $entry->getTimestamp() );
+ $expiry = strtotime( $params['5::duration'], $ts );
+ if ( $expiry !== false && $expiry > 0 ) {
+ $params[':timestamp:expiry'] = $expiry;
+ }
+ }
+ }
+
+ return $params;
+ }
+
+ public function formatParametersForApi() {
+ $ret = parent::formatParametersForApi();
+ if ( isset( $ret['flags'] ) ) {
+ ApiResult::setIndexedTagName( $ret['flags'], 'f' );
+ }
+ return $ret;
+ }
+
}