Skip to content

Commit

Permalink
Merge pull request #57 from rica-carv/revert-56-rica-carv-patch-textt…
Browse files Browse the repository at this point in the history
…runcate

Revert "Add files via upload"
  • Loading branch information
rica-carv authored Aug 3, 2024
2 parents c8483ad + 3de1ea4 commit 6a7eeb0
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions e107_handlers/e_parse_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1275,18 +1275,16 @@ public function html_truncate($text, $length = 100, $ending = '...', $exact = tr

/**
* @param string $text string to process
* @param integer $len length of characters to be truncated, if it has 'w' at the end, it truncates on word instead of chars (example: limit=50w)
* @param integer $len length of characters to be truncated
* @param string $more string which will be added if truncation
* @return string Always returns text.
* @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
*
*/
public function text_truncate($text, $lenght = 200, $more = ' ... ')
public function text_truncate($text, $len = 200, $more = ' ... ')
{

$len = intval($lenght);

if ($this->ustrlen($text) <= $len)
{
Expand All @@ -1298,16 +1296,15 @@ public function text_truncate($text, $lenght = 200, $more = ' ... ')
$text = $this->toText($text);
}


$text = html_entity_decode($text, ENT_QUOTES, 'utf-8');

if (stristr($lenght, "w") && false !== ($p = strpos(wordwrap($text, $len, $more), $more)))
{$ret = sprintf('%.'. $p . 's', $text);}
elseif (function_exists('mb_strimwidth'))
if (function_exists('mb_strimwidth'))
{
return mb_strimwidth($text, 0, $len, $more);
}
else
{$ret = $this->usubstr($text, 0, $len);}

$ret = $this->usubstr($text, 0, $len);

// search for possible broken html entities
// - if an & is in the last 8 chars, removing it and whatever follows shouldn't hurt
Expand Down Expand Up @@ -4311,14 +4308,22 @@ public function toAvatar($userData = null, $options = array())
$image = (!empty($userData['user_image'])) ? varset($userData['user_image']) : null;

$genericFile = e_IMAGE . 'generic/blank_avatar.jpg';
$genericImg = $tp->thumbUrl($genericFile, 'w=' . $width . '&h=' . $height, true, $full);
$genericImg = $tp->thumbUrl($genericFile, 'w=' . $width . '&h=' . $height, false, $full);

if (!empty($image))
{

if (strpos($image, '://') !== false) // Remote Image
{
$url = $image;
if (@fopen($image, 'r'))
{
$url = $image;
}
else
{
$file = $genericFile;
$url = $genericImg;
}
}
elseif (strpos($image, '-upload-') === 0)
{
Expand Down

0 comments on commit 6a7eeb0

Please sign in to comment.