projects
/
mw_pages
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2efbfd3
)
syntaxe POO (visibilite)
dev
master
mw_pages.0.13
author
dj3c1t
<dj3c1t@free.fr>
Sun, 15 Jun 2014 17:38:01 +0000
(19:38 +0200)
committer
dj3c1t
<dj3c1t@free.fr>
Sun, 15 Jun 2014 17:38:01 +0000
(19:38 +0200)
app/controllers/pages/admin.php
patch
|
blob
|
history
app/controllers/pages/index.php
patch
|
blob
|
history
app/controllers/pages/view.php
patch
|
blob
|
history
app/data/modules/sql/mw_data_pages.php
patch
|
blob
|
history
app/data/modules/xml/mw_data_pages.php
patch
|
blob
|
history
app/helpers/mw_helper_pages.php
patch
|
blob
|
history
app/observers/mw_observer_pages.php
patch
|
blob
|
history
mw_pages.php
patch
|
blob
|
history
diff --git
a/app/controllers/pages/admin.php
b/app/controllers/pages/admin.php
index
321d9cd
..
7ae7279
100644
(file)
--- a/
app/controllers/pages/admin.php
+++ b/
app/controllers/pages/admin.php
@@
-2,7
+2,8
@@
class mw_pages_admin extends mw_controller{
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);
$data = $env->data();
if(($arbo = $data->pages_arbo()) !== false){
$env->set_out("arbo", $arbo);
@@
-34,7
+35,8
@@
else $env->erreur("impossible de lire l'arborescence des pages");
}
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"]){
$page = isset($page) ? $page : array();
$_page = array();
if(($user = $env->user()) && $user["id"]){
@@
-51,7
+53,8
@@
return $_page;
}
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){
$data = $env->data();
$_SESSION["upload_dir"] = $env->path("web").($env->path("web") ? "" : "/").$env->path("content")."uploads";
if(($arbo = $data->pages_arbo()) !== false){
@@
-61,7
+64,7
@@
"content" => ""
);
if($_POST){
"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(
if(!$env->messages()){
if(($id_page = $data->add_page($page)) !== false){
$env->redirect(
@@
-77,14
+80,15
@@
else $env->erreur("impossible de lire l'arborescence des pages");
}
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){
$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(
if(!$env->messages()){
if($data->set_page($_GET[$env->param("id")], $page)){
$env->redirect(
@@
-102,7
+106,8
@@
else $env->erreur("impossible de lire les informations de la page");
}
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();
if(($user = $env->user()) && $user["id"]){
if($_POST){
$data = $env->data();
@@
-131,7
+136,8
@@
else $env->erreur("impossible de lire les informations de l'utilisateur");
}
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 = "";
if(($user = $env->user()) && $user["id"]){
$data = $env->data();
$start_action = "";
@@
-164,7
+170,8
@@
else $env->erreur("impossible de lire les informations de l'utilisateur");
}
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"])){
$data = $env->data();
if($page = $data->page($_GET[$env->param("id")])){
if($data->del_page($page["id"])){
@@
-179,5
+186,3
@@
}
}
}
}
-
-?>
\ No newline at end of file
diff --git
a/app/controllers/pages/index.php
b/app/controllers/pages/index.php
index
3a6b3d5
..
41bd38e
100644
(file)
--- a/
app/controllers/pages/index.php
+++ b/
app/controllers/pages/index.php
@@
-2,10
+2,9
@@
class mw_pages_index extends mw_controller{
class mw_pages_index extends mw_controller{
- function index(&$env){
+ public function index(){
+ $env = $this->env();
$env->run("pages/view");
}
}
$env->run("pages/view");
}
}
-
-?>
\ No newline at end of file
diff --git
a/app/controllers/pages/view.php
b/app/controllers/pages/view.php
index
bbd74f5
..
0ba4581
100644
(file)
--- a/
app/controllers/pages/view.php
+++ b/
app/controllers/pages/view.php
@@
-2,10
+2,11
@@
class mw_pages_view extends mw_controller{
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);
$data = $env->data();
if(($arbo = $data->pages_arbo(array("enabled" => 1, "order_by" => "position", "order" => "ASC"))) !== false){
$env->set_out("arbo", $arbo);
@@
-37,5
+38,3
@@
}
}
}
}
-
-?>
\ No newline at end of file
diff --git
a/app/data/modules/sql/mw_data_pages.php
b/app/data/modules/sql/mw_data_pages.php
index
c7648d7
..
e1702d7
100644
(file)
--- a/
app/data/modules/sql/mw_data_pages.php
+++ b/
app/data/modules/sql/mw_data_pages.php
@@
-2,7
+2,7
@@
class mw_data_pages extends mw_data{
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;
if($page = $this->page($id)){
if($page["id_parent"]) $ariane = $this->page_ariane($page["id_parent"], $ariane);
$ariane[] = $page;
@@
-11,7
+11,7
@@
return false;
}
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;
$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;
@@
-49,7
+49,7
@@
return $pages;
}
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;
$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;
@@
-85,7
+85,7
@@
return $arbo;
}
return $arbo;
}
- function page($id){
+
public
function page($id){
$page = array();
$sgbd = $this->sgbd();
$sql = "SELECT * FROM #--pages WHERE id=".$this->eq($id);
$page = array();
$sgbd = $this->sgbd();
$sql = "SELECT * FROM #--pages WHERE id=".$this->eq($id);
@@
-98,7
+98,7
@@
return $page;
}
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;
$id_parent = isset($params["id_parent"]) ? $params["id_parent"] : null;
$title = isset($params["title"]) ? $params["title"] : null;
$content = isset($params["content"]) ? $params["content"] : null;
@@
-128,7
+128,7
@@
return $id_page;
}
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"]);
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"]);
@@
-156,7
+156,7
@@
return false;
}
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));
$sgbd = $this->sgbd();
try{
$sgbd->query("UPDATE #--pages SET id_parent=NULL WHERE id_parent=".$this->eq($id));
@@
-167,5
+167,3
@@
}
}
}
}
-
-?>
\ No newline at end of file
diff --git
a/app/data/modules/xml/mw_data_pages.php
b/app/data/modules/xml/mw_data_pages.php
index
bde8ba1
..
ec94e31
100644
(file)
--- a/
app/data/modules/xml/mw_data_pages.php
+++ b/
app/data/modules/xml/mw_data_pages.php
@@
-2,7
+2,7
@@
class mw_data_pages extends mw_data{
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;
if($page = $this->page($id)){
if(isset($page["id_parent"]) && $page["id_parent"]) $ariane = $this->page_ariane($page["id_parent"], $ariane);
$ariane[] = $page;
@@
-11,7
+11,7
@@
return false;
}
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;
$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;
@@
-63,7
+63,7
@@
return $pages;
}
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;
$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;
@@
-85,12
+85,12
@@
return $arbo;
}
return $arbo;
}
- function page($id){
+
public
function page($id){
$sgbd = $this->sgbd();
return ($page = $sgbd->get_data("pages", $id)) ? $page : false;
}
$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;
$id_parent = isset($params["id_parent"]) ? $params["id_parent"] : null;
$title = isset($params["title"]) ? $params["title"] : null;
$content = isset($params["content"]) ? $params["content"] : null;
@@
-118,7
+118,7
@@
);
}
);
}
- 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"]);
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"]);
@@
-146,7
+146,7
@@
return false;
}
return false;
}
- function del_page($id){
+
public
function del_page($id){
$sgbd = $this->sgbd();
if($sgbd->del_data("pages", $id)){
$OK = true;
$sgbd = $this->sgbd();
if($sgbd->del_data("pages", $id)){
$OK = true;
@@
-171,5
+171,3
@@
}
}
}
}
-
-?>
\ No newline at end of file
diff --git
a/app/helpers/mw_helper_pages.php
b/app/helpers/mw_helper_pages.php
index
f6db62c
..
e4ee747
100644
(file)
--- a/
app/helpers/mw_helper_pages.php
+++ b/
app/helpers/mw_helper_pages.php
@@
-2,7
+2,7
@@
class mw_helper_pages extends mw_helper{
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);
list($date, $time) = explode(" ", $string);
list($year, $month, $day) = explode("-", $date);
list($hour, $minute, $second) = explode(":", $time);
@@
-10,7
+10,7
@@
return $timestamp;
}
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)){
$content = "";
if($arbo["subs"]){
if($path_item = array_shift($ariane)){
@@
-35,7
+35,7
@@
return $content;
}
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"
$arbo["id"] = $arbo["id"] ? $arbo["id"] : "";
$content =
"<option"
@@
-55,7
+55,7
@@
return $content;
}
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"
$arbo["id"] = isset($arbo["id"]) ? $arbo["id"] : "";
$content =
"<option"
@@
-73,7
+73,7
@@
return $content;
}
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"]){
$arbo["id"] = isset($arbo["id"]) ? $arbo["id"] : "";
$content = "";
if($arbo["id"]){
@@
-103,5
+103,3
@@
}
}
}
}
-
-?>
\ No newline at end of file
diff --git
a/app/observers/mw_observer_pages.php
b/app/observers/mw_observer_pages.php
index
8dd40c4
..
9c247f8
100644
(file)
--- a/
app/observers/mw_observer_pages.php
+++ b/
app/observers/mw_observer_pages.php
@@
-2,7
+2,7
@@
class mw_observer_pages extends mw_observer{
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");
$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");
@@
-11,5
+11,3
@@
}
}
}
}
-
-?>
\ No newline at end of file
diff --git
a/mw_pages.php
b/mw_pages.php
index
c33eb05
..
7d99241
100644
(file)
--- a/
mw_pages.php
+++ b/
mw_pages.php
@@
-2,15
+2,15
@@
class mw_pages extends mw_plugin{
class mw_pages extends mw_plugin{
- function title(){
+
public
function title(){
return "Pages";
}
return "Pages";
}
- function description(){
+
public
function description(){
return "Pour ajouter des pages, avec un éditeur dans l'administration du site";
}
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();
$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();
@@
-30,7
+30,7
@@
return true;
}
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(
if($arbo["subs"]){
foreach($arbo["subs"] as $page){
$env->set_link(
@@
-44,7
+44,7
@@
}
}
}
}
- 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();
$plugins_pages_start_id = $env->config("plugins_pages_start_id");
if($plugins_pages_start_id){
$data = $env->data();
@@
-59,7
+59,7
@@
return true;
}
return true;
}
- function disable($env){
+
public
function disable($env){
$start_action = $env->config("start_action");
if($start_action == "pages/view/page"){
$data = $env->data();
$start_action = $env->config("start_action");
if($start_action == "pages/view/page"){
$data = $env->data();
@@
-78,7
+78,7
@@
// install
//
// install
//
- function install($env){
+
public
function install($env){
if(
$env->bdd("sgbd") == "mysql"
|| $env->bdd("sgbd") == "pdo_mysql"
if(
$env->bdd("sgbd") == "mysql"
|| $env->bdd("sgbd") == "pdo_mysql"
@@
-101,7
+101,7
@@
return true;
}
return true;
}
- function install_mysql($env){
+
public
function install_mysql($env){
$data = $env->data();
$sgbd = $data->sgbd();
try{
$data = $env->data();
$sgbd = $data->sgbd();
try{
@@
-145,7
+145,7
@@
return true;
}
return true;
}
- function install_sqlite($env){
+
public
function install_sqlite($env){
$data = $env->data();
$sgbd = $data->sgbd();
try{
$data = $env->data();
$sgbd = $data->sgbd();
try{
@@
-189,7
+189,7
@@
return true;
}
return true;
}
- function install_xml($env){
+
public
function install_xml($env){
$data = $env->data();
$sgbd = $data->sgbd();
$EXISTS = $sgbd->data_exists("pages");
$data = $env->data();
$sgbd = $data->sgbd();
$EXISTS = $sgbd->data_exists("pages");
@@
-213,12
+213,12
@@
// uninstall
//
// uninstall
//
- function uninstall($env){
+
public
function uninstall($env){
if($env->bdd("sgbd") == "xml") return $this->uninstall_xml($env);
else return $this->uninstall_sql($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";
$data = $env->data();
$sgbd = $data->sgbd();
if(!$this->disable($env)) return "impossible de desactiver le plugin";
@@
-253,7
+253,7
@@
return true;
}
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";
$data = $env->data();
$sgbd = $data->sgbd();
if(!$this->disable($env)) return "impossible de desactiver le plugin";
@@
-287,5
+287,3
@@
}
}
}
}
-
-?>
\ No newline at end of file