Added spaces before if, foreach
Added some braces for one line statements
Change-Id: Ibb8dd102db045522d12ff939075ba7420d95ab6b
75 files changed:
wfDebug( __METHOD__ . ": showing CSS/JS source\n" );
$this->showCssOrJsPage();
$outputDone = true;
wfDebug( __METHOD__ . ": showing CSS/JS source\n" );
$this->showCssOrJsPage();
$outputDone = true;
- } elseif( !wfRunHooks( 'ArticleContentViewCustom',
+ } elseif ( !wfRunHooks( 'ArticleContentViewCustom',
array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) {
# Allow extensions do their own custom view for certain pages
$outputDone = true;
array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) {
# Allow extensions do their own custom view for certain pages
$outputDone = true;
- } elseif( !ContentHandler::runLegacyHooks( 'ArticleViewCustom',
+ } elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom',
array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) {
# Allow extensions do their own custom view for certain pages
array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) {
# Allow extensions do their own custom view for certain pages
}
if ( Block::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block ) {
return array(
}
if ( Block::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block ) {
return array(
'follow' => 'nofollow'
);
}
'follow' => 'nofollow'
);
}
if ( $this->mPage->getID() === 0 || $this->getOldID() ) {
# Non-articles (special pages etc), and old revisions
return array(
if ( $this->mPage->getID() === 0 || $this->getOldID() ) {
# Non-articles (special pages etc), and old revisions
return array(
'follow' => 'nofollow'
);
} elseif ( $this->getContext()->getOutput()->isPrintable() ) {
# Discourage indexing of printable versions, but encourage following
return array(
'follow' => 'nofollow'
);
} elseif ( $this->getContext()->getOutput()->isPrintable() ) {
# Discourage indexing of printable versions, but encourage following
return array(
'follow' => 'follow'
);
} elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
# For ?curid=x urls, disallow indexing
return array(
'follow' => 'follow'
);
} elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
# For ?curid=x urls, disallow indexing
return array(
'follow' => 'follow'
);
}
'follow' => 'follow'
);
}
'LSLockManager' => 'includes/filebackend/lockmanager/LSLockManager.php',
'MemcLockManager' => 'includes/filebackend/lockmanager/MemcLockManager.php',
'QuorumLockManager' => 'includes/filebackend/lockmanager/QuorumLockManager.php',
'LSLockManager' => 'includes/filebackend/lockmanager/LSLockManager.php',
'MemcLockManager' => 'includes/filebackend/lockmanager/MemcLockManager.php',
'QuorumLockManager' => 'includes/filebackend/lockmanager/QuorumLockManager.php',
- 'MySqlLockManager'=> 'includes/filebackend/lockmanager/DBLockManager.php',
- 'PostgreSqlLockManager'=> 'includes/filebackend/lockmanager/DBLockManager.php',
- 'RedisLockManager'=> 'includes/filebackend/lockmanager/RedisLockManager.php',
+ 'MySqlLockManager' => 'includes/filebackend/lockmanager/DBLockManager.php',
+ 'PostgreSqlLockManager' => 'includes/filebackend/lockmanager/DBLockManager.php',
+ 'RedisLockManager' => 'includes/filebackend/lockmanager/RedisLockManager.php',
'NullLockManager' => 'includes/filebackend/lockmanager/LockManager.php',
'FileOp' => 'includes/filebackend/FileOp.php',
'FileOpBatch' => 'includes/filebackend/FileOpBatch.php',
'NullLockManager' => 'includes/filebackend/lockmanager/LockManager.php',
'FileOp' => 'includes/filebackend/FileOp.php',
'FileOpBatch' => 'includes/filebackend/FileOpBatch.php',
$timestamp = 0, $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0,
$hideName = 0, $blockEmail = 0, $allowUsertalk = 0, $byText = '' )
{
$timestamp = 0, $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0,
$hideName = 0, $blockEmail = 0, $allowUsertalk = 0, $byText = '' )
{
- if( $timestamp === 0 ) {
+ if ( $timestamp === 0 ) {
$timestamp = wfTimestampNow();
}
$timestamp = wfTimestampNow();
}
- if( count( func_get_args() ) > 0 ) {
+ if ( count( func_get_args() ) > 0 ) {
# Soon... :D
# wfDeprecated( __METHOD__ . " with arguments" );
}
# Soon... :D
# wfDeprecated( __METHOD__ . " with arguments" );
}
*/
public function load( $address = '', $user = 0 ) {
wfDeprecated( __METHOD__, '1.18' );
*/
public function load( $address = '', $user = 0 ) {
wfDeprecated( __METHOD__, '1.18' );
$username = User::whoIs( $user );
$block = self::newFromTarget( $username, $address );
} else {
$block = self::newFromTarget( null, $address );
}
$username = User::whoIs( $user );
$block = self::newFromTarget( $username, $address );
} else {
$block = self::newFromTarget( null, $address );
}
- if( $block instanceof Block ) {
+ if ( $block instanceof Block ) {
# This is mildly evil, but hey, it's B/C :D
# This is mildly evil, but hey, it's B/C :D
- foreach( $block as $variable => $value ) {
+ foreach ( $block as $variable => $value ) {
$this->$variable = $value;
}
return true;
$this->$variable = $value;
}
return true;
protected function newLoad( $vagueTarget = null ) {
$db = wfGetDB( $this->mFromMaster ? DB_MASTER : DB_SLAVE );
protected function newLoad( $vagueTarget = null ) {
$db = wfGetDB( $this->mFromMaster ? DB_MASTER : DB_SLAVE );
- if( $this->type !== null ) {
+ if ( $this->type !== null ) {
$conds = array(
'ipb_address' => array( (string)$this->target ),
);
$conds = array(
'ipb_address' => array( (string)$this->target ),
);
# Be aware that the != '' check is explicit, since empty values will be
# passed by some callers (bug 29116)
# Be aware that the != '' check is explicit, since empty values will be
# passed by some callers (bug 29116)
- if( $vagueTarget != '' ) {
+ if ( $vagueTarget != '' ) {
list( $target, $type ) = self::parseTarget( $vagueTarget );
switch( $type ) {
case self::TYPE_USER:
list( $target, $type ) = self::parseTarget( $vagueTarget );
switch( $type ) {
case self::TYPE_USER:
# This is begging for $this = $bestBlock, but that's not allowed in PHP :(
$bestBlockPreventsEdit = null;
# This is begging for $this = $bestBlock, but that's not allowed in PHP :(
$bestBlockPreventsEdit = null;
- foreach( $res as $row ) {
+ foreach ( $res as $row ) {
$block = self::newFromRow( $row );
# Don't use expired blocks
$block = self::newFromRow( $row );
# Don't use expired blocks
- if( $block->deleteIfExpired() ) {
+ if ( $block->deleteIfExpired() ) {
continue;
}
# Don't use anon only blocks on users
continue;
}
# Don't use anon only blocks on users
- if( $this->type == self::TYPE_USER && !$block->isHardblock() ) {
+ if ( $this->type == self::TYPE_USER && !$block->isHardblock() ) {
- if( $block->getType() == self::TYPE_RANGE ) {
+ if ( $block->getType() == self::TYPE_RANGE ) {
# This is the number of bits that are allowed to vary in the block, give
# or take some floating point errors
$end = wfBaseconvert( $block->getRangeEnd(), 16, 10 );
# This is the number of bits that are allowed to vary in the block, give
# or take some floating point errors
$end = wfBaseconvert( $block->getRangeEnd(), 16, 10 );
$score = $block->getType();
}
$score = $block->getType();
}
- if( $score < $bestBlockScore ) {
+ if ( $score < $bestBlockScore ) {
$bestBlockScore = $score;
$bestRow = $row;
$bestBlockPreventsEdit = $block->prevents( 'edit' );
}
}
$bestBlockScore = $score;
$bestRow = $row;
$bestBlockPreventsEdit = $block->prevents( 'edit' );
}
}
- if( $bestRow !== null ) {
+ if ( $bestRow !== null ) {
$this->initFromRow( $bestRow );
$this->prevents( 'edit', $bestBlockPreventsEdit );
return true;
$this->initFromRow( $bestRow );
$this->prevents( 'edit', $bestBlockPreventsEdit );
return true;
global $wgPutIPinRC;
// No IPs are in recentchanges table, so nothing to select
global $wgPutIPinRC;
// No IPs are in recentchanges table, so nothing to select
foreach ( $res as $row ) {
if ( $row->rc_ip ) {
$id = $block->doAutoblock( $row->rc_ip );
foreach ( $res as $row ) {
if ( $row->rc_ip ) {
$id = $block->doAutoblock( $row->rc_ip );
- if ( $id ) $blockIds[] = $id;
+ if ( $id ) {
+ $blockIds[] = $id;
+ }
public static function newFromTarget( $specificTarget, $vagueTarget = null, $fromMaster = false ) {
list( $target, $type ) = self::parseTarget( $specificTarget );
public static function newFromTarget( $specificTarget, $vagueTarget = null, $fromMaster = false ) {
list( $target, $type ) = self::parseTarget( $specificTarget );
- if( $type == Block::TYPE_ID || $type == Block::TYPE_AUTO ) {
+ if ( $type == Block::TYPE_ID || $type == Block::TYPE_AUTO ) {
return Block::newFromID( $target );
return Block::newFromID( $target );
- } elseif( $target === null && $vagueTarget == '' ) {
+ } elseif ( $target === null && $vagueTarget == '' ) {
# We're not going to find anything useful here
# Be aware that the == '' check is explicit, since empty values will be
# passed by some callers (bug 29116)
return null;
# We're not going to find anything useful here
# Be aware that the == '' check is explicit, since empty values will be
# passed by some callers (bug 29116)
return null;
- } elseif( in_array( $type, array( Block::TYPE_USER, Block::TYPE_IP, Block::TYPE_RANGE, null ) ) ) {
+ } elseif ( in_array( $type, array( Block::TYPE_USER, Block::TYPE_IP, Block::TYPE_RANGE, null ) ) ) {
$block = new Block();
$block->fromMaster( $fromMaster );
$block = new Block();
$block->fromMaster( $fromMaster );
+ if ( $type !== null ) {
$block->setTarget( $target );
}
$block->setTarget( $target );
}
- if( $block->newLoad( $vagueTarget ) ) {
+ if ( $block->newLoad( $vagueTarget ) ) {
*/
public static function parseTarget( $target ) {
# We may have been through this before
*/
public static function parseTarget( $target ) {
# We may have been through this before
- if( $target instanceof User ) {
- if( IP::isValid( $target->getName() ) ) {
+ if ( $target instanceof User ) {
+ if ( IP::isValid( $target->getName() ) ) {
return array( $target, self::TYPE_IP );
} else {
return array( $target, self::TYPE_USER );
}
return array( $target, self::TYPE_IP );
} else {
return array( $target, self::TYPE_USER );
}
- } elseif( $target === null ) {
+ } elseif ( $target === null ) {
return array( null, null );
}
return array( null, null );
}
# Consider the possibility that this is not a username at all
# but actually an old subpage (bug #29797)
# Consider the possibility that this is not a username at all
# but actually an old subpage (bug #29797)
- if( strpos( $target, '/' ) !== false ) {
+ if ( strpos( $target, '/' ) !== false ) {
# An old subpage, drill down to the user behind it
$parts = explode( '/', $target );
$target = $parts[0];
# An old subpage, drill down to the user behind it
$parts = explode( '/', $target );
$target = $parts[0];
- if( isset( $this->handle ) ) {
+ if ( isset( $this->handle ) ) {
dba_close( $this->handle );
}
unset( $this->handle );
dba_close( $this->handle );
}
unset( $this->handle );
- if( isset( $this->handle ) ) {
+ if ( isset( $this->handle ) ) {
dba_close( $this->handle );
}
if ( wfIsWindows() ) {
dba_close( $this->handle );
}
if ( wfIsWindows() ) {
- if( isset( $this->handle ) ) {
+ if ( isset( $this->handle ) ) {
fclose( $this->handle );
}
unset( $this->handle );
fclose( $this->handle );
}
unset( $this->handle );
*/
public function close() {
$this->finish();
*/
public function close() {
$this->finish();
- if( isset( $this->handle ) ) {
+ if ( isset( $this->handle ) ) {
fclose( $this->handle );
}
if ( wfIsWindows() && file_exists( $this->realFileName ) ) {
fclose( $this->handle );
}
if ( wfIsWindows() && file_exists( $this->realFileName ) ) {
$hp = $packedTables[$starts[$i] + $u];
$where = CdbFunctions::unsignedMod(
CdbFunctions::unsignedShiftRight( $hp['h'], 8 ), $len );
$hp = $packedTables[$starts[$i] + $u];
$where = CdbFunctions::unsignedMod(
CdbFunctions::unsignedShiftRight( $hp['h'], 8 ), $len );
- while ( $hashtable[$where]['p'] )
- if ( ++$where == $len )
+ while ( $hashtable[$where]['p'] ) {
+ if ( ++$where == $len ) {
$hashtable[$where] = $hp;
}
$hashtable[$where] = $hp;
}
static function formatSummaryRow( $tags, $page ) {
global $wgLang;
static function formatSummaryRow( $tags, $page ) {
global $wgLang;
return array( '', array() );
return array( '', array() );
$classes = array();
$tags = explode( ',', $tags );
$displayTags = array();
$classes = array();
$tags = explode( ',', $tags );
$displayTags = array();
- foreach( $tags as $tag ) {
+ foreach ( $tags as $tag ) {
$displayTags[] = Xml::tags(
'span',
array( 'class' => 'mw-tag-marker ' .
$displayTags[] = Xml::tags(
'span',
array( 'class' => 'mw-tag-marker ' .
$tags = array_filter( $tags ); // Make sure we're submitting all tags...
$tags = array_filter( $tags ); // Make sure we're submitting all tags...
- if( !$rc_id && !$rev_id && !$log_id ) {
+ if ( !$rc_id && !$rev_id && !$log_id ) {
throw new MWException( "At least one of: RCID, revision ID, and log ID MUST be specified when adding a tag to a change!" );
}
$dbr = wfGetDB( DB_SLAVE );
// Might as well look for rcids and so on.
throw new MWException( "At least one of: RCID, revision ID, and log ID MUST be specified when adding a tag to a change!" );
}
$dbr = wfGetDB( DB_SLAVE );
// Might as well look for rcids and so on.
$dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave.
$dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave.
$rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_logid' => $log_id ), __METHOD__ );
$rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_logid' => $log_id ), __METHOD__ );
$rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_this_oldid' => $rev_id ), __METHOD__ );
}
$rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_this_oldid' => $rev_id ), __METHOD__ );
}
- } elseif( !$log_id && !$rev_id ) {
+ } elseif ( !$log_id && !$rev_id ) {
$dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave.
$log_id = $dbr->selectField( 'recentchanges', 'rc_logid', array( 'rc_id' => $rc_id ), __METHOD__ );
$rev_id = $dbr->selectField( 'recentchanges', 'rc_this_oldid', array( 'rc_id' => $rc_id ), __METHOD__ );
$dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave.
$log_id = $dbr->selectField( 'recentchanges', 'rc_logid', array( 'rc_id' => $rc_id ), __METHOD__ );
$rev_id = $dbr->selectField( 'recentchanges', 'rc_this_oldid', array( 'rc_id' => $rc_id ), __METHOD__ );
// Insert the tags rows.
$tagsRows = array();
// Insert the tags rows.
$tagsRows = array();
- foreach( $tags as $tag ) { // Filter so we don't insert NULLs as zero accidentally.
+ foreach ( $tags as $tag ) { // Filter so we don't insert NULLs as zero accidentally.
$tagsRows[] = array_filter(
array(
'ct_tag' => $tag,
$tagsRows[] = array_filter(
array(
'ct_tag' => $tag,
&$join_conds, &$options, $filter_tag = false ) {
global $wgRequest, $wgUseTagFilter;
&$join_conds, &$options, $filter_tag = false ) {
global $wgRequest, $wgUseTagFilter;
- if( $filter_tag === false ) {
+ if ( $filter_tag === false ) {
$filter_tag = $wgRequest->getVal( 'tagfilter' );
}
// Figure out which conditions can be done.
if ( in_array( 'recentchanges', $tables ) ) {
$join_cond = 'rc_id';
$filter_tag = $wgRequest->getVal( 'tagfilter' );
}
// Figure out which conditions can be done.
if ( in_array( 'recentchanges', $tables ) ) {
$join_cond = 'rc_id';
- } elseif( in_array( 'logging', $tables ) ) {
+ } elseif ( in_array( 'logging', $tables ) ) {
$join_cond = 'log_id';
} elseif ( in_array( 'revision', $tables ) ) {
$join_cond = 'rev_id';
$join_cond = 'log_id';
} elseif ( in_array( 'revision', $tables ) ) {
$join_cond = 'rev_id';
$join_conds['tag_summary'] = array( 'LEFT JOIN', "ts_$join_cond=$join_cond" );
$fields[] = 'ts_tags';
$join_conds['tag_summary'] = array( 'LEFT JOIN', "ts_$join_cond=$join_cond" );
$fields[] = 'ts_tags';
- if( $wgUseTagFilter && $filter_tag ) {
+ if ( $wgUseTagFilter && $filter_tag ) {
// Somebody wants to filter on a tag.
// Add an INNER JOIN on change_tag
// Somebody wants to filter on a tag.
// Add an INNER JOIN on change_tag
- if( !array_key_exists( $this->format, $wgFeedClasses ) ) {
+ if ( !array_key_exists( $this->format, $wgFeedClasses ) ) {
// falling back to atom
$this->format = 'atom';
}
// falling back to atom
$this->format = 'atom';
}
* gets it quick too.
*/
$cachedFeed = $this->loadFromCache( $lastmod, $timekey, $key );
* gets it quick too.
*/
$cachedFeed = $this->loadFromCache( $lastmod, $timekey, $key );
- if( is_string( $cachedFeed ) ) {
+ if ( is_string( $cachedFeed ) ) {
wfDebug( "RC: Outputting cached feed\n" );
$feed->httpHeaders();
echo $cachedFeed;
wfDebug( "RC: Outputting cached feed\n" );
$feed->httpHeaders();
echo $cachedFeed;
$feedLastmod = $messageMemc->get( $timekey );
$feedLastmod = $messageMemc->get( $timekey );
- if( ( $wgFeedCacheTimeout > 0 ) && $feedLastmod ) {
+ if ( ( $wgFeedCacheTimeout > 0 ) && $feedLastmod ) {
/**
* If the cached feed was rendered very recently, we may
* go ahead and use it even if there have been edits made
/**
* If the cached feed was rendered very recently, we may
* go ahead and use it even if there have been edits made
$feedLastmodUnix = wfTimestamp( TS_UNIX, $feedLastmod );
$lastmodUnix = wfTimestamp( TS_UNIX, $lastmod );
$feedLastmodUnix = wfTimestamp( TS_UNIX, $feedLastmod );
$lastmodUnix = wfTimestamp( TS_UNIX, $lastmod );
- if( $feedAge < $wgFeedCacheTimeout || $feedLastmodUnix > $lastmodUnix ) {
+ if ( $feedAge < $wgFeedCacheTimeout || $feedLastmodUnix > $lastmodUnix ) {
wfDebug( "RC: loading feed from cache ($key; $feedLastmod; $lastmod)...\n" );
if ( $feedLastmodUnix < $lastmodUnix ) {
$wgOut->setLastModified( $feedLastmod ); // bug 21916
wfDebug( "RC: loading feed from cache ($key; $feedLastmod; $lastmod)...\n" );
if ( $feedLastmodUnix < $lastmodUnix ) {
$wgOut->setLastModified( $feedLastmod ); // bug 21916
# Merge adjacent edits by one user
$sorted = array();
$n = 0;
# Merge adjacent edits by one user
$sorted = array();
$n = 0;
- foreach( $rows as $obj ) {
- if( $n > 0 &&
+ foreach ( $rows as $obj ) {
+ if ( $n > 0 &&
$obj->rc_type == RC_EDIT &&
$obj->rc_namespace >= 0 &&
$obj->rc_cur_id == $sorted[$n - 1]->rc_cur_id &&
$obj->rc_type == RC_EDIT &&
$obj->rc_namespace >= 0 &&
$obj->rc_cur_id == $sorted[$n - 1]->rc_cur_id &&
- foreach( $sorted as $obj ) {
+ foreach ( $sorted as $obj ) {
$title = Title::makeTitle( $obj->rc_namespace, $obj->rc_title );
$talkpage = MWNamespace::canTalk( $obj->rc_namespace ) ? $title->getTalkPage()->getFullURL() : '';
// Skip items with deleted content (avoids partially complete/inconsistent output)
$title = Title::makeTitle( $obj->rc_namespace, $obj->rc_title );
$talkpage = MWNamespace::canTalk( $obj->rc_namespace ) ? $title->getTalkPage()->getFullURL() : '';
// Skip items with deleted content (avoids partially complete/inconsistent output)
- if( $obj->rc_deleted ) continue;
+ if ( $obj->rc_deleted ) {
+ continue;
+ }
if ( $obj->rc_this_oldid ) {
$url = $title->getFullURL(
if ( $obj->rc_this_oldid ) {
$url = $title->getFullURL(
$user = $context->getUser();
$sk = $context->getSkin();
$list = null;
$user = $context->getUser();
$sk = $context->getSkin();
$list = null;
- if( wfRunHooks( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) {
+ if ( wfRunHooks( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) {
$new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
return $new ? new EnhancedChangesList( $context ) : new OldChangesList( $context );
} else {
$new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
return $new ? new EnhancedChangesList( $context ) : new OldChangesList( $context );
} else {
* they are called often, we call them once and save them in $this->message
*/
private function preCacheMessages() {
* they are called often, we call them once and save them in $this->message
*/
private function preCacheMessages() {
- if( !isset( $this->message ) ) {
+ if ( !isset( $this->message ) ) {
foreach ( explode( ' ', 'cur diff hist last blocklink history ' .
'semicolon-separator pipe-separator' ) as $msg ) {
$this->message[$msg] = $this->msg( $msg )->escaped();
foreach ( explode( ' ', 'cur diff hist last blocklink history ' .
'semicolon-separator pipe-separator' ) as $msg ) {
$this->message[$msg] = $this->msg( $msg )->escaped();
*/
protected function recentChangesFlags( $flags, $nothing = ' ' ) {
$f = '';
*/
protected function recentChangesFlags( $flags, $nothing = ' ' ) {
$f = '';
- foreach( array( 'newpage', 'minor', 'bot', 'unpatrolled' ) as $flag ) {
+ foreach ( array( 'newpage', 'minor', 'bot', 'unpatrolled' ) as $flag ) {
$f .= isset( $flags[$flag] ) && $flags[$flag]
? self::flag( $flag )
: $nothing;
$f .= isset( $flags[$flag] ) && $flags[$flag]
? self::flag( $flag )
: $nothing;
'botedit' => array( 'boteditletter', 'recentchanges-label-bot' ),
'unpatrolled' => array( 'unpatrolledletter', 'recentchanges-label-unpatrolled' ),
);
'botedit' => array( 'boteditletter', 'recentchanges-label-bot' ),
'unpatrolled' => array( 'unpatrolledletter', 'recentchanges-label-unpatrolled' ),
);
- foreach( $messages as &$value ) {
+ foreach ( $messages as &$value ) {
$value[0] = wfMessage( $value[0] )->escaped();
$value[1] = wfMessage( $value[1] )->escaped();
}
$value[0] = wfMessage( $value[0] )->escaped();
$value[1] = wfMessage( $value[1] )->escaped();
}
$formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text();
}
$formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text();
}
- if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
+ if ( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
$tag = 'strong';
} else {
$tag = 'span';
$tag = 'strong';
} else {
$tag = 'span';
$newlen = $old->mAttribs['rc_new_len'];
}
$newlen = $old->mAttribs['rc_new_len'];
}
- if( $oldlen === null || $newlen === null ) {
+ if ( $oldlen === null || $newlen === null ) {
* @return String
*/
public function endRecentChangesList() {
* @return String
*/
public function endRecentChangesList() {
- if( $this->rclistOpen ) {
+ if ( $this->rclistOpen ) {
return "</ul>\n";
} else {
return '';
return "</ul>\n";
} else {
return '';
public function insertDateHeader( &$s, $rc_timestamp ) {
# Make date header if necessary
$date = $this->getLanguage()->userDate( $rc_timestamp, $this->getUser() );
public function insertDateHeader( &$s, $rc_timestamp ) {
# Make date header if necessary
$date = $this->getLanguage()->userDate( $rc_timestamp, $this->getUser() );
- if( $date != $this->lastdate ) {
- if( $this->lastdate != '' ) {
+ if ( $date != $this->lastdate ) {
+ if ( $this->lastdate != '' ) {
$s .= "</ul>\n";
}
$s .= Xml::element( 'h4', null, $date ) . "\n<ul class=\"special\">";
$s .= "</ul>\n";
}
$s .= Xml::element( 'h4', null, $date ) . "\n<ul class=\"special\">";
*/
public function insertDiffHist( &$s, &$rc, $unpatrolled ) {
# Diff link
*/
public function insertDiffHist( &$s, &$rc, $unpatrolled ) {
# Diff link
- if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
+ if ( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
$diffLink = $this->message['diff'];
} elseif ( !self::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
$diffLink = $this->message['diff'];
$diffLink = $this->message['diff'];
} elseif ( !self::userCan( $rc, Revision::DELETED_TEXT, $this->getUser() ) ) {
$diffLink = $this->message['diff'];
'oldid' => $rc->mAttribs['rc_last_oldid']
);
'oldid' => $rc->mAttribs['rc_last_oldid']
);
$query['rcid'] = $rc->mAttribs['rc_id'];
};
$query['rcid'] = $rc->mAttribs['rc_id'];
};
array( 'class' => 'mw-changeslist-title' ),
$params
);
array( 'class' => 'mw-changeslist-title' ),
$params
);
- if( $this->isDeleted( $rc, Revision::DELETED_TEXT ) ) {
+ if ( $this->isDeleted( $rc, Revision::DELETED_TEXT ) ) {
$articlelink = '<span class="history-deleted">' . $articlelink . '</span>';
}
# To allow for boldening pages watched by this user
$articlelink = '<span class="history-deleted">' . $articlelink . '</span>';
}
# To allow for boldening pages watched by this user
* @param &$rc RecentChange
*/
public function insertUserRelatedLinks( &$s, &$rc ) {
* @param &$rc RecentChange
*/
public function insertUserRelatedLinks( &$s, &$rc ) {
- if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
+ if ( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
$s .= ' <span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
} else {
$s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'],
$s .= ' <span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
} else {
$s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'],
* @return string
*/
public function insertComment( $rc ) {
* @return string
*/
public function insertComment( $rc ) {
- if( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) {
- if( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) {
+ if ( $rc->mAttribs['rc_type'] != RC_MOVE && $rc->mAttribs['rc_type'] != RC_MOVE_OVER_REDIRECT ) {
+ if ( $this->isDeleted( $rc, Revision::DELETED_COMMENT ) ) {
return ' <span class="history-deleted">' . $this->msg( 'rev-deleted-comment' )->escaped() . '</span>';
} else {
return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
return ' <span class="history-deleted">' . $this->msg( 'rev-deleted-comment' )->escaped() . '</span>';
} else {
return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
*/
protected function numberofWatchingusers( $count ) {
static $cache = array();
*/
protected function numberofWatchingusers( $count ) {
static $cache = array();
- if( $count > 0 ) {
- if( !isset( $cache[$count] ) ) {
+ if ( $count > 0 ) {
+ if ( !isset( $cache[$count] ) ) {
$cache[$count] = $this->msg( 'number_of_watching_users_RCview' )->numParams( $count )->escaped();
}
return $cache[$count];
$cache[$count] = $this->msg( 'number_of_watching_users_RCview' )->numParams( $count )->escaped();
}
return $cache[$count];
* @return Boolean
*/
public static function userCan( $rc, $field, User $user = null ) {
* @return Boolean
*/
public static function userCan( $rc, $field, User $user = null ) {
- if( $rc->mAttribs['rc_type'] == RC_LOG ) {
+ if ( $rc->mAttribs['rc_type'] == RC_LOG ) {
return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
} else {
return Revision::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
return LogEventsList::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
} else {
return Revision::userCanBitfield( $rc->mAttribs['rc_deleted'], $field, $user );
* @return string
*/
protected function maybeWatchedLink( $link, $watched = false ) {
* @return string
*/
protected function maybeWatchedLink( $link, $watched = false ) {
return '<strong class="mw-watched">' . $link . '</strong>';
} else {
return '<span class="mw-rc-unwatched">' . $link . '</span>';
return '<strong class="mw-watched">' . $link . '</strong>';
} else {
return '<span class="mw-rc-unwatched">' . $link . '</span>';
* @param $rc RecentChange
*/
public function insertRollback( &$s, &$rc ) {
* @param $rc RecentChange
*/
public function insertRollback( &$s, &$rc ) {
- if( $rc->mAttribs['rc_type'] != RC_NEW && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) {
+ if ( $rc->mAttribs['rc_type'] != RC_NEW && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] ) {
$page = $rc->getTitle();
/** Check for rollback and edit permissions, disallow special pages, and only
* show a link on the top-most revision */
$page = $rc->getTitle();
/** Check for rollback and edit permissions, disallow special pages, and only
* show a link on the top-most revision */
* @param $classes
*/
public function insertTags( &$s, &$rc, &$classes ) {
* @param $classes
*/
public function insertTags( &$s, &$rc, &$classes ) {
- if ( empty( $rc->mAttribs['ts_tags'] ) )
+ if ( empty( $rc->mAttribs['ts_tags'] ) ) {
list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow( $rc->mAttribs['ts_tags'], 'changeslist' );
$classes = array_merge( $classes, $newClasses );
list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow( $rc->mAttribs['ts_tags'], 'changeslist' );
$classes = array_merge( $classes, $newClasses );
$s = '';
$classes = array();
// use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
$s = '';
$classes = array();
// use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
- if( $linenumber ) {
- if( $linenumber & 1 ) {
+ if ( $linenumber ) {
+ if ( $linenumber & 1 ) {
$classes[] = 'mw-line-odd';
$classes[] = 'mw-line-odd';
$classes[] = 'mw-line-even';
}
}
$classes[] = 'mw-line-even';
}
}
$classes[] = $watched ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
// Moved pages (very very old, not supported anymore)
$classes[] = $watched ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched';
// Moved pages (very very old, not supported anymore)
- if( $rc->mAttribs['rc_type'] == RC_MOVE || $rc->mAttribs['rc_type'] == RC_MOVE_OVER_REDIRECT ) {
+ if ( $rc->mAttribs['rc_type'] == RC_MOVE || $rc->mAttribs['rc_type'] == RC_MOVE_OVER_REDIRECT ) {
- } elseif( $rc->mAttribs['rc_log_type'] ) {
+ } elseif ( $rc->mAttribs['rc_log_type'] ) {
$logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
$this->insertLog( $s, $logtitle, $rc->mAttribs['rc_log_type'] );
// Log entries (old format) or log targets, and special pages
$logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
$this->insertLog( $s, $logtitle, $rc->mAttribs['rc_log_type'] );
// Log entries (old format) or log targets, and special pages
- } elseif( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
+ } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $rc->mAttribs['rc_title'] );
list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $rc->mAttribs['rc_title'] );
+ if ( $name == 'Log' ) {
$this->insertLog( $s, $rc->getTitle(), $subpage );
}
// Regular entries
$this->insertLog( $s, $rc->getTitle(), $subpage );
}
// Regular entries
$this->insertExtra( $s, $rc, $classes );
# How many users watch this page
$this->insertExtra( $s, $rc, $classes );
# How many users watch this page
- if( $rc->numberofWatchingusers > 0 ) {
+ if ( $rc->numberofWatchingusers > 0 ) {
$s .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
}
$s .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
}
- if( $this->watchlist ) {
+ if ( $this->watchlist ) {
$classes[] = Sanitizer::escapeClass( 'watchlist-' . $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
}
$classes[] = Sanitizer::escapeClass( 'watchlist-' . $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
}
# If it's a new day, add the headline and flush the cache
$date = $this->getLanguage()->userDate( $rc->mAttribs['rc_timestamp'], $this->getUser() );
$ret = '';
# If it's a new day, add the headline and flush the cache
$date = $this->getLanguage()->userDate( $rc->mAttribs['rc_timestamp'], $this->getUser() );
$ret = '';
- if( $date != $this->lastdate ) {
+ if ( $date != $this->lastdate ) {
# Process current cache
$ret = $this->recentChangesBlock();
$this->rc_cache = array();
# Process current cache
$ret = $this->recentChangesBlock();
$this->rc_cache = array();
$type = $rc->mAttribs['rc_type'];
$logType = $rc->mAttribs['rc_log_type'];
// Page moves, very old style, not supported anymore
$type = $rc->mAttribs['rc_type'];
$logType = $rc->mAttribs['rc_log_type'];
// Page moves, very old style, not supported anymore
- if( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
+ if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
- } elseif( $rc->unpatrolled && $type == RC_NEW ) {
+ } elseif ( $rc->unpatrolled && $type == RC_NEW ) {
$clink = Linker::linkKnown( $rc->getTitle(), null, array(),
array( 'rcid' => $rc->mAttribs['rc_id'] ) );
// Log entries
$clink = Linker::linkKnown( $rc->getTitle(), null, array(),
array( 'rcid' => $rc->mAttribs['rc_id'] ) );
// Log entries
- } elseif( $type == RC_LOG ) {
- if( $logType ) {
+ } elseif ( $type == RC_LOG ) {
+ if ( $logType ) {
$logtitle = SpecialPage::getTitleFor( 'Log', $logType );
$logpage = new LogPage( $logType );
$logname = $logpage->getName()->escaped();
$logtitle = SpecialPage::getTitleFor( 'Log', $logType );
$logpage = new LogPage( $logType );
$logname = $logpage->getName()->escaped();
}
$watched = false;
// Log entries (old format) and special pages
}
$watched = false;
// Log entries (old format) and special pages
- } elseif( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
+ } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
wfDebug( "Unexpected special page in recentchanges\n" );
$clink = '';
// Edits
wfDebug( "Unexpected special page in recentchanges\n" );
$clink = '';
// Edits
# called too many times (50% of CPU time on RecentChanges!).
$thisOldid = $rc->mAttribs['rc_this_oldid'];
$lastOldid = $rc->mAttribs['rc_last_oldid'];
# called too many times (50% of CPU time on RecentChanges!).
$thisOldid = $rc->mAttribs['rc_this_oldid'];
$lastOldid = $rc->mAttribs['rc_last_oldid'];
- if( $rc->unpatrolled ) {
+ if ( $rc->unpatrolled ) {
$rcIdQuery = array( 'rcid' => $rc->mAttribs['rc_id'] );
} else {
$rcIdQuery = array();
$rcIdQuery = array( 'rcid' => $rc->mAttribs['rc_id'] );
} else {
$rcIdQuery = array();
$querydiff = $curIdEq + array( 'diff' => $thisOldid, 'oldid' =>
$lastOldid ) + $rcIdQuery;
$querydiff = $curIdEq + array( 'diff' => $thisOldid, 'oldid' =>
$lastOldid ) + $rcIdQuery;
- if( !$showdifflinks ) {
+ if ( !$showdifflinks ) {
$curLink = $this->message['cur'];
$diffLink = $this->message['diff'];
$curLink = $this->message['cur'];
$diffLink = $this->message['diff'];
- } elseif( in_array( $type, array( RC_NEW, RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) {
+ } elseif ( in_array( $type, array( RC_NEW, RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) {
if ( $type != RC_NEW ) {
$curLink = $this->message['cur'];
} else {
if ( $type != RC_NEW ) {
$curLink = $this->message['cur'];
} else {
- if( !$showdifflinks || !$lastOldid ) {
+ if ( !$showdifflinks || !$lastOldid ) {
$lastLink = $this->message['last'];
$lastLink = $this->message['last'];
- } elseif( in_array( $type, array( RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) {
+ } elseif ( in_array( $type, array( RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT ) ) ) {
$lastLink = $this->message['last'];
} else {
$lastLink = Linker::linkKnown( $rc->getTitle(), $this->message['last'],
$lastLink = $this->message['last'];
} else {
$lastLink = Linker::linkKnown( $rc->getTitle(), $this->message['last'],
- if( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
+ if ( $this->isDeleted( $rc, Revision::DELETED_USER ) ) {
$rc->userlink = ' <span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
} else {
$rc->userlink = Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
$rc->userlink = ' <span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
} else {
$rc->userlink = Linker::userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
# Page moves go on their own line
$title = $rc->getTitle();
$secureName = $title->getPrefixedDBkey();
# Page moves go on their own line
$title = $rc->getTitle();
$secureName = $title->getPrefixedDBkey();
- if( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
+ if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
# Use an @ character to prevent collision with page names
$this->rc_cache['@@' . ($this->rcMoveIndex++)] = array( $rc );
} else {
# Logs are grouped by type
# Use an @ character to prevent collision with page names
$this->rc_cache['@@' . ($this->rcMoveIndex++)] = array( $rc );
} else {
# Logs are grouped by type
- if( $type == RC_LOG ) {
+ if ( $type == RC_LOG ) {
$secureName = SpecialPage::getTitleFor( 'Log', $logType )->getPrefixedDBkey();
}
$secureName = SpecialPage::getTitleFor( 'Log', $logType )->getPrefixedDBkey();
}
- if( !isset( $this->rc_cache[$secureName] ) ) {
+ if ( !isset( $this->rc_cache[$secureName] ) ) {
$this->rc_cache[$secureName] = array();
}
$this->rc_cache[$secureName] = array();
}
# Some catalyst variables...
$namehidden = true;
$allLogs = true;
# Some catalyst variables...
$namehidden = true;
$allLogs = true;
- foreach( $block as $rcObj ) {
+ foreach ( $block as $rcObj ) {
$oldid = $rcObj->mAttribs['rc_last_oldid'];
$oldid = $rcObj->mAttribs['rc_last_oldid'];
- if( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
+ if ( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
$isnew = true;
}
// If all log actions to this page were hidden, then don't
// give the name of the affected page for this block!
$isnew = true;
}
// If all log actions to this page were hidden, then don't
// give the name of the affected page for this block!
- if( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
+ if ( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
$namehidden = false;
}
$u = $rcObj->userlink;
$namehidden = false;
}
$u = $rcObj->userlink;
- if( !isset( $userlinks[$u] ) ) {
+ if ( !isset( $userlinks[$u] ) ) {
- if( $rcObj->unpatrolled ) {
+ if ( $rcObj->unpatrolled ) {
- if( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
+ if ( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
$allLogs = false;
}
# Get the latest entry with a page_id and oldid
# since logs may not have these.
$allLogs = false;
}
# Get the latest entry with a page_id and oldid
# since logs may not have these.
- if( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
+ if ( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
$curId = $rcObj->mAttribs['rc_cur_id'];
}
$curId = $rcObj->mAttribs['rc_cur_id'];
}
- if( !$currentRevision && $rcObj->mAttribs['rc_this_oldid'] ) {
+ if ( !$currentRevision && $rcObj->mAttribs['rc_this_oldid'] ) {
$currentRevision = $rcObj->mAttribs['rc_this_oldid'];
}
$currentRevision = $rcObj->mAttribs['rc_this_oldid'];
}
- if( !$rcObj->mAttribs['rc_bot'] ) {
+ if ( !$rcObj->mAttribs['rc_bot'] ) {
- if( !$rcObj->mAttribs['rc_minor'] ) {
+ if ( !$rcObj->mAttribs['rc_minor'] ) {
krsort( $userlinks );
asort( $userlinks );
$users = array();
krsort( $userlinks );
asort( $userlinks );
$users = array();
- foreach( $userlinks as $userlink => $count ) {
+ foreach ( $userlinks as $userlink => $count ) {
$text = $userlink;
$text .= $this->getLanguage()->getDirMark();
$text = $userlink;
$text .= $this->getLanguage()->getDirMark();
$text .= ' ' . $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->formatNum( $count ) . '×' )->escaped();
}
array_push( $users, $text );
$text .= ' ' . $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->formatNum( $count ) . '×' )->escaped();
}
array_push( $users, $text );
$r .= ' ' . $block[0]->timestamp . ' </td><td>';
# Article link
$r .= ' ' . $block[0]->timestamp . ' </td><td>';
# Article link
$r .= ' <span class="history-deleted">' . $this->msg( 'rev-deleted-event' )->escaped() . '</span>';
$r .= ' <span class="history-deleted">' . $this->msg( 'rev-deleted-event' )->escaped() . '</span>';
+ } elseif ( $allLogs ) {
$r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
} else {
$this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
$r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
} else {
$this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
# Total change link
$r .= ' ';
$logtext = '';
# Total change link
$r .= ' ';
$logtext = '';
- if( !$allLogs ) {
- if( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
+ if ( !$allLogs ) {
+ if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
$logtext .= $nchanges[$n];
$logtext .= $nchanges[$n];
$logtext .= $nchanges[$n];
} else {
$params = $queryParams;
$logtext .= $nchanges[$n];
} else {
$params = $queryParams;
// don't show history link for logs
// don't show history link for logs
- } elseif( $namehidden || !$block[0]->getTitle()->exists() ) {
+ } elseif ( $namehidden || !$block[0]->getTitle()->exists() ) {
$logtext .= $this->message['pipe-separator'] . $this->message['hist'];
} else {
$params = $queryParams;
$logtext .= $this->message['pipe-separator'] . $this->message['hist'];
} else {
$params = $queryParams;
- if( $logtext !== '' ) {
+ if ( $logtext !== '' ) {
$r .= $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
}
$r .= ' <span class="mw-changeslist-separator">. .</span> ';
# Character difference (does not apply if only log items)
$r .= $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
}
$r .= ' <span class="mw-changeslist-separator">. .</span> ';
# Character difference (does not apply if only log items)
- if( $wgRCShowChangedSize && !$allLogs ) {
+ if ( $wgRCShowChangedSize && !$allLogs ) {
$last = 0;
$first = count( $block ) - 1;
# Some events (like logs) have an "empty" size, so we need to skip those...
$last = 0;
$first = count( $block ) - 1;
# Some events (like logs) have an "empty" size, so we need to skip those...
- while( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) {
+ while ( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) {
- while( $first > $last && $block[$first]->mAttribs['rc_old_len'] === null ) {
+ while ( $first > $last && $block[$first]->mAttribs['rc_old_len'] === null ) {
$first--;
}
# Get net change
$chardiff = $this->formatCharacterDifference( $block[$first], $block[$last] );
$first--;
}
# Get net change
$chardiff = $this->formatCharacterDifference( $block[$first], $block[$last] );
- if( $chardiff == '' ) {
+ if ( $chardiff == '' ) {
$r .= ' ';
} else {
$r .= ' ' . $chardiff . ' <span class="mw-changeslist-separator">. .</span> ';
$r .= ' ';
} else {
$r .= ' ' . $chardiff . ' <span class="mw-changeslist-separator">. .</span> ';
$r .= $this->numberofWatchingusers( $block[0]->numberofWatchingusers );
# Sub-entries
$r .= $this->numberofWatchingusers( $block[0]->numberofWatchingusers );
# Sub-entries
- foreach( $block as $rcObj ) {
+ foreach ( $block as $rcObj ) {
# Classes to apply -- TODO implement
$classes = array();
$type = $rcObj->mAttribs['rc_type'];
# Classes to apply -- TODO implement
$classes = array();
$type = $rcObj->mAttribs['rc_type'];
- if( $rcObj->mAttribs['rc_this_oldid'] != 0 ) {
+ if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) {
$params['oldid'] = $rcObj->mAttribs['rc_this_oldid'];
}
# Log timestamp
$params['oldid'] = $rcObj->mAttribs['rc_this_oldid'];
}
# Log timestamp
- if( $type == RC_LOG ) {
+ if ( $type == RC_LOG ) {
$link = $rcObj->timestamp;
# Revision link
$link = $rcObj->timestamp;
# Revision link
- } elseif( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
+ } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
$link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> ';
} else {
if ( $rcObj->unpatrolled && $type == RC_NEW) {
$link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> ';
} else {
if ( $rcObj->unpatrolled && $type == RC_NEW) {
- if( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) {
+ if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) {
$link = '<span class="history-deleted">' . $link . '</span> ';
}
}
$link = '<span class="history-deleted">' . $link . '</span> ';
}
}
$type = $rcObj->mAttribs['rc_type'];
$logType = $rcObj->mAttribs['rc_log_type'];
$classes = array( 'mw-enhanced-rc' );
$type = $rcObj->mAttribs['rc_type'];
$logType = $rcObj->mAttribs['rc_log_type'];
$classes = array( 'mw-enhanced-rc' );
# Log entry
$classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
. $logType . '-' . $rcObj->mAttribs['rc_title'] );
# Log entry
$classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
. $logType . '-' . $rcObj->mAttribs['rc_title'] );
$r .= '<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
# Flag and Timestamp
$r .= '<td class="mw-enhanced-rc"><span class="mw-enhancedchanges-arrow-space"></span>';
# Flag and Timestamp
- if( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
+ if ( $type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT ) {
$r .= '    '; // 4 flags -> 4 spaces
} else {
$r .= $this->recentChangesFlags( array(
$r .= '    '; // 4 flags -> 4 spaces
} else {
$r .= $this->recentChangesFlags( array(
}
$r .= ' ' . $rcObj->timestamp . ' </td><td>';
# Article or log link
}
$r .= ' ' . $rcObj->timestamp . ' </td><td>';
# Article or log link
$logPage = new LogPage( $logType );
$logTitle = SpecialPage::getTitleFor( 'Log', $logType );
$logName = $logPage->getName()->escaped();
$logPage = new LogPage( $logType );
$logTitle = SpecialPage::getTitleFor( 'Log', $logType );
$logName = $logPage->getName()->escaped();
* @return string
*/
protected function recentChangesBlock() {
* @return string
*/
protected function recentChangesBlock() {
- if( count ( $this->rc_cache ) == 0 ) {
+ if ( count ( $this->rc_cache ) == 0 ) {
return '';
}
wfProfileIn( __METHOD__ );
$blockOut = '';
return '';
}
wfProfileIn( __METHOD__ );
$blockOut = '';
- foreach( $this->rc_cache as $block ) {
- if( count( $block ) < 2 ) {
+ foreach ( $this->rc_cache as $block ) {
+ if ( count( $block ) < 2 ) {
$blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
} else {
$blockOut .= $this->recentChangesBlockGroup( $block );
$blockOut .= $this->recentChangesBlockLine( array_shift( $block ) );
} else {
$blockOut .= $this->recentChangesBlockGroup( $block );
$prev = false;
$duplicatePrefixes = array();
$prev = false;
$duplicatePrefixes = array();
- foreach( $letterMap as $key => $value ) {
+ foreach ( $letterMap as $key => $value ) {
// Remove terminator byte. Otherwise the prefix
// comparison will get hung up on that.
$trimmedKey = rtrim( $key, "\0" );
// Remove terminator byte. Otherwise the prefix
// comparison will get hung up on that.
$trimmedKey = rtrim( $key, "\0" );
- foreach( $duplicatePrefixes as $badKey ) {
+ foreach ( $duplicatePrefixes as $badKey ) {
wfDebug( "Removing '{$letterMap[$badKey]}' from first letters." );
unset( $letterMap[$badKey] );
// This code assumes that unsetting does not change sort order.
wfDebug( "Removing '{$letterMap[$badKey]}' from first letters." );
unset( $letterMap[$badKey] );
// This code assumes that unsetting does not change sort order.
function getVars() {
$vars = array();
$this->parse();
function getVars() {
$vars = array();
$this->parse();
- foreach( $this->pathInfo as $path => $data ) {
- if ( $path[0] != '$' )
+ foreach ( $this->pathInfo as $path => $data ) {
+ if ( $path[0] != '$' ) {
$trimmedPath = substr( $path, 1 );
$name = $data['name'];
$trimmedPath = substr( $path, 1 );
$name = $data['name'];
+ if ( $name[0] == '@' ) {
+ }
+ if ( $name[0] == '$' ) {
$name = substr( $name, 1 );
$name = substr( $name, 1 );
$parentPath = substr( $trimmedPath, 0,
strlen( $trimmedPath ) - strlen( $name ) );
$parentPath = substr( $trimmedPath, 0,
strlen( $trimmedPath ) - strlen( $name ) );
- if( substr( $parentPath, -1 ) == '/' )
+ if ( substr( $parentPath, -1 ) == '/' ) {
$parentPath = substr( $parentPath, 0, -1 );
$parentPath = substr( $parentPath, 0, -1 );
$value = substr( $this->text, $data['valueStartByte'],
$data['valueEndByte'] - $data['valueStartByte']
$value = substr( $this->text, $data['valueStartByte'],
$data['valueEndByte'] - $data['valueStartByte']
$target =& $array;
if ( $path !== '' ) {
foreach ( $pathArr as $p ) {
$target =& $array;
if ( $path !== '' ) {
foreach ( $pathArr as $p ) {
- if( !isset( $target[$p] ) )
+ if ( !isset( $target[$p] ) ) {
$target =& $target[$p];
}
}
$target =& $target[$p];
}
}
- if ( !isset( $target[$key] ) )
+ if ( !isset( $target[$key] ) ) {
* @return mixed Parsed value
*/
function parseScalar( $str ) {
* @return mixed Parsed value
*/
function parseScalar( $str ) {
- if ( $str !== '' && $str[0] == '\'' )
+ if ( $str !== '' && $str[0] == '\'' ) {
// Single-quoted string
// @todo FIXME: trim() call is due to mystery bug where whitespace gets
// appended to the token; without it we ended up reading in the
// extra quote on the end!
return strtr( substr( trim( $str ), 1, -1 ),
array( '\\\'' => '\'', '\\\\' => '\\' ) );
// Single-quoted string
// @todo FIXME: trim() call is due to mystery bug where whitespace gets
// appended to the token; without it we ended up reading in the
// extra quote on the end!
return strtr( substr( trim( $str ), 1, -1 ),
array( '\\\'' => '\'', '\\\\' => '\\' ) );
- if ( $str !== '' && $str[0] == '"' )
+ }
+ if ( $str !== '' && $str[0] == '"' ) {
// Double-quoted string
// @todo FIXME: trim() call is due to mystery bug where whitespace gets
// appended to the token; without it we ended up reading in the
// extra quote on the end!
return stripcslashes( substr( trim( $str ), 1, -1 ) );
// Double-quoted string
// @todo FIXME: trim() call is due to mystery bug where whitespace gets
// appended to the token; without it we ended up reading in the
// extra quote on the end!
return stripcslashes( substr( trim( $str ), 1, -1 ) );
- if ( substr( $str, 0, 4 ) == 'true' )
+ }
+ if ( substr( $str, 0, 4 ) == 'true' ) {
- if ( substr( $str, 0, 5 ) == 'false' )
+ }
+ if ( substr( $str, 0, 5 ) == 'false' ) {
- if ( substr( $str, 0, 4 ) == 'null' )
+ }
+ if ( substr( $str, 0, 4 ) == 'null' ) {
// Must be some kind of numeric value, so let PHP's weak typing
// be useful for a change
return $str;
// Must be some kind of numeric value, so let PHP's weak typing
// be useful for a change
return $str;
$this->expect( '=' );
$this->skipSpace();
$this->startPathValue();
$this->expect( '=' );
$this->skipSpace();
$this->startPathValue();
$this->pushState( 'expression', 'array assign end' );
$this->pushState( 'expression', 'array assign end' );
$this->pushState( 'expression', 'statement end' );
$this->pushState( 'expression', 'statement end' );
break;
case 'array assign end':
case 'statement end':
$this->endPathValue();
break;
case 'array assign end':
case 'statement end':
$this->endPathValue();
- if ( $state == 'array assign end' )
+ if ( $state == 'array assign end' ) {
$this->skipSpace();
$this->expect( ';' );
$this->nextPath( '@extra-' . ($this->serial++) );
$this->skipSpace();
$this->expect( ';' );
$this->nextPath( '@extra-' . ($this->serial++) );
}
}
// The absolute filename itself will differ from install to install so don't leave it out
}
}
// The absolute filename itself will differ from install to install so don't leave it out
- if( ( $path = realpath( $file ) ) !== false ) {
+ if ( ( $path = realpath( $file ) ) !== false ) {
$state .= $path;
} else {
$state .= $file;
$state .= $path;
} else {
$state .= $file;
* @throws Exception|null
*/
public static function runUpdates( $updates ) {
* @throws Exception|null
*/
public static function runUpdates( $updates ) {
- if ( empty( $updates ) ) return; # nothing to do
+ if ( empty( $updates ) ) {
+ return; # nothing to do
+ }
$open_transactions = array();
$exception = null;
$open_transactions = array();
$exception = null;
// customized by the local wiki. So get the default English version for
// passing to the parent constructor. Our overridden report() below
// makes sure that the page shown to the user is not forced to English.
// customized by the local wiki. So get the default English version for
// passing to the parent constructor. Our overridden report() below
// makes sure that the page shown to the user is not forced to English.
- if( $msg instanceof Message ) {
+ if ( $msg instanceof Message ) {
$enMsg = clone( $msg );
} else {
$enMsg = wfMessage( $msg, $params );
$enMsg = clone( $msg );
} else {
$enMsg = wfMessage( $msg, $params );
}
$reason = $block->mReason;
}
$reason = $block->mReason;
$reason = wfMessage( 'blockednoreason' )->text();
}
$reason = wfMessage( 'blockednoreason' )->text();
}
$where = array( 'user_id = log_user' );
# Hide private logs
$hideLogs = LogEventsList::getExcludeClause( $this->db );
$where = array( 'user_id = log_user' );
# Hide private logs
$hideLogs = LogEventsList::getExcludeClause( $this->db );
- if ( $hideLogs ) $where[] = $hideLogs;
+ if ( $hideLogs ) {
+ $where[] = $hideLogs;
+ }
# Add on any caller specified conditions
# Add on any caller specified conditions
- if ( $cond ) $where[] = $cond;
+ if ( $cond ) {
+ $where[] = $cond;
+ }
# Get logging table name for logging.* clause
$logging = $this->db->tableName( 'logging' );
# Get logging table name for logging.* clause
$logging = $this->db->tableName( 'logging' );
$out = " <revision>\n";
$out .= " " . Xml::element( 'id', null, strval( $row->rev_id ) ) . "\n";
$out = " <revision>\n";
$out .= " " . Xml::element( 'id', null, strval( $row->rev_id ) ) . "\n";
- if( isset( $row->rev_parent_id ) && $row->rev_parent_id ) {
+ if ( isset( $row->rev_parent_id ) && $row->rev_parent_id ) {
$out .= " " . Xml::element( 'parentid', null, strval( $row->rev_parent_id ) ) . "\n";
}
$out .= " " . Xml::element( 'parentid', null, strval( $row->rev_parent_id ) ) . "\n";
}
if ( substr( $to, -8 ) == '//IGNORE' ) {
$to = substr( $to, 0, strlen( $to ) - 8 );
}
if ( substr( $to, -8 ) == '//IGNORE' ) {
$to = substr( $to, 0, strlen( $to ) - 8 );
}
- if( strcasecmp( $from, $to ) == 0 ) {
+ if ( strcasecmp( $from, $to ) == 0 ) {
- if( strcasecmp( $from, 'utf-8' ) == 0 ) {
+ if ( strcasecmp( $from, 'utf-8' ) == 0 ) {
return utf8_decode( $string );
}
return utf8_decode( $string );
}
- if( strcasecmp( $to, 'utf-8' ) == 0 ) {
+ if ( strcasecmp( $to, 'utf-8' ) == 0 ) {
return utf8_encode( $string );
}
return $string;
return utf8_encode( $string );
}
return $string;
* @return string
*/
public static function mb_substr( $str, $start, $count = 'end' ) {
* @return string
*/
public static function mb_substr( $str, $start, $count = 'end' ) {
$split = self::mb_substr_split_unicode( $str, intval( $start ) );
$str = substr( $str, $split );
}
$split = self::mb_substr_split_unicode( $str, intval( $start ) );
$str = substr( $str, $split );
}
- if( $count !== 'end' ) {
+ if ( $count !== 'end' ) {
$split = self::mb_substr_split_unicode( $str, intval( $count ) );
$str = substr( $str, 0, $split );
}
$split = self::mb_substr_split_unicode( $str, intval( $count ) );
$str = substr( $str, 0, $split );
}
* @return int
*/
public static function mb_substr_split_unicode( $str, $splitPos ) {
* @return int
*/
public static function mb_substr_split_unicode( $str, $splitPos ) {
+ if ( $splitPos == 0 ) {
return 0;
}
$byteLen = strlen( $str );
return 0;
}
$byteLen = strlen( $str );
- if( $splitPos > 0 ) {
- if( $splitPos > 256 ) {
+ if ( $splitPos > 0 ) {
+ if ( $splitPos > 256 ) {
// Optimize large string offsets by skipping ahead N bytes.
// This will cut out most of our slow time on Latin-based text,
// and 1/2 to 1/3 on East European and Asian scripts.
// Optimize large string offsets by skipping ahead N bytes.
// This will cut out most of our slow time on Latin-based text,
// and 1/2 to 1/3 on East European and Asian scripts.
- while( $charPos++ < $splitPos ) {
+ while ( $charPos++ < $splitPos ) {
++$bytePos;
// Move past any tail bytes
while ( $bytePos < $byteLen && $str[$bytePos] >= "\x80" && $str[$bytePos] < "\xc0" ) {
++$bytePos;
// Move past any tail bytes
while ( $bytePos < $byteLen && $str[$bytePos] >= "\x80" && $str[$bytePos] < "\xc0" ) {
$splitPosX = $splitPos + 1;
$charPos = 0; // relative to end of string; we don't care about the actual char position here
$bytePos = $byteLen;
$splitPosX = $splitPos + 1;
$charPos = 0; // relative to end of string; we don't care about the actual char position here
$bytePos = $byteLen;
- while( $bytePos > 0 && $charPos-- >= $splitPosX ) {
+ while ( $bytePos > 0 && $charPos-- >= $splitPosX ) {
--$bytePos;
// Move past any tail bytes
while ( $bytePos > 0 && $str[$bytePos] >= "\x80" && $str[$bytePos] < "\xc0" ) {
--$bytePos;
// Move past any tail bytes
while ( $bytePos > 0 && $str[$bytePos] >= "\x80" && $str[$bytePos] < "\xc0" ) {
$total = 0;
// Count ASCII bytes
$total = 0;
// Count ASCII bytes
- for( $i = 0; $i < 0x80; $i++ ) {
+ for ( $i = 0; $i < 0x80; $i++ ) {
$total += $counts[$i];
}
// Count multibyte sequence heads
$total += $counts[$i];
}
// Count multibyte sequence heads
- for( $i = 0xc0; $i < 0xff; $i++ ) {
+ for ( $i = 0xc0; $i < 0xff; $i++ ) {
$total += $counts[$i];
}
return $total;
$total += $counts[$i];
}
return $total;
$ar = array();
preg_match( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
$ar = array();
preg_match( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
- if( isset( $ar[0][1] ) ) {
+ if ( isset( $ar[0][1] ) ) {
return $ar[0][1];
} else {
return false;
return $ar[0][1];
} else {
return false;
$ar = array();
preg_match_all( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
$ar = array();
preg_match_all( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
- if( isset( $ar[0] ) && count( $ar[0] ) > 0 &&
+ if ( isset( $ar[0] ) && count( $ar[0] ) > 0 &&
isset( $ar[0][count( $ar[0] ) - 1][1] ) ) {
return $ar[0][count( $ar[0] ) - 1][1];
} else {
isset( $ar[0][count( $ar[0] ) - 1][1] ) ) {
return $ar[0][count( $ar[0] ) - 1][1];
} else {
global $wgRequest;
$ctype = $wgRequest->getVal( 'ctype', 'application/xml' );
$allowedctypes = array( 'application/xml', 'text/xml', 'application/rss+xml', 'application/atom+xml' );
global $wgRequest;
$ctype = $wgRequest->getVal( 'ctype', 'application/xml' );
$allowedctypes = array( 'application/xml', 'text/xml', 'application/rss+xml', 'application/atom+xml' );
- return (in_array( $ctype, $allowedctypes ) ? $ctype : 'application/xml');
+ return ( in_array( $ctype, $allowedctypes ) ? $ctype : 'application/xml' );
function outItem( $item ) {
?>
<item>
function outItem( $item ) {
?>
<item>
- <title><?php print $item->getTitle() ?></title>
- <link><?php print wfExpandUrl( $item->getUrl(), PROTO_CURRENT ) ?></link>
- <guid<?php if( !$item->rssIsPermalink ) print ' isPermaLink="false"' ?>><?php print $item->getUniqueId() ?></guid>
+ <title><?php print $item->getTitle(); ?></title>
+ <link><?php print wfExpandUrl( $item->getUrl(), PROTO_CURRENT ); ?></link>
+ <guid<?php if ( !$item->rssIsPermalink ) { print ' isPermaLink="false"'; } ?>><?php print $item->getUniqueId(); ?></guid>
<description><?php print $item->getDescription() ?></description>
<description><?php print $item->getDescription() ?></description>
- <?php if( $item->getDate() ) { ?><pubDate><?php print $this->formatTime( $item->getDate() ) ?></pubDate><?php } ?>
- <?php if( $item->getAuthor() ) { ?><dc:creator><?php print $item->getAuthor() ?></dc:creator><?php }?>
- <?php if( $item->getComments() ) { ?><comments><?php print wfExpandUrl( $item->getComments(), PROTO_CURRENT ) ?></comments><?php }?>
+ <?php if ( $item->getDate() ) { ?><pubDate><?php print $this->formatTime( $item->getDate() ); ?></pubDate><?php } ?>
+ <?php if ( $item->getAuthor() ) { ?><dc:creator><?php print $item->getAuthor(); ?></dc:creator><?php }?>
+ <?php if ( $item->getComments() ) { ?><comments><?php print wfExpandUrl( $item->getComments(), PROTO_CURRENT ); ?></comments><?php }?>
global $wgMimeType;
?>
<entry>
global $wgMimeType;
?>
<entry>
- <id><?php print $item->getUniqueId() ?></id>
- <title><?php print $item->getTitle() ?></title>
- <link rel="alternate" type="<?php print $wgMimeType ?>" href="<?php print wfExpandUrl( $item->getUrl(), PROTO_CURRENT ) ?>"/>
- <?php if( $item->getDate() ) { ?>
- <updated><?php print $this->formatTime( $item->getDate() ) ?>Z</updated>
+ <id><?php print $item->getUniqueId(); ?></id>
+ <title><?php print $item->getTitle(); ?></title>
+ <link rel="alternate" type="<?php print $wgMimeType ?>" href="<?php print wfExpandUrl( $item->getUrl(), PROTO_CURRENT ); ?>"/>
+ <?php if ( $item->getDate() ) { ?>
+ <updated><?php print $this->formatTime( $item->getDate() ); ?>Z</updated>
<?php } ?>
<summary type="html"><?php print $item->getDescription() ?></summary>
<?php } ?>
<summary type="html"><?php print $item->getDescription() ?></summary>
- <?php if( $item->getAuthor() ) { ?><author><name><?php print $item->getAuthor() ?></name></author><?php }?>
+ <?php if ( $item->getAuthor() ) { ?><author><name><?php print $item->getAuthor(); ?></name></author><?php }?>
</entry>
<?php /* @todo FIXME: Need to add comments
</entry>
<?php /* @todo FIXME: Need to add comments
- if( !isset( $wgFeedClasses[$type] ) ) {
+ if ( !isset( $wgFeedClasses[$type] ) ) {
$wgOut->addWikiMsg( 'feed-invalid' );
return false;
}
$wgOut->addWikiMsg( 'feed-invalid' );
return false;
}
$titleObj = Title::makeTitle( $row->rc_namespace, $row->rc_title );
$timestamp = wfTimestamp( TS_MW, $row->rc_timestamp );
$actiontext = '';
$titleObj = Title::makeTitle( $row->rc_namespace, $row->rc_title );
$timestamp = wfTimestamp( TS_MW, $row->rc_timestamp );
$actiontext = '';
- if( $row->rc_type == RC_LOG ) {
+ if ( $row->rc_type == RC_LOG ) {
$rcRow = (array)$row; // newFromRow() only accepts arrays for RC rows
$actiontext = LogFormatter::newFromRow( $rcRow )->getActionText();
}
$rcRow = (array)$row; // newFromRow() only accepts arrays for RC rows
$actiontext = LogFormatter::newFromRow( $rcRow )->getActionText();
}
// Can't diff special pages, unreadable pages or pages with no new revision
// to compare against: just return the text.
// Can't diff special pages, unreadable pages or pages with no new revision
// to compare against: just return the text.
- if( $title->getNamespace() < 0 || $accErrors || !$newid ) {
+ if ( $title->getNamespace() < 0 || $accErrors || !$newid ) {
wfProfileOut( __METHOD__ );
return $completeText;
}
wfProfileOut( __METHOD__ );
return $completeText;
}
wfProfileIn( __METHOD__ . "-dodiff" );
#$diffText = $de->getDiff( wfMessage( 'revisionasof',
wfProfileIn( __METHOD__ . "-dodiff" );
#$diffText = $de->getDiff( wfMessage( 'revisionasof',
wfProfileOut( __METHOD__ . "-dodiff" );
} else {
$rev = Revision::newFromId( $newid );
wfProfileOut( __METHOD__ . "-dodiff" );
} else {
$rev = Revision::newFromId( $newid );
- if( $wgFeedDiffCutoff <= 0 || is_null( $rev ) ) {
+ if ( $wgFeedDiffCutoff <= 0 || is_null( $rev ) ) {
$newContent = ContentHandler::getForTitle( $title )->makeEmptyContent();
} else {
$newContent = $rev->getContent();
$newContent = ContentHandler::getForTitle( $title )->makeEmptyContent();
} else {
$newContent = $rev->getContent();
'diffchange' => 'font-weight: bold; text-decoration: none;',
);
'diffchange' => 'font-weight: bold; text-decoration: none;',
);
- foreach( $styles as $class => $style ) {
+ foreach ( $styles as $class => $style ) {
$text = preg_replace( "/(<[^>]+)class=(['\"])$class\\2([^>]*>)/",
"\\1style=\"$style\"\\3", $text );
}
$text = preg_replace( "/(<[^>]+)class=(['\"])$class\\2([^>]*>)/",
"\\1style=\"$style\"\\3", $text );
}
# Flag to hide all contents of the archived revisions
$suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' );
# Flag to hide all contents of the archived revisions
$suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' );
- if( $this->oldimage ) {
+ if ( $this->oldimage ) {
$this->oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->title, $this->oldimage );
}
$this->oldfile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->title, $this->oldimage );
}
- if( !self::haveDeletableFile( $this->file, $this->oldfile, $this->oldimage ) ) {
+ if ( !self::haveDeletableFile( $this->file, $this->oldfile, $this->oldimage ) ) {
$wgOut->addHTML( $this->prepareMessage( 'filedelete-nofile' ) );
$wgOut->addReturnTo( $this->title );
return;
}
// Perform the deletion if appropriate
$wgOut->addHTML( $this->prepareMessage( 'filedelete-nofile' ) );
$wgOut->addReturnTo( $this->title );
return;
}
// Perform the deletion if appropriate
- if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $token, $this->oldimage ) ) {
+ if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $token, $this->oldimage ) ) {
$deleteReasonList = $wgRequest->getText( 'wpDeleteReasonList' );
$deleteReason = $wgRequest->getText( 'wpReason' );
$deleteReasonList = $wgRequest->getText( 'wpDeleteReasonList' );
$deleteReason = $wgRequest->getText( 'wpReason' );
$status = self::doDelete( $this->title, $this->file, $this->oldimage, $reason, $suppress, $wgUser );
$status = self::doDelete( $this->title, $this->file, $this->oldimage, $reason, $suppress, $wgUser );
- if( !$status->isGood() ) {
+ if ( !$status->isGood() ) {
$wgOut->addHTML( '<h2>' . $this->prepareMessage( 'filedeleteerror-short' ) . "</h2>\n" );
$wgOut->addWikiText( '<div class="error">' . $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) . '</div>' );
}
$wgOut->addHTML( '<h2>' . $this->prepareMessage( 'filedeleteerror-short' ) . "</h2>\n" );
$wgOut->addWikiText( '<div class="error">' . $status->getWikiText( 'filedeleteerror-short', 'filedeleteerror-long' ) . '</div>' );
}
$wgOut->setPageTitle( wfMessage( 'actioncomplete' ) );
$wgOut->addHTML( $this->prepareMessage( 'filedelete-success' ) );
// Return to the main page if we just deleted all versions of the
$wgOut->setPageTitle( wfMessage( 'actioncomplete' ) );
$wgOut->addHTML( $this->prepareMessage( 'filedelete-success' ) );
// Return to the main page if we just deleted all versions of the
$page = null;
$status = $file->deleteOld( $oldimage, $reason, $suppress );
$page = null;
$status = $file->deleteOld( $oldimage, $reason, $suppress );
// Need to do a log item
$logComment = wfMessage( 'deletedrevision', $oldimage )->inContentLanguage()->text();
// Need to do a log item
$logComment = wfMessage( 'deletedrevision', $oldimage )->inContentLanguage()->text();
- if( trim( $reason ) != '' ) {
+ if ( trim( $reason ) != '' ) {
$logComment .= wfMessage( 'colon-separator' )
->inContentLanguage()->text() . $reason;
}
$logComment .= wfMessage( 'colon-separator' )
->inContentLanguage()->text() . $reason;
}
// or revision is missing, so check for isOK() rather than isGood()
if ( $deleteStatus->isOK() ) {
$status = $file->delete( $reason, $suppress );
// or revision is missing, so check for isOK() rather than isGood()
if ( $deleteStatus->isOK() ) {
$status = $file->delete( $reason, $suppress );
- if( $status->isOK() ) {
+ if ( $status->isOK() ) {
$dbw->commit( __METHOD__ );
} else {
$dbw->rollback( __METHOD__ );
$dbw->commit( __METHOD__ );
} else {
$dbw->rollback( __METHOD__ );
private function showForm() {
global $wgOut, $wgUser, $wgRequest;
private function showForm() {
global $wgOut, $wgUser, $wgRequest;
- if( $wgUser->isAllowed( 'suppressrevision' ) ) {
+ if ( $wgUser->isAllowed( 'suppressrevision' ) ) {
$suppress = "<tr id=\"wpDeleteSuppressRow\">
<td></td>
<td class='mw-input'><strong>" .
$suppress = "<tr id=\"wpDeleteSuppressRow\">
<td></td>
<td class='mw-input'><strong>" .
"</td>
</tr>
{$suppress}";
"</td>
</tr>
{$suppress}";
- if( $wgUser->isLoggedIn() ) {
+ if ( $wgUser->isLoggedIn() ) {
$form .= "
<tr>
<td></td>
$form .= "
<tr>
<td></td>
*/
private function prepareMessage( $message ) {
global $wgLang;
*/
private function prepareMessage( $message ) {
global $wgLang;
- if( $this->oldimage ) {
+ if ( $this->oldimage ) {
return wfMessage(
"{$message}-old", # To ensure grep will find them: 'filedelete-intro-old', 'filedelete-nofile-old', 'filedelete-success-old'
wfEscapeWikiText( $this->title->getText() ),
return wfMessage(
"{$message}-old", # To ensure grep will find them: 'filedelete-intro-old', 'filedelete-nofile-old', 'filedelete-success-old'
wfEscapeWikiText( $this->title->getText() ),
$q = array();
$q['action'] = 'delete';
$q = array();
$q['action'] = 'delete';
- if( $this->oldimage ) {
+ if ( $this->oldimage ) {
$q['oldimage'] = $this->oldimage;
}
$q['oldimage'] = $this->oldimage;
}
if ( function_exists( 'pcntl_signal_dispatch' ) ) {
pcntl_signal_dispatch();
} else {
if ( function_exists( 'pcntl_signal_dispatch' ) ) {
pcntl_signal_dispatch();
} else {
- declare (ticks=1) { $status = $status; }
+ declare( ticks = 1 ) {
+ $status = $status;
+ }
}
// Respond to TERM signal
if ( $this->termReceived ) {
}
// Respond to TERM signal
if ( $this->termReceived ) {
switch( $type ) {
case self::BOOL:
switch( $type ) {
case self::BOOL:
- $value = $r->getBool( $name, $default ); break;
+ $value = $r->getBool( $name, $default );
+ break;
- $value = $r->getInt( $name, $default ); break;
+ $value = $r->getInt( $name, $default );
+ break;
- $value = $r->getText( $name, $default ); break;
+ $value = $r->getText( $name, $default );
+ break;
- $value = $r->getIntOrNull( $name ); break;
+ $value = $r->getIntOrNull( $name );
+ break;
default:
throw new MWException( 'Unsupported datatype' );
}
default:
throw new MWException( 'Unsupported datatype' );
}
if ( isset( $configArray['remote origin'] ) ) {
$remote = $configArray['remote origin'];
} else {
if ( isset( $configArray['remote origin'] ) ) {
$remote = $configArray['remote origin'];
} else {
- foreach( $configArray as $sectionName => $sectionConf ) {
+ foreach ( $configArray as $sectionName => $sectionConf ) {
if ( substr( $sectionName, 0, 6 ) == 'remote' ) {
$remote = $sectionConf;
}
if ( substr( $sectionName, 0, 6 ) == 'remote' ) {
$remote = $sectionConf;
}
if ( substr( $url, -4 ) !== '.git' ) {
$url .= '.git';
}
if ( substr( $url, -4 ) !== '.git' ) {
$url .= '.git';
}
- foreach( self::getViewers() as $repo => $viewer ) {
+ foreach ( self::getViewers() as $repo => $viewer ) {
$pattern = '#^' . $repo . '$#';
if ( preg_match( $pattern, $url ) ) {
$viewerUrl = preg_replace( $pattern, $viewer, $url );
$pattern = '#^' . $repo . '$#';
if ( preg_match( $pattern, $url ) ) {
$viewerUrl = preg_replace( $pattern, $viewer, $url );
protected static function getViewers() {
global $wgGitRepositoryViewers;
protected static function getViewers() {
global $wgGitRepositoryViewers;
- if( self::$viewers === false ) {
+ if ( self::$viewers === false ) {
self::$viewers = $wgGitRepositoryViewers;
wfRunHooks( 'GitViewers', array( &self::$viewers ) );
}
self::$viewers = $wgGitRepositoryViewers;
wfRunHooks( 'GitViewers', array( &self::$viewers ) );
}
* done already.
* @deprecated since 1.18 load modules with ResourceLoader instead
*/
* done already.
* @deprecated since 1.18 load modules with ResourceLoader instead
*/
- static function addJS() { wfDeprecated( __METHOD__, '1.18' ); }
+ static function addJS() {
+ wfDeprecated( __METHOD__, '1.18' );
+ }
/**
* Initialise a new Object for the field
/**
* Initialise a new Object for the field
$validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] );
$validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] );
- if ( in_array( $value, $validOptions ) )
+ if ( in_array( $value, $validOptions ) ) {
return $this->msg( 'htmlform-select-badoption' )->parse();
return $this->msg( 'htmlform-select-badoption' )->parse();
}
function getInputHTML( $value ) {
}
function getInputHTML( $value ) {
return $this->getTableRow( $value );
}
return $this->getTableRow( $value );
}
- public function getInputHTML( $value ) { return ''; }
+ public function getInputHTML( $value ) {
+ return '';
+ }
// Fit the map to weight-proportionate one with a space of size RING_SIZE
$standardMap = array();
foreach ( $map as $location => $weight ) {
// Fit the map to weight-proportionate one with a space of size RING_SIZE
$standardMap = array();
foreach ( $map as $location => $weight ) {
- $standardMap[$location] = (int)floor( $weight/$sum * self::RING_SIZE );
+ $standardMap[$location] = (int)floor( $weight / $sum * self::RING_SIZE );
}
// Build a ring of RING_SIZE spots, with each location at a spot in location hash order
$index = 0;
}
// Build a ring of RING_SIZE spots, with each location at a spot in location hash order
$index = 0;
* @return string
*/
function getText() {
* @return string
*/
function getText() {
- if( isset( self::$blobCache[$this->mOldId] ) ) {
+ if ( isset( self::$blobCache[$this->mOldId] ) ) {
$obj = self::$blobCache[$this->mOldId];
} else {
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow( 'text', array( 'old_flags', 'old_text' ), array( 'old_id' => $this->mOldId ) );
$obj = self::$blobCache[$this->mOldId];
} else {
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow( 'text', array( 'old_flags', 'old_text' ), array( 'old_id' => $this->mOldId ) );
return false;
}
$flags = explode( ',', $row->old_flags );
return false;
}
$flags = explode( ',', $row->old_flags );
- if( in_array( 'external', $flags ) ) {
+ if ( in_array( 'external', $flags ) ) {
$url = $row->old_text;
$parts = explode( '://', $url, 2 );
if ( !isset( $parts[1] ) || $parts[1] == '' ) {
$url = $row->old_text;
$parts = explode( '://', $url, 2 );
if ( !isset( $parts[1] ) || $parts[1] == '' ) {
$row->old_text = ExternalStore::fetchFromUrl( $url );
}
$row->old_text = ExternalStore::fetchFromUrl( $url );
}
- if( !in_array( 'object', $flags ) ) {
+ if ( !in_array( 'object', $flags ) ) {
- if( in_array( 'gzip', $flags ) ) {
+ if ( in_array( 'gzip', $flags ) ) {
// This shouldn't happen, but a bug in the compress script
// may at times gzip-compress a HistoryBlob object row.
$obj = unserialize( gzinflate( $row->old_text ) );
// This shouldn't happen, but a bug in the compress script
// may at times gzip-compress a HistoryBlob object row.
$obj = unserialize( gzinflate( $row->old_text ) );
$obj = unserialize( $row->old_text );
}
$obj = unserialize( $row->old_text );
}
- if( !is_object( $obj ) ) {
+ if ( !is_object( $obj ) ) {
// Correct for old double-serialization bug.
$obj = unserialize( $obj );
}
// Correct for old double-serialization bug.
$obj = unserialize( $obj );
}
function getText() {
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mCurId ) );
function getText() {
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mCurId ) );
return false;
}
return $row->cur_text;
return false;
}
return $row->cur_text;
* @param $callback Mixed: callback function to attach
*/
public static function register( $name, $callback ) {
* @param $callback Mixed: callback function to attach
*/
public static function register( $name, $callback ) {
- if( !isset( self::$handlers[$name] ) ) {
+ if ( !isset( self::$handlers[$name] ) ) {
self::$handlers[$name] = array();
}
self::$handlers[$name] = array();
}
/* String return is an error; false return means stop processing. */
if ( is_string( $retval ) ) {
throw new FatalError( $retval );
/* String return is an error; false return means stop processing. */
if ( is_string( $retval ) ) {
throw new FatalError( $retval );
- } elseif( $retval === null ) {
+ } elseif ( $retval === null ) {
if ( $closure ) {
$prettyFunc = "$event closure";
if ( $closure ) {
$prettyFunc = "$event closure";
- } elseif( is_array( $callback ) ) {
- if( is_object( $callback[0] ) ) {
+ } elseif ( is_array( $callback ) ) {
+ if ( is_object( $callback[0] ) ) {
$prettyClass = get_class( $callback[0] );
} else {
$prettyClass = strval( $callback[0] );
$prettyClass = get_class( $callback[0] );
} else {
$prettyClass = strval( $callback[0] );
);
// Allow more input types in HTML5 mode
);
// Allow more input types in HTML5 mode
$validTypes = array_merge( $validTypes, array(
'datetime',
'datetime-local',
$validTypes = array_merge( $validTypes, array(
'datetime',
'datetime-local',
foreach ( $attribs as $attrib => $value ) {
$lcattrib = strtolower( $attrib );
foreach ( $attribs as $attrib => $value ) {
$lcattrib = strtolower( $attrib );
- if( is_array( $value ) ) {
+ if ( is_array( $value ) ) {
$value = implode( ' ', $value );
} else {
$value = strval( $value );
$value = implode( ' ', $value );
} else {
$value = strval( $value );
*/
static function srcSet( $urls ) {
$candidates = array();
*/
static function srcSet( $urls ) {
$candidates = array();
- foreach( $urls as $density => $url ) {
+ foreach ( $urls as $density => $url ) {
// Image candidate syntax per current whatwg live spec, 2012-09-23:
// http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-1.html#attr-img-srcset
$candidates[] = "{$url} {$density}x";
// Image candidate syntax per current whatwg live spec, 2012-09-23:
// http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-1.html#attr-img-srcset
$candidates[] = "{$url} {$density}x";
} else {
$this->timeout = $wgHTTPTimeout;
}
} else {
$this->timeout = $wgHTTPTimeout;
}
- if( isset( $options['userAgent'] ) ) {
+ if ( isset( $options['userAgent'] ) ) {
$this->setUserAgent( $options['userAgent'] );
}
$this->setUserAgent( $options['userAgent'] );
}
if ( $this->method == 'POST' ) {
// Required for HTTP 1.0 POSTs
$this->reqHeaders['Content-Length'] = strlen( $this->postData );
if ( $this->method == 'POST' ) {
// Required for HTTP 1.0 POSTs
$this->reqHeaders['Content-Length'] = strlen( $this->postData );
- if( !isset( $this->reqHeaders['Content-Type'] ) ) {
+ if ( !isset( $this->reqHeaders['Content-Type'] ) ) {
$this->reqHeaders['Content-Type'] = "application/x-www-form-urlencoded";
}
}
$this->reqHeaders['Content-Type'] = "application/x-www-form-urlencoded";
}
}
// An IPv6 address is made up of 8 words (each x0000 to xFFFF).
// However, the "::" abbreviation can be used on consecutive x0000 words.
define( 'RE_IPV6_WORD', '([0-9A-Fa-f]{1,4})' );
// An IPv6 address is made up of 8 words (each x0000 to xFFFF).
// However, the "::" abbreviation can be used on consecutive x0000 words.
define( 'RE_IPV6_WORD', '([0-9A-Fa-f]{1,4})' );
-define( 'RE_IPV6_PREFIX', '(12[0-8]|1[01][0-9]|[1-9]?\d)');
+define( 'RE_IPV6_PREFIX', '(12[0-8]|1[01][0-9]|[1-9]?\d)' );
define( 'RE_IPV6_ADD',
'(?:' . // starts with "::" (including "::")
':(?::|(?::' . RE_IPV6_WORD . '){1,7})' .
define( 'RE_IPV6_ADD',
'(?:' . // starts with "::" (including "::")
':(?::|(?::' . RE_IPV6_WORD . '){1,7})' .
static $privateRanges = false;
if ( !$privateRanges ) {
$privateRanges = array(
static $privateRanges = false;
if ( !$privateRanges ) {
$privateRanges = array(
- array( '10.0.0.0', '10.255.255.255' ), # RFC 1918 (private)
- array( '172.16.0.0', '172.31.255.255' ), # "
- array( '192.168.0.0', '192.168.255.255' ), # "
- array( '0.0.0.0', '0.255.255.255' ), # this network
- array( '127.0.0.0', '127.255.255.255' ), # loopback
+ array( '10.0.0.0', '10.255.255.255' ), # RFC 1918 (private)
+ array( '172.16.0.0', '172.31.255.255' ), # RFC 1918 (private)
+ array( '192.168.0.0', '192.168.255.255' ), # RFC 1918 (private)
+ array( '0.0.0.0', '0.255.255.255' ), # this network
+ array( '127.0.0.0', '127.255.255.255' ), # loopback
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">'
. htmlspecialchars( $nt->getText() ) . '</div>';
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">'
. htmlspecialchars( $nt->getText() ) . '</div>';
- } elseif( $this->mHideBadImages && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) ) {
+ } elseif ( $this->mHideBadImages && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) ) {
# The image is blacklisted, just show it as a text link.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">' .
Linker::link(
# The image is blacklisted, just show it as a text link.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">' .
Linker::link(
array( 'known', 'noclasses' )
) .
'</div>';
array( 'known', 'noclasses' )
) .
'</div>';
- } elseif( !( $thumb = $img->transform( $params ) ) ) {
+ } elseif ( !( $thumb = $img->transform( $params ) ) ) {
# Error generating thumbnail.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">'
. htmlspecialchars( $img->getLastError() ) . '</div>';
# Error generating thumbnail.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">'
. htmlspecialchars( $img->getLastError() ) . '</div>';
// $linkTarget = Title::newFromText( $wgContLang->getNsText( MWNamespace::getUser() ) . ":{$ut}" );
// $ul = Linker::link( $linkTarget, $ut );
// $linkTarget = Title::newFromText( $wgContLang->getNsText( MWNamespace::getUser() ) . ":{$ut}" );
// $ul = Linker::link( $linkTarget, $ut );
- if( $this->mShowBytes ) {
- if( $img ) {
+ if ( $this->mShowBytes ) {
+ if ( $img ) {
$fileSize = htmlspecialchars( $lang->formatSize( $img->getSize() ) );
} else {
$fileSize = wfMessage( 'filemissing' )->escaped();
$fileSize = htmlspecialchars( $lang->formatSize( $img->getSize() ) );
} else {
$fileSize = wfMessage( 'filemissing' )->escaped();
}
// Add remote Filepage.css
}
// Add remote Filepage.css
- if( !$this->repo->isLocal() ) {
+ if ( !$this->repo->isLocal() ) {
$css = $this->repo->getDescriptionStylesheetUrl();
if ( $css ) {
$out->addStyle( $css );
$css = $this->repo->getDescriptionStylesheetUrl();
if ( $css ) {
$out->addStyle( $css );
$descText = $this->mPage->getFile()->getDescriptionText();
/* Add canonical to head if there is no local page for this shared file */
$descText = $this->mPage->getFile()->getDescriptionText();
/* Add canonical to head if there is no local page for this shared file */
- if( $descUrl && $this->mPage->getID() == 0 ) {
+ if ( $descUrl && $this->mPage->getID() == 0 ) {
$out->setCanonicalUrl( $descUrl );
}
$out->setCanonicalUrl( $descUrl );
}
// Create links for every element
$currentCount = 0;
// Create links for every element
$currentCount = 0;
- foreach( $rows as $element ) {
+ foreach ( $rows as $element ) {
$currentCount++;
if ( $currentCount > $limit ) {
break;
$currentCount++;
if ( $currentCount > $limit ) {
break;
* @param int $offset Paging offset
*/
protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
* @param int $offset Paging offset
*/
protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
$gallery = new ImageGallery();
# $res might contain the whole 1,000 rows, so we read up to
# $num [should update this to use a Pager]
$gallery = new ImageGallery();
# $res might contain the whole 1,000 rows, so we read up to
# $num [should update this to use a Pager]
- for( $i = 0; $i < $num && $row = $dbr->fetchObject( $res ); $i++ ) {
+ for ( $i = 0; $i < $num && $row = $dbr->fetchObject( $res ); $i++ ) {
$namespace = isset( $row->namespace ) ? $row->namespace : NS_FILE;
$title = Title::makeTitleSafe( $namespace, $row->title );
if ( $title instanceof Title && $title->getNamespace() == NS_FILE ) {
$namespace = isset( $row->namespace ) ? $row->namespace : NS_FILE;
$title = Title::makeTitleSafe( $namespace, $row->title );
if ( $title instanceof Title && $title->getNamespace() == NS_FILE ) {
}
private function debug( $data ) {
}
private function debug( $data ) {
wfDebug( "IMPORT: $data\n" );
}
}
wfDebug( "IMPORT: $data\n" );
}
}
* @return bool
*/
public function setTargetNamespace( $namespace ) {
* @return bool
*/
public function setTargetNamespace( $namespace ) {
- if( is_null( $namespace ) ) {
+ if ( is_null( $namespace ) ) {
// Don't override namespaces
$this->mTargetNamespace = null;
// Don't override namespaces
$this->mTargetNamespace = null;
- } elseif( $namespace >= 0 ) {
+ } elseif ( $namespace >= 0 ) {
// @todo FIXME: Check for validity
$this->mTargetNamespace = intval( $namespace );
} else {
// @todo FIXME: Check for validity
$this->mTargetNamespace = intval( $namespace );
} else {
*/
public function setTargetRootPage( $rootpage ) {
$status = Status::newGood();
*/
public function setTargetRootPage( $rootpage ) {
$status = Status::newGood();
- if( is_null( $rootpage ) ) {
+ if ( is_null( $rootpage ) ) {
// No rootpage
$this->mTargetRootPage = null;
// No rootpage
$this->mTargetRootPage = null;
- } elseif( $rootpage !== '' ) {
+ } elseif ( $rootpage !== '' ) {
$rootpage = rtrim( $rootpage, '/' ); //avoid double slashes
$title = Title::newFromText( $rootpage, !is_null( $this->mTargetNamespace ) ? $this->mTargetNamespace : NS_MAIN );
$rootpage = rtrim( $rootpage, '/' ); //avoid double slashes
$title = Title::newFromText( $rootpage, !is_null( $this->mTargetNamespace ) ? $this->mTargetNamespace : NS_MAIN );
- if( !$title || $title->isExternal() ) {
+ if ( !$title || $title->isExternal() ) {
$status->fatal( 'import-rootpage-invalid' );
} else {
$status->fatal( 'import-rootpage-invalid' );
} else {
- if( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
+ if ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
global $wgContLang;
$displayNSText = $title->getNamespace() == NS_MAIN
global $wgContLang;
$displayNSText = $title->getNamespace() == NS_MAIN
*/
public function debugRevisionHandler( &$revision ) {
$this->debug( "Got revision:" );
*/
public function debugRevisionHandler( &$revision ) {
$this->debug( "Got revision:" );
- if( is_object( $revision->title ) ) {
+ if ( is_object( $revision->title ) ) {
$this->debug( "-- Title: " . $revision->title->getPrefixedText() );
} else {
$this->debug( "-- Title: <invalid>" );
$this->debug( "-- Title: " . $revision->title->getPrefixedText() );
} else {
$this->debug( "-- Title: <invalid>" );
* @param $title Title
*/
function pageCallback( $title ) {
* @param $title Title
*/
function pageCallback( $title ) {
- if( isset( $this->mPageCallback ) ) {
+ if ( isset( $this->mPageCallback ) ) {
call_user_func( $this->mPageCallback, $title );
}
}
call_user_func( $this->mPageCallback, $title );
}
}
* @param array $pageInfo associative array of page information
*/
private function pageOutCallback( $title, $origTitle, $revCount, $sucCount, $pageInfo ) {
* @param array $pageInfo associative array of page information
*/
private function pageOutCallback( $title, $origTitle, $revCount, $sucCount, $pageInfo ) {
- if( isset( $this->mPageOutCallback ) ) {
+ if ( isset( $this->mPageOutCallback ) ) {
$args = func_get_args();
call_user_func_array( $this->mPageOutCallback, $args );
}
$args = func_get_args();
call_user_func_array( $this->mPageOutCallback, $args );
}
* @access private
*/
private function nodeContents() {
* @access private
*/
private function nodeContents() {
- if( $this->reader->isEmptyElement ) {
+ if ( $this->reader->isEmptyElement ) {
return "";
}
$buffer = "";
return "";
}
$buffer = "";
- while( $this->reader->read() ) {
+ while ( $this->reader->read() ) {
switch( $this->reader->nodeType ) {
case XmlReader::TEXT:
case XmlReader::SIGNIFICANT_WHITESPACE:
switch( $this->reader->nodeType ) {
case XmlReader::TEXT:
case XmlReader::SIGNIFICANT_WHITESPACE:
"END_ELEMENT",
"END_ENTITY",
"XML_DECLARATION",
"END_ELEMENT",
"END_ENTITY",
"XML_DECLARATION",
- foreach( $xmlReaderConstants as $name ) {
+ foreach ( $xmlReaderConstants as $name ) {
$lookup[constant("XmlReader::$name")] = $name;
}
}
$lookup[constant("XmlReader::$name")] = $name;
}
}
private function processRevision( $pageInfo, $revisionInfo ) {
$revision = new WikiRevision;
private function processRevision( $pageInfo, $revisionInfo ) {
$revision = new WikiRevision;
- if( isset( $revisionInfo['id'] ) ) {
+ if ( isset( $revisionInfo['id'] ) ) {
$revision->setID( $revisionInfo['id'] );
}
if ( isset( $revisionInfo['text'] ) ) {
$revision->setID( $revisionInfo['id'] );
}
if ( isset( $revisionInfo['text'] ) ) {
$workTitle = $text;
$origTitle = Title::newFromText( $workTitle );
$workTitle = $text;
$origTitle = Title::newFromText( $workTitle );
- if( !is_null( $this->mTargetNamespace ) && !is_null( $origTitle ) ) {
+ if ( !is_null( $this->mTargetNamespace ) && !is_null( $origTitle ) ) {
# makeTitleSafe, because $origTitle can have a interwiki (different setting of interwiki map)
# and than dbKey can begin with a lowercase char
$title = Title::makeTitleSafe( $this->mTargetNamespace,
$origTitle->getDBkey() );
} else {
# makeTitleSafe, because $origTitle can have a interwiki (different setting of interwiki map)
# and than dbKey can begin with a lowercase char
$title = Title::makeTitleSafe( $this->mTargetNamespace,
$origTitle->getDBkey() );
} else {
- if( !is_null( $this->mTargetRootPage ) ) {
+ if ( !is_null( $this->mTargetRootPage ) ) {
$workTitle = $this->mTargetRootPage . '/' . $workTitle;
}
$title = Title::newFromText( $workTitle );
}
$workTitle = $this->mTargetRootPage . '/' . $workTitle;
}
$title = Title::newFromText( $workTitle );
}
- if( is_null( $title ) ) {
+ if ( is_null( $title ) ) {
# Invalid page title? Ignore the page
$this->notice( 'import-error-invalid', $workTitle );
return false;
# Invalid page title? Ignore the page
$this->notice( 'import-error-invalid', $workTitle );
return false;
- } elseif( $title->isExternal() ) {
+ } elseif ( $title->isExternal() ) {
$this->notice( 'import-error-interwiki', $title->getPrefixedText() );
return false;
$this->notice( 'import-error-interwiki', $title->getPrefixedText() );
return false;
- } elseif( !$title->canExist() ) {
+ } elseif ( !$title->canExist() ) {
$this->notice( 'import-error-special', $title->getPrefixedText() );
return false;
$this->notice( 'import-error-special', $title->getPrefixedText() );
return false;
- } elseif( !$title->userCan( 'edit' ) && !$wgCommandLineMode ) {
+ } elseif ( !$title->userCan( 'edit' ) && !$wgCommandLineMode ) {
# Do not import if the importing wiki user cannot edit this page
$this->notice( 'import-error-edit', $title->getPrefixedText() );
return false;
# Do not import if the importing wiki user cannot edit this page
$this->notice( 'import-error-edit', $title->getPrefixedText() );
return false;
- } elseif( !$title->exists() && !$title->userCan( 'create' ) && !$wgCommandLineMode ) {
+ } elseif ( !$title->exists() && !$title->userCan( 'create' ) && !$wgCommandLineMode ) {
# Do not import if the importing wiki user cannot create this page
$this->notice( 'import-error-create', $title->getPrefixedText() );
return false;
# Do not import if the importing wiki user cannot create this page
$this->notice( 'import-error-create', $title->getPrefixedText() );
return false;
* @return bool|string
*/
function nodeContents() {
* @return bool|string
*/
function nodeContents() {
- if( $this->isEmptyElement ) {
+ if ( $this->isEmptyElement ) {
return "";
}
$buffer = "";
return "";
}
$buffer = "";
- while( $this->read() ) {
+ while ( $this->read() ) {
switch( $this->nodeType ) {
case XmlReader::TEXT:
case XmlReader::SIGNIFICANT_WHITESPACE:
switch( $this->nodeType ) {
case XmlReader::TEXT:
case XmlReader::SIGNIFICANT_WHITESPACE:
* @throws MWException
*/
function setTitle( $title ) {
* @throws MWException
*/
function setTitle( $title ) {
- if( is_object( $title ) ) {
+ if ( is_object( $title ) ) {
- } elseif( is_null( $title ) ) {
+ } elseif ( is_null( $title ) ) {
throw new MWException( "WikiRevision given a null title in import. You may need to adjust \$wgLegalTitleChars." );
} else {
throw new MWException( "WikiRevision given non-object title in import." );
throw new MWException( "WikiRevision given a null title in import. You may need to adjust \$wgLegalTitleChars." );
} else {
throw new MWException( "WikiRevision given non-object title in import." );
# Sneak a single revision into place
$user = User::newFromName( $this->getUser() );
# Sneak a single revision into place
$user = User::newFromName( $this->getUser() );
$userId = intval( $user->getId() );
$userText = $user->getName();
$userObj = $user;
$userId = intval( $user->getId() );
$userText = $user->getName();
$userObj = $user;
$linkCache->clear();
$page = WikiPage::factory( $this->title );
$linkCache->clear();
$page = WikiPage::factory( $this->title );
- if( !$page->exists() ) {
+ if ( !$page->exists() ) {
# must create the page...
$pageId = $page->insertOn( $dbw );
$created = true;
# must create the page...
$pageId = $page->insertOn( $dbw );
$created = true;
'rev_comment' => $this->getComment() ),
__METHOD__
);
'rev_comment' => $this->getComment() ),
__METHOD__
);
// @todo FIXME: This could fail slightly for multiple matches :P
wfDebug( __METHOD__ . ": skipping existing revision for [[" .
$this->title->getPrefixedText() . "]], timestamp " . $this->timestamp . "\n" );
// @todo FIXME: This could fail slightly for multiple matches :P
wfDebug( __METHOD__ . ": skipping existing revision for [[" .
$this->title->getPrefixedText() . "]], timestamp " . $this->timestamp . "\n" );
function importLogItem() {
$dbw = wfGetDB( DB_MASTER );
# @todo FIXME: This will not record autoblocks
function importLogItem() {
$dbw = wfGetDB( DB_MASTER );
# @todo FIXME: This will not record autoblocks
- if( !$this->getTitle() ) {
+ if ( !$this->getTitle() ) {
wfDebug( __METHOD__ . ": skipping invalid {$this->type}/{$this->action} log time, timestamp " .
$this->timestamp . "\n" );
return;
wfDebug( __METHOD__ . ": skipping invalid {$this->type}/{$this->action} log time, timestamp " .
$this->timestamp . "\n" );
return;
__METHOD__
);
// @todo FIXME: This could fail slightly for multiple matches :P
__METHOD__
);
// @todo FIXME: This could fail slightly for multiple matches :P
wfDebug( __METHOD__ . ": skipping existing item for Log:{$this->type}/{$this->action}, timestamp " .
$this->timestamp . "\n" );
return;
wfDebug( __METHOD__ . ": skipping existing item for Log:{$this->type}/{$this->action}, timestamp " .
$this->timestamp . "\n" );
return;
wfDebug( __METHOD__ . "File already exists; importing as $archiveName\n" );
}
}
wfDebug( __METHOD__ . "File already exists; importing as $archiveName\n" );
}
}
wfDebug( __METHOD__ . ': Bad file for ' . $this->getTitle() . "\n" );
return false;
}
wfDebug( __METHOD__ . ': Bad file for ' . $this->getTitle() . "\n" );
return false;
}
$source = $this->downloadSource();
$flags |= File::DELETE_SOURCE;
}
$source = $this->downloadSource();
$flags |= File::DELETE_SOURCE;
}
wfDebug( __METHOD__ . ": Could not fetch remote file.\n" );
return false;
}
wfDebug( __METHOD__ . ": Could not fetch remote file.\n" );
return false;
}
*/
function downloadSource() {
global $wgEnableUploads;
*/
function downloadSource() {
global $wgEnableUploads;
- if( !$wgEnableUploads ) {
+ if ( !$wgEnableUploads ) {
return false;
}
$tempo = tempnam( wfTempDir(), 'download' );
$f = fopen( $tempo, 'wb' );
return false;
}
$tempo = tempnam( wfTempDir(), 'download' );
$f = fopen( $tempo, 'wb' );
wfDebug( "IMPORT: couldn't write to temp file $tempo\n" );
return false;
}
wfDebug( "IMPORT: couldn't write to temp file $tempo\n" );
return false;
}
// @todo FIXME!
$src = $this->getSrc();
$data = Http::get( $src );
// @todo FIXME!
$src = $this->getSrc();
$data = Http::get( $src );
wfDebug( "IMPORT: couldn't fetch source $src\n" );
fclose( $f );
unlink( $tempo );
wfDebug( "IMPORT: couldn't fetch source $src\n" );
fclose( $f );
unlink( $tempo );
* @return bool|string
*/
function readChunk() {
* @return bool|string
*/
function readChunk() {
+ if ( $this->atEnd() ) {
return false;
}
$this->mRead = true;
return false;
}
$this->mRead = true;
wfSuppressWarnings();
$file = fopen( $filename, 'rt' );
wfRestoreWarnings();
wfSuppressWarnings();
$file = fopen( $filename, 'rt' );
wfRestoreWarnings();
return Status::newFatal( "importcantopen" );
}
return Status::newGood( new ImportStreamSource( $file ) );
return Status::newFatal( "importcantopen" );
}
return Status::newGood( new ImportStreamSource( $file ) );
static function newFromUpload( $fieldname = "xmlimport" ) {
$upload =& $_FILES[$fieldname];
static function newFromUpload( $fieldname = "xmlimport" ) {
$upload =& $_FILES[$fieldname];
- if( $upload === null || !$upload['name'] ) {
+ if ( $upload === null || !$upload['name'] ) {
return Status::newFatal( 'importnofile' );
}
return Status::newFatal( 'importnofile' );
}
- if( !empty( $upload['error'] ) ) {
+ if ( !empty( $upload['error'] ) ) {
switch( $upload['error'] ) {
case 1: # The uploaded file exceeds the upload_max_filesize directive in php.ini.
return Status::newFatal( 'importuploaderrorsize' );
switch( $upload['error'] ) {
case 1: # The uploaded file exceeds the upload_max_filesize directive in php.ini.
return Status::newFatal( 'importuploaderrorsize' );
}
$fname = $upload['tmp_name'];
}
$fname = $upload['tmp_name'];
- if( is_uploaded_file( $fname ) ) {
+ if ( is_uploaded_file( $fname ) ) {
return ImportStreamSource::newFromFile( $fname );
} else {
return Status::newFatal( 'importnofile' );
return ImportStreamSource::newFromFile( $fname );
} else {
return Status::newFatal( 'importnofile' );
# otherwise prevent importing from large sites, such
# as the Wikimedia cluster, etc.
$data = Http::request( $method, $url, array( 'followRedirects' => true ) );
# otherwise prevent importing from large sites, such
# as the Wikimedia cluster, etc.
$data = Http::request( $method, $url, array( 'followRedirects' => true ) );
- if( $data !== false ) {
+ if ( $data !== false ) {
$file = tmpfile();
fwrite( $file, $data );
fflush( $file );
$file = tmpfile();
fwrite( $file, $data );
fflush( $file );
* @return Status
*/
public static function newFromInterwiki( $interwiki, $page, $history = false, $templates = false, $pageLinkDepth = 0 ) {
* @return Status
*/
public static function newFromInterwiki( $interwiki, $page, $history = false, $templates = false, $pageLinkDepth = 0 ) {
return Status::newFatal( 'import-noarticle' );
}
$link = Title::newFromText( "$interwiki:Special:Export/$page" );
return Status::newFatal( 'import-noarticle' );
}
$link = Title::newFromText( "$interwiki:Special:Export/$page" );
- if( is_null( $link ) || $link->getInterwiki() == '' ) {
+ if ( is_null( $link ) || $link->getInterwiki() == '' ) {
return Status::newFatal( 'importbadinterwiki' );
} else {
$params = array();
return Status::newFatal( 'importbadinterwiki' );
} else {
$params = array();
- if ( $history ) $params['history'] = 1;
- if ( $templates ) $params['templates'] = 1;
- if ( $pageLinkDepth ) $params['pagelink-depth'] = $pageLinkDepth;
+ if ( $history ) {
+ $params['history'] = 1;
+ }
+ if ( $templates ) {
+ $params['templates'] = 1;
+ }
+ if ( $pageLinkDepth ) {
+ $params['pagelink-depth'] = $pageLinkDepth;
+ }
$url = $link->getFullURL( $params );
# For interwikis, use POST to avoid redirects.
return ImportStreamSource::newFromURL( $url, "POST" );
$url = $link->getFullURL( $params );
# For interwikis, use POST to avoid redirects.
return ImportStreamSource::newFromURL( $url, "POST" );
protected function stackItem( &$list, $path, $item ) {
$position =& $list;
if ( $path ) {
protected function stackItem( &$list, $path, $item ) {
$position =& $list;
if ( $path ) {
- foreach( $path as $key ) {
+ foreach ( $path as $key ) {
$position =& $position[$key];
}
}
$position =& $position[$key];
}
}
* @return array filtered array
*/
public static function keepOneWildcard( $arr ) {
* @return array filtered array
*/
public static function keepOneWildcard( $arr ) {
- if( !is_array( $arr ) ) {
+ if ( !is_array( $arr ) ) {
- foreach( $arr as $key => $value ) {
+ foreach ( $arr as $key => $value ) {
if ( $value instanceof LikeMatch ) {
return array_slice( $arr, 0, $key + 1 );
}
if ( $value instanceof LikeMatch ) {
return array_slice( $arr, 0, $key + 1 );
}
return "<!-- ERROR -->$html";
}
return "<!-- ERROR -->$html";
}
- if( is_string( $query ) ) {
+ if ( is_string( $query ) ) {
// some functions withing core using this still hand over query strings
wfDeprecated( __METHOD__ . ' with parameter $query as string (should be array)', '1.20' );
$query = wfCgiToArray( $query );
// some functions withing core using this still hand over query strings
wfDeprecated( __METHOD__ . ' with parameter $query as string (should be array)', '1.20' );
$query = wfCgiToArray( $query );
# If a thumbnail width has not been provided, it is set
# to the default user option as specified in Language*.php
if ( $fp['align'] == '' ) {
# If a thumbnail width has not been provided, it is set
# to the default user option as specified in Language*.php
if ( $fp['align'] == '' ) {
- if( $parser instanceof Parser ) {
+ if ( $parser instanceof Parser ) {
$fp['align'] = $parser->getTargetLanguage()->alignEnd();
} else {
# backwards compatibility, remove with makeImageLink2()
$fp['align'] = $parser->getTargetLanguage()->alignEnd();
} else {
# backwards compatibility, remove with makeImageLink2()
$hp =& $handlerParams;
$page = isset( $hp['page'] ) ? $hp['page'] : false;
$hp =& $handlerParams;
$page = isset( $hp['page'] ) ? $hp['page'] : false;
- if ( !isset( $fp['align'] ) ) $fp['align'] = 'right';
- if ( !isset( $fp['alt'] ) ) $fp['alt'] = '';
- if ( !isset( $fp['title'] ) ) $fp['title'] = '';
- if ( !isset( $fp['caption'] ) ) $fp['caption'] = '';
+ if ( !isset( $fp['align'] ) ) {
+ $fp['align'] = 'right';
+ }
+ if ( !isset( $fp['alt'] ) ) {
+ $fp['alt'] = '';
+ }
+ if ( !isset( $fp['title'] ) ) {
+ $fp['title'] = '';
+ }
+ if ( !isset( $fp['caption'] ) ) {
+ $fp['caption'] = '';
+ }
if ( empty( $hp['width'] ) ) {
// Reduce width for upright images when parameter 'upright' is used
if ( empty( $hp['width'] ) ) {
// Reduce width for upright images when parameter 'upright' is used
protected static function getUploadUrl( $destFile, $query = '' ) {
global $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
$q = 'wpDestFile=' . $destFile->getPartialURL();
protected static function getUploadUrl( $destFile, $query = '' ) {
global $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
$q = 'wpDestFile=' . $destFile->getPartialURL();
if ( $wgUploadMissingFileUrl ) {
return wfAppendQuery( $wgUploadMissingFileUrl, $q );
if ( $wgUploadMissingFileUrl ) {
return wfAppendQuery( $wgUploadMissingFileUrl, $q );
- } elseif( $wgUploadNavigationUrl ) {
+ } elseif ( $wgUploadNavigationUrl ) {
return wfAppendQuery( $wgUploadNavigationUrl, $q );
} else {
$upload = SpecialPage::getTitleFor( 'Upload' );
return wfAppendQuery( $wgUploadNavigationUrl, $q );
} else {
$upload = SpecialPage::getTitleFor( 'Upload' );
$trail = "";
}
$linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
$trail = "";
}
$linkRegexp = '/\[\[(.*?)\]\]' . preg_quote( $trail, '/' ) . '/';
- if ( isset( $match[1][0] ) && $match[1][0] == ':' )
+ if ( isset( $match[1][0] ) && $match[1][0] == ':' ) {
$match[1] = substr( $match[1], 1 );
$match[1] = substr( $match[1], 1 );
list( $inside, $trail ) = self::splitTrail( $trail );
$linkText = $text;
list( $inside, $trail ) = self::splitTrail( $trail );
$linkText = $text;
$toc = '';
$lastLevel = 0;
foreach ( $tree as $section ) {
$toc = '';
$lastLevel = 0;
foreach ( $tree as $section ) {
- if ( $section['toclevel'] > $lastLevel )
+ if ( $section['toclevel'] > $lastLevel ) {
$toc .= self::tocIndent();
$toc .= self::tocIndent();
- elseif ( $section['toclevel'] < $lastLevel )
+ } elseif ( $section['toclevel'] < $lastLevel ) {
$toc .= self::tocUnindent(
$lastLevel - $section['toclevel'] );
$toc .= self::tocUnindent(
$lastLevel - $section['toclevel'] );
$toc .= self::tocLineEnd();
$toc .= self::tocLineEnd();
$toc .= self::tocLine( $section['anchor'],
$section['line'], $section['number'],
$toc .= self::tocLine( $section['anchor'],
$section['line'], $section['number'],
}
$disableRollbackEditCount = false;
}
$disableRollbackEditCount = false;
- if( $wgMiserMode ) {
- foreach( $disableRollbackEditCountSpecialPage as $specialPage ) {
- if( $context->getTitle()->isSpecial( $specialPage ) ) {
+ if ( $wgMiserMode ) {
+ foreach ( $disableRollbackEditCountSpecialPage as $specialPage ) {
+ if ( $context->getTitle()->isSpecial( $specialPage ) ) {
$disableRollbackEditCount = true;
break;
}
}
}
$disableRollbackEditCount = true;
break;
}
}
}
- if( !$disableRollbackEditCount && is_int( $wgShowRollbackEditCount ) && $wgShowRollbackEditCount > 0 ) {
+ if ( !$disableRollbackEditCount && is_int( $wgShowRollbackEditCount ) && $wgShowRollbackEditCount > 0 ) {
if ( !is_numeric( $editCount ) ) {
$editCount = self::getRollbackEditCount( $rev, false );
}
if ( !is_numeric( $editCount ) ) {
$editCount = self::getRollbackEditCount( $rev, false );
}
- if( $editCount > $wgShowRollbackEditCount ) {
+ if ( $editCount > $wgShowRollbackEditCount ) {
$editCount_output = $context->msg( 'rollbacklinkcount-morethan' )->numParams( $wgShowRollbackEditCount )->parse();
} else {
$editCount_output = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse();
$editCount_output = $context->msg( 'rollbacklinkcount-morethan' )->numParams( $wgShowRollbackEditCount )->parse();
} else {
$editCount_output = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse();
*/
private function getLinkInsertions( $existing = array() ) {
$arr = array();
*/
private function getLinkInsertions( $existing = array() ) {
$arr = array();
- foreach( $this->mLinks as $ns => $dbkeys ) {
+ foreach ( $this->mLinks as $ns => $dbkeys ) {
$diffs = isset( $existing[$ns] )
? array_diff_key( $dbkeys, $existing[$ns] )
: $dbkeys;
$diffs = isset( $existing[$ns] )
? array_diff_key( $dbkeys, $existing[$ns] )
: $dbkeys;
*/
private function getTemplateInsertions( $existing = array() ) {
$arr = array();
*/
private function getTemplateInsertions( $existing = array() ) {
$arr = array();
- foreach( $this->mTemplates as $ns => $dbkeys ) {
+ foreach ( $this->mTemplates as $ns => $dbkeys ) {
$diffs = isset( $existing[$ns] ) ? array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys;
foreach ( $diffs as $dbk => $id ) {
$arr[] = array(
$diffs = isset( $existing[$ns] ) ? array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys;
foreach ( $diffs as $dbk => $id ) {
$arr[] = array(
private function getImageInsertions( $existing = array() ) {
$arr = array();
$diffs = array_diff_key( $this->mImages, $existing );
private function getImageInsertions( $existing = array() ) {
$arr = array();
$diffs = array_diff_key( $this->mImages, $existing );
- foreach( $diffs as $iname => $dummy ) {
+ foreach ( $diffs as $iname => $dummy ) {
$arr[] = array(
'il_from' => $this->mId,
'il_to' => $iname
$arr[] = array(
'il_from' => $this->mId,
'il_to' => $iname
private function getExternalInsertions( $existing = array() ) {
$arr = array();
$diffs = array_diff_key( $this->mExternals, $existing );
private function getExternalInsertions( $existing = array() ) {
$arr = array();
$diffs = array_diff_key( $this->mExternals, $existing );
- foreach( $diffs as $url => $dummy ) {
- foreach( wfMakeUrlIndexes( $url ) as $index ) {
+ foreach ( $diffs as $url => $dummy ) {
+ foreach ( wfMakeUrlIndexes( $url ) as $index ) {
$arr[] = array(
'el_from' => $this->mId,
'el_to' => $url,
$arr[] = array(
'el_from' => $this->mId,
'el_to' => $url,
private function getInterlangInsertions( $existing = array() ) {
$diffs = array_diff_assoc( $this->mInterlangs, $existing );
$arr = array();
private function getInterlangInsertions( $existing = array() ) {
$diffs = array_diff_assoc( $this->mInterlangs, $existing );
$arr = array();
- foreach( $diffs as $lang => $title ) {
+ foreach ( $diffs as $lang => $title ) {
$arr[] = array(
'll_from' => $this->mId,
'll_lang' => $lang,
$arr[] = array(
'll_from' => $this->mId,
'll_lang' => $lang,
*/
private function getInterwikiInsertions( $existing = array() ) {
$arr = array();
*/
private function getInterwikiInsertions( $existing = array() ) {
$arr = array();
- foreach( $this->mInterwikis as $prefix => $dbkeys ) {
+ foreach ( $this->mInterwikis as $prefix => $dbkeys ) {
$diffs = isset( $existing[$prefix] ) ? array_diff_key( $dbkeys, $existing[$prefix] ) : $dbkeys;
foreach ( $diffs as $dbk => $id ) {
$arr[] = array(
$diffs = isset( $existing[$prefix] ) ? array_diff_key( $dbkeys, $existing[$prefix] ) : $dbkeys;
foreach ( $diffs as $dbk => $id ) {
$arr[] = array(
* @throws MWException
*/
protected static function cleanCallback( $callback ) {
* @throws MWException
*/
protected static function cleanCallback( $callback ) {
- if( is_string( $callback ) ) {
+ if ( is_string( $callback ) ) {
if ( strpos( $callback, '::' ) !== false ) {
// PHP 5.1 cannot use call_user_func( 'Class::Method' )
// It can only handle only call_user_func( array( 'Class', 'Method' ) )
if ( strpos( $callback, '::' ) !== false ) {
// PHP 5.1 cannot use call_user_func( 'Class::Method' )
// It can only handle only call_user_func( array( 'Class', 'Method' ) )
- if( count( $callback ) == 2 && $callback[0] == 'self' || $callback[0] == 'parent' ) {
+ if ( count( $callback ) == 2 && $callback[0] == 'self' || $callback[0] == 'parent' ) {
throw new MWException( 'MWFunction cannot call self::method() or parent::method()' );
}
throw new MWException( 'MWFunction cannot call self::method() or parent::method()' );
}
* @return object
*/
public static function newObj( $class, $args = array() ) {
* @return object
*/
public static function newObj( $class, $args = array() ) {
- if( !count( $args ) ) {
+ if ( !count( $args ) ) {
usort( $synonyms, array( $this, 'compareStringLength' ) );
$escSyn = array();
usort( $synonyms, array( $this, 'compareStringLength' ) );
$escSyn = array();
- foreach ( $synonyms as $synonym )
+ foreach ( $synonyms as $synonym ) {
// In case a magic word contains /, like that's going to happen;)
$escSyn[] = preg_quote( $synonym, '/' );
// In case a magic word contains /, like that's going to happen;)
$escSyn[] = preg_quote( $synonym, '/' );
$this->mBaseRegex = implode( '|', $escSyn );
$case = $this->mCaseSensitive ? '' : 'iu';
$this->mBaseRegex = implode( '|', $escSyn );
$case = $this->mCaseSensitive ? '' : 'iu';
* @return string
*/
function getRegexCase() {
* @return string
*/
function getRegexCase() {
- if ( $this->mRegex === '' )
+ if ( $this->mRegex === '' ) {
return $this->mCaseSensitive ? '' : 'iu';
}
return $this->mCaseSensitive ? '' : 'iu';
}
function replaceMultiple( $magicarr, $subject, &$result ) {
$search = array();
$replace = array();
function replaceMultiple( $magicarr, $subject, &$result ) {
$search = array();
$replace = array();
- foreach( $magicarr as $id => $replacement ) {
+ foreach ( $magicarr as $id => $replacement ) {
$mw = MagicWord::get( $id );
$search[] = $mw->getRegex();
$replace[] = $replacement;
$mw = MagicWord::get( $id );
$search[] = $mw->getRegex();
$replace[] = $replacement;
if ( isset( $params[0] ) && is_array( $params[0] ) ) {
$params = $params[0];
}
if ( isset( $params[0] ) && is_array( $params[0] ) ) {
$params = $params[0];
}
- foreach( $params as $param ) {
+ foreach ( $params as $param ) {
$this->parameters[] = self::rawParam( $param );
}
return $this;
$this->parameters[] = self::rawParam( $param );
}
return $this;
if ( isset( $params[0] ) && is_array( $params[0] ) ) {
$params = $params[0];
}
if ( isset( $params[0] ) && is_array( $params[0] ) ) {
$params = $params[0];
}
- foreach( $params as $param ) {
+ foreach ( $params as $param ) {
$this->parameters[] = self::numParam( $param );
}
return $this;
$this->parameters[] = self::numParam( $param );
}
return $this;
if ( $lang instanceof Language || $lang instanceof StubUserLang ) {
$this->language = $lang;
} elseif ( is_string( $lang ) ) {
if ( $lang instanceof Language || $lang instanceof StubUserLang ) {
$this->language = $lang;
} elseif ( is_string( $lang ) ) {
- if( $this->language->getCode() != $lang ) {
+ if ( $this->language->getCode() != $lang ) {
$this->language = Language::factory( $lang );
}
} else {
$this->language = Language::factory( $lang );
}
} else {
$string = $this->replaceParameters( $string, 'before' );
# Maybe transform using the full parser
$string = $this->replaceParameters( $string, 'before' );
# Maybe transform using the full parser
- if( $this->format === 'parse' ) {
+ if ( $this->format === 'parse' ) {
$string = $this->parseText( $string );
$m = array();
$string = $this->parseText( $string );
$m = array();
- if( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $string, $m ) ) {
+ if ( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $string, $m ) ) {
- } elseif( $this->format === 'block-parse' ) {
+ } elseif ( $this->format === 'block-parse' ) {
$string = $this->parseText( $string );
$string = $this->parseText( $string );
- } elseif( $this->format === 'text' ) {
+ } elseif ( $this->format === 'text' ) {
$string = $this->transformText( $string );
$string = $this->transformText( $string );
- } elseif( $this->format === 'escaped' ) {
+ } elseif ( $this->format === 'escaped' ) {
$string = $this->transformText( $string );
$string = htmlspecialchars( $string, ENT_QUOTES, 'UTF-8', false );
}
$string = $this->transformText( $string );
$string = htmlspecialchars( $string, ENT_QUOTES, 'UTF-8', false );
}
*/
protected function replaceParameters( $message, $type = 'before' ) {
$replacementKeys = array();
*/
protected function replaceParameters( $message, $type = 'before' ) {
$replacementKeys = array();
- foreach( $this->parameters as $n => $param ) {
+ foreach ( $this->parameters as $n => $param ) {
list( $paramType, $value ) = $this->extractParam( $param );
if ( $type === $paramType ) {
$replacementKeys['$' . ($n + 1)] = $value;
list( $paramType, $value ) = $this->extractParam( $param );
if ( $type === $paramType ) {
$replacementKeys['$' . ($n + 1)] = $value;
*/
public function fetchMessage() {
// Just in case the message is unset somewhere.
*/
public function fetchMessage() {
// Just in case the message is unset somewhere.
- if( !isset( $this->message ) ) {
+ if ( !isset( $this->message ) ) {
$this->message = $this->key;
}
return $this->message;
$this->message = $this->key;
}
return $this->message;
$httpaccept = isset( $_SERVER['HTTP_ACCEPT'] ) ? $_SERVER['HTTP_ACCEPT'] : null;
$rdftype = wfNegotiateType( wfAcceptToPrefs( $httpaccept ), wfAcceptToPrefs( self::RDF_TYPE_PREFS ) );
$httpaccept = isset( $_SERVER['HTTP_ACCEPT'] ) ? $_SERVER['HTTP_ACCEPT'] : null;
$rdftype = wfNegotiateType( wfAcceptToPrefs( $httpaccept ), wfAcceptToPrefs( self::RDF_TYPE_PREFS ) );
throw new HttpError( 406, wfMessage( 'notacceptable' ) );
}
throw new HttpError( 406, wfMessage( 'notacceptable' ) );
}
$lastEditor = User::newFromId( $this->mArticle->getUser() );
$this->person( 'creator', $lastEditor );
$lastEditor = User::newFromId( $this->mArticle->getUser() );
$this->person( 'creator', $lastEditor );
- foreach( $this->mArticle->getContributors() as $user ) {
+ foreach ( $this->mArticle->getContributors() as $user ) {
$this->person( 'contributor', $user );
}
$this->person( 'contributor', $user );
}
}
protected function pageOrString( $name, $page, $str ) {
}
protected function pageOrString( $name, $page, $str ) {
- if( $page instanceof Title ) {
+ if ( $page instanceof Title ) {
$nt = $page;
} else {
$nt = Title::newFromText( $page );
}
$nt = $page;
} else {
$nt = Title::newFromText( $page );
}
- if( !$nt || $nt->getArticleID() == 0 ) {
+ if ( !$nt || $nt->getArticleID() == 0 ) {
$this->element( $name, $str );
} else {
$this->page( $name, $nt );
$this->element( $name, $str );
} else {
$this->page( $name, $nt );
}
protected function person( $name, User $user ) {
}
protected function person( $name, User $user ) {
- if( $user->isAnon() ) {
+ if ( $user->isAnon() ) {
$this->element( $name, wfMessage( 'anonymous' )->numParams( 1 )->text() );
} else {
$real = $user->getRealName();
$this->element( $name, wfMessage( 'anonymous' )->numParams( 1 )->text() );
} else {
$real = $user->getRealName();
$this->element( $name, $real );
} else {
$userName = $user->getName();
$this->element( $name, $real );
} else {
$userName = $user->getName();
protected function rights() {
global $wgRightsPage, $wgRightsUrl, $wgRightsText;
protected function rights() {
global $wgRightsPage, $wgRightsUrl, $wgRightsText;
- if( $wgRightsPage && ( $nt = Title::newFromText( $wgRightsPage ) )
+ if ( $wgRightsPage && ( $nt = Title::newFromText( $wgRightsPage ) )
&& ( $nt->getArticleID() != 0 ) ) {
$this->page( 'rights', $nt );
&& ( $nt->getArticleID() != 0 ) ) {
$this->page( 'rights', $nt );
- } elseif( $wgRightsUrl ) {
+ } elseif ( $wgRightsUrl ) {
$this->url( 'rights', $wgRightsUrl );
$this->url( 'rights', $wgRightsUrl );
- } elseif( $wgRightsText ) {
+ } elseif ( $wgRightsText ) {
$this->element( 'rights', $wgRightsText );
}
}
$this->element( 'rights', $wgRightsText );
}
}
protected function getTerms( $url ) {
global $wgLicenseTerms;
protected function getTerms( $url ) {
global $wgLicenseTerms;
- if( $wgLicenseTerms ) {
+ if ( $wgLicenseTerms ) {
return $wgLicenseTerms;
} else {
$known = $this->getKnownLicenses();
return $wgLicenseTerms;
} else {
$known = $this->getKnownLicenses();
- if( isset( $known[$url] ) ) {
+ if ( isset( $known[$url] ) ) {
return $known[$url];
} else {
return array();
return $known[$url];
} else {
return array();
foreach ( $ccVersions as $version ) {
foreach ( $ccLicenses as $license ) {
foreach ( $ccVersions as $version ) {
foreach ( $ccLicenses as $license ) {
- if( $version == '2.0' && substr( $license, 0, 2 ) != 'by' ) {
+ if ( $version == '2.0' && substr( $license, 0, 2 ) != 'by' ) {
# 2.0 dropped the non-attribs licenses
continue;
}
# 2.0 dropped the non-attribs licenses
continue;
}
* appending MM_WELL_KNOWN_MIME_TYPES behind $wgMimeTypeFile, but who knows
* what will break? In practice this probably isn't a problem anyway -- Bryan)
*/
* appending MM_WELL_KNOWN_MIME_TYPES behind $wgMimeTypeFile, but who knows
* what will break? In practice this probably isn't a problem anyway -- Bryan)
*/
-define('MM_WELL_KNOWN_MIME_TYPES', <<<END_STRING
+define( 'MM_WELL_KNOWN_MIME_TYPES', <<<END_STRING
application/ogg ogx ogg ogm ogv oga spx
application/pdf pdf
application/vnd.oasis.opendocument.chart odc
application/ogg ogx ogg ogm ogv oga spx
application/pdf pdf
application/vnd.oasis.opendocument.chart odc
* An extensive list of well known mime types is provided by
* the file mime.info in the includes directory.
*/
* An extensive list of well known mime types is provided by
* the file mime.info in the includes directory.
*/
-define('MM_WELL_KNOWN_MIME_INFO', <<<END_STRING
+define( 'MM_WELL_KNOWN_MIME_INFO', <<<END_STRING
application/pdf [OFFICE]
application/vnd.oasis.opendocument.chart [OFFICE]
application/vnd.oasis.opendocument.chart-template [OFFICE]
application/pdf [OFFICE]
application/vnd.oasis.opendocument.chart [OFFICE]
application/vnd.oasis.opendocument.chart-template [OFFICE]
$mime = $this->doGuessMimeType( $file, $ext );
$mime = $this->doGuessMimeType( $file, $ext );
wfDebug( __METHOD__ . ": internal type detection failed for $file (.$ext)...\n" );
$mime = $this->detectMimeType( $file, $ext );
}
wfDebug( __METHOD__ . ": internal type detection failed for $file (.$ext)...\n" );
$mime = $this->detectMimeType( $file, $ext );
}
$f = fopen( $file, 'rt' );
wfRestoreWarnings();
$f = fopen( $file, 'rt' );
wfRestoreWarnings();
return 'unknown/unknown';
}
$head = fread( $f, 1024 );
return 'unknown/unknown';
}
$head = fread( $f, 1024 );
$pack = array( 'UTF-16BE' => 'n*', 'UTF-16LE' => 'v*' );
$chars = unpack( $pack[$script_type], substr( $head, 2 ) );
$head = '';
$pack = array( 'UTF-16BE' => 'n*', 'UTF-16LE' => 'v*' );
$chars = unpack( $pack[$script_type], substr( $head, 2 ) );
$head = '';
- foreach( $chars as $codepoint ) {
- if( $codepoint < 128 ) {
+ foreach ( $chars as $codepoint ) {
+ if ( $codepoint < 128 ) {
$head .= chr( $codepoint );
} else {
$head .= '?';
$head .= chr( $codepoint );
} else {
$head .= '?';
$gis = getimagesize( $file );
wfRestoreWarnings();
$gis = getimagesize( $file );
wfRestoreWarnings();
- if( $gis && isset( $gis['mime'] ) ) {
+ if ( $gis && isset( $gis['mime'] ) ) {
$mime = $gis['mime'];
wfDebug( __METHOD__ . ": getimagesize detected $file as $mime\n" );
return $mime;
$mime = $gis['mime'];
wfDebug( __METHOD__ . ": getimagesize detected $file as $mime\n" );
return $mime;
// Also test DjVu
$deja = new DjVuImage( $file );
// Also test DjVu
$deja = new DjVuImage( $file );
- if( $deja->isValid() ) {
+ if ( $deja->isValid() ) {
wfDebug( __METHOD__ . ": detected $file as image/vnd.djvu\n" );
return 'image/vnd.djvu';
}
wfDebug( __METHOD__ . ": detected $file as image/vnd.djvu\n" );
return 'image/vnd.djvu';
}
* @return string
*/
function detectZipType( $header, $tail = null, $ext = false ) {
* @return string
*/
function detectZipType( $header, $tail = null, $ext = false ) {
- if( $ext ) { # TODO: remove $ext param
+ if ( $ext ) { # TODO: remove $ext param
wfDebug( __METHOD__ . ": WARNING: use of the \$ext parameter is deprecated. " .
"Use improveTypeFromExtension(\$mime, \$ext) instead.\n" );
}
wfDebug( __METHOD__ . ": WARNING: use of the \$ext parameter is deprecated. " .
"Use improveTypeFromExtension(\$mime, \$ext) instead.\n" );
}
$ext = strtolower( $i ? substr( $file, $i + 1 ) : '' );
}
if ( $ext ) {
$ext = strtolower( $i ? substr( $file, $i + 1 ) : '' );
}
if ( $ext ) {
- if( $this->isRecognizableExtension( $ext ) ) {
+ if ( $this->isRecognizableExtension( $ext ) ) {
wfDebug( __METHOD__ . ": refusing to guess mime type for .$ext file, we should have recognized it\n" );
} else {
$m = $this->guessTypesForExtension( $ext );
wfDebug( __METHOD__ . ": refusing to guess mime type for .$ext file, we should have recognized it\n" );
} else {
$m = $this->guessTypesForExtension( $ext );
* @return (int?string?) a value to be used with the MEDIATYPE_xxx constants.
*/
function getMediaType( $path = null, $mime = null ) {
* @return (int?string?) a value to be used with the MEDIATYPE_xxx constants.
*/
function getMediaType( $path = null, $mime = null ) {
- if( !$mime && !$path ) {
+ if ( !$mime && !$path ) {
return MEDIATYPE_UNKNOWN;
}
// If mime type is unknown, guess it
return MEDIATYPE_UNKNOWN;
}
// If mime type is unknown, guess it
$mime = $this->guessMimeType( $path, false );
}
$mime = $this->guessMimeType( $path, false );
}
// Read a chunk of the file
$f = fopen( $path, "rt" );
// Read a chunk of the file
$f = fopen( $path, "rt" );
- if ( !$f ) return MEDIATYPE_UNKNOWN;
+ if ( !$f ) {
+ return MEDIATYPE_UNKNOWN;
+ }
$head = fread( $f, 256 );
fclose( $f );
$head = strtolower( $head );
// This is an UGLY HACK, file should be parsed correctly
$head = fread( $f, 256 );
fclose( $f );
$head = strtolower( $head );
// This is an UGLY HACK, file should be parsed correctly
- if ( strpos( $head, 'theora' ) !== false ) return MEDIATYPE_VIDEO;
- elseif ( strpos( $head, 'vorbis' ) !== false ) return MEDIATYPE_AUDIO;
- elseif ( strpos( $head, 'flac' ) !== false ) return MEDIATYPE_AUDIO;
- elseif ( strpos( $head, 'speex' ) !== false ) return MEDIATYPE_AUDIO;
- else return MEDIATYPE_MULTIMEDIA;
+ if ( strpos( $head, 'theora' ) !== false ) {
+ return MEDIATYPE_VIDEO;
+ } elseif ( strpos( $head, 'vorbis' ) !== false ) {
+ return MEDIATYPE_AUDIO;
+ } elseif ( strpos( $head, 'flac' ) !== false ) {
+ return MEDIATYPE_AUDIO;
+ } elseif ( strpos( $head, 'speex' ) !== false ) {
+ return MEDIATYPE_AUDIO;
+ } else {
+ return MEDIATYPE_MULTIMEDIA;
+ }
}
// Check for entry for full mime type
}
// Check for entry for full mime type
$type = $this->findMediaType( $mime );
if ( $type !== MEDIATYPE_UNKNOWN ) {
return $type;
$type = $this->findMediaType( $mime );
if ( $type !== MEDIATYPE_UNKNOWN ) {
return $type;
$type = MEDIATYPE_UNKNOWN;
}
$type = MEDIATYPE_UNKNOWN;
}
*/
function wfRequestExtension() {
/// @todo FIXME: this sort of dupes some code in WebRequest::getRequestUrl()
*/
function wfRequestExtension() {
/// @todo FIXME: this sort of dupes some code in WebRequest::getRequestUrl()
- if( isset( $_SERVER['REQUEST_URI'] ) ) {
+ if ( isset( $_SERVER['REQUEST_URI'] ) ) {
// Strip the query string...
list( $path ) = explode( '?', $_SERVER['REQUEST_URI'], 2 );
// Strip the query string...
list( $path ) = explode( '?', $_SERVER['REQUEST_URI'], 2 );
- } elseif( isset( $_SERVER['SCRIPT_NAME'] ) ) {
+ } elseif ( isset( $_SERVER['SCRIPT_NAME'] ) ) {
// Probably IIS. QUERY_STRING appears separately.
$path = $_SERVER['SCRIPT_NAME'];
} else {
// Probably IIS. QUERY_STRING appears separately.
$path = $_SERVER['SCRIPT_NAME'];
} else {
}
$period = strrpos( $path, '.' );
}
$period = strrpos( $path, '.' );
- if( $period !== false ) {
+ if ( $period !== false ) {
return strtolower( substr( $path, $period ) );
}
return '';
return strtolower( substr( $path, $period ) );
}
return '';
* @return string
*/
function wfGzipHandler( $s ) {
* @return string
*/
function wfGzipHandler( $s ) {
- if( !function_exists( 'gzencode' ) ) {
+ if ( !function_exists( 'gzencode' ) ) {
wfDebug( __FUNCTION__ . "() skipping compression (gzencode unavailable)\n" );
return $s;
}
wfDebug( __FUNCTION__ . "() skipping compression (gzencode unavailable)\n" );
return $s;
}
+ if ( headers_sent() ) {
wfDebug( __FUNCTION__ . "() skipping compression (headers already sent)\n" );
return $s;
}
$ext = wfRequestExtension();
wfDebug( __FUNCTION__ . "() skipping compression (headers already sent)\n" );
return $s;
}
$ext = wfRequestExtension();
- if( $ext == '.gz' || $ext == '.tgz' ) {
+ if ( $ext == '.gz' || $ext == '.tgz' ) {
// Don't do gzip compression if the URL path ends in .gz or .tgz
// This confuses Safari and triggers a download of the page,
// even though it's pretty clearly labeled as viewable HTML.
// Don't do gzip compression if the URL path ends in .gz or .tgz
// This confuses Safari and triggers a download of the page,
// even though it's pretty clearly labeled as viewable HTML.
- if( wfClientAcceptsGzip() ) {
+ if ( wfClientAcceptsGzip() ) {
wfDebug( __FUNCTION__ . "() is compressing output\n" );
header( 'Content-Encoding: gzip' );
$s = gzencode( $s, 6 );
wfDebug( __FUNCTION__ . "() is compressing output\n" );
header( 'Content-Encoding: gzip' );
$s = gzencode( $s, 6 );
$index = $this->getIndexField(); // column to sort on
$extraSort = $this->getExtraSortFields(); // extra columns to sort on for query planning
$order = $this->mRequest->getVal( 'order' );
$index = $this->getIndexField(); // column to sort on
$extraSort = $this->getExtraSortFields(); // extra columns to sort on for query planning
$order = $this->mRequest->getVal( 'order' );
- if( is_array( $index ) && isset( $index[$order] ) ) {
+ if ( is_array( $index ) && isset( $index[$order] ) ) {
$this->mOrderType = $order;
$this->mIndexField = $index[$order];
$this->mExtraSortFields = isset( $extraSort[$order] )
? (array)$extraSort[$order]
: array();
$this->mOrderType = $order;
$this->mIndexField = $index[$order];
$this->mExtraSortFields = isset( $extraSort[$order] )
? (array)$extraSort[$order]
: array();
- } elseif( is_array( $index ) ) {
+ } elseif ( is_array( $index ) ) {
# First element is the default
reset( $index );
list( $this->mOrderType, $this->mIndexField ) = each( $index );
# First element is the default
reset( $index );
list( $this->mOrderType, $this->mIndexField ) = each( $index );
$this->mExtraSortFields = (array)$extraSort;
}
$this->mExtraSortFields = (array)$extraSort;
}
- if( !isset( $this->mDefaultDirection ) ) {
+ if ( !isset( $this->mDefaultDirection ) ) {
$dir = $this->getDefaultDirections();
$this->mDefaultDirection = is_array( $dir )
? $dir[$this->mOrderType]
$dir = $this->getDefaultDirections();
$this->mDefaultDirection = is_array( $dir )
? $dir[$this->mOrderType]
- if( in_array( $type, array( 'first', 'prev', 'next', 'last' ) ) ) {
+ if ( in_array( $type, array( 'first', 'prev', 'next', 'last' ) ) ) {
# HTML5 rel attributes
$attrs['rel'] = $type;
}
# HTML5 rel attributes
$attrs['rel'] = $type;
}
$attrs['class'] = "mw-{$type}link";
}
$attrs['class'] = "mw-{$type}link";
}
- protected function getExtraSortFields() { return array(); }
+ protected function getExtraSortFields() {
+ return array();
+ }
/**
* Return the default sorting direction: false for ascending, true for
/**
* Return the default sorting direction: false for ascending, true for
- protected function getDefaultDirections() { return false; }
+ protected function getDefaultDirections() {
+ return false;
+ }
- if( isset( $this->mNavigationBar ) ) {
+ if ( isset( $this->mNavigationBar ) ) {
return $this->mNavigationBar;
}
return $this->mNavigationBar;
}
$this->msg( 'viewprevnext' )->rawParams( $pagingLinks['prev'],
$pagingLinks['next'], $limits )->escaped();
$this->msg( 'viewprevnext' )->rawParams( $pagingLinks['prev'],
$pagingLinks['next'], $limits )->escaped();
- if( !is_array( $this->getIndexField() ) ) {
+ if ( !is_array( $this->getIndexField() ) ) {
# Early return to avoid undue nesting
return $this->mNavigationBar;
}
# Early return to avoid undue nesting
return $this->mNavigationBar;
}
$extra = '';
$first = true;
$msgs = $this->getOrderTypeMessages();
$extra = '';
$first = true;
$msgs = $this->getOrderTypeMessages();
- foreach( array_keys( $msgs ) as $order ) {
- if( $first ) {
+ foreach ( array_keys( $msgs ) as $order ) {
+ if ( $first ) {
$first = false;
} else {
$extra .= $this->msg( 'pipe-separator' )->escaped();
}
$first = false;
} else {
$extra .= $this->msg( 'pipe-separator' )->escaped();
}
- if( $order == $this->mOrderType ) {
+ if ( $order == $this->mOrderType ) {
$extra .= $this->msg( $msgs[$order] )->escaped();
} else {
$extra .= $this->makeLink(
$extra .= $this->msg( $msgs[$order] )->escaped();
} else {
$extra .= $this->makeLink(
$extra = ' ' . $this->msg( 'parentheses' )->rawParams( $extra )->escaped();
$this->mNavigationBar .= $extra;
}
$extra = ' ' . $this->msg( 'parentheses' )->rawParams( $extra )->escaped();
$this->mNavigationBar .= $extra;
}
// If no year given, assume the current one
$year = gmdate( 'Y' );
// If this month hasn't happened yet this year, go back to last year's month
// If no year given, assume the current one
$year = gmdate( 'Y' );
// If this month hasn't happened yet this year, go back to last year's month
- if( $this->mMonth > gmdate( 'n' ) ) {
+ if ( $this->mMonth > gmdate( 'n' ) ) {
'next' => 'arrow_disabled_right_25.png',
'last' => 'arrow_disabled_last_25.png',
);
'next' => 'arrow_disabled_right_25.png',
'last' => 'arrow_disabled_last_25.png',
);
- if( $this->getLanguage()->isRTL() ) {
+ if ( $this->getLanguage()->isRTL() ) {
$keys = array_keys( $labels );
$images = array_combine( $keys, array_reverse( $images ) );
$disabledImages = array_combine( $keys, array_reverse( $disabledImages ) );
$keys = array_keys( $labels );
$images = array_combine( $keys, array_reverse( $images ) );
$disabledImages = array_combine( $keys, array_reverse( $disabledImages ) );
# The pair is either $index => $limit, in which case the $value
# will be numeric, or $limit => $text, in which case the $value
# will be a string.
# The pair is either $index => $limit, in which case the $value
# will be numeric, or $limit => $text, in which case the $value
# will be a string.
- if( is_int( $value ) ) {
+ if ( is_int( $value ) ) {
$limit = $value;
$text = $this->getLanguage()->formatNum( $limit );
} else {
$limit = $value;
$text = $this->getLanguage()->formatNum( $limit );
} else {
}
$pattern = (object)array(
}
$pattern = (object)array(
- 'path' => $path,
- 'params' => $params,
+ 'path' => $path,
+ 'params' => $params,
);
$pattern->weight = self::makeWeight( $pattern );
$this->patterns[] = $pattern;
);
$pattern->weight = self::makeWeight( $pattern );
$this->patterns[] = $pattern;
*/
protected function sortByWeight() {
$weights = array();
*/
protected function sortByWeight() {
$weights = array();
- foreach( $this->patterns as $key => $pattern ) {
+ foreach ( $this->patterns as $key => $pattern ) {
$weights[$key] = $pattern->weight;
}
array_multisort( $weights, SORT_DESC, SORT_NUMERIC, $this->patterns );
$weights[$key] = $pattern->weight;
}
array_multisort( $weights, SORT_DESC, SORT_NUMERIC, $this->patterns );
$path = explode( '/', $pattern->path );
# For each level of the path
$path = explode( '/', $pattern->path );
# For each level of the path
- foreach( $path as $piece ) {
+ foreach ( $path as $piece ) {
if ( preg_match( '/^\$(\d+|key)$/u', $piece ) ) {
# For a piece that is only a $1 variable add 1 points of weight
$weight += 1;
if ( preg_match( '/^\$(\d+|key)$/u', $piece ) ) {
# For a piece that is only a $1 variable add 1 points of weight
$weight += 1;
? 'prefs-help-email-required'
: 'prefs-help-email';
? 'prefs-help-email-required'
: 'prefs-help-email';
- if( $wgEnableUserEmail ) {
+ if ( $wgEnableUserEmail ) {
// additional messages when users can send email to each other
$helpMessages[] = 'prefs-help-email-others';
}
// additional messages when users can send email to each other
$helpMessages[] = 'prefs-help-email-others';
}
$nsOptions = $wgContLang->getFormattedNamespaces();
$nsOptions[0] = $context->msg( 'blanknamespace' )->text();
foreach ( $nsOptions as $ns => $name ) {
$nsOptions = $wgContLang->getFormattedNamespaces();
$nsOptions[0] = $context->msg( 'blanknamespace' )->text();
foreach ( $nsOptions as $ns => $name ) {
unset( $nsOptions[$ns] );
unset( $nsOptions[$ns] );
}
$defaultPreferences['searchnamespaces'] = array(
}
$defaultPreferences['searchnamespaces'] = array(
$data[0] = intval( $data[0] );
$data[1] = intval( $data[1] );
$minDiff = abs( $data[0] ) * 60 + $data[1];
$data[0] = intval( $data[0] );
$data[1] = intval( $data[1] );
$minDiff = abs( $data[0] ) * 60 + $data[1];
- if ( $data[0] < 0 ) $minDiff = - $minDiff;
+ if ( $data[0] < 0 ) {
+ $minDiff = - $minDiff;
+ }
} else {
$minDiff = intval( $data[0] ) * 60;
}
} else {
$minDiff = intval( $data[0] ) * 60;
}
# via $wgHiddenPrefs, we don't want to destroy that setting in case the preference
# is subsequently re-enabled
# TODO: maintenance script to actually delete these
# via $wgHiddenPrefs, we don't want to destroy that setting in case the preference
# is subsequently re-enabled
# TODO: maintenance script to actually delete these
- foreach( $wgHiddenPrefs as $pref ) {
+ foreach ( $wgHiddenPrefs as $pref ) {
# If the user has not set a non-default value here, the default will be returned
# and subsequently discarded
$formData[$pref] = $user->getOption( $pref, null, true );
# If the user has not set a non-default value here, the default will be returned
# and subsequently discarded
$formData[$pref] = $user->getOption( $pref, null, true );
*/
public static function titleSearch( $search, $limit, $namespaces = array() ) {
$search = trim( $search );
*/
public static function titleSearch( $search, $limit, $namespaces = array() ) {
$search = trim( $search );
return array(); // Return empty result
}
$namespaces = self::validateNamespaces( $namespaces );
// Find a Title which is not an interwiki and is in NS_MAIN
$title = Title::newFromText( $search );
return array(); // Return empty result
}
$namespaces = self::validateNamespaces( $namespaces );
// Find a Title which is not an interwiki and is in NS_MAIN
$title = Title::newFromText( $search );
- if( $title && $title->getInterwiki() == '' ) {
+ if ( $title && $title->getInterwiki() == '' ) {
$ns = array( $title->getNamespace() );
$ns = array( $title->getNamespace() );
- if( $ns[0] == NS_MAIN ) {
+ if ( $ns[0] == NS_MAIN ) {
$ns = $namespaces; // no explicit prefix, use default namespaces
}
return self::searchBackend(
$ns = $namespaces; // no explicit prefix, use default namespaces
}
return self::searchBackend(
// Is this a namespace prefix?
$title = Title::newFromText( $search . 'Dummy' );
// Is this a namespace prefix?
$title = Title::newFromText( $search . 'Dummy' );
- if( $title && $title->getText() == 'Dummy'
+ if ( $title && $title->getText() == 'Dummy'
&& $title->getNamespace() != NS_MAIN
&& $title->getInterwiki() == '' ) {
return self::searchBackend(
&& $title->getNamespace() != NS_MAIN
&& $title->getInterwiki() == '' ) {
return self::searchBackend(
* @return Array of strings
*/
protected static function searchBackend( $namespaces, $search, $limit ) {
* @return Array of strings
*/
protected static function searchBackend( $namespaces, $search, $limit ) {
- if( count( $namespaces ) == 1 ) {
+ if ( count( $namespaces ) == 1 ) {
- if( $ns == NS_MEDIA ) {
+ if ( $ns == NS_MEDIA ) {
$namespaces = array( NS_FILE );
$namespaces = array( NS_FILE );
- } elseif( $ns == NS_SPECIAL ) {
+ } elseif ( $ns == NS_SPECIAL ) {
return self::specialSearch( $search, $limit );
}
}
$srchres = array();
return self::specialSearch( $search, $limit );
}
}
$srchres = array();
- if( wfRunHooks( 'PrefixSearchBackend', array( $namespaces, $search, $limit, &$srchres ) ) ) {
+ if ( wfRunHooks( 'PrefixSearchBackend', array( $namespaces, $search, $limit, &$srchres ) ) ) {
return self::defaultSearchBackend( $namespaces, $search, $limit );
}
return $srchres;
return self::defaultSearchBackend( $namespaces, $search, $limit );
}
return $srchres;
// Unlike SpecialPage itself, we want the canonical forms of both
// canonical and alias title forms...
$keys = array();
// Unlike SpecialPage itself, we want the canonical forms of both
// canonical and alias title forms...
$keys = array();
- foreach( SpecialPageFactory::getList() as $page => $class ) {
+ foreach ( SpecialPageFactory::getList() as $page => $class ) {
$keys[$wgContLang->caseFold( $page )] = $page;
}
$keys[$wgContLang->caseFold( $page )] = $page;
}
- foreach( $wgContLang->getSpecialPageAliases() as $page => $aliases ) {
- if( !array_key_exists( $page, SpecialPageFactory::getList() ) ) {# bug 20885
+ foreach ( $wgContLang->getSpecialPageAliases() as $page => $aliases ) {
+ if ( !array_key_exists( $page, SpecialPageFactory::getList() ) ) {# bug 20885
- foreach( $aliases as $alias ) {
+ foreach ( $aliases as $alias ) {
$keys[$wgContLang->caseFold( $alias )] = $alias;
}
}
ksort( $keys );
$srchres = array();
$keys[$wgContLang->caseFold( $alias )] = $alias;
}
}
ksort( $keys );
$srchres = array();
- foreach( $keys as $pageKey => $page ) {
- if( $searchKey === '' || strpos( $pageKey, $searchKey ) === 0 ) {
+ foreach ( $keys as $pageKey => $page ) {
+ if ( $searchKey === '' || strpos( $pageKey, $searchKey ) === 0 ) {
wfSuppressWarnings();
// bug 27671: Don't use SpecialPage::getTitleFor() here because it
// localizes its input leading to searches for e.g. Special:All
wfSuppressWarnings();
// bug 27671: Don't use SpecialPage::getTitleFor() here because it
// localizes its input leading to searches for e.g. Special:All
- if( count( $srchres ) >= $limit ) {
+ if ( count( $srchres ) >= $limit ) {
*/
protected static function defaultSearchBackend( $namespaces, $search, $limit ) {
$ns = array_shift( $namespaces ); // support only one namespace
*/
protected static function defaultSearchBackend( $namespaces, $search, $limit ) {
$ns = array_shift( $namespaces ); // support only one namespace
- if( in_array( NS_MAIN, $namespaces ) ) {
+ if ( in_array( NS_MAIN, $namespaces ) ) {
$ns = NS_MAIN; // if searching on many always default to main
}
$ns = NS_MAIN; // if searching on many always default to main
}
// We will look at each given namespace against wgContLang namespaces
$validNamespaces = $wgContLang->getNamespaces();
// We will look at each given namespace against wgContLang namespaces
$validNamespaces = $wgContLang->getNamespaces();
- if( is_array( $namespaces ) && count( $namespaces ) > 0 ) {
+ if ( is_array( $namespaces ) && count( $namespaces ) > 0 ) {
$valid = array();
foreach ( $namespaces as $ns ) {
$valid = array();
foreach ( $namespaces as $ns ) {
- if( is_numeric( $ns ) && array_key_exists( $ns, $validNamespaces ) ) {
+ if ( is_numeric( $ns ) && array_key_exists( $ns, $validNamespaces ) ) {
- if( count( $valid ) > 0 ) {
+ if ( count( $valid ) > 0 ) {
$this->mReasonSelection = $wgRequest->getText( 'wpProtectReasonSelection' );
$this->mCascade = $wgRequest->getBool( 'mwProtect-cascade', $this->mCascade );
$this->mReasonSelection = $wgRequest->getText( 'wpProtectReasonSelection' );
$this->mCascade = $wgRequest->getBool( 'mwProtect-cascade', $this->mCascade );
- foreach( $this->mApplicableTypes as $action ) {
+ foreach ( $this->mApplicableTypes as $action ) {
// @todo FIXME: This form currently requires individual selections,
// but the db allows multiples separated by commas.
// @todo FIXME: This form currently requires individual selections,
// but the db allows multiples separated by commas.
}
$val = $wgRequest->getVal( "mwProtect-level-$action" );
}
$val = $wgRequest->getVal( "mwProtect-level-$action" );
- if( isset( $val ) && in_array( $val, $wgRestrictionLevels ) ) {
+ if ( isset( $val ) && in_array( $val, $wgRestrictionLevels ) ) {
// Prevent users from setting levels that they cannot later unset
// Prevent users from setting levels that they cannot later unset
- if( $val == 'sysop' ) {
+ if ( $val == 'sysop' ) {
// Special case, rewrite sysop to either protect and editprotected
// Special case, rewrite sysop to either protect and editprotected
- if( !$wgUser->isAllowedAny( 'protect', 'editprotected' ) )
- continue;
- } else {
- if( !$wgUser->isAllowed( $val ) )
+ if ( !$wgUser->isAllowedAny( 'protect', 'editprotected' ) ) {
+ }
+ } elseif ( !$wgUser->isAllowed( $val ) ) {
+ continue;
}
$this->mRestrictions[$action] = $val;
}
}
$this->mRestrictions[$action] = $val;
}
throw new ErrorPageError( 'protect-badnamespace-title', 'protect-badnamespace-text' );
}
throw new ErrorPageError( 'protect-badnamespace-title', 'protect-badnamespace-text' );
}
- if( $wgRequest->wasPosted() ) {
- if( $this->save() ) {
+ if ( $wgRequest->wasPosted() ) {
+ if ( $this->save() ) {
$q = $this->mArticle->isRedirect() ? 'redirect=no' : '';
$wgOut->redirect( $this->mTitle->getFullURL( $q ) );
}
$q = $this->mArticle->isRedirect() ? 'redirect=no' : '';
$wgOut->redirect( $this->mTitle->getFullURL( $q ) );
}
$reasonstr = $this->mReason;
}
$expiry = array();
$reasonstr = $this->mReason;
}
$expiry = array();
- foreach( $this->mApplicableTypes as $action ) {
+ foreach ( $this->mApplicableTypes as $action ) {
$expiry[$action] = $this->getExpiry( $action );
$expiry[$action] = $this->getExpiry( $action );
- if( empty( $this->mRestrictions[$action] ) )
+ if ( empty( $this->mRestrictions[$action] ) ) {
if ( !$expiry[$action] ) {
$this->show( array( 'protect_expiry_invalid' ) );
return false;
if ( !$expiry[$action] ) {
$this->show( array( 'protect_expiry_invalid' ) );
return false;
# to a semi-protected page.
$edit_restriction = isset( $this->mRestrictions['edit'] ) ? $this->mRestrictions['edit'] : '';
$this->mCascade = $wgRequest->getBool( 'mwProtect-cascade' );
# to a semi-protected page.
$edit_restriction = isset( $this->mRestrictions['edit'] ) ? $this->mRestrictions['edit'] : '';
$this->mCascade = $wgRequest->getBool( 'mwProtect-cascade' );
- if ( $this->mCascade && ($edit_restriction != 'protect') &&
- !User::groupHasPermission( $edit_restriction, 'protect' ) )
+ if ( $this->mCascade && ( $edit_restriction != 'protect' ) &&
+ !User::groupHasPermission( $edit_restriction, 'protect' ) ) {
$status = $this->mArticle->doUpdateRestrictions( $this->mRestrictions, $expiry, $this->mCascade, $reasonstr, $wgUser );
$status = $this->mArticle->doUpdateRestrictions( $this->mRestrictions, $expiry, $this->mCascade, $reasonstr, $wgUser );
* you can also return an array of message name and its parameters
*/
$errorMsg = '';
* you can also return an array of message name and its parameters
*/
$errorMsg = '';
- if( !wfRunHooks( 'ProtectionForm::save', array( $this->mArticle, &$errorMsg ) ) ) {
+ if ( !wfRunHooks( 'ProtectionForm::save', array( $this->mArticle, &$errorMsg ) ) ) {
if ( $errorMsg == '' ) {
$errorMsg = array( 'hookaborted' );
}
}
if ( $errorMsg == '' ) {
$errorMsg = array( 'hookaborted' );
}
}
- if( $errorMsg != '' ) {
+ if ( $errorMsg != '' ) {
$this->show( $errorMsg );
return false;
}
$this->show( $errorMsg );
return false;
}
- if( !$this->disabled ) {
+ if ( !$this->disabled ) {
$wgOut->addModules( 'mediawiki.legacy.protect' );
$out .= Xml::openElement( 'form', array( 'method' => 'post',
'action' => $this->mTitle->getLocalURL( 'action=protect' ),
$wgOut->addModules( 'mediawiki.legacy.protect' );
$out .= Xml::openElement( 'form', array( 'method' => 'post',
'action' => $this->mTitle->getLocalURL( 'action=protect' ),
Xml::openElement( 'table', array( 'id' => 'mwProtectSet' ) ) .
Xml::openElement( 'tbody' );
Xml::openElement( 'table', array( 'id' => 'mwProtectSet' ) ) .
Xml::openElement( 'tbody' );
- foreach( $this->mRestrictions as $action => $selected ) {
+ foreach ( $this->mRestrictions as $action => $selected ) {
/* Not all languages have V_x <-> N_x relation */
$msg = wfMessage( 'restriction-' . $action );
$out .= "<tr><td>" .
/* Not all languages have V_x <-> N_x relation */
$msg = wfMessage( 'restriction-' . $action );
$out .= "<tr><td>" .
wfMessage( 'protect-othertime-op' )->text(),
"othertime"
) . "\n";
wfMessage( 'protect-othertime-op' )->text(),
"othertime"
) . "\n";
- foreach( explode( ',', $scExpiryOptions ) as $option ) {
+ foreach ( explode( ',', $scExpiryOptions ) as $option ) {
if ( strpos( $option, ":" ) === false ) {
$show = $value = $option;
} else {
if ( strpos( $option, ":" ) === false ) {
$show = $value = $option;
} else {
$expiryFormOptions .= Xml::option( $show, $value, $this->mExpirySelection[$action] === $value ) . "\n";
}
# Add expiry dropdown
$expiryFormOptions .= Xml::option( $show, $value, $this->mExpirySelection[$action] === $value ) . "\n";
}
# Add expiry dropdown
- if( $showProtectOptions && !$this->disabled ) {
+ if ( $showProtectOptions && !$this->disabled ) {
$out .= "
<table><tr>
<td class='mw-label'>
$out .= "
<table><tr>
<td class='mw-label'>
$out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
// JavaScript will add another row with a value-chaining checkbox
$out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
// JavaScript will add another row with a value-chaining checkbox
- if( $this->mTitle->exists() ) {
+ if ( $this->mTitle->exists() ) {
$out .= Xml::openElement( 'table', array( 'id' => 'mw-protect-table2' ) ) .
Xml::openElement( 'tbody' );
$out .= '<tr>
$out .= Xml::openElement( 'table', array( 'id' => 'mw-protect-table2' ) ) .
Xml::openElement( 'tbody' );
$out .= '<tr>
}
# Add manual and custom reason field/selects as well as submit
}
# Add manual and custom reason field/selects as well as submit
- if( !$this->disabled ) {
+ if ( !$this->disabled ) {
$out .= Xml::openElement( 'table', array( 'id' => 'mw-protect-table3' ) ) .
Xml::openElement( 'tbody' );
$out .= "
$out .= Xml::openElement( 'table', array( 'id' => 'mw-protect-table3' ) ) .
Xml::openElement( 'tbody' );
$out .= "
"</td>
</tr>";
# Disallow watching is user is not logged in
"</td>
</tr>";
# Disallow watching is user is not logged in
- if( $wgUser->isLoggedIn() ) {
+ if ( $wgUser->isLoggedIn() ) {
global $wgRestrictionLevels, $wgUser;
$levels = array();
global $wgRestrictionLevels, $wgUser;
$levels = array();
- foreach( $wgRestrictionLevels as $key ) {
+ foreach ( $wgRestrictionLevels as $key ) {
//don't let them choose levels above their own (aka so they can still unprotect and edit the page). but only when the form isn't disabled
//don't let them choose levels above their own (aka so they can still unprotect and edit the page). but only when the form isn't disabled
- if( $key == 'sysop' ) {
+ if ( $key == 'sysop' ) {
//special case, rewrite sysop to protect and editprotected
//special case, rewrite sysop to protect and editprotected
- if( !$wgUser->isAllowedAny( 'protect', 'editprotected' ) && !$this->disabled )
+ if ( !$wgUser->isAllowedAny( 'protect', 'editprotected' ) && !$this->disabled ) {
- if( !$wgUser->isAllowed( $key ) && !$this->disabled )
+ if ( !$wgUser->isAllowed( $key ) && !$this->disabled ) {
) + $this->disabledAttrib;
$out = Xml::openElement( 'select', $attribs );
) + $this->disabledAttrib;
$out = Xml::openElement( 'select', $attribs );
- foreach( $levels as $key ) {
+ foreach ( $levels as $key ) {
$out .= Xml::option( $this->getOptionLabel( $key ), $key, $key == $selected );
}
$out .= Xml::closeElement( 'select' );
$out .= Xml::option( $this->getOptionLabel( $key ), $key, $key == $selected );
}
$out .= Xml::closeElement( 'select' );
* @return String
*/
private function getOptionLabel( $permission ) {
* @return String
*/
private function getOptionLabel( $permission ) {
- if( $permission == '' ) {
+ if ( $permission == '' ) {
return wfMessage( 'protect-default' )->text();
} else {
$msg = wfMessage( "protect-level-{$permission}" );
return wfMessage( 'protect-default' )->text();
} else {
$msg = wfMessage( "protect-level-{$permission}" );
+ if ( $msg->exists() ) {
return $msg->text();
}
return wfMessage( 'protect-fallback', $permission )->text();
return $msg->text();
}
return wfMessage( 'protect-fallback', $permission )->text();
global $wgRestrictionLevels, $wgOut;
$cascadeableLevels = array();
global $wgRestrictionLevels, $wgOut;
$cascadeableLevels = array();
- foreach( $wgRestrictionLevels as $key ) {
+ foreach ( $wgRestrictionLevels as $key ) {
if ( User::groupHasPermission( $key, 'protect' )
|| $key == 'protect'
) {
if ( User::groupHasPermission( $key, 'protect' )
|| $key == 'protect'
) {
wfRunHooks( 'wgQueryPages', array( &$wgQueryPages ) );
global $wgDisableCounters;
wfRunHooks( 'wgQueryPages', array( &$wgQueryPages ) );
global $wgDisableCounters;
-if ( !$wgDisableCounters )
+if ( !$wgDisableCounters ) {
$wgQueryPages[] = array( 'PopularPagesPage', 'Popularpages' );
$wgQueryPages[] = array( 'PopularPagesPage', 'Popularpages' );
/**
* This is a class for doing query pages; since they're almost all the same,
/**
* This is a class for doing query pages; since they're almost all the same,
public static function newFromTitle( $title, $id = 0, $flags = 0 ) {
$conds = array(
'page_namespace' => $title->getNamespace(),
public static function newFromTitle( $title, $id = 0, $flags = 0 ) {
$conds = array(
'page_namespace' => $title->getNamespace(),
- 'page_title' => $title->getDBkey()
+ 'page_title' => $title->getDBkey()
);
if ( $id ) {
// Use the specified ID
);
if ( $id ) {
// Use the specified ID
* @return Revision or null
*/
public static function loadFromPageId( $db, $pageid, $id = 0 ) {
* @return Revision or null
*/
public static function loadFromPageId( $db, $pageid, $id = 0 ) {
- $conds = array( 'rev_page' => intval( $pageid ), 'page_id' => intval( $pageid ) );
- if( $id ) {
+ $conds = array( 'rev_page' => intval( $pageid ), 'page_id' => intval( $pageid ) );
+ if ( $id ) {
$conds['rev_id'] = intval( $id );
} else {
$conds[] = 'rev_id=page_latest';
$conds['rev_id'] = intval( $id );
} else {
$conds[] = 'rev_id=page_latest';
* @return Revision or null
*/
public static function loadFromTitle( $db, $title, $id = 0 ) {
* @return Revision or null
*/
public static function loadFromTitle( $db, $title, $id = 0 ) {
$matchId = intval( $id );
} else {
$matchId = 'page_latest';
$matchId = intval( $id );
} else {
$matchId = 'page_latest';
array(
"rev_id=$matchId",
'page_namespace' => $title->getNamespace(),
array(
"rev_id=$matchId",
'page_namespace' => $title->getNamespace(),
- 'page_title' => $title->getDBkey()
+ 'page_title' => $title->getDBkey()
public static function loadFromTimestamp( $db, $title, $timestamp ) {
return self::loadFromConds( $db,
array(
public static function loadFromTimestamp( $db, $title, $timestamp ) {
return self::loadFromConds( $db,
array(
- 'rev_timestamp' => $db->timestamp( $timestamp ),
+ 'rev_timestamp' => $db->timestamp( $timestamp ),
'page_namespace' => $title->getNamespace(),
'page_namespace' => $title->getNamespace(),
- 'page_title' => $title->getDBkey()
+ 'page_title' => $title->getDBkey()
*/
private static function loadFromConds( $db, $conditions, $flags = 0 ) {
$res = self::fetchFromConds( $db, $conditions, $flags );
*/
private static function loadFromConds( $db, $conditions, $flags = 0 ) {
$res = self::fetchFromConds( $db, $conditions, $flags );
$row = $res->fetchObject();
$row = $res->fetchObject();
$ret = new Revision( $row );
return $ret;
}
$ret = new Revision( $row );
return $ret;
}
array(
'rev_id=page_latest',
'page_namespace' => $title->getNamespace(),
array(
'rev_id=page_latest',
'page_namespace' => $title->getNamespace(),
- 'page_title' => $title->getDBkey()
+ 'page_title' => $title->getDBkey()
* @access private
*/
function __construct( $row ) {
* @access private
*/
function __construct( $row ) {
- if( is_object( $row ) ) {
+ if ( is_object( $row ) ) {
$this->mId = intval( $row->rev_id );
$this->mPage = intval( $row->rev_page );
$this->mTextId = intval( $row->rev_text_id );
$this->mId = intval( $row->rev_id );
$this->mPage = intval( $row->rev_page );
$this->mTextId = intval( $row->rev_text_id );
$this->mSha1 = $row->rev_sha1;
}
$this->mSha1 = $row->rev_sha1;
}
- if( isset( $row->page_latest ) ) {
+ if ( isset( $row->page_latest ) ) {
$this->mCurrent = ( $row->rev_id == $row->page_latest );
$this->mTitle = Title::newFromRow( $row );
} else {
$this->mCurrent = ( $row->rev_id == $row->page_latest );
$this->mTitle = Title::newFromRow( $row );
} else {
- if( !isset( $row->rev_content_model ) || is_null( $row->rev_content_model ) ) {
+ if ( !isset( $row->rev_content_model ) || is_null( $row->rev_content_model ) ) {
$this->mContentModel = null; # determine on demand if needed
} else {
$this->mContentModel = strval( $row->rev_content_model );
}
$this->mContentModel = null; # determine on demand if needed
} else {
$this->mContentModel = strval( $row->rev_content_model );
}
- if( !isset( $row->rev_content_format ) || is_null( $row->rev_content_format ) ) {
+ if ( !isset( $row->rev_content_format ) || is_null( $row->rev_content_format ) ) {
$this->mContentFormat = null; # determine on demand if needed
} else {
$this->mContentFormat = strval( $row->rev_content_format );
$this->mContentFormat = null; # determine on demand if needed
} else {
$this->mContentFormat = strval( $row->rev_content_format );
// Lazy extraction...
$this->mText = null;
// Lazy extraction...
$this->mText = null;
- if( isset( $row->old_text ) ) {
+ if ( isset( $row->old_text ) ) {
$this->mTextRow = $row;
} else {
// 'text' table row entry will be lazy-loaded
$this->mTextRow = $row;
} else {
// 'text' table row entry will be lazy-loaded
$this->mUserText = $row->user_name; // logged-in user
}
$this->mOrigUserText = $row->rev_user_text;
$this->mUserText = $row->user_name; // logged-in user
}
$this->mOrigUserText = $row->rev_user_text;
- } elseif( is_array( $row ) ) {
+ } elseif ( is_array( $row ) ) {
// Build a new revision to be saved...
global $wgUser; // ugh
// Build a new revision to be saved...
global $wgUser; // ugh
* @return Title|null
*/
public function getTitle() {
* @return Title|null
*/
public function getTitle() {
- if( isset( $this->mTitle ) ) {
+ if ( isset( $this->mTitle ) ) {
- if( !is_null( $this->mId ) ) { //rev_id is defined as NOT NULL, but this revision may not yet have been inserted.
+ if ( !is_null( $this->mId ) ) { //rev_id is defined as NOT NULL, but this revision may not yet have been inserted.
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow(
array( 'page', 'revision' ),
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow(
array( 'page', 'revision' ),
* @return Integer
*/
public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
* @return Integer
*/
public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
- if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) {
+ if ( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) {
- } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER, $user ) ) {
+ } elseif ( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER, $user ) ) {
return 0;
} else {
return $this->mUser;
return 0;
} else {
return $this->mUser;
* @return string
*/
public function getUserText( $audience = self::FOR_PUBLIC, User $user = null ) {
* @return string
*/
public function getUserText( $audience = self::FOR_PUBLIC, User $user = null ) {
- if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) {
+ if ( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) {
- } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER, $user ) ) {
+ } elseif ( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER, $user ) ) {
return '';
} else {
return $this->getRawUserText();
return '';
} else {
return $this->getRawUserText();
* @return String
*/
function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
* @return String
*/
function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
- if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_COMMENT ) ) {
+ if ( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_COMMENT ) ) {
- } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_COMMENT, $user ) ) {
+ } elseif ( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_COMMENT, $user ) ) {
return '';
} else {
return $this->mComment;
return '';
} else {
return $this->mComment;
* @return Integer rcid of the unpatrolled row, zero if there isn't one
*/
public function isUnpatrolled() {
* @return Integer rcid of the unpatrolled row, zero if there isn't one
*/
public function isUnpatrolled() {
- if( $this->mUnpatrolled !== null ) {
+ if ( $this->mUnpatrolled !== null ) {
return $this->mUnpatrolled;
}
$dbr = wfGetDB( DB_SLAVE );
$this->mUnpatrolled = $dbr->selectField( 'recentchanges',
'rc_id',
array( // Add redundant user,timestamp condition so we can use the existing index
return $this->mUnpatrolled;
}
$dbr = wfGetDB( DB_SLAVE );
$this->mUnpatrolled = $dbr->selectField( 'recentchanges',
'rc_id',
array( // Add redundant user,timestamp condition so we can use the existing index
- 'rc_user_text' => $this->getRawUserText(),
- 'rc_timestamp' => $dbr->timestamp( $this->getTimestamp() ),
+ 'rc_user_text' => $this->getRawUserText(),
+ 'rc_timestamp' => $dbr->timestamp( $this->getTimestamp() ),
'rc_this_oldid' => $this->getId(),
'rc_this_oldid' => $this->getId(),
* @return Content|null
*/
public function getContent( $audience = self::FOR_PUBLIC, User $user = null ) {
* @return Content|null
*/
public function getContent( $audience = self::FOR_PUBLIC, User $user = null ) {
- if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_TEXT ) ) {
+ if ( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_TEXT ) ) {
- } elseif( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_TEXT, $user ) ) {
+ } elseif ( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_TEXT, $user ) ) {
return null;
} else {
return $this->getContentInternal();
return null;
} else {
return $this->getContentInternal();
* @return Content|null the Revision's content, or null on failure.
*/
protected function getContentInternal() {
* @return Content|null the Revision's content, or null on failure.
*/
protected function getContentInternal() {
- if( is_null( $this->mContent ) ) {
+ if ( is_null( $this->mContent ) ) {
// Revision is immutable. Load on demand:
// Revision is immutable. Load on demand:
- if( is_null( $this->mText ) ) {
+ if ( is_null( $this->mText ) ) {
$this->mText = $this->loadText();
}
$this->mText = $this->loadText();
}
* @return Revision|null
*/
public function getPrevious() {
* @return Revision|null
*/
public function getPrevious() {
- if( $this->getTitle() ) {
+ if ( $this->getTitle() ) {
$prev = $this->getTitle()->getPreviousRevisionID( $this->getId() );
$prev = $this->getTitle()->getPreviousRevisionID( $this->getId() );
return self::newFromTitle( $this->getTitle(), $prev );
}
}
return self::newFromTitle( $this->getTitle(), $prev );
}
}
* @return Revision or null
*/
public function getNext() {
* @return Revision or null
*/
public function getNext() {
- if( $this->getTitle() ) {
+ if ( $this->getTitle() ) {
$next = $this->getTitle()->getNextRevisionID( $this->getId() );
if ( $next ) {
return self::newFromTitle( $this->getTitle(), $next );
$next = $this->getTitle()->getNextRevisionID( $this->getId() );
if ( $next ) {
return self::newFromTitle( $this->getTitle(), $next );
* @return Integer
*/
private function getPreviousRevisionId( $db ) {
* @return Integer
*/
private function getPreviousRevisionId( $db ) {
- if( is_null( $this->mPage ) ) {
+ if ( is_null( $this->mPage ) ) {
return 0;
}
# Use page_latest if ID is not given
return 0;
}
# Use page_latest if ID is not given
$prevId = $db->selectField( 'page', 'page_latest',
array( 'page_id' => $this->mPage ),
__METHOD__ );
$prevId = $db->selectField( 'page', 'page_latest',
array( 'page_id' => $this->mPage ),
__METHOD__ );
$textField = $prefix . 'text';
$flagsField = $prefix . 'flags';
$textField = $prefix . 'text';
$flagsField = $prefix . 'flags';
- if( isset( $row->$flagsField ) ) {
+ if ( isset( $row->$flagsField ) ) {
$flags = explode( ',', $row->$flagsField );
} else {
$flags = array();
}
$flags = explode( ',', $row->$flagsField );
} else {
$flags = array();
}
- if( isset( $row->$textField ) ) {
+ if ( isset( $row->$textField ) ) {
$text = $row->$textField;
} else {
wfProfileOut( __METHOD__ );
$text = $row->$textField;
} else {
wfProfileOut( __METHOD__ );
if ( in_array( 'external', $flags ) ) {
$url = $text;
$parts = explode( '://', $url, 2 );
if ( in_array( 'external', $flags ) ) {
$url = $text;
$parts = explode( '://', $url, 2 );
- if( count( $parts ) == 1 || $parts[1] == '' ) {
+ if ( count( $parts ) == 1 || $parts[1] == '' ) {
wfProfileOut( __METHOD__ );
return false;
}
wfProfileOut( __METHOD__ );
return false;
}
// If the text was fetched without an error, convert it
if ( $text !== false ) {
// If the text was fetched without an error, convert it
if ( $text !== false ) {
- if( in_array( 'gzip', $flags ) ) {
+ if ( in_array( 'gzip', $flags ) ) {
# Deal with optional compression of archived pages.
# This can be done periodically via maintenance/compressOld.php, and
# as pages are saved if $wgCompressRevisions is set.
$text = gzinflate( $text );
}
# Deal with optional compression of archived pages.
# This can be done periodically via maintenance/compressOld.php, and
# as pages are saved if $wgCompressRevisions is set.
$text = gzinflate( $text );
}
- if( in_array( 'object', $flags ) ) {
+ if ( in_array( 'object', $flags ) ) {
# Generic compressed storage
$obj = unserialize( $text );
if ( !is_object( $obj ) ) {
# Generic compressed storage
$obj = unserialize( $text );
if ( !is_object( $obj ) ) {
}
global $wgLegacyEncoding;
}
global $wgLegacyEncoding;
- if( $text !== false && $wgLegacyEncoding
+ if ( $text !== false && $wgLegacyEncoding
&& !in_array( 'utf-8', $flags ) && !in_array( 'utf8', $flags ) )
{
# Old revisions kept around in a legacy encoding?
&& !in_array( 'utf-8', $flags ) && !in_array( 'utf8', $flags ) )
{
# Old revisions kept around in a legacy encoding?
# on load if $wgLegacyCharset is set in the future.
$flags[] = 'utf-8';
# on load if $wgLegacyCharset is set in the future.
$flags[] = 'utf-8';
- if( $wgCompressRevisions ) {
- if( function_exists( 'gzdeflate' ) ) {
+ if ( $wgCompressRevisions ) {
+ if ( function_exists( 'gzdeflate' ) ) {
$text = gzdeflate( $text );
$flags[] = 'gzip';
} else {
$text = gzdeflate( $text );
$flags[] = 'gzip';
} else {
$flags = self::compressRevisionText( $data );
# Write to external storage if required
$flags = self::compressRevisionText( $data );
# Write to external storage if required
- if( $wgDefaultExternalStore ) {
+ if ( $wgDefaultExternalStore ) {
// Store and get the URL
$data = ExternalStore::insertToDefault( $data );
// Store and get the URL
$data = ExternalStore::insertToDefault( $data );
wfProfileOut( __METHOD__ );
throw new MWException( "Unable to store text to external storage" );
}
wfProfileOut( __METHOD__ );
throw new MWException( "Unable to store text to external storage" );
}
$flags .= ',';
}
$flags .= 'external';
}
# Record the text (or external storage URL) to the text table
$flags .= ',';
}
$flags .= 'external';
}
# Record the text (or external storage URL) to the text table
- if( !isset( $this->mTextId ) ) {
+ if ( !isset( $this->mTextId ) ) {
$old_id = $dbw->nextSequenceValue( 'text_old_id_seq' );
$dbw->insert( 'text',
array(
$old_id = $dbw->nextSequenceValue( 'text_old_id_seq' );
$dbw->insert( 'text',
array(
- 'old_id' => $old_id,
- 'old_text' => $data,
+ 'old_id' => $old_id,
+ 'old_text' => $data,
'old_flags' => $flags,
), __METHOD__
);
$this->mTextId = $dbw->insertId();
}
'old_flags' => $flags,
), __METHOD__
);
$this->mTextId = $dbw->insertId();
}
- if ( $this->mComment === null ) $this->mComment = "";
+ if ( $this->mComment === null ) {
+ $this->mComment = "";
+ }
# Record the edit in revisions
$rev_id = isset( $this->mId )
# Record the edit in revisions
$rev_id = isset( $this->mId )
global $wgRevisionCacheExpiry, $wgMemc;
$textId = $this->getTextId();
$key = wfMemcKey( 'revisiontext', 'textid', $textId );
global $wgRevisionCacheExpiry, $wgMemc;
$textId = $this->getTextId();
$key = wfMemcKey( 'revisiontext', 'textid', $textId );
- if( $wgRevisionCacheExpiry ) {
+ if ( $wgRevisionCacheExpiry ) {
$text = $wgMemc->get( $key );
$text = $wgMemc->get( $key );
- if( is_string( $text ) ) {
+ if ( is_string( $text ) ) {
wfDebug( __METHOD__ . ": got id $textId from cache\n" );
wfProfileOut( __METHOD__ );
return $text;
wfDebug( __METHOD__ . ": got id $textId from cache\n" );
wfProfileOut( __METHOD__ );
return $text;
// Text data is immutable; check slaves first.
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow( 'text',
// Text data is immutable; check slaves first.
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow( 'text',
- if( !$row && wfGetLB()->getServerCount() > 1 ) {
+ if ( !$row && wfGetLB()->getServerCount() > 1 ) {
// Possible slave lag!
$dbw = wfGetDB( DB_MASTER );
$row = $dbw->selectRow( 'text',
// Possible slave lag!
$dbw = wfGetDB( DB_MASTER );
$row = $dbw->selectRow( 'text',
$text = self::getRevisionText( $row );
# No negative caching -- negative hits on text rows may be due to corrupted slave servers
$text = self::getRevisionText( $row );
# No negative caching -- negative hits on text rows may be due to corrupted slave servers
- if( $wgRevisionCacheExpiry && $text !== false ) {
+ if ( $wgRevisionCacheExpiry && $text !== false ) {
$wgMemc->set( $key, $text, $wgRevisionCacheExpiry );
}
$wgMemc->set( $key, $text, $wgRevisionCacheExpiry );
}
$row = array(
'page' => $pageId,
'comment' => $summary,
$row = array(
'page' => $pageId,
'comment' => $summary,
* @return Boolean
*/
public static function userCanBitfield( $bitfield, $field, User $user = null ) {
* @return Boolean
*/
public static function userCanBitfield( $bitfield, $field, User $user = null ) {
- if( $bitfield & $field ) { // aspect is deleted
+ if ( $bitfield & $field ) { // aspect is deleted
if ( $bitfield & self::DELETED_RESTRICTED ) {
$permission = 'suppressrevision';
} elseif ( $field & self::DELETED_TEXT ) {
if ( $bitfield & self::DELETED_RESTRICTED ) {
$permission = 'suppressrevision';
} elseif ( $field & self::DELETED_TEXT ) {
static function countByPageId( $db, $id ) {
$row = $db->selectRow( 'revision', array( 'revCount' => 'COUNT(*)' ),
array( 'rev_page' => $id ), __METHOD__ );
static function countByPageId( $db, $id ) {
$row = $db->selectRow( 'revision', array( 'revCount' => 'COUNT(*)' ),
array( 'rev_page' => $id ), __METHOD__ );
return $row->revCount;
}
return 0;
return $row->revCount;
}
return 0;
*/
static function countByTitle( $db, $title ) {
$id = $title->getArticleID();
*/
static function countByTitle( $db, $title ) {
$id = $title->getArticleID();
return self::countByPageId( $db, $id );
}
return 0;
return self::countByPageId( $db, $id );
}
return 0;
* @return bool True if the given user was the only one to edit since the given timestamp
*/
public static function userWasLastToEdit( $db, $pageId, $userId, $since ) {
* @return bool True if the given user was the only one to edit since the given timestamp
*/
public static function userWasLastToEdit( $db, $pageId, $userId, $since ) {
- if ( !$userId ) return false;
+ if ( !$userId ) {
+ return false;
+ }
if ( is_int( $db ) ) {
$db = wfGetDB( $db );
if ( is_int( $db ) ) {
$db = wfGetDB( $db );
* @return int
*/
public function length() {
* @return int
*/
public function length() {
return 0;
} else {
return $this->res->numRows();
return 0;
} else {
return $this->res->numRows();
'td', 'th', 'tr',
);
$htmllist = array( # Tags used by list
'td', 'th', 'tr',
);
$htmllist = array( # Tags used by list
);
$listtags = array( # Tags that can appear in a list
'li',
);
$listtags = array( # Tags that can appear in a list
'li',
# $params: String between element name and >
# $brace: Ending '>' or '/>'
# $rest: Everything until the next element of $bits
# $params: String between element name and >
# $brace: Ending '>' or '/>'
# $rest: Everything until the next element of $bits
- if( preg_match( '!^(/?)(\\w+)([^>]*?)(/{0,1}>)([^<]*)$!', $x, $regs ) ) {
+ if ( preg_match( '!^(/?)(\\w+)([^>]*?)(/{0,1}>)([^<]*)$!', $x, $regs ) ) {
list( /* $qbar */, $slash, $t, $params, $brace, $rest ) = $regs;
} else {
$slash = $t = $params = $brace = $rest = null;
list( /* $qbar */, $slash, $t, $params, $brace, $rest ) = $regs;
} else {
$slash = $t = $params = $brace = $rest = null;
# Replace any variables or template parameters with
# plaintext results.
# Replace any variables or template parameters with
# plaintext results.
- if( is_callable( $processCallback ) ) {
+ if ( is_callable( $processCallback ) ) {
call_user_func_array( $processCallback, array( &$params, $args ) );
}
call_user_func_array( $processCallback, array( &$params, $args ) );
}
@list( /* $qbar */, $slash, $t, $params, $brace, $rest ) = $regs;
$badtag = false;
if ( isset( $htmlelements[$t = strtolower( $t )] ) ) {
@list( /* $qbar */, $slash, $t, $params, $brace, $rest ) = $regs;
$badtag = false;
if ( isset( $htmlelements[$t = strtolower( $t )] ) ) {
- if( is_callable( $processCallback ) ) {
+ if ( is_callable( $processCallback ) ) {
call_user_func_array( $processCallback, array( &$params, $args ) );
}
call_user_func_array( $processCallback, array( &$params, $args ) );
}
$spaceStart--;
$spaceLen++;
}
$spaceStart--;
$spaceLen++;
}
- while ( substr( $text, $spaceStart + $spaceLen, 1 ) === ' ' )
+ while ( substr( $text, $spaceStart + $spaceLen, 1 ) === ' ' ) {
if ( substr( $text, $spaceStart, 1 ) === "\n" and substr( $text, $spaceStart + $spaceLen, 1 ) === "\n" ) {
# Remove the comment, leading and trailing
# spaces, and leave only one newline.
if ( substr( $text, $spaceStart, 1 ) === "\n" and substr( $text, $spaceStart + $spaceLen, 1 ) === "\n" ) {
# Remove the comment, leading and trailing
# spaces, and leave only one newline.
$hrefExp = '/^(' . wfUrlProtocols() . ')[^\s]+$/';
$out = array();
$hrefExp = '/^(' . wfUrlProtocols() . ')[^\s]+$/';
$out = array();
- foreach( $attribs as $attribute => $value ) {
+ foreach ( $attribs as $attribute => $value ) {
#allow XML namespace declaration if RDFa is enabled
if ( $wgAllowRdfaAttributes && preg_match( self::XMLNS_ATTRIBUTE_PATTERN, $attribute ) ) {
if ( !preg_match( self::EVIL_URI_PATTERN, $value ) ) {
#allow XML namespace declaration if RDFa is enabled
if ( $wgAllowRdfaAttributes && preg_match( self::XMLNS_ATTRIBUTE_PATTERN, $attribute ) ) {
if ( !preg_match( self::EVIL_URI_PATTERN, $value ) ) {
# Strip javascript "expression" from stylesheets.
# http://msdn.microsoft.com/workshop/author/dhtml/overview/recalc.asp
# Strip javascript "expression" from stylesheets.
# http://msdn.microsoft.com/workshop/author/dhtml/overview/recalc.asp
- if( $attribute == 'style' ) {
+ if ( $attribute == 'style' ) {
$value = Sanitizer::checkCss( $value );
}
$value = Sanitizer::checkCss( $value );
}
*/
static function mergeAttributes( $a, $b ) {
$out = array_merge( $a, $b );
*/
static function mergeAttributes( $a, $b ) {
$out = array_merge( $a, $b );
- if( isset( $a['class'] ) && isset( $b['class'] )
- && is_string( $a['class'] ) && is_string( $b['class'] )
- && $a['class'] !== $b['class'] ) {
+ if ( isset( $a['class'] ) && isset( $b['class'] )
+ && is_string( $a['class'] ) && is_string( $b['class'] )
+ && $a['class'] !== $b['class']
+ ) {
$classes = preg_split( '/\s+/', "{$a['class']} {$b['class']}",
-1, PREG_SPLIT_NO_EMPTY );
$out['class'] = implode( ' ', array_unique( $classes ) );
$classes = preg_split( '/\s+/', "{$a['class']} {$b['class']}",
-1, PREG_SPLIT_NO_EMPTY );
$out['class'] = implode( ' ', array_unique( $classes ) );
* @return String
*/
static function fixTagAttributes( $text, $element ) {
* @return String
*/
static function fixTagAttributes( $text, $element ) {
- if( trim( $text ) == '' ) {
+ if ( trim( $text ) == '' ) {
$stripped = Sanitizer::validateTagAttributes( $decoded, $element );
$attribs = array();
$stripped = Sanitizer::validateTagAttributes( $decoded, $element );
$attribs = array();
- foreach( $stripped as $attribute => $value ) {
+ foreach ( $stripped as $attribute => $value ) {
$encAttribute = htmlspecialchars( $attribute );
$encValue = Sanitizer::safeEncodeAttribute( $value );
$encAttribute = htmlspecialchars( $attribute );
$encValue = Sanitizer::safeEncodeAttribute( $value );
* @return Array
*/
public static function decodeTagAttributes( $text ) {
* @return Array
*/
public static function decodeTagAttributes( $text ) {
- if( trim( $text ) == '' ) {
+ if ( trim( $text ) == '' ) {
return array();
}
$attribs = array();
$pairs = array();
return array();
}
$attribs = array();
$pairs = array();
self::getAttribsRegex(),
$text,
$pairs,
self::getAttribsRegex(),
$text,
$pairs,
- foreach( $pairs as $set ) {
+ foreach ( $pairs as $set ) {
$attribute = strtolower( $set[1] );
$value = Sanitizer::getTagAttributeCallback( $set );
$attribute = strtolower( $set[1] );
$value = Sanitizer::getTagAttributeCallback( $set );
* @return String
*/
private static function getTagAttributeCallback( $set ) {
* @return String
*/
private static function getTagAttributeCallback( $set ) {
- if( isset( $set[6] ) ) {
+ if ( isset( $set[6] ) ) {
# Illegal #XXXXXX color with no quotes.
return $set[6];
# Illegal #XXXXXX color with no quotes.
return $set[6];
- } elseif( isset( $set[5] ) ) {
+ } elseif ( isset( $set[5] ) ) {
# No quotes.
return $set[5];
# No quotes.
return $set[5];
- } elseif( isset( $set[4] ) ) {
+ } elseif ( isset( $set[4] ) ) {
# Single-quoted
return $set[4];
# Single-quoted
return $set[4];
- } elseif( isset( $set[3] ) ) {
+ } elseif ( isset( $set[3] ) ) {
# Double-quoted
return $set[3];
# Double-quoted
return $set[3];
- } elseif( !isset( $set[2] ) ) {
+ } elseif ( !isset( $set[2] ) ) {
# In XHTML, attributes must have a value.
# For 'reduced' form, return explicitly the attribute name here.
return $set[1];
# In XHTML, attributes must have a value.
# For 'reduced' form, return explicitly the attribute name here.
return $set[1];
*/
static function normalizeCharReferencesCallback( $matches ) {
$ret = null;
*/
static function normalizeCharReferencesCallback( $matches ) {
$ret = null;
- if( $matches[1] != '' ) {
+ if ( $matches[1] != '' ) {
$ret = Sanitizer::normalizeEntity( $matches[1] );
$ret = Sanitizer::normalizeEntity( $matches[1] );
- } elseif( $matches[2] != '' ) {
+ } elseif ( $matches[2] != '' ) {
$ret = Sanitizer::decCharReference( $matches[2] );
$ret = Sanitizer::decCharReference( $matches[2] );
- } elseif( $matches[3] != '' ) {
+ } elseif ( $matches[3] != '' ) {
$ret = Sanitizer::hexCharReference( $matches[3] );
}
$ret = Sanitizer::hexCharReference( $matches[3] );
}
- if( is_null( $ret ) ) {
+ if ( is_null( $ret ) ) {
return htmlspecialchars( $matches[0] );
} else {
return $ret;
return htmlspecialchars( $matches[0] );
} else {
return $ret;
*/
static function decCharReference( $codepoint ) {
$point = intval( $codepoint );
*/
static function decCharReference( $codepoint ) {
$point = intval( $codepoint );
- if( Sanitizer::validateCodepoint( $point ) ) {
+ if ( Sanitizer::validateCodepoint( $point ) ) {
return sprintf( '&#%d;', $point );
} else {
return null;
return sprintf( '&#%d;', $point );
} else {
return null;
*/
static function hexCharReference( $codepoint ) {
$point = hexdec( $codepoint );
*/
static function hexCharReference( $codepoint ) {
$point = hexdec( $codepoint );
- if( Sanitizer::validateCodepoint( $point ) ) {
+ if ( Sanitizer::validateCodepoint( $point ) ) {
return sprintf( '&#x%x;', $point );
} else {
return null;
return sprintf( '&#x%x;', $point );
} else {
return null;
* @return String
*/
static function decodeCharReferencesCallback( $matches ) {
* @return String
*/
static function decodeCharReferencesCallback( $matches ) {
- if( $matches[1] != '' ) {
+ if ( $matches[1] != '' ) {
return Sanitizer::decodeEntity( $matches[1] );
return Sanitizer::decodeEntity( $matches[1] );
- } elseif( $matches[2] != '' ) {
+ } elseif ( $matches[2] != '' ) {
return Sanitizer::decodeChar( intval( $matches[2] ) );
return Sanitizer::decodeChar( intval( $matches[2] ) );
- } elseif( $matches[3] != '' ) {
+ } elseif ( $matches[3] != '' ) {
return Sanitizer::decodeChar( hexdec( $matches[3] ) );
}
# Last case should be an ampersand by itself
return Sanitizer::decodeChar( hexdec( $matches[3] ) );
}
# Last case should be an ampersand by itself
* @private
*/
static function decodeChar( $codepoint ) {
* @private
*/
static function decodeChar( $codepoint ) {
- if( Sanitizer::validateCodepoint( $codepoint ) ) {
+ if ( Sanitizer::validateCodepoint( $codepoint ) ) {
return codepointToUtf8( $codepoint );
} else {
return UTF8_REPLACEMENT;
return codepointToUtf8( $codepoint );
} else {
return UTF8_REPLACEMENT;
if ( isset( self::$htmlEntityAliases[$name] ) ) {
$name = self::$htmlEntityAliases[$name];
}
if ( isset( self::$htmlEntityAliases[$name] ) ) {
$name = self::$htmlEntityAliases[$name];
}
- if( isset( self::$htmlEntities[$name] ) ) {
+ if ( isset( self::$htmlEntities[$name] ) ) {
return codepointToUtf8( self::$htmlEntities[$name] );
} else {
return "&$name;";
return codepointToUtf8( self::$htmlEntities[$name] );
} else {
return "&$name;";
*/
static function hackDocType() {
$out = "<!DOCTYPE html [\n";
*/
static function hackDocType() {
$out = "<!DOCTYPE html [\n";
- foreach( self::$htmlEntities as $entity => $codepoint ) {
+ foreach ( self::$htmlEntities as $entity => $codepoint ) {
$out .= "<!ENTITY $entity \"&#$codepoint;\">";
}
$out .= "]>\n";
$out .= "<!ENTITY $entity \"&#$codepoint;\">";
}
$out .= "]>\n";
# Validate hostname portion
$matches = array();
# Validate hostname portion
$matches = array();
- if( preg_match( '!^([^:]+:)(//[^/]+)?(.*)$!iD', $url, $matches ) ) {
+ if ( preg_match( '!^([^:]+:)(//[^/]+)?(.*)$!iD', $url, $matches ) ) {
list( /* $whole */, $protocol, $host, $rest ) = $matches;
// Characters that will be ignored in IDNs.
list( /* $whole */, $protocol, $host, $rest ) = $matches;
// Characters that will be ignored in IDNs.
*/
public static function validateEmail( $addr ) {
$result = null;
*/
public static function validateEmail( $addr ) {
$result = null;
- if( !wfRunHooks( 'isValidEmailAddr', array( $addr, &$result ) ) ) {
+ if ( !wfRunHooks( 'isValidEmailAddr', array( $addr, &$result ) ) ) {
}
// Set various default paths sensibly...
}
// Set various default paths sensibly...
-if ( $wgScript === false ) $wgScript = "$wgScriptPath/index$wgScriptExtension";
-if ( $wgLoadScript === false ) $wgLoadScript = "$wgScriptPath/load$wgScriptExtension";
+if ( $wgScript === false ) {
+ $wgScript = "$wgScriptPath/index$wgScriptExtension";
+}
+if ( $wgLoadScript === false ) {
+ $wgLoadScript = "$wgScriptPath/load$wgScriptExtension";
+}
if ( $wgArticlePath === false ) {
if ( $wgUsePathInfo ) {
if ( $wgArticlePath === false ) {
if ( $wgUsePathInfo ) {
$wgActionPaths['view'] = $wgArticlePath;
}
$wgActionPaths['view'] = $wgArticlePath;
}
-if ( $wgStylePath === false ) $wgStylePath = "$wgScriptPath/skins";
-if ( $wgLocalStylePath === false ) $wgLocalStylePath = "$wgScriptPath/skins";
-if ( $wgStyleDirectory === false ) $wgStyleDirectory = "$IP/skins";
-if ( $wgExtensionAssetsPath === false ) $wgExtensionAssetsPath = "$wgScriptPath/extensions";
+if ( $wgStylePath === false ) {
+ $wgStylePath = "$wgScriptPath/skins";
+}
+if ( $wgLocalStylePath === false ) {
+ $wgLocalStylePath = "$wgScriptPath/skins";
+}
+if ( $wgStyleDirectory === false ) {
+ $wgStyleDirectory = "$IP/skins";
+}
+if ( $wgExtensionAssetsPath === false ) {
+ $wgExtensionAssetsPath = "$wgScriptPath/extensions";
+}
-if ( $wgLogo === false ) $wgLogo = "$wgStylePath/common/images/wiki.png";
+if ( $wgLogo === false ) {
+ $wgLogo = "$wgStylePath/common/images/wiki.png";
+}
-if ( $wgUploadPath === false ) $wgUploadPath = "$wgScriptPath/images";
-if ( $wgUploadDirectory === false ) $wgUploadDirectory = "$IP/images";
-if ( $wgReadOnlyFile === false ) $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
-if ( $wgFileCacheDirectory === false ) $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
-if ( $wgDeletedDirectory === false ) $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
+if ( $wgUploadPath === false ) {
+ $wgUploadPath = "$wgScriptPath/images";
+}
+if ( $wgUploadDirectory === false ) {
+ $wgUploadDirectory = "$IP/images";
+}
+if ( $wgReadOnlyFile === false ) {
+ $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
+}
+if ( $wgFileCacheDirectory === false ) {
+ $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
+}
+if ( $wgDeletedDirectory === false ) {
+ $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
+}
if ( isset( $wgFileStore['deleted']['directory'] ) ) {
$wgDeletedDirectory = $wgFileStore['deleted']['directory'];
if ( isset( $wgFileStore['deleted']['directory'] ) ) {
$wgDeletedDirectory = $wgFileStore['deleted']['directory'];
* Initialise $wgLockManagers to include basic FS version
*/
$wgLockManagers[] = array(
* Initialise $wgLockManagers to include basic FS version
*/
$wgLockManagers[] = array(
- 'name' => 'fsLockManager',
- 'class' => 'FSLockManager',
+ 'name' => 'fsLockManager',
+ 'class' => 'FSLockManager',
'lockDirectory' => "{$wgUploadDirectory}/lockdir",
);
$wgLockManagers[] = array(
'lockDirectory' => "{$wgUploadDirectory}/lockdir",
);
$wgLockManagers[] = array(
- 'name' => 'nullLockManager',
- 'class' => 'NullLockManager',
+ 'name' => 'nullLockManager',
+ 'class' => 'NullLockManager',
}
if ( $wgUseInstantCommons ) {
$wgForeignFileRepos[] = array(
}
if ( $wgUseInstantCommons ) {
$wgForeignFileRepos[] = array(
- 'class' => 'ForeignAPIRepo',
- 'name' => 'wikimediacommons',
- 'apibase' => WebRequest::detectProtocol() === 'https' ?
+ 'class' => 'ForeignAPIRepo',
+ 'name' => 'wikimediacommons',
+ 'apibase' => WebRequest::detectProtocol() === 'https' ?
'https://commons.wikimedia.org/w/api.php' :
'http://commons.wikimedia.org/w/api.php',
'https://commons.wikimedia.org/w/api.php' :
'http://commons.wikimedia.org/w/api.php',
- 'hashLevels' => 2,
- 'fetchDescription' => true,
+ 'hashLevels' => 2,
+ 'fetchDescription' => true,
'descriptionCacheExpiry' => 43200,
'descriptionCacheExpiry' => 43200,
- 'apiThumbCacheExpiry' => 86400,
+ 'apiThumbCacheExpiry' => 86400,
-if( is_array( $wgExtraNamespaces ) ) {
+if ( is_array( $wgExtraNamespaces ) ) {
$wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
}
$wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
}
}
# $wgDisabledActions is deprecated as of 1.18
}
# $wgDisabledActions is deprecated as of 1.18
-foreach( $wgDisabledActions as $action ) {
+foreach ( $wgDisabledActions as $action ) {
$wgActions[$action] = false;
}
$wgActions[$action] = false;
}
}
date_default_timezone_set( $wgLocaltimezone );
}
date_default_timezone_set( $wgLocaltimezone );
-if( is_null( $wgLocalTZoffset ) ) {
+if ( is_null( $wgLocalTZoffset ) ) {
$wgLocalTZoffset = date( 'Z' ) / 60;
}
$wgLocalTZoffset = date( 'Z' ) / 60;
}
if ( is_object( $func ) && $func instanceof Closure ) {
$profName = $fname . '-extensions-closure';
} elseif ( is_array( $func ) ) {
if ( is_object( $func ) && $func instanceof Closure ) {
$profName = $fname . '-extensions-closure';
} elseif ( is_array( $func ) ) {
- if ( is_object( $func[0] ) )
+ if ( is_object( $func[0] ) ) {
$profName = $fname . '-extensions-' . get_class( $func[0] ) . '::' . $func[1];
$profName = $fname . '-extensions-' . get_class( $func[0] ) . '::' . $func[1];
$profName = $fname . '-extensions-' . implode( '::', $func );
$profName = $fname . '-extensions-' . implode( '::', $func );
} else {
$profName = $fname . '-extensions-' . strval( $func );
}
} else {
$profName = $fname . '-extensions-' . strval( $func );
}
*/
protected function getSetting( $settingName, $wiki, /*array*/ $params ) {
$retval = null;
*/
protected function getSetting( $settingName, $wiki, /*array*/ $params ) {
$retval = null;
- if( array_key_exists( $settingName, $this->settings ) ) {
+ if ( array_key_exists( $settingName, $this->settings ) ) {
$thisSetting =& $this->settings[$settingName];
do {
// Do individual wiki settings
$thisSetting =& $this->settings[$settingName];
do {
// Do individual wiki settings
- if( array_key_exists( $wiki, $thisSetting ) ) {
+ if ( array_key_exists( $wiki, $thisSetting ) ) {
$retval = $thisSetting[$wiki];
break;
} elseif ( array_key_exists( "+$wiki", $thisSetting ) && is_array( $thisSetting["+$wiki"] ) ) {
$retval = $thisSetting[$wiki];
break;
} elseif ( array_key_exists( "+$wiki", $thisSetting ) && is_array( $thisSetting["+$wiki"] ) ) {
- foreach( $params['tags'] as $tag ) {
- if( array_key_exists( $tag, $thisSetting ) ) {
+ foreach ( $params['tags'] as $tag ) {
+ if ( array_key_exists( $tag, $thisSetting ) ) {
if ( isset( $retval ) && is_array( $retval ) && is_array( $thisSetting[$tag] ) ) {
$retval = self::arrayMerge( $retval, $thisSetting[$tag] );
} else {
$retval = $thisSetting[$tag];
}
break 2;
if ( isset( $retval ) && is_array( $retval ) && is_array( $thisSetting[$tag] ) ) {
$retval = self::arrayMerge( $retval, $thisSetting[$tag] );
} else {
$retval = $thisSetting[$tag];
}
break 2;
- } elseif( array_key_exists( "+$tag", $thisSetting ) && is_array( $thisSetting["+$tag"] ) ) {
- if( !isset( $retval ) ) {
+ } elseif ( array_key_exists( "+$tag", $thisSetting ) && is_array( $thisSetting["+$tag"] ) ) {
+ if ( !isset( $retval ) ) {
$retval = array();
}
$retval = self::arrayMerge( $retval, $thisSetting["+$tag"] );
$retval = array();
}
$retval = self::arrayMerge( $retval, $thisSetting["+$tag"] );
}
// Do suffix settings
$suffix = $params['suffix'];
}
// Do suffix settings
$suffix = $params['suffix'];
- if( !is_null( $suffix ) ) {
- if( array_key_exists( $suffix, $thisSetting ) ) {
+ if ( !is_null( $suffix ) ) {
+ if ( array_key_exists( $suffix, $thisSetting ) ) {
if ( isset( $retval ) && is_array( $retval ) && is_array( $thisSetting[$suffix] ) ) {
$retval = self::arrayMerge( $retval, $thisSetting[$suffix] );
} else {
if ( isset( $retval ) && is_array( $retval ) && is_array( $thisSetting[$suffix] ) ) {
$retval = self::arrayMerge( $retval, $thisSetting[$suffix] );
} else {
}
// Fall back to default.
}
// Fall back to default.
- if( array_key_exists( 'default', $thisSetting ) ) {
- if( is_array( $retval ) && is_array( $thisSetting['default'] ) ) {
+ if ( array_key_exists( 'default', $thisSetting ) ) {
+ if ( is_array( $retval ) && is_array( $thisSetting['default'] ) ) {
$retval = self::arrayMerge( $retval, $thisSetting['default'] );
} else {
$retval = $thisSetting['default'];
$retval = self::arrayMerge( $retval, $thisSetting['default'] );
} else {
$retval = $thisSetting['default'];
- if( !is_null( $retval ) && count( $params['params'] ) ) {
+ if ( !is_null( $retval ) && count( $params['params'] ) ) {
foreach ( $params['params'] as $key => $value ) {
$retval = $this->doReplace( '$' . $key, $value, $retval );
}
foreach ( $params['params'] as $key => $value ) {
$retval = $this->doReplace( '$' . $key, $value, $retval );
}
* @return string
*/
function doReplace( $from, $to, $in ) {
* @return string
*/
function doReplace( $from, $to, $in ) {
- if( is_string( $in ) ) {
+ if ( is_string( $in ) ) {
return str_replace( $from, $to, $in );
return str_replace( $from, $to, $in );
- } elseif( is_array( $in ) ) {
- foreach( $in as $key => $val ) {
+ } elseif ( is_array( $in ) ) {
+ foreach ( $in as $key => $val ) {
$in[$key] = $this->doReplace( $from, $to, $val );
}
return $in;
$in[$key] = $this->doReplace( $from, $to, $val );
}
return $in;
public function getAll( $wiki, $suffix = null, $params = array(), $wikiTags = array() ) {
$params = $this->mergeParams( $wiki, $suffix, $params, $wikiTags );
$localSettings = array();
public function getAll( $wiki, $suffix = null, $params = array(), $wikiTags = array() ) {
$params = $this->mergeParams( $wiki, $suffix, $params, $wikiTags );
$localSettings = array();
- foreach( $this->settings as $varname => $stuff ) {
+ foreach ( $this->settings as $varname => $stuff ) {
$append = false;
$var = $varname;
if ( substr( $varname, 0, 1 ) == '+' ) {
$append = false;
$var = $varname;
if ( substr( $varname, 0, 1 ) == '+' ) {
- if( !is_callable( $this->siteParamsCallback ) ) {
+ if ( !is_callable( $this->siteParamsCallback ) ) {
return $default;
}
$ret = call_user_func_array( $this->siteParamsCallback, array( $this, $wiki ) );
# Validate the returned value
return $default;
}
$ret = call_user_func_array( $this->siteParamsCallback, array( $this, $wiki ) );
# Validate the returned value
- if( !is_array( $ret ) ) {
+ if ( !is_array( $ret ) ) {
- foreach( $default as $name => $def ) {
- if( !isset( $ret[$name] ) || ( is_array( $default[$name] ) && !is_array( $ret[$name] ) ) ) {
+ foreach ( $default as $name => $def ) {
+ if ( !isset( $ret[$name] ) || ( is_array( $default[$name] ) && !is_array( $ret[$name] ) ) ) {
$ret[$name] = $default[$name];
}
}
$ret[$name] = $default[$name];
}
}
protected function mergeParams( $wiki, $suffix, /*array*/ $params, /*array*/ $wikiTags ) {
$ret = $this->getWikiParams( $wiki );
protected function mergeParams( $wiki, $suffix, /*array*/ $params, /*array*/ $wikiTags ) {
$ret = $this->getWikiParams( $wiki );
- if( is_null( $ret['suffix'] ) ) {
+ if ( is_null( $ret['suffix'] ) ) {
$ret['suffix'] = $suffix;
}
$ret['suffix'] = $suffix;
}
$ret['params'] += $params;
// Automatically fill that ones if needed
$ret['params'] += $params;
// Automatically fill that ones if needed
- if( !isset( $ret['params']['lang'] ) && !is_null( $ret['lang'] ) ) {
+ if ( !isset( $ret['params']['lang'] ) && !is_null( $ret['lang'] ) ) {
$ret['params']['lang'] = $ret['lang'];
}
$ret['params']['lang'] = $ret['lang'];
}
- if( !isset( $ret['params']['site'] ) && !is_null( $ret['suffix'] ) ) {
+ if ( !isset( $ret['params']['site'] ) && !is_null( $ret['suffix'] ) ) {
$ret['params']['site'] = $ret['suffix'];
}
$ret['params']['site'] = $ret['suffix'];
}
public function siteFromDB( $db ) {
// Allow override
$def = $this->getWikiParams( $db );
public function siteFromDB( $db ) {
// Allow override
$def = $this->getWikiParams( $db );
- if( !is_null( $def['suffix'] ) && !is_null( $def['lang'] ) ) {
+ if ( !is_null( $def['suffix'] ) && !is_null( $def['lang'] ) ) {
return array( $def['suffix'], $def['lang'] );
}
return array( $def['suffix'], $def['lang'] );
}
*/
static function arrayMerge( $array1/* ... */ ) {
$out = $array1;
*/
static function arrayMerge( $array1/* ... */ ) {
$out = $array1;
- for( $i = 1; $i < func_num_args(); $i++ ) {
- foreach( func_get_arg( $i ) as $key => $value ) {
+ for ( $i = 1; $i < func_num_args(); $i++ ) {
+ foreach ( func_get_arg( $i ) as $key => $value ) {
if ( isset( $out[$key] ) && is_array( $out[$key] ) && is_array( $value ) ) {
$out[$key] = self::arrayMerge( $out[$key], $value );
} elseif ( !isset( $out[$key] ) || !$out[$key] && !is_numeric( $key ) ) {
if ( isset( $out[$key] ) && is_array( $out[$key] ) && is_array( $value ) ) {
$out[$key] = self::arrayMerge( $out[$key], $value );
} elseif ( !isset( $out[$key] ) || !$out[$key] && !is_numeric( $key ) ) {
wfDebug( __METHOD__ . ": reading site_stats from slave\n" );
$row = self::doLoad( wfGetDB( DB_SLAVE ) );
wfDebug( __METHOD__ . ": reading site_stats from slave\n" );
$row = self::doLoad( wfGetDB( DB_SLAVE ) );
- if( !self::isSane( $row ) ) {
+ if ( !self::isSane( $row ) ) {
// Might have just been initialized during this request? Underflow?
wfDebug( __METHOD__ . ": site_stats damaged or missing on slave\n" );
$row = self::doLoad( wfGetDB( DB_MASTER ) );
}
// Might have just been initialized during this request? Underflow?
wfDebug( __METHOD__ . ": site_stats damaged or missing on slave\n" );
$row = self::doLoad( wfGetDB( DB_MASTER ) );
}
- if( !self::isSane( $row ) ) {
+ if ( !self::isSane( $row ) ) {
// Normally the site_stats table is initialized at install time.
// Some manual construction scenarios may leave the table empty or
// broken, however, for instance when importing from a dump into a
// Normally the site_stats table is initialized at install time.
// Some manual construction scenarios may leave the table empty or
// broken, however, for instance when importing from a dump into a
$row = self::doLoad( wfGetDB( DB_MASTER ) );
}
$row = self::doLoad( wfGetDB( DB_MASTER ) );
}
- if( !self::isSane( $row ) ) {
+ if ( !self::isSane( $row ) ) {
wfDebug( __METHOD__ . ": site_stats persistently nonsensical o_O\n" );
}
return $row;
wfDebug( __METHOD__ . ": site_stats persistently nonsensical o_O\n" );
}
return $row;
*/
static function pagesInNs( $ns ) {
wfProfileIn( __METHOD__ );
*/
static function pagesInNs( $ns ) {
wfProfileIn( __METHOD__ );
- if( !isset( self::$pageCount[$ns] ) ) {
+ if ( !isset( self::$pageCount[$ns] ) ) {
$dbr = wfGetDB( DB_SLAVE );
self::$pageCount[$ns] = (int)$dbr->selectField(
'page',
$dbr = wfGetDB( DB_SLAVE );
self::$pageCount[$ns] = (int)$dbr->selectField(
'page',
* @return bool
*/
private static function isSane( $row ) {
* @return bool
*/
private static function isSane( $row ) {
$row === false
|| $row->ss_total_pages < $row->ss_good_articles
|| $row->ss_total_edits < $row->ss_total_pages
$row === false
|| $row->ss_total_pages < $row->ss_good_articles
|| $row->ss_total_edits < $row->ss_total_pages
return false;
}
// Now check for underflow/overflow
return false;
}
// Now check for underflow/overflow
- foreach( array( 'total_views', 'total_edits', 'good_articles',
+ foreach ( array( 'total_views', 'total_edits', 'good_articles',
'total_pages', 'users', 'images' ) as $member ) {
'total_pages', 'users', 'images' ) as $member ) {
$row->{"ss_$member"} > 2000000000
|| $row->{"ss_$member"} < 0
) {
$row->{"ss_$member"} > 2000000000
|| $row->{"ss_$member"} < 0
) {
$counter->files();
// Only do views if we don't want to not count them
$counter->files();
// Only do views if we don't want to not count them
- if( $options['views'] ) {
+ if ( $options['views'] ) {
$counter->views();
}
// Update/refresh
$counter->views();
}
// Update/refresh
- if( $options['update'] ) {
+ if ( $options['update'] ) {
$counter->update();
} else {
$counter->refresh();
}
// Count active users if need be
$counter->update();
} else {
$counter->refresh();
}
// Count active users if need be
- if( $options['activeUsers'] ) {
+ if ( $options['activeUsers'] ) {
SiteStatsUpdate::cacheUpdate( wfGetDB( DB_MASTER ) );
}
}
SiteStatsUpdate::cacheUpdate( wfGetDB( DB_MASTER ) );
}
}
*/
static function getSkinNameMessages() {
$messages = array();
*/
static function getSkinNameMessages() {
$messages = array();
- foreach( self::getSkinNames() as $skinKey => $skinName ) {
+ foreach ( self::getSkinNames() as $skinKey => $skinName ) {
$messages[] = "skinname-$skinKey";
}
return $messages;
$messages[] = "skinname-$skinKey";
}
return $messages;
return $this->mRelevantUser;
}
$title = $this->getRelevantTitle();
return $this->mRelevantUser;
}
$title = $this->getRelevantTitle();
- if( $title->hasSubjectNamespace( NS_USER ) ) {
+ if ( $title->hasSubjectNamespace( NS_USER ) ) {
$rootUser = $title->getRootText();
if ( User::isIP( $rootUser ) ) {
$this->mRelevantUser = User::newFromName( $rootUser, false );
$rootUser = $title->getRootText();
if ( User::isIP( $rootUser ) ) {
$this->mRelevantUser = User::newFromName( $rootUser, false );
if ( $c > 1 ) {
$subpages .= $wgLang->getDirMarkEntity() . $this->msg( 'pipe-separator' )->escaped();
if ( $c > 1 ) {
$subpages .= $wgLang->getDirMarkEntity() . $this->msg( 'pipe-separator' )->escaped();
*/
static function makeSpecialUrl( $name, $urlaction = '', $proto = null ) {
$title = SpecialPage::getSafeTitleFor( $name );
*/
static function makeSpecialUrl( $name, $urlaction = '', $proto = null ) {
$title = SpecialPage::getSafeTitleFor( $name );
- if( is_null( $proto ) ) {
+ if ( is_null( $proto ) ) {
return $title->getLocalURL( $urlaction );
} else {
return $title->getFullURL( $urlaction, false, $proto );
return $title->getLocalURL( $urlaction );
} else {
return $title->getFullURL( $urlaction, false, $proto );
- if( $name === 'default' ) {
+ if ( $name === 'default' ) {
// special case
global $wgSiteNotice;
$notice = $wgSiteNotice;
// special case
global $wgSiteNotice;
$notice = $wgSiteNotice;
- if( empty( $notice ) ) {
+ if ( empty( $notice ) ) {
wfProfileOut( __METHOD__ );
return false;
}
} else {
$msg = $this->msg( $name )->inContentLanguage();
wfProfileOut( __METHOD__ );
return false;
}
} else {
$msg = $this->msg( $name )->inContentLanguage();
- if( $msg->isDisabled() ) {
+ if ( $msg->isDisabled() ) {
wfProfileOut( __METHOD__ );
return false;
}
wfProfileOut( __METHOD__ );
return false;
}
// Use the extra hash appender to let eg SSL variants separately cache.
$key = wfMemcKey( $name . $wgRenderHashAppend );
$cachedNotice = $parserMemc->get( $key );
// Use the extra hash appender to let eg SSL variants separately cache.
$key = wfMemcKey( $name . $wgRenderHashAppend );
$cachedNotice = $parserMemc->get( $key );
- if( is_array( $cachedNotice ) ) {
- if( md5( $notice ) == $cachedNotice['hash'] ) {
+ if ( is_array( $cachedNotice ) ) {
+ if ( md5( $notice ) == $cachedNotice['hash'] ) {
$notice = $cachedNotice['html'];
} else {
$needParse = true;
$notice = $cachedNotice['html'];
} else {
$needParse = true;
$ret = array();
$items = array( 'viewcount', 'credits', 'lastmod', 'numberofwatchingusers', 'copyright' );
$ret = array();
$items = array( 'viewcount', 'credits', 'lastmod', 'numberofwatchingusers', 'copyright' );
- foreach( $items as $item ) {
+ foreach ( $items as $item ) {
if ( $this->data[$item] !== false ) {
$ret[] = $this->data[$item];
}
if ( $this->data[$item] !== false ) {
$ret[] = $this->data[$item];
}
case NS_FILE:
$text = wfMessage( 'imagepage' );
# Make link known if image exists, even if the desc. page doesn't.
case NS_FILE:
$text = wfMessage( 'imagepage' );
# Make link known if image exists, even if the desc. page doesn't.
- if ( wfFindFile( $link ) )
+ if ( wfFindFile( $link ) ) {
$linkOptions[] = 'known';
$linkOptions[] = 'known';
break;
case NS_MEDIAWIKI:
$text = wfMessage( 'mediawikipage' );
break;
case NS_MEDIAWIKI:
$text = wfMessage( 'mediawikipage' );
$value = wfMessage( $value )->text();
// interpolate variables
$m = array();
$value = wfMessage( $value )->text();
// interpolate variables
$m = array();
- while( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
+ while ( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
list( $src, $var ) = $m;
wfSuppressWarnings();
$varValue = $this->_context[$var];
list( $src, $var ) = $m;
wfSuppressWarnings();
$varValue = $this->_context[$var];
$language_urls = array();
if ( !$wgHideInterlanguageLinks ) {
$language_urls = array();
if ( !$wgHideInterlanguageLinks ) {
- foreach( $out->getLanguageLinks() as $languageLinkText ) {
+ foreach ( $out->getLanguageLinks() as $languageLinkText ) {
$languageLinkParts = explode( ':', $languageLinkText, 2 );
$class = 'interwiki-' . $languageLinkParts[0];
unset( $languageLinkParts );
$languageLinkParts = explode( ':', $languageLinkText, 2 );
$class = 'interwiki-' . $languageLinkParts[0];
unset( $languageLinkParts );
}
$tpl->set( 'catlinks', $this->getCategories() );
}
$tpl->set( 'catlinks', $this->getCategories() );
- if( $out->isSyndicated() ) {
+ if ( $out->isSyndicated() ) {
- foreach( $out->getSyndicationLinks() as $format => $link ) {
+ foreach ( $out->getSyndicationLinks() as $format => $link ) {
$feeds[$format] = array(
'text' => $this->msg( "feed-$format" )->text(),
'href' => $link
$feeds[$format] = array(
'text' => $this->msg( "feed-$format" )->text(),
'href' => $link
$tpl->set( 'reporttime', wfReportTime() );
// original version by hansm
$tpl->set( 'reporttime', wfReportTime() );
// original version by hansm
- if( !wfRunHooks( 'SkinTemplateOutputPageBeforeExec', array( &$this, &$tpl ) ) ) {
+ if ( !wfRunHooks( 'SkinTemplateOutputPageBeforeExec', array( &$this, &$tpl ) ) ) {
wfDebug( __METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n" );
}
wfDebug( __METHOD__ . ": Hook SkinTemplateOutputPageBeforeExec broke outputPage execution!\n" );
}
if ( strval( $page ) !== '' ) {
$a['returnto'] = $page;
$query = $request->getVal( 'returntoquery', $this->thisquery );
if ( strval( $page ) !== '' ) {
$a['returnto'] = $page;
$query = $request->getVal( 'returntoquery', $this->thisquery );
$a['returntoquery'] = $query;
}
}
$a['returntoquery'] = $query;
}
}
}
$returnto = wfArrayToCgi( $a );
}
$returnto = wfArrayToCgi( $a );
- if( $this->loggedin ) {
+ if ( $this->loggedin ) {
$personal_urls['userpage'] = array(
'text' => $this->username,
'href' => &$this->userpageUrlDetails['href'],
$personal_urls['userpage'] = array(
'text' => $this->username,
'href' => &$this->userpageUrlDetails['href'],
# thickens, because the Title object is altered for special pages,
# so it doesn't contain the original alias-with-subpage.
$origTitle = Title::newFromText( $request->getText( 'title' ) );
# thickens, because the Title object is altered for special pages,
# so it doesn't contain the original alias-with-subpage.
$origTitle = Title::newFromText( $request->getText( 'title' ) );
- if( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
+ if ( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
list( $spName, $spPar ) = SpecialPageFactory::resolveAlias( $origTitle->getText() );
$active = $spName == 'Contributions'
&& ( ( $spPar && $spPar == $this->username )
list( $spName, $spPar ) = SpecialPageFactory::resolveAlias( $origTitle->getText() );
$active = $spName == 'Contributions'
&& ( ( $spPar && $spPar == $this->username )
'class' => $wgSecureLogin ? 'link-https' : ''
);
'class' => $wgSecureLogin ? 'link-https' : ''
);
- if( $this->showIPinHeader() ) {
+ if ( $this->showIPinHeader() ) {
$href = &$this->userpageUrlDetails['href'];
$personal_urls['anonuserpage'] = array(
'text' => $this->username,
$href = &$this->userpageUrlDetails['href'];
$personal_urls['anonuserpage'] = array(
'text' => $this->username,
*/
function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
$classes = array();
*/
function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
$classes = array();
$classes[] = 'selected';
}
$classes[] = 'selected';
}
- if( $checkEdit && !$title->isKnown() ) {
+ if ( $checkEdit && !$title->isKnown() ) {
$classes[] = 'new';
if ( $query !== '' ) {
$query = 'action=edit&redlink=1&' . $query;
$classes[] = 'new';
if ( $query !== '' ) {
$query = 'action=edit&redlink=1&' . $query;
- if( !wfRunHooks( 'SkinTemplateTabAction', array( &$this,
+ if ( !wfRunHooks( 'SkinTemplateTabAction', array( &$this,
$title, $message, $selected, $checkEdit,
&$classes, &$query, &$text, &$result ) ) ) {
return $result;
$title, $message, $selected, $checkEdit,
&$classes, &$query, &$text, &$result ) ) ) {
return $result;
function makeTalkUrlDetails( $name, $urlaction = '' ) {
$title = Title::newFromText( $name );
function makeTalkUrlDetails( $name, $urlaction = '' ) {
$title = Title::newFromText( $name );
- if( !is_object( $title ) ) {
+ if ( !is_object( $title ) ) {
throw new MWException( __METHOD__ . " given invalid pagename $name" );
}
$title = $title->getTalkPage();
throw new MWException( __METHOD__ . " given invalid pagename $name" );
}
$title = $title->getTalkPage();
wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$preventActiveTabs ) );
// Checks if page is some kind of content
wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$preventActiveTabs ) );
// Checks if page is some kind of content
- if( $title->canExist() ) {
+ if ( $title->canExist() ) {
// Gets page objects for the related namespaces
$subjectPage = $title->getSubjectPage();
$talkPage = $title->getTalkPage();
// Gets page objects for the related namespaces
$subjectPage = $title->getSubjectPage();
$talkPage = $title->getTalkPage();
$params = array();
}
// Loops over each variant
$params = array();
}
// Loops over each variant
- foreach( $variants as $code ) {
+ foreach ( $variants as $code ) {
// Gets variant name from language code
$varname = $pageLang->getVariantname( $code );
// Appends variant link
// Gets variant name from language code
$varname = $pageLang->getVariantname( $code );
// Appends variant link
$nav_urls = array();
$nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
$nav_urls = array();
$nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
- if( $wgUploadNavigationUrl ) {
+ if ( $wgUploadNavigationUrl ) {
$nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
$nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
- } elseif( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getUser() ) === true ) {
+ } elseif ( UploadBase::isEnabled() && UploadBase::isAllowed( $this->getUser() ) === true ) {
$nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
} else {
$nav_urls['upload'] = false;
$nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
} else {
$nav_urls['upload'] = false;
$ptool['active'] = $plink['active'];
}
foreach ( array( 'href', 'class', 'text' ) as $k ) {
$ptool['active'] = $plink['active'];
}
foreach ( array( 'href', 'class', 'text' ) as $k ) {
- if ( isset( $plink[$k] ) )
+ if ( isset( $plink[$k] ) ) {
$ptool['links'][0][$k] = $plink[$k];
$ptool['links'][0][$k] = $plink[$k];
}
$personal_tools[$key] = $ptool;
}
}
$personal_tools[$key] = $ptool;
}
case 'SEARCH':
// Search is a special case, skins should custom implement this
$boxes[$boxName] = array(
case 'SEARCH':
// Search is a special case, skins should custom implement this
$boxes[$boxName] = array(
- 'id' => 'p-search',
- 'header' => $this->getMsg( 'search' )->text(),
+ 'id' => 'p-search',
+ 'header' => $this->getMsg( 'search' )->text(),
);
break;
case 'TOOLBOX':
$msgObj = $this->getMsg( 'toolbox' );
$boxes[$boxName] = array(
);
break;
case 'TOOLBOX':
$msgObj = $this->getMsg( 'toolbox' );
$boxes[$boxName] = array(
- 'id' => 'p-tb',
- 'header' => $msgObj->exists() ? $msgObj->text() : 'toolbox',
+ 'id' => 'p-tb',
+ 'header' => $msgObj->exists() ? $msgObj->text() : 'toolbox',
- 'content' => $this->getToolbox(),
+ 'content' => $this->getToolbox(),
);
break;
case 'LANGUAGES':
if ( $this->data['language_urls'] ) {
$msgObj = $this->getMsg( 'otherlanguages' );
$boxes[$boxName] = array(
);
break;
case 'LANGUAGES':
if ( $this->data['language_urls'] ) {
$msgObj = $this->getMsg( 'otherlanguages' );
$boxes[$boxName] = array(
- 'id' => 'p-lang',
- 'header' => $msgObj->exists() ? $msgObj->text() : 'otherlanguages',
+ 'id' => 'p-lang',
+ 'header' => $msgObj->exists() ? $msgObj->text() : 'otherlanguages',
- 'content' => $this->data['language_urls'],
+ 'content' => $this->data['language_urls'],
);
}
break;
default:
$msgObj = $this->getMsg( $boxName );
$boxes[$boxName] = array(
);
}
break;
default:
$msgObj = $this->getMsg( $boxName );
$boxes[$boxName] = array(
- 'id' => "p-$boxName",
- 'header' => $msgObj->exists() ? $msgObj->text() : $boxName,
+ 'id' => "p-$boxName",
+ 'header' => $msgObj->exists() ? $msgObj->text() : $boxName,
} else {
if ( $hookContents ) {
$boxes['TOOLBOXEND'] = array(
} else {
if ( $hookContents ) {
$boxes['TOOLBOXEND'] = array(
- 'id' => 'p-toolboxend',
- 'header' => $boxes['TOOLBOX']['header'],
+ 'id' => 'p-toolboxend',
+ 'header' => $boxes['TOOLBOX']['header'],
- 'content' => "<ul>{$hookContents}</ul>",
+ 'content' => "<ul>{$hookContents}</ul>",
);
// HACK: Make sure that TOOLBOXEND is sorted next to TOOLBOX
$boxes2 = array();
);
// HACK: Make sure that TOOLBOXEND is sorted next to TOOLBOX
$boxes2 = array();
// Reduce footer links down to only those which are being used
$validFooterLinks = array();
// Reduce footer links down to only those which are being used
$validFooterLinks = array();
- foreach( $footerlinks as $category => $links ) {
+ foreach ( $footerlinks as $category => $links ) {
$validFooterLinks[$category] = array();
$validFooterLinks[$category] = array();
- foreach( $links as $link ) {
- if( isset( $this->data[$link] ) && $this->data[$link] ) {
+ foreach ( $links as $link ) {
+ if ( isset( $this->data[$link] ) && $this->data[$link] ) {
$validFooterLinks[$category][] = $link;
}
}
$validFooterLinks[$category][] = $link;
}
}
self::$mList['ChangeEmail'] = 'SpecialChangeEmail';
}
self::$mList['ChangeEmail'] = 'SpecialChangeEmail';
}
- if( $wgEnableJavaScriptTest ) {
+ if ( $wgEnableJavaScriptTest ) {
self::$mList['JavaScriptTest'] = 'SpecialJavaScriptTest';
}
self::$mList['JavaScriptTest'] = 'SpecialJavaScriptTest';
}
*/
protected function getErrorMessage( $error ) {
if ( is_array( $error ) ) {
*/
protected function getErrorMessage( $error ) {
if ( is_array( $error ) ) {
- if( isset( $error['message'] ) && $error['message'] instanceof Message ) {
+ if ( isset( $error['message'] ) && $error['message'] instanceof Message ) {
$msg = $error['message'];
} elseif ( isset( $error['message'] ) && isset( $error['params'] ) ) {
$msg = wfMessage( $error['message'],
$msg = $error['message'];
} elseif ( isset( $error['message'] ) && isset( $error['params'] ) ) {
$msg = wfMessage( $error['message'],
$result = array();
foreach ( $this->errors as $error ) {
if ( $error['type'] === $type ) {
$result = array();
foreach ( $this->errors as $error ) {
if ( $error['type'] === $type ) {
- if( $error['message'] instanceof Message ) {
+ if ( $error['message'] instanceof Message ) {
$result[] = $error['message'];
$result[] = $error['message'];
- } elseif( $error['params'] ) {
+ } elseif ( $error['params'] ) {
$result[] = array_merge( array( $error['message'] ), $error['params'] );
} else {
$result[] = array( $error['message'] );
$result[] = array_merge( array( $error['message'] ), $error['params'] );
} else {
$result[] = array( $error['message'] );
// Explode, then put the replaced separators back in
$items = explode( $separator, $cleaned );
// Explode, then put the replaced separators back in
$items = explode( $separator, $cleaned );
- foreach( $items as $i => $str ) {
+ foreach ( $items as $i => $str ) {
$items[$i] = str_replace( $placeholder, $separator, $str );
}
$items[$i] = str_replace( $placeholder, $separator, $str );
}
* @param $data array
*/
function removeArray( $data ) {
* @param $data array
*/
function removeArray( $data ) {
- foreach( $data as $from => $to ) {
+ foreach ( $data as $from => $to ) {
$this->removePair( $from );
}
$this->fss = false;
$this->removePair( $from );
}
$this->fss = false;
throw new TimestampException( __METHOD__ . " : Invalid timestamp - $ts" );
}
throw new TimestampException( __METHOD__ . " : Invalid timestamp - $ts" );
}
$da = array_map( 'intval', $da );
$da[0] = "%04d-%02d-%02dT%02d:%02d:%02d.00+00:00";
$strtime = call_user_func_array( "sprintf", $da );
$da = array_map( 'intval', $da );
$da[0] = "%04d-%02d-%02dT%02d:%02d:%02d.00+00:00";
$strtime = call_user_func_array( "sprintf", $da );
throw new TimestampException( __METHOD__ . ' Invalid timestamp format.' );
}
throw new TimestampException( __METHOD__ . ' Invalid timestamp format.' );
}
- if( $final === false ) {
+ if ( $final === false ) {
throw new TimestampException( __METHOD__ . ' Invalid timestamp format.' );
}
$this->timestamp = $final;
throw new TimestampException( __METHOD__ . ' Invalid timestamp format.' );
}
$this->timestamp = $final;
* @return string The formatted timestamp
*/
public function getTimestamp( $style = TS_UNIX ) {
* @return string The formatted timestamp
*/
public function getTimestamp( $style = TS_UNIX ) {
- if( !isset( self::$formats[$style] ) ) {
+ if ( !isset( self::$formats[$style] ) ) {
throw new TimestampException( __METHOD__ . ' : Illegal timestamp output type.' );
}
throw new TimestampException( __METHOD__ . ' : Illegal timestamp output type.' );
}
- if( is_object( $this->timestamp ) ) {
+ if ( is_object( $this->timestamp ) ) {
// DateTime object was used, call DateTime::format.
$output = $this->timestamp->format( self::$formats[$style] );
// DateTime object was used, call DateTime::format.
$output = $this->timestamp->format( self::$formats[$style] );
- } elseif( TS_UNIX == $style ) {
+ } elseif ( TS_UNIX == $style ) {
// Unix timestamp was used and is wanted, just return it.
$output = $this->timestamp;
} else {
// Unix timestamp was used and is wanted, just return it.
$output = $this->timestamp;
} else {
$timeago = ($now - $then) * 1000;
$message = false;
$timeago = ($now - $then) * 1000;
$message = false;
- foreach( self::$units as $unit => $factor ) {
+ foreach ( self::$units as $unit => $factor ) {
$next = $timeago / $factor;
$next = $timeago / $factor;
break;
} else {
$timeago = $next;
break;
} else {
$timeago = $next;
$initial = call_user_func_array( 'wfMessage', $message );
return wfMessage( 'ago', $initial->parse() );
} else {
$initial = call_user_func_array( 'wfMessage', $message );
return wfMessage( 'ago', $initial->parse() );
} else {
$this->loadFromId();
break;
case 'session':
$this->loadFromId();
break;
case 'session':
- if( !$this->loadFromSession() ) {
+ if ( !$this->loadFromSession() ) {
// Loading from session failed. Load defaults.
$this->loadDefaults();
}
// Loading from session failed. Load defaults.
$this->loadDefaults();
}
'user_email_token' => md5( $code ),
'user_email_token_expires > ' . $dbr->addQuotes( $dbr->timestamp() ),
) );
'user_email_token' => md5( $code ),
'user_email_token_expires > ' . $dbr->addQuotes( $dbr->timestamp() ),
) );
return User::newFromId( $id );
} else {
return null;
return User::newFromId( $id );
} else {
return null;
*/
public static function idFromName( $name ) {
$nt = Title::makeTitleSafe( NS_USER, $name );
*/
public static function idFromName( $name ) {
$nt = Title::makeTitleSafe( NS_USER, $name );
+ if ( is_null( $nt ) ) {
# Illegal name
return null;
}
# Illegal name
return null;
}
// Ensure that the name can't be misresolved as a different title,
// such as with extra namespace keys at the start.
$parsed = Title::newFromText( $name );
// Ensure that the name can't be misresolved as a different title,
// such as with extra namespace keys at the start.
$parsed = Title::newFromText( $name );
+ if ( is_null( $parsed )
|| $parsed->getNamespace()
|| strcmp( $name, $parsed->getPrefixedText() ) ) {
wfDebugLog( 'username', __METHOD__ .
|| $parsed->getNamespace()
|| strcmp( $name, $parsed->getPrefixedText() ) ) {
wfDebugLog( 'username', __METHOD__ .
'\x{3000}' . # ideographic space
'\x{e000}-\x{f8ff}' . # private use
']/u';
'\x{3000}' . # ideographic space
'\x{e000}-\x{f8ff}' . # private use
']/u';
- if( preg_match( $unicodeBlacklist, $name ) ) {
+ if ( preg_match( $unicodeBlacklist, $name ) ) {
wfDebugLog( 'username', __METHOD__ .
": '$name' invalid due to blacklisted characters" );
return false;
wfDebugLog( 'username', __METHOD__ .
": '$name' invalid due to blacklisted characters" );
return false;
// Ensure that the username isn't longer than 235 bytes, so that
// (at least for the builtin skins) user javascript and css files
// will work. (bug 23080)
// Ensure that the username isn't longer than 235 bytes, so that
// (at least for the builtin skins) user javascript and css files
// will work. (bug 23080)
- if( strlen( $name ) > 235 ) {
+ if ( strlen( $name ) > 235 ) {
wfDebugLog( 'username', __METHOD__ .
": '$name' invalid due to length" );
return false;
}
// Preg yells if you try to give it an empty string
wfDebugLog( 'username', __METHOD__ .
": '$name' invalid due to length" );
return false;
}
// Preg yells if you try to give it an empty string
- if( $wgInvalidUsernameCharacters !== '' ) {
- if( preg_match( '/[' . preg_quote( $wgInvalidUsernameCharacters, '/' ) . ']/', $name ) ) {
+ if ( $wgInvalidUsernameCharacters !== '' ) {
+ if ( preg_match( '/[' . preg_quote( $wgInvalidUsernameCharacters, '/' ) . ']/', $name ) ) {
wfDebugLog( 'username', __METHOD__ .
": '$name' invalid due to wgInvalidUsernameCharacters" );
return false;
wfDebugLog( 'username', __METHOD__ .
": '$name' invalid due to wgInvalidUsernameCharacters" );
return false;
$result = false; //init $result to false for the internal checks
$result = false; //init $result to false for the internal checks
- if( !wfRunHooks( 'isValidPassword', array( $password, &$result, $this ) ) )
+ if ( !wfRunHooks( 'isValidPassword', array( $password, &$result, $this ) ) ) {
if ( $result === false ) {
if ( $result === false ) {
- if( strlen( $password ) < $wgMinimalPasswordLength ) {
+ if ( strlen( $password ) < $wgMinimalPasswordLength ) {
return 'passwordtooshort';
} elseif ( $wgContLang->lc( $password ) == $wgContLang->lc( $this->mName ) ) {
return 'password-name-match';
return 'passwordtooshort';
} elseif ( $wgContLang->lc( $password ) == $wgContLang->lc( $this->mName ) ) {
return 'password-name-match';
//a valid password.
return true;
}
//a valid password.
return true;
}
- } elseif( $result === true ) {
+ } elseif ( $result === true ) {
return true;
} else {
return $result; //the isValidPassword hook set a string $result and returned true
return true;
} else {
return $result; //the isValidPassword hook set a string $result and returned true
# Reject names containing '#'; these will be cleaned up
# with title normalisation, but then it's too late to
# check elsewhere
# Reject names containing '#'; these will be cleaned up
# with title normalisation, but then it's too late to
# check elsewhere
- if( strpos( $name, '#' ) !== false )
+ if ( strpos( $name, '#' ) !== false ) {
# Clean up name according to title rules
$t = ( $validate === 'valid' ) ?
Title::newFromText( $name ) : Title::makeTitle( NS_USER, $name );
# Check for invalid titles
# Clean up name according to title rules
$t = ( $validate === 'valid' ) ?
Title::newFromText( $name ) : Title::makeTitle( NS_USER, $name );
# Check for invalid titles
$this->mOptionsLoaded = false;
$loggedOut = $this->getRequest()->getCookie( 'LoggedOut' );
$this->mOptionsLoaded = false;
$loggedOut = $this->getRequest()->getCookie( 'LoggedOut' );
- if( $loggedOut !== null ) {
+ if ( $loggedOut !== null ) {
$this->mTouched = wfTimestamp( TS_MW, $loggedOut );
} else {
$this->mTouched = '1'; # Allow any pages to be cached
$this->mTouched = wfTimestamp( TS_MW, $loggedOut );
} else {
$this->mTouched = '1'; # Allow any pages to be cached
if ( $cookieId !== null ) {
$sId = intval( $cookieId );
if ( $cookieId !== null ) {
$sId = intval( $cookieId );
- if( $sessId !== null && $cookieId != $sessId ) {
+ if ( $sessId !== null && $cookieId != $sessId ) {
wfDebugLog( 'loginSessions', "Session user ID ($sessId) and
cookie user ID ($sId) don't match!" );
return false;
wfDebugLog( 'loginSessions', "Session user ID ($sessId) and
cookie user ID ($sId) don't match!" );
return false;
}
global $wgBlockDisablesLogin;
}
global $wgBlockDisablesLogin;
- if( $wgBlockDisablesLogin && $proposedUser->isBlocked() ) {
+ if ( $wgBlockDisablesLogin && $proposedUser->isBlocked() ) {
# User blocked and we've disabled blocked user logins
return false;
}
# User blocked and we've disabled blocked user logins
return false;
}
$this->mId = intval( $this->mId );
/** Anonymous user */
$this->mId = intval( $this->mId );
/** Anonymous user */
$this->loadDefaults();
return false;
}
$this->loadDefaults();
return false;
}
# default language setting
$defOpt['variant'] = $wgContLang->getCode();
$defOpt['language'] = $wgContLang->getCode();
# default language setting
$defOpt['variant'] = $wgContLang->getCode();
$defOpt['language'] = $wgContLang->getCode();
- foreach( SearchEngine::searchableNamespaces() as $nsnum => $nsname ) {
+ foreach ( SearchEngine::searchableNamespaces() as $nsnum => $nsname ) {
$defOpt['searchNs' . $nsnum] = !empty( $wgNamespacesToBeSearchedDefault[$nsnum] );
}
$defOpt['skin'] = $wgDefaultSkin;
$defOpt['searchNs' . $nsnum] = !empty( $wgNamespacesToBeSearchedDefault[$nsnum] );
}
$defOpt['skin'] = $wgDefaultSkin;
*/
public static function getDefaultOption( $opt ) {
$defOpts = self::getDefaultOptions();
*/
public static function getDefaultOption( $opt ) {
$defOpts = self::getDefaultOptions();
- if( isset( $defOpts[$opt] ) ) {
+ if ( isset( $defOpts[$opt] ) ) {
return $defOpts[$opt];
} else {
return null;
return $defOpts[$opt];
} else {
return null;
global $wgEnableSorbs, $wgEnableDnsBlacklist,
$wgSorbsUrl, $wgDnsBlacklistUrls, $wgProxyWhitelist;
global $wgEnableSorbs, $wgEnableDnsBlacklist,
$wgSorbsUrl, $wgDnsBlacklistUrls, $wgProxyWhitelist;
- if ( !$wgEnableDnsBlacklist && !$wgEnableSorbs )
+ if ( !$wgEnableDnsBlacklist && !$wgEnableSorbs ) {
- if ( $checkWhitelist && in_array( $ip, $wgProxyWhitelist ) )
+ if ( $checkWhitelist && in_array( $ip, $wgProxyWhitelist ) ) {
$urls = array_merge( $wgDnsBlacklistUrls, (array)$wgSorbsUrl );
return $this->inDnsBlacklist( $ip, $urls );
$urls = array_merge( $wgDnsBlacklistUrls, (array)$wgSorbsUrl );
return $this->inDnsBlacklist( $ip, $urls );
$found = false;
// @todo FIXME: IPv6 ??? (http://bugs.php.net/bug.php?id=33170)
$found = false;
// @todo FIXME: IPv6 ??? (http://bugs.php.net/bug.php?id=33170)
- if( IP::isIPv4( $ip ) ) {
+ if ( IP::isIPv4( $ip ) ) {
# Reverse IP, bug 21255
$ipReversed = implode( '.', array_reverse( explode( '.', $ip ) ) );
# Reverse IP, bug 21255
$ipReversed = implode( '.', array_reverse( explode( '.', $ip ) ) );
- foreach( (array)$bases as $base ) {
+ foreach ( (array)$bases as $base ) {
# Make hostname
# If we have an access key, use that too (ProjectHoneypot, etc.)
# Make hostname
# If we have an access key, use that too (ProjectHoneypot, etc.)
- if( is_array( $base ) ) {
- if( count( $base ) >= 2 ) {
+ if ( is_array( $base ) ) {
+ if ( count( $base ) >= 2 ) {
# Access key is 1, base URL is 0
$host = "{$base[1]}.$ipReversed.{$base[0]}";
} else {
# Access key is 1, base URL is 0
$host = "{$base[1]}.$ipReversed.{$base[0]}";
} else {
# Send query
$ipList = gethostbynamel( $host );
# Send query
$ipList = gethostbynamel( $host );
wfDebugLog( 'dnsblacklist', "Hostname $host is {$ipList[0]}, it's a proxy says $base!\n" );
$found = true;
break;
wfDebugLog( 'dnsblacklist', "Hostname $host is {$ipList[0]}, it's a proxy says $base!\n" );
$found = true;
break;
*/
public function isPingLimitable() {
global $wgRateLimitsExcludedIPs;
*/
public function isPingLimitable() {
global $wgRateLimitsExcludedIPs;
- if( in_array( $this->getRequest()->getIP(), $wgRateLimitsExcludedIPs ) ) {
+ if ( in_array( $this->getRequest()->getIP(), $wgRateLimitsExcludedIPs ) ) {
// No other good way currently to disable rate limits
// for specific IPs. :P
// But this is a crappy hack and should die.
// No other good way currently to disable rate limits
// for specific IPs. :P
// But this is a crappy hack and should die.
public function pingLimiter( $action = 'edit' ) {
# Call the 'PingLimiter' hook
$result = false;
public function pingLimiter( $action = 'edit' ) {
# Call the 'PingLimiter' hook
$result = false;
- if( !wfRunHooks( 'PingLimiter', array( &$this, $action, &$result ) ) ) {
+ if ( !wfRunHooks( 'PingLimiter', array( &$this, $action, &$result ) ) ) {
return $result;
}
global $wgRateLimits;
return $result;
}
global $wgRateLimits;
- if( !isset( $wgRateLimits[$action] ) ) {
+ if ( !isset( $wgRateLimits[$action] ) ) {
return false;
}
# Some groups shouldn't trigger the ping limiter, ever
return false;
}
# Some groups shouldn't trigger the ping limiter, ever
- if( !$this->isPingLimitable() )
+ if ( !$this->isPingLimitable() ) {
global $wgMemc, $wgRateLimitLog;
wfProfileIn( __METHOD__ );
global $wgMemc, $wgRateLimitLog;
wfProfileIn( __METHOD__ );
$ip = $this->getRequest()->getIP();
$userLimit = false;
$ip = $this->getRequest()->getIP();
$userLimit = false;
- if( isset( $limits['anon'] ) && $id == 0 ) {
+ if ( isset( $limits['anon'] ) && $id == 0 ) {
$keys[wfMemcKey( 'limiter', $action, 'anon' )] = $limits['anon'];
}
$keys[wfMemcKey( 'limiter', $action, 'anon' )] = $limits['anon'];
}
- if( isset( $limits['user'] ) && $id != 0 ) {
+ if ( isset( $limits['user'] ) && $id != 0 ) {
$userLimit = $limits['user'];
}
$userLimit = $limits['user'];
}
- if( $this->isNewbie() ) {
- if( isset( $limits['newbie'] ) && $id != 0 ) {
+ if ( $this->isNewbie() ) {
+ if ( isset( $limits['newbie'] ) && $id != 0 ) {
$keys[wfMemcKey( 'limiter', $action, 'user', $id )] = $limits['newbie'];
}
$keys[wfMemcKey( 'limiter', $action, 'user', $id )] = $limits['newbie'];
}
- if( isset( $limits['ip'] ) ) {
+ if ( isset( $limits['ip'] ) ) {
$keys["mediawiki:limiter:$action:ip:$ip"] = $limits['ip'];
}
$matches = array();
$keys["mediawiki:limiter:$action:ip:$ip"] = $limits['ip'];
}
$matches = array();
- if( isset( $limits['subnet'] ) && preg_match( '/^(\d+\.\d+\.\d+)\.\d+$/', $ip, $matches ) ) {
+ if ( isset( $limits['subnet'] ) && preg_match( '/^(\d+\.\d+\.\d+)\.\d+$/', $ip, $matches ) ) {
$subnet = $matches[1];
$keys["mediawiki:limiter:$action:subnet:$subnet"] = $limits['subnet'];
}
$subnet = $matches[1];
$keys["mediawiki:limiter:$action:subnet:$subnet"] = $limits['subnet'];
}
- foreach( $keys as $key => $limit ) {
+ foreach ( $keys as $key => $limit ) {
list( $max, $period ) = $limit;
$summary = "(limit $max in {$period}s)";
$count = $wgMemc->get( $key );
// Already pinged?
list( $max, $period ) = $limit;
$summary = "(limit $max in {$period}s)";
$count = $wgMemc->get( $key );
// Already pinged?
- if( $count ) {
- if( $count >= $max ) {
+ if ( $count ) {
+ if ( $count >= $max ) {
wfDebug( __METHOD__ . ": tripped! $key at $count $summary\n" );
wfDebug( __METHOD__ . ": tripped! $key at $count $summary\n" );
- if( $wgRateLimitLog ) {
+ if ( $wgRateLimitLog ) {
wfSuppressWarnings();
file_put_contents( $wgRateLimitLog, wfTimestamp( TS_MW ) . ' ' . wfWikiID() . ': ' . $this->getName() . " tripped $key at $count $summary\n", FILE_APPEND );
wfRestoreWarnings();
wfSuppressWarnings();
file_put_contents( $wgRateLimitLog, wfTimestamp( TS_MW ) . ' ' . wfWikiID() . ': ' . $this->getName() . " tripped $key at $count $summary\n", FILE_APPEND );
wfRestoreWarnings();
* @return Bool True if blocked, false otherwise
*/
public function isBlockedGlobally( $ip = '' ) {
* @return Bool True if blocked, false otherwise
*/
public function isBlockedGlobally( $ip = '' ) {
- if( $this->mBlockedGlobally !== null ) {
+ if ( $this->mBlockedGlobally !== null ) {
return $this->mBlockedGlobally;
}
// User is already an IP?
return $this->mBlockedGlobally;
}
// User is already an IP?
- if( IP::isIPAddress( $this->getName() ) ) {
+ if ( IP::isIPAddress( $this->getName() ) ) {
$ip = $this->getRequest()->getIP();
}
$blocked = false;
$ip = $this->getRequest()->getIP();
}
$blocked = false;
* @return Bool True if locked, false otherwise
*/
public function isLocked() {
* @return Bool True if locked, false otherwise
*/
public function isLocked() {
- if( $this->mLocked !== null ) {
+ if ( $this->mLocked !== null ) {
return $this->mLocked;
}
global $wgAuth;
return $this->mLocked;
}
global $wgAuth;
* @return Bool True if hidden, false otherwise
*/
public function isHidden() {
* @return Bool True if hidden, false otherwise
*/
public function isHidden() {
- if( $this->mHideName !== null ) {
+ if ( $this->mHideName !== null ) {
return $this->mHideName;
}
$this->getBlockedStatus();
return $this->mHideName;
}
$this->getBlockedStatus();
- if( !$this->mHideName ) {
+ if ( !$this->mHideName ) {
global $wgAuth;
$authUser = $wgAuth->getUserInstance( $this );
$this->mHideName = (bool)$authUser->isHidden();
global $wgAuth;
$authUser = $wgAuth->getUserInstance( $this );
$this->mHideName = (bool)$authUser->isHidden();
* @return Int The user's ID; 0 if the user is anonymous or nonexistent
*/
public function getId() {
* @return Int The user's ID; 0 if the user is anonymous or nonexistent
*/
public function getId() {
- if( $this->mId === null && $this->mName !== null
- && User::isIP( $this->mName ) ) {
+ if ( $this->mId === null && $this->mName !== null && User::isIP( $this->mName ) ) {
// Special case, we know the user is anonymous
return 0;
// Special case, we know the user is anonymous
return 0;
- } elseif( !$this->isItemLoaded( 'id' ) ) {
+ } elseif ( !$this->isItemLoaded( 'id' ) ) {
// Don't load if this was initialized from an ID
$this->load();
}
// Don't load if this was initialized from an ID
$this->load();
}
$this->load();
# Load the newtalk status if it is unloaded (mNewtalk=-1)
$this->load();
# Load the newtalk status if it is unloaded (mNewtalk=-1)
- if( $this->mNewtalk === -1 ) {
+ if ( $this->mNewtalk === -1 ) {
$this->mNewtalk = false; # reset talk page status
# Check memcached separately for anons, who have no
# entire User object stored in there.
$this->mNewtalk = false; # reset talk page status
# Check memcached separately for anons, who have no
# entire User object stored in there.
global $wgDisableAnonTalk;
global $wgDisableAnonTalk;
- if( $wgDisableAnonTalk ) {
+ if ( $wgDisableAnonTalk ) {
// Anon newtalk disabled by configuration.
$this->mNewtalk = false;
} else {
global $wgMemc;
$key = wfMemcKey( 'newtalk', 'ip', $this->getName() );
$newtalk = $wgMemc->get( $key );
// Anon newtalk disabled by configuration.
$this->mNewtalk = false;
} else {
global $wgMemc;
$key = wfMemcKey( 'newtalk', 'ip', $this->getName() );
$newtalk = $wgMemc->get( $key );
- if( strval( $newtalk ) !== '' ) {
+ if ( strval( $newtalk ) !== '' ) {
$this->mNewtalk = (bool)$newtalk;
} else {
// Since we are caching this, make sure it is up to date by getting it
$this->mNewtalk = (bool)$newtalk;
} else {
// Since we are caching this, make sure it is up to date by getting it
*/
public function getNewMessageLinks() {
$talks = array();
*/
public function getNewMessageLinks() {
$talks = array();
- if( !wfRunHooks( 'UserRetrieveNewTalks', array( &$this, &$talks ) ) ) {
+ if ( !wfRunHooks( 'UserRetrieveNewTalks', array( &$this, &$talks ) ) ) {
- } elseif( !$this->getNewtalk() ) {
+ } elseif ( !$this->getNewtalk() ) {
return array();
}
$utp = $this->getTalkPage();
return array();
}
$utp = $this->getTalkPage();
* @param $curRev Revision new, as yet unseen revision of the user talk page. Ignored if null or !$val.
*/
public function setNewtalk( $val, $curRev = null ) {
* @param $curRev Revision new, as yet unseen revision of the user talk page. Ignored if null or !$val.
*/
public function setNewtalk( $val, $curRev = null ) {
return;
}
$this->load();
$this->mNewtalk = $val;
return;
}
$this->load();
$this->mNewtalk = $val;
- if( $this->isAnon() ) {
+ if ( $this->isAnon() ) {
$field = 'user_ip';
$id = $this->getName();
} else {
$field = 'user_ip';
$id = $this->getName();
} else {
$changed = $this->updateNewtalk( $field, $id, $curRev );
} else {
$changed = $this->deleteNewtalk( $field, $id );
}
$changed = $this->updateNewtalk( $field, $id, $curRev );
} else {
$changed = $this->deleteNewtalk( $field, $id );
}
- if( $this->isAnon() ) {
+ if ( $this->isAnon() ) {
// Anons have a separate memcached space, since
// user records aren't kept for them.
$key = wfMemcKey( 'newtalk', 'ip', $id );
// Anons have a separate memcached space, since
// user records aren't kept for them.
$key = wfMemcKey( 'newtalk', 'ip', $id );
*/
private function clearSharedCache() {
$this->load();
*/
private function clearSharedCache() {
$this->load();
global $wgMemc;
$wgMemc->delete( wfMemcKey( 'user', 'id', $this->mId ) );
}
global $wgMemc;
$wgMemc->delete( wfMemcKey( 'user', 'id', $this->mId ) );
}
public function setPassword( $str ) {
global $wgAuth;
public function setPassword( $str ) {
global $wgAuth;
- if( $str !== null ) {
- if( !$wgAuth->allowPasswordChange() ) {
+ if ( $str !== null ) {
+ if ( !$wgAuth->allowPasswordChange() ) {
throw new PasswordError( wfMessage( 'password-change-forbidden' )->text() );
}
throw new PasswordError( wfMessage( 'password-change-forbidden' )->text() );
}
- if( !$this->isValidPassword( $str ) ) {
+ if ( !$this->isValidPassword( $str ) ) {
global $wgMinimalPasswordLength;
$valid = $this->getPasswordValidity( $str );
if ( is_array( $valid ) ) {
global $wgMinimalPasswordLength;
$valid = $this->getPasswordValidity( $str );
if ( is_array( $valid ) ) {
- if( !$wgAuth->setPassword( $this, $str ) ) {
+ if ( !$wgAuth->setPassword( $this, $str ) ) {
throw new PasswordError( wfMessage( 'externaldberror' )->text() );
}
throw new PasswordError( wfMessage( 'externaldberror' )->text() );
}
$this->load();
$this->setToken();
$this->load();
$this->setToken();
// Save an invalid hash...
$this->mPassword = '';
} else {
// Save an invalid hash...
$this->mPassword = '';
} else {
*/
public function setEmail( $str ) {
$this->load();
*/
public function setEmail( $str ) {
$this->load();
- if( $str == $this->mEmail ) {
+ if ( $str == $this->mEmail ) {
return;
}
$this->mEmail = $str;
return;
}
$this->mEmail = $str;
# set it, and then it was disabled removing their ability to change it). But
# we don't want to erase the preferences in the database in case the preference
# is re-enabled again. So don't touch $mOptions, just override the returned value
# set it, and then it was disabled removing their ability to change it). But
# we don't want to erase the preferences in the database in case the preference
# is re-enabled again. So don't touch $mOptions, just override the returned value
- if( in_array( $oname, $wgHiddenPrefs ) && !$ignoreHidden ) {
+ if ( in_array( $oname, $wgHiddenPrefs ) && !$ignoreHidden ) {
return self::getDefaultOption( $oname );
}
return self::getDefaultOption( $oname );
}
# set it, and then it was disabled removing their ability to change it). But
# we don't want to erase the preferences in the database in case the preference
# is re-enabled again. So don't touch $mOptions, just override the returned value
# set it, and then it was disabled removing their ability to change it). But
# we don't want to erase the preferences in the database in case the preference
# is re-enabled again. So don't touch $mOptions, just override the returned value
- foreach( $wgHiddenPrefs as $pref ) {
+ foreach ( $wgHiddenPrefs as $pref ) {
$default = self::getDefaultOption( $pref );
$default = self::getDefaultOption( $pref );
- if( $default !== null ) {
+ if ( $default !== null ) {
$options[$pref] = $default;
}
}
$options[$pref] = $default;
}
}
*/
public function getIntOption( $oname, $defaultOverride = 0 ) {
$val = $this->getOption( $oname );
*/
public function getIntOption( $oname, $defaultOverride = 0 ) {
$val = $this->getOption( $oname );
$val = $defaultOverride;
}
return intval( $val );
$val = $defaultOverride;
}
return intval( $val );
$this->loadOptions();
// Explicitly NULL values should refer to defaults
$this->loadOptions();
// Explicitly NULL values should refer to defaults
- if( is_null( $val ) ) {
+ if ( is_null( $val ) ) {
$val = self::getDefaultOption( $oname );
}
$val = self::getDefaultOption( $oname );
}
foreach ( $options as $key => $value ) {
if ( isset( $prefs[$key] ) ) {
$mapping[$key] = 'registered';
foreach ( $options as $key => $value ) {
if ( isset( $prefs[$key] ) ) {
$mapping[$key] = 'registered';
- } elseif( isset( $multiselectOptions[$key] ) ) {
+ } elseif ( isset( $multiselectOptions[$key] ) ) {
$mapping[$key] = 'registered-multiselect';
$mapping[$key] = 'registered-multiselect';
- } elseif( isset( $checkmatrixOptions[$key] ) ) {
+ } elseif ( isset( $checkmatrixOptions[$key] ) ) {
$mapping[$key] = 'registered-checkmatrix';
} elseif ( substr( $key, 0, 7 ) === 'userjs-' ) {
$mapping[$key] = 'userjs';
$mapping[$key] = 'registered-checkmatrix';
} elseif ( substr( $key, 0, 7 ) === 'userjs-' ) {
$mapping[$key] = 'userjs';
* @return array Names of the groups the user has belonged to.
*/
public function getFormerGroups() {
* @return array Names of the groups the user has belonged to.
*/
public function getFormerGroups() {
- if( is_null( $this->mFormerGroups ) ) {
+ if ( is_null( $this->mFormerGroups ) ) {
$dbr = wfGetDB( DB_MASTER );
$res = $dbr->select( 'user_former_groups',
array( 'ufg_group' ),
array( 'ufg_user' => $this->mId ),
__METHOD__ );
$this->mFormerGroups = array();
$dbr = wfGetDB( DB_MASTER );
$res = $dbr->select( 'user_former_groups',
array( 'ufg_group' ),
array( 'ufg_user' => $this->mId ),
__METHOD__ );
$this->mFormerGroups = array();
- foreach( $res as $row ) {
+ foreach ( $res as $row ) {
$this->mFormerGroups[] = $row->ufg_group;
}
}
$this->mFormerGroups[] = $row->ufg_group;
}
}
- if( $count === null ) {
+ if ( $count === null ) {
// it has not been initialized. do so.
$count = $this->initEditCount();
}
// it has not been initialized. do so.
$count = $this->initEditCount();
}
* @param string $group Name of the group to add
*/
public function addGroup( $group ) {
* @param string $group Name of the group to add
*/
public function addGroup( $group ) {
- if( wfRunHooks( 'UserAddGroup', array( $this, &$group ) ) ) {
+ if ( wfRunHooks( 'UserAddGroup', array( $this, &$group ) ) ) {
$dbw = wfGetDB( DB_MASTER );
$dbw = wfGetDB( DB_MASTER );
+ if ( $this->getId() ) {
$dbw->insert( 'user_groups',
array(
'ug_user' => $this->getID(),
$dbw->insert( 'user_groups',
array(
'ug_user' => $this->getID(),
*/
public function removeGroup( $group ) {
$this->load();
*/
public function removeGroup( $group ) {
$this->load();
- if( wfRunHooks( 'UserRemoveGroup', array( $this, &$group ) ) ) {
+ if ( wfRunHooks( 'UserRemoveGroup', array( $this, &$group ) ) ) {
$dbw = wfGetDB( DB_MASTER );
$dbw->delete( 'user_groups',
array(
$dbw = wfGetDB( DB_MASTER );
$dbw->delete( 'user_groups',
array(
*/
public function isAllowedAny( /*...*/ ) {
$permissions = func_get_args();
*/
public function isAllowedAny( /*...*/ ) {
$permissions = func_get_args();
- foreach( $permissions as $permission ) {
- if( $this->isAllowed( $permission ) ) {
+ foreach ( $permissions as $permission ) {
+ if ( $this->isAllowed( $permission ) ) {
*/
public function isAllowedAll( /*...*/ ) {
$permissions = func_get_args();
*/
public function isAllowedAll( /*...*/ ) {
$permissions = func_get_args();
- foreach( $permissions as $permission ) {
- if( !$this->isAllowed( $permission ) ) {
+ foreach ( $permissions as $permission ) {
+ if ( !$this->isAllowed( $permission ) ) {
return true; // In the spirit of DWIM
}
# Patrolling may not be enabled
return true; // In the spirit of DWIM
}
# Patrolling may not be enabled
- if( $action === 'patrol' || $action === 'autopatrol' ) {
+ if ( $action === 'patrol' || $action === 'autopatrol' ) {
global $wgUseRCPatrol, $wgUseNPPatrol;
global $wgUseRCPatrol, $wgUseNPPatrol;
- if( !$wgUseRCPatrol && !$wgUseNPPatrol )
+ if ( !$wgUseRCPatrol && !$wgUseNPPatrol ) {
}
# Use strict parameter to avoid matching numeric 0 accidentally inserted
# by misconfiguration: 0 == 'foo'
}
# Use strict parameter to avoid matching numeric 0 accidentally inserted
# by misconfiguration: 0 == 'foo'
global $wgUseEnotif, $wgShowUpdatedMarker;
# Do nothing if the database is locked to writes
global $wgUseEnotif, $wgShowUpdatedMarker;
# Do nothing if the database is locked to writes
- if( $title->getNamespace() == NS_USER_TALK &&
+ if ( $title->getNamespace() == NS_USER_TALK &&
$title->getText() == $this->getName() ) {
$title->getText() == $this->getName() ) {
- if( !wfRunHooks( 'UserClearNewTalkNotification', array( &$this ) ) )
+ if ( !wfRunHooks( 'UserClearNewTalkNotification', array( &$this ) ) ) {
$this->setNewtalk( false );
}
$this->setNewtalk( false );
}
- if( !$wgUseEnotif && !$wgShowUpdatedMarker ) {
+ if ( !$wgUseEnotif && !$wgShowUpdatedMarker ) {
- if( $this->isAnon() ) {
+ if ( $this->isAnon() ) {
// Nothing else to do...
return;
}
// Nothing else to do...
return;
}
return;
}
$id = $this->getId();
return;
}
$id = $this->getId();
$dbw = wfGetDB( DB_MASTER );
$dbw->update( 'watchlist',
array( /* SET */
$dbw = wfGetDB( DB_MASTER );
$dbw->update( 'watchlist',
array( /* SET */
*/
private function decodeOptions( $str ) {
wfDeprecated( __METHOD__, '1.19' );
*/
private function decodeOptions( $str ) {
wfDeprecated( __METHOD__, '1.19' );
$this->mOptionsLoaded = true;
$this->mOptionOverrides = array();
$this->mOptionsLoaded = true;
$this->mOptionOverrides = array();
* Log this user out.
*/
public function logout() {
* Log this user out.
*/
public function logout() {
- if( wfRunHooks( 'UserLogout', array( &$this ) ) ) {
+ if ( wfRunHooks( 'UserLogout', array( &$this ) ) ) {
global $wgAuth;
$this->load();
global $wgAuth;
$this->load();
- if ( wfReadOnly() ) { return; }
- if ( 0 == $this->mId ) { return; }
+ if ( wfReadOnly() ) {
+ return;
+ }
+ if ( 0 == $this->mId ) {
+ return;
+ }
$this->mTouched = self::newTouchedTimestamp();
if ( !$wgAuth->allowSetLocalPassword() ) {
$this->mTouched = self::newTouchedTimestamp();
if ( !$wgAuth->allowSetLocalPassword() ) {
*/
public function idForName() {
$s = trim( $this->getName() );
*/
public function idForName() {
$s = trim( $this->getName() );
- if ( $s === '' ) return 0;
+ if ( $s === '' ) {
+ return 0;
+ }
$dbr = wfGetDB( DB_SLAVE );
$id = $dbr->selectField( 'user', 'user_id', array( 'user_name' => $s ), __METHOD__ );
$dbr = wfGetDB( DB_SLAVE );
$id = $dbr->selectField( 'user', 'user_id', array( 'user_name' => $s ), __METHOD__ );
wfDeprecated( __METHOD__, '1.17' );
global $wgRenderHashAppend, $wgLang, $wgContLang;
wfDeprecated( __METHOD__, '1.17' );
global $wgRenderHashAppend, $wgLang, $wgContLang;
*/
public function isBlockedFromCreateAccount() {
$this->getBlockedStatus();
*/
public function isBlockedFromCreateAccount() {
$this->getBlockedStatus();
- if( $this->mBlock && $this->mBlock->prevents( 'createaccount' ) ) {
+ if ( $this->mBlock && $this->mBlock->prevents( 'createaccount' ) ) {
// to. Certain authentication plugins do NOT want to save
// domain passwords in a mysql database, so we should
// check this (in case $wgAuth->strict() is false).
// to. Certain authentication plugins do NOT want to save
// domain passwords in a mysql database, so we should
// check this (in case $wgAuth->strict() is false).
- if( !$this->isValidPassword( $password ) ) {
+ if ( !$this->isValidPassword( $password ) ) {
- if( $wgAuth->authenticate( $this->getName(), $password ) ) {
+ if ( $wgAuth->authenticate( $this->getName(), $password ) ) {
- } elseif( $wgAuth->strict() ) {
+ } elseif ( $wgAuth->strict() ) {
/* Auth plugin doesn't allow local authentication */
return false;
/* Auth plugin doesn't allow local authentication */
return false;
- } elseif( $wgAuth->strictUserAuth( $this->getName() ) ) {
+ } elseif ( $wgAuth->strictUserAuth( $this->getName() ) ) {
/* Auth plugin doesn't allow local authentication for this user name */
return false;
}
/* Auth plugin doesn't allow local authentication for this user name */
return false;
}
global $wgNewPasswordExpiry;
$this->load();
global $wgNewPasswordExpiry;
$this->load();
- if( self::comparePasswords( $this->mNewpassword, $plaintext, $this->getId() ) ) {
+ if ( self::comparePasswords( $this->mNewpassword, $plaintext, $this->getId() ) ) {
if ( is_null( $this->mNewpassTime ) ) {
return true;
}
if ( is_null( $this->mNewpassTime ) ) {
return true;
}
$token = MWCryptRand::generateHex( 32 );
$request->setSessionData( 'wsEditToken', $token );
}
$token = MWCryptRand::generateHex( 32 );
$request->setSessionData( 'wsEditToken', $token );
}
- if( is_array( $salt ) ) {
+ if ( is_array( $salt ) ) {
$salt = implode( '|', $salt );
}
return md5( $token . $salt ) . EDIT_TOKEN_SUFFIX;
$salt = implode( '|', $salt );
}
return md5( $token . $salt ) . EDIT_TOKEN_SUFFIX;
* @return Status
*/
public function sendMail( $subject, $body, $from = null, $replyto = null ) {
* @return Status
*/
public function sendMail( $subject, $body, $from = null, $replyto = null ) {
- if( is_null( $from ) ) {
+ if ( is_null( $from ) ) {
global $wgPasswordSender, $wgPasswordSenderName;
$sender = new MailAddress( $wgPasswordSender, $wgPasswordSenderName );
} else {
global $wgPasswordSender, $wgPasswordSenderName;
$sender = new MailAddress( $wgPasswordSender, $wgPasswordSenderName );
} else {
*/
public function canSendEmail() {
global $wgEnableEmail, $wgEnableUserEmail;
*/
public function canSendEmail() {
global $wgEnableEmail, $wgEnableUserEmail;
- if( !$wgEnableEmail || !$wgEnableUserEmail || !$this->isAllowed( 'sendemail' ) ) {
+ if ( !$wgEnableEmail || !$wgEnableUserEmail || !$this->isAllowed( 'sendemail' ) ) {
return false;
}
$canSend = $this->isEmailConfirmed();
return false;
}
$canSend = $this->isEmailConfirmed();
global $wgEmailAuthentication;
$this->load();
$confirmed = true;
global $wgEmailAuthentication;
$this->load();
$confirmed = true;
- if( wfRunHooks( 'EmailConfirmed', array( &$this, &$confirmed ) ) ) {
- if( $this->isAnon() ) {
+ if ( wfRunHooks( 'EmailConfirmed', array( &$this, &$confirmed ) ) ) {
+ if ( $this->isAnon() ) {
- if( !Sanitizer::validateEmail( $this->mEmail ) ) {
+ if ( !Sanitizer::validateEmail( $this->mEmail ) ) {
- if( $wgEmailAuthentication && !$this->getEmailAuthenticationTimestamp() ) {
+ if ( $wgEmailAuthentication && !$this->getEmailAuthenticationTimestamp() ) {
return false;
}
return true;
return false;
}
return true;
* non-existent/anonymous user accounts.
*/
public function getFirstEditTimestamp() {
* non-existent/anonymous user accounts.
*/
public function getFirstEditTimestamp() {
- if( $this->getId() == 0 ) {
+ if ( $this->getId() == 0 ) {
return false; // anons
}
$dbr = wfGetDB( DB_SLAVE );
return false; // anons
}
$dbr = wfGetDB( DB_SLAVE );
__METHOD__,
array( 'ORDER BY' => 'rev_timestamp ASC' )
);
__METHOD__,
array( 'ORDER BY' => 'rev_timestamp ASC' )
);
return false; // no edits
}
return wfTimestamp( TS_MW, $time );
return false; // no edits
}
return wfTimestamp( TS_MW, $time );
global $wgGroupPermissions, $wgRevokePermissions;
$rights = array();
// grant every granted permission first
global $wgGroupPermissions, $wgRevokePermissions;
$rights = array();
// grant every granted permission first
- foreach( $groups as $group ) {
- if( isset( $wgGroupPermissions[$group] ) ) {
+ foreach ( $groups as $group ) {
+ if ( isset( $wgGroupPermissions[$group] ) ) {
$rights = array_merge( $rights,
// array_filter removes empty items
array_keys( array_filter( $wgGroupPermissions[$group] ) ) );
}
}
// now revoke the revoked permissions
$rights = array_merge( $rights,
// array_filter removes empty items
array_keys( array_filter( $wgGroupPermissions[$group] ) ) );
}
}
// now revoke the revoked permissions
- foreach( $groups as $group ) {
- if( isset( $wgRevokePermissions[$group] ) ) {
+ foreach ( $groups as $group ) {
+ if ( isset( $wgRevokePermissions[$group] ) ) {
$rights = array_diff( $rights,
array_keys( array_filter( $wgRevokePermissions[$group] ) ) );
}
$rights = array_diff( $rights,
array_keys( array_filter( $wgRevokePermissions[$group] ) ) );
}
*/
public static function getGroupPage( $group ) {
$msg = wfMessage( 'grouppage-' . $group )->inContentLanguage();
*/
public static function getGroupPage( $group ) {
$msg = wfMessage( 'grouppage-' . $group )->inContentLanguage();
+ if ( $msg->exists() ) {
$title = Title::newFromText( $msg->text() );
$title = Title::newFromText( $msg->text() );
- if( is_object( $title ) )
+ if ( is_object( $title ) ) {
* @return String HTML link to the group
*/
public static function makeGroupLinkHTML( $group, $text = '' ) {
* @return String HTML link to the group
*/
public static function makeGroupLinkHTML( $group, $text = '' ) {
$text = self::getGroupName( $group );
}
$title = self::getGroupPage( $group );
$text = self::getGroupName( $group );
}
$title = self::getGroupPage( $group );
return Linker::link( $title, htmlspecialchars( $text ) );
} else {
return $text;
return Linker::link( $title, htmlspecialchars( $text ) );
} else {
return $text;
* @return String Wikilink to the group
*/
public static function makeGroupLinkWiki( $group, $text = '' ) {
* @return String Wikilink to the group
*/
public static function makeGroupLinkWiki( $group, $text = '' ) {
$text = self::getGroupName( $group );
}
$title = self::getGroupPage( $group );
$text = self::getGroupName( $group );
}
$title = self::getGroupPage( $group );
$page = $title->getPrefixedText();
return "[[$page|$text]]";
} else {
$page = $title->getPrefixedText();
return "[[$page|$text]]";
} else {
global $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
$groups = array( 'add' => array(), 'remove' => array(), 'add-self' => array(), 'remove-self' => array() );
global $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
$groups = array( 'add' => array(), 'remove' => array(), 'add-self' => array(), 'remove-self' => array() );
- if( empty( $wgAddGroups[$group] ) ) {
+ if ( empty( $wgAddGroups[$group] ) ) {
// Don't add anything to $groups
// Don't add anything to $groups
- } elseif( $wgAddGroups[$group] === true ) {
+ } elseif ( $wgAddGroups[$group] === true ) {
// You get everything
$groups['add'] = self::getAllGroups();
// You get everything
$groups['add'] = self::getAllGroups();
- } elseif( is_array( $wgAddGroups[$group] ) ) {
+ } elseif ( is_array( $wgAddGroups[$group] ) ) {
$groups['add'] = $wgAddGroups[$group];
}
// Same thing for remove
$groups['add'] = $wgAddGroups[$group];
}
// Same thing for remove
- if( empty( $wgRemoveGroups[$group] ) ) {
- } elseif( $wgRemoveGroups[$group] === true ) {
+ if ( empty( $wgRemoveGroups[$group] ) ) {
+ } elseif ( $wgRemoveGroups[$group] === true ) {
$groups['remove'] = self::getAllGroups();
$groups['remove'] = self::getAllGroups();
- } elseif( is_array( $wgRemoveGroups[$group] ) ) {
+ } elseif ( is_array( $wgRemoveGroups[$group] ) ) {
$groups['remove'] = $wgRemoveGroups[$group];
}
// Re-map numeric keys of AddToSelf/RemoveFromSelf to the 'user' key for backwards compatibility
$groups['remove'] = $wgRemoveGroups[$group];
}
// Re-map numeric keys of AddToSelf/RemoveFromSelf to the 'user' key for backwards compatibility
- if( empty( $wgGroupsAddToSelf['user'] ) || $wgGroupsAddToSelf['user'] !== true ) {
- foreach( $wgGroupsAddToSelf as $key => $value ) {
- if( is_int( $key ) ) {
+ if ( empty( $wgGroupsAddToSelf['user'] ) || $wgGroupsAddToSelf['user'] !== true ) {
+ foreach ( $wgGroupsAddToSelf as $key => $value ) {
+ if ( is_int( $key ) ) {
$wgGroupsAddToSelf['user'][] = $value;
}
}
}
$wgGroupsAddToSelf['user'][] = $value;
}
}
}
- if( empty( $wgGroupsRemoveFromSelf['user'] ) || $wgGroupsRemoveFromSelf['user'] !== true ) {
- foreach( $wgGroupsRemoveFromSelf as $key => $value ) {
- if( is_int( $key ) ) {
+ if ( empty( $wgGroupsRemoveFromSelf['user'] ) || $wgGroupsRemoveFromSelf['user'] !== true ) {
+ foreach ( $wgGroupsRemoveFromSelf as $key => $value ) {
+ if ( is_int( $key ) ) {
$wgGroupsRemoveFromSelf['user'][] = $value;
}
}
}
// Now figure out what groups the user can add to him/herself
$wgGroupsRemoveFromSelf['user'][] = $value;
}
}
}
// Now figure out what groups the user can add to him/herself
- if( empty( $wgGroupsAddToSelf[$group] ) ) {
- } elseif( $wgGroupsAddToSelf[$group] === true ) {
+ if ( empty( $wgGroupsAddToSelf[$group] ) ) {
+ } elseif ( $wgGroupsAddToSelf[$group] === true ) {
// No idea WHY this would be used, but it's there
$groups['add-self'] = User::getAllGroups();
// No idea WHY this would be used, but it's there
$groups['add-self'] = User::getAllGroups();
- } elseif( is_array( $wgGroupsAddToSelf[$group] ) ) {
+ } elseif ( is_array( $wgGroupsAddToSelf[$group] ) ) {
$groups['add-self'] = $wgGroupsAddToSelf[$group];
}
$groups['add-self'] = $wgGroupsAddToSelf[$group];
}
- if( empty( $wgGroupsRemoveFromSelf[$group] ) ) {
- } elseif( $wgGroupsRemoveFromSelf[$group] === true ) {
+ if ( empty( $wgGroupsRemoveFromSelf[$group] ) ) {
+ } elseif ( $wgGroupsRemoveFromSelf[$group] === true ) {
$groups['remove-self'] = User::getAllGroups();
$groups['remove-self'] = User::getAllGroups();
- } elseif( is_array( $wgGroupsRemoveFromSelf[$group] ) ) {
+ } elseif ( is_array( $wgGroupsRemoveFromSelf[$group] ) ) {
$groups['remove-self'] = $wgGroupsRemoveFromSelf[$group];
}
$groups['remove-self'] = $wgGroupsRemoveFromSelf[$group];
}
* 'remove-self' => array( removable groups from self) )
*/
public function changeableGroups() {
* 'remove-self' => array( removable groups from self) )
*/
public function changeableGroups() {
- if( $this->isAllowed( 'userrights' ) ) {
+ if ( $this->isAllowed( 'userrights' ) ) {
// This group gives the right to modify everything (reverse-
// compatibility with old "userrights lets you change
// everything")
// This group gives the right to modify everything (reverse-
// compatibility with old "userrights lets you change
// everything")
);
$addergroups = $this->getEffectiveGroups();
);
$addergroups = $this->getEffectiveGroups();
- foreach( $addergroups as $addergroup ) {
+ foreach ( $addergroups as $addergroup ) {
$groups = array_merge_recursive(
$groups, $this->changeableByGroup( $addergroup )
);
$groups = array_merge_recursive(
$groups, $this->changeableByGroup( $addergroup )
);
* Will have no effect for anonymous users.
*/
public function incEditCount() {
* Will have no effect for anonymous users.
*/
public function incEditCount() {
- if( !$this->isAnon() ) {
+ if ( !$this->isAnon() ) {
$dbw = wfGetDB( DB_MASTER );
$dbw->update(
'user',
$dbw = wfGetDB( DB_MASTER );
$dbw->update(
'user',
);
// Lazy initialization check...
);
// Lazy initialization check...
- if( $dbw->affectedRows() == 0 ) {
+ if ( $dbw->affectedRows() == 0 ) {
// Now here's a goddamn hack...
$dbr = wfGetDB( DB_SLAVE );
// Now here's a goddamn hack...
$dbr = wfGetDB( DB_SLAVE );
// If we actually have a slave server, the count is
// at least one behind because the current transaction
// has not been committed and replicated.
// If we actually have a slave server, the count is
// at least one behind because the current transaction
// has not been committed and replicated.
global $wgPasswordSalt;
$hash = '';
global $wgPasswordSalt;
$hash = '';
- if( !wfRunHooks( 'UserCryptPassword', array( &$password, &$salt, &$wgPasswordSalt, &$hash ) ) ) {
+ if ( !wfRunHooks( 'UserCryptPassword', array( &$password, &$salt, &$wgPasswordSalt, &$hash ) ) ) {
- if( $wgPasswordSalt ) {
+ if ( $wgPasswordSalt ) {
if ( $salt === false ) {
$salt = MWCryptRand::generateHex( 8 );
}
if ( $salt === false ) {
$salt = MWCryptRand::generateHex( 8 );
}
$type = substr( $hash, 0, 3 );
$result = false;
$type = substr( $hash, 0, 3 );
$result = false;
- if( !wfRunHooks( 'UserComparePasswords', array( &$hash, &$password, &$userId, &$result ) ) ) {
+ if ( !wfRunHooks( 'UserComparePasswords', array( &$hash, &$password, &$userId, &$result ) ) ) {
*/
public function addNewUserLogEntry( $action = false, $reason = '' ) {
global $wgUser, $wgNewUserLog;
*/
public function addNewUserLogEntry( $action = false, $reason = '' ) {
global $wgUser, $wgNewUserLog;
- if( empty( $wgNewUserLog ) ) {
+ if ( empty( $wgNewUserLog ) ) {
return true; // disabled
}
return true; // disabled
}
// Maybe load from the object
if ( !is_null( $this->mOptionOverrides ) ) {
wfDebug( "User: loading options for user " . $this->getId() . " from override cache.\n" );
// Maybe load from the object
if ( !is_null( $this->mOptionOverrides ) ) {
wfDebug( "User: loading options for user " . $this->getId() . " from override cache.\n" );
- foreach( $this->mOptionOverrides as $key => $value ) {
+ foreach ( $this->mOptionOverrides as $key => $value ) {
$this->mOptions[$key] = $value;
}
} else {
$this->mOptions[$key] = $value;
}
} else {
- if( !is_array( $data ) ) {
+ if ( !is_array( $data ) ) {
wfDebug( "User: loading options for user " . $this->getId() . " from database.\n" );
// Load from database
$dbr = wfGetDB( DB_SLAVE );
wfDebug( "User: loading options for user " . $this->getId() . " from database.\n" );
// Load from database
$dbr = wfGetDB( DB_SLAVE );
// Allow hooks to abort, for instance to save to a global profile.
// Reset options to default state before saving.
// Allow hooks to abort, for instance to save to a global profile.
// Reset options to default state before saving.
- if( !wfRunHooks( 'UserSaveOptions', array( $this, &$saveOptions ) ) ) {
+ if ( !wfRunHooks( 'UserSaveOptions', array( $this, &$saveOptions ) ) ) {
return;
}
$userId = $this->getId();
$insert_rows = array();
return;
}
$userId = $this->getId();
$insert_rows = array();
- foreach( $saveOptions as $key => $value ) {
+ foreach ( $saveOptions as $key => $value ) {
# Don't bother storing default values
$defaultOption = self::getDefaultOption( $key );
if ( ( is_null( $defaultOption ) &&
# Don't bother storing default values
$defaultOption = self::getDefaultOption( $key );
if ( ( is_null( $defaultOption ) &&
*/
static function arrayToHeaderString( $headers, $endl = "\n" ) {
$strings = array();
*/
static function arrayToHeaderString( $headers, $endl = "\n" ) {
$strings = array();
- foreach( $headers as $name => $value ) {
+ foreach ( $headers as $name => $value ) {
$strings[] = "$name: $value";
}
return implode( $endl, $strings );
$strings[] = "$name: $value";
}
return implode( $endl, $strings );
- if( count( $to ) > 1 ) {
+ if ( count( $to ) > 1 ) {
$headers['To'] = 'undisclosed-recipients:;';
}
$headers = self::arrayToHeaderString( $headers, $endl );
$headers['To'] = 'undisclosed-recipients:;';
}
$headers = self::arrayToHeaderString( $headers, $endl );
*/
public static function quotedPrintable( $string, $charset = '' ) {
# Probably incomplete; see RFC 2045
*/
public static function quotedPrintable( $string, $charset = '' ) {
# Probably incomplete; see RFC 2045
- if( empty( $charset ) ) {
+ if ( empty( $charset ) ) {
$charset = 'UTF-8';
}
$charset = strtoupper( $charset );
$charset = 'UTF-8';
}
$charset = strtoupper( $charset );
$illegal = '\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff=';
$replace = $illegal . '\t ?_';
$illegal = '\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff=';
$replace = $illegal . '\t ?_';
- if( !preg_match( "/[$illegal]/", $string ) ) {
+ if ( !preg_match( "/[$illegal]/", $string ) ) {
return $string;
}
$out = "=?$charset?Q?";
return $string;
}
$out = "=?$charset?Q?";
function compose( $user ) {
global $wgEnotifImpersonal;
function compose( $user ) {
global $wgEnotifImpersonal;
- if ( !$this->composed_common )
+ if ( !$this->composed_common ) {
$this->composeCommonMailtext();
$this->composeCommonMailtext();
if ( $wgEnotifImpersonal ) {
$this->mailTargets[] = new MailAddress( $user );
if ( $wgEnotifImpersonal ) {
$this->mailTargets[] = new MailAddress( $user );
*/
public static function whoIs( $database, $id, $ignoreInvalidDB = false ) {
$user = self::newFromId( $database, $id, $ignoreInvalidDB );
*/
public static function whoIs( $database, $id, $ignoreInvalidDB = false ) {
$user = self::newFromId( $database, $id, $ignoreInvalidDB );
return $user->name;
} else {
return false;
return $user->name;
} else {
return false;
*/
private static function newFromLookup( $database, $field, $value, $ignoreInvalidDB = false ) {
$db = self::getDB( $database, $ignoreInvalidDB );
*/
private static function newFromLookup( $database, $field, $value, $ignoreInvalidDB = false ) {
$db = self::getDB( $database, $ignoreInvalidDB );
$row = $db->selectRow( 'user',
array( 'user_id', 'user_name' ),
array( $field => $value ),
__METHOD__ );
$row = $db->selectRow( 'user',
array( 'user_id', 'user_name' ),
array( $field => $value ),
__METHOD__ );
+ if ( $row !== false ) {
return new UserRightsProxy( $db, $database,
$row->user_name,
intval( $row->user_id ) );
return new UserRightsProxy( $db, $database,
$row->user_name,
intval( $row->user_id ) );
*/
public static function getDB( $database, $ignoreInvalidDB = false ) {
global $wgDBname;
*/
public static function getDB( $database, $ignoreInvalidDB = false ) {
global $wgDBname;
- if( self::validDatabase( $database ) ) {
- if( $database == $wgDBname ) {
+ if ( self::validDatabase( $database ) ) {
+ if ( $database == $wgDBname ) {
// Hmm... this shouldn't happen though. :)
return wfGetDB( DB_MASTER );
} else {
// Hmm... this shouldn't happen though. :)
return wfGetDB( DB_MASTER );
} else {
- if( empty( $values ) ) {
+ if ( empty( $values ) ) {
// Nothing to do
return true;
}
// Nothing to do
return true;
}
wfSuppressWarnings();
$a = parse_url( $url );
wfRestoreWarnings();
wfSuppressWarnings();
$a = parse_url( $url );
wfRestoreWarnings();
$path = isset( $a['path'] ) ? $a['path'] : '';
global $wgScript;
$path = isset( $a['path'] ) ? $a['path'] : '';
global $wgScript;
- if( $path == $wgScript && $want !== 'all' ) {
+ if ( $path == $wgScript && $want !== 'all' ) {
// Script inside a rewrite path?
// Abort to keep from breaking...
return $matches;
// Script inside a rewrite path?
// Abort to keep from breaking...
return $matches;
// Raw PATH_INFO style
$router->add( "$wgScript/$1" );
// Raw PATH_INFO style
$router->add( "$wgScript/$1" );
- if( isset( $_SERVER['SCRIPT_NAME'] )
+ if ( isset( $_SERVER['SCRIPT_NAME'] )
&& preg_match( '/\.php5?/', $_SERVER['SCRIPT_NAME'] ) )
{
# Check for SCRIPT_NAME, we handle index.php explicitly
&& preg_match( '/\.php5?/', $_SERVER['SCRIPT_NAME'] ) )
{
# Check for SCRIPT_NAME, we handle index.php explicitly
+ if ( $wgArticlePath ) {
$router->add( $wgArticlePath );
}
global $wgActionPaths;
$router->add( $wgArticlePath );
}
global $wgActionPaths;
+ if ( $wgActionPaths ) {
$router->add( $wgActionPaths, array( 'action' => '$key' ) );
}
global $wgVariantArticlePath, $wgContLang;
$router->add( $wgActionPaths, array( 'action' => '$key' ) );
}
global $wgVariantArticlePath, $wgContLang;
- if( $wgVariantArticlePath ) {
+ if ( $wgVariantArticlePath ) {
$router->add( $wgVariantArticlePath,
array( 'variant' => '$2' ),
array( '$2' => $wgContLang->getVariants() )
$router->add( $wgVariantArticlePath,
array( 'variant' => '$2' ),
array( '$2' => $wgContLang->getVariants() )
}
$matches = self::getPathInfo( 'title' );
}
$matches = self::getPathInfo( 'title' );
- foreach( $matches as $key => $val ) {
+ foreach ( $matches as $key => $val ) {
$this->data[$key] = $_GET[$key] = $_REQUEST[$key] = $val;
}
}
$this->data[$key] = $_GET[$key] = $_REQUEST[$key] = $val;
}
}
* @return array of URL variables to interpolate; empty if no match
*/
static function extractTitle( $path, $bases, $key = false ) {
* @return array of URL variables to interpolate; empty if no match
*/
static function extractTitle( $path, $bases, $key = false ) {
- foreach( (array)$bases as $keyValue => $base ) {
+ foreach ( (array)$bases as $keyValue => $base ) {
// Find the part after $wgArticlePath
$base = str_replace( '$1', '', $base );
$baseLen = strlen( $base );
// Find the part after $wgArticlePath
$base = str_replace( '$1', '', $base );
$baseLen = strlen( $base );
- if( substr( $path, 0, $baseLen ) == $base ) {
+ if ( substr( $path, 0, $baseLen ) == $base ) {
$raw = substr( $path, $baseLen );
$raw = substr( $path, $baseLen );
$matches = array( 'title' => rawurldecode( $raw ) );
$matches = array( 'title' => rawurldecode( $raw ) );
$matches[$key] = $keyValue;
}
return $matches;
$matches[$key] = $keyValue;
}
return $matches;
*/
private function &fix_magic_quotes( &$arr, $topLevel = true ) {
$clean = array();
*/
private function &fix_magic_quotes( &$arr, $topLevel = true ) {
$clean = array();
- foreach( $arr as $key => $val ) {
- if( is_array( $val ) ) {
+ foreach ( $arr as $key => $val ) {
+ if ( is_array( $val ) ) {
$cleanKey = $topLevel ? stripslashes( $key ) : $key;
$clean[$cleanKey] = $this->fix_magic_quotes( $arr[$key], false );
} else {
$cleanKey = $topLevel ? stripslashes( $key ) : $key;
$clean[$cleanKey] = $this->fix_magic_quotes( $arr[$key], false );
} else {
private function checkMagicQuotes() {
$mustFixQuotes = function_exists( 'get_magic_quotes_gpc' )
&& get_magic_quotes_gpc();
private function checkMagicQuotes() {
$mustFixQuotes = function_exists( 'get_magic_quotes_gpc' )
&& get_magic_quotes_gpc();
+ if ( $mustFixQuotes ) {
$this->fix_magic_quotes( $_COOKIE );
$this->fix_magic_quotes( $_ENV );
$this->fix_magic_quotes( $_GET );
$this->fix_magic_quotes( $_COOKIE );
$this->fix_magic_quotes( $_ENV );
$this->fix_magic_quotes( $_GET );
* @private
*/
function normalizeUnicode( $data ) {
* @private
*/
function normalizeUnicode( $data ) {
- if( is_array( $data ) ) {
- foreach( $data as $key => $val ) {
+ if ( is_array( $data ) ) {
+ foreach ( $data as $key => $val ) {
$data[$key] = $this->normalizeUnicode( $val );
}
} else {
$data[$key] = $this->normalizeUnicode( $val );
}
} else {
# http://us2.php.net/variables.external#language.variables.external.dot-in-names
# Work around PHP *feature* to avoid *bugs* elsewhere.
$name = strtr( $name, '.', '_' );
# http://us2.php.net/variables.external#language.variables.external.dot-in-names
# Work around PHP *feature* to avoid *bugs* elsewhere.
$name = strtr( $name, '.', '_' );
- if( isset( $arr[$name] ) ) {
+ if ( isset( $arr[$name] ) ) {
global $wgContLang;
$data = $arr[$name];
global $wgContLang;
$data = $arr[$name];
- if( isset( $_GET[$name] ) && !is_array( $data ) ) {
+ if ( isset( $_GET[$name] ) && !is_array( $data ) ) {
# Check for alternate/legacy character encoding.
# Check for alternate/legacy character encoding.
- if( isset( $wgContLang ) ) {
+ if ( isset( $wgContLang ) ) {
$data = $wgContLang->checkTitleEncoding( $data );
}
}
$data = $wgContLang->checkTitleEncoding( $data );
}
}
*/
public function getVal( $name, $default = null ) {
$val = $this->getGPCVal( $this->data, $name, $default );
*/
public function getVal( $name, $default = null ) {
$val = $this->getGPCVal( $this->data, $name, $default );
- if( is_array( $val ) ) {
+ if ( is_array( $val ) ) {
- if( is_null( $val ) ) {
+ if ( is_null( $val ) ) {
return $val;
} else {
return (string)$val;
return $val;
} else {
return (string)$val;
*/
public function getArray( $name, $default = null ) {
$val = $this->getGPCVal( $this->data, $name, $default );
*/
public function getArray( $name, $default = null ) {
$val = $this->getGPCVal( $this->data, $name, $default );
- if( is_null( $val ) ) {
+ if ( is_null( $val ) ) {
return null;
} else {
return (array)$val;
return null;
} else {
return (array)$val;
*/
public function getIntArray( $name, $default = null ) {
$val = $this->getArray( $name, $default );
*/
public function getIntArray( $name, $default = null ) {
$val = $this->getArray( $name, $default );
- if( is_array( $val ) ) {
+ if ( is_array( $val ) ) {
$val = array_map( 'intval', $val );
}
return $val;
$val = array_map( 'intval', $val );
}
return $val;
* @return Mixed: cookie value or $default if the cookie not set
*/
public function getCookie( $key, $prefix = null, $default = null ) {
* @return Mixed: cookie value or $default if the cookie not set
*/
public function getCookie( $key, $prefix = null, $default = null ) {
- if( $prefix === null ) {
+ if ( $prefix === null ) {
global $wgCookiePrefix;
$prefix = $wgCookiePrefix;
}
global $wgCookiePrefix;
$prefix = $wgCookiePrefix;
}
* @return String
*/
public function getRequestURL() {
* @return String
*/
public function getRequestURL() {
- if( isset( $_SERVER['REQUEST_URI'] ) && strlen( $_SERVER['REQUEST_URI'] ) ) {
+ if ( isset( $_SERVER['REQUEST_URI'] ) && strlen( $_SERVER['REQUEST_URI'] ) ) {
$base = $_SERVER['REQUEST_URI'];
} elseif ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) && strlen( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
// Probably IIS; doesn't set REQUEST_URI
$base = $_SERVER['HTTP_X_ORIGINAL_URL'];
$base = $_SERVER['REQUEST_URI'];
} elseif ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) && strlen( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
// Probably IIS; doesn't set REQUEST_URI
$base = $_SERVER['HTTP_X_ORIGINAL_URL'];
- } elseif( isset( $_SERVER['SCRIPT_NAME'] ) ) {
+ } elseif ( isset( $_SERVER['SCRIPT_NAME'] ) ) {
$base = $_SERVER['SCRIPT_NAME'];
$base = $_SERVER['SCRIPT_NAME'];
- if( isset( $_SERVER['QUERY_STRING'] ) && $_SERVER['QUERY_STRING'] != '' ) {
+ if ( isset( $_SERVER['QUERY_STRING'] ) && $_SERVER['QUERY_STRING'] != '' ) {
$base .= '?' . $_SERVER['QUERY_STRING'];
}
} else {
$base .= '?' . $_SERVER['QUERY_STRING'];
}
} else {
// need to strip it or we get false-positive redirect loops
// or weird output URLs
$hash = strpos( $base, '#' );
// need to strip it or we get false-positive redirect loops
// or weird output URLs
$hash = strpos( $base, '#' );
- if( $hash !== false ) {
+ if ( $hash !== false ) {
$base = substr( $base, 0, $hash );
}
$base = substr( $base, 0, $hash );
}
- if( $base[0] == '/' ) {
+ if ( $base[0] == '/' ) {
// More than one slash will look like it is protocol relative
return preg_replace( '!^/+!', '/', $base );
} else {
// More than one slash will look like it is protocol relative
return preg_replace( '!^/+!', '/', $base );
} else {
global $wgUser;
$limit = $this->getInt( 'limit', 0 );
global $wgUser;
$limit = $this->getInt( 'limit', 0 );
- if( ( $limit == 0 ) && ( $optionname != '' ) ) {
+ if ( ( $limit == 0 ) && ( $optionname != '' ) ) {
$limit = $wgUser->getIntOption( $optionname );
}
$limit = $wgUser->getIntOption( $optionname );
}
$limit = 5000; # We have *some* limits...
}
$offset = $this->getInt( 'offset', 0 );
$limit = 5000; # We have *some* limits...
}
$offset = $this->getInt( 'offset', 0 );
* @return Mixed
*/
public function getSessionData( $key ) {
* @return Mixed
*/
public function getSessionData( $key ) {
- if( !isset( $_SESSION[$key] ) ) {
+ if ( !isset( $_SESSION[$key] ) ) {
return null;
}
return $_SESSION[$key];
return null;
}
return $_SESSION[$key];
* @throws MWException
*/
public function __construct( $data = array(), $wasPosted = false, $session = null ) {
* @throws MWException
*/
public function __construct( $data = array(), $wasPosted = false, $session = null ) {
- if( is_array( $data ) ) {
+ if ( is_array( $data ) ) {
$this->data = $data;
} else {
throw new MWException( "FauxRequest() got bogus data" );
}
$this->wasPosted = $wasPosted;
$this->data = $data;
} else {
throw new MWException( "FauxRequest() got bogus data" );
}
$this->wasPosted = $wasPosted;
$this->session = $session;
}
}
$this->session = $session;
}
}
* @return mixed
*/
public function getSessionData( $key ) {
* @return mixed
*/
public function getSessionData( $key ) {
- if( isset( $this->session[$key] ) ) {
+ if ( isset( $this->session[$key] ) ) {
return $this->session[$key];
}
return null;
return $this->session[$key];
}
return null;
if ( $expire == 0 ) {
$expire = time() + $wgCookieExpiration;
}
if ( $expire == 0 ) {
$expire = time() + $wgCookieExpiration;
}
- if( $prefix === null ) {
+ if ( $prefix === null ) {
$prefix = $wgCookiePrefix;
}
$prefix = $wgCookiePrefix;
}
- if( $domain === null ) {
+ if ( $domain === null ) {
$domain = $wgCookieDomain;
}
$domain = $wgCookieDomain;
}
} else {
list( $key, $val ) = array_map( 'trim', explode( ":", $string, 2 ) );
} else {
list( $key, $val ) = array_map( 'trim', explode( ":", $string, 2 ) );
- if( $replace || !isset( $this->headers[$key] ) ) {
+ if ( $replace || !isset( $this->headers[$key] ) ) {
$this->headers[$key] = $val;
}
}
$this->headers[$key] = $val;
}
}
'HTTP_SESSION_VARS'
);
foreach ( $_REQUEST as $name => $value ) {
'HTTP_SESSION_VARS'
);
foreach ( $_REQUEST as $name => $value ) {
- if( in_array( $name, $verboten ) ) {
+ if ( in_array( $name, $verboten ) ) {
header( "HTTP/1.1 500 Internal Server Error" );
echo "register_globals security paranoia: trying to overwrite superglobals, aborting.";
die( -1 );
header( "HTTP/1.1 500 Internal Server Error" );
echo "register_globals security paranoia: trying to overwrite superglobals, aborting.";
die( -1 );
# if we don't have permissions on parent directories.
$IP = getenv( 'MW_INSTALL_PATH' );
if ( $IP === false ) {
# if we don't have permissions on parent directories.
$IP = getenv( 'MW_INSTALL_PATH' );
if ( $IP === false ) {
- if( realpath( '.' ) ) {
+ if ( realpath( '.' ) ) {
$IP = realpath( '.' );
} else {
$IP = dirname( __DIR__ );
$IP = realpath( '.' );
} else {
$IP = dirname( __DIR__ );
# LocalSettings.php is the per site customization file. If it does not exist
# the wiki installer needs to be launched or the generated file uploaded to
# the root wiki directory
# LocalSettings.php is the per site customization file. If it does not exist
# the wiki installer needs to be launched or the generated file uploaded to
# the root wiki directory
- if( !file_exists( MW_CONFIG_FILE ) ) {
+ if ( !file_exists( MW_CONFIG_FILE ) ) {
require_once( "$IP/includes/templates/NoLocalSettings.php" );
die();
}
require_once( "$IP/includes/templates/NoLocalSettings.php" );
die();
}
* @return Title
*/
public function getTitle() {
* @return Title
*/
public function getTitle() {
- if( $this->context->getTitle() === null ) {
+ if ( $this->context->getTitle() === null ) {
$this->context->setTitle( $this->parseTitle() );
}
return $this->context->getTitle();
$this->context->setTitle( $this->parseTitle() );
}
return $this->context->getTitle();
$resp->header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
$resp->header( 'X-Database-Lag: ' . intval( $lag ) );
$resp->header( 'Content-Type: text/plain' );
$resp->header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
$resp->header( 'X-Database-Lag: ' . intval( $lag ) );
$resp->header( 'Content-Type: text/plain' );
- if( $wgShowHostnames ) {
+ if ( $wgShowHostnames ) {
echo "Waiting for $host: $lag seconds lagged\n";
} else {
echo "Waiting for a database server: $lag seconds lagged\n";
echo "Waiting for $host: $lag seconds lagged\n";
} else {
echo "Waiting for a database server: $lag seconds lagged\n";
}
function _extractContext( $context, $offset ) {
}
function _extractContext( $context, $offset ) {
- if( is_null( $context ) ) {
+ if ( is_null( $context ) ) {
return null;
} else {
// Hopefully integer overflow will be handled transparently here
return null;
} else {
// Hopefully integer overflow will be handled transparently here
$wgConf->loadFullData();
list( $major, $minor ) = $wgConf->siteFromDB( $wikiID );
$wgConf->loadFullData();
list( $major, $minor ) = $wgConf->siteFromDB( $wikiID );
- if( $major === null ) {
+ if ( $major === null ) {
return null;
}
$canonicalServer = $wgConf->get( 'wgCanonicalServer', $wikiID, $major,
return null;
}
$canonicalServer = $wgConf->get( 'wgCanonicalServer', $wikiID, $major,
public function pageDataFromTitle( $dbr, $title, $options = array() ) {
return $this->pageData( $dbr, array(
'page_namespace' => $title->getNamespace(),
public function pageDataFromTitle( $dbr, $title, $options = array() ) {
return $this->pageData( $dbr, array(
'page_namespace' => $title->getNamespace(),
- 'page_title' => $title->getDBkey() ), $options );
+ 'page_title' => $title->getDBkey() ), $options );
*/
public function isRedirect() {
$content = $this->getContent();
*/
public function isRedirect() {
$content = $this->getContent();
- if ( !$content ) return false;
+ if ( !$content ) {
+ return false;
+ }
return $content->isRedirect();
}
return $content->isRedirect();
}
$dbw = wfGetDB( DB_MASTER );
$dbw->replace( 'redirect', array( 'rd_from' ),
array(
$dbw = wfGetDB( DB_MASTER );
$dbw->replace( 'redirect', array( 'rd_from' ),
array(
- 'rd_from' => $this->getId(),
+ 'rd_from' => $this->getId(),
'rd_namespace' => $rt->getNamespace(),
'rd_namespace' => $rt->getNamespace(),
- 'rd_title' => $rt->getDBkey(),
- 'rd_fragment' => $rt->getFragment(),
+ 'rd_title' => $rt->getDBkey(),
+ 'rd_fragment' => $rt->getFragment(),
'rd_interwiki' => $rt->getInterwiki(),
),
__METHOD__
'rd_interwiki' => $rt->getInterwiki(),
),
__METHOD__
public function doPurge() {
global $wgUseSquid;
public function doPurge() {
global $wgUseSquid;
- if( !wfRunHooks( 'ArticlePurge', array( &$this ) ) ) {
+ if ( !wfRunHooks( 'ArticlePurge', array( &$this ) ) ) {
$content = $this->getContent();
$text = $content === null ? null : $content->getWikitextForTransclusion();
$content = $this->getContent();
$text = $content === null ? null : $content->getWikitextForTransclusion();
- if ( $text === null ) $text = false;
+ if ( $text === null ) {
+ $text = false;
+ }
} else {
$text = false;
}
} else {
$text = false;
}
// Provide autosummaries if one is not provided and autosummaries are enabled.
if ( $wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '' ) {
// Provide autosummaries if one is not provided and autosummaries are enabled.
if ( $wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '' ) {
- if ( !$old_content ) $old_content = null;
+ if ( !$old_content ) {
+ $old_content = null;
+ }
$summary = $handler->getAutosummary( $old_content, $content, $flags );
}
$summary = $handler->getAutosummary( $old_content, $content, $flags );
}
if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
// XXX: could skip pseudo-messages like js/css here, based on content model.
$msgtext = $content ? $content->getWikitextForTransclusion() : null;
if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
// XXX: could skip pseudo-messages like js/css here, based on content model.
$msgtext = $content ? $content->getWikitextForTransclusion() : null;
- if ( $msgtext === false || $msgtext === null ) $msgtext = '';
+ if ( $msgtext === false || $msgtext === null ) {
+ $msgtext = '';
+ }
MessageCache::singleton()->replace( $shortTitle, $msgtext );
}
MessageCache::singleton()->replace( $shortTitle, $msgtext );
}
- if( $options['created'] ) {
+ if ( $options['created'] ) {
self::onArticleCreate( $this->mTitle );
} else {
self::onArticleEdit( $this->mTitle );
self::onArticleCreate( $this->mTitle );
} else {
self::onArticleEdit( $this->mTitle );
$wgContLang->timeanddate( wfTimestamp( TS_MW, $s->rev_timestamp ) ),
$current->getId(), $wgContLang->timeanddate( $current->getTimestamp() )
);
$wgContLang->timeanddate( wfTimestamp( TS_MW, $s->rev_timestamp ) ),
$current->getId(), $wgContLang->timeanddate( $current->getTimestamp() )
);
- if( $summary instanceof Message ) {
+ if ( $summary instanceof Message ) {
$summary = $summary->params( $args )->inContentLanguage()->text();
} else {
$summary = wfMsgReplaceArgs( $summary, $args );
$summary = $summary->params( $args )->inContentLanguage()->text();
} else {
$summary = wfMsgReplaceArgs( $summary, $args );
$resultDetails = array(
'summary' => $summary,
'current' => $current,
$resultDetails = array(
'summary' => $summary,
'current' => $current,
- 'target' => $target,
- 'newid' => $revId
+ 'target' => $target,
+ 'newid' => $revId
- foreach( $added as $catName ) {
+ foreach ( $added as $catName ) {
$cat = Category::newFromName( $catName );
wfRunHooks( 'CategoryAfterPageAdded', array( $cat, $that ) );
}
$cat = Category::newFromName( $catName );
wfRunHooks( 'CategoryAfterPageAdded', array( $cat, $that ) );
}
- foreach( $deleted as $catName ) {
+ foreach ( $deleted as $catName ) {
$cat = Category::newFromName( $catName );
wfRunHooks( 'CategoryAfterPageRemoved', array( $cat, $that ) );
}
$cat = Category::newFromName( $catName );
wfRunHooks( 'CategoryAfterPageRemoved', array( $cat, $that ) );
}
*/
public static function element( $element, $attribs = null, $contents = '', $allowShortTag = true ) {
$out = '<' . $element;
*/
public static function element( $element, $attribs = null, $contents = '', $allowShortTag = true ) {
$out = '<' . $element;
- if( !is_null( $attribs ) ) {
+ if ( !is_null( $attribs ) ) {
$out .= self::expandAttributes( $attribs );
}
$out .= self::expandAttributes( $attribs );
}
- if( is_null( $contents ) ) {
+ if ( is_null( $contents ) ) {
- if( $allowShortTag && $contents === '' ) {
+ if ( $allowShortTag && $contents === '' ) {
$out .= ' />';
} else {
$out .= '>' . htmlspecialchars( $contents ) . "</$element>";
$out .= ' />';
} else {
$out .= '>' . htmlspecialchars( $contents ) . "</$element>";
*/
public static function expandAttributes( $attribs ) {
$out = '';
*/
public static function expandAttributes( $attribs ) {
$out = '';
- if( is_null( $attribs ) ) {
+ if ( is_null( $attribs ) ) {
- } elseif( is_array( $attribs ) ) {
- foreach( $attribs as $name => $val ) {
+ } elseif ( is_array( $attribs ) ) {
+ foreach ( $attribs as $name => $val ) {
$out .= " {$name}=\"" . Sanitizer::encodeAttribute( $val ) . '"';
}
return $out;
$out .= " {$name}=\"" . Sanitizer::encodeAttribute( $val ) . '"';
}
return $out;
*/
public static function elementClean( $element, $attribs = array(), $contents = '' ) {
global $wgContLang;
*/
public static function elementClean( $element, $attribs = array(), $contents = '' ) {
global $wgContLang;
$attribs = array_map( array( 'UtfNormal', 'cleanUp' ), $attribs );
}
$attribs = array_map( array( 'UtfNormal', 'cleanUp' ), $attribs );
}
wfProfileIn( __METHOD__ . '-norm' );
$contents = $wgContLang->normalize( $contents );
wfProfileOut( __METHOD__ . '-norm' );
wfProfileIn( __METHOD__ . '-norm' );
$contents = $wgContLang->normalize( $contents );
wfProfileOut( __METHOD__ . '-norm' );
* @param string $element element name
* @return string
*/
* @param string $element element name
* @return string
*/
- public static function closeElement( $element ) { return "</$element>"; }
+ public static function closeElement( $element ) {
+ return "</$element>";
+ }
/**
* Same as Xml::element(), but does not escape contents. Handy when the
/**
* Same as Xml::element(), but does not escape contents. Handy when the
wfDeprecated( __METHOD__, '1.19' );
return Html::namespaceSelector( array(
'selected' => $selected,
wfDeprecated( __METHOD__, '1.19' );
return Html::namespaceSelector( array(
'selected' => $selected,
- 'all' => $all,
- 'label' => $label,
+ 'all' => $all,
+ 'label' => $label,
- 'name' => $element_name,
- 'id' => 'namespace',
+ 'name' => $element_name,
+ 'id' => 'namespace',
'class' => 'namespaceselector',
) );
}
'class' => 'namespaceselector',
) );
}
public static function monthSelector( $selected = '', $allmonths = null, $id = 'month' ) {
global $wgLang;
$options = array();
public static function monthSelector( $selected = '', $allmonths = null, $id = 'month' ) {
global $wgLang;
$options = array();
- if( is_null( $selected ) )
+ if ( is_null( $selected ) ) {
- if( !is_null( $allmonths ) )
+ }
+ if ( !is_null( $allmonths ) ) {
$options[] = self::option( wfMessage( 'monthsall' )->text(), $allmonths, $selected === $allmonths );
$options[] = self::option( wfMessage( 'monthsall' )->text(), $allmonths, $selected === $allmonths );
- for( $i = 1; $i < 13; $i++ )
+ }
+ for ( $i = 1; $i < 13; $i++ ) {
$options[] = self::option( $wgLang->getMonthName( $i ), $i, $selected === $i );
$options[] = self::option( $wgLang->getMonthName( $i ), $i, $selected === $i );
return self::openElement( 'select', array( 'id' => $id, 'name' => 'month', 'class' => 'mw-month-selector' ) )
. implode( "\n", $options )
. self::closeElement( 'select' );
return self::openElement( 'select', array( 'id' => $id, 'name' => 'month', 'class' => 'mw-month-selector' ) )
. implode( "\n", $options )
. self::closeElement( 'select' );
*/
public static function dateMenu( $year, $month ) {
# Offset overrides year/month selection
*/
public static function dateMenu( $year, $month ) {
# Offset overrides year/month selection
- if( $month && $month !== -1 ) {
+ if ( $month && $month !== -1 ) {
$encMonth = intval( $month );
} else {
$encMonth = '';
}
$encMonth = intval( $month );
} else {
$encMonth = '';
}
$encYear = intval( $year );
$encYear = intval( $year );
- } elseif( $encMonth ) {
+ } elseif ( $encMonth ) {
$thisMonth = intval( gmdate( 'n' ) );
$thisYear = intval( gmdate( 'Y' ) );
$thisMonth = intval( gmdate( 'n' ) );
$thisYear = intval( gmdate( 'Y' ) );
- if( intval( $encMonth ) > $thisMonth ) {
+ if ( intval( $encMonth ) > $thisMonth ) {
$thisYear--;
}
$encYear = $thisYear;
$thisYear--;
}
$encYear = $thisYear;
// Make sure the site language is in the list;
// a custom language code might not have a defined name...
// Make sure the site language is in the list;
// a custom language code might not have a defined name...
- if( !array_key_exists( $wgLanguageCode, $languages ) ) {
+ if ( !array_key_exists( $wgLanguageCode, $languages ) ) {
$languages[$wgLanguageCode] = $wgLanguageCode;
}
$languages[$wgLanguageCode] = $wgLanguageCode;
}
*/
$selected = isset( $languages[$selected] ) ? $selected : $wgLanguageCode;
$options = "\n";
*/
$selected = isset( $languages[$selected] ) ? $selected : $wgLanguageCode;
$options = "\n";
- foreach( $languages as $code => $name ) {
+ foreach ( $languages as $code => $name ) {
$options .= Xml::option( "$code - $name", $code, ($code == $selected) ) . "\n";
}
$attrs = array( 'id' => 'wpUserLanguage', 'name' => 'wpUserLanguage' );
$attrs = array_merge( $attrs, $overrideAttrs );
$options .= Xml::option( "$code - $name", $code, ($code == $selected) ) . "\n";
}
$attrs = array( 'id' => 'wpUserLanguage', 'name' => 'wpUserLanguage' );
$attrs = array_merge( $attrs, $overrideAttrs );
$msg = wfMessage( 'yourlanguage' );
}
return array(
$msg = wfMessage( 'yourlanguage' );
}
return array(
public static function input( $name, $size = false, $value = false, $attribs = array() ) {
$attributes = array( 'name' => $name );
public static function input( $name, $size = false, $value = false, $attribs = array() ) {
$attributes = array( 'name' => $name );
$attributes['size'] = $size;
}
$attributes['size'] = $size;
}
- if( $value !== false ) { // maybe 0
+ if ( $value !== false ) { // maybe 0
$attributes['value'] = $value;
}
$attributes['value'] = $value;
}
$a = array( 'for' => $id );
# FIXME avoid copy pasting below:
$a = array( 'for' => $id );
# FIXME avoid copy pasting below:
- if( isset( $attribs['class'] ) ) {
+ if ( isset( $attribs['class'] ) ) {
$a['class'] = $attribs['class'];
}
$a['class'] = $attribs['class'];
}
- if( isset( $attribs['title'] ) ) {
+ if ( isset( $attribs['title'] ) ) {
$a['title'] = $attribs['title'];
}
$a['title'] = $attribs['title'];
}
*/
public static function option( $text, $value = null, $selected = false,
$attribs = array() ) {
*/
public static function option( $text, $value = null, $selected = false,
$attribs = array() ) {
- if( !is_null( $value ) ) {
+ if ( !is_null( $value ) ) {
$attribs['value'] = $value;
}
$attribs['value'] = $value;
}
$attribs['selected'] = 'selected';
}
return Html::element( 'option', $attribs, $text );
$attribs['selected'] = 'selected';
}
return Html::element( 'option', $attribs, $text );
} elseif ( substr( $value, 0, 1 ) == '*' && substr( $value, 1, 1 ) != '*' ) {
// A new group is starting ...
$value = trim( substr( $value, 1 ) );
} elseif ( substr( $value, 0, 1 ) == '*' && substr( $value, 1, 1 ) != '*' ) {
// A new group is starting ...
$value = trim( substr( $value, 1 ) );
- if( $optgroup ) $options .= self::closeElement( 'optgroup' );
+ if ( $optgroup ) {
+ $options .= self::closeElement( 'optgroup' );
+ }
$options .= self::openElement( 'optgroup', array( 'label' => $value ) );
$optgroup = true;
} elseif ( substr( $value, 0, 2 ) == '**' ) {
$options .= self::openElement( 'optgroup', array( 'label' => $value ) );
$optgroup = true;
} elseif ( substr( $value, 0, 2 ) == '**' ) {
$options .= self::option( $value, $value, $selected === $value );
} else {
// groupless reason list
$options .= self::option( $value, $value, $selected === $value );
} else {
// groupless reason list
- if( $optgroup ) $options .= self::closeElement( 'optgroup' );
+ if ( $optgroup ) {
+ $options .= self::closeElement( 'optgroup' );
+ }
$options .= self::option( $value, $value, $selected === $value );
$optgroup = false;
}
}
$options .= self::option( $value, $value, $selected === $value );
$optgroup = false;
}
}
- if( $optgroup ) $options .= self::closeElement( 'optgroup' );
+ if ( $optgroup ) {
+ $options .= self::closeElement( 'optgroup' );
+ }
$attribs['id'] = $name;
$attribs['name'] = $name;
}
$attribs['id'] = $name;
$attribs['name'] = $name;
}
$attribs['class'] = $class;
}
$attribs['class'] = $class;
}
$attribs['tabindex'] = $tabindex;
}
$attribs['tabindex'] = $tabindex;
}
# case folding violates XML standard, turn it off
xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, false );
# case folding violates XML standard, turn it off
xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, false );
- if( !xml_parse( $parser, $text, true ) ) {
+ if ( !xml_parse( $parser, $text, true ) ) {
//$err = xml_error_string( xml_get_error_code( $parser ) );
//$position = xml_get_current_byte_index( $parser );
//$fragment = $this->extractFragment( $html, $position );
//$err = xml_error_string( xml_get_error_code( $parser ) );
//$position = xml_get_current_byte_index( $parser );
//$fragment = $this->extractFragment( $html, $position );
$form = '';
$form .= "<table><tbody>";
$form = '';
$form .= "<table><tbody>";
- foreach( $fields as $labelmsg => $input ) {
+ foreach ( $fields as $labelmsg => $input ) {
$id = "mw-$labelmsg";
$form .= Xml::openElement( 'tr', array( 'id' => $id ) );
$form .= Xml::tags( 'td', array( 'class' => 'mw-label' ), wfMessage( $labelmsg )->parse() );
$id = "mw-$labelmsg";
$form .= Xml::openElement( 'tr', array( 'id' => $id ) );
$form .= Xml::tags( 'td', array( 'class' => 'mw-label' ), wfMessage( $labelmsg )->parse() );
$form .= Xml::closeElement( 'tr' );
}
$form .= Xml::closeElement( 'tr' );
}
$form .= Xml::openElement( 'tr' );
$form .= Xml::tags( 'td', array(), '' );
$form .= Xml::openElement( 'td', array( 'class' => 'mw-submit' ) ) . Xml::submitButton( wfMessage( $submitLabel )->text() ) . Xml::closeElement( 'td' );
$form .= Xml::openElement( 'tr' );
$form .= Xml::tags( 'td', array(), '' );
$form .= Xml::openElement( 'td', array( 'class' => 'mw-submit' ) ) . Xml::submitButton( wfMessage( $submitLabel )->text() ) . Xml::closeElement( 'td' );
if ( is_array( $headers ) ) {
$s .= Xml::openElement( 'thead', $attribs );
if ( is_array( $headers ) ) {
$s .= Xml::openElement( 'thead', $attribs );
- foreach( $headers as $id => $header ) {
+ foreach ( $headers as $id => $header ) {
$attribs = array();
if ( is_string( $id ) ) {
$attribs = array();
if ( is_string( $id ) ) {
$s .= Xml::closeElement( 'thead' );
}
$s .= Xml::closeElement( 'thead' );
}
- foreach( $rows as $id => $row ) {
+ foreach ( $rows as $id => $row ) {
$attribs = array();
if ( is_string( $id ) ) {
$attribs = array();
if ( is_string( $id ) ) {
public static function buildTableRow( $attribs, $cells ) {
$s = Xml::openElement( 'tr', $attribs );
public static function buildTableRow( $attribs, $cells ) {
$s = Xml::openElement( 'tr', $attribs );
- foreach( $cells as $id => $cell ) {
-
+ foreach ( $cells as $id => $cell ) {
$attribs = array();
if ( is_string( $id ) ) {
$attribs = array();
if ( is_string( $id ) ) {
static function formatOptions( $options, $default = false ) {
$data = '';
static function formatOptions( $options, $default = false ) {
$data = '';
- foreach( $options as $label => $value ) {
+ foreach ( $options as $label => $value ) {
if ( is_array( $value ) ) {
$contents = self::formatOptions( $value, $default );
$data .= Html::rawElement( 'optgroup', array( 'label' => $label ), $contents ) . "\n";
if ( is_array( $value ) ) {
$contents = self::formatOptions( $value, $default );
$data .= Html::rawElement( 'optgroup', array( 'label' => $label ), $contents ) . "\n";
do {
$chunk = fread( $file, 32768 );
$ret = xml_parse( $parser, $chunk, feof( $file ) );
do {
$chunk = fread( $file, 32768 );
$ret = xml_parse( $parser, $chunk, feof( $file ) );
// XML isn't well-formed!
fclose( $file );
xml_parser_free( $parser );
return;
}
// XML isn't well-formed!
fclose( $file );
xml_parser_free( $parser );
return;
}
- } while( !feof( $file ) );
+ } while ( !feof( $file ) );
private function rootElementOpen( $parser, $name, $attribs ) {
$this->rootElement = $name;
private function rootElementOpen( $parser, $name, $attribs ) {
$this->rootElement = $name;
- if( is_callable( $this->filterCallback ) ) {
+ if ( is_callable( $this->filterCallback ) ) {
xml_set_element_handler( $parser, array( $this, 'elementOpen' ), false );
$this->elementOpen( $parser, $name, $attribs );
} else {
xml_set_element_handler( $parser, array( $this, 'elementOpen' ), false );
$this->elementOpen( $parser, $name, $attribs );
} else {
* @param $attribs
*/
private function elementOpen( $parser, $name, $attribs ) {
* @param $attribs
*/
private function elementOpen( $parser, $name, $attribs ) {
- if( call_user_func( $this->filterCallback, $name, $attribs ) ) {
+ if ( call_user_func( $this->filterCallback, $name, $attribs ) ) {
// Filter hit!
$this->filterMatch = true;
}
// Filter hit!
$this->filterMatch = true;
}
$result = fgets( $this->mFP, 1024 );
list( $status, $len ) = explode( ' ', $result );
$result = fgets( $this->mFP, 1024 );
list( $status, $len ) = explode( ' ', $result );
- if( $status == 'ERROR' ) {
+ if ( $status == 'ERROR' ) {
// $len is actually the error code...
print "zhdaemon error $len<br />\n";
return false;
}
$bytesread = 0;
$data = '';
// $len is actually the error code...
print "zhdaemon error $len<br />\n";
return false;
}
$bytesread = 0;
$data = '';
- while( !feof( $this->mFP ) && $bytesread < $len ) {
+ while ( !feof( $this->mFP ) && $bytesread < $len ) {
$str = fread( $this->mFP, $len - $bytesread );
$bytesread += strlen( $str );
$data .= $str;
$str = fread( $this->mFP, $len - $bytesread );
$bytesread += strlen( $str );
$data .= $str;
$info = explode( ';', $infoline );
$ret = array();
$i = 0;
$info = explode( ';', $infoline );
$ret = array();
$i = 0;
- foreach( $info as $variant ) {
+ foreach ( $info as $variant ) {
list( $code, $len ) = explode( ' ', $variant );
$ret[strtolower( $code )] = substr( $data, $i, $len );
$i += $len;
list( $code, $len ) = explode( ' ', $variant );
$ret[strtolower( $code )] = substr( $data, $i, $len );
$i += $len;