From eaf2ab7fcf4a915443d3890d98e1d4049e65be64 Mon Sep 17 00:00:00 2001 From: dave Date: Tue, 27 May 2008 10:22:41 +0000 Subject: create a new social library in the engine. Moved string parsing for links to input.php and removed converting strings to tags from the shouts plugin and added them to the social library. git-svn-id: https://code.elgg.org/elgg/trunk@723 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/input.php | 73 ++++++++++++++++++++++------------- engine/lib/social.php | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+), 27 deletions(-) create mode 100644 engine/lib/social.php diff --git a/engine/lib/input.php b/engine/lib/input.php index 8cbea6986..9244c16f3 100644 --- a/engine/lib/input.php +++ b/engine/lib/input.php @@ -1,37 +1,37 @@ - - * @copyright Curverider Ltd 2008 - * @link http://elgg.org/ - */ - - /** - * Get some input from variables passed on the GET or POST line. - * - * @param $variable string The variable we want to return. - * @param $default mixed A default value for the variable if it is not found. - */ - function get_input($variable, $default = "") - { - + + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + */ + + /** + * Get some input from variables passed on the GET or POST line. + * + * @param $variable string The variable we want to return. + * @param $default mixed A default value for the variable if it is not found. + */ + function get_input($variable, $default = "") + { + if (isset($_REQUEST[$variable])) { - $value = $_REQUEST[$variable]; + $value = $_REQUEST[$variable]; return trim($_REQUEST[$variable]); } global $CONFIG; if (isset($CONFIG->input[$variable])) - return $CONFIG->input[$variable]; - + return $CONFIG->input[$variable]; + return $default; - + } /** @@ -49,5 +49,24 @@ } - + /** + * This is a function to make url clickable + * @param string text + * @return string text + **/ + + function parse_urls($text) { + + if (preg_match_all('/(?"\'\!\(\)]+)/ie', $text, $urls)) { + + foreach (array_unique($urls[1]) AS $url){ + $urltext = $url; + $text = str_replace($url, 'view link', $text); + } + } + + return $text; + } + + ?> \ No newline at end of file diff --git a/engine/lib/social.php b/engine/lib/social.php new file mode 100644 index 000000000..bc66c0466 --- /dev/null +++ b/engine/lib/social.php @@ -0,0 +1,103 @@ +wordblacklist)) + return false; + + return true; + + } + + // Set the shout words blacklist, these do not become tags when the string is converted + GLOBAL $CONFIG; + $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', + ); + +?> \ No newline at end of file -- cgit v1.2.3