phpBB

Code Changes

File: includes/functions_content.php

  Unmodified   Added   Modified   Removed
Line 336Line 336
	$text = str_replace($entities, $characters, $text);

$word_indizes = array();

	$text = str_replace($entities, $characters, $text);

$word_indizes = array();

	if (sizeof($words))

	if (count($words))

	{
$match = '';
// find the starting indizes of all words

	{
$match = '';
// find the starting indizes of all words

Line 361Line 361
		}
unset($match);


		}
unset($match);


		if (sizeof($word_indizes))

		if (count($word_indizes))

		{
$word_indizes = array_unique($word_indizes);
sort($word_indizes);


		{
$word_indizes = array_unique($word_indizes);
sort($word_indizes);


			$wordnum = sizeof($word_indizes);

			$wordnum = count($word_indizes);

			// number of characters on the right and left side of each word
$sequence_length = (int) ($length / (2 * $wordnum)) - 2;
$final_text = '';

			// number of characters on the right and left side of each word
$sequence_length = (int) ($length / (2 * $wordnum)) - 2;
$final_text = '';

Line 434Line 434
		}
}


		}
}


	if (!sizeof($words) || !sizeof($word_indizes))

	if (!count($words) || !count($word_indizes))

	{
return str_replace($characters, $entities, ((utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text));
}

	{
return str_replace($characters, $entities, ((utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text));
}

Line 557Line 557
function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text = true)
{
static $bbcode;

function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text = true)
{
static $bbcode;

 
	global $auth, $config, $user;

	global $phpbb_dispatcher, $phpbb_container;

if ($text === '')

	global $phpbb_dispatcher, $phpbb_container;

if ($text === '')

Line 584Line 585

// Temporarily switch off viewcensors if applicable
$old_censor = $renderer->get_viewcensors();


// Temporarily switch off viewcensors if applicable
$old_censor = $renderer->get_viewcensors();

 

// Check here if the user is having viewing censors disabled (and also allowed to do so).
if (!$user->optionget('viewcensors') && $config['allow_nocensors'] && $auth->acl_get('u_chgcensors'))
{
$censor_text = false;
}


		if ($old_censor !== $censor_text)
{
$renderer->set_viewcensors($censor_text);

		if ($old_censor !== $censor_text)
{
$renderer->set_viewcensors($censor_text);

Line 619Line 627
			}
else
{

			}
else
{

				$bbcode->bbcode($bitfield);

				$bbcode->bbcode_set_bitfield($bitfield);

			}

$bbcode->bbcode_second_pass($text, $uid);

			}

$bbcode->bbcode_second_pass($text, $uid);

Line 686Line 694
	* @var bool		allow_url_bbcode	Whether or not to parse the [url] BBCode
* @var string mode Mode to parse text as, e.g. post or sig
* @since 3.1.0-a1

	* @var bool		allow_url_bbcode	Whether or not to parse the [url] BBCode
* @var string mode Mode to parse text as, e.g. post or sig
* @since 3.1.0-a1

	* @changed 3.2.0-a1

	* @changed 3.2.0-a1 Added mode

	*/
$vars = array(
'text',

	*/
$vars = array(
'text',

Line 734Line 742
	* @var string	uid				The BBCode UID
* @var string bitfield The BBCode Bitfield
* @var int flags The BBCode Flags

	* @var string	uid				The BBCode UID
* @var string bitfield The BBCode Bitfield
* @var int flags The BBCode Flags

 
	* @var string	message_parser	The message_parser object

	* @since 3.1.0-a1

	* @since 3.1.0-a1

 
	* @changed 3.1.11-RC1			Added message_parser to vars

	*/

	*/

	$vars = array('text', 'uid', 'bitfield', 'flags');

	$vars = array('text', 'uid', 'bitfield', 'flags', 'message_parser');

	extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_after', compact($vars)));

return $message_parser->warn_msg;

	extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_after', compact($vars)));

return $message_parser->warn_msg;

Line 1011Line 1021
		}
}


		}
}


	if (sizeof($censors))

	if (count($censors))

	{
return preg_replace($censors['match'], $censors['replace'], $text);
}

	{
return preg_replace($censors['match'], $censors['replace'], $text);
}

Line 1069Line 1079
*/
function parse_attachments($forum_id, &$message, &$attachments, &$update_count_ary, $preview = false)
{

*/
function parse_attachments($forum_id, &$message, &$attachments, &$update_count_ary, $preview = false)
{

	if (!sizeof($attachments))

	if (!count($attachments))

	{
return;
}

	{
return;
}

Line 1104Line 1114
	}

// Grab attachments (security precaution)

	}

