diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-10-14 11:06:19 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-10-14 11:06:19 +0000 |
commit | 06b1e918d5b47be44536981876ce8a11edfa31e8 (patch) | |
tree | d608be79fdaae29a825ec621087bcfaa1ed00513 /engine/lib/output.php | |
parent | 79527ef4c43e97060d2412037adcdcb03220a4fa (diff) | |
download | elgg-06b1e918d5b47be44536981876ce8a11edfa31e8.tar.gz elgg-06b1e918d5b47be44536981876ce8a11edfa31e8.tar.bz2 |
Fixes #2339 - removes social library and deprecates its two functions (put it output.php for lack of a better location)
git-svn-id: http://code.elgg.org/elgg/trunk@7078 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/output.php')
-rw-r--r-- | engine/lib/output.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/engine/lib/output.php b/engine/lib/output.php index 640ada1cf..28e520e56 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -263,3 +263,60 @@ function elgg_strip_tags($string) { return $string; } + +/** + * Filters a string into an array of significant words + * + * @deprecated 1.8 + * @param string $string + * @return array + */ +function filter_string($string) { + elgg_deprecated_notice('filter_string() was deprecated!', 1.8); + + // Convert it to lower and trim + $string = strtolower($string); + $string = trim($string); + + // Remove links and email addresses + // match protocol://address/path/file.extension?some=variable&another=asf% + $string = preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu"," ", $string); + // match www.something.domain/path/file.extension?some=variable&another=asf% + $string = preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu"," ", $string); + // match name@address + $string = preg_replace("/\s([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,])/iu"," ", $string); + + // Sanitise the string; remove unwanted characters + $string = preg_replace('/\W/ui', ' ', $string); + + // Explode it into an array + $terms = explode(' ',$string); + + // Remove any blacklist terms + //$terms = array_filter($terms, 'remove_blacklist'); + + return $terms; +} + +/** + * Returns true if the word in $input is considered significant + * + * @deprecated 1.8 + * @param string $input + * @return true|false + */ +function remove_blacklist($input) { + elgg_deprecated_notice('remove_blacklist() was deprecated!', 1.8); + + global $CONFIG; + + if (!is_array($CONFIG->wordblacklist)) { + return $input; + } + + if (strlen($input) < 3 || in_array($input,$CONFIG->wordblacklist)) { + return false; + } + + return true; +}
\ No newline at end of file |