X-Git-Url: http://git.dj3c1t.com/index.cgi?a=blobdiff_plain;f=mw%2Fmw_app.php;h=9af31bc0a68380d259cb585fb45d14d70fb0b066;hb=refs%2Ftags%2Fmtweb.0.11.0;hp=1c18b21f4a3089d2a1b41d2cf4f6b9ef6b7a3b88;hpb=b91d4ed0a098b00708072de6fecd8c5047cb586b;p=mtweb diff --git a/mw/mw_app.php b/mw/mw_app.php index 1c18b21..9af31bc 100644 --- a/mw/mw_app.php +++ b/mw/mw_app.php @@ -11,7 +11,7 @@ var $error; var $DO_SETUP; - function mw_app($path_file, $DO_SETUP = true){ + function mw_app($path_file, $DO_SETUP = false){ $this->DO_SETUP = $DO_SETUP; $this->path_file = $path_file; $this->pathes = array(); @@ -29,13 +29,18 @@ return $this->env; } + function param($name){ + if(!isset($this->env)) return false; + return $this->env->param($name); + } + function init(){ - if(!$this->init_pathes()) return false; - if(!$this->init_config()) return false; - if(!$this->init_env()) return false; + if(!$this->init_pathes()) return $this->get_error(); + if(!$this->init_config()) return $this->get_error(); + if(!$this->init_env()) return $this->get_error(); if($this->config_file) return true; if($this->DO_SETUP) $this->setup(); - return false; + return $this->get_error(); } function init_pathes(){ @@ -52,12 +57,12 @@ $this->error("le fichier des chemins est introuvable"); return false; } - require_once $this->path_file; + require $this->path_file; if( !isset($PATHES) || !is_array($PATHES) ){ - $this->erreur("variable PATHES non defini"); + $this->error("variable PATHES non defini"); return false; } foreach($PATHES as $path_name => $path_value){ @@ -150,13 +155,7 @@ function run($etat = "", $params = array(), $valid_role = true){ $env = $this->env(); if(!is_callable(array($env, "run"))) return false; - $env->run( - $etat ? - $etat - : (isset($_GET[$env->param("e")]) ? $_GET[$env->param("e")] : ""), - $params, - $valid_role - ); + $env->run($etat); return true; } @@ -181,8 +180,8 @@ $this->error = $content; } - function show_error(){ - echo $this->error; + function get_error(){ + return isset($this->error) && $this->error ? $this->error : false; } }