Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 3bd4908

Browse files
author
Charles Marion
committed
STYLE: Fixed style
1 parent 52ce3e4 commit 3bd4908

File tree

7 files changed

+493
-493
lines changed

7 files changed

+493
-493
lines changed

core/controllers/InstallController.php

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class InstallController extends AppController
1515
*/
1616
function init()
1717
{
18-
if(file_exists(BASE_PATH."/core/configs/database.local.ini")&&file_exists(BASE_PATH."/core/configs/application.local.ini"))
18+
if(file_exists(BASE_PATH."/core/configs/database.local.ini") && file_exists(BASE_PATH."/core/configs/application.local.ini"))
1919
{
2020
throw new Zend_Exception("Midas is already installed.");
2121
}
@@ -30,7 +30,7 @@ function indexAction()
3030
{
3131
$this->_redirect('/install/step3');
3232
}
33-
$this->view->header="Step1: Server Configuration";
33+
$this->view->header = "Step1: Server Configuration";
3434
// Check PHP extension / function
3535
$phpextensions = array (
3636
"curl_init" => array(false, "Certain features, such as statistics won't be available. It is recommended to enable/install cURL."),
@@ -41,14 +41,14 @@ function indexAction()
4141
$this->view->writable = is_writable(BASE_PATH.'/core/configs');
4242
$this->view->convertfound = $this->Component->Utility->isImageMagickWorking();
4343
$this->view->basePath = BASE_PATH;
44-
if(!empty($_POST)&&$this->view->writable)
44+
if(!empty($_POST) && $this->view->writable)
4545
{
4646
$this->_redirect("/install/step2");
4747
}
4848
} // end method indexAction
4949

5050

51-
/**
51+
/**
5252
* @method step2Action()
5353
*/
5454
function step2Action()
@@ -57,7 +57,7 @@ function step2Action()
5757
{
5858
$this->_redirect('/install/step3');
5959
}
60-
$this->view->header="Step2: Database Configuration";
60+
$this->view->header = "Step2: Database Configuration";
6161
// Check PHP extension / function
6262
$phpextensions = array (
6363
"mysql" => array(false, ''),
@@ -71,22 +71,24 @@ function step2Action()
7171

7272
foreach($phpextensions as $key => $t)
7373
{
74-
if(!file_exists(BASE_PATH."/core/database/{$key}"))
74+
if(!file_exists(BASE_PATH."/core/database/".$key))
7575
{
7676
unset($phpextensions[$key]);
7777
}
7878
else
7979
{
8080
$form = $this->Form->Install->createDBForm($key);
8181
$port = $form->getElement('port');
82-
switch ($key)
82+
switch($key)
8383
{
8484
case 'mysql':
8585
$port->setValue('3306');
8686
break;
8787
case 'pgsql':
8888
$port->setValue('5432');
8989
break;
90+
default:
91+
break;
9092
}
9193
$this->view->databaseType[$key] = $this->getFormAsArray($form);
9294
}
@@ -102,13 +104,13 @@ function step2Action()
102104
$form = $this->Form->Install->createDBForm($type);
103105
if($form->isValid($this->getRequest()->getPost()))
104106
{
105-
$databaseConfig = parse_ini_file (BASE_PATH.'/core/configs/database.ini',true);
106-
$MyDirectory = opendir(BASE_PATH."/core/database/{$type}");
107-
while($Entry = @readdir($MyDirectory))
107+
$databaseConfig = parse_ini_file(BASE_PATH.'/core/configs/database.ini', true);
108+
$MyDirectory = opendir(BASE_PATH."/core/database/".$type);
109+
while($Entry = readdir($MyDirectory))
108110
{
109111
if(strpos($Entry, ".sql") != false)
110112
{
111-
$sqlFile = BASE_PATH."/core/database/{$type}/".$Entry;
113+
$sqlFile = BASE_PATH."/core/database/".$type."/".$Entry;
112114
}
113115
}
114116
if(!isset($sqlFile))
@@ -121,65 +123,65 @@ function step2Action()
121123
case 'mysql':
122124
$this->Component->Utility->run_mysql_from_file($sqlFile,
123125
$form->getValue('host'), $form->getValue('username'), $form->getValue('password'), $form->getValue('dbname'), $form->getValue('port'));
124-
$params= array(
125-
'host' => $form->getValue('host'),
126-
'username' => $form->getValue('username'),
127-
'password' => $form->getValue('password'),
128-
'dbname' => $form->getValue('dbname'),
129-
'port' => $form->getValue('port'),
130-
);
131-
132-
$databaseConfig['production']['database.type'] = 'pdo';
133-
$databaseConfig['development']['database.type'] = 'pdo';
134-
$databaseConfig['production']['database.adapter'] = 'PDO_MYSQL';
135-
$databaseConfig['development']['database.adapter'] = 'PDO_MYSQL';
136-
$databaseConfig['production']['database.params.host'] = $form->getValue('host');
137-
$databaseConfig['development']['database.params.host'] = $form->getValue('host');
138-
$databaseConfig['production']['database.params.username'] = $form->getValue('username');
139-
$databaseConfig['development']['database.params.username'] = $form->getValue('username');
140-
$databaseConfig['production']['database.params.password'] = $form->getValue('password');
141-
$databaseConfig['development']['database.params.password'] = $form->getValue('password');
142-
$databaseConfig['production']['database.params.dbname'] = $form->getValue('dbname');
143-
$databaseConfig['development']['database.params.dbname'] = $form->getValue('dbname');
144-
$databaseConfig['development']['database.params.port'] = $form->getValue('port');
145-
$databaseConfig['production']['database.params.port'] = $form->getValue('port');
126+
$params = array(
127+
'host' => $form->getValue('host'),
128+
'username' => $form->getValue('username'),
129+
'password' => $form->getValue('password'),
130+
'dbname' => $form->getValue('dbname'),
131+
'port' => $form->getValue('port'),
132+
);
146133

147-
$db = Zend_Db::factory("PDO_MYSQL", $params);
148-
Zend_Db_Table::setDefaultAdapter($db);
149-
Zend_Registry::set('dbAdapter', $db);
150-
151-
$dbtype = 'PDO_MYSQL';
134+
$databaseConfig['production']['database.type'] = 'pdo';
135+
$databaseConfig['development']['database.type'] = 'pdo';
136+
$databaseConfig['production']['database.adapter'] = 'PDO_MYSQL';
137+
$databaseConfig['development']['database.adapter'] = 'PDO_MYSQL';
138+
$databaseConfig['production']['database.params.host'] = $form->getValue('host');
139+
$databaseConfig['development']['database.params.host'] = $form->getValue('host');
140+
$databaseConfig['production']['database.params.username'] = $form->getValue('username');
141+
$databaseConfig['development']['database.params.username'] = $form->getValue('username');
142+
$databaseConfig['production']['database.params.password'] = $form->getValue('password');
143+
$databaseConfig['development']['database.params.password'] = $form->getValue('password');
144+
$databaseConfig['production']['database.params.dbname'] = $form->getValue('dbname');
145+
$databaseConfig['development']['database.params.dbname'] = $form->getValue('dbname');
146+
$databaseConfig['development']['database.params.port'] = $form->getValue('port');
147+
$databaseConfig['production']['database.params.port'] = $form->getValue('port');
148+
149+
$db = Zend_Db::factory("PDO_MYSQL", $params);
150+
Zend_Db_Table::setDefaultAdapter($db);
151+
Zend_Registry::set('dbAdapter', $db);
152+
153+
$dbtype = 'PDO_MYSQL';
152154
break;
153-
case 'pgsql':
155+
case 'pgsql':
154156
$this->Component->Utility->run_pgsql_from_file($sqlFile,
155157
$form->getValue('host'), $form->getValue('username'), $form->getValue('password'), $form->getValue('dbname'), $form->getValue('port'));
156-
$params= array(
157-
'host' => $form->getValue('host'),
158-
'username' => $form->getValue('username'),
159-
'password' => $form->getValue('password'),
160-
'dbname' => $form->getValue('dbname'),
161-
'port' => $form->getValue('port'),
162-
);
163-
164-
$databaseConfig['production']['database.type'] = 'pdo';
165-
$databaseConfig['development']['database.type'] = 'pdo';
166-
$databaseConfig['production']['database.adapter'] = 'PDO_PGSQL';
167-
$databaseConfig['development']['database.adapter'] = 'PDO_PGSQL';
168-
$databaseConfig['production']['database.params.host'] = $form->getValue('host');
169-
$databaseConfig['development']['database.params.host'] = $form->getValue('host');
170-
$databaseConfig['production']['database.params.username'] = $form->getValue('username');
171-
$databaseConfig['development']['database.params.username'] = $form->getValue('username');
172-
$databaseConfig['production']['database.params.password'] = $form->getValue('password');
173-
$databaseConfig['development']['database.params.password'] = $form->getValue('password');
174-
$databaseConfig['production']['database.params.dbname'] = $form->getValue('dbname');
175-
$databaseConfig['development']['database.params.dbname'] = $form->getValue('dbname');
176-
$databaseConfig['development']['database.params.port'] = $form->getValue('port');
177-
$databaseConfig['production']['database.params.port'] = $form->getValue('port');
158+
$params = array(
159+
'host' => $form->getValue('host'),
160+
'username' => $form->getValue('username'),
161+
'password' => $form->getValue('password'),
162+
'dbname' => $form->getValue('dbname'),
163+
'port' => $form->getValue('port'),
164+
);
178165

179-
$db = Zend_Db::factory("PDO_PGSQL", $params);
180-
Zend_Db_Table::setDefaultAdapter($db);
181-
Zend_Registry::set('dbAdapter', $db);
182-
$dbtype = 'PDO_PGSQL';
166+
$databaseConfig['production']['database.type'] = 'pdo';
167+
$databaseConfig['development']['database.type'] = 'pdo';
168+
$databaseConfig['production']['database.adapter'] = 'PDO_PGSQL';
169+
$databaseConfig['development']['database.adapter'] = 'PDO_PGSQL';
170+
$databaseConfig['production']['database.params.host'] = $form->getValue('host');
171+
$databaseConfig['development']['database.params.host'] = $form->getValue('host');
172+
$databaseConfig['production']['database.params.username'] = $form->getValue('username');
173+
$databaseConfig['development']['database.params.username'] = $form->getValue('username');
174+
$databaseConfig['production']['database.params.password'] = $form->getValue('password');
175+
$databaseConfig['development']['database.params.password'] = $form->getValue('password');
176+
$databaseConfig['production']['database.params.dbname'] = $form->getValue('dbname');
177+
$databaseConfig['development']['database.params.dbname'] = $form->getValue('dbname');
178+
$databaseConfig['development']['database.params.port'] = $form->getValue('port');
179+
$databaseConfig['production']['database.params.port'] = $form->getValue('port');
180+
181+
$db = Zend_Db::factory("PDO_PGSQL", $params);
182+
Zend_Db_Table::setDefaultAdapter($db);
183+
Zend_Registry::set('dbAdapter', $db);
184+
$dbtype = 'PDO_PGSQL';
183185
break;
184186
default:
185187
break;
@@ -214,7 +216,7 @@ function step2Action()
214216
}
215217
} // end method step2Action
216218

217-
/**
219+
/**
218220
* @method step3Action()
219221
*/
220222
function step3Action()
@@ -223,14 +225,14 @@ function step3Action()
223225
{
224226
$this->_redirect('/install/index');
225227
}
226-
$this->view->header="Step3: Midas Configuration";
228+
$this->view->header = "Step3: Midas Configuration";
227229
$userDao = $this->userSession->Dao;
228-
if(!isset($userDao)||!$userDao->isAdmin())
230+
if(!isset($userDao) || !$userDao->isAdmin())
229231
{
230232
unlink(BASE_PATH."/core/configs/database.local.ini");
231233
$this->_redirect('/install/index');
232234
}
233-
$applicationConfig = parse_ini_file (BASE_PATH.'/core/configs/application.ini',true);
235+
$applicationConfig = parse_ini_file(BASE_PATH.'/core/configs/application.ini', true);
234236
$form = $this->Form->Install->createConfigForm();
235237
$formArray = $this->getFormAsArray($form);
236238
$formArray['name']->setValue($applicationConfig['global']['application.name']);
@@ -243,13 +245,13 @@ function step3Action()
243245
$assetstrores = $this->Assetstore->getAll();
244246

245247
$this->view->form = $formArray;
246-
$this->view->databaseType =Zend_Registry::get('configDatabase')->database->adapter;
247-
if($this->_request->isPost()&&$form->isValid($this->getRequest()->getPost()))
248+
$this->view->databaseType = Zend_Registry::get('configDatabase')->database->adapter;
249+
if($this->_request->isPost() && $form->isValid($this->getRequest()->getPost()))
248250
{
249251
$allModules = $this->Component->Utility->getAllModules();
250252
foreach($allModules as $key => $module)
251253
{
252-
$configLocal = BASE_PATH."/modules/$key/configs/module.local.ini";
254+
$configLocal = BASE_PATH."/modules/".$key."/configs/module.local.ini";
253255
if(file_exists($configLocal))
254256
{
255257
unlink($configLocal);
@@ -284,48 +286,46 @@ public function testconnexionAction()
284286
$host = $this->_getParam('host');
285287
$dbname = $this->_getParam('dbname');
286288
$port = $this->_getParam('port');
287-
switch ($type)
289+
switch($type)
288290
{
289291
case 'mysql':
290-
$link = @mysql_connect("$host:$port", "$username", "$password");
292+
$link = mysql_connect($host.":".$port, "$username", "$password");
291293
if(!$link)
292294
{
293-
$return= array(false, "Could not connect to the server '" . $host . "': ".mysql_error());
295+
$return = array(false, "Could not connect to the server '" . $host . "': ".mysql_error());
294296
break;
295297
}
296298
$dbcheck = mysql_select_db("$dbname");
297299
if(!$dbcheck)
298300
{
299-
$return= array(false, "Could not connect to the server '" . $host . "': ".mysql_error());
301+
$return = array(false, "Could not connect to the server '" . $host . "': ".mysql_error());
300302
break;
301303
}
302-
$sql = "SHOW TABLES FROM $dbname";
304+
$sql = "SHOW TABLES FROM ".$dbname;
303305
$result = mysql_query($sql);
304306
if(mysql_num_rows($result) > 0)
305307
{
306-
$return= array(false, "The database is not empty");
308+
$return = array(false, "The database is not empty");
307309
break;
308310
}
309-
$return =array(true, "The database is reachable");
311+
$return = array(true, "The database is reachable");
310312
break;
311313
case 'pgsql':
312-
$link = @pg_connect("host = $host port = $port dbname = $dbname user = $username password = $password");
314+
$link = pg_connect("host = ".$host." port = ".$port." dbname = ".$dbname." user = ".$username." password = ".$password);
313315
if(!$link)
314316
{
315-
$return= array(false, "Could not connect to the server '" . $host . "': ".pg_last_error($link));
317+
$return = array(false, "Could not connect to the server '" . $host . "': ".pg_last_error($link));
316318
break;
317319
}
318-
$return =array(true, "The database is reachable");
320+
$return = array(true, "The database is reachable");
319321
break;
320322
default:
321323
$return = array(false, "Database not defined");
322324
break;
323325
}
324326
echo JsonComponent::encode($return);
325327
}//end getElementInfo
326-
327-
328-
328+
329329
} // end class
330330

331331

0 commit comments

Comments
 (0)