]> git.wh0rd.org - tt-rss.git/blame - lib/htmlpurifier/library/HTMLPurifier/HTMLModule/Forms.php
remove Archived articles from Uncategorized view
[tt-rss.git] / lib / htmlpurifier / library / HTMLPurifier / HTMLModule / Forms.php
CommitLineData
f45a286b
AD
1<?php
2
3/**
4 * XHTML 1.1 Forms module, defines all form-related elements found in HTML 4.
5 */
6class HTMLPurifier_HTMLModule_Forms extends HTMLPurifier_HTMLModule
7{
8 public $name = 'Forms';
9 public $safe = false;
10
11 public $content_sets = array(
12 'Block' => 'Form',
13 'Inline' => 'Formctrl',
14 );
15
16 public function setup($config) {
17 $form = $this->addElement('form', 'Form',
18 'Required: Heading | List | Block | fieldset', 'Common', array(
19 'accept' => 'ContentTypes',
20 'accept-charset' => 'Charsets',
21 'action*' => 'URI',
22 'method' => 'Enum#get,post',
23 // really ContentType, but these two are the only ones used today
24 'enctype' => 'Enum#application/x-www-form-urlencoded,multipart/form-data',
25 ));
26 $form->excludes = array('form' => true);
27
28 $input = $this->addElement('input', 'Formctrl', 'Empty', 'Common', array(
29 'accept' => 'ContentTypes',
30 'accesskey' => 'Character',
31 'alt' => 'Text',
32 'checked' => 'Bool#checked',
33 'disabled' => 'Bool#disabled',
34 'maxlength' => 'Number',
35 'name' => 'CDATA',
36 'readonly' => 'Bool#readonly',
37 'size' => 'Number',
dd205fba 38 'src' => 'URI#embedded',
f45a286b
AD
39 'tabindex' => 'Number',
40 'type' => 'Enum#text,password,checkbox,button,radio,submit,reset,file,hidden,image',
41 'value' => 'CDATA',
42 ));
43 $input->attr_transform_post[] = new HTMLPurifier_AttrTransform_Input();
44
45 $this->addElement('select', 'Formctrl', 'Required: optgroup | option', 'Common', array(
46 'disabled' => 'Bool#disabled',
47 'multiple' => 'Bool#multiple',
48 'name' => 'CDATA',
49 'size' => 'Number',
50 'tabindex' => 'Number',
51 ));
52
53 $this->addElement('option', false, 'Optional: #PCDATA', 'Common', array(
54 'disabled' => 'Bool#disabled',
55 'label' => 'Text',
56 'selected' => 'Bool#selected',
57 'value' => 'CDATA',
58 ));
59 // It's illegal for there to be more than one selected, but not
60 // be multiple. Also, no selected means undefined behavior. This might
61 // be difficult to implement; perhaps an injector, or a context variable.
62
63 $textarea = $this->addElement('textarea', 'Formctrl', 'Optional: #PCDATA', 'Common', array(
64 'accesskey' => 'Character',
65 'cols*' => 'Number',
66 'disabled' => 'Bool#disabled',
67 'name' => 'CDATA',
68 'readonly' => 'Bool#readonly',
69 'rows*' => 'Number',
70 'tabindex' => 'Number',
71 ));
72 $textarea->attr_transform_pre[] = new HTMLPurifier_AttrTransform_Textarea();
73
74 $button = $this->addElement('button', 'Formctrl', 'Optional: #PCDATA | Heading | List | Block | Inline', 'Common', array(
75 'accesskey' => 'Character',
76 'disabled' => 'Bool#disabled',
77 'name' => 'CDATA',
78 'tabindex' => 'Number',
79 'type' => 'Enum#button,submit,reset',
80 'value' => 'CDATA',
81 ));
82
83 // For exclusions, ideally we'd specify content sets, not literal elements
84 $button->excludes = $this->makeLookup(
85 'form', 'fieldset', // Form
86 'input', 'select', 'textarea', 'label', 'button', // Formctrl
dd205fba
MK
87 'a', // as per HTML 4.01 spec, this is omitted by modularization
88 'isindex', 'iframe' // legacy items
f45a286b
AD
89 );
90
91 // Extra exclusion: img usemap="" is not permitted within this element.
92 // We'll omit this for now, since we don't have any good way of
93 // indicating it yet.
94
95 // This is HIGHLY user-unfriendly; we need a custom child-def for this
96 $this->addElement('fieldset', 'Form', 'Custom: (#WS?,legend,(Flow|#PCDATA)*)', 'Common');
97
98 $label = $this->addElement('label', 'Formctrl', 'Optional: #PCDATA | Inline', 'Common', array(
99 'accesskey' => 'Character',
100 // 'for' => 'IDREF', // IDREF not implemented, cannot allow
101 ));
102 $label->excludes = array('label' => true);
103
104 $this->addElement('legend', false, 'Optional: #PCDATA | Inline', 'Common', array(
105 'accesskey' => 'Character',
106 ));
107
108 $this->addElement('optgroup', false, 'Required: option', 'Common', array(
109 'disabled' => 'Bool#disabled',
110 'label*' => 'Text',
111 ));
112
113 // Don't forget an injector for <isindex>. This one's a little complex
114 // because it maps to multiple elements.
115
116 }
117}
118
119// vim: et sw=4 sts=4