X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2FSmilies.php;h=a2d7637c793d779d9334cf3fe988290e27d77248;hb=e40c3a9d7c980c4287c273bc12d934ceb8b55fc0;hp=f4de32f8f8db4f3609594461e4575bb091d9f98c;hpb=fd5d058156185c6c02c1285a794139d07f4d13ce;p=friendica.git
diff --git a/include/Smilies.php b/include/Smilies.php
index f4de32f8f8..a2d7637c79 100644
--- a/include/Smilies.php
+++ b/include/Smilies.php
@@ -3,9 +3,18 @@
/**
* @file include/Smilies.php
* @brief This file contains the Smilies class which contains functions to handle smiles
+ *
+ * @todo Use the shortcodes from here:
+ * https://github.com/iamcal/emoji-data/blob/master/emoji_pretty.json?raw=true
+ * https://raw.githubusercontent.com/emojione/emojione/master/extras/alpha-codes/eac.json?raw=true
+ * https://github.com/johannhof/emoji-helper/blob/master/data/emoji.json?raw=true
+ *
+ * Have also a look here:
+ * https://www.webpagefx.com/tools/emoji-cheat-sheet/
*/
use Friendica\App;
+use Friendica\Core\System;
/**
* This class contains functions to handle smiles
@@ -13,6 +22,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
*
@@ -66,48 +95,47 @@ class Smilies {
);
$icons = array(
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '~friendica ',
- 'redmatrix',
- 'redmatrix'
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '~friendica ',
+ 'redmatrix',
+ 'redmatrix'
);
$params = array('texts' => $texts, 'icons' => $icons);
call_hooks('smilie', $params);
return $params;
-
}
/**
@@ -121,12 +149,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 +164,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, '';
+ $t .= '';
$r = str_replace($x[0],$t,$x[0]);
return $r;
}
-
}