| 1 |
<?php
|
| 2 |
|
| 3 |
function smartlinebreakconverter_filter($op, $delta = 0, $format = -1, $text = '') {
|
| 4 |
switch ($op) {
|
| 5 |
case 'list':
|
| 6 |
return array(0 => t('Smart Line Break Converter'));
|
| 7 |
|
| 8 |
case 'description':
|
| 9 |
return t('Conditionally applies the core line break filter according to need.');
|
| 10 |
|
| 11 |
case 'process':
|
| 12 |
return _smartlinebreakconverter_process($text);
|
| 13 |
|
| 14 |
default:
|
| 15 |
return $text;
|
| 16 |
}
|
| 17 |
}
|
| 18 |
|
| 19 |
function _smartlinebreakconverter_process($text) {
|
| 20 |
if (stristr($text, '<br>') || stristr($text, '<br />') || stristr($text, '<p>') || stristr($text, '</p>')) {
|
| 21 |
// It appears that the content is handling line breaks on its own.
|
| 22 |
return $text;
|
| 23 |
}
|
| 24 |
|
| 25 |
// The content needs line breaks processing from the core filter module.
|
| 26 |
return filter_filter('process', 2, NULL, $text);
|
| 27 |
}
|