8 use Elgg\Traits\Loggable;
 
   10 use Pelago\Emogrifier\CssInliner;
 
   11 use Pelago\Emogrifier\HtmlProcessor\CssToAttributeConverter;
 
   12 use Pelago\Emogrifier\HtmlProcessor\CssVariableEvaluator;
 
   39     public const MENTION_REGEX = 
'/<a[^>]*?>.*?<\/a>|<.*?>|(^|\s|\!|\.|\?|>|\G)+(@([^\s<&]+))/iu';
 
  108             'parse_urls' => true,
 
  109             'parse_emails' => true,
 
  110             'parse_mentions' => true,
 
  120         $params = $this->events->triggerResults(
'prepare', 
'html', [], 
$params);
 
  157         $linkify = new \Misd\Linkify\Linkify();
 
  159         return $linkify->processUrls(
$text, [
'attr' => [
'rel' => 
'nofollow']]);
 
  171         $linkify = new \Misd\Linkify\Linkify();
 
  173         return $linkify->processEmails(
$text, [
'attr' => [
'rel' => 
'nofollow']]);
 
  185         $callback = function (array $matches) {
 
  219             return $preceding_char . $replacement . $period;
 
  222         return preg_replace_callback(self::MENTION_REGEX, $callback, 
$text) ?? 
$text;
 
  234             $result = $this->autop->process($string);
 
  239             $this->getLogger()->warning(
'AutoParagraph failed to process the string: ' . $e->getMessage());
 
  276         foreach (
$attrs as $attr => $val) {
 
  277             if (!str_starts_with($attr, 
'data-') && str_contains($attr, 
'_')) {
 
  282             $attr = strtolower($attr);
 
  284             if (!isset($val) || $val === 
false) {
 
  292             if (is_array($val) && empty($val)) {
 
  297             if (is_scalar($val)) {
 
  301             if (!is_array($val)) {
 
  306             $filtered_val = array_filter($val, 
function($e) {
 
  307                 return is_scalar($e);
 
  310             if (count($val) != count($filtered_val)) {
 
  314             $val = implode(
' ', $val);
 
  316             $val = htmlspecialchars($val, ENT_QUOTES, 
'UTF-8', 
false);
 
  357             'area', 
'base', 
'br', 
'col', 
'embed', 
'hr', 
'img', 
'input', 
'keygen', 
'link', 
'menuitem',
 
  358             'meta', 
'param', 
'source', 
'track', 
'wbr' 
  362             $double_encode = !empty(
$options[
'double_encode']);
 
  363             $text = htmlspecialchars(
$text, ENT_QUOTES | ENT_SUBSTITUTE, 
'UTF-8', $double_encode);
 
  375             return empty(
$options[
'is_xml']) ? 
"<{$tag_name}{$attrs}>" : 
"<{$tag_name}{$attrs} />";
 
  378         return "<{$tag_name}{$attrs}>$text</$tag_name>";
 
  391     public function stripTags(
string $string, ?
string $allowable_tags = 
null): string {
 
  393             'original_string' => $string,
 
  394             'allowable_tags' => $allowable_tags,
 
  397         $space_placeholder = 
'{{elgg_space}}';
 
  398         $string = preg_replace(
'/(\S)<(' . implode(
'|', self::BLOCK_LEVEL_ELEMENTS) . 
')([ >\/])/', 
'$1' . $space_placeholder . 
'<$2$3', $string);
 
  399         $string = strip_tags($string, $allowable_tags);
 
  400         $string = preg_replace(
'/(' . $space_placeholder . 
')+/', 
' ', $string);
 
  402         return (
string) $this->events->triggerResults(
'format', 
'strip_tags', 
$params, $string);
 
  432     public function decode(
string $string): string {
 
  433         $string = str_replace(
 
  434             [
'>', 
'<', 
'&', 
'"', 
'''],
 
  435             [
'&gt;', 
'&lt;', 
'&amp;', 
'&quot;', 
'&#039;'],
 
  438         $string = html_entity_decode($string, ENT_NOQUOTES, 
'UTF-8');
 
  440             [
'&gt;', 
'&lt;', 
'&amp;', 
'&quot;', 
'&#039;'],
 
  441             [
'>', 
'<', 
'&', 
'"', 
'''],
 
  462         $html_with_inlined_css = CssInliner::fromHtml(
$html)->disableStyleBlocksParsing()->inlineCss(
$css)->render();
 
  463         $html_with_css_variables = CssVariableEvaluator::fromHtml($html_with_inlined_css)->evaluateVariables()->render();
 
  464         $inlined_attribute_converter = CssToAttributeConverter::fromHtml($html_with_css_variables)->convertCssToVisualAttributes();
 
  466         return $body_only ? $inlined_attribute_converter->renderBodyContent() : $inlined_attribute_converter->render();
 
  479         $pattern = 
'/\s(?:href|src)=([\'"]\S+[\'"])/i';
 
  483         preg_match_all($pattern, 
$text, $matches);
 
  485         if (empty($matches) || !isset($matches[1])) {
 
  491         $urls = array_unique($urls);
 
  493         foreach ($urls as 
$url) {
 
  495             $real_url = substr(
$url, 1, -1);
 
  499             $replacement = str_replace($real_url, $new_url, 
$url);
 
$params
Saves global plugin settings.
$attributes
Elgg AJAX loader.
Could not register a new user for whatever reason.
Exception thrown if an argument is not of the expected type.
Exception thrown if an error which can only be found on runtime occurs.
Create wrapper P and BR elements in HTML depending on newlines.
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
if($who_can_change_language==='nobody') elseif($who_can_change_language==='admin_only' &&!elgg_is_admin_logged_in()) $options
foreach($plugin_guids as $guid) if(empty($deactivated_plugins)) $url
_elgg_services()
Get the global service provider.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
elgg_get_user_by_username(string $username, bool $try_email=false)
Get a user by username.
elgg_view_url(string $href, ?string $text=null, array $options=[])
Helper function for outputting urls.
if(empty($title) &&empty($body)) if(!empty($link)) $attrs
elgg_normalize_url(string $url)
$html
A wrapper to render a section of the page shell.
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.