diff options
Diffstat (limited to 'phpBB/includes/message_parser.php')
| -rw-r--r-- | phpBB/includes/message_parser.php | 48 | 
1 files changed, 48 insertions, 0 deletions
| diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 04a2726d22..42ca9bf09d 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -21,6 +21,19 @@ if (!defined('IN_PHPBB'))  if (!class_exists('bbcode'))  { +	// The following lines are for extensions which include message_parser.php +	// while $phpbb_root_path and $phpEx are out of the script scope +	// which may lead to the 'Undefined variable' and 'failed to open stream' errors +	if (!isset($phpbb_root_path)) +	{ +		global $phpbb_root_path; +	} + +	if (!isset($phpEx)) +	{ +		global $phpEx; +	} +  	include($phpbb_root_path . 'includes/bbcode.' . $phpEx);  } @@ -115,6 +128,9 @@ class bbcode_firstpass extends bbcode  		// [quote] in second position.  		// To parse multiline URL we enable dotall option setting only for URL text  		// but not for link itself, thus [url][/url] is not affected. +		// +		// To perform custom validation in extension, use $this->validate_bbcode_by_extension() +		// method which accepts variable number of parameters  		$this->bbcodes = array(  			'code'			=> array('bbcode_id' => 8,	'regexp' => array('#\[code(?:=([a-z]+))?\](.+\[/code\])#uise' => "\$this->bbcode_code('\$1', '\$2')")),  			'quote'			=> array('bbcode_id' => 0,	'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#uise' => "\$this->bbcode_quote('\$0')")), @@ -1862,4 +1878,36 @@ class parse_message extends bbcode_firstpass  	{  		$this->mimetype_guesser = $mimetype_guesser;  	} + +	/** +	* Function to perform custom bbcode validation by extensions +	* can be used in bbcode_init() to assign regexp replacement +	* Example: 'regexp' => array('#\[b\](.*?)\[/b\]#uise' => "\$this->validate_bbcode_by_extension('\$1')") +	* +	* Accepts variable number of parameters +	* +	* @return mixed Validation result +	*/ +	public function validate_bbcode_by_extension() +	{ +		global $phpbb_dispatcher; + +		$return = false; +		$params_array = func_get_args(); + +		/** +		* Event to validate bbcode with the custom validating methods +		* provided by extensions +		* +		* @event core.validate_bbcode_by_extension +		* @var array	params_array	Array with the function parameters +		* @var mixed	return			Validation result to return +		* +		* @since 3.1.5-RC1 +		*/ +		$vars = array('params_array', 'return'); +		extract($phpbb_dispatcher->trigger_event('core.validate_bbcode_by_extension', compact($vars))); + +		return $return; +	}  } | 
