Browse Source

- Fix locales in Syndication

- Fix embed preview (link OR picture) during publication
- Display the gateways in the config page to enable/disable them
- First (working) implementation of HttpUploadComponent \o/
pull/56/head
Jaussoin Timothée 10 years ago
parent
commit
81e5e935fa
  1. 36
      app/models/item/ItemDAO.php
  2. 1
      app/views/chat.tpl
  3. 1
      app/views/news.tpl
  4. 17
      app/widgets/Account/Account.php
  5. 5
      app/widgets/Account/_account_form.tpl
  6. 19
      app/widgets/Account/account.tpl
  7. 1
      app/widgets/Account/locales.ini
  8. 13
      app/widgets/Chat/_chat_header.tpl
  9. 7
      app/widgets/Chat/chat.js
  10. 9
      app/widgets/Publish/Publish.php
  11. 8
      app/widgets/Publish/_publish_create.tpl
  12. 7
      app/widgets/Publish/_publish_gallery.tpl
  13. 1
      app/widgets/Publish/locales.ini
  14. 6
      app/widgets/Publish/publish.js
  15. 12
      app/widgets/Syndication/Syndication.php
  16. 6
      app/widgets/Syndication/locales.ini
  17. 6
      app/widgets/Syndication/syndication.tpl
  18. 30
      system/User.php

36
app/models/item/ItemDAO.php

