function _htmlpurifier_config_hack in HTML Purifier 7
Same name and namespace in other branches
- 6.2 htmlpurifier.module \_htmlpurifier_config_hack()
- 6 htmlpurifier.module \_htmlpurifier_config_hack()
Fills out the form state with extra post data originating from the HTML Purifier configuration form. This is an #after_build hook function.
@warning If someone ever gets the smart idea of changing the parameters to this function, I'm SOL! ;-) Also, this function does not work correctly if both filters from this module are enabled for the same format, since only one set of submitted values will make it through.
1 string reference to '_htmlpurifier_config_hack'
- _htmlpurifier_settings in ./
htmlpurifier.module - Generates a settings form for configuring HTML Purifier.
File
- ./
htmlpurifier.module, line 543 - Implements HTML Purifier as a Drupal filter.
Code
function _htmlpurifier_config_hack($form_element, &$form_state) {
$parents = $form_element['#parents'];
$key = end($parents);
if (isset($form_state['input'][$key])) {
$value = $form_state['input'][$key];
foreach (array_reverse($parents) as $parent) {
$value = array(
$parent => $value,
);
}
$form_state['values'] = array_merge_recursive($form_state['values'], $value);
}
foreach ($form_state['values'] as $i => $config_data) {
if (!is_array($config_data)) {
continue;
}
if (!empty($config_data['Filter.ExtractStyleBlocks'])) {
if (!empty($config_data['Null_Filter.ExtractStyleBlocks.Scope'])) {
drupal_set_message(t("You have not set <code>Filter.ExtractStyleBlocks.Scope</code>; this means that users can add CSS that affects all of your Drupal theme and not just their content block. It is recommended to set this to <code>#node-[%HTMLPURIFIER:NID%]</code> (including brackets) which will automatically ensure that CSS directives only apply to their node."), 'warning', FALSE);
}
elseif (!isset($config_data['Filter.ExtractStyleBlocks.Scope']) || $config_data['Filter.ExtractStyleBlocks.Scope'] !== '#node-[%HTMLPURIFIER:NID%]') {
drupal_set_message(t("You have enabled Filter.ExtractStyleBlocks.Scope, but you did not set it to <code>#node-[%HTMLPURIFIER:NID%]</code>; CSS may not work unless you have special theme support."), 'warning', FALSE);
}
}
}
return $form_element;
}