mise a jour pour mtweb.0.6.1
[mw_pages] / app / out / default / functions.php
diff --git a/app/out/default/functions.php b/app/out/default/functions.php
new file mode 100644 (file)
index 0000000..f96e4b8
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+
+  if(!function_exists("datetime2timestamp")) :
+  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);
+    return $timestamp;
+  }
+  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 .=
+               "<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";
+        }
+      }
+    }
+    return $content;
+  }
+  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"] : "";
+    $content =
+     "<option"
+    ." value=\"".$arbo["id"]."\""
+    .(isset($id_parent) && ($arbo["id"] == $id_parent) ? " selected=\"selected\"" : "")
+    .">"
+    .$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);
+        }
+      }
+    }
+    return $content;
+  }
+  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"] : "";
+    $content =
+     "<option"
+    ." value=\"".$env->url($etat, array("parent" => $arbo["id"]))."\""
+    .(isset($current_page_id) && ($arbo["id"] == $current_page_id) ? " selected=\"selected\"" : "")
+    .">"
+    .$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);
+      }
+    }
+    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 =
+       "<option"
+      ." value=\"".$arbo["id"]."\""
+      .(    isset($current_start_action)
+         && ($current_start_action == "pages/view/page")
+         && isset($current_start_action_params["id"])
+         && ($arbo["id"] == $current_start_action_params["id"])
+         ?
+           " selected=\"selected\""
+         : ""
+       )
+      .">"
+      .$indent.$arbo["title"]
+      ."</option>";
+    }
+    if($arbo["subs"]){
+      $indent .= $indent_increment;
+      $indent .= "&nbsp;&nbsp;";
+      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;
+  }
+  endif;
+
+?>
\ No newline at end of file