2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: files.ml,v 1.4 2004/09/08 09:54:28 rich Exp $
13 open Cocanwiki_template
15 let template = get_template "files.html"
17 let run r (q : cgi) (dbh : Dbi.connection) (hostid, _, _) _ =
18 let deleted = q#param_true "deleted" in
19 template#conditional "deleted" deleted;
22 "select id, name, name_deleted, octet_length (content)
24 where hostid = ? and " ^
25 (if not deleted then "name is not null"
26 else "name_deleted is not null") ^
28 let sth = dbh#prepare_cached sql in
29 sth#execute [`Int hostid];
34 let id, name, size, is_deleted =
36 | [`Int id; `String name; `Null; `Int size] ->
38 | [`Int id; `Null; `String name; `Int size] ->
40 | _ -> assert false in
41 [ "id", Template.VarString (string_of_int id);
42 "name", Template.VarString name;
43 "ksize", Template.VarString (string_of_int (size / 1024));
44 "is_deleted", Template.VarConditional is_deleted ]) in
46 template#table "files" table;
51 register_script ~restrict:[CanEdit] run