Index: branches/robchurch/logs/maintenance/language/messages.inc |
— | — | @@ -1326,9 +1326,9 @@ |
1327 | 1327 | 'contribslink', |
1328 | 1328 | 'autoblocker', |
1329 | 1329 | 'blocklogpage', |
1330 | | - 'blocklogentry', |
1331 | 1330 | 'blocklogtext', |
1332 | | - 'unblocklogentry', |
| 1331 | + 'block-log-blocked', |
| 1332 | + 'block-log-unblocked', |
1333 | 1333 | 'block-log-flags-anononly', |
1334 | 1334 | 'block-log-flags-nocreate', |
1335 | 1335 | 'block-log-flags-noautoblock', |
Index: branches/robchurch/logs/includes/AutoLoader.php |
— | — | @@ -254,6 +254,8 @@ |
255 | 255 | 'EmaillingJob' => 'includes/JobQueue.php', |
256 | 256 | |
257 | 257 | # Logging |
| 258 | + 'BlockLogFormatter' => 'includes/BlockLogFormatter.php', |
| 259 | + 'CoreLogFormatter' => 'includes/CoreLogFormatter.php', |
258 | 260 | 'LogFormatter' => 'includes/LogFormatter.php', |
259 | 261 | 'LogItem' => 'includes/LogItem.php', |
260 | 262 | 'LogUser' => 'includes/LogUser.php', |
Index: branches/robchurch/logs/includes/BlockLogFormatter.php |
— | — | @@ -0,0 +1,116 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Formatting functions for the block log |
| 6 | + * |
| 7 | + * @addtogroup Logging |
| 8 | + * @author Rob Church <robchur@gmail.com> |
| 9 | + */ |
| 10 | +class BlockLogFormatter { |
| 11 | + |
| 12 | + /** |
| 13 | + * Tool link constants |
| 14 | + */ |
| 15 | + const LINK_BLOCK = 1; |
| 16 | + const LINK_UNBLOCK = 2; |
| 17 | + |
| 18 | + /** |
| 19 | + * Format a complete block log item |
| 20 | + * |
| 21 | + * @param LogItem $item |
| 22 | + * @param int $flags |
| 23 | + * @return string |
| 24 | + */ |
| 25 | + public static function formatBlock( $item, $flags ) { |
| 26 | + global $wgUser, $wgLang, $wgLogActions; |
| 27 | + $skin = $wgUser->getSkin(); |
| 28 | + $data = $item->getParameters(); |
| 29 | + |
| 30 | + $parts[] = $flags & LogFormatter::NO_DATE |
| 31 | + ? $wgLang->time( $item->getTimestamp() ) |
| 32 | + : $wgLang->timeAndDate( $item->getTimestamp() ); |
| 33 | + $parts[] = $skin->userLink( $item->getUser()->getId(), $item->getUser()->getName() ) |
| 34 | + . $skin->userToolLinks( $item->getUser()->getId(), $item->getUser()->getName() ); |
| 35 | + |
| 36 | + # Target link |
| 37 | + $link = $item->getAction() == 'block' ? self::LINK_BLOCK : self::LINK_UNBLOCK; |
| 38 | + $params[] = self::formatTarget( $item->getTarget(), $link ); |
| 39 | + |
| 40 | + # Format block flags, etc. if applicable |
| 41 | + if( $item->getAction() == 'block' ) { |
| 42 | + $params[] = $wgLang->translateBlockExpiry( $data[0] ); |
| 43 | + $params[] = ( isset( $data[1] ) ? self::formatBlockFlags( $data[1] ) : '' ); |
| 44 | + } |
| 45 | + |
| 46 | + $parts[] = wfMsgReal( $wgLogActions[ $item->getActionKey() ], $params ); |
| 47 | + return "<li>" . implode( ' ', $parts ) . "</li>\n"; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Format the block target; link to the user page, standard tool |
| 52 | + * links and an unblock link (if required) |
| 53 | + * |
| 54 | + * @param Title $target |
| 55 | + * @param int $link |
| 56 | + * @return string |
| 57 | + */ |
| 58 | + private static function formatTarget( $target, $link ) { |
| 59 | + global $wgUser; |
| 60 | + $skin = $wgUser->getSkin(); |
| 61 | + |
| 62 | + $tools[] = $skin->makeLinkObj( $target->getTalkPage(), wfMsgHtml( 'talkpagelinktext' ) ); |
| 63 | + $tools[] = $skin->makeKnownLinkObj( |
| 64 | + SpecialPage::getTitleFor( 'Contributions', $target->getText() ), wfMsgHtml( 'contribslink' ) ); |
| 65 | + |
| 66 | + if( $wgUser->isAllowed( 'block' ) ) { |
| 67 | + if( $link == self::LINK_BLOCK ) { |
| 68 | + $tools[] = $skin->makeKnownLinkObj( |
| 69 | + SpecialPage::getTitleFor( 'Blockip', $target->getText() ), wfMsgHtml( 'blocklink' ) ); |
| 70 | + } else { |
| 71 | + $tools[] = $skin->makeKnownLinkObj( |
| 72 | + SpecialPage::getTitleFor( 'Ipblocklist', wfMsgHtml( 'unblocklink' ), |
| 73 | + 'action=unblock&ip=' . $target->getPartialUrl() ) ); |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + return $skin->makeLinkObj( $target, htmlspecialchars( $target->getText() ) ) |
| 78 | + . ' (' . implode( ' | ', $tools ) . ')'; |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * Convert a comma-delimited list of block log flags |
| 83 | + * into a more readable (and translated) form |
| 84 | + * |
| 85 | + * @param $flags Flags to format |
| 86 | + * @return string |
| 87 | + */ |
| 88 | + private static function formatBlockFlags( $flags ) { |
| 89 | + $flags = explode( ',', trim( $flags ) ); |
| 90 | + if( count( $flags ) > 0 ) { |
| 91 | + for( $i = 0; $i < count( $flags ); $i++ ) |
| 92 | + $flags[$i] = self::formatBlockFlag( $flags[$i] ); |
| 93 | + return '(' . implode( ', ', $flags ) . ')'; |
| 94 | + } else { |
| 95 | + return ''; |
| 96 | + } |
| 97 | + } |
| 98 | + |
| 99 | + /** |
| 100 | + * Translate a block log flag if possible |
| 101 | + * |
| 102 | + * @param $flag Flag to translate |
| 103 | + * @return string |
| 104 | + */ |
| 105 | + private static function formatBlockFlag( $flag ) { |
| 106 | + static $messages = array(); |
| 107 | + if( !isset( $messages[$flag] ) ) { |
| 108 | + $k = 'block-log-flags-' . $flag; |
| 109 | + $msg = wfMsg( $k ); |
| 110 | + $messages[$flag] = htmlspecialchars( wfEmptyMsg( $k, $msg ) ? $flag : $msg ); |
| 111 | + } |
| 112 | + return $messages[$flag]; |
| 113 | + } |
| 114 | + |
| 115 | +} |
| 116 | + |
| 117 | +?> |
\ No newline at end of file |
Property changes on: branches/robchurch/logs/includes/BlockLogFormatter.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 118 | + native |
Index: branches/robchurch/logs/includes/SpecialLog.php |
— | — | @@ -392,11 +392,6 @@ |
393 | 393 | wfMsg( 'undeletebtn' ) , |
394 | 394 | 'target='. urlencode( $title->getPrefixedDBkey() ) ) . ')'; |
395 | 395 | |
396 | | - // show unblock link |
397 | | - } elseif ( $s->log_action == 'block' && $wgUser->isAllowed( 'block' ) ) { |
398 | | - $revert = '(' . $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Ipblocklist' ), |
399 | | - wfMsg( 'unblocklink' ), |
400 | | - 'action=unblock&ip=' . urlencode( $s->log_title ) ) . ')'; |
401 | 396 | // show change protection link |
402 | 397 | } elseif ( ( $s->log_action == 'protect' || $s->log_action == 'modify' ) && $wgUser->isAllowed( 'protect' ) ) { |
403 | 398 | $revert = '(' . $skin->makeKnownLinkObj( $title, wfMsg( 'protect_change' ), 'action=unprotect' ) . ')'; |
Index: branches/robchurch/logs/includes/DefaultSettings.php |
— | — | @@ -2243,8 +2243,8 @@ |
2244 | 2244 | * Extensions with custom log types may add to this array. |
2245 | 2245 | */ |
2246 | 2246 | $wgLogActions = array( |
2247 | | - 'block/block' => 'blocklogentry', |
2248 | | - 'block/unblock' => 'unblocklogentry', |
| 2247 | + 'block/block' => 'block-log-blocked', |
| 2248 | + 'block/unblock' => 'block-log-unblocked', |
2249 | 2249 | 'protect/protect' => 'protectedarticle', |
2250 | 2250 | 'protect/modify' => 'modifiedarticleprotection', |
2251 | 2251 | 'protect/unprotect' => 'unprotectedarticle', |
— | — | @@ -2266,7 +2266,6 @@ |
2267 | 2267 | * a log line during formatting |
2268 | 2268 | */ |
2269 | 2269 | $wgLogFormatAppenders = array( |
2270 | | - |
2271 | 2270 | ); |
2272 | 2271 | |
2273 | 2272 | /** |
— | — | @@ -2276,6 +2275,7 @@ |
2277 | 2276 | * line including <li></li> |
2278 | 2277 | */ |
2279 | 2278 | $wgLogFormatters = array( |
| 2279 | + 'block' => array( 'BlockLogFormatter', 'formatBlock' ), |
2280 | 2280 | 'patrol' => array( 'PatrolLog', 'formatLine' ), |
2281 | 2281 | ); |
2282 | 2282 | |
Index: branches/robchurch/logs/includes/CoreLogFormatter.php |
— | — | @@ -0,0 +1,14 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Log formatting functions for all built-in logs |
| 6 | + * which need them |
| 7 | + * |
| 8 | + * @addtogroup Logging |
| 9 | + * @author Rob Church <robchur@gmail.com> |
| 10 | + */ |
| 11 | +class CoreLogFormatter { |
| 12 | + |
| 13 | +} |
| 14 | + |
| 15 | +?> |
\ No newline at end of file |
Property changes on: branches/robchurch/logs/includes/CoreLogFormatter.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 16 | + native |
Index: branches/robchurch/logs/languages/messages/MessagesEn.php |
— | — | @@ -2019,11 +2019,11 @@ |
2020 | 2020 | 'contribslink' => 'contribs', |
2021 | 2021 | 'autoblocker' => 'Autoblocked because your IP address has been recently used by "[[User:$1|$1]]". The reason given for $1\'s block is: "$2"', |
2022 | 2022 | 'blocklogpage' => 'Block log', |
2023 | | -'blocklogentry' => 'blocked "[[$1]]" with an expiry time of $2 $3', |
2024 | 2023 | 'blocklogtext' => 'This is a log of user blocking and unblocking actions. Automatically |
2025 | 2024 | blocked IP addresses are not listed. See the [[Special:Ipblocklist|IP block list]] for |
2026 | 2025 | the list of currently operational bans and blocks.', |
2027 | | -'unblocklogentry' => 'unblocked $1', |
| 2026 | +'block-log-blocked' => 'blocked $1 with an expiry time of $2 $3', |
| 2027 | +'block-log-unblocked' => 'unblocked $1', |
2028 | 2028 | 'block-log-flags-anononly' => 'anonymous users only', |
2029 | 2029 | 'block-log-flags-nocreate' => 'account creation disabled', |
2030 | 2030 | 'block-log-flags-noautoblock' => 'autoblock disabled', |