r46275 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46274‎ | r46275 | r46276 >
Date:19:23, 26 January 2009
Author:werdna
Status:deferred
Tags:
Comment:
Fix up Abuse Log, by adding descriptions for variables, styling the variable table.

Also, fix up a message naming conflict introduced by r46272.
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.i18n.php (modified) (history)
  • /trunk/extensions/AbuseFilter/SpecialAbuseLog.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php (modified) (history)
  • /trunk/extensions/AbuseFilter/abusefilter.css (added) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/SpecialAbuseLog.php
@@ -19,6 +19,9 @@
2020 $wgOut->setRobotPolicy( "noindex,nofollow" );
2121 $wgOut->setArticleRelated( false );
2222 $wgOut->enableClientCache( false );
 23+
 24+ global $wgScriptPath;
 25+ $wgOut->addExtensionStyle( $wgScriptPath."/extensions/AbuseFilter/abusefilter.css" );
2326
2427 // Are we allowed?
2528 if ( count( $errors = $this->getTitle()->getUserPermissionsErrors( 'abusefilter-log', $wgUser, true, array( 'ns-specialprotected' ) ) ) ) {
@@ -98,6 +101,11 @@
99102 if (!$this->canSeeDetails()) {
100103 return;
101104 }
 105+
 106+ // I don't want to change the names of the pre-existing messages
 107+ // describing the variables, nor do I want to rewrite them, so I'm just
 108+ // mapping the variable names to builder messages with a pre-existing array.
 109+ $variableMessageMappings = array( 'ACCOUNTNAME' => 'accountname', 'ACTION' => 'action', 'ADDED_LINES' => 'addedlines', 'EDIT_DELTA' => 'delta', 'EDIT_DIFF' => 'diff', 'NEW_SIZE' => 'newsize', 'OLD_SIZE' => 'oldsize', 'REMOVED_LINES' => 'removedlines', 'SUMMARY' => 'summary', 'ARTICLE_ARTICLEID' => 'article-id', 'ARTICLE_NAMESPACE' => 'article-ns', 'ARTICLE_TEXT' => 'article-text', 'ARTICLE_PREFIXEDTEXT' => 'article-prefixedtext', 'MOVED_FROM_ARTICLEID' => 'movedfrom-id', 'MOVED_FROM_NAMESPACE' => 'movedfrom-ns', 'MOVED_FROM_TEXT' => 'movedfrom-text', 'MOVED_FROM_PREFIXEDTEXT' => 'movedfrom-prefixedtext', 'MOVED_TO_ARTICLEID' => 'movedto-id', 'MOVED_TO_NAMESPACE' => 'movedto-ns', 'MOVED_TO_TEXT' => 'movedto-text', 'MOVED_TO_PREFIXEDTEXT' => 'movedto-prefixedtext', 'USER_EDITCOUNT' => 'user-editcount', 'USER_AGE' => 'user-age', 'USER_NAME' => 'user-name', 'USER_GROUPS' => 'user-groups', 'USER_EMAILCONFIRM' => 'user-emailconfirm', 'ARTICLE_RECENT_CONTRIBUTORS' => 'recent-contributors', 'ALL_LINKS' => 'all-links', 'ADDED_LINKS' => 'added-links', 'REMOVED_LINKS' => 'removed-links');
102110
103111 $dbr = wfGetDB( DB_SLAVE );
104112
@@ -115,14 +123,21 @@
116124 // Build a table.
117125 $vars = unserialize( $row->afl_var_dump );
118126
119 - $output .= Xml::openElement( 'table', array( 'class' => 'wikitable mw-abuselog-details', 'style' => "width: 80%;" ) ) . Xml::openElement( 'tbody' );
 127+ $output .= Xml::openElement( 'table', array( 'class' => 'mw-abuselog-details', 'style' => "width: 80%;" ) ) . Xml::openElement( 'tbody' );
120128
121129 $header = Xml::element( 'th', null, wfMsg( 'abusefilter-log-details-var' ) ) . Xml::element( 'th', null, wfMsg( 'abusefilter-log-details-val' ) );
122130 $output .= Xml::tags( 'tr', null, $header );
123131
124132 // Now, build the body of the table.
125133 foreach( $vars as $key => $value ) {
126 - $trow = Xml::element( 'td', array( 'class' => 'mw-abuselog-var', 'style' => 'width: 30%;' ), $key ) . Xml::element( 'td', array( 'class' => 'mw-abuselog-var-value', 'style' => "white-space: pre; font-family: monospace;" ), $value );
 134+ if ( !empty($variableMessageMappings[$key]) ) {
 135+ $mapping = $variableMessageMappings[$key];
 136+ $keyDisplay = wfMsgExt( "abusefilter-edit-builder-vars-$mapping", 'parseinline' ) . ' (' . Xml::element( 'tt', null, $key ) . ')';
 137+ } else {
 138+ $keyDisplay = Xml::element( 'tt', null, $key );
 139+ }
 140+
 141+ $trow = Xml::tags( 'td', array( 'class' => 'mw-abuselog-var', 'style' => 'width: 30%;' ), $keyDisplay ) . Xml::element( 'td', array( 'class' => 'mw-abuselog-var-value', 'style' => "white-space: pre; font-family: monospace;" ), $value );
127142 $output .= Xml::tags( 'tr', array( 'class' => "mw-abuselog-details-$key" ), $trow );
128143 }
129144
Index: trunk/extensions/AbuseFilter/abusefilter.css
@@ -0,0 +1,21 @@
 2+/* This code was stolen shamelessly from enwikipedia's Common.css */
 3+table.mw-abuselog-details {
 4+ margin: 1em 1em 1em 0;
 5+ background: #f9f9f9;
 6+ border: 1px #aaa solid;
 7+ border-collapse: collapse;
 8+}
 9+
 10+table.mw-abuselog-details th, table.mw-abuselog-details td {
 11+ border: 1px #aaa solid;
 12+ padding: 0.2em;
 13+}
 14+
 15+table.mw-abuselog-details th {
 16+ background: #f2f2f2;
 17+ text-align: center;
 18+}
 19+
 20+table.mw-abuselog-details caption {
 21+ font-weight: bold;
 22+}
\ No newline at end of file
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php
@@ -20,7 +20,7 @@
2121 if ($filter)
2222 $wgOut->setPageTitle( wfMsg( 'abusefilter-history', $filter ) );
2323 else
24 - $wgOut->setPageTitle( wfMsg( 'abusefilter-log' ) );
 24+ $wgOut->setPageTitle( wfMsg( 'abusefilter-filter-log' ) );
2525
2626 $sk = $wgUser->getSkin();
2727
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php
@@ -228,9 +228,13 @@
229229 'abusefilter-edit-builder-vars-user-name' => 'Name of user account',
230230 'abusefilter-edit-builder-vars-user-groups' => 'Groups (including implicit) user is in',
231231 'abusefilter-edit-builder-vars-user-emailconfirm' => 'Time email address was confirmed',
 232+ 'abusefilter-edit-builder-vars-recent-contributors' => 'Last five contributors to the article',
 233+ 'abusefilter-edit-builder-vars-all-links' => 'All external links in the new text',
 234+ 'abusefilter-edit-builder-vars-added-links' => 'All external links added in the edit',
 235+ 'abusefilter-edit-builder-vars-removed-links' => 'All external links removed oin the edit',
232236
233237 // Filter history
234 - 'abusefilter-log' => 'Recent filter changes',
 238+ 'abusefilter-filter-log' => 'Recent filter changes',
235239 'abusefilter-history' => 'History for filter $1',
236240 'abusefilter-history-foruser' => 'Changes by $1',
237241 'abusefilter-history-hidden' => 'hidden',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r46272Add a handy 'Abuse Filter log' where you can see all recent changes to filter...werdna18:50, 26 January 2009

Status & tagging log