Fixed spacing in context/installer/media/templates/upload folder
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 20 Apr 2013 21:11:46 +0000 (23:11 +0200)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 21 Apr 2013 06:22:06 +0000 (06:22 +0000)
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: I9761be9fa47adc3554852a97b19792b4648466ad

43 files changed:
includes/context/RequestContext.php
includes/installer/CliInstaller.php
includes/installer/DatabaseInstaller.php
includes/installer/Installer.php
includes/installer/LocalSettingsGenerator.php
includes/installer/MysqlInstaller.php
includes/installer/MysqlUpdater.php
includes/installer/PostgresInstaller.php
includes/installer/PostgresUpdater.php
includes/installer/SqliteInstaller.php
includes/installer/WebInstaller.php
includes/installer/WebInstallerOutput.php
includes/installer/WebInstallerPage.php
includes/media/BMP.php
includes/media/Bitmap.php
includes/media/BitmapMetadataHandler.php
includes/media/DjVu.php
includes/media/DjVuImage.php
includes/media/Exif.php
includes/media/FormatMetadata.php
includes/media/GIF.php
includes/media/GIFMetadataExtractor.php
includes/media/ImageHandler.php
includes/media/Jpeg.php
includes/media/JpegMetadataExtractor.php
includes/media/MediaHandler.php
includes/media/MediaTransformOutput.php
includes/media/PNG.php
includes/media/PNGMetadataExtractor.php
includes/media/SVG.php
includes/media/SVGMetadataExtractor.php
includes/media/XCF.php
includes/media/XMP.php
includes/media/XMPInfo.php
includes/templates/Usercreate.php
includes/templates/Userlogin.php
includes/templates/UserloginVForm.php
includes/upload/UploadBase.php
includes/upload/UploadFromChunks.php
includes/upload/UploadFromFile.php
includes/upload/UploadFromStash.php
includes/upload/UploadFromUrl.php
includes/upload/UploadStash.php

