(* camlp4r ./pa_html.cmo *) (* $Id: birthday.ml,v 4.11 2004/12/14 09:30:10 ddr Exp $ *) (* Copyright (c) 1998-2005 INRIA *) open Def; open Config; open Util; open Gutil; type date_event = [ DeBirth | DeDeath of death_reason ]; value print_anniversary_day conf base dead_people liste = do { Wserver.wprint "\n"; } ; value gen_print conf base mois f_scan dead_people = let tab = Array.create 31 [] in let title _ = let lab = if dead_people then transl conf "anniversaries" else transl conf "birthdays" in Wserver.wprint "%s %s" (capitale lab) (nominative (transl_nth conf "(month)" (mois - 1))) in do { try while True do { let (p, txt_of) = f_scan () in if not dead_people then match (Adef.od_of_codate p.birth, p.death) with [ (Some (Dgreg d _), NotDead | DontKnowIfDead) -> if d.prec = Sure && d.day <> 0 && d.month <> 0 && d.month = mois && d.delta = 0 then if authorized_age conf base p then let j = d.day in tab.(pred j) := [(p, d.year, DeBirth, txt_of) :: tab.(pred j)] else () else () | _ -> () ] else match p.death with [ NotDead | DontKnowIfDead -> () | _ -> do { match Adef.od_of_codate p.birth with [ Some (Dgreg dt _) -> if dt.prec = Sure && dt.day <> 0 && dt.month <> 0 && dt.month = mois && dt.delta = 0 then if authorized_age conf base p then let j = dt.day in tab.(pred j) := [(p, dt.year, DeBirth, txt_of) :: tab.(pred j)] else () else () | _ -> () ]; match p.death with [ Death dr d -> match Adef.date_of_cdate d with [ Dgreg dt _ -> if dt.prec = Sure && dt.day <> 0 && dt.month <> 0 && dt.month = mois && dt.delta = 0 then if authorized_age conf base p then let j = dt.day in let a = dt.year in tab.(pred j) := [(p, a, DeDeath dr, txt_of) :: tab.(pred j)] else () else () | _ -> () ] | _ -> () ]; } ] } with [ Not_found -> () ]; header conf title; print_link_to_welcome conf True; Wserver.wprint "\n"; trailer conf; } ; value print_anniversary_list conf base dead_people dt liste = let a_ref = dt.year in do { Wserver.wprint "\n"; } ; value f_scan conf base = let i = ref (-1) in fun () -> do { incr i; if i.val < base.data.persons.len then (pget conf base (Adef.iper_of_int i.val), referenced_person_title_text) else raise Not_found } ; value print_birth conf base mois = gen_print conf base mois (f_scan conf base) False ; value print_dead conf base mois = gen_print conf base mois (f_scan conf base) True ; value print_birth_day conf base day_name verb wd dt list = do { Wserver.wprint "\n"; html_p conf; match list with [ [] -> Wserver.wprint "%s %s.\n" (capitale (transl conf "no birthday")) day_name | _ -> do { Wserver.wprint "%s,\n" (capitale day_name); Wserver.wprint "%s%s\n" (std_color conf ("" ^ transl_decline conf "on (weekday day month year)" (transl_nth conf "(week day)" wd ^ " " ^ Date.code_dmy conf dt) ^ "")) verb; Wserver.wprint "%s\n" (transl_a_of_b conf (transl conf "the birthday") "..."); print_anniversary_list conf base False dt list; } ] } ; value propose_months conf mode = tag "center" begin tag "form" "method=get action=\"%s\"" conf.command begin Util.hidden_env conf; mode (); tag "select" "name=v" begin for i = 1 to 12 do { Wserver.wprint "