class mw_pages_admin extends mw_controller{
- function index(&$env){
+ public function index(){
+ $env = $this->env();
$data = $env->data();
if(($arbo = $data->pages_arbo()) !== false){
$env->set_out("arbo", $arbo);
else $env->erreur("impossible de lire l'arborescence des pages");
}
- function validate_POST_page(&$env, $page = null){
+ protected function validate_POST_page($page = null){
+ $env = $this->env();
$page = isset($page) ? $page : array();
$_page = array();
if(($user = $env->user()) && $user["id"]){
return $_page;
}
- function add(&$env){
+ public function add(){
+ $env = $this->env();
$data = $env->data();
$_SESSION["upload_dir"] = $env->path("web").($env->path("web") ? "" : "/").$env->path("content")."uploads";
if(($arbo = $data->pages_arbo()) !== false){
"content" => ""
);
if($_POST){
- $page = $this->validate_POST_page($env);
+ $page = $this->validate_POST_page();
if(!$env->messages()){
if(($id_page = $data->add_page($page)) !== false){
$env->redirect(
else $env->erreur("impossible de lire l'arborescence des pages");
}
- function edit(&$env){
+ public function edit(){
+ $env = $this->env();
$data = $env->data();
$_SESSION["upload_dir"] = $env->path("web").($env->path("web") ? "" : "/").$env->path("content")."uploads";
if($page = $data->page($_GET[$env->param("id")])){
if(($arbo = $data->pages_arbo()) !== false){
$env->set_out("arbo", $arbo);
if($_POST){
- $page = $this->validate_POST_page($env, $page);
+ $page = $this->validate_POST_page($page);
if(!$env->messages()){
if($data->set_page($_GET[$env->param("id")], $page)){
$env->redirect(
else $env->erreur("impossible de lire les informations de la page");
}
- function edit_pages(&$env){
+ public function edit_pages(){
+ $env = $this->env();
if(($user = $env->user()) && $user["id"]){
if($_POST){
$data = $env->data();
else $env->erreur("impossible de lire les informations de l'utilisateur");
}
- function set_accueil(&$env){
+ public function set_accueil(){
+ $env = $this->env();
if(($user = $env->user()) && $user["id"]){
$data = $env->data();
$start_action = "";
else $env->erreur("impossible de lire les informations de l'utilisateur");
}
- function del(&$env){
+ public function del(){
+ $env = $this->env();
$data = $env->data();
if($page = $data->page($_GET[$env->param("id")])){
if($data->del_page($page["id"])){
}
}
-
-?>
\ No newline at end of file
class mw_pages_index extends mw_controller{
- function index(&$env){
+ public function index(){
+ $env = $this->env();
$env->run("pages/view");
}
}
-
-?>
\ No newline at end of file
class mw_pages_view extends mw_controller{
- function index(&$env){
+ public function index(){
}
- function page(&$env){
+ public function page(){
+ $env = $this->env();
$data = $env->data();
if(($arbo = $data->pages_arbo(array("enabled" => 1, "order_by" => "position", "order" => "ASC"))) !== false){
$env->set_out("arbo", $arbo);
}
}
-
-?>
\ No newline at end of file
class mw_data_pages extends mw_data{
- function page_ariane($id, $ariane = array()){
+ public function page_ariane($id, $ariane = array()){
if($page = $this->page($id)){
if($page["id_parent"]) $ariane = $this->page_ariane($page["id_parent"], $ariane);
$ariane[] = $page;
return false;
}
- function pages($params = array()){
+ public function pages($params = array()){
$id_parent = isset($params["id_parent"]) ? $params["id_parent"] : null;
$enabled = isset($params["enabled"]) ? ($params["enabled"] ? "1" : "0") : null;
$user = isset($params["user"]) ? $params["user"] : null;
return $pages;
}
- function pages_arbo($params = array()){
+ public function pages_arbo($params = array()){
$id_parent = isset($params["id_parent"]) ? $params["id_parent"] : null;
$enabled = isset($params["enabled"]) ? ($params["enabled"] ? "1" : "0") : null;
$user = isset($params["user"]) ? $params["user"] : null;
return $arbo;
}
- function page($id){
+ public function page($id){
$page = array();
$sgbd = $this->sgbd();
$sql = "SELECT * FROM #--pages WHERE id=".$this->eq($id);
return $page;
}
- function add_page($params){
+ public function add_page($params){
$id_parent = isset($params["id_parent"]) ? $params["id_parent"] : null;
$title = isset($params["title"]) ? $params["title"] : null;
$content = isset($params["content"]) ? $params["content"] : null;
return $id_page;
}
- function set_page($id, $params, $RAZ = false){
+ public function set_page($id, $params, $RAZ = false){
if($page = $this->page($id)){
$id_parent = isset($params["id_parent"]) ? $params["id_parent"] : ($RAZ ? null : $page["id_parent"]);
$title = isset($params["title"]) ? $params["title"] : ($RAZ ? null : $page["title"]);
return false;
}
- function del_page($id){
+ public function del_page($id){
$sgbd = $this->sgbd();
try{
$sgbd->query("UPDATE #--pages SET id_parent=NULL WHERE id_parent=".$this->eq($id));
}
}
-
-?>
\ No newline at end of file
class mw_data_pages extends mw_data{
- function page_ariane($id, $ariane = array()){
+ public function page_ariane($id, $ariane = array()){
if($page = $this->page($id)){
if(isset($page["id_parent"]) && $page["id_parent"]) $ariane = $this->page_ariane($page["id_parent"], $ariane);
$ariane[] = $page;
return false;
}
- function pages($params = array()){
+ public function pages($params = array()){
$id_parent = isset($params["id_parent"]) ? $params["id_parent"] : null;
$enabled = isset($params["enabled"]) ? ($params["enabled"] ? "1" : "0") : null;
$user = isset($params["user"]) ? $params["user"] : null;
return $pages;
}
- function pages_arbo($params = array()){
+ public function pages_arbo($params = array()){
$params["id_parent"] = isset($params["id_parent"]) ? $params["id_parent"] : "";
$params["enabled"] = isset($params["enabled"]) ? ($params["enabled"] ? "1" : "0") : null;
$params["user"] = isset($params["user"]) ? $params["user"] : null;
return $arbo;
}
- function page($id){
+ public function page($id){
$sgbd = $this->sgbd();
return ($page = $sgbd->get_data("pages", $id)) ? $page : false;
}
- function add_page($params){
+ public function add_page($params){
$id_parent = isset($params["id_parent"]) ? $params["id_parent"] : null;
$title = isset($params["title"]) ? $params["title"] : null;
$content = isset($params["content"]) ? $params["content"] : null;
);
}
- function set_page($id, $params, $RAZ = false){
+ public function set_page($id, $params, $RAZ = false){
if($page = $this->page($id)){
$id_parent = isset($params["id_parent"]) ? $params["id_parent"] : ($RAZ ? null : (isset($page["id_parent"]) ? $page["id_parent"] : null));
$title = isset($params["title"]) ? $params["title"] : ($RAZ ? null : $page["title"]);
return false;
}
- function del_page($id){
+ public function del_page($id){
$sgbd = $this->sgbd();
if($sgbd->del_data("pages", $id)){
$OK = true;
}
}
-
-?>
\ No newline at end of file
class mw_helper_pages extends mw_helper{
- function datetime2timestamp($string){
+ public function datetime2timestamp($string){
list($date, $time) = explode(" ", $string);
list($year, $month, $day) = explode("-", $date);
list($hour, $minute, $second) = explode(":", $time);
return $timestamp;
}
- function pages_arbo_navig_lis($env, $arbo, $ariane = array()){
+ public function pages_arbo_navig_lis($env, $arbo, $ariane = array()){
$content = "";
if($arbo["subs"]){
if($path_item = array_shift($ariane)){
return $content;
}
- function pages_arbo_edit_select_options($arbo, $id_page, $id_parent, $indent_increment = "", $indent = ""){
+ public function pages_arbo_edit_select_options($arbo, $id_page, $id_parent, $indent_increment = "", $indent = ""){
$arbo["id"] = $arbo["id"] ? $arbo["id"] : "";
$content =
"<option"
return $content;
}
- function pages_arbo_list_select_options($env, $etat, $arbo, $current_page_id, $indent_increment = "", $indent = ""){
+ public function pages_arbo_list_select_options($env, $etat, $arbo, $current_page_id, $indent_increment = "", $indent = ""){
$arbo["id"] = isset($arbo["id"]) ? $arbo["id"] : "";
$content =
"<option"
return $content;
}
- function pages_arbo_start_select_options($env, $arbo, $current_start_action, $current_start_action_params, $indent_increment = "", $indent = ""){
+ public function pages_arbo_start_select_options($env, $arbo, $current_start_action, $current_start_action_params, $indent_increment = "", $indent = ""){
$arbo["id"] = isset($arbo["id"]) ? $arbo["id"] : "";
$content = "";
if($arbo["id"]){
}
}
-
-?>
\ No newline at end of file
class mw_observer_pages extends mw_observer{
- function after_action(){
+ public function after_action(){
$env = $this->env();
if($env->is_running("pages/admin")){
$env->add_js_file($env->path("web").$env->path("mw_path")."libs/tiny_mce/tiny_mce.js");
}
}
-
-?>
\ No newline at end of file
class mw_pages extends mw_plugin{
- function title(){
+ public function title(){
return "Pages";
}
- function description(){
+ public function description(){
return "Pour ajouter des pages, avec un éditeur dans l'administration du site";
}
- function init($env){
+ public function init($env){
$env->set_link("plugins/admin/mw_pages", $env->url("pages/admin"), "éditer les pages");
$env->set_link("admin/pages", $env->url("pages/admin"), "Pages", 40);
$data = $env->data();
return true;
}
- function _set_links($env, $parent, $arbo){
+ public function _set_links($env, $parent, $arbo){
if($arbo["subs"]){
foreach($arbo["subs"] as $page){
$env->set_link(
}
}
- function enable($env){
+ public function enable($env){
$plugins_pages_start_id = $env->config("plugins_pages_start_id");
if($plugins_pages_start_id){
$data = $env->data();
return true;
}
- function disable($env){
+ public function disable($env){
$start_action = $env->config("start_action");
if($start_action == "pages/view/page"){
$data = $env->data();
// install
//
- function install($env){
+ public function install($env){
if(
$env->bdd("sgbd") == "mysql"
|| $env->bdd("sgbd") == "pdo_mysql"
return true;
}
- function install_mysql($env){
+ public function install_mysql($env){
$data = $env->data();
$sgbd = $data->sgbd();
try{
return true;
}
- function install_sqlite($env){
+ public function install_sqlite($env){
$data = $env->data();
$sgbd = $data->sgbd();
try{
return true;
}
- function install_xml($env){
+ public function install_xml($env){
$data = $env->data();
$sgbd = $data->sgbd();
$EXISTS = $sgbd->data_exists("pages");
// uninstall
//
- function uninstall($env){
+ public function uninstall($env){
if($env->bdd("sgbd") == "xml") return $this->uninstall_xml($env);
else return $this->uninstall_sql($env);
}
- function uninstall_xml($env){
+ public function uninstall_xml($env){
$data = $env->data();
$sgbd = $data->sgbd();
if(!$this->disable($env)) return "impossible de desactiver le plugin";
return true;
}
- function uninstall_sql($env){
+ public function uninstall_sql($env){
$data = $env->data();
$sgbd = $data->sgbd();
if(!$this->disable($env)) return "impossible de desactiver le plugin";
}
}
-
-?>
\ No newline at end of file