summaryrefslogtreecommitdiff
path: root/includes/logging/DeleteLogFormatter.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/logging/DeleteLogFormatter.php')
-rw-r--r--includes/logging/DeleteLogFormatter.php78
1 files changed, 74 insertions, 4 deletions
diff --git a/includes/logging/DeleteLogFormatter.php b/includes/logging/DeleteLogFormatter.php
index 8b30e9ba..f0598aa7 100644
--- a/includes/logging/DeleteLogFormatter.php
+++ b/includes/logging/DeleteLogFormatter.php
@@ -79,8 +79,10 @@ class DeleteLogFormatter extends LogFormatter {
$newParams = array_slice( $params, 0, 3 );
$newParams[3] = $changeText;
- $count = count( explode( ',', $params[$paramStart] ) );
- $newParams[4] = $this->context->getLanguage()->formatNum( $count );
+ $ids = is_array( $params[$paramStart] )
+ ? $params[$paramStart]
+ : explode( ',', $params[$paramStart] );
+ $newParams[4] = $this->context->getLanguage()->formatNum( count( $ids ) );
$this->parsedParametersDeleteLog = $newParams;
return $this->parsedParametersDeleteLog;
@@ -137,8 +139,10 @@ class DeleteLogFormatter extends LogFormatter {
// Different revision types use different URL params...
$key = $params[3];
- // This is a CSV of the IDs
- $ids = explode( ',', $params[4] );
+ // This is a array or CSV of the IDs
+ $ids = is_array( $params[4] )
+ ? $params[4]
+ : explode( ',', $params[4] );
$links = array();
@@ -192,6 +196,9 @@ class DeleteLogFormatter extends LogFormatter {
}
// This is a CSV of the IDs
$query = $params[3];
+ if ( is_array( $query ) ) {
+ $query = implode( ',', $query );
+ }
// Link to each hidden object ID, $params[1] is the url param
$revert = Linker::linkKnown(
SpecialPage::getTitleFor( 'Revisiondelete' ),
@@ -209,4 +216,67 @@ class DeleteLogFormatter extends LogFormatter {
return '';
}
}
+
+ protected function getParametersForApi() {
+ $entry = $this->entry;
+ $params = array();
+
+ $subtype = $this->entry->getSubtype();
+ if ( in_array( $subtype, array( 'event', 'revision' ) ) ) {
+ $rawParams = $entry->getParameters();
+ if ( $subtype === 'event' ) {
+ array_unshift( $rawParams, 'logging' );
+ }
+
+ static $map = array(
+ '4::type',
+ '5::ids',
+ '6::ofield',
+ '7::nfield',
+ '4::ids' => '5::ids',
+ '5::ofield' => '6::ofield',
+ '6::nfield' => '7::nfield',
+ );
+ foreach ( $map as $index => $key ) {
+ if ( isset( $rawParams[$index] ) ) {
+ $rawParams[$key] = $rawParams[$index];
+ unset( $rawParams[$index] );
+ }
+ }
+
+ $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 = array(
+ '::type' => $rawParams['4::type'],
+ ':array:ids' => $rawParams['5::ids'],
+ ':assoc:old' => array( 'bitmask' => $old ),
+ ':assoc:new' => array( 'bitmask' => $new ),
+ );
+
+ static $fields = array(
+ Revision::DELETED_TEXT => 'content',
+ Revision::DELETED_COMMENT => 'comment',
+ Revision::DELETED_USER => 'user',
+ Revision::DELETED_RESTRICTED => 'restricted',
+ );
+ foreach ( $fields as $bit => $key ) {
+ $params[':assoc:old'][$key] = (bool)( $old & $bit );
+ $params[':assoc:new'][$key] = (bool)( $new & $bit );
+ }
+ }
+
+ return $params;
+ }
+
+ public function formatParametersForApi() {
+ $ret = parent::formatParametersForApi();
+ if ( isset( $ret['ids'] ) ) {
+ ApiResult::setIndexedTagName( $ret['ids'], 'id' );
+ }
+ return $ret;
+ }
}