3 class mw_env_config extends mw_env{
12 function load_config($bdd, $CONFIG){
15 $this->bdd["table_prefix"] = array();
16 $this->CONFIG = isset($CONFIG) ? $CONFIG : array();
17 $this->PARAMS = array();
18 $this->xml_parser = new sxml();
19 $app_config_file = $this->path("mw_dir")."app/config.xml";
20 if(file_exists($app_config_file)){
21 $this->_load_config($app_config_file, $bdd);
23 if(($plugins = $this->plugins("ASC")) !== false){
24 foreach($plugins as $plugin_name => $plugin){
25 $app_config_file = $this->path("mw_dir")."plugins/".$plugin_name."/app/config.xml";
26 if(file_exists($app_config_file) && $plugin["installed"] && $plugin["enabled"]){
27 $this->_load_config($app_config_file, $bdd);
30 $this->init_additional_get_params();
32 else $this->erreur("impossible de lire les fichiers de configuration pour les plugins", true);
34 else $this->erreur("impossible de trouver le fichier de configuration pour l'installation", true);
37 function _load_config($app_config_file, $bdd){
38 $this->xml_parser->parse(file_get_contents($app_config_file));
39 $app_config = $this->xml_parser->data["config"][0];
40 if(isset($app_config["subs"]["params"])){
41 foreach($app_config["subs"]["params"][0]["subs"] as $param_key => $param_elt){
42 $this->PARAMS[$param_key] = $param_elt[0]["data"];
45 if(isset($app_config["subs"]["config"])){
46 foreach($app_config["subs"]["config"][0]["subs"] as $config_key => $config_elt){
47 $this->CONFIG[$config_key] = $config_elt[0]["data"];
50 if(isset($app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"])){
51 $this->add_table_prefix(
53 $app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"][0]["data"] => $bdd["table_prefix"]
59 function get_config_file(){
60 return $this->config_file;
63 function set_config_file($config_file){
64 $this->config_file = $config_file;
67 function get_PATHES(){
72 return isset($this->PATHES[$name]) ? $this->PATHES[$name] : "";
75 function set_PATHES($PATHES){
76 foreach($PATHES as $path_name => $path_value){
77 if($path_value && substr($path_value, -1) != "/") $PATHES[$path_name] .= "/";
79 $this->PATHES = $PATHES;
82 function get_PARAMS(){
86 function param($name){
87 return isset($this->PARAMS[$name]) ? $this->PARAMS[$name] : "";
90 function get_CONFIG(){
94 function config($name){
95 return isset($this->CONFIG[$name]) ? $this->CONFIG[$name] : null;
98 function set_config($config){
99 if(is_array($config)){
100 foreach($config as $key => $value) $this->CONFIG[$key] = $value;
111 return isset($this->bdd[$name]) ? $this->bdd[$name] : null;
114 function set_bdd($key, $value){
115 $this->bdd[$key] = $value;
118 function add_table_prefix($table_prefix){
119 if(is_array($table_prefix)){
120 foreach($table_prefix as $prefix_code => $prefix) $this->bdd["table_prefix"][$prefix_code] = $prefix;