@ -136,7 +136,6 @@ class ItemDAO extends SQL {
}
function getItems($server) {
$this->_sql = '
select * from item
left outer join (
@ -169,6 +168,41 @@ class ItemDAO extends SQL {
return $this->run('Item');
}
function getGateways($server) {
$this->_sql = '
select * from item
left outer join caps on caps.node = item.jid
where server = :server
and category = \'gateway\'';
$this->prepare(
'Item',
array(
'server' => $server
)
);
return $this->run('Item');
}
function getUpload($server) {
$this->_sql = '
select * from item
left outer join caps on caps.node = item.jid
where server = :server
and category = \'store\'
and type = \'file\'';
$this->prepare(
'Item',
array(
'server' => $server
)
);
return $this->run('Item', 'item');
}
function getUpdatedItems($limitf = false, $limitr = false) {
$this->_sql = '
select * from item natural join (

1
app/views/chat.tpl

@ -10,6 +10,7 @@
<?php $this->widget('Chats');?>
<?php $this->widget('Rooms');?>
</div>
<?php $this->widget('Upload');?>
<?php $this->widget('Chat');?>
</section>
</main>

1
app/views/news.tpl

@ -1,4 +1,5 @@
<?php $this->widget('Init');?>
<?php $this->widget('Upload');?>
<nav class="color dark">
<?php $this->widget('Navigation');?>

17
app/widgets/Account/Account.php

@ -3,6 +3,7 @@
use Moxl\Xec\Action\Register\ChangePassword;
use Moxl\Xec\Action\Register\Remove;
use Moxl\Xec\Action\Register\Get;
use Moxl\Xec\Action\Register\Set;
use Respect\Validation\Validator;
class Account extends WidgetBase
@ -12,7 +13,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');
$this->registerEvent('register_get_handle', 'onRegister');
}
function onPasswordChanged()
@ -41,6 +42,7 @@ class Account extends WidgetBase
$form = $xml->getHTML($content->x->asXML());
$view->assign('form', $form);
$view->assign('from', $package->from);
$view->assign('attributes', $content->attributes());
$view->assign('actions', null);
if(isset($content->actions)) {
@ -91,7 +93,7 @@ class Account extends WidgetBase
$da->request();
}
function ajaxRegister($server)
function ajaxGetRegistration($server)
{
if(!$this->validateServer($server)) return;
@ -100,6 +102,15 @@ class Account extends WidgetBase
->request();
}
function ajaxRegister($server, $form)
{
if(!$this->validateServer($server)) return;
$s = new Set;
$s->setTo($server)
->setData($form)
->request();
}
private function validateServer($server)
{
$validate_server = Validator::string()->noWhitespace()->length(6, 80);
@ -109,5 +120,7 @@ class Account extends WidgetBase
function display()
{
$id = new \Modl\ItemDAO;
$this->view->assign('gateway', $id->getGateways($this->user->getServer()));
}
}

5
app/widgets/Account/_account_form.tpl

@ -1,5 +1,5 @@
<section class="scroll">
<form name="command" data-sessionid="{$attributes->sessionid}" data-node="{$attributes->node}">
<form name="register" data-sessionid="{$attributes->sessionid}" data-node="{$attributes->node}">
{$form}
</form>
</section>
@ -7,6 +7,9 @@
<a onclick="Dialog.clear()" class="button flat">
{$c->__('button.close')}
</a>
<a onclick="Account_ajaxRegister('{$from}', movim_form_to_json('register')); Dialog.clear();" class="button flat">
{$c->__('button.submit')}
</a>
{if="$actions != null"}
{if="isset($actions->next)"}
<a onclick="AdHoc.submit()" class="button flat">

19
app/widgets/Account/account.tpl

@ -1,4 +1,21 @@
<div class="tabelem" title="{$c->__('account.title')}" id="account_widget" >
<div class="tabelem" title="{$c->__('account.title')}" id="account_widget">
{if="isset($gateway)"}
<ul class="active middle divided">
<li class="subheader">{$c->__('account.gateway_title')}</li>
{loop="$gateway"}
<li class="condensed action" onclick="Account_ajaxGetRegistration('{$value->node}')">
<div class="action">
<i class="zmdi zmdi-chevron-right"></i>
</div>
<span class="icon">
<i class="zmdi zmdi-swap"></i>
</span>
<span>{$value->name}</span>
<p>{$value->node}</p>
</li>
{/loop}
</ul>
{/if}
<ul class="middle active divided ">
<li class="subheader">{$c->__('account.password_change_title')}</li>
<li>

1
app/widgets/Account/locales.ini

@ -10,3 +10,4 @@ delete_title = Delete my account
delete = Delete your account
delete_text = You will delete your XMPP account and all the relative information linked to it (profile, contacts and publications).
delete_text_confirm = "Are you sure that you want to delete it ?"
gateway_title = Gateway

13
app/widgets/Chat/_chat_header.tpl

@ -7,17 +7,26 @@
</li>
</ul>
<span class="on_desktop icon"><i class="zmdi zmdi-comments"></i></span>
<h2 class="r1">{$c->__('page.chats')}</h2>
<h2 class="r1">
{$c->__('page.chats')}
</h2>
</div>
<div>
<ul class="active">
{if="$c->supported('upload')"}
<li onclick="Upload_ajaxRequest()">
<span class="icon">
<i class="zmdi zmdi-attachment-alt"></i>
</span>
</li>
{/if}
<li onclick="Chats_ajaxClose('{$jid|echapJS}'); MovimTpl.hidePanel();">
<span class="icon">
<i class="zmdi zmdi-close"></i>
</span>
</li>
</ul>
<div id="chat_header" class="return active r1 condensed" onclick="MovimTpl.hidePanel(); Chat_ajaxGet();">
<div id="chat_header" class="return active {if="$c->supported('upload')"}r2{else}r1{/if} condensed" onclick="MovimTpl.hidePanel(); Chat_ajaxGet();">
<span id="back" class="icon"><i class="zmdi zmdi-arrow-back"></i></span>
<h2>
{if="$contact != null"}

7
app/widgets/Chat/chat.js

@ -121,4 +121,11 @@ var Chat = {
}
}
Upload.attach(function() {
var textarea = document.querySelector('#chat_textarea');
textarea.value = Upload.get + ' ' + textarea.value;
textarea.focus();
movim_textarea_autoheight(textarea);
});
var state = 0;

9
app/widgets/Publish/Publish.php

@ -158,12 +158,13 @@ class Publish extends WidgetBase
if($form->embed->value != '' && filter_var($form->embed->value, FILTER_VALIDATE_URL)) {
$embed = Embed\Embed::create($form->embed->value);
$content .= $this->prepareEmbed($embed);
$p->setLink($form->embed->value);
if($embed->type == 'photo') {
$key = key($embed->images);
$p->setImage($embed->images[0]['value'], $embed->title, $embed->images[0]['mime']);
} else {
$content .= $this->prepareEmbed($embed);
}
}
@ -189,9 +190,11 @@ class Publish extends WidgetBase
if($embed->type == 'photo') {
RPC::call('movim_fill', 'gallery', $this->prepareGallery($embed));
RPC::call('movim_fill', 'preview', '');
} else {
RPC::call('movim_fill', 'preview', $html);
RPC::call('movim_fill', 'gallery', '');
}
RPC::call('movim_fill', 'preview', $html);
}
function prepareEmbed($embed)

8
app/widgets/Publish/_publish_create.tpl

@ -27,6 +27,14 @@
</div>
<ul class="middle flex active">
{if="$c->supported('upload')"}
<li class="block large" onclick="Upload_ajaxRequest()">
<span class="icon">
<i class="zmdi zmdi-attachment-alt"></i>
</span>
<span>{$c->__('publish.attach')}</span>
</li>
{/if}
<li class="subheader">{$c->__('post.embed_tip')}</li>
<a class="block" target="_blank" href="http://imgur.com/">
<li class="block action">

7
app/widgets/Publish/_publish_gallery.tpl

@ -1,8 +1,13 @@
<ul class="thick">
<li>
<li class="condensed">
<span class="icon bubble" style="background-image: url({$embed->images[0]['value']|htmlspecialchars});">
<i class="zmdi zmdi-image"></i>
</span>
<span>{$c->__('post.gallery')}</span>
<p>
<a href="{$embed->images[0]['value']|htmlspecialchars}" target="_blank">
{$embed->images[0]['value']|htmlspecialchars}
</a>
</p>
</li>
</ul>

1
app/widgets/Publish/locales.ini

@ -21,5 +21,6 @@ no_content_preview = No content to preview
no_content = No content
new = New post
title = Publish
attach = Add a file or a picture to your post
no_publication = You cannot publish a post on this Group
form_filled = Some fields have been filled in. Do you still want to go back and loose their content?

6
app/widgets/Publish/publish.js

@ -57,6 +57,12 @@ var Publish = {
}
}
Upload.attach(function() {
var embed = document.querySelector('input[name=embed]');
embed.value = Upload.get;
embed.onpaste();
});
MovimWebsocket.attach(function() {
Publish.init();
});

