1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-07 07:06:30 +02:00

Fix for HTML used on text_truncate(). Ignore setcookie() in CLI mode.

This commit is contained in:
Cameron
2021-01-18 07:40:17 -08:00
parent ba313c558c
commit 419a0e727a
9 changed files with 171 additions and 24 deletions

View File

@@ -1071,7 +1071,32 @@ class e_parse
return $drain;
}
/**
* Universal text/bbcode/html truncate method.
* new in v2.3.1
* @param $text
* @param int $length
* @param string $ending
*/
public function truncate($text, $length = 100, $ending = '...')
{
if($this->isHtml($text))
{
return $this->html_truncate($text, $length, $ending);
}
if($this->isBBcode($text))
{
$text = $this->toText($text);
}
return $this->text_truncate($text, $length, $ending);
}
/**
* @deprecated Soon to be made private. Use $tp->truncate() instead.
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
*
@@ -1177,25 +1202,34 @@ class e_parse
}
/**
* Truncate a string of text to a maximum length $len ­ append the string $more if it was truncated
* Uses current CHARSET ­ for utf-8, returns $len characters rather than $len bytes
* @deprecated for public use. Will be made private. Use $tp->truncate() instead.
* Truncate a string of text to a maximum length $len append the string $more if it was truncated
* Uses current CHARSET for utf-8, returns $len characters rather than $len bytes
*
* @param string $text ­ string to process
* @param integer $len ­ length of characters to be truncated
* @param string $more ­ string which will be added if truncation
* @return string
* @param string $text string to process
* @param integer $len length of characters to be truncated
* @param string $more string which will be added if truncation
* @return string Always returns text.
*/
public function text_truncate($text, $len = 200, $more = ' ... ')
{
// Always valid
if($this->ustrlen($text) <= $len)
{
return $text;
}
if($this->isBBcode($text) || $this->isHtml($text))
{
$text = $this->toText($text);
}
$text = html_entity_decode($text, ENT_QUOTES, 'utf-8');
if(function_exists('mb_strimwidth'))