annotate lisp/w3/w3-forms.el @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents 376386a54a3c
children 9ee227acff29
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
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3 ;; Created: 1996/08/10 16:14:08
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4 ;; Version: 1.14
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)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; This file is not part of GNU Emacs, but the same permissions apply.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; FORMS processing for html 2.0/3.0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (require 'w3-draw))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (require 'widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (if (featurep 'mule) (fset 'string-width 'length))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; These are things in later versions of the widget package that I don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; have yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (defun widget-at (pt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (or (get-text-property pt 'button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (get-text-property pt 'field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; A form entry area is a vector
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; [ type name default-value value maxlength options widget]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; Where:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; type = symbol defining what type of form entry area it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; (ie: file, radio)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; name = the name of the form element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; default-value = the value this started out with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (defsubst w3-form-element-type (obj) (aref obj 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (defsubst w3-form-element-name (obj) (aref obj 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (defsubst w3-form-element-default-value (obj) (aref obj 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (defsubst w3-form-element-value (obj) (aref obj 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defsubst w3-form-element-size (obj) (aref obj 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (defsubst w3-form-element-maxlength (obj) (aref obj 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defsubst w3-form-element-options (obj) (aref obj 6))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defsubst w3-form-element-action (obj) (aref obj 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (defsubst w3-form-element-widget (obj) (aref obj 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defsubst w3-form-element-set-type (obj val) (aset obj 0 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defsubst w3-form-element-set-name (obj val) (aset obj 1 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defsubst w3-form-element-set-default-value (obj val) (aset obj 2 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defsubst w3-form-element-set-value (obj val) (aset obj 3 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defsubst w3-form-element-set-size (obj val) (aset obj 4 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (defsubst w3-form-element-set-maxlength (obj val) (aset obj 5 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (defsubst w3-form-element-set-options (obj val) (aset obj 6 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (defsubst w3-form-element-set-action (obj val) (aset obj 7 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defsubst w3-form-element-set-widget (obj val) (aset obj 8 val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; The main function - this adds a single widget to the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (defun w3-form-add-element (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (let* ((widget nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (inhibit-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (widget-creation-function nil)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
77 (action (cons (cons 'form-number (w3-get-state :formnum))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
78 (nth 6 args)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (node (assoc action w3-form-elements))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (name (or (nth 1 args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (if (memq (nth 0 args) '(submit reset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (symbol-name (nth 0 args)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (val (vector (nth 0 args) ; type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 name ; name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (nth 5 args) ; default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (nth 2 args) ; value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (nth 3 args) ; size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (nth 4 args) ; maxlength
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (nth 7 args) ; options
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 action
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 nil)) ; widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (setq widget-creation-function (or (get (car args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 'w3-widget-creation-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 'w3-form-default-widget-creator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 widget (funcall widget-creation-function val
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (cdr (nth 10 args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (if node
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (setcdr node (cons val (cdr node)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (setq w3-form-elements (cons (cons action (list val)) w3-form-elements)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (if (not widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (w3-form-element-set-widget val widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (widget-put widget 'w3-form-data val))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;; These properties tell the add-element function how to actually create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; each type of widget.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (put 'checkbox 'w3-widget-creation-function 'w3-form-create-checkbox)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (put 'multiline 'w3-widget-creation-function 'w3-form-create-multiline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (put 'radio 'w3-widget-creation-function 'w3-form-create-radio-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (put 'reset 'w3-widget-creation-function 'w3-form-create-submit-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (put 'submit 'w3-widget-creation-function 'w3-form-create-submit-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (put 'hidden 'w3-widget-creation-function 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (put 'file 'w3-widget-creation-function 'w3-form-create-file-browser)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (put 'option 'w3-widget-creation-function 'w3-form-create-option-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (put 'keygen 'w3-widget-creation-function 'w3-form-create-keygen-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (put 'button 'w3-widget-creation-function 'w3-form-create-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (put 'image 'w3-widget-creation-function 'w3-form-create-image)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defun w3-form-create-checkbox (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (widget-create 'checkbox :value-face face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (and (w3-form-element-default-value el) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defun w3-form-create-radio-button (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (let* ((name (w3-form-element-name el))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (formobj (cdr (assoc name w3-form-radio-elements)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (widget nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (if formobj
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (setq widget (w3-form-element-widget formobj))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
133 (widget-radio-add-item widget
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
134 (list 'item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
135 :format "%t"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
136 :tag ""
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
137 :value (w3-form-element-value el)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
138 (if (w3-form-element-default-value el)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
139 (widget-value-set widget (w3-form-element-value el)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 nil)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
141 (setq widget (widget-create 'radio
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
142 :value (w3-form-element-value el)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
143 (list 'item
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
144 :format "%t"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
145 :tag ""
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
146 :value (w3-form-element-value el)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 w3-form-radio-elements (cons (cons name el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 w3-form-radio-elements))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 widget)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (defun w3-form-create-button (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; This handles dealing with the bogus Netscape 'button' input type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;; that lots of places have been using to slap javascript shit onto
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (let ((val (w3-form-element-value el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (if (or (not val) (string= val ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (setq val "Push Me"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (widget-create 'push :notify 'ignore :button-face face val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (defun w3-form-create-image (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (let ((widget (widget-create 'push
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 :notify 'w3-form-submit/reset-callback
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 :value "Form-Image")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 widget))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (defun w3-form-create-submit-button (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (let ((val (w3-form-element-value el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (if (or (not val) (string= val ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (setq val (if (eq (w3-form-element-type el) 'submit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 "Submit"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 "Reset")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (widget-create 'push :notify 'w3-form-submit/reset-callback
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 :button-face face val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (defun w3-form-create-file-browser (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (widget-create 'file :value-face face :value (w3-form-element-value el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (defvar w3-form-valid-key-sizes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ("1024 (Premium)" . 1024)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ("896 (Regular)" . 896)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ("768 (Unleaded)" . 768)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ("512 (Low Grade)" . 512)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ("508 (Woos)" . 508)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ("256 (Test Grade)" . 256)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 "An assoc list of available key sizes and meaningful descriptions.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (defun w3-form-create-keygen-list (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (let ((tmp w3-form-valid-key-sizes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (longest 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (options nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (while tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (if (> (length (caar tmp)) longest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (setq longest (length (caar tmp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (setq options (cons (list 'choice-item :tag (caar tmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 :value (cdar tmp)) options)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 tmp (cdr tmp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (apply 'widget-create 'choice :value 1024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 :tag "Key Length"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 :size (1+ longest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 :value-face face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 options)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (defun w3-form-create-option-list (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (let ((widget (apply 'widget-create 'choice :value (w3-form-element-value el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 :tag "Choose"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
207 :format "%v"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 :size (w3-form-element-size el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 :value-face face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (list 'choice-item :format "%[%t%]"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
214 :tag (car x) :value (car x))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (reverse (w3-form-element-options el))))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
216 (widget-value-set widget (w3-form-element-value el))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 widget))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;(defun w3-form-create-multiline (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ; ;; FIX THIS! - need to padd out with newlines or something...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ; (widget-create 'field :value-face face (w3-form-element-value el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (defun w3-form-create-multiline (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (widget-create 'push :notify 'w3-do-text-entry "Multiline text area"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (defun w3-form-default-widget-creator (el face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (widget-create 'link
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 :notify 'w3-form-default-button-callback
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 :size (w3-form-element-size el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 :tag (w3-truncate-string (w3-form-element-value el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (w3-form-element-size el) ?_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 :value-face face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (w3-form-element-value el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (defun w3-form-default-button-callback (widget &rest ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (let* ((obj (widget-get widget 'w3-form-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (typ (w3-form-element-type obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (def (widget-value widget))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (val nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (case typ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (setq val (funcall url-passwd-entry-func "Password: " def))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (widget-put widget :tag (w3-truncate-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (make-string (length val) ?*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (w3-form-element-size obj) ?_)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (setq val (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (concat (capitalize (symbol-name typ)) ": ") def))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (widget-put widget :tag (w3-truncate-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 val (w3-form-element-size obj) ?_))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (widget-value-set widget val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (apply 'w3-form-possibly-submit widget ignore))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (defun w3-truncate-string (str len &optional pad)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 "Truncate string STR so that string-width of STR is not greater than LEN.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 If width of the truncated string is less than LEN, and if a character PAD is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 defined, add padding end of it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (if (featurep 'mule)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (let ((cl (string-to-char-list str)) (n 0) (sw 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (if (<= (string-width str) len) str
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (while (<= (setq sw (+ (char-width (nth n cl)) sw)) len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (setq n (1+ n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (string-match (make-string n ?.) str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (setq str (substring str 0 (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (if pad (concat str (make-string (- len (string-width str)) pad)) str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (concat (if (> (length str) len) (substring str 0 len) str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (if (or (null pad) (> (length str) len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (make-string (- len (length str)) pad)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (defun w3-form-possibly-submit (widget &rest ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (let* ((formobj (widget-get widget 'w3-form-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (ident (w3-form-element-action formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (widgets (w3-all-widgets ident))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (text-fields 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (text-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;; Gack. Netscape auto-submits forms of one text field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;; here we go through the list of widgets in this form and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;; determine which are not submit/reset/button inputs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;; If the # == 1, then submit the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (while widgets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (setq text-fields (+
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 text-fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (case (w3-form-element-type (car widgets))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ((submit reset image button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (setq text-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 widgets (cdr widgets)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (if (and (= text-fields 1) text-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (w3-submit-form ident))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (defun w3-form-submit/reset-callback (widget &rest ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (let* ((formobj (widget-get widget 'w3-form-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (w3-submit-button formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (case (w3-form-element-type formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (submit (w3-submit-form (w3-form-element-action formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (reset (w3-revert-form (w3-form-element-action formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (image (w3-submit-form (w3-form-element-action formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 "Impossible widget type %s triggered w3-form-submit/reset-callback"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (w3-form-element-type formobj))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (defun w3-do-text-entry (widget &rest ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (let* ((data (list widget (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (formobj (widget-get widget 'w3-form-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (buff (get-buffer-create (format "Form Entry: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (w3-form-element-name formobj)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (switch-to-buffer-other-window buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (indented-text-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (if (w3-form-element-value formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (insert (w3-form-element-value formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (setq w3-current-last-buffer data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (message "Press C-c C-c when finished with text entry.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (local-set-key "\C-c\C-c" 'w3-finish-text-entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (defun w3-finish-text-entry ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (if w3-current-last-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (let* ((widget (nth 0 w3-current-last-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (formobj (widget-get widget 'w3-form-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (buff (nth 1 w3-current-last-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (valu (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (inhibit-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (local-set-key "\C-c\C-c" 'undefined)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (delete-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (if (not (and buff (bufferp buff) (buffer-name buff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (message "Could not find the form buffer for this text!")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (switch-to-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (w3-form-element-set-value formobj valu)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (defsubst w3-all-widgets (actn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;; Return a list of data entry widgets in form number ACTN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (cdr-safe (assoc actn w3-form-elements)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (defun w3-revert-form (actn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (let* ((formobjs (w3-all-widgets actn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (inhibit-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 deft type widget formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (while formobjs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (setq formobj (car formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 widget (w3-form-element-widget formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 formobjs (cdr formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 deft (w3-form-element-default-value formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 type (w3-form-element-type formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (case type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ((submit reset image) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (radio
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ;; Ack - how!?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (checkbox
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (if deft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (widget-value-set widget t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (widget-value-set widget nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (widget-value-set widget deft))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (widget-value-set widget deft)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (defun w3-form-encode-helper (formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (submit-button-data w3-submit-button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 formobj result widget temp type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (while formobjs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (setq formobj (car formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 type (w3-form-element-type formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 widget (w3-form-element-widget formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 formobjs (cdr formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 temp (case type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (reset nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (image
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (if (and (eq submit-button-data formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (w3-form-element-name formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (setq result (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (concat (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ".x") "0")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (concat (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 ".y") "0"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (submit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (if (and (eq submit-button-data formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (w3-form-element-name formobj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (cons (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (w3-form-element-value formobj))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (radio
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
403 (let* ((radio-name (w3-form-element-name formobj))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
404 (radio-object (cdr-safe
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
405 (assoc radio-name
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
406 w3-form-radio-elements)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
407 (chosen-widget (and radio-object
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
408 (widget-radio-chosen
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
409 (w3-form-element-widget
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
410 radio-object)))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
411 (if (assoc radio-name result)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 nil
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
413 (cons radio-name (widget-value chosen-widget)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (checkbox
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (if (widget-value widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (cons (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (w3-form-element-value formobj))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (let ((dat nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (fname (widget-value widget)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (set-buffer (get-buffer-create " *w3-temp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (setq dat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (insert-file-contents-literally fname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (error (concat "Error accessing " fname))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (cons (w3-form-element-name formobj) dat))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (option
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (cons (w3-form-element-name formobj)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
431 (cdr-safe
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
432 (assoc (widget-value widget)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
433 (w3-form-element-options formobj)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (keygen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (cons (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (format "Should create a %d bit RSA key"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (widget-value widget))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ((multiline hidden)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (cons (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (w3-form-element-value formobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (cons (w3-form-element-name formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (widget-value widget)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (if temp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (setq result (cons temp result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (defun w3-form-encode-make-mime-part (id data separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (concat separator "\nContent-id: " id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 "\nContent-length: " (length data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 "\n\n" data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (defun w3-form-encode-multipart/x-www-form-data (formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ;; Create a multipart form submission.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ;; Returns a cons of two strings. Car is the separator used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ;; cdr is the body of the MIME message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (let ((separator "---some-separator-for-www-form-data"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (cons separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (lambda (formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (w3-form-encode-make-mime-part (car formobj) (cdr formobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 separator)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (w3-form-encode-helper formobjs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (fset 'w3-form-encode-multipart/form-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 'w3-form-encode-multipart/x-www-form-data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (fset 'w3-form-encode- 'w3-form-encode-application/x-www-form-urlencoded)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (defun w3-next-widget (pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (let* ((next (cond ((get-text-property pos 'button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (next-single-property-change pos 'button))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ((get-text-property pos 'field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (next-single-property-change pos 'field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (t pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (button (next-single-property-change next 'button))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (field (next-single-property-change next 'field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (setq next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ((and button field) (min button field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (button button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (field field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (and next
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (or (get-text-property next 'button)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (get-text-property next 'field)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (defun w3-form-encode (result &optional enctype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 "Create a string suitably encoded for a URL request."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (let ((func (intern (concat "w3-form-encode-" enctype))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
492 (if (fboundp func)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
493 (funcall func result)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
494 (w3-warn 'html (format "Bad encoding type for form data: %s" enctype))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
495 (w3-form-encode-application/x-www-form-urlencoded result))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (defun w3-form-encode-text/plain (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (let ((query ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (setq query
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (lambda (widget)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (let ((nam (car widget))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (val (cdr widget)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (if (string-match "\n" nam)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (setq nam (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (if (= x ?\n) "," (char-to-string x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 nam "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (concat nam " " val))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (w3-form-encode-helper result) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 query))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
515 (defun w3-form-encode-application/x-w3-wais (result)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
516 (cdr (car (w3-form-encode-helper result))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
517
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (defun w3-form-encode-application/x-gopher-query (result)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
519 (concat "\t" (cdr (car (w3-form-encode-helper result)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (defconst w3-xwfu-acceptable-chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 ?a ?b ?c ?d ?e ?f ?g ?h ?i ?j ?k ?l ?m ?n ?o ?p ?q ?r ?s ?t ?u ?v ?w ?x ?y ?z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K ?L ?M ?N ?O ?P ?Q ?R ?S ?T ?U ?V ?W ?X ?Y ?Z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
526 ?_ ;; BOGUS! This is for #!%#@!ing netscape compatibility
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
527 ?. ;; BOGUS! This is for #!%#@!ing netscape compatibility
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 "A list of characters that we do not have to escape in the media type
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
530 application/x-www-form-urlencoded")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (defun w3-form-encode-xwfu (chunk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 "Escape characters in a string for application/x-www-form-urlencoded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 Blasphemous crap because someone didn't think %20 was good enough for encoding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 spaces. Die Die Die."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (if (and (featurep 'mule) chunk)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
537 (setq chunk (if w3-running-xemacs
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
538 (decode-coding-string
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
539 chunk url-mule-retrieval-coding-system)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
540 (code-convert-string
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
541 chunk *internal* url-mule-retrieval-coding-system))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (lambda (char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ((= char ? ) "+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 ((memq char w3-xwfu-acceptable-chars) (char-to-string char))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
548 (t (upcase (format "%%%02x" char))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 chunk ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (defun w3-form-encode-application/x-www-form-urlencoded (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (lambda (data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (concat (w3-form-encode-xwfu (car data)) "="
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (w3-form-encode-xwfu (cdr data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (w3-form-encode-helper result) "&"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (defun w3-form-encode-application/x-w3-isindex (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (let* ((info (w3-form-encode-helper result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (query (cdr-safe (assoc "isindex" info))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (if query
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (url-hexify-string query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (defun w3-form-encode-application/gopher-ask-block (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (let ((query ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;;; gopher+ will expect all the checkboxes/etc, even if they are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 ;;; not turned on. Should still ignore RADIO boxes that are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 ;;; active though.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (while result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (if (and (not (and (string= (nth 2 (car result)) "RADIO")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (not (nth 6 (car result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (not (member (nth 2 (car result)) '("SUBMIT" "RESET"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (setq query (format "%s\r\n%s" query (nth 5 (car result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (setq result (cdr result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (concat query "\r\n.\r\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (defun w3-submit-form (ident)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;; Submit form entry fields matching ACTN as their action identifier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (let* ((result (w3-all-widgets ident))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (enctype (cdr (assq 'enctype ident)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (query (w3-form-encode result enctype))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (themeth (upcase (or (cdr (assq 'method ident)) "get")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (theurl (cdr (assq 'action ident))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (if (and (string= "GET" themeth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (string-match "\\([^\\?]*\\)\\?" theurl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (setq theurl (url-match theurl 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ((or (string= "POST" themeth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (string= "PUT" themeth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (if (consp query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (setq enctype (concat enctype "; separator=\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (substring (car query) 3 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 query (cdr query)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (let ((url-request-method themeth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (url-request-data query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (url-request-extra-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (cons (cons "Content-type" enctype) url-request-extra-headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (w3-fetch theurl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ((string= "GET" themeth)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
603 (let ((theurl (concat theurl (if (string-match "gopher" enctype)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
604 "" "?") query)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (w3-fetch theurl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (w3-warn 'html (format "Unknown submit method: %s" themeth))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (let ((theurl (concat theurl "?" query)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (w3-fetch theurl))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (provide 'w3-forms)