(bug 18361) Suppression log should be in the UI language, not content language

This commit is contained in:
Aaron Schulz 2009-04-10 20:01:10 +00:00
parent 077bd631af
commit ec0dd5b272
3 changed files with 38 additions and 33 deletions

View file

@ -282,7 +282,7 @@ class LogEventsList {
'mergepoint' => $paramArray[1] ) ) ) . ')'; 'mergepoint' => $paramArray[1] ) ) ) . ')';
// If an edit was hidden from a page give a review link to the history // If an edit was hidden from a page give a review link to the history
} else if( self::typeAction($row,array('delete','suppress'),'revision','deleterevision') ) { } else if( self::typeAction($row,array('delete','suppress'),'revision','deleterevision') ) {
if( count($paramArray) == 2 ) { if( count($paramArray) >= 2 ) {
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
// Different revision types use different URL params... // Different revision types use different URL params...
$key = $paramArray[0]; $key = $paramArray[0];
@ -304,7 +304,7 @@ class LogEventsList {
} }
// Hidden log items, give review link // Hidden log items, give review link
} else if( self::typeAction($row,array('delete','suppress'),'event','deleterevision') ) { } else if( self::typeAction($row,array('delete','suppress'),'event','deleterevision') ) {
if( count($paramArray) == 1 ) { if( count($paramArray) >= 1 ) {
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
// $paramArray[1] is a CVS of the IDs // $paramArray[1] is a CVS of the IDs
$Ids = explode( ',', $paramArray[0] ); $Ids = explode( ',', $paramArray[0] );

View file

@ -201,6 +201,7 @@ class LogPage {
} else { } else {
$details = ''; $details = '';
array_unshift( $params, $titleLink ); array_unshift( $params, $titleLink );
// User suppression
if ( preg_match( '/^(block|suppress)\/(block|reblock)$/', $key ) ) { if ( preg_match( '/^(block|suppress)\/(block|reblock)$/', $key ) ) {
if ( $skin ) { if ( $skin ) {
$params[1] = '<span title="' . htmlspecialchars( $params[1] ). '">' . $params[1] = '<span title="' . htmlspecialchars( $params[1] ). '">' .
@ -210,6 +211,7 @@ class LogPage {
} }
$params[2] = isset( $params[2] ) ? $params[2] = isset( $params[2] ) ?
self::formatBlockFlags( $params[2], is_null( $skin ) ) : ''; self::formatBlockFlags( $params[2], is_null( $skin ) ) : '';
// Page protections
} else if ( $type == 'protect' && count($params) == 3 ) { } else if ( $type == 'protect' && count($params) == 3 ) {
$details .= " {$params[1]}"; // restrictions and expiries $details .= " {$params[1]}"; // restrictions and expiries
if( $params[2] ) { if( $params[2] ) {
@ -219,6 +221,7 @@ class LogPage {
$details .= ' ['.wfMsgForContent('protect-summary-cascade').']'; $details .= ' ['.wfMsgForContent('protect-summary-cascade').']';
} }
} }
// Page moves
} else if ( $type == 'move' && count( $params ) == 3 ) { } else if ( $type == 'move' && count( $params ) == 3 ) {
if( $params[2] ) { if( $params[2] ) {
if ( $skin ) { if ( $skin ) {
@ -227,6 +230,18 @@ class LogPage {
$details .= ' [' . wfMsgForContent( 'move-redirect-suppressed' ) . ']'; $details .= ' [' . wfMsgForContent( 'move-redirect-suppressed' ) . ']';
} }
} }
// Revision deletion
} else if ( preg_match( '/^(delete|suppress)\/revision$/', $key ) && count( $params ) == 5 ) {
$count = substr_count( $params[1], ',' ) + 1; // revisions
$ofield = intval( substr( $params[3], 7 ) ); // <ofield=x>
$nfield = intval( substr( $params[4], 7 ) ); // <nfield=x>
$details .= ': '.RevisionDeleter::getLogMessage( $count, $nfield, $ofield, false );
// Log deletion
} else if ( preg_match( '/^(delete|suppress)\/event$/', $key ) && count( $params ) == 4 ) {
$count = substr_count( $params[1], ',' ) + 1; // log items
$ofield = intval( substr( $params[2], 7 ) ); // <ofield=x>
$nfield = intval( substr( $params[3], 7 ) ); // <nfield=x>
$details .= ': '.RevisionDeleter::getLogMessage( $count, $nfield, $ofield, true );
} }
$rv = wfMsgReal( $wgLogActions[$key], $params, true, !$skin ) . $details; $rv = wfMsgReal( $wgLogActions[$key], $params, true, !$skin ) . $details;
} }

View file

@ -165,7 +165,9 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
} }
// Format is <id1,id2,i3...> // Format is <id1,id2,i3...>
if( count($safeIds) ) { if( count($safeIds) ) {
$conds[] = "log_params RLIKE '(^|\n|,)(".implode('|',$safeIds).")(,|$)'"; $conds[] = "log_params RLIKE '(^|\n|,)(".implode('|',$safeIds).")(,|\n|$)'";
} else {
$conds = array('1=0');
} }
return array($conds,$limit); return array($conds,$limit);
} }
@ -678,9 +680,8 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
$pageLink = "<a href=\"{$url}\">{$date}</a>"; $pageLink = "<a href=\"{$url}\">{$date}</a>";
} }
$data = wfMsg( 'widthheight', $data = wfMsg( 'widthheight', $wgLang->formatNum( $file->getWidth() ),
$wgLang->formatNum( $file->getWidth() ), $wgLang->formatNum( $file->getHeight() ) ) .
$wgLang->formatNum( $file->getHeight() ) ) .
' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')'; ' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')';
$data = htmlspecialchars( $data ); $data = htmlspecialchars( $data );
@ -707,9 +708,8 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
$del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>'; $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
} }
$data = wfMsg( 'widthheight', $data = wfMsg( 'widthheight', $wgLang->formatNum( $file->getWidth() ),
$wgLang->formatNum( $file->getWidth() ), $wgLang->formatNum( $file->getHeight() ) ) .
$wgLang->formatNum( $file->getHeight() ) ) .
' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')'; ' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')';
$data = htmlspecialchars( $data ); $data = htmlspecialchars( $data );
@ -1467,7 +1467,7 @@ class RevisionDeleter {
* @param int $diff The xor of the old and new bitfields. * @param int $diff The xor of the old and new bitfields.
* @param array $arr The array to update. * @param array $arr The array to update.
*/ */
function checkItem( $desc, $field, $diff, $new, &$arr ) { protected static function checkItem( $desc, $field, $diff, $new, &$arr ) {
if( $diff & $field ) { if( $diff & $field ) {
$arr[ ( $new & $field ) ? 0 : 1 ][] = $desc; $arr[ ( $new & $field ) ? 0 : 1 ][] = $desc;
} }
@ -1485,15 +1485,15 @@ class RevisionDeleter {
* @param int $o The old bitfield. * @param int $o The old bitfield.
* @return An array as described above. * @return An array as described above.
*/ */
function getChanges( $n, $o ) { protected static function getChanges( $n, $o ) {
$diff = $n ^ $o; $diff = $n ^ $o;
$ret = array( 0 => array(), 1 => array(), 2 => array() ); $ret = array( 0 => array(), 1 => array(), 2 => array() );
// Build bitfield changes in language // Build bitfield changes in language
$this->checkItem( wfMsgForContent( 'revdelete-content' ), self::checkItem( wfMsgForContent( 'revdelete-content' ),
Revision::DELETED_TEXT, $diff, $n, $ret ); Revision::DELETED_TEXT, $diff, $n, $ret );
$this->checkItem( wfMsgForContent( 'revdelete-summary' ), self::checkItem( wfMsgForContent( 'revdelete-summary' ),
Revision::DELETED_COMMENT, $diff, $n, $ret ); Revision::DELETED_COMMENT, $diff, $n, $ret );
$this->checkItem( wfMsgForContent( 'revdelete-uname' ), self::checkItem( wfMsgForContent( 'revdelete-uname' ),
Revision::DELETED_USER, $diff, $n, $ret ); Revision::DELETED_USER, $diff, $n, $ret );
// Restriction application to sysops // Restriction application to sysops
if( $diff & Revision::DELETED_RESTRICTED ) { if( $diff & Revision::DELETED_RESTRICTED ) {
@ -1513,15 +1513,12 @@ class RevisionDeleter {
* @param int $count The number of effected revisions. * @param int $count The number of effected revisions.
* @param int $nbitfield The new bitfield for the revision. * @param int $nbitfield The new bitfield for the revision.
* @param int $obitfield The old bitfield for the revision. * @param int $obitfield The old bitfield for the revision.
* @param string $comment The comment associated with the change.
* @param bool $isForLog * @param bool $isForLog
*/ */
function getLogMessage( $count, $nbitfield, $obitfield, $comment, $isForLog = false ) { public static function getLogMessage( $count, $nbitfield, $obitfield, $isForLog = false ) {
global $wgContLang; global $wgLang;
$s = ''; $s = '';
$changes = $this->getChanges( $nbitfield, $obitfield ); $changes = self::getChanges( $nbitfield, $obitfield );
if( count( $changes[0] ) ) { if( count( $changes[0] ) ) {
$s .= wfMsgForContent ( 'revdelete-hid', implode ( ', ', $changes[0] ) ); $s .= wfMsgForContent ( 'revdelete-hid', implode ( ', ', $changes[0] ) );
} }
@ -1532,14 +1529,8 @@ class RevisionDeleter {
if( count( $changes[2] ) ) { if( count( $changes[2] ) ) {
$s .= $s ? ' (' . $changes[2][0] . ')' : $changes[2][0]; $s .= $s ? ' (' . $changes[2][0] . ')' : $changes[2][0];
} }
$msg = $isForLog ? 'logdelete-log-message' : 'revdelete-log-message'; $msg = $isForLog ? 'logdelete-log-message' : 'revdelete-log-message';
$ret = wfMsgExt ( $msg, array( 'parsemag', 'content' ), return wfMsgExt( $msg, array( 'parsemag', 'content' ), $s, $wgLang->formatNum($count) );
$s, $wgContLang->formatNum( $count ) );
if( $comment ) $ret .= ": $comment";
return $ret;
} }
@ -1561,16 +1552,15 @@ class RevisionDeleter {
$logtype = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ? $logtype = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ?
'suppress' : 'delete'; 'suppress' : 'delete';
$log = new LogPage( $logtype ); $log = new LogPage( $logtype );
$itemCSV = implode(',',$items);
$reason = $this->getLogMessage( $count, $nbitfield, $obitfield, $comment, $param == 'logid' );
if( $param == 'logid' ) { if( $param == 'logid' ) {
$params = array( implode( ',', $items) ); $params = array( $itemCSV, "ofield={$obitfield}", "nfield={$nbitfield}" );
$log->addEntry( 'event', $title, $reason, $params ); $log->addEntry( 'event', $title, $comment, $params );
} else { } else {
// Add params for effected page and ids // Add params for effected page and ids
$params = array( $param, implode( ',', $items) ); $params = array( $param, $itemCSV, "ofield={$obitfield}", "nfield={$nbitfield}" );
$log->addEntry( 'revision', $title, $reason, $params ); $log->addEntry( 'revision', $title, $comment, $params );
} }
} }
} }