if(!$plugin["installed"]){
$env->run("config/plugins/install", array("get" => array("id" => $plugin_name)), false);
if($env->erreurs()) return;
- $env->init_plugins("DESC", true);
+ $env->load_plugin($plugin_name);
}
if(!$plugin["enabled"]){
$env->run("config/plugins/enable", array("get" => array("id" => $plugin_name)), false);
if($env->erreurs()) return;
- $env->init_plugins("DESC", true);
+ $env->load_plugin($plugin_name);
}
}
$env->redirect(
+++ /dev/null
-<?php
-
- // -------------------------------------------------------------------------
- // sgbd
- //
-
- $sgbd_impl_file = $this->path("mw_dir")."env/sgbd/mw_".$this->bdd("sgbd").".php";
- if($this->bdd("sgbd")){
- if(!file_exists($sgbd_impl_file)){
- $this->erreur("Impossible de trouver le fichier d'implementation du sgbd ".$this->bdd("sgbd"), true);
- }
- $sgbd_impl = "mw_".$this->bdd("sgbd");
- if(!class_exists($sgbd_impl)) require_once $sgbd_impl_file;
- if(!class_exists($sgbd_impl)){
- $this->erreur("Impossible de trouver la classe d'implementation du sgbd ".$this->bdd("sgbd"), true);
- }
- $sgbd = new $sgbd_impl(
- $this,
- array(
- "host" => $this->bdd("host"),
- "base" => $this->bdd("base"),
- "user" => $this->bdd("user"),
- "password" => $this->bdd("password")
- )
- );
- if(!$sgbd->extention_ok()){
- $this->erreur("L'extention php ".$this->bdd("sgbd")." n'est pas installée", true);
- }
- }
-
- // -------------------------------------------------------------------------
- // data
- //
-
- if(($plugins = $this->plugins("DESC")) === false){
- $this->erreur("Impossible de lire les plugins pour charger les modules de donnees", true);
- }
- $data = new mw_data(true);
- foreach($plugins as $plugin_name => $plugin){
- if($plugin["installed"] && $plugin["enabled"]){
- $data->load_modules($this->path("mw_dir")."plugins/".$plugin_name."/app/", "data/modules/share/");
- if($this->bdd("sgbd")){
- $data->load_modules($this->path("mw_dir")."plugins/".$plugin_name."/app/", "data/modules/".($this->bdd("sgbd") == "xml" ? "xml" : "sql")."/");
- }
- }
- }
- $data->load_modules($this->path("mw_dir")."app/", "data/modules/share/");
- if($this->bdd("sgbd")){
- $data->load_modules($this->path("mw_dir")."app/", "data/modules/".($this->bdd("sgbd") == "xml" ? "xml" : "sql")."/");
- $data->set_sgbd($sgbd);
- }
- $data->set_env($this);
- $this->set_data($data);
+++ /dev/null
-<?php
-
- if($this->bdd_ready() !== true) return;
- if(($plugins = $this->plugins("DESC")) !== false){
- foreach($plugins as $plugin_name => $plugin){
- if($plugin["installed"] && $plugin["enabled"]){
- if(!$plugin["impl"]->init($this)) $this->erreur("erreur lors de l'initialisation du plugin ".$plugin_name, true);
- }
- }
- }
- else $this->erreur("erreur lors de l'initialisation des plugins", true);
if(($config = $data->config()) === false){
$this->erreur("Impossible de lire la configuration en base", true);
}
-
$this->set_config($config);
-
$this->set_config(
array(
"start_action_params" => (
if($data->load_session() === false){
$this->erreur("Impossible de charger la session", true);
}
-
if($data->init_roles() === false){
- $this->erreur("Impossible de charger les statuts des utilisateurs", true);
+ $this->erreur("Impossible de charger les roles des utilisateurs", true);
}
-
if($data->init_actions_roles() === false){
- $this->erreur("Impossible de charger les statuts des actions", true);
+ $this->erreur("Impossible de charger les roles pour les actions", true);
}
<?php
- if($this->bdd_ready() !== true) return;
-
if(!$this->init_links()){
$this->erreur("impossible de charger les liens", true);
}
return isset($this->data) ? $this->data : false;
}
+ public function load_data(){
+ if(($plugins = $this->plugins("DESC")) === false){
+ $this->erreur("Impossible de lire les plugins pour charger les modules de donnees", true);
+ }
+ $data = new mw_data(true);
+ foreach($plugins as $plugin_name => $plugin){
+ if($plugin["installed"] && $plugin["enabled"]){
+ $data->load_modules($this->path("mw_dir")."plugins/".$plugin_name."/app/", "data/modules/share/");
+ if($this->bdd("sgbd")){
+ $data->load_modules($this->path("mw_dir")."plugins/".$plugin_name."/app/", "data/modules/".($this->bdd("sgbd") == "xml" ? "xml" : "sql")."/");
+ }
+ }
+ }
+ $data->load_modules($this->path("mw_dir")."app/", "data/modules/share/");
+ if($this->bdd("sgbd")){
+ $data->load_modules($this->path("mw_dir")."app/", "data/modules/".($this->bdd("sgbd") == "xml" ? "xml" : "sql")."/");
+ }
+ $data->set_env($this);
+ $this->set_data($data);
+ }
+
}
// -------------------------------------------------------------------------------------------
return $this->data_upgrades;
}
- public function init_data_upgrades(){
+ public function load_data_upgrades(){
$impl_dir = ($this->bdd("sgbd") == "xml" ? "xml" : "sql")."/";
$versions_dir = $this->path("mw_dir")."app/data/upgrades/".$impl_dir;
if(is_dir($versions_dir)){
public function data_upgrade_required($RELOAD = false){
if(!isset($this->data_upgrades)){
- if(($res = $this->init_data_upgrades()) !== true){
+ if(($res = $this->load_data_upgrades()) !== true){
return $res;
}
}
class mw_env_init extends mw_env{
public function init(){
+ $data = $this->data();
$init_files = array();
if(($plugins = $this->plugins()) !== false){
foreach($plugins as $plugin_name => $plugin){
public $plugins_desc;
public function plugins($PRIORITE = "ASC"){
- $this->init_plugins($PRIORITE);
+ if(!isset($this->plugins_asc) || !isset($this->plugins_desc)){
+ return false;
+ }
if($PRIORITE == "ASC") return $this->plugins_asc;
if($PRIORITE == "DESC") return $this->plugins_desc;
return false;
}
+ public function plugin($plugin_name){
+ if(!isset($this->plugins_asc) || isset($this->plugins_desc)){
+ return false;
+ }
+ if(!isset($this->plugins_asc[$plugin_name])){
+ return false;
+ }
+ return $this->plugins_asc[$plugin_name];
+ }
+
# ---------------------------------------------------------------------------------
# init
#
- public function init_plugins($PRIORITE = "ASC", $RELOAD = false){
- if(!$RELOAD && (isset($this->plugins_asc) || isset($this->plugins_desc))){
- if($PRIORITE == "ASC"){
- if(!isset($this->plugins_asc)) $this->plugins_asc = $this->ordonne_plugins($this->plugins_desc, $PRIORITE);
- }
- elseif($PRIORITE == "DESC"){
- if(!isset($this->plugins_desc)) $this->plugins_desc = $this->ordonne_plugins($this->plugins_asc, $PRIORITE);
+ public function load_plugins($RELOAD = false){
+ if(!$RELOAD && isset($this->plugins_asc) && isset($this->plugins_desc)){
+ return true;
+ }
+ $this->plugins_asc = array();
+ $this->plugins_desc = array();
+ if(!($dh = opendir($this->path("mw_dir")."plugins/"))){
+ return false;
+ }
+ $OK = true;
+ while($OK && ($plugin_name = readdir($dh)) !== false){
+ if(substr($plugin_name, 0 ,1) !== "." && is_dir($this->path("mw_dir")."plugins/".$plugin_name)){
+ if(($plugin = $this->load_plugin($plugin_name)) === false){
+ $OK = false;
+ }
}
- return;
}
- $plugins = array();
- if($dh = opendir($this->path("mw_dir")."plugins/")){
- $OK = true;
- while($OK && ($plugin_name = readdir($dh)) !== false){
- if(substr($plugin_name, 0 ,1) !== "." && is_dir($this->path("mw_dir")."plugins/".$plugin_name)){
- if(!isset($plugins[$plugin_name])){
- if(($plugin = $this->plugin_data($plugin_name)) !== false){
- $MAJ = false;
- if(!isset($plugin["installed"]) || !isset($plugin["enabled"])){
- $plugin["installed"] = false;
- $plugin["enabled"] = false;
- $plugin["priorite"] = 0;
- $MAJ = true;
- }
- if(!$plugin["installed"] && $plugin["enabled"]){
- $plugin["enabled"] = false;
- $MAJ = true;
- }
- if($MAJ) $OK = $this->set_plugin_data($plugin_name, $plugin);
- if($OK){
- if(($plugin["impl"] = $this->plugin_impl($plugin_name)) !== false){
- $plugin["title"] = ($plugin_title = $this->plugin_call($plugin["impl"], "title")) ? $plugin_title : "";
- $plugin["description"] = ($plugin_description = $this->plugin_call($plugin["impl"], "description")) ? $plugin_description : "";
- $plugin["name"] = $plugin_name;
- $plugins[$plugin_name] = $plugin;
- }
- }
- }
- else $OK = false;
- }
+ closedir($dh);
+ if(!$OK){
+ return false;
+ }
+ if(($plugins = $this->plugins()) === false){
+ return false;
+ }
+ if(file_exists($this->plugins_data_dir()) && is_dir($this->plugins_data_dir())){
+ if(!($dh = opendir($this->plugins_data_dir()))){
+ return false;
+ }
+ while(($plugin_name = readdir($dh)) !== false){
+ if(substr($plugin_name, 0 ,1) != "." && !is_dir($this->plugin_data_file($plugin_name))){
+ if(!isset($plugins[$plugin_name])) $this->del_plugin_data($plugin_name);
}
- if(!$OK) $plugins = false;
}
closedir($dh);
- if($plugins !== false){
- if(file_exists($this->plugins_data_dir()) && is_dir($this->plugins_data_dir())){
- if($dh = opendir($this->plugins_data_dir())){
- $plugins_data_files = array();
- $OK = true;
- while($OK && ($plugin_name = readdir($dh)) !== false){
- if(substr($plugin_name, 0 ,1) != "." && !is_dir($this->plugin_data_file($plugin_name))){
- if(!isset($plugins[$plugin_name])) $this->del_plugin_data($plugin_name);
- }
- if(!$OK) $plugins = false;
- }
- closedir($dh);
- }
- }
+ }
+ return true;
+ }
+
+ public function load_plugin($plugin_name){
+ if(substr($plugin_name, 0 ,1) == "." || !is_dir($this->path("mw_dir")."plugins/".$plugin_name)){
+ return false;
+ }
+ if(($plugin = $this->plugin_data($plugin_name)) === false){
+ return false;
+ }
+ if(($plugin["impl"] = $this->plugin_impl($plugin_name)) === false){
+ return false;
+ }
+ $MAJ = false;
+ if(!isset($plugin["installed"]) || !isset($plugin["enabled"])){
+ $plugin["installed"] = false;
+ $plugin["enabled"] = false;
+ $plugin["priorite"] = 0;
+ $MAJ = true;
+ }
+ if(!$plugin["installed"] && $plugin["enabled"]){
+ $plugin["enabled"] = false;
+ $MAJ = true;
+ }
+ if($MAJ){
+ if(!$this->set_plugin_data($plugin_name, $plugin)){
+ return false;
}
}
- else $plugins = false;
- if($plugins !== false){
- if($PRIORITE == "ASC") $this->plugins_asc = $this->ordonne_plugins($plugins, $PRIORITE);
- elseif($PRIORITE == "DESC") $this->plugins_desc = $this->ordonne_plugins($plugins, $PRIORITE);
+ $plugin["title"] = ($plugin_title = $this->plugin_call($plugin["impl"], "title")) ? $plugin_title : "";
+ $plugin["description"] = ($plugin_description = $this->plugin_call($plugin["impl"], "description")) ? $plugin_description : "";
+ $plugin["name"] = $plugin_name;
+ if(!isset($this->plugins_asc)) $this->plugins_asc = array();
+ $this->plugins_asc[$plugin_name] = $plugin;
+ $this->plugins_asc = $this->ordonne_plugins($this->plugins_asc, "ASC");
+ $this->plugins_desc = $this->ordonne_plugins($this->plugins_asc, "DESC");
+ return $plugin;
+ }
+
+ public function plugins_loaded(){
+ if(($plugins = $this->plugins()) === false){
+ return;
+ }
+ foreach($plugins as $plugin_name => $plugin){
+ $plugin["impl"]->loaded($this);
}
- else{
- $this->plugins_asc = false;
- $this->plugins_desc = false;
+ }
+
+ public function init_plugins(){
+ if($this->bdd_ready() !== true) return;
+ if(($plugins = $this->plugins("DESC")) === false){
+ $this->erreur("erreur lors de l'initialisation des plugins", true);
+ }
+ foreach($plugins as $plugin_name => $plugin){
+ if($plugin["installed"] && $plugin["enabled"]){
+ if(!$plugin["impl"]->init($this)){
+ $this->erreur("erreur lors de l'initialisation du plugin ".$plugin_name, true);
+ }
+ }
}
}
if(method_exists($impl, $method)) return $impl->$method($this);
}
- public function loaded_plugins(){
- if($plugins = $this->plugins()){
- foreach($plugins as $plugin_name => $plugin){
- $plugin["impl"]->loaded($this);
- }
- }
- }
-
# ---------------------------------------------------------------------------------
# impl
#
return $this->sgbds;
}
+ public function load_sgbd(){
+ if(($data = $this->data()) && $this->bdd("sgbd")){
+ $sgbd_impl_file = $this->path("mw_dir")."env/sgbd/mw_".$this->bdd("sgbd").".php";
+ if(!file_exists($sgbd_impl_file)){
+ $this->erreur("Impossible de trouver le fichier d'implementation du sgbd ".$this->bdd("sgbd"), true);
+ }
+ $sgbd_impl = "mw_".$this->bdd("sgbd");
+ if(!class_exists($sgbd_impl)) require_once $sgbd_impl_file;
+ if(!class_exists($sgbd_impl)){
+ $this->erreur("Impossible de trouver la classe d'implementation du sgbd ".$this->bdd("sgbd"), true);
+ }
+ $sgbd = new $sgbd_impl(
+ $this,
+ array(
+ "host" => $this->bdd("host"),
+ "base" => $this->bdd("base"),
+ "user" => $this->bdd("user"),
+ "password" => $this->bdd("password")
+ )
+ );
+ if(!$sgbd->extention_ok()){
+ $this->erreur("L'extention php ".$this->bdd("sgbd")." n'est pas installée", true);
+ }
+ $data->set_sgbd($sgbd);
+ }
+ }
+
}
// -------------------------------------------------------------------------------------------
$env->load_modules($this->pathes["mw_dir"], "env/modules/");
$env->set_config_file($this->config_file);
$env->set_PATHES($this->pathes);
- $env->init_plugins();
- $env->load_versions();
+ $env->load_plugins();
$env->load_config($this->bdd, $this->config);
+ $env->load_data();
+ $env->load_sgbd();
+ $env->plugins_loaded();
+ $env->load_versions();
+ $env->load_data_upgrades();
$env->init();
- $env->loaded_plugins();
- if(($res = $env->init_data_upgrades()) !== true){
- $this->error("impossible de lire les upgrades. ".$res);
- return false;
- }
+ $env->init_plugins();
return true;
}