*
* @file
* @author Niklas Laxström
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
* @since 1.22
*/
-use MediaWiki\MediaWikiServices;
+use MediaWiki\Storage\RevisionRecord;
/**
* This class formats delete log entries.
// logentry-suppress-event-legacy, logentry-suppress-revision-legacy
return "$key-legacy";
}
+ } elseif ( $this->entry->getSubtype() === 'restore' ) {
+ $rawParams = $this->entry->getParameters();
+ if ( !isset( $rawParams[':assoc:count'] ) ) {
+ // Message: logentry-delete-restore-nocount
+ return $key . '-nocount';
+ }
}
return $key;
$this->parsedParametersDeleteLog = array_slice( $params, 0, 3 );
return $this->parsedParametersDeleteLog;
}
+ } elseif ( $subtype === 'restore' ) {
+ $rawParams = $this->entry->getParameters();
+ if ( isset( $rawParams[':assoc:count'] ) ) {
+ $countList = [];
+ foreach ( $rawParams[':assoc:count'] as $type => $count ) {
+ if ( $count ) {
+ // Messages: restore-count-revisions, restore-count-files
+ $countList[] = $this->context->msg( 'restore-count-' . $type )
+ ->numParams( $count )->plain();
+ }
+ }
+ $params[3] = $this->context->getLanguage()->listToText( $countList );
+ }
}
$this->parsedParametersDeleteLog = $params;
public function getActionLinks() {
$user = $this->context->getUser();
- $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
+ $linkRenderer = $this->getLinkRenderer();
if ( !$user->isAllowed( 'deletedhistory' )
|| $this->entry->isDeleted( LogPage::DELETED_ACTION )
) {
}
}
- $old = $this->parseBitField( $rawParams['6::ofield'] );
- $new = $this->parseBitField( $rawParams['7::nfield'] );
if ( !is_array( $rawParams['5::ids'] ) ) {
$rawParams['5::ids'] = explode( ',', $rawParams['5::ids'] );
}
$params = [
'::type' => $rawParams['4::type'],
':array:ids' => $rawParams['5::ids'],
- ':assoc:old' => [ 'bitmask' => $old ],
- ':assoc:new' => [ 'bitmask' => $new ],
];
static $fields = [
- Revision::DELETED_TEXT => 'content',
- Revision::DELETED_COMMENT => 'comment',
- Revision::DELETED_USER => 'user',
- Revision::DELETED_RESTRICTED => 'restricted',
+ RevisionRecord::DELETED_TEXT => 'content',
+ RevisionRecord::DELETED_COMMENT => 'comment',
+ RevisionRecord::DELETED_USER => 'user',
+ RevisionRecord::DELETED_RESTRICTED => 'restricted',
];
- foreach ( $fields as $bit => $key ) {
- $params[':assoc:old'][$key] = (bool)( $old & $bit );
- $params[':assoc:new'][$key] = (bool)( $new & $bit );
+
+ if ( isset( $rawParams['6::ofield'] ) ) {
+ $old = $this->parseBitField( $rawParams['6::ofield'] );
+ $params[':assoc:old'] = [ 'bitmask' => $old ];
+ foreach ( $fields as $bit => $key ) {
+ $params[':assoc:old'][$key] = (bool)( $old & $bit );
+ }
+ }
+ if ( isset( $rawParams['7::nfield'] ) ) {
+ $new = $this->parseBitField( $rawParams['7::nfield'] );
+ $params[':assoc:new'] = [ 'bitmask' => $new ];
+ foreach ( $fields as $bit => $key ) {
+ $params[':assoc:new'][$key] = (bool)( $new & $bit );
+ }
+ }
+ } elseif ( $subtype === 'restore' ) {
+ $rawParams = $entry->getParameters();
+ if ( isset( $rawParams[':assoc:count'] ) ) {
+ $params[':assoc:count'] = $rawParams[':assoc:count'];
}
}