You are here

function _htmlpurifier_config_hack in HTML Purifier 6.2

Same name and namespace in other branches
  1. 6 htmlpurifier.module \_htmlpurifier_config_hack()
  2. 7 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! ;-)

1 string reference to '_htmlpurifier_config_hack'
_htmlpurifier_settings in ./htmlpurifier.module
Generates a settings form for configuring HTML Purifier.

File

./htmlpurifier.module, line 506
Implements HTML Purifier as a Drupal filter.

Code

function _htmlpurifier_config_hack($form_element, &$form_state) {
  $key = $form_element['#parents'][0];
  if (!empty($form_element['#post']) && isset($form_element['#post'][$key])) {
    $form_state['values'][$key] = $form_element['#post'][$key];
  }
  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("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("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;
}