1 (* COCANWIKI - a wiki written in Objective CAML.
2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: edit_image_form.ml,v 1.1 2004/11/01 17:05:14 rich Exp $
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
28 open Cocanwiki_template
31 let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ =
32 let template = get_template dbh hostid "edit_image_form.html" in
34 let id = int_of_string (q#param "id") in
36 let sth = dbh#prepare_cached "select name, alt, coalesce (title, ''),
37 coalesce (longdesc, ''),
40 coalesce (tn_width, 0),
41 coalesce (tn_height, 0),
44 where hostid = ? and id = ?" in
45 sth#execute [`Int hostid; `Int id];
47 let name, alt, title, longdesc, clazz, mime_type, tn_width, tn_height,
49 match sth#fetch1 () with
50 [ `String name; `String alt; `String title; `String longdesc;
51 `String clazz; `String mime_type; `Int tn_width; `Int tn_height;
52 `Timestamp upload_date ] ->
53 name, alt, title, longdesc, clazz, mime_type, tn_width, tn_height,
55 | _ -> assert false in
57 template#set "id" (string_of_int id);
58 template#set "name" name;
59 template#set "alt" alt;
60 template#set "title" title;
61 template#set "longdesc" longdesc;
62 template#set "class" clazz;
63 template#set "mime_type" mime_type;
64 template#set "tn_width" (string_of_int tn_width);
65 template#set "tn_height" (string_of_int tn_height);
66 template#set "upload_date" (printable_date upload_date);
71 register_script ~restrict:[CanEdit] run