Browse Source

merge with movim

pull/16/head
Christine Ho 11 years ago
parent
commit
c1bc49ca44
  1. 14
      .htaccess
  2. 2
      VERSION
  3. 7
      app/assets/js/movim_tpl.js
  4. 8
      app/controllers/MainController.php
  5. 8
      app/controllers/NewsController.php
  6. 7
      app/controllers/PodsController.php
  7. 21
      app/helpers/StringHelper.php
  8. 4
      app/models/config/Config.php
  9. 5
      app/models/config/ConfigDAO.php
  10. 21
      app/models/contact/Contact.php
  11. 26
      app/models/contact/ContactDAO.php
  12. 45
      app/models/postn/Postn.php
  13. 163
      app/models/postn/PostnDAO.php
  14. 22
      app/views/about.tpl
  15. 23
      app/views/blog.tpl
  16. 3
      app/views/chat.tpl
  17. 5
      app/views/conf.tpl
  18. 7
      app/views/contact.tpl
  19. 2
      app/views/help.tpl
  20. 7
      app/views/login.tpl
  21. 5
      app/views/main.tpl
  22. 30
      app/views/news.tpl
  23. 65
      app/views/page.tpl
  24. 18
      app/views/pods.tpl
  25. 29
      app/widgets/About/about.tpl
  26. 2
      app/widgets/AccountNext/AccountNext.php
  27. 2
      app/widgets/AccountNext/_accountnext_registered.tpl
  28. 118
      app/widgets/AdHoc/AdHoc.php
  29. 32
      app/widgets/AdHoc/_adhoc_form.tpl
  30. 13
      app/widgets/AdHoc/_adhoc_list.tpl
  31. 8
      app/widgets/AdHoc/_adhoc_note.tpl
  32. 33
      app/widgets/AdHoc/adhoc.js
  33. 1
      app/widgets/AdHoc/adhoc.tpl
  34. 1
      app/widgets/AdHoc/locales.ini
  35. 2
      app/widgets/AdminDB/AdminDB.php
  36. 24
      app/widgets/AdminDB/admindb.tpl
  37. 13
      app/widgets/AdminMain/AdminMain.php
  38. 96
      app/widgets/AdminMain/adminmain.tpl
  39. 4
      app/widgets/AdminMain/locales.ini
  40. 10
      app/widgets/AdminTest/admintest.css
  41. 46
      app/widgets/AdminTest/admintest.tpl
  42. 2
      app/widgets/AdminTest/locales.ini
  43. 17
      app/widgets/Avatar/Avatar.php
  44. 60
      app/widgets/Avatar/_avatar_form.tpl
  45. 52
      app/widgets/Avatar/avatar.css
  46. 92
      app/widgets/Avatar/avatar.js
  47. 2
      app/widgets/Avatar/locales.ini
  48. 39
      app/widgets/Blog/Blog.php
  49. 61
      app/widgets/Blog/blog.tpl
  50. 10
      app/widgets/Caps/caps.css
  51. 2
      app/widgets/Caps/caps.tpl
  52. 84
      app/widgets/Chat/Chat.php
  53. 2
      app/widgets/Chat/_chat.tpl
  54. 35
      app/widgets/Chat/_chat_header.tpl
  55. 47
      app/widgets/Chat/_chat_header_room.tpl
  56. 32
      app/widgets/Chat/_chat_message.tpl
  57. 37
      app/widgets/Chat/_chat_messages.tpl
  58. 5
      app/widgets/Chat/_chat_state.tpl
  59. 9
      app/widgets/Chat/chat.css
  60. 32
      app/widgets/Chats/Chats.php
  61. 6
      app/widgets/Chats/_chats.tpl
  62. 20
      app/widgets/Chats/_chats_add.tpl
  63. 18
      app/widgets/Chats/_chats_add_extend.tpl
  64. 2
      app/widgets/Chats/chats.js
  65. 2
      app/widgets/Chats/chats.tpl
  66. 4
      app/widgets/Chats/locales.ini
  67. 14
      app/widgets/Config/Config.php
  68. 18
      app/widgets/Config/_config_form.tpl
  69. 15
      app/widgets/Config/locales.ini
  70. 81
      app/widgets/Contact/Contact.php
  71. 110
      app/widgets/Contact/_contact.tpl
  72. 10
      app/widgets/Contact/_contact_edit.tpl
  73. 30
      app/widgets/Contact/_contact_explore.tpl
  74. 70
      app/widgets/Contact/_contact_header.tpl
  75. 2
      app/widgets/Contact/contact.tpl
  76. 5
      app/widgets/Contact/locales.ini
  77. 153
      app/widgets/ContactAction/ContactAction.php
  78. 3
      app/widgets/ContactAction/contactaction.tpl
  79. 5
      app/widgets/ContactAction/locales.ini
  80. 151
      app/widgets/ContactCard/ContactCard.php
  81. 7
      app/widgets/ContactCard/contactcard.css
  82. 6
      app/widgets/ContactCard/contactcard.tpl
  83. 15
      app/widgets/ContactCard/locales.ini
  84. 163
      app/widgets/ContactInfo/ContactInfo.php
  85. 12
      app/widgets/ContactInfo/contactinfo.css
  86. 3
      app/widgets/ContactInfo/contactinfo.tpl
  87. 13
      app/widgets/ContactInfo/locales.ini
  88. 76
      app/widgets/ContactManage/ContactManage.php
  89. 35
      app/widgets/ContactManage/_contact_manage_form.tpl
  90. 5
      app/widgets/ContactManage/contactmanage.tpl
  91. 4
      app/widgets/ContactManage/locales.ini
  92. 74
      app/widgets/ContactPubsubSubscription/ContactPubsubSubscription.php
  93. 5
      app/widgets/ContactPubsubSubscription/contactpubsubsubscription.js
  94. 10
      app/widgets/ContactPubsubSubscription/contactpubsubsubscription.tpl
  95. 2
      app/widgets/ContactPubsubSubscription/locales.ini
  96. 76
      app/widgets/ContactSummary/ContactSummary.php
  97. 20
      app/widgets/ContactSummary/_contactsummary_content.tpl
  98. 37
      app/widgets/ContactSummary/contactsummary.css
  99. 11
      app/widgets/ContactSummary/contactsummary.tpl
  100. 5
      app/widgets/Dialog/Dialog.php

14
.htaccess

