mediawiki-extensions-AbuseF.../Views/AbuseFilterView.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

50 lines
1.1 KiB
PHP

<?php
if (!defined( 'MEDIAWIKI' ))
die();
abstract class AbuseFilterView {
function __construct( $page, $params ) {
$this->mPage = $page;
$this->mParams = $params;
}
function getTitle( $subpage='' ) {
return $this->mPage->getTitle( $subpage );
}
abstract function show();
function canEdit() {
global $wgUser;
static $canEdit = 'unset';
if ($canEdit == 'unset') {
$canEdit = $wgUser->isAllowed( 'abusefilter-modify' );
}
return $canEdit;
}
}
class AbuseFilterChangesList extends OldChangesList {
protected function insertExtra( &$s, &$rc, &$classes ) {
$sk = $this->skin;
$examineParams = empty($rc->examineParams) ? array() : $rc->examineParams;
$title = SpecialPage::getTitleFor( 'AbuseFilter', "examine/".$rc->mAttribs['rc_id'] );
$examineLink = $sk->link( $title, wfMsgExt( 'abusefilter-changeslist-examine', 'parseinline' ), array(), $examineParams );
$s .= " ($examineLink)";
## If we have a match..
if ( isset( $rc->filterResult ) ) {
$class = $rc->filterResult ?
'mw-abusefilter-changeslist-match' :
'mw-abusefilter-changeslist-nomatch';
$classes[] = $class;
}
}
}