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