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 $xml_parser = new sxml();
19 $app_config_file = $this->path("app")."config.xml";
20 if(file_exists($app_config_file))
21 { $xml_parser->parse(file_get_contents($app_config_file));
22 $app_config = $xml_parser->data["config"][0];
23 if(isset($app_config["subs"]["params"]))
24 { foreach($app_config["subs"]["params"][0]["subs"] as $param_key => $param_elt)
25 { $this->PARAMS[$param_key] = $param_elt[0]["data"];
28 if(isset($app_config["subs"]["config"]))
29 { foreach($app_config["subs"]["config"][0]["subs"] as $config_key => $config_elt)
30 { $this->CONFIG[$config_key] = $config_elt[0]["data"];
33 if(isset($app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"]))
34 { $this->add_table_prefix
36 ( $app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"][0]["data"] => $bdd["table_prefix"]
41 if(($plugins = $this->plugins("ASC")) !== false)
42 { foreach($plugins as $plugin_name => $plugin)
43 { $app_config_file = $this->path("plugins").$plugin_name."/app/config.xml";
44 if(file_exists($app_config_file) && $plugin["installed"] && $plugin["enabled"])
45 { $xml_parser->parse(file_get_contents($app_config_file));
46 $app_config = $xml_parser->data["config"][0];
47 if(isset($app_config["subs"]["params"]))
48 { foreach($app_config["subs"]["params"][0]["subs"] as $param_key => $param_elt)
49 { $this->PARAMS[$param_key] = $param_elt[0]["data"];
52 if(isset($app_config["subs"]["config"]))
53 { foreach($app_config["subs"]["config"][0]["subs"] as $config_key => $config_elt)
54 { $this->CONFIG[$config_key] = $config_elt[0]["data"];
57 if(isset($app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"]))
58 { $this->add_table_prefix
60 ( $app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"][0]["data"] => $bdd["table_prefix"]
66 $this->init_additional_get_params();
68 else $this->erreur("impossible de lire les fichiers de configuration pour les plugins", true);
70 else $this->erreur("impossible de trouver le fichier de configuration pour l'installation", true);
73 function get_config_file() { return $this->config_file; }
74 function set_config_file($config_file) { $this->config_file = $config_file; }
76 function get_PATHES() { return $this->PATHES; }
78 { if(isset($this->PATHES[$name])) return $this->PATHES[$name];
81 function set_PATHES($PATHES)
82 { foreach($PATHES as $path_name => $path_value)
83 { if($path_value && substr($path_value, -1) != "/") $PATHES[$path_name] .= "/";
85 $this->PATHES = $PATHES;
88 function get_PARAMS() { return $this->PARAMS; }
89 function param($name) { return $this->PARAMS[$name]; }
91 function get_CONFIG() { return $this->CONFIG; }
92 function config($name) { return $this->CONFIG[$name]; }
93 function set_config($config)
94 { if(is_array($config))
95 { foreach($config as $key => $value) $this->CONFIG[$key] = $value;
101 function get_bdd() { return $this->bdd; }
102 function bdd($name) { return $this->bdd[$name]; }
103 function set_bdd($key, $value) { $this->bdd[$key] = $value; }
104 function add_table_prefix($table_prefix)
105 { if(is_array($table_prefix))
106 { foreach($table_prefix as $prefix_code => $prefix) $this->bdd["table_prefix"][$prefix_code] = $prefix;