From b524bbf2f3ff382587d8048fcd9d08f69d6d8fa3 Mon Sep 17 00:00:00 2001 From: brettp Date: Sat, 29 May 2010 02:26:01 +0000 Subject: Merged r6263:6271 to trunk. git-svn-id: http://code.elgg.org/elgg/trunk@6285 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 42 ++++++++++++++++++++++++++++++++++++++++-- engine/lib/output.php | 4 ++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 9d0bae0b6..7a3e47e7d 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1670,6 +1670,36 @@ function add_to_register($register_name, $subregister_name, $subregister_value, return true; } +/** + * Removes what has been registered at [register_name][subregister_name] + * + * @param string $register_name The name of the top-level register + * @param string $subregister_name The name of the subregister + * @return true|false Depending on success + */ +function remove_from_register($register_name, $subregister_name) { + global $CONFIG; + + if (empty($register_name) || empty($subregister_name)) { + return false; + } + + if (!isset($CONFIG->registers)) { + return false; + } + + if (!isset($CONFIG->registers[$register_name])) { + return false; + } + + if (isset($CONFIG->registers[$register_name][$subregister_name])) { + unset($CONFIG->registers[$register_name][$subregister_name]); + return true; + } + + return false; +} + /** * Returns a register object * @@ -1738,6 +1768,16 @@ function add_menu($menu_name, $menu_url, $menu_children = array(), $context = "" return add_to_register('menu', $menu_name, $value, $menu_children); } +/** + * Removes an item from the menu register + * + * @param string $menu_name The name of the menu item + * @return true|false Depending on success + */ +function remove_menu($menu_name) { + return remove_from_register('menu', $menu_name); +} + /** * Returns a menu item for use in the children section of add_menu() * This is not currently used in the Elgg core @@ -1751,7 +1791,6 @@ function menu_item($menu_name, $menu_url) { return make_register_object($menu_name, $menu_url); } - /** * Message register handling * If a null $message parameter is given, the function returns the array of messages so far and empties it @@ -1762,7 +1801,6 @@ function menu_item($menu_name, $menu_url) { * @param bool $count Count the number of messages (default: false) * @return true|false|array Either the array of messages, or a response regarding whether the message addition was successful */ - function system_messages($message = null, $register = "messages", $count = false) { if (!isset($_SESSION['msg'])) { $_SESSION['msg'] = array(); diff --git a/engine/lib/output.php b/engine/lib/output.php index b2eb532ca..6e861e4ac 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -100,6 +100,10 @@ function autop($pee, $br = 1) { function elgg_make_excerpt($text, $num_chars = 250) { $text = trim(strip_tags($text)); $string_length = elgg_strlen($text); + + if ($string_length <= $num_chars) { + return $text; + } // handle cases $excerpt = elgg_substr($text, 0, $num_chars); -- cgit v1.2.3