From 3c5cbd014bb23c77129dea9d30a6f592289b5572 Mon Sep 17 00:00:00 2001 From: Jim Hu Date: Tue, 23 Dec 2008 10:20:50 +0000 Subject: bug fixes from tracker --- functions/draw_functions.php | 32 ++++++++++++++++++++++++++++++-- templates/default/sidebar.tpl | 2 +- templates/default/sidebar_year.tpl | 2 +- templates/green/sidebar.tpl | 2 +- templates/grey/sidebar.tpl | 2 +- templates/red/sidebar.tpl | 2 +- templates/red/sidebar_year.tpl | 2 +- templates/tan/sidebar.tpl | 2 +- 8 files changed, 37 insertions(+), 9 deletions(-) diff --git a/functions/draw_functions.php b/functions/draw_functions.php index cc1c363..a5a98a9 100644 --- a/functions/draw_functions.php +++ b/functions/draw_functions.php @@ -40,8 +40,36 @@ function drawEventTimes ($start, $end) { function word_wrap($str, $length, $lines=0) { if ($lines > 0) { $len = $length * $lines; - if ($len < strlen($str)) { - $str = substr($str,0,$len).'...'; + //if ($len < strlen($str)) { + // $str = substr($str,0,$len).'...'; + //} + $rstr=bite_str($str,0,$len+1); + } + return $rstr; +} + +// String intercept By Bleakwind +// utf-8:$byte=3 | gb2312:$byte=2 | big5:$byte=2 +function bite_str($string, $start, $len, $byte=3){ + $str = ""; + $count = 0; + $str_len = strlen($string); + for ($i=0; $i<$str_len; $i++) { + if (($count+1-$start)>$len) { + $str .= "..."; + break; + } elseif ((ord(substr($string,$i,1)) <= 128) && ($count < $start)){ + $count++; + } elseif ((ord(substr($string,$i,1)) > 128) && ($count < $start)){ + $count = $count+2; + $i = $i+$byte-1; + } elseif ((ord(substr($string,$i,1)) <= 128) && ($count >= $start)){ + $str .= substr($string,$i,1); + $count++; + } elseif ((ord(substr($string,$i,1)) > 128) && ($count >= $start)){ + $str .= substr($string,$i,$byte); + $count = $count+2; + $i = $i+$byte-1; } } return $str; diff --git a/templates/default/sidebar.tpl b/templates/default/sidebar.tpl index e5aa36a..8a96ae6 100644 --- a/templates/default/sidebar.tpl +++ b/templates/default/sidebar.tpl @@ -23,7 +23,7 @@
-
+
diff --git a/templates/default/sidebar_year.tpl b/templates/default/sidebar_year.tpl index f4b40d9..bdbb2d3 100644 --- a/templates/default/sidebar_year.tpl +++ b/templates/default/sidebar_year.tpl @@ -23,7 +23,7 @@
-
+
diff --git a/templates/green/sidebar.tpl b/templates/green/sidebar.tpl index e5aa36a..8a96ae6 100644 --- a/templates/green/sidebar.tpl +++ b/templates/green/sidebar.tpl @@ -23,7 +23,7 @@
-
+
diff --git a/templates/grey/sidebar.tpl b/templates/grey/sidebar.tpl index e5aa36a..8a96ae6 100644 --- a/templates/grey/sidebar.tpl +++ b/templates/grey/sidebar.tpl @@ -23,7 +23,7 @@
-
+
diff --git a/templates/red/sidebar.tpl b/templates/red/sidebar.tpl index e5aa36a..8a96ae6 100644 --- a/templates/red/sidebar.tpl +++ b/templates/red/sidebar.tpl @@ -23,7 +23,7 @@
-
+
diff --git a/templates/red/sidebar_year.tpl b/templates/red/sidebar_year.tpl index f4b40d9..bdbb2d3 100644 --- a/templates/red/sidebar_year.tpl +++ b/templates/red/sidebar_year.tpl @@ -23,7 +23,7 @@
-
+
diff --git a/templates/tan/sidebar.tpl b/templates/tan/sidebar.tpl index e5aa36a..8a96ae6 100644 --- a/templates/tan/sidebar.tpl +++ b/templates/tan/sidebar.tpl @@ -23,7 +23,7 @@
-
+
-- cgit v1.2.3