2012-06-07 Hirofumi Kosaka <kosaka@rworks.jp>
* include/functions_ui.php: Merged from 4.0.x: Fixed bug: string truncation did not always work for multi-byte characters. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6437 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
5c009d2ddc
commit
0a8d926336
|
@ -1,3 +1,9 @@
|
||||||
|
2012-06-07 Hirofumi Kosaka <kosaka@rworks.jp>
|
||||||
|
|
||||||
|
* include/functions_ui.php: Merged from 4.0.x: Fixed bug:
|
||||||
|
string truncation did not always work for multi-byte
|
||||||
|
characters.
|
||||||
|
|
||||||
2012-06-07 Dario Rodriguez <dario.rodriguez@artica.es>
|
2012-06-07 Dario Rodriguez <dario.rodriguez@artica.es>
|
||||||
|
|
||||||
* operation/tree.php,
|
* operation/tree.php,
|
||||||
|
|
|
@ -52,12 +52,13 @@ function ui_print_truncate_text($text, $numChars = 25, $showTextInAToopTip = tru
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = io_safe_output($text);
|
$text = io_safe_output($text);
|
||||||
if ((strlen($text)) > ($numChars)) {
|
if (mb_strlen($text, "UTF-8") > ($numChars)) {
|
||||||
$half_length = intval(($numChars - 3) / 2); // '/2' because [...] is in the middle of the word.
|
$half_length = intval(($numChars - 3) / 2); // '/2' because [...] is in the middle of the word.
|
||||||
$truncateText2 = mb_strimwidth($text, (strlen($text) - $half_length), strlen($text));
|
// Depending on the strange behavior of mb_strimwidth() itself,
|
||||||
// In case $numChars were an odd number.
|
// the 3rd parameter is not to be $numChars but the length of original text (just means 'large enough').
|
||||||
$half_length = $numChars - $half_length - 3;
|
$truncateText2 = mb_strimwidth($text, (mb_strlen($text, "UTF-8") - $half_length), strlen($text), "", "UTF-8" );
|
||||||
$truncateText = mb_strimwidth($text, 0, $half_length) . $suffix;
|
|
||||||
|
$truncateText = mb_strimwidth($text, 0, ($numChars - $half_length), $suffix, "UTF-8");
|
||||||
$truncateText=$truncateText . $truncateText2;
|
$truncateText=$truncateText . $truncateText2;
|
||||||
|
|
||||||
if ($showTextInTitle) {
|
if ($showTextInTitle) {
|
||||||
|
|
Loading…
Reference in New Issue