maj syntaxe accolades et correction param manquant
[mw_pages] / app / data / modules / sql / mw_data_pages.php
index 3ef0b6c..e6fec6f 100644 (file)
@@ -1,19 +1,18 @@
 <?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;
@@ -28,8 +27,8 @@
       $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 : "")
         : ""
       );
@@ -39,8 +38,8 @@
       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);
@@ -93,8 +92,8 @@
       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;
     }