Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -2556,9 +2556,6 @@ |
2557 | 2557 | 'patrol-log' => array( |
2558 | 2558 | 'patrol-log-page', |
2559 | 2559 | 'patrol-log-header', |
2560 | | - 'patrol-log-line', |
2561 | | - 'patrol-log-auto', |
2562 | | - 'patrol-log-diff', |
2563 | 2560 | 'log-show-hide-patrol', |
2564 | 2561 | ), |
2565 | 2562 | 'imagedeletion' => array( |
— | — | @@ -3515,6 +3512,8 @@ |
3516 | 3513 | 'logentry-move-move-noredirect', |
3517 | 3514 | 'logentry-move-move_redir', |
3518 | 3515 | 'logentry-move-move_redir-noredirect', |
| 3516 | + 'logentry-patrol-patrol', |
| 3517 | + 'logentry-patrol-patrol-auto', |
3519 | 3518 | ), |
3520 | 3519 | ); |
3521 | 3520 | |
Index: trunk/phase3/includes/PatrolLog.php |
— | — | @@ -5,6 +5,7 @@ |
6 | 6 | * logs of patrol events |
7 | 7 | * |
8 | 8 | * @author Rob Church <robchur@gmail.com> |
| 9 | + * @author Niklas Laxström |
9 | 10 | */ |
10 | 11 | class PatrolLog { |
11 | 12 | |
— | — | @@ -17,64 +18,29 @@ |
18 | 19 | * @return bool |
19 | 20 | */ |
20 | 21 | public static function record( $rc, $auto = false ) { |
21 | | - if( !( $rc instanceof RecentChange ) ) { |
| 22 | + if ( !$rc instanceof RecentChange ) { |
22 | 23 | $rc = RecentChange::newFromId( $rc ); |
23 | | - if( !is_object( $rc ) ) |
| 24 | + if ( !is_object( $rc ) ) { |
24 | 25 | return false; |
| 26 | + } |
25 | 27 | } |
| 28 | + |
26 | 29 | $title = Title::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) ); |
27 | | - if( is_object( $title ) ) { |
28 | | - $params = self::buildParams( $rc, $auto ); |
29 | | - $log = new LogPage( 'patrol', false, $auto ? "skipUDP" : "UDP" ); # False suppresses RC entries |
30 | | - $log->addEntry( 'patrol', $title, '', $params ); |
| 30 | + if( $title ) { |
| 31 | + $entry = new ManualLogEntry( 'patrol', 'patrol' ); |
| 32 | + $entry->setTarget( $title ); |
| 33 | + $entry->setParameters( self::buildParams( $rc, $auto ) ); |
| 34 | + $entry->setPerformer( User::newFromName( $rc->getAttribute( 'rc_user_text' ) ) ); |
| 35 | + $logid = $entry->insert(); |
| 36 | + if ( !$auto ) { |
| 37 | + $entry->publish( $logid, 'udp' ); |
| 38 | + } |
31 | 39 | return true; |
32 | 40 | } |
33 | 41 | return false; |
34 | 42 | } |
35 | 43 | |
36 | 44 | /** |
37 | | - * Generate the log action text corresponding to a patrol log item |
38 | | - * |
39 | | - * @param $title Title of the page that was patrolled |
40 | | - * @param $params Array: log parameters (from logging.log_params) |
41 | | - * @param $lang Language object to use, or false |
42 | | - * @return String |
43 | | - */ |
44 | | - public static function makeActionText( $title, $params, $lang ) { |
45 | | - list( $cur, /* $prev */, $auto ) = $params; |
46 | | - if( is_object( $lang ) ) { |
47 | | - # Standard link to the page in question |
48 | | - $link = Linker::link( $title ); |
49 | | - if( $title->exists() ) { |
50 | | - # Generate a diff link |
51 | | - $query = array( |
52 | | - 'oldid' => $cur, |
53 | | - 'diff' => 'prev' |
54 | | - ); |
55 | | - |
56 | | - $diff = Linker::link( |
57 | | - $title, |
58 | | - htmlspecialchars( wfMsg( 'patrol-log-diff', $lang->formatNum( $cur, true ) ) ), |
59 | | - array(), |
60 | | - $query, |
61 | | - array( 'known', 'noclasses' ) |
62 | | - ); |
63 | | - } else { |
64 | | - # Don't bother with a diff link, it's useless |
65 | | - $diff = htmlspecialchars( wfMsg( 'patrol-log-diff', $cur ) ); |
66 | | - } |
67 | | - # Indicate whether or not the patrolling was automatic |
68 | | - $auto = $auto ? wfMsgHtml( 'patrol-log-auto' ) : ''; |
69 | | - # Put it all together |
70 | | - return wfMsgHtml( 'patrol-log-line', $diff, $link, $auto ); |
71 | | - } else { |
72 | | - $text = $title->getPrefixedText(); |
73 | | - $diff = htmlspecialchars( wfMsgForContent( 'patrol-log-diff', $cur ) ); |
74 | | - return wfMsgForContent( 'patrol-log-line', $diff, "[[$text]]", '' ); |
75 | | - } |
76 | | - } |
77 | | - |
78 | | - /** |
79 | 45 | * Prepare log parameters for a patrolled change |
80 | 46 | * |
81 | 47 | * @param $change RecentChange to represent |
— | — | @@ -83,9 +49,10 @@ |
84 | 50 | */ |
85 | 51 | private static function buildParams( $change, $auto ) { |
86 | 52 | return array( |
87 | | - $change->getAttribute( 'rc_this_oldid' ), |
88 | | - $change->getAttribute( 'rc_last_oldid' ), |
89 | | - (int)$auto |
| 53 | + '4::curid' => $change->getAttribute( 'rc_this_oldid' ), |
| 54 | + '5::previd' => $change->getAttribute( 'rc_last_oldid' ), |
| 55 | + '6::auto' => (int)$auto |
90 | 56 | ); |
91 | 57 | } |
| 58 | + |
92 | 59 | } |
Index: trunk/phase3/includes/logging/LogEntry.php |
— | — | @@ -312,7 +312,7 @@ |
313 | 313 | protected $performer; ///!< @var User |
314 | 314 | protected $target; ///!< @var Title |
315 | 315 | protected $timestamp; ///!< @var string |
316 | | - protected $comment; ///!< @var string |
| 316 | + protected $comment = ''; ///!< @var string |
317 | 317 | protected $deleted; ///!< @var int |
318 | 318 | |
319 | 319 | public function __construct( $type, $subtype ) { |
Index: trunk/phase3/includes/logging/LogFormatter.php |
— | — | @@ -417,3 +417,42 @@ |
418 | 418 | } |
419 | 419 | } |
420 | 420 | } |
| 421 | + |
| 422 | +/** |
| 423 | + * This class formats patrol log entries. |
| 424 | + * @since 1.19 |
| 425 | + */ |
| 426 | +class PatrolLogFormatter extends LogFormatter { |
| 427 | + protected function getMessageKey() { |
| 428 | + $key = parent::getMessageKey(); |
| 429 | + $params = $this->getMessageParameters(); |
| 430 | + if ( isset( $params[5] ) && $params[5] ) { |
| 431 | + $key .= '-auto'; |
| 432 | + } |
| 433 | + return $key; |
| 434 | + } |
| 435 | + |
| 436 | + protected function getMessageParameters() { |
| 437 | + $params = parent::getMessageParameters(); |
| 438 | + $newParams = array_slice( $params, 0, 3 ); |
| 439 | + |
| 440 | + $target = $this->entry->getTarget(); |
| 441 | + $oldid = $params[3]; |
| 442 | + $revision = $this->context->getLang()->formatNum( $oldid, true ); |
| 443 | + |
| 444 | + if ( $this->plaintext ) { |
| 445 | + $revlink = $revision; |
| 446 | + } elseif ( $target->exists() ) { |
| 447 | + $query = array( |
| 448 | + 'oldid' => $oldid, |
| 449 | + 'diff' => 'prev' |
| 450 | + ); |
| 451 | + $revlink = Linker::link( $target, htmlspecialchars( $revision ), array(), $query ); |
| 452 | + } else { |
| 453 | + $revlink = htmlspecialchars( $revision ); |
| 454 | + } |
| 455 | + |
| 456 | + $newParams[3] = Message::rawParam( $revlink ); |
| 457 | + return $newParams; |
| 458 | + } |
| 459 | +} |
\ No newline at end of file |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -547,6 +547,7 @@ |
548 | 548 | 'LegacyLogFormatter' => 'includes/logging/LogFormatter.php', |
549 | 549 | 'DeleteLogFormatter' => 'includes/logging/LogFormatter.php', |
550 | 550 | 'MoveLogFormatter' => 'includes/logging/LogFormatter.php', |
| 551 | + 'PatrolLogFormatter' => 'includes/logging/LogFormatter.php', |
551 | 552 | |
552 | 553 | # includes/media |
553 | 554 | 'BitmapHandler' => 'includes/media/Bitmap.php', |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -5063,7 +5063,6 @@ |
5064 | 5064 | 'merge/merge' => 'pagemerge-logentry', |
5065 | 5065 | 'suppress/block' => 'blocklogentry', |
5066 | 5066 | 'suppress/reblock' => 'reblock-logentry', |
5067 | | - 'patrol/patrol' => 'patrol-log-line', |
5068 | 5067 | ); |
5069 | 5068 | |
5070 | 5069 | /** |
— | — | @@ -5080,6 +5079,7 @@ |
5081 | 5080 | 'suppress/revision' => 'DeleteLogFormatter', |
5082 | 5081 | 'suppress/event' => 'DeleteLogFormatter', |
5083 | 5082 | 'suppress/delete' => 'DeleteLogFormatter', |
| 5083 | + 'patrol/patrol' => 'PatrolLogFormatter', |
5084 | 5084 | ); |
5085 | 5085 | |
5086 | 5086 | /** |
Index: trunk/phase3/includes/LogPage.php |
— | — | @@ -225,11 +225,6 @@ |
226 | 226 | |
227 | 227 | $key = "$type/$action"; |
228 | 228 | |
229 | | - # Defer patrol log to PatrolLog class |
230 | | - if( $key == 'patrol/patrol' ) { |
231 | | - return PatrolLog::makeActionText( $title, $params, $langObjOrNull ); |
232 | | - } |
233 | | - |
234 | 229 | if( isset( $wgLogActions[$key] ) ) { |
235 | 230 | if( is_null( $title ) ) { |
236 | 231 | $rv = wfMsgExt( $wgLogActions[$key], array( 'parsemag', 'escape', 'language' => $langObj ) ); |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -3603,9 +3603,6 @@ |
3604 | 3604 | # Patrol log |
3605 | 3605 | 'patrol-log-page' => 'Patrol log', |
3606 | 3606 | 'patrol-log-header' => 'This is a log of patrolled revisions.', |
3607 | | -'patrol-log-line' => 'marked $1 of $2 patrolled $3', |
3608 | | -'patrol-log-auto' => '(automatic)', |
3609 | | -'patrol-log-diff' => 'revision $1', |
3610 | 3607 | 'log-show-hide-patrol' => '$1 patrol log', |
3611 | 3608 | |
3612 | 3609 | # Image deletion |
— | — | @@ -4651,5 +4648,7 @@ |
4652 | 4649 | 'logentry-move-move-noredirect' => '$1 {{GENDER:$2|moved}} page $3 to $4 without leaving a redirect', |
4653 | 4650 | 'logentry-move-move_redir' => '$1 {{GENDER:$2|moved}} page $3 to $4 over redirect', |
4654 | 4651 | 'logentry-move-move_redir-noredirect' => '$1 {{GENDER:$2|moved}} page $3 to $4 over a redirect without leaving a redirect', |
| 4652 | +'logentry-patrol-patrol' => '$1 {{GENDER:$2|marked}} revision $4 of page $3 patrolled', |
| 4653 | +'logentry-patrol-patrol-auto' => '$1 automatically {{GENDER:$2|marked}} revision $4 of page $3 patrolled', |
4655 | 4654 | |
4656 | 4655 | ); |