Browse Source
- Add support for 0050 - AdHoc with a new widget
- Add support for 0050 - AdHoc with a new widget
- Fix little issues (scroll) in the Dialog widget - Remove old commented sourcecode - Fix a lot of issues in XMPPtoForm and FormtoXMPPpull/16/head
23 changed files with 275 additions and 167 deletions
-
1app/views/conf.tpl
-
118app/widgets/AdHoc/AdHoc.php
-
32app/widgets/AdHoc/_adhoc_form.tpl
-
13app/widgets/AdHoc/_adhoc_list.tpl
-
8app/widgets/AdHoc/_adhoc_note.tpl
-
33app/widgets/AdHoc/adhoc.js
-
1app/widgets/AdHoc/adhoc.tpl
-
1app/widgets/AdHoc/locales.ini
-
2app/widgets/AdminMain/AdminMain.php
-
2app/widgets/Chats/_chats.tpl
-
2app/widgets/Chats/locales.ini
-
5app/widgets/Dialog/Dialog.php
-
4app/widgets/Dialog/dialog.js
-
4app/widgets/Menu/_menu_list.tpl
-
1app/widgets/Notification/notification.js
-
2app/widgets/Post/_post.tpl
-
24app/widgets/Presence/presence.js
-
63lib/XMPPtoForm.php
-
6linker.php
-
2locales/locales.ini
-
6themes/material/css/color.css
-
2themes/material/css/form.css
-
110themes/material/css/style.css
@ -0,0 +1,118 @@ |
|||
<?php |
|||
|
|||
use Moxl\Xec\Action\AdHoc\Get; |
|||
use Moxl\Xec\Action\AdHoc\Command; |
|||
use Moxl\Xec\Action\AdHoc\Submit; |
|||
|
|||
class AdHoc extends WidgetBase |
|||
{ |
|||
function load() |
|||
{ |
|||
$this->addjs('adhoc.js'); |
|||
$this->registerEvent('adhoc_get_handle', 'onList'); |
|||
$this->registerEvent('adhoc_command_handle', 'onCommand'); |
|||
$this->registerEvent('adhoc_submit_handle', 'onCommand'); |
|||
} |
|||
|
|||
function onList($package) |
|||
{ |
|||
$list = $package->content; |
|||
$html = $this->prepareList($list); |
|||
RPC::call('movim_fill', 'adhoc_widget', $html); |
|||
RPC::call('AdHoc.refresh'); |
|||
} |
|||
|
|||
function onCommand($package) |
|||
{ |
|||
$command = $package->content; |
|||
|
|||
$view = $this->tpl(); |
|||
|
|||
if(isset($command->note)) { |
|||
$view->assign('note', $command->note); |
|||
|
|||
Dialog::fill($view->draw('_adhoc_note', true)); |
|||
} |
|||
|
|||
if(isset($command->x)) { |
|||
$xml = new \XMPPtoForm(); |
|||
$form = $xml->getHTML($command->x->asXML()); |
|||
|
|||
$view->assign('form', $form); |
|||
$view->assign('attributes', $command->attributes()); |
|||
$view->assign('actions', null); |
|||
if(isset($command->actions)) { |
|||
$view->assign('actions', $command->actions); |
|||
} |
|||
|
|||
Dialog::fill($view->draw('_adhoc_form', true), true); |
|||
} |
|||
|
|||
RPC::call('AdHoc.initForm'); |
|||
} |
|||
|
|||
function prepareList($list) |
|||
{ |
|||
$view = $this->tpl(); |
|||
$view->assign('list', $list); |
|||
return $view->draw('_adhoc_list', true); |
|||
} |
|||
|
|||
function ajaxGet() |
|||
{ |
|||
$session = \Sessionx::start(); |
|||
|
|||
$g = new Get; |
|||
$g->setTo($session->host) |
|||
->request(); |
|||
} |
|||
|
|||
function ajaxCommand($jid, $node) |
|||
{ |
|||
$c = new Command; |
|||
$c->setTo($jid) |
|||
->setNode($node) |
|||
->request(); |
|||
} |
|||
|
|||
function ajaxSubmit($data, $node, $sessionid) |
|||
{ |
|||
$session = \Sessionx::start(); |
|||
|
|||
$s = new Submit; |
|||
$s->setTo($session->host) |
|||
->setNode($node) |
|||
->setData($data) |
|||
->setSessionid($sessionid) |
|||
->request(); |
|||
} |
|||
|
|||
function getIcon($command) |
|||
{ |
|||
$icons = array( |
|||
'http://jabber.org/protocol/admin#delete-user' => 'md-delete', |
|||
'http://jabber.org/protocol/admin#end-user-session' => 'md-stop', |
|||
'http://jabber.org/protocol/admin#change-user-password' => 'md-lock', |
|||
'ping' => 'md-swap-horiz', |
|||
'http://jabber.org/protocol/admin#shutdown' => 'md-settings-power', |
|||
'http://jabber.org/protocol/admin#add-user' => 'md-person-add', |
|||
'http://jabber.org/protocol/admin#user-stats' => 'md-people', |
|||
'uptime' => 'md-access-time', |
|||
'http://jabber.org/protocol/admin#server-buddy' => 'md-stop', |
|||
'http://jabber.org/protocol/admin#get-user-roster' => 'md-format-list-bulleted', |
|||
'http://jabber.org/protocol/admin#get-online-users' => 'md-trending-up', |
|||
'http://jabber.org/protocol/admin#announce' => 'md-notifications', |
|||
); |
|||
|
|||
if(array_key_exists($command, $icons)) { |
|||
return $icons[$command]; |
|||
} else { |
|||
return 'md-chevron-right'; |
|||
} |
|||
} |
|||
|
|||
function display() |
|||
{ |
|||
|
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
<section class="scroll"> |
|||
<form name="command" data-sessionid="{$attributes->sessionid}" data-node="{$attributes->node}"> |
|||
{$form} |
|||
</form> |
|||
</section> |
|||
<div> |
|||
<a onclick="Dialog.clear()" class="button flat"> |
|||
{$c->__('button.close')} |
|||
</a> |
|||
{if="$actions != null"} |
|||
{if="isset($actions->next)"} |
|||
<a onclick="AdHoc.submit()" class="button flat"> |
|||
{$c->__('button.next')} |
|||
</a> |
|||
{/if} |
|||
{if="isset($actions->previous)"} |
|||
<a onclick="" class="button flat"> |
|||
{$c->__('button.previous')} |
|||
</a> |
|||
{/if} |
|||
{if="isset($actions->cancel)"} |
|||
<a onclick="" class="button flat"> |
|||
{$c->__('button.cancel')} |
|||
</a> |
|||
{/if} |
|||
{if="isset($actions->complete)"} |
|||
<!--<a onclick="" class="button flat"> |
|||
{$c->__('button.submit')} |
|||
</a>--> |
|||
{/if} |
|||
{/if} |
|||
</div> |
@ -0,0 +1,13 @@ |
|||
<ul class="divided active"> |
|||
{loop="$list"} |
|||
<li class="action" data-node="{$value->attributes()->node}" data-jid="{$value->attributes()->jid}"> |
|||
<span class="icon gray"> |
|||
<i class="md {$c->getIcon((string)$value->attributes()->node)}"></i> |
|||
</span> |
|||
<div class="action"> |
|||
<i class="md md-chevron-right"></i> |
|||
</div> |
|||
<span>{$value->attributes()->name}</span> |
|||
</li> |
|||
{/loop} |
|||
</ul> |
@ -0,0 +1,8 @@ |
|||
<section> |
|||
<h4 class="gray">{$note}</h4> |
|||
</section> |
|||
<div> |
|||
<a onclick="Dialog.clear()" class="button flat"> |
|||
{$c->__('button.close')} |
|||
</a> |
|||
</div> |
@ -0,0 +1,33 @@ |
|||
var AdHoc = { |
|||
refresh: function() { |
|||
var items = document.querySelectorAll('#adhoc_widget li'); |
|||
var i = 0; |
|||
|
|||
while(i < items.length) |
|||
{ |
|||
items[i].onclick = function() { |
|||
AdHoc_ajaxCommand(this.dataset.jid, this.dataset.node); |
|||
}; |
|||
|
|||
i++; |
|||
} |
|||
}, |
|||
initForm: function() { |
|||
var textareas = document.querySelectorAll('#dialog form[name=command] textarea'); |
|||
var i = 0; |
|||
|
|||
while(i < textareas.length) |
|||
{ |
|||
movim_textarea_autoheight(textareas[i]); |
|||
i++; |
|||
} |
|||
}, |
|||
submit: function() { |
|||
var form = document.querySelector('#dialog form[name=command]'); |
|||
AdHoc_ajaxSubmit(movim_parse_form('command'), form.dataset.node, form.dataset.sessionid); |
|||
} |
|||
} |
|||
|
|||
MovimWebsocket.attach(function() { |
|||
AdHoc_ajaxGet(); |
|||
}); |
@ -0,0 +1 @@ |
|||
<div class="tabelem" title="{$c->__('adhoc.title')}" id="adhoc_widget" ></div> |
@ -0,0 +1 @@ |
|||
adhoc.title = 'Actions' |
Write
Preview
Loading…
Cancel
Save
Reference in new issue