Line 289 | Line 289 |
---|
*/ function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_poster, $last_topic_poster) {
|
*/ function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_poster, $last_topic_poster) {
|
global $config, $auth, $user;
| global $config, $auth, $user, $phpbb_dispatcher;
/** * Event to run code before the topic bump checks * * @event core.bump_topic_allowed_before * @var int forum_id ID of the forum * @var int topic_bumped Flag indicating if the topic was already bumped (0/1) * @var int last_post_time The time of the topic last post * @var int topic_poster User ID of the topic author * @var int last_topic_poster User ID of the topic last post author * @since 3.3.14-RC1 */ $vars = [ 'forum_id', 'topic_bumped', 'last_post_time', 'topic_poster', 'last_topic_poster', ]; extract($phpbb_dispatcher->trigger_event('core.bump_topic_allowed_before', compact($vars)));
|
// Check permission and make sure the last post was not already bumped if (!$auth->acl_get('f_bump', $forum_id) || $topic_bumped)
| // Check permission and make sure the last post was not already bumped if (!$auth->acl_get('f_bump', $forum_id) || $topic_bumped)
|
Line 311 | Line 331 |
---|
{ return false; }
|
{ return false; }
|
| /** * Event to run code after the topic bump checks * * @event core.bump_topic_allowed_after * @var int forum_id ID of the forum * @var int topic_bumped Flag indicating if the topic was already bumped (0/1) * @var int last_post_time The time of the topic last post * @var int topic_poster User ID of the topic author * @var int last_topic_poster User ID of the topic last post author * @var int bump_time Bump time range * @since 3.3.14-RC1 */ $vars = [ 'forum_id', 'topic_bumped', 'last_post_time', 'topic_poster', 'last_topic_poster', 'bump_time', ]; extract($phpbb_dispatcher->trigger_event('core.bump_topic_allowed_after', compact($vars)));
|
// A bump time of 0 will completely disable the bump feature... not intended but might be useful. return $bump_time;
| // A bump time of 0 will completely disable the bump feature... not intended but might be useful. return $bump_time;
|
Line 329 | Line 371 |
---|
{ if ($length <= 0) {
|
{ if ($length <= 0) {
|
return '...';
| return $text;
|
}
|
}
|
// we need to turn the entities back into their original form, to not cut the message in between them $text = html_entity_decode($text);
| // We need to turn the entities back into their original form, to not cut the message in between them $text = htmlspecialchars_decode($text);
|
// Replace all spaces/invisible characters with single spaces
|
// Replace all spaces/invisible characters with single spaces
|
$text = preg_replace("/\s+/u", ' ', $text);
| $text = preg_replace("/[\p{Z}\h\v]+/u", ' ', $text);
|
$text_length = utf8_strlen($text);
| $text_length = utf8_strlen($text);
|
Line 351 | Line 393 |
---|
$word_indexes[$pos] = $word; } }
|
$word_indexes[$pos] = $word; } }
|
| |
if (!empty($word_indexes)) { ksort($word_indexes);
| if (!empty($word_indexes)) { ksort($word_indexes);
|
Line 400 | Line 441 |
---|
$fragment_end = $end - $start + 1;
// Find the first valid alphanumeric character in the fragment to don't cut words
|
$fragment_end = $end - $start + 1;
// Find the first valid alphanumeric character in the fragment to don't cut words
|
if ($start > 0)
| if ($start > 0 && preg_match('/[^\p{L}\p{N}][\p{L}\p{N}]/u', $fragment, $matches, PREG_OFFSET_CAPTURE))
|
{
|
{
|
preg_match('/[^a-zA-Z0-9][a-zA-Z0-9]/u', $fragment, $matches, PREG_OFFSET_CAPTURE); $fragment_start = (int) $matches[0][1] + 1; // first valid alphanumeric character
| $fragment_start = utf8_strlen(substr($fragment, 0, (int) $matches[0][1])) + 1;
|
}
// Find the last valid alphanumeric character in the fragment to don't cut words
|
}
// Find the last valid alphanumeric character in the fragment to don't cut words
|
if ($end < $text_length - 1)
| if ($end < $text_length - 1 && preg_match_all('/[\p{L}\p{N}][^\p{L}\p{N}]/u', $fragment, $matches, PREG_OFFSET_CAPTURE))
|
{
|
{
|
preg_match_all('/[a-zA-Z0-9][^a-zA-Z0-9]/u', $fragment, $matches, PREG_OFFSET_CAPTURE); $fragment_end = end($matches[0])[1]; // last valid alphanumeric character
| $fragment_end = utf8_strlen(substr($fragment, 0, end($matches[0])[1]));
|
}
$output[] = utf8_substr($fragment, $fragment_start, $fragment_end - $fragment_start + 1); }
|
}
$output[] = utf8_substr($fragment, $fragment_start, $fragment_end - $fragment_start + 1); }
|
return ($fragments[0][0] !== 0 ? '... ' : '') . htmlentities(implode(' ... ', $output)) . ($end < $text_length - 1 ? ' ...' : '');
| return ($fragments[0][0] !== 0 ? '... ' : '') . utf8_htmlspecialchars(implode(' ... ', $output)) . ($end < $text_length - 1 ? ' ...' : '');
|
}
/**
| }
/**
|