From 54a3c3e7e9e70c4770010e442e95f734200d03f9 Mon Sep 17 00:00:00 2001 From: brettp Date: Thu, 15 Oct 2009 04:41:46 +0000 Subject: Standardized gobs of files. git-svn-id: http://code.elgg.org/elgg/trunk@3548 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/social.php | 233 ++++++++++++++++++++++++-------------------------- 1 file changed, 112 insertions(+), 121 deletions(-) (limited to 'engine/lib/social.php') diff --git a/engine/lib/social.php b/engine/lib/social.php index e8bfccda5..381c7ea4f 100644 --- a/engine/lib/social.php +++ b/engine/lib/social.php @@ -1,128 +1,119 @@ wordblacklist)) - return $input; - - if (strlen($input) < 3 || in_array($input,$CONFIG->wordblacklist)) - return false; - - return true; - - } - + // Explode it into an array + $terms = explode(' ',$string); - /** - * Initialise. - * - * Sets a blacklist of words in the current language. This is a comma separated list in word:blacklist. - */ - function social_init() { - global $CONFIG; - - $CONFIG->wordblacklist = array(); - - $list = explode(',', elgg_echo('word:blacklist')); - if ($list) - { - foreach ($list as $l) - $CONFIG->wordblacklist[] = trim($l); - } - else - { - // Fallback - shouldn't happen - $CONFIG->wordblacklist = array( - 'and', - 'the', - 'then', - 'but', - 'she', - 'his', - 'her', - 'him', - 'one', - 'not', - 'also', - 'about', - 'now', - 'hence', - 'however', - 'still', - 'likewise', - 'otherwise', - 'therefore', - 'conversely', - 'rather', - 'consequently', - 'furthermore', - 'nevertheless', - 'instead', - 'meanwhile', - 'accordingly', - 'this', - 'seems', - 'what', - 'whom', - 'whose', - 'whoever', - 'whomever', - ); - } - } + // Remove any blacklist terms + //$terms = array_filter($terms, 'remove_blacklist'); - register_elgg_event_handler("init","system","social_init"); - -?> \ No newline at end of file + return $terms; +} + +/** + * Returns true if the word in $input is considered significant + * + * @param string $input + * @return true|false + */ +function remove_blacklist($input) { + global $CONFIG; + + if (!is_array($CONFIG->wordblacklist)) { + return $input; + } + + if (strlen($input) < 3 || in_array($input,$CONFIG->wordblacklist)) { + return false; + } + + return true; +} + + +/** + * Initialise. + * + * Sets a blacklist of words in the current language. This is a comma separated list in word:blacklist. + */ +function social_init() { + global $CONFIG; + + $CONFIG->wordblacklist = array(); + + $list = explode(',', elgg_echo('word:blacklist')); + if ($list) { + foreach ($list as $l) { + $CONFIG->wordblacklist[] = trim($l); + } + } else { + // Fallback - shouldn't happen + $CONFIG->wordblacklist = array( + 'and', + 'the', + 'then', + 'but', + 'she', + 'his', + 'her', + 'him', + 'one', + 'not', + 'also', + 'about', + 'now', + 'hence', + 'however', + 'still', + 'likewise', + 'otherwise', + 'therefore', + 'conversely', + 'rather', + 'consequently', + 'furthermore', + 'nevertheless', + 'instead', + 'meanwhile', + 'accordingly', + 'this', + 'seems', + 'what', + 'whom', + 'whose', + 'whoever', + 'whomever', + ); + } +} + +register_elgg_event_handler("init","system","social_init"); \ No newline at end of file -- cgit v1.2.3