mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-18 23:51:49 +02:00
[ticket/15043] Small code cleanup
PHPBB-15043
This commit is contained in:
committed by
Ruben Calvo
parent
67ad543135
commit
7181b05e38
@@ -326,7 +326,6 @@ function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_po
|
|||||||
*/
|
*/
|
||||||
function get_context(string $text, array $words, int $length = 400)
|
function get_context(string $text, array $words, int $length = 400)
|
||||||
{
|
{
|
||||||
$output = '';
|
|
||||||
$text_length = utf8_strlen($text);
|
$text_length = utf8_strlen($text);
|
||||||
|
|
||||||
// Replace all spaces/invisible characters with single spaces
|
// Replace all spaces/invisible characters with single spaces
|
||||||
@@ -335,7 +334,7 @@ function get_context(string $text, array $words, int $length = 400)
|
|||||||
// we need to turn the entities back into their original form, to not cut the message in between them
|
// we need to turn the entities back into their original form, to not cut the message in between them
|
||||||
$text = html_entity_decode($text);
|
$text = html_entity_decode($text);
|
||||||
|
|
||||||
// Get first ocurrence of each word
|
// Get first occurrence of each word
|
||||||
$word_indizes = [];
|
$word_indizes = [];
|
||||||
foreach ($words as $word)
|
foreach ($words as $word)
|
||||||
{
|
{
|
||||||
@@ -374,7 +373,7 @@ function get_context(string $text, array $words, int $length = 400)
|
|||||||
$fragments[] = $fragment;
|
$fragments[] = $fragment;
|
||||||
|
|
||||||
$start = $indize - ($characters_per_word / 2);
|
$start = $indize - ($characters_per_word / 2);
|
||||||
// Start fragment at the begining of a word
|
// Start fragment at the beginning of a word
|
||||||
$end = $start = ($start > 0) ? (utf8_strpos($text, ' ', $start - 1) + 1) : 0;
|
$end = $start = ($start > 0) ? (utf8_strpos($text, ' ', $start - 1) + 1) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user