Index: trunk/phase3/includes/LogPage.php |
— | — | @@ -96,6 +96,7 @@ |
97 | 97 | # And update recentchanges |
98 | 98 | if( $this->updateRecentChanges ) { |
99 | 99 | $titleObj = SpecialPage::getTitleFor( 'Log', $this->type ); |
| 100 | + |
100 | 101 | RecentChange::notifyLog( |
101 | 102 | $now, $titleObj, $this->doer, $this->getRcComment(), '', |
102 | 103 | $this->type, $this->action, $this->target, $this->comment, |
— | — | @@ -106,6 +107,7 @@ |
107 | 108 | if( isset( $wgLogRestrictions[$this->type] ) && $wgLogRestrictions[$this->type] != '*' ) { |
108 | 109 | return true; |
109 | 110 | } |
| 111 | + |
110 | 112 | # Notify external application via UDP. |
111 | 113 | # We send this to IRC but do not want to add it the RC table. |
112 | 114 | $titleObj = SpecialPage::getTitleFor( 'Log', $this->type ); |
— | — | @@ -124,6 +126,7 @@ |
125 | 127 | */ |
126 | 128 | public function getRcComment() { |
127 | 129 | $rcComment = $this->actionText; |
| 130 | + |
128 | 131 | if( $this->comment != '' ) { |
129 | 132 | if ( $rcComment == '' ) { |
130 | 133 | $rcComment = $this->comment; |
— | — | @@ -131,6 +134,7 @@ |
132 | 135 | $rcComment .= wfMsgForContent( 'colon-separator' ) . $this->comment; |
133 | 136 | } |
134 | 137 | } |
| 138 | + |
135 | 139 | return $rcComment; |
136 | 140 | } |
137 | 141 | |
— | — | @@ -216,17 +220,21 @@ |
217 | 221 | } |
218 | 222 | |
219 | 223 | $key = "$type/$action"; |
| 224 | + |
220 | 225 | # Defer patrol log to PatrolLog class |
221 | 226 | if( $key == 'patrol/patrol' ) { |
222 | 227 | return PatrolLog::makeActionText( $title, $params, $langObjOrNull ); |
223 | 228 | } |
| 229 | + |
224 | 230 | if( isset( $wgLogActions[$key] ) ) { |
225 | 231 | if( is_null( $title ) ) { |
226 | 232 | $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'language' => $langObj ) ); |
227 | 233 | } else { |
228 | 234 | $titleLink = self::getTitleLink( $type, $langObjOrNull, $title, $params ); |
| 235 | + |
229 | 236 | if( preg_match( '/^rights\/(rights|autopromote)/', $key ) ) { |
230 | 237 | $rightsnone = wfMsgExt( 'rightsnone', array( 'parsemag', 'language' => $langObj ) ); |
| 238 | + |
231 | 239 | if( $skin ) { |
232 | 240 | foreach ( $params as &$param ) { |
233 | 241 | $groupArray = array_map( 'trim', explode( ',', $param ) ); |
— | — | @@ -234,18 +242,22 @@ |
235 | 243 | $param = $wgLang->listToText( $groupArray ); |
236 | 244 | } |
237 | 245 | } |
| 246 | + |
238 | 247 | if( !isset( $params[0] ) || trim( $params[0] ) == '' ) { |
239 | 248 | $params[0] = $rightsnone; |
240 | 249 | } |
| 250 | + |
241 | 251 | if( !isset( $params[1] ) || trim( $params[1] ) == '' ) { |
242 | 252 | $params[1] = $rightsnone; |
243 | 253 | } |
244 | 254 | } |
| 255 | + |
245 | 256 | if( count( $params ) == 0 ) { |
246 | 257 | $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'replaceafter', 'language' => $langObj ), $titleLink ); |
247 | 258 | } else { |
248 | 259 | $details = ''; |
249 | 260 | array_unshift( $params, $titleLink ); |
| 261 | + |
250 | 262 | // User suppression |
251 | 263 | if ( preg_match( '/^(block|suppress)\/(block|reblock)$/', $key ) ) { |
252 | 264 | if ( $skin ) { |
— | — | @@ -254,9 +266,9 @@ |
255 | 267 | } else { |
256 | 268 | $params[1] = $wgContLang->translateBlockExpiry( $params[1] ); |
257 | 269 | } |
| 270 | + |
258 | 271 | $params[2] = isset( $params[2] ) ? |
259 | 272 | self::formatBlockFlags( $params[2], $langObj ) : ''; |
260 | | - |
261 | 273 | // Page protections |
262 | 274 | } elseif ( $type == 'protect' && count($params) == 3 ) { |
263 | 275 | // Restrictions and expiries |
— | — | @@ -265,24 +277,22 @@ |
266 | 278 | } else { |
267 | 279 | $details .= " {$params[1]}"; |
268 | 280 | } |
| 281 | + |
269 | 282 | // Cascading flag... |
270 | 283 | if( $params[2] ) { |
271 | 284 | $details .= ' [' . wfMsgExt( 'protect-summary-cascade', array( 'parsemag', 'language' => $langObj ) ) . ']'; |
272 | 285 | } |
273 | | - |
274 | 286 | // Page moves |
275 | 287 | } elseif ( $type == 'move' && count( $params ) == 3 ) { |
276 | 288 | if( $params[2] ) { |
277 | 289 | $details .= ' [' . wfMsgExt( 'move-redirect-suppressed', array( 'parsemag', 'language' => $langObj ) ) . ']'; |
278 | 290 | } |
279 | | - |
280 | 291 | // Revision deletion |
281 | 292 | } elseif ( preg_match( '/^(delete|suppress)\/revision$/', $key ) && count( $params ) == 5 ) { |
282 | 293 | $count = substr_count( $params[2], ',' ) + 1; // revisions |
283 | 294 | $ofield = intval( substr( $params[3], 7 ) ); // <ofield=x> |
284 | 295 | $nfield = intval( substr( $params[4], 7 ) ); // <nfield=x> |
285 | 296 | $details .= ': ' . RevisionDeleter::getLogMessage( $count, $nfield, $ofield, $langObj, false ); |
286 | | - |
287 | 297 | // Log deletion |
288 | 298 | } elseif ( preg_match( '/^(delete|suppress)\/event$/', $key ) && count( $params ) == 4 ) { |
289 | 299 | $count = substr_count( $params[1], ',' ) + 1; // log items |
— | — | @@ -296,6 +306,7 @@ |
297 | 307 | } |
298 | 308 | } else { |
299 | 309 | global $wgLogActionsHandlers; |
| 310 | + |
300 | 311 | if( isset( $wgLogActionsHandlers[$key] ) ) { |
301 | 312 | $args = func_get_args(); |
302 | 313 | $rv = call_user_func_array( $wgLogActionsHandlers[$key], $args ); |
— | — | @@ -319,6 +330,7 @@ |
320 | 331 | $rv = str_replace( '[[', '', $rv ); |
321 | 332 | $rv = str_replace( ']]', '', $rv ); |
322 | 333 | } |
| 334 | + |
323 | 335 | return $rv; |
324 | 336 | } |
325 | 337 | |
— | — | @@ -332,9 +344,11 @@ |
333 | 345 | */ |
334 | 346 | protected static function getTitleLink( $type, $lang, $title, &$params ) { |
335 | 347 | global $wgContLang, $wgUserrightsInterwikiDelimiter; |
| 348 | + |
336 | 349 | if( !$lang ) { |
337 | 350 | return $title->getPrefixedText(); |
338 | 351 | } |
| 352 | + |
339 | 353 | switch( $type ) { |
340 | 354 | case 'move': |
341 | 355 | $titleLink = Linker::link( |
— | — | @@ -343,7 +357,9 @@ |
344 | 358 | array(), |
345 | 359 | array( 'redirect' => 'no' ) |
346 | 360 | ); |
| 361 | + |
347 | 362 | $targetTitle = Title::newFromText( $params[0] ); |
| 363 | + |
348 | 364 | if ( !$targetTitle ) { |
349 | 365 | # Workaround for broken database |
350 | 366 | $params[0] = htmlspecialchars( $params[0] ); |
— | — | @@ -358,7 +374,7 @@ |
359 | 375 | if( substr( $title->getText(), 0, 1 ) == '#' ) { |
360 | 376 | $titleLink = $title->getText(); |
361 | 377 | } else { |
362 | | - // TODO: Store the user identifier in the parameters |
| 378 | + // @todo Store the user identifier in the parameters |
363 | 379 | // to make this faster for future log entries |
364 | 380 | $id = User::idFromName( $title->getText() ); |
365 | 381 | $titleLink = Linker::userLink( $id, $title->getText() ) |
— | — | @@ -368,9 +384,11 @@ |
369 | 385 | case 'rights': |
370 | 386 | $text = $wgContLang->ucfirst( $title->getText() ); |
371 | 387 | $parts = explode( $wgUserrightsInterwikiDelimiter, $text, 2 ); |
| 388 | + |
372 | 389 | if ( count( $parts ) == 2 ) { |
373 | 390 | $titleLink = WikiMap::foreignUserLink( $parts[1], $parts[0], |
374 | 391 | htmlspecialchars( $title->getPrefixedText() ) ); |
| 392 | + |
375 | 393 | if ( $titleLink !== false ) { |
376 | 394 | break; |
377 | 395 | } |
— | — | @@ -393,6 +411,7 @@ |
394 | 412 | default: |
395 | 413 | if( $title->getNamespace() == NS_SPECIAL ) { |
396 | 414 | list( $name, $par ) = SpecialPageFactory::resolveAlias( $title->getDBkey() ); |
| 415 | + |
397 | 416 | # Use the language name for log titles, rather than Log/X |
398 | 417 | if( $name == 'Log' ) { |
399 | 418 | $titleLink = '(' . Linker::link( $title, LogPage::logName( $par ) ) . ')'; |
— | — | @@ -403,6 +422,7 @@ |
404 | 423 | $titleLink = Linker::link( $title ); |
405 | 424 | } |
406 | 425 | } |
| 426 | + |
407 | 427 | return $titleLink; |
408 | 428 | } |
409 | 429 | |
— | — | @@ -460,7 +480,9 @@ |
461 | 481 | if( !strlen( $field ) || empty( $values ) ) { |
462 | 482 | return false; // nothing |
463 | 483 | } |
| 484 | + |
464 | 485 | $data = array(); |
| 486 | + |
465 | 487 | foreach( $values as $value ) { |
466 | 488 | $data[] = array( |
467 | 489 | 'ls_field' => $field, |
— | — | @@ -468,8 +490,10 @@ |
469 | 491 | 'ls_log_id' => $logid |
470 | 492 | ); |
471 | 493 | } |
| 494 | + |
472 | 495 | $dbw = wfGetDB( DB_MASTER ); |
473 | 496 | $dbw->insert( 'log_search', $data, __METHOD__, 'IGNORE' ); |
| 497 | + |
474 | 498 | return true; |
475 | 499 | } |
476 | 500 | |
— | — | @@ -507,6 +531,7 @@ |
508 | 532 | */ |
509 | 533 | public static function formatBlockFlags( $flags, $lang ) { |
510 | 534 | $flags = explode( ',', trim( $flags ) ); |
| 535 | + |
511 | 536 | if( count( $flags ) > 0 ) { |
512 | 537 | for( $i = 0; $i < count( $flags ); $i++ ) { |
513 | 538 | $flags[$i] = self::formatBlockFlag( $flags[$i], $lang ); |
— | — | @@ -526,6 +551,7 @@ |
527 | 552 | */ |
528 | 553 | public static function formatBlockFlag( $flag, $lang ) { |
529 | 554 | static $messages = array(); |
| 555 | + |
530 | 556 | if( !isset( $messages[$flag] ) ) { |
531 | 557 | $messages[$flag] = htmlspecialchars( $flag ); // Fallback |
532 | 558 | |
— | — | @@ -538,10 +564,12 @@ |
539 | 565 | // * block-log-flags-noemail |
540 | 566 | // * block-log-flags-nousertalk |
541 | 567 | $msg = wfMessage( 'block-log-flags-' . $flag )->inLanguage( $lang ); |
| 568 | + |
542 | 569 | if ( $msg->exists() ) { |
543 | 570 | $messages[$flag] = $msg->escaped(); |
544 | 571 | } |
545 | 572 | } |
| 573 | + |
546 | 574 | return $messages[$flag]; |
547 | 575 | } |
548 | 576 | } |