(* camlp4r ./pa_html.cmo *) (* $Id: descend.ml,v 4.24 2004/12/14 09:30:11 ddr Exp $ *) (* Copyright (c) 1998-2005 INRIA *) open Config; open Def; open Gutil; open Util; open Dag2html; value limit_desc conf = match p_getint conf.base_env "max_desc_level" with [ Some x -> max 1 x | None -> 12 ] ; value limit_by_tree conf = match p_getint conf.base_env "max_desc_tree" with [ Some x -> max 1 x | None -> 4 ] ; value infinite = 10000; value make_level_table conf base max_level p = let mark = Array.create base.data.persons.len False in let levt = Array.create base.data.persons.len infinite in let rec fill ip u lev = if max_level == infinite && mark.(Adef.int_of_iper ip) then () else do { mark.(Adef.int_of_iper ip) := True; if lev <= max_level then do { if lev < levt.(Adef.int_of_iper ip) then levt.(Adef.int_of_iper ip) := lev else (); Array.iter (fun ifam -> let ipl = (doi base ifam).children in Array.iter (fun ip -> fill ip (uget conf base ip) (succ lev)) ipl) u.family } else () } in do { fill p.cle_index (uget conf base p.cle_index) 0; levt } ; value level_max conf base p = let levt = make_level_table conf base infinite p in let x = ref 0 in do { for i = 0 to Array.length levt - 1 do { let lev = levt.(i) in if lev != infinite && x.val < lev then x.val := lev else () }; x.val } ; value text_to conf = fun [ 0 -> transl conf "specify" ^ " " ^ transl_nth conf "generation/generations" 0 | 1 -> transl conf "to the children" | 2 -> transl conf "to the grandchildren" | 3 -> transl conf "to the great-grandchildren" | i -> Printf.sprintf (ftransl conf "to the %s generation") (transl_nth conf "nth (generation)" i) ] ; value text_level conf = fun [ 0 -> transl conf "specify" ^ " " ^ transl_nth conf "generation/generations" 0 | 1 -> transl conf "the children" | 2 -> transl conf "the grandchildren" | 3 -> transl conf "the great-grandchildren" | i -> Printf.sprintf (ftransl conf "the %s generation") (transl_nth conf "nth (generation)" i) ] ; value print_choice conf base p effective_level = tag "form" "method=get action=\"%s\"" conf.command begin List.iter (fun (k, v) -> Wserver.wprint "\n" k (quote_escaped (decode_varenv v))) conf.henv; Wserver.wprint "\n"; wprint_hidden_person conf base "" p; tag "select" "name=v" begin let rec loop i = if i > effective_level then () else do { Wserver.wprint "