MediaWiki  1.23.15
DeleteLogFormatter.php
Go to the documentation of this file.
1 <?php
32  protected function getMessageKey() {
33  $key = parent::getMessageKey();
34  if ( in_array( $this->entry->getSubtype(), array( 'event', 'revision' ) ) ) {
35  if ( count( $this->getMessageParameters() ) < 5 ) {
36  return "$key-legacy";
37  }
38  }
39 
40  return $key;
41  }
42 
43  protected function getMessageParameters() {
44  if ( isset( $this->parsedParametersDeleteLog ) ) {
45  return $this->parsedParametersDeleteLog;
46  }
47 
48  $params = parent::getMessageParameters();
49  $subtype = $this->entry->getSubtype();
50  if ( in_array( $subtype, array( 'event', 'revision' ) ) ) {
51  // $params[3] here is 'revision' or 'archive' for page revisions, 'oldimage' or
52  // 'filearchive' for file versions, or a comma-separated list of log_ids for log
53  // entries. $subtype here is 'revision' for page revisions and file
54  // versions, or 'event' for log entries.
55  if ( ( $subtype === 'event' && count( $params ) === 6 )
56  || ( $subtype === 'revision' && isset( $params[3] )
57  && ( $params[3] === 'revision' || $params[3] === 'oldimage'
58  || $params[3] === 'archive' || $params[3] === 'filearchive' )
59  )
60  ) {
61  $paramStart = $subtype === 'revision' ? 4 : 3;
62 
63  $old = $this->parseBitField( $params[$paramStart + 1] );
64  $new = $this->parseBitField( $params[$paramStart + 2] );
65  list( $hid, $unhid, $extra ) = RevisionDeleter::getChanges( $new, $old );
66  $changes = array();
67  // messages used: revdelete-content-hid, revdelete-summary-hid, revdelete-uname-hid
68  foreach ( $hid as $v ) {
69  $changes[] = $this->msg( "$v-hid" )->plain();
70  }
71  // messages used: revdelete-content-unhid, revdelete-summary-unhid, revdelete-uname-unhid
72  foreach ( $unhid as $v ) {
73  $changes[] = $this->msg( "$v-unhid" )->plain();
74  }
75  foreach ( $extra as $v ) {
76  $changes[] = $this->msg( $v )->plain();
77  }
78  $changeText = $this->context->getLanguage()->listToText( $changes );
79 
80  $newParams = array_slice( $params, 0, 3 );
81  $newParams[3] = $changeText;
82  $count = count( explode( ',', $params[$paramStart] ) );
83  $newParams[4] = $this->context->getLanguage()->formatNum( $count );
84 
85  $this->parsedParametersDeleteLog = $newParams;
86  return $this->parsedParametersDeleteLog;
87  } else {
88  $this->parsedParametersDeleteLog = array_slice( $params, 0, 3 );
89  return $this->parsedParametersDeleteLog;
90  }
91  }
92 
93  $this->parsedParametersDeleteLog = $params;
94  return $this->parsedParametersDeleteLog;
95  }
96 
97  protected function parseBitField( $string ) {
98  // Input is like ofield=2134 or just the number
99  if ( strpos( $string, 'field=' ) === 1 ) {
100  list( , $field ) = explode( '=', $string );
101 
102  return (int)$field;
103  } else {
104  return (int)$string;
105  }
106  }
107 
108  public function getActionLinks() {
109  $user = $this->context->getUser();
110  if ( !$user->isAllowed( 'deletedhistory' )
111  || $this->entry->isDeleted( LogPage::DELETED_ACTION )
112  ) {
113  return '';
114  }
115 
116  switch ( $this->entry->getSubtype() ) {
117  case 'delete': // Show undelete link
118  if ( $user->isAllowed( 'undelete' ) ) {
119  $message = 'undeletelink';
120  } else {
121  $message = 'undeleteviewlink';
122  }
124  SpecialPage::getTitleFor( 'Undelete' ),
125  $this->msg( $message )->escaped(),
126  array(),
127  array( 'target' => $this->entry->getTarget()->getPrefixedDBkey() )
128  );
129 
130  return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
131 
132  case 'revision': // If an edit was hidden from a page give a review link to the history
133  $params = $this->extractParameters();
134  if ( !isset( $params[3] ) || !isset( $params[4] ) ) {
135  return '';
136  }
137 
138  // Different revision types use different URL params...
139  $key = $params[3];
140  // This is a CSV of the IDs
141  $ids = explode( ',', $params[4] );
142 
143  $links = array();
144 
145  // If there's only one item, we can show a diff link
146  if ( count( $ids ) == 1 ) {
147  // Live revision diffs...
148  if ( $key == 'oldid' || $key == 'revision' ) {
149  $links[] = Linker::linkKnown(
150  $this->entry->getTarget(),
151  $this->msg( 'diff' )->escaped(),
152  array(),
153  array(
154  'diff' => intval( $ids[0] ),
155  'unhide' => 1
156  )
157  );
158  // Deleted revision diffs...
159  } elseif ( $key == 'artimestamp' || $key == 'archive' ) {
160  $links[] = Linker::linkKnown(
161  SpecialPage::getTitleFor( 'Undelete' ),
162  $this->msg( 'diff' )->escaped(),
163  array(),
164  array(
165  'target' => $this->entry->getTarget()->getPrefixedDBkey(),
166  'diff' => 'prev',
167  'timestamp' => $ids[0]
168  )
169  );
170  }
171  }
172 
173  // View/modify link...
174  $links[] = Linker::linkKnown(
175  SpecialPage::getTitleFor( 'Revisiondelete' ),
176  $this->msg( 'revdel-restore' )->escaped(),
177  array(),
178  array(
179  'target' => $this->entry->getTarget()->getPrefixedText(),
180  'type' => $key,
181  'ids' => implode( ',', $ids ),
182  )
183  );
184 
185  return $this->msg( 'parentheses' )->rawParams(
186  $this->context->getLanguage()->pipeList( $links ) )->escaped();
187 
188  case 'event': // Hidden log items, give review link
189  $params = $this->extractParameters();
190  if ( !isset( $params[3] ) ) {
191  return '';
192  }
193  // This is a CSV of the IDs
194  $query = $params[3];
195  // Link to each hidden object ID, $params[1] is the url param
197  SpecialPage::getTitleFor( 'Revisiondelete' ),
198  $this->msg( 'revdel-restore' )->escaped(),
199  array(),
200  array(
201  'target' => $this->entry->getTarget()->getPrefixedText(),
202  'type' => 'logging',
203  'ids' => $query
204  )
205  );
206 
207  return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
208  default:
209  return '';
210  }
211  }
212 }
$revert
this hook is for auditing only etc create2 Corresponds to logging log_action database field and which is displayed in the UI & $revert
Definition: hooks.txt:1644
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
$params
$params
Definition: styleTest.css.php:40
DeleteLogFormatter\parseBitField
parseBitField( $string)
Definition: DeleteLogFormatter.php:97
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
Definition: SpecialPage.php:74
DeleteLogFormatter\getMessageKey
getMessageKey()
Returns a key to be used for formatting the action sentence.
Definition: DeleteLogFormatter.php:32
Linker\linkKnown
static linkKnown( $target, $html=null, $customAttribs=array(), $query=array(), $options=array( 'known', 'noclasses'))
Identical to link(), except $options defaults to 'known'.
Definition: Linker.php:264
LogFormatter\msg
msg( $key)
Shortcut for wfMessage which honors local context.
Definition: LogFormatter.php:624
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:33
RevisionDeleter\getChanges
static getChanges( $n, $o)
Gets an array of message keys describing the changes made to the visibility of the revision.
Definition: RevisionDeleter.php:125
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
LogFormatter
Implements the default log formatting.
Definition: LogFormatter.php:33
$count
$count
Definition: UtfNormalTest2.php:96
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
DeleteLogFormatter\getMessageParameters
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
Definition: DeleteLogFormatter.php:43
$query
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1105
DeleteLogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition: DeleteLogFormatter.php:108
LogFormatter\extractParameters
extractParameters()
Extracts the optional extra parameters for use in action messages.
Definition: LogFormatter.php:395
DeleteLogFormatter
This class formats delete log entries.
Definition: DeleteLogFormatter.php:31