mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
inbound support for custom emojis
This commit is contained in:
@@ -2183,18 +2183,6 @@ class Activity {
|
||||
if (grapheme_strlen($t) === 1) {
|
||||
$content['content'] = $t;
|
||||
}
|
||||
|
||||
// Custom emojis
|
||||
$e = self::decode_taxonomy($act->data);
|
||||
|
||||
if ($e) {
|
||||
$s['term'] = $e;
|
||||
foreach ($e as $ee) {
|
||||
if ($ee['ttype'] === TERM_EMOJI) {
|
||||
$content['content'] = '[img=32x32]' . $ee['url'] . '[/img]';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2894,8 +2882,17 @@ class Activity {
|
||||
}
|
||||
}
|
||||
|
||||
if (!PConfig::Get($channel['channel_id'], 'system', 'no_smilies')) {
|
||||
foreach ($item['term'] as $t) {
|
||||
if ($t['ttype'] === TERM_EMOJI) {
|
||||
$item['body'] = str_replace($t['term'], '[img class="smiley emoji custom-emoji" alt="' . $t['term'] . '" title="' . $t['term'] . '"]' . $t['url'] . '[/img]', $item['body']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: not implemented
|
||||
// self::rewrite_mentions($item);
|
||||
|
||||
$r = q("select id, created, edited from item where mid = '%s' and uid = %d limit 1",
|
||||
dbesc($item['mid']),
|
||||
intval($item['uid'])
|
||||
|
||||
@@ -869,11 +869,13 @@ function bb_imgoptions($match) {
|
||||
// [img|zmg=wwwxhhh float=left|right alt=alt text]url[/img|zmg]
|
||||
|
||||
$local_match = null;
|
||||
$width = 0;
|
||||
$float = false;
|
||||
$alt = false;
|
||||
|
||||
$style = EMPTY_STR;
|
||||
$width = EMPTY_STR;
|
||||
$height = EMPTY_STR;
|
||||
$float = EMPTY_STR;
|
||||
$alt = EMPTY_STR;
|
||||
$title = EMPTY_STR;
|
||||
$style = EMPTY_STR;
|
||||
$class = EMPTY_STR;
|
||||
|
||||
$attributes = $match[3];
|
||||
|
||||
@@ -882,6 +884,16 @@ function bb_imgoptions($match) {
|
||||
$alt = $matches[1];
|
||||
}
|
||||
|
||||
$x = preg_match("/title=\"\;(.*?)\"\;/ism", $attributes, $matches);
|
||||
if ($x) {
|
||||
$title = $matches[1];
|
||||
}
|
||||
|
||||
$x = preg_match("/title='(.*?)'/ism", $attributes, $matches);
|
||||
if ($x) {
|
||||
$title = $matches[1];
|
||||
}
|
||||
|
||||
$x = preg_match("/alt=\"\;(.*?)\"\;/ism", $attributes, $matches);
|
||||
if ($x) {
|
||||
$alt = $matches[1];
|
||||
@@ -907,16 +919,27 @@ function bb_imgoptions($match) {
|
||||
$height = $matches[1];
|
||||
}
|
||||
|
||||
$x = preg_match("/class='(.*?)'/ism", $attributes, $matches);
|
||||
if ($x) {
|
||||
$class = $matches[1];
|
||||
}
|
||||
|
||||
$x = preg_match("/class=\"\;(.*?)\"\;/ism", $attributes, $matches);
|
||||
if ($x) {
|
||||
$class = $matches[1];
|
||||
}
|
||||
|
||||
/* should probably sanitize css somehow
|
||||
$x = preg_match("/style='(.*?)'/ism", $attributes, $matches);
|
||||
if ($x) {
|
||||
$style = $matches[1];
|
||||
$style = $matches[1] . ' ';
|
||||
}
|
||||
|
||||
$x = preg_match("/style=\"\;(.*?)\"\;/ism", $attributes, $matches);
|
||||
if ($x) {
|
||||
$style = $matches[1];
|
||||
$style = $matches[1] . ' ';
|
||||
}
|
||||
|
||||
*/
|
||||
// legacy img options
|
||||
|
||||
if ($match[2] === '=') {
|
||||
@@ -932,6 +955,7 @@ function bb_imgoptions($match) {
|
||||
$float = 'left';
|
||||
$match[3] = substr($match[3],$n + 10);
|
||||
}
|
||||
|
||||
if ($n = strpos($match[3],'float=right') !== false) {
|
||||
$float = 'right';
|
||||
$match[3] = substr($match[3],$n + 11);
|
||||
@@ -947,18 +971,25 @@ function bb_imgoptions($match) {
|
||||
$output = '<img ' . (($match[1] === 'z') ? 'class="zrl" loading="eager"' : '') . ' ';
|
||||
|
||||
if ($width) {
|
||||
$style .= 'width: 100%; max-width: ' . $width . 'px; ';
|
||||
$style .= 'width: ' . intval($width) . 'px; ';
|
||||
}
|
||||
else {
|
||||
$style .= 'max-width: 100%; ';
|
||||
|
||||
if ($height) {
|
||||
$style .= 'height: ' . intval($height) . 'px; ';
|
||||
}
|
||||
|
||||
if ($float) {
|
||||
$style .= 'float: ' . $float . '; ';
|
||||
}
|
||||
|
||||
$output .= (($style) ? 'style="' . $style . '" ' : '') . 'alt="' . htmlentities(($alt) ? $alt : t('Image/photo'),ENT_COMPAT,'UTF-8') . '" ';
|
||||
$style .= 'max-width: 100%;';
|
||||
|
||||
$output .= 'src="' . $match[4] . '" >';
|
||||
$output .= 'style="' . $style . '" ';
|
||||
$output .= 'alt="' . htmlentities(($alt ? $alt : t('Image/photo')), ENT_COMPAT, 'UTF-8') . '" ';
|
||||
$output .= 'title="' . htmlentities($title, ENT_COMPAT, 'UTF-8') . '" ';
|
||||
$output .= 'class="' . htmlentities($class, ENT_COMPAT, 'UTF-8') . '" ';
|
||||
|
||||
$output .= 'src="' . $match[4] . '" />';
|
||||
|
||||
return $output;
|
||||
|
||||
|
||||
@@ -1317,38 +1317,37 @@ function list_smilies($default_only = false) {
|
||||
);
|
||||
|
||||
$icons = array(
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-heart.gif" alt="<3" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-brokenheart.gif" alt="</3" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-smile.gif" alt=":-)" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-wink.gif" alt=";-)" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-frown.gif" alt=":-(" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-tongue-out.gif" alt=":-P" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-tongue-out.gif" alt=":-p" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-kiss.gif" alt=":-\"" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-kiss.gif" alt=":-\"" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-kiss.gif" alt=":-x" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-kiss.gif" alt=":-X" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-laughing.gif" alt=":-D" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-surprised.gif" alt="8-|" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-surprised.gif" alt="8-O" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-surprised.gif" alt=":-O" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-thumbsup.gif" alt="\\o/" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-Oo.gif" alt="o.O" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-Oo.gif" alt="O.o" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-Oo.gif" alt="o_O" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-Oo.gif" alt="O_o" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-cry.gif" alt=":\'(" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-foot-in-mouth.gif" alt=":-!" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-undecided.gif" alt=":-/" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-embarassed.gif" alt=":-[" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-cool.gif" alt="8-)" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/beer_mug.gif" alt=":beer" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/beer_mug.gif" alt=":homebrew" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/coffee.gif" alt=":coffee" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/smiley-facepalm.gif" alt=":facepalm" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/like.gif" alt=":like" />',
|
||||
'<img class="smiley" src="' . z_root() . '/images/emoticons/dislike.gif" alt=":dislike" />'
|
||||
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-heart.gif" alt="<3" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-brokenheart.gif" alt="</3" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-smile.gif" alt=":-)" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-wink.gif" alt=";-)" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-frown.gif" alt=":-(" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-tongue-out.gif" alt=":-P" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-tongue-out.gif" alt=":-p" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-kiss.gif" alt=":-\"" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-kiss.gif" alt=":-\"" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-kiss.gif" alt=":-x" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-kiss.gif" alt=":-X" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-laughing.gif" alt=":-D" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-surprised.gif" alt="8-|" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-surprised.gif" alt="8-O" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-surprised.gif" alt=":-O" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-thumbsup.gif" alt="\\o/" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-Oo.gif" alt="o.O" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-Oo.gif" alt="O.o" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-Oo.gif" alt="o_O" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-Oo.gif" alt="O_o" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-cry.gif" alt=":\'(" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-foot-in-mouth.gif" alt=":-!" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-undecided.gif" alt=":-/" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-embarassed.gif" alt=":-[" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-cool.gif" alt="8-)" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/beer_mug.gif" alt=":beer" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/beer_mug.gif" alt=":homebrew" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/coffee.gif" alt=":coffee" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/smiley-facepalm.gif" alt=":facepalm" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/like.gif" alt=":like" />',
|
||||
'<img class="smiley emoji" src="' . z_root() . '/images/emoticons/dislike.gif" alt=":dislike" />'
|
||||
);
|
||||
|
||||
$params = array('texts' => $texts, 'icons' => $icons);
|
||||
|
||||
@@ -299,10 +299,16 @@ code.inline-code {
|
||||
text-decoration: overline;
|
||||
}
|
||||
|
||||
img.smiley.emoji {
|
||||
height: .9em;
|
||||
vertical-align: baseline;
|
||||
margin-bottom: -.1em;
|
||||
}
|
||||
|
||||
img.smiley.emoji:hover {
|
||||
transform: scale(2);
|
||||
transition: transform .1s ease-out;
|
||||
filter: drop-shadow(0px 0px 1px rgba(0,0,0,.5));
|
||||
filter: drop-shadow(0px 0px 1px rgba(0, 0, 0, .5));
|
||||
}
|
||||
|
||||
.checklist input {
|
||||
|
||||
Reference in New Issue
Block a user