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