Revision: 46307
Author: werdna
Date: 2009-01-27 01:31:42 +0000 (Tue, 27 Jan 2009)
Log Message:
-----------
Add OLD_TEXT and NEW_TEXT variables, refactor variable storage, and clean up
the AbuseLog interface just a little.
Modified Paths:
--------------
trunk/extensions/AbuseFilter/AbuseFilter.class.php
trunk/extensions/AbuseFilter/AbuseFilter.hooks.php
trunk/extensions/AbuseFilter/AbuseFilter.i18n.php
trunk/extensions/AbuseFilter/SpecialAbuseLog.php
trunk/extensions/AbuseFilter/abusefilter.css
Modified: trunk/extensions/AbuseFilter/AbuseFilter.class.php
===================================================================
--- trunk/extensions/AbuseFilter/AbuseFilter.class.php 2009-01-27 01:00:32 UTC
(rev 46306)
+++ trunk/extensions/AbuseFilter/AbuseFilter.class.php 2009-01-27 01:31:42 UTC
(rev 46307)
@@ -12,6 +12,14 @@
public static $filters = array();
public static $tagsToSet = array();
public static $history_mappings = array( 'af_pattern' => 'afh_pattern',
'af_user' => 'afh_user', 'af_user_text' => 'afh_user_text', 'af_timestamp' =>
'afh_timestamp', 'af_comments' => 'afh_comments', 'af_public_comments' =>
'afh_public_comments', 'af_deleted' => 'afh_deleted', 'af_id' => 'afh_filter' );
+ public static $builderValues = array(
+ 'op-arithmetic' => array('+' => 'addition', '-' =>
'subtraction', '*' => 'multiplication', '/' => 'divide', '%' => 'modulo', '**'
=> 'pow'),
+ 'op-comparison' => array('==' => 'equal', '!=' =>
'notequal', '<' => 'lt', '>' => 'gt', '<=' => 'lte', '>=' => 'gte'),
+ 'op-bool' => array( '!' => 'not', '&' => 'and', '|' =>
'or', '^' => 'xor' ),
+ 'misc' => array( 'in' => 'in', 'like' => 'like', '""'
=> 'stringlit', ),
+ 'funcs' => array( 'length(string)' => 'length',
'lcase(string)' => 'lcase', 'ccnorm(string)' => 'ccnorm', 'rmdoubles(string)'
=> 'rmdoubles', 'specialratio(string)' => 'specialratio', 'norm(string)' =>
'norm', 'count(needle,haystack)' => 'count' ),
+ 'vars' => 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', 'OLD_TEXT' => 'old-text', 'NEW_TEXT' => 'new-text'),
+ );
public static function generateUserVars( $user ) {
$vars = array();
@@ -641,14 +649,7 @@
$rules = Xml::textarea( $textName, ( isset( $rules ) ?
$rules."\n" : "\n" ) );
- $dropDown = array(
- 'op-arithmetic' => array('+' => 'addition', '-' =>
'subtraction', '*' => 'multiplication', '/' => 'divide', '%' => 'modulo', '**'
=> 'pow'),
- 'op-comparison' => array('==' => 'equal', '!=' =>
'notequal', '<' => 'lt', '>' => 'gt', '<=' => 'lte', '>=' => 'gte'),
- 'op-bool' => array( '!' => 'not', '&' => 'and', '|' =>
'or', '^' => 'xor' ),
- 'misc' => array( 'in' => 'in', 'like' => 'like', '""'
=> 'stringlit', ),
- 'funcs' => array( 'length(string)' => 'length',
'lcase(string)' => 'lcase', 'ccnorm(string)' => 'ccnorm', 'rmdoubles(string)'
=> 'rmdoubles', 'specialratio(string)' => 'specialratio', 'norm(string)' =>
'norm', 'count(needle,haystack)' => 'count' ),
- 'vars' => 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'),
- );
+ $dropDown = self::$builderValues;
// Generate builder drop-down
$builder = '';
Modified: trunk/extensions/AbuseFilter/AbuseFilter.hooks.php
===================================================================
--- trunk/extensions/AbuseFilter/AbuseFilter.hooks.php 2009-01-27 01:00:32 UTC
(rev 46306)
+++ trunk/extensions/AbuseFilter/AbuseFilter.hooks.php 2009-01-27 01:31:42 UTC
(rev 46307)
@@ -26,6 +26,9 @@
$diff = trim( str_replace( '\No newline at end of file', '',
$diff ) );
$vars['EDIT_DIFF'] = $diff;
$vars['NEW_SIZE'] = strlen($new_text);
+
+ $vars['OLD_TEXT'] = $old_text;
+ $vars['NEW_TEXT'] = $new_text;
// Some more specific/useful details about the changes.
$diff_lines = explode( "\n", $diff );
Modified: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php
===================================================================
--- trunk/extensions/AbuseFilter/AbuseFilter.i18n.php 2009-01-27 01:00:32 UTC
(rev 46306)
+++ trunk/extensions/AbuseFilter/AbuseFilter.i18n.php 2009-01-27 01:31:42 UTC
(rev 46307)
@@ -232,6 +232,8 @@
'abusefilter-edit-builder-vars-all-links' => 'All external links in the
new text',
'abusefilter-edit-builder-vars-added-links' => 'All external links
added in the edit',
'abusefilter-edit-builder-vars-removed-links' => 'All external links
removed in the edit',
+ 'abusefilter-edit-builder-vars-old-text' => 'Old article text, before
the edit',
+ 'abusefilter-edit-builder-vars-new-text' => 'New article text, after
the edit',
// Filter history
'abusefilter-filter-log' => 'Recent filter changes',
Modified: trunk/extensions/AbuseFilter/SpecialAbuseLog.php
===================================================================
--- trunk/extensions/AbuseFilter/SpecialAbuseLog.php 2009-01-27 01:00:32 UTC
(rev 46306)
+++ trunk/extensions/AbuseFilter/SpecialAbuseLog.php 2009-01-27 01:31:42 UTC
(rev 46307)
@@ -105,7 +105,7 @@
// I don't want to change the names of the pre-existing messages
// describing the variables, nor do I want to rewrite them, so
I'm just
// mapping the variable names to builder messages with a
pre-existing array.
- $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');
+ $variableMessageMappings = AbuseFilter::$builderValues['vars'];
$dbr = wfGetDB( DB_SLAVE );
@@ -138,7 +138,7 @@
}
$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 );
- $output .= Xml::tags( 'tr', array( 'class' =>
"mw-abuselog-details-$key" ), $trow );
+ $output .= Xml::tags( 'tr', array( 'class' =>
"mw-abuselog-details-$key mw-abuselog-value" ), $trow );
}
$output .= Xml::closeElement( 'tbody' ) . Xml::closeElement(
'table' );
Modified: trunk/extensions/AbuseFilter/abusefilter.css
===================================================================
--- trunk/extensions/AbuseFilter/abusefilter.css 2009-01-27 01:00:32 UTC
(rev 46306)
+++ trunk/extensions/AbuseFilter/abusefilter.css 2009-01-27 01:31:42 UTC
(rev 46307)
@@ -22,4 +22,9 @@
.mw-abusefilter-history-changed {
background: #ffe0e0;
+}
+
+.mw-abuselog-var-value {
+ overflow: auto;
+ max-height: 10em;
}
\ No newline at end of file
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs