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->makeLinkObj( $title );
00046 if( $title->exists() ) {
00047 # Generate a diff link
00048 $bits[] = 'oldid=' . urlencode( $cur );
00049 $bits[] = 'diff=prev';
00050 $bits = implode( '&', $bits );
00051 $diff = $skin->makeKnownLinkObj( $title, htmlspecialchars( wfMsg( 'patrol-log-diff', $cur ) ), $bits );
00052 } else {
00053 # Don't bother with a diff link, it's useless
00054 $diff = htmlspecialchars( wfMsg( 'patrol-log-diff', $cur ) );
00055 }
00056 # Indicate whether or not the patrolling was automatic
00057 $auto = $auto ? wfMsgHtml( 'patrol-log-auto' ) : '';
00058 # Put it all together
00059 return wfMsgHtml( 'patrol-log-line', $diff, $link, $auto );
00060 } else {
00061 $text = $title->getPrefixedText();
00062 return wfMsgForContent( 'patrol-log-line', wfMsgHtml('patrol-log-diff',$cur), "[[$text]]", '' );
00063 }
00064 }
00065
00073 private static function buildParams( $change, $auto ) {
00074 return array(
00075 $change->getAttribute( 'rc_this_oldid' ),
00076 $change->getAttribute( 'rc_last_oldid' ),
00077 (int)$auto
00078 );
00079 }
00080 }