r45783 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45782‎ | r45783 | r45784 >
Date:19:04, 15 January 2009
Author:werdna
Status:ok
Tags:
Comment:
Fix up AbuseFilter syntax checking:
* Display result below the field, rather than at the top of the page.
* Clear the result when the field is changed, not after some arbitrary time period.
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.i18n.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.php (modified) (history)
  • /trunk/extensions/AbuseFilter/SpecialAbuseFilter.php (modified) (history)
  • /trunk/extensions/AbuseFilter/edit.js (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.php
@@ -70,4 +70,7 @@
7171
7272 $wgAjaxExportList[] = 'AbuseFilter::ajaxCheckSyntax';
7373 $wgAjaxExportList[] = 'AbuseFilter::ajaxEvaluateExpression';
74 -$wgAjaxExportList[] = 'AbuseFilter::ajaxReAutoconfirm';
\ No newline at end of file
 74+$wgAjaxExportList[] = 'AbuseFilter::ajaxReAutoconfirm';
 75+
 76+## Style version
 77+$wgAbuseFilterStyleVersion = 1;
\ No newline at end of file
Index: trunk/extensions/AbuseFilter/SpecialAbuseFilter.php
@@ -14,8 +14,10 @@
1515 }
1616
1717 function execute( $subpage ) {
18 - global $wgUser,$wgOut,$wgRequest;
 18+ global $wgUser,$wgOut,$wgRequest, $wgAbuseFilterStyleVersion, $wgScriptPath;
1919
 20+ $wgOut->addExtensionStyle( "{$wgScriptPath}/extensions/AbuseFilter/abusefilter.css?{$wgAbuseFilterStyleVersion}" );
 21+
2022 $this->setHeaders();
2123
2224 $this->loadParameters( $subpage );
@@ -463,12 +465,11 @@
464466
465467 // Add syntax checking
466468 $rules .= Xml::element( 'input', array( 'type' => 'button', 'onclick' => 'doSyntaxCheck()', 'value' => wfMsg( 'abusefilter-edit-check' ), 'id' => 'mw-abusefilter-syntaxcheck' ) );
 469+ $rules .= Xml::element( 'div', array( 'id' => 'mw-abusefilter-syntaxresult', 'style' => 'display: none;' ), ' ' );
467470
468471 // Add script
469 - $scScript = file_get_contents(dirname(__FILE__)."/edit.js");
 472+ $wgOut->addInlineScript( file_get_contents(dirname(__FILE__)."/edit.js") );
470473
471 - $wgOut->addInlineScript( $scScript );
472 -
473474 return $rules;
474475 }
475476
Index: trunk/extensions/AbuseFilter/edit.js
@@ -8,13 +8,16 @@
99 var response = request.responseText;
1010
1111 removeSpinner( 'abusefilter-syntaxcheck' );
 12+
 13+ var el = document.getElementById( 'mw-abusefilter-syntaxresult' );
 14+ el.style.display = 'block';
1215
1316 if (response.match( /OK/ )) {
1417 // Successful
15 - jsMsg( 'No syntax errors.', 'mw-abusefilter-syntaxresult' );
 18+ changeText( el, 'No syntax errors.' );
1619 } else {
1720 var error = response.substr(4);
18 - jsMsg( 'Syntax error: '+error, 'mw-abusefilter-syntaxresult' );
 21+ changeText( el, 'Syntax error: '+error );
1922 }
2023 }
2124 function addText() {
@@ -22,7 +25,7 @@
2326 return;
2427 }
2528
26 - insertAtCursor(document.getElementById('wpFilterRules'), document.getElementById('wpFilterBuilder').value);
 29+ insertAtCursor(document.getElementById('wpFilterRules'), document.getElementById('wpFilterBuilder').value + " ");
2730 document.getElementById('wpFilterBuilder').selectedIndex = 0;
2831 }
2932
@@ -44,4 +47,10 @@
4548 } else {
4649 myField.value += myValue;
4750 }
48 -}
\ No newline at end of file
 51+}
 52+
 53+addOnloadHook( function() {
 54+ addHandler( document.getElementById( 'wpFilterRules' ), 'keyup', function() {
 55+ document.getElementById( 'mw-abusefilter-syntaxresult' ).style.display = 'none';
 56+ } );
 57+} );
\ No newline at end of file
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php
@@ -224,8 +224,6 @@
225225 'abusefilter-edit-builder-vars-user-name' => 'Name of user account',
226226 'abusefilter-edit-builder-vars-user-groups' => 'Groups (including implicit) user is in',
227227 'abusefilter-edit-builder-vars-user-emailconfirm' => 'Time email address was confirmed',
228 -
229 -
230228
231229 // Filter history
232230 'abusefilter-history' => 'History for filter $1',

Status & tagging log