@ -2,7 +2,7 @@ Options -Indexes
AddType application/x-web-app-manifest+json .webapp
<IfModule mod_rewrite.c>
# Tell PHP that the mod_rewrite module is ENABLED.
#SetEnv HTTP_MOD_REWRITE 1
SetEnv HTTP_MOD_REWRITE 1
# If you have troubles or use VirtualDocumentRoot
# uncomment this and set it to the path where your Movim installation is
@ -12,11 +12,11 @@ AddType application/x-web-app-manifest+json .webapp
# Movim url: http://some.example.com/movim
# RewriteBase /movim/
#RewriteBase /0.9/
#RewriteEngine On
RewriteBase /0.9/
RewriteEngine On
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule (.*) index.php?query=$1 [L]
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?query=$1 [L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

2
VERSION

@ -1 +1 @@
0.8.1
0.9

7
app/assets/js/movim_tpl.js

@ -89,6 +89,9 @@ var MovimTpl = {
toggleMenu : function() {
movim_toggle_class('body > nav', 'active');
},
hideMenu : function() {
movim_remove_class('body > nav', 'active');
},
back : function() {
// If a dialog box is shown
if(Dialog.filled()) {
@ -102,6 +105,10 @@ var MovimTpl = {
} else {
window.history.back();
}
},
getHeaderColor : function() {
var header = document.querySelector('body main > header');
return window.getComputedStyle(header).backgroundColor;
}
}

8
app/controllers/MainController.php

@ -7,13 +7,5 @@ class MainController extends BaseController {
function dispatch() {
$this->page->setTitle(__('title.main', APP_TITLE));
$this->page->menuAddLink(__('page.home'), 'root', true);
$this->page->menuAddLink(__('page.news'), 'news');
$this->page->menuAddLink(__('page.explore'), 'explore');
$this->page->menuAddLink(__('page.profile'), 'profile');
$this->page->menuAddLink(__('page.media'), 'media');
$this->page->menuAddLink(__('page.configuration'), 'conf', false, true);
$this->page->menuAddLink(__('page.help'), 'help', false, true);
}
}

8
app/controllers/NewsController.php

@ -7,13 +7,5 @@ class NewsController extends BaseController {
function dispatch() {
$this->page->setTitle(__('title.news', APP_TITLE));
$this->page->menuAddLink(__('page.home'), 'root');
$this->page->menuAddLink(__('page.news'), 'news', true);
$this->page->menuAddLink(__('page.explore'), 'explore');
$this->page->menuAddLink(__('page.profile'), 'profile');
$this->page->menuAddLink(__('page.media'), 'media');
$this->page->menuAddLink(__('page.configuration'), 'conf', false, true);
$this->page->menuAddLink(__('page.help'), 'help', false, true);
}
}

7
app/controllers/PodsController.php

@ -9,10 +9,7 @@ class PodsController extends BaseController {
function dispatch() {
$this->page->setTitle(__('title.discover', APP_TITLE));
$this->page->menuAddLink(__('page.home'), 'root');
$this->page->menuAddLink(__('page.discover'), 'discover');
$this->page->menuAddLink(__('page.pods'), 'pods', true);
$this->page->menuAddLink(__('page.about'), 'about');
$this->page->setColor('indigo');
}
}

21
app/helpers/StringHelper.php

@ -1,5 +1,8 @@
<?php
use HeyUpdate\Emoji\Emoji;
use HeyUpdate\Emoji\EmojiIndex;
/**
* Prepare the string (add the a to the links and show the smileys)
*
@ -125,12 +128,17 @@ function prepareString($string) {
$config = $cd->get();
$theme = $config->theme;
$path = BASE_URI . 'themes/' . $theme . '/img/smileys/';
$path = BASE_URI . 'themes/' . $theme . '/img/emojis/';
/*
foreach($smileys as $key => $value) {
$replace = ' <img class="smiley" alt="smiley" src="'.$path.$value.'">';
$string = preg_replace('/(^|[ ])('.$key.')/', $replace, $string);
}
}*/
$emoji = new Emoji(new EmojiIndex(), $path.'%s.png');
$string = $emoji->replaceEmojiWithImages($string);
return trim($string);
}
@ -196,6 +204,14 @@ function echapJid($jid)
return str_replace(' ', '\40', $jid);
}
/*
* Echap the anti-slashs for Javascript
*/
function echapJS($string)
{
return str_replace("\\", "\\\\", $string);
}
/*
* Clean the resource of a jid
*/
@ -302,4 +318,3 @@ function stringToColor($string) {
function firstLetterCapitalize($string) {
return ucfirst(strtolower(mb_substr($string, 0, 2)));
}

4
app/models/config/Config.php

@ -16,6 +16,7 @@ class Config extends Model {
public $unregister;
public $username;
public $password;
public $rewrite;
public $sizelimit;
public function __construct() {
@ -47,6 +48,8 @@ class Config extends Model {
{"type":"string", "size":32, "mandatory":true },
"password" :
{"type":"string", "size":64, "mandatory":true },
"rewrite" :
{"type":"int", "size":1 },
"sizelimit" :
{"type":"int", "size":16 }
}';
@ -66,6 +69,7 @@ class Config extends Model {
$this->unregister = false;
$this->username = 'admin';
$this->password = sha1('password');
$this->rewrite = false;
$this->sizelimit = 20240001;
}
}

5
app/models/config/ConfigDAO.php

@ -19,6 +19,7 @@ class ConfigDAO extends SQL {
unregister = :unregister,
username = :username,
password = :password,
rewrite = :rewrite,
sizelimit = :sizelimit';
$this->prepare(
@ -37,6 +38,7 @@ class ConfigDAO extends SQL {
'unregister' => $c->unregister,
'username' => $c->username,
'password' => $c->password,
'rewrite' => $c->rewrite,
'sizelimit' => $c->sizelimit
)
);
@ -71,6 +73,7 @@ class ConfigDAO extends SQL {
unregister,
username,
password,
rewrite,
sizelimit
)
values
@ -88,6 +91,7 @@ class ConfigDAO extends SQL {
:unregister,
:username,
:password,
:rewrite,
:sizelimit
)
';
@ -108,6 +112,7 @@ class ConfigDAO extends SQL {
'unregister' => $c->unregister,
'username' => $c->username,
'password' => $c->password,
'rewrite' => $c->rewrite,
'sizelimit' => $c->sizelimit
)
);

21
app/models/contact/Contact.php

@ -10,7 +10,7 @@ class Contact extends Model {
protected $date;
protected $url;
protected $email;
public $email;
protected $adrlocality;
protected $adrpostalcode;
@ -192,8 +192,9 @@ class Contact extends Model {
$p->fromBase($this->photobin);
$p->set($this->jid);
if(isset($this->email))
if(isset($this->email)) {
\createEmailPic(strtolower($this->jid), $this->email);
}
}
public function getPhoto($size = 'l', $jid = false) {
@ -207,17 +208,19 @@ class Contact extends Model {
if(isset($jid)) {
$sizes = array(
'l' => 210,
'm' => 120,
's' => 50,
'xs' => 28,
'xxs' => 24
'wall' => array(1920, 1080),
'xxl' => array(1280, 300),
'l' => array(210 , false),
'm' => array(120 , false),
's' => array(50 , false),
'xs' => array(28 , false),
'xxs' => array(24 , false)
);
$p = new \Picture;
if($p->get($jid, $sizes[$size])) {
return $p->get($jid, $sizes[$size]);
if($p->get($jid, $sizes[$size][0], $sizes[$size][1])) {
return $p->get($jid, $sizes[$size][0], $sizes[$size][1]);
} else {
$out = base_convert($jid, 32, 8);

26
app/models/contact/ContactDAO.php

@ -7,7 +7,7 @@ class ContactDAO extends SQL {
parent::__construct();
}
function get($jid = null) {
function get($jid = null, $empty = false) {
$this->_sql = '
select *, privacy.value as privacy from contact
left outer join privacy
@ -26,7 +26,7 @@ class ContactDAO extends SQL {
$contact = $this->run('Contact', 'item');
// If we cannot find the contact
if($contact == null) {
if($contact == null && $empty == false) {
$contact = new Contact;
$contact->jid = $jid;
return $contact;
@ -573,7 +573,29 @@ class ContactDAO extends SQL {
return $this->run('RosterContact');
else
return $this->run('RosterContact', 'item');
}
function getTop($limit = 5) {
$this->_sql = '
select *, jidfrom from (
select jidfrom, count(*) as count from message
where jidfrom not like :jid
and session = :jid
group by jidfrom
order by count desc
limit :tunelenght
) as top
left outer join contact on jidfrom = contact.jid';
$this->prepare(
'Contact',
array(
'jid' => $this->_user,
'tunelenght' => $limit // And an another hack…
)
);
return $this->run('Contact');
}
function getStatistics() {

45
app/models/postn/Postn.php

@ -3,9 +3,7 @@
namespace Modl;
class Postn extends Model {
public $session;
public $jid; // Where the post is comming from (jid or server)
public $origin; // Where the post is comming from (jid or server)
public $node; // microblog or pubsub
public $nodeid; // the ID if the item
@ -23,7 +21,8 @@ class Postn extends Model {
public $updated; //
public $delay; //
public $tags;
public $tags; // Store the tags
public $picture; // Tell if the post contain embeded pictures
public $lat;
public $lon;
@ -33,15 +32,13 @@ class Postn extends Model {
public $privacy;
public $hash;
public function __construct() {
$this->hash = md5(openssl_random_pseudo_bytes(5));
$this->_struct = '
{
"session" :
{"type":"string", "size":64, "mandatory":true, "key":true },
"jid" :
"origin" :
{"type":"string", "size":64, "mandatory":true, "key":true },
"node" :
{"type":"string", "size":96, "mandatory":true, "key":true },
@ -76,6 +73,8 @@ class Postn extends Model {
"links" :
{"type":"text" },
"picture" :
{"type":"int", "size":4 },
"tags" :
{"type":"text" },
"hash" :
@ -86,15 +85,12 @@ class Postn extends Model {
}
public function set($item, $from, $delay = false, $node = false) {
$user = new \User();
$this->session = $user->getLogin();
if($item->item)
$entry = $item->item;
else
$entry = $item;
$this->jid = $from;
$this->origin = $from;
if($node)
$this->node = $node;
@ -183,7 +179,7 @@ class Postn extends Model {
$content .= '<br />'.$contentimg;
if(!isset($this->commentplace))
$this->commentplace = $this->jid;
$this->commentplace = $this->origin;
$this->content = trim($content);
$this->contentcleaned = prepareString(html_entity_decode($this->content));
@ -195,6 +191,10 @@ class Postn extends Model {
$this->lon = (string)$entry->entry->geoloc->lon;
}
}
private function typeIsPicture($type) {
return in_array($type, array('image/jpeg', 'image/png', 'image/jpg'));
}
private function setAttachements($links) {
$contentimg = '';
@ -205,9 +205,13 @@ class Postn extends Model {
$enc = array();
$enc = (array)$attachment->attributes();
$enc = $enc['@attributes'];
array_push($l, $enc);
array_push($l, $enc);
if(array_key_exists('type', $enc)
&& $this->typeIsPicture($enc['type'])) {
$this->picture = true;
}
if((string)$attachment->attributes()->title == 'comments') {
$substr = explode('?',substr((string)$attachment->attributes()->href, 5));
$this->commentplace = reset($substr);
@ -231,7 +235,7 @@ class Postn extends Model {
foreach($links as $l) {
switch($l['rel']) {
case 'enclosure' :
if(in_array($l['type'], array('image/jpeg', 'image/png', 'image/jpg'))) {
if($this->typeIsPicture($l['type'])) {
array_push($attachements['pictures'], $l);
} else {
array_push($attachements['files'], $l);
@ -259,6 +263,15 @@ class Postn extends Model {
return false;
}
public function isMine() {
$user = new \User();
if($this->origin == $user->getLogin())
return true;
else
return false;
}
public function isMicroblog() {
if($this->node == "urn:xmpp:microblog:0")
return true;

163
app/models/postn/PostnDAO.php

@ -24,15 +24,15 @@ class PostnDAO extends SQL {
lon = :lon,
links = :links,
picture = :picture,
tags = :tags,
hash = :hash
where session = :session
and jid = :jid
where origin = :origin
and node = :node
and nodeid = :nodeid';
$this->prepare(
'Postn',
array(
@ -54,26 +54,24 @@ class PostnDAO extends SQL {
'lon' => $post->lon,
'links' => $post->links,
'picture' => $post->picture,
'tags' => $post->tags,
'hash' => $post->hash,
'session' => $post->session,
'jid' => $post->jid,
'origin' => $post->origin,
'node' => $post->node,
'nodeid' => $post->nodeid
)
);
$this->run('Postn');
if(!$this->_effective) {
$this->_sql ='
insert into postn
(
session,
jid,
origin,
node,
nodeid,
@ -95,13 +93,12 @@ class PostnDAO extends SQL {
lon,
links,
picture,
tags,
hash)
values(
:session,
:jid,
values(
:origin,
:node,
:nodeid,
@ -123,6 +120,7 @@ class PostnDAO extends SQL {
:lon,
:links,
:picture,
:tags,
:hash
@ -149,12 +147,12 @@ class PostnDAO extends SQL {
'lon' => $post->lon,
'links' => $post->links,
'picture' => $post->picture,
'tags' => $post->tags,
'hash' => $post->hash,
'session' => $post->session,
'jid' => $post->jid,
'origin' => $post->origin,
'node' => $post->node,
'nodeid' => $post->nodeid
)
@ -201,8 +199,8 @@ class PostnDAO extends SQL {
select *, postn.aid, privacy.value as privacy from postn
left outer join contact on postn.aid = contact.jid
left outer join privacy on postn.nodeid = privacy.pkey
where postn.session = :session
and postn.jid = :jid
where ((postn.origin, node) in (select server, node from subscription where jid = :aid))
and postn.origin = :origin
and postn.node = :node
order by postn.published desc';
@ -212,8 +210,8 @@ class PostnDAO extends SQL {
$this->prepare(
'Postn',
array(
'session' => $this->_user,
'jid' => $from,
'aid' => $this->_user, // TODO: Little hack to bypass the check, need to fix it in Modl
'origin' => $from,
'node' => $node
)
);
@ -221,19 +219,37 @@ class PostnDAO extends SQL {
return $this->run('ContactPostn');
}
function getItem($id) {
function getGallery($from) {
$this->_sql = '
select *, postn.aid, privacy.value as privacy from postn
left outer join contact on postn.aid = contact.jid
left outer join privacy on postn.nodeid = privacy.pkey
where postn.session = :session
and postn.nodeid = :nodeid
where (postn.origin in (select jid from rosterlink where session = :origin and rostersubscription in (\'both\', \'to\')))
and postn.origin = :aid
and postn.picture = 1
order by postn.published desc';
$this->prepare(
'Postn',
array(
'session' => $this->_user,
'origin' => $this->_user,
'aid' => $from // Another hack
)
);
return $this->run('ContactPostn');
}
function getItem($id) {
$this->_sql = '
select *, postn.aid, privacy.value as privacy from postn
left outer join contact on postn.aid = contact.jid
left outer join privacy on postn.nodeid = privacy.pkey
where postn.nodeid = :nodeid';
$this->prepare(
'Postn',
array(
'nodeid' => $id
)
);
@ -246,8 +262,15 @@ class PostnDAO extends SQL {
select *, postn.aid, privacy.value as privacy from postn
left outer join contact on postn.aid = contact.jid
left outer join privacy on postn.nodeid = privacy.pkey
where postn.session = :session
order by postn.published desc';
where (
(postn.origin in (select jid from rosterlink where session = :origin and rostersubscription in (\'both\', \'to\')) and node = \'urn:xmpp:microblog:0\')
or (postn.origin = :origin and node = \'urn:xmpp:microblog:0\')
or ((postn.origin, node) in (select server, node from subscription where jid = :origin))
)
and postn.node not like \'urn:xmpp:microblog:0:comments/%\'
and postn.node not like \'urn:xmpp:inbox\'
order by postn.published desc
';
if($limitr)
$this->_sql = $this->_sql.' limit '.$limitr.' offset '.$limitf;
@ -258,7 +281,7 @@ class PostnDAO extends SQL {
$this->prepare(
'Postn',
array(
'session' => $jid
'origin' => $jid
)
);
@ -267,14 +290,15 @@ class PostnDAO extends SQL {
function getFeed($limitf = false, $limitr = false) {
$this->_sql = '
select *, postn.aid as jid, privacy.value as privacy from postn
select *, postn.aid, privacy.value as privacy from postn
left outer join contact on postn.aid = contact.jid
left outer join privacy on postn.nodeid = privacy.pkey
where postn.session = :session
and postn.node like \'urn:xmpp:microblog:0\'
and (postn.jid in (select rosterlink.jid from rosterlink where rosterlink.session = :session)
or postn.jid = :session)
order by postn.published desc';
where ((postn.origin in (select jid from rosterlink where session = :origin and rostersubscription in (\'both\', \'to\')) and node = \'urn:xmpp:microblog:0\')
or (postn.origin = :origin and node = \'urn:xmpp:microblog:0\'))
and postn.node not like \'urn:xmpp:microblog:0:comments/%\'
and postn.node not like \'urn:xmpp:inbox\'
order by postn.published desc
';
if($limitr)
$this->_sql = $this->_sql.' limit '.$limitr.' offset '.$limitf;
@ -282,7 +306,7 @@ class PostnDAO extends SQL {
$this->prepare(
'Postn',
array(
'session' => $this->_user
'origin' => $this->_user
)
);
@ -291,18 +315,12 @@ class PostnDAO extends SQL {
function getNews($limitf = false, $limitr = false) {
$this->_sql = '
select *, postn.aid as jid, privacy.value as privacy from postn
select *, postn.aid, privacy.value as privacy from postn
left outer join contact on postn.aid = contact.jid
left outer join privacy on postn.nodeid = privacy.pkey
left outer join subscription on
postn.session = subscription.jid and
postn.jid = subscription.server and
postn.node = subscription.node
where postn.session = :session
and postn.node not like \'urn:xmpp:microblog:0:comments/%\'
and postn.node not like \'urn:xmpp:inbox\'
and subscription is not null
order by postn.published desc';
where ((postn.origin, node) in (select server, node from subscription where jid = :origin))
order by postn.published desc
';
if($limitr)
$this->_sql = $this->_sql.' limit '.$limitr.' offset '.$limitf;
@ -310,21 +328,19 @@ class PostnDAO extends SQL {
$this->prepare(
'Postn',
array(
'session' => $this->_user
'origin' => $this->_user
)
);
return $this->run('ContactPostn');
}
function getPublic($jid, $node) {
function getPublic($origin, $node) {
$this->_sql = '
select *, postn.aid, privacy.value as privacy from postn
left outer join contact on postn.aid = contact.jid
left outer join privacy on postn.nodeid = privacy.pkey
where postn.jid = :jid
and postn.session = :jid
where postn.origin = :origin
and postn.node = :node
and privacy.value = 1
order by postn.published desc';
@ -332,14 +348,15 @@ class PostnDAO extends SQL {
$this->prepare(
'Postn',
array(
'jid' => $jid,
'origin' => $origin,
'node' => $node
)
);
return $this->run('ContactPostn');
}
// TODO: fixme
function getComments($posts) {
$commentsid = '';
if(is_array($posts)) {
@ -387,7 +404,8 @@ class PostnDAO extends SQL {
return $this->run('Postn');
}
// TODO: fixme
function getStatistics() {
$this->_sql = '
select count(*) as count, extract(month from published) as month, extract(year from published) as year
@ -408,20 +426,20 @@ class PostnDAO extends SQL {
function getCountSince($date) {
$this->_sql = '
select count(*) from postn
left outer join subscription on
postn.session = subscription.jid and
postn.jid = subscription.server and
postn.node = subscription.node
where postn.session = :session
and postn.node not like \'urn:xmpp:microblog:0:comments/%\'
and postn.node not like \'urn:xmpp:inbox\'
and subscription is not null
and published > :published';
where (
(postn.origin in (select jid from rosterlink where session = :origin and rostersubscription in (\'both\', \'to\')) and node = \'urn:xmpp:microblog:0\')
or (postn.origin = :origin and node = \'urn:xmpp:microblog:0\')
or ((postn.origin, node) in (select server, node from subscription where jid = :origin))
)
and postn.node not like \'urn:xmpp:microblog:0:comments/%\'
and postn.node not like \'urn:xmpp:inbox\'
and published > :published
';
$this->prepare(
'Postn',
array(
'session' => $this->_user,
'origin' => $this->_user,
'published' => $date
)
);
@ -436,21 +454,20 @@ class PostnDAO extends SQL {
function getLastDate() {
$this->_sql = '
select published from postn
left outer join subscription on
postn.session = subscription.jid and
postn.jid = subscription.server and
postn.node = subscription.node
where postn.session = :session
and postn.node not like \'urn:xmpp:microblog:0:comments/%\'
and postn.node not like \'urn:xmpp:inbox\'
and subscription is not null
where (
(postn.origin in (select jid from rosterlink where session = :origin and rostersubscription in (\'both\', \'to\')) and node = \'urn:xmpp:microblog:0\')
or (postn.origin = :origin and node = \'urn:xmpp:microblog:0\')
or ((postn.origin, node) in (select server, node from subscription where jid = :origin))
)
and postn.node not like \'urn:xmpp:microblog:0:comments/%\'
and postn.node not like \'urn:xmpp:inbox\'
order by postn.published desc
limit 1 offset 0';
$this->prepare(
'Postn',
array(
'session' => $this->_user
'origin' => $this->_user
)
);
@ -462,14 +479,12 @@ class PostnDAO extends SQL {
function exist($id) {
$this->_sql = '
select count(*) from postn
where postn.session = :session
and postn.nodeid = :nodeid
where postn.nodeid = :nodeid
';
$this->prepare(
'Postn',
array(
'session' => $this->_user,
'nodeid' => $id
)
);

22
app/views/about.tpl

@ -1,14 +1,10 @@
<?php /* -*- mode: html -*- */
?>
<main>
<section>
<div>
<?php $this->widget('Tabs');?>
<div id="main">
<div id="left">
</div>
<?php $this->widget('Tabs');?>
<div id="center">
<?php $this->widget('About');?>
<?php $this->widget('Caps');?>
</div>
</div>
<?php $this->widget('About');?>
<?php $this->widget('Caps');?>
</div>
</section>
</main>

23
app/views/blog.tpl

@ -1,14 +1,11 @@
<?php /* -*- mode: html -*- */
?>
<main>
<section>
<div>
<?php //$this->widget('Tabs');?>
<div id="main">
<div id="left">
<?php $this->widget('ContactSummary');?>
</div>
<?php $this->widget('Tabs');?>
<div id="center">
<?php $this->widget('Blog');?>
<?php $this->widget('ContactCard');?>
</div>
</div>
<?php $this->widget('Blog');?>
<?php //$this->widget('ContactSummary');?>
<?php //$this->widget('ContactCard');?>
</div>
</section>
</main>

3
app/views/chat.tpl

@ -1,7 +1,6 @@
<nav class="color dark">
<?php $this->widget('Presence');?>
<?php $this->widget('Navigation');?>
<?php //$this->widget('Notification');?>
<?php $this->widget('Presence');?>
</nav>
<main>

5
app/views/conf.tpl

@ -1,6 +1,6 @@
<nav class="color dark">
<?php $this->widget('Presence');?>
<?php $this->widget('Navigation');?>
<?php $this->widget('Presence');?>
</nav>
<main>
@ -11,8 +11,9 @@
<?php $this->widget('Vcard4');?>
<?php $this->widget('Avatar');?>
<?php $this->widget('Config');?>
<?php $this->widget('AdHoc');?>
<?php //$this->widget('ConfigData');?>
<?php $this->widget('PubsubSubscriptionConfig');?>
<?php //$this->widget('PubsubSubscriptionConfig');?>
</div>
</section>
</main>

7
app/views/contact.tpl

@ -1,17 +1,16 @@
<nav class="color dark">
<?php $this->widget('Presence');?>
<?php $this->widget('Navigation');?>
<?php $this->widget('Presence');?>
</nav>
<main>
<?php $this->widget('Header'); ?>
<section>
<div>
<?php $this->widget('Notifs');?>
<?php $this->widget('Roster');?>
</div>
<div>
<?php $this->widget('Notifs');?>
<?php $this->widget('Tabs');?>
<div id="contact_widget">
<?php $this->widget('Contact');?>
</div>
</section>

2
app/views/help.tpl

@ -1,6 +1,6 @@
<nav class="color dark">
<?php $this->widget('Presence');?>
<?php $this->widget('Navigation');?>
<?php $this->widget('Presence');?>
</nav>
<main>

7
app/views/login.tpl

@ -1,9 +1,8 @@
<?php $this->widget('Presence'); ?>
<main>
<section>
<div>
<?php $this->widget('Login'); ?>
</div>
<div>
<?php $this->widget('Login'); ?>
</div>
</section>
</main>

5
app/views/main.tpl

@ -1,3 +1,5 @@
<?php $this->widget('Init');?>
<nav class="color dark">
<?php $this->widget('Navigation');?>
<?php $this->widget('Presence');?>
@ -6,7 +8,6 @@
<main>
<?php $this->widget('Header');?>
<section>
<?php $this->widget('Menu');?>
<?php $this->widget('Post');?>
<?php $this->widget('Hello');?>
</section>
</main>

30
app/views/news.tpl

@ -1,20 +1,14 @@
<?php /* -*- mode: html -*- */
?>
<?php $this->widget('Presence');?>
<?php $this->widget('Chat');?>
<?php $this->widget('VisioExt');?>
<?php $this->widget('Init');?>
<div id="container">
<div id="left">
<?php $this->widget('Profile');?>
<?php $this->widget('Notifs');?>
<?php $this->widget('Bookmark'); ?>
</div>
<?php $this->widget('Menu');?>
<?php $this->widget('Post');?>
</div>
<div id="right">
<?php $this->widget('Roster');?>
</div>
<nav class="color dark">
<?php $this->widget('Navigation');?>
<?php $this->widget('Presence');?>
</nav>
<main>
<?php $this->widget('Header');?>
<section>
<?php $this->widget('Menu');?>
<?php $this->widget('Post');?>
</section>
</main>

65
app/views/page.tpl

@ -8,14 +8,13 @@
<title><?php $this->title();?></title>
<meta name="description" content="<?php echo $config->description; ?>" />
<meta name="theme-color" content="#1C1D5B" />
<link rel="shortcut icon" href="<?php $this->linkFile('img/favicon.ico');?>" />
<link rel="stylesheet" href="<?php echo BASE_URI; ?>app/assets/js/leaflet.css" />
<script src="<?php echo BASE_URI; ?>app/assets/js/leaflet.js"></script>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800' rel='stylesheet' type='text/css'>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, user-scalable=no">
<?php
@ -28,55 +27,13 @@
$this->addCss('block.css');
$this->addCss('menu.css');
$this->addCss('material-design-iconic-font.min.css');
/*$this->addCss('css/animations.css');
$this->addCss('css/fonts.css');
$this->addCss('css/forms.css');
$this->addCss('css/submitform.css');
$this->addCss('css/nav.css');
$this->addCss('css/style.css');
$this->addCss('css/posts.css');
$this->addCss('css/template.css');
*/
$this->widget('System');
$this->scripts();
/*
$this->addCss('css/mobile.css');
$this->addCss('css/font-awesome.css');
$user = new User();
$color = $user->getConfig('color');
if(isset($color)) {
echo '
<style type="text/css">
nav {
background-color: #'.$color.';
animation: none;
-webkit-animation: none;
}
</style>';
}
$size = $user->getConfig('size');
if(isset($size)) {
echo '
<style type="text/css">
body { font-size: '.$size.'px; }
@media screen and (max-width: 1024px) {
body { font-size: '.floor($size*1.15).'px; }
}
</style>';
}*/
?>
</head>
<body class="<?php $this->color();?>">
<body class="<?php //$this->color();?>">
<noscript>
<style type="text/css">
nav {display:none;} #content {display: none;}
@ -90,24 +47,6 @@
<?php $this->widget('Notification');?>
<?php $this->content();?>
<!--
<nav>
<div class="wrapper">
<?php //$this->menu();?>
</div>
</nav>-->
<!--<div id="baseline"></div>-->
<!--
<div id="content">
<?php //$this->widget('Ack');?>
<?php //$this->content();?>
<footer>
© <a href="http://www.movim.eu">Movim</a> • 2008 - 2014 • Under <a href="http://www.gnu.org/licenses/agpl-3.0.html">GNU Affero General Public License</a>
</footer>
</div>-->
<?php
$this->displayFooterDebug();
?>

18
app/views/pods.tpl

@ -1,12 +1,8 @@
<?php /* -*- mode: html -*- */
?>
<div id="main">
<div id="left">
</div>
<div id="center">
<?php $this->widget('Pods');?>
<div class="spacetop clear"></div>
</div>
<main>
<?php $this->widget('Header'); ?>
<section>
<div>
<?php $this->widget('Pods');?>
</div>
</section>
</div>

29
app/widgets/About/about.tpl

@ -11,8 +11,8 @@
<span class="icon bubble color red"><i class="md md-developer-mode"></i></span>
<span>{$c->__('title.developers')}</span>
<p>
<a href="http://edhelas.movim.eu/">Jaussoin Timothée aka edhelas</a></br>
<a href="https://launchpad.net/~nodpounod">Ho Christine aka nodpounod</a></br>
<a href="http://edhelas.movim.eu/">Jaussoin Timothée aka edhelas</a><br/>
<a href="https://launchpad.net/~nodpounod">Ho Christine aka nodpounod</a><br/>
<a href="https://etenil.net/">Pasquet Guillaume aka Etenil</a>
</p>
</li>
@ -20,36 +20,37 @@
<span class="icon bubble color purple"><i class="md md-flag"></i></span>
<span>{$c->__('title.translators')}</span>
<p>
Thanks to all the translators https://translations.launchpad.net/movim
Thanks to all the translators <a href="https://translations.launchpad.net/movim">translations.launchpad.net/movim</a>
</p>
</li>
<li class="subheader">{$c->__('title.software')}</li>
<li class="condensed">
<span class="icon bubble color orange"><i class="md md-archive"></i></span>
<p>
Modl - Movim DB Layer - <a href="https://github.com/edhelas/modl">GitHub Modl</a> under AGPLv3</br>
Moxl - Movim XMPP Library - <a href="https://github.com/edhelas/moxl">GitHub Moxl</a> under AGPLv3</br>
<p class="all">
Modl - Movim DB Layer - <a href="https://github.com/edhelas/modl">GitHub Modl</a> under AGPLv3<br/>
Moxl - Movim XMPP Library - <a href="https://github.com/edhelas/moxl">GitHub Moxl</a> under AGPLv3<br/>
Map Library - Leaflet <a href="http://leafletjs.com/">leafletjs.com</a> under BSD</br>
Markdown - Michel Fortin <a href="http://michelf.ca/projects/php-markdown/">michelf.ca</a> ©Michel Fortin
</dl>
Map Library - Leaflet <a href="http://leafletjs.com/">leafletjs.com</a> under BSD<br/>
Markdown - Michel Fortin <a href="http://michelf.ca/projects/php-markdown/">michelf.ca</a> ©Michel Fortin<br/>
Template Engine - RainTPL - Federico Ulfo <a href="http://www.raintpl.com/">www.raintpl.com</a> under MIT<br/>
Embed - Oscar Otero <a href="https://github.com/oscarotero/Embed">GitHub Embed</a> under MIT<br/><br />
WebSocket and Daemon engine - ReactPHP - <a href="http://socketo.me/">socketo.me</a> ©Chris Boden<br/>
</p>
</li>
<li class="condensed">
<span class="icon bubble color brown"><i class="md md-insert-emoticon"></i></span>
<span>{$c->__('title.resources')}</span>
<p>
FontAwesome <a href="http://fortawesome.github.io/">by Dave Gandy</a> under CC BY 3.0</br>
Boyan Kostov <a href="http://boyankostov.com/">boyankostov.com</a> <a href="https://www.iconfinder.com/iconsets/flatified">Free for commercial use</a>
Material Design Iconic Font <a href="http://zavoloklom.github.io/material-design-iconic-font/icons.html">by Google and Sergey Kupletsky</a> under SIL OFL 1.1<br/>
</p>
</li>
<li class="condensed">
<span class="icon bubble color indigo"><i class="md md-import-export"></i></span>
<span>{$c->__('title.api')}</span>
<p>
OpenStreetMap - Nominatim <a href="http://nominatim.openstreetmap.org/">nominatim.openstreetmap.org</a></br>
Last.fm API - <a href="http://www.last.fm/api">www.last.fm/api</a></br>
Youtube API - <a href="http://developers.google.com/youtube">developers.google.com/youtube</a></br>
OpenStreetMap - Nominatim <a href="http://nominatim.openstreetmap.org/">nominatim.openstreetmap.org</a><br/>
Last.fm API - <a href="http://www.last.fm/api">www.last.fm/api</a><br/>
Youtube API - <a href="http://developers.google.com/youtube">developers.google.com/youtube</a><br/>
</p>
</li>
</ul>

2
app/widgets/AccountNext/AccountNext.php

@ -71,7 +71,7 @@ class AccountNext extends WidgetBase {
RPC::call('movim_fill', 'subscription_form', $html);
RPC::call('setUsername', $data->username->value);
RPC::call('remoteUnregister');
//RPC::call('remoteUnregister');
}
function onRegisterError($package)

2
app/widgets/AccountNext/_accountnext_registered.tpl

@ -3,7 +3,7 @@
<h2 id="username">username@server.com</h2>
<a class="button color" href="{$c->route('login')}">
<a class="button color" onclick="remoteUnregister(); MovimWebsocket.attach(function() {movim_redirect('{$c->route('login')}')});" href="#">
{$c->__('page.login')}
</a>
</div>

118
app/widgets/AdHoc/AdHoc.php

@ -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()
{
}
}

32
app/widgets/AdHoc/_adhoc_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>

13
app/widgets/AdHoc/_adhoc_list.tpl

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

8
app/widgets/AdHoc/_adhoc_note.tpl

@ -0,0 +1,8 @@
<section>
<h4 class="gray">{$note}</h4>
</section>
<div>
<a onclick="Dialog.clear()" class="button flat">
{$c->__('button.close')}
</a>
</div>

33
app/widgets/AdHoc/adhoc.js

@ -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();
});

1
app/widgets/AdHoc/adhoc.tpl

@ -0,0 +1 @@
<div class="tabelem" title="{$c->__('adhoc.title')}" id="adhoc_widget" ></div>

1
app/widgets/AdHoc/locales.ini

@ -0,0 +1 @@
adhoc.title = 'Actions'

2
app/widgets/AdminDB/AdminDB.php

@ -42,7 +42,7 @@ class AdminDB extends WidgetBase
$this->view->assign('infos', $infos);
$this->view->assign('db_update', $this->call('ajaxUpdateDatabase')
."this.className='button color orange icon loading'; setTimeout(function() {location.reload(false)}, 1000);");
."this.className='button color loading';");
try {
$md->connect();
} catch(Exception $e) {

24
app/widgets/AdminDB/admindb.tpl

@ -1,12 +1,12 @@
<div id="admindb" class="tabelem paddedtop" title="{$c->__('db.legend')}">
<form>
<ul>
<form class="flex">
<ul class="block large">
<li class="subheader">{$c->__('db.legend')}</li>
{if="!$connected"}
<li class="block large condensed">
<span class="icon bubble color red">
<i class="fa fa-plug"></i>
<i class="md md-settings-ethernet"></i>
</span>
<span>{$c->__('db.connect_error')}</span>
<p>{$errors}</p>
@ -14,20 +14,19 @@
{else}
<li class="block large">
<span class="icon bubble color green">
<i class="fa fa-plug"></i>
<i class="md md-settings-ethernet"></i>
</span>
<span>{$c->__('db.connect_success')}</span>
</li>
{if="null !== $infos"}
<li class="block large condensed">
<li class="block large condensed action">
<div class="action">
<a class="button" onclick="{$db_update}"> {$c->__('button.update')}</a>
</div>
<span class="icon bubble color orange">
<i class="fa fa-refresh"></i>
<i class="md md-refresh"></i>
</span>
<span>{$c->__('db.update')}</span>
<div class="control">
<a class="button oppose"
onclick="{$db_update}"> {$c->__('button.update')}</a>
</div>
{loop="$infos"}
<p>{$value}</p>
{/loop}
@ -35,15 +34,14 @@
{else}
<li class="block large">
<span class="icon bubble color green">
<i class="fa fa-refresh"></i>
<i class="md md-refresh"></i>
</span>
<span>{$c->__('db.up_to_date')}</span>
</li>
{/if}
{/if}
</ul>
<div class="clear"></div>
<div class="block">
<input value="{$dbtype}" disabled/>
<label for="logLevel">{$c->__('db.type')}</label>

13
app/widgets/AdminMain/AdminMain.php

@ -34,9 +34,17 @@ class AdminMain extends WidgetBase
}
unset($form['repassword']);
if(isset($form['rewrite']) && $form['rewrite'] == 'on') {
$form['rewrite'] = 1;
} else {
$form['rewrite'] = 0;
}
foreach($form as $key => $value) {
$config->$key = $value;
}
$cd->set($config);
//set timezone
@ -86,6 +94,11 @@ class AdminMain extends WidgetBase
if(isset($json) && $json->status != 404) {
$this->view->assign('websockets', $json);
}
$this->view->assign('server_rewrite', false);
if(isset($_SERVER['HTTP_MOD_REWRITE']) && $_SERVER['HTTP_MOD_REWRITE']) {
$this->view->assign('server_rewrite', true);
}
$this->view->assign('timezones', getTimezoneList());
$this->view->assign('langs', loadLangArray());

96
app/widgets/AdminMain/adminmain.tpl

@ -1,7 +1,7 @@
<div id="admingen" class="tabelem paddedtop" title="{$c->__('admin.general')}">
<form name="admin" id="adminform" action="#" method="post">
<legend><i class="fa fa-wrench"></i> {$c->__('admin.general')}</legend>
<br />
<h3>{$c->__('admin.general')}</h3>
<div>
<label for="da">{$c->__('general.language')}</label>
<div class="select">
@ -74,13 +74,10 @@
<br /><br />
</div>
<legend><i class="fa fa-code"></i> {$c->__('websocket.title')}</legend>
<div class="clear"></div>
<p>
{$c->__('websocket.info')}: <code>ws(s)://domain:port</code>
</p>
<br />
<h3>{$c->__('websocket.title')}</h3>
<!--{if="!$c->testBosh($conf->boshurl)"}
<div class="message error">
{$c->__('bosh.not_recheable')}
@ -107,41 +104,86 @@
</dl>
</div>
{/if}
<div class="message info block">
<i class="fa fa-exclamation-triangle"></i> {$c->__('websocket.save_info')}
</div>
<legend><i class="fa fa-check-square-o"></i> {$c->__('whitelist.title')}</legend>
<div class="clear"></div>
<ul class="thick">
<li class="condensed">
<span class="icon bubble color orange">
<i class="md md-warning"></i>
</span>
<span>{$c->__('websocket.info')}: <code>ws(s)://domain:port</code></span>
<p>{$c->__('websocket.save_info')}</p>
</li>
</ul>
<div>
<p>{$c->__('whitelist.info1')}</p>
<p>{$c->__('whitelist.info2')}</p>
</div>
<h3>{$c->__('whitelist.title')}</h3>
<div>
<input type="text" name="xmppwhitelist" id="xmppwhitelist" placeholder="{$c->__('whitelist.label')}" value="{$conf->xmppwhitelist}" />
<label for="xmppwhitelist">{$c->__('whitelist.label')}</label>
</div>
<legend><i class="fa fa-comment"></i> {$c->__('information.title')}</legend>
<div class="clear"></div>
<ul class="thick">
<li class="condensed">
<span class="icon bubble color blue">
<i class="md md-info"></i>
</span>
<p>{$c->__('whitelist.info1')}</p>
<p>{$c->__('whitelist.info2')}</p>
</li>
</ul>
<br />
<h3>{$c->__('information.title')}</h3>
<div>
<textarea type="text" name="description" id="description" />{$conf->description}</textarea>
<textarea type="text" name="description" id="description" placeholder="{$conf->description}"/>{$conf->description}</textarea>
<label for="description">{$c->__('information.description')}</label>
</div>
<div class="clear"></div>
<div>
<textarea type="text" name="info" id="info" placeholder="{$c->__('information.label')}" />{$conf->info}</textarea>
<label for="info">{$c->__('information.label')}</label>
<p>{$c->__('information.info1')}</p>
<p>{$c->__('information.info2')}</p>
<textarea type="text" name="info" id="info" />{$conf->info}</textarea>
</div>
<legend><i class="fa fa-user"></i> {$c->__('credentials.title')}</legend>
<ul class="thick">
<li class="condensed">
<span class="icon bubble color blue">
<i class="md md-info"></i>
</span>
<span>{$c->__('information.info1')}</span>
<p>{$c->__('information.info2')}</p>
</li>
</ul>
{if="$server_rewrite"}
<br />
<h3>{$c->__('rewrite.title')}</h3>
<div>
<ul class="thick simple">
<li class="action">
<div class="control action">
<div class="checkbox">
<input
type="checkbox"
id="rewrite"
name="rewrite"
{if="$conf->rewrite"}
checked
{/if}>
<label for="rewrite"></label>
</div>
</div>
<span>{$c->__('rewrite.info')}</span>
</li>
</ul>
</div>
{/if}
<br />
<h3>{$c->__('credentials.title')}</h3>
{if="$conf->user == 'admin' || $conf->pass == sha1('password')"}
<div class="message error">
@ -170,4 +212,4 @@
value="{$c->__('button.submit')}"/>
<div class="clear"></div>
</form>
</div>
</div>

4
app/widgets/AdminMain/locales.ini

@ -39,3 +39,7 @@ information.label = 'Information Message'
log.empty = 'Empty'
log.syslog = 'Syslog'
log.syslog_files = 'Syslog and files'
[rewrite]
rewrite.title = 'URL Rewriting'
rewrite.info = 'The URL Rewriting can be enabled'

10
app/widgets/AdminTest/admintest.css

@ -51,11 +51,11 @@ figure div.link {
}
figure div.link i {
background-color: white;
margin-top: -0.75em;
padding: 0.25em;
border-radius: 2em;
font-size: 2em;
background-color: #FFF;
margin-top: -3rem;
padding: 3rem 1rem;
border-radius: 6rem;
font-size: 3rem;
}
figure div.disabled { background-color: rgba(0, 0, 0, 0.1); color: white;}

46
app/widgets/AdminTest/admintest.tpl

@ -4,14 +4,14 @@
<div id="webserver">
</div>
<div id="movim-daemon" class="link vertical disabled"><i class="fa fa-cog"></i></div>
<div id="movim-browser" class="link horizontal success"><i class="fa fa-globe"></i></div>
<div id="browser-daemon" class="link horizontal error"><i class="fa fa-plug"></i></div>
<div id="daemon-xmpp" class="link horizontal error"><i class="fa fa-code"></i></div>
<div id="movim-daemon" class="link vertical disabled"><i class="md md-settings"></i></div>
<div id="movim-browser" class="link horizontal success"><i class="md md-open-in-browser"></i></div>
<div id="browser-daemon" class="link horizontal error"><i class="md md-settings-ethernet"></i></div>
<div id="daemon-xmpp" class="link horizontal error"><i class="md md-import-export"></i></div>
<div id="movim-database" class="link vertical {if="$dbconnected"}success {if="$dbinfos > 0"}warning{/if} {else}error{/if}">
<i class="fa fa-database"></i>
<i class="md md-data-usage"></i>
</div>
<div id="movim-api" class="link horizontal disabled"><i class="fa fa-puzzle-piece"></i></div>
<div id="movim-api" class="link horizontal disabled"><i class="md md-cloud"></i></div>
<div id="browser_block">
Browser
</div>
@ -41,7 +41,7 @@
{if="$dbconnected"}
{if="$dbinfos > 0"}
<li>
<span class="icon bubble color orange"><i class="fa fa-refresh"></i></span>
<span class="icon bubble color orange"><i class="md md-refresh"></i></span>
<span>The database need to be updated, go to the database panel to fix this</span>
</li>
{else}
@ -49,7 +49,7 @@
{/if}
{else}
<li class="condensed">
<span class="icon bubble color red"><i class="fa fa-database"></i></span>
<span class="icon bubble color red"><i class="md md-data-usage"></i></span>
<span>Database connection error</span>
<p>Check if database configuration exist in the <code>config/</code> folder and fill it with proper values</p>
</li>
@ -57,7 +57,7 @@
<li id="websocket_error">
<span class="icon bubble color red">
<i class="fa fa-plug"></i>
<i class="md md-settings-ethernet"></i>
</span>
<span>
WebSocket connection error, check if the Movim Daemon is running and is reacheable
@ -66,7 +66,7 @@
<li id="xmpp_websocket_error">
<span class="icon bubble color red">
<i class="fa fa-plug"></i>
<i class="md md-settings-ethernet"></i>
</span>
<span>
XMPP Websocket connection error, please check the validity of the URL given in the General Configuration. <code>{$websocketurl}</code>
@ -75,31 +75,41 @@
{if="!$c->version()"}
<li class="condensed">
<span class="icon color bubble red"><i class="fa fa-code"></i> </span>
<span class="icon color bubble red">
<i class="md md-sync-problem"></i>
</span>
<span>{$c->__('compatibility.php1', PHP_VERSION)}</span>
<p>{$c->__('compatibility.php2')}</p>
</li>
<script type="text/javascript">AdminTest.disableMovim()</script>
{/if}
{if="!extension_loaded('gd')"}
<div class="message error">
<i class="fa fa-file-image-o"></i> {$c->__('compatibility.gd')}
{if="!extension_loaded('imagick')"}
<li>
<span class="icon color bubble red">
<i class="md md-image"></i>
</span>
<span>
{$c->__('compatibility.imagick')}
</span>
</div>
<script type="text/javascript">AdminTest.disableMovim()</script>
{/if}
{if="!$c->testDir(DOCUMENT_ROOT)"}
<div class="message error">
<i class="fa fa-folder"></i> {$c->__('compatibility.rights')}
</div>
<li>
<span class="icon color bubble red">
<i class="md md-folder"></i>
</span>
<span>{$c->__('compatibility.rights')}</span>
</li>
<script type="text/javascript">AdminTest.disableMovim()</script>
{/if}
{if="!$_SERVER['HTTP_MOD_REWRITE']"}
<li>
<span class="icon bubble color orange">
<i class="fa fa-pencil"></i>
<i class="md md-mode-edit"></i>
</span>
<span>{$c->__('compatibility.rewrite')}</span>
</li>

2
app/widgets/AdminTest/locales.ini

@ -5,6 +5,6 @@ compatibility.info = 'Movim has found some issues or things that need to be
compatibility.php1 = 'Update your PHP-Version: %s'
compatibility.php2 = 'Required: 5.3.0'
compatibility.curl = 'Install the php5-curl library'
compatibility.gd = 'Install the php5-gd library'
compatibility.imagick = 'Install the php5-imagick library'
compatibility.rights = "Read and write rights for the webserver in Movim's root directory"
compatibility.rewrite = 'The URL Rewriting support is currently disabled'

17
app/widgets/Avatar/Avatar.php

@ -17,6 +17,7 @@
use Moxl\Xec\Action\Avatar\Get;
use Moxl\Xec\Action\Avatar\Set;
use forxer\Gravatar\Gravatar;
class Avatar extends WidgetBase
{
@ -32,7 +33,7 @@ class Avatar extends WidgetBase
$this->registerEvent('avatar_set_errornotallowed', 'onMyAvatarError');
}
function onMyAvatar($me)
function onMyAvatar($packet)
{
$me = $packet->content;
$html = $this->prepareForm($me);
@ -61,9 +62,19 @@ class Avatar extends WidgetBase
$avatarform->assign('photobin', $p->toBase());
$avatarform->assign('me', $me);
if(isset($me->email)) {
$result = requestURL(Gravatar::profile($me->email, 'json'), 3);
$obj = json_decode($result);
if($obj != 'User not found') {
$avatarform->assign('gravatar_bin', base64_encode(requestURL('http://www.gravatar.com/avatar/'.$obj->entry[0]->hash.'?s=250')));
$avatarform->assign('gravatar', $obj);
}
}
$avatarform->assign(
'submit',
$this->call('ajaxAvatarSubmit', "movim_form_to_json('avatarform')")
$this->call('ajaxSubmit', "movim_form_to_json('avatarform')")
);
return $avatarform->draw('_avatar_form', true);
@ -77,7 +88,7 @@ class Avatar extends WidgetBase
->request();
}
function ajaxAvatarSubmit($avatar)
function ajaxSubmit($avatar)
{
$p = new \Picture;
$p->fromBase((string)$avatar->photobin->value);

60
app/widgets/Avatar/_avatar_form.tpl

@ -1,11 +1,59 @@
<form name="avatarform" id="avatarform">
<h3>{$c->__('page.avatar')}</h3>
<br />
<h3 class="block large">{$c->__('page.avatar')}</h3>
<div class="flex">
<div id="preview" class="block">
<div>
<form name="avatarform" id="avatarform">
<img src="data:image/jpeg;base64,{$photobin}">
<input type="hidden" name="photobin" value="{$photobin}"/>
</form>
</div>
</div>
<div class="block">
<ul class="thick divided">
<li class="condensed">
<span class="icon bubble color green">
<i class="md md-attach-file"></i>
</span>
<span>{$c->__('avatar.file')}</span>
<p><input type="file" onchange="Avatar.file(this.files);"></p>
</li>
{if="$gravatar != null"}
<li class="condensed action">
<div class="action">
<a
onclick="Avatar.preview('data:image/jpeg;base64,{$gravatar_bin}')"
class="button flat">
{$c->__('avatar.use_it')}
</a>
</div>
<span class="icon bubble color blue">
<img src="http://www.gravatar.com/avatar/{$gravatar->entry[0]->hash}?s=50" />
</span>
<span>Gravatar</span>
<p>We found a Gravatar picture</p>
</li>
{/if}
</ul>
</div>
</div>
<!--
<div class="block">
<input type="file" onchange="vCardImageLoad(this.files);">
<label for="avatar">{$c->__('page.avatar')}</label>
<input type="hidden" name="photobin" value="{$photobin}"/>
</div>
{if="$gravatar != null"}
<div class="block">
<h4>Gravatar</h4>
{$gravatar->entry[0]|var_dump}
<img src="http://www.gravatar.com/avatar/{$gravatar->entry[0]->hash}?s=500" />
</div>
{/if}
<div class="block" id="result">
<img id="vCardPhotoPreview" src="data:image/jpeg;base64,{$photobin}">
<span id="picturesize" class="clean"></span>
@ -30,10 +78,9 @@
{$c->__('avatar.snapshot')}
</a>
<label for="url">{$c->__('avatar.webcam')}</label>
</div>
<div class="clear"></div>
</div>-->
<div class="block large">
<a
onclick="
{$submit}
@ -43,4 +90,5 @@
class="button color oppose"
id="avatarvalidate"
>{$c->__('button.submit')}</a>
</form>
</div>

52
app/widgets/Avatar/avatar.css

@ -1,4 +1,52 @@
#avatar form {
#avatar_form div#preview {
flex: 1 1 20%;
text-align: center;
padding-top: 2rem;
}
#avatar_form input[type=file] {
max-width: 200px;
}
#avatar_form div#preview > div,
#avatar_form div#preview img {
max-width: 250px;
border-radius: 0.25rem;
margin: 0 auto;
}
/*
#avatar_form div.flex div:first-child {
flex: 1 1 25%;
background-color: #333;
display: block;
height: 25rem;
}
#avatar_form div.flex div:nth-child(2) {
padding-left: 2rem;
}
#avatar_form div.flex div#preview div {
display: table;
width: 100%;
}
#avatar_form div.flex div:first-child form {
display: table-cell;
text-align: center;
vertical-align: middle;
}
#avatar_form div.flex div:first-child div form img {
max-width: 300px;
}
#avatar_form input[type=file] {
max-width: 200px;
}*/
/*#avatar form {
margin-top: 2rem;
}
@ -53,7 +101,7 @@
font-size: 1.5rem;
margin-left: -3rem;
}
*/
/*
.squares, #snap{
height:200px;

92
app/widgets/Avatar/avatar.js

@ -1,58 +1,48 @@
function vCardImageResize(img) {
var canvas = document.createElement('canvas');
canvas.width = canvas.height = 210;
var width = canvas.width;
var height = canvas.height;
if (img.width == img.height) {
canvas.getContext("2d").drawImage(img, 0, 0, width, height);
} else {
minVal = Math.min(img.width, img.height);
if (img.width > img.height) {
canvas.getContext("2d").drawImage(img, (img.width - minVal) / 2, 0, minVal, minVal, 0, 0, width, height);
var Avatar = {
file : function(files) {
var f = files[0];
if (!f.type.match(/image.*/)) {
console.log("Not a picture !");
} else {
canvas.getContext("2d").drawImage(img, 0, (img.height - minVal) / 2, minVal, minVal, 0, 0, width, height);
var reader = new FileReader();
reader.readAsDataURL(f);
reader.onload = function (ev) {
var img = new Image();
img.src = ev.target.result;
Avatar.preview(img.src);
};
};
},
preview : function(src) {
var canvas = document.createElement('canvas');
width = height = canvas.width = canvas.height = 410;
var image = new Image();
image.src = src;
image.onload = function(){
if (image.width == image.height) {
canvas.getContext("2d").drawImage(image, 0, 0, width, height);
} else {
minVal = parseInt(Math.min(image.width, image.height));
if (image.width > image.height) {
canvas.getContext("2d").drawImage(image, (parseInt(image.width) - minVal) / 2, 0, minVal, minVal, 0, 0, width, height);
} else {
canvas.getContext("2d").drawImage(image, 0, (parseInt(image.height) - minVal) / 2, minVal, minVal, 0, 0, width, height);
}
}
var base64 = canvas.toDataURL('image/jpeg', 0.9);
var preview = document.querySelector('form[name=avatarform] img');
var input = document.querySelector('input[name="photobin"]');
preview.src = base64;
var bin = base64.split(",");
input.value = bin[1];
}
}
}
canvas.style.width = 200;
canvas.style.height = 200;
var base64 = canvas.toDataURL('image/jpeg', 0.9);
var bin = base64.split(",");
document.querySelector('#vCardPhotoPreview').src = base64;
//document.querySelector('input[name="phototype"]').value = 'image/jpeg';
document.querySelector('input[name="photobin"]').value = bin[1];
function bytesToSize(bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return 'n/a';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i];
};
document.getElementById("picturesize").innerHTML = bytesToSize(encodeURI(base64).split(/%..|./).length - 1);
};
function vCardImageLoad(files) {
var f = files[0];
if (!f.type.match(/image.*/)) {
console.log("Not a picture !");
} else {
var reader = new FileReader();
reader.readAsDataURL(f);
reader.onload = function ( ev ) {
var img = new Image();
img.src = ev.target.result;
img.onload = function() {
vCardImageResize(this);
};
};
};
};
function showVideo(){
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;

2
app/widgets/Avatar/locales.ini

@ -1,3 +1,5 @@
avatar.file = 'File'
avatar.use_it = 'Use it'
avatar.webcam = 'Webcam'
avatar.cheese = 'Cheese !'
avatar.snapshot = 'Take a webcam snapshot'

39
app/widgets/Blog/Blog.php

@ -8,45 +8,30 @@ class Blog extends WidgetCommon {
function display()
{
if(!isset($_GET['f']) || !isset($_GET['n'])) {
if(!isset($_GET['f'])) {
return;
}
$from = $_GET['f'];
$node = $_GET['n'];
$this->view->assign('from', $from);
if(isset($node))
$this->view->assign('node', $node);
if(filter_var($from, FILTER_VALIDATE_EMAIL)) {
$node = 'urn:xmpp:microblog:0';
} else {
return;
}
$pd = new \modl\PostnDAO();
if(isset($from) && isset($node))
$messages = $pd->getPublic($from, $node);
$messages = $pd->getPublic($from, $node);
if($messages[0] != null) {
// Title and logo
// For a Pubsub feed
if(isset($from) && isset($node) && $node != 'urn:xmpp:microblog:0') {
$pd = new \modl\NodeDAO();
$n = $pd->getNode($from, $node);
if(isset($n->title))
$this->view->assign('title', $n->title);
elseif(isset($n->nodeid))
$this->view->assign('title', $n->nodeid);
// For a simple contact
} else {
$this->view->assign('title', $this->__('blog.title',$messages[0]->getContact()->getTrueName()));
$this->view->assign('logo', $messages[0]->getContact()->getPhoto('l'));
}
$this->view->assign('date', date('c'));
$this->view->assign('name', $messages[0]->getContact()->getTrueName());
$this->view->assign('feed', Route::urlize('feed',array($from, $node)));
$cd = new \modl\ContactDAO();
$c = $cd->get($from);
$this->view->assign('contact', $c);
} else {
$this->view->assign('title', $this->__('page.feed'));
}
$this->view->assign('posts', $this->preparePosts($messages, true));
$this->view->assign('posts', $messages);
}
}

61
app/widgets/Blog/blog.tpl

@ -1,16 +1,51 @@
<div class="tabelem" title="{$c->__('page.feed')}" id="blog" >
<h1 class="paddedtopbottom">{$title}</h1>
<div class="posthead paddedtopbottom">
<a
class="button color orange merged left"
href="{$feed}"
target="_blank"
>
<i class="fa fa-rss"></i> {$c->__('page.feed')} (Atom)
</a>
</div>
<div class="tabelem divided" title="{$c->__('page.feed')}" id="blog" >
{$posts}
<ul class="thick">
<li class="action">
<div class="action">
<a
href="{$c->route('feed', array($contact->jid, 'urn:xmpp:microblog:0'))}"
target="_blank"
>
<i class="md md-wifi-tethering"></i> Atom
</a>
</div>
<span class="icon gray">
<i class="md md-edit"></i>
</span>
<span>
<h2>{$c->__('blog.title', $contact->getTrueName())}</h2>
</span>
</li>
</ul>
<div class="spacetop clear"></div>
{loop="$posts"}
<article>
<header>
<ul class="thick">
<li class="condensed">
<span class="icon bubble">
<img src="{$value->getContact()->getPhoto('s')}">
</span>
<h2>
{if="$value->title != null"}
{$value->title}
{else}
{$c->__('post.default_title')}
{/if}
</h2>
<p>
{if="$value->node == 'urn:xmpp:microblog:0'"}
{$value->getContact()->getTrueName()} -
{/if}
{$value->published|strtotime|prepareDate}
</p>
</li>
</ul>
</header>
<section>
{$value->contentcleaned}
</section>
</article>
{/loop}
</div>

10
app/widgets/Caps/caps.css

@ -3,6 +3,8 @@
display: block;
overflow: auto;
font-size: 2rem;
}
#caps_widget table tr:not(:first-child):hover{
@ -50,6 +52,10 @@
color: white;
}
body {
padding-right: 0;
#caps_widget table td {
padding: 0 0.5rem;
}
main > section > div > * {
max-width: calc(100% - 4rem);
}

2
app/widgets/Caps/caps.tpl

@ -1,5 +1,5 @@
<div id="caps_widget" class="tabelem paddedtop" title="Capabilities">
<h1><i class="fa fa-check-square"></i> Capabilities</h1>
<h1>Capabilities</h1>
<h2>Legend</h2>
<table>

84
app/widgets/Chat/Chat.php

@ -19,58 +19,62 @@ class Chat extends WidgetCommon
function onMessage($packet)
{
$message = $packet->content;
$cd = new \Modl\ContactDAO;
if($message->session == $message->jidto) {
$from = $message->jidfrom;
$cd = new \Modl\ContactDAO;
$contact = $cd->get($from);
$contact = $cd->getRosterItem($from);
if($contact == null)
$contact = $cd->get($from);
if($contact != null
&& !preg_match('#^\?OTR#', $message->body)
&& $message->type != 'groupchat') {
Notification::append('chat|'.$from, $contact->getTrueName(), $message->body, $contact->getPhoto('s'), 4);
}
RPC::call('movim_fill', $from.'_state', '');
// If the message is from me
} else {
$from = $message->jidto;
$contact = $cd->get();
}
RPC::call('movim_fill', $from.'_messages', $this->prepareMessages($from));
$me = $cd->get();
if($me == null) {
$me = new \Modl\Contact;
}
RPC::call('movim_append', $from.'_conversation', $this->prepareMessage($message, $from, $contact, $me));
RPC::call('MovimTpl.scrollPanel');
}
function onComposing($array)
{
list($from, $to) = $array;
$myself = false;
if($from == $this->user->getLogin()) {
// If the message is from me
$myself = true;
$jid = $to;
} else {
$jid = $from;
}
RPC::call('movim_fill', $jid.'_messages', $this->prepareMessages($jid, 'composing', $myself));
RPC::call('MovimTpl.scrollPanel');
$this->setState($array, $this->__('message.composing'));
}
function onPaused($array)
{
list($from, $to) = $array;
$myself = false;
$this->setState($array, $this->__('message.paused'));
}
private function setState($array, $message)
{
list($from, $to) = $array;
if($from == $this->user->getLogin()) {
// If the message is from me
$myself = true;
$jid = $to;
} else {
$jid = $from;
}
RPC::call('movim_fill', $jid.'_messages', $this->prepareMessages($jid, 'paused', $myself));
$view = $this->tpl();
$view->assign('message', $message);
$html = $view->draw('_chat_state', true);
RPC::call('movim_fill', $jid.'_state', $html);
RPC::call('MovimTpl.scrollPanel');
}
@ -142,7 +146,7 @@ class Chat extends WidgetCommon
if($muc) {
$m->type = 'groupchat';
$m->resource = $session->user;
$m->resource = $session->user;
$m->jidfrom = $to;
}
@ -237,7 +241,7 @@ class Chat extends WidgetCommon
function prepareChat($jid, $muc = false)
{
$view = $this->tpl();
$view->assign('jid', $jid);
$view->assign('messages', $this->prepareMessages($jid));
@ -268,7 +272,7 @@ class Chat extends WidgetCommon
return $view->draw('_chat', true);
}
function prepareMessages($jid, $status = false, $myself = false)
function prepareMessages($jid)
{
$md = new \Modl\MessageDAO();
$messages = $md->getContact(echapJid($jid), 0, 15);
@ -277,25 +281,32 @@ class Chat extends WidgetCommon
$view = $this->tpl();
$contact = $cd->get($jid);
/*if($contact == null) {
$contact = new \Modl\Contact;
$contact->jid = $jid;
} */
$me = $cd->get();
if($me == null) {
$me = new \Modl\Contact;
}
$messages = array_reverse($messages);
$messages_html = '';
foreach($messages as $m) {
$messages_html .= $this->prepareMessage($m, $jid, $contact, $me);
}
$view->assign('jid', $jid);
$view->assign('messages_html', $messages_html);
return $view->draw('_chat_messages', true);
}
function prepareMessage($message, $jid, $contact, $me)
{
$view = $this->tpl();
$view->assign('jid', $jid);
$view->assign('contact', $contact);
$view->assign('me', $me);
$view->assign('messages', $messages);
$view->assign('status', $status);
$view->assign('myself', $myself);
$view->assign('message', $message);
$cd = new \Modl\ContactDAO;
$presences = $cd->getPresence($jid);
@ -306,9 +317,8 @@ class Chat extends WidgetCommon
}
$view->assign('contacts', $contacts);
return $view->draw('_chat_messages', true);
return $view->draw('_chat_message', true);
}
function prepareEmpty()

2
app/widgets/Chat/_chat.tpl

@ -2,6 +2,7 @@
<section id="{$jid}_messages">
{$messages}
</section>
<div id="{$jid}_state"></div>
</div>
<div class="chat_box">
<ul class="simple thin">
@ -42,7 +43,6 @@
"
placeholder="{$c->__('chat.placeholder')}"
></textarea>
<label>Your message</label>
</div>
</form>
</li>

35
app/widgets/Chat/_chat_header.tpl

@ -1,14 +1,21 @@
<span id="back" class="icon" onclick="MovimTpl.hidePanel(); Chat_ajaxGet();"><i class="md md-arrow-back"></i></span>
<ul class="active">
<li onclick="Chats_ajaxClose('{$jid}'); MovimTpl.hidePanel();">
<span class="icon">
<i class="md md-close"></i>
</span>
</li>
</ul>
{if="$contact != null"}
<h2>{$contact->getTrueName()}</h2>
{else}
<h2>{$jid}</h2>
{/if}
<div>
<span class="on_desktop icon"><i class="md md-forum"></i></span>
<h2>{$c->__('page.chats')}</h2>
</div>
<div>
<ul class="active">
<li onclick="Chats_ajaxClose('{$jid|echapJS}'); MovimTpl.hidePanel();">
<span class="icon">
<i class="md md-close"></i>
</span>
</li>
</ul>
<h2 class="active r1" onclick="MovimTpl.hidePanel(); Chat_ajaxGet();">
<span id="back" class="icon"><i class="md md-arrow-back"></i></span>
{if="$contact != null"}
{$contact->getTrueName()}
{else}
{$jid|echapJS}
{/if}
</h2>
</div>

47
app/widgets/Chat/_chat_header_room.tpl

@ -1,20 +1,27 @@
<span id="back" class="icon" onclick="MovimTpl.hidePanel(); Chat_ajaxGet();"><i class="md md-arrow-back"></i></span>
<ul class="active">
<li onclick="Rooms_ajaxList('{$room}')">
<span class="icon">
<i class="md md-menu"></i>
</span>
</li>
<li onclick="Rooms_ajaxRemoveConfirm('{$room}')">
<span class="icon">
<i class="md md-delete"></i>
</span>
</li>
<li onclick="Rooms_ajaxExit('{$room}'); MovimTpl.hidePanel();">
<span class="icon">
<i class="md md-close"></i>
</span>
</li>
</ul>
<h2>{$room}</h2>
<div>
<span class="on_desktop icon"><i class="md md-forum"></i></span>
<h2>{$c->__('page.chats')}</h2>
</div>
<div>
<ul class="active">
<li onclick="Rooms_ajaxList('{$room}')">
<span class="icon">
<i class="md md-menu"></i>
</span>
</li>
<li onclick="Rooms_ajaxRemoveConfirm('{$room}')">
<span class="icon">
<i class="md md-delete"></i>
</span>
</li>
<li onclick="Rooms_ajaxExit('{$room}'); MovimTpl.hidePanel();">
<span class="icon">
<i class="md md-close"></i>
</span>
</li>
</ul>
<h2 class="active r3" onclick="MovimTpl.hidePanel(); Chat_ajaxGet();">
<span id="back" class="icon" ><i class="md md-arrow-back"></i></span>
{$room}
</h2>
</div>

32
app/widgets/Chat/_chat_message.tpl

@ -0,0 +1,32 @@
{if="$message->body != ''"}
<li {if="$message->jidfrom != $jid"}class="oppose"{/if}>
<span class="icon bubble {if="$contact->updated == null && !array_key_exists($message->resource, $contacts)"}color {$message->resource|stringToColor}{/if}">
{if="$message->jidfrom == $jid"}
{if="$contact->updated != null"}
<img src="{$contact->getPhoto('s', $jid)}">
{elseif="array_key_exists($message->resource, $contacts)"}
<img src="{$contacts[$message->resource]->getPhoto('s', $jid)}">
{else}
{$message->resource|firstLetterCapitalize}
{/if}
{else}
<img src="{$me->getPhoto('s')}">
{/if}
</span>
<div class="bubble">
{if="preg_match('#^\?OTR#', $message->body)"}
<i class="md md-lock"></i> {$c->__('message.encrypted')}
{else}
{if="isset($message->html)"}
{$message->html|prepareString}
{else}
{$message->body|htmlentities:ENT_COMPAT,'UTF-8'|prepareString}
{/if}
{/if}
<span class="info">{$message->delivered|strtotime|prepareDate}</span>
{if="$message->type == 'groupchat'"}
<span class="info">{$message->resource} - </span>
{/if}
</div>
</li>
{/if}

37
app/widgets/Chat/_chat_messages.tpl

@ -1,38 +1,5 @@
<ul class="middle">
{loop="$messages"}
{if="$value->body != ''"}
<li {if="$value->jidfrom != $jid"}class="oppose"{/if}>
<span class="icon bubble {if="$contact->updated == null && !array_key_exists($value->resource, $contacts)"}color {$value->resource|stringToColor}{/if}">
{if="$value->jidfrom == $jid"}
{if="$contact->updated != null"}
<img src="{$contact->getPhoto('s')}">
{elseif="array_key_exists($value->resource, $contacts)"}
<img src="{$contacts[$value->resource]->getPhoto('s')}">
{else}
{$value->resource|firstLetterCapitalize}
{/if}
{else}
<img src="{$me->getPhoto('s')}">
{/if}
</span>
<div class="bubble">
{if="preg_match('#^\?OTR#', $value->body)"}
<i class="md md-lock"></i> {$c->__('message.encrypted')}
{else}
{if="isset($value->html)"}
{$value->body}
{else}
{$value->body|htmlentities:ENT_COMPAT,'UTF-8'|prepareString}
{/if}
{/if}
<span class="info">{$value->delivered|strtotime|prepareDate}</span>
{if="$value->type == 'groupchat'"}
<span class="info">{$value->resource} - </span>
{/if}
</div>
</li>
{/if}
{/loop}
<ul class="middle" id="{$jid}_conversation">
{$messages_html}
{if="$status != false"}
<li {if="$myself != false"}class="oppose"{/if}>
<span class="icon bubble">

5
app/widgets/Chat/_chat_state.tpl

@ -0,0 +1,5 @@
<ul class="simple thin">
<li>
<p>{$message}</p>
</li>
</ul>

9
app/widgets/Chat/chat.css

@ -2,7 +2,7 @@
position: fixed;
bottom: 0;
background-color: white;
width: 75%;
width: 70%;
max-width: 100%;
border-top: 1px solid rgba(0, 0, 0, 0.12);
}
@ -16,8 +16,13 @@
width: calc(100% - 1rem);
}
#chat_widget .chat_box form > div {
min-height: 0;
margin-bottom: -1rem;
}
#chat_widget .chat_box form textarea {
margin-bottom: 0;
padding: 3rem 0px 1rem;
}
#chat_widget .chat_box div.action {

32
app/widgets/Chats/Chats.php

@ -56,13 +56,20 @@ class Chats extends WidgetCommon
$chats = Cache::c('chats');
if($chats == null) $chats = array();
if(!array_key_exists($jid, $chats)) {
if(!array_key_exists($jid, $chats)
&& $jid != $this->user->getLogin()
&& $jid != '') {
$chats[$jid] = 1;
Cache::c('chats', $chats);
RPC::call('movim_prepend', 'chats_widget_list', $this->prepareChat($jid));
RPC::call('Chats.refresh');
} else {
unset($chats[$jid]);
}
$chats[$jid] = 1;
Cache::c('chats', $chats);
RPC::call('movim_prepend', 'chats_widget_list', $this->prepareChat($jid));
RPC::call('Chats.refresh');
}
function ajaxClose($jid)
@ -85,11 +92,24 @@ class Chats extends WidgetCommon
{
$view = $this->tpl();
$cd = new \Modl\ContactDAO;
$view->assign('top', $cd->getTop(10));
Dialog::fill($view->draw('_chats_add', true), true);
}
/**
* @brief Display the extended list
*/
function ajaxAddExtend()
{
$view = $this->tpl();
$cd = new \Modl\ContactDAO;
$contacts = $cd->getRosterSimple();
$view->assign('contacts', $contacts);
Dialog::fill($view->draw('_chats_add', true), true);
RPC::call('movim_fill', 'add_extend', $view->draw('_chats_add_extend', true));
}
function prepareChats()

6
app/widgets/Chats/_chats.tpl

@ -1,6 +1,6 @@
{if="$chats == null"}
<li class="condensed">
<span class="icon bubble color green"><i class="md md-chat"></i></span>
<span class="icon green"><i class="md md-chat"></i></span>
<p>{$c->__('chats.empty')}</p>
</li>
{/if}
@ -8,3 +8,7 @@
{loop="$chats"}
{$c->prepareChat($key)}
{/loop}
<a onclick="Chats_ajaxAdd()" class="button action color">
<i class="md md-add"></i>
</a>

20
app/widgets/Chats/_chats_add.tpl

@ -1,12 +1,9 @@
<section class="scroll">
<h3>{$c->__('chats.add')}</h3>
<br />
<ul class="active">
{loop="$contacts"}
{if="$group != $value->groupname"}
<li class="subheader">{$value->groupname}</li>
{/if}
<li onclick="Chats_ajaxOpen('{$value->jid}'); Dialog.clear()">
<ul class="active" id="add_extend">
<li class="subheader condensed">{$c->__('chats.frequent')}</li>
{loop="$top"}
<li class="condensed" onclick="Chats_ajaxOpen('{$value->jid}'); Dialog.clear()">
<span class="icon bubble">
<img
class="avatar"
@ -15,10 +12,17 @@
/>
</span>
<span>{$value->getTrueName()}</span>
<p class="wrap">{$value->jid}</p>
</li>
{$group = $value->groupname}
{/loop}
<li onclick="Chats_ajaxAddExtend()">
<span class="icon">
<i class="md md-add"></i>
</span>
<span>{$c->__('chats.more')}</span>
</li>
</ul>
<br />
<!--<div id="search_results">
</div>-->

18
app/widgets/Chats/_chats_add_extend.tpl

@ -0,0 +1,18 @@
<br />
{loop="$contacts"}
{if="$group != $value->groupname"}
<li class="subheader">{$value->groupname}</li>
{/if}
<li class="condensed" onclick="Chats_ajaxOpen('{$value->jid}'); Dialog.clear()">
<span class="icon bubble">
<img
class="avatar"
src="{$value->getPhoto('s')}"
alt="avatar"
/>
</span>
<span>{$value->getTrueName()}</span>
<p class="wrap">{$value->jid}</p>
</li>
{$group = $value->groupname}
{/loop}

2
app/widgets/Chats/chats.js

@ -15,7 +15,7 @@ var Chats = {
Chat_ajaxGet(this.dataset.jid);
Chats.reset(items);
Notification_ajaxClear('chat|' + this.dataset.jid);
Notification_ajaxCurrent('chat|' + this.dataset.jid);
Notification.current('chat|' + this.dataset.jid);
movim_add_class(this, 'active');
}

2
app/widgets/Chats/chats.tpl

@ -1,3 +1,3 @@
<ul id="chats_widget_list" class="thick active divided">
<ul id="chats_widget_list" class="thick active divided spaced">
{$list}
</ul>

4
app/widgets/Chats/locales.ini

@ -1,6 +1,8 @@
[chats]
chats.empty = 'Open a new conversation here by clicking on the plus button bellow'
chats.empty = 'Open a new conversation by clicking on the plus button bellow'
chats.add = 'Chat with a contact'
chats.frequent = 'Frequent contacts'
chats.more = 'Load more contacts'
[message]
message.encrypted = 'Encrypted message'

14
app/widgets/Config/Config.php

@ -35,16 +35,11 @@ class Config extends WidgetBase
$view = $this->tpl();
/* We load the user configuration */
$this->user->reload();
$view->assign('languages', loadLangArray());
$view->assign('me', $this->user->getLogin());
$view->assign('conf', $this->user->getConfig('language'));
//$view->assign('color', $this->user->getConfig('color'));
//$view->assign('size', $this->user->getConfig('size'));
if($this->user->getConfig('chatbox'))
$view->assign('chatbox', 'checked');
else
$view->assign('chatbox', '');
$view->assign('conf', $this->user->getConfig());
$view->assign('submit',
$this->call(
@ -70,7 +65,8 @@ class Config extends WidgetBase
Notification::append(null, $this->__('config.updated'));
}
function ajaxSubmit($data) {
function ajaxSubmit($data)
{
$config = $this->user->getConfig();
if(isset($config))
$data = array_merge($config, $data);

18
app/widgets/Config/_config_form.tpl

@ -8,10 +8,10 @@
<h3>{$c->__('config.general')}</h3>
<div class="block">
<div class="select">
<select name="language" id="language">
<select name="language" id="language" value="{$conf.language}">
<option value="en">English (default)</option>
{loop="$languages"}
{if="$key == $conf"}
{if="$key == $conf.language"}
<option
value="{$key}"
selected="selected">
@ -29,6 +29,20 @@
<label for="language">{$c->__('config.language')}</label>
</div>
<div class="block">
<div class="select">
<select name="roster" id="roster" value="{$conf.roster}">
<option value="hide" {if="$conf.roster == 'hide'"}selected="selected"{/if}>
{$c->__('config.roster_hide')}
</option>
<option value="show" {if="$conf.roster == 'show'"}selected="selected"{/if} >
{$c->__('config.roster_show')}
</option>
</select>
</div>
<label for="roster">{$c->__('config.roster')}</label>
</div>
<div class="clear"></div>
<br />
<!--

15
app/widgets/Config/locales.ini

@ -1,13 +1,16 @@
config.feed_configuration = 'Feed Configuration'
#config.feed_configuration = 'Feed Configuration'
config.general = 'General'
config.language = 'Language'
config.roster = 'Roster display'
config.roster_show = 'Show the offline contacts'
config.roster_hide = 'Hide the offline contacts'
config.appearence = 'Appearence'
config.background_color = 'Background color'
config.font_size = 'Font size'
config.notifications = 'Notifications'
config.pattern = 'Pattern'
#config.background_color = 'Background color'
#config.font_size = 'Font size'
#config.notifications = 'Notifications'
#config.pattern = 'Pattern'
config.info = 'This configuration is shared wherever you are connected !'
config.updated = 'Configuration updated'
notifications.message = 'Notifify on incoming message'
notifications.message = 'Notify on incoming message'
notifications.desktop = 'Use desktop notifications'

81
app/widgets/Contact/Contact.php

@ -1,12 +1,20 @@
<?php
use Moxl\Xec\Action\Roster\UpdateItem;
use Moxl\Xec\Action\Vcard\Get;
class Contact extends WidgetCommon
{
function load()
{
$this->registerEvent('roster_updateitem_handle', 'onContactEdited');
$this->registerEvent('vcard_get_handle', 'onVcardReceived');
}
public function onVcardReceived($packet)
{
$contact = $packet->content;
$this->ajaxGetContact($contact->jid);
}
public function onContactEdited($packet)
@ -40,6 +48,12 @@ class Contact extends WidgetCommon
->request();
}
function ajaxRefreshVcard($jid)
{
$r = new Get;
$r->setTo(echapJid($jid))->request();
}
function ajaxEditContact($jid)
{
$rd = new \Modl\RosterLinkDAO();
@ -84,18 +98,18 @@ class Contact extends WidgetCommon
$view = $this->tpl();
$view->assign('jid', $jid);
$view->assign('jid', echapJS($jid));
if(isset($cr)) {
$view->assign('contactr', $cr);
$view->assign('edit',
$this->call(
'ajaxEditContact',
"'".$cr->jid."'"));
"'".echapJS($cr->jid)."'"));
$view->assign('delete',
$this->call(
'ajaxDeleteContact',
"'".$cr->jid."'"));
"'".echapJS($cr->jid)."'"));
} else {
$view->assign('contactr', null);
$c = $cd->get($jid);
@ -131,21 +145,56 @@ class Contact extends WidgetCommon
function prepareContact($jid)
{
$cd = new \Modl\ContactDAO;
$c = $cd->get($jid);
$c = $cd->get($jid, true);
if($c == null) {
$c = new \Modl\Contact;
$c->jid = $jid;
$this->ajaxRefreshVcard($jid);
}
$cr = $cd->getRosterItem($jid);
$view = $this->tpl();
$pd = new \Modl\PostnDAO;
$gallery = $pd->getGallery($jid);
if(isset($c)) {
$view->assign('mood', getMood());
$view->assign('contact', $c);
$view->assign('contactr', $cr);
if( $cr->node != null
&& $cr->ver != null
&& $cr->node
&& $cr->ver) {
$node = $cr->node.'#'.$cr->ver;
$cad = new \Modl\CapsDAO();
$caps = $cad->get($node);
if(
isset($caps)
&& $caps->name != ''
&& $caps->type != '' ) {
$clienttype = getClientTypes();
$view->assign('caps', $caps);
$view->assign('clienttype', $clienttype);
}
} else {
$view->assign('caps', null);
}
$view->assign('gallery', $gallery);
$view->assign('chat',
$this->call(
'ajaxChat',
"'".$c->jid."'"));
"'".echapJS($c->jid)."'"));
return $view->draw('_contact', true);
} elseif(isset($cr)) {
@ -155,7 +204,7 @@ class Contact extends WidgetCommon
$view->assign('chat',
$this->call(
'ajaxChat',
"'".$cr->jid."'"));
"'".echapJS($cr->jid)."'"));
return $view->draw('_contact', true);
} else {
@ -163,6 +212,26 @@ class Contact extends WidgetCommon
}
}
function getLastFM($contact)
{
$uri = str_replace(
' ',
'%20',
'http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=80c1aa3abfa9e3d06f404a2e781e38f9&artist='.
$contact->tuneartist.
'&album='.
$contact->tunesource.
'&format=json'
);
$json = json_decode(requestURL($uri, 2));
$img = $json->album->image[2]->{'#text'};
$url = $json->album->url;
return array($img, $url);
}
function display()
{
}

110
app/widgets/Contact/_contact.tpl

@ -1,11 +1,38 @@
{if="$contact != null"}
<ul class="thick">
<li>
<span class="icon bubble"><img src="{$contact->getPhoto('l')}"></span>
<h2>{$contact->getTrueName()}</h2>
</li>
</ul>
<ul>
<header class="big" style="background-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0) 100%), url('{$contact->getPhoto('xxl')}');">
<ul class="thick">
<li class="">
<span class="icon bubble"><img src="{$contact->getPhoto('l')}"></span>
<span>
<h2>{$contact->getTrueName()}</h2>
</span>
</li>
{if="$caps"}
<li class="">
<span class="icon">
<i class="md
{if="$caps->type == 'handheld' || $caps->type == 'phone'"}
md-phone-android
{elseif="$caps->type == 'bot'"}
md-memory
{else}
md-laptop
{/if}
">
</i>
</span>
<span>
{$caps->name}
{if="isset($clienttype[$caps->type])"}
- {$clienttype[$caps->type]}
{/if}
</span>
</li>
{/if}
</ul>
</header>
<br />
<ul class="flex">
{if="$contact->delay != null"}
<li class="condensed block">
<span class="icon brown"><i class="md md-restore"></i></span>
@ -99,11 +126,51 @@
{/if}
</ul>
{if="$contact->tuneartist || $contact->tunetitle"}
<ul class="flex">
<li class="subheader block large">{$c->__('general.tune')}</li>
{$img_array = $c->getLastFM($contact)}
<li class="
block
{if="$contact->tunetitle"}condensed{/if}
{if="isset($img_array[1]) && $img_array[1] != ''"} action{/if}
">
{if="isset($img_array[1]) && $img_array[1] != ''"}
<div class="action">
<a href="{$img_array[1]}" target="_blank">
<i class="md md-radio"></i>
</a>
</div>
{/if}
<span class="icon bubble">
{if="isset($img_array[0]) && $img_array[0] != ''"}
<img src="{$img_array[0]}"/>
{else}
<i class="md md-play-circle-fill"></i>
{/if}
</span>
<span>
{if="$contact->tuneartist"}
{$contact->tuneartist} -
{/if}
{if="$contact->tunesource"}
{$contact->tunesource}
{/if}
</span>
{if="$contact->tunetitle"}
<p>{$contact->tunetitle}</p>
{/if}
</li>
</ul>
{/if}
<div class="clear"></div>
{if="$contact->adrlocality != null || $contact->adrcountry != null"}
<ul>
<li class="subheader"></li>
<li class="subheader">{$c->__('position.legend')}</li>
<br />
<ul class="flex">
<li class="subheader block large">{$c->__('position.legend')}</li>
{if="$contact->adrlocality != null"}
<li class="condensed block">
@ -128,8 +195,8 @@
<div class="clear"></div>
{if="$contact->twitter != null || $contact->skype != null || $contact->yahoo != null"}
<ul class="thick">
<li class="subheader">{$c->__('general.accounts')}</li>
<ul class="flex">
<li class="subheader block large">{$c->__('general.accounts')}</li>
{if="$contact->twitter != null"}
<li class="condensed block">
@ -173,6 +240,24 @@
</ul>
{/if}
{if="isset($gallery)"}
<br />
<h3 class="padded">{$c->__('page.gallery')}</h3>
<br />
<ul class="grid">
{loop="$gallery"}
{$attachements = $value->getAttachements()}
<li style="background-image: url('{$attachements['pictures'][0]['href']}');">
<nav>
<a href="{$attachements['pictures'][0]['href']}" target="_blank">
{$attachements['pictures'][0]['title']}
</a>
</nav>
</li>
{/loop}
</ul>
{/if}
<a onclick="{$chat}" class="button action color red">
<i class="md md-chat"></i>
</a>
@ -184,3 +269,4 @@
</li>
</ul>
{/if}
<br />

10
app/widgets/Contact/_contact_edit.tpl

@ -7,11 +7,15 @@
id="alias"
class="tiny"
placeholder="{$c->__('edit.alias')}"
value="{$contact->rostername}"/>
{if="$contact->rostername"}
value="{$contact->rostername}"
{else}
value="{$contact->jid}"
{/if}"/>
<label for="alias">{$c->__('edit.alias')}</label>
</div>
<div>
<datalist id="group" style="display: none;">
<datalist id="group_list" style="display: none;">
{if="is_array($groups)"}
{loop="$groups"}
<option value="{$value}"/>
@ -20,7 +24,7 @@
</datalist>
<input
name="group"
list="group"
list="group_list"
id="group"
class="tiny"
placeholder="{$c->__('edit.group')}"

30
app/widgets/Contact/_contact_explore.tpl

@ -1,23 +1,31 @@
<h2 class="padded">{$c->__('last_registered')}</h2>
<br />
<h2>{$c->__('explore')}</h2>
<ul class="active">
<ul class="flex card active thick">
{loop="$users"}
<li class="condensed" onclick="Contact_ajaxGetContact('{$value->jid}');">
<span class="icon bubble"><img class="avatar" src="{$value->getPhoto('m')}"/></span>
<li class="{if="$value->description != ''"}condensed{/if} block" style="background-image: url();" onclick="Contact_ajaxGetContact('{$value->jid}');">
<span class="icon bubble">
<img src="{$value->getPhoto('m')}"/>
</span>
<span>{$value->getTrueName()}</span>
<p>
{if="$value->getAge()"}
<span class="tag blue on_desktop">{$value->getAge()}</span>
<span class="info">{$c->__('age.years', $value->getAge())}</span>
{/if}
{if="$value->getGender()"}
<span class="tag green on_desktop">{$value->getGender()}</span>
<span class="info">{$value->getGender()}</span>
{/if}
<!--
{if="$value->getMarital()"}
<span class="tag yellow on_desktop">{$value->getMarital()}</span>
<span class="info">{$value->getMarital()}</span>
{/if}
-->
{if="$value->description != ''"}
<p>
{$value->description|strip_tags}
</p>
{/if}
<br/>
<span class="desc on_desktop">{$value->description|strip_tags}</span>
</p>
</li>
{/loop}
</ul>

70
app/widgets/Contact/_contact_header.tpl

@ -1,36 +1,50 @@
<span id="back" class="icon" onclick="MovimTpl.hidePanel(); Contact_ajaxClear();"><i class="md md-arrow-back"></i></span>
{if="$contactr != null"}
<ul class="active">
<li onclick="{$edit}">
<span class="icon">
<i class="md md-edit"></i>
</span>
</li>
<li onclick="{$delete}">
<span class="icon">
<i class="md md-delete"></i>
</span>
</li>
</ul>
<h2>{$contactr->getTrueName()}</h2>
{else}
{if="$contact != null"}
<ul>
<li onclick="Roster_ajaxDisplaySearch('{$jid}')">
<div>
<span class="icon"><i class="md md-people"></i></span>
<h2>{$c->__('page.contacts')}</h2>
</div>
<div>
{if="$contactr != null"}
<ul class="active">
<li onclick="{$edit}">
<span class="icon">
<i class="md md-person-add"></i>
<i class="md md-edit"></i>
</span>
</li>
</ul>
<h2>{$contact->getTrueName()}</h2>
{else}
<ul>
<li onclick="Roster_ajaxDisplaySearch('{$jid}')">
<li onclick="{$delete}">
<span class="icon">
<i class="md md-person-add"></i>
<i class="md md-delete"></i>
</span>
</li>
</ul>
<h2>{$jid}</h2>
<h2 class="active r2" onclick="MovimTpl.hidePanel(); Contact_ajaxClear();">
<span id="back" class="icon" ><i class="md md-arrow-back"></i></span>
{$contactr->getTrueName()}
</h2>
{else}
{if="$contact != null"}
<ul class="active">
<li onclick="Roster_ajaxDisplaySearch('{$jid}')">
<span class="icon">
<i class="md md-person-add"></i>
</span>
</li>
</ul>
<h2 class="active r2" onclick="MovimTpl.hidePanel(); Contact_ajaxClear();">
<span id="back" class="icon" ><i class="md md-arrow-back"></i></span>
{$contact->getTrueName()}
</h2>
{else}
<ul class="active">
<li onclick="Roster_ajaxDisplaySearch('{$jid}')">
<span class="icon">
<i class="md md-person-add"></i>
</span>
</li>
</ul>
<h2 class="active r2" onclick="MovimTpl.hidePanel(); Contact_ajaxClear();">
<span id="back" class="icon" ><i class="md md-arrow-back"></i></span>
{$jid}
</h2>
{/if}
{/if}
{/if}
</div>

2
app/widgets/Contact/contact.tpl

@ -1,3 +1,3 @@
<div id="contact_widget" class="tabelem" title="{$c->__('page.profile')}">
<div class="tabelem" title="{$c->__('page.profile')}">
{$c->prepareEmpty()}
</div>

5
app/widgets/Contact/locales.ini

@ -9,6 +9,7 @@ general.email = 'Email'
general.website = 'Website'
general.about = 'About Me'
general.accounts = 'Other Accounts'
general.tune = 'Is Listening'
[position]
position.legend = 'Geographic Position'
@ -31,6 +32,7 @@ client.title = 'Client Informations'
[explore]
last_registered = 'Last registered'
explore = 'Find some new friends'
[edit]
edit.title = 'Edit'
@ -41,3 +43,6 @@ edit.updated = 'Contact updated'
[delete]
delete.title = 'Are you sure?'
delete.text = 'You are going to delete one of your contacts, please confirm your action'
[age]
age.years = '%s years'

153
app/widgets/ContactAction/ContactAction.php

@ -1,153 +0,0 @@
<?php
/**
* @package Widgets
*
* @file ContactAction.php
* This file is part of MOVIM.
*
* @brief Do some actions on a contact
*
* @author Jaussoin Timothée <edhelas@gmail.com>
*
* Copyright (C)2013 MOVIM project
*
* See COPYING for licensing information.
*/
use Moxl\Xec\Action\Roster\AddItem;
use Moxl\Xec\Action\Roster\RemoveItem;
use Moxl\Xec\Action\Presence\Subscribe;
use Moxl\Xec\Action\Presence\Unsubscribe;
class ContactAction extends WidgetCommon
{
/**
* @brief Adding a new contact
* @param $jid
* @param $alias
* @returns
*/
function ajaxAddContact($jid) {
$r = new AddItem;
$r->setTo($jid)
->setFrom($this->user->getLogin())
->request();
}
function ajaxSubscribeContact($jid) {
$p = new Subscribe;
$p->setTo($jid)
->request();
}
function ajaxRemoveContact($jid) {
$r = new RemoveItem;
$r->setTo($jid)
->request();
}
function ajaxUnsubscribeContact($jid) {
$p = new Unsubscribe;
$p->setTo($jid)
->request();
}
function prepareContactInfo()
{
$cd = new \modl\ContactDAO();
$c = $cd->getRosterItem($_GET['f']);
$html = '';
if(isset($c)) {
// Chat button
if($c->jid != $this->user->getLogin()) {
$presences = getPresences();
$html .='<h2>'.$this->__('action.title').'</h2>';
$ptoc = array(
1 => 'green',
2 => 'yellow',
3 => 'red',
4 => 'purple'
);
if($c->value && !in_array((int)$c->value, array(5, 6))) {
$html .= '
<a
class="button color '.$ptoc[(int)$c->value].'"
id="friendchat"
onclick="'.$this->genCallWidget("Chat","ajaxOpenTalk", "'".$c->jid."'").'"
>
<i class="fa fa-comment"></i> '.$presences[(int)$c->value].' - '.$this->__('action.chat').'
</a>';
}
}
$html .= '<div style="clear: both;"></div><br />';
$html .='
<a
class="button color black"
id="friendremoveask"
onclick="
document.querySelector(\'#friendremoveyes\').style.display = \'block\';
document.querySelector(\'#friendremoveno\').style.display = \'block\';
this.style.display = \'none\'
"
>
<i class="fa fa-minus"></i> '.$this->__('action.remove').'
</a>
<a
class="button color green merged left';
if(!isset($c->presence) || $c->presence == 5)
$html .=' left';
$html .= '"
id="friendremoveyes"
style="float: left; display: none;"
onclick="
setTimeout(function() {'.
$this->call("ajaxRemoveContact", "'".$_GET['f']."'").
'}, 1500);'.
$this->call("ajaxUnsubscribeContact", "'".$_GET['f']."'").
'this.className=\'button color green icon loading merged left\'; setTimeout(function() {location.reload(false)}, 2000);"
>
<i class="fa fa-check"></i> '.__('button.yes').'
</a>
<a
class="button color red merged right"
style="float: left; display: none;"
id="friendremoveno"
onclick="
document.querySelector(\'#friendremoveask\').style.display = \'block\';
document.querySelector(\'#friendremoveyes\').style.display = \'none\';
this.style.display = \'none\'
"
>
<i class="fa fa-times"></i> '.__('button.no').'
</a>';
} elseif($_GET['f'] != $this->user->getLogin()) {
$html .='<h2>'.$this->__('action.actions').'</h2>';
$html .='
<a
class="button color purple"
onclick="
setTimeout(function() {'.
$this->call("ajaxAddContact", "'".$_GET['f']."'").
'}, 1500);'.
$this->call("ajaxSubscribeContact", "'".$_GET['f']."'").
'this.className=\'button color purple icon loading merged left\'; setTimeout(function() {location.reload(false)}, 3000);"
>
<i class="fa fa-plus"></i> '.$this->__('action.invite').'
</a>';
}
return $html;
}
}

3
app/widgets/ContactAction/contactaction.tpl

@ -1,3 +0,0 @@
<div class="paddedtopbottom" id="contactaction_widget">
{$c->prepareContactInfo()}
</div>

5
app/widgets/ContactAction/locales.ini

@ -1,5 +0,0 @@
action.title = 'Actions'
action.chat = 'Chat'
action.actions = 'Actions'
action.invite = 'Invite this user'
action.remove = 'Remove this contact'

151
app/widgets/ContactCard/ContactCard.php

@ -1,151 +0,0 @@
<?php
/**
* @package Widgets
*
* @file Roster.php
* This file is part of MOVIM.
*
* @brief The Roster widget
*
* @author Jaussoin Timothée <edhelas@gmail.com>
*
* @version 1.0
* @date 30 August 2010
*
* Copyright (C)2010 MOVIM project
*
* See COPYING for licensing information.
*/
class ContactCard extends WidgetCommon
{
function load()
{
$this->addcss('contactcard.css');
$this->registerEvent('vcard', 'onVcard');
}
function display()
{
$cd = new \Modl\ContactDAO();
$this->view->assign('contact', $cd->get($_GET['f']));
}
function onVcard($contact)
{
$html = $this->prepareContactCard($contact);
RPC::call('movim_fill', 'contactcard', $html);
}
function prepareContactCard($contact)
{
$gender = getGender();
$marital = getMarital();
$html = '';
$html .= '
<form name="vcard" id="vcardform">
<h1 class="padded">'.$this->__('Profile').'</h1>
<fieldset>
<legend>'.$this->__('general.legend').'</legend>';
if($this->testIsSet($contact->fn))
$html .= '<div class="element simple">
<label for="fn">'.$this->__('general.name').'</label>
<span>'.$contact->fn.'</span>
</div>';
if($this->testIsSet($contact->name))
$html .= '<div class="element simple">
<label for="name">'.$this->__('general.nickname').'</label>
<span>'.$contact->name.'</span>
</div>';
if(strtotime($contact->date) != 0)
$html .= '<div class="element simple">
<label for="day">'.$this->__('general.date_of_birth').'</label>
<span>'.prepareDate(strtotime($contact->date), false).'</span>
</div>';
if($contact->gender != 'N' && $this->testIsSet($contact->gender))
$html .= '<div class="element simple">
<label for="gender">'.$this->__('general.gender').'</label>
<span>'.$gender[(string)$contact->gender].'</span>
</div>';
if($contact->marital != 'none' && $this->testIsSet($contact->marital))
$html .= '<div class="element simple">
<label for="marital">'.$this->__('general.marital').'</label>
<span>'.$marital[(string)$contact->marital].'</span>
</div>';
if($this->testIsSet($contact->email)) {
if(filter_var($contact->email, FILTER_VALIDATE_EMAIL)) {
$html .= '<div class="element simple">
<label for="url">'.$this->__('general.email').'</label>
<img src="'.$contact->getPhoto('email').'"/>
</div>';
} else {
$html .= '<div class="element simple">
<label for="url">'.$this->__('general.email').'</label>
'.$contact->email.'
</div>';
}
}
if($this->testIsSet($contact->url)) {
if(filter_var($contact->url, FILTER_VALIDATE_URL)) {
$html .= '<div class="element simple">
<label for="url">'.$this->__('general.legend').'</label>
<a target="_blank" href="'.$contact->url.'">'.$contact->url.'</a>
</div>';
} else {
$html .= '<div class="element simple">
<label for="url">'.$this->__('general.legend').'</label>
'.$contact->url.'
</div>';
}
}
if($this->testIsSet($contact->description) && prepareString($contact->description) != '')
$html .= '<div class="element large simple">
<label for="desc">'.$this->__('general.about').'</label>
<span style="white-space: pre-wrap;">'.prepareString($contact->description).'</span>
</div>';
if($this->testIsSet($contact->adrlocality) ||
$this->testIsSet($contact->adrcountry)) {
$html .= '</fieldset>
<br />
<fieldset>
<legend>'.$this->__('position.legend').'</legend>';
if($this->testIsSet($contact->adrlocality)) {
$locality = '<div class="element simple">
<label for="adrlocality">'.$this->__('position.locality').'</label>
<span>'.$contact->adrlocality;
if($contact->adrpostalcode != 0)
$locality .= ' ('.$contact->adrpostalcode.')';
$locality .= '</span>
</div>';
$html .= $locality;
}
if($this->testIsSet($contact->adrcountry))
$html .= '<div class="element simple">
<label for="adrcountry">'.$this->__('position.coutry').'</label>
<span>'.$contact->adrcountry.'</span>
</div>';
}
$html .= '</fieldset>
<div class="config_button" onclick="'.$this->genCallWidget("ContactSummary","ajaxRefreshVcard", "'".$contact->jid."'").'"></div>
</form>';
return $html;
}
}

7
app/widgets/ContactCard/contactcard.css

@ -1,7 +0,0 @@
#contactcard h1 {
padding: 0;
}
#contactcard .protect {
margin-right: -1rem;
}

6
app/widgets/ContactCard/contactcard.tpl

@ -1,6 +0,0 @@
<div class="tabelem paddedtop" title="{$c->__('page.profile')}" id="contactcard">
<div class="protect red" title="{function="getFlagTitle("red")"}"></div>
{if="isset($contact)"}
{$c->prepareContactCard($contact)}
{/if}
</div>

15
app/widgets/ContactCard/locales.ini

@ -1,15 +0,0 @@
[general]
general.legend = 'General Informations'
general.name = 'Name'
general.nickname = 'Nickname'
general.date_of_birth = 'Date of Birth'
general.gender = 'Gender'
general.marital = 'Marital Status'
general.email = 'Email'
general.website = 'Website'
general.about = 'About Me'
[position]
position.legend = 'Geographic Position'
position.locality = 'Locality'
position.country = 'Country'

163
app/widgets/ContactInfo/ContactInfo.php

@ -1,163 +0,0 @@
<?php
/**
* @package Widgets
*
* @file ContactInfo.php
* This file is part of MOVIM.
*
* @brief Display some informations on a Contact
*
* @author Jaussoin Timothée <edhelas@gmail.com>
*
* Copyright (C)2013 MOVIM project
*
* See COPYING for licensing information.
*/
class ContactInfo extends WidgetCommon
{
function load()
{
$this->addcss('contactinfo.css');
$this->registerEvent('tune', 'onTune');
}
function onTune($from)
{
$html = $this->prepareContactInfo($from);
RPC::call('movim_fill', 'contactinfo', $html);
}
function prepareContactInfo($from = false)
{
$cd = new \Modl\ContactDAO();
if($from != $this->user->getLogin())
$c = $cd->getRosterItem($from);
else
$c = $cd->get($from);
$html = '';
if(isset($c)) {
// Mood
if($c->mood) {
$moodarray = getMood();
$html .= '<h2><i class="fa fa-smile-o"></i> '.$this->__('mood.title').'</h2>';
$mood = '';
foreach(unserialize($c->mood) as $m)
$mood .= $moodarray[$m].',';
$html .= $this->__('mood.im').substr($mood, 0, -1).'<br />';
}
// Tune
if($c->tuneartist || $c->tunetitle) {
$album = $artist = $title = $img = '';
$html .= '<h2><i class="fa fa-music"></i> '.$this->__('listen.title').'</h2>';
if($c->tuneartist)
$artist = $c->tuneartist. ' - ';
if($c->tunetitle)
$title = $c->tunetitle;
if($c->tunesource)
$album = $this->__('listen.on').' '.$c->tunesource;
if($c->tunesource) {
$l = str_replace(
' ',
'%20',
'http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=80c1aa3abfa9e3d06f404a2e781e38f9&artist='.
$c->tuneartist.
'&album='.
$c->tunesource.
'&format=json'
);
$json = json_decode(requestURL($l, 2));
$img = $json->album->image[2]->{'#text'};
$url = $json->album->url;
if(isset($img) && $img != '') {
$img = '
<a href="'.$url.'" target="_blank">
<img src="'.$img.'"/>
</a>';
}
}
$html .= $artist.$title.' '.$album.$img;
}
// Last seen
if($c->delay != null
&& $c->delay
&& $c->delay != '0000-00-00 00:00:00') {
$html .= '<h2><i class="fa fa-clock-o"></i> '.$this->__('last.title').'</h2>';
$html .= prepareDate(strtotime($c->delay)).'<br />';
}
// Client informations
if( $c->node != null
&& $c->ver != null
&& $c->node
&& $c->ver) {
$node = $c->node.'#'.$c->ver;
$cad = new \Modl\CapsDAO();
$caps = $cad->get($node);
$clienttype = getClientTypes();
if(isset($caps) && $caps->name != '' && $caps->type != '' ) {
$cinfos = '';
if(isset($clienttype[$caps->type]))
$type = ' ('.$clienttype[$caps->type].')';
else
$type = '';
$cinfos .= $caps->name.$type.'<br />';
$html .='<h2><i class="fa fa-info-circle"></i> '.$this->__('client.title').'</h2>' . $cinfos;
}
}
$html .= '<div class="clear"></div>';
// Accounts
if($c->twitter && $c->twitter != '') {
$html .= '
<a
class="button color blue"
target="_blank"
href="https://twitter.com/'.$c->twitter.'">
<i class="fa fa-twitter"></i> @'.$c->twitter.'
</a>';
}
if($c->skype && $c->skype != '') {
$html .= '
<a
class="button color green"
target="_blank"
href="callto://'.$c->skype.'">
<i class="fa fa-skype"></i> '.$c->skype.'
</a>';
}
if($c->yahoo && $c->yahoo != '') {
$html .= '
<a
class="button color purple"
target="_blank"
href="ymsgr:sendIM?'.$c->yahoo.'">
<i class="fa fa-yahoo"></i> '.$c->yahoo.'
</a>';
}
$html .= '<div class="clear"></div>';
}
return $html;
}
}

12
app/widgets/ContactInfo/contactinfo.css

@ -1,12 +0,0 @@
#contactinfo a {
display: inline-block;
margin-top: 1em;
}
#contactinfo a:first-child {
margin-top: 2em;
}
#contactinfo img {
width: 100%;
}

3
app/widgets/ContactInfo/contactinfo.tpl

@ -1,3 +0,0 @@
<div id="contactinfo" class="paddedtop">
{$c->prepareContactInfo($_GET['f'])}
</div>

13
app/widgets/ContactInfo/locales.ini

@ -1,13 +0,0 @@
[mood]
mood.title = 'Mood'
mood.im = "I'm "
[listen]
listen.title = 'Listening'
listen.on = 'on'
[last]
last.title = 'Last seen'
[client]
client.title = 'Client Informations'

76
app/widgets/ContactManage/ContactManage.php

@ -1,76 +0,0 @@
<?php
/**
* @package Widgets
*
* @file ContactManage.php
* This file is part of MOVIM.
*
* @brief A little widget which manage the current contact
*
* @author Jaussoin Timothée <edhelas@gmail.com>
*
* @version 1.0
* @date 24 March 2013
*
* Copyright (C)2013 MOVIM project
*
* See COPYING for licensing information.
*/
use Moxl\Xec\Action\Roster\UpdateItem;
class ContactManage extends WidgetCommon
{
function load()
{
$this->registerEvent('roster_updateitem_handle', 'onRoster');
}
function display()
{
$this->view->assign('ok', ($_GET['f'] != $this->user->getLogin()));
$this->view->assign('contact', $this->prepareContactManage($_GET['f']));
}
public function onRoster($packet)
{
$contact = $packet->content[0];
$html = $this->prepareContactManage($contact->jid);
Notification::append(null, $this->__('contact.updated'));
RPC::call('movim_fill', 'contactmanage', $html);
}
public function ajaxContactManage($form)
{
$rd = new UpdateItem;
$rd->setTo(echapJid($form['jid']))
->setFrom($this->user->getLogin())
->setName(htmlspecialchars($form['alias']))
->setGroup(htmlspecialchars($form['group']))
->request();
}
private function prepareContactManage($jid)
{
$rd = new \Modl\RosterLinkDAO();
$groups = $rd->getGroups();
$rl = $rd->get($jid);
$html = '';
if(isset($rl)) {
$form = $this->tpl();
$form->assign('submit',
$this->call(
'ajaxContactManage',
"movim_parse_form('manage')"));
$form->assign('rl', $rl);
$form->assign('groups', $groups);
$html = $form->draw('_contact_manage_form', true);
}
return $html;
}
}

35
app/widgets/ContactManage/_contact_manage_form.tpl

@ -1,35 +0,0 @@
<h2>{$c->__('title')}</h2>
<form name="manage">
<input type="hidden" name="jid" value="{$rl->jid}"/>
<div class="element large mini">
<input
name="alias"
id="alias"
class="tiny"
placeholder="{$c->__('alias')}"
value="{$rl->rostername}"/>
</div>
<div class="element large mini">
<datalist id="group" style="display: none;">
{if="is_array($groups)"}
{loop="$groups"}
<option value="{$value}"/>
{/loop}
{/if}
</datalist>
<input
name="group"
list="group"
id="alias"
class="tiny"
placeholder="{$c->__('group')}"
value="{$rl->groupname}"/>
</div>
<a
name="submit"
class="button color green"
onclick="{$submit} this.style.display = 'none';">
<i class="fa fa-check"></i> {$c->__('button.save')}
</a>
</form>

5
app/widgets/ContactManage/contactmanage.tpl

@ -1,5 +0,0 @@
<div id="contactmanage" class="paddedtop">
{if="$ok"}
{$contact}
{/if}
</div>

4
app/widgets/ContactManage/locales.ini

@ -1,4 +0,0 @@
title = 'Manage'
alias = 'Alias'
group = 'Group'
contact.updated = 'Contact updated'

74
app/widgets/ContactPubsubSubscription/ContactPubsubSubscription.php

@ -1,74 +0,0 @@
<?php
/**
* @package Widgets
*
* @file ContactPubsubSubscription.php
* This file is part of MOVIM.
*
* @brief The Group configuration widget
*
* @author Ho Christine <nodpounod@gmail.com>
*
* @version 1.0
* @date 24 March 2013
*
* Copyright (C)2010 MOVIM project
*
* See COPYING for licensing information.
*/
use Moxl\Xec\Action\PubsubSubscription\ListGetFriends;
class ContactPubsubSubscription extends WidgetBase
{
function load()
{
$this->registerEvent('groupsubscribedlist', 'onGroupSubscribedList');
$this->registerEvent('groupsubscribedlisterror', 'onGroupSubscribedListError');
$this->addjs('contactpubsubsubscription.js');
}
function display()
{
$this->view->assign('refresh', $this->call('ajaxGetGroupSubscribedList', "'".$_GET['f']."'"));
}
function prepareList($list)
{
if(is_array(array_slice($list, 0, 1))){
$html = '<ul class="list">';
foreach($list as $item){
if(is_array($item)) {
$html .= '<li><a href="'.Route::urlize('node', array($item[1], $item[0])).'">'.$item[2].'</a></li>';
}
}
$html .= '</ul>';
return $html;
} else {
Notification::append(null, $this->__('not_found'));
}
}
function onGroupSubscribedList($list)
{
$html = $this->prepareList($list);
RPC::call('movim_fill', 'publicgroups', $html);
}
function onGroupSubscribedListError($error)
{
//Notification::appendNotification($error, 'error');
RPC::call('hidePubsubSubscription');
}
function ajaxGetGroupSubscribedList($to)
{
$r = new ListGetFriends;
$r->setTo($to)->request();
}
}
?>

5
app/widgets/ContactPubsubSubscription/contactpubsubsubscription.js

@ -1,5 +0,0 @@
function hidePubsubSubscription() {
wall = document.querySelector("#groupsubscribedlistfromfriend");
wall.parentNode.removeChild(wall);
createTabs();
}

10
app/widgets/ContactPubsubSubscription/contactpubsubsubscription.tpl

@ -1,10 +0,0 @@
<div class="tabelem" title="{$c->__('title')}" id="groupsubscribedlistfromfriend">
<div class="protect red" title="{function="getFlagTitle("red")"}"></div>
<h1 class="paddedtopbottom">{$c->__('title')}</h1>
<script type="text/javascript">
MovimWebsocket.attach(function() {
{$refresh}
});
</script>
<div id="publicgroups" class="paddedtop"></div>
</div>

2
app/widgets/ContactPubsubSubscription/locales.ini

@ -1,2 +0,0 @@
title = 'Public groups'
not_found = 'No public groups found'

76
app/widgets/ContactSummary/ContactSummary.php

@ -1,76 +0,0 @@
<?php
/**
* @package Widgets
*
* @file ContactSummary.php
* This file is part of MOVIM.
*
* @brief Contact Summary widget
*
* @author Jaussoin Timothée <edhelas@movim.eu>
*
* Copyright (C)2014 MOVIM project
*
* See COPYING for licensing information.
*/
use Moxl\Xec\Action\Vcard\Get;
class ContactSummary extends WidgetCommon
{
function load()
{
$this->addcss('contactsummary.css');
$this->registerEvent('vcard_get_handle', 'onVcard');
}
function display()
{
$cd = new \Modl\ContactDAO();
$contact = $cd->getRosterItem($_GET['f']);
if(!isset($contact)) {
$contact = $cd->get($_GET['f']);
}
if(isset($contact)) {
$this->view->assign('contact', $contact);
} else {
$contact = new \Modl\Contact();
$contact->jid = $_GET['f'];
$this->view->assign('contact', $contact);
}
$this->view->assign('refresh', $this->call('ajaxRefreshVcard', "'".$_GET['f']."'"));
}
function onVcard($packet)
{
$contact = $packet->content;
// We try to get more informations on the contact
$cd = new \Modl\ContactDAO();
$contact_roster = $cd->getRosterItem($contact->jid);
if(!isset($contact_roster)) {
$contact_roster = $contact;
}
$html = $this->prepareContactSummary($contact_roster);
RPC::call('movim_fill', 'contactsummary', $html);
}
function ajaxRefreshVcard($jid)
{
$r = new Get;
$r->setTo(echapJid($jid))->request();
}
function prepareContactSummary($contact)
{
$csc = $this->tpl();
$csc->assign('contact', $contact);
return $csc->draw('_contactsummary_content', true);
}
}

20
app/widgets/ContactSummary/_contactsummary_content.tpl

@ -1,20 +0,0 @@
<div class="profile"
{if="$contact->loclatitude"}
data-lat="{$contact->loclatitude}"
data-lon="{$contact->loclongitude}"
data-avatar="{$contact->getPhoto('s')}"
data-date="{$contact->loctimestamp|strtotime|prepareDate}"
{/if}>
<a
class="avatar"
style="background-image: url({$contact->getPhoto('l')});"
href="{$c->route('friend',$contact->jid)}">
</a>
<h1 class="paddedbottom">{$contact->getTrueName()}</h1>
{if="$contact->status"}
<div class="status">
{$contact->status|prepareString}
</div>
{/if}
</div>

37
app/widgets/ContactSummary/contactsummary.css

@ -1,37 +0,0 @@
#contactsummary_widget {
line-height: 1.5em;
padding-bottom: 1rem;
}
#contactsummary_widget h1 {
text-align: center;
color: #333;
margin-bottom: 0.5em;
line-height: 1.5em;
}
#contactsummary_widget a.avatar {
width: 92%;
padding-bottom: 92%;
box-shadow: 0 0.1em 0.2em rgba(0, 0, 0, 0.25), 0 0.1em 0.5em rgba(0, 0, 0, 0.20);
display: block;
margin: 4%;
background-size: 100%;
border-radius: 0.5em;
}
#contactsummary_widget a.url {
width: 100%;
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
#contactsummary_widget .status {
text-align: center;
}

11
app/widgets/ContactSummary/contactsummary.tpl

@ -1,11 +0,0 @@
<div id="contactsummary_widget">
{$c->prepareContactSummary($contact)}
<script type="text/javascript">
MovimWebsocket.attach(function()
{
{$refresh}
MovimMap.addContact();
});
</script>
</div>

5
app/widgets/Dialog/Dialog.php

@ -9,10 +9,11 @@ class Dialog extends WidgetBase
static function fill($html = '', $scroll = false)
{
RPC::call('movim_fill', 'dialog', $html);
if($scroll) {
RPC::call('Dialog.toggleScroll');
RPC::call('Dialog.addScroll');
}
RPC::call('movim_fill', 'dialog', $html);
}
function display()

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save