function _ckeditor_filter_process in CKEditor Filter 7
Process callback for filter.
4 calls to _ckeditor_filter_process()
- CKEditorFilterTest::testComplex in ./
ckeditor_filter.test - Complex stripping: ensure style elements in nested
- CKEditorFilterTest::testFilter in ./
ckeditor_filter.test - Sanity test: ensure blacklisted elements are removed.
- CKEditorFilterTest::testNested in ./
ckeditor_filter.test - Sanity check: ensure blacklisted elements are removed even if nested.
- CKEditorFilterTest::testStress in ./
ckeditor_filter.test - Stress test: a flat list of elements shouldn't cause recursion errors.
1 string reference to '_ckeditor_filter_process'
- ckeditor_filter_filter_info in ./
ckeditor_filter.module - Implements hook_filter_info().
File
- ./
ckeditor_filter.module, line 30 - Provides an input filter that allows site administrators configure which HTML elements, attributes and style properties are allowed.
Code
function _ckeditor_filter_process($text, $filter) {
$settings = $filter->settings;
if (!isset($settings['valid_elements']) || !isset($settings['valid_attributes']) || !isset($settings['valid_styles'])) {
return;
}
// Mega strip
$special_cases = ckeditor_filter_get_elements_blacklist();
// grab dom object
$html = new simple_html_dom();
$html
->load($text);
// just make sure simple_html worked
if (method_exists($html, 'find')) {
// grab attributes
$attributes = explode(',', $settings['valid_attributes']);
$styles = explode(',', $settings['valid_styles']);
// grab regex for styles
$styles_regex = _ckeditor_filter_styles_regex_builder($styles);
// there are styles so add to allowed attributes
if (!empty($styles_regex)) {
array_push($attributes, 'style');
}
// @TODO account for wildcards
// grab root html element
$root = $html
->find('root', 0);
// call recursive handler to run through tree
_ckeditor_filter_process_recursive($root, explode(',', $settings['valid_elements']), $special_cases, $attributes, $styles_regex);
return $root->outertext;
}
return $text;
}