ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
HTMLPurifier_HTMLModule_Forms Class Reference

XHTML 1.1 Forms module, defines all form-related elements found in HTML 4. More...

+ Inheritance diagram for HTMLPurifier_HTMLModule_Forms:
+ Collaboration diagram for HTMLPurifier_HTMLModule_Forms:

Public Member Functions

 setup ($config)
 
- Public Member Functions inherited from HTMLPurifier_HTMLModule
 getChildDef ($def)
 Retrieves a proper HTMLPurifier_ChildDef subclass based on content_model and content_model_type member variables of the HTMLPurifier_ElementDef class. More...
 
 addElement ($element, $type, $contents, $attr_includes=array(), $attr=array())
 Convenience function that sets up a new element. More...
 
 addBlankElement ($element)
 Convenience function that creates a totally blank, non-standalone element. More...
 
 addElementToContentSet ($element, $type)
 Convenience function that registers an element to a content set. More...
 
 parseContents ($contents)
 Convenience function that transforms single-string contents into separate content model and content model type. More...
 
 mergeInAttrIncludes (&$attr, $attr_includes)
 Convenience function that merges a list of attribute includes into an attribute array. More...
 
 makeLookup ($list)
 Convenience function that generates a lookup table with boolean true as value. More...
 
 setup ($config)
 Lazy load construction of the module after determining whether or not it's needed, and also when a finalized configuration object is available. More...
 

Data Fields

 $name = 'Forms'
 @type string More...
 
 $safe = false
 @type bool More...
 
 $content_sets
 @type array More...
 
- Data Fields inherited from HTMLPurifier_HTMLModule
 $name
 Short unique string identifier of the module. More...
 
 $elements = array()
 Informally, a list of elements this module changes. More...
 
 $info = array()
 Associative array of element names to element definitions. More...
 
 $content_sets = array()
 Associative array of content set names to content set additions. More...
 
 $attr_collections = array()
 Associative array of attribute collection names to attribute collection additions. More...
 
 $info_tag_transform = array()
 Associative array of deprecated tag name to HTMLPurifier_TagTransform. More...
 
 $info_attr_transform_pre = array()
 List of HTMLPurifier_AttrTransform to be performed before validation. More...
 
 $info_attr_transform_post = array()
 List of HTMLPurifier_AttrTransform to be performed after validation. More...
 
 $info_injector = array()
 List of HTMLPurifier_Injector to be performed during well-formedness fixing. More...
 
 $defines_child_def = false
 Boolean flag that indicates whether or not getChildDef is implemented. More...
 
 $safe = true
 Boolean flag whether or not this module is safe. More...
 

Detailed Description

XHTML 1.1 Forms module, defines all form-related elements found in HTML 4.

Definition at line 6 of file Forms.php.

Member Function Documentation

◆ setup()

HTMLPurifier_HTMLModule_Forms::setup (   $config)
Parameters
HTMLPurifier_Config$config

Reimplemented from HTMLPurifier_HTMLModule.

Definition at line 29 of file Forms.php.

