X-Git-Url: http://git.dj3c1t.com/index.cgi?a=blobdiff_plain;f=mw%2Fapp%2Fcontrollers%2Finstall%2Findex.php;h=79734f3fdf4f79eacdbd1ebabe00b72293982f54;hb=HEAD;hp=1decc17a887dcb0667b55bbfa743d37c1a0bb776;hpb=bec31526c19092982057acabfe12e121442ec19b;p=mtweb diff --git a/mw/app/controllers/install/index.php b/mw/app/controllers/install/index.php index 1decc17..79734f3 100644 --- a/mw/app/controllers/install/index.php +++ b/mw/app/controllers/install/index.php @@ -2,16 +2,16 @@ class mw_install_index extends mw_controller{ - var $config_file; + public $config_file; - function validate(){ + public function validate(){ $env = $this->env(); $this->config_file = $env->path("content")."config/config.php"; if(file_exists($this->config_file)) return "le site est deja installé"; return true; } - function index(){ + public function index(){ $env = $this->env(); $data = $env->data(); $admin = array( @@ -19,7 +19,7 @@ "email" => "", "password" => "" ); - if(($sgbds = $data->sgbds()) === false){ + if(($sgbds = $env->sgbds()) === false){ $env->erreur("impossible de lister les sgbds disponibles"); return; } @@ -29,7 +29,7 @@ "#--" => $table_prefix ) ); - $current_sgbd = "mw_pdo_sqlite"; + $current_sgbd = isset($sgbds["mw_pdo_sqlite"]) ? "mw_pdo_sqlite" : "mw_xml"; if($_POST){ if(!isset($_POST["sgbd"])){ $env->erreur("Parametre de SGBD manquant"); @@ -77,14 +77,9 @@ else $env->message("merci de choisir un mot de passe pour l'administrateur"); if(!$env->messages()){ $sgbds[$current_sgbd] = null; - $impl = new $current_sgbd($params); + $impl = new $current_sgbd($env, $params); $sgbds[$current_sgbd] = $impl; - $data->set_sgbd( - new mw_sgbd( - $sgbds[$current_sgbd], - $env - ) - ); + $data->set_sgbd($sgbds[$current_sgbd]); $data->load_modules($env->path("mw_dir")."app/", "data/modules/".($current_sgbd == "mw_xml" ? "xml" : "sql")."/"); if( $current_sgbd == "mw_xml" @@ -159,6 +154,51 @@ $env->erreur("impossible de créer le fichier de configuration"); return; } + require_once $this->config_file; + if( + isset($CONFIG) + && is_array($CONFIG) + ){ + $env->set_config($CONFIG); + } + if( + isset($bdd) + && is_array($bdd) + ){ + foreach($bdd as $bdd_key => $bdd_value){ + if($bdd_key == "table_prefix"){ + if(!($table_prefix = $env->bdd("table_prefix"))){ + $env->erreur("impossible de lire les prefixes de tables"); + return; + } + foreach($table_prefix as $prefix_code => $prefix_value) break; + if(!isset($prefix_code)){ + $env->erreur("impossible de lire le code pour le prefixe de tables"); + return; + } + $table_prefix[$prefix_code] = $bdd_value; + $env->add_table_prefix($table_prefix); + } + else{ + $env->set_bdd($bdd_key, $bdd_value); + } + } + } + if(($plugins = $env->plugins("DESC")) === false){ + $env->erreur("impossible de lister les plugins"); + } + foreach($plugins as $plugin_name => $plugin){ + if(!$plugin["installed"]){ + $env->run("config/plugins/install", array("get" => array("id" => $plugin_name)), false); + if($env->erreurs()) return; + $env->load_plugin($plugin_name); + } + if(!$plugin["enabled"]){ + $env->run("config/plugins/enable", array("get" => array("id" => $plugin_name)), false); + if($env->erreurs()) return; + $env->load_plugin($plugin_name); + } + } $env->redirect( $env->url(), "le site a été installé" @@ -172,5 +212,3 @@ } } - -?> \ No newline at end of file