38 public const MENTION_REGEX =
'/<a[^>]*?>.*?<\/a>|<.*?>|(^|\s|\!|\.|\?|>|\G)+(@([^\s<&]+))/iu';
70 'parse_emails' =>
true,
71 'parse_mentions' =>
true,
81 $params = $this->events->triggerResults(
'prepare',
'html', [],
$params);
118 $linkify = new \Misd\Linkify\Linkify();
120 return $linkify->processUrls($text, [
'attr' => [
'rel' =>
'nofollow']]);
132 $linkify = new \Misd\Linkify\Linkify();
134 return $linkify->processEmails($text, [
'attr' => [
'rel' =>
'nofollow']]);
146 $callback =
function (array $matches) {
180 return $preceding_char . $replacement . $period;
183 return preg_replace_callback(self::MENTION_REGEX, $callback, $text) ??
$text;
195 $result = $this->autop->process($string);
200 $this->
getLogger()->warning(
'AutoParagraph failed to process the string: ' . $e->getMessage());
237 foreach (
$attrs as $attr => $val) {
238 if (!str_starts_with($attr,
'data-') && str_contains($attr,
'_')) {
243 $attr = strtolower($attr);
245 if (!isset($val) || $val ===
false) {
253 if (is_array($val) && empty($val)) {
258 if (is_scalar($val)) {
262 if (!is_array($val)) {
267 $filtered_val = array_filter($val,
function($e) {
268 return is_scalar($e);
277 $val = htmlspecialchars($val, ENT_QUOTES,
'UTF-8',
false);
312 if ($tag_name ===
'') {
317 $is_void =
$options[
'is_void'] ?? in_array(strtolower($tag_name), [
318 'area',
'base',
'br',
'col',
'embed',
'hr',
'img',
'input',
'keygen',
'link',
'menuitem',
319 'meta',
'param',
'source',
'track',
'wbr' 323 $double_encode = !empty(
$options[
'double_encode']);
324 $text = htmlspecialchars(
$text, ENT_QUOTES | ENT_SUBSTITUTE,
'UTF-8', $double_encode);
336 return empty(
$options[
'is_xml']) ?
"<{$tag_name}{$attrs}>" :
"<{$tag_name}{$attrs} />";
339 return "<{$tag_name}{$attrs}>$text</$tag_name>";
352 public function stripTags(
string $string,
string $allowable_tags = null): string {
354 'original_string' => $string,
355 'allowable_tags' => $allowable_tags,
358 $string = strip_tags($string, $allowable_tags);
359 return (
string) $this->events->triggerResults(
'format',
'strip_tags',
$params, $string);
389 public function decode(
string $string): string {
391 [
'>',
'<',
'&',
'"',
'''],
392 [
'&gt;',
'&lt;',
'&amp;',
'&quot;',
'&#039;'],
395 $string = html_entity_decode($string, ENT_NOQUOTES,
'UTF-8');
397 [
'&gt;',
'&lt;',
'&amp;',
'&quot;',
'&#039;'],
398 [
'>',
'<',
'&',
'"',
'''],
415 if (empty($html) || empty($css)) {
419 $html_with_inlined_css = CssInliner::fromHtml($html)->disableStyleBlocksParsing()->inlineCss($css)->render();
420 $inlined_attribute_converter = CssToAttributeConverter::fromHtml($html_with_inlined_css)->convertCssToVisualAttributes();
422 return $body_only ? $inlined_attribute_converter->renderBodyContent() : $inlined_attribute_converter->render();
435 $pattern =
'/\s(?:href|src)=([\'"]\S+[\'"])/i';
439 preg_match_all($pattern, $text, $matches);
441 if (empty($matches) || !isset($matches[1])) {
447 $urls = array_unique($urls);
449 foreach ($urls as
$url) {
451 $real_url =
substr($url, 1, -1);
455 $replacement =
str_replace($real_url, $new_url, $url);
Exception thrown if an argument is not of the expected type.
$params
Saves global plugin settings.
Exception thrown if an error which can only be found on runtime occurs.
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
Elgg registration action.
elgg_get_user_by_username(string $username, bool $try_email=false)
Get a user by username.
Could not register a new user for whatever reason.
Create wrapper P and BR elements in HTML depending on newlines.
$html
A wrapper to render a section of the page shell.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
if($who_can_change_language=== 'nobody') elseif($who_can_change_language=== 'admin_only'&&!elgg_is_admin_logged_in()) $options
trait Loggable
Enables adding a logger.
getLogger()
Returns logger.
elgg_view_url(string $href, string $text=null, array $options=[])
Helper function for outputting urls.
foreach($plugin_guids as $guid) if(empty($deactivated_plugins)) $url
_elgg_services()
Get the global service provider.
elgg_normalize_url(string $url)
$attributes
Elgg AJAX loader.
if(empty($title)&&empty($body)) if(!empty($link)) $attrs