index 6aefc98..fd99caf 100644 (file)
@@ -401,10 +401,10 @@ class RequestContext implements IContextSource {
         */
        public function exportSession() {
                return array(
-                       'ip'        => $this->getRequest()->getIP(),
-                       'headers'   => $this->getRequest()->getAllHeaders(),
+                       'ip' => $this->getRequest()->getIP(),
+                       'headers' => $this->getRequest()->getAllHeaders(),
                        'sessionId' => session_id(),
-                       'userId'    => $this->getUser()->getId()
+                       'userId' => $this->getUser()->getId()
                );
        }
 
index bb7e877..e3bcb6f 100644 (file)
@@ -114,7 +114,7 @@ class CliInstaller extends Installer {
         */
        public function execute() {
                $vars = Installer::getExistingLocalSettings();
-               if( $vars ) {
+               if ( $vars ) {
                        $this->showStatusMessage(
                                Status::newFatal( "config-localsettings-cli-upgrade" )
                        );
index cd14e4e..13d5d42 100644 (file)
@@ -173,7 +173,7 @@ abstract class DatabaseInstaller {
                }
                $this->db->selectDB( $this->getVar( 'wgDBname' ) );
 
-               if( $this->db->tableExists( 'archive', __METHOD__ ) ) {
+               if ( $this->db->tableExists( 'archive', __METHOD__ ) ) {
                        $status->warning( 'config-install-tables-exist' );
                        $this->enableLB();
                        return $status;
@@ -183,7 +183,7 @@ abstract class DatabaseInstaller {
                $this->db->begin( __METHOD__ );
 
                $error = $this->db->sourceFile( $this->db->getSchemaPath() );
-               if( $error !== true ) {
+               if ( $error !== true ) {
                        $this->db->reportQueryError( $error, 0, '', __METHOD__ );
                        $this->db->rollback( __METHOD__ );
                        $status->fatal( 'config-install-tables-failed', $error );
@@ -191,7 +191,7 @@ abstract class DatabaseInstaller {
                        $this->db->commit( __METHOD__ );
                }
                // Resume normal operations
-               if( $status->isOk() ) {
+               if ( $status->isOk() ) {
                        $this->enableLB();
                }
                return $status;
@@ -569,7 +569,7 @@ abstract class DatabaseInstaller {
                        $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) );
                }
 
-               if( $this->getVar( '_CreateDBAccount' ) && strval( $this->getVar( 'wgDBpassword' ) ) == '' ) {
+               if ( $this->getVar( '_CreateDBAccount' ) && strval( $this->getVar( 'wgDBpassword' ) ) == '' ) {
                        return Status::newFatal( 'config-db-password-empty', $this->getVar( 'wgDBuser' ) );
                }
 
@@ -588,7 +588,7 @@ abstract class DatabaseInstaller {
                }
                $this->db->selectDB( $this->getVar( 'wgDBname' ) );
 
-               if( $this->db->selectRow( 'interwiki', '*', array(), __METHOD__ ) ) {
+               if ( $this->db->selectRow( 'interwiki', '*', array(), __METHOD__ ) ) {
                        $status->warning( 'config-install-interwiki-exists' );
                        return $status;
                }
@@ -601,9 +601,11 @@ abstract class DatabaseInstaller {
                if ( !$rows ) {
                        return Status::newFatal( 'config-install-interwiki-list' );
                }
-               foreach( $rows as $row ) {
+               foreach ( $rows as $row ) {
                        $row = preg_replace( '/^\s*([^#]*?)\s*(#.*)?$/', '\\1', $row ); // strip comments - whee
-                       if ( $row == "" ) continue;
+                       if ( $row == "" ) {
+                               continue;
+                       }
                        $row .= "||";
                        $interwikis[] = array_combine(
                                array( 'iw_prefix', 'iw_url', 'iw_local', 'iw_api', 'iw_wikiid' ),
index 6a7970b..35a546c 100644 (file)
@@ -401,7 +401,7 @@ abstract class Installer {
         */
        public function doEnvironmentChecks() {
                $phpVersion = phpversion();
-               if( version_compare( $phpVersion, self::MINIMUM_PHP_VERSION, '>=' ) ) {
+               if ( version_compare( $phpVersion, self::MINIMUM_PHP_VERSION, '>=' ) ) {
                        $this->showMessage( 'config-env-php', $phpVersion );
                        $good = true;
                } else {
@@ -409,7 +409,7 @@ abstract class Installer {
                        $good = false;
                }
 
-               if( $good ) {
+               if ( $good ) {
                        foreach ( $this->envChecks as $check ) {
                                $status = $this->$check();
                                if ( $status === false ) {
@@ -486,7 +486,7 @@ abstract class Installer {
                $_lsExists = file_exists( "$IP/LocalSettings.php" );
                wfRestoreWarnings();
 
-               if( !$_lsExists ) {
+               if ( !$_lsExists ) {
                        return false;
                }
                unset( $_lsExists );
@@ -684,7 +684,7 @@ abstract class Installer {
         * Environment check for register_globals.
         */
        protected function envCheckRegisterGlobals() {
-               if( wfIniGetBool( 'register_globals' ) ) {
+               if ( wfIniGetBool( 'register_globals' ) ) {
                        $this->showMessage( 'config-register-globals' );
                }
        }
@@ -722,7 +722,7 @@ abstract class Installer {
         * @return bool
         */
        protected function envCheckMagicQuotes() {
-               if( wfIniGetBool( "magic_quotes_runtime" ) ) {
+               if ( wfIniGetBool( "magic_quotes_runtime" ) ) {
                        $this->showError( 'config-magic-quotes-runtime' );
                        return false;
                }
@@ -830,10 +830,10 @@ abstract class Installer {
 
                $n = wfShorthandToInteger( $limit );
 
-               if( $n < $this->minMemorySize * 1024 * 1024 ) {
+               if ( $n < $this->minMemorySize * 1024 * 1024 ) {
                        $newLimit = "{$this->minMemorySize}M";
 
-                       if( ini_set( "memory_limit", $newLimit ) === false ) {
+                       if ( ini_set( "memory_limit", $newLimit ) === false ) {
                                $this->showMessage( 'config-memory-bad', $limit );
                        } else {
                                $this->showMessage( 'config-memory-raised', $limit, $newLimit );
@@ -1082,7 +1082,7 @@ abstract class Installer {
        protected function envCheckSuhosinMaxValueLength() {
                $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
                if ( $maxValueLength > 0 ) {
-                       if( $maxValueLength < 1024 ) {
+                       if ( $maxValueLength < 1024 ) {
                                # Only warn if the value is below the sane 1024
                                $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength );
                        }
@@ -1140,14 +1140,14 @@ abstract class Installer {
                 * We're going to prefer the pecl extension here unless
                 * utf8_normalize is more up to date.
                 */
-               if( $utf8 ) {
+               if ( $utf8 ) {
                        $useNormalizer = 'utf8';
                        $utf8 = utf8_normalize( $not_normal_c, UtfNormal::UNORM_NFC );
                        if ( $utf8 !== $normal_c ) {
                                $needsUpdate = true;
                        }
                }
-               if( $intl ) {
+               if ( $intl ) {
                        $useNormalizer = 'intl';
                        $intl = normalizer_normalize( $not_normal_c, Normalizer::FORM_C );
                        if ( $intl !== $normal_c ) {
@@ -1156,11 +1156,11 @@ abstract class Installer {
                }
 
                // Uses messages 'config-unicode-using-php', 'config-unicode-using-utf8', 'config-unicode-using-intl'
-               if( $useNormalizer === 'php' ) {
+               if ( $useNormalizer === 'php' ) {
                        $this->showMessage( 'config-unicode-pure-php-warning' );
                } else {
                        $this->showMessage( 'config-unicode-using-' . $useNormalizer );
-                       if( $needsUpdate ) {
+                       if ( $needsUpdate ) {
                                $this->showMessage( 'config-unicode-update-warning' );
                        }
                }
@@ -1243,9 +1243,9 @@ abstract class Installer {
         * @return bool|string
         */
        public static function locateExecutableInDefaultPaths( $names, $versionInfo = false ) {
-               foreach( self::getPossibleBinPaths() as $path ) {
+               foreach ( self::getPossibleBinPaths() as $path ) {
                        $exe = self::locateExecutable( $path, $names, $versionInfo );
-                       if( $exe !== false ) {
+                       if ( $exe !== false ) {
                                return $exe;
                        }
                }
@@ -1344,7 +1344,7 @@ abstract class Installer {
         * @return array
         */
        public function findExtensions() {
-               if( $this->getVar( 'IP' ) === null ) {
+               if ( $this->getVar( 'IP' ) === null ) {
                        return array();
                }
 
@@ -1356,10 +1356,10 @@ abstract class Installer {
                $dh = opendir( $extDir );
                $exts = array();
                while ( ( $file = readdir( $dh ) ) !== false ) {
-                       if( !is_dir( "$extDir/$file" ) ) {
+                       if ( !is_dir( "$extDir/$file" ) ) {
                                continue;
                        }
-                       if( file_exists( "$extDir/$file/$file.php" ) ) {
+                       if ( file_exists( "$extDir/$file/$file.php" ) ) {
                                $exts[] = $file;
                        }
                }
@@ -1392,7 +1392,7 @@ abstract class Installer {
 
                require( "$IP/includes/DefaultSettings.php" );
 
-               foreach( $exts as $e ) {
+               foreach ( $exts as $e ) {
                        require_once( "$IP/extensions/$e/$e.php" );
                }
 
@@ -1431,9 +1431,9 @@ abstract class Installer {
 
                // Build the array of install steps starting from the core install list,
                // then adding any callbacks that wanted to attach after a given step
-               foreach( $coreInstallSteps as $step ) {
+               foreach ( $coreInstallSteps as $step ) {
                        $this->installSteps[] = $step;
-                       if( isset( $this->extraInstallSteps[$step['name']] ) ) {
+                       if ( isset( $this->extraInstallSteps[$step['name']] ) ) {
                                $this->installSteps = array_merge(
                                        $this->installSteps,
                                        $this->extraInstallSteps[$step['name']]
@@ -1442,7 +1442,7 @@ abstract class Installer {
                }
 
                // Prepend any steps that want to be at the beginning
-               if( isset( $this->extraInstallSteps['BEGINNING'] ) ) {
+               if ( isset( $this->extraInstallSteps['BEGINNING'] ) ) {
                        $this->installSteps = array_merge(
                                $this->extraInstallSteps['BEGINNING'],
                                $this->installSteps
@@ -1450,7 +1450,7 @@ abstract class Installer {
                }
 
                // Extensions should always go first, chance to tie into hooks and such
-               if( count( $this->getVar( '_Extensions' ) ) ) {
+               if ( count( $this->getVar( '_Extensions' ) ) ) {
                        array_unshift( $this->installSteps,
                                array( 'name' => 'extensions', 'callback' => array( $this, 'includeExtensions' ) )
                        );
@@ -1475,7 +1475,7 @@ abstract class Installer {
                $installer = $this->getDBInstaller();
                $installer->preInstall();
                $steps = $this->getInstallSteps( $installer );
-               foreach( $steps as $stepObj ) {
+               foreach ( $steps as $stepObj ) {
                        $name = $stepObj['name'];
                        call_user_func_array( $startCB, array( $name ) );
 
@@ -1488,11 +1488,11 @@ abstract class Installer {
 
                        // If we've hit some sort of fatal, we need to bail.
                        // Callback already had a chance to do output above.
-                       if( !$status->isOk() ) {
+                       if ( !$status->isOk() ) {
                                break;
                        }
                }
-               if( $status->isOk() ) {
+               if ( $status->isOk() ) {
                        $this->setVar( '_InstallDone', true );
                }
                return $installResults;
@@ -1566,7 +1566,7 @@ abstract class Installer {
 
                        $user->addGroup( 'sysop' );
                        $user->addGroup( 'bureaucrat' );
-                       if( $this->getVar( '_AdminEmail' ) ) {
+                       if ( $this->getVar( '_AdminEmail' ) ) {
                                $user->setEmail( $this->getVar( '_AdminEmail' ) );
                        }
                        $user->saveSettings();
@@ -1577,7 +1577,7 @@ abstract class Installer {
                }
                $status = Status::newGood();
 
-               if( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) {
+               if ( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) {
                        $this->subscribeToMediaWikiAnnounce( $status );
                }
 
@@ -1589,23 +1589,23 @@ abstract class Installer {
         */
        private function subscribeToMediaWikiAnnounce( Status $s ) {
                $params = array(
-                       'email'    => $this->getVar( '_AdminEmail' ),
+                       'email' => $this->getVar( '_AdminEmail' ),
                        'language' => 'en',
-                       'digest'   => 0
+                       'digest' => 0
                );
 
                // Mailman doesn't support as many languages as we do, so check to make
                // sure their selected language is available
                $myLang = $this->getVar( '_UserLang' );
-               if( in_array( $myLang, $this->mediaWikiAnnounceLanguages ) ) {
+               if ( in_array( $myLang, $this->mediaWikiAnnounceLanguages ) ) {
                        $myLang = $myLang == 'pt-br' ? 'pt_BR' : $myLang; // rewrite to Mailman's pt_BR
                        $params['language'] = $myLang;
                }
 
-               if( MWHttpRequest::canMakeRequests() ) {
+               if ( MWHttpRequest::canMakeRequests() ) {
                        $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
                                array( 'method' => 'POST', 'postData' => $params ) )->execute();
-                       if( !$res->isOK() ) {
+                       if ( !$res->isOK() ) {
                                $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
                        }
                } else {
index c9ebc7e..d3dfc83 100644 (file)
@@ -73,10 +73,10 @@ class LocalSettingsGenerator {
                        'wgEnotifWatchlist', 'wgEmailAuthentication', 'wgEnableUploads', 'wgUseInstantCommons'
                );
 
-               foreach( $confItems as $c ) {
+               foreach ( $confItems as $c ) {
                        $val = $installer->getVar( $c );
 
-                       if( in_array( $c, $boolItems ) ) {
+                       if ( in_array( $c, $boolItems ) ) {
                                $val = wfBoolToStr( $val );
                        }
 
@@ -136,13 +136,13 @@ class LocalSettingsGenerator {
        public function getText() {
                $localSettings = $this->getDefaultText();
 
-               if( count( $this->extensions ) ) {
+               if ( count( $this->extensions ) ) {
                        $localSettings .= "
 # Enabled Extensions. Most extensions are enabled by including the base extension file here
 # but check specific extension documentation for more details
 # The following extensions were automatically enabled:\n";
 
-                       foreach( $this->extensions as $extName ) {
+                       foreach ( $this->extensions as $extName ) {
                                $encExtName = self::escapePhpString( $extName );
                                $localSettings .= "require_once( \"\$IP/extensions/$encExtName/$encExtName.php\" );\n";
                        }
@@ -169,13 +169,13 @@ class LocalSettingsGenerator {
        protected function buildMemcachedServerList() {
                $servers = $this->values['_MemCachedServers'];
 
-               if( !$servers ) {
+               if ( !$servers ) {
                        return 'array()';
                } else {
                        $ret = 'array( ';
                        $servers = explode( ',', $servers );
 
-                       foreach( $servers as $srv ) {
+                       foreach ( $servers as $srv ) {
                                $srv = trim( $srv );
                                $ret .= "'$srv', ";
                        }
@@ -188,14 +188,14 @@ class LocalSettingsGenerator {
         * @return String
         */
        protected function getDefaultText() {
-               if( !$this->values['wgImageMagickConvertCommand'] ) {
+               if ( !$this->values['wgImageMagickConvertCommand'] ) {
                        $this->values['wgImageMagickConvertCommand'] = '/usr/bin/convert';
                        $magic = '#';
                } else {
                        $magic = '';
                }
 
-               if( !$this->values['wgShellLocale'] ) {
+               if ( !$this->values['wgShellLocale'] ) {
                        $this->values['wgShellLocale'] = 'en_US.UTF-8';
                        $locale = '#';
                } else {
@@ -205,16 +205,16 @@ class LocalSettingsGenerator {
                //$rightsUrl = $this->values['wgRightsUrl'] ? '' : '#'; // TODO: Fixme, I'm unused!
                $hashedUploads = $this->safeMode ? '' : '#';
                $metaNamespace = '';
-               if( $this->values['wgMetaNamespace'] !== $this->values['wgSitename'] ) {
+               if ( $this->values['wgMetaNamespace'] !== $this->values['wgSitename'] ) {
                        $metaNamespace = "\$wgMetaNamespace = \"{$this->values['wgMetaNamespace']}\";\n";
                }
 
                $groupRights = '';
-               if( $this->groupPermissions ) {
+               if ( $this->groupPermissions ) {
                        $groupRights .= "# The following permissions were set based on your choice in the installer\n";
-                       foreach( $this->groupPermissions as $group => $rightArr ) {
+                       foreach ( $this->groupPermissions as $group => $rightArr ) {
                                $group = self::escapePhpString( $group );
-                               foreach( $rightArr as $right => $perm ) {
+                               foreach ( $rightArr as $right => $perm ) {
                                        $right = self::escapePhpString( $right );
                                        $groupRights .= "\$wgGroupPermissions['$group']['$right'] = " .
                                                wfBoolToStr( $perm ) . ";\n";
index 72514f2..d550909 100644 (file)
@@ -353,7 +353,7 @@ class MysqlInstaller extends DatabaseInstaller {
                $s .= $this->parent->getWarningBox( wfMessage( 'config-mysql-myisam-dep' )->text() );
                $s .= Xml::closeElement( 'div' );
 
-               if( $this->getVar( '_MysqlEngine' ) != 'MyISAM' ) {
+               if ( $this->getVar( '_MysqlEngine' ) != 'MyISAM' ) {
                        $s .= Xml::openElement( 'script', array( 'type' => 'text/javascript' ) );
                        $s .= '$(\'#dbMyisamWarning\').hide();';
                        $s .= Xml::closeElement( 'script' );
@@ -371,10 +371,12 @@ class MysqlInstaller extends DatabaseInstaller {
                                'itemAttribs' => array(
                                        'MyISAM' => array(
                                                'class' => 'showHideRadio',
-                                               'rel'   => 'dbMyisamWarning'),
+                                               'rel' => 'dbMyisamWarning'
+                                       ),
                                        'InnoDB' => array(
                                                'class' => 'hideShowRadio',
-                                               'rel'   => 'dbMyisamWarning')
+                                               'rel' => 'dbMyisamWarning'
+                                       )
                        )));
                        $s .= $this->parent->getHelpBox( 'config-mysql-engine-help' );
                }
@@ -470,7 +472,7 @@ class MysqlInstaller extends DatabaseInstaller {
                }
                $conn = $status->value;
                $dbName = $this->getVar( 'wgDBname' );
-               if( !$conn->selectDB( $dbName ) ) {
+               if ( !$conn->selectDB( $dbName ) ) {
                        $conn->query( "CREATE DATABASE " . $conn->addIdentifierQuotes( $dbName ), __METHOD__ );
                        $conn->selectDB( $dbName );
                }
@@ -483,7 +485,7 @@ class MysqlInstaller extends DatabaseInstaller {
         */
        public function setupUser() {
                $dbUser = $this->getVar( 'wgDBuser' );
-               if( $dbUser == $this->getVar( '_InstallUser' ) ) {
+               if ( $dbUser == $this->getVar( '_InstallUser' ) ) {
                        return Status::newGood();
                }
                $status = $this->getConnection();
@@ -520,7 +522,7 @@ class MysqlInstaller extends DatabaseInstaller {
                        $tryToCreate = false;
                }
 
-               if( $tryToCreate ) {
+               if ( $tryToCreate ) {
                        $createHostList = array(
                                $server,
                                'localhost',
@@ -531,16 +533,16 @@ class MysqlInstaller extends DatabaseInstaller {
                        $createHostList = array_unique( $createHostList );
                        $escPass = $this->db->addQuotes( $password );
 
-                       foreach( $createHostList as $host ) {
+                       foreach ( $createHostList as $host ) {
                                $fullName = $this->buildFullUserName( $dbUser, $host );
-                               if( !$this->userDefinitelyExists( $dbUser, $host ) ) {
+                               if ( !$this->userDefinitelyExists( $dbUser, $host ) ) {
                                        try{
                                                $this->db->begin( __METHOD__ );
                                                $this->db->query( "CREATE USER $fullName IDENTIFIED BY $escPass", __METHOD__ );
                                                $this->db->commit( __METHOD__ );
                                                $grantableNames[] = $fullName;
                                        } catch( DBQueryError $dqe ) {
-                                               if( $this->db->lastErrno() == 1396 /* ER_CANNOT_USER */ ) {
+                                               if ( $this->db->lastErrno() == 1396 /* ER_CANNOT_USER */ ) {
                                                        // User (probably) already exists
                                                        $this->db->rollback( __METHOD__ );
                                                        $status->warning( 'config-install-user-alreadyexists', $dbUser );
@@ -563,7 +565,7 @@ class MysqlInstaller extends DatabaseInstaller {
 
                // Try to grant to all the users we know exist or we were able to create
                $dbAllTables = $this->db->addIdentifierQuotes( $dbName ) . '.*';
-               foreach( $grantableNames as $name ) {
+               foreach ( $grantableNames as $name ) {
                        try {
                                $this->db->begin( __METHOD__ );
                                $this->db->query( "GRANT ALL PRIVILEGES ON $dbAllTables TO $name", __METHOD__ );
index df1f610..1c22afb 100644 (file)
@@ -331,7 +331,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        return;
                }
 
-               if( $this->applyPatch( 'patch-fix-il_from.sql', false, "Fixing ancient broken imagelinks table." ) ) {
+               if ( $this->applyPatch( 'patch-fix-il_from.sql', false, "Fixing ancient broken imagelinks table." ) ) {
                        $this->output( "NOTE: you will have to run maintenance/refreshLinks.php after this." );
                }
        }
@@ -368,7 +368,7 @@ class MysqlUpdater extends DatabaseUpdater {
                $this->output( wfTimestamp( TS_DB ) );
                $this->output( "......checking for duplicate entries.\n" );
 
-               list ( $cur, $old, $page, $revision, $text ) = $this->db->tableNamesN( 'cur', 'old', 'page', 'revision', 'text' );
+               list( $cur, $old, $page, $revision, $text ) = $this->db->tableNamesN( 'cur', 'old', 'page', 'revision', 'text' );
 
                $rows = $this->db->query( "SELECT cur_title, cur_namespace, COUNT(cur_namespace) AS c
                                FROM $cur GROUP BY cur_title, cur_namespace HAVING c>1", __METHOD__ );
@@ -525,12 +525,12 @@ class MysqlUpdater extends DatabaseUpdater {
 
        protected function doNamespaceSize() {
                $tables = array(
-                       'page'          => 'page',
-                       'archive'       => 'ar',
+                       'page' => 'page',
+                       'archive' => 'ar',
                        'recentchanges' => 'rc',
-                       'watchlist'     => 'wl',
-                       'querycache'    => 'qc',
-                       'logging'       => 'log',
+                       'watchlist' => 'wl',
+                       'querycache' => 'qc',
+                       'logging' => 'log',
                );
                foreach ( $tables as $table => $prefix ) {
                        $field = $prefix . '_namespace';
@@ -651,7 +651,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        foreach ( $groups as $group ) {
                                $this->db->insert( 'user_groups',
                                        array(
-                                               'ug_user'  => $row->ur_user,
+                                               'ug_user' => $row->ur_user,
                                                'ug_group' => $group ),
                                        __METHOD__ );
                        }
@@ -686,7 +686,7 @@ class MysqlUpdater extends DatabaseUpdater {
                $this->db->query( "UPDATE $page SET page_random = RAND() WHERE page_random = 0", __METHOD__ );
                $rows = $this->db->affectedRows();
 
-               if( $rows ) {
+               if ( $rows ) {
                        $this->output( "Set page_random to a random value on $rows rows where it was set to 0\n" );
                } else {
                        $this->output( "...no page_random rows needed to be set\n" );
index e7ae8d5..3747189 100644 (file)
@@ -431,7 +431,7 @@ class PostgresInstaller extends DatabaseInstaller {
                        'callback' => array( $this, 'setupSchema' )
                );
 
-               if( $this->getVar( '_CreateDBAccount' ) ) {
+               if ( $this->getVar( '_CreateDBAccount' ) ) {
                        $this->parent->addInstallStep( $createDbAccount, 'database' );
                }
                $this->parent->addInstallStep( $commitCB, 'interwiki' );
@@ -469,7 +469,7 @@ class PostgresInstaller extends DatabaseInstaller {
                $schema = $this->getVar( 'wgDBmwschema' );
                $safeschema = $conn->addIdentifierQuotes( $schema );
                $safeuser = $conn->addIdentifierQuotes( $this->getVar( 'wgDBuser' ) );
-               if( !$conn->schemaExists( $schema ) ) {
+               if ( !$conn->schemaExists( $schema ) ) {
                        try {
                                $conn->query( "CREATE SCHEMA $safeschema AUTHORIZATION $safeuser" );
                        } catch ( DBQueryError $e ) {
@@ -557,7 +557,7 @@ class PostgresInstaller extends DatabaseInstaller {
                 */
                $conn = $status->value;
 
-               if( $conn->tableExists( 'archive' ) ) {
+               if ( $conn->tableExists( 'archive' ) ) {
                        $status->warning( 'config-install-tables-exist' );
                        $this->enableLB();
                        return $status;
@@ -565,12 +565,12 @@ class PostgresInstaller extends DatabaseInstaller {
 
                $conn->begin( __METHOD__ );
 
-               if( !$conn->schemaExists( $schema ) ) {
+               if ( !$conn->schemaExists( $schema ) ) {
                        $status->fatal( 'config-install-pg-schema-not-exist' );
                        return $status;
                }
                $error = $conn->sourceFile( $conn->getSchemaPath() );
-               if( $error !== true ) {
+               if ( $error !== true ) {
                        $conn->reportQueryError( $error, 0, '', __METHOD__ );
                        $conn->rollback( __METHOD__ );
                        $status->fatal( 'config-install-tables-failed', $error );
@@ -578,7 +578,7 @@ class PostgresInstaller extends DatabaseInstaller {
                        $conn->commit( __METHOD__ );
                }
                // Resume normal operations
-               if( $status->isOk() ) {
+               if ( $status->isOk() ) {
                        $this->enableLB();
                }
                return $status;
index 2615fc6..58a54c4 100644 (file)
@@ -46,9 +46,9 @@ class PostgresUpdater extends DatabaseUpdater {
                        # r15791 Change reserved word table names "user" and "text"
                        array( 'renameTable', 'user', 'mwuser' ),
                        array( 'renameTable', 'text', 'pagecontent' ),
-                       array( 'renameIndex', 'mwuser', 'user_pkey', 'mwuser_pkey'),
+                       array( 'renameIndex', 'mwuser', 'user_pkey', 'mwuser_pkey' ),
                        array( 'renameIndex', 'mwuser', 'user_user_name_key', 'mwuser_user_name_key' ),
-                       array( 'renameIndex', 'pagecontent','text_pkey', 'pagecontent_pkey' ),
+                       array( 'renameIndex', 'pagecontent', 'text_pkey', 'pagecontent_pkey' ),
 
                        # renamed sequences
                        array( 'renameSequence', 'ipblocks_ipb_id_val', 'ipblocks_ipb_id_seq'         ),
@@ -252,9 +252,9 @@ class PostgresUpdater extends DatabaseUpdater {
                        ),
                        'CREATE INDEX cl_sortkey ON "categorylinks" USING "btree" ("cl_to", "cl_sortkey", "cl_from")' ),
                        array( 'checkIndex', 'iwl_prefix_title_from', array(
-                               array('iwl_prefix', 'text_ops', 'btree', 0),
-                               array('iwl_title', 'text_ops', 'btree', 0),
-                               array('iwl_from', 'int4_ops', 'btree', 0),
+                               array( 'iwl_prefix', 'text_ops', 'btree', 0 ),
+                               array( 'iwl_title', 'text_ops', 'btree', 0 ),
+                               array( 'iwl_from', 'int4_ops', 'btree', 0 ),
                        ),
                        'CREATE INDEX iwl_prefix_title_from ON "iwlinks" USING "btree" ("iwl_prefix", "iwl_title", "iwl_from")' ),
                        array( 'checkIndex', 'logging_times', array(
@@ -308,11 +308,11 @@ class PostgresUpdater extends DatabaseUpdater {
                        array( 'checkOiNameConstraint' ),
                        array( 'checkPageDeletedTrigger' ),
                        array( 'checkRevUserFkey' ),
-                       array( 'dropIndex', 'ipblocks', 'ipb_address'),
+                       array( 'dropIndex', 'ipblocks', 'ipb_address' ),
                        array( 'checkIndex', 'ipb_address_unique', array(
                                array( 'ipb_address', 'text_ops', 'btree', 0 ),
-                               array( 'ipb_user',    'int4_ops', 'btree', 0 ),
-                               array( 'ipb_auto',    'int2_ops', 'btree', 0 ),
+                               array( 'ipb_user', 'int4_ops', 'btree', 0 ),
+                               array( 'ipb_auto', 'int2_ops', 'btree', 0 ),
                                array( 'ipb_anon_only', 'int2_ops', 'btree', 0 ),
                        ),
                        'CREATE UNIQUE INDEX ipb_address_unique ON ipblocks (ipb_address,ipb_user,ipb_auto,ipb_anon_only)' ),
@@ -515,7 +515,7 @@ END;
                if ( !$this->db->sequenceExists( $ns ) ) {
                        $this->output( "Creating sequence $ns\n" );
                        $this->db->query( "CREATE SEQUENCE $ns" );
-                       if( $pkey !== false ) {
+                       if ( $pkey !== false ) {
                                $this->setDefault( $table, $pkey, '"nextval"(\'"' . $ns . '"\'::"regclass")' );
                        }
                }
@@ -538,7 +538,7 @@ END;
                        $old = $this->db->realTableName( $old, "quoted" );
                        $new = $this->db->realTableName( $new, "quoted" );
                        $this->db->query( "ALTER TABLE $old RENAME TO $new" );
-                       if( $patch !== false ) {
+                       if ( $patch !== false ) {
                                $this->applyPatch( $patch );
                        }
                }
@@ -592,9 +592,9 @@ END;
                        exit( 1 );
                }
 
-               if ( $fi->type() === $newtype )
+               if ( $fi->type() === $newtype ) {
                        $this->output( "...column '$table.$field' is already of type '$newtype'\n" );
-               else {
+               else {
                        $this->output( "Changing column type of '$table.$field' from '{$fi->type()}' to '$newtype'\n" );
                        $sql = "ALTER TABLE $table ALTER $field TYPE $newtype";
                        if ( strlen( $default ) ) {
index 68df6ab..50a7181 100644 (file)
@@ -60,7 +60,7 @@ class SqliteInstaller extends DatabaseInstaller {
                        $result->fatal( 'config-outdated-sqlite', $db->getServerVersion(), self::MINIMUM_VERSION );
                }
                // Check for FTS3 full-text search module
-               if( DatabaseSqlite::getFulltextSearchModule() != 'FTS3' ) {
+               if ( DatabaseSqlite::getFulltextSearchModule() != 'FTS3' ) {
                        $result->warning( 'config-no-fts3' );
                }
                return $result;
index 30aa956..9c56558 100644 (file)
@@ -154,7 +154,7 @@ class WebInstaller extends Installer {
                $this->exportVars();
                $this->setupLanguage();
 
-               if( ( $this->getVar( '_InstallDone' ) || $this->getVar( '_UpgradeDone' ) )
+               if ( ( $this->getVar( '_InstallDone' ) || $this->getVar( '_UpgradeDone' ) )
                        && $this->request->getVal( 'localsettings' ) )
                {
                        $this->request->response()->header( 'Content-type: application/x-httpd-php' );
@@ -164,7 +164,7 @@ class WebInstaller extends Installer {
 
                        $ls = InstallerOverrides::getLocalSettingsGenerator( $this );
                        $rightsProfile = $this->rightsProfiles[$this->getVar( '_RightsProfile' )];
-                       foreach( $rightsProfile as $group => $rightsArr ) {
+                       foreach ( $rightsProfile as $group => $rightsArr ) {
                                $ls->setGroupRights( $group, $rightsArr );
                        }
                        echo $ls->getText();
@@ -172,7 +172,7 @@ class WebInstaller extends Installer {
                }
 
                $cssDir = $this->request->getVal( 'css' );
-               if( $cssDir ) {
+               if ( $cssDir ) {
                        $cssDir = ( $cssDir == 'rtl' ? 'rtl' : 'ltr' );
                        $this->request->response()->header( 'Content-type: text/css' );
                        echo $this->output->getCSS( $cssDir );
@@ -250,7 +250,7 @@ class WebInstaller extends Installer {
                                do {
                                        $nextPageId--;
                                        $nextPage = $this->pageSequence[$nextPageId];
-                               } while( isset( $this->skippedPages[$nextPage] ) );
+                               } while ( isset( $this->skippedPages[$nextPage] ) );
                        } else {
                                $nextPage = $this->pageSequence[$lowestUnhappy];
                        }
@@ -263,7 +263,7 @@ class WebInstaller extends Installer {
                $this->currentPageName = $page->getName();
                $this->startPageWrapper( $pageName );
 
-               if( $page->isSlow() ) {
+               if ( $page->isSlow() ) {
                        $this->disableTimeLimit();
                }
 
@@ -324,7 +324,7 @@ class WebInstaller extends Installer {
         * @return bool
         */
        public function startSession() {
-               if( wfIniGetBool( 'session.auto_start' ) || session_id() ) {
+               if ( wfIniGetBool( 'session.auto_start' ) || session_id() ) {
                        // Done already
                        return true;
                }
@@ -889,7 +889,7 @@ class WebInstaller extends Installer {
                if ( !isset( $params['help'] ) ) {
                        $params['help'] = "";
                }
-               if( isset( $params['rawtext'] ) ) {
+               if ( isset( $params['rawtext'] ) ) {
                        $labelText = $params['rawtext'];
                } else {
                        $labelText = $this->parse( wfMessage( $params['label'] )->text() );
@@ -983,10 +983,10 @@ class WebInstaller extends Installer {
         * @param $status Status
         */
        public function showStatusBox( $status ) {
-               if( !$status->isGood() ) {
+               if ( !$status->isGood() ) {
                        $text = $status->getWikiText();
 
-                       if( $status->isOk() ) {
+                       if ( $status->isOk() ) {
                                $box = $this->getWarningBox( $text );
                        } else {
                                $box = $this->getErrorBox( $text );
index a6a8667..3e65eae 100644 (file)
@@ -146,7 +146,7 @@ class WebInstallerOutput {
                }
                wfRestoreWarnings();
 
-               if( $dir == 'rtl' ) {
+               if ( $dir == 'rtl' ) {
                        $css = CSSJanus::transform( $css, true );
                }
 
index 3f3e50a..b640fb8 100644 (file)
@@ -254,7 +254,9 @@ class WebInstaller_Language extends WebInstallerPage {
                $languages = Language::fetchLanguageNames();
                ksort( $languages );
                foreach ( $languages as $code => $lang ) {
-                       if ( isset( $wgDummyLanguageCodes[$code] ) ) continue;
+                       if ( isset( $wgDummyLanguageCodes[$code] ) ) {
+                               continue;
+                       }
                        $s .= "\n" . Xml::option( "$code - $lang", $code, $code == $selectedCode );
                }
                $s .= "\n</select>\n";
@@ -310,7 +312,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage {
                $r = $this->parent->request;
                if ( $r->wasPosted() ) {
                        $key = $r->getText( 'config_wgUpgradeKey' );
-                       if( !$key || $key !== $vars['wgUpgradeKey'] ) {
+                       if ( !$key || $key !== $vars['wgUpgradeKey'] ) {
                                $this->parent->showError( 'config-localsettings-badkey' );
                                $this->showKeyForm();
                                return 'output';
@@ -458,7 +460,7 @@ class WebInstaller_DBConnect extends WebInstallerPage {
                // Give grep a chance to find the usages:
                // config-support-mysql, config-support-postgres, config-support-oracle, config-support-sqlite
                $dbSupport = '';
-               foreach( $this->parent->getDBTypes() as $type ) {
+               foreach ( $this->parent->getDBTypes() as $type ) {
                        $link = DatabaseBase::factory( $type )->getSoftwareLink();
                        $dbSupport .= wfMessage( "config-support-$type", $link )->plain() . "\n";
                }
@@ -552,7 +554,7 @@ class WebInstaller_Upgrade extends WebInstallerPage {
                        if ( $result ) {
                                // If they're going to possibly regenerate LocalSettings, we
                                // need to create the upgrade/secret keys. Bug 26481
-                               if( !$this->getVar( '_ExistingDBSettings' ) ) {
+                               if ( !$this->getVar( '_ExistingDBSettings' ) ) {
                                        $this->parent->generateKeys();
                                }
                                $this->setVar( '_UpgradeDone', true );
@@ -764,7 +766,7 @@ class WebInstaller_Name extends WebInstallerPage {
                // Make sure it won't conflict with any existing namespaces
                global $wgContLang;
                $nsIndex = $wgContLang->getNsIndex( $name );
-               if( $nsIndex !== false && $nsIndex !== NS_PROJECT ) {
+               if ( $nsIndex !== false && $nsIndex !== NS_PROJECT ) {
                        $this->parent->showError( 'config-ns-conflict', $name );
                        $retVal = false;
                }
@@ -812,13 +814,13 @@ class WebInstaller_Name extends WebInstallerPage {
 
                // Validate e-mail if provided
                $email = $this->getVar( '_AdminEmail' );
-               if( $email && !Sanitizer::validateEmail( $email ) ) {
+               if ( $email && !Sanitizer::validateEmail( $email ) ) {
                        $this->parent->showError( 'config-admin-error-bademail' );
                        $retVal = false;
                }
                // If they asked to subscribe to mediawiki-announce but didn't give
                // an e-mail, show an error. Bug 29332
-               if( !$email && $this->getVar( '_Subscribe' ) ) {
+               if ( !$email && $this->getVar( '_Subscribe' ) ) {
                        $this->parent->showError( 'config-subscribe-noemail' );
                        $retVal = false;
                }
@@ -911,10 +913,10 @@ class WebInstaller_Options extends WebInstallerPage {
 
                $extensions = $this->parent->findExtensions();
 
-               if( $extensions ) {
+               if ( $extensions ) {
                        $extHtml = $this->getFieldSetStart( 'config-extensions' );
 
-                       foreach( $extensions as $ext ) {
+                       foreach ( $extensions as $ext ) {
                                $extHtml .= $this->parent->getCheckBox( array(
                                        'var' => "ext-$ext",
                                        'rawtext' => $ext,
@@ -974,7 +976,7 @@ class WebInstaller_Options extends WebInstallerPage {
                );
 
                $caches = array( 'none' );
-               if( count( $this->getVar( '_Caches' ) ) ) {
+               if ( count( $this->getVar( '_Caches' ) ) ) {
                        $caches[] = 'accel';
                }
                $caches[] = 'memcached';
@@ -987,7 +989,7 @@ class WebInstaller_Options extends WebInstallerPage {
                        // or going back!
                        $cacheval = 'none';
                }
-               $hidden = ($cacheval == 'memcached') ? '' : 'display: none';
+               $hidden = ( $cacheval == 'memcached' ) ? '' : 'display: none';
                $this->addHTML(
                        # Advanced settings
                        $this->getFieldSetStart( 'config-advanced-settings' ) .
@@ -1054,7 +1056,7 @@ class WebInstaller_Options extends WebInstallerPage {
                } else {
                        $iframeAttribs['src'] = $this->getCCPartnerUrl();
                }
-               $wrapperStyle = ($this->getVar( '_LicenseCode' ) == 'cc-choose') ? '' : 'display: none';
+               $wrapperStyle = ( $this->getVar( '_LicenseCode' ) == 'cc-choose' ) ? '' : 'display: none';
 
                return "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"$wrapperStyle\">\n" .
                        Html::element( 'iframe', $iframeAttribs, '', false /* not short */ ) .
@@ -1139,31 +1141,31 @@ class WebInstaller_Options extends WebInstallerPage {
 
                $extsAvailable = $this->parent->findExtensions();
                $extsToInstall = array();
-               foreach( $extsAvailable as $ext ) {
-                       if( $this->parent->request->getCheck( 'config_ext-' . $ext ) ) {
+               foreach ( $extsAvailable as $ext ) {
+                       if ( $this->parent->request->getCheck( 'config_ext-' . $ext ) ) {
                                $extsToInstall[] = $ext;
                        }
                }
                $this->parent->setVar( '_Extensions', $extsToInstall );
 
-               if( $this->getVar( 'wgMainCacheType' ) == 'memcached' ) {
+               if ( $this->getVar( 'wgMainCacheType' ) == 'memcached' ) {
                        $memcServers = explode( "\n", $this->getVar( '_MemCachedServers' ) );
-                       if( !$memcServers ) {
+                       if ( !$memcServers ) {
                                $this->parent->showError( 'config-memcache-needservers' );
                                return false;
                        }
 
-                       foreach( $memcServers as $server ) {
+                       foreach ( $memcServers as $server ) {
                                $memcParts = explode( ":", $server, 2 );
                                if ( !isset( $memcParts[0] )
                                                || ( !IP::isValid( $memcParts[0] )
                                                        && ( gethostbyname( $memcParts[0] ) == $memcParts[0] ) ) ) {
                                        $this->parent->showError( 'config-memcache-badip', $memcParts[0] );
                                        return false;
-                               } elseif( !isset( $memcParts[1] )  ) {
+                               } elseif ( !isset( $memcParts[1] ) ) {
                                        $this->parent->showError( 'config-memcache-noport', $memcParts[0] );
                                        return false;
-                               } elseif( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
+                               } elseif ( $memcParts[1] < 1 || $memcParts[1] > 65535 ) {
                                        $this->parent->showError( 'config-memcache-badport', 1, 65535 );
                                        return false;
                                }
@@ -1180,11 +1182,11 @@ class WebInstaller_Install extends WebInstallerPage {
        }
 
        public function execute() {
-               if( $this->getVar( '_UpgradeDone' ) ) {
+               if ( $this->getVar( '_UpgradeDone' ) ) {
                        return 'skip';
-               } elseif( $this->getVar( '_InstallDone' ) ) {
+               } elseif ( $this->getVar( '_InstallDone' ) ) {
                        return 'continue';
-               } elseif( $this->parent->request->wasPosted() ) {
+               } elseif ( $this->parent->request->wasPosted() ) {
                        $this->startForm();
                        $this->addHTML( "<ul>" );
                        $results = $this->parent->performInstallation(
@@ -1227,7 +1229,7 @@ class WebInstaller_Install extends WebInstallerPage {
                        $html = "<span class=\"error\">$html</span>";
                }
                $this->addHTML( $html . "</li>\n" );
-               if( !$status->isGood() ) {
+               if ( !$status->isGood() ) {
                        $this->parent->showStatusBox( $status );
                }
        }
@@ -1302,7 +1304,7 @@ abstract class WebInstaller_Document extends WebInstallerPage {
 
        public function getFileContents() {
                $file = __DIR__ . '/../../' . $this->getFileName();
-               if( ! file_exists( $file ) ) {
+               if ( ! file_exists( $file ) ) {
                        return wfMessage( 'config-nofile', $file )->plain();
                }
                return file_get_contents( $file );
@@ -1320,7 +1322,7 @@ class WebInstaller_ReleaseNotes extends WebInstaller_Document {
        protected function getFileName() {
                global $wgVersion;
 
-               if( !preg_match( '/^(\d+)\.(\d+).*/i', $wgVersion, $result ) ) {
+               if ( !preg_match( '/^(\d+)\.(\d+).*/i', $wgVersion, $result ) ) {
                        throw new MWException( 'Variable $wgVersion has an invalid value.' );
                }
 
index e1bacf3..99b7741 100644 (file)
@@ -58,7 +58,7 @@ class BmpHandler extends BitmapHandler {
         */
        function getImageSize( $image, $filename ) {
                $f = fopen( $filename, 'rb' );
-               if( !$f ) {
+               if ( !$f ) {
                        return false;
                }
                $header = fread( $f, 54 );
index 1d8337d..1ce3d5e 100644 (file)
@@ -398,7 +398,7 @@ class BitmapHandler extends ImageHandler {
                                        $im->sharpenImage( $radius, $sigma );
                                }
                                $im->setCompressionQuality( 80 );
-                       } elseif( $params['mimeType'] == 'image/png' ) {
+                       } elseif ( $params['mimeType'] == 'image/png' ) {
                                $im->setCompressionQuality( 95 );
                        } elseif ( $params['mimeType'] == 'image/gif' ) {
                                if ( $this->getImageArea( $image ) > $wgMaxAnimatedGifArea ) {
index 3876c52..555a414 100644 (file)
@@ -156,7 +156,7 @@ class BitmapMetadataHandler {
                        $meta->addMetadata( Array( 'JPEGFileComment' => $seg['COM'] ), 'native' );
                }
                if ( isset( $seg['PSIR'] ) && count( $seg['PSIR'] ) > 0 ) {
-                       foreach( $seg['PSIR'] as $curPSIRValue ) {
+                       foreach ( $seg['PSIR'] as $curPSIRValue ) {
                                $meta->doApp13( $curPSIRValue );
                        }
                }
@@ -286,7 +286,9 @@ class BitmapMetadataHandler {
         */
        static function getTiffByteOrder( $filename ) {
                $fh = fopen( $filename, 'rb' );
-               if ( !$fh ) return false;
+               if ( !$fh ) {
+                       return false;
+               }
                $head = fread( $fh, 2 );
                fclose( $fh );
 
index a7aa82f..8d4e033 100644 (file)
@@ -246,12 +246,11 @@ class DjVuHandler extends ImageHandler {
                        $image->dejaMetaTree = false;
                        $image->djvuTextTree = false;
                        $tree = new SimpleXMLElement( $metadata );
-                       if( $tree->getName() == 'mw-djvu' ) {
-                               foreach( $tree->children() as $b ) {
-                                       if( $b->getName() == 'DjVuTxt' ) {
+                       if ( $tree->getName() == 'mw-djvu' ) {
+                               foreach ( $tree->children() as $b ) {
+                                       if ( $b->getName() == 'DjVuTxt' ) {
                                                $image->djvuTextTree = $b;
-                                       }
-                                       elseif ( $b->getName() == 'DjVuXML' ) {
+                                       } elseif ( $b->getName() == 'DjVuXML' ) {
                                                $image->dejaMetaTree = $b;
                                        }
                                }
@@ -263,7 +262,7 @@ class DjVuHandler extends ImageHandler {
                }
                wfRestoreWarnings();
                wfProfileOut( __METHOD__ );
-               if( $gettext ) {
+               if ( $gettext ) {
                        return $image->djvuTextTree;
                } else {
                        return $image->dejaMetaTree;
index 5d31898..54efe7a 100644 (file)
@@ -64,7 +64,7 @@ class DjVuImage {
        public function getImageSize() {
                $data = $this->getInfo();
 
-               if( $data !== false ) {
+               if ( $data !== false ) {
                        $width = $data['width'];
                        $height = $data['height'];
 
@@ -93,20 +93,20 @@ class DjVuImage {
                $start = ftell( $file );
                $secondary = fread( $file, 4 );
                echo str_repeat( ' ', $indent * 4 ) . "($secondary)\n";
-               while( ftell( $file ) - $start < $length ) {
+               while ( ftell( $file ) - $start < $length ) {
                        $chunkHeader = fread( $file, 8 );
-                       if( $chunkHeader == '' ) {
+                       if ( $chunkHeader == '' ) {
                                break;
                        }
                        // @todo FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
                        extract( unpack( 'a4chunk/NchunkLength', $chunkHeader ) );
                        echo str_repeat( ' ', $indent * 4 ) . "$chunk $chunkLength\n";
 
-                       if( $chunk == 'FORM' ) {
+                       if ( $chunk == 'FORM' ) {
                                $this->dumpForm( $file, $chunkLength, $indent + 1 );
                        } else {
                                fseek( $file, $chunkLength, SEEK_CUR );
-                               if( $chunkLength & 1 == 1 ) {
+                               if ( $chunkLength & 1 == 1 ) {
                                        // Padding byte between chunks
                                        fseek( $file, 1, SEEK_CUR );
                                }
@@ -118,7 +118,7 @@ class DjVuImage {
                wfSuppressWarnings();
                $file = fopen( $this->mFilename, 'rb' );
                wfRestoreWarnings();
-               if( $file === false ) {
+               if ( $file === false ) {
                        wfDebug( __METHOD__ . ": missing or failed file read\n" );
                        return false;
                }
@@ -126,21 +126,21 @@ class DjVuImage {
                $header = fread( $file, 16 );
                $info = false;
 
-               if( strlen( $header ) < 16 ) {
+               if ( strlen( $header ) < 16 ) {
                        wfDebug( __METHOD__ . ": too short file header\n" );
                } else {
                        // @todo FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
                        extract( unpack( 'a4magic/a4form/NformLength/a4subtype', $header ) );
 
-                       if( $magic != 'AT&T' ) {
+                       if ( $magic != 'AT&T' ) {
                                wfDebug( __METHOD__ . ": not a DjVu file\n" );
-                       } elseif( $subtype == 'DJVU' ) {
+                       } elseif ( $subtype == 'DJVU' ) {
                                // Single-page document
                                $info = $this->getPageInfo( $file, $formLength );
-                       } elseif( $subtype == 'DJVM' ) {
+                       } elseif ( $subtype == 'DJVM' ) {
                                // Multi-page document
                                $info = $this->getMultiPageInfo( $file, $formLength );
-                       } else  {
+                       } else {
                                wfDebug( __METHOD__ . ": unrecognized DJVU file type '$formType'\n" );
                        }
                }
@@ -150,7 +150,7 @@ class DjVuImage {
 
        private function readChunk( $file ) {
                $header = fread( $file, 8 );
-               if( strlen( $header ) < 8 ) {
+               if ( strlen( $header ) < 8 ) {
                        return array( false, 0 );
                } else {
                        // @todo FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
@@ -162,7 +162,7 @@ class DjVuImage {
        private function skipChunk( $file, $chunkLength ) {
                fseek( $file, $chunkLength, SEEK_CUR );
 
-               if( $chunkLength & 0x01 == 1 && !feof( $file ) ) {
+               if ( $chunkLength & 0x01 == 1 && !feof( $file ) ) {
                        // padding byte
                        fseek( $file, 1, SEEK_CUR );
                }
@@ -174,13 +174,13 @@ class DjVuImage {
                $start = ftell( $file );
                do {
                        list( $chunk, $length ) = $this->readChunk( $file );
-                       if( !$chunk ) {
+                       if ( !$chunk ) {
                                break;
                        }
 
-                       if( $chunk == 'FORM' ) {
+                       if ( $chunk == 'FORM' ) {
                                $subtype = fread( $file, 4 );
-                               if( $subtype == 'DJVU' ) {
+                               if ( $subtype == 'DJVU' ) {
                                        wfDebug( __METHOD__ . ": found first subpage\n" );
                                        return $this->getPageInfo( $file, $length );
                                }
@@ -189,7 +189,7 @@ class DjVuImage {
                                wfDebug( __METHOD__ . ": skipping '$chunk' chunk\n" );
                                $this->skipChunk( $file, $length );
                        }
-               } while( $length != 0 && !feof( $file ) && ftell( $file ) - $start < $formLength );
+               } while ( $length != 0 && !feof( $file ) && ftell( $file ) - $start < $formLength );
 
                wfDebug( __METHOD__ . ": multi-page DJVU file contained no pages\n" );
                return false;
@@ -197,17 +197,17 @@ class DjVuImage {
 
        private function getPageInfo( $file, $formLength ) {
                list( $chunk, $length ) = $this->readChunk( $file );
-               if( $chunk != 'INFO' ) {
+               if ( $chunk != 'INFO' ) {
                        wfDebug( __METHOD__ . ": expected INFO chunk, got '$chunk'\n" );
                        return false;
                }
 
-               if( $length < 9 ) {
+               if ( $length < 9 ) {
                        wfDebug( __METHOD__ . ": INFO should be 9 or 10 bytes, found $length\n" );
                        return false;
                }
                $data = fread( $file, $length );
-               if( strlen( $data ) < $length ) {
+               if ( strlen( $data ) < $length ) {
                        wfDebug( __METHOD__ . ": INFO chunk cut off\n" );
                        return false;
                }
@@ -263,7 +263,7 @@ class DjVuImage {
                        $retval = '';
                        $txt = wfShellExec( $cmd, $retval, array(), array( 'memory' => self::DJVUTXT_MEMORY_LIMIT ) );
                        wfProfileOut( 'djvutxt' );
-                       if( $retval == 0 ) {
+                       if ( $retval == 0 ) {
                                # Strip some control characters
                                $txt = preg_replace( "/[\013\035\037]/", "", $txt );
                                $reg = <<<EOR
index 5581503..6058f45 100644 (file)
@@ -297,7 +297,7 @@ class Exif {
                }
 
                $this->debugFile( $this->basename, __FUNCTION__, true );
-               if( function_exists( 'exif_read_data' ) ) {
+               if ( function_exists( 'exif_read_data' ) ) {
                        wfSuppressWarnings();
                        $data = exif_read_data( $this->file, 0, true );
                        wfRestoreWarnings();
@@ -738,19 +738,20 @@ class Exif {
                $debug = "tag is '$tag'";
                $etype = $this->mExifTags[$section][$tag];
                $ecount = 1;
-               if( is_array( $etype ) ) {
+               if ( is_array( $etype ) ) {
                        list( $etype, $ecount ) = $etype;
-                       if ( $recursive )
+                       if ( $recursive ) {
                                $ecount = 1; // checking individual elements
+                       }
                }
                $count = count( $val );
-               if( $ecount != $count ) {
+               if ( $ecount != $count ) {
                        $this->debug( $val, __FUNCTION__, "Expected $ecount elements for $tag but got $count" );
                        return false;
                }
-               if( $count > 1 ) {
-                       foreach( $val as $v ) {
-                               if( !$this->validate( $section, $tag, $v, true ) ) {
+               if ( $count > 1 ) {
+                       foreach ( $val as $v ) {
+                               if ( !$this->validate( $section, $tag, $v, true ) ) {
                                        return false;
                                }
                        }
index 5bcb484..3d153eb 100644 (file)
@@ -307,11 +307,11 @@ class FormatMetadata {
 
                                case 'Flash':
                                        $flashDecode = array(
-                                               'fired'    => $val & bindec( '00000001' ),
-                                               'return'   => ( $val & bindec( '00000110' ) ) >> 1,
-                                               'mode'     => ( $val & bindec( '00011000' ) ) >> 3,
+                                               'fired' => $val & bindec( '00000001' ),
+                                               'return' => ( $val & bindec( '00000110' ) ) >> 1,
+                                               'mode' => ( $val & bindec( '00011000' ) ) >> 3,
                                                'function' => ( $val & bindec( '00100000' ) ) >> 5,
-                                               'redeye'   => ( $val & bindec( '01000000' ) ) >> 6,
+                                               'redeye' => ( $val & bindec( '01000000' ) ) >> 6,
 //                                             'reserved' => ($val & bindec( '10000000' )) >> 7,
                                        );
                                        $flashMsgs = array();
@@ -1015,8 +1015,9 @@ class FormatMetadata {
        static function msg( $tag, $val, $arg = null, $arg2 = null ) {
                global $wgContLang;
 
-               if ( $val === '' )
+               if ( $val === '' ) {
                        $val = 'value';
+               }
                return wfMessage( $wgContLang->lc( "exif-$tag-$val" ), $arg, $arg2 )->text();
        }
 
@@ -1031,9 +1032,9 @@ class FormatMetadata {
        static function formatNum( $num, $round = false ) {
                global $wgLang;
                $m = array();
-               if( is_array( $num ) ) {
+               if ( is_array( $num ) ) {
                        $out = array();
-                       foreach( $num as $number ) {
+                       foreach ( $num as $number ) {
                                $out[] = self::formatNum( $number );
                        }
                        return $wgLang->commaList( $out );
@@ -1071,7 +1072,7 @@ class FormatMetadata {
                        $numerator = intval( $m[1] );
                        $denominator = intval( $m[2] );
                        $gcd = self::gcd( abs( $numerator ), $denominator );
-                       if( $gcd != 0 ) {
+                       if ( $gcd != 0 ) {
                                // 0 shouldn't happen! ;)
                                return self::formatNum( $numerator / $gcd ) . '/' . self::formatNum( $denominator / $gcd );
                        }
@@ -1096,7 +1097,7 @@ class FormatMetadata {
                        else
                                return gcd( $b, $a % $b );
                */
-               while( $b != 0 ) {
+               while ( $b != 0 ) {
                        $remainder = $a % $b;
 
                        // tail recursion...
@@ -1236,7 +1237,7 @@ class FormatMetadata {
         * @return String of html-ish looking wikitext
         */
        public static function collapseContactInfo( $vals ) {
-               if( !( isset( $vals['CiAdrExtadr'] )
+               if ( !( isset( $vals['CiAdrExtadr'] )
                        || isset( $vals['CiAdrCity'] )
                        || isset( $vals['CiAdrCtry'] )
                        || isset( $vals['CiEmailWork'] )
@@ -1254,7 +1255,7 @@ class FormatMetadata {
                        // because people often insert >, etc into
                        // the metadata which should not be interpreted
                        // but we still want to auto-link urls.
-                       foreach( $vals as &$val ) {
+                       foreach ( $vals as &$val ) {
                                $val = htmlspecialchars( $val );
                        }
                        return self::flattenArray( $vals );
index 2e532fe..4bb7208 100644 (file)
@@ -86,7 +86,7 @@ class GIFHandler extends BitmapHandler {
                $ser = $image->getMetadata();
                if ( $ser ) {
                        $metadata = unserialize( $ser );
-                       if( $metadata['frameCount'] > 1 ) {
+                       if ( $metadata['frameCount'] > 1 ) {
                                return true;
                        }
                }
index 6a46cc0..968a2cd 100644 (file)
@@ -90,7 +90,7 @@ class GIFMetadataExtractor {
                // Skip over the GCT
                self::readGCT( $fh, $bpp );
 
-               while( !feof( $fh ) ) {
+               while ( !feof( $fh ) ) {
                        $buf = fread( $fh, 1 );
 
                        if ( $buf == self::$gif_frame_sep ) {
@@ -110,7 +110,9 @@ class GIFMetadataExtractor {
                                self::skipBlock( $fh );
                        } elseif ( $buf == self::$gif_extension_sep ) {
                                $buf = fread( $fh, 1 );
-                               if ( strlen( $buf ) < 1 ) throw new Exception( "Ran out of input" );
+                               if ( strlen( $buf ) < 1 ) {
+                                       throw new Exception( "Ran out of input" );
+                               }
                                $extension_code = unpack( 'C', $buf );
                                $extension_code = $extension_code[1];
 
@@ -121,7 +123,9 @@ class GIFMetadataExtractor {
                                        fread( $fh, 1 ); // Transparency, disposal method, user input
 
                                        $buf = fread( $fh, 2 ); // Delay, in hundredths of seconds.
-                                       if ( strlen( $buf ) < 2 ) throw new Exception( "Ran out of input" );
+                                       if ( strlen( $buf ) < 2 ) {
+                                               throw new Exception( "Ran out of input" );
+                                       }
                                        $delay = unpack( 'v', $buf );
                                        $delay = $delay[1];
                                        $duration += $delay * 0.01;
@@ -129,7 +133,9 @@ class GIFMetadataExtractor {
                                        fread( $fh, 1 ); // Transparent colour index
 
                                        $term = fread( $fh, 1 ); // Should be a terminator
-                                       if ( strlen( $term ) < 1 ) throw new Exception( "Ran out of input" );
+                                       if ( strlen( $term ) < 1 ) {
+                                               throw new Exception( "Ran out of input" );
+                                       }
                                        $term = unpack( 'C', $term );
                                        $term = $term[1];
                                        if ( $term != 0 ) {
@@ -168,7 +174,9 @@ class GIFMetadataExtractor {
                                        // Application extension (Netscape info about the animated gif)
                                        // or XMP (or theoretically any other type of extension block)
                                        $blockLength = fread( $fh, 1 );
-                                       if ( strlen( $blockLength ) < 1 ) throw new Exception( "Ran out of input" );
+                                       if ( strlen( $blockLength ) < 1 ) {
+                                               throw new Exception( "Ran out of input" );
+                                       }
                                        $blockLength = unpack( 'C', $blockLength );
                                        $blockLength = $blockLength[1];
                                        $data = fread( $fh, $blockLength );
@@ -190,7 +198,9 @@ class GIFMetadataExtractor {
 
                                                // Unsigned little-endian integer, loop count or zero for "forever"
                                                $loopData = fread( $fh, 2 );
-                                               if ( strlen( $loopData ) < 2 ) throw new Exception( "Ran out of input" );
+                                               if ( strlen( $loopData ) < 2 ) {
+                                                       throw new Exception( "Ran out of input" );
+                                               }
                                                $loopData = unpack( 'v', $loopData );
                                                $loopCount = $loopData[1];
 
@@ -228,7 +238,9 @@ class GIFMetadataExtractor {
                        } elseif ( $buf == self::$gif_term ) {
                                break;
                        } else {
-                               if ( strlen( $buf ) < 1 ) throw new Exception( "Ran out of input" );
+                               if ( strlen( $buf ) < 1 ) {
+                                       throw new Exception( "Ran out of input" );
+                               }
                                $byte = unpack( 'C', $buf );
                                $byte = $byte[1];
                                throw new Exception( "At position: " . ftell( $fh ) . ", Unknown byte " . $byte );
@@ -251,7 +263,7 @@ class GIFMetadataExtractor {
         */
        static function readGCT( $fh, $bpp ) {
                if ( $bpp > 0 ) {
-                       for( $i = 1; $i <= pow( 2, $bpp ); ++$i ) {
+                       for ( $i = 1; $i <= pow( 2, $bpp ); ++$i ) {
                                fread( $fh, 3 );
                        }
                }
@@ -263,7 +275,9 @@ class GIFMetadataExtractor {
         * @return int
         */
        static function decodeBPP( $data ) {
-               if ( strlen( $data ) < 1 ) throw new Exception( "Ran out of input" );
+               if ( strlen( $data ) < 1 ) {
+                       throw new Exception( "Ran out of input" );
+               }
                $buf = unpack( 'C', $data );
                $buf = $buf[1];
                $bpp = ( $buf & 7 ) + 1;
@@ -281,7 +295,9 @@ class GIFMetadataExtractor {
        static function skipBlock( $fh ) {
                while ( !feof( $fh ) ) {
                        $buf = fread( $fh, 1 );
-                       if ( strlen( $buf ) < 1 ) throw new Exception( "Ran out of input" );
+                       if ( strlen( $buf ) < 1 ) {
+                               throw new Exception( "Ran out of input" );
+                       }
                        $block_len = unpack( 'C', $buf );
                        $block_len = $block_len[1];
                        if ( $block_len == 0 ) {
@@ -310,7 +326,7 @@ class GIFMetadataExtractor {
                $subLength = fread( $fh, 1 );
                $blocks = 0;
 
-               while( $subLength !== "\0" ) {
+               while ( $subLength !== "\0" ) {
                        $blocks++;
                        if ( $blocks > self::MAX_SUBBLOCKS ) {
                                throw new Exception( "MAX_SUBBLOCKS exceeded (over $blocks sub-blocks)" );
index d2bf1f3..8e46f2f 100644 (file)
@@ -92,7 +92,7 @@ abstract class ImageHandler extends MediaHandler {
 
                if ( !isset( $params['page'] ) ) {
                        $params['page'] = 1;
-               } else  {
+               } else {
                        if ( $params['page'] > $image->pageCount() ) {
                                $params['page'] = $image->pageCount();
                        }
@@ -160,7 +160,7 @@ abstract class ImageHandler extends MediaHandler {
                $width = intval( $width );
 
                # Sanity check $width
-               if( $width <= 0 ) {
+               if ( $width <= 0 ) {
                        wfDebug( __METHOD__ . ": Invalid destination width: $width\n" );
                        return false;
                }
@@ -189,7 +189,7 @@ abstract class ImageHandler extends MediaHandler {
                }
                $url = wfAppendQuery( $script, $this->getScriptParams( $params ) );
 
-               if( $image->mustRender() || $params['width'] < $image->getWidth() ) {
+               if ( $image->mustRender() || $params['width'] < $image->getWidth() ) {
                        return new ThumbnailImage( $image, $url, false, $params );
                }
        }
index cb0fbb3..1feb378 100644 (file)
@@ -71,7 +71,7 @@ class JpegHandler extends ExifBitmapHandler {
 
                $rotation = ( $params['rotation'] + $this->getRotation( $file ) ) % 360;
 
-               if( $wgJpegTran && is_file( $wgJpegTran ) ) {
+               if ( $wgJpegTran && is_file( $wgJpegTran ) ) {
                        $cmd = wfEscapeShellArg( $wgJpegTran ) .
                                " -rotate " . wfEscapeShellArg( $rotation ) .
                                " -outfile " . wfEscapeShellArg( $params['dstPath'] ) .
index 121652f..5165760 100644 (file)
@@ -87,7 +87,7 @@ class JpegMetadataExtractor {
                        }
 
                        $buffer = fread( $fh, 1 );
-                       while( $buffer === "\xFF" && !feof( $fh ) ) {
+                       while ( $buffer === "\xFF" && !feof( $fh ) ) {
                                // Skip through any 0xFF padding bytes.
                                $buffer = fread( $fh, 1 );
                        }
@@ -155,7 +155,9 @@ class JpegMetadataExtractor {
                        } else {
                                // segment we don't care about, so skip
                                $size = wfUnpack( "nint", fread( $fh, 2 ), 2 );
-                               if ( $size['int'] <= 2 ) throw new MWException( "invalid marker size in jpeg" );
+                               if ( $size['int'] <= 2 ) {
+                                       throw new MWException( "invalid marker size in jpeg" );
+                               }
                                fseek( $fh, $size['int'] - 2, SEEK_CUR );
                        }
 
@@ -243,7 +245,9 @@ class JpegMetadataExtractor {
                        // PHP can take issue with very large unsigned ints and make them negative.
                        // Which should never ever happen, as this has to be inside a segment
                        // which is limited to a 16 bit number.
-                       if ( $lenData['len'] < 0 ) throw new MWException( "Too big PSIR (" . $lenData['len'] . ')' );
+                       if ( $lenData['len'] < 0 ) {
+                               throw new MWException( "Too big PSIR (" . $lenData['len'] . ')' );
+                       }
 
                        $offset += 4; // 4bytes length field;
 
@@ -267,7 +271,9 @@ class JpegMetadataExtractor {
 
                        // if odd, add 1 to length to account for
                        // null pad byte.
-                       if ( $lenData['len'] % 2 == 1 ) $lenData['len']++;
+                       if ( $lenData['len'] % 2 == 1 ) {
+                               $lenData['len']++;
+                       }
                        $offset += $lenData['len'];
 
                }
index b67f3d3..b368906 100644 (file)
@@ -116,7 +116,9 @@ abstract class MediaHandler {
         * @param string $path the filename
         * @return String
         */
-       function getMetadata( $image, $path ) { return ''; }
+       function getMetadata( $image, $path ) {
+               return '';
+       }
 
        /**
         * Get metadata version.
@@ -166,7 +168,9 @@ abstract class MediaHandler {
         *
         * @return string
         */
-       function getMetadataType( $image ) { return false; }
+       function getMetadataType( $image ) {
+               return false;
+       }
 
        /**
         * Check if the metadata string is valid for this handler.
@@ -255,46 +259,69 @@ abstract class MediaHandler {
         * True if the handled types can be transformed
         * @return bool
         */
-       function canRender( $file ) { return true; }
+       function canRender( $file ) {
+               return true;
+       }
+
        /**
         * True if handled types cannot be displayed directly in a browser
         * but can be rendered
         * @return bool
         */
-       function mustRender( $file ) { return false; }
+       function mustRender( $file ) {
+               return false;
+       }
+
        /**
         * True if the type has multi-page capabilities
         * @return bool
         */
-       function isMultiPage( $file ) { return false; }
+       function isMultiPage( $file ) {
+               return false;
+       }
+
        /**
         * Page count for a multi-page document, false if unsupported or unknown
         * @return bool
         */
-       function pageCount( $file ) { return false; }
+       function pageCount( $file ) {
+               return false;
+       }
+
        /**
         * The material is vectorized and thus scaling is lossless
         * @return bool
         */
-       function isVectorized( $file ) { return false; }
+       function isVectorized( $file ) {
+               return false;
+       }
+
        /**
         * The material is an image, and is animated.
         * In particular, video material need not return true.
         * @note Before 1.20, this was a method of ImageHandler only
         * @return bool
         */
-       function isAnimatedImage( $file ) { return false; }
+       function isAnimatedImage( $file ) {
+               return false;
+       }
+
        /**
         * If the material is animated, we can animate the thumbnail
         * @since 1.20
         * @return bool If material is not animated, handler may return any value.
         */
-       function canAnimateThumbnail( $file ) { return true; }
+       function canAnimateThumbnail( $file ) {
+               return true;
+       }
+
        /**
         * False if the handler is disabled for all files
         * @return bool
         */
-       function isEnabled() { return true; }
+       function isEnabled() {
+               return true;
+       }
 
        /**
         * Get an associative array of page dimensions
@@ -394,9 +421,9 @@ abstract class MediaHandler {
        function visibleMetadataFields() {
                $fields = array();
                $lines = explode( "\n", wfMessage( 'metadata-fields' )->inContentLanguage()->text() );
-               foreach( $lines as $line ) {
+               foreach ( $lines as $line ) {
                        $matches = array();
-                       if( preg_match( '/^\\*\s*(.*?)\s*$/', $line, $matches ) ) {
+                       if ( preg_match( '/^\\*\s*(.*?)\s*$/', $line, $matches ) ) {
                                $fields[] = $matches[1];
                        }
                }
@@ -496,7 +523,7 @@ abstract class MediaHandler {
        public static function fitBoxWidth( $boxWidth, $boxHeight, $maxHeight ) {
                $idealWidth = $boxWidth * $maxHeight / $boxHeight;
                $roundedUp = ceil( $idealWidth );
-               if( round( $roundedUp * $boxHeight / $boxWidth ) > $maxHeight ) {
+               if ( round( $roundedUp * $boxHeight / $boxWidth ) > $maxHeight ) {
                        return floor( $idealWidth );
                } else {
                        return $roundedUp;
@@ -535,9 +562,9 @@ abstract class MediaHandler {
         * @return bool True if removed, false otherwise
         */
        function removeBadFile( $dstPath, $retval = 0 ) {
-               if( file_exists( $dstPath ) ) {
+               if ( file_exists( $dstPath ) ) {
                        $thumbstat = stat( $dstPath );
-                       if( $thumbstat['size'] == 0 || $retval != 0 ) {
+                       if ( $thumbstat['size'] == 0 || $retval != 0 ) {
                                $result = unlink( $dstPath );
 
                                if ( $result ) {
index 2616edb..1d197b1 100644 (file)
@@ -205,7 +205,7 @@ abstract class MediaTransformOutput {
                if ( $this->page && $this->page !== 1 ) {
                        $query = 'page=' . urlencode( $this->page );
                }
-               if( $params ) {
+               if ( $params ) {
                        $query .= $query ? '&' . $params : $params;
                }
                $attribs = array(
@@ -242,7 +242,7 @@ class ThumbnailImage extends MediaTransformOutput {
                # Previous parameters:
                #   $file, $url, $width, $height, $path = false, $page = false
 
-               if( is_array( $parameters ) ) {
+               if ( is_array( $parameters ) ) {
                        $defaults = array(
                                'page' => false
                        );
index b8a5b40..9dfd5d1 100644 (file)
@@ -76,7 +76,9 @@ class PNGHandler extends BitmapHandler {
                $ser = $image->getMetadata();
                if ( $ser ) {
                        $metadata = unserialize( $ser );
-                       if( $metadata['frameCount'] > 1 ) return true;
+                       if ( $metadata['frameCount'] > 1 ) {
+                               return true;
+                       }
                }
                return false;
        }
@@ -129,8 +131,9 @@ class PNGHandler extends BitmapHandler {
                $metadata = unserialize( $image->getMetadata() );
                wfRestoreWarnings();
 
-               if( !$metadata || $metadata['frameCount'] <= 0 )
+               if ( !$metadata || $metadata['frameCount'] <= 0 ) {
                        return $original;
+               }
 
                $info = array();
                $info[] = $original;
index e65a558..d2e2cc9 100644 (file)
@@ -142,7 +142,7 @@ class PNGMetadataExtractor {
                                }
                        } elseif ( $chunk_type == "acTL" ) {
                                $buf = fread( $fh, $chunk_size );
-                               if( !$buf || strlen( $buf ) < $chunk_size || $chunk_size < 4 ) {
+                               if ( !$buf || strlen( $buf ) < $chunk_size || $chunk_size < 4 ) {
                                        throw new Exception( __METHOD__ . ": Read error" );
                                }
 
index cddab51..423e756 100644 (file)
@@ -56,7 +56,7 @@ class SvgHandler extends ImageHandler {
                $metadata = $file->getMetadata();
                if ( $metadata ) {
                        $metadata = $this->unpackMetadata( $metadata );
-                       if( isset( $metadata['animated'] ) ) {
+                       if ( isset( $metadata['animated'] ) ) {
                                return $metadata['animated'];
                        }
                }
@@ -267,7 +267,7 @@ class SvgHandler extends ImageHandler {
                        // File not found, broken, etc.
                        $metadata['error'] = array(
                                'message' => $e->getMessage(),
-                               'code'    => $e->getCode()
+                               'code' => $e->getCode()
                        );
                        wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
                }
index 592403a..c9a20f2 100644 (file)
@@ -128,7 +128,7 @@ class SVGReader {
                $keepReading = $this->reader->read();
 
                /* Skip until first element */
-               while( $keepReading && $this->reader->nodeType != XmlReader::ELEMENT ) {
+               while ( $keepReading && $this->reader->nodeType != XmlReader::ELEMENT ) {
                        $keepReading = $this->reader->read();
                }
 
@@ -187,14 +187,14 @@ class SVGReader {
         */
        private function readField( $name, $metafield = null ) {
                $this->debug( "Read field $metafield" );
-               if( !$metafield || $this->reader->nodeType != XmlReader::ELEMENT ) {
+               if ( !$metafield || $this->reader->nodeType != XmlReader::ELEMENT ) {
                        return;
                }
                $keepReading = $this->reader->read();
-               while( $keepReading ) {
-                       if( $this->reader->localName == $name && $this->reader->namespaceURI == self::NS_SVG && $this->reader->nodeType == XmlReader::END_ELEMENT ) {
+               while ( $keepReading ) {
+                       if ( $this->reader->localName == $name && $this->reader->namespaceURI == self::NS_SVG && $this->reader->nodeType == XmlReader::END_ELEMENT ) {
                                break;
-                       } elseif( $this->reader->nodeType == XmlReader::TEXT ) {
+                       } elseif ( $this->reader->nodeType == XmlReader::TEXT ) {
                                $this->metadata[$metafield] = trim( $this->reader->value );
                        }
                        $keepReading = $this->reader->read();
@@ -209,11 +209,11 @@ class SVGReader {
         */
        private function readXml( $metafield = null ) {
                $this->debug( "Read top level metadata" );
-               if( !$metafield || $this->reader->nodeType != XmlReader::ELEMENT ) {
+               if ( !$metafield || $this->reader->nodeType != XmlReader::ELEMENT ) {
                        return;
                }
                // TODO: find and store type of xml snippet. metadata['metadataType'] = "rdf"
-               if( method_exists( $this->reader, 'readInnerXML' ) ) {
+               if ( method_exists( $this->reader, 'readInnerXML' ) ) {
                        $this->metadata[$metafield] = trim( $this->reader->readInnerXML() );
                } else {
                        throw new MWException( "The PHP XMLReader extension does not come with readInnerXML() method. Your libxml is probably out of date (need 2.6.20 or later)." );
@@ -228,7 +228,7 @@ class SVGReader {
         */
        private function animateFilter( $name ) {
                $this->debug( "animate filter for tag $name" );
-               if( $this->reader->nodeType != XmlReader::ELEMENT ) {
+               if ( $this->reader->nodeType != XmlReader::ELEMENT ) {
                        return;
                }
                if ( $this->reader->isEmptyElement ) {
@@ -236,8 +236,8 @@ class SVGReader {
                }
                $exitDepth = $this->reader->depth;
                $keepReading = $this->reader->read();
-               while( $keepReading ) {
-                       if( $this->reader->localName == $name && $this->reader->depth <= $exitDepth
+               while ( $keepReading ) {
+                       if ( $this->reader->localName == $name && $this->reader->depth <= $exitDepth
                                && $this->reader->nodeType == XmlReader::END_ELEMENT ) {
                                break;
                        } elseif ( $this->reader->namespaceURI == self::NS_SVG && $this->reader->nodeType == XmlReader::ELEMENT ) {
@@ -267,7 +267,7 @@ class SVGReader {
        }
 
        private function debug( $data ) {
-               if( $this->mDebug ) {
+               if ( $this->mDebug ) {
                        wfDebug( "SVGReader: $data\n" );
                }
        }
@@ -292,37 +292,37 @@ class SVGReader {
                $width = null;
                $height = null;
 
-               if( $this->reader->getAttribute( 'viewBox' ) ) {
+               if ( $this->reader->getAttribute( 'viewBox' ) ) {
                        // min-x min-y width height
                        $viewBox = preg_split( '/\s+/', trim( $this->reader->getAttribute( 'viewBox' ) ) );
-                       if( count( $viewBox ) == 4 ) {
+                       if ( count( $viewBox ) == 4 ) {
                                $viewWidth = $this->scaleSVGUnit( $viewBox[2] );
                                $viewHeight = $this->scaleSVGUnit( $viewBox[3] );
-                               if( $viewWidth > 0 && $viewHeight > 0 ) {
+                               if ( $viewWidth > 0 && $viewHeight > 0 ) {
                                        $aspect = $viewWidth / $viewHeight;
                                        $defaultHeight = $defaultWidth / $aspect;
                                }
                        }
                }
-               if( $this->reader->getAttribute( 'width' ) ) {
+               if ( $this->reader->getAttribute( 'width' ) ) {
                        $width = $this->scaleSVGUnit( $this->reader->getAttribute( 'width' ), $defaultWidth );
                        $this->metadata['originalWidth'] = $this->reader->getAttribute( 'width' );
                }
-               if( $this->reader->getAttribute( 'height' ) ) {
+               if ( $this->reader->getAttribute( 'height' ) ) {
                        $height = $this->scaleSVGUnit( $this->reader->getAttribute( 'height' ), $defaultHeight );
                        $this->metadata['originalHeight'] = $this->reader->getAttribute( 'height' );
                }
 
-               if( !isset( $width ) && !isset( $height ) ) {
+               if ( !isset( $width ) && !isset( $height ) ) {
                        $width = $defaultWidth;
                        $height = $width / $aspect;
-               } elseif( isset( $width ) && !isset( $height ) ) {
+               } elseif ( isset( $width ) && !isset( $height ) ) {
                        $height = $width / $aspect;
-               } elseif( isset( $height ) && !isset( $width ) ) {
+               } elseif ( isset( $height ) && !isset( $width ) ) {
                        $width = $height * $aspect;
                }
 
-               if( $width > 0 && $height > 0 ) {
+               if ( $width > 0 && $height > 0 ) {
                        $this->metadata['width'] = intval( round( $width ) );
                        $this->metadata['height'] = intval( round( $height ) );
                }
@@ -346,13 +346,13 @@ class SVGReader {
                        'in' => 90.0,
                        'em' => 16.0, // fake it?
                        'ex' => 12.0, // fake it?
-                       ''   => 1.0, // "User units" pixels by default
+                       '' => 1.0, // "User units" pixels by default
                        );
                $matches = array();
-               if( preg_match( '/^\s*(\d+(?:\.\d+)?)(em|ex|px|pt|pc|cm|mm|in|%|)\s*$/', $length, $matches ) ) {
+               if ( preg_match( '/^\s*(\d+(?:\.\d+)?)(em|ex|px|pt|pc|cm|mm|in|%|)\s*$/', $length, $matches ) ) {
                        $length = floatval( $matches[1] );
                        $unit = $matches[2];
-                       if( $unit == '%' ) {
+                       if ( $unit == '%' ) {
                                return $length * 0.01 * $viewportSize;
                        } else {
                                return $length * $unitLength[$unit];
index ba38d15..8872d73 100644 (file)
@@ -78,7 +78,7 @@ class XCFHandler extends BitmapHandler {
        static function getXCFMetaData( $filename ) {
                # Decode master structure
                $f = fopen( $filename, 'rb' );
-               if( !$f ) {
+               if ( !$f ) {
                        return false;
                }
                # The image structure always starts at offset 0 in the XCF file.
@@ -115,7 +115,7 @@ class XCFHandler extends BitmapHandler {
                }
 
                # Check values
-               if( $header['magic'] !== 'gimp xcf' ) {
+               if ( $header['magic'] !== 'gimp xcf' ) {
                        wfDebug( __METHOD__ . " '$filename' has invalid magic signature.\n" );
                        return false;
                }
index 081433b..b2b95e4 100644 (file)
@@ -180,12 +180,12 @@ class XMPReader {
                ) {
                        // the is_array is just paranoia. It should always
                        // be an array.
-                       foreach( $data['xmp-special']['LocationShown'] as $loc ) {
+                       foreach ( $data['xmp-special']['LocationShown'] as $loc ) {
                                if ( !is_array( $loc ) ) {
                                        // To avoid copying over the _type meta-fields.
                                        continue;
                                }
-                               foreach( $loc as $field => $val ) {
+                               foreach ( $loc as $field => $val ) {
                                        $data['xmp-general'][$field . 'Dest'][] = $val;
                                }
                        }
@@ -195,12 +195,12 @@ class XMPReader {
                ) {
                        // the is_array is just paranoia. It should always
                        // be an array.
-                       foreach( $data['xmp-special']['LocationCreated'] as $loc ) {
+                       foreach ( $data['xmp-special']['LocationCreated'] as $loc ) {
                                if ( !is_array( $loc ) ) {
                                        // To avoid copying over the _type meta-fields.
                                        continue;
                                }
-                               foreach( $loc as $field => $val ) {
+                               foreach ( $loc as $field => $val ) {
                                        $data['xmp-general'][$field . 'Created'][] = $val;
                                }
                        }
@@ -391,7 +391,9 @@ class XMPReader {
                        throw new MWException( 'Unexpected character data before first rdf:Description element' );
                }
 
-               if ( $this->mode[0] === self::MODE_IGNORE ) return;
+               if ( $this->mode[0] === self::MODE_IGNORE ) {
+                       return;
+               }
 
                if ( $this->mode[0] !== self::MODE_SIMPLE
                        && $this->mode[0] !== self::MODE_QDESC
index feacc2a..f0b2cb5 100644 (file)
@@ -32,7 +32,7 @@ class XMPInfo {
         * @return Array XMP item configuration array.
         */
        public static function getItems() {
-               if( !self::$ranHooks ) {
+               if ( !self::$ranHooks ) {
                        // This is for if someone makes a custom metadata extension.
                        // For example, a medical wiki might want to decode DICOM xmp properties.
                        wfRunHooks( 'XMPGetInfo', Array( &self::$items ) );
index dff9ada..28b5d79 100644 (file)
@@ -46,12 +46,12 @@ class UsercreateTemplate extends QuickTemplate {
        function execute() {
                if ( $this->data['message'] ) {
 ?>
-       <div class="<?php $this->text('messagetype') ?>box">
+       <div class="<?php $this->text( 'messagetype' ); ?>box">
 <?php
                        if ( $this->data['messagetype'] == 'error' ) {
-                               ?><strong><?php $this->msg( 'loginerror' ) ?></strong><br /><?php
+                               ?><strong><?php $this->msg( 'loginerror' ); ?></strong><br /><?php
                        }
-                       $this->html('message');
+                       $this->html( 'message' );
 ?>
        </div>
        <div class="visualClear"></div>
@@ -62,10 +62,10 @@ class UsercreateTemplate extends QuickTemplate {
 <div id="signupstart"><?php $this->msgWiki( 'signupstart' ); ?></div>
 <div id="userlogin">
 
-<form name="userlogin2" id="userlogin2" method="post" action="<?php $this->text('action') ?>">
-       <h2><?php $this->msg('createaccount') ?></h2>
-       <p id="userloginlink"><?php $this->html('link') ?></p>
-       <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
+<form name="userlogin2" id="userlogin2" method="post" action="<?php $this->text( 'action' ); ?>">
+       <h2><?php $this->msg( 'createaccount' ); ?></h2>
+       <p id="userloginlink"><?php $this->html( 'link' ); ?></p>
+       <?php $this->html( 'header' ); /* pre-table point for form plugins... */ ?>
 <?php
        if ( $this->haveData( 'languages' ) ) {
                ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php
@@ -73,7 +73,7 @@ class UsercreateTemplate extends QuickTemplate {
 ?>
        <table>
                <tr>
-                       <td class="mw-label"><label for='wpName2'><?php $this->msg('yourname') ?></label></td>
+                       <td class="mw-label"><label for='wpName2'><?php $this->msg( 'yourname' ); ?></label></td>
                        <td class="mw-input">
                                <?php
                        echo Html::input( 'wpName', $this->data['name'], 'text', array(
@@ -103,7 +103,7 @@ class UsercreateTemplate extends QuickTemplate {
                        </td>
                </tr>
                <tr class="mw-row-password">
-                       <td class="mw-label"><label for='wpPassword2'><?php $this->msg('yourpassword') ?></label></td>
+                       <td class="mw-label"><label for='wpPassword2'><?php $this->msg( 'yourpassword' ); ?></label></td>
                        <td class="mw-input">
 <?php
                        echo Html::input( 'wpPassword', null, 'password', array(
@@ -122,9 +122,9 @@ class UsercreateTemplate extends QuickTemplate {
                }
 ?>
                <tr id="mw-user-domain-section">
-                       <td class="mw-label"><?php $this->msg( 'yourdomainname' ) ?></td>
+                       <td class="mw-label"><?php $this->msg( 'yourdomainname' ); ?></td>
                        <td class="mw-input">
-                               <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
+                               <select name="wpDomain" value="<?php $this->text( 'domain' ); ?>"
                                        tabindex="4">
                                        <?php echo $doms ?>
                                </select>
@@ -134,7 +134,7 @@ class UsercreateTemplate extends QuickTemplate {
                }
 ?>
                <tr class="mw-row-password">
-                       <td class="mw-label"><label for='wpRetype'><?php $this->msg('yourpasswordagain') ?></label></td>
+                       <td class="mw-label"><label for='wpRetype'><?php $this->msg( 'yourpasswordagain' ); ?></label></td>
                        <td class="mw-input">
                                <?php
                echo Html::input( 'wpRetype', null, 'password', array(
@@ -149,7 +149,7 @@ class UsercreateTemplate extends QuickTemplate {
 <?php
                if ( $this->data['useemail'] ) {
 ?>
-                               <td class="mw-label"><label for='wpEmail'><?php $this->msg('youremail') ?></label></td>
+                               <td class="mw-label"><label for='wpEmail'><?php $this->msg( 'youremail' ); ?></label></td>
                                <td class="mw-input">
                                        <?php
                echo Html::input( 'wpEmail', $this->data['email'], 'email', array(
@@ -160,13 +160,13 @@ class UsercreateTemplate extends QuickTemplate {
                ) ); ?>
                                        <div class="prefsectiontip">
                                                <?php  // duplicated in Preferences.php profilePreferences()
-                                                       if( $this->data['emailrequired'] ) {
-                                                               $this->msgWiki('prefs-help-email-required');
+                                                       if ( $this->data['emailrequired'] ) {
+                                                               $this->msgWiki( 'prefs-help-email-required' );
                                                        } else {
-                                                               $this->msgWiki('prefs-help-email');
+                                                               $this->msgWiki( 'prefs-help-email' );
                                                        }
-                                                       if( $this->data['emailothers'] ) {
-                                                               $this->msgWiki('prefs-help-email-others');
+                                                       if ( $this->data['emailothers'] ) {
+                                                               $this->msgWiki( 'prefs-help-email-others' );
                                                        } ?>
                                        </div>
                                </td>
@@ -177,13 +177,13 @@ class UsercreateTemplate extends QuickTemplate {
 ?>
                                </tr>
                                <tr>
-                                       <td class="mw-label"><label for='wpRealName'><?php $this->msg('yourrealname') ?></label></td>
+                                       <td class="mw-label"><label for='wpRealName'><?php $this->msg( 'yourrealname' ); ?></label></td>
                                        <td class="mw-input">
                                                <input type='text' class='loginText' name="wpRealName" id="wpRealName"
                                                        tabindex="7"
-                                                       value="<?php $this->text('realname') ?>" size='20' />
+                                                       value="<?php $this->text( 'realname' ); ?>" size='20' />
                                                <div class="prefsectiontip">
-                                                       <?php $this->msgWiki('prefs-help-realname'); ?>
+                                                       <?php $this->msgWiki( 'prefs-help-realname' ); ?>
                                                </div>
                                        </td>
 <?php
@@ -193,11 +193,11 @@ class UsercreateTemplate extends QuickTemplate {
 ?>
                                </tr>
                                <tr>
-                                       <td class="mw-label"><label for='wpReason'><?php $this->msg('createaccountreason') ?></label></td>
+                                       <td class="mw-label"><label for='wpReason'><?php $this->msg( 'createaccountreason' ); ?></label></td>
                                        <td class="mw-input">
                                                <input type='text' class='loginText' name="wpReason" id="wpReason"
                                                        tabindex="8"
-                                                       value="<?php $this->text('reason') ?>" size='20' />
+                                                       value="<?php $this->text( 'reason' ); ?>" size='20' />
                                        </td>
 <?php
                }
@@ -233,13 +233,13 @@ class UsercreateTemplate extends QuickTemplate {
                                if ( !empty( $inputItem['msg'] ) && $inputItem['type'] != 'checkbox' ) {
                                        ?><td class="mw-label"><label for="<?php
                                        echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
-                                       $this->msgWiki( $inputItem['msg'] ) ?></label><?php
+                                       $this->msgWiki( $inputItem['msg'] ); ?></label><?php
                                } else {
                                        ?><td><?php
                                }
                        ?></td>
                        <td class="mw-input">
-                               <input type="<?php echo htmlspecialchars( $inputItem['type'] ) ?>" name="<?php
+                               <input type="<?php echo htmlspecialchars( $inputItem['type'] ); ?>" name="<?php
                                echo htmlspecialchars( $inputItem['name'] ); ?>"
                                        tabindex="<?php echo $tabIndex++; ?>"
                                        value="<?php
@@ -250,13 +250,14 @@ class UsercreateTemplate extends QuickTemplate {
                                }
                                        ?>" id="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"
                                        <?php
-                               if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) )
+                               if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['value'] ) ) {
                                        echo 'checked="checked"';
+                               }
                                        ?> /> <?php
                                        if ( $inputItem['type'] == 'checkbox' && !empty( $inputItem['msg'] ) ) {
                                                ?>
                                <label for="<?php echo htmlspecialchars( $inputItem['name'] ); ?>"><?php
-                                       $this->msgHtml( $inputItem['msg'] ) ?></label><?php
+                                       $this->msgHtml( $inputItem['msg'] ); ?></label><?php
                                        }
                                if ( $inputItem['helptext'] !== false ) {
                                ?>
@@ -276,7 +277,7 @@ class UsercreateTemplate extends QuickTemplate {
                        <td class="mw-submit">
                                <input type='submit' name="wpCreateaccount" id="wpCreateaccount"
                                        tabindex="<?php echo $tabIndex++; ?>"
-                                       value="<?php $this->msg('createaccount') ?>" />
+                                       value="<?php $this->msg( 'createaccount' ); ?>" />
                        </td>
                </tr>
        </table>
index 0b4b8e5..8c937a7 100644 (file)
@@ -33,13 +33,13 @@ class UserloginTemplate extends QuickTemplate {
        function execute() {
                if ( $this->data['message'] ) {
 ?>
-       <div class="<?php $this->text('messagetype') ?>box">
+       <div class="<?php $this->text( 'messagetype' ); ?>box">
                <?php
                if ( $this->data['messagetype'] == 'error' ) {
-                       ?><strong><?php $this->msg( 'loginerror' ) ?></strong><br /><?php
+                       ?><strong><?php $this->msg( 'loginerror' ); ?></strong><br /><?php
                }
                ?>
-               <?php $this->html('message') ?>
+               <?php $this->html( 'message' ); ?>
        </div>
        <div class="visualClear"></div><?php
 
@@ -47,11 +47,11 @@ class UserloginTemplate extends QuickTemplate {
 ?>
 <div id="loginstart"><?php $this->msgWiki( 'loginstart' ); ?></div>
 <div id="userloginForm">
-<form name="userlogin" method="post" action="<?php $this->text('action') ?>">
-       <h2><?php $this->msg('login') ?></h2>
-       <p id="userloginlink"><?php $this->html('link') ?></p>
-       <?php $this->html('header'); /* pre-table point for form plugins... */ ?>
-       <div id="userloginprompt"><?php  $this->msgWiki('loginprompt') ?></div>
+<form name="userlogin" method="post" action="<?php $this->text( 'action' ); ?>">
+       <h2><?php $this->msg( 'login' ); ?></h2>
+       <p id="userloginlink"><?php $this->html( 'link' ); ?></p>
+       <?php $this->html( 'header' ); /* pre-table point for form plugins... */ ?>
+       <div id="userloginprompt"><?php  $this->msgWiki( 'loginprompt' ); ?></div>
 <?php
                if ( $this->haveData( 'languages' ) ) {
                        ?><div id="languagelinks"><p><?php $this->html( 'languages' ); ?></p></div><?php
@@ -59,7 +59,7 @@ class UserloginTemplate extends QuickTemplate {
 ?>
        <table>
                <tr>
-                       <td class="mw-label"><label for='wpName1'><?php $this->msg('yourname') ?></label></td>
+                       <td class="mw-label"><label for='wpName1'><?php $this->msg( 'yourname' ); ?></label></td>
                        <td class="mw-input">
                                <?php
                        echo Html::input( 'wpName', $this->data['name'], 'text', array(
@@ -75,7 +75,7 @@ class UserloginTemplate extends QuickTemplate {
                        </td>
                </tr>
                <tr>
-                       <td class="mw-label"><label for='wpPassword1'><?php $this->msg('yourpassword') ?></label></td>
+                       <td class="mw-label"><label for='wpPassword1'><?php $this->msg( 'yourpassword' ); ?></label></td>
                        <td class="mw-input">
                                <?php
                        echo Html::input( 'wpPassword', null, 'password', array(
index 2e90c09..a944c0a 100644 (file)
@@ -32,29 +32,29 @@ class UserloginTemplateVForm extends BaseTemplate {
 <div class="mw-ui-container">
        <?php
        // Some extensions including CAPTCHAs add content to header on UserLoginForm hook.
-       $this->html('header');
-       if( $this->haveData( 'languages' ) ) {
+       $this->html( 'header' );
+       if ( $this->haveData( 'languages' ) ) {
        ?>
                <div id="languagelinks">
-                       <p><?php $this->html('languages' ); ?></p>
+                       <p><?php $this->html( 'languages' ); ?></p>
                </div>
        <?php
        }
        ?>
 <div id="userloginForm">
-<form name="userlogin" class="mw-ui-vform" method="post" action="<?php $this->text('action') ?>">
+<form name="userlogin" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
        <?php
 
-       if( $this->data['message'] ) {
+       if ( $this->data['message'] ) {
        ?>
-               <div class="<?php $this->text('messagetype') ?>box">
+               <div class="<?php $this->text( 'messagetype' ); ?>box">
                <?php
                if ( $this->data['messagetype'] == 'error' ) {
                ?>
                        <strong><?php $this->msg( 'loginerror' )?></strong><br />
                <?php
                }
-               $this->html('message')
+               $this->html( 'message' );
                ?>
                </div>
        <?php
@@ -92,7 +92,7 @@ class UserloginTemplateVForm extends BaseTemplate {
                <div>
                        <label for='wpPassword1'>
                        <?php
-                       $this->msg('userlogin-yourpassword');
+                       $this->msg( 'userlogin-yourpassword' );
 
                        if ( $this->data['useemail'] && $this->data['canreset'] && $this->data['resetlink'] === true ) {
                                echo Linker::link(
@@ -122,28 +122,28 @@ class UserloginTemplateVForm extends BaseTemplate {
                        ?>
                </div>
        <?php
-       if( isset( $this->data['usedomain'] ) && $this->data['usedomain'] ) {
+       if ( isset( $this->data['usedomain'] ) && $this->data['usedomain'] ) {
                $doms = "";
-               foreach( $this->data['domainnames'] as $dom ) {
+               foreach ( $this->data['domainnames'] as $dom ) {
                        $doms .= "<option>" . htmlspecialchars( $dom ) . "</option>";
                }
        ?>
                <div id="mw-user-domain-section">
-                       <label for='wpDomain' class="pos-above"><?php $this->msg( 'yourdomain' ) ?></label>
-                               <select name="wpDomain" value="<?php $this->text( 'domain' ) ?>"
+                       <label for='wpDomain' class="pos-above"><?php $this->msg( 'yourdomain' ); ?></label>
+                               <select name="wpDomain" value="<?php $this->text( 'domain' ); ?>"
                                        tabindex="3">
                                        <?php echo $doms ?>
                                </select>
                </div>
        <?php }
 
-       if( $this->haveData( 'extrafields' ) ) {
+       if ( $this->haveData( 'extrafields' ) ) {
                echo $this->data['extrafields'];
        } ?>
 
                <div>
 
-       <?php if( $this->data['canremember'] ) { ?>
+       <?php if ( $this->data['canremember'] ) { ?>
                <label class="mw-ui-checkbox-label">
                        <input name="wpRemember" type="checkbox" value="1" id="wpRemember" tabindex="4"
                                <?php if ( $this->data['remember'] ) {
@@ -155,7 +155,7 @@ class UserloginTemplateVForm extends BaseTemplate {
        <?php } ?>
                </div>
 
-       <?php if( $this->data['cansecurelogin'] ) { ?>
+       <?php if ( $this->data['cansecurelogin'] ) { ?>
                <div>
                        <label class="mw-ui-checkbox-label">
                                <input name="wpStickHTTPS" type="checkbox" value="1" id="wpStickHTTPS" tabindex="5"
@@ -177,16 +177,16 @@ class UserloginTemplateVForm extends BaseTemplate {
                        ?>
                </div>
                <div id="mw-userlogin-help">
-                       <?php echo $this->getMsg( 'userlogin-helplink' )->parse() ?>
+                       <?php echo $this->getMsg( 'userlogin-helplink' )->parse(); ?>
                </div>
-               <?php if( $this->haveData( 'createOrLoginHref' ) ) { ?>
+               <?php if ( $this->haveData( 'createOrLoginHref' ) ) { ?>
                        <div id="mw-createaccount-cta">
-                               <h3 id="mw-userloginlink"><?php $this->msg( 'userlogin-noaccount' ) ?><a href="<?php $this->text( 'createOrLoginHref' ) ?>" id="mw-createaccount-join" tabindex="7"  class="mw-ui-button mw-ui-constructive"><?php $this->msg( 'userlogin-joinproject' ) ?></a></h3>
+                               <h3 id="mw-userloginlink"><?php $this->msg( 'userlogin-noaccount' ); ?><a href="<?php $this->text( 'createOrLoginHref' ); ?>" id="mw-createaccount-join" tabindex="7"  class="mw-ui-button mw-ui-constructive"><?php $this->msg( 'userlogin-joinproject' ); ?></a></h3>
                        </div>
                <?php } ?>
        <input type="hidden" id="mw-useNew" name="useNew" value="1" />
-<?php if( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
-<?php if( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
+<?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
+<?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpLoginToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
 </form>
 </div>
 </div>
index c98c445..6a31582 100644 (file)
@@ -83,7 +83,7 @@ abstract class UploadBase {
                        self::WINDOWS_NONASCII_FILENAME => 'windows-nonascii-filename',
                        self::FILENAME_TOO_LONG => 'filename-toolong',
                );
-               if( isset( $code_to_status[$error] ) ) {
+               if ( isset( $code_to_status[$error] ) ) {
                        return $code_to_status[$error];
                }
 
@@ -136,7 +136,7 @@ abstract class UploadBase {
        public static function createFromRequest( &$request, $type = null ) {
                $type = $type ? $type : $request->getVal( 'wpSourceType', 'File' );
 
-               if( !$type ) {
+               if ( !$type ) {
                        return null;
                }
 
@@ -149,18 +149,18 @@ abstract class UploadBase {
                if ( is_null( $className ) ) {
                        $className = 'UploadFrom' . $type;
                        wfDebug( __METHOD__ . ": class name: $className\n" );
-                       if( !in_array( $type, self::$uploadHandlers ) ) {
+                       if ( !in_array( $type, self::$uploadHandlers ) ) {
                                return null;
                        }
                }
 
                // Check whether this upload class is enabled
-               if( !call_user_func( array( $className, 'isEnabled' ) ) ) {
+               if ( !call_user_func( array( $className, 'isEnabled' ) ) ) {
                        return null;
                }
 
                // Check whether the request is valid
-               if( !call_user_func( array( $className, 'isValidRequest' ), $request ) ) {
+               if ( !call_user_func( array( $className, 'isValidRequest' ), $request ) ) {
                        return null;
                }
 
@@ -275,7 +275,7 @@ abstract class UploadBase {
                /**
                 * If there was no filename or a zero size given, give up quick.
                 */
-               if( $this->isEmptyFile() ) {
+               if ( $this->isEmptyFile() ) {
                        wfProfileOut( __METHOD__ );
                        return array( 'status' => self::EMPTY_FILE );
                }
@@ -284,7 +284,7 @@ abstract class UploadBase {
                 * Honor $wgMaxUploadSize
                 */
                $maxSize = self::getMaxUploadSize( $this->getSourceType() );
-               if( $this->mFileSize > $maxSize ) {
+               if ( $this->mFileSize > $maxSize ) {
                        wfProfileOut( __METHOD__ );
                        return array(
                                'status' => self::FILE_TOO_LARGE,
@@ -298,7 +298,7 @@ abstract class UploadBase {
                 * probably not accept it.
                 */
                $verification = $this->verifyFile();
-               if( $verification !== true ) {
+               if ( $verification !== true ) {
                        wfProfileOut( __METHOD__ );
                        return array(
                                'status' => self::VERIFICATION_ERROR,
@@ -310,13 +310,13 @@ abstract class UploadBase {
                 * Make sure this file can be created
                 */
                $result = $this->validateName();
-               if( $result !== true ) {
+               if ( $result !== true ) {
                        wfProfileOut( __METHOD__ );
                        return $result;
                }
 
                $error = '';
-               if( !wfRunHooks( 'UploadVerification',
+               if ( !wfRunHooks( 'UploadVerification',
                        array( $this->mDestName, $this->mTempPath, &$error ) ) )
                {
                        wfProfileOut( __METHOD__ );
@@ -335,9 +335,9 @@ abstract class UploadBase {
         **/
        public function validateName() {
                $nt = $this->getTitle();
-               if( is_null( $nt ) ) {
+               if ( is_null( $nt ) ) {
                        $result = array( 'status' => $this->mTitleError );
-                       if( $this->mTitleError == self::ILLEGAL_FILENAME ) {
+                       if ( $this->mTitleError == self::ILLEGAL_FILENAME ) {
                                $result['filtered'] = $this->mFilteredName;
                        }
                        if ( $this->mTitleError == self::FILETYPE_BADTYPE ) {
@@ -421,12 +421,12 @@ abstract class UploadBase {
 
                # check for htmlish code and javascript
                if ( !$wgDisableUploadScriptChecks ) {
-                       if( self::detectScript( $this->mTempPath, $mime, $this->mFinalExtension ) ) {
+                       if ( self::detectScript( $this->mTempPath, $mime, $this->mFinalExtension ) ) {
                                wfProfileOut( __METHOD__ );
                                return array( 'uploadscripted' );
                        }
-                       if( $this->mFinalExtension == 'svg' || $mime == 'image/svg+xml' ) {
-                               if( $this->detectScriptInSvg( $this->mTempPath ) ) {
+                       if ( $this->mFinalExtension == 'svg' || $mime == 'image/svg+xml' ) {
+                               if ( $this->detectScriptInSvg( $this->mTempPath ) ) {
                                        wfProfileOut( __METHOD__ );
                                        return array( 'uploadscripted' );
                                }
@@ -532,7 +532,7 @@ abstract class UploadBase {
                 * to modify it by uploading a new revision.
                 */
                $nt = $this->getTitle();
-               if( is_null( $nt ) ) {
+               if ( is_null( $nt ) ) {
                        return true;
                }
                $permErrors = $nt->getUserPermissionsErrors( 'edit', $user );
@@ -542,7 +542,7 @@ abstract class UploadBase {
                } else {
                        $permErrorsCreate = array();
                }
-               if( $permErrors || $permErrorsUpload || $permErrorsCreate ) {
+               if ( $permErrors || $permErrorsUpload || $permErrorsCreate ) {
                        $permErrors = array_merge( $permErrors, wfArrayDiff2( $permErrorsUpload, $permErrors ) );
                        $permErrors = array_merge( $permErrors, wfArrayDiff2( $permErrorsCreate, $permErrors ) );
                        return $permErrors;
@@ -579,7 +579,7 @@ abstract class UploadBase {
                $comparableName = str_replace( ' ', '_', $this->mDesiredDestName );
                $comparableName = Title::capitalize( $comparableName, NS_FILE );
 
-               if( $this->mDesiredDestName != $filename && $comparableName != $filename ) {
+               if ( $this->mDesiredDestName != $filename && $comparableName != $filename ) {
                        $warnings['badfilename'] = $filename;
                }
 
@@ -602,7 +602,7 @@ abstract class UploadBase {
                }
 
                $exists = self::getExistsWarning( $localFile );
-               if( $exists !== false ) {
+               if ( $exists !== false ) {
                        $warnings['exists'] = $exists;
                }
 
@@ -612,11 +612,11 @@ abstract class UploadBase {
                $title = $this->getTitle();
                // Remove all matches against self
                foreach ( $dupes as $key => $dupe ) {
-                       if( $title->equals( $dupe->getTitle() ) ) {
+                       if ( $title->equals( $dupe->getTitle() ) ) {
                                unset( $dupes[$key] );
                        }
                }
-               if( $dupes ) {
+               if ( $dupes ) {
                        $warnings['duplicate'] = $dupes;
                }
 
@@ -654,7 +654,7 @@ abstract class UploadBase {
                        $user
                );
 
-               if( $status->isGood() ) {
+               if ( $status->isGood() ) {
                        if ( $watch ) {
                                $user->addWatch( $this->getLocalFile()->getTitle() );
                        }
@@ -701,7 +701,7 @@ abstract class UploadBase {
                $this->mFilteredName = wfStripIllegalFilenameChars( $this->mFilteredName );
                /* Normalize to title form before we do any further processing */
                $nt = Title::makeTitleSafe( NS_FILE, $this->mFilteredName );
-               if( is_null( $nt ) ) {
+               if ( is_null( $nt ) ) {
                        $this->mTitleError = self::ILLEGAL_FILENAME;
                        return $this->mTitle = null;
                }
@@ -713,7 +713,7 @@ abstract class UploadBase {
                 */
                list( $partname, $ext ) = $this->splitExtensions( $this->mFilteredName );
 
-               if( count( $ext ) ) {
+               if ( count( $ext ) ) {
                        $this->mFinalExtension = trim( $ext[count( $ext ) - 1] );
                } else {
                        $this->mFinalExtension = '';
@@ -761,13 +761,13 @@ abstract class UploadBase {
 
                # If there was more than one "extension", reassemble the base
                # filename to prevent bogus complaints about length
-               if( count( $ext ) > 1 ) {
-                       for( $i = 0; $i < count( $ext ) - 1; $i++ ) {
+               if ( count( $ext ) > 1 ) {
+                       for ( $i = 0; $i < count( $ext ) - 1; $i++ ) {
                                $partname .= '.' . $ext[$i];
                        }
                }
 
-               if( strlen( $partname ) < 1 ) {
+               if ( strlen( $partname ) < 1 ) {
                        $this->mTitleError = self::MIN_LENGTH_PARTNAME;
                        return $this->mTitle = null;
                }
@@ -781,7 +781,7 @@ abstract class UploadBase {
         * @return LocalFile|null
         */
        public function getLocalFile() {
-               if( is_null( $this->mLocalFile ) ) {
+               if ( is_null( $this->mLocalFile ) ) {
                        $nt = $this->getTitle();
                        $this->mLocalFile = is_null( $nt ) ? null : wfLocalFile( $nt );
                }
@@ -894,7 +894,7 @@ abstract class UploadBase {
        public static function verifyExtension( $mime, $extension ) {
                $magic = MimeMagic::singleton();
 
-               if ( !$mime || $mime == 'unknown' || $mime == 'unknown/unknown' )
+               if ( !$mime || $mime == 'unknown' || $mime == 'unknown/unknown' ) {
                        if ( !$magic->isRecognizableExtension( $extension ) ) {
                                wfDebug( __METHOD__ . ": passing file with unknown detected mime type; " .
                                        "unrecognized extension '$extension', can't verify\n" );
@@ -904,13 +904,14 @@ abstract class UploadBase {
                                        "recognized extension '$extension', so probably invalid file\n" );
                                return false;
                        }
+               }
 
                $match = $magic->isMatchingExtension( $extension, $mime );
 
                if ( $match === null ) {
                        wfDebug( __METHOD__ . ": no file extension known for mime type $mime, passing file\n" );
                        return true;
-               } elseif( $match === true ) {
+               } elseif ( $match === true ) {
                        wfDebug( __METHOD__ . ": mime type $mime matches extension $extension, passing file\n" );
 
                        #TODO: if it's a bitmap, make sure PHP or ImageMagic resp. can handle it!
@@ -940,7 +941,7 @@ abstract class UploadBase {
                # ugly hack: for text files, always look at the entire file.
                # For binary field, just check the first K.
 
-               if( strpos( $mime, 'text/' ) === 0 ) {
+               if ( strpos( $mime, 'text/' ) === 0 ) {
                        $chunk = file_get_contents( $file );
                } else {
                        $fp = fopen( $file, 'rb' );
@@ -950,21 +951,21 @@ abstract class UploadBase {
 
                $chunk = strtolower( $chunk );
 
-               if( !$chunk ) {
+               if ( !$chunk ) {
                        wfProfileOut( __METHOD__ );
                        return false;
                }
 
                # decode from UTF-16 if needed (could be used for obfuscation).
-               if( substr( $chunk, 0, 2 ) == "\xfe\xff" ) {
+               if ( substr( $chunk, 0, 2 ) == "\xfe\xff" ) {
                        $enc = 'UTF-16BE';
-               } elseif( substr( $chunk, 0, 2 ) == "\xff\xfe" ) {
+               } elseif ( substr( $chunk, 0, 2 ) == "\xff\xfe" ) {
                        $enc = 'UTF-16LE';
                } else {
                        $enc = null;
                }
 
-               if( $enc ) {
+               if ( $enc ) {
                        $chunk = iconv( $enc, "ASCII//IGNORE", $chunk );
                }
 
@@ -1005,12 +1006,12 @@ abstract class UploadBase {
                        '<table'
                );
 
-               if( !$wgAllowTitlesInSVG && $extension !== 'svg' && $mime !== 'image/svg' ) {
+               if ( !$wgAllowTitlesInSVG && $extension !== 'svg' && $mime !== 'image/svg' ) {
                        $tags[] = '<title';
                }
 
-               foreach( $tags as $tag ) {
-                       if( false !== strpos( $chunk, $tag ) ) {
+               foreach ( $tags as $tag ) {
+                       if ( false !== strpos( $chunk, $tag ) ) {
                                wfDebug( __METHOD__ . ": found something that may make it be mistaken for html: $tag\n" );
                                wfProfileOut( __METHOD__ );
                                return true;
@@ -1025,21 +1026,21 @@ abstract class UploadBase {
                $chunk = Sanitizer::decodeCharReferences( $chunk );
 
                # look for script-types
-               if( preg_match( '!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!sim', $chunk ) ) {
+               if ( preg_match( '!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!sim', $chunk ) ) {
                        wfDebug( __METHOD__ . ": found script types\n" );
                        wfProfileOut( __METHOD__ );
                        return true;
                }
 
                # look for html-style script-urls
-               if( preg_match( '!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) ) {
+               if ( preg_match( '!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) ) {
                        wfDebug( __METHOD__ . ": found html-style script urls\n" );
                        wfProfileOut( __METHOD__ );
                        return true;
                }
 
                # look for css-style script-urls
-               if( preg_match( '!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) ) {
+               if ( preg_match( '!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) ) {
                        wfDebug( __METHOD__ . ": found css-style script urls\n" );
                        wfProfileOut( __METHOD__ );
                        return true;
@@ -1071,77 +1072,77 @@ abstract class UploadBase {
                /*
                 * check for elements that can contain javascript
                 */
-               if( $strippedElement == 'script' ) {
+               if ( $strippedElement == 'script' ) {
                        wfDebug( __METHOD__ . ": Found script element '$element' in uploaded file.\n" );
                        return true;
                }
 
                # e.g., <svg xmlns="http://www.w3.org/2000/svg"> <handler xmlns:ev="http://www.w3.org/2001/xml-events" ev:event="load">alert(1)</handler> </svg>
-               if( $strippedElement == 'handler' ) {
+               if ( $strippedElement == 'handler' ) {
                        wfDebug( __METHOD__ . ": Found scriptable element '$element' in uploaded file.\n" );
                        return true;
                }
 
                # SVG reported in Feb '12 that used xml:stylesheet to generate javascript block
-               if( $strippedElement == 'stylesheet' ) {
+               if ( $strippedElement == 'stylesheet' ) {
                        wfDebug( __METHOD__ . ": Found scriptable element '$element' in uploaded file.\n" );
                        return true;
                }
 
-               foreach( $attribs as $attrib => $value ) {
+               foreach ( $attribs as $attrib => $value ) {
                        $stripped = $this->stripXmlNamespace( $attrib );
                        $value = strtolower( $value );
 
-                       if( substr( $stripped, 0, 2 ) == 'on' ) {
+                       if ( substr( $stripped, 0, 2 ) == 'on' ) {
                                wfDebug( __METHOD__ . ": Found event-handler attribute '$attrib'='$value' in uploaded file.\n" );
                                return true;
                        }
 
                        # href with javascript target
-                       if( $stripped == 'href' && strpos( strtolower( $value ), 'javascript:' ) !== false ) {
+                       if ( $stripped == 'href' && strpos( strtolower( $value ), 'javascript:' ) !== false ) {
                                wfDebug( __METHOD__ . ": Found script in href attribute '$attrib'='$value' in uploaded file.\n" );
                                return true;
                        }
 
                        # href with embedded svg as target
-                       if( $stripped == 'href' && preg_match( '!data:[^,]*image/svg[^,]*,!sim', $value ) ) {
+                       if ( $stripped == 'href' && preg_match( '!data:[^,]*image/svg[^,]*,!sim', $value ) ) {
                                wfDebug( __METHOD__ . ": Found href to embedded svg \"<$strippedElement '$attrib'='$value'...\" in uploaded file.\n" );
                                return true;
                        }
 
                        # href with embedded (text/xml) svg as target
-                       if( $stripped == 'href' && preg_match( '!data:[^,]*text/xml[^,]*,!sim', $value ) ) {
+                       if ( $stripped == 'href' && preg_match( '!data:[^,]*text/xml[^,]*,!sim', $value ) ) {
                                wfDebug( __METHOD__ . ": Found href to embedded svg \"<$strippedElement '$attrib'='$value'...\" in uploaded file.\n" );
                                return true;
                        }
 
                        # use set/animate to add event-handler attribute to parent
-                       if( ( $strippedElement == 'set' || $strippedElement == 'animate' ) && $stripped == 'attributename' && substr( $value, 0, 2 ) == 'on' ) {
+                       if ( ( $strippedElement == 'set' || $strippedElement == 'animate' ) && $stripped == 'attributename' && substr( $value, 0, 2 ) == 'on' ) {
                                wfDebug( __METHOD__ . ": Found svg setting event-handler attribute with \"<$strippedElement $stripped='$value'...\" in uploaded file.\n" );
                                return true;
                        }
 
                        # use set to add href attribute to parent element
-                       if( $strippedElement == 'set' && $stripped == 'attributename' && strpos( $value, 'href' ) !== false ) {
+                       if ( $strippedElement == 'set' && $stripped == 'attributename' && strpos( $value, 'href' ) !== false ) {
                                wfDebug( __METHOD__ . ": Found svg setting href attribute '$value' in uploaded file.\n" );
                                return true;
                        }
 
                        # use set to add a remote / data / script target to an element
-                       if( $strippedElement == 'set' && $stripped == 'to' && preg_match( '!(http|https|data|script):!sim', $value ) ) {
+                       if ( $strippedElement == 'set' && $stripped == 'to' && preg_match( '!(http|https|data|script):!sim', $value ) ) {
                                wfDebug( __METHOD__ . ": Found svg setting attribute to '$value' in uploaded file.\n" );
                                return true;
                        }
 
                        # use handler attribute with remote / data / script
-                       if( $stripped == 'handler' && preg_match( '!(http|https|data|script):!sim', $value ) ) {
+                       if ( $stripped == 'handler' && preg_match( '!(http|https|data|script):!sim', $value ) ) {
                                wfDebug( __METHOD__ . ": Found svg setting handler with remote/data/script '$attrib'='$value' in uploaded file.\n" );
                                return true;
                        }
 
                        # use CSS styles to bring in remote code
                        # catch url("http:..., url('http:..., url(http:..., but not url("#..., url('#..., url(#....
-                       if( $stripped == 'style' && preg_match_all( '!((?:font|clip-path|fill|filter|marker|marker-end|marker-mid|marker-start|mask|stroke)\s*:\s*url\s*\(\s*["\']?\s*[^#]+.*?\))!sim', $value, $matches ) ) {
+                       if ( $stripped == 'style' && preg_match_all( '!((?:font|clip-path|fill|filter|marker|marker-end|marker-mid|marker-start|mask|stroke)\s*:\s*url\s*\(\s*["\']?\s*[^#]+.*?\))!sim', $value, $matches ) ) {
                                foreach ( $matches[1] as $match ) {
                                        if ( !preg_match( '!(?:font|clip-path|fill|filter|marker|marker-end|marker-mid|marker-start|mask|stroke)\s*:\s*url\s*\(\s*(#|\'#|"#)!sim', $match ) ) {
                                                wfDebug( __METHOD__ . ": Found svg setting a style with remote url '$attrib'='$value' in uploaded file.\n" );
@@ -1151,7 +1152,7 @@ abstract class UploadBase {
                        }
 
                        # image filters can pull in url, which could be svg that executes scripts
-                       if( $strippedElement == 'image' && $stripped == 'filter' && preg_match( '!url\s*\(!sim', $value ) ) {
+                       if ( $strippedElement == 'image' && $stripped == 'filter' && preg_match( '!url\s*\(!sim', $value ) ) {
                                wfDebug( __METHOD__ . ": Found image filter with url: \"<$strippedElement $stripped='$value'...\" in uploaded file.\n" );
                                return true;
                        }
@@ -1281,8 +1282,8 @@ abstract class UploadBase {
        private function checkOverwrite( $user ) {
                // First check whether the local file can be overwritten
                $file = $this->getLocalFile();
-               if( $file->exists() ) {
-                       if( !self::userCanReUpload( $user, $file ) ) {
+               if ( $file->exists() ) {
+                       if ( !self::userCanReUpload( $user, $file ) ) {
                                return array( 'fileexists-forbidden', $file->getName() );
                        } else {
                                return true;
@@ -1308,13 +1309,13 @@ abstract class UploadBase {
         * @return Boolean
         */
        public static function userCanReUpload( User $user, $img ) {
-               if( $user->isAllowed( 'reupload' ) ) {
+               if ( $user->isAllowed( 'reupload' ) ) {
                        return true; // non-conditional
                }
-               if( !$user->isAllowed( 'reupload-own' ) ) {
+               if ( !$user->isAllowed( 'reupload-own' ) ) {
                        return false;
                }
-               if( is_string( $img ) ) {
+               if ( is_string( $img ) ) {
                        $img = wfLocalFile( $img );
                }
                if ( !( $img instanceof LocalFile ) ) {
@@ -1336,11 +1337,11 @@ abstract class UploadBase {
         * @return mixed False if the file does not exists, else an array
         */
        public static function getExistsWarning( $file ) {
-               if( $file->exists() ) {
+               if ( $file->exists() ) {
                        return array( 'warning' => 'exists', 'file' => $file );
                }
 
-               if( $file->getTitle()->getArticleID() ) {
+               if ( $file->getTitle()->getArticleID() ) {
                        return array( 'warning' => 'page-exists', 'file' => $file );
                }
 
@@ -1348,7 +1349,7 @@ abstract class UploadBase {
                        return array( 'warning' => 'was-deleted', 'file' => $file );
                }
 
-               if( strpos( $file->getName(), '.' ) == false ) {
+               if ( strpos( $file->getName(), '.' ) == false ) {
                        $partname = $file->getName();
                        $extension = '';
                } else {
@@ -1367,7 +1368,7 @@ abstract class UploadBase {
                        $nt_lc = Title::makeTitle( NS_FILE, "{$partname}.{$normalizedExtension}" );
                        $file_lc = wfLocalFile( $nt_lc );
 
-                       if( $file_lc->exists() ) {
+                       if ( $file_lc->exists() ) {
                                return array(
                                        'warning' => 'exists-normalized',
                                        'file' => $file,
@@ -1391,7 +1392,7 @@ abstract class UploadBase {
                        # Check for filenames like 50px- or 180px-, these are mostly thumbnails
                        $nt_thb = Title::newFromText( substr( $partname, strpos( $partname, '-' ) + 1 ) . '.' . $extension, NS_FILE );
                        $file_thb = wfLocalFile( $nt_thb );
-                       if( $file_thb->exists() ) {
+                       if ( $file_thb->exists() ) {
                                return array(
                                        'warning' => 'thumb',
                                        'file' => $file,
@@ -1407,7 +1408,7 @@ abstract class UploadBase {
                        }
                }
 
-               foreach( self::getFilenamePrefixBlacklist() as $prefix ) {
+               foreach ( self::getFilenamePrefixBlacklist() as $prefix ) {
                        if ( substr( $partname, 0, strlen( $prefix ) ) == $prefix ) {
                                return array(
                                        'warning' => 'bad-prefix',
@@ -1443,9 +1444,9 @@ abstract class UploadBase {
        public static function getFilenamePrefixBlacklist() {
                $blacklist = array();
                $message = wfMessage( 'filename-prefix-blacklist' )->inContentLanguage();
-               if( !$message->isDisabled() ) {
+               if ( !$message->isDisabled() ) {
                        $lines = explode( "\n", $message->plain() );
-                       foreach( $lines as $line ) {
+                       foreach ( $lines as $line ) {
                                // Remove comment lines
                                $comment = substr( trim( $line ), 0, 1 );
                                if ( $comment == '#' || $comment == '' ) {
index 7e07516..37db688 100644 (file)
@@ -41,16 +41,16 @@ class UploadFromChunks extends UploadFromFile {
                // user object. sometimes this won't exist, as when running from cron.
                $this->user = $user;
 
-               if( $repo ) {
+               if ( $repo ) {
                        $this->repo = $repo;
                } else {
                        $this->repo = RepoGroup::singleton()->getLocalRepo();
                }
 
-               if( $stash ) {
+               if ( $stash ) {
                        $this->stash = $stash;
                } else {
-                       if( $user ) {
+                       if ( $user ) {
                                wfDebug( __METHOD__ . " creating new UploadFromChunks instance for " . $user->getId() . "\n" );
                        } else {
                                wfDebug( __METHOD__ . " creating new UploadFromChunks instance with no user\n" );
@@ -112,7 +112,7 @@ class UploadFromChunks extends UploadFromFile {
                // Concatenate all the chunks to mVirtualTempPath
                $fileList = Array();
                // The first chunk is stored at the mVirtualTempPath path so we start on "chunk 1"
-               for( $i = 0; $i <= $this->getChunkIndex(); $i++ ) {
+               for ( $i = 0; $i <= $this->getChunkIndex(); $i++ ) {
                        $fileList[] = $this->getVirtualChunkLocation( $i );
                }
 
@@ -127,7 +127,7 @@ class UploadFromChunks extends UploadFromFile {
                $tStart = microtime( true );
                $status = $this->repo->concatenate( $fileList, $tmpPath, FileRepo::DELETE_SOURCE );
                $tAmount = microtime( true ) - $tStart;
-               if( !$status->isOk() ) {
+               if ( !$status->isOk() ) {
                        return $status;
                }
                wfDebugLog( 'fileconcatenate', "Combined $i chunks in $tAmount seconds.\n" );
@@ -190,7 +190,7 @@ class UploadFromChunks extends UploadFromFile {
                                // Update local chunk index for the current chunk
                                $this->mChunkIndex++;
                                $status = $this->outputChunk( $chunkPath );
-                               if( $status->isGood() ) {
+                               if ( $status->isGood() ) {
                                        // Update local offset:
                                        $this->mOffset = $preAppendOffset + $chunkSize;
                                        // Update chunk table status db
@@ -257,7 +257,7 @@ class UploadFromChunks extends UploadFromFile {
         * @return Integer index of the current chunk
         */
        private function getChunkIndex() {
-               if( $this->mChunkIndex !== null ) {
+               if ( $this->mChunkIndex !== null ) {
                        return $this->mChunkIndex;
                }
                return 0;
@@ -307,7 +307,7 @@ class UploadFromChunks extends UploadFromFile {
        }
 
        private function getChunkFileKey( $index = null ) {
-               if( $index === null ) {
+               if ( $index === null ) {
                        $index = $this->getChunkIndex();
                }
                return $this->mFileKey . '.' . $index;
index ab2a7a3..a00ed32 100644 (file)
@@ -40,7 +40,7 @@ class UploadFromFile extends UploadBase {
        function initializeFromRequest( &$request ) {
                $upload = $request->getUpload( 'wpUploadFile' );
                $desiredDestName = $request->getText( 'wpDestFile' );
-               if( !$desiredDestName ) {
+               if ( !$desiredDestName ) {
                        $desiredDestName = $upload->getName();
                }
 
index fd2416d..9276b53 100644 (file)
@@ -45,16 +45,16 @@ class UploadFromStash extends UploadBase {
                // user object. sometimes this won't exist, as when running from cron.
                $this->user = $user;
 
-               if( $repo ) {
+               if ( $repo ) {
                        $this->repo = $repo;
                } else {
                        $this->repo = RepoGroup::singleton()->getLocalRepo();
                }
 
-               if( $stash ) {
+               if ( $stash ) {
                        $this->stash = $stash;
                } else {
-                       if( $user ) {
+                       if ( $user ) {
                                wfDebug( __METHOD__ . " creating new UploadStash instance for " . $user->getId() . "\n" );
                        } else {
                                wfDebug( __METHOD__ . " creating new UploadStash instance with no user\n" );
index 150e516..c99feef 100644 (file)
@@ -77,7 +77,7 @@ class UploadFromUrl extends UploadBase {
                        return false;
                }
                $valid = false;
-               foreach( $wgCopyUploadsDomains as $domain ) {
+               foreach ( $wgCopyUploadsDomains as $domain ) {
                        // See if the domain for the upload matches this whitelisted domain
                        $whitelistedDomainPieces = explode( '.', $domain );
                        $uploadDomainPieces = explode( '.', $parsedUrl['host'] );
@@ -172,7 +172,7 @@ class UploadFromUrl extends UploadBase {
                        return Status::newFatal( 'http-invalid-url' );
                }
 
-               if( !self::isAllowedHost( $this->mUrl ) ) {
+               if ( !self::isAllowedHost( $this->mUrl ) ) {
                        return Status::newFatal( 'upload-copy-upload-invalid-domain' );
                }
                if ( !$this->mAsync ) {
index a90fecf..1ee4627 100644 (file)
@@ -338,7 +338,7 @@ class UploadStash {
                        __METHOD__
                );
 
-               if( !$row ) {
+               if ( !$row ) {
                        throw new UploadStashNoSuchKeyException( "No such key ($key), cannot remove" );
                }
 
@@ -454,7 +454,7 @@ class UploadStash {
        protected function fetchFileMetadata( $key, $readFromDB = DB_SLAVE ) {
                // populate $fileMetadata[$key]
                $dbr = null;
-               if( $readFromDB === DB_MASTER ) {
+               if ( $readFromDB === DB_MASTER ) {
                        // sometimes reading from the master is necessary, if there's replication lag.
                        $dbr = $this->repo->getMasterDb();
                } else {