@@ -15,7 +15,7 @@ class InstallController extends AppController
15
15
*/
16
16
function init ()
17
17
{
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 " ))
19
19
{
20
20
throw new Zend_Exception ("Midas is already installed. " );
21
21
}
@@ -30,7 +30,7 @@ function indexAction()
30
30
{
31
31
$ this ->_redirect ('/install/step3 ' );
32
32
}
33
- $ this ->view ->header = "Step1: Server Configuration " ;
33
+ $ this ->view ->header = "Step1: Server Configuration " ;
34
34
// Check PHP extension / function
35
35
$ phpextensions = array (
36
36
"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()
41
41
$ this ->view ->writable = is_writable (BASE_PATH .'/core/configs ' );
42
42
$ this ->view ->convertfound = $ this ->Component ->Utility ->isImageMagickWorking ();
43
43
$ this ->view ->basePath = BASE_PATH ;
44
- if (!empty ($ _POST )&& $ this ->view ->writable )
44
+ if (!empty ($ _POST ) && $ this ->view ->writable )
45
45
{
46
46
$ this ->_redirect ("/install/step2 " );
47
47
}
48
48
} // end method indexAction
49
49
50
50
51
- /**
51
+ /**
52
52
* @method step2Action()
53
53
*/
54
54
function step2Action ()
@@ -57,7 +57,7 @@ function step2Action()
57
57
{
58
58
$ this ->_redirect ('/install/step3 ' );
59
59
}
60
- $ this ->view ->header = "Step2: Database Configuration " ;
60
+ $ this ->view ->header = "Step2: Database Configuration " ;
61
61
// Check PHP extension / function
62
62
$ phpextensions = array (
63
63
"mysql " => array (false , '' ),
@@ -71,22 +71,24 @@ function step2Action()
71
71
72
72
foreach ($ phpextensions as $ key => $ t )
73
73
{
74
- if (!file_exists (BASE_PATH ."/core/database/ { $ key}" ))
74
+ if (!file_exists (BASE_PATH ."/core/database/ " . $ key ))
75
75
{
76
76
unset($ phpextensions [$ key ]);
77
77
}
78
78
else
79
79
{
80
80
$ form = $ this ->Form ->Install ->createDBForm ($ key );
81
81
$ port = $ form ->getElement ('port ' );
82
- switch ($ key )
82
+ switch ($ key )
83
83
{
84
84
case 'mysql ' :
85
85
$ port ->setValue ('3306 ' );
86
86
break ;
87
87
case 'pgsql ' :
88
88
$ port ->setValue ('5432 ' );
89
89
break ;
90
+ default :
91
+ break ;
90
92
}
91
93
$ this ->view ->databaseType [$ key ] = $ this ->getFormAsArray ($ form );
92
94
}
@@ -102,13 +104,13 @@ function step2Action()
102
104
$ form = $ this ->Form ->Install ->createDBForm ($ type );
103
105
if ($ form ->isValid ($ this ->getRequest ()->getPost ()))
104
106
{
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 ))
108
110
{
109
111
if (strpos ($ Entry , ".sql " ) != false )
110
112
{
111
- $ sqlFile = BASE_PATH ."/core/database/ { $ type} / " .$ Entry ;
113
+ $ sqlFile = BASE_PATH ."/core/database/ " . $ type. " / " .$ Entry ;
112
114
}
113
115
}
114
116
if (!isset ($ sqlFile ))
@@ -121,65 +123,65 @@ function step2Action()
121
123
case 'mysql ' :
122
124
$ this ->Component ->Utility ->run_mysql_from_file ($ sqlFile ,
123
125
$ 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
+ );
146
133
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 ' ;
152
154
break ;
153
- case 'pgsql ' :
155
+ case 'pgsql ' :
154
156
$ this ->Component ->Utility ->run_pgsql_from_file ($ sqlFile ,
155
157
$ 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
+ );
178
165
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 ' ;
183
185
break ;
184
186
default :
185
187
break ;
@@ -214,7 +216,7 @@ function step2Action()
214
216
}
215
217
} // end method step2Action
216
218
217
- /**
219
+ /**
218
220
* @method step3Action()
219
221
*/
220
222
function step3Action ()
@@ -223,14 +225,14 @@ function step3Action()
223
225
{
224
226
$ this ->_redirect ('/install/index ' );
225
227
}
226
- $ this ->view ->header = "Step3: Midas Configuration " ;
228
+ $ this ->view ->header = "Step3: Midas Configuration " ;
227
229
$ userDao = $ this ->userSession ->Dao ;
228
- if (!isset ($ userDao )|| !$ userDao ->isAdmin ())
230
+ if (!isset ($ userDao ) || !$ userDao ->isAdmin ())
229
231
{
230
232
unlink (BASE_PATH ."/core/configs/database.local.ini " );
231
233
$ this ->_redirect ('/install/index ' );
232
234
}
233
- $ applicationConfig = parse_ini_file (BASE_PATH .'/core/configs/application.ini ' ,true );
235
+ $ applicationConfig = parse_ini_file (BASE_PATH .'/core/configs/application.ini ' , true );
234
236
$ form = $ this ->Form ->Install ->createConfigForm ();
235
237
$ formArray = $ this ->getFormAsArray ($ form );
236
238
$ formArray ['name ' ]->setValue ($ applicationConfig ['global ' ]['application.name ' ]);
@@ -243,13 +245,13 @@ function step3Action()
243
245
$ assetstrores = $ this ->Assetstore ->getAll ();
244
246
245
247
$ 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 ()))
248
250
{
249
251
$ allModules = $ this ->Component ->Utility ->getAllModules ();
250
252
foreach ($ allModules as $ key => $ module )
251
253
{
252
- $ configLocal = BASE_PATH ."/modules/ $ key/configs/module.local.ini " ;
254
+ $ configLocal = BASE_PATH ."/modules/ " . $ key. " /configs/module.local.ini " ;
253
255
if (file_exists ($ configLocal ))
254
256
{
255
257
unlink ($ configLocal );
@@ -284,48 +286,46 @@ public function testconnexionAction()
284
286
$ host = $ this ->_getParam ('host ' );
285
287
$ dbname = $ this ->_getParam ('dbname ' );
286
288
$ port = $ this ->_getParam ('port ' );
287
- switch ($ type )
289
+ switch ($ type )
288
290
{
289
291
case 'mysql ' :
290
- $ link = @ mysql_connect (" $ host: $ port" , "$ username " , "$ password " );
292
+ $ link = mysql_connect ($ host. " : " . $ port , "$ username " , "$ password " );
291
293
if (!$ link )
292
294
{
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 ());
294
296
break ;
295
297
}
296
298
$ dbcheck = mysql_select_db ("$ dbname " );
297
299
if (!$ dbcheck )
298
300
{
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 ());
300
302
break ;
301
303
}
302
- $ sql = "SHOW TABLES FROM $ dbname" ;
304
+ $ sql = "SHOW TABLES FROM " . $ dbname ;
303
305
$ result = mysql_query ($ sql );
304
306
if (mysql_num_rows ($ result ) > 0 )
305
307
{
306
- $ return = array (false , "The database is not empty " );
308
+ $ return = array (false , "The database is not empty " );
307
309
break ;
308
310
}
309
- $ return =array (true , "The database is reachable " );
311
+ $ return = array (true , "The database is reachable " );
310
312
break ;
311
313
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 );
313
315
if (!$ link )
314
316
{
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 ));
316
318
break ;
317
319
}
318
- $ return =array (true , "The database is reachable " );
320
+ $ return = array (true , "The database is reachable " );
319
321
break ;
320
322
default :
321
323
$ return = array (false , "Database not defined " );
322
324
break ;
323
325
}
324
326
echo JsonComponent::encode ($ return );
325
327
}//end getElementInfo
326
-
327
-
328
-
328
+
329
329
} // end class
330
330
331
331
0 commit comments