(* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. * $Id: edit_host_settings_form.ml,v 1.7 2006/03/27 18:09:46 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. *) open Apache open Registry open Cgi open Printf open Cocanwiki open Cocanwiki_template let run r (q : cgi) dbh hostid _ _ = let template = get_template dbh hostid "edit_host_settings_form.html" in (* List of themes. *) let rows = PGSQL(dbh) "select theme_css, name, description from themes order by 2, 1" in let themes = List.map (fun (theme_css, name, description) -> theme_css, (name, description)) rows in (* Get lots of host-specific stuff from the database. *) let rows = PGSQL(dbh) "select canonical_hostname, edit_anon, create_account_anon, theme_css, feedback_email, mailing_list, search_box, navigation, view_anon, brand, brand_tagline, brand_description from hosts where id = $hostid" in let canonical_hostname, edit_anon, create_account_anon, theme_css, feedback_email, mailing_list, search_box, navigation, view_anon, brand, brand_tagline, brand_description = match rows with | [canonical_hostname, edit_anon, create_account_anon, theme_css, feedback_email, mailing_list, search_box, navigation, view_anon, brand, brand_tagline, brand_description] -> let theme_css = match theme_css with Some s -> s | None -> "" in let feedback_email = match feedback_email with Some s -> s | None -> "" in let brand = match brand with Some s -> s | None -> "" in let brand_tagline = match brand_tagline with Some s -> s | None -> "" in let brand_description = match brand_description with Some s -> s | None -> "" in canonical_hostname, edit_anon, create_account_anon, theme_css, feedback_email, mailing_list, search_box, navigation, view_anon, brand, brand_tagline, brand_description | _ -> assert false in template#set "canonical_hostname" canonical_hostname; template#conditional "edit_anon" edit_anon; template#conditional "create_account_anon" create_account_anon; template#set "feedback_email" feedback_email; template#conditional "mailing_list" mailing_list; template#conditional "search_box" search_box; template#conditional "navigation" navigation; template#conditional "view_anon" view_anon; template#set "brand" brand; template#set "brand_tagline" brand_tagline; template#set "brand_description" brand_description; (* Themes table. *) let table = List.map (fun (css, (name, description)) -> let selected = css = theme_css in [ "theme_css", Template.VarString css; "name", Template.VarString name; "description", Template.VarString description; "selected", Template.VarConditional selected ]) themes in template#table "themes" table; q#template template let () = register_script ~restrict:[CanManageSite] run