| Server IP : 104.21.84.107 / Your IP : 104.23.197.209 Web Server : Apache/2.4.63 (Ubuntu) System : Linux adminpruebas-Virtual-Machine 6.14.0-37-generic #37-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 14 22:10:32 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.4.5 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/bienestar/libraries/syw/src/ |
Upload File : |
<?php
/**
* @copyright Copyright (C) 2011 Simplify Your Web, Inc. All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE.txt
*/
namespace SYW\Library;
defined('_JEXEC') or die;
use Joomla\CMS\HTML\Helpers\StringHelper;
class Text
{
/**
* Get text from string with or without stripped html tags
* Strips out Joomla plugin tags
* Joomla 3.1+ only
*
*/
static function getText($text, $type='html', $max_letter_count = 0, $strip_tags = true, $tags_to_keep = '', $strip_plugin_tags = true, $split_last_word = false)
{
if ($max_letter_count == 0) {
return '';
}
if ($max_letter_count > 0) {
if ($type === 'html') {
$text = self::stripPluginTags($text);
if ($strip_tags) {
$text = strip_tags($text, $tags_to_keep);
return StringHelper::truncateComplex($text, $max_letter_count, !$split_last_word);
} else {
return StringHelper::truncateComplex($text, $max_letter_count, !$split_last_word);
}
} else { // 'txt'
return StringHelper::truncate($text, $max_letter_count, !$split_last_word, false); // no html allowed
}
} else { // take everything
if ($type === 'html') {
if ($strip_plugin_tags) {
$text = self::stripPluginTags($text);
}
if ($strip_tags) {
if ($tags_to_keep == '') {
$text = strip_tags($text);
return html_entity_decode($text, ENT_QUOTES, 'UTF-8');
} else {
$text = strip_tags($text, $tags_to_keep);
return html_entity_decode($text, ENT_QUOTES, 'UTF-8');
}
} else {
return html_entity_decode($text, ENT_QUOTES, 'UTF-8');
}
}
}
return $text;
}
static function stripPluginTags($output)
{
$plugins = array();
preg_match_all('/\{\w*/', $output, $matches);
foreach ($matches[0] as $match) {
$match = str_replace('{', '', $match);
if (strlen($match)) {
$plugins[$match] = $match;
}
}
$find = array();
foreach ($plugins as $plugin) {
$find[] = '\{'.$plugin.'\s?.*?\}.*?\{/'.$plugin.'\}';
$find[] = '\{'.$plugin.'\s?.*?\}';
}
if(!empty($find)) {
foreach($find as $key=>$f) {
$f = '/'.str_replace('/','\/',$f).'/';
$find[$key] = $f;
}
$output = preg_replace($find ,'', $output);
}
return $output;
}
}
?>