function filter_filter in Drupal 5
Same name and namespace in other branches
- 4 modules/filter.module \filter_filter()
- 6 modules/filter/filter.module \filter_filter()
Implementation of hook_filter(). Contains a basic set of essential filters.
- HTML filter: Validates user-supplied HTML, transforming it as necessary.
- PHP evaluator: Executes PHP code.
- Line break converter: Converts newlines into paragraph and break tags.
File
- modules/
filter/ filter.module, line 994 - Framework for handling filtering of content.
Code
function filter_filter($op, $delta = 0, $format = -1, $text = '') {
switch ($op) {
case 'list':
return array(
0 => t('HTML filter'),
1 => t('PHP evaluator'),
2 => t('Line break converter'),
3 => t('URL filter'),
);
case 'no cache':
return $delta == 1;
// No caching for the PHP evaluator.
case 'description':
switch ($delta) {
case 0:
return t('Allows you to restrict if users can post HTML and which tags to filter out.');
case 1:
return t('Runs a piece of PHP code. The usage of this filter should be restricted to administrators only!');
case 2:
return t('Converts line breaks into HTML (i.e. <br> and <p> tags).');
case 3:
return t('Turns web and e-mail addresses into clickable links.');
default:
return;
}
case 'process':
switch ($delta) {
case 0:
return _filter_html($text, $format);
case 1:
return drupal_eval($text);
case 2:
return _filter_autop($text);
case 3:
return _filter_url($text, $format);
default:
return $text;
}
case 'settings':
switch ($delta) {
case 0:
return _filter_html_settings($format);
case 3:
return _filter_url_settings($format);
default:
return;
}
default:
return $text;
}
}