Merge "Show absolute block expiry in user timezone on block logs"
This commit is contained in:
commit
bb333d91a4
3 changed files with 11 additions and 7 deletions
|
|
@ -58,7 +58,8 @@ class BlockLogFormatter extends LogFormatter {
|
|||
// 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() ) : '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3895,10 +3895,11 @@ class Language {
|
|||
* match up with it.
|
||||
*
|
||||
* @param string $str The validated block duration in English
|
||||
* @param User $user User object to use timezone from or null for $wgUser
|
||||
* @return string Somehow translated block duration
|
||||
* @see LanguageFi.php for example implementation
|
||||
*/
|
||||
function translateBlockExpiry( $str ) {
|
||||
function translateBlockExpiry( $str, User $user = null ) {
|
||||
$duration = SpecialBlock::getSuggestedDurations( $this );
|
||||
foreach ( $duration as $show => $value ) {
|
||||
if ( strcmp( $str, $value ) == 0 ) {
|
||||
|
|
@ -3924,10 +3925,12 @@ class Language {
|
|||
} else { // It's an absolute timestamp.
|
||||
if ( $time === 0 ) {
|
||||
// wfTimestamp() handles 0 as current time instead of epoch.
|
||||
return $this->timeanddate( '19700101000000' );
|
||||
} else {
|
||||
return $this->timeanddate( $time );
|
||||
$time = '19700101000000';
|
||||
}
|
||||
if ( $user ) {
|
||||
return $this->userTimeAndDate( $time, $user );
|
||||
}
|
||||
return $this->timeanddate( $time );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,10 +84,10 @@ class LanguageFi extends Language {
|
|||
|
||||
/**
|
||||
* @param string $str
|
||||
* @param bool $forContent
|
||||
* @param User $user User object to use timezone from or null for $wgUser
|
||||
* @return string
|
||||
*/
|
||||
function translateBlockExpiry( $str, $forContent = false ) {
|
||||
function translateBlockExpiry( $str, User $user = null ) {
|
||||
/*
|
||||
'ago', 'now', 'today', 'this', 'next',
|
||||
'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth',
|
||||
|
|
|
|||
Loading…
Reference in a new issue