From: Michael Date: Sun, 20 Aug 2017 19:47:00 +0000 (+0000) Subject: Preparation for Unicode Emojis X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=85c49060e2b11d9f86fa6a42256d5419f7922bf3;p=friendica.git Preparation for Unicode Emojis --- diff --git a/include/Smilies.php b/include/Smilies.php index f4de32f8f8..92b2063e47 100644 --- a/include/Smilies.php +++ b/include/Smilies.php @@ -13,6 +13,26 @@ use Friendica\App; class Smilies { + /** + * @brief Replaces/adds the emoticon list + * + * This function should be used whenever emoticons are added + * + * @param array $b Array of emoticons + * @param string $smiley The text smilie + * @param string $representation The replacement + */ + public static function add(&$b, $smiley, $representation) { + $found = array_search($smiley, $b['texts']); + + if (!is_int($found)) { + $b['texts'][] = $smiley; + $b['icons'][] = $representation; + } else { + $b['icons'][$found] = $representation; + } + } + /** * @brief Function to list all smilies * @@ -107,7 +127,6 @@ class Smilies { call_hooks('smilie', $params); return $params; - } /** @@ -121,12 +140,13 @@ class Smilies { * function from being executed by the prepare_text() routine when preparing * bbcode source for HTML display * - * @param string $s + * @param string $s Text that should be replaced * @param boolean $sample + * @param boolean $no_images Only replace emoticons without images * * @return string HML Output of the Smilie */ - public static function replace($s, $sample = false) { + public static function replace($s, $sample = false, $no_images = false) { if(intval(get_config('system','no_smilies')) || (local_user() && intval(get_pconfig(local_user(),'system','no_smilies')))) return $s; @@ -135,6 +155,19 @@ class Smilies { $s = preg_replace_callback('/(.*?)<\/code>/ism','self::encode',$s); $params = self::get_list(); + + if ($no_images) { + $cleaned = array('texts' => array(), 'icons' => array()); + $icons = $params['icons']; + foreach ($icons AS $key => $icon) { + if (!strstr($icon, ']*>)([^<]*)(?!]*>)|ism",