aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Emoji.php60
-rw-r--r--Zotlabs/Module/Item.php28
-rw-r--r--Zotlabs/Module/React.php25
-rw-r--r--Zotlabs/Module/Smilies.php16
4 files changed, 112 insertions, 17 deletions
diff --git a/Zotlabs/Module/Emoji.php b/Zotlabs/Module/Emoji.php
new file mode 100644
index 000000000..595c9fc60
--- /dev/null
+++ b/Zotlabs/Module/Emoji.php
@@ -0,0 +1,60 @@
+<?php
+namespace Zotlabs\Module;
+
+use Zotlabs\Web\Controller;
+use Zotlabs\Daemon\Master;
+use Zotlabs\Lib\ActivityStreams;
+use App;
+
+
+class Emoji extends Controller {
+
+ function init() {
+
+ $shortname = argv(1);
+
+ if (!$shortname) {
+ killme();
+ }
+
+ $emojis = get_emojis();
+
+ if (!isset($emojis[$shortname])) {
+ killme();
+ }
+
+ $emoji = $emojis[$shortname];
+
+hz_syslog(print_r($emoji, true));
+
+
+ if (!file_exists($emoji['filepath'])) {
+ killme();
+ }
+
+ $image = getimagesize($emoji['filepath']);
+
+ if(ActivityStreams::is_as_request()) {
+ $last_modified = date(ATOM_TIME, filemtime($emoji['filepath']));
+
+ $obj = [
+ 'id' => z_root() . '/emoji/' . $shortname,
+ 'type' => 'Emoji',
+ 'name' => $emoji['shortname'],
+ 'updated' => $last_modified,
+ 'icon' => [
+ 'type' => 'Image',
+ 'mediaType' => $image['mime'],
+ 'url' => z_root() . '/' . $emoji['filepath']
+ ]
+ ];
+
+ as_return_and_die($obj);
+ }
+
+ header('Content-Type: ' . $image['mime']);
+ echo file_get_contents($emoji['filepath']);
+ killme();
+ }
+
+}
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index 5c802f557..b158ed4e0 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -938,6 +938,30 @@ class Item extends Controller {
}
}
+ if (preg_match_all('/(\:(\w|\+|\-)+\:)(?=|[\!\.\?]|$)/', $body, $match)) {
+ // emoji shortcodes
+ $emojis = get_emojis();
+ foreach ($match[0] as $mtch) {
+ $shortname = trim($mtch, ':');
+
+ if (!isset($emojis[$shortname])) {
+ continue;
+ }
+
+ $emoji = $emojis[$shortname];
+
+ $post_tags[] = [
+ 'uid' => $profile_uid,
+ 'ttype' => TERM_EMOJI,
+ 'otype' => TERM_OBJ_POST,
+ 'term' => trim($mtch),
+ 'url' => z_root() . '/emoji/' . $shortname,
+ 'imgurl' => z_root() . '/' . $emoji['filepath']
+ ];
+ }
+ }
+
+
// BBCODE end alert
}
@@ -958,6 +982,10 @@ class Item extends Controller {
}
}
+
+
+
+
if ($orig_post) {
// preserve original tags
$t = q("select * from term where oid = %d and otype = %d and uid = %d and ttype in ( %d, %d, %d )",
diff --git a/Zotlabs/Module/React.php b/Zotlabs/Module/React.php
index 6a3b525b2..e04b9b257 100644
--- a/Zotlabs/Module/React.php
+++ b/Zotlabs/Module/React.php
@@ -24,7 +24,15 @@ class React extends Controller {
return;
}
- $emoji = $_REQUEST['emoji'];
+ $shortname = $_REQUEST['emoji'];
+
+ $emojis = get_emojis();
+
+ if (!isset($emojis[$shortname])) {
+ return;
+ }
+
+ $emoji = $emojis[$shortname];
if (!$emoji) {
return;
@@ -62,10 +70,19 @@ class React extends Controller {
$n['uuid'] = $uuid;
$n['mid'] = z_root() . '/item/' . $uuid;
$n['verb'] = 'Create';
- $n['body'] = '[zmg=32x32]' . z_root() . '/images/emoji/' . $emoji . '.png[/zmg]';
+ $n['body'] = $emoji['shortname']; //'[img class="emoji single-emoji"]' . z_root() . '/' . $emoji['filepath'] . '[/img]';
$n['author_xchan'] = $channel['channel_hash'];
- $n['obj'] = Activity::fetch_item(['id' => $item['mid']]);
- $n['obj_type'] = ((array_path_exists('obj/type', $n)) ? $n['obj']['type'] : EMPTY_STR);
+ // $n['obj'] = Activity::fetch_item(['id' => $i[0]['mid']]);
+ // $n['obj_type'] = ((array_path_exists('obj/type', $n)) ? $n['obj']['type'] : EMPTY_STR);
+
+ $n['term'][] = [
+ 'uid' => $channel['channel_id'],
+ 'ttype' => TERM_EMOJI,
+ 'otype' => TERM_OBJ_POST,
+ 'term' => $emoji['shortname'],
+ 'url' => z_root() . '/emoji/' . $shortname,
+ 'imgurl' => z_root() . '/' . $emoji['filepath']
+ ];
$x = item_store($n);
diff --git a/Zotlabs/Module/Smilies.php b/Zotlabs/Module/Smilies.php
index efac07f84..7dde8c834 100644
--- a/Zotlabs/Module/Smilies.php
+++ b/Zotlabs/Module/Smilies.php
@@ -4,18 +4,8 @@ namespace Zotlabs\Module;
class Smilies extends \Zotlabs\Web\Controller {
- function get() {
- if (\App::$argv[1]==="json"){
- $tmp = list_smilies();
- $results = array();
- for($i = 0; $i < count($tmp['texts']); $i++) {
- $results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]);
- }
- json_return_and_die($results);
- }
- else {
- return smilies('',true);
- }
+ function init() {
+ json_return_and_die(get_emojis());
}
-
+
}