implementation sgbd herite de mw_sgbd
[mtweb] / mw / app / init / 0300_data.php
1 <?php
2
3   if(($plugins = $this->plugins("DESC")) === false){
4     $this->erreur("Impossible de lire les plugins pour charger les modules de donnees", true);
5   }
6   $data = new mw_data(true);
7   if($this->bdd("sgbd")){
8     if(!$this->app_file_exists("data/impl/mw_".$this->bdd("sgbd").".php")){
9       $this->erreur("Impossible de trouver le fichier d'implementation du sgbd ".$this->bdd("sgbd"), true);
10     }
11     $sgbd_impl = "mw_".$this->bdd("sgbd");
12     if(!class_exists($sgbd_impl)) require_once $this->app_file("data/impl/".$sgbd_impl.".php");
13     if(!class_exists($sgbd_impl)){
14       $this->erreur("Impossible de trouver la classe d'implementation du sgbd ".$this->bdd("sgbd"), true);
15     }
16     $sgbd = new $sgbd_impl(
17       $this,
18       array(
19         "host" => $this->bdd("host"),
20         "base" => $this->bdd("base"),
21         "user" => $this->bdd("user"),
22         "password" => $this->bdd("password")
23       )
24     );
25     if(!$sgbd->extention_ok()){
26       $this->erreur("L'extention php ".$this->bdd("sgbd")." n'est pas install&eacute;e", true);
27     }
28   }
29   foreach($plugins as $plugin_name => $plugin){
30     if($plugin["installed"] && $plugin["enabled"]){
31       $data->load_modules($this->path("mw_dir")."plugins/".$plugin_name."/app/", "data/modules/share/");
32       if($this->bdd("sgbd")){
33         $data->load_modules($this->path("mw_dir")."plugins/".$plugin_name."/app/", "data/modules/".($this->bdd("sgbd") == "xml" ? "xml" : "sql")."/");
34       }
35     }
36   }
37   $data->load_modules($this->path("mw_dir")."app/", "data/modules/share/");
38   if($this->bdd("sgbd")){
39     $data->load_modules($this->path("mw_dir")."app/", "data/modules/".($this->bdd("sgbd") == "xml" ? "xml" : "sql")."/");
40     $data->set_sgbd($sgbd);
41   }
42   $data->set_env($this);
43   $this->set_data($data);