From 1ea73bda2882b6fa3e5fb6a66f5eb40e3593c59b Mon Sep 17 00:00:00 2001 From: Alec Smecher Date: Mon, 19 Jul 2010 10:16:36 -0700 Subject: [PATCH] *5568* Added String::html2text method --- classes/core/String.inc.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/classes/core/String.inc.php b/classes/core/String.inc.php index f4916a44e44..0417632b505 100644 --- a/classes/core/String.inc.php +++ b/classes/core/String.inc.php @@ -458,6 +458,20 @@ function stripUnsafeHtml($input) { return $html; } + /** + * Convert limited HTML into a string. + * @param $html string + * @return string + */ + function html2text($html) { + $html = String::regexp_replace('/<[\/]?p>/', "\n", $html); + $html = String::regexp_replace('/
  • /', '• ', $html); + $html = String::regexp_replace('/<\/li>/', "\n", $html); + $html = String::regexp_replace('//', "\n", $html); + $html = String::html2utf(strip_tags($html)); + return $html; + } + // // Wrappers for UTF-8 validation routines // See the phputf8 documentation for usage.