Browse Source

- Fix bug #1429835 (recent chat on top of the list)

- New feature, post deletion
pull/16/head
Jaussoin Timothée 11 years ago
parent
commit
defcfd5a5e
  1. 3
      app/widgets/Chats/Chats.php
  2. 31
      app/widgets/Post/Post.php
  3. 16
      app/widgets/Post/_post_delete.tpl
  4. 9
      app/widgets/Post/_post_header.tpl
  5. 5
      app/widgets/Post/locales.ini
  6. 8
      linker.php

3
app/widgets/Chats/Chats.php

@ -32,7 +32,8 @@ class Chats extends WidgetCommon
$this->ajaxOpen($from);
} else {
// TODO notification overwrite issue
RPC::call('movim_replace', $from.'_chat_item', $this->prepareChat($from));
RPC::call('movim_delete', $from.'_chat_item');
RPC::call('movim_prepend', 'chats_widget_list', $this->prepareChat($from));
RPC::call('Chats.refresh');
$n = new Notification;

31
app/widgets/Post/Post.php

@ -19,6 +19,7 @@
*/
use Moxl\Xec\Action\Pubsub\PostPublish;
use Moxl\Xec\Action\Pubsub\PostDelete;
use Moxl\Xec\Action\Microblog\CommentsGet;
use \Michelf\Markdown;
@ -29,6 +30,7 @@ class Post extends WidgetCommon
$this->addcss('post.css');
$this->registerEvent('microblog_commentsget_handle', 'onComments');
$this->registerEvent('pubsub_postpublish_handle', 'onPublish');
$this->registerEvent('pubsub_postdelete_handle', 'onDelete');
}
function onPublish()
@ -38,6 +40,14 @@ class Post extends WidgetCommon
RPC::call('MovimTpl.hidePanel');
}
function onDelete()
{
Notification::append(false, $this->__('post.deleted'));
$this->ajaxClear();
RPC::call('MovimTpl.hidePanel');
RPC::call('Menu_ajaxGetAll');
}
function ajaxClear()
{
RPC::call('movim_fill', 'post_widget', $this->prepareEmpty());
@ -70,7 +80,7 @@ class Post extends WidgetCommon
$view = $this->tpl();
$view->assign('content', Markdown::defaultTransform($form->content->value));
Dialog::fill($view->draw('_post_preview', true));
Dialog::fill($view->draw('_post_preview', true), true);
} else {
Notification::append(false, $this->__('post.no_content_preview'));
}
@ -115,6 +125,25 @@ class Post extends WidgetCommon
}
}
function ajaxDelete($to, $node, $id)
{
$view = $this->tpl();
$view->assign('to', $to);
$view->assign('node', $node);
$view->assign('id', $id);
Dialog::fill($view->draw('_post_delete', true));
}
function ajaxDeleteConfirm($to, $node, $id) {
$p = new PostDelete;
$p->setTo($to)
->setNode($node)
->setId($id)
->request();
}
function ajaxGetComments($jid, $id)
{
$c = new CommentsGet;

16
app/widgets/Post/_post_delete.tpl

@ -0,0 +1,16 @@
<section>
<h3>{$c->__('post.delete_title')}</h3>
<br />
<h4 class="gray">{$c->__('post.delete_text')}</h4>
</section>
<div class="no_bar">
<a onclick="Dialog.clear()" class="button flat">
{$c->__('button.cancel')}
</a>
<a
name="submit"
class="button flat"
onclick="Post_ajaxDeleteConfirm('{$to}', '{$node}', '{$id}'); Dialog.clear()">
{$c->__('button.delete')}
</a>
</div>

9
app/widgets/Post/_post_header.tpl

@ -9,6 +9,15 @@
</h2>
</div>
<div>
{if="$post->isMine()"}
<ul class="active">
<li onclick="Post_ajaxDelete('{$post->origin}', '{$post->node}', '{$post->nodeid}')">
<span class="icon">
<i class="md md-delete"></i>
</span>
</li>
</ul>
{/if}
<h2 class="active" onclick="MovimTpl.hidePanel(); Post_ajaxClear();">
<span id="back" class="icon"><i class="md md-arrow-back"></i></span>
{if="$post != null"}

5
app/widgets/Post/locales.ini

@ -13,6 +13,7 @@ post.valid_url = 'Please enter a valid url'
post.no_content_preview = 'No content to preview'
post.no_content = 'No content'
post.published = 'Post published'
post.deleted = 'Post deleted'
post.gallery = 'This picture will be added to your gallery'
post.hot = "What's Hot"
@ -20,3 +21,7 @@ post.hot = "What's Hot"
post.public = 'Publish this post on your public feed?'
post.blog_add = 'Post published on your blog'
post.blog_remove = 'Post removed from your blog'
[delete]
post.delete_title = 'Delete this post'
post.delete_text = 'You are going to delete this post, please confirm your action'

8
linker.php

@ -45,7 +45,7 @@ $connector($config->websocketurl, array('xmpp'))->then(function($conn) use (&$st
$conn->on('message', function($message) use ($conn, $loop) {
if($message != '') {
#fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received', 'green')."\n");
fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received', 'green')."\n");
if($message == '</stream:stream>') {
$conn->close();
@ -76,7 +76,7 @@ $connector($config->websocketurl, array('xmpp'))->then(function($conn) use (&$st
}
if(!empty($xml)) {
#fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
$conn->send(trim($xml));
}
}
@ -98,7 +98,7 @@ $connector($config->websocketurl, array('xmpp'))->then(function($conn) use (&$st
$buffer = '';
foreach ($messages as $message) {
#fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received from the browser', 'green')."\n");
fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received from the browser', 'green')."\n");
$msg = json_decode($message);
@ -118,7 +118,7 @@ $connector($config->websocketurl, array('xmpp'))->then(function($conn) use (&$st
\Moxl\API::clear();
if(!empty($xml)) {
#fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
$conn->send(trim($xml));
}

Loading…
Cancel
Save