aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2007-07-15 20:53:27 +0000
committerNils Adermann <naderman@naderman.de>2007-07-15 20:53:27 +0000
commit909e195a9b54f38294f217ee8e10b17a62876756 (patch)
tree2d7999ce793f784c8a0915c98bf957b322c8952e /phpBB/includes/functions.php
parentf27fa04b8c7f6d668e9cc651afaa10334f5d7067 (diff)
downloadforums-909e195a9b54f38294f217ee8e10b17a62876756.tar
forums-909e195a9b54f38294f217ee8e10b17a62876756.tar.gz
forums-909e195a9b54f38294f217ee8e10b17a62876756.tar.bz2
forums-909e195a9b54f38294f217ee8e10b17a62876756.tar.xz
forums-909e195a9b54f38294f217ee8e10b17a62876756.zip
- search result extract shouldn't end in the middle of a multibyte character [Bug #11863]
- missing localisation for an imageset shouldn't create lots of "imageset refreshed" log messages [Bug #12027] - explain that themes which need parsing cannot be stored on the filesystem [Bug #11134] - normalize usernames (we really need to make sure we normalize everything) - improved utf8_clean_string, more complete list of homographs and NFKC normalization, also the resulting string is now trimmed - corrected searching subforums explanation [Bug #12209] git-svn-id: file:///svn/phpbb/trunk@7890 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r--phpBB/includes/functions.php16
1 files changed, 8 insertions, 8 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 661641a2e3..41c022062f 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -2394,7 +2394,7 @@ function get_context($text, $words, $length = 400)
{
if (preg_match('#(?:[^\w]|^)(' . $word . ')(?:[^\w]|$)#i', $text, $match))
{
- $pos = strpos($text, $match[1]);
+ $pos = utf8_strpos($text, $match[1]);
if ($pos !== false)
{
$word_indizes[] = $pos;
@@ -2417,21 +2417,21 @@ function get_context($text, $words, $length = 400)
$final_text_index = -1;
// cycle through every character in the original text
- for ($i = $word_indizes[$word], $n = strlen($text); $i < $n; $i++)
+ for ($i = $word_indizes[$word], $n = utf8_strlen($text); $i < $n; $i++)
{
// if the current position is the start of one of the words then append $sequence_length characters to the final text
if (isset($word_indizes[$word]) && ($i == $word_indizes[$word]))
{
if ($final_text_index < $i - $sequence_length - 1)
{
- $final_text .= '... ' . preg_replace('#^([^ ]*)#', '', substr($text, $i - $sequence_length, $sequence_length));
+ $final_text .= '... ' . preg_replace('#^([^ ]*)#', '', utf8_substr($text, $i - $sequence_length, $sequence_length));
}
else
{
// if the final text is already nearer to the current word than $sequence_length we only append the text
// from its current index on and distribute the unused length to all other sequenes
$sequence_length += (int) (($final_text_index - $i + $sequence_length + 1) / (2 * $wordnum));
- $final_text .= substr($text, $final_text_index + 1, $i - $final_text_index - 1);
+ $final_text .= utf8_substr($text, $final_text_index + 1, $i - $final_text_index - 1);
}
$final_text_index = $i - 1;
@@ -2443,17 +2443,17 @@ function get_context($text, $words, $length = 400)
if ($j > 0)
{
// add the character to the final text and increment the sequence counter
- $final_text .= $text[$i];
+ $final_text .= utf8_substr($text, $i, 1);
$final_text_index++;
$j++;
// if this is a whitespace then check whether we are done with this sequence
- if ($text[$i] == ' ')
+ if (utf8_substr($text, $i, 1) == ' ')
{
// only check whether we have to exit the context generation completely if we haven't already reached the end anyway
if ($i + 4 < $n)
{
- if (($j > $sequence_length && $word >= $wordnum) || strlen($final_text) > $length)
+ if (($j > $sequence_length && $word >= $wordnum) || utf8_strlen($final_text) > $length)
{
$final_text .= ' ...';
break;
@@ -2479,7 +2479,7 @@ function get_context($text, $words, $length = 400)
if (!sizeof($words) || !sizeof($word_indizes))
{
- return (strlen($text) >= $length + 3) ? substr($text, 0, $length) . '...' : $text;
+ return (utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text;
}
}