4 * Class containing static functions for working with
5 * logs of patrol events
7 * @author Rob Church <robchur@gmail.com>
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 ) )
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 );
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.
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' ) : '';
60 return wfMsgHtml( 'patrol-log-line', $diff, $link, $auto );
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
73 private static function buildParams( $change, $auto ) {
75 $change->getAttribute( 'rc_this_oldid' ),
76 $change->getAttribute( 'rc_last_oldid' ),