diff --git a/pi.excerpt.php b/pi.excerpt.php index 0fe7067..25e9220 100644 --- a/pi.excerpt.php +++ b/pi.excerpt.php @@ -52,16 +52,26 @@ public function __construct() // Strip tags $content = trim(strip_tags($content, $allow_param)); - + $append = false; + if (isset($chars_param) && $chars_param != "") { $content = substr($content, 0, $chars_param); + $append = (strlen($content)>$chars_param); } elseif (isset($words_param) && $words_param != "") { - $content = implode(' ', array_slice(explode(' ', $content), 0, $words_param)); + $words = explode(' ', $content); + $content = implode(' ', array_slice($words, 0, $words_param)); + $append = (count($words)>$words_param); } elseif (isset($cutoff_param) && $cutoff_param != "") { - $content = explode($cutoff_param, $content, 2)[0]; + $exploded = explode($cutoff_param, $content, 2); + $content = $exploded[0]; + $append = (count($exploded)>1); } - $this->return_data = $content . $append_param; + if ($append) + { + $content .= $append_param; + } + $this->return_data = $content; } /** @@ -111,4 +121,4 @@ public static function usage() } /* End of file pi.excerpt.php */ -/* Location: /system/user/addons/excerpt/pi.excerpt.php */ \ No newline at end of file +/* Location: /system/user/addons/excerpt/pi.excerpt.php */