30 {
31 if ($config->get('HTML.Forms')) {
32 $this->safe = true;
33 }
34
35 $form = $this->addElement(
36 'form',
37 'Form',
38 'Required: Heading | List | Block | fieldset',
39 'Common',
40 array(
41 'accept' => 'ContentTypes',
42 'accept-charset' => 'Charsets',
43 'action*' => 'URI',
44 'method' => 'Enum#get,post',
45 // really ContentType, but these two are the only ones used today
46 'enctype' => 'Enum#application/x-www-form-urlencoded,multipart/form-data',
47 )
48 );
49 $form->excludes = array('form' => true);
50
51 $input = $this->addElement(
52 'input',
53 'Formctrl',
54 'Empty',
55 'Common',
56 array(
57 'accept' => 'ContentTypes',
58 'accesskey' => 'Character',
59 'alt' => 'Text',
60 'checked' => 'Bool#checked',
61 'disabled' => 'Bool#disabled',
62 'maxlength' => 'Number',
63 'name' => 'CDATA',
64 'readonly' => 'Bool#readonly',
65 'size' => 'Number',
66 'src' => 'URI#embedded',
67 'tabindex' => 'Number',
68 'type' => 'Enum#text,password,checkbox,button,radio,submit,reset,file,hidden,image',
69 'value' => 'CDATA',
70 )
71 );
72 $input->attr_transform_post[] = new HTMLPurifier_AttrTransform_Input();
73
74 $this->addElement(
75 'select',
76 'Formctrl',
77 'Required: optgroup | option',
78 'Common',
79 array(
80 'disabled' => 'Bool#disabled',
81 'multiple' => 'Bool#multiple',
82 'name' => 'CDATA',
83 'size' => 'Number',
84 'tabindex' => 'Number',
85 )
86 );
87
88 $this->addElement(
89 'option',
90 false,
91 'Optional: #PCDATA',
92 'Common',
93 array(
94 'disabled' => 'Bool#disabled',
95 'label' => 'Text',
96 'selected' => 'Bool#selected',
97 'value' => 'CDATA',
98 )
99 );
100 // It's illegal for there to be more than one selected, but not
101 // be multiple. Also, no selected means undefined behavior. This might
102 // be difficult to implement; perhaps an injector, or a context variable.
103
104 $textarea = $this->addElement(
105 'textarea',
106 'Formctrl',
107 'Optional: #PCDATA',
108 'Common',
109 array(
110 'accesskey' => 'Character',
111 'cols*' => 'Number',
112 'disabled' => 'Bool#disabled',
113 'name' => 'CDATA',
114 'readonly' => 'Bool#readonly',
115 'rows*' => 'Number',
116 'tabindex' => 'Number',
117 )
118 );
119 $textarea->attr_transform_pre[] = new HTMLPurifier_AttrTransform_Textarea();
120
121 $button = $this->addElement(
122 'button',
123 'Formctrl',
124 'Optional: #PCDATA | Heading | List | Block | Inline',
125 'Common',
126 array(
127 'accesskey' => 'Character',
128 'disabled' => 'Bool#disabled',
129 'name' => 'CDATA',
130 'tabindex' => 'Number',
131 'type' => 'Enum#button,submit,reset',
132 'value' => 'CDATA',
133 )
134 );
135
136 // For exclusions, ideally we'd specify content sets, not literal elements
137 $button->excludes = $this->makeLookup(
138 'form',
139 'fieldset', // Form
140 'input',
141 'select',
142 'textarea',
143 'label',
144 'button', // Formctrl
145 'a', // as per HTML 4.01 spec, this is omitted by modularization
146 'isindex',
147 'iframe' // legacy items
148 );
149
150 // Extra exclusion: img usemap="" is not permitted within this element.
151 // We'll omit this for now, since we don't have any good way of
152 // indicating it yet.
153
154 // This is HIGHLY user-unfriendly; we need a custom child-def for this
155 $this->addElement('fieldset', 'Form', 'Custom: (#WS?,legend,(Flow|#PCDATA)*)', 'Common');
156
157 $label = $this->addElement(
158 'label',
159 'Formctrl',
160 'Optional: #PCDATA | Inline',
161 'Common',
162 array(
163 'accesskey' => 'Character',
164 // 'for' => 'IDREF', // IDREF not implemented, cannot allow
165 )
166 );
167 $label->excludes = array('label' => true);
168
169 $this->addElement(
170 'legend',
171 false,
172 'Optional: #PCDATA | Inline',
173 'Common',
174 array(
175 'accesskey' => 'Character',
176 )
177 );
178
179 $this->addElement(
180 'optgroup',
181 false,
182 'Required: option',
183 'Common',
184 array(
185 'disabled' => 'Bool#disabled',
186 'label*' => 'Text',
187 )
188 );
189 // Don't forget an injector for <isindex>. This one's a little complex
190 // because it maps to multiple elements.
191 }
Performs miscellaneous cross attribute validation and filtering for input elements.
Definition: Input.php:8
Sets height/width defaults for <textarea>
Definition: Textarea.php:7
makeLookup($list)
Convenience function that generates a lookup table with boolean true as value.
Definition: HTMLModule.php:258
addElement($element, $type, $contents, $attr_includes=array(), $attr=array())
Convenience function that sets up a new element.
Definition: HTMLModule.php:144
$config
Definition: bootstrap.php:15
if(isset($_POST['submit'])) $form

References $config, $form, $input, HTMLPurifier_HTMLModule\addElement(), and HTMLPurifier_HTMLModule\makeLookup().

+ Here is the call graph for this function:

Field Documentation

◆ $content_sets

HTMLPurifier_HTMLModule_Forms::$content_sets
Initial value:
= array(
'Block' => 'Form',
'Inline' => 'Formctrl',
)

@type array

Definition at line 21 of file Forms.php.

◆ $name

HTMLPurifier_HTMLModule_Forms::$name = 'Forms'

@type string

Definition at line 11 of file Forms.php.

◆ $safe

HTMLPurifier_HTMLModule_Forms::$safe = false

@type bool

Definition at line 16 of file Forms.php.


The documentation for this class was generated from the following file: