aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2006-10-02 15:11:40 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2006-10-02 15:11:40 +0000
commitcc4a0a2f7a02f909735d265f4f199f9736c30a48 (patch)
treeaa984be5c8fca4b1f05d7fa755b2f3d382a89cf7 /phpBB/includes/functions.php
parentfc76c94ab14993f98e0bbbf8b26150886ce69352 (diff)
downloadforums-cc4a0a2f7a02f909735d265f4f199f9736c30a48.tar
forums-cc4a0a2f7a02f909735d265f4f199f9736c30a48.tar.gz
forums-cc4a0a2f7a02f909735d265f4f199f9736c30a48.tar.bz2
forums-cc4a0a2f7a02f909735d265f4f199f9736c30a48.tar.xz
forums-cc4a0a2f7a02f909735d265f4f199f9736c30a48.zip
consistent acp layout regarding backlinks and messages.
git-svn-id: file:///svn/phpbb/trunk@6428 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r--phpBB/includes/functions.php22
1 files changed, 17 insertions, 5 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 6093976084..8ada82cffe 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -2683,10 +2683,17 @@ function get_preg_expression($mode)
* Truncates string while retaining special characters if going over the max length
* The default max length is 60 at the moment
*/
-function truncate_string($string, $max_length = 60)
+function truncate_string($string, $max_length = 60, $allow_reply = true)
{
$chars = array();
+ $strip_reply = false;
+ if ($allow_reply && strpos($string, 'Re: ') === 0)
+ {
+ $strip_reply = true;
+ $string = substr($string, 4);
+ }
+
// split the multibyte characters first
$string_ary = preg_split('/(&#[0-9]+;)/', $string, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
@@ -2705,13 +2712,18 @@ function truncate_string($string, $max_length = 60)
}
// Now check the length ;)
- if (sizeof($chars) <= $max_length)
+ if (sizeof($chars) > $max_length)
+ {
+ // Cut off the last elements from the array
+ $string = implode('', array_slice($chars, 0, $max_length));
+ }
+
+ if ($strip_reply)
{
- return $string;
+ $string = 'Re: ' . $string;
}
- // Cut off the last elements from the array
- return implode('', array_slice($chars, 0, $max_length));
+ return $string;
}