@@ -108,7 +108,7 @@ function step2Action()
108
108
switch ($ type )
109
109
{
110
110
case 'mysql ' :
111
- $ this ->run_mysql_from_file ($ sqlFile ,
111
+ $ this ->Component -> Utility -> run_mysql_from_file ($ sqlFile ,
112
112
$ form ->getValue ('host ' ), $ form ->getValue ('username ' ), $ form ->getValue ('password ' ), $ form ->getValue ('dbname ' ),$ form ->getValue ('port ' ));
113
113
$ params = array (
114
114
'host ' => $ form ->getValue ('host ' ),
@@ -138,7 +138,7 @@ function step2Action()
138
138
Zend_Registry::set ('dbAdapter ' , $ db );
139
139
break ;
140
140
case 'pgsql ' :
141
- $ this ->run_pgsql_from_file ($ sqlFile ,
141
+ $ this ->Component -> Utility -> run_pgsql_from_file ($ sqlFile ,
142
142
$ form ->getValue ('host ' ), $ form ->getValue ('username ' ), $ form ->getValue ('password ' ), $ form ->getValue ('dbname ' ),$ form ->getValue ('port ' ));
143
143
$ params = array (
144
144
'host ' => $ form ->getValue ('host ' ),
@@ -217,66 +217,30 @@ function step3Action()
217
217
$ formArray ['process ' ]->setValue ($ applicationConfig ['global ' ]['processing ' ]);
218
218
219
219
$ assetstrores =$ this ->Assetstore ->getAll ();
220
- $ formArray ['assetstore ' ]->addMultiOptions (array (
221
- $ assetstrores [0 ]->getKey () => $ assetstrores [0 ]->getPath ()
222
- ));
223
-
220
+
224
221
$ this ->view ->form =$ formArray ;
225
- $ allModules =$ this ->Component ->Utility ->getAllModules ();
226
- $ this ->view ->modules =$ allModules ;
227
- $ this ->view ->defaultModules = new Zend_Config_Ini (APPLICATION_CONFIG , 'module ' );
228
222
$ this ->view ->databaseType =Zend_Registry::get ('configDatabase ' )->database ->adapter ;
229
223
if ($ this ->_request ->isPost ()&&$ form ->isValid ($ this ->getRequest ()->getPost ()))
230
224
{
231
-
225
+ $ allModules =$ this ->Component ->Utility ->getAllModules ();
226
+ foreach ($ allModules as $ key =>$ module )
227
+ {
228
+ $ configLocal =BASE_PATH ."/modules/ $ key/configs/module.local.ini " ;
229
+ if (file_exists ($ configLocal ))
230
+ {
231
+ unlink ($ configLocal );
232
+ }
233
+ }
232
234
$ applicationConfig ['global ' ]['application.name ' ]=$ form ->getValue ('name ' );
233
235
$ applicationConfig ['global ' ]['application.lang ' ]=$ form ->getValue ('lang ' );
234
236
$ applicationConfig ['global ' ]['environment ' ]=$ form ->getValue ('environment ' );
235
- $ applicationConfig ['global ' ]['defaultassetstore.id ' ]=$ form -> getValue ( ' assetstore ' );
237
+ $ applicationConfig ['global ' ]['defaultassetstore.id ' ]=$ assetstrores [ 0 ]-> getKey ( );
236
238
$ applicationConfig ['global ' ]['smartoptimizer ' ]=$ form ->getValue ('smartoptimizer ' );
237
239
$ applicationConfig ['global ' ]['default.timezone ' ]=$ form ->getValue ('timezone ' );
238
240
$ applicationConfig ['global ' ]['processing ' ]=$ form ->getValue ('process ' );
239
- $ applicationConfig ['module ' ]=array ();
240
- $ modules =$ this ->getRequest ()->getPost ();
241
- if (isset ($ modules ['module ' ]))
242
- {
243
- $ modules =$ modules ['module ' ];
244
- }
245
- else
246
- {
247
- $ modules =array ();
248
- }
249
- foreach ($ modules as $ key =>$ module )
250
- {
251
- $ applicationConfig ['module ' ][$ key ]='true ' ;
252
- switch (Zend_Registry::get ('configDatabase ' )->database ->adapter )
253
- {
254
- case 'PDO_MYSQL ' :
255
- $ this ->run_mysql_from_file (BASE_PATH .'/modules/ ' .$ key .'/database/mysql/ ' .$ allModules [$ key ]->version .'.sql ' ,
256
- Zend_Registry::get ('configDatabase ' )->database ->params ->host ,
257
- Zend_Registry::get ('configDatabase ' )->database ->params ->username ,
258
- Zend_Registry::get ('configDatabase ' )->database ->params ->password ,
259
- Zend_Registry::get ('configDatabase ' )->database ->params ->dbname ,
260
- Zend_Registry::get ('configDatabase ' )->database ->params ->port );
261
- break ;
262
- case 'PDO_PGSQL ' :
263
- $ this ->run_pgsql_from_file (BASE_PATH .'/modules/ ' .$ key .'/database/pgsql/ ' .$ allModules [$ key ]->version .'.sql ' ,
264
- Zend_Registry::get ('configDatabase ' )->database ->params ->host ,
265
- Zend_Registry::get ('configDatabase ' )->database ->params ->username ,
266
- Zend_Registry::get ('configDatabase ' )->database ->params ->password ,
267
- Zend_Registry::get ('configDatabase ' )->database ->params ->dbname ,
268
- Zend_Registry::get ('configDatabase ' )->database ->params ->port );
269
- break ;
270
- }
271
-
272
- $ path =BASE_PATH .'/modules/ ' .$ key .'/configs/module.ini ' ;
273
- $ newpath =BASE_PATH .'/modules/ ' .$ key .'/configs/module.local.ini ' ;
274
- $ data =parse_ini_file ($ path ,true );
275
- @unlink ($ newpath );
276
- $ this ->Component ->Utility ->createInitFile ($ newpath , $ data );
277
- }
241
+
278
242
$ this ->Component ->Utility ->createInitFile (BASE_PATH .'/core/configs/application.local.ini ' ,$ applicationConfig );
279
- $ this ->_redirect ("/ " );
243
+ $ this ->_redirect ("/admin " );
280
244
}
281
245
} // end method step2Action
282
246
@@ -338,66 +302,6 @@ public function testconnexionAction()
338
302
339
303
340
304
341
- /** Function to run the sql script */
342
- function run_mysql_from_file ($ sqlfile ,$ host ,$ username ,$ password ,$ dbname ,$ port )
343
- {
344
- $ db = @mysql_connect ("$ host: $ port " , "$ username " , "$ password " );
345
- $ select =@mysql_select_db ($ dbname ,$ db );
346
- if (!$ db ||!$ select )
347
- {
348
- throw new Zend_Exception ("Unable to connect. " );
349
- }
350
- $ requetes ="" ;
351
-
352
- $ sql =file ($ sqlfile );
353
- foreach ($ sql as $ l )
354
- {
355
- if (substr (trim ($ l ),0 ,2 )!="-- " )
356
- {
357
- $ requetes .= $ l ;
358
- }
359
- }
360
-
361
- $ reqs = explode ("; " ,$ requetes );
362
- foreach ($ reqs as $ req )
363
- { // et on les éxécute
364
- if (!mysql_query ($ req ,$ db ) && trim ($ req )!="" )
365
- {
366
- throw new Zend_Exception ("Unable to execute: " .$ req );
367
- }
368
- }
369
- return true ;
370
- }
371
- /** Function to run the sql script */
372
- function run_pgsql_from_file ($ sqlfile ,$ host ,$ username ,$ password ,$ dbname ,$ port )
373
- {
374
- $ pgdb = @pg_connect ("host= $ host port= $ port dbname= $ dbname user= $ username password= $ password " );
375
- $ file_content = file ($ sqlfile );
376
- $ query = "" ;
377
- $ linnum = 0 ;
378
- foreach ($ file_content as $ sql_line )
379
- {
380
- $ tsl = trim ($ sql_line );
381
- if (($ sql_line != "" ) && (substr ($ tsl , 0 , 2 ) != "-- " ) && (substr ($ tsl , 0 , 1 ) != "# " ))
382
- {
383
- $ query .= $ sql_line ;
384
- if (preg_match ("/;\s*$/ " , $ sql_line ))
385
- {
386
- $ query = str_replace ("; " , "" , "$ query " );
387
- $ result = pg_query ($ query );
388
- if (!$ result )
389
- {
390
- echo "Error line: " .$ linnum ."<br> " ;
391
- return pg_last_error ();
392
- }
393
- $ query = "" ;
394
- }
395
- }
396
- $ linnum ++;
397
- } // end for each line
398
- return true ;
399
- }
400
-
401
305
} // end class
402
306
403
307
0 commit comments