00001 <?php
00002
00009 class PatrolLog {
00010
00017 public static function record( $rc, $auto = false ) {
00018 if( !( $rc instanceof RecentChange ) ) {
00019 $rc = RecentChange::newFromId( $rc );
00020 if( !is_object( $rc ) )
00021 return false;
00022 }
00023 $title = Title::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) );
00024 if( is_object( $title ) ) {
00025 $params = self::buildParams( $rc, $auto );
00026 $log = new LogPage( 'patrol', false, $auto ? "skipUDP" : "UDP" ); # False suppresses RC entries
00027 $log->addEntry( 'patrol', $title, '', $params );
00028 return true;
00029 }
00030 return false;
00031 }
00032
00041 public static function makeActionText( $title, $params, $skin ) {
00042 list( $cur, , $auto ) = $params;
00043 if( is_object( $skin ) ) {
00044 # Standard link to the page in question
00045 $link = $skin->link( $title );
00046 if( $title->exists() ) {
00047 # Generate a diff link
00048 $query = array(
00049 'oldid' => $cur,
00050 'diff' => 'prev'
00051 );
00052
00053 $diff = $skin->link(
00054 $title,
00055 htmlspecialchars( wfMsg( 'patrol-log-diff', $cur ) ),
00056 array(),
00057 $query,
00058 array( 'known', 'noclasses' )
00059 );
00060 } else {
00061 # Don't bother with a diff link, it's useless
00062 $diff = htmlspecialchars( wfMsg( 'patrol-log-diff', $cur ) );
00063 }
00064 # Indicate whether or not the patrolling was automatic
00065 $auto = $auto ? wfMsgHtml( 'patrol-log-auto' ) : '';
00066 # Put it all together
00067 return wfMsgHtml( 'patrol-log-line', $diff, $link, $auto );
00068 } else {
00069 $text = $title->getPrefixedText();
00070 return wfMsgForContent( 'patrol-log-line', wfMsgHtml('patrol-log-diff',$cur), "[[$text]]", '' );
00071 }
00072 }
00073
00081 private static function buildParams( $change, $auto ) {
00082 return array(
00083 $change->getAttribute( 'rc_this_oldid' ),
00084 $change->getAttribute( 'rc_last_oldid' ),
00085 (int)$auto
00086 );
00087 }
00088 }