annotate lisp/w3/w3-forms.el @ 53:875393c1a535

Added tag r19-16-pre1 for changeset 461c7ba8286a
author cvs
date Mon, 13 Aug 2007 08:57:25 +0200
parents 8d2a9b52c682
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1 ;;; w3-forms.el --- Emacs-w3 forms parsing code for new display engine
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Author: wmperry
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
3 ;; Created: 1997/03/25 23:33:51
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
4 ;; Version: 1.81
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: faces, help, comm, data, languages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;;
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
11 ;;; This file is part of GNU Emacs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; You should have received a copy of the GNU General Public License
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
24 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
25 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
26 ;;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; FORMS processing for html 2.0/3.0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
32 (eval-when-compile
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
33 (require 'cl))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
34
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (eval-and-compile
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
36 (require 'w3-display)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
37 (require 'widget)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
38 (condition-case nil
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
39 (require 'wid-edit)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
40 (error (require 'widget-edit))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
42 (require 'w3-vars)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
43 (require 'mule-sysdp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
45 (defvar w3-form-use-old-style nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
46 "*Non-nil means use the old way of interacting for form fields.")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
47
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
48 (define-widget-keywords :emacspeak-help :w3-form-data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
49
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
50 (defvar w3-form-keymap
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
51 (let ((map (copy-keymap global-map))
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
52 (eol-loc (where-is-internal 'end-of-line global-map t)))
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
53 (if widget-keymap
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
54 (cl-map-keymap (function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
55 (lambda (key binding)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
56 (define-key map
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
57 (if (vectorp key) key (vector key))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
58 (case binding
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
59 (widget-backward 'w3-widget-backward)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
60 (widget-forward 'w3-widget-forward)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
61 (otherwise binding)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
62 widget-keymap))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
63 (define-key map [return] 'w3-form-maybe-submit-by-keypress)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
64 (define-key map "\r" 'w3-form-maybe-submit-by-keypress)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
65 (define-key map "\n" 'w3-form-maybe-submit-by-keypress)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
66 (define-key map "\t" 'w3-widget-forward)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
67 (define-key map "\C-k" 'widget-kill-line)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
68 (define-key map "\C-a" 'widget-beginning-of-line)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
69 (if eol-loc
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
70 (define-key map eol-loc 'widget-end-of-line))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
71 map))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
72
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; A form entry area is a vector
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
74 ;; [ type name default-value value maxlength options widget plist]
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; Where:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; type = symbol defining what type of form entry area it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; (ie: file, radio)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; name = the name of the form element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; default-value = the value this started out with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (defsubst w3-form-element-type (obj) (aref obj 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (defsubst w3-form-element-name (obj) (aref obj 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (defsubst w3-form-element-default-value (obj) (aref obj 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (defsubst w3-form-element-value (obj) (aref obj 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (defsubst w3-form-element-size (obj) (aref obj 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (defsubst w3-form-element-maxlength (obj) (aref obj 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (defsubst w3-form-element-options (obj) (aref obj 6))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defsubst w3-form-element-action (obj) (aref obj 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (defsubst w3-form-element-widget (obj) (aref obj 8))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
90 (defsubst w3-form-element-plist (obj) (aref obj 9))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (defsubst w3-form-element-set-type (obj val) (aset obj 0 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defsubst w3-form-element-set-name (obj val) (aset obj 1 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (defsubst w3-form-element-set-default-value (obj val) (aset obj 2 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (defsubst w3-form-element-set-value (obj val) (aset obj 3 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (defsubst w3-form-element-set-size (obj val) (aset obj 4 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (defsubst w3-form-element-set-maxlength (obj val) (aset obj 5 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (defsubst w3-form-element-set-options (obj val) (aset obj 6 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (defsubst w3-form-element-set-action (obj val) (aset obj 7 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defsubst w3-form-element-set-widget (obj val) (aset obj 8 val))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
101 (defsubst w3-form-element-set-plist (obj val) (aset obj 9 val))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
103 (defvar w3-form-valid-key-sizes
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
104 '(
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
105 ("1024 (Premium)" . 1024)
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
106 ("896 (Regular)" . 896)
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
107 ("768 (Unleaded)" . 768)
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
108 ("512 (Low Grade)" . 512)
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
109 ("508 (Woos)" . 508)
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
110 ("256 (Test Grade)" . 256)
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
111 )
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
112 "An assoc list of available key sizes and meaningful descriptions.")
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
113
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
114 (defun w3-form-determine-size (el size)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
115 (case (w3-form-element-type el)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
116 (checkbox 3)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
117 (radio 4)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
118 ((reset submit) (+ 2 (length (or (w3-form-element-value el)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
119 (symbol-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
120 (w3-form-element-type el))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
121 (multiline 21)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
122 (hidden nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
123 (file (or size 26))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
124 ((float password text int)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
125 (if w3-form-use-old-style
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
126 (or size 22)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
127 (or size 20)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
128 (image (+ 2 (length (or
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
129 (plist-get (w3-form-element-plist el) 'alt)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
130 "Form-Image"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
131 (option
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
132 (let ((options (copy-sequence (w3-form-element-options el))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
133 (or size
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
134 (length (caar (sort options
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
135 (function
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
136 (lambda (x y)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
137 (>= (length (car x))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
138 (length (car y)))))))))))
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
139 (keygen
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
140 (+ (length "Key Length: ")
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
141 (apply 'max
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
142 (mapcar (function (lambda (pair)
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
143 (length (car pair))))
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
144 w3-form-valid-key-sizes))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
145 (otherwise (or size 22))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
146
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
147 ;;###autoload
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
148 (defun w3-form-add-element (plist face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
149 (let* ((action (plist-get plist 'action))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
150 (el (vector (plist-get plist 'type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
151 (plist-get plist 'name)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
152 (plist-get plist 'default)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
153 (plist-get plist 'value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
154 (plist-get plist 'size)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
155 (plist-get plist 'maxlength)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
156 (plist-get plist 'options)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
157 action
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
158 nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
159 plist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
160 (size (w3-form-determine-size el (plist-get plist 'size)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
161 (node (assoc action w3-form-elements)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
162 (if (and (eq (plist-get plist 'type) 'hidden)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
163 (not (assq '*table-autolayout w3-display-open-element-stack)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
164 (if node
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
165 (setcdr node (cons el (cdr node)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
166 (setq w3-form-elements (cons (cons action (list el))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
167 w3-form-elements))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
168 (if size
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
169 (set-text-properties (point)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
170 (progn (insert-char ?T size) (point))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
171 (list 'w3-form-info (cons el face)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
172 'start-open t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
173 'end-open t
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
174 'rear-nonsticky t)))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
175
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
176 (defun w3-form-resurrect-widgets ()
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
177 (let ((st (point-min))
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
178 ;; FIXME! For some reason this loses on long lines right now.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
179 (widget-push-button-gui nil)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
180 info nd node action face)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
181 (while st
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
182 (if (setq info (get-text-property st 'w3-form-info))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
183 (progn
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
184 (setq nd (or (next-single-property-change st 'w3-form-info)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
185 (point-max))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
186 face (cdr info)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
187 info (car info)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
188 action (w3-form-element-action info)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
189 node (assoc action w3-form-elements))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
190 (goto-char st)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
191 (delete-region st nd)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
192 (if (not (w3-form-element-size info))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
193 (w3-form-element-set-size info 20))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
194 (if node
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
195 (setcdr node (cons info (cdr node)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
196 (setq w3-form-elements (cons (cons action (list info))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
197 w3-form-elements)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
198 (w3-form-add-element-internal info face)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
199 (setq st (next-single-property-change st 'w3-form-info)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
200 (setq st (next-single-property-change st 'w3-form-info))))))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
201
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
202 (defsubst w3-form-mark-widget (widget el)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
203 (let ((widgets (list widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
204 (children (widget-get widget :children))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
205 (parent (widget-get widget :parent)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
206 (w3-form-element-set-widget el widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
207 ;; Get _all_ the children associated with this widget
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
208 (while children
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
209 (setq widgets (cons (car children) widgets))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
210 (if (widget-get (car children) :children)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
211 (setq children (append children
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
212 (widget-get (car children) :children))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
213 (setq children (cdr children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
214 (while (widget-get widget :parent)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
215 (setq widget (widget-get widget :parent)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
216 widgets (cons widget widgets)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
217 (setq children (widget-get widget :buttons))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
218 ;; Special case for radio buttons
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
219 (while children
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
220 (setq widgets (cons (car children) widgets))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
221 (if (widget-get (car children) :children)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
222 (setq children (append children
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
223 (widget-get (car children) :children))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
224 (setq children (cdr children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
225 (while widgets
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
226 (setq widget (pop widgets))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
227 (widget-put widget :emacspeak-help 'w3-form-summarize-field)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
228 (widget-put widget :help-echo 'w3-form-summarize-field)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
229 (widget-put widget :w3-form-data el))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
230
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
231 (defun w3-form-add-element-internal (el face)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (let* ((widget nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (inhibit-read-only t)
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
235 (widget-creation-function nil))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
236 (setq widget-creation-function (or (get (w3-form-element-type el)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 'w3-widget-creation-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 'w3-form-default-widget-creator)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
239 widget (and (fboundp widget-creation-function)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
240 (funcall widget-creation-function el face)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (if (not widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 nil
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
243 (w3-form-mark-widget widget el))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;; These properties tell the add-element function how to actually create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;; each type of widget.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (put 'checkbox 'w3-widget-creation-function 'w3-form-create-checkbox)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (put 'multiline 'w3-widget-creation-function 'w3-form-create-multiline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (put 'radio 'w3-widget-creation-function 'w3-form-create-radio-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (put 'reset 'w3-widget-creation-function 'w3-form-create-submit-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (put 'submit 'w3-widget-creation-function 'w3-form-create-submit-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (put 'hidden 'w3-widget-creation-function 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (put 'file 'w3-widget-creation-function 'w3-form-create-file-browser)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (put 'option 'w3-widget-creation-function 'w3-form-create-option-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (put 'keygen 'w3-widget-creation-function 'w3-form-create-keygen-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (put 'button 'w3-widget-creation-function 'w3-form-create-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (put 'image 'w3-widget-creation-function 'w3-form-create-image)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
258 (put 'int 'w3-widget-creation-function 'w3-form-create-integer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
259 (put 'float 'w3-widget-creation-function 'w3-form-create-float)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
260 (put 'custom 'w3-widget-creation-function 'w3-form-create-custom)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
261 (put 'text 'w3-widget-creation-function 'w3-form-create-text)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
262 (put 'password 'w3-widget-creation-function 'w3-form-create-password)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
263
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
264 ;; Custom support.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
265 (defvar w3-custom-options nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
266 (make-variable-buffer-local 'w3-custom-options)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
267
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
268 (defun w3-form-create-custom (el face)
36
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 30
diff changeset
269 (condition-case ()
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 30
diff changeset
270 (require 'cus-edit)
c53a95d3c46d Import from CVS: tag r19-15b101
cvs
parents: 30
diff changeset
271 (error (require 'custom-edit)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
272 (let* ((name (w3-form-element-name el))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
273 (var-name (w3-form-element-value el))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
274 (type (plist-get (w3-form-element-plist el) 'custom-type))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
275 (widget (widget-create (cond ((string-equal type "variable")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
276 'custom-variable)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
277 ((string-equal type "face")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
278 'custom-face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
279 ((string-equal type "group")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
280 'custom-group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
281 (t 'item)) (intern var-name))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
282 (custom-magic-reset widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
283 (push widget w3-custom-options)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
284 widget))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (defun w3-form-create-checkbox (el face)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
287 (widget-create 'checkbox
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
288 :button-face face
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (and (w3-form-element-default-value el) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
291 (defun w3-form-radio-button-update (widget child event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
292 (widget-radio-action widget child event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
293 (w3-form-mark-widget widget (widget-get widget :w3-form-data)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
294
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (defun w3-form-create-radio-button (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (let* ((name (w3-form-element-name el))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
297 (action (w3-form-element-action el))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
298 (uniqid (cons name action))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
299 (formobj (cdr (assoc uniqid w3-form-radio-elements)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (widget nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (if formobj
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (setq widget (w3-form-element-widget formobj))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
305 (widget-radio-add-item widget
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
306 (list 'item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
307 :format "%t"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
308 :tag ""
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
309 :value (w3-form-element-value el)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
310 (w3-form-mark-widget widget el)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
311 (if (w3-form-element-default-value el)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
312 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
313 (widget-put widget 'w3-form-default-value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
314 (w3-form-element-value el))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
315 (widget-value-set widget (w3-form-element-value el))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 nil)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
317 (setq widget (widget-create
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
318 'radio-button-choice
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
319 :value (w3-form-element-value el)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
320 :action 'w3-form-radio-button-update
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
321 (list 'item
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
322 :format "%t"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
323 :tag ""
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
324 :value (w3-form-element-value el)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
325 w3-form-radio-elements (cons (cons uniqid el)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 w3-form-radio-elements))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
327 (widget-put widget 'w3-form-default-value (w3-form-element-value el))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 widget)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (defun w3-form-create-button (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; This handles dealing with the bogus Netscape 'button' input type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; that lots of places have been using to slap javascript shit onto
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (let ((val (w3-form-element-value el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (if (or (not val) (string= val ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (setq val "Push Me"))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
336 (widget-create 'push-button
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
337 :notify 'ignore
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
338 :button-face face
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
339 :value-face face
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
340 val)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (defun w3-form-create-image (el face)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
343 (widget-create 'push-button
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
344 :notify 'w3-form-submit/reset-callback
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
345 :value (or
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
346 (plist-get (w3-form-element-plist el) 'alt)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
347 (w3-form-element-value el)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
348 "Form-Image")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (defun w3-form-create-submit-button (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (let ((val (w3-form-element-value el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (if (or (not val) (string= val ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (setq val (if (eq (w3-form-element-type el) 'submit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 "Submit"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 "Reset")))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
356 (widget-create 'push-button
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
357 :notify 'w3-form-submit/reset-callback
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 :button-face face val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (defun w3-form-create-file-browser (el face)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
361 (widget-create 'file
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
362 :button-face face
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
363 :value-face face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
364 :size (w3-form-element-size el)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
365 :must-match t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
366 :value (w3-form-element-value el)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (defun w3-form-create-keygen-list (el face)
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
369 (let* ((size (apply 'max (mapcar (function (lambda (pair) (length (car pair))))
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
370 w3-form-valid-key-sizes)))
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
371 (options (mapcar (function (lambda (pair)
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
372 (list 'choice-item
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
373 :format "%[%t%]"
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
374 :menu-tag-get `(lambda (zed) ,(car pair))
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
375 :tag (mule-truncate-string (car pair) size ? )
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
376 :value (cdr pair))))
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
377 w3-form-valid-key-sizes)))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
378 (apply 'widget-create 'menu-choice
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
379 :value 1024
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
380 :ignore-case t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 :tag "Key Length"
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
382 :size size
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
383 :button-face face
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 :value-face face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 options)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (defun w3-form-create-option-list (el face)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
388 (let* ((size (w3-form-determine-size el nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
389 (widget (apply 'widget-create 'menu-choice
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
390 :value (w3-form-element-value el)
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
391 :ignore-case t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 :tag "Choose"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
393 :format "%v"
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
394 :size size
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 :value-face face
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
396 :button-face face
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (list 'choice-item :format "%[%t%]"
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
401 :emacspeak-help 'w3-form-summarize-field
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 20
diff changeset
402 :menu-tag-get (` (lambda (zed) (, (car x))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
403 :tag (mule-truncate-string (car x) size ? )
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
404 :button-face face
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
405 :value-face face
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
406 :value (car x))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
407 (w3-form-element-options el)))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
408 (widget-value-set widget (w3-form-element-value el))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 widget))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 ;(defun w3-form-create-multiline (el face)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
412 ; (widget-create 'text :value-face face (w3-form-element-value el)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (defun w3-form-create-multiline (el face)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
415 (widget-create 'push-button
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
416 :notify 'w3-do-text-entry
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
417 "Multiline text area"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
418
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
419 (defun w3-form-create-integer (el face)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
420 (if w3-form-use-old-style
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
421 (w3-form-default-widget-creator el face)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
422 (widget-create 'integer
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
423 :size (w3-form-element-size el)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
424 :value-face face
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
425 :tag ""
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
426 :format "%v"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
427 :keymap w3-form-keymap
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
428 :w3-form-data el
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
429 (w3-form-element-value el))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
430
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
431 (defun w3-form-create-float (el face)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
432 (if w3-form-use-old-style
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
433 (w3-form-default-widget-creator el face)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
434 (widget-create 'number
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
435 :size (w3-form-element-size el)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
436 :value-face face
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
437 :format "%v"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
438 :tag ""
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
439 :keymap w3-form-keymap
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
440 :w3-form-data el
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
441 (w3-form-element-value el))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
442
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
443 (defun w3-form-create-text (el face)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
444 (if w3-form-use-old-style
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
445 (w3-form-default-widget-creator el face)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
446 (widget-create 'editable-field
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
447 :keymap w3-form-keymap
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
448 :size (w3-form-element-size el)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
449 :value-face face
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
450 :w3-form-data el
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
451 (w3-form-element-value el))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
452
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
453 (defun w3-form-create-password (el face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
454 ;; *sigh* This will fail under XEmacs, but I can yell at them about
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
455 ;; upgrading separately for the release of 19.15 and 20.0
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
456 (if w3-form-use-old-style
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
457 (w3-form-default-widget-creator el face)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
458 (widget-create 'editable-field
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
459 :secret ?*
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
460 :keymap w3-form-keymap
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
461 :size (w3-form-element-size el)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
462 :value-face face
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
463 :button-face face
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
464 :w3-form-data el
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
465 (w3-form-element-value el))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (defun w3-form-default-widget-creator (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (widget-create 'link
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 :notify 'w3-form-default-button-callback
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
470 :value-to-internal 'w3-form-default-button-update
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 :size (w3-form-element-size el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 :value-face face
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
473 :button-face face
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
474 :w3-form-data el
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (w3-form-element-value el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
477 (defun w3-form-default-button-update (w v)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
478 (let ((info (widget-get w :w3-form-data)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
479 (widget-put w :tag
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
480 (if info
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
481 (mule-truncate-string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
482 (if (eq 'password (w3-form-element-type info))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
483 (make-string (length v) ?*)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
484 v)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
485 (w3-form-element-size info) ? )))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
486 v))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
487
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (defun w3-form-default-button-callback (widget &rest ignore)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
489 (let* ((obj (widget-get widget :w3-form-data))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (typ (w3-form-element-type obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (def (widget-value widget))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (val nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (case typ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (password
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
496 (setq val (funcall url-passwd-entry-func "Password: " def)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (setq val (read-string
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
499 (concat (capitalize (symbol-name typ)) ": ") def))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (widget-value-set widget val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (apply 'w3-form-possibly-submit widget ignore))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
502
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
503 ;; These properties tell the help-echo function how to summarize each
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
504 ;; type of widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
505 (put 'checkbox 'w3-summarize-function 'w3-form-summarize-checkbox)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
506 (put 'multiline 'w3-summarize-function 'w3-form-summarize-multiline)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
507 (put 'radio 'w3-summarize-function 'w3-form-summarize-radio-button)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
508 (put 'reset 'w3-summarize-function 'w3-form-summarize-submit-button)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
509 (put 'submit 'w3-summarize-function 'w3-form-summarize-submit-button)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
510 (put 'button 'w3-summarize-function 'w3-form-summarize-submit-button)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
511 (put 'file 'w3-summarize-function 'w3-form-summarize-file-browser)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
512 (put 'option 'w3-summarize-function 'w3-form-summarize-option-list)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
513 (put 'keygen 'w3-summarize-function 'w3-form-summarize-keygen-list)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
514 (put 'image 'w3-summarize-function 'w3-form-summarize-image)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 22
diff changeset
515 (put 'password 'w3-summarize-function 'w3-form-summarize-password)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
516 (put 'hidden 'w3-summarize-function 'ignore)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
517
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
518 (defun w3-form-summarize-field (widget &rest ignore)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
519 "Sumarize a widget that should be a W3 form entry area.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
520 This can be used as the :help-echo property of all w3 form entry widgets."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
521 (let ((info nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
522 (func nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
523 (msg nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
524 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
525 (setq info (widget-get widget :w3-form-data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
526 (if info
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
527 nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
528 (while (widget-get widget :parent)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
529 (setq widget (widget-get widget :parent)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
530 (setq info (widget-get widget :w3-form-data)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
531 (if (not info)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
532 (signal 'wrong-type-argument (list 'w3-form-widget widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
533 (setq func (or (get (w3-form-element-type info) 'w3-summarize-function)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
534 'w3-form-summarize-default)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
535 msg (and (fboundp func) (funcall func info widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
536 ;; FIXME! This should be removed once emacspeak is updated to
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
537 ;; more closely follow the widget-y way of just returning the string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
538 ;; instead of having the underlying :help-echo or :emacspeak-help
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
539 ;; implementation do it.
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 22
diff changeset
540 (and msg (message "%s" msg))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
541
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
542 (defsubst w3-form-field-label (data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
543 ;;; FIXXX!!! Need to reimplement using the new forms implementation!
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
544 (declare (special w3-form-labels))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
545 (cdr-safe
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
546 (assoc (or (plist-get (w3-form-element-plist data) 'id)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
547 (plist-get (w3-form-element-plist data) 'label))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
548 w3-form-labels)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
549
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
550 (defun w3-form-summarize-default (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
551 (let ((label (w3-form-field-label data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
552 (name (w3-form-element-name data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
553 (value (widget-value (w3-form-element-widget data))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
554 (format "Text field %s set to: %s" (or label (concat "called " name))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
555 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
556
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 22
diff changeset
557 (defun w3-form-summarize-password (data widget)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 22
diff changeset
558 (let ((label (w3-form-field-label data))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 22
diff changeset
559 (name (w3-form-element-name data)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 22
diff changeset
560 (format "Password field %s is a secret. Shhh."
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 22
diff changeset
561 (or label (concat "called " name)))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 22
diff changeset
562
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
563 (defun w3-form-summarize-multiline (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
564 (let ((name (w3-form-element-name data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
565 (label (w3-form-field-label data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
566 (value (w3-form-element-value data)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
567 (format "Multiline text input %s set to: %s"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
568 (or label (concat "called " name))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
569 value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
570
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
571 (defun w3-form-summarize-checkbox (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
572 (let ((name (w3-form-element-name data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
573 (label (w3-form-field-label data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
574 (checked (widget-value (w3-form-element-widget data))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
575 (format "Checkbox %s is %s" (or label name) (if checked "on" "off"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
576
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
577 (defun w3-form-summarize-option-list (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
578 (let ((name (w3-form-element-name data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
579 (label (w3-form-field-label data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
580 (default (w3-form-element-default-value data)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
581 (format "Option list (%s) set to: %s" (or label name)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
582 (widget-value (w3-form-element-widget data)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
583
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
584 (defun w3-form-summarize-image (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
585 (let ((name (w3-form-element-name data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
586 (label (w3-form-field-label data)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
587 (concat "Image entry " (or label (concat "called " name)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
588
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
589 (defun w3-form-summarize-submit-button (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
590 (let* ((type (w3-form-element-type data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
591 (label (w3-form-field-label data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
592 (button-text (widget-value (w3-form-element-widget data)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
593 (type-desc (case type
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
594 (submit "Submit Form")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
595 (reset "Reset Form")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
596 (button "A Button"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
597 (format "%s: %s" type-desc (or label button-text ""))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
598
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
599 (defun w3-form-summarize-radio-button (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
600 (let ((name (w3-form-element-name data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
601 (label (w3-form-field-label data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
602 (cur-value (widget-value (w3-form-element-widget data)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
603 (this-value (widget-value (widget-get-sibling widget))))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 22
diff changeset
604 (if (equal this-value cur-value)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 22
diff changeset
605 (format "Radio group %s has %s pressed"
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 22
diff changeset
606 (or label name) this-value)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 22
diff changeset
607 (format "Press this to change radio group %s from %s to %s" (or label name) cur-value
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 22
diff changeset
608 this-value))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
609
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
610 (defun w3-form-summarize-file-browser (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
611 (let ((name (w3-form-element-name data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
612 (label (w3-form-field-label data))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
613 (file (widget-value (w3-form-element-widget data))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
614 (format "File entry %s pointing to: %s" (or label name) (or file
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
615 "[nothing]"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
616
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
617 (defun w3-form-summarize-keygen-list (data widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
618 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
619
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
620
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
621 (defun w3-form-maybe-submit-by-keypress ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
622 (interactive)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
623 (let ((widget (widget-at (point))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
624 (if widget
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
625 (w3-form-possibly-submit widget))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (defun w3-form-possibly-submit (widget &rest ignore)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
628 (let* ((formobj (widget-get widget :w3-form-data))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (ident (w3-form-element-action formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (widgets (w3-all-widgets ident))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (text-fields 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (text-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;; Gack. Netscape auto-submits forms of one text field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ;; here we go through the list of widgets in this form and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 ;; determine which are not submit/reset/button inputs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ;; If the # == 1, then submit the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (while widgets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (setq text-fields (+
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 text-fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (case (w3-form-element-type (car widgets))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 ((submit reset image button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (setq text-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 widgets (cdr widgets)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (if (and (= text-fields 1) text-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (w3-submit-form ident))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (defun w3-form-submit/reset-callback (widget &rest ignore)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
655 (let* ((formobj (widget-get widget :w3-form-data))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (w3-submit-button formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (case (w3-form-element-type formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (submit (w3-submit-form (w3-form-element-action formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (reset (w3-revert-form (w3-form-element-action formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (image (w3-submit-form (w3-form-element-action formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 "Impossible widget type %s triggered w3-form-submit/reset-callback"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (w3-form-element-type formobj))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (defun w3-do-text-entry (widget &rest ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (let* ((data (list widget (current-buffer)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
668 (formobj (widget-get widget :w3-form-data))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (buff (get-buffer-create (format "Form Entry: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (w3-form-element-name formobj)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (switch-to-buffer-other-window buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (indented-text-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (if (w3-form-element-value formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (insert (w3-form-element-value formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (setq w3-current-last-buffer data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (message "Press C-c C-c when finished with text entry.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (local-set-key "\C-c\C-c" 'w3-finish-text-entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (defun w3-finish-text-entry ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (if w3-current-last-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (let* ((widget (nth 0 w3-current-last-buffer))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
684 (formobj (widget-get widget :w3-form-data))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (buff (nth 1 w3-current-last-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (valu (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (inhibit-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (local-set-key "\C-c\C-c" 'undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (delete-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (if (not (and buff (bufferp buff) (buffer-name buff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (message "Could not find the form buffer for this text!")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (switch-to-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (w3-form-element-set-value formobj valu)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (defsubst w3-all-widgets (actn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 ;; Return a list of data entry widgets in form number ACTN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (cdr-safe (assoc actn w3-form-elements)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (defun w3-revert-form (actn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (let* ((formobjs (w3-all-widgets actn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (inhibit-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 deft type widget formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (while formobjs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (setq formobj (car formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 widget (w3-form-element-widget formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 formobjs (cdr formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 deft (w3-form-element-default-value formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 type (w3-form-element-type formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (case type
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 16
diff changeset
715 ((submit reset image hidden) nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (radio
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
717 (setq deft (widget-get widget 'w3-form-default-value))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
718 (if (and widget deft)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
719 (widget-value-set widget deft)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (checkbox
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (if deft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (widget-value-set widget t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (widget-value-set widget nil)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
724 (multiline
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
725 (w3-form-element-set-value formobj (w3-form-element-default-value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
726 formobj)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (widget-value-set widget deft))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (otherwise
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
730 (widget-value-set widget deft))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
731 (widget-setup))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (defun w3-form-encode-helper (formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (submit-button-data w3-submit-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 formobj result widget temp type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (while formobjs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (setq formobj (car formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 type (w3-form-element-type formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 widget (w3-form-element-widget formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 formobjs (cdr formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 temp (case type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (reset nil)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
744 (button nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (image
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (if (and (eq submit-button-data formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (w3-form-element-name formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (setq result (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (concat (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 ".x") "0")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (concat (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 ".y") "0"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (submit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (if (and (eq submit-button-data formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (w3-form-element-name formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (cons (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (w3-form-element-value formobj))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (radio
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
764 (let* ((radio-name (w3-form-element-name formobj))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
765 (radio-object (cdr-safe
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
766 (assoc
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
767 (cons
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
768 radio-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
769 (w3-form-element-action formobj))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
770 w3-form-radio-elements)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
771 (chosen-widget (and radio-object
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
772 (widget-radio-chosen
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
773 (w3-form-element-widget
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
774 radio-object)))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
775 (if (assoc radio-name result)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 nil
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
777 (cons radio-name (widget-value chosen-widget)))))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
778 ((int float)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
779 (cons (w3-form-element-name formobj)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
780 (number-to-string (or (condition-case ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
781 (widget-value widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
782 (error nil)) 0))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (checkbox
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (if (widget-value widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (cons (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (w3-form-element-value formobj))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (let ((dat nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (fname (widget-value widget)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (set-buffer (get-buffer-create " *w3-temp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (setq dat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (insert-file-contents-literally fname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (error (concat "Error accessing " fname))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (cons (w3-form-element-name formobj) dat))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (option
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (cons (w3-form-element-name formobj)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
800 (cdr-safe
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
801 (assoc (widget-value widget)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
802 (w3-form-element-options formobj)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (keygen
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
804 (condition-case ()
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
805 (require 'ssl)
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
806 (error (error "Not configured for SSL, please read the info pages.")))
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
807 (if (fboundp 'ssl-req-user-cert) nil
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
808 (error "This version of SSL isn't capable of requesting certificates."))
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
809 (let ((challenge (plist-get (w3-form-element-plist formobj) 'challenge))
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
810 (size (widget-value widget)))
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
811 (cons (w3-form-element-name formobj)
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 38
diff changeset
812 (ssl-req-user-cert size challenge))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 ((multiline hidden)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (cons (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (w3-form-element-value formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (cons (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (widget-value widget)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (if temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (setq result (cons temp result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (defun w3-form-encode-make-mime-part (id data separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (concat separator "\nContent-id: " id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 "\nContent-length: " (length data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 "\n\n" data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (defun w3-form-encode-multipart/x-www-form-data (formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ;; Create a multipart form submission.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 ;; Returns a cons of two strings. Car is the separator used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 ;; cdr is the body of the MIME message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (let ((separator "---some-separator-for-www-form-data"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (cons separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (lambda (formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (w3-form-encode-make-mime-part (car formobj) (cdr formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 separator)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (w3-form-encode-helper formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (fset 'w3-form-encode-multipart/form-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 'w3-form-encode-multipart/x-www-form-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (fset 'w3-form-encode- 'w3-form-encode-application/x-www-form-urlencoded)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (defun w3-next-widget (pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (let* ((next (cond ((get-text-property pos 'button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (next-single-property-change pos 'button))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ((get-text-property pos 'field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (next-single-property-change pos 'field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (t pos)))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
852 (button (and next (next-single-property-change next 'button)))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
853 (field (and next (next-single-property-change next 'field))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (setq next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 ((and button field) (min button field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (button button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (field field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (and next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (or (get-text-property next 'button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (get-text-property next 'field)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (defun w3-form-encode (result &optional enctype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 "Create a string suitably encoded for a URL request."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (let ((func (intern (concat "w3-form-encode-" enctype))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
867 (if (fboundp func)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
868 (funcall func result)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
869 (w3-warn 'html (format "Bad encoding type for form data: %s" enctype))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
870 (w3-form-encode-application/x-www-form-urlencoded result))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (defun w3-form-encode-text/plain (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (let ((query ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (setq query
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (lambda (widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (let ((nam (car widget))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (val (cdr widget)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (if (string-match "\n" nam)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (setq nam (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (if (= x ?\n) "," (char-to-string x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 nam "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (concat nam " " val))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (w3-form-encode-helper result) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 query))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (defun w3-form-encode-application/x-gopher-query (result)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
891 (concat "\t" (cdr (car (w3-form-encode-helper result)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (defun w3-form-encode-xwfu (chunk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 "Escape characters in a string for application/x-www-form-urlencoded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 Blasphemous crap because someone didn't think %20 was good enough for encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 spaces. Die Die Die."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (lambda (char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 ((= char ? ) "+")
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
902 ((memq char url-unreserved-chars) (char-to-string char))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
903 (t (upcase (format "%%%02x" char))))))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
904 (mule-encode-string chunk) ""))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (defun w3-form-encode-application/x-www-form-urlencoded (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (lambda (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (concat (w3-form-encode-xwfu (car data)) "="
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (w3-form-encode-xwfu (cdr data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (w3-form-encode-helper result) "&"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (defun w3-form-encode-application/x-w3-isindex (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (let* ((info (w3-form-encode-helper result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (query (cdr-safe (assoc "isindex" info))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (if query
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (url-hexify-string query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (defun w3-form-encode-application/gopher-ask-block (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (let ((query ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 ;;; gopher+ will expect all the checkboxes/etc, even if they are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 ;;; not turned on. Should still ignore RADIO boxes that are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ;;; active though.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (while result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (if (and (not (and (string= (nth 2 (car result)) "RADIO")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (not (nth 6 (car result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (not (member (nth 2 (car result)) '("SUBMIT" "RESET"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (setq query (format "%s\r\n%s" query (nth 5 (car result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (setq result (cdr result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (concat query "\r\n.\r\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (defun w3-submit-form (ident)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 ;; Submit form entry fields matching ACTN as their action identifier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (let* ((result (w3-all-widgets ident))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
937 (enctype (or (cdr (assq 'enctype ident))
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
938 "application/x-www-form-urlencoded"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (query (w3-form-encode result enctype))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (themeth (upcase (or (cdr (assq 'method ident)) "get")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (theurl (cdr (assq 'action ident))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (if (and (string= "GET" themeth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (string-match "\\([^\\?]*\\)\\?" theurl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (setq theurl (url-match theurl 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 ((or (string= "POST" themeth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (string= "PUT" themeth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (if (consp query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (setq enctype (concat enctype "; separator=\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (substring (car query) 3 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 query (cdr query)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (let ((url-request-method themeth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (url-request-data query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (url-request-extra-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (cons (cons "Content-type" enctype) url-request-extra-headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (w3-fetch theurl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 ((string= "GET" themeth)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
959 (let ((theurl (concat theurl (if (string-match "gopher" enctype)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
960 "" "?") query)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (w3-fetch theurl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (w3-warn 'html (format "Unknown submit method: %s" themeth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (let ((theurl (concat theurl "?" query)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (w3-fetch theurl))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (provide 'w3-forms)