*/
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()
);
}
*/
public function execute() {
$vars = Installer::getExistingLocalSettings();
- if( $vars ) {
+ if ( $vars ) {
$this->showStatusMessage(
Status::newFatal( "config-localsettings-cli-upgrade" )
);
}
$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;
$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 );
$this->db->commit( __METHOD__ );
}
// Resume normal operations
- if( $status->isOk() ) {
+ if ( $status->isOk() ) {
$this->enableLB();
}
return $status;
$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' ) );
}
}
$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;
}
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' ),
*/
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 {
$good = false;
}
- if( $good ) {
+ if ( $good ) {
foreach ( $this->envChecks as $check ) {
$status = $this->$check();
if ( $status === false ) {
$_lsExists = file_exists( "$IP/LocalSettings.php" );
wfRestoreWarnings();
- if( !$_lsExists ) {
+ if ( !$_lsExists ) {
return false;
}
unset( $_lsExists );
* Environment check for register_globals.
*/
protected function envCheckRegisterGlobals() {
- if( wfIniGetBool( 'register_globals' ) ) {
+ if ( wfIniGetBool( 'register_globals' ) ) {
$this->showMessage( 'config-register-globals' );
}
}
* @return bool
*/
protected function envCheckMagicQuotes() {
- if( wfIniGetBool( "magic_quotes_runtime" ) ) {
+ if ( wfIniGetBool( "magic_quotes_runtime" ) ) {
$this->showError( 'config-magic-quotes-runtime' );
return false;
}
$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 );
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 );
}
* 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 ) {
}
// 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' );
}
}
* @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;
}
}
* @return array
*/
public function findExtensions() {
- if( $this->getVar( 'IP' ) === null ) {
+ if ( $this->getVar( 'IP' ) === null ) {
return array();
}
$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;
}
}
require( "$IP/includes/DefaultSettings.php" );
- foreach( $exts as $e ) {
+ foreach ( $exts as $e ) {
require_once( "$IP/extensions/$e/$e.php" );
}
// 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']]
}
// 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
}
// 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' ) )
);
$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 ) );
// 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;
$user->addGroup( 'sysop' );
$user->addGroup( 'bureaucrat' );
- if( $this->getVar( '_AdminEmail' ) ) {
+ if ( $this->getVar( '_AdminEmail' ) ) {
$user->setEmail( $this->getVar( '_AdminEmail' ) );
}
$user->saveSettings();
}
$status = Status::newGood();
- if( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) {
+ if ( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) {
$this->subscribeToMediaWikiAnnounce( $status );
}
*/
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 {
'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 );
}
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";
}
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', ";
}
* @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 {
//$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";
$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' );
'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' );
}
}
$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 );
}
*/
public function setupUser() {
$dbUser = $this->getVar( 'wgDBuser' );
- if( $dbUser == $this->getVar( '_InstallUser' ) ) {
+ if ( $dbUser == $this->getVar( '_InstallUser' ) ) {
return Status::newGood();
}
$status = $this->getConnection();
$tryToCreate = false;
}
- if( $tryToCreate ) {
+ if ( $tryToCreate ) {
$createHostList = array(
$server,
'localhost',
$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 );
// 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__ );
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." );
}
}
$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__ );
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';
foreach ( $groups as $group ) {
$this->db->insert( 'user_groups',
array(
- 'ug_user' => $row->ur_user,
+ 'ug_user' => $row->ur_user,
'ug_group' => $group ),
__METHOD__ );
}
$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" );
'callback' => array( $this, 'setupSchema' )
);
- if( $this->getVar( '_CreateDBAccount' ) ) {
+ if ( $this->getVar( '_CreateDBAccount' ) ) {
$this->parent->addInstallStep( $createDbAccount, 'database' );
}
$this->parent->addInstallStep( $commitCB, 'interwiki' );
$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 ) {
*/
$conn = $status->value;
- if( $conn->tableExists( 'archive' ) ) {
+ if ( $conn->tableExists( 'archive' ) ) {
$status->warning( 'config-install-tables-exist' );
$this->enableLB();
return $status;
$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 );
$conn->commit( __METHOD__ );
}
// Resume normal operations
- if( $status->isOk() ) {
+ if ( $status->isOk() ) {
$this->enableLB();
}
return $status;
# 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' ),
),
'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(
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)' ),
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")' );
}
}
$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 );
}
}
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 ) ) {
$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;
$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' );
$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();
}
$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 );
do {
$nextPageId--;
$nextPage = $this->pageSequence[$nextPageId];
- } while( isset( $this->skippedPages[$nextPage] ) );
+ } while ( isset( $this->skippedPages[$nextPage] ) );
} else {
$nextPage = $this->pageSequence[$lowestUnhappy];
}
$this->currentPageName = $page->getName();
$this->startPageWrapper( $pageName );
- if( $page->isSlow() ) {
+ if ( $page->isSlow() ) {
$this->disableTimeLimit();
}
* @return bool
*/
public function startSession() {
- if( wfIniGetBool( 'session.auto_start' ) || session_id() ) {
+ if ( wfIniGetBool( 'session.auto_start' ) || session_id() ) {
// Done already
return true;
}
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() );
* @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 );
}
wfRestoreWarnings();
- if( $dir == 'rtl' ) {
+ if ( $dir == 'rtl' ) {
$css = CSSJanus::transform( $css, true );
}
$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";
$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';
// 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";
}
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 );
// 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;
}
// 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;
}
$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,
);
$caches = array( 'none' );
- if( count( $this->getVar( '_Caches' ) ) ) {
+ if ( count( $this->getVar( '_Caches' ) ) ) {
$caches[] = 'accel';
}
$caches[] = 'memcached';
// or going back!
$cacheval = 'none';
}
- $hidden = ($cacheval == 'memcached') ? '' : 'display: none';
+ $hidden = ( $cacheval == 'memcached' ) ? '' : 'display: none';
$this->addHTML(
# Advanced settings
$this->getFieldSetStart( 'config-advanced-settings' ) .
} 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 */ ) .
$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;
}
}
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(
$html = "<span class=\"error\">$html</span>";
}
$this->addHTML( $html . "</li>\n" );
- if( !$status->isGood() ) {
+ if ( !$status->isGood() ) {
$this->parent->showStatusBox( $status );
}
}
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 );
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.' );
}
*/
function getImageSize( $image, $filename ) {
$f = fopen( $filename, 'rb' );
- if( !$f ) {
+ if ( !$f ) {
return false;
}
$header = fread( $f, 54 );
$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 ) {
$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 );
}
}
*/
static function getTiffByteOrder( $filename ) {
$fh = fopen( $filename, 'rb' );
- if ( !$fh ) return false;
+ if ( !$fh ) {
+ return false;
+ }
$head = fread( $fh, 2 );
fclose( $fh );
$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;
}
}
}
wfRestoreWarnings();
wfProfileOut( __METHOD__ );
- if( $gettext ) {
+ if ( $gettext ) {
return $image->djvuTextTree;
} else {
return $image->dejaMetaTree;
public function getImageSize() {
$data = $this->getInfo();
- if( $data !== false ) {
+ if ( $data !== false ) {
$width = $data['width'];
$height = $data['height'];
$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 );
}
wfSuppressWarnings();
$file = fopen( $this->mFilename, 'rb' );
wfRestoreWarnings();
- if( $file === false ) {
+ if ( $file === false ) {
wfDebug( __METHOD__ . ": missing or failed file read\n" );
return false;
}
$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" );
}
}
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.
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 );
}
$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 );
}
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;
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;
}
$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
}
$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();
$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;
}
}
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();
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();
}
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 );
$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 );
}
else
return gcd( $b, $a % $b );
*/
- while( $b != 0 ) {
+ while ( $b != 0 ) {
$remainder = $a % $b;
// tail recursion...
* @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'] )
// 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 );
$ser = $image->getMetadata();
if ( $ser ) {
$metadata = unserialize( $ser );
- if( $metadata['frameCount'] > 1 ) {
+ if ( $metadata['frameCount'] > 1 ) {
return true;
}
}
// Skip over the GCT
self::readGCT( $fh, $bpp );
- while( !feof( $fh ) ) {
+ while ( !feof( $fh ) ) {
$buf = fread( $fh, 1 );
if ( $buf == self::$gif_frame_sep ) {
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];
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;
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 ) {
// 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 );
// 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];
} 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 );
*/
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 );
}
}
* @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;
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 ) {
$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)" );
if ( !isset( $params['page'] ) ) {
$params['page'] = 1;
- } else {
+ } else {
if ( $params['page'] > $image->pageCount() ) {
$params['page'] = $image->pageCount();
}
$width = intval( $width );
# Sanity check $width
- if( $width <= 0 ) {
+ if ( $width <= 0 ) {
wfDebug( __METHOD__ . ": Invalid destination width: $width\n" );
return false;
}
}
$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 );
}
}
$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'] ) .
}
$buffer = fread( $fh, 1 );
- while( $buffer === "\xFF" && !feof( $fh ) ) {
+ while ( $buffer === "\xFF" && !feof( $fh ) ) {
// Skip through any 0xFF padding bytes.
$buffer = fread( $fh, 1 );
}
} 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 );
}
// 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;
// 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'];
}
* @param string $path the filename
* @return String
*/
- function getMetadata( $image, $path ) { return ''; }
+ function getMetadata( $image, $path ) {
+ return '';
+ }
/**
* Get metadata version.
*
* @return string
*/
- function getMetadataType( $image ) { return false; }
+ function getMetadataType( $image ) {
+ return false;
+ }
/**
* Check if the metadata string is valid for this handler.
* 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
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];
}
}
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;
* @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 ) {
if ( $this->page && $this->page !== 1 ) {
$query = 'page=' . urlencode( $this->page );
}
- if( $params ) {
+ if ( $params ) {
$query .= $query ? '&' . $params : $params;
}
$attribs = array(
# Previous parameters:
# $file, $url, $width, $height, $path = false, $page = false
- if( is_array( $parameters ) ) {
+ if ( is_array( $parameters ) ) {
$defaults = array(
'page' => false
);
$ser = $image->getMetadata();
if ( $ser ) {
$metadata = unserialize( $ser );
- if( $metadata['frameCount'] > 1 ) return true;
+ if ( $metadata['frameCount'] > 1 ) {
+ return true;
+ }
}
return false;
}
$metadata = unserialize( $image->getMetadata() );
wfRestoreWarnings();
- if( !$metadata || $metadata['frameCount'] <= 0 )
+ if ( !$metadata || $metadata['frameCount'] <= 0 ) {
return $original;
+ }
$info = array();
$info[] = $original;
}
} 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" );
}
$metadata = $file->getMetadata();
if ( $metadata ) {
$metadata = $this->unpackMetadata( $metadata );
- if( isset( $metadata['animated'] ) ) {
+ if ( isset( $metadata['animated'] ) ) {
return $metadata['animated'];
}
}
// File not found, broken, etc.
$metadata['error'] = array(
'message' => $e->getMessage(),
- 'code' => $e->getCode()
+ 'code' => $e->getCode()
);
wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
}
$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();
}
*/
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();
*/
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)." );
*/
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 ) {
}
$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 ) {
}
private function debug( $data ) {
- if( $this->mDebug ) {
+ if ( $this->mDebug ) {
wfDebug( "SVGReader: $data\n" );
}
}
$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 ) );
}
'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];
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.
}
# Check values
- if( $header['magic'] !== 'gimp xcf' ) {
+ if ( $header['magic'] !== 'gimp xcf' ) {
wfDebug( __METHOD__ . " '$filename' has invalid magic signature.\n" );
return false;
}
) {
// 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;
}
}
) {
// 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;
}
}
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
* @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 ) );
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>
<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
?>
<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(
</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(
}
?>
<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>
}
?>
<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(
<?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(
) ); ?>
<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>
?>
</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
?>
</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
}
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
}
?>" 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 ) {
?>
<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>
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
?>
<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
?>
<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(
</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(
<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
<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(
?>
</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'] ) {
<?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"
?>
</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>
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];
}
public static function createFromRequest( &$request, $type = null ) {
$type = $type ? $type : $request->getVal( 'wpSourceType', 'File' );
- if( !$type ) {
+ if ( !$type ) {
return null;
}
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;
}
/**
* 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 );
}
* Honor $wgMaxUploadSize
*/
$maxSize = self::getMaxUploadSize( $this->getSourceType() );
- if( $this->mFileSize > $maxSize ) {
+ if ( $this->mFileSize > $maxSize ) {
wfProfileOut( __METHOD__ );
return array(
'status' => self::FILE_TOO_LARGE,
* probably not accept it.
*/
$verification = $this->verifyFile();
- if( $verification !== true ) {
+ if ( $verification !== true ) {
wfProfileOut( __METHOD__ );
return array(
'status' => self::VERIFICATION_ERROR,
* 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__ );
**/
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 ) {
# 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' );
}
* 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 );
} 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;
$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;
}
}
$exists = self::getExistsWarning( $localFile );
- if( $exists !== false ) {
+ if ( $exists !== false ) {
$warnings['exists'] = $exists;
}
$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;
}
$user
);
- if( $status->isGood() ) {
+ if ( $status->isGood() ) {
if ( $watch ) {
$user->addWatch( $this->getLocalFile()->getTitle() );
}
$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;
}
*/
list( $partname, $ext ) = $this->splitExtensions( $this->mFilteredName );
- if( count( $ext ) ) {
+ if ( count( $ext ) ) {
$this->mFinalExtension = trim( $ext[count( $ext ) - 1] );
} else {
$this->mFinalExtension = '';
# 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;
}
* @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 );
}
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" );
"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!
# 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' );
$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 );
}
'<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;
$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;
/*
* 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" );
}
# 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;
}
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;
* @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 ) ) {
* @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 );
}
return array( 'warning' => 'was-deleted', 'file' => $file );
}
- if( strpos( $file->getName(), '.' ) == false ) {
+ if ( strpos( $file->getName(), '.' ) == false ) {
$partname = $file->getName();
$extension = '';
} else {
$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,
# 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,
}
}
- foreach( self::getFilenamePrefixBlacklist() as $prefix ) {
+ foreach ( self::getFilenamePrefixBlacklist() as $prefix ) {
if ( substr( $partname, 0, strlen( $prefix ) ) == $prefix ) {
return array(
'warning' => 'bad-prefix',
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 == '' ) {
// 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" );
// 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 );
}
$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" );
// 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
* @return Integer index of the current chunk
*/
private function getChunkIndex() {
- if( $this->mChunkIndex !== null ) {
+ if ( $this->mChunkIndex !== null ) {
return $this->mChunkIndex;
}
return 0;
}
private function getChunkFileKey( $index = null ) {
- if( $index === null ) {
+ if ( $index === null ) {
$index = $this->getChunkIndex();
}
return $this->mFileKey . '.' . $index;
function initializeFromRequest( &$request ) {
$upload = $request->getUpload( 'wpUploadFile' );
$desiredDestName = $request->getText( 'wpDestFile' );
- if( !$desiredDestName ) {
+ if ( !$desiredDestName ) {
$desiredDestName = $upload->getName();
}
// 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" );
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'] );
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 ) {
__METHOD__
);
- if( !$row ) {
+ if ( !$row ) {
throw new UploadStashNoSuchKeyException( "No such key ($key), cannot remove" );
}
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 {