diff --git a/includes/functions.php b/includes/functions.php
index d049ab01..093b75fd 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -128,27 +128,6 @@ function character_limit(&$title, $limit = 0)
}
}
-/**
-* Cut post text to given length
-*
-* @param string $message post text
-* @param string $bbcode_uid bbcode uid
-* @param int $length The desired length
-*
-* @return string Shortened message
-*/
-function get_sub_taged_string($message, $bbcode_uid, $length)
-{
- if (class_exists('\Nickvergessen\TrimMessage\TrimMessage'))
- {
- $trim = new \Nickvergessen\TrimMessage\TrimMessage($message, $bbcode_uid, $length);
- $message = $trim->message();
- unset($trim);
- }
-
- return $message;
-}
-
function ap_validate($str)
{
$s = str_replace('
', '
', $str);
diff --git a/portal/fetch_posts.php b/portal/fetch_posts.php
index 9616b605..8931fe3b 100644
--- a/portal/fetch_posts.php
+++ b/portal/fetch_posts.php
@@ -627,7 +627,7 @@ class fetch_posts
if ($text_length > 0 && (strlen($row['post_text']) > $text_length))
{
$message = str_replace(array("\n", "\r"), array('
', "\n"), $row['post_text']);
- $message = get_sub_taged_string($message, $row['bbcode_uid'], $text_length);
+ $message = $this->shorten_message($message, $row['bbcode_uid'], $text_length);
$posts_striped = true;
}
else
@@ -637,4 +637,25 @@ class fetch_posts
return $message;
}
+
+ /**
+ * Shorten message to specified length
+ *
+ * @param string $message Post text
+ * @param string $bbcode_uid BBCode UID
+ * @param int $length Length the text should have after shortening
+ *
+ * @return string Shortened messsage
+ */
+ public function shorten_message($message, $bbcode_uid, $length)
+ {
+ if (class_exists('\Nickvergessen\TrimMessage\TrimMessage'))
+ {
+ $trim = new \Nickvergessen\TrimMessage\TrimMessage($message, $bbcode_uid, $length);
+ $message = $trim->message();
+ unset($trim);
+ }
+
+ return $message;
+ }
}
diff --git a/tests/unit/portal/fetch_posts_test.php b/tests/unit/portal/fetch_posts_test.php
index 557b77c5..1d23faed 100644
--- a/tests/unit/portal/fetch_posts_test.php
+++ b/tests/unit/portal/fetch_posts_test.php
@@ -10,6 +10,9 @@
require_once(dirname(__FILE__) . '/../../../../../../includes/functions_acp.php');
require_once(dirname(__FILE__) . '/../../../../../../includes/functions.php');
require_once(dirname(__FILE__) . '/../../../../../../includes/utf/utf_tools.php');
+require_once(dirname(__FILE__) . '/../../../vendor/nickvergessen/phpbb-tool-trimmessage/src/Nickvergessen/TrimMessage/TrimMessage.php');
+require_once(dirname(__FILE__) . '/../../../vendor/nickvergessen/phpbb-tool-trimmessage/src/Nickvergessen/TrimMessage/PhpbbBbcodes.php');
+
class phpbb_portal_fetch_posts_test extends \board3\portal\tests\testframework\database_test_case
{