better handle urls

This commit is contained in:
2018-07-28 16:45:03 +02:00
parent f879d195df
commit 3a8d54a569
7 changed files with 59 additions and 21 deletions
+11 -2
View File
@@ -50,7 +50,14 @@ class CollapsibleTextBoxWidget
$out = nl2br($out);
$out = preg_replace('|(https?://[^\s]+)|i', '<a href="\1">\1</a>', $out);
$out = preg_replace_callback('#\b((https?://|ftp://|mailto:)[^\s]+)#i', function($m) {
$href = $m[1];
$text = $href;
if (strpos($text, 'mailto:') === 0) {
$text = str_replace('mailto:', '', $text);
}
return "<a href=\"".e($href)."\">".e($text)."</a>";
}, $out);
return $out;
}
@@ -67,7 +74,9 @@ class CollapsibleTextBoxWidget
}
if ($this->collapsing) {
return '<div class="block-collapse" style="max-height:'.$this->maxHeight.'">' . $prefix . $content . '</div>';
return '<div class="block-collapse"
title="Click to expand / Double-click to collapse"
style="max-height:'.$this->maxHeight.'">' . $prefix . $content . '</div>';
} else {
return $prefix.'<div>' . $prefix . $content . '</div>';
}