X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=include%2FSmilies.php;h=d63511cd1d20af430b1c6ac0bcf3df09f0459cf1;hb=ef8ad9f1ede56c80ba0cc13298511d7943e04894;hp=d67b92d8b00f60a4e38ab0664510adb794b336ae;hpb=bbd5878734e658cbc514cacc20e231e843015d04;p=friendica.git
diff --git a/include/Smilies.php b/include/Smilies.php
index d67b92d8b0..d63511cd1d 100644
--- a/include/Smilies.php
+++ b/include/Smilies.php
@@ -5,21 +5,44 @@
* @brief This file contains the Smilies class which contains functions to handle smiles
*/
+use Friendica\App;
+use Friendica\Core\System;
+
/**
* This class contains functions to handle smiles
*/
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
- *
+ *
* Get an array of all smilies, both internal and from addons.
- *
+ *
* @return array
* 'texts' => smilie shortcut
* 'icons' => icon in html
- *
+ *
* @hook smilie ('texts' => smilies texts array, 'icons' => smilies html array)
*/
public static function get_list() {
@@ -64,48 +87,47 @@ class Smilies {
);
$icons = array(
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '',
- '~friendica ',
- 'redmatrix',
- 'redmatrix'
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ '~friendica ',
+ 'redmatrix',
+ 'redmatrix'
);
$params = array('texts' => $texts, 'icons' => $icons);
call_hooks('smilie', $params);
return $params;
-
}
/**
@@ -119,12 +141,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;
@@ -133,6 +156,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;
}
-
}