You are here

function _ckeditor_filter_process_styles in CKEditor Filter 7

Runs style values against defined values

1 call to _ckeditor_filter_process_styles()
_ckeditor_filter_process_recursive in ./ckeditor_filter.module
Recursive call to process html block

File

./ckeditor_filter.module, line 159
Provides an input filter that allows site administrators configure which HTML elements, attributes and style properties are allowed.

Code

function _ckeditor_filter_process_styles(&$e, $styles_regex) {

  // deal with styles
  if ($e->style) {

    // we have some styles allowed
    if (!empty($styles_regex)) {

      // match
      preg_match($styles_regex, $e->style, $matches);
      $matches = array_filter($matches);

      // always matches 1, so must have more for actual hits
      if (count($matches) >= 2) {
        array_shift($matches);
        $e->style = implode(';', $matches) . ';';
        return;
      }
    }

    // clear
    $e
      ->removeAttribute('style');
  }
}