From a2406c017486019ab992d68b921d3202b7626284 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 7 Jul 2011 07:18:45 -0700 Subject: [PATCH] Trim comment bloat in Text class. --- system/text.php | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/system/text.php b/system/text.php index 6a06a92b..1881b1ed 100644 --- a/system/text.php +++ b/system/text.php @@ -17,15 +17,8 @@ public static function words($value, $limit, $end = '…') return $value; } - // ----------------------------------------------------- - // Limit the words in the string. - // ----------------------------------------------------- preg_match('/^\s*+(?:\S++\s*+){1,'.$limit.'}/', $value, $matches); - // ----------------------------------------------------- - // If the string did not exceed the limit, we won't - // need an ending character. - // ----------------------------------------------------- if (strlen($value) == strlen($matches[0])) { $end = ''; @@ -49,9 +42,7 @@ public static function characters($value, $limit, $end = '…') return $value; } - // ----------------------------------------------------- // Replace new lines and whitespace in the string. - // ----------------------------------------------------- $value = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $value)); if (strlen($value) <= $limit) @@ -61,10 +52,6 @@ public static function characters($value, $limit, $end = '…') $out = ''; - // ----------------------------------------------------- - // The string exceeds the character limit. Add each word - // to the output individually until we reach the limit. - // ----------------------------------------------------- foreach (explode(' ', trim($value)) as $val) { $out .= $val.' '; @@ -90,14 +77,9 @@ public static function censor($value, $censored, $replacement = '####') { $value = ' '.$value.' '; - // ----------------------------------------------------- // Assume the word will be book-ended by the following. - // ----------------------------------------------------- $delim = '[-_\'\"`(){}<>\[\]|!?@#%&,.:;^~*+=\/ 0-9\n\r\t]'; - // ----------------------------------------------------- - // Replace the censored words. - // ----------------------------------------------------- foreach ($censored as $word) { if ($replacement != '')