Index: trunk/phase3/includes/Article.php |
— | — | @@ -1348,6 +1348,7 @@ |
1349 | 1349 | # Mark as patrolled if the user can do so |
1350 | 1350 | if( $wgUser->isAllowed( 'autopatrol' ) ) { |
1351 | 1351 | RecentChange::markPatrolled( $rcid ); |
| 1352 | + PatrolLog::record( $rcid, true ); |
1352 | 1353 | } |
1353 | 1354 | } |
1354 | 1355 | $wgUser->incEditCount(); |
— | — | @@ -1409,6 +1410,7 @@ |
1410 | 1411 | # Mark as patrolled if the user can |
1411 | 1412 | if( $wgUser->isAllowed( 'autopatrol' ) ) { |
1412 | 1413 | RecentChange::markPatrolled( $rcid ); |
| 1414 | + PatrolLog::record( $rcid, true ); |
1413 | 1415 | } |
1414 | 1416 | } |
1415 | 1417 | $wgUser->incEditCount(); |
— | — | @@ -1514,6 +1516,7 @@ |
1515 | 1517 | |
1516 | 1518 | # Mark the edit as patrolled |
1517 | 1519 | RecentChange::markPatrolled( $rcid ); |
| 1520 | + PatrolLog::record( $rcid ); |
1518 | 1521 | wfRunHooks( 'MarkPatrolledComplete', array( &$rcid, &$wgUser, false ) ); |
1519 | 1522 | |
1520 | 1523 | # Inform the user |
Index: trunk/phase3/includes/PatrolLog.php |
— | — | @@ -0,0 +1,84 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Class containing static functions for working with |
| 6 | + * logs of patrol events |
| 7 | + * |
| 8 | + * @package MediaWiki |
| 9 | + * @author Rob Church <robchur@gmail.com> |
| 10 | + */ |
| 11 | +class PatrolLog { |
| 12 | + |
| 13 | + /** |
| 14 | + * Record a log event for a change being patrolled |
| 15 | + * |
| 16 | + * @param mixed $change Change identifier or RecentChange object |
| 17 | + * @param bool $auto Was this patrol event automatic? |
| 18 | + */ |
| 19 | + public static function record( $change, $auto = false ) { |
| 20 | + if( !( is_object( $change ) && $change instanceof RecentChange ) ) { |
| 21 | + $change = RecentChange::newFromId( $change ); |
| 22 | + if( !is_object( $change ) ) |
| 23 | + return false; |
| 24 | + } |
| 25 | + $title = Title::makeTitleSafe( $change->getAttribute( 'rc_namespace' ), |
| 26 | + $change->getAttribute( 'rc_title' ) ); |
| 27 | + if( is_object( $title ) ) { |
| 28 | + $params = self::buildParams( $change, $auto ); |
| 29 | + $log = new LogPage( 'patrol', false ); # False suppresses RC entries |
| 30 | + $log->addEntry( 'patrol', $title, '', $params ); |
| 31 | + return true; |
| 32 | + } else { |
| 33 | + return false; |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * Generate the log action text corresponding to a patrol log item |
| 39 | + * |
| 40 | + * @param Title $title Title of the page that was patrolled |
| 41 | + * @param array $params Log parameters (from logging.log_params) |
| 42 | + * @param Skin $skin Skin to use for building links, etc. |
| 43 | + * @return string |
| 44 | + */ |
| 45 | + public static function makeActionText( $title, $params, $skin ) { |
| 46 | + # This is a bit of a hack, but...if $skin is not a Skin, then *do nothing* |
| 47 | + # -- this is fine, because the action text we would be queried for under |
| 48 | + # these conditions would have gone into recentchanges, which we aren't |
| 49 | + # supposed to be updating |
| 50 | + if( is_object( $skin ) ) { |
| 51 | + list( $cur, $prev, $auto ) = $params; |
| 52 | + # Standard link to the page in question |
| 53 | + $link = $skin->makeLinkObj( $title ); |
| 54 | + # Generate a diff link |
| 55 | + $bits[] = 'oldid=' . urlencode( $cur ); |
| 56 | + $bits[] = 'diff=prev'; |
| 57 | + $bits = implode( '&', $bits ); |
| 58 | + $diff = $skin->makeLinkObj( $title, htmlspecialchars( wfMsg( 'patrol-log-diff', $cur ) ), $bits ); |
| 59 | + # Indicate whether or not the patrolling was automatic |
| 60 | + $auto = $auto ? wfMsgHtml( 'patrol-log-auto' ) : ''; |
| 61 | + # Put it all together |
| 62 | + return wfMsgHtml( 'patrol-log-line', $diff, $link, $auto ); |
| 63 | + } else { |
| 64 | + return ''; |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * Prepare log parameters for a patrolled change |
| 70 | + * |
| 71 | + * @param RecentChange $change RecentChange to represent |
| 72 | + * @param bool $auto Whether the patrol event was automatic |
| 73 | + * @return array |
| 74 | + */ |
| 75 | + private static function buildParams( $change, $auto ) { |
| 76 | + return array( |
| 77 | + $change->getAttribute( 'rc_this_oldid' ), |
| 78 | + $change->getAttribute( 'rc_last_oldid' ), |
| 79 | + (int)$auto |
| 80 | + ); |
| 81 | + } |
| 82 | + |
| 83 | +} |
| 84 | + |
| 85 | +?> |
\ No newline at end of file |
Property changes on: trunk/phase3/includes/PatrolLog.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 86 | + native |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -240,6 +240,7 @@ |
241 | 241 | 'UserloginTemplate' => 'includes/templates/Userlogin.php', |
242 | 242 | 'Language' => 'languages/Language.php', |
243 | 243 | 'PasswordResetForm' => 'includes/SpecialResetpass.php', |
| 244 | + 'PatrolLog' => 'includes/PatrolLog.php', |
244 | 245 | |
245 | 246 | // API classes |
246 | 247 | 'ApiBase' => 'includes/api/ApiBase.php', |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -2004,7 +2004,9 @@ |
2005 | 2005 | 'delete', |
2006 | 2006 | 'upload', |
2007 | 2007 | 'move', |
2008 | | - 'import' ); |
| 2008 | + 'import', |
| 2009 | + 'patrol', |
| 2010 | +); |
2009 | 2011 | |
2010 | 2012 | /** |
2011 | 2013 | * Lists the message key string for each log type. The localized messages |
— | — | @@ -2020,7 +2022,9 @@ |
2021 | 2023 | 'delete' => 'dellogpage', |
2022 | 2024 | 'upload' => 'uploadlogpage', |
2023 | 2025 | 'move' => 'movelogpage', |
2024 | | - 'import' => 'importlogpage' ); |
| 2026 | + 'import' => 'importlogpage', |
| 2027 | + 'patrol' => 'patrol-log-page', |
| 2028 | +); |
2025 | 2029 | |
2026 | 2030 | /** |
2027 | 2031 | * Lists the message key string for descriptive text to be shown at the |
— | — | @@ -2036,7 +2040,9 @@ |
2037 | 2041 | 'delete' => 'dellogpagetext', |
2038 | 2042 | 'upload' => 'uploadlogpagetext', |
2039 | 2043 | 'move' => 'movelogpagetext', |
2040 | | - 'import' => 'importlogpagetext', ); |
| 2044 | + 'import' => 'importlogpagetext', |
| 2045 | + 'patrol' => 'patrol-log-header', |
| 2046 | +); |
2041 | 2047 | |
2042 | 2048 | /** |
2043 | 2049 | * Lists the message key string for formatting individual events of each |
— | — | @@ -2058,7 +2064,8 @@ |
2059 | 2065 | 'move/move' => '1movedto2', |
2060 | 2066 | 'move/move_redir' => '1movedto2_redir', |
2061 | 2067 | 'import/upload' => 'import-logentry-upload', |
2062 | | - 'import/interwiki' => 'import-logentry-interwiki' ); |
| 2068 | + 'import/interwiki' => 'import-logentry-interwiki', |
| 2069 | +); |
2063 | 2070 | |
2064 | 2071 | /** |
2065 | 2072 | * Experimental preview feature to fetch rendered text |
Index: trunk/phase3/includes/LogPage.php |
— | — | @@ -134,6 +134,10 @@ |
135 | 135 | global $wgLang, $wgContLang, $wgLogActions; |
136 | 136 | |
137 | 137 | $key = "$type/$action"; |
| 138 | + |
| 139 | + if( $key == 'patrol/patrol' ) |
| 140 | + return PatrolLog::makeActionText( $title, $params, $skin ); |
| 141 | + |
138 | 142 | if( isset( $wgLogActions[$key] ) ) { |
139 | 143 | if( is_null( $title ) ) { |
140 | 144 | $rv=wfMsg( $wgLogActions[$key] ); |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2236,6 +2236,13 @@ |
2237 | 2237 | 'markedaspatrollederrortext' => "You need to specify a revision to mark as patrolled.", |
2238 | 2238 | 'markedaspatrollederror-noautopatrol' => 'You are not allowed to mark your own changes as patrolled.', |
2239 | 2239 | |
| 2240 | +# Patrol log |
| 2241 | +'patrol-log-page' => 'Patrol log', |
| 2242 | +'patrol-log-header' => '', |
| 2243 | +'patrol-log-line' => 'marked $1 of $2 patrolled $3', |
| 2244 | +'patrol-log-auto' => '(automatic)', |
| 2245 | +'patrol-log-diff' => 'r$1', |
| 2246 | + |
2240 | 2247 | # image deletion |
2241 | 2248 | 'deletedrevision' => 'Deleted old revision $1.', |
2242 | 2249 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -78,8 +78,8 @@ |
79 | 79 | * Suppress PHP warning about set_time_limit in installer when safe mode is on |
80 | 80 | * (bug 3000) Fall back to SCRIPT_NAME plus QUERY_STRING when REQUEST_URI is |
81 | 81 | not available, as on IIS with PHP-CGI |
| 82 | +* (bug 8621) Log revisions marked as patrolled |
82 | 83 | |
83 | | - |
84 | 84 | == Languages updated == |
85 | 85 | |
86 | 86 | * Belarusian (be) |