12
app/widgets/Syndication/Syndication.php

@ -21,33 +21,33 @@ class Syndication extends WidgetBase
} else {
return;
}
$pd = new \modl\PostnDAO();
$cd = new \modl\ContactDAO();
$this->view->assign('contact', $cd->get($from, true));
$this->view->assign('uri', Route::urlize('blog',array($from)));
if(isset($from) && isset($node)) {
$messages = $pd->getPublic($from, $node, 10, 0);
$this->view->assign('messages', $messages);
}
if(isset($messages[0])) {
header("Content-Type: application/atom+xml; charset=UTF-8");
$this->view->assign('date', date('c'));
}
}
function prepareTitle($title)
{
if($title == null)
return '...';
else
return $this->prepareContent($title, true);
return $this->prepareContent($title, true);
}
function prepareContent($content, $title = false)
{
if($title)

6
app/widgets/Syndication/locales.ini

@ -1,4 +1,4 @@
[feed]
title = "%s's feed"
no = No public feed for this contact
no_contact = No contact specified
title = "%s's feed"
nope = No public feed for this contact
nope_contact = No contact specified

6
app/widgets/Syndication/syndication.tpl

@ -1,4 +1,4 @@
{if="isset($contact)"}
{if="isset($contact)"}
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{$c->__('feed.title', $contact->getTrueName())}</title>
@ -15,7 +15,7 @@
</generator>
<id>urn:uuid:{$uuid}</id>
{if="!empty($messages)"}
{if="!empty($messages)"}
{loop="$messages"}
<entry>
<title>
@ -39,5 +39,5 @@
{/loop}
</feed>
{else}
{$c->__('feed.no_contact')}
{$c->__('feed.nope_contact')}
{/if}

30
system/User.php

@ -22,10 +22,10 @@ class User {
private $config = array();
public $caps;
public $userdir;
public $useruri;
public $sizelimit;
/**
@ -35,7 +35,7 @@ class User {
function __construct()
{
$session = \Sessionx::start();
if($session->active) {
if($session->active) {
$this->username = $session->user.'@'.$session->host;
//$this->reload();
@ -64,7 +64,7 @@ class User {
$this->caps = unserialize($caps->features);
}
}
/**
* Get the current size in bytes of the user directory
*/
@ -74,10 +74,10 @@ class User {
foreach($this->getDir() as $s)
$sum = $sum + filesize($this->userdir.$s);
return $sum;
}
/**
* Get a list of the files in the user dir with uri, dir and thumbs
*/
@ -87,14 +87,14 @@ class User {
if(is_dir($this->userdir))
foreach(scandir($this->userdir) as $s) {
if(
$s != '.' &&
$s != '..' &&
$s != '.' &&
$s != '..' &&
$s != 'index.html') {
array_push($dir, $s);
}
}
return $dir;
}
@ -119,7 +119,7 @@ class User {
$s = \Sessionx::start();
$s->destroy();
$sess = Session::start();
Session::dispose();
}
@ -138,6 +138,12 @@ class User {
return $this->username;
}
function getServer()
{
$exp = explodeJid($this->username);
return $exp['server'];
}
function getPass()
{
return $this->password;
@ -167,6 +173,10 @@ class User {
case 'pubsub':
return in_array('http://jabber.org/protocol/pubsub#publish', $this->caps);
break;
case 'upload':
$id = new \Modl\ItemDAO;
return ($id->getUpload($this->getServer()) != null);
break;
default:
return false;
break;

Loading…
Cancel
Save