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