/[drupal]/contributions/modules/smartlinebreakconverter/smartlinebreakconverter.module
ViewVC logotype

Contents of /contributions/modules/smartlinebreakconverter/smartlinebreakconverter.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Mon Nov 12 18:40:28 2007 UTC (2 years ago) by nschelly
Branch: MAIN
CVS Tags: DRUPAL-5--1-1, HEAD
Branch point for: DRUPAL-5
File MIME type: text/x-php
Initial commit of smart line break converter, which is a filter that selectively applies the built-in line break converter according to need.
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 }

  ViewVC Help
Powered by ViewVC 1.1.2