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 $rc Mixed: change identifier or RecentChange object
15 * @param $auto Boolean: was this patrol event automatic?
17 public static function record( $rc, $auto = false ) {
18 if( !( $rc instanceof RecentChange
) ) {
19 $rc = RecentChange
::newFromId( $rc );
20 if( !is_object( $rc ) )
23 $title = Title
::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) );
24 if( is_object( $title ) ) {
25 $params = self
::buildParams( $rc, $auto );
26 $log = new LogPage( 'patrol', false, $auto ?
"skipUDP" : "UDP" ); # False suppresses RC entries
27 $log->addEntry( 'patrol', $title, '', $params );
34 * Generate the log action text corresponding to a patrol log item
36 * @param $title Title of the page that was patrolled
37 * @param $params Array: log parameters (from logging.log_params)
38 * @param $skin Skin to use for building links, etc.
41 public static function makeActionText( $title, $params, $skin ) {
44 list( $cur, /* $prev */, $auto ) = $params;
45 if( is_object( $skin ) ) {
46 # Standard link to the page in question
47 $link = $skin->link( $title );
48 if( $title->exists() ) {
49 # Generate a diff link
57 htmlspecialchars( wfMsg( 'patrol-log-diff', $wgLang->formatNum( $cur, true ) ) ),
60 array( 'known', 'noclasses' )
63 # Don't bother with a diff link, it's useless
64 $diff = htmlspecialchars( wfMsg( 'patrol-log-diff', $cur ) );
66 # Indicate whether or not the patrolling was automatic
67 $auto = $auto ?
wfMsgHtml( 'patrol-log-auto' ) : '';
69 return wfMsgHtml( 'patrol-log-line', $diff, $link, $auto );
71 $text = $title->getPrefixedText();
72 return wfMsgForContent( 'patrol-log-line', wfMsgHtml('patrol-log-diff',$cur), "[[$text]]", '' );
77 * Prepare log parameters for a patrolled change
79 * @param $change RecentChange to represent
80 * @param $auto Boolean: whether the patrol event was automatic
83 private static function buildParams( $change, $auto ) {
85 $change->getAttribute( 'rc_this_oldid' ),
86 $change->getAttribute( 'rc_last_oldid' ),