Fixed spacing in files direct in includes folder
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 20 Apr 2013 22:49:30 +0000 (00:49 +0200)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 21 Apr 2013 06:38:49 +0000 (06:38 +0000)
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Ibb8dd102db045522d12ff939075ba7420d95ab6b

75 files changed:
includes/Article.php
includes/AutoLoader.php
includes/Block.php
includes/Cdb.php
includes/Cdb_PHP.php
includes/ChangeTags.php
includes/ChangesFeed.php
includes/ChangesList.php
includes/Collation.php
includes/ConfEditor.php
includes/CryptRand.php
includes/DataUpdate.php
includes/Exception.php
includes/Export.php
includes/Fallback.php
includes/Feed.php
includes/FeedUtils.php
includes/FileDeleteForm.php
includes/ForkController.php
includes/FormOptions.php
includes/GitInfo.php
includes/HTMLForm.php
includes/HashRing.php
includes/HistoryBlob.php
includes/Hooks.php
includes/Html.php
includes/HttpFunctions.php
includes/IP.php
includes/ImageGallery.php
includes/ImagePage.php
includes/ImageQueryPage.php
includes/Import.php
includes/Licenses.php
includes/LinkFilter.php
includes/Linker.php
includes/LinksUpdate.php
includes/MWFunction.php
includes/MagicWord.php
includes/Message.php
includes/Metadata.php
includes/MimeMagic.php
includes/OutputHandler.php
includes/Pager.php
includes/PathRouter.php
includes/Preferences.php
includes/PrefixSearch.php
includes/ProtectionForm.php
includes/QueryPage.php
includes/Revision.php
includes/RevisionList.php
includes/Sanitizer.php
includes/Setup.php
includes/SiteConfiguration.php
includes/SiteStats.php
includes/Skin.php
includes/SkinLegacy.php
includes/SkinTemplate.php
includes/SpecialPageFactory.php
includes/Status.php
includes/StringUtils.php
includes/Timestamp.php
includes/User.php
includes/UserMailer.php
includes/UserRightsProxy.php
includes/WatchedItem.php
includes/WebRequest.php
includes/WebResponse.php
includes/WebStart.php
includes/Wiki.php
includes/WikiError.php
includes/WikiMap.php
includes/WikiPage.php
includes/Xml.php
includes/XmlTypeCheck.php
includes/ZhClient.php

