Browse Source

- Redirect when you've successfully created a group

- Move the feed creation system to InitAccount and clean the Feed widget
- Move some translations
pull/16/head
Jaussoin Timothée 11 years ago
parent
commit
b0fe1dae4d
  1. 71
      app/widgets/Feed/Feed.php
  2. 2
      app/widgets/Feed/locales.ini
  3. 30
      app/widgets/InitAccount/InitAccount.php
  4. 10
      app/widgets/InitAccount/initaccount.tpl
  5. 1
      app/widgets/InitAccount/locales.ini
  6. 64
      app/widgets/ServerNodes/ServerNodes.php

71
app/widgets/Feed/Feed.php

@ -24,9 +24,6 @@ class Feed extends WidgetCommon {
$this->registerEvent('postpublished', 'onPostPublished');
$this->registerEvent('postpublisherror', 'onPostPublishError');
$this->registerEvent('nodecreated', 'onNodeCreated');
$this->registerEvent('nodecreationerror', 'onNodeCreationError');
$this->registerEvent('config', 'onConfig');
}
@ -45,30 +42,6 @@ class Feed extends WidgetCommon {
RPC::call('movim_fill', 'feedhead', $this->prepareHead());
}
function onNodeCreated() {
$config = $this->user->getConfig();
$config['feed'] = 'created';
$s = new Set;
$s->setXmlns('movim:prefs')
->setData(serialize($config))
->request();
}
function onNodeCreationError() {
$config = $this->user->getConfig();
$config['feed'] = 'error';
$s = new Set;
$s->setXmlns('movim:prefs')
->setData(serialize($config))
->request();
Notification::appendNotification(
$this->__('feed.no_support'),
'error');
}
function onCommentPublishError() {
$html =
'<div class="message error">'.
@ -97,35 +70,14 @@ class Feed extends WidgetCommon {
}
function prepareHead() {
$html = '';
$session = \Sessionx::start();
if($session->config['config'] == false) {
$html .=
'<div class="message warning">'.
$this->__('feed.no_support').
'</div>';
} elseif(!isset($session->config['feed'])) {
$html .= '
<div id="feednotifs">
<div class="message info">'.
$this->__('feed.creating').
'</div>
</div>
<script type="text/javascript">'.
$this->genCallAjax('ajaxCreateNode').
'</script>';
} else {
$html .= '
<script type="text/javascript">
function createCommentNode(parentid) {'.
$this->genCallAjax('ajaxCreateCommentNode', 'parentid[0]').
'}
</script>
'.$this->prepareSubmitForm($this->user->getLogin(), 'urn:xmpp:microblog:0').'
<div id="feednotifs"></div>';
}
$html = '
<script type="text/javascript">
function createCommentNode(parentid) {'.
$this->genCallAjax('ajaxCreateCommentNode', 'parentid[0]').
' }
</script>
'.$this->prepareSubmitForm($this->user->getLogin(), 'urn:xmpp:microblog:0').'
<div id="feednotifs"></div>';
return $html;
}
@ -185,11 +137,4 @@ class Feed extends WidgetCommon {
RPC::call('movim_fill', 'feedcontent', $html);
RPC::commit();
}
function ajaxCreateNode()
{
$p = new CreateNode;
$p->setTo($this->user->getLogin())
->request();
}
}

2
app/widgets/Feed/locales.ini

@ -1,6 +1,4 @@
my_posts = 'My Posts'
feed.no_support = "Your server doesn't support post publication, you can only read contact's feeds"
feed.error = 'An error occured : '
feed.creating = 'Creating your feed...'
feed.empty_title = 'Hi!'
feed.empty = 'This is your newsfeed, here you will see the posts published by you and your contacts.'

30
app/widgets/InitAccount/InitAccount.php

@ -8,6 +8,8 @@ class InitAccount extends WidgetCommon {
function load()
{
$this->registerEvent('configurepersistentstorage_handle', 'onConfigured');
$this->registerEvent('nodecreated', 'onNodeCreated');
$this->registerEvent('nodecreationerror', 'onNodeCreationError');
}
function onConfigured($packet)
@ -20,6 +22,31 @@ class InitAccount extends WidgetCommon {
->setData(serialize($config))
->request();
}
function onNodeCreated() {
$config = $this->user->getConfig();
$config['feed'] = 'created';
$s = new Set;
$s->setXmlns('movim:prefs')
->setData(serialize($config))
->request();
}
// TODO : do we really need this handler ?
function onNodeCreationError() {
$config = $this->user->getConfig();
$config['feed'] = 'error';
$s = new Set;
$s->setXmlns('movim:prefs')
->setData(serialize($config))
->request();
Notification::appendNotification(
$this->__('feed.no_support'),
'error');
}
private function createPersistentStorage($node)
{
@ -97,6 +124,9 @@ class InitAccount extends WidgetCommon {
} elseif(!isset($config['urn:xmpp:pubsub:subscription'])) {
$this->view->assign('create_pubsubsubscription', $this->genCallAjax('ajaxCreatePubsubSubscription'));
$creating = 5;
} elseif(!isset($config['feed'])) {
$this->view->assign('create_microblog', $this->genCallAjax('ajaxCreateMicroblog'));
$creating = 6;
}
if($creating != false) {

10
app/widgets/InitAccount/initaccount.tpl

@ -16,12 +16,18 @@
{if="isset($create_pubsubsubscription)"}
setTimeout('{$create_pubsubsubscription}', 2000);
{/if}
</script>
{if="$creating"}
<div class="spacetop"></div>
<div class="message info">{$c->__('pubsub.creating')} - {$c->__('step.step', $creating)}</div>
<div class="message info">{$c->__('pubsub.creating')} - {$c->__('step.step', $creating)}/6</div>
{/if}
{if="isset($create_microblog)"}
<script type="text/javascript">
setTimeout('{$create_microblog}', 2000);
</script>
<div class="message info">{$c->__('pubsub.creating_feed')} </div>
{/if}
{if="$no_pubsub"}

1
app/widgets/InitAccount/locales.ini

@ -6,3 +6,4 @@ creating.avatar = 'Creating your avatar node'
pubsub.creating = "Movim is currently configuring your account, please wait…"
pubsub.no_support = "Your server doesn't support post publication, you can only read contact's feeds"
pubsub.creating_feed = "Creating your feed..."

64
app/widgets/ServerNodes/ServerNodes.php

@ -44,6 +44,35 @@ class ServerNodes extends WidgetCommon
RPC::call('movim_fill', 'servernodeshead', '');
}
function onCreationSuccess($items)
{
RPC::call('movim_redirect', Route::urlize('node', array($items[0], $items[1])));
}
function onCreationError($error) {
RPC::call('movim_fill', 'servernodes', '');
RPC::commit();
}
function ajaxGetNodes($server)
{
$nd = new \Modl\ItemDAO();
$nd->deleteItems($server);
$r = new DiscoItems;
$r->setTo($server)->request();
}
function ajaxCreateGroup($data)
{
//make a uri of the title
$uri = stringToUri($data['title']);
$r = new Create;
$r->setTo($data['server'])->setNode($uri)->setData($data['title'])
->request();
}
function onDiscoItems($server) {
$submit = $this->genCallAjax('ajaxCreateGroup', "movim_parse_form('groupCreation')");
@ -133,39 +162,4 @@ class ServerNodes extends WidgetCommon
return $html;
}
function onCreationSuccess($items)
{
$html = '
<a href="
'.Route::urlize('node', array($items[0], $items[1])).'
">'.$items[2].'</a>';
RPC::call('movim_fill', 'servernodes', $html);
RPC::commit();
}
function onCreationError($error) {
RPC::call('movim_fill', 'servernodes', '');
RPC::commit();
}
function ajaxGetNodes($server)
{
$nd = new \Modl\ItemDAO();
$nd->deleteItems($server);
$r = new DiscoItems;
$r->setTo($server)->request();
}
function ajaxCreateGroup($data)
{
//make a uri of the title
$uri = stringToUri($data['title']);
$r = new Create;
$r->setTo($data['server'])->setNode($uri)->setData($data['title'])
->request();
}
}
Loading…
Cancel
Save