better handle urls
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user