class mw_env_config extends mw_env{
- var $xml_parser;
- var $config_file;
- var $PATHES;
- var $PARAMS;
- var $CONFIG;
- var $bdd;
-
- function load_config($bdd, $CONFIG){
+ public $xml_parser;
+ public $config_file;
+ public $PATHES;
+ public $PARAMS;
+ public $CONFIG;
+ public $bdd;
+ public $actions;
+
+ public function load_config($bdd, $CONFIG){
if(true){
$this->bdd = $bdd;
$this->bdd["table_prefix"] = array();
else $this->erreur("impossible de trouver le fichier de configuration pour l'installation", true);
}
- function _load_config($app_config_file, $bdd){
+ public function _load_config($app_config_file, $bdd){
$this->xml_parser->parse(file_get_contents($app_config_file));
$app_config = $this->xml_parser->data["config"][0];
if(isset($app_config["subs"]["params"])){
if(isset($app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"])){
$this->add_table_prefix(
array(
- $app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"][0]["data"] => $bdd["table_prefix"]
+ $app_config["subs"]["bdd"][0]["subs"]["table_prefix_code"][0]["data"] => isset($bdd["table_prefix"]) ? $bdd["table_prefix"] : ""
)
);
}
+ if(isset($app_config["subs"]["actions"][0]["subs"]["module"])){
+ foreach($app_config["subs"]["actions"][0]["subs"]["module"] as $module_elt){
+ $module_name = $module_elt["attrs"]["name"];
+ if(!isset($this->actions[$module_name])) $this->actions[$module_name] = array(
+ "controleurs" => array(),
+ "module_allowed" => false,
+ "is_public" => false
+ );
+ if(isset($module_elt["subs"]["controleur"])){
+ foreach($module_elt["subs"]["controleur"] as $controleur_elt){
+ $controleur_name = $controleur_elt["attrs"]["name"];
+ if(!isset($this->actions[$module_name]["controleurs"][$controleur_name])) $this->actions[$module_name]["controleurs"][$controleur_name] = array(
+ "als" => array(),
+ "controleur_allowed" => false,
+ "is_public" => false
+ );
+ if(isset($controleur_elt["subs"]["al"])){
+ $al_index = 0;
+ foreach($controleur_elt["subs"]["al"] as $al_elt){
+ $action_title = $al_elt["attrs"]["title"];
+ if(isset($al_elt["subs"]["action"])){
+ foreach($al_elt["subs"]["action"] as $action_elt){
+ if(!isset($this->actions[$module_name]["controleurs"][$controleur_name]["als"][$al_index])){
+ $this->actions[$module_name]["controleurs"][$controleur_name]["als"][$al_index] = array(
+ "title" => $action_title,
+ "action_allowed" => false,
+ "is_public" => false,
+ "actions" => array()
+ );
+ }
+ $this->actions[$module_name]["controleurs"][$controleur_name]["als"][$al_index]["actions"][] = $action_elt["attrs"]["name"];
+ }
+ }
+ $al_index++;
+ }
+ }
+ }
+ }
+ }
+ }
}
- function get_config_file(){
+ public function get_config_file(){
return $this->config_file;
}
- function set_config_file($config_file){
+ public function set_config_file($config_file){
$this->config_file = $config_file;
}
- function get_PATHES(){
+ public function get_PATHES(){
return $this->PATHES;
}
- function path($name){
+ public function path($name){
return isset($this->PATHES[$name]) ? $this->PATHES[$name] : "";
}
- function set_PATHES($PATHES){
+ public function set_PATHES($PATHES){
foreach($PATHES as $path_name => $path_value){
if($path_value && substr($path_value, -1) != "/") $PATHES[$path_name] .= "/";
}
$this->PATHES = $PATHES;
}
- function get_PARAMS(){
+ public function get_PARAMS(){
return $this->PARAMS;
}
- function param($name){
+ public function param($name){
return isset($this->PARAMS[$name]) ? $this->PARAMS[$name] : "";
}
- function get_CONFIG(){
+ public function get_CONFIG(){
return $this->CONFIG;
}
- function config($name){
+ public function config($name){
return isset($this->CONFIG[$name]) ? $this->CONFIG[$name] : null;
}
- function set_config($config){
+ public function set_config($config){
if(is_array($config)){
foreach($config as $key => $value) $this->CONFIG[$key] = $value;
return true;
return false;
}
- function get_bdd(){
+ public function get_bdd(){
return $this->bdd;
}
- function bdd($name){
+ public function bdd($name){
return isset($this->bdd[$name]) ? $this->bdd[$name] : null;
}
- function set_bdd($key, $value){
+ public function set_bdd($key, $value){
$this->bdd[$key] = $value;
}
- function add_table_prefix($table_prefix){
+ public function bdd_ready(){
+ if(!$this->bdd("sgbd")) return "aucun sgbd defini";
+ $data = $this->data();
+ if(!$data) return "objet data non defini";
+ if(($res = $this->data_upgrade_required()) !== false){
+ if($res === true){
+ return "la base de donnees doit etre mise a jour";
+ }
+ else return $res;
+ }
+ return true;
+ }
+
+ public function add_table_prefix($table_prefix){
if(is_array($table_prefix)){
foreach($table_prefix as $prefix_code => $prefix) $this->bdd["table_prefix"][$prefix_code] = $prefix;
return true;
return false;
}
- }
+ public function get_actions(){
+ return isset($this->actions) ? $this->actions : array();
+ }
-?>
\ No newline at end of file
+ }