// Grab attachments (security precaution)

	if (sizeof($attach_ids))

	if (count($attach_ids))

	{
global $db;


	{
global $db;


Line 1141Line 1151

foreach ($attachments as $attachment)
{


foreach ($attachments as $attachment)
{

		if (!sizeof($attachment))

		if (!count($attachment))

		{
continue;
}

		{
continue;
}

Line 1433Line 1443
	$chars = array_map('utf8_htmlspecialchars', $_chars);

// Now check the length ;)

	$chars = array_map('utf8_htmlspecialchars', $_chars);

// Now check the length ;)

	if (sizeof($chars) > $max_length)

	if (count($chars) > $max_length)

	{
// Cut off the last elements from the array
$string = implode('', array_slice($chars, 0, $max_length - utf8_strlen($append)));

	{
// Cut off the last elements from the array
$string = implode('', array_slice($chars, 0, $max_length - utf8_strlen($append)));

Line 1471Line 1481
/**
* Get username details for placing into templates.
* This function caches all modes on first call, except for no_profile and anonymous user - determined by $user_id.

/**
* Get username details for placing into templates.
* This function caches all modes on first call, except for no_profile and anonymous user - determined by $user_id.

 
*
* @html Username spans and links

*
* @param string $mode Can be profile (for getting an url to the profile), username (for obtaining the username), colour (for obtaining the user colour), full (for obtaining a html string representing a coloured link to the users profile) or no_profile (the same as full but forcing no profile link)
* @param int $user_id The users id

*
* @param string $mode Can be profile (for getting an url to the profile), username (for obtaining the username), colour (for obtaining the user colour), full (for obtaining a html string representing a coloured link to the users profile) or no_profile (the same as full but forcing no profile link)
* @param int $user_id The users id

Line 1491Line 1503
	{
global $phpbb_root_path, $phpEx;


	{
global $phpbb_root_path, $phpEx;


 
		/** @html Username spans and links for usage in the template */

		$_profile_cache['base_url'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u={USER_ID}');
$_profile_cache['tpl_noprofile'] = '<span class="username">{USERNAME}</span>';
$_profile_cache['tpl_noprofile_colour'] = '<span style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</span>';

		$_profile_cache['base_url'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&amp;u={USER_ID}');
$_profile_cache['tpl_noprofile'] = '<span class="username">{USERNAME}</span>';
$_profile_cache['tpl_noprofile_colour'] = '<span style="color: {USERNAME_COLOUR};" class="username-coloured">{USERNAME}</span>';

Line 1641Line 1654
		return '';
}


		return '';
}


	$count = sizeof($items);

	$count = count($items);

	$last_item = array_pop($items);
$lang_key = 'STRING_LIST_MULTI';


	$last_item = array_pop($items);
$lang_key = 'STRING_LIST_MULTI';


Line 1662Line 1675
{
var $data;


{
var $data;


	function bitfield($bitfield = '')

	function __construct($bitfield = '')

	{
$this->data = base64_decode($bitfield);
}

	{
$this->data = base64_decode($bitfield);
}

Line 1746Line 1759
	function merge($bitfield)
{
$this->data = $this->data | $bitfield->get_blob();

	function merge($bitfield)
{
$this->data = $this->data | $bitfield->get_blob();

 
	}
}

/**
* Formats the quote according to the given BBCode status setting
*
* @param phpbb\language\language $language Language class
* @param parse_message $message_parser Message parser class
* @param phpbb\textformatter\utils_interface $text_formatter_utils Text formatter utilities
* @param bool $bbcode_status The status of the BBCode setting
* @param array $quote_attributes The attributes of the quoted post
* @param string $message_link Link of the original quoted post
*/
function phpbb_format_quote($language, $message_parser, $text_formatter_utils, $bbcode_status, $quote_attributes, $message_link = '')
{
if ($bbcode_status)
{
$quote_text = $text_formatter_utils->generate_quote(
censor_text($message_parser->message),
$quote_attributes
);

$message_parser->message = $quote_text . "\n\n";
}
else
{
$offset = 0;
$quote_string = "&gt; ";
$message = censor_text(trim($message_parser->message));
// see if we are nesting. It's easily tricked but should work for one level of nesting
if (strpos($message, "&gt;") !== false)
{
$offset = 10;
}
$message = utf8_wordwrap($message, 75 + $offset, "\n");

$message = $quote_string . $message;
$message = str_replace("\n", "\n" . $quote_string, $message);

$message_parser->message = $quote_attributes['author'] . " " . $language->lang('WROTE') . ":\n" . $message . "\n";
}

if ($message_link)
{
$message_parser->message = $message_link . $message_parser->message;

	}
}


	}
}