aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-06-04 17:06:12 -0700
committerredmatrix <git@macgirvin.com>2016-06-04 17:06:12 -0700
commita6012af00d13bdab1806b7ae172d271d4ad9ebe5 (patch)
tree0d27c71f3d71073d43673a15c0fecc749cbc452c /include
parenta0d339f208ce991ccc429e7d4ac1bbacce393b38 (diff)
downloadvolse-hubzilla-a6012af00d13bdab1806b7ae172d271d4ad9ebe5.tar.gz
volse-hubzilla-a6012af00d13bdab1806b7ae172d271d4ad9ebe5.tar.bz2
volse-hubzilla-a6012af00d13bdab1806b7ae172d271d4ad9ebe5.zip
For emojis in posts, extend smilies and save a lot of duplication of effort
Diffstat (limited to 'include')
-rw-r--r--include/bbcode.php14
-rw-r--r--include/text.php12
2 files changed, 12 insertions, 14 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index ed332146f..42741b392 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -66,19 +66,6 @@ function bb_unspacefy_and_trim($st) {
}
-function bb_emoji($mtch) {
- $s = strtolower($mtch[1]);
- if(strpos($s,'x')) {
- $e = substr($s,strpos($s,'x')+1);
- if(file_exists('images/emoji/' . $e . '.png')) {
- return '<img width="24" height="24" src="' . z_root() . '/images/emoji/' . $e . '.png" alt="emoji" />';
- }
- else {
- return $mtch[0];
- }
- }
-}
-
function bb_extract_images($body) {
$saved_image = array();
@@ -1014,7 +1001,6 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false)
$Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_unspacefy_and_trim', $Text);
}
- $Text = preg_replace_callback('/\[\&amp\;([#a-z0-9]+)\;\]/', 'bb_emoji', $Text);
$Text = preg_replace('/\[\&amp\;([#a-z0-9]+)\;\]/', '&$1;', $Text);
// fix any escaped ampersands that may have been converted into links
diff --git a/include/text.php b/include/text.php
index 72db9c5ea..5d0010bd5 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1155,6 +1155,18 @@ function list_smilies() {
);
+ $x = get_config('feature','emoji');
+ if($x === false)
+ $x = 1;
+ if($x) {
+ if(! App::$emojitab)
+ App::$emojitab = json_decode(file_get_contents('library/emoji.json'),true);
+ foreach(App::$emojitab as $e) {
+ $texts[] = $e['shortname'];
+ $icons[] = '<img height="16" width="16" src="images/emoji/' . $e['unicode'] . '.png' . '" alt="' . $e['name'] . '" />';
+ }
+ }
+
$params = array('texts' => $texts, 'icons' => $icons);
call_hooks('smilie', $params);