Skip to content

Commit

Permalink
Code style: Clean up spacing [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
ginatrapani committed Jun 18, 2012
1 parent 58dc741 commit dc473ce
Show file tree
Hide file tree
Showing 40 changed files with 156 additions and 156 deletions.
4 changes: 2 additions & 2 deletions extras/dev/makemodel/classes/class.ModelMaker.php
Expand Up @@ -66,7 +66,7 @@ public function __construct($table_name, $object_name, $parent_object_name = nul
$this->parent_object_name = $parent_object_name;
$this->config = Config::getInstance();
//connect to database
if(is_null(self::$pdo)) {
if (is_null(self::$pdo)) {
self::$pdo = $this->connect();
}
}
Expand Down Expand Up @@ -105,7 +105,7 @@ public function makeModel() {
private function connect() {
$db_string = sprintf("mysql:dbname=%s;host=%s", $this->config->getValue('db_name'),
$this->config->getValue('db_host'));
if($this->DEBUG) {
if ($this->DEBUG) {
echo "DEBUG: Connecting to $db_string\n";
}
$db_socket = $this->config->getValue('db_socket');
Expand Down
2 changes: 1 addition & 1 deletion tests/TestOfBackupMySQLDAO.php
Expand Up @@ -180,7 +180,7 @@ public function testImportDataDropNewTables() {

public function recursiveDelete($str){
if (is_file($str)){
if (! preg_match("MAKETHISDIRWRITABLE", $str)) {
if (!preg_match("MAKETHISDIRWRITABLE", $str)) {
return @unlink($str);
} else {
return true;
Expand Down
4 changes: 2 additions & 2 deletions tests/TestOfTableStatsMySQLDAO.php
Expand Up @@ -53,9 +53,9 @@ public function testGetCounts() {
// no counts...
$counts = $table_stats_daa->getTableRowCounts();
foreach($counts as $table) {
if($table['table'] == $this->table_prefix . 'options') {
if ($table['table'] == $this->table_prefix . 'options') {
$this->assertEqual($table['count'], 1);
} else if($table['table'] == $this->table_prefix . 'plugins') {
} else if ($table['table'] == $this->table_prefix . 'plugins') {
$this->assertEqual($table['count'], 4);
} else {
$this->assertEqual($table['count'], 0);
Expand Down
10 changes: 5 additions & 5 deletions tests/TestOfUpgradeDatabaseController.php
Expand Up @@ -47,7 +47,7 @@ public function setUp(){

$this->init_db_version = $config->getValue('THINKUP_VERSION');
$new_version = $config->getValue('THINKUP_VERSION') + 10;
if (! preg_match('/\./', $new_version)) {
if (!preg_match('/\./', $new_version)) {
$new_version .= '.0';
}
$config->setValue('THINKUP_VERSION', $new_version ); //set a high version num
Expand Down Expand Up @@ -829,7 +829,7 @@ private function migrationFiles($count = 1) {
$config = Config::getInstance();
$app_version = $config->getValue('THINKUP_VERSION');
$migration_version = $app_version - 1;
if (! preg_match('/\./', $migration_version)) {
if (!preg_match('/\./', $migration_version)) {
$migration_version .= '.0';
}
$migration_test1 = $this->migrations_test_dir . $this->migrations_file1;
Expand All @@ -851,7 +851,7 @@ private function migrationFiles($count = 1) {
private function newMigrationFiles($name, $old = false, $add_sql = false, $no_version = false, $date = false) {
$config = Config::getInstance();
$app_version = $config->getValue('THINKUP_VERSION');
if (! $date) {
if (!$date) {
$date = '2011-09-21';
}
$migration_version = $app_version;
Expand All @@ -865,7 +865,7 @@ private function newMigrationFiles($name, $old = false, $add_sql = false, $no_ve
$migration_test1 = $this->migrations_test_dir . $this->migrations_file2;
}
$migration1 = $this->migrations_dir . $date . '_' . $name;
if (! $no_version) {
if (!$no_version) {
$migration1 .= '_v' . $migration_version;
}
$migration1 .= '.sql';
Expand All @@ -883,7 +883,7 @@ private function newMigrationFiles($name, $old = false, $add_sql = false, $no_ve
private function newMigrationFiles2($name, $date = false, $bad_sql = false) {
$config = Config::getInstance();
$app_version = $config->getValue('THINKUP_VERSION');
if (! $date) {
if (!$date) {
$date = '2011-09-21';
}
$migration_version = $app_version;
Expand Down
4 changes: 2 additions & 2 deletions tests/classes/class.TestController.php
Expand Up @@ -30,10 +30,10 @@
class TestController extends ThinkUpController {

public function control() {
if(isset($_GET['json'])) {
if (isset($_GET['json'])) {
$this->setJsonData( array( 'aname' => 'a value', 'alist' => array('apple', 'pear', 'banana'), 'alink' =>
'http://thinkupapp.com'));
} else if(isset($_GET['text'])) {
} else if (isset($_GET['text'])) {
$this->setContentType('text/plain');
} else if (isset($_GET['png'])) {
$this->setContentType('image/png');
Expand Down
2 changes: 1 addition & 1 deletion tests/classes/class.TestPreAuthController.php
Expand Up @@ -36,7 +36,7 @@ public function authControl() {
}

protected function preAuthControl() {
if(isset($_GET['preauth'])) {
if (isset($_GET['preauth'])) {
$this->addToView('test', 'We are preauthed!');
} else {
return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/classes/class.ThinkUpTestDatabaseHelper.php
Expand Up @@ -115,7 +115,7 @@ private function getDBString() {
}
$db_type = $config->getValue('db_type');

if(!$db_type) {
if (!$db_type) {
$db_type = 'mysql';
}
$db_socket = $config->getValue('db_socket');
Expand Down
2 changes: 1 addition & 1 deletion tests/classes/class.ThinkUpUnitTestCase.php
Expand Up @@ -52,7 +52,7 @@ public function setUp() {

$config = Config::getInstance();

if (! self::ramDiskTestMode() ) {
if (!self::ramDiskTestMode() ) {
//Override default CFG values
$THINKUP_CFG['db_name'] = $this->test_database_name;
$config->setValue('db_name', $this->test_database_name);
Expand Down
46 changes: 23 additions & 23 deletions tests/fixtures/class.FixtureBuilder.php
Expand Up @@ -102,7 +102,7 @@ class FixtureBuilder {
public function __construct($debug = false) {
$this->DEBUG = $debug ? $debug : $this->DEBUG;
$this->config = Config::getInstance();
if(is_null(self::$pdo)) {
if (is_null(self::$pdo)) {
self::$pdo = $this->connect();
}
}
Expand All @@ -128,7 +128,7 @@ public static function build($table, $args = null, $debug = false) {
private function connect() {
$db_string = sprintf("mysql:dbname=%s;host=%s", $this->config->getValue('db_name'),
$this->config->getValue('db_host'));
if($this->DEBUG) { echo "DEBUG: Connecting to $db_string\n"; }
if ($this->DEBUG) { echo "DEBUG: Connecting to $db_string\n"; }
$db_socket = $this->config->getValue('db_socket');
if ( $db_socket) {
$db_string.=";unix_socket=".$db_socket;
Expand Down Expand Up @@ -164,7 +164,7 @@ public static function truncateTable($table) {
public function describeTable($table) {
$columns = array();
$table = $this->config->getValue('table_prefix') . $table;
if(isset(self::$table_descs[$table])) {
if (isset(self::$table_descs[$table])) {
return self::$table_descs[$table];
}
try {
Expand All @@ -191,45 +191,45 @@ public function buildData($table, $args = null) {
$sql = "INSERT INTO " . $this->config->getValue('table_prefix') . $table;
foreach( $columns as $column) {
$field_value = (! is_null($args)) && isset( $args[ $column['Field'] ]) ? $args[ $column['Field'] ] : null;
if( isset($column['Key']) && $column['Key'] == 'UNI' && ! $field_value) {
if ( isset($column['Key']) && $column['Key'] == 'UNI' && ! $field_value) {
throw new FixtureBuilderException($column['Field'] .
' has a unique key constraint, a value must be defined for this column');
}
if( isset($column['Extra']) && $column['Extra'] == 'auto_increment' && ! $field_value ) {
if ( isset($column['Extra']) && $column['Extra'] == 'auto_increment' && ! $field_value ) {
continue;
}
if(isset($field_value)) {
if(gettype($field_value) == 'array') {
if(! isset($field_value['function'])) {
if (isset($field_value)) {
if (gettype($field_value) == 'array') {
if (!isset($field_value['function'])) {
throw new FixtureBuilderException("Column value array/hash must have a function defined");
} else {
$column['value'] = $field_value;
}
} else {
if(preg_match('/^(times|date)/', $column['Type'])) {
if (preg_match('/^(times|date)/', $column['Type'])) {
$column['value'] = $this->genDate($field_value);
} else {
$column['value'] = $field_value;
}
}
} else if(isset($args) && array_search($column['Field'], array_keys($args)) !== false) {
} else if (isset($args) && array_search($column['Field'], array_keys($args)) !== false) {
// Column value was specified, but is null; we just don't want to specify a value for that column
continue;
} else if (isset($column['Default']) && $column['Default'] != ''
&& $column['Default'] != 'CURRENT_TIMESTAMP') {
$column['value'] = $column['Default'];
} else {
if(preg_match('/^enum/', $column['Type'])) {
if (preg_match('/^enum/', $column['Type'])) {
$column['value'] = $this->genEnum( $column['Type'] );
} else if(preg_match('/^decimal/', $column['Type'])) {
} else if (preg_match('/^decimal/', $column['Type'])) {
$column['value'] = $this->genDecimal($column['Type']);
} else if(preg_match('/^(int|tinyint)/', $column['Type'])) {
} else if (preg_match('/^(int|tinyint)/', $column['Type'])) {
$column['value'] = $this->genInt();
} else if(preg_match('/^bigint/', $column['Type'])) {
} else if (preg_match('/^bigint/', $column['Type'])) {
$column['value'] = $this->genBigint();
} else if(preg_match('/^(times|date)/', $column['Type'])) {
} else if (preg_match('/^(times|date)/', $column['Type'])) {
$column['value'] = $this->genDate();
} else if(preg_match('/^(varchar|text|tinytext|mediumtext|longtext|blob)/', $column['Type'])) {
} else if (preg_match('/^(varchar|text|tinytext|mediumtext|longtext|blob)/', $column['Type'])) {
$column['value'] = $this->genVarchar();
}
}
Expand All @@ -239,12 +239,12 @@ public function buildData($table, $args = null) {
$values = array();
$values_string = '';
foreach(array_values($this->columns) as $value) {
if($values_string == '') {
if ($values_string == '') {
$values_string = ' (';
} else {
$values_string .= ',';
}
if(gettype($value) == 'array') {
if (gettype($value) == 'array') {
$values_string .= $value['function'];
} else {
array_push($values, $value);
Expand All @@ -255,7 +255,7 @@ public function buildData($table, $args = null) {
$stmt = self::$pdo->prepare($sql);
$stmt->execute($values);
$last_insert_id = self::$pdo->lastInsertId();
if(isset($last_insert_id)) {
if (isset($last_insert_id)) {
$this->columns['last_insert_id'] = $last_insert_id;
}
}
Expand Down Expand Up @@ -369,14 +369,14 @@ public function genDecimal($values) {
public function genDate($value = null) {
$time_inc_map = array('h' => 'HOUR', 'd' => 'DAY', 'm' => 'MINUTE', 's' => 'SECOND');
$sql = 'select now() - interval rand()*100000000 second';
if($value) {
if(preg_match('/^(\+|\-)(\d+)(s|m|h|d)/', $value, $matches)) {
if ($value) {
if (preg_match('/^(\+|\-)(\d+)(s|m|h|d)/', $value, $matches)) {
$sql = "select now() $matches[1] interval $matches[2] " . $time_inc_map[$matches[3]];
} else {
$sql = null;
}
}
if($sql) {
if ($sql) {
$stmt = self::$pdo->query( $sql . ' as FDATE' );
$data = $stmt->fetch();
return $data[0];
Expand All @@ -390,7 +390,7 @@ public function genDate($value = null) {
* truncates the fixture table
*/
function __destruct() {
if(isset($this->table)) {
if (isset($this->table)) {
$table = Config::getInstance()->getValue('table_prefix') . $this->table;
try {
self::$pdo->query('truncate table ' . $table);
Expand Down
Expand Up @@ -93,7 +93,7 @@ public function authControl() {
if (isset($_POST['reset_api_key']) && $_POST['reset_api_key'] == 'Reset API Key') {
$this->validateCSRFToken();
$api_key = $owner_dao->resetAPIKey($owner->id);
if(! $api_key) {
if (!$api_key) {
throw new Exception("Unbale to update user's api_key, something bad must have happened");
}
$this->addSuccessMessage("Your API Key has been reset! Please update your ThinkUp RSS feed subscription.",
Expand Down
4 changes: 2 additions & 2 deletions webapp/_lib/controller/class.AppConfigController.php
Expand Up @@ -73,7 +73,7 @@ public function adminControl() {
if ( isset($app_config[$dep_key]['match'])
&& ! preg_match($app_config[$dep_key]['match'], $value) ) {
$required[$dep_key] = $app_config[$dep_key]['title'] .
' is required if ' . $app_config[$key]['title'] .
' is required if ' . $app_config[$key]['title'] .
' is set ' . $app_config[$dep_key]['match_message'];
}
}
Expand Down Expand Up @@ -104,7 +104,7 @@ public function adminControl() {
}
foreach($app_config as $key => $value) {
// delete the record if it exists and is empty in the post request
if (! isset($config_values[$key]['value']) || $config_values[$key]['value'] == '') {
if (!isset($config_values[$key]['value']) || $config_values[$key]['value'] == '') {
$config = $option_dao->getOptionByName(OptionDAO::APP_OPTIONS, $key);
if ($config) {
$option_dao->deleteOption($config->option_id);
Expand Down
4 changes: 2 additions & 2 deletions webapp/_lib/controller/class.BackupController.php
Expand Up @@ -47,7 +47,7 @@ public function __construct($session_started=false) {
public function adminControl() {
$this->disableCaching();
$this->view_mgr->addHelp('backup', 'install/backup');
if (! self::checkForZipSupport()) {
if (!self::checkForZipSupport()) {
$this->addToView('no_zip_support', true);
}
// pass the count of the table with the most records
Expand Down Expand Up @@ -151,7 +151,7 @@ public static function mutexLock($release = false) {
} else {
// Everyone needs to check the global mutex
$lock_successful = $mutex_dao->getMutex($global_mutex_name);
if (! $lock_successful) {
if (!$lock_successful) {
throw new CrawlerLockedException("A crawl is in progress, please wait until completed...");
}
}
Expand Down
Expand Up @@ -63,7 +63,7 @@ public function __construct($session_started=false) {

public function adminControl() {
$this->disableCaching();
if (! BackupController::checkForZipSupport()) {
if (!BackupController::checkForZipSupport()) {
$this->addToView('no_zip_support', true);
} else {
$instance_dao = DAOFactory::getDAO('InstanceDAO');
Expand All @@ -83,7 +83,7 @@ public function adminControl() {
'describes how to import that data into an existing ThinkUp installation.
');
if (! self::exportData($instance->network_username, $instance->network)) {
if (!self::exportData($instance->network_username, $instance->network)) {
return $this->generateView();
}
self::generateZipFile();
Expand Down
6 changes: 3 additions & 3 deletions webapp/_lib/controller/class.GridController.php
Expand Up @@ -91,7 +91,7 @@ public function authControl($owner = false) {
$username = $_GET['u'];
$ownerinstance_dao = DAOFactory::getDAO('OwnerInstanceDAO');
$owner_dao = DAOFactory::getDAO('OwnerDAO');
if (! $owner) {
if (!$owner) {
$owner = $owner_dao->getByEmail($this->getLoggedInUser());
}
$instance = $instance_dao->getByUsername($username, $_GET['n']);
Expand All @@ -105,7 +105,7 @@ public function authControl($owner = false) {
$post_dao = DAOFactory::getDAO('PostDAO');
$posts_it = $post_dao->getRepliesToPostIterator($_GET['t'],$_GET['n'], 'default','km',
$public_search);
if (! $public_search) {
if (!$public_search) {
$private_reply_search = true;
}
} else {
Expand All @@ -125,7 +125,7 @@ public function authControl($owner = false) {
}
foreach($posts_it as $key => $value) {
if ($private_reply_search) {
if (! $ownerinstance_dao->doesOwnerHaveAccessToPost($owner, $value)) {
if (!$ownerinstance_dao->doesOwnerHaveAccessToPost($owner, $value)) {
continue;
}
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/_lib/controller/class.GridExportController.php
Expand Up @@ -52,7 +52,7 @@ public function authControl() {
$_POST['grid_export_data'] = stripslashes($_POST['grid_export_data']);
}
$data = json_decode( $_POST['grid_export_data'] );
if (! $data ) {
if (!$data ) {
echo('No search data to export.' . json_last_error() . "<br />");
echo( $_POST['grid_export_data']);
} else {
Expand Down
2 changes: 1 addition & 1 deletion webapp/_lib/controller/class.PluginOptionController.php
Expand Up @@ -97,7 +97,7 @@ public function setPluginOptions($plugin_id) {
}
} else {
$insert_id = $plugin_option_dao->insertOption($plugin_id, $name, $value);
if (! $insert_id) {
if (! $insert_id) {
$this->json_data['message'] = "Unable to add plugin option: $name";
return;
} else {
Expand Down
2 changes: 1 addition & 1 deletion webapp/_lib/controller/class.UpgradeDatabaseController.php
Expand Up @@ -147,7 +147,7 @@ public function authControl() {
// pass the count of the table with the most records
$table_stats_dao = DAOFactory::getDAO('TableStatsDAO');
$table_counts = $table_stats_dao->getTableRowCounts();
if($table_counts[0]['count'] > self::$WARN_TABLE_ROW_COUNT) {
if ($table_counts[0]['count'] > self::$WARN_TABLE_ROW_COUNT) {
$this->addToView('high_table_row_count',$table_counts[0]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/_lib/model/class.AppUpgraderDiskUtil.php
Expand Up @@ -216,7 +216,7 @@ public function writeZip($data) {
$result = file_put_contents($filename, $data);
if ($result === false) {
throw new Exception("Unable to save ".$filename.". Result ".$result);
} else if(is_int($result)) {
} else if (is_int($result)) {
if ($result < 1) {
throw new Exception("Unable to save ".$filename.". Wrote ".$result.' bytes.');
}
Expand Down

0 comments on commit dc473ce

Please sign in to comment.