Add link shortening for http links in sms, using YOURLS

This commit is contained in:
osaajani 2023-09-17 16:16:35 +02:00
parent fb3f9425d1
commit 241d079ffb
6 changed files with 140 additions and 1 deletions

View file

@ -85,6 +85,22 @@ use BenMorel\GsmCharsetConverter\Converter;
return '<a href="' . self::s($url, false, true, false) . '">' . self::s($number_format, false, true, false) . '</a>';
}
/**
* Check for http link in a text
*
* @param string $text : Text to search a link in
*
* @return bool|array : False if no link in the text, or an array of all http links
*/
public static function search_http_links($text)
{
$regex = "#http(s?)://\S+#i";
$matches = [];
$nb_matches = preg_match_all($regex, $text, $matches);
return $nb_matches > 0 ? $matches[0] : false;
}
/**
* Cette fonction fait la correspondance entre un type d'evenement et une icone font awesome.
*