diff options
Diffstat (limited to 'phpBB/includes/functions_content.php')
| -rw-r--r-- | phpBB/includes/functions_content.php | 163 | 
1 files changed, 141 insertions, 22 deletions
| diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index b7650ecd6a..c54cc25f34 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -2,9 +2,8 @@  /**  *  * @package phpBB3 -* @version $Id$  * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2  *  */ @@ -409,16 +408,34 @@ function strip_bbcode(&$text, $uid = '')  * For display of custom parsed text on user-facing pages  * Expects $text to be the value directly from the database (stored value)  */ -function generate_text_for_display($text, $uid, $bitfield, $flags) +function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text = true)  {  	static $bbcode; +	global $phpbb_dispatcher;  	if (!$text)  	{  		return '';  	} -	$text = censor_text($text); +	/** +	* 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 +	* @var bool		censor_text		Whether or not to apply word censors +	* @since 3.1-A1 +	*/ +	$vars = array('text', 'uid', 'bitfield', 'flags', 'censor_text'); +	extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_before', compact($vars))); + +	if ($censor_text) +	{		 +		$text = censor_text($text); +	}  	// Parse bbcode if bbcode uid stored and bbcode enabled  	if ($uid && ($flags & OPTION_FLAG_BBCODE)) @@ -444,6 +461,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;  } @@ -454,7 +484,23 @@ function generate_text_for_display($text, $uid, $bitfield, $flags)  */  function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bbcode = false, $allow_urls = false, $allow_smilies = false)  { -	global $phpbb_root_path, $phpEx; +	global $phpbb_root_path, $phpEx, $phpbb_dispatcher; + +	/** +	* Use this event to modify the text before it is prepared for storage +	* +	* @event core.modify_text_for_storage_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 +	* @var bool		allow_bbcode	Whether or not to parse BBCode +	* @var bool		allow_urls		Whether or not to parse URLs +	* @var bool		allow_smilies	Whether or not to parse Smilies +	* @since 3.1-A1 +	*/ +	$vars = array('text', 'uid', 'bitfield', 'flags', 'allow_bbcode', 'allow_urls', 'allow_smilies'); +	extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_before', compact($vars)));  	$uid = $bitfield = '';  	$flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0); @@ -483,6 +529,19 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb  	$bitfield = $message_parser->bbcode_bitfield; +	/** +	* Use this event to modify the text after it is prepared for storage +	* +	* @event core.modify_text_for_storage_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_storage_after', compact($vars))); +  	return;  } @@ -492,10 +551,33 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb  */  function generate_text_for_edit($text, $uid, $flags)  { -	global $phpbb_root_path, $phpEx; +	global $phpbb_root_path, $phpEx, $phpbb_dispatcher; + +	/** +	* Use this event to modify the text before it is decoded for editing +	* +	* @event core.modify_text_for_edit_before +	* @var string	text			The text to parse +	* @var string	uid				The BBCode UID +	* @var int		flags			The BBCode Flags +	* @since 3.1-A1 +	*/ +	$vars = array('text', 'uid', 'flags'); +	extract($phpbb_dispatcher->trigger_event('core.modify_text_for_edit_before', compact($vars)));  	decode_message($text, $uid); +	/** +	* Use this event to modify the text after it is decoded for editing +	* +	* @event core.modify_text_for_edit_after +	* @var string	text			The text to parse +	* @var int		flags			The BBCode Flags +	* @since 3.1-A1 +	*/ +	$vars = array('text', 'flags'); +	extract($phpbb_dispatcher->trigger_event('core.modify_text_for_edit_after', compact($vars))); +  	return array(  		'allow_bbcode'	=> ($flags & OPTION_FLAG_BBCODE) ? 1 : 0,  		'allow_smilies'	=> ($flags & OPTION_FLAG_SMILIES) ? 1 : 0, @@ -740,7 +822,7 @@ function smiley_text($text, $force_option = false)  	else  	{  		$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; -		return preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/(.*?) \/><!\-\- s\1 \-\->#', '<img src="' . $root_path . $config['smilies_path'] . '/\2 />', $text); +		return preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/(.*?) \/><!\-\- s\1 \-\->#', '<img class="smilies" src="' . $root_path . $config['smilies_path'] . '/\2 />', $text);  	}  } @@ -938,12 +1020,12 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,  			}  			$download_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id']); +			$l_downloaded_viewed = 'VIEWED_COUNTS';  			switch ($display_cat)  			{  				// Images  				case ATTACHMENT_CATEGORY_IMAGE: -					$l_downloaded_viewed = 'VIEWED_COUNT';  					$inline_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id']);  					$download_link .= '&mode=view'; @@ -957,7 +1039,6 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,  				// Images, but display Thumbnail  				case ATTACHMENT_CATEGORY_THUMB: -					$l_downloaded_viewed = 'VIEWED_COUNT';  					$thumbnail_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id'] . '&t=1');  					$download_link .= '&mode=view'; @@ -971,7 +1052,6 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,  				// Windows Media Streams  				case ATTACHMENT_CATEGORY_WM: -					$l_downloaded_viewed = 'VIEWED_COUNT';  					// Giving the filename directly because within the wm object all variables are in local context making it impossible  					// to validate against a valid session (all params can differ) @@ -990,7 +1070,6 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,  				// Real Media Streams  				case ATTACHMENT_CATEGORY_RM:  				case ATTACHMENT_CATEGORY_QUICKTIME: -					$l_downloaded_viewed = 'VIEWED_COUNT';  					$block_array += array(  						'S_RM_FILE'			=> ($display_cat == ATTACHMENT_CATEGORY_RM) ? true : false, @@ -1007,8 +1086,6 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,  				case ATTACHMENT_CATEGORY_FLASH:  					list($width, $height) = @getimagesize($filename); -					$l_downloaded_viewed = 'VIEWED_COUNT'; -  					$block_array += array(  						'S_FLASH_FILE'	=> true,  						'WIDTH'			=> $width, @@ -1021,7 +1098,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,  				break;  				default: -					$l_downloaded_viewed = 'DOWNLOAD_COUNT'; +					$l_downloaded_viewed = 'DOWNLOAD_COUNTS';  					$block_array += array(  						'S_FILE'		=> true, @@ -1029,11 +1106,14 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count,  				break;  			} -			$l_download_count = (!isset($attachment['download_count']) || $attachment['download_count'] == 0) ? $user->lang[$l_downloaded_viewed . '_NONE'] : (($attachment['download_count'] == 1) ? sprintf($user->lang[$l_downloaded_viewed], $attachment['download_count']) : sprintf($user->lang[$l_downloaded_viewed . 'S'], $attachment['download_count'])); +			if (!isset($attachment['download_count'])) +			{ +				$attachment['download_count'] = 0; +			}  			$block_array += array(  				'U_DOWNLOAD_LINK'		=> $download_link, -				'L_DOWNLOAD_COUNT'		=> $l_download_count +				'L_DOWNLOAD_COUNT'		=> $user->lang($l_downloaded_viewed, (int) $attachment['download_count']),  			);  		} @@ -1106,8 +1186,8 @@ function extension_allowed($forum_id, $extension, &$extensions)  * @param string $string The text to truncate to the given length. String is specialchared.  * @param int $max_length Maximum length of string (multibyte character count as 1 char / Html entity count as 1 char)  * @param int $max_store_length Maximum character length of string (multibyte character count as 1 char / Html entity count as entity chars). -* @param bool $allow_reply Allow Re: in front of string  -* 	NOTE: This parameter can cause undesired behavior (returning strings longer than $max_store_length) and is deprecated.  +* @param bool $allow_reply Allow Re: in front of string +* 	NOTE: This parameter can cause undesired behavior (returning strings longer than $max_store_length) and is deprecated.  * @param string $append String to be appended  */  function truncate_string($string, $max_length = 60, $max_store_length = 255, $allow_reply = false, $append = '') @@ -1178,6 +1258,7 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al  function get_username_string($mode, $user_id, $username, $username_colour = '', $guest_username = false, $custom_profile_url = false)  {  	static $_profile_cache; +	global $phpbb_dispatcher;  	// We cache some common variables we need within this function  	if (empty($_profile_cache)) @@ -1255,10 +1336,50 @@ function get_username_string($mode, $user_id, $username, $username_colour = '',  	if (($mode == 'full' && !$profile_url) || $mode == 'no_profile')  	{ -		return str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_noprofile'] : $_profile_cache['tpl_noprofile_colour']); +		$username_string = str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_noprofile'] : $_profile_cache['tpl_noprofile_colour']); +	} +	else +	{ +		$username_string = str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_profile'] : $_profile_cache['tpl_profile_colour']);  	} +	 +	/** +	* Use this event to change the output of get_username_string() +	* +	* @event core.modify_username_string +	* @var string mode				profile|username|colour|full|no_profile +	* @var int user_id				String or array of additional url +	*								parameters +	* @var string username			The user's username +	* @var string username_colour	The user's colour +	* @var string guest_username	Optional parameter to specify the +	*								guest username. +	* @var string custom_profile_url Optional parameter to specify a +	*								profile url. +	* @var string username_string	The string that has been generated +	* @var array _profile_cache		Array of original return templates +	* @since 3.1-A1 +	*/ +	$vars = array('mode', 'user_id', 'username', 'username_colour', 'guest_username', 'custom_profile_url', 'username_string', '_profile_cache'); +	extract($phpbb_dispatcher->trigger_event('core.modify_username_string', compact($vars))); + +	return $username_string; +} -	return str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_profile'] : $_profile_cache['tpl_profile_colour']); +/** + * Add an option to the quick-mod tools. + * + * @param string $option The language key for the value of the option. + * @param string $lang_string The language string to use. + */ +function phpbb_add_quickmod_option($option, $lang_string) +{ +	global $template, $user; +	$lang_string = $user->lang($lang_string); +	$template->assign_block_vars('quickmod', array( +		'VALUE'  => $option, +		'TITLE'    => $lang_string, +	));  }  /** @@ -1354,5 +1475,3 @@ class bitfield  		$this->data = $this->data | $bitfield->get_blob();  	}  } - -?>
\ No newline at end of file | 
