\n"
}
else ()
;
value print_notes_for_family conf base all_gp ifam nth moth_nb =
let des = doi base ifam in
for i = 0 to Array.length des.children - 1 do {
let ipc = des.children.(i) in
let pc = pget conf base ipc in
let n = get_link all_gp ipc in
match n with
[ Some _ -> ()
| None ->
let child_n =
let s = String.make 1 (Char.chr (Char.code 'a' + i)) in
match nth with
[ Some (_, i) -> "-" ^ string_of_int i ^ s
| None -> s ]
in
print_notes_for_someone conf base pc moth_nb child_n ]
}
;
value print_notes_for_other_families conf base all_gp excl_ifam moth_nb =
let print ip n =
let u = uget conf base ip in
for i = 0 to Array.length u.family - 1 do {
let ifam = u.family.(i) in
if ifam <> excl_ifam && Array.length (doi base ifam).children <> 0 then
print_notes_for_family conf base all_gp ifam (Some (n, i + 1)) moth_nb
else ()
}
in
let cpl = coi base excl_ifam in
do { print (father cpl) (Num.sub moth_nb Num.one); print (mother cpl) moth_nb }
;
value print_notes conf base all_gp ws =
fun
[ GP_person n ip ifamo ->
do {
print_notes_for_someone conf base (pget conf base ip) n "";
match ifamo with
[ Some ifam ->
if not (Num.even n) && ws then do {
print_notes_for_family conf base all_gp ifam None n;
print_notes_for_other_families conf base all_gp ifam n
}
else ()
| _ -> () ]
}
| _ -> () ]
;
value display_ancestors_with_numbers_long conf base max_level ws wn p =
let only = p_getenv conf.env "only" = Some "on" in
let mark = Array.create base.data.persons.len Num.zero in
let rec get_generations level gpll gpl =
let gpll = [gpl :: gpll] in
if level < max_level then
let next_gpl = next_generation conf base mark gpl in
if List.exists will_print next_gpl then
get_generations (level + 1) gpll next_gpl
else gpll
else gpll
in
let rec generation level all_gp =
fun
[ [gpl :: gpll] ->
do {
if not only || level = max_level then do {
tag "h3" begin
Wserver.wprint "%s %d\n"
(capitale (transl_nth conf "generation/generations" 0))
level;
end;
List.iter
(print_generation_person_long conf base ws wn all_gp
(gpll = []))
gpl;
Wserver.wprint "
";
html_br conf
}
else ();
generation (level + 1) all_gp gpll
}
| [] -> () ]
in
let title h =
let txt_fun = if h then gen_person_text_no_html else gen_person_text in
Wserver.wprint "%s"
(capitale
(transl_a_of_b conf (transl conf "ancestors")
(txt_fun raw_access conf base p)))
in
do {
header conf title;
if only then ()
else Wserver.wprint "%s.\n" (capitale (text_to conf max_level));
mark.(Adef.int_of_iper p.cle_index) := Num.one;
let gpll1 = get_generations 1 [] [GP_person Num.one p.cle_index None] in
let gpll = List.rev gpll1 in
let all_gp = List.flatten gpll in
generation 1 all_gp gpll;
let all_gp = if only then List.hd gpll1 else all_gp in
if wn && has_notes conf base all_gp then do {
Wserver.wprint "
\n"
}
else ()
| None ->
do {
html_li conf;
Wserver.wprint "%c\n" i i;
Wserver.wprint "\n"
} ]
else ();
html_li conf;
print_alphabetic_missing conf base spouses_included e;
Wserver.wprint "\n";
Some i
})
None list
in
if print_initials then Wserver.wprint "
\n" else ();
end;
trailer conf
}
;
value tree_reference gv bd color conf base p s =
if conf.cancel_links || is_hidden p then s
else
let im = p_getenv conf.env "image" = Some "on" in
sprintf "%s"
(commd conf) gv (acces conf base p) (if im then ";image=on" else "")
(if bd > 0 then ";bd=" ^ string_of_int bd else "")
(if color <> "" then ";color=" ^ color else "") s
;
type pos = [ Left | Right | Center | Alone ];
type cell = [ Cell of person and pos and bool and int | Empty ];
(* Ascendant tree:
8 ? ? ? ? ? ? ?
4 5 ? 7
2 3
1
1) Build list of levels (t1 = True for parents flag, size 1)
=> [ [8At1 E E] [4Lt1 5Rt1 7At1] [2Lt1 3Rt1] [1Ct1] ]
2) Enrich list of levels (parents flag, sizing)
=> [ [8At1 E E] [4Lt1 5Rf1 7Af1] [2Lt3 3Rt1] [1Ct5] ]
3) Display it
For each cell:
Top vertical bar if parents flag (not on top line)
Person
Person tree link (vertical bar) ) not on bottom line
Horizontal line )
*)
value rec enrich lst1 lst2 =
match (lst1, lst2) with
[ (_, []) -> []
| ([], lst) -> lst
| (_, _) ->
match (List.hd lst1, List.hd lst2) with
[ (Cell _ Right _ s1, Cell p d u s2) ->
[Cell p d u (s1 + s2 + 1) :: enrich (List.tl lst1) (List.tl lst2)]
| (Cell _ Left _ s, Cell p d u _) ->
enrich (List.tl lst1) [Cell p d u s :: List.tl lst2]
| (Cell _ _ _ s, Cell p d u _) ->
[Cell p d u s :: enrich (List.tl lst1) (List.tl lst2)]
| (Empty, Cell p d _ s) ->
[Cell p d False s :: enrich (List.tl lst1) (List.tl lst2)]
| (_, Empty) -> [Empty :: enrich (List.tl lst1) (List.tl lst2)] ] ]
;
value is_empty lst =
List.fold_left (fun test po -> test && po == Empty) True lst
;
value rec enrich_tree lst =
match lst with
[ [] -> []
| [head :: tail] ->
if is_empty head then enrich_tree tail
else
match tail with
[ [] -> [head]
| [thead :: ttail] ->
[head :: enrich_tree [enrich head thead :: ttail]] ] ]
;
(* print_tree_with_table:
conf: configuration parameters
base: base name
gv: number of generations
p: person *)
value print_tree_with_table conf base gv p =
let gv = min (limit_by_tree conf) gv in
let bd = match p_getint conf.env "bd" with [ Some x -> x | None -> 0 ] in
let color =
match Util.p_getenv conf.env "color" with
[ None -> ""
| Some x -> x ]
in
let td_prop =
match Util.p_getenv conf.env "td" with
[ Some x -> " " ^ x
| _ -> if color = "" then "" else " bgcolor=" ^ color ]
in
let next_gen pol =
List.fold_right
(fun po list ->
match po with
[ Empty -> [Empty :: list]
| Cell p _ _ _ ->
match parents (aget conf base p.cle_index) with
[ Some ifam ->
let cpl = coi base ifam in
let fath =
let p = pget conf base (father cpl) in
if know base p then Some p else None
in
let moth =
let p = pget conf base (mother cpl) in
if know base p then Some p else None
in
match (fath, moth) with
[ (Some f, Some m) ->
[Cell f Left True 1; Cell m Right True 1 :: list]
| (Some f, None) -> [Cell f Alone True 1 :: list]
| (None, Some m) -> [Cell m Alone True 1 :: list]
| (None, None) -> [Empty :: list] ]
| _ -> [Empty :: list] ] ])
pol []
in
let gen =
loop (gv - 1) [Cell p Center True 1] [] where rec loop i gen list =
if i == 0 then [gen :: list]
else loop (i - 1) (next_gen gen) [gen :: list]
in
let gen = enrich_tree gen in
let down_reference p s =
if conf.cancel_links then s else reference conf base p s
in
let colspan =
fun
[ Empty | Cell _ _ _ 1 -> ""
| Cell _ _ _ s -> " colspan=" ^ string_of_int s ]
in
let align =
fun
[ Cell _ Center _ _ | Cell _ Alone _ _ -> "align=center"
| Cell _ Left _ _ -> "align=right"
| _ -> "" ]
in
let print_ancestor_link gen first po =
do {
if not first then Wserver.wprint " | \n" else ();
stag "td" "align=center%s" (colspan po) begin
let txt =
match po with
[ Empty -> " "
| Cell p _ _ _ -> tree_reference gv bd color conf base p "|" ]
in
Wserver.wprint "%s" txt;
end;
Wserver.wprint "\n"
}
in
let print_ancestor gen first po =
do {
if not first then Wserver.wprint " | \n" else ();
stag "td" "align=center%s" (colspan po) begin
let txt =
match po with
[ Empty -> " "
| Cell p _ _ _ ->
let txt = person_title_text conf base p in
let txt = down_reference p txt in
let txt = txt ^ Date.short_dates_text conf base p in
let txt =
if bd > 0 || td_prop <> "" then
sprintf
""
bd td_prop txt
else txt
in
txt ^ Dag.image_txt conf base p ]
in
Wserver.wprint "%s" txt;
end;
Wserver.wprint "\n"
}
in
let print_vertical_bars gen first po =
do {
if not first then Wserver.wprint " | \n" else ();
stag "td" "align=center%s" (colspan po) begin
let txt =
match po with
[ Empty | Cell _ _ False _ -> " "
| _ -> "|" ]
in
Wserver.wprint "%s" txt;
end;
Wserver.wprint "\n"
}
in
let print_horizontal_line gen first po =
do {
if not first then do {
stag "td" "%s" (align po) begin
let txt =
match po with
[ Cell _ Right _ _ | Cell _ Center _ _ ->
"
"
| _ -> " " ]
in
Wserver.wprint "%s" txt;
end;
Wserver.wprint "\n"
}
else ();
stag "td" "%s%s" (align po) (colspan po) begin
let txt =
match po with
[ Empty -> " "
| Cell _ Left _ _ ->
"
"
| Cell _ Right _ _ ->
"
"
| Cell _ Alone _ _ -> "|"
| Cell _ Center _ _ -> "
" ]
in
Wserver.wprint "%s" txt;
end;
Wserver.wprint "\n"
}
in
tag "table" "border=%d cellspacing=0 cellpadding=0 width=\"100%%\""
conf.border
begin
list_iter_first
(fun firstline gen ->
do {
if not firstline then
tag "tr" "align=left" begin
list_iter_first
(fun first po -> print_vertical_bars gen first po) gen;
end
else ();
tag "tr" "align=left" begin
list_iter_first (fun first po -> print_ancestor gen first po)
gen;
end;
match gen with
[ [Cell _ Center _ _ :: _] -> ()
| _ ->
do {
tag "tr" "align=left" begin
list_iter_first
(fun first po -> print_ancestor_link gen first po) gen;
end;
tag "tr" "align=left" begin
list_iter_first
(fun first po -> print_horizontal_line gen first po) gen;
end
} ]
})
gen;
end
;
value print_normal_tree conf base v p =
let title _ =
Wserver.wprint "%s: %s" (capitale (transl conf "tree"))
(person_text_no_html conf base p)
in
do {
header_no_page_title conf title;
Wserver.wprint "\n";
print_tree_with_table conf base v p;
trailer conf
}
;
value print_tree conf base v p =
let v = min (limit_by_tree conf) v in
if p_getenv conf.env "dag" = Some "on" ||
browser_doesnt_have_tables conf then
let set =
loop Dag.Pset.empty v p.cle_index where rec loop set lev ip =
let set = Dag.Pset.add ip set in
if lev <= 1 then set
else
match parents (aget conf base ip) with
[ Some ifam ->
let cpl = coi base ifam in
let set = loop set (lev - 1) (mother cpl) in
loop set (lev - 1) (father cpl)
| None -> set ]
in
let d = Dag.make_dag conf base (Dag.Pset.elements set) in
Dag.gen_print_dag conf base False True set [] d
else print_normal_tree conf base v p
;
value no_spaces s =
loop 0 0 where rec loop len i =
if i == String.length s then Buff.get len
else
let len =
match s.[i] with
[ ' ' -> Buff.mstore len " "
| x -> Buff.store len s.[i] ]
in
loop len (i + 1)
;
value htree_reference gv conf base p s =
if conf.cancel_links || is_hidden p then s
else
"" ^ s ^ ""
;
value print_horizontally conf base max_level p =
let title h =
let txt_fun = if h then gen_person_text_no_html else gen_person_text in
Wserver.wprint "%s"
(capitale
(transl_a_of_b conf (transl conf "ancestors")
(txt_fun raw_access conf base p)))
in
let max_level = min (limit_by_list conf) max_level in
let suff1 = " " in
let suff2 = " +-- " in
let suff3 = " | " in
let rec loop level s1 s2 s3 ip =
if level >= max_level then ()
else do {
match parents (aget conf base ip) with
[ Some ifam ->
loop (level + 1) (s1 ^ suff1) (s1 ^ suff2) (s1 ^ suff3)
(father (coi base ifam))
| None -> () ];
Wserver.wprint "%s" s2;
let p = pget conf base ip in
let ref = if level = 0 then reference else htree_reference max_level in
Wserver.wprint "%s%s
\n"
(ref conf base p (no_spaces (person_text conf base p)))
(no_spaces (Date.short_dates_text conf base p));
match parents (aget conf base ip) with
[ Some ifam ->
loop (level + 1) (s3 ^ suff3) (s3 ^ suff2) (s3 ^ suff1)
(mother (coi base ifam))
| None -> () ]
}
in
do {
header conf title;
print_link_to_welcome conf True;
Wserver.wprint "%s.\n" (capitale (text_to conf max_level));
Wserver.wprint "| \n";
let suff13 = " " in
let suff2 = "-- " in
loop 0 suff13 suff2 suff13 p.cle_index;
Wserver.wprint " |
\n";
trailer conf
}
;
value print_male_female_line male conf base v p =
let list =
loop [] v p.cle_index where rec loop list lev ip =
let list = [ip :: list] in
if lev <= 1 then list
else
match parents (aget conf base ip) with
[ Some ifam ->
let cpl = coi base ifam in
loop list (lev - 1) (if male then (father cpl) else (mother cpl))
| None -> list ]
in
let title _ =
Wserver.wprint "%s: %s"
(capitale
(transl_nth conf "male line/female line" (if male then 0 else 1)))
(person_text_no_html conf base p)
in
do {
header_no_page_title conf title;
tag "center" begin
list_iter_first
(fun first ip ->
let p = pget conf base ip in
do {
if not first then Wserver.wprint "|
\n" else ();
Wserver.wprint "%s\n%s
\n"
(referenced_person_title_text conf base p)
(Date.short_dates_text conf base p);
Wserver.wprint "%s" (Dag.image_txt conf base p)
})
list;
end;
trailer conf
}
;
value print_male_line = print_male_female_line True;
value print_female_line = print_male_female_line False;
(* Surnames list *)
value get_date_place conf base auth_for_all_anc p =
if auth_for_all_anc || authorized_age conf base p then
let d1 =
match Adef.od_of_codate p.birth with
[ None -> Adef.od_of_codate p.baptism
| x -> x ]
in
let d1 =
if d1 <> None then d1
else
List.fold_left
(fun d ifam ->
if d <> None then d
else Adef.od_of_codate (foi base ifam).marriage)
d1 (Array.to_list (uget conf base p.cle_index).family)
in
let d2 =
match p.death with
[ Death _ cd -> Some (Adef.date_of_cdate cd)
| _ ->
match p.burial with
[ Buried cod -> Adef.od_of_codate cod
| Cremated cod -> Adef.od_of_codate cod
| _ -> None ] ]
in
let auth_for_all_anc =
if auth_for_all_anc then True
else
match d2 with
[ Some (Dgreg d _)
when (time_gone_by d conf.today).year > conf.private_years ->
True
| _ -> False ]
in
let pl =
let pl = "" in
let pl = if pl <> "" then pl else sou base p.birth_place in
let pl = if pl <> "" then pl else sou base p.baptism_place in
let pl = if pl <> "" then pl else sou base p.death_place in
let pl = if pl <> "" then pl else sou base p.burial_place in
let pl =
if pl <> "" then pl
else
List.fold_left
(fun pl ifam ->
if pl <> "" then pl
else sou base (foi base ifam).marriage_place)
pl (Array.to_list (uget conf base p.cle_index).family)
in
pl
in
((d1, d2, pl), auth_for_all_anc)
else ((None, None, ""), False)
;
value merge_date_place conf base surn ((d1, d2, pl), auth) p =
let ((pd1, pd2, ppl), auth) = get_date_place conf base auth p in
let nd1 =
if pd1 <> None then pd1
else if p.surname = surn then if pd2 <> None then pd2 else d1
else None
in
let nd2 =
if p.surname = surn then
if d2 <> None then d2
else if d1 <> None then d1
else if pd1 <> None then pd2
else pd1
else if pd2 <> None then pd2
else if pd1 <> None then pd1
else d1
in
let pl = if ppl <> "" then ppl else if p.surname = surn then pl else "" in
((nd1, nd2, pl), auth)
;
value build_surnames_list conf base v p =
let ht = Hashtbl.create 701 in
let mark = Array.create base.data.persons.len 5 in
let auth = conf.wizard || conf.friend in
let add_surname sosa p surn dp =
let r =
try Hashtbl.find ht surn with
[ Not_found ->
let r = ref ((fst dp, p), []) in
do { Hashtbl.add ht surn r; r } ]
in
r.val := (fst r.val, [sosa :: snd r.val])
in
let rec loop lev sosa p surn dp =
if mark.(Adef.int_of_iper p.cle_index) = 0 then ()
else if lev = v then
if conf.hide_names && not (fast_auth_age conf p) then ()
else add_surname sosa p surn dp
else do {
mark.(Adef.int_of_iper p.cle_index) :=
mark.(Adef.int_of_iper p.cle_index) - 1;
match parents (aget conf base p.cle_index) with
[ Some ifam ->
let cpl = coi base ifam in
let fath = pget conf base (father cpl) in
let moth = pget conf base (mother cpl) in
do {
if surn <> fath.surname && surn <> moth.surname then
add_surname sosa p surn dp
else ();
let sosa = Num.twice sosa in
if not (is_hidden fath) then
let dp1 = merge_date_place conf base surn dp fath in
loop (lev + 1) sosa fath fath.surname dp1
else ();
let sosa = Num.inc sosa 1 in
if not (is_hidden moth) then
let dp2 = merge_date_place conf base surn dp moth in
loop (lev + 1) sosa moth moth.surname dp2
else ();
}
| None -> add_surname sosa p surn dp ]
}
in
do {
loop 0 Num.one p p.surname (get_date_place conf base auth p);
let list = ref [] in
Hashtbl.iter
(fun i dp ->
let surn = sou base i in
if surn <> "?" then list.val := [(surn, dp.val) :: list.val] else ())
ht;
Sort.list (fun (s1, _) (s2, _) -> Gutil.alphabetic s1 s2 <= 0) list.val
}
;
value print_surnames_list conf base v p =
let title h =
do {
if not h then Wserver.wprint "%s
" (person_text conf base p) else ();
Wserver.wprint "- %s -" (capitale (transl conf "surnames list"))
}
in
let list = build_surnames_list conf base v p in
let with_tab =
not (Util.browser_doesnt_have_tables conf) &&
p_getenv conf.env "tab" = Some "on"
in
do {
Util.header conf title;
Util.print_link_to_welcome conf True;
if with_tab then Wserver.wprint "
\n" else ();
Wserver.wprint "<%s>\n"
(if with_tab then "table border=1 width=90%%" else "ul");
List.iter
(fun (surn, (((d1, d2, pl), anc), sosa_list)) ->
let d2 = if d2 = d1 then None else d2 in
do {
Wserver.wprint "<%s>\n" (if with_tab then "tr>
let str =
str ^ ";s" ^ string_of_int n ^ "=" ^ Num.to_string sosa
in
(str, n + 1))
sosa_list ("", 1)
in
wprint_geneweb_link conf
("m=DAG;" ^ acces_n conf base "1" p ^ str)
(surname_end surn ^ surname_begin surn);
if conf.cancel_links then ()
else
let comm =
match List.length sosa_list with
[ 1 -> ""
| n -> " (" ^ string_of_int n ^ ")" ]
in
Wserver.wprint "%s" comm;
Wserver.wprint "%s %s%s" (if with_tab then " | " else ";") pl
(if with_tab then " | " else ";");
Wserver.wprint " ";
match d1 with
[ Some (Dgreg d _) -> Wserver.wprint "%d" d.year
| Some (Dtext s) -> Wserver.wprint "%s" s
| None -> () ];
if d1 <> None && d2 <> None then Wserver.wprint "-" else ();
match d2 with
[ Some (Dgreg d _) -> Wserver.wprint "%d" d.year
| Some (Dtext s) -> Wserver.wprint "%s" s
| None -> () ];
Wserver.wprint "\n"
})
list;
Wserver.wprint "%s>\n" (if with_tab then "table" else "ul");
Util.trailer conf
}
;
value print conf base p =
match (p_getenv conf.env "t", p_getint conf.env "v") with
[ (Some "L", Some v) -> display_ancestors_upto conf base v p
| (Some "N", Some v) ->
if p_getenv conf.env "only" = Some "on" then
display_ancestors_level conf base v p
else display_ancestors_with_numbers conf base v p
| (Some "G", Some v) ->
let ws =
match p_getenv conf.env "siblings" with
[ Some "on" -> True
| _ -> False ]
in
let wn =
match p_getenv conf.env "notes" with
[ Some "on" -> True
| _ -> False ]
in
display_ancestors_with_numbers_long conf base v ws wn p
| (Some "M", Some v) ->
let al =
match p_getenv conf.env "al" with
[ Some "on" -> True
| _ -> False ]
in
let si =
match p_getenv conf.env "ms" with
[ Some "on" -> True
| _ -> False ]
in
if al then print_missing_ancestors_alphabetically conf base v si p
else print_missing_ancestors conf base v si p
| (Some "T", Some v) -> print_tree conf base v p
| (Some "H", Some v) -> print_horizontally conf base v p
| (Some "A", Some v) -> print_male_line conf base v p
| (Some "C", Some v) -> print_female_line conf base v p
| (Some "D", x) ->
match (find_person_in_env conf base "1", x) with
[ (Some anc, _) -> print_ancestors_same_time_descendants conf base p anc
| (_, Some v) ->
print_ancestors_same_time_descendants conf base p
(pget conf base (Adef.iper_of_int v))
| _ -> display_ancestor_menu conf base p ]
| (Some "F", Some v) -> print_surnames_list conf base v p
| _ -> display_ancestor_menu conf base p ]
;
|