--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<config>
+
+ <params>
+ <parent>parent</parent>
+ </params>
+
+</config>
\ No newline at end of file
<?php
- class mw_data_pages extends mw_data
- {
+ class mw_data_pages extends mw_data{
- function page_ariane($id, $ariane = array())
- { if($page = $this->page($id))
- { if($page["id_parent"]) $ariane = $this->page_ariane($page["id_parent"], $ariane);
+ 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 $ariane;
}
return false;
}
- function pages($params = array())
- { $id_parent = isset($params["id_parent"]) ? $params["id_parent"] : null;
+ 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;
$order_by = isset($params["order_by"]) ? $params["order_by"] : null;
$WHERE .= (isset($id_parent) ? ($WHERE ? " AND" : " WHERE")." id_parent".(strlen($id_parent) > 0 ? "=".$this->eq($id_parent) : " IS NULL") : "");
$WHERE .= (isset($enabled) ? ($WHERE ? " AND" : " WHERE")." enabled=".$this->eq($enabled) : "");
$WHERE .= (isset($user) ? ($WHERE ? " AND" : " WHERE")." user_creation=".$this->eq($user) : "");
- $ORDER_BY =
- ( isset($order_by) ?
+ $ORDER_BY = (
+ isset($order_by) ?
" ORDER BY ".$order_by.(isset($order) ? " ".$order : "")
: ""
);
if(!isset($rst)) return false;
if($v_rst = $sgbd->fetch_assoc($rst)) $pages["total"] = $v_rst["n"];
$sgbd->free_result($rst);
- if($pages["total"])
- { $sql = $SELECT.$WHERE.$ORDER_BY.$LIMIT;
+ if($pages["total"]){
+ $sql = $SELECT.$WHERE.$ORDER_BY.$LIMIT;
$rst = $sgbd->query($sql);
if(!isset($rst)) return false;
while($v_rst = $sgbd->fetch_assoc($rst)) $pages["list"][$v_rst["id"]] = $v_rst;
return $pages;
}
- function pages_arbo($params = array())
- { $id_parent = isset($params["id_parent"]) ? $params["id_parent"] : null;
+ 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;
$order_by = isset($params["order_by"]) ? $params["order_by"] : null;
$order = isset($params["order"]) ? $params["order"] : "ASC";
$sgbd = $this->sgbd();
$arbo = array();
- if(isset($id_parent))
- { if($parent = $this->page($id_parent)) $arbo = $parent;
+ if(isset($id_parent)){
+ if($parent = $this->page($id_parent)) $arbo = $parent;
else return false;
}
$arbo["subs"] = array();
$WHERE .= ($WHERE ? " AND" : " WHERE")." id_parent".(isset($id_parent) && $id_parent ? "=".$this->eq($id_parent) : " IS NULL");
$WHERE .= (isset($enabled) ? ($WHERE ? " AND" : " WHERE")." enabled=".$this->eq($enabled) : "");
$WHERE .= (isset($user) ? ($WHERE ? " AND" : " WHERE")." user_creation=".$this->eq($user) : "");
- $ORDER_BY =
- ( isset($order_by) ?
+ $ORDER_BY = (
+ isset($order_by) ?
" ORDER BY ".$order_by.(isset($order) ? " ".$order : "")
: ""
);
$sql = $SELECT.$WHERE.$ORDER_BY;
$rst = $sgbd->query($sql);
if(!isset($rst)) return false;
- while($v_rst = $sgbd->fetch_assoc($rst))
- { $params["id_parent"] = $v_rst["id"];
+ while($v_rst = $sgbd->fetch_assoc($rst)){
+ $params["id_parent"] = $v_rst["id"];
$arbo["subs"][] = $this->pages_arbo($params);
}
$sgbd->free_result($rst);
return $arbo;
}
- function page($id)
- { $page = array();
+ function page($id){
+ $page = array();
$sgbd = $this->sgbd();
$sql = "SELECT * FROM #--pages WHERE id=".$this->eq($id);
$rst = $sgbd->query($sql);
return $page;
}
- function add_page($params)
- { $id_parent = isset($params["id_parent"]) ? $params["id_parent"] : null;
+ 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;
$user = isset($params["user"]) ? $params["user"] : null;
return false;
}
- 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"]);
+ 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"]);
$content = isset($params["content"]) ? $params["content"] : ($RAZ ? null : $page["content"]);
$user = isset($params["user"]) ? $params["user"] : null;
return false;
}
- function del_page($id)
- { $sgbd = $this->sgbd();
- if($sgbd->query("DELETE FROM #--pages WHERE id=".$this->eq($id)))
- { return $sgbd->query("UPDATE #--pages SET id_parent=NULL WHERE id_parent=".$this->eq($id)) ? true : false;
+ function del_page($id){
+ $sgbd = $this->sgbd();
+ if($sgbd->query("DELETE FROM #--pages WHERE id=".$this->eq($id))){
+ return $sgbd->query("UPDATE #--pages SET id_parent=NULL WHERE id_parent=".$this->eq($id)) ? true : false;
}
return false;
}
<?php
- class mw_data_pages extends mw_data
- {
+ class mw_data_pages extends mw_data{
- function page_ariane($id, $ariane = array())
- { if($page = $this->page($id))
- { if($page["id_parent"]) $ariane = $this->page_ariane($page["id_parent"], $ariane);
+ 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 $ariane;
}
return false;
}
- function pages($params = array())
- { $id_parent = isset($params["id_parent"]) ? $params["id_parent"] : null;
+ 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;
$order_by = isset($params["order_by"]) ? $params["order_by"] : null;
$sgbd = $this->sgbd();
$pages = array("list" => array(), "total" => 0);
$res = array();
- if($rst = $sgbd->open_data("pages"))
- { while($v_rst = $sgbd->fetch_data($rst))
- { if(isset($v_rst)) $res[$v_rst["id"]] = $v_rst;
- else
- { $res = false;
+ if($rst = $sgbd->open_data("pages")){
+ while($v_rst = $sgbd->fetch_data($rst)){
+ if(isset($v_rst)) $res[$v_rst["id"]] = $v_rst;
+ else{
+ $res = false;
break;
}
}
$sgbd->close_data($rst);
- if($res !== false)
- { if(isset($order_by)) $res = $this->ordonne($res, "position", isset($order) ? $order : "ASC");
- foreach($res as $id_res => $v_rst)
- { $MATCH = true;
- if(isset($id_parent))
- { $MATCH =
- ( ($id_parent && isset($v_rst["id_parent"]) && ($id_parent == $v_rst["id_parent"]))
+ if($res !== false){
+ if(isset($order_by)) $res = $this->ordonne($res, "position", isset($order) ? $order : "ASC");
+ foreach($res as $id_res => $v_rst){
+ $MATCH = true;
+ if(isset($id_parent)){
+ $MATCH = (
+ ($id_parent && isset($v_rst["id_parent"]) && ($id_parent == $v_rst["id_parent"]))
|| ($id_parent == "" && !$v_rst["id_parent"])
);
}
- if($MATCH)
- { if(isset($enabled))
- { $MATCH = ($v_rst["enabled"] == $enabled);
+ if($MATCH){
+ if(isset($enabled)){
+ $MATCH = ($v_rst["enabled"] == $enabled);
}
}
- if($MATCH)
- { if(isset($user))
- { $MATCH = ($v_rst["user_creation"] == $user);
+ if($MATCH){
+ if(isset($user)){
+ $MATCH = ($v_rst["user_creation"] == $user);
}
}
- if($MATCH)
- { $pages["total"]++;
+ if($MATCH){
+ $pages["total"]++;
$MATCH = !isset($start) || !$max || ($pages["total"] > $start && $pages["total"] <= ($start + $max));
}
if($MATCH) $pages["list"][$v_rst["id"]] = $v_rst;
return $pages;
}
- function pages_arbo($params = array())
- { $params["id_parent"] = isset($params["id_parent"]) ? $params["id_parent"] : "";
+ 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["order_by"] = isset($params["order_by"]) ? $params["order_by"] : null;
$params["order"] = isset($params["order"]) ? $params["order"] : "ASC";
$sgbd = $this->sgbd();
$arbo = array();
- if($params["id_parent"])
- { if($parent = $this->page($params["id_parent"])) $arbo = $parent;
+ if($params["id_parent"]){
+ if($parent = $this->page($params["id_parent"])) $arbo = $parent;
else return false;
}
$arbo["subs"] = array();
- if(($subs = $this->pages($params)) !== false)
- { foreach($subs["list"] as $id_sub => $sub)
- { $params["id_parent"] = $sub["id"];
+ if(($subs = $this->pages($params)) !== false){
+ foreach($subs["list"] as $id_sub => $sub){
+ $params["id_parent"] = $sub["id"];
$arbo["subs"][] = $this->pages_arbo($params);
}
}
return $arbo;
}
- function page($id)
- { $sgbd = $this->sgbd();
+ function page($id){
+ $sgbd = $this->sgbd();
return ($page = $sgbd->get_data("pages", $id)) ? $page : false;
}
- function add_page($params)
- { $id_parent = isset($params["id_parent"]) ? $params["id_parent"] : null;
+ 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;
$user = isset($params["user"]) ? $params["user"] : null;
$enabled = isset($params["enabled"]) ? ($params["enabled"] ? 1 : 0) : 1;
$position = isset($params["position"]) ? $params["position"] : 0;
$sgbd = $this->sgbd();
- return
- ( ( $id_page = $sgbd->add_data
- ( "pages",
+ return (
+ (
+ $id_page = $sgbd->add_data(
+ "pages",
array
( "id_parent" => $id_parent,
"title" => $title,
);
}
- 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"]);
+ 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"]);
$content = isset($params["content"]) ? $params["content"] : ($RAZ ? null : $page["content"]);
$user = isset($params["user"]) ? $params["user"] : null;
$enabled = isset($params["enabled"]) ? ($params["enabled"] ? 1 : 0) : ($RAZ ? 1 : $page["enabled"]);
$position = isset($params["position"]) ? $params["position"] : ($RAZ ? 0 : $page["position"]);
$sgbd = $this->sgbd();
- return $sgbd->set_data
- ( "pages",
+ return $sgbd->set_data(
+ "pages",
$id,
- array
- ( "id_parent" => $id_parent,
+ array(
+ "id_parent" => $id_parent,
"title" => $title,
"content" => $content,
"date_creation" => $page["date_creation"],
return false;
}
- function del_page($id)
- { $sgbd = $this->sgbd();
- if($sgbd->del_data("pages", $id))
- { $OK = true;
- if($rst = $sgbd->open_data("pages"))
- { while($v_rst = $sgbd->fetch_data($rst))
- { if(isset($v_rst))
- { if(isset($v_rst["id_parent"]) && isset($v_rst["id"]) && $v_rst["id_parent"] == $id)
- { unset($v_rst["id_parent"]);
- if(!$sgbd->set_data("pages", $v_rst["id"], $v_rst))
- { $OK = false;
+ function del_page($id){
+ $sgbd = $this->sgbd();
+ if($sgbd->del_data("pages", $id)){
+ $OK = true;
+ if($rst = $sgbd->open_data("pages")){
+ while($v_rst = $sgbd->fetch_data($rst)){
+ if(isset($v_rst)){
+ if(isset($v_rst["id_parent"]) && isset($v_rst["id"]) && $v_rst["id_parent"] == $id){
+ unset($v_rst["id_parent"]);
+ if(!$sgbd->set_data("pages", $v_rst["id"], $v_rst)){
+ $OK = false;
break;
}
}
<?php
- class mw_pages_admin extends mw_mod
- {
+ class mw_pages_admin extends mw_mod{
- function index(&$env)
- { $data = $env->data();
- if(($arbo = $data->pages_arbo()) !== false)
- { $env->set_out("arbo", $arbo);
+ function index(&$env){
+ $data = $env->data();
+ if(($arbo = $data->pages_arbo()) !== false){
+ $env->set_out("arbo", $arbo);
$id_parent = isset($_GET[$env->param("parent")]) ? $_GET[$env->param("parent")] : null;
- if
- ( ( $pages = $data->pages
- ( array
- ( "id_parent" => $id_parent,
+ if(
+ (
+ $pages = $data->pages(
+ array(
+ "id_parent" => $id_parent,
"order_by" => "position",
"order" => "ASC",
"start" => isset($_GET[$env->param("start")]) && $_GET[$env->param("start")] ? $_GET[$env->param("start")] : 0,
)
)
) !== false
- )
- { $env->set_out("pages", $pages);
+ ){
+ $env->set_out("pages", $pages);
$ariane = array();
- if($id_parent)
- { if(($ariane = $data->page_ariane($id_parent)) === false)
- { $env->erreur("impossible de lire le fil d'ariane");
+ if($id_parent){
+ if(($ariane = $data->page_ariane($id_parent)) === false){
+ $env->erreur("impossible de lire le fil d'ariane");
}
}
$env->set_out("ariane", $ariane);
else $env->erreur("impossible de lire l'arborescence des pages");
}
- function validate_POST_page(&$env, $page = null)
- { $page = isset($page) ? $page : array();
+ function validate_POST_page(&$env, $page = null){
+ $page = isset($page) ? $page : array();
$_page = array();
- if(($user = $env->user()) && $user["id"])
- { if($_POST)
- { $_page["id_parent"] = isset($_POST["id_parent"]) ? ($_POST["id_parent"] ? $_POST["id_parent"] : null) : ($page["id_parent"] ? $page["id_parent"] : null);
+ if(($user = $env->user()) && $user["id"]){
+ if($_POST){
+ $_page["id_parent"] = isset($_POST["id_parent"]) ? ($_POST["id_parent"] ? $_POST["id_parent"] : null) : ($page["id_parent"] ? $page["id_parent"] : null);
$_page["title"] = isset($_POST["title"]) ? $_POST["title"] : ($page["title"] ? $page["title"] : null);
$_page["content"] = isset($_POST["content"]) ? $_POST["content"] : ($page["content"] ? $page["content"] : null);
$_page["user"] = $user["id"];
return $_page;
}
- function add(&$env)
- { $data = $env->data();
- if(($arbo = $data->pages_arbo()) !== false)
- { $env->set_out("arbo", $arbo);
+ function add(&$env){
+ $data = $env->data();
+ if(($arbo = $data->pages_arbo()) !== false){
+ $env->set_out("arbo", $arbo);
$page = array();
- if($_POST)
- { $page = $this->validate_POST_page($env);
- if(!$env->messages())
- { if(($id_page = $data->add_page($page)) !== false)
- { $env->redirect
- ( $env->url("pages/admin"),
+ if($_POST){
+ $page = $this->validate_POST_page($env);
+ if(!$env->messages()){
+ if(($id_page = $data->add_page($page)) !== false){
+ $env->redirect(
+ $env->url("pages/admin/edit", array("id" => $id_page)),
"la page a été ajoutée"
);
}
else $env->erreur("impossible de lire l'arborescence des pages");
}
- function edit(&$env)
- { $data = $env->data();
- 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);
- if(!$env->messages())
- { if($data->set_page($_GET[$env->param("id")], $page))
- { $env->redirect
- ( $env->url("pages/admin"),
+ function edit(&$env){
+ $data = $env->data();
+ 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);
+ if(!$env->messages()){
+ if($data->set_page($_GET[$env->param("id")], $page)){
+ $env->redirect(
+ $env->url("pages/admin/edit", array("id" => $_GET[$env->param("id")])),
"la page a été modifiée"
);
}
else $env->erreur("impossible de lire les informations de la page");
}
- function edit_pages(&$env)
- { if(($user = $env->user()) && $user["id"])
- { if($_POST)
- { $data = $env->data();
+ function edit_pages(&$env){
+ if(($user = $env->user()) && $user["id"]){
+ if($_POST){
+ $data = $env->data();
$OK = true;
- foreach($_POST as $key => $value)
- { $OK = true;
- if(substr($key, 0, 9) == "position_")
- { $id_page = substr($key, 9);
+ foreach($_POST as $key => $value){
+ $OK = true;
+ if(substr($key, 0, 9) == "position_"){
+ $id_page = substr($key, 9);
$enabled = isset($_POST["enabled_".$id_page]) && $_POST["enabled_".$id_page] ? 1 : 0;
- if(!$data->set_page($id_page, array("position" => $value, "enabled" => $enabled)))
- { $env->erreur("impossible d'enregistrer la position");
+ if(!$data->set_page($id_page, array("position" => $value, "enabled" => $enabled))){
+ $env->erreur("impossible d'enregistrer la position");
$OK = false;
$break;
}
}
}
- if($OK)
- { $env->redirect
- ( $env->url("pages/admin"),
+ if($OK){
+ $env->redirect(
+ $env->url("pages/admin"),
"Les informations des pages ont été enregistrées"
);
}
else $env->erreur("impossible de lire les informations de l'utilisateur");
}
- function set_accueil(&$env)
- { if(($user = $env->user()) && $user["id"])
- { $data = $env->data();
+ function set_accueil(&$env){
+ if(($user = $env->user()) && $user["id"]){
+ $data = $env->data();
$start_action = "";
$start_action_params = "";
$id_page = $_POST["id"] ? $_POST["id"] : "";
- if($id_page)
- { if($page = $data->page($id_page))
- { $start_action = "pages/view/page";
+ if($id_page){
+ if($page = $data->page($id_page)){
+ $start_action = "pages/view/page";
$start_action_params = @serialize(array("id" => $id_page));
}
- else
- { $start_action = false;
+ else{
+ $start_action = false;
$env->erreur("impossible de lire les informations de la page");
}
}
- if($start_action !== false && $start_action_params !== false)
- { if
- ( $data->set_config("start_action", $start_action)
+ if($start_action !== false && $start_action_params !== false){
+ if(
+ $data->set_config("start_action", $start_action)
&& $data->set_config("start_action_params", $start_action_params)
- )
- { $data->set_config("plugins_pages_start_id", $id_page);
- $env->redirect
- ( $env->url("pages/admin"),
+ ){
+ $data->set_config("plugins_pages_start_id", $id_page);
+ $env->redirect(
+ $env->url("pages/admin"),
"La page d'accueil a été enregistrée"
);
}
else $env->erreur("impossible de lire les informations de l'utilisateur");
}
- function del(&$env)
- { $data = $env->data();
- if($page = $data->page($_GET[$env->param("id")]))
- { if($data->del_page($page["id"]))
- { $env->redirect
- ( $env->url("pages/admin"),
+ function del(&$env){
+ $data = $env->data();
+ if($page = $data->page($_GET[$env->param("id")])){
+ if($data->del_page($page["id"])){
+ $env->redirect(
+ $env->url("pages/admin"),
"la page a été supprimée"
);
}
<?php
- class mw_pages_index extends mw_mod
- {
+ class mw_pages_index extends mw_mod{
- function index(&$env)
- { $env->run("pages/view");
+ function index(&$env){
+ $env->run("pages/view");
}
}
<?php
- class mw_pages_view extends mw_mod
- {
+ class mw_pages_view extends mw_mod{
- function index(&$env)
- {
+ function index(&$env){
}
- function page(&$env)
- { $data = $env->data();
- if(($arbo = $data->pages_arbo(array("enabled" => 1))) !== false)
- { $env->set_out("arbo", $arbo);
- if(($page = $data->page($_GET[$env->param("id")])) && $page["enabled"])
- { $env->set_out("page", $page);
- if
- ( ( $pages = $data->pages
- ( array
- ( "id_parent" => $page["id"],
+ function page(&$env){
+ $data = $env->data();
+ if(($arbo = $data->pages_arbo(array("enabled" => 1))) !== false){
+ $env->set_out("arbo", $arbo);
+ if(($page = $data->page($_GET[$env->param("id")])) && $page["enabled"]){
+ $env->set_out("page", $page);
+ if(
+ (
+ $pages = $data->pages(
+ array(
+ "id_parent" => $page["id"],
"enabled" => 1,
"order_by" => "position",
"order" => "ASC"
)
)
) !== false
- )
- { $env->set_out("pages", $pages);
- if(($ariane = $data->page_ariane($page["id"])) !== false)
- { $env->set_out("ariane", $ariane);
+ ){
+ $env->set_out("pages", $pages);
+ if(($ariane = $data->page_ariane($page["id"])) !== false){
+ $env->set_out("ariane", $ariane);
}
else $env->erreur("impossible de lire le fil d'ariane");
}
<?php
- class mw_pages extends mw_plugin
- {
+ class mw_pages extends mw_plugin{
- function title($env)
- { return "Pages";
+ function title($env){
+ return "Pages";
}
- function description($env)
- { return "Pour ajouter des pages, avec un éditeur dans l'administration du site";
+ function description($env){
+ return "Pour ajouter des pages, avec un éditeur dans l'administration du site";
}
- function init($env)
- { $env->set_link("plugins/admin/mw_pages", $env->url("pages/admin"), "éditer les pages");
+ 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();
- if
- ( ( $pages = $data->pages
- ( array
- ( "id_parent" => "",
+ if(
+ (
+ $pages = $data->pages(
+ array(
+ "id_parent" => "",
"enabled" => 1,
"order_by" => "position",
"order" => "ASC"
)
)
) !== false
- )
- { foreach($pages["list"] as $id_page => $page)
- { $env->set_link
- ( "menu_top/mw_page_".$id_page,
+ ){
+ foreach($pages["list"] as $id_page => $page){
+ $env->set_link(
+ "menu_top/mw_page_".$id_page,
$env->url("pages/view/page", array("id" => $id_page)),
$page["title"],
$page["position"]
return true;
}
- function enable($env)
- { $plugins_pages_start_id = $env->config("plugins_pages_start_id");
- if($plugins_pages_start_id)
- { $data = $env->data();
- if
- ( $data->set_config("start_action", "pages/view/page")
+ function enable($env){
+ $plugins_pages_start_id = $env->config("plugins_pages_start_id");
+ if($plugins_pages_start_id){
+ $data = $env->data();
+ if(
+ $data->set_config("start_action", "pages/view/page")
&& $data->set_config("start_action_params", @serialize(array("id" => $plugins_pages_start_id)))
- )
- { return true;
+ ){
+ return true;
}
return false;
}
return true;
}
- function disable($env)
- { $start_action = $env->config("start_action");
- if($start_action == "pages/view/page")
- { $data = $env->data();
- if
- ( $data->set_config("start_action", "")
+ function disable($env){
+ $start_action = $env->config("start_action");
+ if($start_action == "pages/view/page"){
+ $data = $env->data();
+ if(
+ $data->set_config("start_action", "")
&& $data->set_config("start_action_params", "")
- )
- { return true;
+ ){
+ return true;
}
return false;
}
// install
//
- function install($env)
- { if($env->bdd("sgbd") == "xml") return $this->install_xml($env);
+ function install($env){
+ if($env->bdd("sgbd") == "xml") return $this->install_xml($env);
if($env->bdd("sgbd") == "sqlite") return $this->install_sqlite($env);
if($env->bdd("sgbd") == "mysql") return $this->install_mysql($env);
}
- function install_xml($env)
- { $data = $env->data();
+ function install_xml($env){
+ $data = $env->data();
$sgbd = $data->sgbd();
$EXISTS = $sgbd->data_exists("pages");
- if(!isset($EXISTS))
- { return "impossible de savoir si la table #--pages existe";
+ if(!isset($EXISTS)){
+ return "impossible de savoir si la table #--pages existe";
}
- if($EXISTS)
- { return "la table #--pages existe deja";
+ if($EXISTS){
+ return "la table #--pages existe deja";
}
- if(!$sgbd->create_data("pages"))
- { return "imposible de creer la table #--pages";
+ if(!$sgbd->create_data("pages")){
+ return "imposible de creer la table #--pages";
}
- if(!$sgbd->add_data("action_status", array("action" => "pages/admin", "id_status" => "1")))
- { $sgbd->remove_data("pages");
+ if(!$sgbd->add_data("action_status", array("action" => "pages/admin", "id_status" => "1"))){
+ $sgbd->remove_data("pages");
return "impossible d'ajouter un statut pour l'action pages/admin";
}
return true;
}
- function install_sqlite($env)
- { $data = $env->data();
+ function install_sqlite($env){
+ $data = $env->data();
$sgbd = $data->sgbd();
$EXISTS = $sgbd->table_exists("#--pages");
- if(!isset($EXISTS))
- { return "impossible de savoir si la table #--pages existe";
+ if(!isset($EXISTS)){
+ return "impossible de savoir si la table #--pages existe";
}
- if($EXISTS)
- { return "la table #--pages existe deja";
+ if($EXISTS){
+ return "la table #--pages existe deja";
}
$sql =
"CREATE TABLE #--pages"
.", enabled INTEGER NOT NULL DEFAULT 1"
.", position INTEGER NOT NULL DEFAULT 0"
.")";
- if(!$sgbd->query($sql))
- { return "imposible de creer la table #--pages";
+ if(!$sgbd->query($sql)){
+ return "imposible de creer la table #--pages";
}
- if(!$sgbd->query("INSERT INTO #--action_status(action, id_status) VALUES('pages/admin', 1)"))
- { $sgbd->query("DROP TABLE \"main\".\"#--pages\"");
+ if(!$sgbd->query("INSERT INTO #--action_status(action, id_status) VALUES('pages/admin', 1)")){
+ $sgbd->query("DROP TABLE \"main\".\"#--pages\"");
return "impossible d'ajouter un statut pour l'action pages/admin";
}
return true;
}
- function install_mysql($env)
- { $data = $env->data();
+ function install_mysql($env){
+ $data = $env->data();
$sgbd = $data->sgbd();
$EXISTS = $sgbd->table_exists("#--pages");
- if(!isset($EXISTS))
- { return "impossible de savoir si la table #--pages existe";
+ if(!isset($EXISTS)){
+ return "impossible de savoir si la table #--pages existe";
}
- if($EXISTS)
- { return "la table #--pages existe deja";
+ if($EXISTS){
+ return "la table #--pages existe deja";
}
$sql =
"CREATE TABLE #--pages"
.", enabled TINYINT NOT NULL DEFAULT '1'"
.", position INT(11) NOT NULL DEFAULT '0'"
.") DEFAULT CHARSET=utf8";
- if(!$sgbd->query($sql))
- { return "imposible de creer la table #--pages";
+ if(!$sgbd->query($sql)){
+ return "imposible de creer la table #--pages";
}
- if(!$sgbd->query("INSERT INTO #--action_status(action, id_status) VALUES('pages/admin', 1)"))
- { $sgbd->query("DROP TABLE #--pages");
+ if(!$sgbd->query("INSERT INTO #--action_status(action, id_status) VALUES('pages/admin', 1)")){
+ $sgbd->query("DROP TABLE #--pages");
return "impossible d'ajouter un statut pour l'action pages/admin";
}
return true;
// uninstall
//
- function uninstall($env)
- { if($env->bdd("sgbd") == "xml") return $this->uninstall_xml($env);
+ function uninstall($env){
+ if($env->bdd("sgbd") == "xml") return $this->uninstall_xml($env);
if($env->bdd("sgbd") == "sqlite") return $this->uninstall_sqlite($env);
if($env->bdd("sgbd") == "mysql") return $this->uninstall_mysql($env);
}
- function uninstall_xml($env)
- { $data = $env->data();
+ function uninstall_xml($env){
+ $data = $env->data();
$sgbd = $data->sgbd();
if(!$this->disable($env)) return "impossible de desactiver le plugin";
$data->del_config("plugins_pages_start_id");
$EXISTS = $sgbd->data_exists("pages");
- if(!isset($EXISTS))
- { return "impossible de savoir si la table #--pages existe";
+ if(!isset($EXISTS)){
+ return "impossible de savoir si la table #--pages existe";
}
- if(!$EXISTS)
- { // return "la table #--pages n'existe pas";
+ if(!$EXISTS){
+ // return "la table #--pages n'existe pas";
}
- elseif(!$sgbd->remove_data("pages"))
- { return "imposible de supprimer la table #--pages";
+ elseif(!$sgbd->remove_data("pages")){
+ return "imposible de supprimer la table #--pages";
}
$ids = array();
- if($rst = $sgbd->open_data("action_status"))
- { while($v_rst = $sgbd->fetch_data($rst))
- { if(isset($v_rst))
- { if(isset($v_rst["action"]) && isset($v_rst["id"]) && $v_rst["action"] == "pages/admin")
- { $ids[] = $v_rst["id"];
+ if($rst = $sgbd->open_data("action_status")){
+ while($v_rst = $sgbd->fetch_data($rst)){
+ if(isset($v_rst)){
+ if(isset($v_rst["action"]) && isset($v_rst["id"]) && $v_rst["action"] == "pages/admin"){
+ $ids[] = $v_rst["id"];
}
}
else $ids = false;
}
$sgbd->close_data($rst);
}
- if($ids !== false)
- { foreach($ids as $id)
- { $sgbd->del_data("action_status", $id);
+ if($ids !== false){
+ foreach($ids as $id){
+ $sgbd->del_data("action_status", $id);
}
}
return true;
}
- function uninstall_sqlite($env)
- { $data = $env->data();
+ function uninstall_sqlite($env){
+ $data = $env->data();
$sgbd = $data->sgbd();
if(!$this->disable($env)) return "impossible de desactiver le plugin";
$data->del_config("plugins_pages_start_id");
$EXISTS = $sgbd->table_exists("#--pages");
- if(!isset($EXISTS))
- { return "impossible de savoir si la table #--pages existe";
+ if(!isset($EXISTS)){
+ return "impossible de savoir si la table #--pages existe";
}
- if(!$EXISTS)
- { // return "la table #--pages n'existe pas";
+ if(!$EXISTS){
+ // return "la table #--pages n'existe pas";
}
- elseif(!$sgbd->query("DROP TABLE \"main\".\"#--pages\""))
- { return "imposible de supprimer la table #--pages";
+ elseif(!$sgbd->query("DROP TABLE \"main\".\"#--pages\"")){
+ return "imposible de supprimer la table #--pages";
}
$sgbd->query("DELETE FROM #--action_status WHERE action='pages/admin'");
return true;
}
- function uninstall_mysql($env)
- { $data = $env->data();
+ function uninstall_mysql($env){
+ $data = $env->data();
$sgbd = $data->sgbd();
if(!$this->disable($env)) return "impossible de desactiver le plugin";
$data->del_config("plugins_pages_start_id");
$EXISTS = $sgbd->table_exists("#--pages");
- if(!isset($EXISTS))
- { return "impossible de savoir si la table #--pages existe";
+ if(!isset($EXISTS)){
+ return "impossible de savoir si la table #--pages existe";
}
- if(!$EXISTS)
- { // return "la table #--pages n'existe pas";
+ if(!$EXISTS){
+ // return "la table #--pages n'existe pas";
}
- elseif(!$sgbd->query("DROP TABLE #--pages"))
- { return "imposible de supprimer la table #--pages";
+ elseif(!$sgbd->query("DROP TABLE #--pages")){
+ return "imposible de supprimer la table #--pages";
}
$sgbd->query("DELETE FROM #--action_status WHERE action='pages/admin'");
return true;
}
-
?>
\ No newline at end of file
-ul.pages_menu
-{ list-style-type: none;
+ul.pages_menu{
+ list-style-type: none;
margin: 5px 20px 5px 10px;
padding: 0;
}
-ul.pages_menu ul
-{ list-style-type: none;
+ul.pages_menu ul{
+ list-style-type: none;
margin: 0 0 0 20px;
padding: 0;
}
-ul.pages_menu li
-{ margin: 1px 0;
+ul.pages_menu li{
+ margin: 1px 0;
padding: 0;
border-bottom: solid 1px #e5e5e5;
}
-ul.pages_menu li a
-{ display: block;
+ul.pages_menu li a{
+ display: block;
line-height: 2em;
padding: 0 1em;
background-color: #f5f5f5;
}
-ul.pages_menu li a:hover
-{ color: #000066;
+ul.pages_menu li a:hover{
+ color: #000066;
background-color: #f1f1f1;
-}
\ No newline at end of file
+}
<?php
if(!function_exists("datetime2timestamp")) :
- function datetime2timestamp($string)
- { list($date, $time) = explode(" ", $string);
+ function datetime2timestamp($string){
+ list($date, $time) = explode(" ", $string);
list($year, $month, $day) = explode("-", $date);
list($hour, $minute, $second) = explode(":", $time);
$timestamp = mktime($hour, $minute, $second, $month, $day, $year);
endif;
if(!function_exists("pages_arbo_navig_lis")) :
- function pages_arbo_navig_lis($env, $arbo, $ariane = array())
- { $content = "";
- if($arbo["subs"])
- { if($path_item = array_shift($ariane))
- { foreach($arbo["subs"] as $page)
- { $content .= "<li".($path_item["id"] == $page["id"] ? " class=\"current\"" : "")."><a href=\"".$env->url("pages/view/page", array("id" => $page["id"]))."\">".$page["title"]."</a></li>\n";
- if($path_item["id"] == $page["id"])
- { if($sub_content = pages_arbo_navig_lis($env, $page, $ariane))
- { $content .=
+ function pages_arbo_navig_lis($env, $arbo, $ariane = array()){
+ $content = "";
+ if($arbo["subs"]){
+ if($path_item = array_shift($ariane)){
+ foreach($arbo["subs"] as $page){
+ $content .= "<li".($path_item["id"] == $page["id"] ? " class=\"current\"" : "")."><a href=\"".$env->url("pages/view/page", array("id" => $page["id"]))."\">".$page["title"]."</a></li>\n";
+ if($path_item["id"] == $page["id"]){
+ if($sub_content = pages_arbo_navig_lis($env, $page, $ariane)){
+ $content .=
"<ul>\n"
.$sub_content
."</ul>\n";
}
}
}
- else
- { foreach($arbo["subs"] as $page)
- { $content .= "<li><a href=\"".$env->url("pages/view/page", array("id" => $page["id"]))."\">".$page["title"]."</a></li>\n";
+ else{
+ foreach($arbo["subs"] as $page){
+ $content .= "<li><a href=\"".$env->url("pages/view/page", array("id" => $page["id"]))."\">".$page["title"]."</a></li>\n";
}
}
}
endif;
if(!function_exists("pages_arbo_edit_select_options")) :
- function pages_arbo_edit_select_options($arbo, $id_page, $id_parent, $indent_increment = "", $indent = "")
- { $arbo["id"] = $arbo["id"] ? $arbo["id"] : "";
+ function pages_arbo_edit_select_options($arbo, $id_page, $id_parent, $indent_increment = "", $indent = ""){
+ $arbo["id"] = $arbo["id"] ? $arbo["id"] : "";
$content =
"<option"
." value=\"".$arbo["id"]."\""
.">"
.$indent.($arbo["id"] ? $arbo["title"] : "Aucune")
."</option>";
- if($arbo["subs"])
- { $indent .= $indent_increment;
- foreach($arbo["subs"] as $i => $sub)
- { if(!isset($id_page) || $id_page != $sub["id"])
- { $content .= pages_arbo_edit_select_options($sub, $id_page, $id_parent, $indent_increment, $indent);
+ if($arbo["subs"]){
+ $indent .= $indent_increment;
+ foreach($arbo["subs"] as $i => $sub){
+ if(!isset($id_page) || $id_page != $sub["id"]){
+ $content .= pages_arbo_edit_select_options($sub, $id_page, $id_parent, $indent_increment, $indent);
}
}
}
endif;
if(!function_exists("pages_arbo_list_select_options")) :
- function pages_arbo_list_select_options($env, $etat, $arbo, $current_page_id, $indent_increment = "", $indent = "")
- { $arbo["id"] = isset($arbo["id"]) ? $arbo["id"] : "";
+ function pages_arbo_list_select_options($env, $etat, $arbo, $current_page_id, $indent_increment = "", $indent = ""){
+ $arbo["id"] = isset($arbo["id"]) ? $arbo["id"] : "";
$content =
"<option"
." value=\"".$env->url($etat, array("parent" => $arbo["id"]))."\""
.">"
.$indent.($arbo["id"] ? $arbo["title"] : "Racine des pages")
."</option>";
- if($arbo["subs"])
- { $indent .= $indent_increment;
- foreach($arbo["subs"] as $i => $sub)
- { $content .= pages_arbo_list_select_options($env, $etat, $sub, $current_page_id, $indent_increment, $indent);
+ if($arbo["subs"]){
+ $indent .= $indent_increment;
+ foreach($arbo["subs"] as $i => $sub){
+ $content .= pages_arbo_list_select_options($env, $etat, $sub, $current_page_id, $indent_increment, $indent);
}
}
return $content;
endif;
if(!function_exists("pages_arbo_start_select_options")) :
- 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"] : "";
- if($arbo["id"])
- { $content =
+ 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"] : "";
+ if($arbo["id"]){
+ $content =
"<option"
." value=\"".$arbo["id"]."\""
.( isset($current_start_action)
.$indent.$arbo["title"]
."</option>";
}
- if($arbo["subs"])
- { $indent .= $indent_increment;
+ if($arbo["subs"]){
+ $indent .= $indent_increment;
$indent .= " ";
- foreach($arbo["subs"] as $i => $sub)
- { $content .= pages_arbo_start_select_options($env, $sub, $current_start_action, $current_start_action_params, $indent_increment, $indent);
+ foreach($arbo["subs"] as $i => $sub){
+ $content .= pages_arbo_start_select_options($env, $sub, $current_start_action, $current_start_action_params, $indent_increment, $indent);
}
}
return $content;
-$(document).ready
-( function()
- { init_tinymce();
+$(document).ready(
+ function(){
+ init_tinymce();
}
);
-function init_tinymce()
-{ $(".tinymce").each
- ( function()
- { tinyMCE.execCommand("mceAddControl", true, $(this).attr("id"));
+function init_tinymce(){
+ $(".tinymce").each(
+ function(){
+ tinyMCE.execCommand("mceAddControl", true, $(this).attr("id"));
}
);
}
<?= $this->out["page"]["title"] ?>
</h2>
-<div>
- <?= $this->out["page"]["content"] ?>
-</div>
<?php if($this->out["pages"]["list"]) : ?>
<ul class="pages_menu">
<?php foreach($this->out["pages"]["list"] as $page) : ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
+
+<div>
+ <?= $this->out["page"]["content"] ?>
+</div>