Browse Source

- Refactor rewrited url generation

- Fix join/exit Room (for some MUC)
- Start implementing Gateway support
pull/16/head
Jaussoin Timothée 10 years ago
parent
commit
b5dae7b11c
  1. 2
      app/assets/js/movim_tpl.js
  2. 40
      app/widgets/Account/Account.php
  3. 32
      app/widgets/Account/_account_form.tpl
  4. 2
      app/widgets/Chat/chat.js
  5. 15
      app/widgets/Rooms/Rooms.php
  6. 30
      system/Route.php

2
app/assets/js/movim_tpl.js

@ -128,7 +128,7 @@ var MovimTpl = {
back : function() {
// If the contect menu is show
var cm = document.querySelector('ul.context_menu');
if(cm != null && cm.className.contains('shown')) {
if(cm != null && cm.className.includes('shown')) {
MovimTpl.toggleContextMenu(document);
}
// If a dialog box is show

40
app/widgets/Account/Account.php

@ -2,6 +2,7 @@
use Moxl\Xec\Action\Register\ChangePassword;
use Moxl\Xec\Action\Register\Remove;
use Moxl\Xec\Action\Register\Get;
use Respect\Validation\Validator;
class Account extends WidgetBase
@ -11,6 +12,7 @@ class Account extends WidgetBase
$this->addjs('account.js');
$this->registerEvent('register_changepassword_handle', 'onPasswordChanged');
$this->registerEvent('register_remove_handle', 'onRemoved');
$this->registerEvent('register_get_handle', 'onRegister');
}
function onPasswordChanged()
@ -28,6 +30,28 @@ class Account extends WidgetBase
RPC::call('Account.clearAccount');
}
function onRegister($package)
{
$content = $package->content;
$view = $this->tpl();
if(isset($content->x)) {
$xml = new \XMPPtoForm();
$form = $xml->getHTML($content->x->asXML());
$view->assign('form', $form);
$view->assign('attributes', $content->attributes());
$view->assign('actions', null);
if(isset($content->actions)) {
$view->assign('actions', $content->actions);
}
Dialog::fill($view->draw('_account_form', true), true);
}
}
function ajaxChangePassword($form)
{
$validate = Validator::string()->length(6, 40);
@ -67,6 +91,22 @@ class Account extends WidgetBase
$da->request();
}
function ajaxRegister($server)
{
if(!$this->validateServer($server)) return;
$da = new Get;
$da->setTo($server)
->request();
}
private function validateServer($server)
{
$validate_server = Validator::string()->noWhitespace()->length(6, 80);
if(!$validate_server->validate($server)) return false;
else return true;
}
function display()
{
}

32
app/widgets/Account/_account_form.tpl

@ -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>

2
app/widgets/Chat/chat.js

@ -48,8 +48,6 @@ var Chat = {
appendMessage : function(message) {
if(message.body == '') return;
console.log(message);
var bubble = null;
var id = null;

15
app/widgets/Rooms/Rooms.php

@ -19,17 +19,13 @@ class Rooms extends WidgetBase
function onBookmark()
{
RPC::call('movim_fill', 'rooms_widget', $this->prepareRooms());
Notification::append(null, $this->__('bookmarks.updated'));
RPC::call('Rooms.refresh');
$this->refreshRooms();
RPC::call('MovimTpl.hidePanel');
}
function onConnected()
{
RPC::call('movim_fill', 'rooms_widget', $this->prepareRooms());
Notification::append(null, $this->__('chatrooms.connected'));
RPC::call('Rooms.refresh');
$this->refreshRooms();
}
function onDisconnected()
@ -38,6 +34,11 @@ class Rooms extends WidgetBase
$c = new Chat();
$c->ajaxGet();
$this->refreshRooms();
}
private function refreshRooms()
{
RPC::call('movim_fill', 'rooms_widget', $this->prepareRooms());
Notification::append(null, $this->__('chatrooms.disconnected'));
RPC::call('Rooms.refresh');
@ -248,7 +249,7 @@ class Rooms extends WidgetBase
*/
private function validateRoom($room)
{
$validate_server = Validator::email()->noWhitespace()->length(6, 40);
$validate_server = Validator::string()->noWhitespace()->length(6, 80);
if(!$validate_server->validate($room)) return false;
else return true;
}

30
system/Route.php

@ -34,7 +34,9 @@ class Route extends \BaseController {
$cd = new \Modl\ConfigDAO();
$config = $cd->get();
if($config->rewrite == true) {
if($config->rewrite == true
&& isset($_SERVER['HTTP_MOD_REWRITE'])
&& $_SERVER['HTTP_MOD_REWRITE']) {
$request = explode('/', $this->fetchGet('query'));
$this->_page = $request[0];
array_shift($request);
@ -80,28 +82,30 @@ class Route extends \BaseController {
//} else {
if($tab != false)
$tab = '#'.$tab;
// Here we got a beautiful rewriten URL !
if($config->rewrite == true
&& isset($_SERVER['HTTP_MOD_REWRITE'])
&& $_SERVER['HTTP_MOD_REWRITE']) {
$uri = BASE_URI . $page;
if($params != false && is_array($params))
foreach($params as $value)
$uri .= '/' . $value;
elseif($params != false)
$uri .= '/' . $params;
}
//We construct a classic URL if the rewriting is disabled
if($config->rewrite == false) {
$uri = BASE_URI . '?q='.$page;
else {
$uri = BASE_URI . '?q=' . $page;
if($params != false && is_array($params)) {
$i = 0;
foreach($params as $value) {
$uri .= '&'.$routes[$page][$i].'='.$value;
$uri .= '&' . $routes[$page][$i] . '=' . $value;
$i++;
}
}
elseif($params != false)
$uri .= '&'.$routes[$page][0].'='.$params;
}
// Here we got a beautiful rewriten URL !
else {
$uri = BASE_URI . $page;
if($params != false && is_array($params))
foreach($params as $value)
$uri .= '/'.$value;
elseif($params != false)
$uri .= '/'.$params;
}
return $uri.$tab;
//}

Loading…
Cancel
Save