Start implementing a Stickers feature in Movim (not enabled yet)
Refactor the Picture lib to make it compatible with PNGpull/183/head
-
11app/helpers/StringHelper.php
-
15app/models/message/Message.php
-
9app/models/message/MessageDAO.php
-
1app/views/chat.tpl
-
15app/widgets/Chat/Chat.php
-
5app/widgets/Chat/_chat_smiley.tpl
-
12app/widgets/Chat/chat.js
-
124app/widgets/Stickers/Stickers.php
-
17app/widgets/Stickers/_stickers.tpl
-
0app/widgets/Stickers/stickers.tpl
-
BINapp/widgets/Stickers/stickers/04c6573f4e67c1ec8a0ce1ee4510b0ccd0583290.png
-
BINapp/widgets/Stickers/stickers/0fc649c7ad655722c1c63bea09c6aa6cd3b6e5ed.png
-
BINapp/widgets/Stickers/stickers/30dddf556a53a6f4fcb74c36c4301d59c2290f69.png
-
BINapp/widgets/Stickers/stickers/347b058305ec44e49b839f665f030cb000e14477.png
-
BINapp/widgets/Stickers/stickers/530de08965c7a8653af311c414ca0ac79f0f7fb8.png
-
BINapp/widgets/Stickers/stickers/66bda812246d091b57ab927f89e1b7d429cbc73e.png
-
BINapp/widgets/Stickers/stickers/a19626467b06ccc6836105a790b660c6e1a0f92a.png
-
BINapp/widgets/Stickers/stickers/a650e0b8ea76646bf8ba08694c666fbfb7f7402c.png
-
BINapp/widgets/Stickers/stickers/a8f48774260a5560a88be6944bc80545854ea48b.png
-
BINapp/widgets/Stickers/stickers/f72754fd1bdf83b87ee717ff6f5b181ae7384cd2.png
-
2bootstrap.php
-
31system/Picture.php
-
20themes/material/css/listn.css
@ -0,0 +1,124 @@ |
|||
<?php |
|||
|
|||
use Moxl\Xec\Action\Message\Publish; |
|||
use Moxl\Xec\Action\BOB\Answer; |
|||
use Ramsey\Uuid\Uuid; |
|||
|
|||
class Stickers extends WidgetBase |
|||
{ |
|||
function load() |
|||
{ |
|||
$this->registerEvent('bob', 'onRequest'); |
|||
} |
|||
|
|||
function onRequest($packet) |
|||
{ |
|||
$content = $packet->content; |
|||
|
|||
$to = $content[0]; |
|||
$id = $content[1]; |
|||
$cid = $content[2]; |
|||
|
|||
list($c, $ext) = explode('@', $cid); |
|||
list($sh, $key) = explode('+', $c); |
|||
|
|||
$base64 = base64_encode(file_get_contents(dirname(__FILE__).'/stickers/'.$key.'.png')); |
|||
|
|||
$a = new Answer; |
|||
$a->setTo($to) |
|||
->setId($id) |
|||
->setCid($cid) |
|||
->setType('image/png') |
|||
->setBase64($base64) |
|||
->request(); |
|||
} |
|||
|
|||
function ajaxSend($to, $file) |
|||
{ |
|||
if(!$this->validateJid($jid)) return; |
|||
|
|||
list($key, $ext) = explode('.', $file); |
|||
|
|||
$filepath = dirname(__FILE__).'/stickers/'.$key.'.png'; |
|||
|
|||
if(!file_exists($filepath)) return; |
|||
|
|||
// We get the base64
|
|||
$base64 = base64_encode(file_get_contents($filepath)); |
|||
|
|||
// Caching the picture
|
|||
$p = new Picture; |
|||
$p->fromBase($base64); |
|||
$p->set($key, 'png'); |
|||
|
|||
// Creating a message
|
|||
$m = new \Modl\Message(); |
|||
$m->session = $this->user->getLogin(); |
|||
$m->jidto = echapJid($to); |
|||
$m->jidfrom = $this->user->getLogin(); |
|||
$m->sticker = $key; |
|||
$m->body = 'A Stickers has been sent using Movim'; |
|||
|
|||
$m->published = gmdate('Y-m-d H:i:s'); |
|||
$m->delivered = gmdate('Y-m-d H:i:s'); |
|||
|
|||
$session = \Sessionx::start(); |
|||
|
|||
$m->id = Uuid::uuid4(); |
|||
$m->type = 'chat'; |
|||
$m->resource = $session->resource; |
|||
|
|||
// Sending the sticker
|
|||
$html = "<p><img alt='Sticker' src='cid:sha1+".$key."@bob.xmpp.org'/></p>"; |
|||
|
|||
$p = new Publish; |
|||
$p->setTo($m->jidto) |
|||
->setContent($m->body) |
|||
->setHTML($html) |
|||
->setId($m->id) |
|||
->request(); |
|||
|
|||
$md = new \Modl\MessageDAO(); |
|||
$md->set($m); |
|||
|
|||
// Sending it to Chat
|
|||
$packet = new Moxl\Xec\Payload\Packet; |
|||
$packet->content = $m; |
|||
$c = new Chat; |
|||
$c->onMessage($packet/*, true*/); |
|||
} |
|||
|
|||
function ajaxShow($to) |
|||
{ |
|||
if(!$this->validateJid($to)) return; |
|||
|
|||
$files = scandir(dirname(__FILE__).'/stickers/'); |
|||
|
|||
array_shift($files); |
|||
array_shift($files); |
|||
|
|||
$view = $this->tpl(); |
|||
$view->assign('jid', $to); |
|||
$view->assign('stickers', $files); |
|||
$view->assign('path', $this->respath('stickers').'/'); |
|||
|
|||
Dialog::fill($view->draw('_stickers', true), true); |
|||
} |
|||
|
|||
/** |
|||
* @brief Validate the jid |
|||
* |
|||
* @param string $jid |
|||
*/ |
|||
private function validateJid($jid) |
|||
{ |
|||
$validate_jid = Validator::stringType()->noWhitespace()->length(6, 60); |
|||
if(!$validate_jid->validate($jid)) return false; |
|||
else return true; |
|||
} |
|||
|
|||
function display() |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
<section class="scroll"> |
|||
<ul class="list flex active"> |
|||
{loop="$stickers"} |
|||
<li class="block" onclick="Stickers_ajaxSend('{$jid}', '{$value}')"> |
|||
<img src="{$path}{$value}"/> |
|||
</li> |
|||
{/loop} |
|||
</ul> |
|||
</section> |
|||
<div> |
|||
<a onclick="Chat_ajaxSmiley()" class="button flat"> |
|||
Emojis |
|||
</a> |
|||
<a onclick="Dialog.clear()" class="button flat"> |
|||
{$c->__('button.close')} |
|||
</a> |
|||
</div> |
|||
|
After Width: 259 | Height: 224 | Size: 14 KiB |
|
After Width: 190 | Height: 224 | Size: 17 KiB |
|
After Width: 278 | Height: 210 | Size: 59 KiB |
|
After Width: 206 | Height: 224 | Size: 17 KiB |
|
After Width: 242 | Height: 233 | Size: 44 KiB |
|
After Width: 259 | Height: 224 | Size: 14 KiB |
|
After Width: 278 | Height: 218 | Size: 47 KiB |
|
After Width: 112 | Height: 100 | Size: 23 KiB |
|
After Width: 278 | Height: 224 | Size: 49 KiB |
|
After Width: 16 | Height: 16 | Size: 620 B |