Fix regression in even sizing of diff columns; forgot to restore a couple bits I...
[mediawiki.git] / includes / PatrolLog.php
blob157dcbddded125db14d045403b834c2303ba0eaf
1 <?php
3 /**
4 * Class containing static functions for working with
5 * logs of patrol events
7 * @author Rob Church <robchur@gmail.com>
8 */
9 class PatrolLog {
11 /**
12 * Record a log event for a change being patrolled
14 * @param mixed $change Change identifier or RecentChange object
15 * @param bool $auto Was this patrol event automatic?
17 public static function record( $change, $auto = false ) {
18 if( !( is_object( $change ) && $change instanceof RecentChange ) ) {
19 $change = RecentChange::newFromId( $change );
20 if( !is_object( $change ) )
21 return false;
23 $title = Title::makeTitleSafe( $change->getAttribute( 'rc_namespace' ),
24 $change->getAttribute( 'rc_title' ) );
25 if( is_object( $title ) ) {
26 $params = self::buildParams( $change, $auto );
27 $log = new LogPage( 'patrol', false ); # False suppresses RC entries
28 $log->addEntry( 'patrol', $title, '', $params );
29 return true;
30 } else {
31 return false;
35 /**
36 * Generate the log action text corresponding to a patrol log item
38 * @param Title $title Title of the page that was patrolled
39 * @param array $params Log parameters (from logging.log_params)
40 * @param Skin $skin Skin to use for building links, etc.
41 * @return string
43 public static function makeActionText( $title, $params, $skin ) {
44 # This is a bit of a hack, but...if $skin is not a Skin, then *do nothing*
45 # -- this is fine, because the action text we would be queried for under
46 # these conditions would have gone into recentchanges, which we aren't
47 # supposed to be updating
48 if( is_object( $skin ) ) {
49 list( $cur, /* $prev */, $auto ) = $params;
50 # Standard link to the page in question
51 $link = $skin->makeLinkObj( $title );
52 # Generate a diff link
53 $bits[] = 'oldid=' . urlencode( $cur );
54 $bits[] = 'diff=prev';
55 $bits = implode( '&', $bits );
56 $diff = $skin->makeLinkObj( $title, htmlspecialchars( wfMsg( 'patrol-log-diff', $cur ) ), $bits );
57 # Indicate whether or not the patrolling was automatic
58 $auto = $auto ? wfMsgHtml( 'patrol-log-auto' ) : '';
59 # Put it all together
60 return wfMsgHtml( 'patrol-log-line', $diff, $link, $auto );
61 } else {
62 return '';
66 /**
67 * Prepare log parameters for a patrolled change
69 * @param RecentChange $change RecentChange to represent
70 * @param bool $auto Whether the patrol event was automatic
71 * @return array
73 private static function buildParams( $change, $auto ) {
74 return array(
75 $change->getAttribute( 'rc_this_oldid' ),
76 $change->getAttribute( 'rc_last_oldid' ),
77 (int)$auto