From 1e29f064e87dcab1a3bb65c63d254bde03d6422d Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 21 Aug 2012 12:51:41 -0400 Subject: [PATCH] [feature/add_events] Added events for modifying generate_text_for_display() The events allow you to perform extra functions on the text before nad/or after it has been parsed for BBCode and Smilies. PHPBB3-9550 --- phpBB/includes/functions_content.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 8b7565d8f1..6bad2111ef 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -411,12 +411,26 @@ function strip_bbcode(&$text, $uid = '') function generate_text_for_display($text, $uid, $bitfield, $flags) { static $bbcode; + global $phpbb_dispatcher; if (!$text) { return ''; } + /** + * Use this event to modify the text before it is parsed + * + * @event core.modify_text_for_display_before + * @var string text The text to parse + * @var string uid The BBCode UID + * @var string bitfield The BBCode Bitfield + * @var int flags The BBCode Flags + * @since 3.1-A1 + */ + $vars = array('text', 'uid', 'bitfield', 'flags'); + extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_before', compact($vars))); + $text = censor_text($text); // Parse bbcode if bbcode uid stored and bbcode enabled @@ -443,6 +457,19 @@ function generate_text_for_display($text, $uid, $bitfield, $flags) $text = bbcode_nl2br($text); $text = smiley_text($text, !($flags & OPTION_FLAG_SMILIES)); + /** + * Use this event to modify the text after it is parsed + * + * @event core.modify_text_for_display_after + * @var string text The text to parse + * @var string uid The BBCode UID + * @var string bitfield The BBCode Bitfield + * @var int flags The BBCode Flags + * @since 3.1-A1 + */ + $vars = array('text', 'uid', 'bitfield', 'flags'); + extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_after', compact($vars))); + return $text; }