You are here

static function Messaging_Text::text_clean in Messaging 7

Clean text of HTML stuff and optionally of line endings

Parameters

$text: Dirty HTML text to be filtered

$newline: Optional string to be used as line ending

File

messaging_template/messaging_template.inc, line 33
Drupal Messaging Framework - Text filtering functions

Class

Messaging_Text
Message text class.

Code

static function text_clean($text, $newline = NULL) {

  // HTML entities to plain text conversion.
  $text = decode_entities($text);

  // Filters out all remaining HTML tags
  $text = filter_xss($text, array());

  // Optionally, replace new lines
  if (!is_null($newline)) {
    $text = str_replace("\n", $newline, $text);
  }

  // Trim out remaining beginning/ending spaces
  $text = trim($text);
  return $text;
}