3 class mw_env_config extends mw_env{
13 function load_config($bdd, $CONFIG){
16 $this->bdd["table_prefix"] = array();
17 $this->CONFIG = isset($CONFIG) ? $CONFIG : array();
18 $this->PARAMS = array();
19 $this->xml_parser = new sxml();
20 $app_config_file = $this->path("mw_dir")."app/config.xml";
21 if(file_exists($app_config_file)){
22 $this->_load_config($app_config_file, $bdd);
24 if(($plugins = $this->plugins("ASC")) !== false){
25 foreach($plugins as $plugin_name => $plugin){
26 $app_config_file = $this->path("mw_dir")."plugins/".$plugin_name."/app/config.xml";
27 if(file_exists($app_config_file) && $plugin["installed"] && $plugin["enabled"]){
28 $this->_load_config($app_config_file, $bdd);
31 $this->init_additional_get_params();
33 else $this->erreur("impossible de lire les fichiers de configuration pour les plugins", true);
35 else $this->erreur("impossible de trouver le fichier de configuration pour l'installation", true);
38 function _load_config($app_config_file, $bdd){
39 $this->xml_parser->parse(file_get_contents($app_config_file));
40 $app_config = $this->xml_parser->data["config"][0];
41 if(isset($app_config["subs"]["params"])){
42 foreach($app_config["subs"]["params"][0]["subs"] as $param_key => $param_elt){
43 $this->PARAMS[$param_key] = $param_elt[0]["data"];
46 if(isset($app_config["subs"]["config"])){
47 foreach($app_config["subs"]["config"][0]["subs"] as $config_key => $config_elt){
48 $this->CONFIG[$config_key] = $config_elt[0]["data"];
51 if(isset($app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"])){
52 $this->add_table_prefix(
54 $app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"][0]["data"] => $bdd["table_prefix"]
58 if(isset($app_config["subs"]["actions"][0]["subs"]["module"])){
59 foreach($app_config["subs"]["actions"][0]["subs"]["module"] as $module_elt){
60 $module_name = $module_elt["attrs"]["name"];
61 if(!isset($this->actions[$module_name])) $this->actions[$module_name] = array(
62 "controleurs" => array(),
63 "module_allowed" => false,
66 if(isset($module_elt["subs"]["controleur"])){
67 foreach($module_elt["subs"]["controleur"] as $controleur_elt){
68 $controleur_name = $controleur_elt["attrs"]["name"];
69 if(!isset($this->actions[$module_name]["controleurs"][$controleur_name])) $this->actions[$module_name]["controleurs"][$controleur_name] = array(
71 "controleur_allowed" => false,
74 if(isset($controleur_elt["subs"]["al"])){
76 foreach($controleur_elt["subs"]["al"] as $al_elt){
77 $action_title = $al_elt["attrs"]["title"];
78 if(isset($al_elt["subs"]["action"])){
79 foreach($al_elt["subs"]["action"] as $action_elt){
80 if(!isset($this->actions[$module_name]["controleurs"][$controleur_name]["als"][$al_index])){
81 $this->actions[$module_name]["controleurs"][$controleur_name]["als"][$al_index] = array(
82 "title" => $action_title,
83 "action_allowed" => false,
88 $this->actions[$module_name]["controleurs"][$controleur_name]["als"][$al_index]["actions"][] = $action_elt["attrs"]["name"];
100 function get_config_file(){
101 return $this->config_file;
104 function set_config_file($config_file){
105 $this->config_file = $config_file;
108 function get_PATHES(){
109 return $this->PATHES;
112 function path($name){
113 return isset($this->PATHES[$name]) ? $this->PATHES[$name] : "";
116 function set_PATHES($PATHES){
117 foreach($PATHES as $path_name => $path_value){
118 if($path_value && substr($path_value, -1) != "/") $PATHES[$path_name] .= "/";
120 $this->PATHES = $PATHES;
123 function get_PARAMS(){
124 return $this->PARAMS;
127 function param($name){
128 return isset($this->PARAMS[$name]) ? $this->PARAMS[$name] : "";
131 function get_CONFIG(){
132 return $this->CONFIG;
135 function config($name){
136 return isset($this->CONFIG[$name]) ? $this->CONFIG[$name] : null;
139 function set_config($config){
140 if(is_array($config)){
141 foreach($config as $key => $value) $this->CONFIG[$key] = $value;
152 return isset($this->bdd[$name]) ? $this->bdd[$name] : null;
155 function set_bdd($key, $value){
156 $this->bdd[$key] = $value;
159 function add_table_prefix($table_prefix){
160 if(is_array($table_prefix)){
161 foreach($table_prefix as $prefix_code => $prefix) $this->bdd["table_prefix"][$prefix_code] = $prefix;
167 function get_actions(){
168 return isset($this->actions) ? $this->actions : array();