e4f80ac86e75d5950095d50c0b620d043c9e2acb
4 * Class containing static functions for working with
5 * logs of patrol events
8 * @author Rob Church <robchur@gmail.com>
13 * Record a log event for a change being patrolled
15 * @param mixed $change Change identifier or RecentChange object
16 * @param bool $auto Was this patrol event automatic?
18 public static function record( $change, $auto = false ) {
19 if( !( is_object( $change ) && $change instanceof RecentChange
) ) {
20 $change = RecentChange
::newFromId( $change );
21 if( !is_object( $change ) )
24 $title = Title
::makeTitleSafe( $change->getAttribute( 'rc_namespace' ),
25 $change->getAttribute( 'rc_title' ) );
26 if( is_object( $title ) ) {
27 $params = self
::buildParams( $change, $auto );
28 $log = new LogPage( 'patrol', false ); # False suppresses RC entries
29 $log->addEntry( 'patrol', $title, '', $params );
37 * Generate the log action text corresponding to a patrol log item
39 * @param Title $title Title of the page that was patrolled
40 * @param array $params Log parameters (from logging.log_params)
41 * @param Skin $skin Skin to use for building links, etc.
44 public static function makeActionText( $title, $params, $skin ) {
45 # This is a bit of a hack, but...if $skin is not a Skin, then *do nothing*
46 # -- this is fine, because the action text we would be queried for under
47 # these conditions would have gone into recentchanges, which we aren't
48 # supposed to be updating
49 if( is_object( $skin ) ) {
50 list( $cur, $prev, $auto ) = $params;
51 # Standard link to the page in question
52 $link = $skin->makeLinkObj( $title );
53 # Generate a diff link
54 $bits[] = 'oldid=' . urlencode( $cur );
55 $bits[] = 'diff=prev';
56 $bits = implode( '&', $bits );
57 $diff = $skin->makeLinkObj( $title, htmlspecialchars( wfMsg( 'patrol-log-diff', $cur ) ), $bits );
58 # Indicate whether or not the patrolling was automatic
59 $auto = $auto ?
wfMsgHtml( 'patrol-log-auto' ) : '';
61 return wfMsgHtml( 'patrol-log-line', $diff, $link, $auto );
68 * Prepare log parameters for a patrolled change
70 * @param RecentChange $change RecentChange to represent
71 * @param bool $auto Whether the patrol event was automatic
74 private static function buildParams( $change, $auto ) {
76 $change->getAttribute( 'rc_this_oldid' ),
77 $change->getAttribute( 'rc_last_oldid' ),