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
+17
View File
@@ -31,6 +31,23 @@ class WidgetFactory
"</div>";
}
/**
* Convert the given string to a-href if it is a link.
*
* @param $href
* @return string
*/
public function tryLink($href)
{
$href = trim($href);
if (starts_with($href, ['http://', 'https://', 'mailto:', 'ftp://'])) {
$href_e = e($href);
return "<a href=\"".$href_e."\">".$href_e."</a>";
} else {
return $href;
}
}
public function collapsible($text, $thrSize, $maxHeight)
{
return new CollapsibleTextBoxWidget($text, $thrSize, $maxHeight);