mecanisme d'upgrade
[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 mw_sgbd(
17       new $sgbd_impl(
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       $this
26     );
27     if(!$sgbd->extention_ok()){
28       $this->erreur("L'extention php ".$this->bdd("sgbd")." n'est pas install&eacute;e", true);
29     }
30   }
31   foreach($plugins as $plugin_name => $plugin){
32     if($plugin["installed"] && $plugin["enabled"]){
33       $data->load_modules($this->path("mw_dir")."plugins/".$plugin_name."/app/", "data/modules/share/");
34       if($this->bdd("sgbd")){
35         $data->load_modules($this->path("mw_dir")."plugins/".$plugin_name."/app/", "data/modules/".($this->bdd("sgbd") == "xml" ? "xml" : "sql")."/");
36       }
37     }
38   }
39   $data->load_modules($this->path("mw_dir")."app/", "data/modules/share/");
40   if($this->bdd("sgbd")){
41     $data->load_modules($this->path("mw_dir")."app/", "data/modules/".($this->bdd("sgbd") == "xml" ? "xml" : "sql")."/");
42     $data->set_sgbd($sgbd);
43   }
44   $data->set_env($this);
45   $this->set_data($data);