index d2f52bc..1354a48 100644 (file)
@@ -673,12 +673,12 @@ class Article implements Page {
                                                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;
-                                       } elseif( !ContentHandler::runLegacyHooks( 'ArticleViewCustom',
+                                       } elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom',
                                                        array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) {
 
                                                # Allow extensions do their own custom view for certain pages
@@ -875,7 +875,7 @@ class Article implements Page {
                        }
                        if ( Block::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block ) {
                                return array(
-                                       'index'  => 'noindex',
+                                       'index' => 'noindex',
                                        'follow' => 'nofollow'
                                );
                        }
@@ -884,19 +884,19 @@ class Article implements Page {
                if ( $this->mPage->getID() === 0 || $this->getOldID() ) {
                        # Non-articles (special pages etc), and old revisions
                        return array(
-                               'index'  => 'noindex',
+                               'index' => 'noindex',
                                'follow' => 'nofollow'
                        );
                } elseif ( $this->getContext()->getOutput()->isPrintable() ) {
                        # Discourage indexing of printable versions, but encourage following
                        return array(
-                               'index'  => 'noindex',
+                               'index' => 'noindex',
                                'follow' => 'follow'
                        );
                } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
                        # For ?curid=x urls, disallow indexing
                        return array(
-                               'index'  => 'noindex',
+                               'index' => 'noindex',
                                'follow' => 'follow'
                        );
                }
index 4e562f6..8c20c8a 100644 (file)
@@ -574,9 +574,9 @@ $wgAutoloadLocalClasses = array(
        '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',
index 3f00a51..638b9a6 100644 (file)
@@ -65,11 +65,11 @@ class Block {
                $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();
                }
 
-               if( count( func_get_args() ) > 0 ) {
+               if ( count( func_get_args() ) > 0 ) {
                        # Soon... :D
                        # wfDeprecated( __METHOD__ . " with arguments" );
                }
@@ -206,16 +206,16 @@ class Block {
         */
        public function load( $address = '', $user = 0 ) {
                wfDeprecated( __METHOD__, '1.18' );
-               if( $user ) {
+               if ( $user ) {
                        $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
-                       foreach( $block as $variable => $value ) {
+                       foreach ( $block as $variable => $value ) {
                                $this->$variable = $value;
                        }
                        return true;
@@ -237,7 +237,7 @@ class Block {
        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 ),
                        );
@@ -247,7 +247,7 @@ class Block {
 
                # 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:
@@ -285,20 +285,20 @@ class Block {
                # 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
-                       if( $block->deleteIfExpired() ) {
+                       if ( $block->deleteIfExpired() ) {
                                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() ) {
                                continue;
                        }
 
-                       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 );
@@ -313,14 +313,14 @@ class Block {
                                $score = $block->getType();
                        }
 
-                       if( $score < $bestBlockScore ) {
+                       if ( $score < $bestBlockScore ) {
                                $bestBlockScore = $score;
                                $bestRow = $row;
                                $bestBlockPreventsEdit = $block->prevents( 'edit' );
                        }
                }
 
-               if( $bestRow !== null ) {
+               if ( $bestRow !== null ) {
                        $this->initFromRow( $bestRow );
                        $this->prevents( 'edit', $bestBlockPreventsEdit );
                        return true;
@@ -579,7 +579,7 @@ class Block {
                global $wgPutIPinRC;
 
                // No IPs are in recentchanges table, so nothing to select
-               if( !$wgPutIPinRC ) {
+               if ( !$wgPutIPinRC ) {
                        return;
                }
 
@@ -601,7 +601,9 @@ class Block {
                        foreach ( $res as $row ) {
                                if ( $row->rc_ip ) {
                                        $id = $block->doAutoblock( $row->rc_ip );
-                                       if ( $id ) $blockIds[] = $id;
+                                       if ( $id ) {
+                                               $blockIds[] = $id;
+                                       }
                                }
                        }
                }
@@ -1057,24 +1059,24 @@ class Block {
        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 );
 
-               } 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;
 
-               } 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 );
 
-                       if( $type !== null ) {
+                       if ( $type !== null ) {
                                $block->setTarget( $target );
                        }
 
-                       if( $block->newLoad( $vagueTarget ) ) {
+                       if ( $block->newLoad( $vagueTarget ) ) {
                                return $block;
                        }
                }
@@ -1278,13 +1280,13 @@ class Block {
         */
        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 );
                        }
-               } elseif( $target === null ) {
+               } elseif ( $target === null ) {
                        return array( null, null );
                }
 
@@ -1305,7 +1307,7 @@ class Block {
 
                # 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];
index a142c7c..81c0afe 100644 (file)
@@ -133,7 +133,7 @@ class CdbReader_DBA {
        }
 
        function close() {
-               if( isset( $this->handle ) ) {
+               if ( isset( $this->handle ) ) {
                        dba_close( $this->handle );
                }
                unset( $this->handle );
@@ -164,7 +164,7 @@ class CdbWriter_DBA {
        }
 
        function close() {
-               if( isset( $this->handle ) ) {
+               if ( isset( $this->handle ) ) {
                        dba_close( $this->handle );
                }
                if ( wfIsWindows() ) {
index e16397b..166242a 100644 (file)
@@ -138,7 +138,7 @@ class CdbReader_PHP extends CdbReader {
        }
 
        function close() {
-               if( isset( $this->handle ) ) {
+               if ( isset( $this->handle ) ) {
                        fclose( $this->handle );
                }
                unset( $this->handle );
@@ -332,7 +332,7 @@ class CdbWriter_PHP extends CdbWriter {
         */
        public function close() {
                $this->finish();
-               if( isset( $this->handle ) ) {
+               if ( isset( $this->handle ) ) {
                        fclose( $this->handle );
                }
                if ( wfIsWindows() && file_exists( $this->realFileName ) ) {
@@ -450,9 +450,11 @@ class CdbWriter_PHP extends CdbWriter {
                                $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 ) {
                                                $where = 0;
+                                       }
+                               }
                                $hashtable[$where] = $hp;
                        }
 
index 3adf58f..5478396 100644 (file)
@@ -37,14 +37,15 @@ class ChangeTags {
        static function formatSummaryRow( $tags, $page ) {
                global $wgLang;
 
-               if( !$tags )
+               if ( !$tags ) {
                        return array( '', 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 ' .
@@ -93,21 +94,21 @@ class ChangeTags {
 
                $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.
-               if( !$rc_id ) {
+               if ( !$rc_id ) {
                        $dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave.
-                       if( $log_id ) {
+                       if ( $log_id ) {
                                $rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_logid' => $log_id ), __METHOD__ );
-                       } elseif( $rev_id ) {
+                       } elseif ( $rev_id ) {
                                $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__ );
@@ -138,7 +139,7 @@ class ChangeTags {
 
                // 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,
@@ -173,14 +174,14 @@ class ChangeTags {
                                                                                &$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';
-               } elseif( in_array( 'logging', $tables ) ) {
+               } elseif ( in_array( 'logging', $tables ) ) {
                        $join_cond = 'log_id';
                } elseif ( in_array( 'revision', $tables ) ) {
                        $join_cond = 'rev_id';
@@ -193,7 +194,7 @@ class ChangeTags {
                $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
 
index e900e34..8e710de 100644 (file)
@@ -54,7 +54,7 @@ class ChangesFeed {
                        return false;
                }
 
-               if( !array_key_exists( $this->format, $wgFeedClasses ) ) {
+               if ( !array_key_exists( $this->format, $wgFeedClasses ) ) {
                        // falling back to atom
                        $this->format = 'atom';
                }
@@ -92,7 +92,7 @@ class ChangesFeed {
                 * 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;
@@ -134,7 +134,7 @@ class ChangesFeed {
 
                $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
@@ -146,7 +146,7 @@ class ChangesFeed {
                        $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
@@ -172,8 +172,8 @@ class ChangesFeed {
                # 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 &&
@@ -185,11 +185,13 @@ class ChangesFeed {
                        }
                }
 
-               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)
-                       if( $obj->rc_deleted ) continue;
+                       if ( $obj->rc_deleted ) {
+                               continue;
+                       }
 
                        if ( $obj->rc_this_oldid ) {
                                $url = $title->getFullURL(
index 79e2d0b..3170a7d 100644 (file)
@@ -99,7 +99,7 @@ class ChangesList extends ContextSource {
                $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 {
@@ -120,7 +120,7 @@ class ChangesList extends ContextSource {
         * 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();
@@ -136,7 +136,7 @@ class ChangesList extends ContextSource {
         */
        protected function recentChangesFlags( $flags, $nothing = '&#160;' ) {
                $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;
@@ -162,7 +162,7 @@ class ChangesList extends ContextSource {
                                '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();
                        }
@@ -227,7 +227,7 @@ class ChangesList extends ContextSource {
                        $formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text();
                }
 
-               if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
+               if ( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) {
                        $tag = 'strong';
                } else {
                        $tag = 'span';
@@ -267,7 +267,7 @@ class ChangesList extends ContextSource {
                        $newlen = $old->mAttribs['rc_new_len'];
                }
 
-               if( $oldlen === null || $newlen === null ) {
+               if ( $oldlen === null || $newlen === null ) {
                        return '';
                }
 
@@ -279,7 +279,7 @@ class ChangesList extends ContextSource {
         * @return String
         */
        public function endRecentChangesList() {
-               if( $this->rclistOpen ) {
+               if ( $this->rclistOpen ) {
                        return "</ul>\n";
                } else {
                        return '';
@@ -293,8 +293,8 @@ class ChangesList extends ContextSource {
        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\">";
@@ -321,7 +321,7 @@ class ChangesList extends ContextSource {
         */
        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'];
@@ -332,7 +332,7 @@ class ChangesList extends ContextSource {
                                'oldid' => $rc->mAttribs['rc_last_oldid']
                        );
 
-                       if( $unpatrolled ) {
+                       if ( $unpatrolled ) {
                                $query['rcid'] = $rc->mAttribs['rc_id'];
                        };
 
@@ -378,7 +378,7 @@ class ChangesList extends ContextSource {
                        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
@@ -421,7 +421,7 @@ class ChangesList extends ContextSource {
         * @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'],
@@ -450,8 +450,8 @@ class ChangesList extends ContextSource {
         * @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() );
@@ -475,8 +475,8 @@ class ChangesList extends ContextSource {
         */
        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];
@@ -504,7 +504,7 @@ class ChangesList extends ContextSource {
         * @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 );
@@ -517,7 +517,7 @@ class ChangesList extends ContextSource {
         * @return string
         */
        protected function maybeWatchedLink( $link, $watched = false ) {
-               if( $watched ) {
+               if ( $watched ) {
                        return '<strong class="mw-watched">' . $link . '</strong>';
                } else {
                        return '<span class="mw-rc-unwatched">' . $link . '</span>';
@@ -530,7 +530,7 @@ class ChangesList extends ContextSource {
         * @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 */
@@ -554,8 +554,9 @@ class ChangesList extends ContextSource {
         * @param $classes
         */
        public function insertTags( &$s, &$rc, &$classes ) {
-               if ( empty( $rc->mAttribs['ts_tags'] ) )
+               if ( empty( $rc->mAttribs['ts_tags'] ) ) {
                        return;
+               }
 
                list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow( $rc->mAttribs['ts_tags'], 'changeslist' );
                $classes = array_merge( $classes, $newClasses );
@@ -605,11 +606,10 @@ class OldChangesList extends ChangesList {
                $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';
-                       }
-                       else {
+                       } else {
                                $classes[] = 'mw-line-even';
                        }
                }
@@ -619,15 +619,15 @@ class OldChangesList extends ChangesList {
                $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 ) {
                // Log entries
-               } 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
-               } elseif( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
+               } elseif ( $rc->mAttribs['rc_namespace'] == NS_SPECIAL ) {
                        list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $rc->mAttribs['rc_title'] );
-                       if( $name == 'Log' ) {
+                       if ( $name == 'Log' ) {
                                $this->insertLog( $s, $rc->getTitle(), $subpage );
                        }
                // Regular entries
@@ -673,11 +673,11 @@ class OldChangesList extends ChangesList {
                $this->insertExtra( $s, $rc, $classes );
 
                # How many users watch this page
-               if( $rc->numberofWatchingusers > 0 ) {
+               if ( $rc->numberofWatchingusers > 0 ) {
                        $s .= ' ' . $this->numberofWatchingusers( $rc->numberofWatchingusers );
                }
 
-               if( $this->watchlist ) {
+               if ( $this->watchlist ) {
                        $classes[] = Sanitizer::escapeClass( 'watchlist-' . $rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
                }
 
@@ -730,7 +730,7 @@ class EnhancedChangesList extends ChangesList {
                # 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();
@@ -746,14 +746,14 @@ class EnhancedChangesList extends ChangesList {
                $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 ) {
                // New unpatrolled pages
-               } 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
-               } 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();
@@ -763,7 +763,7 @@ class EnhancedChangesList extends ChangesList {
                        }
                        $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
@@ -786,7 +786,7 @@ class EnhancedChangesList extends ChangesList {
                # 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();
@@ -795,10 +795,10 @@ class EnhancedChangesList extends ChangesList {
                $querydiff = $curIdEq + array( 'diff' => $thisOldid, 'oldid' =>
                        $lastOldid ) + $rcIdQuery;
 
-               if( !$showdifflinks ) {
+               if ( !$showdifflinks ) {
                        $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 {
@@ -814,9 +814,9 @@ class EnhancedChangesList extends ChangesList {
                }
 
                # Make "last" link
-               if( !$showdifflinks || !$lastOldid ) {
+               if ( !$showdifflinks || !$lastOldid ) {
                        $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'],
@@ -824,7 +824,7 @@ class EnhancedChangesList extends ChangesList {
                }
 
                # Make user links
-               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'] );
@@ -839,15 +839,15 @@ class EnhancedChangesList extends ChangesList {
                # 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
-                       if( $type == RC_LOG ) {
+                       if ( $type == RC_LOG ) {
                                $secureName = SpecialPage::getTitleFor( 'Log', $logType )->getPrefixedDBkey();
                        }
-                       if( !isset( $this->rc_cache[$secureName] ) ) {
+                       if ( !isset( $this->rc_cache[$secureName] ) ) {
                                $this->rc_cache[$secureName] = array();
                        }
 
@@ -893,39 +893,39 @@ class EnhancedChangesList extends ChangesList {
                # Some catalyst variables...
                $namehidden = true;
                $allLogs = true;
-               foreach( $block as $rcObj ) {
+               foreach ( $block as $rcObj ) {
                        $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!
-                       if( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
+                       if ( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION ) ) {
                                $namehidden = false;
                        }
                        $u = $rcObj->userlink;
-                       if( !isset( $userlinks[$u] ) ) {
+                       if ( !isset( $userlinks[$u] ) ) {
                                $userlinks[$u] = 0;
                        }
-                       if( $rcObj->unpatrolled ) {
+                       if ( $rcObj->unpatrolled ) {
                                $unpatrolled = true;
                        }
-                       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.
-                       if( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
+                       if ( !$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'];
                        }
 
-                       if( !$rcObj->mAttribs['rc_bot'] ) {
+                       if ( !$rcObj->mAttribs['rc_bot'] ) {
                                $allBots = false;
                        }
-                       if( !$rcObj->mAttribs['rc_minor'] ) {
+                       if ( !$rcObj->mAttribs['rc_minor'] ) {
                                $allMinors = false;
                        }
 
@@ -936,10 +936,10 @@ class EnhancedChangesList extends ChangesList {
                krsort( $userlinks );
                asort( $userlinks );
                $users = array();
-               foreach( $userlinks as $userlink => $count ) {
+               foreach ( $userlinks as $userlink => $count ) {
                        $text = $userlink;
                        $text .= $this->getLanguage()->getDirMark();
-                       if( $count > 1 ) {
+                       if ( $count > 1 ) {
                                $text .= ' ' . $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->formatNum( $count ) . '×' )->escaped();
                        }
                        array_push( $users, $text );
@@ -965,9 +965,9 @@ class EnhancedChangesList extends ChangesList {
                $r .= '&#160;' . $block[0]->timestamp . '&#160;</td><td>';
 
                # Article link
-               if( $namehidden ) {
+               if ( $namehidden ) {
                        $r .= ' <span class="history-deleted">' . $this->msg( 'rev-deleted-event' )->escaped() . '</span>';
-               } elseif( $allLogs ) {
+               } elseif ( $allLogs ) {
                        $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
                } else {
                        $this->insertArticleLink( $r, $block[0], $block[0]->unpatrolled, $block[0]->watched );
@@ -985,10 +985,10 @@ class EnhancedChangesList extends ChangesList {
                # 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];
-                       } elseif( $isnew ) {
+                       } elseif ( $isnew ) {
                                $logtext .= $nchanges[$n];
                        } else {
                                $params = $queryParams;
@@ -1006,9 +1006,9 @@ class EnhancedChangesList extends ChangesList {
                }
 
                # History
-               if( $allLogs ) {
+               if ( $allLogs ) {
                        // 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;
@@ -1023,27 +1023,27 @@ class EnhancedChangesList extends ChangesList {
                                );
                }
 
-               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)
-               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...
-                       while( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) {
+                       while ( $last < $first && $block[$last]->mAttribs['rc_new_len'] === null ) {
                                $last++;
                        }
-                       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] );
 
-                       if( $chardiff == '' ) {
+                       if ( $chardiff == '' ) {
                                $r .= ' ';
                        } else {
                                $r .= ' ' . $chardiff . ' <span class="mw-changeslist-separator">. .</span> ';
@@ -1054,7 +1054,7 @@ class EnhancedChangesList extends ChangesList {
                $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'];
@@ -1070,15 +1070,15 @@ class EnhancedChangesList extends ChangesList {
 
                        $params = $queryParams;
 
-                       if( $rcObj->mAttribs['rc_this_oldid'] != 0 ) {
+                       if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) {
                                $params['oldid'] = $rcObj->mAttribs['rc_this_oldid'];
                        }
 
                        # Log timestamp
-                       if( $type == RC_LOG ) {
+                       if ( $type == RC_LOG ) {
                                $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) {
@@ -1091,7 +1091,7 @@ class EnhancedChangesList extends ChangesList {
                                                array(),
                                                $params
                                        );
-                               if( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) {
+                               if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) {
                                        $link = '<span class="history-deleted">' . $link . '</span> ';
                                }
                        }
@@ -1192,7 +1192,7 @@ class EnhancedChangesList extends ChangesList {
                $type = $rcObj->mAttribs['rc_type'];
                $logType = $rcObj->mAttribs['rc_log_type'];
                $classes = array( 'mw-enhanced-rc' );
-               if( $logType ) {
+               if ( $logType ) {
                        # Log entry
                        $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-'
                                        . $logType . '-' . $rcObj->mAttribs['rc_title'] );
@@ -1206,7 +1206,7 @@ class EnhancedChangesList extends ChangesList {
 
                $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 .= '&#160;&#160;&#160;&#160;'; // 4 flags -> 4 spaces
                } else {
                        $r .= $this->recentChangesFlags( array(
@@ -1218,7 +1218,7 @@ class EnhancedChangesList extends ChangesList {
                }
                $r .= '&#160;' . $rcObj->timestamp . '&#160;</td><td>';
                # Article or log link
-               if( $logType ) {
+               if ( $logType ) {
                        $logPage = new LogPage( $logType );
                        $logTitle = SpecialPage::getTitleFor( 'Log', $logType );
                        $logName = $logPage->getName()->escaped();
@@ -1272,15 +1272,15 @@ class EnhancedChangesList extends ChangesList {
         * @return string
         */
        protected function recentChangesBlock() {
-               if( count ( $this->rc_cache ) == 0 ) {
+               if ( count ( $this->rc_cache ) == 0 ) {
                        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 );
index 723b38e..215659e 100644 (file)
@@ -430,7 +430,7 @@ class IcuCollation extends Collation {
 
                $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" );
@@ -456,7 +456,7 @@ class IcuCollation extends Collation {
                        }
                        $prev = $trimmedKey;
                }
-               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.
index 293d53d..78af1c1 100644 (file)
@@ -278,19 +278,23 @@ class ConfEditor {
        function getVars() {
                $vars = array();
                $this->parse();
-               foreach( $this->pathInfo as $path => $data ) {
-                       if ( $path[0] != '$' )
+               foreach ( $this->pathInfo as $path => $data ) {
+                       if ( $path[0] != '$' ) {
                                continue;
+                       }
                        $trimmedPath = substr( $path, 1 );
                        $name = $data['name'];
-                       if ( $name[0] == '@' )
+                       if ( $name[0] == '@' ) {
                                continue;
-                       if ( $name[0] == '$' )
+                       }
+                       if ( $name[0] == '$' ) {
                                $name = substr( $name, 1 );
+                       }
                        $parentPath = substr( $trimmedPath, 0,
                                strlen( $trimmedPath ) - strlen( $name ) );
-                       if( substr( $parentPath, -1 ) == '/' )
+                       if ( substr( $parentPath, -1 ) == '/' ) {
                                $parentPath = substr( $parentPath, 0, -1 );
+                       }
 
                        $value = substr( $this->text, $data['valueStartByte'],
                                $data['valueEndByte'] - $data['valueStartByte']
@@ -315,13 +319,15 @@ class ConfEditor {
                $target =& $array;
                if ( $path !== '' ) {
                        foreach ( $pathArr as $p ) {
-                               if( !isset( $target[$p] ) )
+                               if ( !isset( $target[$p] ) ) {
                                        $target[$p] = array();
+                               }
                                $target =& $target[$p];
                        }
                }
-               if ( !isset( $target[$key] ) )
+               if ( !isset( $target[$key] ) ) {
                        $target[$key] = $value;
+               }
        }
 
        /**
@@ -329,25 +335,30 @@ class ConfEditor {
         * @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( '\\\'' => '\'', '\\\\' => '\\' ) );
-               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 ) );
-               if ( substr( $str, 0, 4 ) == 'true' )
+               }
+               if ( substr( $str, 0, 4 ) == 'true' ) {
                        return true;
-               if ( substr( $str, 0, 5 ) == 'false' )
+               }
+               if ( substr( $str, 0, 5 ) == 'false' ) {
                        return false;
-               if ( substr( $str, 0, 4 ) == 'null' )
+               }
+               if ( substr( $str, 0, 4 ) == 'null' ) {
                        return null;
+               }
                // Must be some kind of numeric value, so let PHP's weak typing
                // be useful for a change
                return $str;
@@ -617,16 +628,18 @@ class ConfEditor {
                                $this->expect( '=' );
                                $this->skipSpace();
                                $this->startPathValue();
-                               if ( $arrayAssign )
+                               if ( $arrayAssign ) {
                                        $this->pushState( 'expression', 'array assign end' );
-                               else
+                               } else {
                                        $this->pushState( 'expression', 'statement end' );
+                               }
                                break;
                        case 'array assign end':
                        case 'statement end':
                                $this->endPathValue();
-                               if ( $state == 'array assign end' )
+                               if ( $state == 'array assign end' ) {
                                        $this->popPath();
+                               }
                                $this->skipSpace();
                                $this->expect( ';' );
                                $this->nextPath( '@extra-' . ($this->serial++) );
index d0305d8..bac018e 100644 (file)
@@ -106,7 +106,7 @@ class MWCryptRand {
                                        }
                                }
                                // 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;
index c1076b2..7b9ac28 100644 (file)
@@ -78,7 +78,9 @@ abstract class DataUpdate implements DeferrableUpdate {
         * @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;
index 93fddac..b42ae99 100644 (file)
@@ -333,7 +333,7 @@ class ErrorPageError extends MWException {
                // 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 );
@@ -478,7 +478,7 @@ class UserBlockedError extends ErrorPageError {
                }
 
                $reason = $block->mReason;
-               if( $reason == '' ) {
+               if ( $reason == '' ) {
                        $reason = wfMessage( 'blockednoreason' )->text();
                }
 
index 996c14b..9400c41 100644 (file)
@@ -249,9 +249,13 @@ class WikiExporter {
                        $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
-                       if ( $cond ) $where[] = $cond;
+                       if ( $cond ) {
+                               $where[] = $cond;
+                       }
                        # Get logging table name for logging.* clause
                        $logging = $this->db->tableName( 'logging' );
 
@@ -638,7 +642,7 @@ class XmlDumpWriter {
 
                $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";
                }
 
index 2e19a09..cdf6c88 100644 (file)
@@ -35,13 +35,13 @@ class Fallback {
                if ( substr( $to, -8 ) == '//IGNORE' ) {
                        $to = substr( $to, 0, strlen( $to ) - 8 );
                }
-               if( strcasecmp( $from, $to ) == 0 ) {
+               if ( strcasecmp( $from, $to ) == 0 ) {
                        return $string;
                }
-               if( strcasecmp( $from, 'utf-8' ) == 0 ) {
+               if ( strcasecmp( $from, 'utf-8' ) == 0 ) {
                        return utf8_decode( $string );
                }
-               if( strcasecmp( $to, 'utf-8' ) == 0 ) {
+               if ( strcasecmp( $to, 'utf-8' ) == 0 ) {
                        return utf8_encode( $string );
                }
                return $string;
@@ -64,12 +64,12 @@ class Fallback {
         * @return string
         */
        public static function mb_substr( $str, $start, $count = 'end' ) {
-               if( $start != 0 ) {
+               if ( $start != 0 ) {
                        $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 );
                }
@@ -83,14 +83,14 @@ class Fallback {
         * @return int
         */
        public static function mb_substr_split_unicode( $str, $splitPos ) {
-               if( $splitPos == 0 ) {
+               if ( $splitPos == 0 ) {
                        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.
@@ -104,7 +104,7 @@ class Fallback {
                                $bytePos = 0;
                        }
 
-                       while( $charPos++ < $splitPos ) {
+                       while ( $charPos++ < $splitPos ) {
                                ++$bytePos;
                                // Move past any tail bytes
                                while ( $bytePos < $byteLen && $str[$bytePos] >= "\x80" && $str[$bytePos] < "\xc0" ) {
@@ -115,7 +115,7 @@ class Fallback {
                        $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" ) {
@@ -138,12 +138,12 @@ class Fallback {
                $total = 0;
 
                // Count ASCII bytes
-               for( $i = 0; $i < 0x80; $i++ ) {
+               for ( $i = 0; $i < 0x80; $i++ ) {
                        $total += $counts[$i];
                }
 
                // Count multibyte sequence heads
-               for( $i = 0xc0; $i < 0xff; $i++ ) {
+               for ( $i = 0xc0; $i < 0xff; $i++ ) {
                        $total += $counts[$i];
                }
                return $total;
@@ -163,7 +163,7 @@ class Fallback {
                $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;
@@ -184,7 +184,7 @@ class Fallback {
                $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 {
index caf2e57..635b04e 100644 (file)
@@ -245,7 +245,7 @@ abstract class ChannelFeed extends FeedItem {
                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' );
        }
 
        /**
@@ -306,13 +306,13 @@ class RSSFeed extends ChannelFeed {
        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>
-                       <?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 }?>
                </item>
 <?php
        }
@@ -392,15 +392,15 @@ class AtomFeed extends ChannelFeed {
                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 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
index 4842c38..6f3b42c 100644 (file)
@@ -59,7 +59,7 @@ class FeedUtils {
                        return false;
                }
 
-               if( !isset( $wgFeedClasses[$type] ) ) {
+               if ( !isset( $wgFeedClasses[$type] ) ) {
                        $wgOut->addWikiMsg( 'feed-invalid' );
                        return false;
                }
@@ -77,7 +77,7 @@ class FeedUtils {
                $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();
                }
@@ -121,12 +121,12 @@ class FeedUtils {
 
                // 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;
                }
 
-               if( $oldid ) {
+               if ( $oldid ) {
                        wfProfileIn( __METHOD__ . "-dodiff" );
 
                        #$diffText = $de->getDiff( wfMessage( 'revisionasof',
@@ -171,7 +171,7 @@ class FeedUtils {
                        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();
@@ -250,7 +250,7 @@ class FeedUtils {
                        '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 );
                }
index 9ce2f76..9fc70eb 100644 (file)
@@ -82,18 +82,18 @@ class FileDeleteForm {
                # 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 );
                }
 
-               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
-               if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $token, $this->oldimage ) ) {
+               if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $token, $this->oldimage ) ) {
                        $deleteReasonList = $wgRequest->getText( 'wpDeleteReasonList' );
                        $deleteReason = $wgRequest->getText( 'wpReason' );
 
@@ -109,11 +109,11 @@ class FileDeleteForm {
 
                        $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>' );
                        }
-                       if( $status->ok ) {
+                       if ( $status->ok ) {
                                $wgOut->setPageTitle( wfMessage( 'actioncomplete' ) );
                                $wgOut->addHTML( $this->prepareMessage( 'filedelete-success' ) );
                                // Return to the main page if we just deleted all versions of the
@@ -153,13 +153,13 @@ class FileDeleteForm {
                        $user = $wgUser;
                }
 
-               if( $oldimage ) {
+               if ( $oldimage ) {
                        $page = null;
                        $status = $file->deleteOld( $oldimage, $reason, $suppress );
-                       if( $status->ok ) {
+                       if ( $status->ok ) {
                                // 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;
                                }
@@ -187,7 +187,7 @@ class FileDeleteForm {
                                // 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__ );
@@ -213,7 +213,7 @@ class FileDeleteForm {
        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>" .
@@ -258,7 +258,7 @@ class FileDeleteForm {
                                "</td>
                        </tr>
                        {$suppress}";
-               if( $wgUser->isLoggedIn() ) {
+               if ( $wgUser->isLoggedIn() ) {
                        $form .= "
                        <tr>
                                <td></td>
@@ -314,7 +314,7 @@ class FileDeleteForm {
         */
        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() ),
@@ -375,7 +375,7 @@ class FileDeleteForm {
                $q = array();
                $q['action'] = 'delete';
 
-               if( $this->oldimage ) {
+               if ( $this->oldimage ) {
                        $q['oldimage'] = $this->oldimage;
                }
 
index 89ad955..ced45af 100644 (file)
@@ -121,7 +121,9 @@ class ForkController {
                        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 ) {
index 8477ed9..0a5cb68 100644 (file)
@@ -292,13 +292,17 @@ class FormOptions implements ArrayAccess {
 
                        switch( $type ) {
                                case self::BOOL:
-                                       $value = $r->getBool( $name, $default ); break;
+                                       $value = $r->getBool( $name, $default );
+                                       break;
                                case self::INT:
-                                       $value = $r->getInt( $name, $default ); break;
+                                       $value = $r->getInt( $name, $default );
+                                       break;
                                case self::STRING:
-                                       $value = $r->getText( $name, $default ); break;
+                                       $value = $r->getText( $name, $default );
+                                       break;
                                case self::INTNULL:
-                                       $value = $r->getIntOrNull( $name ); break;
+                                       $value = $r->getIntOrNull( $name );
+                                       break;
                                default:
                                        throw new MWException( 'Unsupported datatype' );
                        }
index bf3bff7..a54b807 100644 (file)
@@ -177,7 +177,7 @@ class GitInfo {
                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;
                                }
@@ -192,7 +192,7 @@ class GitInfo {
                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 );
@@ -238,7 +238,7 @@ class GitInfo {
        protected static function getViewers() {
                global $wgGitRepositoryViewers;
 
-               if( self::$viewers === false ) {
+               if ( self::$viewers === false ) {
                        self::$viewers = $wgGitRepositoryViewers;
                        wfRunHooks( 'GitViewers', array( &self::$viewers ) );
                }
index e204087..b7bdcfd 100644 (file)
@@ -277,7 +277,9 @@ class HTMLForm extends ContextSource {
         * 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
@@ -1978,10 +1980,11 @@ class HTMLSelectField extends HTMLFormField {
 
                $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] );
 
-               if ( in_array( $value, $validOptions ) )
+               if ( in_array( $value, $validOptions ) ) {
                        return true;
-               else
+               } else {
                        return $this->msg( 'htmlform-select-badoption' )->parse();
+               }
        }
 
        function getInputHTML( $value ) {
@@ -2530,7 +2533,9 @@ class HTMLHiddenField extends HTMLFormField {
                return $this->getTableRow( $value );
        }
 
-       public function getInputHTML( $value ) { return ''; }
+       public function getInputHTML( $value ) {
+               return '';
+       }
 }
 
 /**
index 976d36d..10a3c9c 100644 (file)
@@ -51,7 +51,7 @@ class HashRing {
                // 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;
index 1af733a..8d83751 100644 (file)
@@ -231,16 +231,16 @@ class HistoryBlobStub {
         * @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 ) );
-                       if( !$row ) {
+                       if ( !$row ) {
                                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] == '' ) {
@@ -249,11 +249,11 @@ class HistoryBlobStub {
                                $row->old_text = ExternalStore::fetchFromUrl( $url );
 
                        }
-                       if( !in_array( 'object', $flags ) ) {
+                       if ( !in_array( 'object', $flags ) ) {
                                return false;
                        }
 
-                       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 ) );
@@ -261,7 +261,7 @@ class HistoryBlobStub {
                                $obj = unserialize( $row->old_text );
                        }
 
-                       if( !is_object( $obj ) ) {
+                       if ( !is_object( $obj ) ) {
                                // Correct for old double-serialization bug.
                                $obj = unserialize( $obj );
                        }
@@ -318,7 +318,7 @@ class HistoryBlobCurStub {
        function getText() {
                $dbr = wfGetDB( DB_SLAVE );
                $row = $dbr->selectRow( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mCurId ) );
-               if( !$row ) {
+               if ( !$row ) {
                        return false;
                }
                return $row->cur_text;
index 740abf7..16fee41 100644 (file)
@@ -66,7 +66,7 @@ class Hooks {
         * @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();
                }
 
@@ -265,11 +265,11 @@ class Hooks {
                        /* 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";
-                               } 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] );
index 07bb42b..cb082a1 100644 (file)
@@ -207,7 +207,7 @@ class Html {
                        );
 
                        // Allow more input types in HTML5 mode
-                       if( $wgHtml5 ) {
+                       if ( $wgHtml5 ) {
                                $validTypes = array_merge( $validTypes, array(
                                        'datetime',
                                        'datetime-local',
@@ -340,7 +340,7 @@ class Html {
 
                foreach ( $attribs as $attrib => $value ) {
                        $lcattrib = strtolower( $attrib );
-                       if( is_array( $value ) ) {
+                       if ( is_array( $value ) ) {
                                $value = implode( ' ', $value );
                        } else {
                                $value = strval( $value );
@@ -962,7 +962,7 @@ class Html {
         */
        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";
index 489a83a..28daf91 100644 (file)
@@ -232,7 +232,7 @@ class MWHttpRequest {
                } else {
                        $this->timeout = $wgHTTPTimeout;
                }
-               if( isset( $options['userAgent'] ) ) {
+               if ( isset( $options['userAgent'] ) ) {
                        $this->setUserAgent( $options['userAgent'] );
                }
 
@@ -841,7 +841,7 @@ class PhpHttpRequest extends MWHttpRequest {
                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";
                        }
                }
index 72b9a52..0a8faa2 100644 (file)
@@ -33,7 +33,7 @@ define( 'RE_IP_BLOCK', RE_IP_ADD . '\/' . RE_IP_PREFIX );
 // 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})' .
@@ -392,11 +392,11 @@ class IP {
                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
                        );
                }
 
index 8f8022f..43cf7f6 100644 (file)
@@ -282,11 +282,11 @@ class ImageGallery {
                                $img = false;
                        }
 
-                       if( !$img ) {
+                       if ( !$img ) {
                                # 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(
@@ -297,7 +297,7 @@ class ImageGallery {
                                                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>';
@@ -334,8 +334,8 @@ class ImageGallery {
                        // $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();
index 5e51878..e687046 100644 (file)
@@ -206,7 +206,7 @@ class ImagePage extends Article {
                }
 
                // Add remote Filepage.css
-               if( !$this->repo->isLocal() ) {
+               if ( !$this->repo->isLocal() ) {
                        $css = $this->repo->getDescriptionStylesheetUrl();
                        if ( $css ) {
                                $out->addStyle( $css );
@@ -597,7 +597,7 @@ EOT
                $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 );
                }
 
@@ -753,7 +753,7 @@ EOT
 
                // Create links for every element
                $currentCount = 0;
-               foreach( $rows as $element ) {
+               foreach ( $rows as $element ) {
                        $currentCount++;
                        if ( $currentCount > $limit ) {
                                break;
index b9ec6e0..eeec5cd 100644 (file)
@@ -41,12 +41,12 @@ abstract class ImageQueryPage extends QueryPage {
         * @param int $offset Paging offset
         */
        protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
-               if( $num > 0 ) {
+               if ( $num > 0 ) {
                        $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 ) {
index 0e12e6d..8220287 100644 (file)
@@ -66,7 +66,7 @@ class WikiImporter {
        }
 
        private function debug( $data ) {
-               if( $this->mDebug ) {
+               if ( $this->mDebug ) {
                        wfDebug( "IMPORT: $data\n" );
                }
        }
@@ -188,10 +188,10 @@ class WikiImporter {
         * @return bool
         */
        public function setTargetNamespace( $namespace ) {
-               if( is_null( $namespace ) ) {
+               if ( is_null( $namespace ) ) {
                        // Don't override namespaces
                        $this->mTargetNamespace = null;
-               } elseif( $namespace >= 0 ) {
+               } elseif ( $namespace >= 0 ) {
                        // @todo FIXME: Check for validity
                        $this->mTargetNamespace = intval( $namespace );
                } else {
@@ -206,16 +206,16 @@ class WikiImporter {
         */
        public function setTargetRootPage( $rootpage ) {
                $status = Status::newGood();
-               if( is_null( $rootpage ) ) {
+               if ( is_null( $rootpage ) ) {
                        // 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 );
-                       if( !$title || $title->isExternal() ) {
+                       if ( !$title || $title->isExternal() ) {
                                $status->fatal( 'import-rootpage-invalid' );
                        } else {
-                               if( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
+                               if ( !MWNamespace::hasSubpages( $title->getNamespace() ) ) {
                                        global $wgContLang;
 
                                        $displayNSText = $title->getNamespace() == NS_MAIN
@@ -304,7 +304,7 @@ class WikiImporter {
         */
        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>" );
@@ -320,7 +320,7 @@ class WikiImporter {
         * @param $title Title
         */
        function pageCallback( $title ) {
-               if( isset( $this->mPageCallback ) ) {
+               if ( isset( $this->mPageCallback ) ) {
                        call_user_func( $this->mPageCallback, $title );
                }
        }
@@ -334,7 +334,7 @@ class WikiImporter {
         * @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 );
                }
@@ -376,11 +376,11 @@ class WikiImporter {
         * @access private
         */
        private function nodeContents() {
-               if( $this->reader->isEmptyElement ) {
+               if ( $this->reader->isEmptyElement ) {
                        return "";
                }
                $buffer = "";
-               while( $this->reader->read() ) {
+               while ( $this->reader->read() ) {
                        switch( $this->reader->nodeType ) {
                        case XmlReader::TEXT:
                        case XmlReader::SIGNIFICANT_WHITESPACE:
@@ -420,10 +420,10 @@ class WikiImporter {
                                "END_ELEMENT",
                                "END_ENTITY",
                                "XML_DECLARATION",
-                               );
+                       );
                        $lookup = array();
 
-                       foreach( $xmlReaderConstants as $name ) {
+                       foreach ( $xmlReaderConstants as $name ) {
                                $lookup[constant("XmlReader::$name")] = $name;
                        }
                }
@@ -666,7 +666,7 @@ class WikiImporter {
        private function processRevision( $pageInfo, $revisionInfo ) {
                $revision = new WikiRevision;
 
-               if( isset( $revisionInfo['id'] ) ) {
+               if ( isset( $revisionInfo['id'] ) ) {
                        $revision->setID( $revisionInfo['id'] );
                }
                if ( isset( $revisionInfo['text'] ) ) {
@@ -840,33 +840,33 @@ class WikiImporter {
                $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 {
-                       if( !is_null( $this->mTargetRootPage ) ) {
+                       if ( !is_null( $this->mTargetRootPage ) ) {
                                $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;
-               } elseif( $title->isExternal() ) {
+               } elseif ( $title->isExternal() ) {
                        $this->notice( 'import-error-interwiki', $title->getPrefixedText() );
                        return false;
-               } elseif( !$title->canExist() ) {
+               } elseif ( !$title->canExist() ) {
                        $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;
-               } 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;
@@ -997,11 +997,11 @@ class XMLReader2 extends XMLReader {
         * @return bool|string
         */
        function nodeContents() {
-               if( $this->isEmptyElement ) {
+               if ( $this->isEmptyElement ) {
                        return "";
                }
                $buffer = "";
-               while( $this->read() ) {
+               while ( $this->read() ) {
                        switch( $this->nodeType ) {
                        case XmlReader::TEXT:
                        case XmlReader::SIGNIFICANT_WHITESPACE:
@@ -1051,9 +1051,9 @@ class WikiRevision {
         * @throws MWException
         */
        function setTitle( $title ) {
-               if( is_object( $title ) ) {
+               if ( is_object( $title ) ) {
                        $this->title = $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." );
@@ -1369,7 +1369,7 @@ class WikiRevision {
 
                # Sneak a single revision into place
                $user = User::newFromName( $this->getUser() );
-               if( $user ) {
+               if ( $user ) {
                        $userId = intval( $user->getId() );
                        $userText = $user->getName();
                        $userObj = $user;
@@ -1384,7 +1384,7 @@ class WikiRevision {
                $linkCache->clear();
 
                $page = WikiPage::factory( $this->title );
-               if( !$page->exists() ) {
+               if ( !$page->exists() ) {
                        # must create the page...
                        $pageId = $page->insertOn( $dbw );
                        $created = true;
@@ -1400,7 +1400,7 @@ class WikiRevision {
                                        'rev_comment' => $this->getComment() ),
                                __METHOD__
                        );
-                       if( $prior ) {
+                       if ( $prior ) {
                                // @todo FIXME: This could fail slightly for multiple matches :P
                                wfDebug( __METHOD__ . ": skipping existing revision for [[" .
                                        $this->title->getPrefixedText() . "]], timestamp " . $this->timestamp . "\n" );
@@ -1440,7 +1440,7 @@ class WikiRevision {
        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;
@@ -1459,7 +1459,7 @@ class WikiRevision {
                        __METHOD__
                );
                // @todo FIXME: This could fail slightly for multiple matches :P
-               if( $prior ) {
+               if ( $prior ) {
                        wfDebug( __METHOD__ . ": skipping existing item for Log:{$this->type}/{$this->action}, timestamp " .
                                $this->timestamp . "\n" );
                        return;
@@ -1500,7 +1500,7 @@ class WikiRevision {
                                wfDebug( __METHOD__ . "File already exists; importing as $archiveName\n" );
                        }
                }
-               if( !$file ) {
+               if ( !$file ) {
                        wfDebug( __METHOD__ . ': Bad file for ' . $this->getTitle() . "\n" );
                        return false;
                }
@@ -1512,7 +1512,7 @@ class WikiRevision {
                        $source = $this->downloadSource();
                        $flags |= File::DELETE_SOURCE;
                }
-               if( !$source ) {
+               if ( !$source ) {
                        wfDebug( __METHOD__ . ": Could not fetch remote file.\n" );
                        return false;
                }
@@ -1551,13 +1551,13 @@ class WikiRevision {
         */
        function downloadSource() {
                global $wgEnableUploads;
-               if( !$wgEnableUploads ) {
+               if ( !$wgEnableUploads ) {
                        return false;
                }
 
                $tempo = tempnam( wfTempDir(), 'download' );
                $f = fopen( $tempo, 'wb' );
-               if( !$f ) {
+               if ( !$f ) {
                        wfDebug( "IMPORT: couldn't write to temp file $tempo\n" );
                        return false;
                }
@@ -1565,7 +1565,7 @@ class WikiRevision {
                // @todo FIXME!
                $src = $this->getSrc();
                $data = Http::get( $src );
-               if( !$data ) {
+               if ( !$data ) {
                        wfDebug( "IMPORT: couldn't fetch source $src\n" );
                        fclose( $f );
                        unlink( $tempo );
@@ -1601,7 +1601,7 @@ class ImportStringSource {
         * @return bool|string
         */
        function readChunk() {
-               if( $this->atEnd() ) {
+               if ( $this->atEnd() ) {
                        return false;
                }
                $this->mRead = true;
@@ -1640,7 +1640,7 @@ class ImportStreamSource {
                wfSuppressWarnings();
                $file = fopen( $filename, 'rt' );
                wfRestoreWarnings();
-               if( !$file ) {
+               if ( !$file ) {
                        return Status::newFatal( "importcantopen" );
                }
                return Status::newGood( new ImportStreamSource( $file ) );
@@ -1653,10 +1653,10 @@ class ImportStreamSource {
        static function newFromUpload( $fieldname = "xmlimport" ) {
                $upload =& $_FILES[$fieldname];
 
-               if( $upload === null || !$upload['name'] ) {
+               if ( $upload === null || !$upload['name'] ) {
                        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' );
@@ -1671,7 +1671,7 @@ class ImportStreamSource {
 
                }
                $fname = $upload['tmp_name'];
-               if( is_uploaded_file( $fname ) ) {
+               if ( is_uploaded_file( $fname ) ) {
                        return ImportStreamSource::newFromFile( $fname );
                } else {
                        return Status::newFatal( 'importnofile' );
@@ -1690,7 +1690,7 @@ class ImportStreamSource {
                # 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 );
@@ -1710,17 +1710,23 @@ class ImportStreamSource {
         * @return Status
         */
        public static function newFromInterwiki( $interwiki, $page, $history = false, $templates = false, $pageLinkDepth = 0 ) {
-               if( $page == '' ) {
+               if ( $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();
-                       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" );
index e8aee0b..6c582aa 100644 (file)
@@ -105,7 +105,7 @@ class Licenses extends HTMLFormField {
        protected function stackItem( &$list, $path, $item ) {
                $position =& $list;
                if ( $path ) {
-                       foreach( $path as $key ) {
+                       foreach ( $path as $key ) {
                                $position =& $position[$key];
                        }
                }
index 11b6559..d552c69 100644 (file)
@@ -152,11 +152,11 @@ class LinkFilter {
         * @return array filtered array
         */
        public static function keepOneWildcard( $arr ) {
-               if( !is_array( $arr ) ) {
+               if ( !is_array( $arr ) ) {
                        return $arr;
                }
 
-               foreach( $arr as $key => $value ) {
+               foreach ( $arr as $key => $value ) {
                        if ( $value instanceof LikeMatch ) {
                                return array_slice( $arr, 0, $key + 1 );
                        }
index 3e8a3c9..5e4675a 100644 (file)
@@ -199,7 +199,7 @@ class Linker {
                        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 );
@@ -644,7 +644,7 @@ class Linker {
                        # 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()
@@ -786,10 +786,18 @@ class Linker {
                $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
@@ -970,12 +978,13 @@ class Linker {
        protected static function getUploadUrl( $destFile, $query = '' ) {
                global $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
                $q = 'wpDestFile=' . $destFile->getPartialURL();
-               if ( $query != '' )
+               if ( $query != '' ) {
                        $q .= '&' . $query;
+               }
 
                if ( $wgUploadMissingFileUrl ) {
                        return wfAppendQuery( $wgUploadMissingFileUrl, $q );
-               } elseif( $wgUploadNavigationUrl ) {
+               } elseif ( $wgUploadNavigationUrl ) {
                        return wfAppendQuery( $wgUploadNavigationUrl, $q );
                } else {
                        $upload = SpecialPage::getTitleFor( 'Upload' );
@@ -1450,8 +1459,9 @@ class Linker {
                                $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 );
+                       }
                        list( $inside, $trail ) = self::splitTrail( $trail );
 
                        $linkText = $text;
@@ -1695,13 +1705,14 @@ class Linker {
                $toc = '';
                $lastLevel = 0;
                foreach ( $tree as $section ) {
-                       if ( $section['toclevel'] > $lastLevel )
+                       if ( $section['toclevel'] > $lastLevel ) {
                                $toc .= self::tocIndent();
-                       elseif ( $section['toclevel'] < $lastLevel )
+                       } elseif ( $section['toclevel'] < $lastLevel ) {
                                $toc .= self::tocUnindent(
                                        $lastLevel - $section['toclevel'] );
-                       else
+                       } else {
                                $toc .= self::tocLineEnd();
+                       }
 
                        $toc .= self::tocLine( $section['anchor'],
                                $section['line'], $section['number'],
@@ -1895,21 +1906,21 @@ class Linker {
                }
 
                $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;
                                }
                        }
                }
 
-               if( !$disableRollbackEditCount && is_int( $wgShowRollbackEditCount ) && $wgShowRollbackEditCount > 0 ) {
+               if ( !$disableRollbackEditCount && is_int( $wgShowRollbackEditCount ) && $wgShowRollbackEditCount > 0 ) {
                        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();
index f54487a..8c6d762 100644 (file)
@@ -354,7 +354,7 @@ class LinksUpdate extends SqlDataUpdate {
         */
        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;
@@ -376,7 +376,7 @@ class LinksUpdate extends SqlDataUpdate {
         */
        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(
@@ -398,7 +398,7 @@ class LinksUpdate extends SqlDataUpdate {
        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
@@ -415,8 +415,8 @@ class LinksUpdate extends SqlDataUpdate {
        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,
@@ -481,7 +481,7 @@ class LinksUpdate extends SqlDataUpdate {
        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,
@@ -517,7 +517,7 @@ class LinksUpdate extends SqlDataUpdate {
         */
        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(
index 240a6d3..3eaa8fe 100644 (file)
@@ -28,7 +28,7 @@ class MWFunction {
         * @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' ) )
@@ -36,7 +36,7 @@ class MWFunction {
                        }
                }
 
-               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()' );
                }
 
@@ -74,7 +74,7 @@ class MWFunction {
         * @return object
         */
        public static function newObj( $class, $args = array() ) {
-               if( !count( $args ) ) {
+               if ( !count( $args ) ) {
                        return new $class;
                }
 
index 86508ec..18b79c4 100644 (file)
@@ -327,9 +327,10 @@ class MagicWord {
                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, '/' );
+               }
                $this->mBaseRegex = implode( '|', $escSyn );
 
                $case = $this->mCaseSensitive ? '' : 'iu';
@@ -382,8 +383,9 @@ class MagicWord {
         * @return string
         */
        function getRegexCase() {
-               if ( $this->mRegex === '' )
+               if ( $this->mRegex === '' ) {
                        $this->initRegex();
+               }
 
                return $this->mCaseSensitive ? '' : 'iu';
        }
@@ -598,7 +600,7 @@ class MagicWord {
        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;
index 5719f83..531551d 100644 (file)
@@ -326,7 +326,7 @@ class Message {
                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;
@@ -344,7 +344,7 @@ class Message {
                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;
@@ -377,7 +377,7 @@ class Message {
                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 {
@@ -484,17 +484,17 @@ class Message {
                $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();
-                       if( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $string, $m ) ) {
+                       if ( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $string, $m ) ) {
                                $string = $m[1];
                        }
-               } elseif( $this->format === 'block-parse' ) {
+               } elseif ( $this->format === 'block-parse' ) {
                        $string = $this->parseText( $string );
-               } elseif( $this->format === 'text' ) {
+               } elseif ( $this->format === 'text' ) {
                        $string = $this->transformText( $string );
-               } elseif( $this->format === 'escaped' ) {
+               } elseif ( $this->format === 'escaped' ) {
                        $string = $this->transformText( $string );
                        $string = htmlspecialchars( $string, ENT_QUOTES, 'UTF-8', false );
                }
@@ -641,7 +641,7 @@ class Message {
         */
        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;
@@ -760,7 +760,7 @@ class RawMessage extends Message {
         */
        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;
index 96d00ae..cd77ef8 100644 (file)
@@ -42,7 +42,7 @@ abstract class RdfMetaData {
                $httpaccept = isset( $_SERVER['HTTP_ACCEPT'] ) ? $_SERVER['HTTP_ACCEPT'] : null;
                $rdftype = wfNegotiateType( wfAcceptToPrefs( $httpaccept ), wfAcceptToPrefs( self::RDF_TYPE_PREFS ) );
 
-               if( !$rdftype ) {
+               if ( !$rdftype ) {
                        throw new HttpError( 406, wfMessage( 'notacceptable' ) );
                }
 
@@ -70,7 +70,7 @@ abstract class RdfMetaData {
                $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 );
                }
 
@@ -89,13 +89,13 @@ abstract class RdfMetaData {
        }
 
        protected function pageOrString( $name, $page, $str ) {
-               if( $page instanceof Title ) {
+               if ( $page instanceof Title ) {
                        $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 );
@@ -116,11 +116,11 @@ abstract class RdfMetaData {
        }
 
        protected function person( $name, User $user ) {
-               if( $user->isAnon() ) {
+               if ( $user->isAnon() ) {
                        $this->element( $name, wfMessage( 'anonymous' )->numParams( 1 )->text() );
                } else {
                        $real = $user->getRealName();
-                       if( $real ) {
+                       if ( $real ) {
                                $this->element( $name, $real );
                        } else {
                                $userName = $user->getName();
@@ -140,12 +140,12 @@ abstract class RdfMetaData {
        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 );
-               } elseif( $wgRightsUrl ) {
+               } elseif ( $wgRightsUrl ) {
                        $this->url( 'rights', $wgRightsUrl );
-               } elseif( $wgRightsText ) {
+               } elseif ( $wgRightsText ) {
                        $this->element( 'rights', $wgRightsText );
                }
        }
@@ -153,11 +153,11 @@ abstract class RdfMetaData {
        protected function getTerms( $url ) {
                global $wgLicenseTerms;
 
-               if( $wgLicenseTerms ) {
+               if ( $wgLicenseTerms ) {
                        return $wgLicenseTerms;
                } else {
                        $known = $this->getKnownLicenses();
-                       if( isset( $known[$url] ) ) {
+                       if ( isset( $known[$url] ) ) {
                                return $known[$url];
                        } else {
                                return array();
@@ -173,7 +173,7 @@ abstract class RdfMetaData {
 
                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;
                                }
index 11fc574..24d803b 100644 (file)
@@ -39,7 +39,7 @@
  * 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
@@ -91,7 +91,7 @@ END_STRING
  * 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]
@@ -560,7 +560,7 @@ class MimeMagic {
 
                $mime = $this->doGuessMimeType( $file, $ext );
 
-               if( !$mime ) {
+               if ( !$mime ) {
                        wfDebug( __METHOD__ . ": internal type detection failed for $file (.$ext)...\n" );
                        $mime = $this->detectMimeType( $file, $ext );
                }
@@ -587,7 +587,7 @@ class MimeMagic {
                $f = fopen( $file, 'rt' );
                wfRestoreWarnings();
 
-               if( !$f ) {
+               if ( !$f ) {
                        return 'unknown/unknown';
                }
                $head = fread( $f, 1024 );
@@ -705,8 +705,8 @@ class MimeMagic {
                                $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 .= '?';
@@ -733,7 +733,7 @@ class MimeMagic {
                $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;
@@ -741,7 +741,7 @@ class MimeMagic {
 
                // 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';
                }
@@ -763,7 +763,7 @@ class MimeMagic {
         * @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" );
                }
@@ -935,7 +935,7 @@ class MimeMagic {
                        $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 );
@@ -968,12 +968,12 @@ class MimeMagic {
         * @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
-               if( !$mime ) {
+               if ( !$mime ) {
                        $mime = $this->guessMimeType( $path, false );
                }
 
@@ -983,22 +983,30 @@ class MimeMagic {
 
                        // 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
-                       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
-               if( $mime ) {
+               if ( $mime ) {
                        $type = $this->findMediaType( $mime );
                        if ( $type !== MEDIATYPE_UNKNOWN ) {
                                return $type;
@@ -1029,7 +1037,7 @@ class MimeMagic {
                        }
                }
 
-               if( !$type ) {
+               if ( !$type ) {
                        $type = MEDIATYPE_UNKNOWN;
                }
 
index 6b40c30..e7928cc 100644 (file)
@@ -64,10 +64,10 @@ function wfOutputHandler( $s ) {
  */
 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 );
-       } elseif( isset( $_SERVER['SCRIPT_NAME'] ) ) {
+       } elseif ( isset( $_SERVER['SCRIPT_NAME'] ) ) {
                // Probably IIS. QUERY_STRING appears separately.
                $path = $_SERVER['SCRIPT_NAME'];
        } else {
@@ -76,7 +76,7 @@ function wfRequestExtension() {
        }
 
        $period = strrpos( $path, '.' );
-       if( $period !== false ) {
+       if ( $period !== false ) {
                return strtolower( substr( $path, $period ) );
        }
        return '';
@@ -91,17 +91,17 @@ function wfRequestExtension() {
  * @return string
  */
 function wfGzipHandler( $s ) {
-       if( !function_exists( 'gzencode' ) ) {
+       if ( !function_exists( 'gzencode' ) ) {
                wfDebug( __FUNCTION__ . "() skipping compression (gzencode unavailable)\n" );
                return $s;
        }
-       if( headers_sent() ) {
+       if ( headers_sent() ) {
                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.
@@ -109,7 +109,7 @@ function wfGzipHandler( $s ) {
                return $s;
        }
 
-       if( wfClientAcceptsGzip() ) {
+       if ( wfClientAcceptsGzip() ) {
                wfDebug( __FUNCTION__ . "() is compressing output\n" );
                header( 'Content-Encoding: gzip' );
                $s = gzencode( $s, 6 );
index 8058c09..d70734c 100644 (file)
@@ -155,13 +155,13 @@ abstract class IndexPager extends ContextSource implements Pager {
                $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();
-               } elseif( is_array( $index ) ) {
+               } elseif ( is_array( $index ) ) {
                        # First element is the default
                        reset( $index );
                        list( $this->mOrderType, $this->mIndexField ) = each( $index );
@@ -175,7 +175,7 @@ abstract class IndexPager extends ContextSource implements Pager {
                        $this->mExtraSortFields = (array)$extraSort;
                }
 
-               if( !isset( $this->mDefaultDirection ) ) {
+               if ( !isset( $this->mDefaultDirection ) ) {
                        $dir = $this->getDefaultDirections();
                        $this->mDefaultDirection = is_array( $dir )
                                ? $dir[$this->mOrderType]
@@ -443,12 +443,12 @@ abstract class IndexPager extends ContextSource implements Pager {
                }
 
                $attrs = array();
-               if( in_array( $type, array( 'first', 'prev', 'next', 'last' ) ) ) {
+               if ( in_array( $type, array( 'first', 'prev', 'next', 'last' ) ) ) {
                        # HTML5 rel attributes
                        $attrs['rel'] = $type;
                }
 
-               if( $type ) {
+               if ( $type ) {
                        $attrs['class'] = "mw-{$type}link";
                }
 
@@ -685,7 +685,9 @@ abstract class IndexPager extends ContextSource implements Pager {
         *
         * @return Array
         */
-       protected function getExtraSortFields() { return array(); }
+       protected function getExtraSortFields() {
+               return array();
+       }
 
        /**
         * Return the default sorting direction: false for ascending, true for
@@ -706,7 +708,9 @@ abstract class IndexPager extends ContextSource implements Pager {
         *
         * @return Boolean
         */
-       protected function getDefaultDirections() { return false; }
+       protected function getDefaultDirections() {
+               return false;
+       }
 }
 
 /**
@@ -726,7 +730,7 @@ abstract class AlphabeticPager extends IndexPager {
                        return '';
                }
 
-               if( isset( $this->mNavigationBar ) ) {
+               if ( isset( $this->mNavigationBar ) ) {
                        return $this->mNavigationBar;
                }
 
@@ -749,7 +753,7 @@ abstract class AlphabeticPager extends IndexPager {
                        $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;
                }
@@ -757,14 +761,14 @@ abstract class AlphabeticPager extends IndexPager {
                $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();
                        }
 
-                       if( $order == $this->mOrderType ) {
+                       if ( $order == $this->mOrderType ) {
                                $extra .= $this->msg( $msgs[$order] )->escaped();
                        } else {
                                $extra .= $this->makeLink(
@@ -774,7 +778,7 @@ abstract class AlphabeticPager extends IndexPager {
                        }
                }
 
-               if( $extra !== '' ) {
+               if ( $extra !== '' ) {
                        $extra = ' ' . $this->msg( 'parentheses' )->rawParams( $extra )->escaped();
                        $this->mNavigationBar .= $extra;
                }
@@ -857,7 +861,7 @@ abstract class ReverseChronologicalPager extends IndexPager {
                        // 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' ) ) {
                                $year--;
                        }
                }
@@ -1125,7 +1129,7 @@ abstract class TablePager extends IndexPager {
                        '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 ) );
@@ -1169,7 +1173,7 @@ abstract class TablePager extends IndexPager {
                        # 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 {
index fc891bb..435e09e 100644 (file)
@@ -141,10 +141,10 @@ class PathRouter {
                }
 
                $pattern = (object)array(
-                       'path'    => $path,
-                       'params'  => $params,
+                       'path' => $path,
+                       'params' => $params,
                        'options' => $options,
-                       'key'     => $key,
+                       'key' => $key,
                );
                $pattern->weight = self::makeWeight( $pattern );
                $this->patterns[] = $pattern;
@@ -185,7 +185,7 @@ class PathRouter {
         */
        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 );
@@ -203,7 +203,7 @@ class PathRouter {
                $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;
index 79c3dd3..44c87f0 100644 (file)
@@ -378,7 +378,7 @@ class Preferences {
                                        ? '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';
                        }
@@ -1012,8 +1012,9 @@ class Preferences {
                $nsOptions = $wgContLang->getFormattedNamespaces();
                $nsOptions[0] = $context->msg( 'blanknamespace' )->text();
                foreach ( $nsOptions as $ns => $name ) {
-                       if ( $ns < 0 )
+                       if ( $ns < 0 ) {
                                unset( $nsOptions[$ns] );
+                       }
                }
 
                $defaultPreferences['searchnamespaces'] = array(
@@ -1351,7 +1352,9 @@ class Preferences {
                                        $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;
                                }
@@ -1406,7 +1409,7 @@ class Preferences {
                # 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 );
index e422a3b..3c464c5 100644 (file)
@@ -37,16 +37,16 @@ class PrefixSearch {
         */
        public static function titleSearch( $search, $limit, $namespaces = array() ) {
                $search = trim( $search );
-               if( $search == '' ) {
+               if ( $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() );
-                       if( $ns[0] == NS_MAIN ) {
+                       if ( $ns[0] == NS_MAIN ) {
                                $ns = $namespaces; // no explicit prefix, use default namespaces
                        }
                        return self::searchBackend(
@@ -55,7 +55,7 @@ class PrefixSearch {
 
                // 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(
@@ -73,16 +73,16 @@ class PrefixSearch {
         * @return Array of strings
         */
        protected static function searchBackend( $namespaces, $search, $limit ) {
-               if( count( $namespaces ) == 1 ) {
+               if ( count( $namespaces ) == 1 ) {
                        $ns = $namespaces[0];
-                       if( $ns == NS_MEDIA ) {
+                       if ( $ns == NS_MEDIA ) {
                                $namespaces = array( NS_FILE );
-                       } elseif( $ns == NS_SPECIAL ) {
+                       } elseif ( $ns == NS_SPECIAL ) {
                                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;
@@ -106,24 +106,24 @@ class PrefixSearch {
                // 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;
                }
 
-               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
                                continue;
                        }
 
-                       foreach( $aliases as $alias ) {
+                       foreach ( $aliases as $alias ) {
                                $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
@@ -133,7 +133,7 @@ class PrefixSearch {
                                wfRestoreWarnings();
                        }
 
-                       if( count( $srchres ) >= $limit ) {
+                       if ( count( $srchres ) >= $limit ) {
                                break;
                        }
                }
@@ -154,7 +154,7 @@ class PrefixSearch {
         */
        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
                }
 
@@ -196,14 +196,14 @@ class PrefixSearch {
 
                // 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 ) {
-                               if( is_numeric( $ns ) && array_key_exists( $ns, $validNamespaces ) ) {
+                               if ( is_numeric( $ns ) && array_key_exists( $ns, $validNamespaces ) ) {
                                        $valid[] = $ns;
                                }
                        }
-                       if( count( $valid ) > 0 ) {
+                       if ( count( $valid ) > 0 ) {
                                return $valid;
                        }
                }
index de5e9db..9439b90 100644 (file)
@@ -91,7 +91,7 @@ class ProtectionForm {
                $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.
 
@@ -132,15 +132,15 @@ class ProtectionForm {
                        }
 
                        $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
-                               if( $val == 'sysop' ) {
+                               if ( $val == 'sysop' ) {
                                        // 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' ) ) {
                                                continue;
+                                       }
+                               } elseif ( !$wgUser->isAllowed( $val ) ) {
+                                       continue;
                                }
                                $this->mRestrictions[$action] = $val;
                        }
@@ -188,8 +188,8 @@ class ProtectionForm {
                        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 ) );
                        }
@@ -282,10 +282,11 @@ class ProtectionForm {
                        $reasonstr = $this->mReason;
                }
                $expiry = array();
-               foreach( $this->mApplicableTypes as $action ) {
+               foreach ( $this->mApplicableTypes as $action ) {
                        $expiry[$action] = $this->getExpiry( $action );
-                       if( empty( $this->mRestrictions[$action] ) )
+                       if ( empty( $this->mRestrictions[$action] ) ) {
                                continue; // unprotected
+                       }
                        if ( !$expiry[$action] ) {
                                $this->show( array( 'protect_expiry_invalid' ) );
                                return false;
@@ -300,9 +301,10 @@ class ProtectionForm {
                #  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' ) ) {
                        $this->mCascade = false;
+               }
 
                $status = $this->mArticle->doUpdateRestrictions( $this->mRestrictions, $expiry, $this->mCascade, $reasonstr, $wgUser );
 
@@ -318,12 +320,12 @@ class ProtectionForm {
                 *             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 != '' ) {
+               if ( $errorMsg != '' ) {
                        $this->show( $errorMsg );
                        return false;
                }
@@ -356,7 +358,7 @@ class ProtectionForm {
                );
 
                $out = '';
-               if( !$this->disabled ) {
+               if ( !$this->disabled ) {
                        $wgOut->addModules( 'mediawiki.legacy.protect' );
                        $out .= Xml::openElement( 'form', array( 'method' => 'post',
                                'action' => $this->mTitle->getLocalURL( 'action=protect' ),
@@ -368,7 +370,7 @@ class ProtectionForm {
                        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>" .
@@ -412,7 +414,7 @@ class ProtectionForm {
                                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 {
@@ -423,7 +425,7 @@ class ProtectionForm {
                                $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'>
@@ -463,7 +465,7 @@ class ProtectionForm {
                $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>
@@ -481,7 +483,7 @@ class ProtectionForm {
                }
 
                # 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 .= "
@@ -506,7 +508,7 @@ class ProtectionForm {
                                        "</td>
                                </tr>";
                        # Disallow watching is user is not logged in
-                       if( $wgUser->isLoggedIn() ) {
+                       if ( $wgUser->isLoggedIn() ) {
                                $out .= "
                                <tr>
                                        <td></td>
@@ -562,15 +564,17 @@ class ProtectionForm {
                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
-                       if( $key == 'sysop' ) {
+                       if ( $key == 'sysop' ) {
                                //special case, rewrite sysop to protect and editprotected
-                               if( !$wgUser->isAllowedAny( 'protect', 'editprotected' ) && !$this->disabled )
+                               if ( !$wgUser->isAllowedAny( 'protect', 'editprotected' ) && !$this->disabled ) {
                                        continue;
+                               }
                        } else {
-                               if( !$wgUser->isAllowed( $key ) && !$this->disabled )
+                               if ( !$wgUser->isAllowed( $key ) && !$this->disabled ) {
                                        continue;
+                               }
                        }
                        $levels[] = $key;
                }
@@ -584,7 +588,7 @@ class ProtectionForm {
                        ) + $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' );
@@ -598,11 +602,11 @@ class ProtectionForm {
         * @return String
         */
        private function getOptionLabel( $permission ) {
-               if( $permission == '' ) {
+               if ( $permission == '' ) {
                        return wfMessage( 'protect-default' )->text();
                } else {
                        $msg = wfMessage( "protect-level-{$permission}" );
-                       if( $msg->exists() ) {
+                       if ( $msg->exists() ) {
                                return $msg->text();
                        }
                        return wfMessage( 'protect-fallback', $permission )->text();
@@ -613,7 +617,7 @@ class ProtectionForm {
                global $wgRestrictionLevels, $wgOut;
 
                $cascadeableLevels = array();
-               foreach( $wgRestrictionLevels as $key ) {
+               foreach ( $wgRestrictionLevels as $key ) {
                        if ( User::groupHasPermission( $key, 'protect' )
                                || $key == 'protect'
                        ) {
index a4a1ffb..a93639a 100644 (file)
@@ -69,8 +69,9 @@ $wgQueryPages = array(
 wfRunHooks( 'wgQueryPages', array( &$wgQueryPages ) );
 
 global $wgDisableCounters;
-if ( !$wgDisableCounters )
+if ( !$wgDisableCounters ) {
        $wgQueryPages[] = array( 'PopularPagesPage', 'Popularpages' );
+}
 
 /**
  * This is a class for doing query pages; since they're almost all the same,
index 3ea5da4..1a7d825 100644 (file)
@@ -106,7 +106,7 @@ class Revision implements IDBAccessObject {
        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
@@ -228,8 +228,8 @@ class Revision implements IDBAccessObject {
         * @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';
@@ -248,7 +248,7 @@ class Revision implements IDBAccessObject {
         * @return Revision or null
         */
        public static function loadFromTitle( $db, $title, $id = 0 ) {
-               if( $id ) {
+               if ( $id ) {
                        $matchId = intval( $id );
                } else {
                        $matchId = 'page_latest';
@@ -257,7 +257,7 @@ class Revision implements IDBAccessObject {
                        array(
                                "rev_id=$matchId",
                                'page_namespace' => $title->getNamespace(),
-                               'page_title'     => $title->getDBkey()
+                               'page_title' => $title->getDBkey()
                        )
                );
        }
@@ -275,9 +275,9 @@ class Revision implements IDBAccessObject {
        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_title'     => $title->getDBkey()
+                               'page_title' => $title->getDBkey()
                        )
                );
        }
@@ -312,9 +312,9 @@ class Revision implements IDBAccessObject {
         */
        private static function loadFromConds( $db, $conditions, $flags = 0 ) {
                $res = self::fetchFromConds( $db, $conditions, $flags );
-               if( $res ) {
+               if ( $res ) {
                        $row = $res->fetchObject();
-                       if( $row ) {
+                       if ( $row ) {
                                $ret = new Revision( $row );
                                return $ret;
                        }
@@ -337,7 +337,7 @@ class Revision implements IDBAccessObject {
                        array(
                                'rev_id=page_latest',
                                'page_namespace' => $title->getNamespace(),
-                               'page_title'     => $title->getDBkey()
+                               'page_title' => $title->getDBkey()
                        )
                );
        }
@@ -489,7 +489,7 @@ class Revision implements IDBAccessObject {
         * @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 );
@@ -517,7 +517,7 @@ class Revision implements IDBAccessObject {
                                $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 {
@@ -525,13 +525,13 @@ class Revision implements IDBAccessObject {
                                $this->mTitle = null;
                        }
 
-                       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 );
                        }
 
-                       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 );
@@ -539,7 +539,7 @@ class Revision implements IDBAccessObject {
 
                        // 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
@@ -554,7 +554,7 @@ class Revision implements IDBAccessObject {
                                $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
 
@@ -714,10 +714,10 @@ class Revision implements IDBAccessObject {
         * @return Title|null
         */
        public function getTitle() {
-               if( isset( $this->mTitle ) ) {
+               if ( isset( $this->mTitle ) ) {
                        return $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' ),
@@ -769,9 +769,9 @@ class Revision implements IDBAccessObject {
         * @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 ) ) {
                        return 0;
-               } 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;
@@ -801,9 +801,9 @@ class Revision implements IDBAccessObject {
         * @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 ) ) {
                        return '';
-               } 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();
@@ -841,9 +841,9 @@ class Revision implements IDBAccessObject {
         * @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 ) ) {
                        return '';
-               } 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;
@@ -870,17 +870,17 @@ class Revision implements IDBAccessObject {
         * @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
-                               '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_patrolled'  => 0
+                               'rc_patrolled' => 0
                        ),
                        __METHOD__
                );
@@ -943,9 +943,9 @@ class Revision implements IDBAccessObject {
         * @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 ) ) {
                        return null;
-               } 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();
@@ -996,9 +996,9 @@ class Revision implements IDBAccessObject {
         * @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:
-                       if( is_null( $this->mText ) ) {
+                       if ( is_null( $this->mText ) ) {
                                $this->mText = $this->loadText();
                        }
 
@@ -1097,9 +1097,9 @@ class Revision implements IDBAccessObject {
         * @return Revision|null
         */
        public function getPrevious() {
-               if( $this->getTitle() ) {
+               if ( $this->getTitle() ) {
                        $prev = $this->getTitle()->getPreviousRevisionID( $this->getId() );
-                       if( $prev ) {
+                       if ( $prev ) {
                                return self::newFromTitle( $this->getTitle(), $prev );
                        }
                }
@@ -1112,7 +1112,7 @@ class Revision implements IDBAccessObject {
         * @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 );
@@ -1129,11 +1129,11 @@ class Revision implements IDBAccessObject {
         * @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
-               if( !$this->mId ) {
+               if ( !$this->mId ) {
                        $prevId = $db->selectField( 'page', 'page_latest',
                                array( 'page_id' => $this->mPage ),
                                __METHOD__ );
@@ -1166,13 +1166,13 @@ class Revision implements IDBAccessObject {
                $textField = $prefix . 'text';
                $flagsField = $prefix . 'flags';
 
-               if( isset( $row->$flagsField ) ) {
+               if ( isset( $row->$flagsField ) ) {
                        $flags = explode( ',', $row->$flagsField );
                } else {
                        $flags = array();
                }
 
-               if( isset( $row->$textField ) ) {
+               if ( isset( $row->$textField ) ) {
                        $text = $row->$textField;
                } else {
                        wfProfileOut( __METHOD__ );
@@ -1183,7 +1183,7 @@ class Revision implements IDBAccessObject {
                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;
                        }
@@ -1192,14 +1192,14 @@ class Revision implements IDBAccessObject {
 
                // 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 );
                        }
 
-                       if( in_array( 'object', $flags ) ) {
+                       if ( in_array( 'object', $flags ) ) {
                                # Generic compressed storage
                                $obj = unserialize( $text );
                                if ( !is_object( $obj ) ) {
@@ -1211,7 +1211,7 @@ class Revision implements IDBAccessObject {
                        }
 
                        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?
@@ -1244,8 +1244,8 @@ class Revision implements IDBAccessObject {
                # 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 {
@@ -1274,33 +1274,35 @@ class Revision implements IDBAccessObject {
                $flags = self::compressRevisionText( $data );
 
                # Write to external storage if required
-               if( $wgDefaultExternalStore ) {
+               if ( $wgDefaultExternalStore ) {
                        // Store and get the URL
                        $data = ExternalStore::insertToDefault( $data );
-                       if( !$data ) {
+                       if ( !$data ) {
                                wfProfileOut( __METHOD__ );
                                throw new MWException( "Unable to store text to external storage" );
                        }
-                       if( $flags ) {
+                       if ( $flags ) {
                                $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'    => $old_id,
-                                       'old_text'  => $data,
+                                       'old_id' => $old_id,
+                                       'old_text' => $data,
                                        '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 )
@@ -1424,9 +1426,9 @@ class Revision implements IDBAccessObject {
                global $wgRevisionCacheExpiry, $wgMemc;
                $textId = $this->getTextId();
                $key = wfMemcKey( 'revisiontext', 'textid', $textId );
-               if( $wgRevisionCacheExpiry ) {
+               if ( $wgRevisionCacheExpiry ) {
                        $text = $wgMemc->get( $key );
-                       if( is_string( $text ) ) {
+                       if ( is_string( $text ) ) {
                                wfDebug( __METHOD__ . ": got id $textId from cache\n" );
                                wfProfileOut( __METHOD__ );
                                return $text;
@@ -1441,7 +1443,7 @@ class Revision implements IDBAccessObject {
                        $row = null;
                }
 
-               if( !$row ) {
+               if ( !$row ) {
                        // Text data is immutable; check slaves first.
                        $dbr = wfGetDB( DB_SLAVE );
                        $row = $dbr->selectRow( 'text',
@@ -1450,7 +1452,7 @@ class Revision implements IDBAccessObject {
                                __METHOD__ );
                }
 
-               if( !$row && wfGetLB()->getServerCount() > 1 ) {
+               if ( !$row && wfGetLB()->getServerCount() > 1 ) {
                        // Possible slave lag!
                        $dbw = wfGetDB( DB_MASTER );
                        $row = $dbw->selectRow( 'text',
@@ -1462,7 +1464,7 @@ class Revision implements IDBAccessObject {
                $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 );
                }
 
@@ -1507,7 +1509,7 @@ class Revision implements IDBAccessObject {
                                ),
                        __METHOD__ );
 
-               if( $current ) {
+               if ( $current ) {
                        $row = array(
                                'page'       => $pageId,
                                'comment'    => $summary,
@@ -1560,7 +1562,7 @@ class Revision implements IDBAccessObject {
         * @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 ) {
@@ -1613,7 +1615,7 @@ class Revision implements IDBAccessObject {
        static function countByPageId( $db, $id ) {
                $row = $db->selectRow( 'revision', array( 'revCount' => 'COUNT(*)' ),
                        array( 'rev_page' => $id ), __METHOD__ );
-               if( $row ) {
+               if ( $row ) {
                        return $row->revCount;
                }
                return 0;
@@ -1628,7 +1630,7 @@ class Revision implements IDBAccessObject {
         */
        static function countByTitle( $db, $title ) {
                $id = $title->getArticleID();
-               if( $id ) {
+               if ( $id ) {
                        return self::countByPageId( $db, $id );
                }
                return 0;
@@ -1650,7 +1652,9 @@ class Revision implements IDBAccessObject {
         * @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 );
index 666df96..1b865bb 100644 (file)
@@ -105,7 +105,7 @@ abstract class RevisionListBase extends ContextSource {
         * @return int
         */
        public function length() {
-               if( !$this->res ) {
+               if ( !$this->res ) {
                        return 0;
                } else {
                        return $this->res->numRows();
index 3acb740..b9b0591 100644 (file)
@@ -405,7 +405,7 @@ class Sanitizer {
                                'td', 'th', 'tr',
                        );
                        $htmllist = array( # Tags used by list
-                               'ul','ol',
+                               'ul', 'ol',
                        );
                        $listtags = array( # Tags that can appear in a list
                                'li',
@@ -446,7 +446,7 @@ class Sanitizer {
                                # $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;
@@ -537,7 +537,7 @@ class Sanitizer {
 
                                                # 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 ) );
                                                }
 
@@ -572,7 +572,7 @@ class Sanitizer {
                                @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 ) );
                                        }
 
@@ -623,8 +623,9 @@ class Sanitizer {
                                $spaceStart--;
                                $spaceLen++;
                        }
-                       while ( substr( $text, $spaceStart + $spaceLen, 1 ) === ' ' )
+                       while ( substr( $text, $spaceStart + $spaceLen, 1 ) === ' ' ) {
                                $spaceLen++;
+                       }
                        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.
@@ -714,7 +715,7 @@ class Sanitizer {
                $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 ) ) {
@@ -731,7 +732,7 @@ class Sanitizer {
 
                        # 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 );
                        }
 
@@ -800,9 +801,10 @@ class Sanitizer {
         */
        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 ) );
@@ -925,7 +927,7 @@ class Sanitizer {
         * @return String
         */
        static function fixTagAttributes( $text, $element ) {
-               if( trim( $text ) == '' ) {
+               if ( trim( $text ) == '' ) {
                        return '';
                }
 
@@ -933,7 +935,7 @@ class Sanitizer {
                $stripped = Sanitizer::validateTagAttributes( $decoded, $element );
 
                $attribs = array();
-               foreach( $stripped as $attribute => $value ) {
+               foreach ( $stripped as $attribute => $value ) {
                        $encAttribute = htmlspecialchars( $attribute );
                        $encValue = Sanitizer::safeEncodeAttribute( $value );
 
@@ -1111,13 +1113,13 @@ class Sanitizer {
         * @return Array
         */
        public static function decodeTagAttributes( $text ) {
-               if( trim( $text ) == '' ) {
+               if ( trim( $text ) == '' ) {
                        return array();
                }
 
                $attribs = array();
                $pairs = array();
-               if( !preg_match_all(
+               if ( !preg_match_all(
                        self::getAttribsRegex(),
                        $text,
                        $pairs,
@@ -1125,7 +1127,7 @@ class Sanitizer {
                        return $attribs;
                }
 
-               foreach( $pairs as $set ) {
+               foreach ( $pairs as $set ) {
                        $attribute = strtolower( $set[1] );
                        $value = Sanitizer::getTagAttributeCallback( $set );
 
@@ -1148,19 +1150,19 @@ class Sanitizer {
         * @return String
         */
        private static function getTagAttributeCallback( $set ) {
-               if( isset( $set[6] ) ) {
+               if ( isset( $set[6] ) ) {
                        # Illegal #XXXXXX color with no quotes.
                        return $set[6];
-               } elseif( isset( $set[5] ) ) {
+               } elseif ( isset( $set[5] ) ) {
                        # No quotes.
                        return $set[5];
-               } elseif( isset( $set[4] ) ) {
+               } elseif ( isset( $set[4] ) ) {
                        # Single-quoted
                        return $set[4];
-               } elseif( isset( $set[3] ) ) {
+               } elseif ( isset( $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];
@@ -1236,14 +1238,14 @@ class Sanitizer {
         */
        static function normalizeCharReferencesCallback( $matches ) {
                $ret = null;
-               if( $matches[1] != '' ) {
+               if ( $matches[1] != '' ) {
                        $ret = Sanitizer::normalizeEntity( $matches[1] );
-               } elseif( $matches[2] != '' ) {
+               } elseif ( $matches[2] != '' ) {
                        $ret = Sanitizer::decCharReference( $matches[2] );
-               } elseif( $matches[3] != '' ) {
+               } elseif ( $matches[3] != '' ) {
                        $ret = Sanitizer::hexCharReference( $matches[3] );
                }
-               if( is_null( $ret ) ) {
+               if ( is_null( $ret ) ) {
                        return htmlspecialchars( $matches[0] );
                } else {
                        return $ret;
@@ -1279,7 +1281,7 @@ class Sanitizer {
         */
        static function decCharReference( $codepoint ) {
                $point = intval( $codepoint );
-               if( Sanitizer::validateCodepoint( $point ) ) {
+               if ( Sanitizer::validateCodepoint( $point ) ) {
                        return sprintf( '&#%d;', $point );
                } else {
                        return null;
@@ -1292,7 +1294,7 @@ class Sanitizer {
         */
        static function hexCharReference( $codepoint ) {
                $point = hexdec( $codepoint );
-               if( Sanitizer::validateCodepoint( $point ) ) {
+               if ( Sanitizer::validateCodepoint( $point ) ) {
                        return sprintf( '&#x%x;', $point );
                } else {
                        return null;
@@ -1356,11 +1358,11 @@ class Sanitizer {
         * @return String
         */
        static function decodeCharReferencesCallback( $matches ) {
-               if( $matches[1] != '' ) {
+               if ( $matches[1] != '' ) {
                        return Sanitizer::decodeEntity( $matches[1] );
-               } elseif( $matches[2] != '' ) {
+               } elseif ( $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
@@ -1375,7 +1377,7 @@ class Sanitizer {
         * @private
         */
        static function decodeChar( $codepoint ) {
-               if( Sanitizer::validateCodepoint( $codepoint ) ) {
+               if ( Sanitizer::validateCodepoint( $codepoint ) ) {
                        return codepointToUtf8( $codepoint );
                } else {
                        return UTF8_REPLACEMENT;
@@ -1394,7 +1396,7 @@ class Sanitizer {
                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;";
@@ -1662,7 +1664,7 @@ class Sanitizer {
         */
        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";
@@ -1684,7 +1686,7 @@ class Sanitizer {
 
                # 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.
@@ -1754,7 +1756,7 @@ class Sanitizer {
         */
        public static function validateEmail( $addr ) {
                $result = null;
-               if( !wfRunHooks( 'isValidEmailAddr', array( $addr, &$result ) ) ) {
+               if ( !wfRunHooks( 'isValidEmailAddr', array( $addr, &$result ) ) ) {
                        return $result;
                }
 
index a5979ea..1ceee49 100644 (file)
@@ -44,8 +44,12 @@ if ( !isset( $wgVersion ) ) {
 }
 
 // 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 ) {
@@ -61,18 +65,38 @@ if ( !empty( $wgActionPaths ) && !isset( $wgActionPaths['view'] ) ) {
        $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'];
@@ -123,13 +147,13 @@ $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
  * Initialise $wgLockManagers to include basic FS version
  */
 $wgLockManagers[] = array(
-       'name'          => 'fsLockManager',
-       'class'         => 'FSLockManager',
+       'name' => 'fsLockManager',
+       'class' => 'FSLockManager',
        'lockDirectory' => "{$wgUploadDirectory}/lockdir",
 );
 $wgLockManagers[] = array(
-       'name'          => 'nullLockManager',
-       'class'         => 'NullLockManager',
+       'name' => 'nullLockManager',
+       'class' => 'NullLockManager',
 );
 
 /**
@@ -195,15 +219,15 @@ if ( $wgUseSharedUploads ) {
 }
 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',
-               'hashLevels'             => 2,
-               'fetchDescription'       => true,
+               'hashLevels' => 2,
+               'fetchDescription' => true,
                'descriptionCacheExpiry' => 43200,
-               'apiThumbCacheExpiry'    => 86400,
+               'apiThumbCacheExpiry' => 86400,
        );
 }
 /*
@@ -294,7 +318,7 @@ $wgCanonicalNamespaceNames = array(
 );
 
 /// @todo UGLY UGLY
-if( is_array( $wgExtraNamespaces ) ) {
+if ( is_array( $wgExtraNamespaces ) ) {
        $wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
 }
 
@@ -316,7 +340,7 @@ if ( !$wgEnotifMinorEdits ) {
 }
 
 # $wgDisabledActions is deprecated as of 1.18
-foreach( $wgDisabledActions as $action ) {
+foreach ( $wgDisabledActions as $action ) {
        $wgActions[$action] = false;
 }
 
@@ -426,7 +450,7 @@ if ( is_null( $wgLocaltimezone ) ) {
 }
 
 date_default_timezone_set( $wgLocaltimezone );
-if( is_null( $wgLocalTZoffset ) ) {
+if ( is_null( $wgLocalTZoffset ) ) {
        $wgLocalTZoffset = date( 'Z' ) / 60;
 }
 
@@ -532,10 +556,11 @@ foreach ( $wgExtensionFunctions as $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];
-               else
+               } else {
                        $profName = $fname . '-extensions-' . implode( '::', $func );
+               }
        } else {
                $profName = $fname . '-extensions-' . strval( $func );
        }
index 2d250df..63c3d34 100644 (file)
@@ -191,11 +191,11 @@ class SiteConfiguration {
         */
        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
-                               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"] ) ) {
@@ -203,16 +203,16 @@ class SiteConfiguration {
                                }
 
                                // Do tag settings
-                               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;
-                                       } 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"] );
@@ -220,8 +220,8 @@ class SiteConfiguration {
                                }
                                // 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 {
@@ -237,8 +237,8 @@ class SiteConfiguration {
                                }
 
                                // 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'];
@@ -248,7 +248,7 @@ class SiteConfiguration {
                        } while ( false );
                }
 
-               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 );
                        }
@@ -266,10 +266,10 @@ class SiteConfiguration {
         * @return string
         */
        function doReplace( $from, $to, $in ) {
-               if( is_string( $in ) ) {
+               if ( is_string( $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;
@@ -289,7 +289,7 @@ class SiteConfiguration {
        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 ) == '+' ) {
@@ -409,18 +409,18 @@ class SiteConfiguration {
                        'params' => array(),
                );
 
-               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
-               if( !is_array( $ret ) ) {
+               if ( !is_array( $ret ) ) {
                        return $default;
                }
 
-               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];
                        }
                }
@@ -443,7 +443,7 @@ class SiteConfiguration {
        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;
                }
 
@@ -452,10 +452,10 @@ class SiteConfiguration {
                $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'];
                }
-               if( !isset( $ret['params']['site'] ) && !is_null( $ret['suffix'] ) ) {
+               if ( !isset( $ret['params']['site'] ) && !is_null( $ret['suffix'] ) ) {
                        $ret['params']['site'] = $ret['suffix'];
                }
 
@@ -471,7 +471,7 @@ class SiteConfiguration {
        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'] );
                }
 
@@ -574,8 +574,8 @@ class SiteConfiguration {
         */
        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 ) ) {
index 4de7333..66bc9ee 100644 (file)
@@ -61,13 +61,13 @@ class SiteStats {
                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 ) );
                }
 
-               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
@@ -79,7 +79,7 @@ class SiteStats {
                        $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;
@@ -205,7 +205,7 @@ class SiteStats {
         */
        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',
@@ -226,7 +226,7 @@ class SiteStats {
         * @return bool
         */
        private static function isSane( $row ) {
-               if(
+               if (
                        $row === false
                        || $row->ss_total_pages < $row->ss_good_articles
                        || $row->ss_total_edits < $row->ss_total_pages
@@ -234,9 +234,9 @@ class SiteStats {
                        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 ) {
-                       if(
+                       if (
                                $row->{"ss_$member"} > 2000000000
                                || $row->{"ss_$member"} < 0
                        ) {
@@ -592,19 +592,19 @@ class SiteStatsInit {
                $counter->files();
 
                // Only do views if we don't want to not count them
-               if( $options['views'] ) {
+               if ( $options['views'] ) {
                        $counter->views();
                }
 
                // Update/refresh
-               if( $options['update'] ) {
+               if ( $options['update'] ) {
                        $counter->update();
                } else {
                        $counter->refresh();
                }
 
                // Count active users if need be
-               if( $options['activeUsers'] ) {
+               if ( $options['activeUsers'] ) {
                        SiteStatsUpdate::cacheUpdate( wfGetDB( DB_MASTER ) );
                }
        }
index 117e6e2..24561d8 100644 (file)
@@ -81,7 +81,7 @@ abstract class Skin extends ContextSource {
         */
        static function getSkinNameMessages() {
                $messages = array();
-               foreach( self::getSkinNames() as $skinKey => $skinName ) {
+               foreach ( self::getSkinNames() as $skinKey => $skinName ) {
                        $messages[] = "skinname-$skinKey";
                }
                return $messages;
@@ -291,7 +291,7 @@ abstract class Skin extends ContextSource {
                        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 );
@@ -668,7 +668,7 @@ abstract class Skin extends ContextSource {
 
                                                if ( $c > 1 ) {
                                                        $subpages .= $wgLang->getDirMarkEntity() . $this->msg( 'pipe-separator' )->escaped();
-                                               } else  {
+                                               } else {
                                                        $subpages .= '&lt; ';
                                                }
 
@@ -1015,7 +1015,7 @@ abstract class Skin extends ContextSource {
         */
        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 );
@@ -1392,17 +1392,17 @@ abstract class Skin extends ContextSource {
 
                $needParse = false;
 
-               if( $name === 'default' ) {
+               if ( $name === 'default' ) {
                        // special case
                        global $wgSiteNotice;
                        $notice = $wgSiteNotice;
-                       if( empty( $notice ) ) {
+                       if ( empty( $notice ) ) {
                                wfProfileOut( __METHOD__ );
                                return false;
                        }
                } else {
                        $msg = $this->msg( $name )->inContentLanguage();
-                       if( $msg->isDisabled() ) {
+                       if ( $msg->isDisabled() ) {
                                wfProfileOut( __METHOD__ );
                                return false;
                        }
@@ -1412,8 +1412,8 @@ abstract class Skin extends ContextSource {
                // 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;
index ca49024..9b9485e 100644 (file)
@@ -162,7 +162,7 @@ class LegacyTemplate extends BaseTemplate {
                $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];
                        }
@@ -707,8 +707,9 @@ class LegacyTemplate extends BaseTemplate {
                                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';
+                                       }
                                        break;
                                case NS_MEDIAWIKI:
                                        $text = wfMessage( 'mediawikipage' );
index d8a1aad..83ae4c6 100644 (file)
@@ -43,7 +43,7 @@ class MediaWiki_I18N {
                $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];
@@ -136,7 +136,7 @@ class SkinTemplate extends Skin {
                $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 );
@@ -272,9 +272,9 @@ class SkinTemplate extends Skin {
                }
 
                $tpl->set( 'catlinks', $this->getCategories() );
-               if( $out->isSyndicated() ) {
+               if ( $out->isSyndicated() ) {
                        $feeds = array();
-                       foreach( $out->getSyndicationLinks() as $format => $link ) {
+                       foreach ( $out->getSyndicationLinks() as $format => $link ) {
                                $feeds[$format] = array(
                                        'text' => $this->msg( "feed-$format" )->text(),
                                        'href' => $link
@@ -483,7 +483,7 @@ class SkinTemplate extends Skin {
                $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" );
                }
 
@@ -582,7 +582,7 @@ class SkinTemplate extends Skin {
                if ( strval( $page ) !== '' ) {
                        $a['returnto'] = $page;
                        $query = $request->getVal( 'returntoquery', $this->thisquery );
-                       if( $query != '' ) {
+                       if ( $query != '' ) {
                                $a['returntoquery'] = $query;
                        }
                }
@@ -592,7 +592,7 @@ class SkinTemplate extends Skin {
                }
 
                $returnto = wfArrayToCgi( $a );
-               if( $this->loggedin ) {
+               if ( $this->loggedin ) {
                        $personal_urls['userpage'] = array(
                                'text' => $this->username,
                                'href' => &$this->userpageUrlDetails['href'],
@@ -628,7 +628,7 @@ class SkinTemplate extends Skin {
                        # 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 )
@@ -676,7 +676,7 @@ class SkinTemplate extends Skin {
                                'class' => $wgSecureLogin ? 'link-https' : ''
                        );
 
-                       if( $this->showIPinHeader() ) {
+                       if ( $this->showIPinHeader() ) {
                                $href = &$this->userpageUrlDetails['href'];
                                $personal_urls['anonuserpage'] = array(
                                        'text' => $this->username,
@@ -719,10 +719,10 @@ class SkinTemplate extends Skin {
         */
        function tabAction( $title, $message, $selected, $query = '', $checkEdit = false ) {
                $classes = array();
-               if( $selected ) {
+               if ( $selected ) {
                        $classes[] = 'selected';
                }
-               if( $checkEdit && !$title->isKnown() ) {
+               if ( $checkEdit && !$title->isKnown() ) {
                        $classes[] = 'new';
                        if ( $query !== '' ) {
                                $query = 'action=edit&redlink=1&' . $query;
@@ -747,7 +747,7 @@ class SkinTemplate extends Skin {
                }
 
                $result = array();
-               if( !wfRunHooks( 'SkinTemplateTabAction', array( &$this,
+               if ( !wfRunHooks( 'SkinTemplateTabAction', array( &$this,
                                $title, $message, $selected, $checkEdit,
                                &$classes, &$query, &$text, &$result ) ) ) {
                        return $result;
@@ -762,7 +762,7 @@ class SkinTemplate extends Skin {
 
        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();
@@ -845,7 +845,7 @@ class SkinTemplate extends Skin {
                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();
@@ -1032,7 +1032,7 @@ class SkinTemplate extends Skin {
                                                $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
@@ -1165,9 +1165,9 @@ class SkinTemplate extends Skin {
 
                $nav_urls = array();
                $nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
-               if( $wgUploadNavigationUrl ) {
+               if ( $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;
@@ -1517,8 +1517,9 @@ abstract class BaseTemplate extends QuickTemplate {
                                $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];
+                               }
                        }
                        $personal_tools[$key] = $ptool;
                }
@@ -1557,39 +1558,39 @@ abstract class BaseTemplate extends QuickTemplate {
                        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(),
                                        'generated' => false,
-                                       'content'   => true,
+                                       'content' => true,
                                );
                                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',
                                        'generated' => false,
-                                       'content'   => $this->getToolbox(),
+                                       'content' => $this->getToolbox(),
                                );
                                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',
                                                'generated' => false,
-                                               'content'   => $this->data['language_urls'],
+                                               'content' => $this->data['language_urls'],
                                        );
                                }
                                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,
                                        'generated' => true,
-                                       'content'   => $content,
+                                       'content' => $content,
                                );
                                break;
                        }
@@ -1629,10 +1630,10 @@ abstract class BaseTemplate extends QuickTemplate {
                } else {
                        if ( $hookContents ) {
                                $boxes['TOOLBOXEND'] = array(
-                                       'id'        => 'p-toolboxend',
-                                       'header'    => $boxes['TOOLBOX']['header'],
+                                       'id' => 'p-toolboxend',
+                                       'header' => $boxes['TOOLBOX']['header'],
                                        'generated' => false,
-                                       'content'   => "<ul>{$hookContents}</ul>",
+                                       'content' => "<ul>{$hookContents}</ul>",
                                );
                                // HACK: Make sure that TOOLBOXEND is sorted next to TOOLBOX
                                $boxes2 = array();
@@ -1881,10 +1882,10 @@ abstract class BaseTemplate extends QuickTemplate {
 
                // 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();
-                       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;
                                }
                        }
index a53b901..675fb83 100644 (file)
@@ -199,7 +199,7 @@ class SpecialPageFactory {
                                self::$mList['ChangeEmail'] = 'SpecialChangeEmail';
                        }
 
-                       if( $wgEnableJavaScriptTest ) {
+                       if ( $wgEnableJavaScriptTest ) {
                                self::$mList['JavaScriptTest'] = 'SpecialJavaScriptTest';
                        }
 
index d8ea24a..64a3c60 100644 (file)
@@ -212,7 +212,7 @@ class Status {
         */
        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'],
@@ -294,9 +294,9 @@ class Status {
                $result = array();
                foreach ( $this->errors as $error ) {
                        if ( $error['type'] === $type ) {
-                               if( $error['message'] instanceof Message ) {
+                               if ( $error['message'] instanceof Message ) {
                                        $result[] = $error['message'];
-                               } elseif( $error['params'] ) {
+                               } elseif ( $error['params'] ) {
                                        $result[] = array_merge( array( $error['message'] ), $error['params'] );
                                } else {
                                        $result[] = array( $error['message'] );
index 21a392a..05b78e0 100644 (file)
@@ -233,7 +233,7 @@ class StringUtils {
 
                // 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 );
                }
 
@@ -440,7 +440,7 @@ class ReplacementArray {
         * @param $data array
         */
        function removeArray( $data ) {
-               foreach( $data as $from => $to ) {
+               foreach ( $data as $from => $to ) {
                        $this->removePair( $from );
                }
                $this->fss = false;
index 7dbfabf..caf78b0 100644 (file)
@@ -133,7 +133,7 @@ class MWTimestamp {
                        throw new TimestampException( __METHOD__ . " : Invalid timestamp - $ts" );
                }
 
-               if( !$strtime ) {
+               if ( !$strtime ) {
                        $da = array_map( 'intval', $da );
                        $da[0] = "%04d-%02d-%02dT%02d:%02d:%02d.00+00:00";
                        $strtime = call_user_func_array( "sprintf", $da );
@@ -145,7 +145,7 @@ class MWTimestamp {
                        throw new TimestampException( __METHOD__ . ' Invalid timestamp format.' );
                }
 
-               if( $final === false ) {
+               if ( $final === false ) {
                        throw new TimestampException( __METHOD__ . ' Invalid timestamp format.' );
                }
                $this->timestamp = $final;
@@ -164,14 +164,14 @@ class MWTimestamp {
         * @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.' );
                }
 
-               if( is_object( $this->timestamp  ) ) {
+               if ( is_object( $this->timestamp  ) ) {
                        // 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 {
@@ -203,9 +203,9 @@ class MWTimestamp {
                $timeago = ($now - $then) * 1000;
                $message = false;
 
-               foreach( self::$units as $unit => $factor ) {
+               foreach ( self::$units as $unit => $factor ) {
                        $next = $timeago / $factor;
-                       if( $next < 1 ) {
+                       if ( $next < 1 ) {
                                break;
                        } else {
                                $timeago = $next;
@@ -213,7 +213,7 @@ class MWTimestamp {
                        }
                }
 
-               if( $message ) {
+               if ( $message ) {
                        $initial = call_user_func_array( 'wfMessage', $message );
                        return wfMessage( 'ago', $initial->parse() );
                } else {
index eda8bc9..03e894e 100644 (file)
@@ -286,7 +286,7 @@ class User {
                                $this->loadFromId();
                                break;
                        case 'session':
-                               if( !$this->loadFromSession() ) {
+                               if ( !$this->loadFromSession() ) {
                                        // Loading from session failed. Load defaults.
                                        $this->loadDefaults();
                                }
@@ -426,7 +426,7 @@ class User {
                        'user_email_token' => md5( $code ),
                        'user_email_token_expires > ' . $dbr->addQuotes( $dbr->timestamp() ),
                        ) );
-               if( $id !== false ) {
+               if ( $id !== false ) {
                        return User::newFromId( $id );
                } else {
                        return null;
@@ -495,7 +495,7 @@ class User {
         */
        public static function idFromName( $name ) {
                $nt = Title::makeTitleSafe( NS_USER, $name );
-               if( is_null( $nt ) ) {
+               if ( is_null( $nt ) ) {
                        # Illegal name
                        return null;
                }
@@ -576,7 +576,7 @@ class User {
                // 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 )
+               if ( is_null( $parsed )
                        || $parsed->getNamespace()
                        || strcmp( $name, $parsed->getPrefixedText() ) ) {
                        wfDebugLog( 'username', __METHOD__ .
@@ -594,7 +594,7 @@ class User {
                        '\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;
@@ -657,15 +657,15 @@ class User {
                // 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
-               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;
@@ -702,11 +702,12 @@ class User {
 
                $result = false; //init $result to false for the internal checks
 
-               if( !wfRunHooks( 'isValidPassword', array( $password, &$result, $this ) ) )
+               if ( !wfRunHooks( 'isValidPassword', array( $password, &$result, $this ) ) ) {
                        return $result;
+               }
 
                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';
@@ -719,7 +720,7 @@ class User {
                                //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
@@ -779,14 +780,15 @@ class User {
                # 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 ) {
                        return false;
+               }
 
                # Clean up name according to title rules
                $t = ( $validate === 'valid' ) ?
                        Title::newFromText( $name ) : Title::makeTitle( NS_USER, $name );
                # Check for invalid titles
-               if( is_null( $t ) ) {
+               if ( is_null( $t ) ) {
                        return false;
                }
 
@@ -870,7 +872,7 @@ class User {
                $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
@@ -934,7 +936,7 @@ class User {
 
                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;
@@ -962,7 +964,7 @@ class User {
                }
 
                global $wgBlockDisablesLogin;
-               if( $wgBlockDisablesLogin && $proposedUser->isBlocked() ) {
+               if ( $wgBlockDisablesLogin && $proposedUser->isBlocked() ) {
                        # User blocked and we've disabled blocked user logins
                        return false;
                }
@@ -1004,7 +1006,7 @@ class User {
                $this->mId = intval( $this->mId );
 
                /** Anonymous user */
-               if( !$this->mId ) {
+               if ( !$this->mId ) {
                        $this->loadDefaults();
                        return false;
                }
@@ -1228,7 +1230,7 @@ class User {
                # 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;
@@ -1246,7 +1248,7 @@ class User {
         */
        public static function getDefaultOption( $opt ) {
                $defOpts = self::getDefaultOptions();
-               if( isset( $defOpts[$opt] ) ) {
+               if ( isset( $defOpts[$opt] ) ) {
                        return $defOpts[$opt];
                } else {
                        return null;
@@ -1356,11 +1358,13 @@ class User {
                global $wgEnableSorbs, $wgEnableDnsBlacklist,
                        $wgSorbsUrl, $wgDnsBlacklistUrls, $wgProxyWhitelist;
 
-               if ( !$wgEnableDnsBlacklist && !$wgEnableSorbs )
+               if ( !$wgEnableDnsBlacklist && !$wgEnableSorbs ) {
                        return false;
+               }
 
-               if ( $checkWhitelist && in_array( $ip, $wgProxyWhitelist ) )
+               if ( $checkWhitelist && in_array( $ip, $wgProxyWhitelist ) ) {
                        return false;
+               }
 
                $urls = array_merge( $wgDnsBlacklistUrls, (array)$wgSorbsUrl );
                return $this->inDnsBlacklist( $ip, $urls );
@@ -1378,15 +1382,15 @@ class User {
 
                $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 ) ) );
 
-                       foreach( (array)$bases as $base ) {
+                       foreach ( (array)$bases as $base ) {
                                # 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 {
@@ -1399,7 +1403,7 @@ class User {
                                # Send query
                                $ipList = gethostbynamel( $host );
 
-                               if( $ipList ) {
+                               if ( $ipList ) {
                                        wfDebugLog( 'dnsblacklist', "Hostname $host is {$ipList[0]}, it's a proxy says $base!\n" );
                                        $found = true;
                                        break;
@@ -1454,7 +1458,7 @@ class User {
         */
        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.
@@ -1476,18 +1480,19 @@ class User {
        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;
-               if( !isset( $wgRateLimits[$action] ) ) {
+               if ( !isset( $wgRateLimits[$action] ) ) {
                        return false;
                }
 
                # Some groups shouldn't trigger the ping limiter, ever
-               if( !$this->isPingLimitable() )
+               if ( !$this->isPingLimitable() ) {
                        return false;
+               }
 
                global $wgMemc, $wgRateLimitLog;
                wfProfileIn( __METHOD__ );
@@ -1498,22 +1503,22 @@ class User {
                $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'];
                }
 
-               if( isset( $limits['user'] ) && $id != 0 ) {
+               if ( isset( $limits['user'] ) && $id != 0 ) {
                        $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'];
                        }
-                       if( isset( $limits['ip'] ) ) {
+                       if ( isset( $limits['ip'] ) ) {
                                $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'];
                        }
@@ -1534,15 +1539,15 @@ class User {
                }
 
                $triggered = false;
-               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?
-                       if( $count ) {
-                               if( $count >= $max ) {
+                       if ( $count ) {
+                               if ( $count >= $max ) {
                                        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();
@@ -1645,13 +1650,13 @@ class User {
         * @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?
-               if( IP::isIPAddress( $this->getName() ) ) {
+               if ( IP::isIPAddress( $this->getName() ) ) {
                        $ip = $this->getName();
-               } elseif( !$ip ) {
+               } elseif ( !$ip ) {
                        $ip = $this->getRequest()->getIP();
                }
                $blocked = false;
@@ -1666,7 +1671,7 @@ class User {
         * @return Bool True if locked, false otherwise
         */
        public function isLocked() {
-               if( $this->mLocked !== null ) {
+               if ( $this->mLocked !== null ) {
                        return $this->mLocked;
                }
                global $wgAuth;
@@ -1681,11 +1686,11 @@ class User {
         * @return Bool True if hidden, false otherwise
         */
        public function isHidden() {
-               if( $this->mHideName !== null ) {
+               if ( $this->mHideName !== null ) {
                        return $this->mHideName;
                }
                $this->getBlockedStatus();
-               if( !$this->mHideName ) {
+               if ( !$this->mHideName ) {
                        global $wgAuth;
                        $authUser = $wgAuth->getUserInstance( $this );
                        $this->mHideName = (bool)$authUser->isHidden();
@@ -1698,11 +1703,10 @@ class User {
         * @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;
-               } elseif( !$this->isItemLoaded( 'id' ) ) {
+               } elseif ( !$this->isItemLoaded( 'id' ) ) {
                        // Don't load if this was initialized from an ID
                        $this->load();
                }
@@ -1770,21 +1774,21 @@ class User {
                $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.
-                       if( !$this->mId ) {
+                       if ( !$this->mId ) {
                                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 );
-                                       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
@@ -1807,9 +1811,9 @@ class User {
         */
        public function getNewMessageLinks() {
                $talks = array();
-               if( !wfRunHooks( 'UserRetrieveNewTalks', array( &$this, &$talks ) ) ) {
+               if ( !wfRunHooks( 'UserRetrieveNewTalks', array( &$this, &$talks ) ) ) {
                        return $talks;
-               } elseif( !$this->getNewtalk() ) {
+               } elseif ( !$this->getNewtalk() ) {
                        return array();
                }
                $utp = $this->getTalkPage();
@@ -1895,14 +1899,14 @@ class User {
         * @param $curRev Revision new, as yet unseen revision of the user talk page. Ignored if null or !$val.
         */
        public function setNewtalk( $val, $curRev = null ) {
-               if( wfReadOnly() ) {
+               if ( wfReadOnly() ) {
                        return;
                }
 
                $this->load();
                $this->mNewtalk = $val;
 
-               if( $this->isAnon() ) {
+               if ( $this->isAnon() ) {
                        $field = 'user_ip';
                        $id = $this->getName();
                } else {
@@ -1911,13 +1915,13 @@ class User {
                }
                global $wgMemc;
 
-               if( $val ) {
+               if ( $val ) {
                        $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 );
@@ -1947,7 +1951,7 @@ class User {
         */
        private function clearSharedCache() {
                $this->load();
-               if( $this->mId ) {
+               if ( $this->mId ) {
                        global $wgMemc;
                        $wgMemc->delete( wfMemcKey( 'user', 'id', $this->mId ) );
                }
@@ -2025,12 +2029,12 @@ class User {
        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() );
                        }
 
-                       if( !$this->isValidPassword( $str ) ) {
+                       if ( !$this->isValidPassword( $str ) ) {
                                global $wgMinimalPasswordLength;
                                $valid = $this->getPasswordValidity( $str );
                                if ( is_array( $valid ) ) {
@@ -2044,7 +2048,7 @@ class User {
                        }
                }
 
-               if( !$wgAuth->setPassword( $this, $str ) ) {
+               if ( !$wgAuth->setPassword( $this, $str ) ) {
                        throw new PasswordError( wfMessage( 'externaldberror' )->text() );
                }
 
@@ -2064,7 +2068,7 @@ class User {
                $this->load();
                $this->setToken();
 
-               if( $str === null ) {
+               if ( $str === null ) {
                        // Save an invalid hash...
                        $this->mPassword = '';
                } else {
@@ -2157,7 +2161,7 @@ class User {
         */
        public function setEmail( $str ) {
                $this->load();
-               if( $str == $this->mEmail ) {
+               if ( $str == $this->mEmail ) {
                        return;
                }
                $this->mEmail = $str;
@@ -2241,7 +2245,7 @@ class User {
                # 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 );
                }
 
@@ -2267,9 +2271,9 @@ class User {
                # 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 );
-                       if( $default !== null ) {
+                       if ( $default !== null ) {
                                $options[$pref] = $default;
                        }
                }
@@ -2298,7 +2302,7 @@ class User {
         */
        public function getIntOption( $oname, $defaultOverride = 0 ) {
                $val = $this->getOption( $oname );
-               if( $val == '' ) {
+               if ( $val == '' ) {
                        $val = $defaultOverride;
                }
                return intval( $val );
@@ -2314,7 +2318,7 @@ class User {
                $this->loadOptions();
 
                // Explicitly NULL values should refer to defaults
-               if( is_null( $val ) ) {
+               if ( is_null( $val ) ) {
                        $val = self::getDefaultOption( $oname );
                }
 
@@ -2410,9 +2414,9 @@ class User {
                foreach ( $options as $key => $value ) {
                        if ( isset( $prefs[$key] ) ) {
                                $mapping[$key] = 'registered';
-                       } elseif( isset( $multiselectOptions[$key] ) ) {
+                       } elseif ( isset( $multiselectOptions[$key] ) ) {
                                $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';
@@ -2598,14 +2602,14 @@ class User {
         * @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();
-                       foreach( $res as $row ) {
+                       foreach ( $res as $row ) {
                                $this->mFormerGroups[] = $row->ufg_group;
                        }
                }
@@ -2632,7 +2636,7 @@ class User {
                                __METHOD__
                        );
 
-                       if( $count === null ) {
+                       if ( $count === null ) {
                                // it has not been initialized. do so.
                                $count = $this->initEditCount();
                        }
@@ -2648,9 +2652,9 @@ class User {
         * @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 );
-                       if( $this->getId() ) {
+                       if ( $this->getId() ) {
                                $dbw->insert( 'user_groups',
                                        array(
                                                'ug_user' => $this->getID(),
@@ -2674,7 +2678,7 @@ class User {
         */
        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(
@@ -2723,8 +2727,8 @@ class User {
         */
        public function isAllowedAny( /*...*/ ) {
                $permissions = func_get_args();
-               foreach( $permissions as $permission ) {
-                       if( $this->isAllowed( $permission ) ) {
+               foreach ( $permissions as $permission ) {
+                       if ( $this->isAllowed( $permission ) ) {
                                return true;
                        }
                }
@@ -2738,8 +2742,8 @@ class User {
         */
        public function isAllowedAll( /*...*/ ) {
                $permissions = func_get_args();
-               foreach( $permissions as $permission ) {
-                       if( !$this->isAllowed( $permission ) ) {
+               foreach ( $permissions as $permission ) {
+                       if ( !$this->isAllowed( $permission ) ) {
                                return false;
                        }
                }
@@ -2756,10 +2760,11 @@ class User {
                        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;
-                       if( !$wgUseRCPatrol && !$wgUseNPPatrol )
+                       if ( !$wgUseRCPatrol && !$wgUseNPPatrol ) {
                                return false;
+                       }
                }
                # Use strict parameter to avoid matching numeric 0 accidentally inserted
                # by misconfiguration: 0 == 'foo'
@@ -2867,22 +2872,23 @@ class User {
                global $wgUseEnotif, $wgShowUpdatedMarker;
 
                # Do nothing if the database is locked to writes
-               if( wfReadOnly() ) {
+               if ( wfReadOnly() ) {
                        return;
                }
 
-               if( $title->getNamespace() == NS_USER_TALK &&
+               if ( $title->getNamespace() == NS_USER_TALK &&
                        $title->getText() == $this->getName() ) {
-                       if( !wfRunHooks( 'UserClearNewTalkNotification', array( &$this ) ) )
+                       if ( !wfRunHooks( 'UserClearNewTalkNotification', array( &$this ) ) ) {
                                return;
+                       }
                        $this->setNewtalk( false );
                }
 
-               if( !$wgUseEnotif && !$wgShowUpdatedMarker ) {
+               if ( !$wgUseEnotif && !$wgShowUpdatedMarker ) {
                        return;
                }
 
-               if( $this->isAnon() ) {
+               if ( $this->isAnon() ) {
                        // Nothing else to do...
                        return;
                }
@@ -2917,7 +2923,7 @@ class User {
                        return;
                }
                $id = $this->getId();
-               if( $id != 0 ) {
+               if ( $id != 0 ) {
                        $dbw = wfGetDB( DB_MASTER );
                        $dbw->update( 'watchlist',
                                array( /* SET */
@@ -2939,8 +2945,9 @@ class User {
         */
        private function decodeOptions( $str ) {
                wfDeprecated( __METHOD__, '1.19' );
-               if( !$str )
+               if ( !$str ) {
                        return;
+               }
 
                $this->mOptionsLoaded = true;
                $this->mOptionOverrides = array();
@@ -3048,7 +3055,7 @@ class User {
         * Log this user out.
         */
        public function logout() {
-               if( wfRunHooks( 'UserLogout', array( &$this ) ) ) {
+               if ( wfRunHooks( 'UserLogout', array( &$this ) ) ) {
                        $this->doLogout();
                }
        }
@@ -3078,8 +3085,12 @@ class User {
                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() ) {
@@ -3118,7 +3129,9 @@ class User {
         */
        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__ );
@@ -3308,7 +3321,7 @@ class User {
                wfDeprecated( __METHOD__, '1.17' );
 
                global $wgRenderHashAppend, $wgLang, $wgContLang;
-               if( $this->mHash ) {
+               if ( $this->mHash ) {
                        return $this->mHash;
                }
 
@@ -3346,7 +3359,7 @@ class User {
         */
        public function isBlockedFromCreateAccount() {
                $this->getBlockedStatus();
-               if( $this->mBlock && $this->mBlock->prevents( 'createaccount' ) ) {
+               if ( $this->mBlock && $this->mBlock->prevents( 'createaccount' ) ) {
                        return $this->mBlock;
                }
 
@@ -3420,16 +3433,16 @@ class User {
                // 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 ) ) {
                        return false;
                }
 
-               if( $wgAuth->authenticate( $this->getName(), $password ) ) {
+               if ( $wgAuth->authenticate( $this->getName(), $password ) ) {
                        return true;
-               } elseif( $wgAuth->strict() ) {
+               } elseif ( $wgAuth->strict() ) {
                        /* 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;
                }
@@ -3460,7 +3473,7 @@ class User {
                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;
                        }
@@ -3509,7 +3522,7 @@ class User {
                                $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;
@@ -3604,7 +3617,7 @@ class User {
         * @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 {
@@ -3726,7 +3739,7 @@ class User {
         */
        public function canSendEmail() {
                global $wgEnableEmail, $wgEnableUserEmail;
-               if( !$wgEnableEmail || !$wgEnableUserEmail || !$this->isAllowed( 'sendemail' ) ) {
+               if ( !$wgEnableEmail || !$wgEnableUserEmail || !$this->isAllowed( 'sendemail' ) ) {
                        return false;
                }
                $canSend = $this->isEmailConfirmed();
@@ -3757,14 +3770,14 @@ class User {
                global $wgEmailAuthentication;
                $this->load();
                $confirmed = true;
-               if( wfRunHooks( 'EmailConfirmed', array( &$this, &$confirmed ) ) ) {
-                       if( $this->isAnon() ) {
+               if ( wfRunHooks( 'EmailConfirmed', array( &$this, &$confirmed ) ) ) {
+                       if ( $this->isAnon() ) {
                                return false;
                        }
-                       if( !Sanitizer::validateEmail( $this->mEmail ) ) {
+                       if ( !Sanitizer::validateEmail( $this->mEmail ) ) {
                                return false;
                        }
-                       if( $wgEmailAuthentication && !$this->getEmailAuthenticationTimestamp() ) {
+                       if ( $wgEmailAuthentication && !$this->getEmailAuthenticationTimestamp() ) {
                                return false;
                        }
                        return true;
@@ -3807,7 +3820,7 @@ class User {
         *     non-existent/anonymous user accounts.
         */
        public function getFirstEditTimestamp() {
-               if( $this->getId() == 0 ) {
+               if ( $this->getId() == 0 ) {
                        return false; // anons
                }
                $dbr = wfGetDB( DB_SLAVE );
@@ -3816,7 +3829,7 @@ class User {
                        __METHOD__,
                        array( 'ORDER BY' => 'rev_timestamp ASC' )
                );
-               if( !$time ) {
+               if ( !$time ) {
                        return false; // no edits
                }
                return wfTimestamp( TS_MW, $time );
@@ -3832,16 +3845,16 @@ class User {
                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
-               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] ) ) );
                        }
@@ -3953,10 +3966,11 @@ class User {
         */
        public static function getGroupPage( $group ) {
                $msg = wfMessage( 'grouppage-' . $group )->inContentLanguage();
-               if( $msg->exists() ) {
+               if ( $msg->exists() ) {
                        $title = Title::newFromText( $msg->text() );
-                       if( is_object( $title ) )
+                       if ( is_object( $title ) ) {
                                return $title;
+                       }
                }
                return false;
        }
@@ -3970,11 +3984,11 @@ class User {
         * @return String HTML link to the group
         */
        public static function makeGroupLinkHTML( $group, $text = '' ) {
-               if( $text == '' ) {
+               if ( $text == '' ) {
                        $text = self::getGroupName( $group );
                }
                $title = self::getGroupPage( $group );
-               if( $title ) {
+               if ( $title ) {
                        return Linker::link( $title, htmlspecialchars( $text ) );
                } else {
                        return $text;
@@ -3990,11 +4004,11 @@ class User {
         * @return String Wikilink to the group
         */
        public static function makeGroupLinkWiki( $group, $text = '' ) {
-               if( $text == '' ) {
+               if ( $text == '' ) {
                        $text = self::getGroupName( $group );
                }
                $title = self::getGroupPage( $group );
-               if( $title ) {
+               if ( $title ) {
                        $page = $title->getPrefixedText();
                        return "[[$page|$text]]";
                } else {
@@ -4015,53 +4029,53 @@ class User {
                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
-               } elseif( $wgAddGroups[$group] === true ) {
+               } elseif ( $wgAddGroups[$group] === true ) {
                        // 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
-               if( empty( $wgRemoveGroups[$group] ) ) {
-               } elseif( $wgRemoveGroups[$group] === true ) {
+               if ( empty( $wgRemoveGroups[$group] ) ) {
+               } elseif ( $wgRemoveGroups[$group] === true ) {
                        $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
-               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;
                                }
                        }
                }
 
-               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
-               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();
-               } elseif( is_array( $wgGroupsAddToSelf[$group] ) ) {
+               } elseif ( is_array( $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();
-               } elseif( is_array( $wgGroupsRemoveFromSelf[$group] ) ) {
+               } elseif ( is_array( $wgGroupsRemoveFromSelf[$group] ) ) {
                        $groups['remove-self'] = $wgGroupsRemoveFromSelf[$group];
                }
 
@@ -4076,7 +4090,7 @@ class User {
         *  '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")
@@ -4099,7 +4113,7 @@ class User {
                );
                $addergroups = $this->getEffectiveGroups();
 
-               foreach( $addergroups as $addergroup ) {
+               foreach ( $addergroups as $addergroup ) {
                        $groups = array_merge_recursive(
                                $groups, $this->changeableByGroup( $addergroup )
                        );
@@ -4116,7 +4130,7 @@ class User {
         * Will have no effect for anonymous users.
         */
        public function incEditCount() {
-               if( !$this->isAnon() ) {
+               if ( !$this->isAnon() ) {
                        $dbw = wfGetDB( DB_MASTER );
                        $dbw->update(
                                'user',
@@ -4126,10 +4140,10 @@ class User {
                        );
 
                        // Lazy initialization check...
-                       if( $dbw->affectedRows() == 0 ) {
+                       if ( $dbw->affectedRows() == 0 ) {
                                // Now here's a goddamn hack...
                                $dbr = wfGetDB( DB_SLAVE );
-                               if( $dbr !== $dbw ) {
+                               if ( $dbr !== $dbw ) {
                                        // If we actually have a slave server, the count is
                                        // at least one behind because the current transaction
                                        // has not been committed and replicated.
@@ -4216,11 +4230,11 @@ class User {
                global $wgPasswordSalt;
 
                $hash = '';
-               if( !wfRunHooks( 'UserCryptPassword', array( &$password, &$salt, &$wgPasswordSalt, &$hash ) ) ) {
+               if ( !wfRunHooks( 'UserCryptPassword', array( &$password, &$salt, &$wgPasswordSalt, &$hash ) ) ) {
                        return $hash;
                }
 
-               if( $wgPasswordSalt ) {
+               if ( $wgPasswordSalt ) {
                        if ( $salt === false ) {
                                $salt = MWCryptRand::generateHex( 8 );
                        }
@@ -4244,7 +4258,7 @@ class User {
                $type = substr( $hash, 0, 3 );
 
                $result = false;
-               if( !wfRunHooks( 'UserComparePasswords', array( &$hash, &$password, &$userId, &$result ) ) ) {
+               if ( !wfRunHooks( 'UserComparePasswords', array( &$hash, &$password, &$userId, &$result ) ) ) {
                        return $result;
                }
 
@@ -4283,7 +4297,7 @@ class User {
         */
        public function addNewUserLogEntry( $action = false, $reason = '' ) {
                global $wgUser, $wgNewUserLog;
-               if( empty( $wgNewUserLog ) ) {
+               if ( empty( $wgNewUserLog ) ) {
                        return true; // disabled
                }
 
@@ -4363,11 +4377,11 @@ class User {
                // 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 {
-                       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 );
@@ -4407,13 +4421,13 @@ class User {
 
                // 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();
-               foreach( $saveOptions as $key => $value ) {
+               foreach ( $saveOptions as $key => $value ) {
                        # Don't bother storing default values
                        $defaultOption = self::getDefaultOption( $key );
                        if ( ( is_null( $defaultOption ) &&
index 2eb8429..7eca76f 100644 (file)
@@ -119,7 +119,7 @@ class UserMailer {
         */
        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 );
@@ -338,7 +338,7 @@ class UserMailer {
                        #
                        # PHP mail()
                        #
-                       if( count( $to ) > 1 ) {
+                       if ( count( $to ) > 1 ) {
                                $headers['To'] = 'undisclosed-recipients:;';
                        }
                        $headers = self::arrayToHeaderString( $headers, $endl );
@@ -409,7 +409,7 @@ class UserMailer {
         */
        public static function quotedPrintable( $string, $charset = '' ) {
                # Probably incomplete; see RFC 2045
-               if( empty( $charset ) ) {
+               if ( empty( $charset ) ) {
                        $charset = 'UTF-8';
                }
                $charset = strtoupper( $charset );
@@ -417,7 +417,7 @@ class UserMailer {
 
                $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?";
@@ -791,8 +791,9 @@ class EmailNotification {
        function compose( $user ) {
                global $wgEnotifImpersonal;
 
-               if ( !$this->composed_common )
+               if ( !$this->composed_common ) {
                        $this->composeCommonMailtext();
+               }
 
                if ( $wgEnotifImpersonal ) {
                        $this->mailTargets[] = new MailAddress( $user );
index cd5dff8..56bb73f 100644 (file)
@@ -74,7 +74,7 @@ class UserRightsProxy {
         */
        public static function whoIs( $database, $id, $ignoreInvalidDB = false ) {
                $user = self::newFromId( $database, $id, $ignoreInvalidDB );
-               if( $user ) {
+               if ( $user ) {
                        return $user->name;
                } else {
                        return false;
@@ -114,12 +114,12 @@ class UserRightsProxy {
         */
        private static function newFromLookup( $database, $field, $value, $ignoreInvalidDB = false ) {
                $db = self::getDB( $database, $ignoreInvalidDB );
-               if( $db ) {
+               if ( $db ) {
                        $row = $db->selectRow( 'user',
                                array( 'user_id', 'user_name' ),
                                array( $field => $value ),
                                __METHOD__ );
-                       if( $row !== false ) {
+                       if ( $row !== false ) {
                                return new UserRightsProxy( $db, $database,
                                        $row->user_name,
                                        intval( $row->user_id ) );
@@ -138,8 +138,8 @@ class UserRightsProxy {
         */
        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 {
index 5ac92f7..01376a0 100644 (file)
@@ -268,7 +268,7 @@ class WatchedItem {
                        );
                }
 
-               if( empty( $values ) ) {
+               if ( empty( $values ) ) {
                        // Nothing to do
                        return true;
                }
index 3bdf645..e85bf9c 100644 (file)
@@ -91,11 +91,11 @@ class WebRequest {
                        wfSuppressWarnings();
                        $a = parse_url( $url );
                        wfRestoreWarnings();
-                       if( $a ) {
+                       if ( $a ) {
                                $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;
@@ -106,7 +106,7 @@ class WebRequest {
                                // 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
@@ -116,17 +116,17 @@ class WebRequest {
                                }
 
                                global $wgArticlePath;
-                               if( $wgArticlePath ) {
+                               if ( $wgArticlePath ) {
                                        $router->add( $wgArticlePath );
                                }
 
                                global $wgActionPaths;
-                               if( $wgActionPaths ) {
+                               if ( $wgActionPaths ) {
                                        $router->add( $wgActionPaths, array( 'action' => '$key' ) );
                                }
 
                                global $wgVariantArticlePath, $wgContLang;
-                               if( $wgVariantArticlePath ) {
+                               if ( $wgVariantArticlePath ) {
                                        $router->add( $wgVariantArticlePath,
                                                array( 'variant' => '$2' ),
                                                array( '$2' => $wgContLang->getVariants() )
@@ -224,7 +224,7 @@ class WebRequest {
                }
 
                $matches = self::getPathInfo( 'title' );
-               foreach( $matches as $key => $val ) {
+               foreach ( $matches as $key => $val ) {
                        $this->data[$key] = $_GET[$key] = $_REQUEST[$key] = $val;
                }
        }
@@ -240,15 +240,15 @@ class WebRequest {
         * @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 );
-                       if( substr( $path, 0, $baseLen ) == $base ) {
+                       if ( substr( $path, 0, $baseLen ) == $base ) {
                                $raw = substr( $path, $baseLen );
-                               if( $raw !== '' ) {
+                               if ( $raw !== '' ) {
                                        $matches = array( 'title' => rawurldecode( $raw ) );
-                                       if( $key ) {
+                                       if ( $key ) {
                                                $matches[$key] = $keyValue;
                                        }
                                        return $matches;
@@ -271,8 +271,8 @@ class WebRequest {
         */
        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 {
@@ -293,7 +293,7 @@ class WebRequest {
        private function checkMagicQuotes() {
                $mustFixQuotes = function_exists( 'get_magic_quotes_gpc' )
                        && get_magic_quotes_gpc();
-               if( $mustFixQuotes ) {
+               if ( $mustFixQuotes ) {
                        $this->fix_magic_quotes( $_COOKIE );
                        $this->fix_magic_quotes( $_ENV );
                        $this->fix_magic_quotes( $_GET );
@@ -311,8 +311,8 @@ class WebRequest {
         * @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 {
@@ -335,12 +335,12 @@ class WebRequest {
                # 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];
-                       if( isset( $_GET[$name] ) && !is_array( $data ) ) {
+                       if ( isset( $_GET[$name] ) && !is_array( $data ) ) {
                                # Check for alternate/legacy character encoding.
-                               if( isset( $wgContLang ) ) {
+                               if ( isset( $wgContLang ) ) {
                                        $data = $wgContLang->checkTitleEncoding( $data );
                                }
                        }
@@ -364,10 +364,10 @@ class WebRequest {
         */
        public function getVal( $name, $default = null ) {
                $val = $this->getGPCVal( $this->data, $name, $default );
-               if( is_array( $val ) ) {
+               if ( is_array( $val ) ) {
                        $val = $default;
                }
-               if( is_null( $val ) ) {
+               if ( is_null( $val ) ) {
                        return $val;
                } else {
                        return (string)$val;
@@ -414,7 +414,7 @@ class WebRequest {
         */
        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;
@@ -433,7 +433,7 @@ class WebRequest {
         */
        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;
@@ -615,7 +615,7 @@ class WebRequest {
         * @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;
                }
@@ -630,14 +630,14 @@ class WebRequest {
         * @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'];
-               } elseif( isset( $_SERVER['SCRIPT_NAME'] ) ) {
+               } elseif ( isset( $_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 {
@@ -651,11 +651,11 @@ class WebRequest {
                // 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 );
                }
 
-               if( $base[0] == '/' ) {
+               if ( $base[0] == '/' ) {
                        // More than one slash will look like it is protocol relative
                        return preg_replace( '!^/+!', '/', $base );
                } else {
@@ -739,21 +739,21 @@ class WebRequest {
                global $wgUser;
 
                $limit = $this->getInt( 'limit', 0 );
-               if( $limit < 0 ) {
+               if ( $limit < 0 ) {
                        $limit = 0;
                }
-               if( ( $limit == 0 ) && ( $optionname != '' ) ) {
+               if ( ( $limit == 0 ) && ( $optionname != '' ) ) {
                        $limit = $wgUser->getIntOption( $optionname );
                }
-               if( $limit <= 0 ) {
+               if ( $limit <= 0 ) {
                        $limit = $deflimit;
                }
-               if( $limit > 5000 ) {
+               if ( $limit > 5000 ) {
                        $limit = 5000; # We have *some* limits...
                }
 
                $offset = $this->getInt( 'offset', 0 );
-               if( $offset < 0 ) {
+               if ( $offset < 0 ) {
                        $offset = 0;
                }
 
@@ -893,7 +893,7 @@ class WebRequest {
         * @return Mixed
         */
        public function getSessionData( $key ) {
-               if( !isset( $_SESSION[$key] ) ) {
+               if ( !isset( $_SESSION[$key] ) ) {
                        return null;
                }
                return $_SESSION[$key];
@@ -1268,13 +1268,13 @@ class FauxRequest extends WebRequest {
         * @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;
-               if( $session ) {
+               if ( $session ) {
                        $this->session = $session;
                }
        }
@@ -1359,7 +1359,7 @@ class FauxRequest extends WebRequest {
         * @return mixed
         */
        public function getSessionData( $key ) {
-               if( isset( $this->session[$key] ) ) {
+               if ( isset( $this->session[$key] ) ) {
                        return $this->session[$key];
                }
                return null;
index 8e15d71..d1f645c 100644 (file)
@@ -57,10 +57,10 @@ class WebResponse {
                if ( $expire == 0 ) {
                        $expire = time() + $wgCookieExpiration;
                }
-               if( $prefix === null ) {
+               if ( $prefix === null ) {
                        $prefix = $wgCookiePrefix;
                }
-               if( $domain === null ) {
+               if ( $domain === null ) {
                        $domain = $wgCookieDomain;
                }
 
@@ -116,7 +116,7 @@ class FauxResponse extends WebResponse {
                } 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;
                        }
                }
index e6f3135..3b7d701 100644 (file)
@@ -48,7 +48,7 @@ if ( ini_get( 'register_globals' ) ) {
                '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 );
@@ -84,7 +84,7 @@ define( 'MEDIAWIKI', true );
 # 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__ );
@@ -129,7 +129,7 @@ if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
        # 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();
        }
index b9a7aac..7d0d5af 100644 (file)
@@ -126,7 +126,7 @@ class MediaWiki {
         * @return Title
         */
        public function getTitle() {
-               if( $this->context->getTitle() === null ) {
+               if ( $this->context->getTitle() === null ) {
                        $this->context->setTitle( $this->parseTitle() );
                }
                return $this->context->getTitle();
@@ -480,7 +480,7 @@ class MediaWiki {
                                $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";
index 6278121..08eb800 100644 (file)
@@ -143,7 +143,7 @@ class WikiXmlError extends WikiError {
        }
 
        function _extractContext( $context, $offset ) {
-               if( is_null( $context ) ) {
+               if ( is_null( $context ) ) {
                        return null;
                } else {
                        // Hopefully integer overflow will be handled transparently here
index ab3d68d..5d90b12 100644 (file)
@@ -37,7 +37,7 @@ class WikiMap {
                $wgConf->loadFullData();
 
                list( $major, $minor ) = $wgConf->siteFromDB( $wikiID );
-               if( $major === null ) {
+               if ( $major === null ) {
                        return null;
                }
                $canonicalServer = $wgConf->get( 'wgCanonicalServer', $wikiID, $major,
index 3f7e497..39a71ad 100644 (file)
@@ -305,7 +305,7 @@ class WikiPage implements Page, IDBAccessObject {
        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 );
        }
 
        /**
@@ -462,7 +462,9 @@ class WikiPage implements Page, IDBAccessObject {
         */
        public function isRedirect() {
                $content = $this->getContent();
-               if ( !$content ) return false;
+               if ( !$content ) {
+                       return false;
+               }
 
                return $content->isRedirect();
        }
@@ -906,10 +908,10 @@ class WikiPage implements Page, IDBAccessObject {
                $dbw = wfGetDB( DB_MASTER );
                $dbw->replace( 'redirect', array( 'rd_from' ),
                        array(
-                               'rd_from'      => $this->getId(),
+                               'rd_from' => $this->getId(),
                                '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__
@@ -1155,7 +1157,7 @@ class WikiPage implements Page, IDBAccessObject {
        public function doPurge() {
                global $wgUseSquid;
 
-               if( !wfRunHooks( 'ArticlePurge', array( &$this ) ) ) {
+               if ( !wfRunHooks( 'ArticlePurge', array( &$this ) ) ) {
                        return false;
                }
 
@@ -1182,7 +1184,9 @@ class WikiPage implements Page, IDBAccessObject {
                                $content = $this->getContent();
                                $text = $content === null ? null : $content->getWikitextForTransclusion();
 
-                               if ( $text === null ) $text = false;
+                               if ( $text === null ) {
+                                       $text = false;
+                               }
                        } else {
                                $text = false;
                        }
@@ -1698,7 +1702,9 @@ class WikiPage implements Page, IDBAccessObject {
 
                // 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 );
                }
 
@@ -2142,12 +2148,14 @@ class WikiPage implements Page, IDBAccessObject {
                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 );
                }
 
-               if( $options['created'] ) {
+               if ( $options['created'] ) {
                        self::onArticleCreate( $this->mTitle );
                } else {
                        self::onArticleEdit( $this->mTitle );
@@ -2811,7 +2819,7 @@ class WikiPage implements Page, IDBAccessObject {
                        $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 );
@@ -2852,8 +2860,8 @@ class WikiPage implements Page, IDBAccessObject {
                $resultDetails = array(
                        'summary' => $summary,
                        'current' => $current,
-                       'target'  => $target,
-                       'newid'   => $revId
+                       'target' => $target,
+                       'newid' => $revId
                );
 
                return array();
@@ -3082,11 +3090,11 @@ class WikiPage implements Page, IDBAccessObject {
                                        );
                                }
 
-                               foreach( $added as $catName ) {
+                               foreach ( $added as $catName ) {
                                        $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 ) );
                                }
index 29c240e..c62cbdf 100644 (file)
@@ -38,13 +38,13 @@ class Xml {
         */
        public static function element( $element, $attribs = null, $contents = '', $allowShortTag = true ) {
                $out = '<' . $element;
-               if( !is_null( $attribs ) ) {
+               if ( !is_null( $attribs ) ) {
                        $out .= self::expandAttributes( $attribs );
                }
-               if( is_null( $contents ) ) {
+               if ( is_null( $contents ) ) {
                        $out .= '>';
                } else {
-                       if( $allowShortTag && $contents === '' ) {
+                       if ( $allowShortTag && $contents === '' ) {
                                $out .= ' />';
                        } else {
                                $out .= '>' . htmlspecialchars( $contents ) . "</$element>";
@@ -64,10 +64,10 @@ class Xml {
         */
        public static function expandAttributes( $attribs ) {
                $out = '';
-               if( is_null( $attribs ) ) {
+               if ( is_null( $attribs ) ) {
                        return null;
-               } 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;
@@ -88,10 +88,10 @@ class Xml {
         */
        public static function elementClean( $element, $attribs = array(), $contents = '' ) {
                global $wgContLang;
-               if( $attribs ) {
+               if ( $attribs ) {
                        $attribs = array_map( array( 'UtfNormal', 'cleanUp' ), $attribs );
                }
-               if( $contents ) {
+               if ( $contents ) {
                        wfProfileIn( __METHOD__ . '-norm' );
                        $contents = $wgContLang->normalize( $contents );
                        wfProfileOut( __METHOD__ . '-norm' );
@@ -115,7 +115,9 @@ class Xml {
         * @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
@@ -144,11 +146,11 @@ class Xml {
                wfDeprecated( __METHOD__, '1.19' );
                return Html::namespaceSelector( array(
                        'selected' => $selected,
-                       'all'      => $all,
-                       'label'    => $label,
+                       'all' => $all,
+                       'label' => $label,
                ), array(
-                       'name'  => $element_name,
-                       'id'    => 'namespace',
+                       'name' => $element_name,
+                       'id' => 'namespace',
                        'class' => 'namespaceselector',
                ) );
        }
@@ -164,12 +166,15 @@ class Xml {
        public static function monthSelector( $selected = '', $allmonths = null, $id = 'month' ) {
                global $wgLang;
                $options = array();
-               if( is_null( $selected ) )
+               if ( is_null( $selected ) ) {
                        $selected = '';
-               if( !is_null( $allmonths ) )
+               }
+               if ( !is_null( $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 );
+               }
                return self::openElement( 'select', array( 'id' => $id, 'name' => 'month', 'class' => 'mw-month-selector' ) )
                        . implode( "\n", $options )
                        . self::closeElement( 'select' );
@@ -182,17 +187,17 @@ class Xml {
         */
        public static function dateMenu( $year, $month ) {
                # Offset overrides year/month selection
-               if( $month && $month !== -1 ) {
+               if ( $month && $month !== -1 ) {
                        $encMonth = intval( $month );
                } else {
                        $encMonth = '';
                }
-               if( $year ) {
+               if ( $year ) {
                        $encYear = intval( $year );
-               } elseif( $encMonth ) {
+               } elseif ( $encMonth ) {
                        $thisMonth = intval( gmdate( 'n' ) );
                        $thisYear = intval( gmdate( 'Y' ) );
-                       if( intval( $encMonth ) > $thisMonth ) {
+                       if ( intval( $encMonth ) > $thisMonth ) {
                                $thisYear--;
                        }
                        $encYear = $thisYear;
@@ -224,7 +229,7 @@ class Xml {
 
                // 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;
                }
 
@@ -237,14 +242,14 @@ class Xml {
                 */
                $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 );
 
-               if( $msg === null ) {
+               if ( $msg === null ) {
                        $msg = wfMessage( 'yourlanguage' );
                }
                return array(
@@ -288,11 +293,11 @@ class Xml {
        public static function input( $name, $size = false, $value = false, $attribs = array() ) {
                $attributes = array( 'name' => $name );
 
-               if( $size ) {
+               if ( $size ) {
                        $attributes['size'] = $size;
                }
 
-               if( $value !== false ) { // maybe 0
+               if ( $value !== false ) { // maybe 0
                        $attributes['value'] = $value;
                }
 
@@ -369,10 +374,10 @@ class Xml {
                $a = array( 'for' => $id );
 
                # FIXME avoid copy pasting below:
-               if( isset( $attribs['class'] ) ) {
+               if ( isset( $attribs['class'] ) ) {
                                $a['class'] = $attribs['class'];
                }
-               if( isset( $attribs['title'] ) ) {
+               if ( isset( $attribs['title'] ) ) {
                                $a['title'] = $attribs['title'];
                }
 
@@ -468,10 +473,10 @@ class Xml {
         */
        public static function option( $text, $value = null, $selected = false,
                        $attribs = array() ) {
-               if( !is_null( $value ) ) {
+               if ( !is_null( $value ) ) {
                        $attribs['value'] = $value;
                }
-               if( $selected ) {
+               if ( $selected ) {
                        $attribs['selected'] = 'selected';
                }
                return Html::element( 'option', $attribs, $text );
@@ -500,7 +505,9 @@ class Xml {
                                } 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 ) == '**' ) {
@@ -509,26 +516,30 @@ class Xml {
                                        $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;
                                }
                        }
 
-                       if( $optgroup ) $options .= self::closeElement( 'optgroup' );
+                       if ( $optgroup ) {
+                               $options .= self::closeElement( 'optgroup' );
+                       }
 
                $attribs = array();
 
-               if( $name ) {
+               if ( $name ) {
                        $attribs['id'] = $name;
                        $attribs['name'] = $name;
                }
 
-               if( $class ) {
+               if ( $class ) {
                        $attribs['class'] = $class;
                }
 
-               if( $tabindex ) {
+               if ( $tabindex ) {
                        $attribs['tabindex'] = $tabindex;
                }
 
@@ -679,7 +690,7 @@ class Xml {
                # 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 );
@@ -736,7 +747,7 @@ class Xml {
                $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() );
@@ -744,7 +755,7 @@ class Xml {
                        $form .= Xml::closeElement( 'tr' );
                }
 
-               if( $submitLabel ) {
+               if ( $submitLabel ) {
                        $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' );
@@ -769,7 +780,7 @@ class Xml {
                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 ) ) {
@@ -781,7 +792,7 @@ class Xml {
                        $s .= Xml::closeElement( 'thead' );
                }
 
-               foreach( $rows as $id => $row ) {
+               foreach ( $rows as $id => $row ) {
                        $attribs = array();
 
                        if ( is_string( $id ) ) {
@@ -805,8 +816,7 @@ class Xml {
        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 ) ) {
@@ -902,7 +912,7 @@ class XmlSelect {
        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";
index 5e4f118..25dde7d 100644 (file)
@@ -78,13 +78,13 @@ class XmlTypeCheck {
                                do {
                                        $chunk = fread( $file, 32768 );
                                        $ret = xml_parse( $parser, $chunk, feof( $file ) );
-                                       if( $ret == 0 ) {
+                                       if ( $ret == 0 ) {
                                                // XML isn't well-formed!
                                                fclose( $file );
                                                xml_parser_free( $parser );
                                                return;
                                        }
-                               } while( !feof( $file ) );
+                               } while ( !feof( $file ) );
 
                                fclose( $file );
                        }
@@ -103,7 +103,7 @@ class XmlTypeCheck {
        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 {
@@ -118,7 +118,7 @@ class XmlTypeCheck {
         * @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;
                }
index fd03ec4..c5955ae 100644 (file)
@@ -81,14 +81,14 @@ class ZhClient {
                $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 = '';
-               while( !feof( $this->mFP ) && $bytesread < $len ) {
+               while ( !feof( $this->mFP ) && $bytesread < $len ) {
                        $str = fread( $this->mFP, $len - $bytesread );
                        $bytesread += strlen( $str );
                        $data .= $str;
@@ -131,7 +131,7 @@ class ZhClient {
                $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;