From: dj3c1t Date: Sun, 8 Jun 2014 16:58:57 +0000 (+0200) Subject: public attr / function, constructeurs __construct X-Git-Tag: mtweb.1.0.0~6 X-Git-Url: http://git.dj3c1t.com/index.cgi?a=commitdiff_plain;h=5abc9d5fca28ef86dee6148bb96780d1a7b670f3;p=mtweb public attr / function, constructeurs __construct --- diff --git a/mw/app/controllers/admin/index.php b/mw/app/controllers/admin/index.php index d4c4e99..9abe30c 100644 --- a/mw/app/controllers/admin/index.php +++ b/mw/app/controllers/admin/index.php @@ -2,11 +2,9 @@ class mw_admin_index extends mw_controller{ - function index(){ + public function index(){ $env = $this->env(); $env->run("admin/users"); } } - -?> \ No newline at end of file diff --git a/mw/app/controllers/admin/users.php b/mw/app/controllers/admin/users.php index 6b23503..e67fde7 100644 --- a/mw/app/controllers/admin/users.php +++ b/mw/app/controllers/admin/users.php @@ -2,16 +2,16 @@ class mw_admin_users extends mw_controller{ - var $roles; + public $roles; - function validate(){ + public function validate(){ $env = $this->env(); $data = $env->data(); if(($this->roles = $data->roles()) === false) return "impossible de lire la liste des roles"; return true; } - function index(){ + public function index(){ $env = $this->env(); $data = $env->data(); if($this->roles) $env->set_out("roles", $this->roles); @@ -32,7 +32,7 @@ else $env->erreur("impossible de lire la liste des utilisateurs"); } - function add(){ + public function add(){ $env = $this->env(); $data = $env->data(); if(!$this->roles){ @@ -90,7 +90,7 @@ $env->set_out("user", $user->get_values()); } - function edit(){ + public function edit(){ $env = $this->env(); if(!$this->roles){ $env->erreur("impossible de lire la liste des roles"); @@ -138,7 +138,7 @@ $env->set_out("user", $user->get_values()); } - function del(){ + public function del(){ $env = $this->env(); $user = $env->get_model("users"); if(!$user->load("login", $_GET[$env->param("id")])){ @@ -156,5 +156,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/controllers/config/index.php b/mw/app/controllers/config/index.php index c3ac7a3..87c36c2 100644 --- a/mw/app/controllers/config/index.php +++ b/mw/app/controllers/config/index.php @@ -2,7 +2,7 @@ class mw_config_index extends mw_controller{ - function index(){ + public function index(){ $env = $this->env(); $data = $env->data(); if(($config = $env->get_CONFIG()) === false){ @@ -30,5 +30,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/controllers/config/plugins.php b/mw/app/controllers/config/plugins.php index 4fc9179..e52a141 100644 --- a/mw/app/controllers/config/plugins.php +++ b/mw/app/controllers/config/plugins.php @@ -2,15 +2,15 @@ class mw_config_plugins extends mw_controller{ - var $plugins; + public $plugins; - function validate(){ + public function validate(){ $env = $this->env(); if(($this->plugins = $env->plugins("DESC")) === false) return "impossible de lire la liste des plugins"; return true; } - function index(){ + public function index(){ $env = $this->env(); if($this->plugins !== false){ if($_POST){ @@ -52,7 +52,7 @@ else $env->erreur("impossible de lire la liste des plugins"); } - function install(){ + public function install(){ $env = $this->env(); $plugin_name = $_GET[$env->param("id")]; if(isset($this->plugins[$plugin_name])){ @@ -77,7 +77,7 @@ else $env->erreur("impossible de trouver le plugin ".$plugin_name); } - function uninstall(){ + public function uninstall(){ $env = $this->env(); $plugin_name = $_GET[$env->param("id")]; if(isset($this->plugins[$plugin_name])){ @@ -102,7 +102,7 @@ else $env->erreur("impossible de trouver le plugin ".$plugin_name); } - function enable(){ + public function enable(){ $env = $this->env(); $plugin_name = $_GET[$env->param("id")]; if(isset($this->plugins[$plugin_name])){ @@ -133,7 +133,7 @@ else $env->erreur("impossible de trouver le plugin ".$plugin_name); } - function disable(){ + public function disable(){ $env = $this->env(); $plugin_name = $_GET[$env->param("id")]; if(isset($this->plugins[$plugin_name])){ @@ -165,5 +165,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/controllers/config/roles.php b/mw/app/controllers/config/roles.php index 6746e69..f8bf27e 100644 --- a/mw/app/controllers/config/roles.php +++ b/mw/app/controllers/config/roles.php @@ -2,16 +2,16 @@ class mw_config_roles extends mw_controller{ - var $roles; + public $roles; - function validate(){ + public function validate(){ $env = $this->env(); $data = $env->data(); if(($this->roles = $data->roles()) === false) return "impossible de lire la liste des roles"; return true; } - function index(){ + public function index(){ $env = $this->env(); $data = $env->data(); $roles = $this->roles; @@ -29,7 +29,7 @@ $env->set_out("actions", $actions); } - function set_default_allow(){ + public function set_default_allow(){ $env = $this->env(); $default_allow = $_GET[$env->param("id")]; if(!isset($default_allow) || ($default_allow !== "0" && $default_allow !== "1")){ @@ -47,7 +47,7 @@ ); } - function add_role(){ + public function add_role(){ $env = $this->env(); $data = $env->data(); $role = array( @@ -70,7 +70,7 @@ $env->set_out("role", $role); } - function edit_role(){ + public function edit_role(){ $env = $this->env(); $data = $env->data(); if(!isset($_GET[$env->param("id")]) || !($role = $data->get_role($_GET[$env->param("id")]))){ @@ -93,7 +93,7 @@ $env->set_out("role", $role); } - function save_role(){ + public function save_role(){ $env = $this->env(); $data = $env->data(); if(!($role = $data->get_role($_POST["id_role"]))){ @@ -130,7 +130,7 @@ ); } - function del_role(){ + public function del_role(){ $env = $this->env(); $data = $env->data(); if(!isset($_GET[$env->param("id")]) || !($role = $data->get_role($_GET[$env->param("id")]))){ @@ -153,5 +153,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/controllers/config/templates.php b/mw/app/controllers/config/templates.php index 120f90f..edcfed5 100644 --- a/mw/app/controllers/config/templates.php +++ b/mw/app/controllers/config/templates.php @@ -2,7 +2,7 @@ class mw_config_templates extends mw_controller{ - function index(){ + public function index(){ $env = $this->env(); $data = $env->data(); if(($templates = $env->templates()) === false){ @@ -33,7 +33,7 @@ $env->set_out("out_config", $out_config); } - function options(){ + public function options(){ $env = $this->env(); $data = $env->data(); if(($config = $env->get_CONFIG()) === false){ @@ -61,5 +61,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/controllers/forms/contact.php b/mw/app/controllers/forms/contact.php index 2b234cb..ddac68d 100644 --- a/mw/app/controllers/forms/contact.php +++ b/mw/app/controllers/forms/contact.php @@ -2,7 +2,7 @@ class mw_forms_contact extends mw_controller{ - function index(){ + public function index(){ $env = $this->env(); if($env->config("contact_form") && $env->config("email")){ if($env->config("captcha")){ @@ -42,7 +42,7 @@ else $env->run("index"); } - function __send_form($from, $titre, $message, $dest, $captcha){ + public function __send_form($from, $titre, $message, $dest, $captcha){ $env = $this->env(); $env->set_out("ENVOYE", false); if(!$captcha || PtitCaptchaHelper::checkCaptcha()){ @@ -74,5 +74,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/controllers/index/index.php b/mw/app/controllers/index/index.php index 4b36820..c71093b 100644 --- a/mw/app/controllers/index/index.php +++ b/mw/app/controllers/index/index.php @@ -2,7 +2,7 @@ class mw_index_index extends mw_controller{ - function index(){ + public function index(){ $env = $this->env(); $start_action = $env->config("start_action"); if($start_action){ @@ -17,5 +17,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/controllers/install/index.php b/mw/app/controllers/install/index.php index 07fb56e..0f7b27c 100644 --- a/mw/app/controllers/install/index.php +++ b/mw/app/controllers/install/index.php @@ -2,16 +2,16 @@ class mw_install_index extends mw_controller{ - var $config_file; + public $config_file; - function validate(){ + public function validate(){ $env = $this->env(); $this->config_file = $env->path("content")."config/config.php"; if(file_exists($this->config_file)) return "le site est deja installé"; return true; } - function index(){ + public function index(){ $env = $this->env(); $data = $env->data(); $admin = array( @@ -217,5 +217,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/controllers/reponses/html.php b/mw/app/controllers/reponses/html.php index 1e87f4a..de8acec 100644 --- a/mw/app/controllers/reponses/html.php +++ b/mw/app/controllers/reponses/html.php @@ -2,15 +2,13 @@ class mw_reponses_html extends mw_controller{ - function index(){ + public function index(){ } - function redirect_javascript(){ + public function redirect_javascript(){ } - function erreur(){ + public function erreur(){ } } - -?> \ No newline at end of file diff --git a/mw/app/controllers/upgrade/index.php b/mw/app/controllers/upgrade/index.php index 83d0b6c..97f2605 100644 --- a/mw/app/controllers/upgrade/index.php +++ b/mw/app/controllers/upgrade/index.php @@ -2,7 +2,7 @@ class mw_upgrade_index extends mw_controller{ - function index(){ + public function index(){ $env = $this->env(); $data = $env->data(); $env->set_out("data_version", $data->version("mtweb")); @@ -10,7 +10,7 @@ $env->set_out("data_upgrades", $env->data_upgrades()); } - function confirm_upgrade(){ + public function confirm_upgrade(){ $env = $this->env(); if(!($user = $env->user())){ $env->redirect($env->url("upgrade"), "", 0); diff --git a/mw/app/controllers/upgrade/user.php b/mw/app/controllers/upgrade/user.php index 9e9485e..87e05f4 100644 --- a/mw/app/controllers/upgrade/user.php +++ b/mw/app/controllers/upgrade/user.php @@ -2,7 +2,7 @@ class mw_upgrade_user extends mw_controller{ - function login(){ + public function login(){ $env = $this->env(); if($_POST){ $data = $env->data(); @@ -17,7 +17,7 @@ } } - function logout(){ + public function logout(){ $env = $this->env(); $data = $env->data(); $data->logout(); diff --git a/mw/app/controllers/users/compte.php b/mw/app/controllers/users/compte.php index c05a1a0..bfebe6a 100644 --- a/mw/app/controllers/users/compte.php +++ b/mw/app/controllers/users/compte.php @@ -2,32 +2,31 @@ class mw_users_compte extends mw_controller{ - var $roles; - var $user; + public $roles; + public $user; + public $validation_result; - var $validation_result; - - function validate(){ + public function validate(){ $this->validation_result = true; if($this->validation_result === true) $this->validate_roles(); if($this->validation_result === true) $this->validate_user(); return $this->validation_result; } - function validate_roles(){ + public function validate_roles(){ $env = $this->env(); $data = $env->data(); if(($this->roles = $data->roles()) !== false) $this->validation_result = true; else $this->validation_result = "impossible de lire la liste des roles"; } - function validate_user(){ + public function validate_user(){ $env = $this->env(); if($this->user = $env->user()) $this->validation_result = true; else $this->validation_result = "Vous devez être identifier pour accéder à cette page"; } - function index(){ + public function index(){ $env = $this->env(); if($this->validation_result === true){ $env->run("users/infos"); @@ -35,5 +34,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/controllers/users/identification.php b/mw/app/controllers/users/identification.php index e8c5f78..aced479 100644 --- a/mw/app/controllers/users/identification.php +++ b/mw/app/controllers/users/identification.php @@ -2,10 +2,10 @@ class mw_users_identification extends mw_controller{ - function index(){ + public function index(){ } - function login(){ + public function login(){ $env = $this->env(); if($_POST){ $data = $env->data(); @@ -20,7 +20,7 @@ } } - function logout(){ + public function logout(){ $env = $this->env(); $data = $env->data(); if($data->logout()){ @@ -33,7 +33,7 @@ else $env->message("Erreur lors de la deconnection. il se peut que vous soyez encore identifié"); } - function check_logout(){ + public function check_logout(){ $env = $this->env(); if($env->user()){ $env->erreur("deconnexion impossible. vous êtes toujours identifié sur le site."); @@ -48,5 +48,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/controllers/users/index.php b/mw/app/controllers/users/index.php index 29b8177..28dbdce 100644 --- a/mw/app/controllers/users/index.php +++ b/mw/app/controllers/users/index.php @@ -2,11 +2,9 @@ class mw_users_index extends mw_controller{ - function index(){ + public function index(){ $env = $this->env(); $env->run("users/infos"); } } - -?> \ No newline at end of file diff --git a/mw/app/controllers/users/infos.php b/mw/app/controllers/users/infos.php index f24f1a1..01f9b68 100644 --- a/mw/app/controllers/users/infos.php +++ b/mw/app/controllers/users/infos.php @@ -2,9 +2,9 @@ class mw_users_infos extends mw_controller{ - var $users_compte_controller; + public $users_compte_controller; - function validate(){ + public function validate(){ $env = $this->env(); if($this->users_compte_controller = $env->get_controller("users/compte")){ return $this->users_compte_controller->validate(); @@ -12,12 +12,12 @@ return "impossible de trouver le controller users/compte"; } - function index(){ + public function index(){ $env = $this->env(); $env->run("users/infos/edit"); } - function edit(){ + public function edit(){ $env = $this->env(); if(isset($this->users_compte_controller->user) && $this->users_compte_controller->user !== false){ $user = $this->users_compte_controller->user; @@ -68,5 +68,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/impl/mw_mysql.php b/mw/app/data/impl/mw_mysql.php index 4f8e41d..8a58384 100644 --- a/mw/app/data/impl/mw_mysql.php +++ b/mw/app/data/impl/mw_mysql.php @@ -2,22 +2,14 @@ class mw_mysql{ - var $link; - - var $host; - var $base; - var $user; - var $password; - - var $EXTENTION_OK; - - function extention_ok(&$env) { return $this->EXTENTION_OK; } - - function authentication_required() { return true; } - - function sgbd_name() { return "MySql"; } - - function mw_mysql($params = array()){ + public $link; + public $host; + public $base; + public $user; + public $password; + public $EXTENTION_OK; + + public function __construct($params = array()){ $this->host = isset($params["host"]) ? $params["host"] : "localhost"; $this->base = isset($params["base"]) ? $params["base"] : "mtweb"; $this->user = isset($params["user"]) ? $params["user"] : ""; @@ -25,7 +17,19 @@ $this->EXTENTION_OK = function_exists("mysql_connect"); } - function connect($host, $base, $user, $password){ + public function extention_ok(&$env){ + return $this->EXTENTION_OK; + } + + public function authentication_required(){ + return true; + } + + public function sgbd_name(){ + return "MySql"; + } + + public function connect($host, $base, $user, $password){ $this->link = @mysql_connect($host, $user, $password); if(!$this->link) throw new Exception($this->exception_out("Impossible d'etablir une connection au serveur")); @mysql_query("SET NAMES 'utf8'"); @@ -36,13 +40,13 @@ return true; } - function select_db($db_name){ + public function select_db($db_name){ $this->base = $db_name; if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password); return $this->query("USE ".$db_name); } - function desc_table($table_name){ + public function desc_table($table_name){ $sql = "SELECT * from information_schema.columns where table_name='".$table_name."'"; $rst = $this->query($sql); $desc = array( @@ -65,7 +69,7 @@ return $desc; } - function table_exists($table_name){ + public function table_exists($table_name){ if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password); $EXISTS = false; try{ @@ -84,7 +88,7 @@ return $EXISTS; } - function field_exists($table_name, $field_name){ + public function field_exists($table_name, $field_name){ if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password); if(!($desc = $this->desc_table($table_name))){ throw new Exception($this->exception_out("Impossible de lire la description de la table")); @@ -99,14 +103,14 @@ return $EXISTS; } - function query($query_string){ + public function query($query_string){ if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password); $result = @mysql_query($query_string, $this->link); if(!$result) throw new Exception($this->exception_out("Syntaxe invalide dans une requete")); return $result; } - function fetch_assoc($rst){ + public function fetch_assoc($rst){ if($this->link){ if($rst){ return mysql_fetch_assoc($rst); @@ -116,14 +120,14 @@ else throw new Exception($this->exception_out("fetch_assoc sans connexion")); } - function insert_id(){ + public function insert_id(){ if($this->link){ return mysql_insert_id($this->link); } else throw new Exception($this->exception_out("insert_id sans connexion")); } - function free_result($rst){ + public function free_result($rst){ if($this->link){ if($rst){ return mysql_free_result($rst); @@ -133,15 +137,13 @@ else throw new Exception($this->exception_out("free_result sans connexion")); } - function close(){ + public function close(){ if($this->link) return mysql_close($this->link); return true; } - function exception_out($message){ + public function exception_out($message){ return "[erreur] mysql : ".$message; } } - -?> \ No newline at end of file diff --git a/mw/app/data/impl/mw_pdo_mysql.php b/mw/app/data/impl/mw_pdo_mysql.php index 70f9876..e8ae3ee 100644 --- a/mw/app/data/impl/mw_pdo_mysql.php +++ b/mw/app/data/impl/mw_pdo_mysql.php @@ -2,34 +2,38 @@ class mw_pdo_mysql{ - var $link; - - var $host; - var $base; - var $user; - var $password; - - var $EXTENTION_OK; + public $link; + public $host; + public $base; + public $user; + public $password; + public $EXTENTION_OK; + + public function __construct($params = array()){ + $this->host = isset($params["host"]) ? $params["host"] : "localhost"; + $this->base = isset($params["base"]) ? $params["base"] : "mtweb"; + $this->user = isset($params["user"]) ? $params["user"] : ""; + $this->password = isset($params["password"]) ? $params["password"] : ""; + $this->EXTENTION_OK = (extension_loaded("pdo") && extension_loaded("pdo_mysql")); + } - function get_link(){ + public function get_link(){ return $this->link; } - function extention_ok(&$env) { return $this->EXTENTION_OK; } - - function authentication_required() { return true; } + public function extention_ok(&$env){ + return $this->EXTENTION_OK; + } - function sgbd_name() { return "PDO MySql"; } + public function authentication_required(){ + return true; + } - function mw_pdo_mysql($params = array()){ - $this->host = isset($params["host"]) ? $params["host"] : "localhost"; - $this->base = isset($params["base"]) ? $params["base"] : "mtweb"; - $this->user = isset($params["user"]) ? $params["user"] : ""; - $this->password = isset($params["password"]) ? $params["password"] : ""; - $this->EXTENTION_OK = (extension_loaded("pdo") && extension_loaded("pdo_mysql")); + public function sgbd_name(){ + return "PDO MySql"; } - function connect($host, $base, $user, $password){ + public function connect($host, $base, $user, $password){ try{ $this->link = new PDO("mysql:host=".$host.";dbname=".$base, $user, $password); $this->link->query("SET NAMES 'utf8'"); @@ -40,13 +44,13 @@ return true; } - function select_db($db_name){ + public function select_db($db_name){ $this->base = $db_name; if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password); return $this->query("USE ".$db_name); } - function desc_table($table_name){ + public function desc_table($table_name){ $sql = "SELECT * from information_schema.columns where table_name='".$table_name."'"; $rst = $this->query($sql); $desc = array( @@ -69,7 +73,7 @@ return $desc; } - function table_exists($table_name){ + public function table_exists($table_name){ if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password); $EXISTS = false; try{ @@ -88,7 +92,7 @@ return $EXISTS; } - function field_exists($table_name, $field_name){ + public function field_exists($table_name, $field_name){ if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password); if(!($desc = $this->desc_table($table_name))){ throw new Exception($this->exception_out("Impossible de lire la description de la table")); @@ -103,7 +107,7 @@ return $EXISTS; } - function query($query_string){ + public function query($query_string){ if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password); if(!($result = $this->link->query($query_string))){ throw new Exception($this->exception_out("Syntaxe invalide dans une requete")); @@ -111,7 +115,7 @@ return $result; } - function fetch_assoc($rst){ + public function fetch_assoc($rst){ if(!$this->link){ throw new Exception($this->exception_out("fetch_assoc sans connexion")); } @@ -127,7 +131,7 @@ return $tuple; } - function insert_id(){ + public function insert_id(){ if(!$this->link){ throw new Exception($this->exception_out("insert_id sans connexion")); } @@ -140,7 +144,7 @@ return $id; } - function free_result($rst){ + public function free_result($rst){ if(!$this->link){ throw new Exception($this->exception_out("free_result sans connexion")); } @@ -157,15 +161,13 @@ return true; } - function close(){ + public function close(){ $this->link = null; return true; } - function exception_out($message){ + public function exception_out($message){ return "[erreur] mysql : ".$message; } } - -?> \ No newline at end of file diff --git a/mw/app/data/impl/mw_pdo_sqlite.php b/mw/app/data/impl/mw_pdo_sqlite.php index 1e4f68e..8fd7deb 100644 --- a/mw/app/data/impl/mw_pdo_sqlite.php +++ b/mw/app/data/impl/mw_pdo_sqlite.php @@ -2,34 +2,38 @@ class mw_pdo_sqlite{ - var $link; - - var $host; - var $base; - var $user; - var $password; - - var $EXTENTION_OK; + public $link; + public $host; + public $base; + public $user; + public $password; + public $EXTENTION_OK; + + public function __construct($params = array()){ + $this->host = isset($params["host"]) ? $params["host"] : "content/data/sqlite"; + $this->base = isset($params["base"]) ? $params["base"] : "mtweb.db"; + $this->user = isset($params["user"]) ? $params["user"] : ""; + $this->password = isset($params["password"]) ? $params["password"] : ""; + $this->EXTENTION_OK = (extension_loaded("pdo") && extension_loaded("pdo_sqlite")); + } - function get_link(){ + public function get_link(){ return $this->link; } - function extention_ok(&$env) { return $this->EXTENTION_OK; } - - function authentication_required() { return false; } + public function extention_ok(&$env){ + return $this->EXTENTION_OK; + } - function sgbd_name() { return "PDO SQLite"; } + public function authentication_required(){ + return false; + } - function mw_pdo_sqlite($params = array()){ - $this->host = isset($params["host"]) ? $params["host"] : "content/data/sqlite"; - $this->base = isset($params["base"]) ? $params["base"] : "mtweb.db"; - $this->user = isset($params["user"]) ? $params["user"] : ""; - $this->password = isset($params["password"]) ? $params["password"] : ""; - $this->EXTENTION_OK = (extension_loaded("pdo") && extension_loaded("pdo_sqlite")); + public function sgbd_name(){ + return "PDO SQLite"; } - function connect($host, $base, $user, $password){ + public function connect($host, $base, $user, $password){ if($host) $host .= substr($host, -1) != "/" ? "/" : ""; try{ $this->link = null; @@ -43,12 +47,12 @@ return true; } - function select_db($db_name){ + public function select_db($db_name){ $this->base = $db_name; return $this->connect($this->host, $this->base, $this->user, $this->password); } - function desc_table($table_name){ + public function desc_table($table_name){ if(strpos($table_name, "'") !== false){ throw new Exception($this->exception_out("nom de table avec un simple quote")); } @@ -73,7 +77,7 @@ return $desc; } - function table_exists($table_name){ + public function table_exists($table_name){ if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password); $EXISTS = false; try{ @@ -92,7 +96,7 @@ return $EXISTS; } - function field_exists($table_name, $field_name){ + public function field_exists($table_name, $field_name){ if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password); if(!($desc = $this->desc_table($table_name))){ throw new Exception($this->exception_out("Impossible de lire la description de la table")); @@ -107,7 +111,7 @@ return $EXISTS; } - function query($query_string){ + public function query($query_string){ if(!$this->link) $this->connect($this->host, $this->base, $this->user, $this->password); if(!($result = $this->link->query($query_string))){ throw new Exception($this->exception_out("Syntaxe invalide dans une requete")); @@ -115,7 +119,7 @@ return $result; } - function fetch_assoc($rst){ + public function fetch_assoc($rst){ if(!$this->link){ throw new Exception($this->exception_out("fetch_assoc sans connexion")); } @@ -131,7 +135,7 @@ return $tuple; } - function insert_id(){ + public function insert_id(){ if(!$this->link){ throw new Exception($this->exception_out("insert_id sans connexion")); } @@ -144,7 +148,7 @@ return $id; } - function free_result($rst){ + public function free_result($rst){ if(!$this->link){ throw new Exception($this->exception_out("free_result sans connexion")); } @@ -161,15 +165,13 @@ return true; } - function close(){ + public function close(){ $this->link = null; return true; } - function exception_out($message){ + public function exception_out($message){ return "[erreur] sqlite : ".$message; } } - -?> \ No newline at end of file diff --git a/mw/app/data/impl/mw_xml.php b/mw/app/data/impl/mw_xml.php index 335e974..3d09caf 100644 --- a/mw/app/data/impl/mw_xml.php +++ b/mw/app/data/impl/mw_xml.php @@ -2,19 +2,16 @@ class mw_xml{ - var $host; - var $base; - var $user; - var $password; - - var $EXTENTION_OK; - - var $xml_data; - - var $data_handlers; - var $last_data_handler; - - function mw_xml($params = array()){ + public $host; + public $base; + public $user; + public $password; + public $EXTENTION_OK; + public $xml_data; + public $data_handlers; + public $last_data_handler; + + public function __construct($params = array()){ $this->init_xml_env( isset($params["host"]) ? $params["host"] : "content/data/xml", isset($params["base"]) ? $params["base"] : "mw", @@ -24,7 +21,7 @@ $this->EXTENTION_OK = true; } - function extention_ok(&$env){ + public function extention_ok(&$env){ if($this->EXTENTION_OK){ if( file_exists($env->app_file("data/impl/xml/mw_xml_data.php")) @@ -45,11 +42,15 @@ return $this->EXTENTION_OK; } - function authentication_required() { return false; } + public function authentication_required(){ + return false; + } - function sgbd_name() { return "XML"; } + public function sgbd_name(){ + return "XML"; + } - function init_xml_env($host, $base, $user, $password){ + public function init_xml_env($host, $base, $user, $password){ $this->host = $host.($host && substr($host, -1) != "/" ? "/" : ""); $this->base = $base.($base && substr($base, -1) != "/" ? "/" : ""); $this->user = $user; @@ -58,7 +59,7 @@ $this->last_data_handler = 0; } - function connect($host, $base, $user, $password){ + public function connect($host, $base, $user, $password){ if($host.$base && is_dir($host.$base) && is_writable($host.$base)){ $this->init_xml_env($host, $base, $user, $password); $this->xml_data = new mw_xml_data($this->host, $this->base); @@ -67,16 +68,16 @@ return null; } - function select_db($base){ + public function select_db($base){ $this->base = $base.($base && substr($base, -1) != "/" ? "/" : ""); return $this->connect($this->host, $this->base, $this->user, $this->password); } - function data_exists($data_path){ + public function data_exists($data_path){ return is_dir($this->host.$this->base.$data_path); } - function create_data($data_path){ + public function create_data($data_path){ if(!is_dir($this->host.$this->base.$data_path)) @mkdir($this->host.$this->base.$data_path); if(is_dir($this->host.$this->base.$data_path)){ if($dh = $this->open_data($data_path, false)){ @@ -87,7 +88,7 @@ return null; } - function get_data($data_path, $data_id){ + public function get_data($data_path, $data_id){ $dh = ++$this->last_data_handler; $this->data_handlers[$dh] = new mw_xml_data_handler($this->xml_data, $data_path); if($this->data_handlers[$dh]->open_data(false)){ @@ -98,7 +99,7 @@ return null; } - function open_data($data_path, $FETCH = true){ + public function open_data($data_path, $FETCH = true){ $dh = ++$this->last_data_handler; $this->data_handlers[$dh] = new mw_xml_data_handler($this->xml_data, $data_path); if($this->data_handlers[$dh]->open_data($FETCH)){ @@ -108,14 +109,14 @@ return null; } - function fetch_data($dh){ + public function fetch_data($dh){ if(isset($this->data_handlers[$dh])){ return $this->data_handlers[$dh]->fetch_assoc(); } return false; } - function add_data($data_path, $data, $index = null){ + public function add_data($data_path, $data, $index = null){ $dh = ++$this->last_data_handler; $this->data_handlers[$dh] = new mw_xml_data_handler($this->xml_data, $data_path); if($this->data_handlers[$dh]->open_data(false)){ @@ -127,14 +128,14 @@ return null; } - function last_index($dh){ + public function last_index($dh){ if(isset($this->data_handlers[$dh])){ return $this->data_handlers[$dh]->last_index; } return null; } - function set_data($data_path, $data_id, $data){ + public function set_data($data_path, $data_id, $data){ $dh = ++$this->last_data_handler; $this->data_handlers[$dh] = new mw_xml_data_handler($this->xml_data, $data_path); if($this->data_handlers[$dh]->open_data(false)){ @@ -145,7 +146,7 @@ return null; } - function del_data($data_path, $data_id){ + public function del_data($data_path, $data_id){ $dh = ++$this->last_data_handler; $this->data_handlers[$dh] = new mw_xml_data_handler($this->xml_data, $data_path); if($this->data_handlers[$dh]->open_data(false)){ @@ -156,14 +157,14 @@ return null; } - function close_data($dh){ + public function close_data($dh){ if(isset($this->data_handlers[$dh])){ $this->data_handlers[$dh]->close_data(); unset($this->data_handlers[$dh]); } } - function remove_data($data_path){ + public function remove_data($data_path){ $OK = strlen($data_path) > 0; if($OK && is_dir($this->host.$this->base.$data_path) && is_writable($this->host.$this->base.$data_path)){ $data_path .= substr($data_path, -1) == "/" ? "" : "/"; @@ -184,5 +185,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/impl/xml/mw_xml_data.php b/mw/app/data/impl/xml/mw_xml_data.php index 0b6c8cd..1148da9 100644 --- a/mw/app/data/impl/xml/mw_xml_data.php +++ b/mw/app/data/impl/xml/mw_xml_data.php @@ -2,40 +2,38 @@ class mw_xml_data{ - var $host; - var $base; + public $host; + public $base; + public $sxml; + public $cache; + public $buffer; - var $sxml; - - var $cache; - var $buffer; - - function mw_xml_data($host, $base){ + public function mw_xml_data($host, $base){ $this->host = $host.(substr($host, -1) != "/" ? "/" : ""); $this->base = $base.(substr($base, -1) != "/" ? "/" : ""); $this->cache = array(); } - function host(){ + public function host(){ return $this->host; } - function base(){ + public function base(){ return $this->base; } - function use_cache(){ + public function use_cache(){ return true; } - function set_cache($data_name, $data, $data_id){ + public function set_cache($data_name, $data, $data_id){ if($this->use_cache()){ $this->cache[$data_name] = $data; $this->cache[$data_name]["id"] = $data_id; } } - function get_data($data_path, $data_id){ + public function get_data($data_path, $data_id){ $data_name = $this->data_name($data_path, $data_id); if(isset($this->cache[$data_name])) return $this->cache[$data_name]; if($this->buffer = @file_get_contents($data_name)){ @@ -48,15 +46,15 @@ return false; } - function add_data($data_path, $data_id, $data){ + public function add_data($data_path, $data_id, $data){ return $this->_set_data($data_path, $data_id, $data); } - function set_data($data_path, $data_id, $data){ + public function set_data($data_path, $data_id, $data){ return $this->_set_data($data_path, $data_id, $data); } - function _set_data($data_path, $data_id, $data){ + public function _set_data($data_path, $data_id, $data){ if($fh = @fopen($this->data_name($data_path, $data_id), "w")){ $this->buffer = $this->serialize_data($data); if(@fwrite($fh, $this->buffer) !== false){ @@ -74,17 +72,17 @@ return null; } - function del_data($data_path, $data_id){ + public function del_data($data_path, $data_id){ $data_name = $this->data_name($data_path, $data_id); if(isset($this->cache[$data_name])) unset($this->cache[$data_name]); return @unlink($this->data_name($data_path, $data_id)); } - function data_name($data_path, $data_id){ + public function data_name($data_path, $data_id){ return $this->host.$this->base.$data_path.$data_id.".xml"; } - function parse_data(){ + public function parse_data(){ if(!isset($this->sxml)) $this->sxml = new sxml(); $this->sxml->parse($this->buffer); if(isset($this->sxml->data["tuple"][0])){ @@ -98,7 +96,7 @@ return false; } - function serialize_data($data){ + public function serialize_data($data){ $this->buffer = "\n"; foreach($data as $key => $value){ if(isset($value)) $this->buffer .= " <".$key.">\n"; @@ -108,5 +106,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/impl/xml/mw_xml_data_handler.php b/mw/app/data/impl/xml/mw_xml_data_handler.php index 6ed8206..606dcee 100644 --- a/mw/app/data/impl/xml/mw_xml_data_handler.php +++ b/mw/app/data/impl/xml/mw_xml_data_handler.php @@ -2,24 +2,24 @@ class mw_xml_data_handler{ - var $xml_data; - var $data_path; - var $data_path_handler; - var $last_index; + public $xml_data; + public $data_path; + public $data_path_handler; + public $last_index; - function mw_xml_data_handler($xml_data, $data_path){ + public function mw_xml_data_handler($xml_data, $data_path){ $this->xml_data = $xml_data; $this->data_path = $data_path.(substr($data_path, -1) != "/" ? "/" : ""); } - function get_data($data_id){ + public function get_data($data_id){ if(file_exists($this->xml_data->host().$this->xml_data->base().$this->data_path.$data_id.".xml")){ return $this->xml_data->get_data($this->data_path, $data_id); } return false; } - function open_data($FETCH = true){ + public function open_data($FETCH = true){ clearstatcache(); $INDEX_OK = false; if($this->xml_data->host() && $this->xml_data->base() && $this->data_path){ @@ -62,7 +62,7 @@ } } - function fetch_assoc(){ + public function fetch_assoc(){ if($this->data_path_handler){ $FORMAT_OK = false; while(!$FORMAT_OK && ($data_file = @readdir($this->data_path_handler)) !== false){ @@ -73,7 +73,7 @@ return false; } - function add_data($data, $index = null){ + public function add_data($data, $index = null){ if(!isset($index)) $index = $this->inc_index(); if(isset($index)){ if(is_array($data)) return $this->xml_data->add_data($this->data_path, $index, $data); @@ -81,7 +81,7 @@ return null; } - function inc_index(){ + public function inc_index(){ clearstatcache(); if(isset($this->last_index)){ $index = $this->last_index + 1; @@ -97,7 +97,7 @@ return null; } - function set_data($data_file, $data){ + public function set_data($data_file, $data){ if(preg_match("/^[0-9]+\.xml$/", $data_file)){ if(is_writable($this->xml_data->host().$this->xml_data->base().$this->data_path.$data_file)){ if(is_array($data)){ @@ -108,7 +108,7 @@ return null; } - function del_data($data_file){ + public function del_data($data_file){ if(preg_match("/^[0-9]+\.xml$/", $data_file)){ if(is_file($this->xml_data->host().$this->xml_data->base().$this->data_path.$data_file)){ return $this->xml_data->del_data($this->data_path, substr($data_file, 0, -4)); @@ -117,12 +117,10 @@ return null; } - function close_data(){ + public function close_data(){ $this->data_path= null; if($this->data_path_handler) @closedir($this->data_path_handler); $this->last_index = null; } } - -?> \ No newline at end of file diff --git a/mw/app/data/models/users.php b/mw/app/data/models/users.php index e9eb8ad..62b4239 100644 --- a/mw/app/data/models/users.php +++ b/mw/app/data/models/users.php @@ -2,24 +2,24 @@ class mw_model_users extends mw_model{ - var $roles; + public $roles; // ---------------------------------------------------------------------------- // accesseurs - function set_roles($roles){ + public function set_roles($roles){ $this->roles = $roles; } - function get_roles(){ + public function get_roles(){ return $this->roles; } - function clear_roles(){ + public function clear_roles(){ $this->roles = null; } - function get_values(){ + public function get_values(){ $values = array(); if(isset($this->roles)) $values["roles"] = $this->roles; foreach($this->attributs as $attribut_name => $attribut){ @@ -28,18 +28,18 @@ return $values; } - function set_password($password){ + public function set_password($password){ $this->attributs["password"]["value"] = $this->encode_password($password); } - function encode_password($password){ + public function encode_password($password){ return md5($password); } // ---------------------------------------------------------------------------- // validation - function valid_email($email){ + public function valid_email($email){ if(!isset($email) || !$email){ return "merci de préciser un email"; } @@ -49,14 +49,14 @@ return true; } - function valid_login($login){ + public function valid_login($login){ if(!isset($login) || !$login){ return "merci de préciser un login"; } return true; } - function valid_password($password){ + public function valid_password($password){ if(!isset($password) || ($password == $this->encode_password(""))){ return "merci de préciser un mot de passe"; } @@ -66,7 +66,7 @@ // ---------------------------------------------------------------------------- // CRUD - function insert(){ + public function insert(){ $data = $this->env->data(); $roles = $this->get_roles(); $this->clear_roles(); @@ -82,7 +82,7 @@ return $id_user; } - function load($index_name, $index_value){ + public function load($index_name, $index_value){ $data = $this->env->data(); if(parent::load($index_name, $index_value) === false) return false; if($this->get_id()){ @@ -93,7 +93,7 @@ return true; } - function update($index_name, $index_value = null){ + public function update($index_name, $index_value = null){ $data = $this->env->data(); $roles = $this->get_roles(); $this->clear_roles(); @@ -106,12 +106,10 @@ return $res; } - function delete($index_name, $index_value = null){ + public function delete($index_name, $index_value = null){ $data = $this->env->data(); if(!$data->clear_user_roles($this->get_id())) return false; return parent::delete($index_name, $index_value); } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/share/mw_data_auto_crud.php b/mw/app/data/modules/share/mw_data_auto_crud.php index 2e72ebc..5c4c4f5 100644 --- a/mw/app/data/modules/share/mw_data_auto_crud.php +++ b/mw/app/data/modules/share/mw_data_auto_crud.php @@ -2,7 +2,7 @@ class mw_data_auto_crud extends mw_data{ - function call_data_auto_crud($method_name, $arguments){ + public function call_data_auto_crud($method_name, $arguments){ $r = false; $sgbd = $this->sgbd(); @@ -92,5 +92,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/share/mw_data_config.php b/mw/app/data/modules/share/mw_data_config.php index 2a8ae51..219feb6 100644 --- a/mw/app/data/modules/share/mw_data_config.php +++ b/mw/app/data/modules/share/mw_data_config.php @@ -2,7 +2,7 @@ class mw_data_config extends mw_data{ - function config($key = null){ + public function config($key = null){ $value = false; if(isset($key)){ $value = ""; @@ -36,7 +36,7 @@ return $value; } - function config_exists($key){ + public function config_exists($key){ if( ( $config = $this->data_read( @@ -51,7 +51,7 @@ return $config ? 1 : 0; } - function set_config($key, $value){ + public function set_config($key, $value){ if( ( $config = $this->data_read( @@ -88,7 +88,7 @@ } } - function del_config($key){ + public function del_config($key){ return $this->data_delete( array( "table_name" => "config", @@ -99,5 +99,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/share/mw_data_images.php b/mw/app/data/modules/share/mw_data_images.php index 48ceeee..8c59b99 100644 --- a/mw/app/data/modules/share/mw_data_images.php +++ b/mw/app/data/modules/share/mw_data_images.php @@ -2,7 +2,7 @@ class mw_data_images extends mw_data{ - function img_size($file, $max_width, $max_height){ + public function img_size($file, $max_width, $max_height){ $img_infos = @getimagesize($file); $img_size = array(); if($img_infos){ diff --git a/mw/app/data/modules/share/mw_data_init.php b/mw/app/data/modules/share/mw_data_init.php index 1a74be4..9eab510 100644 --- a/mw/app/data/modules/share/mw_data_init.php +++ b/mw/app/data/modules/share/mw_data_init.php @@ -2,29 +2,27 @@ class mw_data_init extends mw_data{ - var $env; - var $sgbd; + public $env; + public $sgbd; - function env(){ + public function env(){ return $this->env; } - function sgbd(){ + public function sgbd(){ return $this->sgbd; } - function set_env(&$env){ + public function set_env(&$env){ $this->env = &$env; } - function set_sgbd(&$sgbd){ + public function set_sgbd(&$sgbd){ $this->sgbd = &$sgbd; } - function table_prefix(){ + public function table_prefix(){ return false; } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/share/mw_data_links.php b/mw/app/data/modules/share/mw_data_links.php index d5f3287..223689e 100644 --- a/mw/app/data/modules/share/mw_data_links.php +++ b/mw/app/data/modules/share/mw_data_links.php @@ -2,14 +2,14 @@ class mw_data_links extends mw_data{ - var $links; + public $links; - function init_links(){ + public function init_links(){ $this->links = array(); return true; } - function load_link(&$links, $v_path, $url, $intitule = "", $position = 0){ + public function load_link(&$links, $v_path, $url, $intitule = "", $position = 0){ if($path_item = array_shift($v_path)){ if(!isset($links[$path_item])) $links[$path_item] = array( "nom" => $path_item, @@ -28,7 +28,7 @@ } } - function valid_link_path($path){ + public function valid_link_path($path){ $v_path = explode("/", $path); $SYNTAX_OK = true; foreach($v_path as $i => $path_item){ @@ -43,7 +43,7 @@ return $v_path && $SYNTAX_OK ? $v_path : false; } - function get_link($path = null){ + public function get_link($path = null){ if(!isset($this->links)) $this->init_links(); if($this->links !== false){ if(!isset($path)) return $this->links; @@ -54,7 +54,7 @@ return false; } - function _get_link($links, $v_path){ + public function _get_link($links, $v_path){ if($path_item = array_shift($v_path)){ if(isset($links[$path_item])){ if($v_path) return $this->_get_link($links[$path_item]["subs"], $v_path); @@ -64,7 +64,7 @@ } } - function set_link($path, $url, $intitule = "", $position = 0){ + public function set_link($path, $url, $intitule = "", $position = 0){ if(!isset($this->links)) $this->init_links(); if($v_path = $this->valid_link_path($path)){ $this->load_link($this->links, $v_path, $url, $intitule, $position); @@ -72,7 +72,7 @@ } } - function ordonne_links($links){ + public function ordonne_links($links){ if(!is_array($links)) return false; $values = array_values($links); $maximum = count($values); @@ -95,5 +95,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/share/mw_data_sgbds.php b/mw/app/data/modules/share/mw_data_sgbds.php index db90855..c93d814 100644 --- a/mw/app/data/modules/share/mw_data_sgbds.php +++ b/mw/app/data/modules/share/mw_data_sgbds.php @@ -2,7 +2,7 @@ class mw_data_sgbds extends mw_data{ - function sgbds(){ + public function sgbds(){ $env = $this->env(); $sgbds = array(); $impls_dir = $env->app_file("data/impl"); @@ -33,5 +33,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/share/mw_data_users_files.php b/mw/app/data/modules/share/mw_data_users_files.php index e2754e3..c84fda7 100644 --- a/mw/app/data/modules/share/mw_data_users_files.php +++ b/mw/app/data/modules/share/mw_data_users_files.php @@ -2,7 +2,7 @@ class mw_data_users_files extends mw_data{ - function check_user_uploads_dir($id_user = null){ + public function check_user_uploads_dir($id_user = null){ $env = $this->env(); if(!isset($id_user)){ $user = $env->user(); @@ -19,5 +19,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/share/mw_data_users_sessions.php b/mw/app/data/modules/share/mw_data_users_sessions.php index df81d46..7203e99 100644 --- a/mw/app/data/modules/share/mw_data_users_sessions.php +++ b/mw/app/data/modules/share/mw_data_users_sessions.php @@ -2,9 +2,9 @@ class mw_data_users_sessions extends mw_data{ - var $user; + public $user; - function login($login, $password, $reference_user = null){ + public function login($login, $password, $reference_user = null){ if(($user = isset($reference_user) ? $reference_user : $this->user($login)) !== false){ if(isset($reference_user) && $login != $reference_user["login"]){ $this->clear_session(); @@ -21,11 +21,11 @@ return $user; } - function logout(){ + public function logout(){ return $this->clear_session(); } - function user_ok($user){ + public function user_ok($user){ return (isset($_SESSION[$this->app_session_key()]["id"])) && (isset($_SESSION[$this->app_session_key()]["pass"])) @@ -34,7 +34,7 @@ && ($_SESSION[$this->app_session_key()]["ip"] == $_SERVER["REMOTE_ADDR"]); } - function password_ok($user, $password){ + public function password_ok($user, $password){ if(!$user) return false; $OK = (isset($_SESSION[$this->app_session_key()]["id"])) @@ -49,12 +49,12 @@ # session # - function app_session_key(){ + public function app_session_key(){ $env = $this->env(); return "mw_".str_replace("/", "_", $env->path("web")); } - function load_session($reference_user = null){ + public function load_session($reference_user = null){ @session_start(); if(!isset($_SESSION[$this->app_session_key()]["id"])) $this->clear_session(); $user = array(); @@ -78,7 +78,7 @@ return $user; } - function set_session($user){ + public function set_session($user){ if(!isset($_SESSION[$this->app_session_key()])) $this->clear_session(); $_SESSION[$this->app_session_key()]["user"] = $user["login"]; $_SESSION[$this->app_session_key()]["pass"] = md5($user["password"].$_SESSION[$this->app_session_key()]["id"]); @@ -88,7 +88,7 @@ && @setcookie($this->app_session_key()."_pass", $user["password"], time() + (60 * 60 * 24 * 7), "/"); } - function clear_session(){ + public function clear_session(){ unset($_SESSION[$this->app_session_key()]); $_SESSION[$this->app_session_key()] = array( "ip" => $_SERVER["REMOTE_ADDR"], @@ -99,15 +99,13 @@ && @setcookie($this->app_session_key()."_pass", "", 0, "/"); } - function set_session_user($user){ + public function set_session_user($user){ $this->set_session($user); $this->user =& $user; } - function get_session_user(){ + public function get_session_user(){ return $this->user; } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/share/mw_data_utils.php b/mw/app/data/modules/share/mw_data_utils.php index df4a549..e939a75 100644 --- a/mw/app/data/modules/share/mw_data_utils.php +++ b/mw/app/data/modules/share/mw_data_utils.php @@ -2,11 +2,11 @@ class mw_data_utils extends mw_data{ - function eq($content){ + public function eq($content){ return isset($content) ? "'".str_replace("'", "\'", $content)."'" : "NULL"; } - function ordonne($list, $key, $order = "ASC"){ + public function ordonne($list, $key, $order = "ASC"){ $values = array_values($list); $maximum = count($values); while($maximum > 0){ @@ -29,7 +29,7 @@ return $res; } - function upload($image, $upload_dir){ + public function upload($image, $upload_dir){ $file = ""; $upload_dir .= $upload_dir && (substr($upload_dir, -1) != "/") ? "/" : ""; if($_FILES){ @@ -48,5 +48,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/share/mw_data_valid_config.php b/mw/app/data/modules/share/mw_data_valid_config.php index aace0d7..1d75b85 100644 --- a/mw/app/data/modules/share/mw_data_valid_config.php +++ b/mw/app/data/modules/share/mw_data_valid_config.php @@ -2,7 +2,7 @@ class mw_data_valid_config extends mw_data{ - function valid_config($input, $config = array()){ + public function valid_config($input, $config = array()){ $res = array( "config" => $config, "messages" => array(), @@ -31,5 +31,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/share/mw_data_versions.php b/mw/app/data/modules/share/mw_data_versions.php index 1f539b4..82ef591 100644 --- a/mw/app/data/modules/share/mw_data_versions.php +++ b/mw/app/data/modules/share/mw_data_versions.php @@ -2,7 +2,7 @@ class mw_data_versions extends mw_data{ - function version($application_name){ + public function version($application_name){ if( $version = $this->data_read( array( @@ -15,7 +15,7 @@ return false; } - function set_version($application_name, $version){ + public function set_version($application_name, $version){ if( ( $data_version = $this->data_read( diff --git a/mw/app/data/modules/sql/mw_data_sql_crud.php b/mw/app/data/modules/sql/mw_data_sql_crud.php index 3d1d210..696e1d9 100644 --- a/mw/app/data/modules/sql/mw_data_sql_crud.php +++ b/mw/app/data/modules/sql/mw_data_sql_crud.php @@ -6,7 +6,7 @@ # parametres du sgbd # - function set_sgbd_param($key, $value){ + public function set_sgbd_param($key, $value){ $env = $this->env(); if(($env->bdd("sgbd") == "pdo_mysql") || ($env->bdd("sgbd") == "mysql")){ return $this->set_sgbd_mysql_param($key, $value); @@ -14,7 +14,7 @@ return false; } - function set_sgbd_mysql_param($key, $value){ + public function set_sgbd_mysql_param($key, $value){ $sgbd = $this->sgbd(); $sql = "SET ".$key."=\"".$value."\""; try{ @@ -30,7 +30,7 @@ # create table # - function data_create_table($params){ + public function data_create_table($params){ $env = $this->env(); if($env->bdd("sgbd") == "pdo_sqlite"){ return $this->data_create_sqlite_table($params); @@ -38,7 +38,7 @@ return $this->data_create_mysql_table($params); } - function data_create_mysql_table($params){ + public function data_create_mysql_table($params){ $sgbd = $this->sgbd(); $table_name = isset($params["table_name"]) ? $params["table_name"] : ""; $fields = isset($params["fields"]) ? $params["fields"] : array(); @@ -115,7 +115,7 @@ return true; } - function data_create_sqlite_table($params){ + public function data_create_sqlite_table($params){ $sgbd = $this->sgbd(); $table_name = isset($params["table_name"]) ? $params["table_name"] : ""; $fields = isset($params["fields"]) ? $params["fields"] : array(); @@ -175,7 +175,7 @@ # description # - function data_desc($params = array()){ + public function data_desc($params = array()){ $sgbd = $this->sgbd(); $table_name = isset($params["table_name"]) ? $params["table_name"] : ""; if(!$table_name) return false; @@ -190,7 +190,7 @@ # insert # - function data_insert($params = array()){ + public function data_insert($params = array()){ $sgbd = $this->sgbd(); $table_name = isset($params["table_name"]) ? $params["table_name"] : ""; if(!$table_name) return false; @@ -217,7 +217,7 @@ # read # - function data_read($params = array()){ + public function data_read($params = array()){ $sgbd = $this->sgbd(); $table_name = isset($params["table_name"]) ? $params["table_name"] : ""; $index_name = isset($params["index_name"]) ? $params["index_name"] : ""; @@ -238,7 +238,7 @@ # update # - function data_update($params = array()){ + public function data_update($params = array()){ $sgbd = $this->sgbd(); $table_name = isset($params["table_name"]) ? $params["table_name"] : false; $values = (isset($params["values"]) && is_array($params["values"])) ? $params["values"] : false; @@ -263,7 +263,7 @@ # delete # - function data_delete($params = array()){ + public function data_delete($params = array()){ $sgbd = $this->sgbd(); $table_name = isset($params["table_name"]) ? $params["table_name"] : false; $index_name = isset($params["index_name"]) ? $params["index_name"] : false; @@ -281,7 +281,7 @@ # list # - function data_list($params = array()){ + public function data_list($params = array()){ $sgbd = $this->sgbd(); $table_name = isset($params["table_name"]) ? $params["table_name"] : ""; if(!$table_name) return false; @@ -351,5 +351,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/sql/mw_data_sql_install.php b/mw/app/data/modules/sql/mw_data_sql_install.php index 22b86dc..9dd746d 100644 --- a/mw/app/data/modules/sql/mw_data_sql_install.php +++ b/mw/app/data/modules/sql/mw_data_sql_install.php @@ -2,7 +2,7 @@ class mw_data_sql_install extends mw_data{ - function install_sql($params){ + public function install_sql($params){ $env = $this->env(); $data = $env->data(); $sgbd = $data->sgbd(); @@ -152,5 +152,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/sql/mw_data_sql_users.php b/mw/app/data/modules/sql/mw_data_sql_users.php index 3611968..309e4e5 100644 --- a/mw/app/data/modules/sql/mw_data_sql_users.php +++ b/mw/app/data/modules/sql/mw_data_sql_users.php @@ -2,16 +2,16 @@ class mw_data_sql_users extends mw_data{ - var $users; - var $user; - var $roles; - var $actions_roles; + public $users; + public $user; + public $roles; + public $actions_roles; # ---------------------------------------------------------------------------------------- # users # - function users($start = 0, $alpha = null, $id_role = null){ + public function users($start = 0, $alpha = null, $id_role = null){ $sgbd = $this->sgbd(); $env = $this->env(); $users = array("list" => array(), "total" => 0); @@ -54,7 +54,7 @@ return $users; } - function list_user_roles($id_user){ + public function list_user_roles($id_user){ $sgbd = $this->sgbd(); $roles = array(); try{ @@ -66,21 +66,21 @@ return $roles; } - function user_by_id($id){ + public function user_by_id($id){ $env = $this->env(); $user = $env->get_model("users"); if($user->load("id", $id) === false) return false; return $user->get_values(); } - function user($login){ + public function user($login){ $env = $this->env(); $user = $env->get_model("users"); if($user->load("login", $login) === false) return false; return $user->get_values(); } - function user_exists($login){ + public function user_exists($login){ $sgbd = $this->sgbd(); $EXISTS = 0; try{ @@ -93,7 +93,7 @@ return $EXISTS; } - function add_user($login, $password, $email, $roles){ + public function add_user($login, $password, $email, $roles){ $sgbd = $this->sgbd(); $user_id = false; try{ @@ -118,7 +118,7 @@ return $user_id; } - function set_user($id, $login, $password, $email, $roles){ + public function set_user($id, $login, $password, $email, $roles){ $sgbd = $this->sgbd(); try{ $sql = @@ -137,7 +137,7 @@ return true; } - function clear_user_roles($id_user){ + public function clear_user_roles($id_user){ $sgbd = $this->sgbd(); try{ $sql = "DELETE FROM #--users_roles WHERE id_user=".$this->eq($id_user); @@ -147,7 +147,7 @@ return true; } - function add_user_role($id_user, $id_role){ + public function add_user_role($id_user, $id_role){ $sgbd = $this->sgbd(); try{ $sql = @@ -161,7 +161,7 @@ return true; } - function del_user($login){ + public function del_user($login){ if(($user = $this->user($login)) !== false){ $sgbd = $this->sgbd(); try{ @@ -180,7 +180,7 @@ # roles # - function init_roles(){ + public function init_roles(){ $sgbd = $this->sgbd(); $this->roles = array(); try{ @@ -193,12 +193,12 @@ return $this->roles; } - function roles(){ + public function roles(){ if(!isset($this->roles)) return false; return $this->roles; } - function add_role($nom, $intitule){ + public function add_role($nom, $intitule){ $sgbd = $this->sgbd(); try{ $sql = @@ -213,7 +213,7 @@ return $id_role; } - function get_role($id){ + public function get_role($id){ if($id === "0") return array( "id" => 0, "nom" => "", @@ -231,7 +231,7 @@ return $role; } - function set_role($id, $nom, $intitule){ + public function set_role($id, $nom, $intitule){ $sgbd = $this->sgbd(); try{ $sql = @@ -245,7 +245,7 @@ return true; } - function clear_role_actions($id_role){ + public function clear_role_actions($id_role){ $sgbd = $this->sgbd(); try{ $sql = "DELETE FROM #--actions_roles WHERE id_role=".$this->eq($id_role); @@ -255,7 +255,7 @@ return true; } - function clear_role_users($id_role){ + public function clear_role_users($id_role){ $sgbd = $this->sgbd(); try{ $sql = "DELETE FROM #--users_roles WHERE id_role=".$this->eq($id_role); @@ -265,7 +265,7 @@ return true; } - function add_role_action($id_role, $action){ + public function add_role_action($id_role, $action){ $sgbd = $this->sgbd(); try{ $sql = "INSERT INTO #--actions_roles(action, id_role) VALUES(".$this->eq($action).", ".$this->eq($id_role).")"; @@ -276,7 +276,7 @@ return $id_action_role; } - function del_role($id_role){ + public function del_role($id_role){ $sgbd = $this->sgbd(); try{ $sql = "DELETE FROM #--roles WHERE id=".$this->eq($id_role); @@ -286,7 +286,7 @@ return true; } - function get_user_roles(){ + public function get_user_roles(){ $user_roles = array(); $user = $this->get_session_user(); if($user && isset($user["id"])){ @@ -304,13 +304,13 @@ return $user_roles; } - function init_actions_roles(){ + public function init_actions_roles(){ if(!isset($this->roles)) return false; $this->actions_roles = $this->read_actions_roles(); return $this->actions_roles; } - function read_actions_roles($params = array()){ + public function read_actions_roles($params = array()){ $group_by_action = isset($params["group_by_action"]) ? $params["group_by_action"] : false; $sgbd = $this->sgbd(); $actions_roles = array(); @@ -330,7 +330,7 @@ return $actions_roles; } - function get_action_roles($mod, $controller = "index", $action = "index"){ + public function get_action_roles($mod, $controller = "index", $action = "index"){ $sgbd = $this->sgbd(); $roles = array(); try{ @@ -351,7 +351,7 @@ return $roles; } - function get_actions($id_role = null){ + public function get_actions($id_role = null){ $env = $this->env(); if($actions = $env->get_actions()){ if(($actions_roles = $this->read_actions_roles(array("group_by_action" => true))) !== false){ @@ -410,5 +410,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/sql/mw_data_sqlite_install.php b/mw/app/data/modules/sql/mw_data_sqlite_install.php index 2f241f6..7e42995 100644 --- a/mw/app/data/modules/sql/mw_data_sqlite_install.php +++ b/mw/app/data/modules/sql/mw_data_sqlite_install.php @@ -2,7 +2,7 @@ class mw_data_sqlite_install extends mw_data{ - function install_sqlite($params){ + public function install_sqlite($params){ $env = $this->env(); $data = $env->data(); $sgbd = $data->sgbd(); @@ -177,5 +177,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/xml/mw_data_xml_crud.php b/mw/app/data/modules/xml/mw_data_xml_crud.php index ed64dc6..dd29b58 100644 --- a/mw/app/data/modules/xml/mw_data_xml_crud.php +++ b/mw/app/data/modules/xml/mw_data_xml_crud.php @@ -6,7 +6,7 @@ # insert # - function data_insert($params = array()){ + public function data_insert($params = array()){ $table_name = isset($params["table_name"]) ? $params["table_name"] : ""; if(!$table_name) return false; $values = (isset($params["values"]) && is_array($params["values"])) ? $params["values"] : false; @@ -20,7 +20,7 @@ # read # - function data_read($params = array()){ + public function data_read($params = array()){ $sgbd = $this->sgbd(); $table_name = isset($params["table_name"]) ? $params["table_name"] : ""; $index_name = isset($params["index_name"]) ? $params["index_name"] : ""; @@ -49,7 +49,7 @@ # update # - function data_update($params = array()){ + public function data_update($params = array()){ $sgbd = $this->sgbd(); $table_name = isset($params["table_name"]) ? $params["table_name"] : false; $values = (isset($params["values"]) && is_array($params["values"])) ? $params["values"] : false; @@ -84,7 +84,7 @@ # delete # - function data_delete($params = array()){ + public function data_delete($params = array()){ $sgbd = $this->sgbd(); $table_name = isset($params["table_name"]) ? $params["table_name"] : false; $index_name = isset($params["index_name"]) ? $params["index_name"] : false; @@ -115,7 +115,7 @@ # list # - function data_list($params = array()){ + public function data_list($params = array()){ $sgbd = $this->sgbd(); $table_name = isset($params["table_name"]) ? $params["table_name"] : ""; if(!$table_name) return false; @@ -191,5 +191,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/xml/mw_data_xml_install.php b/mw/app/data/modules/xml/mw_data_xml_install.php index 61bfe96..216d2a9 100644 --- a/mw/app/data/modules/xml/mw_data_xml_install.php +++ b/mw/app/data/modules/xml/mw_data_xml_install.php @@ -2,7 +2,7 @@ class mw_data_xml_install extends mw_data{ - function install_xml($params){ + public function install_xml($params){ $env = $this->env(); $data = $env->data(); $sgbd = $data->sgbd(); @@ -274,5 +274,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/modules/xml/mw_data_xml_users.php b/mw/app/data/modules/xml/mw_data_xml_users.php index 96dc87d..12c0480 100644 --- a/mw/app/data/modules/xml/mw_data_xml_users.php +++ b/mw/app/data/modules/xml/mw_data_xml_users.php @@ -2,16 +2,16 @@ class mw_data_xml_users extends mw_data{ - var $users; - var $user; - var $roles; - var $actions_roles; + public $users; + public $user; + public $roles; + public $actions_roles; # ---------------------------------------------------------------------------------------- # users # - function users($start = 0, $alpha = null, $id_role = null){ + public function users($start = 0, $alpha = null, $id_role = null){ $sgbd = $this->sgbd(); $env = $this->env(); $users = array("list" => array(), "total" => 0); @@ -77,7 +77,7 @@ return $users; } - function list_user_roles($id_user){ + public function list_user_roles($id_user){ $sgbd = $this->sgbd(); $roles = array(); if($rst = $sgbd->open_data("users_roles")){ @@ -98,21 +98,21 @@ return $roles; } - function user_by_id($id){ + public function user_by_id($id){ $env = $this->env(); $user = $env->get_model("users"); if($user->load("id", $id) === false) return false; return $user->get_values(); } - function user($login){ + public function user($login){ $env = $this->env(); $user = $env->get_model("users"); if($user->load("login", $login) === false) return false; return $user->get_values(); } - function user_exists($login){ + public function user_exists($login){ $sgbd = $this->sgbd(); $EXISTS = 0; if($rst = $sgbd->open_data("users")){ @@ -133,7 +133,7 @@ return $EXISTS; } - function add_user($login, $password, $email, $roles){ + public function add_user($login, $password, $email, $roles){ $sgbd = $this->sgbd(); if( ( @@ -162,7 +162,7 @@ return $id_user; } - function set_user($id, $login, $password, $email, $roles){ + public function set_user($id, $login, $password, $email, $roles){ $sgbd = $this->sgbd(); if( !$sgbd->set_data( @@ -206,7 +206,7 @@ return true; } - function clear_user_roles($id_user){ + public function clear_user_roles($id_user){ $sgbd = $this->sgbd(); if($rst = $sgbd->open_data("users_roles")){ $OK = true; @@ -227,7 +227,7 @@ return $OK; } - function add_user_role($id_user, $id_role){ + public function add_user_role($id_user, $id_role){ $sgbd = $this->sgbd(); $OK = $sgbd->add_data( "users_roles", @@ -240,7 +240,7 @@ return true; } - function del_user($login){ + public function del_user($login){ if(($user = $this->user($login)) !== false){ $sgbd = $this->sgbd(); if(!$sgbd->del_data("users", $user["id"])) return false; @@ -268,7 +268,7 @@ # roles # - function init_roles(){ + public function init_roles(){ $sgbd = $this->sgbd(); $this->roles = array(); if($rst = $sgbd->open_data("roles")){ @@ -287,12 +287,12 @@ return $this->roles; } - function roles(){ + public function roles(){ if(!isset($this->roles)) return false; return $this->roles; } - function add_role($nom, $intitule){ + public function add_role($nom, $intitule){ $sgbd = $this->sgbd(); $id_role = $sgbd->add_data( "roles", @@ -305,7 +305,7 @@ return $id_role; } - function get_role($id){ + public function get_role($id){ if($id === "0") return array( "id" => 0, "nom" => "", @@ -317,7 +317,7 @@ return $role ? $role : array(); } - function set_role($id, $nom, $intitule){ + public function set_role($id, $nom, $intitule){ $sgbd = $this->sgbd(); if( !$sgbd->set_data( @@ -332,7 +332,7 @@ return true; } - function clear_role_actions($id_role){ + public function clear_role_actions($id_role){ $sgbd = $this->sgbd(); if($rst = $sgbd->open_data("actions_roles")){ $OK = true; @@ -353,7 +353,7 @@ return false; } - function clear_role_users($id_role){ + public function clear_role_users($id_role){ $sgbd = $this->sgbd(); if($rst = $sgbd->open_data("users_roles")){ $OK = true; @@ -374,7 +374,7 @@ return false; } - function add_role_action($id_role, $action){ + public function add_role_action($id_role, $action){ $sgbd = $this->sgbd(); $id_action_role = $sgbd->add_data( "actions_roles", @@ -392,7 +392,7 @@ return $sgbd->del_data("roles", $id_role) ? true : false; } - function get_user_roles(){ + public function get_user_roles(){ $user_roles = array(); $user = $this->get_session_user(); if($user && isset($user["id"])){ @@ -419,13 +419,13 @@ return $user_roles; } - function init_actions_roles(){ + public function init_actions_roles(){ if(!isset($this->roles)) return false; $this->actions_roles = $this->read_actions_roles(); return $this->actions_roles; } - function read_actions_roles($params = array()){ + public function read_actions_roles($params = array()){ if(!isset($this->roles)) return false; $group_by_action = isset($params["group_by_action"]) ? $params["group_by_action"] : false; $sgbd = $this->sgbd(); @@ -452,7 +452,7 @@ return $actions_roles; } - function get_action_roles($mod, $controller = "index", $action = "index"){ + public function get_action_roles($mod, $controller = "index", $action = "index"){ $sgbd = $this->sgbd(); $roles = array(); if($rst = $sgbd->open_data("actions_roles")){ @@ -475,7 +475,7 @@ return $roles; } - function get_actions($id_role = null){ + public function get_actions($id_role = null){ $env = $this->env(); if($actions = $env->get_actions()){ if(($actions_roles = $this->read_actions_roles(array("group_by_action" => true))) !== false){ @@ -534,5 +534,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/data/upgrades/sql/mtweb_sql_version_0_11_2.php b/mw/app/data/upgrades/sql/mtweb_sql_version_0_11_2.php index 6ca9c4c..2c3454f 100644 --- a/mw/app/data/upgrades/sql/mtweb_sql_version_0_11_2.php +++ b/mw/app/data/upgrades/sql/mtweb_sql_version_0_11_2.php @@ -2,11 +2,11 @@ class mtweb_sql_version_0_11_2 extends mw_data_version{ - function version(){ + public function version(){ return "0.11.2"; } - function do_upgrade(){ + public function do_upgrade(){ $env = $this->env(); $data = $env->data(); diff --git a/mw/app/data/upgrades/xml/mtweb_xml_version_0_11_2.php b/mw/app/data/upgrades/xml/mtweb_xml_version_0_11_2.php index 456e039..fb84365 100644 --- a/mw/app/data/upgrades/xml/mtweb_xml_version_0_11_2.php +++ b/mw/app/data/upgrades/xml/mtweb_xml_version_0_11_2.php @@ -2,11 +2,11 @@ class mtweb_xml_version_0_11_2 extends mw_data_version{ - function version(){ + public function version(){ return "0.11.2"; } - function do_upgrade(){ + public function do_upgrade(){ $env = $this->env(); $data = $env->data(); diff --git a/mw/app/helpers/mw_helper_out.php b/mw/app/helpers/mw_helper_out.php index c32e102..9b35c0c 100644 --- a/mw/app/helpers/mw_helper_out.php +++ b/mw/app/helpers/mw_helper_out.php @@ -2,7 +2,7 @@ class mw_helper_out extends mw_helper{ - function pagination_menu($current, $total, $max, $base_url, $start_param, $legende = null){ + public function pagination_menu($current, $total, $max, $base_url, $start_param, $legende = null){ $navig = ""; if($max && $total > $max){ if(isset($legende)){ @@ -53,11 +53,11 @@ return $navig; } - function esc_attr($content){ + public function esc_attr($content){ return htmlspecialchars($content, ENT_COMPAT, "UTF-8"); } - function get_menu_ul($menu, $indent = ""){ + public function get_menu_ul($menu, $indent = ""){ $html = ""; if($menu["subs"]){ $html .= $indent."
    \n"; @@ -73,5 +73,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/init/0100_functions.php b/mw/app/init/0100_functions.php index 81b6871..af3e428 100644 --- a/mw/app/init/0100_functions.php +++ b/mw/app/init/0100_functions.php @@ -8,5 +8,3 @@ : "
    ".htmlentities(print_r($content, true), ENT_QUOTES, "UTF-8")."
    "; } endif; - -?> \ No newline at end of file diff --git a/mw/app/init/0200_inputs.php b/mw/app/init/0200_inputs.php index 265d0f9..99a1c00 100644 --- a/mw/app/init/0200_inputs.php +++ b/mw/app/init/0200_inputs.php @@ -14,5 +14,3 @@ } unset($process); } - -?> \ No newline at end of file diff --git a/mw/app/init/0400_config.php b/mw/app/init/0400_config.php index 1566400..55d0e81 100644 --- a/mw/app/init/0400_config.php +++ b/mw/app/init/0400_config.php @@ -10,5 +10,3 @@ $this->set_config(array("start_action_params" => $start_action_params_config)); } else $this->erreur("Impossible de lire la configuration en base", true); - -?> \ No newline at end of file diff --git a/mw/app/init/0500_users.php b/mw/app/init/0500_users.php index 890c368..beb2971 100644 --- a/mw/app/init/0500_users.php +++ b/mw/app/init/0500_users.php @@ -10,5 +10,3 @@ else $this->erreur("Impossible de charger les statuts des utilisateurs", true); } else $this->erreur("Impossible de charger la session", true); - -?> \ No newline at end of file diff --git a/mw/app/init/0600_links.php b/mw/app/init/0600_links.php index 7421160..f5e3bf2 100644 --- a/mw/app/init/0600_links.php +++ b/mw/app/init/0600_links.php @@ -10,5 +10,3 @@ $this->set_link("config/plugins", $this->url("config/plugins"), "Plugins", 40); } else $this->erreur("impossible de charger les liens", true); - -?> \ No newline at end of file diff --git a/mw/app/init/0700_init_plugins.php b/mw/app/init/0700_init_plugins.php index a936fbe..02cdcff 100644 --- a/mw/app/init/0700_init_plugins.php +++ b/mw/app/init/0700_init_plugins.php @@ -9,5 +9,3 @@ } } else $this->erreur("erreur lors de l'initialisation des plugins", true); - -?> \ No newline at end of file diff --git a/mw/app/observers/mw_observer_login.php b/mw/app/observers/mw_observer_login.php index 250bf0b..eddcee1 100644 --- a/mw/app/observers/mw_observer_login.php +++ b/mw/app/observers/mw_observer_login.php @@ -2,7 +2,7 @@ class mw_observer_login extends mw_observer{ - function action_permission_denied(){ + public function action_permission_denied(){ $env = $this->env(); if(!$env->user()){ $env->erreur("Merci de vous identifier", "users/identification"); @@ -16,7 +16,7 @@ } } - function user_login($params){ + public function user_login($params){ $env = $this->env(); $redirect_action = "index"; $redirect_params = array(); @@ -35,5 +35,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/app/out/default/template.php b/mw/app/out/default/template.php index 8a48e08..2d03ab5 100644 --- a/mw/app/out/default/template.php +++ b/mw/app/out/default/template.php @@ -2,13 +2,13 @@ class mw_template_default extends mw_template{ - function get_template_infos(){ + public function get_template_infos(){ return array( "name" => "Default" ); } - function get_out_config(){ + public function get_out_config(){ $out_config = parent::get_out_config(); $out_config["navig_menu_top"] = array( "type" => "checkbox", @@ -28,7 +28,7 @@ return $out_config; } - function init(){ + public function init(){ $this->add_js_file($this->out_url("js/jquery-1.8.3.min.js")); if($this->is_running("users/identification")){ $this->add_js_file($this->out_url("js/md5.js")); @@ -37,5 +37,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/env/modules/mw_env_app_files.php b/mw/env/modules/mw_env_app_files.php index bb5816c..a3972db 100644 --- a/mw/env/modules/mw_env_app_files.php +++ b/mw/env/modules/mw_env_app_files.php @@ -2,17 +2,17 @@ class mw_env_app_files extends mw_env{ - function app_file_exists($file, $PRIORITE = "ASC"){ + public function app_file_exists($file, $PRIORITE = "ASC"){ $app_file = $this->_app_file($file, $PRIORITE); return $app_file ? true : false; } - function app_file($file, $PRIORITE = "ASC"){ + public function app_file($file, $PRIORITE = "ASC"){ $app_file = $this->_app_file($file, $PRIORITE); return $app_file ? $app_file : $file; } - function _app_file($file, $PRIORITE = "ASC"){ + public function _app_file($file, $PRIORITE = "ASC"){ $app_file = false; if($PRIORITE == "ASC" && file_exists($this->path("mw_dir")."app/".$file)) return $this->path("mw_dir")."app/".$file; if(($plugins = $this->plugins($PRIORITE)) !== false){ @@ -35,5 +35,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/env/modules/mw_env_cli.php b/mw/env/modules/mw_env_cli.php index 7ff6ca2..adac17d 100644 --- a/mw/env/modules/mw_env_cli.php +++ b/mw/env/modules/mw_env_cli.php @@ -2,14 +2,14 @@ class mw_env_cli extends mw_env{ - var $argv; - var $etat; - var $login; - var $password; - var $params; - var $INITED; + public $argv; + public $etat; + public $login; + public $password; + public $params; + public $INITED; - function run_cli($argv){ + public function run_cli($argv){ if(PHP_SAPI != "cli"){ $this->INITED = false; return "php cli uniquement"; @@ -34,11 +34,11 @@ return true; } - function inited(){ + public function inited(){ return isset($this->INITED) && $this->INITED; } - function parse_cli_arguments(){ + public function parse_cli_arguments(){ if(!$this->inited()) return "cli not inited"; $FIRST = false; $SECOND = false; @@ -87,7 +87,7 @@ return true; } - function init_cli_user(){ + public function init_cli_user(){ if(!$this->inited()) return "cli not inited"; $data = $this->data(); if($this->login){ @@ -115,7 +115,7 @@ return true; } - function cmd_prompt($prompt, $SILENT = false){ + public function cmd_prompt($prompt, $SILENT = false){ if(preg_match('/^win/i', PHP_OS)){ $vbscript = sys_get_temp_dir().'prompt_password.vbs'; file_put_contents( @@ -141,5 +141,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/env/modules/mw_env_config.php b/mw/env/modules/mw_env_config.php index fcb85f2..a9fa106 100644 --- a/mw/env/modules/mw_env_config.php +++ b/mw/env/modules/mw_env_config.php @@ -2,15 +2,15 @@ class mw_env_config extends mw_env{ - var $xml_parser; - var $config_file; - var $PATHES; - var $PARAMS; - var $CONFIG; - var $bdd; - var $actions; - - 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(); @@ -35,7 +35,7 @@ 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"])){ @@ -97,46 +97,46 @@ } } - 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; @@ -144,19 +144,19 @@ 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 bdd_ready(){ + public function bdd_ready(){ if(!$this->bdd("sgbd")) return "aucun sgbd defini"; $data = $this->data(); if(!$data) return "objet data non defini"; @@ -169,7 +169,7 @@ return true; } - function add_table_prefix($table_prefix){ + 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; @@ -177,10 +177,8 @@ return false; } - function get_actions(){ + public function get_actions(){ return isset($this->actions) ? $this->actions : array(); } } - -?> \ No newline at end of file diff --git a/mw/env/modules/mw_env_data.php b/mw/env/modules/mw_env_data.php index e6cb000..e5c3c4c 100644 --- a/mw/env/modules/mw_env_data.php +++ b/mw/env/modules/mw_env_data.php @@ -2,13 +2,13 @@ class mw_env_data extends mw_env{ - var $data; + public $data; - function set_data(&$data){ + public function set_data(&$data){ $this->data = &$data; } - function data(){ + public function data(){ return isset($this->data) ? $this->data : false; } @@ -16,7 +16,7 @@ class mw_data extends empty_class{ - function call_default($inst, $method_name, $arguments){ + public function call_default($inst, $method_name, $arguments){ return $this->call_data_auto_crud($method_name, $arguments); } @@ -24,27 +24,27 @@ class mw_sgbd{ - var $sgbd_impl; - var $env; + public $sgbd_impl; + public $env; - function mw_sgbd($sgbd_impl, $env){ + public function __construct($sgbd_impl, $env){ $this->sgbd_impl = $sgbd_impl; $this->env = $env; } - function extention_ok(){ + public function extention_ok(){ return $this->sgbd_impl->extention_ok($this->env); } - function authentication_required(){ + public function authentication_required(){ return $this->sgbd_impl->authentication_required(); } - function connect($host, $base, $user, $password){ + public function connect($host, $base, $user, $password){ return $this->sgbd_impl->connect($host, $base, $user, $password); } - function select_db($db_name){ + public function select_db($db_name){ return $this->sgbd_impl->select_db($db_name); } @@ -52,7 +52,7 @@ # SQL # - function desc_table($table_name){ + public function desc_table($table_name){ if(!method_exists($this->sgbd_impl, "desc_table")) return false; return $this->sgbd_impl->desc_table( ($prefix_codes = array_keys($this->env->bdd("table_prefix"))) ? @@ -61,7 +61,7 @@ ); } - function table_exists($table_name){ + public function table_exists($table_name){ if(!method_exists($this->sgbd_impl, "table_exists")) return false; return $this->sgbd_impl->table_exists( ($prefix_codes = array_keys($this->env->bdd("table_prefix"))) ? @@ -70,7 +70,7 @@ ); } - function field_exists($table_name, $field_name){ + public function field_exists($table_name, $field_name){ if(!method_exists($this->sgbd_impl, "field_exists")) return false; return $this->sgbd_impl->field_exists( ( @@ -81,7 +81,7 @@ ); } - function query($sql){ + public function query($sql){ if(!method_exists($this->sgbd_impl, "query")) return false; return $this->sgbd_impl->query( ($prefix_codes = array_keys($this->env->bdd("table_prefix"))) ? @@ -90,22 +90,22 @@ ); } - function insert_id(){ + public function insert_id(){ if(!method_exists($this->sgbd_impl, "insert_id")) return false; return $this->sgbd_impl->insert_id(); } - function fetch_assoc($rst){ + public function fetch_assoc($rst){ if(!method_exists($this->sgbd_impl, "fetch_assoc")) return false; return $this->sgbd_impl->fetch_assoc($rst); } - function free_result($rst){ + public function free_result($rst){ if(!method_exists($this->sgbd_impl, "")) return false; return $this->sgbd_impl->free_result($rst); } - function close(){ + public function close(){ if(!method_exists($this->sgbd_impl, "")) return false; return $this->sgbd_impl->close(); } @@ -114,61 +114,59 @@ # XML # - function data_exists($data_path){ + public function data_exists($data_path){ if(!method_exists($this->sgbd_impl, "data_exists")) return false; return $this->sgbd_impl->data_exists($data_path); } - function create_data($data_path){ + public function create_data($data_path){ if(!method_exists($this->sgbd_impl, "create_data")) return false; return $this->sgbd_impl->create_data($data_path); } - function get_data($data_path, $data_id){ + public function get_data($data_path, $data_id){ if(!method_exists($this->sgbd_impl, "get_data")) return false; return $this->sgbd_impl->get_data($data_path, $data_id); } - function open_data($data_path, $FETCH = true){ + public function open_data($data_path, $FETCH = true){ if(!method_exists($this->sgbd_impl, "open_data")) return false; return $this->sgbd_impl->open_data($data_path, $FETCH); } - function fetch_data($dh){ + public function fetch_data($dh){ if(!method_exists($this->sgbd_impl, "fetch_data")) return false; return $this->sgbd_impl->fetch_data($dh); } - function add_data($data_path, $data, $index = null){ + public function add_data($data_path, $data, $index = null){ if(!method_exists($this->sgbd_impl, "add_data")) return false; return $this->sgbd_impl->add_data($data_path, $data, $index); } - function last_index($dh){ + public function last_index($dh){ if(!method_exists($this->sgbd_impl, "last_index")) return false; return $this->sgbd_impl->last_index($dh); } - function set_data($data_path, $data_id, $data){ + public function set_data($data_path, $data_id, $data){ if(!method_exists($this->sgbd_impl, "set_data")) return false; return $this->sgbd_impl->set_data($data_path, $data_id, $data); } - function del_data($data_path, $data_id){ + public function del_data($data_path, $data_id){ if(!method_exists($this->sgbd_impl, "del_data")) return false; return $this->sgbd_impl->del_data($data_path, $data_id); } - function close_data($dh){ + public function close_data($dh){ if(!method_exists($this->sgbd_impl, "close_data")) return false; return $this->sgbd_impl->close_data($dh); } - function remove_data($data_path){ + public function remove_data($data_path){ if(!method_exists($this->sgbd_impl, "remove_data")) return false; return $this->sgbd_impl->remove_data($data_path); } } - -?> \ No newline at end of file diff --git a/mw/env/modules/mw_env_data_upgrade.php b/mw/env/modules/mw_env_data_upgrade.php index 1d65551..f326bfe 100644 --- a/mw/env/modules/mw_env_data_upgrade.php +++ b/mw/env/modules/mw_env_data_upgrade.php @@ -2,14 +2,14 @@ class mw_env_data_upgrade extends mw_env{ - var $data_upgrades; - var $UPGRADE_REQUIRED; + public $data_upgrades; + public $UPGRADE_REQUIRED; - function data_upgrades(){ + public function data_upgrades(){ return $this->data_upgrades; } - function init_data_upgrades(){ + public function init_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)){ @@ -45,7 +45,7 @@ return true; } - function data_upgrade_required($RELOAD = false){ + public function data_upgrade_required($RELOAD = false){ if(!isset($this->data_upgrades)){ if(($res = $this->init_data_upgrades()) !== true){ return $res; @@ -66,7 +66,7 @@ return $this->UPGRADE_REQUIRED; } - function do_data_upgrade(){ + public function do_data_upgrade(){ if(!isset($this->data_upgrades)) return false; foreach($this->data_upgrades as $data_upgrade){ if($data_upgrade->upgrade_required() && ($res = $data_upgrade->do_upgrade()) !== true){ @@ -78,22 +78,26 @@ } + // ------------------------------------------------------------------------------------------- + // class mw_data_upgrade + // + class mw_data_upgrade{ - var $application_name; - var $versions; - var $env; + public $application_name; + public $versions; + public $env; - function mw_data_upgrade($env, $application_name){ + public function __construct($env, $application_name){ $this->env = $env; $this->application_name = $application_name; } - function env(){ + public function env(){ return isset($this->env) ? $this->env : false; } - function load_versions($versions_dir){ + public function load_versions($versions_dir){ if($dh = opendir($versions_dir)){ $versions_dir .= $versions_dir && substr($versions_dir, -1) != "/" ? "/" : ""; while(($file = readdir($dh)) !== false){ @@ -109,7 +113,7 @@ return true; } - function load_version($versions_dir, $version_file){ + public function load_version($versions_dir, $version_file){ if( !$version_file || !file_exists($versions_dir.$version_file) @@ -124,7 +128,7 @@ return $this->add_version($version); } - function add_version($version){ + public function add_version($version){ if(!$version->version()) return false; if(!isset($this->versions)) $this->versions = array(); $tmp = array(); @@ -147,7 +151,7 @@ return true; } - function upgrade_required(){ + public function upgrade_required(){ if(!isset($this->versions)) return false; foreach($this->versions as $version){ if($version->upgrade_required()) return true; @@ -155,7 +159,7 @@ return false; } - function do_upgrade(){ + public function do_upgrade(){ if(!isset($this->versions)) return true; foreach($this->versions as $version){ if($version->upgrade_required() && ($res = $version->do_upgrade()) !== true){ @@ -170,29 +174,33 @@ } - class mw_data_version{ + // ------------------------------------------------------------------------------------------- + // class mw_data_version + // - var $env; - var $application_name; + abstract class mw_data_version{ - function version(){ - return false; + public $env; + public $application_name; + + public function __construct($env, $application_name){ + $this->env = $env; + $this->application_name = $application_name; } - function application_name(){ - return $this->application_name; + public function version(){ + return false; } - function mw_data_version($env, $application_name){ - $this->env = $env; - $this->application_name = $application_name; + public function application_name(){ + return $this->application_name; } - function env(){ + public function env(){ return isset($this->env) ? $this->env : false; } - function upgrade_required(){ + public function upgrade_required(){ if(!isset($this->application_name)) return false; if(!$this->version()) return false; $env = $this->env(); @@ -201,11 +209,11 @@ return version_compare($data_version, $this->version()) < 0; } - function do_upgrade(){ + public function do_upgrade(){ return true; } - function set_data_version(){ + public function set_data_version(){ if(!isset($this->application_name)) return false; if(!$this->version()) return false; $env = $this->env(); diff --git a/mw/env/modules/mw_env_helpers.php b/mw/env/modules/mw_env_helpers.php index 5b78601..0492f59 100644 --- a/mw/env/modules/mw_env_helpers.php +++ b/mw/env/modules/mw_env_helpers.php @@ -2,9 +2,9 @@ class mw_env_helpers extends mw_env{ - var $helpers; + public $helpers; - function init_helpers(){ + public function init_helpers(){ $this->helpers = false; $helpers_files = array(); if(($plugins = $this->plugins()) !== false){ @@ -56,7 +56,7 @@ return true; } - function helper($helper_name){ + public function helper($helper_name){ if(!isset($this->helpers)) $this->init_helpers(); if($this->helpers === false || !isset($this->helpers[$helper_name])) return false; if(!isset($this->helpers[$helper_name]["file"])) return false; @@ -64,7 +64,7 @@ return false; } - function init_helper($helper_name){ + public function init_helper($helper_name){ if(!isset($this->helpers[$helper_name]["impl"])){ if(!class_exists($helper_name)){ if( @@ -85,18 +85,20 @@ } - class mw_helper{ + // ------------------------------------------------------------------------------------------- + // class mw_helper + // - var $env; + abstract class mw_helper{ - function set_env(&$env){ + public $env; + + public function set_env(&$env){ $this->env = &$env; } - function env(){ + public function env(){ return $this->env; } } - -?> \ No newline at end of file diff --git a/mw/env/modules/mw_env_init.php b/mw/env/modules/mw_env_init.php index 0fd19b8..c2975df 100644 --- a/mw/env/modules/mw_env_init.php +++ b/mw/env/modules/mw_env_init.php @@ -2,7 +2,7 @@ class mw_env_init extends mw_env{ - function init(){ + public function init(){ $init_files = array(); if(($plugins = $this->plugins()) !== false){ foreach($plugins as $plugin_name => $plugin){ @@ -59,5 +59,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/env/modules/mw_env_links.php b/mw/env/modules/mw_env_links.php index b614df0..f92683c 100644 --- a/mw/env/modules/mw_env_links.php +++ b/mw/env/modules/mw_env_links.php @@ -2,21 +2,19 @@ class mw_env_links extends mw_env{ - function init_links(){ + public function init_links(){ $data = $this->data(); return $data->init_links(); } - function get_link($path = null){ + public function get_link($path = null){ $data = $this->data(); return $data->get_link($path); } - function set_link($path, $url, $intitule = "", $position = 0){ + public function set_link($path, $url, $intitule = "", $position = 0){ $data = $this->data(); return $data->set_link($path, $url, $intitule, $position); } } - -?> \ No newline at end of file diff --git a/mw/env/modules/mw_env_messages.php b/mw/env/modules/mw_env_messages.php index 26132a2..7f3ad9f 100644 --- a/mw/env/modules/mw_env_messages.php +++ b/mw/env/modules/mw_env_messages.php @@ -2,7 +2,7 @@ class mw_env_messages extends mw_env{ - function erreur($message, $EXIT = false){ + public function erreur($message, $EXIT = false){ if($EXIT === true){ echo "[erreur] ".$message; exit(); @@ -24,25 +24,23 @@ } } - function erreurs(){ + public function erreurs(){ $erreurs = $this->out("erreur"); if(isset($erreurs)) return $erreurs; return array(); } - function message($message){ + public function message($message){ $messages = $this->out("messages"); if(!isset($messages)) $messages = array(); $messages[] = $message; $this->set_out("messages", $messages); } - function messages(){ + public function messages(){ $messages = $this->out("messages"); if(isset($messages)) return $messages; return array(); } } - -?> \ No newline at end of file diff --git a/mw/env/modules/mw_env_models.php b/mw/env/modules/mw_env_models.php index 0576268..757b53b 100644 --- a/mw/env/modules/mw_env_models.php +++ b/mw/env/modules/mw_env_models.php @@ -2,7 +2,7 @@ class mw_env_models extends mw_env{ - function get_model($model_name, $default_values = array(), $RETURN_INSERT_ID = false){ + public function get_model($model_name, $default_values = array(), $RETURN_INSERT_ID = false){ $model_class_name = "mw_model_".$model_name; if(!class_exists($model_class_name)){ if($this->app_file_exists("data/models/".$model_name.".php")){ @@ -17,19 +17,33 @@ } + // ------------------------------------------------------------------------------------------- + // class mw_model + // + class mw_model{ - var $env; - var $model_name; - var $attributs; + public $env; + public $model_name; + public $attributs; + public $RETURN_INSERT_ID; - var $RETURN_INSERT_ID; + public function __construct(&$env, $model_name, $default_values = array(), $RETURN_INSERT_ID = false){ + $this->env = &$env; + $this->model_name = $model_name; + $this->attributs = array(); + $this->RETURN_INSERT_ID = $RETURN_INSERT_ID; + foreach($default_values as $attribut_name => $attribut_value){ + $set_function = "set_".$attribut_name; + $this->$set_function($attribut_value); + } + } - function env(){ + public function env(){ return $this->env; } - function get_values(){ + public function get_values(){ $values = array(); foreach($this->attributs as $attribut_name => $attribut){ $values[$attribut_name] = isset($attribut["value"]) ? $attribut["value"] : null; @@ -37,18 +51,7 @@ return $values; } - function mw_model(&$env, $model_name, $default_values = array(), $RETURN_INSERT_ID = false){ - $this->env = &$env; - $this->model_name = $model_name; - $this->attributs = array(); - $this->RETURN_INSERT_ID = $RETURN_INSERT_ID; - foreach($default_values as $attribut_name => $attribut_value){ - $set_function = "set_".$attribut_name; - $this->$set_function($attribut_value); - } - } - - function load($index_name, $index_value){ + public function load($index_name, $index_value){ if(!isset($this->model_name)) return false; $data = $this->env->data(); if( @@ -69,40 +72,7 @@ return true; } - function __call($method_name, $arguments){ - $r = false; - if(substr($method_name, 0, 4) == "get_"){ - if( - ($attribut_name = substr($method_name, 4)) - ){ - if(isset($this->attributs[$attribut_name]["value"])){ - $r = $this->attributs[$attribut_name]["value"]; - } - else $r = null; - } - } - elseif(substr($method_name, 0, 4) == "set_"){ - if( - ($attribut_name = substr($method_name, 4)) - && isset($arguments[0]) - ){ - if(!isset($this->attributs[$attribut_name])) $this->attributs[$attribut_name] = array(); - $this->attributs[$attribut_name]["value"] = $arguments[0]; - $r = true; - } - } - elseif(substr($method_name, 0, 6) == "valid_"){ - if( - ($attribut_name = substr($method_name, 6)) - && isset($arguments[0]) - ){ - $r = true; - } - } - return $r; - } - - function insert(){ + public function insert(){ if(!isset($this->model_name)) return false; $data = $this->env->data(); return $data->data_insert( @@ -114,7 +84,7 @@ ); } - function update($index_name, $index_value = null){ + public function update($index_name, $index_value = null){ if(!isset($this->model_name)) return false; $data = $this->env->data(); if(!isset($index_value)){ @@ -132,7 +102,7 @@ ); } - function delete($index_name, $index_value = null){ + public function delete($index_name, $index_value = null){ if(!isset($this->model_name)) return false; $data = $this->env->data(); if(!isset($index_value)){ @@ -149,7 +119,7 @@ ); } - function valid(){ + public function valid(){ $res = array( "VALID" => true, "messages" => array() @@ -165,6 +135,37 @@ return $res; } - } + public function __call($method_name, $arguments){ + $r = false; + if(substr($method_name, 0, 4) == "get_"){ + if( + ($attribut_name = substr($method_name, 4)) + ){ + if(isset($this->attributs[$attribut_name]["value"])){ + $r = $this->attributs[$attribut_name]["value"]; + } + else $r = null; + } + } + elseif(substr($method_name, 0, 4) == "set_"){ + if( + ($attribut_name = substr($method_name, 4)) + && isset($arguments[0]) + ){ + if(!isset($this->attributs[$attribut_name])) $this->attributs[$attribut_name] = array(); + $this->attributs[$attribut_name]["value"] = $arguments[0]; + $r = true; + } + } + elseif(substr($method_name, 0, 6) == "valid_"){ + if( + ($attribut_name = substr($method_name, 6)) + && isset($arguments[0]) + ){ + $r = true; + } + } + return $r; + } -?> \ No newline at end of file + } diff --git a/mw/env/modules/mw_env_observers.php b/mw/env/modules/mw_env_observers.php index 4184bc6..8492889 100644 --- a/mw/env/modules/mw_env_observers.php +++ b/mw/env/modules/mw_env_observers.php @@ -2,9 +2,9 @@ class mw_env_observers extends mw_env{ - var $observers; + public $observers; - function init_observers(){ + public function init_observers(){ $observers_files = array(); if(($plugins = $this->plugins()) !== false){ foreach($plugins as $plugin_name => $plugin){ @@ -61,7 +61,7 @@ return $observers; } - function call_observers($observer_call, $params = array()){ + public function call_observers($observer_call, $params = array()){ if(!isset($this->observers)){ $this->observers = $this->init_observers(); } @@ -77,18 +77,20 @@ } - class mw_observer{ + // ------------------------------------------------------------------------------------------- + // class mw_observer + // - var $env; + abstract class mw_observer{ - function set_env(&$env){ + public $env; + + public function set_env(&$env){ $this->env = &$env; } - function env(){ + public function env(){ return $this->env; } } - -?> \ No newline at end of file diff --git a/mw/env/modules/mw_env_out.php b/mw/env/modules/mw_env_out.php index 998f489..2042744 100644 --- a/mw/env/modules/mw_env_out.php +++ b/mw/env/modules/mw_env_out.php @@ -2,29 +2,27 @@ class mw_env_out extends mw_env{ - var $out; - var $out_config; - var $layout; - - var $js_files; - var $css_files; - - var $template; + public $out; + public $out_config; + public $layout; + public $js_files; + public $css_files; + public $template; // --------------------------------------------------------------------------------- // out vars // - function set_out($key, $value){ + public function set_out($key, $value){ $this->out[$key] = $value; return $value; } - function get_out(){ + public function get_out(){ return $this->out; } - function out($key){ + public function out($key){ return isset($this->out[$key]) ? $this->out[$key] : null; } @@ -32,7 +30,7 @@ // templates // - function templates(){ + public function templates(){ if(($out_pathes = $this->out_pathes()) === false) return false; $templates = array(); $current_out_path = $this->config("out"); @@ -44,13 +42,13 @@ return $templates; } - function get_template(){ + public function get_template(){ if(isset($this->template)) return $this->template; $this->template = $this->_get_template(); return $this->template; } - function _get_template(){ + public function _get_template(){ $template_class_name = "mw_template"; if($this->out_file_exists("template.php")){ $template_class_file = $this->out_file("template.php"); @@ -63,7 +61,7 @@ return $template; } - function out_pathes(){ + public function out_pathes(){ $pathes = array(); if(($plugins = $this->plugins()) !== false){ foreach($plugins as $plugin_name => $plugin){ @@ -85,7 +83,7 @@ return $pathes; } - function _out_pathes($out_dir, $pathes = array()){ + public function _out_pathes($out_dir, $pathes = array()){ if($dh = opendir($out_dir)){ while(($file = readdir($dh)) !== false){ if(is_dir($out_dir.$file) && substr($file, 0 ,1) != "." && !in_array($file, $pathes)) $pathes[] = $file; @@ -100,22 +98,22 @@ // out files // - function out_file_exists($file, $PRIORITE = "DESC"){ + public function out_file_exists($file, $PRIORITE = "DESC"){ $out_file = $this->_out_file($file, $PRIORITE); return $out_file ? true : false; } - function out_file($file, $PRIORITE = "DESC"){ + public function out_file($file, $PRIORITE = "DESC"){ $out_file = $this->_out_file($file, $PRIORITE); return $out_file ? $this->path("mw_dir").$out_file : $file; } - function out_url($file, $PRIORITE = "DESC"){ + public function out_url($file, $PRIORITE = "DESC"){ $out_file = $this->_out_file($file, $PRIORITE); return $out_file ? $this->path("web").$this->path("mw_path").$out_file : $file; } - function _out_file($file, $PRIORITE = "DESC"){ + public function _out_file($file, $PRIORITE = "DESC"){ $out_file = false; if($PRIORITE == "ASC"){ $tmp_out_file = "app/out/".$this->config("out")."/".$file; @@ -165,7 +163,7 @@ // js / css files // - function js_files(){ + public function js_files(){ if(!isset($this->js_files)) $this->js_files = array(); $files = array(); foreach($this->js_files as $url => $enabled){ @@ -174,18 +172,18 @@ return $files; } - function add_js_file($url){ + public function add_js_file($url){ if(!isset($this->js_files)) $this->js_files = array(); $this->js_files[$url] = true; } - function remove_js_file($url){ + public function remove_js_file($url){ if(isset($this->js_files) && isset($this->js_files[$url])){ unset($this->js_files[$url]); } } - function css_files(){ + public function css_files(){ if(!isset($this->css_files)) $this->css_files = array(); $files = array(); foreach($this->css_files as $url => $enabled){ @@ -194,12 +192,12 @@ return $files; } - function add_css_file($url){ + public function add_css_file($url){ if(!isset($this->css_files)) $this->css_files = array(); $this->css_files[$url] = true; } - function remove_css_file($url){ + public function remove_css_file($url){ if(isset($this->css_files) && isset($this->css_files[$url])){ unset($this->css_files[$url]); } @@ -209,16 +207,16 @@ // out config // - function set_out_config($out_config){ + public function set_out_config($out_config){ $this->out_config = $out_config; return $this->out_config; } - function get_out_config(){ + public function get_out_config(){ return isset($this->out_config) ? $this->out_config : array(); } - function out_config($name){ + public function out_config($name){ if(isset($this->out_config)){ $CONFIG = $this->get_CONFIG(); return isset($CONFIG["out_".$name]) ? $CONFIG["out_".$name] : (isset($this->out_config[$name]) ? $this->out_config[$name]["default"] : ""); @@ -230,18 +228,18 @@ // layouts // - function layout(){ + public function layout(){ return $this->layout; } - function init_layout(){ + public function init_layout(){ $this->layout = array(); $this->_init_layout("index"); if(($mod = $this->etat("mod")) != "index") $this->_init_layout($mod); return $this->get_layout(); } - function _init_layout($mod){ + public function _init_layout($mod){ if(($plugins = $this->plugins("ASC")) !== false){ $layout_file = false; $tmp_layout_file = $this->path("mw_dir")."app/out/".$this->config("out")."/layouts/".$mod.".xml"; @@ -266,7 +264,7 @@ } } - function load_layout($layout_file){ + public function load_layout($layout_file){ if(file_exists($layout_file)){ $xml_parser = new sxml(); $xml_parser->parse(file_get_contents($layout_file)); @@ -313,7 +311,7 @@ return false; } - function get_layout(){ + public function get_layout(){ $mod = $this->etat("mod"); $controller = $this->etat("controller"); $action = $this->etat("action"); @@ -363,20 +361,24 @@ } + // ------------------------------------------------------------------------------------------- + // class mw_template + // + class mw_template extends empty_class{ - var $out; - var $ENV_SET; - var $template_infos; + public $out; + public $ENV_SET; + public $template_infos; - function set_env(&$env){ + public function set_env(&$env){ $this->modules = array("env" => $env); $this->ENV_SET = true; $this->set_out_config($this->get_out_config()); $this->set_template_infos($this->get_template_infos()); } - function render_layout($layout = null){ + public function render_layout($layout = null){ if(!isset($this->ENV_SET) || !$this->ENV_SET) return false; if(!isset($layout)) $layout = $this->init_layout(); $this->out = $this->get_out(); @@ -394,19 +396,19 @@ } } - function get_template_info($key){ + public function get_template_info($key){ return isset($this->template_infos[$key]) ? $this->template_infos[$key] : ""; } - function init(){ + public function init(){ return true; } - function init_script(){ + public function init_script(){ return false; } - function get_out_config(){ + public function get_out_config(){ $out_config = array(); if($this->ENV_SET){ $env = $this->modules["env"]; @@ -415,14 +417,12 @@ return $out_config; } - function set_template_infos($template_infos){ + public function set_template_infos($template_infos){ $this->template_infos = $template_infos; } - function get_template_infos(){ + public function get_template_infos(){ return array(); } } - -?> \ No newline at end of file diff --git a/mw/env/modules/mw_env_plugins.php b/mw/env/modules/mw_env_plugins.php index b9fe042..286060f 100644 --- a/mw/env/modules/mw_env_plugins.php +++ b/mw/env/modules/mw_env_plugins.php @@ -2,10 +2,10 @@ class mw_env_plugins extends mw_env{ - var $plugins_asc; - var $plugins_desc; + public $plugins_asc; + public $plugins_desc; - function plugins($PRIORITE = "ASC"){ + public function plugins($PRIORITE = "ASC"){ $this->init_plugins($PRIORITE); if($PRIORITE == "ASC") return $this->plugins_asc; if($PRIORITE == "DESC") return $this->plugins_desc; @@ -16,7 +16,7 @@ # init # - function init_plugins($PRIORITE = "ASC", $RELOAD = false){ + 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); @@ -87,7 +87,7 @@ } } - function ordonne_plugins($plugins, $PRIORITE = "ASC"){ + public function ordonne_plugins($plugins, $PRIORITE = "ASC"){ $values = array_values($plugins); $maximum = count($values); while($maximum > 0){ @@ -110,11 +110,11 @@ return $res; } - function plugin_call($impl, $method){ + public function plugin_call($impl, $method){ if(method_exists($impl, $method)) return $impl->$method($this); } - function loaded_plugins(){ + public function loaded_plugins(){ if($plugins = $this->plugins()){ foreach($plugins as $plugin_name => $plugin){ $plugin["impl"]->loaded($this); @@ -126,7 +126,7 @@ # impl # - function plugin_impl($plugin_name){ + public function plugin_impl($plugin_name){ $plugin = false; if(file_exists($this->path("mw_dir")."plugins")){ if(substr($plugin_name, 0 ,1) !== "." && is_dir($this->path("mw_dir")."plugins/".$plugin_name)){ @@ -147,15 +147,15 @@ # data # - function plugins_data_dir(){ + public function plugins_data_dir(){ return $this->path("content")."data/plugins/"; } - function plugin_data_file($plugin_name){ + public function plugin_data_file($plugin_name){ return $this->plugins_data_dir().$plugin_name; } - function plugin_data($plugin_name){ + public function plugin_data($plugin_name){ $data_file = $this->plugin_data_file($plugin_name); $data = array(); if(file_exists($data_file)){ @@ -166,7 +166,7 @@ return $data; } - function set_plugin_data($plugin_name, $data){ + public function set_plugin_data($plugin_name, $data){ if(!is_dir($this->plugins_data_dir())) @mkdir($this->plugins_data_dir()); if(!is_dir($this->plugins_data_dir())) return false; $data_file = $this->plugin_data_file($plugin_name); @@ -181,7 +181,7 @@ return $OK; } - function del_plugin_data($plugin_name){ + public function del_plugin_data($plugin_name){ $data_file = $this->plugin_data_file($plugin_name); if(file_exists($data_file)) return @unlink($data_file); return true; @@ -189,39 +189,41 @@ } - class mw_plugin{ + // ------------------------------------------------------------------------------------------- + // class mw_plugin + // - function title(){ + abstract class mw_plugin{ + + public function title(){ return "(sans titre)"; } - function description(){ + public function description(){ return ""; } - function loaded($env){ + public function loaded($env){ } - function install($env){ + public function install($env){ return true; } - function uninstall($env){ + public function uninstall($env){ return true; } - function enable($env){ + public function enable($env){ return true; } - function disable($env){ + public function disable($env){ return true; } - function init($env){ + public function init($env){ return true; } } - -?> \ No newline at end of file diff --git a/mw/env/modules/mw_env_run.php b/mw/env/modules/mw_env_run.php index 10a4022..a2b9b78 100644 --- a/mw/env/modules/mw_env_run.php +++ b/mw/env/modules/mw_env_run.php @@ -2,15 +2,15 @@ class mw_env_run extends mw_env{ - var $etat; - var $controllers; + public $etat; + public $controllers; - function user(){ + public function user(){ if(!($data = $this->data())) return array(); return $data->get_session_user(); } - function set_etat($etat, $valid_role = true){ + public function set_etat($etat, $valid_role = true){ if(($this->etat = $this->valid_etat($etat)) !== false){ if(!$valid_role || $this->action_allowed($this->etat, false)){ return $this->etat; @@ -25,7 +25,7 @@ return false; } - function valid_etat($etat){ + public function valid_etat($etat){ $_etat = array( "mod" => "", "controller" => "", @@ -77,11 +77,11 @@ return false; } - function etat_is_valid(){ + public function etat_is_valid(){ return $this->valid_etat($this->etat); } - function action_allowed($etat, $CHECK_FORMAT = true){ + public function action_allowed($etat, $CHECK_FORMAT = true){ if(!$this->bdd("sgbd")) return false; $data = $this->data(); if($CHECK_FORMAT) $etat = $this->valid_etat($etat); @@ -134,7 +134,7 @@ return $OK; } - function run($etat, $params = array(), $valid_role = true){ + public function run($etat, $params = array(), $valid_role = true){ if($this->set_etat($etat, $valid_role)){ if($controller = $this->get_controller($this->etat("mod")."/".$this->etat("controller"))){ $action_method = $this->etat("action"); @@ -171,7 +171,7 @@ } } - function is_running($etat){ + public function is_running($etat){ $_etat = array(); if(is_array($etat)){ if(isset($etat["mod"])){ @@ -204,12 +204,12 @@ return $IS_RUNNING; } - function etat($name = null){ + public function etat($name = null){ if(!isset($name)) return $this->etat; return $this->etat[$name]; } - function get_controller($controller_path){ + public function get_controller($controller_path){ if($etat = $this->valid_etat($controller_path)){ if(!isset($this->controllers)) $this->controllers = array(); if(!isset($this->controllers[$etat["mod"]])) $this->controllers[$etat["mod"]] = array(); @@ -232,26 +232,28 @@ } - class mw_controller{ + // ------------------------------------------------------------------------------------------- + // class mw_controller + // - var $env; + abstract class mw_controller{ - function set_env(&$env){ + public $env; + + public function set_env(&$env){ $this->env = &$env; } - function env(){ + public function env(){ return $this->env; } - function validate(){ + public function validate(){ return true; } - function prepare_inputs(){ + public function prepare_inputs(){ return true; } } - -?> \ No newline at end of file diff --git a/mw/env/modules/mw_env_urls.php b/mw/env/modules/mw_env_urls.php index 9a6b014..b76a270 100644 --- a/mw/env/modules/mw_env_urls.php +++ b/mw/env/modules/mw_env_urls.php @@ -2,9 +2,9 @@ class mw_env_urls extends mw_env{ - var $additional_get_params; + public $additional_get_params; - function init_additional_get_params(){ + public function init_additional_get_params(){ $this->additional_get_params = array(); $_params = $_SERVER["QUERY_STRING"]; $v_params = explode("&", $_params); @@ -17,12 +17,12 @@ } } - function is_a_param($key){ + public function is_a_param($key){ foreach($this->get_PARAMS() as $_key => $_value) if(strcmp($key, $_value) == 0) return true; return false; } - function url($action = "", $_params = array(), $script_name = null){ + public function url($action = "", $_params = array(), $script_name = null){ $script_name = isset($script_name) ? $script_name : ($this->config("script_name") ? $this->config("script_name") : "index.php"); if($action) $_params["e"] = $action; $get_params = ""; @@ -31,7 +31,7 @@ return $this->path("web").$script_name.$get_params; } - function redirect($url, $message, $wait = 1){ + public function redirect($url, $message, $wait = 1){ $this->set_etat("reponses/html/redirect_javascript", false); $this->set_out( "redirect", @@ -50,5 +50,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/env/modules/mw_env_versions.php b/mw/env/modules/mw_env_versions.php index 7c6c09c..af334bc 100644 --- a/mw/env/modules/mw_env_versions.php +++ b/mw/env/modules/mw_env_versions.php @@ -2,14 +2,14 @@ class mw_env_versions extends mw_env{ - var $xml_parser; - var $versions; + public $xml_parser; + public $versions; - function version($application){ + public function version($application){ return isset($this->versions[$application]) ? $this->versions[$application] : false; } - function load_versions(){ + public function load_versions(){ $this->xml_parser = new sxml(); $app_config_file = $this->path("mw_dir")."app/config.xml"; if(file_exists($app_config_file)){ @@ -23,7 +23,7 @@ else $this->erreur("impossible de lire les fichiers de configuration pour les plugins", true); } - function _load_version($app_name, $app_config_file){ + public function _load_version($app_name, $app_config_file){ $this->xml_parser->parse(file_get_contents($app_config_file)); $app_config = $this->xml_parser->data["config"][0]; if(isset($app_config["subs"]["version"][0]["data"])){ @@ -31,7 +31,7 @@ } } - function load_plugin_version($plugin_name){ + public function load_plugin_version($plugin_name){ $app_config_file = $this->path("mw_dir")."plugins/".$plugin_name."/app/config.xml"; if(file_exists($app_config_file)){ $this->_load_version($plugin_name, $app_config_file); @@ -39,5 +39,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/env/mw_env.php b/mw/env/mw_env.php index 1addce4..4f06001 100644 --- a/mw/env/mw_env.php +++ b/mw/env/mw_env.php @@ -2,5 +2,3 @@ class mw_env extends empty_class{ } - -?> \ No newline at end of file diff --git a/mw/libs/empty_class.php b/mw/libs/empty_class.php index 38e14cc..d526460 100644 --- a/mw/libs/empty_class.php +++ b/mw/libs/empty_class.php @@ -121,5 +121,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/libs/ptitcaptcha.php b/mw/libs/ptitcaptcha.php index 34e8d0e..0b5534a 100644 --- a/mw/libs/ptitcaptcha.php +++ b/mw/libs/ptitcaptcha.php @@ -28,7 +28,7 @@ class PtitCaptchaHelper * @param string $baseuri : relative or absolute path to folder containing this file on web * @return IMG Tag */ - static function generateImgTags($baseuri) + public static function generateImgTags($baseuri) { return ""; } @@ -53,7 +53,7 @@ class PtitCaptchaHelper * * @return input tag */ - static function generateInputTags() + public static function generateInputTags() { return ""; } @@ -63,7 +63,7 @@ class PtitCaptchaHelper * * @return boolean (true=correct, false=incorrect) */ - static function checkCaptcha() + public static function checkCaptcha() { if( isset($_POST['ptitcaptcha_entry']) && $_POST['ptitcaptcha_entry'] == PtitCaptchaHelper::_getDisplayText($_POST['ptitcaptcha_key'])) @@ -79,7 +79,7 @@ class PtitCaptchaHelper * @param string $pck * @return string */ - static function _getDisplayText($pck) // internal function + public static function _getDisplayText($pck) // internal function { $src=md5(PTITCAPTCHA_ENTROPY.$pck); $txt=""; @@ -88,8 +88,8 @@ class PtitCaptchaHelper return $txt; } } - - + + // If script called directly : generate image if(basename($_SERVER["SCRIPT_NAME"])=="ptitcaptcha.php" && isset($_GET["pck"])) { @@ -123,5 +123,3 @@ if(basename($_SERVER["SCRIPT_NAME"])=="ptitcaptcha.php" && isset($_GET["pck"])) imagepng($image); imagedestroy($image); } - -?> \ No newline at end of file diff --git a/mw/libs/sxml.php b/mw/libs/sxml.php index 837b674..0ed1f4a 100644 --- a/mw/libs/sxml.php +++ b/mw/libs/sxml.php @@ -67,5 +67,3 @@ } } - -?> \ No newline at end of file diff --git a/mw/mw_app.php b/mw/mw_app.php index 38d094d..ba88f24 100644 --- a/mw/mw_app.php +++ b/mw/mw_app.php @@ -2,16 +2,16 @@ class mw_app{ - var $env; - var $path_file; - var $pathes; - var $config_file; - var $config; - var $bdd; - var $error; - var $DO_INSTALL; - - function mw_app($path_file, $DO_INSTALL = false){ + public $env; + public $path_file; + public $pathes; + public $config_file; + public $config; + public $bdd; + public $error; + public $DO_INSTALL; + + public function __construct($path_file, $DO_INSTALL = false){ $this->DO_INSTALL = $DO_INSTALL; $this->path_file = $path_file; $this->pathes = array(); @@ -21,20 +21,20 @@ $this->error = false; } - function set_env(&$env){ + public function set_env(&$env){ $this->env =& $env; } - function env(){ + public function env(){ return $this->env; } - function param($name){ + public function param($name){ if(!isset($this->env)) return false; return $this->env->param($name); } - function init(){ + public function init(){ if(!$this->init_pathes()) return $this->get_error(); if(!$this->init_config()) return $this->get_error(); if(!$this->init_env()) return $this->get_error(); @@ -59,7 +59,7 @@ return true; } - function init_pathes(){ + public function init_pathes(){ $REQUEST_URI = $_SERVER["REQUEST_URI"]; if(($n = strpos($REQUEST_URI, "?")) !== false){ $REQUEST_URI = substr($REQUEST_URI, 0, $n); @@ -112,7 +112,7 @@ return true; } - function init_config(){ + public function init_config(){ if(file_exists($config_file = $this->pathes["content"]."config/config.php")){ $this->config_file = $config_file; require_once $this->config_file; @@ -142,7 +142,7 @@ return true; } - function init_env(){ + public function init_env(){ if( !($sxml_class_file = (file_exists($this->pathes["mw_dir"]."libs/sxml.php") ? $this->pathes["mw_dir"]."libs/sxml.php" : "")) || !($empty_class_file = (file_exists($this->pathes["mw_dir"]."libs/empty_class.php") ? $this->pathes["mw_dir"]."libs/empty_class.php" : "")) @@ -179,14 +179,14 @@ return true; } - function run($etat = "", $params = array(), $valid_role = true){ + public function run($etat = "", $params = array(), $valid_role = true){ $env = $this->env(); if(!is_callable(array($env, "run"))) return false; $env->run($etat); return true; } - function run_mod($mod_name, $valid_role = true){ + public function run_mod($mod_name, $valid_role = true){ $env = $this->env(); $etat = false; if(isset($_GET[$env->param("e")])){ @@ -203,13 +203,13 @@ return true; } - function install(){ + public function install(){ if($this->run_mod("install", false)){ $this->display(); } } - function upgrade(){ + public function upgrade(){ $env = $this->env(); $data = $env->data(); $data->load_session(); @@ -218,7 +218,7 @@ } } - function display(){ + public function display(){ $env = $this->env(); if($env->etat_is_valid()){ $template = $env->get_template(); @@ -227,11 +227,11 @@ } } - function error($content){ + public function error($content){ $this->error = $content; } - function get_error(){ + public function get_error(){ return isset($this->error) && $this->error ? $this->error : false; }