4 * XHTML 1.1 Forms module, defines all form-related elements found in HTML 4.
6 class HTMLPurifier_HTMLModule_Forms
extends HTMLPurifier_HTMLModule
11 public $name = 'Forms';
21 public $content_sets = array(
23 'Inline' => 'Formctrl',
27 * @param HTMLPurifier_Config $config
29 public function setup($config)
31 $form = $this->addElement(
34 'Required: Heading | List | Block | fieldset',
37 'accept' => 'ContentTypes',
38 'accept-charset' => 'Charsets',
40 'method' => 'Enum#get,post',
41 // really ContentType, but these two are the only ones used today
42 'enctype' => 'Enum#application/x-www-form-urlencoded,multipart/form-data',
45 $form->excludes
= array('form' => true);
47 $input = $this->addElement(
53 'accept' => 'ContentTypes',
54 'accesskey' => 'Character',
56 'checked' => 'Bool#checked',
57 'disabled' => 'Bool#disabled',
58 'maxlength' => 'Number',
60 'readonly' => 'Bool#readonly',
62 'src' => 'URI#embedded',
63 'tabindex' => 'Number',
64 'type' => 'Enum#text,password,checkbox,button,radio,submit,reset,file,hidden,image',
68 $input->attr_transform_post
[] = new HTMLPurifier_AttrTransform_Input();
73 'Required: optgroup | option',
76 'disabled' => 'Bool#disabled',
77 'multiple' => 'Bool#multiple',
80 'tabindex' => 'Number',
90 'disabled' => 'Bool#disabled',
92 'selected' => 'Bool#selected',
96 // It's illegal for there to be more than one selected, but not
97 // be multiple. Also, no selected means undefined behavior. This might
98 // be difficult to implement; perhaps an injector, or a context variable.
100 $textarea = $this->addElement(
106 'accesskey' => 'Character',
108 'disabled' => 'Bool#disabled',
110 'readonly' => 'Bool#readonly',
112 'tabindex' => 'Number',
115 $textarea->attr_transform_pre
[] = new HTMLPurifier_AttrTransform_Textarea();
117 $button = $this->addElement(
120 'Optional: #PCDATA | Heading | List | Block | Inline',
123 'accesskey' => 'Character',
124 'disabled' => 'Bool#disabled',
126 'tabindex' => 'Number',
127 'type' => 'Enum#button,submit,reset',
132 // For exclusions, ideally we'd specify content sets, not literal elements
133 $button->excludes
= $this->makeLookup(
140 'button', // Formctrl
141 'a', // as per HTML 4.01 spec, this is omitted by modularization
143 'iframe' // legacy items
146 // Extra exclusion: img usemap="" is not permitted within this element.
147 // We'll omit this for now, since we don't have any good way of
148 // indicating it yet.
150 // This is HIGHLY user-unfriendly; we need a custom child-def for this
151 $this->addElement('fieldset', 'Form', 'Custom: (#WS?,legend,(Flow|#PCDATA)*)', 'Common');
153 $label = $this->addElement(
156 'Optional: #PCDATA | Inline',
159 'accesskey' => 'Character',
160 // 'for' => 'IDREF', // IDREF not implemented, cannot allow
163 $label->excludes
= array('label' => true);
168 'Optional: #PCDATA | Inline',
171 'accesskey' => 'Character',
181 'disabled' => 'Bool#disabled',
185 // Don't forget an injector for <isindex>. This one's a little complex
186 // because it maps to multiple elements.
190 // vim: et sw=4 sts=4