From 5c81d06b63e4172dae5ebfa745b642e26530e202 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Tue, 8 Jun 2004 23:56:09 +0000 Subject: [PATCH] some double quoting replaced by single quoting --- includes/Block.php | 34 ++++++++++++------------- includes/BlockCache.php | 10 ++++---- includes/CacheManager.php | 30 +++++++++++----------- includes/DateFormatter.php | 52 +++++++++++++++++++------------------- 4 files changed, 63 insertions(+), 63 deletions(-) diff --git a/includes/Block.php b/includes/Block.php index d98b07baeb..c830ccdc45 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -15,8 +15,8 @@ class Block /* public*/ var $mAddress, $mUser, $mBy, $mReason, $mTimestamp, $mAuto, $mId, $mExpiry; /* private */ var $mNetworkBits, $mIntegerAddr; - function Block( $address = "", $user = "", $by = 0, $reason = "", - $timestamp = "" , $auto = 0, $expiry = "" ) + function Block( $address = '', $user = '', $by = 0, $reason = '', + $timestamp = '' , $auto = 0, $expiry = '' ) { $this->mAddress = $address; $this->mUser = $user; @@ -38,14 +38,14 @@ class Block function clear() { - $mAddress = $mReason = $mTimestamp = ""; + $mAddress = $mReason = $mTimestamp = ''; $mUser = $mBy = 0; } # Get a ban from the DB, with either the given address or the given username function load( $address, $user = 0, $killExpired = true ) { - $fname = "Block::load"; + $fname = 'Block::load'; $ret = false; $killed = false; @@ -109,7 +109,7 @@ class Block function initialiseRange() { if ( $this->mUser == 0 ) { - $rangeParts = explode( "/", $this->mAddress ); + $rangeParts = explode( '/', $this->mAddress ); if ( count( $rangeParts ) == 2 ) { $this->mNetworkBits = $rangeParts[1]; } else { @@ -125,8 +125,8 @@ class Block # Callback with a Block object for every block /*static*/ function enumBlocks( $callback, $tag, $killExpired = true ) { - $sql = "SELECT * FROM ipblocks ORDER BY ipb_timestamp DESC"; - $res = wfQuery( $sql, DB_READ, "Block::enumBans" ); + $sql = 'SELECT * FROM ipblocks ORDER BY ipb_timestamp DESC'; + $res = wfQuery( $sql, DB_READ, 'Block::enumBans' ); $block = new Block(); while ( $row = wfFetchObject( $res ) ) { @@ -144,25 +144,25 @@ class Block function delete() { - $fname = "Block::delete"; + $fname = 'Block::delete'; if ( $this->mAddress == "" ) { $sql = "DELETE FROM ipblocks WHERE ipb_id={$this->mId}"; } else { $sql = "DELETE FROM ipblocks WHERE ipb_address='" . wfStrencode( $this->mAddress ) . "'"; } - wfQuery( $sql, DB_WRITE, "Block::delete" ); + wfQuery( $sql, DB_WRITE, 'Block::delete' ); $this->clearCache(); } function insert() { - $sql = "INSERT INTO ipblocks - (ipb_address, ipb_user, ipb_by, ipb_reason, ipb_timestamp, ipb_auto, ipb_expiry ) - VALUES ('" . wfStrencode( $this->mAddress ) . "', {$this->mUser}, {$this->mBy}, '" . + $sql = 'INSERT INTO ipblocks ' . + '(ipb_address, ipb_user, ipb_by, ipb_reason, ipb_timestamp, ipb_auto, ipb_expiry )' . + "VALUES ('" . wfStrencode( $this->mAddress ) . "', {$this->mUser}, {$this->mBy}, '" . wfStrencode( $this->mReason ) . "','{$this->mTimestamp}', {$this->mAuto}, '{$this->mExpiry}')"; - wfQuery( $sql, DB_WRITE, "Block::insert" ); + wfQuery( $sql, DB_WRITE, 'Block::insert' ); $this->clearCache(); } @@ -188,7 +188,7 @@ class Block function isValid() { - return $this->mAddress != ""; + return $this->mAddress != ''; } function updateTimestamp() @@ -197,10 +197,10 @@ class Block $this->mTimestamp = wfTimestampNow(); $this->mExpiry = Block::getAutoblockExpiry( $this->mTimestamp ); - wfQuery( "UPDATE ipblocks SET " . + wfQuery( 'UPDATE ipblocks SET ' . "ipb_timestamp='" . $this->mTimestamp . "', " . "ipb_expiry='" . $this->mExpiry . "' " . - "WHERE ipb_address='" . wfStrencode( $this->mAddress ) . "'", DB_WRITE, "Block::updateTimestamp" ); + "WHERE ipb_address='" . wfStrencode( $this->mAddress ) . "'", DB_WRITE, 'Block::updateTimestamp' ); $this->clearCache(); } @@ -232,7 +232,7 @@ class Block /* static */ function normaliseRange( $range ) { - $parts = explode( "/", $range ); + $parts = explode( '/', $range ); if ( count( $parts ) == 2 ) { $shift = 32 - $parts[1]; $ipint = ip2long( $parts[0] ); diff --git a/includes/BlockCache.php b/includes/BlockCache.php index 135d206d9b..8b49a0142c 100644 --- a/includes/BlockCache.php +++ b/includes/BlockCache.php @@ -7,15 +7,15 @@ class BlockCache { var $mData = false, $mMemcKey; - function BlockCache( $deferLoad = false, $dbName = "" ) + function BlockCache( $deferLoad = false, $dbName = '' ) { global $wgDBname; - if ( $dbName == "" ) { + if ( $dbName == '' ) { $dbName = $wgDBname; } - $this->mMemcKey = "$dbName:ipblocks"; + $this->mMemcKey = $dbName.':ipblocks'; if ( !$deferLoad ) { $this->load(); @@ -39,7 +39,7 @@ class BlockCache if ( !is_array( $this->mData ) ) { # Load from DB $this->mData = array(); - Block::enumBlocks( "wfBlockCacheInsert", "" ); # Calls $this->insert() + Block::enumBlocks( 'wfBlockCacheInsert', '' ); # Calls $this->insert() } if ( $saveMemc ) { @@ -78,7 +78,7 @@ class BlockCache if ( $blocked ) { # Clear low order bits if ( $networkBits != 32 ) { - $ip .= "/$networkBits"; + $ip .= '/'.$networkBits; $ip = Block::normaliseRange( $ip ); } $block = new Block(); diff --git a/includes/CacheManager.php b/includes/CacheManager.php index 5ba6ec7318..e85f69d94b 100644 --- a/includes/CacheManager.php +++ b/includes/CacheManager.php @@ -11,14 +11,14 @@ # $wgFileCacheDirectory # $wgUseGzip -require_once( "Title.php" ); +require_once( 'Title.php' ); class CacheManager { var $mTitle, $mFileCache; function CacheManager( &$title ) { $this->mTitle =& $title; - $this->mFileCache = ""; + $this->mFileCache = ''; } function fileCacheName() { @@ -27,14 +27,14 @@ class CacheManager { $hash = md5( $key = $this->mTitle->getDbkey() ); if( $this->mTitle->getNamespace() ) $key = $wgLang->getNsText( $this->mTitle->getNamespace() ) . ":" . $key; - $key = str_replace( ".", "%2E", urlencode( $key ) ); + $key = str_replace( '.', '%2E', urlencode( $key ) ); $hash1 = substr( $hash, 0, 1 ); $hash2 = substr( $hash, 0, 2 ); $this->mFileCache = "{$wgFileCacheDirectory}/{$hash1}/{$hash2}/{$key}.html"; if($this->useGzip()) - $this->mFileCache .= ".gz"; + $this->mFileCache .= '.gz'; wfDebug( " fileCacheName() - {$this->mFileCache}\n" ); } @@ -75,7 +75,7 @@ class CacheManager { function fetchPageText() { if( $this->useGzip() ) { /* Why is there no gzfile_get_contents() or gzdecode()? */ - return implode( "", gzfile( $this->fileCacheName() ) ); + return implode( '', gzfile( $this->fileCacheName() ) ); } else { return $this->fetchRawText(); } @@ -91,7 +91,7 @@ class CacheManager { if( $this->useGzip() ) { if( wfClientAcceptsGzip() ) { - header( "Content-Encoding: gzip" ); + header( 'Content-Encoding: gzip' ); } else { /* Send uncompressed */ readgzfile( $filename ); @@ -103,38 +103,38 @@ class CacheManager { function checkCacheDirs() { $filename = $this->fileCacheName(); - $mydir2=substr($filename,0,strrpos($filename,"/")); # subdirectory level 2 - $mydir1=substr($mydir2,0,strrpos($mydir2,"/")); # subdirectory level 1 + $mydir2=substr($filename,0,strrpos($filename,'/')); # subdirectory level 2 + $mydir1=substr($mydir2,0,strrpos($mydir2,'/')); # subdirectory level 1 if(!file_exists($mydir1)) { mkdir($mydir1,0775); } # create if necessary if(!file_exists($mydir2)) { mkdir($mydir2,0775); } } function saveToFileCache( $text ) { - if(strcmp($text,"") == 0) return ""; + if(strcmp($text,'') == 0) return ''; wfDebug(" saveToFileCache()\n", false); $this->checkCacheDirs(); - $f = fopen( $this->fileCacheName(), "w" ); + $f = fopen( $this->fileCacheName(), 'w' ); if($f) { $now = wfTimestampNow(); if( $this->useGzip() ) { - $rawtext = str_replace( "", - "\n", + $rawtext = str_replace( '', + '\n", $text ); $text = gzencode( $rawtext ); } else { - $text = str_replace( "", - "\n", + $text = str_replace( '', + '\n", $text ); } fwrite( $f, $text ); fclose( $f ); if( $this->useGzip() ) { if( wfClientAcceptsGzip() ) { - header( "Content-Encoding: gzip" ); + header( 'Content-Encoding: gzip' ); return $text; } else { return $rawtext; diff --git a/includes/DateFormatter.php b/includes/DateFormatter.php index e903f53daa..45196512f5 100755 --- a/includes/DateFormatter.php +++ b/includes/DateFormatter.php @@ -18,7 +18,7 @@ define("DF_LAST", 8); class DateFormatter { var $mSource, $mTarget; - var $monthNames = "", $rxDM, $rxMD, $rxDMY, $rxYDM, $rxMDY, $rxYMD; + var $monthNames = '', $rxDM, $rxMD, $rxDMY, $rxYDM, $rxMDY, $rxYMD; var $regexes, $pDays, $pMonths, $pYears; var $rules, $xMonths; @@ -58,24 +58,24 @@ class DateFormatter # Extraction keys # See the comments in replace() for the meaning of the letters - $this->keys[DF_DMY] = "jFY"; - $this->keys[DF_YDM] = "Y jF"; - $this->keys[DF_MDY] = "FjY"; - $this->keys[DF_YMD] = "Y Fj"; - $this->keys[DF_DM] = "jF"; - $this->keys[DF_MD] = "Fj"; - $this->keys[DF_ISO1] = "ymd"; # y means ISO year - $this->keys[DF_ISO2] = "ymd"; + $this->keys[DF_DMY] = 'jFY'; + $this->keys[DF_YDM] = 'Y jF'; + $this->keys[DF_MDY] = 'FjY'; + $this->keys[DF_YMD] = 'Y Fj'; + $this->keys[DF_DM] = 'jF'; + $this->keys[DF_MD] = 'Fj'; + $this->keys[DF_ISO1] = 'ymd'; # y means ISO year + $this->keys[DF_ISO2] = 'ymd'; # Target date formats - $this->targets[DF_DMY] = "[[F j|j F]] [[Y]]"; - $this->targets[DF_YDM] = "[[Y]], [[F j|j F]]"; - $this->targets[DF_MDY] = "[[F j]], [[Y]]"; - $this->targets[DF_YMD] = "[[Y]] [[F j]]"; - $this->targets[DF_DM] = "[[F j|j F]]"; - $this->targets[DF_MD] = "[[F j]]"; - $this->targets[DF_ISO1] = "[[Y|y]]-[[F j|m-d]]"; - $this->targets[DF_ISO2] = "[[y-m-d]]"; + $this->targets[DF_DMY] = '[[F j|j F]] [[Y]]'; + $this->targets[DF_YDM] = '[[Y]], [[F j|j F]]'; + $this->targets[DF_MDY] = '[[F j]], [[Y]]'; + $this->targets[DF_YMD] = '[[Y]] [[F j]]'; + $this->targets[DF_DM] = '[[F j|j F]]'; + $this->targets[DF_MD] = '[[F j]]'; + $this->targets[DF_ISO1] = '[[Y|y]]-[[F j|m-d]]'; + $this->targets[DF_ISO2] = '[[y-m-d]]'; # Rules # pref source target @@ -103,7 +103,7 @@ class DateFormatter # Default $this->mTarget = $i; } - $text = preg_replace_callback( $this->regexes[$i], "wfMainDateReplace", $text ); + $text = preg_replace_callback( $this->regexes[$i], 'wfMainDateReplace', $text ); } return $text; } @@ -123,7 +123,7 @@ class DateFormatter $format = $this->targets[$this->mTarget]; # Construct new date - $text = ""; + $text = ''; $fail = false; for ( $p=0; $p < strlen( $format ); $p++ ) { @@ -131,7 +131,7 @@ class DateFormatter switch ( $char ) { case 'd': # ISO day of month if ( is_null($bits['d']) ) { - $text .= sprintf( "%02d", $bits['j'] ); + $text .= sprintf( '%02d', $bits['j'] ); } else { $text .= $bits['d']; } @@ -139,7 +139,7 @@ class DateFormatter case 'm': # ISO month if ( is_null($bits['m']) ) { $m = $this->makeIsoMonth( $bits['F'] ); - if ( !$m || $m == "00" ) { + if ( !$m || $m == '00' ) { $fail = true; } else { $text .= $m; @@ -194,14 +194,14 @@ class DateFormatter function getMonthRegex() { global $wgMonthNamesEn; - return implode( "|", $wgMonthNamesEn ); + return implode( '|', $wgMonthNamesEn ); } # Makes an ISO month, e.g. 02, from a month name function makeIsoMonth( $monthName ) { $n = $this->xMonths[strtolower( $monthName )]; - return sprintf( "%02d", $n ); + return sprintf( '%02d', $n ); } function makeIsoYear( $year ) @@ -210,10 +210,10 @@ class DateFormatter if ( substr( $year, -2 ) == 'BC' ) { $num = IntVal(substr( $year, 0, -3 )) - 1; # PHP bug note: sprintf( "%04d", -1 ) fails poorly - $text = sprintf( "-%04d", $num ); + $text = sprintf( '-%04d', $num ); } else { - $text = sprintf( "%04d", $year ); + $text = sprintf( '%04d', $year ); } return $text; } @@ -221,7 +221,7 @@ class DateFormatter function makeNormalYear( $iso ) { if ( $iso{0} == '-' ) { - $text = (IntVal( substr( $iso, 1 ) ) - 1) . " BC"; + $text = (IntVal( substr( $iso, 1 ) ) - 1) . ' BC'; } else { $text = IntVal( $iso ); } -- 2.20.1