let hierarchical_menu_depth_first
?(classe=[])
?(whole_tree=false)
((page, pages) as the_menu)
?service
~sp =
let rec depth_first_fun pages level pos : {{ [Xhtmltypes_duce.ul*] }} =
let rec one_item first last i s : Xhtmltypes_duce.li =
let (classe, pos2, deplier) =
match pos with
| [] -> ([], [], false)
| a::l when a = i -> ([current_class], l, true)
| _::l -> ([], [], false)
in
let classe =
if last then
last_class::classe
else classe
in
let classe =
if first then
first_class::classe
else classe
in
match s with
| (text, Site_tree (Default_page page, []))
| (text, Site_tree (Main_page page, [])) ->
{{ <li class={: attrib_list classe :}>[{: a page sp {: text :} () :}] }}
| (text, Site_tree (Not_clickable, [])) ->
{{ <li class={: attrib_list classe :}>{: text :} }}
| (text, Disabled) ->
{{ <li class={: attrib_list (disabled_class::classe) :}>{: text :} }}
| (text, Site_tree (Default_page page, hsl))
| (text, Site_tree (Main_page page, hsl)) ->
{{ <li class={: attrib_list classe :}>[
{: a page sp {: text :} () :}
!{: if deplier || whole_tree then
(depth_first_fun hsl (level+1) pos2)
else {{ [] }}
:}
] }}
| (text, Site_tree (Not_clickable, hsl)) ->
{{ <li class={: attrib_list classe :}>[
!{: text :}
!{: if deplier || whole_tree then
(depth_first_fun hsl (level+1) pos2)
else
{{ [] }} :}
] }}
and one_menu first i l : {{ [Xhtmltypes_duce.li*] }} = match l with
| [] -> {{ [] }}
| [a] -> let aa = one_item first true i a in {{ [ aa ] }}
| a::l ->
let aa = one_item first false i a in
let al = one_menu false (i+1) l in
{{ [ {: aa :} !{: al :} ] }}
in
let classe = (level_class^string_of_int level)::classe in
match one_menu true 0 pages with
| {{ [] }} -> {{ [] }}
| {{ l }} -> {{ [ <ul class={: attrib_list (menu_class::classe) :}>l ] }}
in
(depth_first_fun pages 0 (find_in_hierarchy service the_menu))