r96176 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96175‎ | r96176 | r96177 >
Date:11:34, 3 September 2011
Author:siebrand
Status:ok
Tags:
Comment:
Update whitespace and a comment.
Modified paths:
  • /trunk/phase3/includes/LogPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/LogPage.php
@@ -96,6 +96,7 @@
9797 # And update recentchanges
9898 if( $this->updateRecentChanges ) {
9999 $titleObj = SpecialPage::getTitleFor( 'Log', $this->type );
 100+
100101 RecentChange::notifyLog(
101102 $now, $titleObj, $this->doer, $this->getRcComment(), '',
102103 $this->type, $this->action, $this->target, $this->comment,
@@ -106,6 +107,7 @@
107108 if( isset( $wgLogRestrictions[$this->type] ) && $wgLogRestrictions[$this->type] != '*' ) {
108109 return true;
109110 }
 111+
110112 # Notify external application via UDP.
111113 # We send this to IRC but do not want to add it the RC table.
112114 $titleObj = SpecialPage::getTitleFor( 'Log', $this->type );
@@ -124,6 +126,7 @@
125127 */
126128 public function getRcComment() {
127129 $rcComment = $this->actionText;
 130+
128131 if( $this->comment != '' ) {
129132 if ( $rcComment == '' ) {
130133 $rcComment = $this->comment;
@@ -131,6 +134,7 @@
132135 $rcComment .= wfMsgForContent( 'colon-separator' ) . $this->comment;
133136 }
134137 }
 138+
135139 return $rcComment;
136140 }
137141
@@ -216,17 +220,21 @@
217221 }
218222
219223 $key = "$type/$action";
 224+
220225 # Defer patrol log to PatrolLog class
221226 if( $key == 'patrol/patrol' ) {
222227 return PatrolLog::makeActionText( $title, $params, $langObjOrNull );
223228 }
 229+
224230 if( isset( $wgLogActions[$key] ) ) {
225231 if( is_null( $title ) ) {
226232 $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'language' => $langObj ) );
227233 } else {
228234 $titleLink = self::getTitleLink( $type, $langObjOrNull, $title, $params );
 235+
229236 if( preg_match( '/^rights\/(rights|autopromote)/', $key ) ) {
230237 $rightsnone = wfMsgExt( 'rightsnone', array( 'parsemag', 'language' => $langObj ) );
 238+
231239 if( $skin ) {
232240 foreach ( $params as &$param ) {
233241 $groupArray = array_map( 'trim', explode( ',', $param ) );
@@ -234,18 +242,22 @@
235243 $param = $wgLang->listToText( $groupArray );
236244 }
237245 }
 246+
238247 if( !isset( $params[0] ) || trim( $params[0] ) == '' ) {
239248 $params[0] = $rightsnone;
240249 }
 250+
241251 if( !isset( $params[1] ) || trim( $params[1] ) == '' ) {
242252 $params[1] = $rightsnone;
243253 }
244254 }
 255+
245256 if( count( $params ) == 0 ) {
246257 $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'replaceafter', 'language' => $langObj ), $titleLink );
247258 } else {
248259 $details = '';
249260 array_unshift( $params, $titleLink );
 261+
250262 // User suppression
251263 if ( preg_match( '/^(block|suppress)\/(block|reblock)$/', $key ) ) {
252264 if ( $skin ) {
@@ -254,9 +266,9 @@
255267 } else {
256268 $params[1] = $wgContLang->translateBlockExpiry( $params[1] );
257269 }
 270+
258271 $params[2] = isset( $params[2] ) ?
259272 self::formatBlockFlags( $params[2], $langObj ) : '';
260 -
261273 // Page protections
262274 } elseif ( $type == 'protect' && count($params) == 3 ) {
263275 // Restrictions and expiries
@@ -265,24 +277,22 @@
266278 } else {
267279 $details .= " {$params[1]}";
268280 }
 281+
269282 // Cascading flag...
270283 if( $params[2] ) {
271284 $details .= ' [' . wfMsgExt( 'protect-summary-cascade', array( 'parsemag', 'language' => $langObj ) ) . ']';
272285 }
273 -
274286 // Page moves
275287 } elseif ( $type == 'move' && count( $params ) == 3 ) {
276288 if( $params[2] ) {
277289 $details .= ' [' . wfMsgExt( 'move-redirect-suppressed', array( 'parsemag', 'language' => $langObj ) ) . ']';
278290 }
279 -
280291 // Revision deletion
281292 } elseif ( preg_match( '/^(delete|suppress)\/revision$/', $key ) && count( $params ) == 5 ) {
282293 $count = substr_count( $params[2], ',' ) + 1; // revisions
283294 $ofield = intval( substr( $params[3], 7 ) ); // <ofield=x>
284295 $nfield = intval( substr( $params[4], 7 ) ); // <nfield=x>
285296 $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, $langObj, false );
286 -
287297 // Log deletion
288298 } elseif ( preg_match( '/^(delete|suppress)\/event$/', $key ) && count( $params ) == 4 ) {
289299 $count = substr_count( $params[1], ',' ) + 1; // log items
@@ -296,6 +306,7 @@
297307 }
298308 } else {
299309 global $wgLogActionsHandlers;
 310+
300311 if( isset( $wgLogActionsHandlers[$key] ) ) {
301312 $args = func_get_args();
302313 $rv = call_user_func_array( $wgLogActionsHandlers[$key], $args );
@@ -319,6 +330,7 @@
320331 $rv = str_replace( '[[', '', $rv );
321332 $rv = str_replace( ']]', '', $rv );
322333 }
 334+
323335 return $rv;
324336 }
325337
@@ -332,9 +344,11 @@
333345 */
334346 protected static function getTitleLink( $type, $lang, $title, &$params ) {
335347 global $wgContLang, $wgUserrightsInterwikiDelimiter;
 348+
336349 if( !$lang ) {
337350 return $title->getPrefixedText();
338351 }
 352+
339353 switch( $type ) {
340354 case 'move':
341355 $titleLink = Linker::link(
@@ -343,7 +357,9 @@
344358 array(),
345359 array( 'redirect' => 'no' )
346360 );
 361+
347362 $targetTitle = Title::newFromText( $params[0] );
 363+
348364 if ( !$targetTitle ) {
349365 # Workaround for broken database
350366 $params[0] = htmlspecialchars( $params[0] );
@@ -358,7 +374,7 @@
359375 if( substr( $title->getText(), 0, 1 ) == '#' ) {
360376 $titleLink = $title->getText();
361377 } else {
362 - // TODO: Store the user identifier in the parameters
 378+ // @todo Store the user identifier in the parameters
363379 // to make this faster for future log entries
364380 $id = User::idFromName( $title->getText() );
365381 $titleLink = Linker::userLink( $id, $title->getText() )
@@ -368,9 +384,11 @@
369385 case 'rights':
370386 $text = $wgContLang->ucfirst( $title->getText() );
371387 $parts = explode( $wgUserrightsInterwikiDelimiter, $text, 2 );
 388+
372389 if ( count( $parts ) == 2 ) {
373390 $titleLink = WikiMap::foreignUserLink( $parts[1], $parts[0],
374391 htmlspecialchars( $title->getPrefixedText() ) );
 392+
375393 if ( $titleLink !== false ) {
376394 break;
377395 }
@@ -393,6 +411,7 @@
394412 default:
395413 if( $title->getNamespace() == NS_SPECIAL ) {
396414 list( $name, $par ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
 415+
397416 # Use the language name for log titles, rather than Log/X
398417 if( $name == 'Log' ) {
399418 $titleLink = '(' . Linker::link( $title, LogPage::logName( $par ) ) . ')';
@@ -403,6 +422,7 @@
404423 $titleLink = Linker::link( $title );
405424 }
406425 }
 426+
407427 return $titleLink;
408428 }
409429
@@ -460,7 +480,9 @@
461481 if( !strlen( $field ) || empty( $values ) ) {
462482 return false; // nothing
463483 }
 484+
464485 $data = array();
 486+
465487 foreach( $values as $value ) {
466488 $data[] = array(
467489 'ls_field' => $field,
@@ -468,8 +490,10 @@
469491 'ls_log_id' => $logid
470492 );
471493 }
 494+
472495 $dbw = wfGetDB( DB_MASTER );
473496 $dbw->insert( 'log_search', $data, __METHOD__, 'IGNORE' );
 497+
474498 return true;
475499 }
476500
@@ -507,6 +531,7 @@
508532 */
509533 public static function formatBlockFlags( $flags, $lang ) {
510534 $flags = explode( ',', trim( $flags ) );
 535+
511536 if( count( $flags ) > 0 ) {
512537 for( $i = 0; $i < count( $flags ); $i++ ) {
513538 $flags[$i] = self::formatBlockFlag( $flags[$i], $lang );
@@ -526,6 +551,7 @@
527552 */
528553 public static function formatBlockFlag( $flag, $lang ) {
529554 static $messages = array();
 555+
530556 if( !isset( $messages[$flag] ) ) {
531557 $messages[$flag] = htmlspecialchars( $flag ); // Fallback
532558
@@ -538,10 +564,12 @@
539565 // * block-log-flags-noemail
540566 // * block-log-flags-nousertalk
541567 $msg = wfMessage( 'block-log-flags-' . $flag )->inLanguage( $lang );
 568+
542569 if ( $msg->exists() ) {
543570 $messages[$flag] = $msg->escaped();
544571 }
545572 }
 573+
546574 return $messages[$flag];
547575 }
548576 }

Status & tagging log