aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/social.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-15 04:41:46 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-15 04:41:46 +0000
commit54a3c3e7e9e70c4770010e442e95f734200d03f9 (patch)
treef8e2e7e383523bbf28654ec171e57c841ed1910b /engine/lib/social.php
parentba331497c03a51ae4b46b387e5f6773620a98cff (diff)
downloadelgg-54a3c3e7e9e70c4770010e442e95f734200d03f9.tar.gz
elgg-54a3c3e7e9e70c4770010e442e95f734200d03f9.tar.bz2
Standardized gobs of files.
git-svn-id: http://code.elgg.org/elgg/trunk@3548 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/social.php')
-rw-r--r--engine/lib/social.php233
1 files changed, 112 insertions, 121 deletions
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 @@
<?php
+/**
+ * Elgg Social
+ * Functions and objects which provide powerful social aspects within Elgg
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @author Curverider
+ * @link http://elgg.org/
- /**
- * Elgg Social
- * Functions and objects which provide powerful social aspects within Elgg
- *
- * @package Elgg
- * @subpackage Core
+/**
+ * Filters a string into an array of significant words
+ *
+ * @param string $string
+ * @return array
+ */
+function filter_string($string) {
+ // Convert it to lower and trim
+ $string = strtolower($string);
+ $string = trim($string);
- * @author Curverider
+ // 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);
- * @link http://elgg.org/
-
- /**
- * Filters a string into an array of significant words
- *
- * @param string $string
- * @return array
- */
- function filter_string($string) {
-
- // 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;
+ // Sanitise the string; remove unwanted characters
+ $string = preg_replace('/\W/ui', ' ', $string);
- }
-
- /**
- * 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;
-
- }
-
+ // 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