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