Added the framework to allow us to populate standards parts of the
[cocanwiki.git] / scripts / edit_page_css_form.ml
1 (* COCANWIKI scripts.
2  * Written by Richard W.M. Jones <rich@merjis.com>.
3  * Copyright (C) 2004 Merjis Ltd.
4  * $Id: edit_page_css_form.ml,v 1.4 2004/09/08 15:46:53 rich Exp $
5  *)
6
7 open Apache
8 open Registry
9 open Cgi
10 open Printf
11
12 open Cocanwiki
13 open Cocanwiki_template
14
15 let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
16   let template = get_template dbh hostid "edit_page_css_form.html" in
17
18   let page = q#param "page" in
19
20   let sth = dbh#prepare_cached "select css from pages
21                                  where hostid = ? and url = ?" in
22   sth#execute [`Int hostid; `String page];
23
24   let css =
25     match sth#fetch1 () with
26       | [ `Null ] -> ""
27       | [ `String css ] -> css
28       | _ -> assert false in
29
30   template#set "page" page;
31   template#set "css" css;
32
33   q#template template
34
35 let () =
36   register_script ~restrict:[CanEdit] run