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(
"email" => "",
"password" => ""
);
- if(($sgbds = $data->sgbds()) === false){
+ if(($sgbds = $env->sgbds()) === false){
$env->erreur("impossible de lister les sgbds disponibles");
return;
}
"#--" => $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");
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"
$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é"
}
}
-
-?>
\ No newline at end of file