}
/**
- * Execute
+ * Show the special page
+ *
+ * @param $par Mixed: parameter passed to the page or null
*/
- function execute( $par ) {
+ public function execute( $par ) {
global $wgOut, $wgRequest;
$this->setHeaders();
$this->filter = $wgRequest->getVal( 'filter', 'all' );
$this->prefix = $wgRequest->getVal( 'prefix', '' );
- $this->table = new AllmessagesTablePager( $this,
- $conds = array(),
- wfGetLangObj( $wgRequest->getVal( 'lang', $par ) ) );
+ $this->table = new AllmessagesTablePager(
+ $this,
+ $conds = array(),
+ wfGetLangObj( $wgRequest->getVal( 'lang', $par ) )
+ );
$this->langCode = $this->table->lang->getCode();
*/
class AllmessagesTablePager extends TablePager {
- var $messages = NULL;
- var $talkPages = NULL;
+ var $messages = null;
+ var $talkPages = null;
function __construct( $page, $conds, $langObj = null ) {
parent::__construct();
$this->mIndexField = 'am_title';
$this->mPage = $page;
$this->mConds = $conds;
- $this->mDefaultDirection = true; //always sort ascending
+ $this->mDefaultDirection = true; // always sort ascending
global $wgLang, $wgContLang, $wgRequest;
$this->foreign = $this->langcode != $wgContLang->getCode();
if( $wgRequest->getVal( 'filter', 'all' ) === 'all' ){
- $this->custom = NULL; //So won't match in either case
+ $this->custom = null; // So won't match in either case
} else {
$this->custom = $wgRequest->getVal( 'filter' ) == 'unmodified' ? 1 : 0;
}
$prefix = $wgLang->ucfirst( $wgRequest->getVal( 'prefix', '' ) );
- $prefix = $prefix != '' ? Title::makeTitleSafe( NS_MEDIAWIKI, $wgRequest->getVal( 'prefix', NULL ) ) : NULL;
- if( $prefix !== NULL ){
+ $prefix = $prefix != '' ? Title::makeTitleSafe( NS_MEDIAWIKI, $wgRequest->getVal( 'prefix', null ) ) : null;
+ if( $prefix !== null ){
$this->prefix = '/^' . preg_quote( $prefix->getDBkey() ) . '/i';
} else {
$this->prefix = false;
}
$this->getSkin();
- //The suffix that may be needed for message names if we're in a
- //different language (eg [[MediaWiki:Foo/fr]]: $suffix = '/fr'
+ // The suffix that may be needed for message names if we're in a
+ // different language (eg [[MediaWiki:Foo/fr]]: $suffix = '/fr'
if( $this->foreign ) {
$this->suffix = '/' . $this->langcode;
} else {
}
function getAllMessages( $desc ){
-
wfProfileIn( __METHOD__ . '-cache' );
# Make sure all extension messages are available
$this->messages[$ukey]['customised'] = 0; //for now
- $sortedArray[$key] = NULL; // trade bytes from $sortedArray to this
+ $sortedArray[$key] = null; // trade bytes from $sortedArray to this
}
wfProfileOut( __METHOD__ . '-cache' );
function markCustomisedMessages(){
$this->talkPages = array();
- wfProfileIn( __METHOD__ . "-db" );
+ wfProfileIn( __METHOD__ . '-db' );
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'page',
array( 'page_namespace', 'page_title' ),
- array( 'page_namespace' => array(NS_MEDIAWIKI,NS_MEDIAWIKI_TALK) ),
+ array( 'page_namespace' => array( NS_MEDIAWIKI, NS_MEDIAWIKI_TALK ) ),
__METHOD__,
array( 'USE INDEX' => 'name_title' )
);
if( $s->page_namespace == NS_MEDIAWIKI ){
if( $this->foreign ){
$title = explode( '/', $s->page_title );
- if( count($title) === 2 && $this->langcode == $title[1] && array_key_exists( $title[0], $this->messages ) ){
+ if( count( $title ) === 2 && $this->langcode == $title[1] && array_key_exists( $title[0], $this->messages ) ){
$this->messages["{$title[0]}"]['customised'] = 1;
}
- } else if( array_key_exists( $s->page_title , $this->messages ) ){
+ } else if( array_key_exists( $s->page_title, $this->messages ) ){
$this->messages[$s->page_title]['customised'] = 1;
}
} else if( $s->page_namespace == NS_MEDIAWIKI_TALK ){
}
$dbr->freeResult( $res );
- wfProfileOut( __METHOD__ . "-db" );
+ wfProfileOut( __METHOD__ . '-db' );
return true;
}
/* This function normally does a database query to get the results; we need
* to make a pretend result using a FakeResultWrapper.
*/
- function reallyDoQuery( $offset , $limit , $descending ){
+ function reallyDoQuery( $offset, $limit, $descending ){
$mResult = new FakeResultWrapper( array() );
if( !$this->messages ) $this->getAllMessages( $descending );
- if( $this->talkPages === NULL ) $this->markCustomisedMessages();
+ if( $this->talkPages === null ) $this->markCustomisedMessages();
$count = 0;
foreach( $this->messages as $key => $value ){
if( $value['customised'] !== $this->custom &&
( $descending && ( $key < $offset || !$offset ) || !$descending && $key > $offset ) &&
- (( $this->prefix && preg_match( $this->prefix, $key ) ) || $this->prefix === false )
+ ( ( $this->prefix && preg_match( $this->prefix, $key ) ) || $this->prefix === false )
){
$mResult->result[] = array(
'am_title' => $key,
}
if( $count == $limit ) break;
}
- unset( $this->messages ); //no longer needed, free up some memory
+ unset( $this->messages ); // no longer needed, free up some memory
return $mResult;
}
</tr></thead><tbody>\n";
}
- function formatValue( $field , $value ){
+ function formatValue( $field, $value ){
global $wgLang;
switch( $field ){
if( $this->mCurrentRow->am_customised ){
$title = $this->mSkin->linkKnown( $title, $wgLang->lcfirst( $value ) );
} else {
- $title = $this->mSkin->link( $title,
- $wgLang->lcfirst( $value ),
- array(),
- array(),
- array( 'broken' ) );
+ $title = $this->mSkin->link(
+ $title,
+ $wgLang->lcfirst( $value ),
+ array(),
+ array(),
+ array( 'broken' )
+ );
}
if( array_key_exists( $talk->getDBkey() , $this->talkPages ) ) {
$talk = $this->mSkin->linkKnown( $talk , $this->talk );
} else {
- $talk = $this->mSkin->link( $talk,
- $this->talk,
- array(),
- array(),
- array( 'broken' ) );
+ $talk = $this->mSkin->link(
+ $talk,
+ $this->talk,
+ array(),
+ array(),
+ array( 'broken' )
+ );
}
return $title . ' (' . $talk . ')';
}
function formatRow( $row ){
- //Do all the normal stuff
+ // Do all the normal stuff
$s = parent::formatRow( $row );
- //But if there's a customised message, add that too.
+ // But if there's a customised message, add that too.
if( $row->am_customised ){
$s .= Xml::openElement( 'tr', $this->getRowAttrs( $row, true ) );
$formatted = strval( $this->formatValue( 'am_actual', $row->am_actual ) );
return $s;
}
- function getRowAttrs( $row, $isSecond=false ){
+ function getRowAttrs( $row, $isSecond = false ){
$arr = array();
global $wgLang;
if( $row->am_customised ){
- $arr['class'] = 'allmessages-customised';
+ $arr['class'] = 'allmessages-customised';
}
if( !$isSecond ){
$arr['id'] = Sanitizer::escapeId( 'msg_' . $wgLang->lcfirst( $row->am_title ) );
// This is not actually used, as getStartBody is overridden above
function getFieldNames() {
- return array( 'am_title' => wfMsg('allmessagesname'),
- 'am_default' => wfMsg('allmessagesdefault') );
+ return array(
+ 'am_title' => wfMsg( 'allmessagesname' ),
+ 'am_default' => wfMsg( 'allmessagesdefault' )
+ );
}
function getTitle() {
return SpecialPage::getTitleFor( 'Allmessages', false );
class FakeResultWrapper extends ResultWrapper {
var $result = array();
- var $db = NULL; //And it's going to stay that way :D
+ var $db = null; // And it's going to stay that way :D
var $pos = 0;
- var $currentRow = NULL;
+ var $currentRow = null;
function __construct( $array ){
$this->result = $array;
function rewind() {
$this->pos = 0;
- $this->currentRow = NULL;
+ $this->currentRow = null;
}
}
return !empty( $available['add'] )
or !empty( $available['remove'] )
or ( ( $this->isself || !$checkIfSelf ) and
- (!empty( $available['add-self'] )
- or !empty( $available['remove-self'] )));
+ ( !empty( $available['add-self'] )
+ or !empty( $available['remove-self'] ) ) );
}
/**
*
* @param $par Mixed: string if any subpage provided, else null
*/
- function execute( $par ) {
+ public function execute( $par ) {
// If the visitor doesn't have permissions to assign or remove
// any groups, it's a bit silly to give them the user search prompt.
global $wgUser, $wgRequest;
return;
}
- if (!$this->mTarget) {
+ if ( !$this->mTarget ) {
/*
* If the user specified no target, and they can only
* edit their own groups, automatically set them as the
* target.
*/
$available = $this->changeableGroups();
- if (empty($available['add']) && empty($available['remove']))
+ if ( empty( $available['add'] ) && empty( $available['remove'] ) )
$this->mTarget = $wgUser->getName();
}
- if ($this->mTarget == $wgUser->getName())
+ if ( $this->mTarget == $wgUser->getName() )
$this->isself = true;
if( !$this->userCanChangeRights( $wgUser, true ) ) {
* @param $reason String: reason for group change
* @return null
*/
- function saveUserGroups( $username, $reason = '') {
+ function saveUserGroups( $username, $reason = '' ) {
global $wgRequest, $wgUser, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
$user = $this->fetchUser( $username );
if( $user instanceof WikiErrorMsg ) {
- $wgOut->addWikiMsgArray($user->getMessageKey(), $user->getMessageArgs());
+ $wgOut->addWikiMsgArray( $user->getMessageKey(), $user->getMessageArgs() );
return;
}
// This could possibly create a highly unlikely race condition if permissions are changed between
// when the form is loaded and when the form is saved. Ignoring it for the moment.
- foreach ($allgroups as $group) {
+ foreach ( $allgroups as $group ) {
// We'll tell it to remove all unchecked groups, and add all checked groups.
// Later on, this gets filtered for what can actually be removed
- if ($wgRequest->getCheck( "wpGroup-$group" )) {
+ if ( $wgRequest->getCheck( "wpGroup-$group" ) ) {
$addgroup[] = $group;
} else {
$removegroup[] = $group;
global $wgUser;
// Validate input set...
- $isself = ($user->getName() == $wgUser->getName());
+ $isself = ( $user->getName() == $wgUser->getName() );
$groups = $user->getGroups();
$changeable = $this->changeableGroups();
$addable = array_merge( $changeable['add'], $isself ? $changeable['add-self'] : array() );
array_intersect( (array)$remove, $removable, $groups ) );
$add = array_unique( array_diff(
array_intersect( (array)$add, $addable ),
- $groups ) );
+ $groups )
+ );
$oldGroups = $user->getGroups();
$newGroups = $oldGroups;
// remove then add groups
if( $remove ) {
- $newGroups = array_diff($newGroups, $remove);
+ $newGroups = array_diff( $newGroups, $remove );
foreach( $remove as $group ) {
$user->removeGroup( $group );
}
}
if( $add ) {
- $newGroups = array_merge($newGroups, $add);
+ $newGroups = array_merge( $newGroups, $add );
foreach( $add as $group ) {
$user->addGroup( $group );
}
$user = $this->fetchUser( $username );
if( $user instanceof WikiErrorMsg ) {
- $wgOut->addWikiMsgArray($user->getMessageKey(), $user->getMessageArgs());
+ $wgOut->addWikiMsgArray( $user->getMessageKey(), $user->getMessageArgs() );
return;
}
* @return Array: Tuple of addable, then removable groups
*/
protected function splitGroups( $groups ) {
- list($addable, $removable, $addself, $removeself) = array_values( $this->changeableGroups() );
+ list( $addable, $removable, $addself, $removeself ) = array_values( $this->changeableGroups() );
$removable = array_intersect(
- array_merge( $this->isself ? $removeself : array(), $removable ),
- $groups ); // Can't remove groups the user doesn't have
- $addable = array_diff(
- array_merge( $this->isself ? $addself : array(), $addable ),
- $groups ); // Can't add groups the user does have
+ array_merge( $this->isself ? $removeself : array(), $removable ),
+ $groups
+ ); // Can't remove groups the user doesn't have
+ $addable = array_diff(
+ array_merge( $this->isself ? $addself : array(), $addable ),
+ $groups
+ ); // Can't add groups the user does have
return array( $addable, $removable );
}
* Returns an array of all groups that may be edited
* @return array Array of groups that may be edited.
*/
- protected static function getAllGroups() {
- return User::getAllGroups();
- }
+ protected static function getAllGroups() {
+ return User::getAllGroups();
+ }
/**
* Adds a table with checkboxes where you can select what groups to add/remove
( !$set && $this->canAdd( $group ) ) );
# Do we need to point out that this action is irreversible?
$irreversible = !$disabled && (
- ($set && !$this->canAdd( $group )) ||
- (!$set && !$this->canRemove( $group ) ) );
+ ( $set && !$this->canAdd( $group ) ) ||
+ ( !$set && !$this->canRemove( $group ) ) );
$checkbox = array(
'set' => $set,
// $this->changeableGroups()['remove'] doesn't work, of course. Thanks,
// PHP.
$groups = $this->changeableGroups();
- return in_array( $group, $groups['remove'] ) || ($this->isself && in_array( $group, $groups['remove-self'] ));
+ return in_array( $group, $groups['remove'] ) || ( $this->isself && in_array( $group, $groups['remove-self'] ) );
}
/**
*/
private function canAdd( $group ) {
$groups = $this->changeableGroups();
- return in_array( $group, $groups['add'] ) || ($this->isself && in_array( $group, $groups['add-self'] ));
+ return in_array( $group, $groups['add'] ) || ( $this->isself && in_array( $group, $groups['add-self'] ) );
}
/**