template default en HTML5
[mw_pages] / app / out / default / functions.php
1 <?php
2
3   if($this->etat("mod") == "pages" && $this->etat("controller") == "admin"){
4     $this->add_js_file($this->path("mw_path")."libs/tiny_mce/tiny_mce.js");
5     $this->add_js_file($this->path("mw_path")."libs/tiny_mce/plugins/tinybrowser/tb_tinymce.js.php");
6   }
7
8   if(!function_exists("datetime2timestamp")) :
9   function datetime2timestamp($string){
10     list($date, $time) = explode(" ", $string);
11     list($year, $month, $day) = explode("-", $date);
12     list($hour, $minute, $second) = explode(":", $time);
13     $timestamp = mktime($hour, $minute, $second, $month, $day, $year);
14     return $timestamp;
15   }
16   endif;
17
18   if(!function_exists("pages_arbo_navig_lis")) :
19   function pages_arbo_navig_lis($env, $arbo, $ariane = array()){
20     $content = "";
21     if($arbo["subs"]){
22       if($path_item = array_shift($ariane)){
23         foreach($arbo["subs"] as $page){
24           $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";
25           if($path_item["id"] == $page["id"]){
26             if($sub_content = pages_arbo_navig_lis($env, $page, $ariane)){
27               $content .=
28                "<ul>\n"
29               .$sub_content
30               ."</ul>\n";
31             }
32           }
33         }
34       }
35       else{
36         foreach($arbo["subs"] as $page){
37           $content .= "<li><a href=\"".$env->url("pages/view/page", array("id" => $page["id"]))."\">".$page["title"]."</a></li>\n";
38         }
39       }
40     }
41     return $content;
42   }
43   endif;
44
45   if(!function_exists("pages_arbo_edit_select_options")) :
46   function pages_arbo_edit_select_options($arbo, $id_page, $id_parent, $indent_increment = "", $indent = ""){
47     $arbo["id"] = $arbo["id"] ? $arbo["id"] : "";
48     $content =
49      "<option"
50     ." value=\"".$arbo["id"]."\""
51     .(isset($id_parent) && ($arbo["id"] == $id_parent) ? " selected=\"selected\"" : "")
52     .">"
53     .$indent.($arbo["id"] ? $arbo["title"] : "Aucune")
54     ."</option>";
55     if($arbo["subs"]){
56       $indent .= $indent_increment;
57       foreach($arbo["subs"] as $i => $sub){
58         if(!isset($id_page) || $id_page != $sub["id"]){
59           $content .= pages_arbo_edit_select_options($sub, $id_page, $id_parent, $indent_increment, $indent);
60         }
61       }
62     }
63     return $content;
64   }
65   endif;
66
67   if(!function_exists("pages_arbo_list_select_options")) :
68   function pages_arbo_list_select_options($env, $etat, $arbo, $current_page_id, $indent_increment = "", $indent = ""){
69     $arbo["id"] = isset($arbo["id"]) ? $arbo["id"] : "";
70     $content =
71      "<option"
72     ." value=\"".$env->url($etat, array("parent" => $arbo["id"]))."\""
73     .(isset($current_page_id) && ($arbo["id"] == $current_page_id) ? " selected=\"selected\"" : "")
74     .">"
75     .$indent.($arbo["id"] ? $arbo["title"] : "Racine des pages")
76     ."</option>";
77     if($arbo["subs"]){
78       $indent .= $indent_increment;
79       foreach($arbo["subs"] as $i => $sub){
80         $content .= pages_arbo_list_select_options($env, $etat, $sub, $current_page_id, $indent_increment, $indent);
81       }
82     }
83     return $content;
84   }
85   endif;
86
87   if(!function_exists("pages_arbo_start_select_options")) :
88   function pages_arbo_start_select_options($env, $arbo, $current_start_action, $current_start_action_params, $indent_increment = "", $indent = ""){
89     $arbo["id"] = isset($arbo["id"]) ? $arbo["id"] : "";
90     if($arbo["id"]){
91       $content =
92        "<option"
93       ." value=\"".$arbo["id"]."\""
94       .(    isset($current_start_action)
95          && ($current_start_action == "pages/view/page")
96          && isset($current_start_action_params["id"])
97          && ($arbo["id"] == $current_start_action_params["id"])
98          ?
99            " selected=\"selected\""
100          : ""
101        )
102       .">"
103       .$indent.$arbo["title"]
104       ."</option>";
105     }
106     if($arbo["subs"]){
107       $indent .= $indent_increment;
108       $indent .= "&nbsp;&nbsp;";
109       foreach($arbo["subs"] as $i => $sub){
110         $content .= pages_arbo_start_select_options($env, $sub, $current_start_action, $current_start_action_params, $indent_increment, $indent);
111       }
112     }
113     return $content;
114   }
115   endif;
116
117 ?>