@@ -49,30 +49,30 @@ discard block |
||
49 | 49 | ['header', 'Block', 'Flow', 'Common'], |
50 | 50 | ['footer', 'Block', 'Flow', 'Common'], |
51 | 51 | |
52 | - // Content model actually excludes several tags, not modelled here |
|
52 | + // Content model actually excludes several tags, not modelled here |
|
53 | 53 | ['address', 'Block', 'Flow', 'Common'], |
54 | 54 | ['hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common'], |
55 | 55 | |
56 | - // http://developers.whatwg.org/grouping-content.html |
|
56 | + // http://developers.whatwg.org/grouping-content.html |
|
57 | 57 | ['figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'], |
58 | 58 | ['figcaption', 'Inline', 'Flow', 'Common'], |
59 | 59 | |
60 | - // http://developers.whatwg.org/the-video-element.html#the-video-element |
|
60 | + // http://developers.whatwg.org/the-video-element.html#the-video-element |
|
61 | 61 | ['video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [ |
62 | 62 | 'src' => 'URI', |
63 | - 'type' => 'Text', |
|
64 | - 'width' => 'Length', |
|
65 | - 'height' => 'Length', |
|
66 | - 'poster' => 'URI', |
|
67 | - 'preload' => 'Enum#auto,metadata,none', |
|
68 | - 'controls' => 'Bool', |
|
63 | + 'type' => 'Text', |
|
64 | + 'width' => 'Length', |
|
65 | + 'height' => 'Length', |
|
66 | + 'poster' => 'URI', |
|
67 | + 'preload' => 'Enum#auto,metadata,none', |
|
68 | + 'controls' => 'Bool', |
|
69 | 69 | ], |
70 | 70 | ['source', 'Block', 'Flow', 'Common', [ |
71 | - 'src' => 'URI', |
|
72 | - 'type' => 'Text', |
|
71 | + 'src' => 'URI', |
|
72 | + 'type' => 'Text', |
|
73 | 73 | ], |
74 | 74 | |
75 | - // http://developers.whatwg.org/text-level-semantics.html |
|
75 | + // http://developers.whatwg.org/text-level-semantics.html |
|
76 | 76 | ['s', 'Inline', 'Inline', 'Common'], |
77 | 77 | ['var', 'Inline', 'Inline', 'Common'], |
78 | 78 | ['sub', 'Inline', 'Inline', 'Common'], |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | ['mark', 'Inline', 'Inline', 'Common'], |
81 | 81 | ['wbr', 'Inline', 'Empty', 'Core'], |
82 | 82 | |
83 | - // http://developers.whatwg.org/edits.html |
|
83 | + // http://developers.whatwg.org/edits.html |
|
84 | 84 | ['ins', 'Block', 'Flow', 'Common', array('cite' => 'URI', 'datetime' => 'CDATA')], |
85 | 85 | ['del', 'Block', 'Flow', 'Common', array('cite' => 'URI', 'datetime' => 'CDATA')], |
86 | 86 | ], |
@@ -78,21 +78,21 @@ discard block |
||
78 | 78 | |
79 | 79 | // Load custom definition if set |
80 | 80 | if ($definitionConfig = $this->config->get('purifier.settings.custom_definition')) { |
81 | - $this->addCustomDefinition($definitionConfig, $config); |
|
81 | + $this->addCustomDefinition($definitionConfig, $config); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | // Load custom elements if set |
85 | 85 | if ($elements = $this->config->get('purifier.settings.custom_elements')) { |
86 | - if ($def = $config->maybeGetRawHTMLDefinition()) { |
|
87 | - $this->addCustomElements($elements, $def); |
|
88 | - } |
|
86 | + if ($def = $config->maybeGetRawHTMLDefinition()) { |
|
87 | + $this->addCustomElements($elements, $def); |
|
88 | + } |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Load custom attributes if set |
92 | 92 | if ($attributes = $this->config->get('purifier.settings.custom_attributes')) { |
93 | - if ($def = $config->maybeGetRawHTMLDefinition()) { |
|
94 | - $this->addCustomAttributes($attributes, $def); |
|
95 | - } |
|
93 | + if ($def = $config->maybeGetRawHTMLDefinition()) { |
|
94 | + $this->addCustomAttributes($attributes, $def); |
|
95 | + } |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | // Create HTMLPurifier object |
@@ -100,94 +100,94 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | - * Add a custom definition |
|
104 | - * |
|
105 | - * @see http://htmlpurifier.org/docs/enduser-customize.html |
|
106 | - * @param array $definitionConfig |
|
107 | - * @param HTML_Purifier_Config $configObject Defaults to using default config |
|
108 | - * |
|
109 | - * @return HTML_Purifier_Config $configObject |
|
110 | - */ |
|
111 | - private function addCustomDefinition(array $definitionConfig, $configObject = null) |
|
112 | - { |
|
113 | - if (!$configObject) { |
|
114 | - $configObject = HTMLPurifier_Config::createDefault(); |
|
115 | - $configObject->loadArray($this->getConfig()); |
|
116 | - } |
|
103 | + * Add a custom definition |
|
104 | + * |
|
105 | + * @see http://htmlpurifier.org/docs/enduser-customize.html |
|
106 | + * @param array $definitionConfig |
|
107 | + * @param HTML_Purifier_Config $configObject Defaults to using default config |
|
108 | + * |
|
109 | + * @return HTML_Purifier_Config $configObject |
|
110 | + */ |
|
111 | + private function addCustomDefinition(array $definitionConfig, $configObject = null) |
|
112 | + { |
|
113 | + if (!$configObject) { |
|
114 | + $configObject = HTMLPurifier_Config::createDefault(); |
|
115 | + $configObject->loadArray($this->getConfig()); |
|
116 | + } |
|
117 | 117 | |
118 | - // Setup the custom definition |
|
119 | - $configObject->set('HTML.DefinitionID', $definitionConfig['id']); |
|
120 | - $configObject->set('HTML.DefinitionRev', $definitionConfig['rev']); |
|
118 | + // Setup the custom definition |
|
119 | + $configObject->set('HTML.DefinitionID', $definitionConfig['id']); |
|
120 | + $configObject->set('HTML.DefinitionRev', $definitionConfig['rev']); |
|
121 | 121 | |
122 | - // Enable debug mode |
|
123 | - if (!isset($definitionConfig['debug']) || $definitionConfig['debug']) { |
|
124 | - $configObject->set('Cache.DefinitionImpl', null); |
|
125 | - } |
|
122 | + // Enable debug mode |
|
123 | + if (!isset($definitionConfig['debug']) || $definitionConfig['debug']) { |
|
124 | + $configObject->set('Cache.DefinitionImpl', null); |
|
125 | + } |
|
126 | 126 | |
127 | - // Start configuring the definition |
|
128 | - if ($def = $configObject->maybeGetRawHTMLDefinition()) { |
|
129 | - // Create the definition attributes |
|
130 | - if (!empty($definitionConfig['attributes'])) { |
|
131 | - $this->addCustomAttributes($definitionConfig['attributes'], $def); |
|
132 | - } |
|
127 | + // Start configuring the definition |
|
128 | + if ($def = $configObject->maybeGetRawHTMLDefinition()) { |
|
129 | + // Create the definition attributes |
|
130 | + if (!empty($definitionConfig['attributes'])) { |
|
131 | + $this->addCustomAttributes($definitionConfig['attributes'], $def); |
|
132 | + } |
|
133 | 133 | |
134 | - // Create the definition elements |
|
135 | - if (!empty($definitionConfig['elements'])) { |
|
136 | - $this->addCustomElements($definitionConfig['elements'], $def); |
|
137 | - } |
|
138 | - } |
|
134 | + // Create the definition elements |
|
135 | + if (!empty($definitionConfig['elements'])) { |
|
136 | + $this->addCustomElements($definitionConfig['elements'], $def); |
|
137 | + } |
|
138 | + } |
|
139 | 139 | |
140 | - return $configObject; |
|
141 | - } |
|
140 | + return $configObject; |
|
141 | + } |
|
142 | 142 | |
143 | - /** |
|
144 | - * Add provided attributes to the provided definition |
|
145 | - * |
|
146 | - * @param array $attributes |
|
147 | - * @param HTMLPurifier_HTMLDefinition $definition |
|
148 | - * |
|
149 | - * @return HTMLPurifier_HTMLDefinition $definition |
|
150 | - */ |
|
151 | - private function addCustomAttributes(array $attributes, $definition) |
|
152 | - { |
|
153 | - foreach ($attributes as $attribute) { |
|
154 | - // Get configuration of attribute |
|
155 | - $required = !empty($attribute[3]) ? true : false; |
|
156 | - $onElement = $attribute[0]; |
|
157 | - $attrName = $required ? $attribute[1] . '*' : $attribute[1]; |
|
158 | - $validValues = $attribute[2]; |
|
143 | + /** |
|
144 | + * Add provided attributes to the provided definition |
|
145 | + * |
|
146 | + * @param array $attributes |
|
147 | + * @param HTMLPurifier_HTMLDefinition $definition |
|
148 | + * |
|
149 | + * @return HTMLPurifier_HTMLDefinition $definition |
|
150 | + */ |
|
151 | + private function addCustomAttributes(array $attributes, $definition) |
|
152 | + { |
|
153 | + foreach ($attributes as $attribute) { |
|
154 | + // Get configuration of attribute |
|
155 | + $required = !empty($attribute[3]) ? true : false; |
|
156 | + $onElement = $attribute[0]; |
|
157 | + $attrName = $required ? $attribute[1] . '*' : $attribute[1]; |
|
158 | + $validValues = $attribute[2]; |
|
159 | 159 | |
160 | - $definition->addAttribute($onElement, $attrName, $validValues); |
|
161 | - } |
|
160 | + $definition->addAttribute($onElement, $attrName, $validValues); |
|
161 | + } |
|
162 | 162 | |
163 | - return $definition; |
|
164 | - } |
|
163 | + return $definition; |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * Add provided elements to the provided definition |
|
168 | - * |
|
169 | - * @param array $elements |
|
170 | - * @param HTMLPurifier_HTMLDefinition $definition |
|
171 | - * |
|
172 | - * @return HTMLPurifier_HTMLDefinition $definition |
|
173 | - */ |
|
174 | - private function addCustomElements(array $elements, $definition) |
|
175 | - { |
|
176 | - foreach ($elements as $element) { |
|
177 | - // Get configuration of element |
|
178 | - $name = $element[0]; |
|
179 | - $contentSet = $element[1]; |
|
180 | - $allowedChildren = $element[2]; |
|
181 | - $attributeCollection = $element[3]; |
|
182 | - $attributes = isset($element[4]) ? $element[4] : null; |
|
166 | + /** |
|
167 | + * Add provided elements to the provided definition |
|
168 | + * |
|
169 | + * @param array $elements |
|
170 | + * @param HTMLPurifier_HTMLDefinition $definition |
|
171 | + * |
|
172 | + * @return HTMLPurifier_HTMLDefinition $definition |
|
173 | + */ |
|
174 | + private function addCustomElements(array $elements, $definition) |
|
175 | + { |
|
176 | + foreach ($elements as $element) { |
|
177 | + // Get configuration of element |
|
178 | + $name = $element[0]; |
|
179 | + $contentSet = $element[1]; |
|
180 | + $allowedChildren = $element[2]; |
|
181 | + $attributeCollection = $element[3]; |
|
182 | + $attributes = isset($element[4]) ? $element[4] : null; |
|
183 | 183 | |
184 | - if (!empty($attributes)) { |
|
185 | - $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection, $attributes); |
|
186 | - } else { |
|
187 | - $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection); |
|
188 | - } |
|
189 | - } |
|
190 | - } |
|
184 | + if (!empty($attributes)) { |
|
185 | + $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection, $attributes); |
|
186 | + } else { |
|
187 | + $definition->addElement($name, $contentSet, $allowedChildren, $attributeCollection); |
|
188 | + } |
|
189 | + } |
|
190 | + } |
|
191 | 191 | |
192 | 192 | /** |
193 | 193 | * Check/Create cache directory |