3 class mw_env_config extends mw_env{
11 function load_config($bdd, $CONFIG){
14 $this->bdd["table_prefix"] = array();
15 $this->CONFIG = isset($CONFIG) ? $CONFIG : array();
16 $this->PARAMS = array();
17 $xml_parser = new sxml();
18 $app_config_file = $this->path("app")."config.xml";
19 if(file_exists($app_config_file)){
20 $xml_parser->parse(file_get_contents($app_config_file));
21 $app_config = $xml_parser->data["config"][0];
22 if(isset($app_config["subs"]["params"])){
23 foreach($app_config["subs"]["params"][0]["subs"] as $param_key => $param_elt){
24 $this->PARAMS[$param_key] = $param_elt[0]["data"];
27 if(isset($app_config["subs"]["config"])){
28 foreach($app_config["subs"]["config"][0]["subs"] as $config_key => $config_elt){
29 $this->CONFIG[$config_key] = $config_elt[0]["data"];
32 if(isset($app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"])){
33 $this->add_table_prefix(
35 $app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"][0]["data"] => $bdd["table_prefix"]
40 if(($plugins = $this->plugins("ASC")) !== false){
41 foreach($plugins as $plugin_name => $plugin){
42 $app_config_file = $this->path("plugins").$plugin_name."/app/config.xml";
43 if(file_exists($app_config_file) && $plugin["installed"] && $plugin["enabled"]){
44 $xml_parser->parse(file_get_contents($app_config_file));
45 $app_config = $xml_parser->data["config"][0];
46 if(isset($app_config["subs"]["params"])){
47 foreach($app_config["subs"]["params"][0]["subs"] as $param_key => $param_elt){
48 $this->PARAMS[$param_key] = $param_elt[0]["data"];
51 if(isset($app_config["subs"]["config"])){
52 foreach($app_config["subs"]["config"][0]["subs"] as $config_key => $config_elt){
53 $this->CONFIG[$config_key] = $config_elt[0]["data"];
56 if(isset($app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"])){
57 $this->add_table_prefix(
59 $app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"][0]["data"] => $bdd["table_prefix"]
65 $this->init_additional_get_params();
67 else $this->erreur("impossible de lire les fichiers de configuration pour les plugins", true);
69 else $this->erreur("impossible de trouver le fichier de configuration pour l'installation", true);
72 function get_config_file(){
73 return $this->config_file;
76 function set_config_file($config_file){
77 $this->config_file = $config_file;
80 function get_PATHES(){
85 if(isset($this->PATHES[$name])) return $this->PATHES[$name];
89 function set_PATHES($PATHES){
90 foreach($PATHES as $path_name => $path_value){
91 if($path_value && substr($path_value, -1) != "/") $PATHES[$path_name] .= "/";
93 $this->PATHES = $PATHES;
96 function get_PARAMS(){
100 function param($name){
101 return $this->PARAMS[$name];
104 function get_CONFIG(){
105 return $this->CONFIG;
108 function config($name){
109 return $this->CONFIG[$name];
112 function set_config($config){
113 if(is_array($config)){
114 foreach($config as $key => $value) $this->CONFIG[$key] = $value;
125 return $this->bdd[$name];
128 function set_bdd($key, $value){
129 $this->bdd[$key] = $value;
132 function add_table_prefix($table_prefix){
133 if(is_array($table_prefix)){
134 foreach($table_prefix as $prefix_code => $prefix) $this->bdd["table_prefix"][$prefix_code] = $prefix;