mediawiki-extensions-AbuseF.../Views/AbuseFilterViewTools.php
Tim Starling c8b0007232 * Break long lines. If I'm going to review this code, I need to be able to read it.
* Write array literals with one item per line. This makes diffs which add or remove items far easier to interpret, and makes merging such changes feasible. And it looks nicer too.
* Use line breaks to show the logical structure of your code. This enhances readability. Bring similar elements in a list into alignment, in order to reveal the differences between those elements at a glance.
* Removed a fun game of spot-the-difference in AbuseFilterHistoryPager::getQueryInfo(). If I want fun games I'll play UFO:AI.
* Moved some oddly placed assignments (in expressions) to their own statements: such assignments reduce readbility.
2009-02-07 09:34:11 +00:00

60 lines
1.6 KiB
PHP

<?php
if (!defined( 'MEDIAWIKI' ))
die();
class AbuseFilterViewTools extends AbuseFilterView {
function show( ) {
global $wgRequest,$wgOut;
// Header
$wgOut->setSubTitle( wfMsg( 'abusefilter-tools-subtitle' ) );
$wgOut->addWikiMsg( 'abusefilter-tools-text' );
// Expression evaluator
$eval = '';
$eval .= AbuseFilter::buildEditBox( '', 'wpTestExpr' );
$eval .= Xml::tags( 'p', null,
Xml::element( 'input',
array(
'type' => 'button',
'id' => 'mw-abusefilter-submitexpr',
'onclick' => 'doExprSubmit();',
'value' => wfMsg( 'abusefilter-tools-submitexpr' ) )
)
);
$eval .= Xml::element( 'p', array( 'id' => 'mw-abusefilter-expr-result' ), ' ' );
$eval = Xml::fieldset( wfMsg( 'abusefilter-tools-expr' ), $eval );
$wgOut->addHTML( $eval );
// Associated script
$exprScript = file_get_contents( dirname( __FILE__ ) . '/tools.js' );
$wgOut->addInlineScript( $exprScript );
global $wgUser;
if ($wgUser->isAllowed( 'abusefilter-modify' )) {
// Hacky little box to re-enable autoconfirmed if it got disabled
$rac = '';
$rac .= Xml::inputLabel(
wfMsg( 'abusefilter-tools-reautoconfirm-user' ),
'wpReAutoconfirmUser',
'reautoconfirm-user',
45 );
$rac .= '&nbsp;';
$rac .= Xml::element(
'input',
array(
'type' => 'button',
'id' => 'mw-abusefilter-reautoconfirmsubmit',
'onclick' => 'doReautoSubmit();',
'value' => wfMsg( 'abusefilter-tools-reautoconfirm-submit' )
)
);
$rac = Xml::fieldset( wfMsg( 'abusefilter-tools-reautoconfirm' ), $rac );
$wgOut->addHTML( $rac );
}
}
}