Browse Source

- Fix a few stuff in Explore

- Reindent the Chat.php file
pull/16/head
Jaussoin Timothée 12 years ago
parent
commit
77afa99296
  1. 657
      app/widgets/Chat/Chat.php
  2. 102
      app/widgets/Explore/Explore.php

657
app/widgets/Chat/Chat.php

@ -17,11 +17,9 @@
*
* See COPYING for licensing information.
*/
class Chat extends WidgetBase {
class Chat extends WidgetBase
{
function load()
{
function load() {
$this->addcss('chat.css');
$this->addjs('chat.js');
$this->registerEvent('message', 'onMessage');
@ -36,197 +34,122 @@ class Chat extends WidgetBase
function display() {
$this->view->assign('chats', $this->prepareChats());
}
function onPresence($presence) {
$arr = $presence->getPresence();
$txt = array(
1 => t('Online'),
2 => t('Away'),
3 => t('Do Not Disturb'),
4 => t('Extended Away'),
5 => t('Offline'),
6 => t('Error')
);
$html = '
function onPresence($presence) {
$arr=$presence->getPresence();
$txt=array(1=>t('Online'), 2=>t('Away'), 3=>t('Do Not Disturb'), 4=>t('Extended Away'), 5=>t('Offline'), 6=>t('Error'));
$html='
<div class="message presence">
<span class="date">'.date('G:i', time()).'</span>'.
prepareString(htmlentities($txt[$arr['presence']].' - '.$arr['ressource'], ENT_COMPAT, "UTF-8")).'
<span class="date">' . date('G:i', time()) . '</span>' . prepareString(htmlentities($txt[$arr['presence']] . ' - ' . $arr['ressource'], ENT_COMPAT, "UTF-8")) . '
</div>';
RPC::call('movim_append',
'messages'.$arr['jid'],
$html);
RPC::call('movim_fill',
'list'.$arr['jid'],
$this->prepareMucList($arr['jid']));
RPC::call('scrollTalk',
'messages'.$arr['jid']);
RPC::call('movim_append', 'messages' . $arr['jid'], $html);
RPC::call('movim_fill', 'list' . $arr['jid'], $this->prepareMucList($arr['jid']));
RPC::call('scrollTalk', 'messages' . $arr['jid']);
}
function onPresenceMuc($toggle) {
if($toggle)
if($toggle) {
Notification::appendNotification(t('Connected to the chatroom'), 'success');
else
} else {
Notification::appendNotification(t('Disconnected to the chatroom'), 'success');
}
RPC::call('movim_fill', 'chats', $this->prepareChats());
RPC::call('scrollAllTalks');
}
function onMessage($message) {
if($message->session == $message->jidfrom) {
$key = $message->jidfrom;
$jid = $message->jidto;
if($message->session==$message->jidfrom) {
$key=$message->jidfrom;
$jid=$message->jidto;
} else {
$key = $message->jidto;
$jid = $message->jidfrom;
$key=$message->jidto;
$jid=$message->jidfrom;
}
$rd = new \modl\RosterLinkDAO();
$rc = new \modl\ContactDAO();
$contact = $rc->getRosterItem(echapJid($jid));
if($contact != null && $message->session != $message->jidfrom)
RPC::call(
'notify',
$contact->getTrueName(),
$message->body,
$contact->getPhoto('m'));
if($contact != null && $contact->chaton == 0) {
$contact->chaton = 2;
$rd=new \ modl\ RosterLinkDAO();
$rc=new \ modl\ ContactDAO();
$contact=$rc->getRosterItem(echapJid($jid));
if($contact!=null&&$message->session!=$message->jidfrom) {
RPC::call('notify', $contact->getTrueName(), $message->body, $contact->getPhoto('m'));
}
if($contact!=null&&$contact->chaton==0) {
$contact->chaton=2;
$rd->setChat($jid, 2);
RPC::call('movim_prepend',
'chats',
$this->prepareChat($contact));
RPC::call('movim_prepend', 'chats', $this->prepareChat($contact));
RPC::call('scrollAllTalks');
} elseif($contact != null && $message->body != '') {
$html = $this->prepareMessage($message);
if($contact->chaton == 1) {
RPC::call('colorTalk',
'messages'.$contact->jid);
} elseif($contact!=null&&$message->body!='') {
$html=$this->prepareMessage($message);
if($contact->chaton==1) {
RPC::call('colorTalk', 'messages' . $contact->jid);
}
RPC::call('movim_append', 'messages' . $contact->jid, $html);
RPC::call('movim_append',
'messages'.$contact->jid,
$html);
//if($message->session != $message->jidfrom) {
RPC::call('hideComposing',
$contact->jid);
RPC::call('hidePaused',
$contact->jid);
RPC::call('hideComposing', $contact->jid);
RPC::call('hidePaused', $contact->jid);
//}
RPC::call('scrollTalk',
'messages'.$contact->jid);
}
RPC::call('scrollTalk', 'messages' . $contact->jid);
}
// Muc case
elseif($message->ressource != '') {
$html = $this->prepareMessage($message, true);
RPC::call('movim_append',
'messages'.$message->jidfrom,
$html);
RPC::call('scrollTalk',
'messages'.$message->jidfrom);
elseif($message->ressource!='') {
$html=$this->prepareMessage($message, true);
RPC::call('movim_append', 'messages' . $message->jidfrom, $html);
RPC::call('scrollTalk', 'messages' . $message->jidfrom);
}
RPC::commit();
}
function onMessagePublished($jid)
{
function onMessagePublished($jid) {
Notification::appendNotification(t('Message Published'), 'success');
}
function onComposing($jid)
{
$rd = new \modl\RosterLinkDAO();
$contact = $rd->get(echapJid($jid));
if(isset($contact) && in_array($contact->chaton, array(1, 2))) {
RPC::call('showComposing',
$contact->jid);
RPC::call('scrollTalk',
'messages'.$contact->jid);
function onComposing($jid) {
$rd=new \ modl\ RosterLinkDAO();
$contact=$rd->get(echapJid($jid));
if(isset($contact)&&in_array($contact->chaton, array(1, 2))) {
RPC::call('showComposing', $contact->jid);
RPC::call('scrollTalk', 'messages' . $contact->jid);
}
}
function onPaused($jid)
{
$rd = new \modl\RosterLinkDAO();
$contact = $rd->get(echapJid($jid));
function onPaused($jid) {
$rd=new \ modl\ RosterLinkDAO();
$contact=$rd->get(echapJid($jid));
if(in_array($contact->chaton, array(1, 2))) {
RPC::call('showPaused',
$contact->jid);
RPC::call('scrollTalk',
'messages'.$contact->jid);
RPC::call('showPaused', $contact->jid);
RPC::call('scrollTalk', 'messages' . $contact->jid);
}
}
function onAttention($jid)
{
$rc = new \modl\ContactDAO();
$contact = $rc->getRosterItem(echapJid($jid));
$html = '
function onAttention($jid) {
$rc=new \ modl\ ContactDAO();
$contact=$rc->getRosterItem(echapJid($jid));
$html='
<div style="font-weight: bold; color: black;" class="message" >
<span class="date">'.date('G:i', time()).'</span>'.
t('%s needs your attention', $contact->getTrueName()).'
<span class="date">' . date('G:i', time()) . '</span>' . t('%s needs your attention', $contact->getTrueName()) . '
</div>';
RPC::call('movim_append',
'messages'.$jid,
$html);
RPC::call('scrollTalk',
'messages'.$jid);
RPC::call('movim_append', 'messages' . $jid, $html);
RPC::call('scrollTalk', 'messages' . $jid);
}
/**
* Open a new talk
*
* @param string $jid
* @return void
*/
function ajaxOpenTalk($jid)
{
$rc = new \modl\ContactDAO();
$contact = $rc->getRosterItem(echapJid($jid));
if(
isset($contact)
&& $contact->chaton == 0
&& !in_array($contact->presence, array(5, 6))) {
$contact->chaton = 2;
$rd = new \modl\RosterLinkDAO();
function ajaxOpenTalk($jid) {
$rc=new \ modl\ ContactDAO();
$contact=$rc->getRosterItem(echapJid($jid));
if(isset($contact)&&$contact->chaton==0&&!in_array($contact->presence, array(5, 6))) {
$contact->chaton=2;
$rd=new \ modl\ RosterLinkDAO();
$rd->setChat(echapJid($jid), 2);
RPC::call('movim_prepend',
'chats',
$this->prepareChat($contact));
RPC::call('movim_prepend', 'chats', $this->prepareChat($contact));
RPC::call('scrollAllTalks');
RPC::commit();
}
}
/**
* Send an encrypted message
*
@ -234,11 +157,9 @@ class Chat extends WidgetBase
* @param string $message
* @return void
*/
function ajaxSendEncryptedMessage($to, $message, $muc = false, $ressource = false)
{
function ajaxSendEncryptedMessage($to, $message, $muc=false, $ressource=false) {
$this->ajaxSendMessage($to, $message, $muc, $ressource, true);
}
/**
* Send a message
*
@ -246,191 +167,151 @@ class Chat extends WidgetBase
* @param string $message
* @return void
*/
function ajaxSendMessage($to, $message, $muc = false, $ressource = false, $encrypted = false)
{
$m = new \modl\Message();
$m->session = $this->user->getLogin();
$m->jidto = echapJid($to);
$m->jidfrom = $this->user->getLogin();
$session = \Sessionx::start();
$m->type = 'chat';
$m->ressource = $session->ressource;
function ajaxSendMessage($to, $message, $muc=false, $ressource=false, $encrypted=false) {
$m=new \ modl\ Message();
$m->session=$this->user->getLogin();
$m->jidto=echapJid($to);
$m->jidfrom=$this->user->getLogin();
$session=\ Sessionx::start();
$m->type='chat';
$m->ressource=$session->ressource;
if($muc) {
$m->type = 'groupchat';
$m->ressource = $session->user;
$m->jidfrom = $to;
$m->type='groupchat';
$m->ressource=$session->user;
$m->jidfrom=$to;
}
$m->body = rawurldecode($message);
$m->published = date('Y-m-d H:i:s');
$m->delivered = date('Y-m-d H:i:s');
$md = new \modl\MessageDAO();
$m->body=rawurldecode($message);
$m->published=date('Y-m-d H:i:s');
$m->delivered=date('Y-m-d H:i:s');
$md=new \ modl\ MessageDAO();
$md->set($m);
$evt=new Event();
$evt->runEvent('message', $m);
if($ressource!=false) {
$to=$to . '/' . $ressource;
}
$evt = new Event();
$evt->runEvent('message', $m);
if($ressource != false)
$to = $to.'/'.$ressource;
// We decode URL codes to send the correct message to the XMPP server
$m = new \moxl\MessagePublish();
$m->setTo($to)
//->setEncrypted($encrypted)
->setContent(htmlspecialchars(rawurldecode($message)));
if($muc)
$m=new \ moxl\ MessagePublish();
$m->setTo($to);
//->setEncrypted($encrypted)->setContent(htmlspecialchars(rawurldecode($message)));
if($muc) {
$m->setMuc();
}
$m->request();
}
/**
* Send a "composing" message
*
* @param string $to
* @return void
*/
function ajaxSendComposing($to)
{
$mc = new \moxl\MessageComposing();
$mc->setTo($to)
->request();
function ajaxSendComposing($to) {
$mc=new \ moxl\ MessageComposing();
$mc->setTo($to)->request();
}
/**
* Send a "paused" message
*
* @param string $to
* @return void
*/
function ajaxSendPaused($to)
{
$mp = new \moxl\MessagePaused();
$mp->setTo($to)
->request();
function ajaxSendPaused($to) {
$mp=new \ moxl\ MessagePaused();
$mp->setTo($to)->request();
}
/**
* Close a talk
*
* @param string $jid
* @return void
*/
function ajaxCloseTalk($jid)
{
$rd = new \modl\RosterLinkDAO();
$contact = $rd->get(echapJid($jid));
$contact->chaton = 0;
function ajaxCloseTalk($jid) {
$rd=new \ modl\ RosterLinkDAO();
$contact=$rd->get(echapJid($jid));
$contact->chaton=0;
$rd->setNow($contact);
RPC::call('movim_delete',
'chat'.echapJid($jid));
RPC::call('movim_delete', 'chat' . echapJid($jid));
RPC::commit();
}
function ajaxHideTalk($jid)
{
$rd = new \modl\RosterLinkDAO();
$contact = $rd->get(echapJid($jid));
if($contact->chaton == 1)
$contact->chaton = 2;
else
$contact->chaton = 1;
function ajaxHideTalk($jid) {
$rd=new \ modl\ RosterLinkDAO();
$contact=$rd->get(echapJid($jid));
if($contact->chaton==1) {
$contact->chaton=2;
} else {
$contact->chaton=1;
}
$rd->setNow($contact);
RPC::call('scrollTalk',
'messages'.$contact->jid);
RPC::call('scrollTalk', 'messages' . $contact->jid);
RPC::commit();
}
/**
* Exit a muc
*
* @param $jid
* @return void
*/
function ajaxExitMuc($jid, $ressource)
{
$pu = new \moxl\PresenceUnavaiable();
$pu->setTo($jid)
->setRessource($ressource)
->request();
function ajaxExitMuc($jid, $ressource) {
$pu=new \ moxl\ PresenceUnavaiable();
$pu->setTo($jid)->setRessource($ressource)->request();
}
function prepareMessage($message, $muc = false) {
if($message->body != '' || $message->subject != '') {
if($message->subject != '')
$message->body = $message->subject;
$html =
'<div class="message ';
if($message->session == $message->jidfrom)
$html.= 'me';
function prepareMessage($message, $muc=false) {
if($message->body!=''||$message->subject!='') {
if($message->subject!='') {
$message->body=$message->subject;
}
$html='<div class="message ';
if($message->session==$message->jidfrom) {
$html.='me';
}
if(isset($message->html)) {
$type = 'html';
$content = $message->html;
$type='html';
$content=$message->html;
} else {
$type = '';
$content = prepareString(htmlentities($message->body, ENT_COMPAT, "UTF-8"));
$type='';
$content=prepareString(htmlentities($message->body, ENT_COMPAT, "UTF-8"));
}
if(preg_match("#^/me#", $message->body)) {
$html .= ' own ';
$content = '** '.substr($message->body, 4);
$html.=' own ';
$content='** ' . substr($message->body, 4);
}
if(preg_match("#^\?OTR:#", $message->body)) {
$html .= ' crypt ';
$content = t('Encrypted message');
$html.=' crypt ';
$content=t('Encrypted message');
}
$c = new \modl\Contact();
$html .= '">
<img class="avatar" src="'.$c->getPhoto('xs', $message->jidfrom).'" />
<span class="date">'.date('H:i', strtotime($message->published)).'</span>';
if($muc != false)
$html .= '
<span class="ressource '.$this->colorNameMuc($message->ressource).'">'.
$message->ressource.'
$c=new \ modl\ Contact();
$html.='">
<img class="avatar" src="' . $c->getPhoto('xs', $message->jidfrom) . '" />
<span class="date">' . date('H:i', strtotime($message->published)) . '</span>';
if($muc!=false) {
$html.='
<span class="ressource ' . $this->colorNameMuc($message->ressource) . '">' . $message->ressource . '
</span>';
$html .=
'<div class="content '.$type.'">'.
$content.
'</div>
}
$html.='<div class="content ' . $type . '">' . $content . '</div>
</div>';
return $html;
} else {
return '';
}
}
function prepareChats()
{
$rc = new \modl\ContactDAO();
$contacts = $rc->getRosterChat();
$html = '';
// Another filter to fix the database request
$check = array();
function prepareChats() {
$rc=new \ modl\ ContactDAO();
$contacts=$rc->getRosterChat();
$html='';
// Another filter to fix the database request
$check=array();
if(isset($contacts)) {
foreach($contacts as $contact) {
if(!in_array($contact->jid,$check)) {
$html .= trim($this->prepareChat($contact));
if(!in_array($contact->jid, $check)) {
$html.=trim($this->prepareChat($contact));
//$jid = $contact->jid;
array_push($check, $contact->jid);
}
@ -438,198 +319,122 @@ class Chat extends WidgetBase
}
// And we show the subscribed conferences
$cd = new \modl\ConferenceDAO();
$cs = $cd->getConnected();
$cd=new \ modl\ ConferenceDAO();
$cs=$cd->getConnected();
if($cs) {
foreach($cs as $c) {
$html .= trim($this->prepareMuc($c));
$html.=trim($this->prepareMuc($c));
}
}
$html .= '<div class="filler"></div>';
$html.='<div class="filler"></div>';
return $html;
}
// Prepare Chat
function prepareChat($contact)
{
$md = new \modl\MessageDAO();
$messages = $md->getContact(echapJid($contact->jid), 0, 10);
$messageshtml = '';
if($messages != null) {
$messages = array_reverse($messages);
$day = '';
function prepareChat($contact) {
$md=new \ modl\ MessageDAO();
$messages=$md->getContact(echapJid($contact->jid), 0, 10);
$messageshtml='';
if($messages!=null) {
$messages=array_reverse($messages);
$day='';
foreach($messages as $m) {
if($day != date('d',strtotime($m->published))) {
$messageshtml .= '<div class="message presence">'.prepareDate(strtotime($m->published), false).'</div>';
$day = date('d',strtotime($m->published));
if($day!=date('d', strtotime($m->published))) {
$messageshtml.='<div class="message presence">' . prepareDate(strtotime($m->published), false) . '</div>';
$day=date('d', strtotime($m->published));
}
$messageshtml .= $this->prepareMessage($m);
$messageshtml.=$this->prepareMessage($m);
}
}
$style = '';
$panelstyle= '';
$tabstyle = '';
if($contact->chaton == 2) {
$tabstyle = ' style="display: none;" ';
$panelstyle = ' style="display: block;" ';
$style='';
$panelstyle='';
$tabstyle='';
if($contact->chaton==2) {
$tabstyle=' style="display: none;" ';
$panelstyle=' style="display: block;" ';
}
$chatview = $this->tpl();
$chatview->assign(
'send',
$this->genCallAjax(
'ajaxSendMessage',
"'".$contact->jid."'",
"sendMessage(this, '".$contact->jid."')",
"false",
"'".$contact->ressource."'"
)
);
$chatview=$this->tpl();
$chatview->assign('send', $this->genCallAjax('ajaxSendMessage', "'" . $contact->jid . "'", "sendMessage(this, '" . $contact->jid . "')", "false", "'" . $contact->ressource . "'"));
$chatview->assign('contact', $contact);
$chatview->assign('tabstyle', $tabstyle);
$chatview->assign('panelstyle', $panelstyle);
$chatview->assign('messageshtml', $messageshtml);
$chatview->assign(
'closetalk',
$this->genCallAjax("ajaxCloseTalk", "'".$contact->jid."'")
);
$chatview->assign(
'hidetalk',
$this->genCallAjax("ajaxHideTalk", "'".$contact->jid."'")
);
$chatview->assign(
'composing',
$this->genCallAjax(
'ajaxSendComposing',
"'".$contact->jid."'"
)
);
$chatview->assign(
'paused',
$this->genCallAjax(
'ajaxSendPaused',
"'".$contact->jid."'"
)
);
$html = $chatview->draw('_chat_contact', true);
$chatview->assign('closetalk', $this->genCallAjax("ajaxCloseTalk", "'" . $contact->jid . "'"));
$chatview->assign('hidetalk', $this->genCallAjax("ajaxHideTalk", "'" . $contact->jid . "'"));
$chatview->assign('composing', $this->genCallAjax('ajaxSendComposing', "'" . $contact->jid . "'"));
$chatview->assign('paused', $this->genCallAjax('ajaxSendPaused', "'" . $contact->jid . "'"));
$html=$chatview->draw('_chat_contact', true);
return $html;
}
function prepareMuc($conference) {
$jid=$conference->conference;
$jid = $conference->conference;
// Zeu messages
$md = new \modl\MessageDAO();
$messages = $md->getContact($jid, 0, 10);
$messageshtml = '';
$md=new \ modl\ MessageDAO();
$messages=$md->getContact($jid, 0, 10);
$messageshtml='';
if(!empty($messages)) {
$messages = array_reverse($messages);
$day = '';
$messages=array_reverse($messages);
$day='';
foreach($messages as $m) {
if($day != date('d',strtotime($m->published))) {
$messageshtml .= '<div class="message presence">'.prepareDate(strtotime($m->published), false).'</div>';
$day = date('d',strtotime($m->published));
if($day!=date('d', strtotime($m->published))) {
$messageshtml.='<div class="message presence">' . prepareDate(strtotime($m->published), false) . '</div>';
$day=date('d', strtotime($m->published));
}
$messageshtml .= $this->prepareMessage($m, true);
$messageshtml.=$this->prepareMessage($m, true);
}
}
$mucview = $this->tpl();
$mucview=$this->tpl();
$mucview->assign('jid', $jid);
$mucview->assign('messageshtml', $messageshtml);
$mucview->assign('toggle',
$this->genCallAjax(
"ajaxToggleMuc", "'".$jid."'")
);
$mucview->assign('sendmessage',
$this->genCallAjax(
'ajaxSendMessage',
"'".$jid."'",
"sendMessage(this, '".$jid."')",
"true"
));
$session = \Sessionx::start();
$mucview->assign(
'exitmuc',
$this->genCallAjax("ajaxExitMuc", "'".$jid."'", "'".$session->username."'")
);
$sess = \Session::start(APP_NAME);
$state = $sess->get(md5('muc'.$jid));
$mucview->assign('conference', $conference);
$mucview->assign('muclist', $this->prepareMucList($jid));
if($state == 1) {
$mucview->assign('tabstyle', 'style="display: none;"');
$mucview->assign('toggle', $this->genCallAjax("ajaxToggleMuc", "'" . $jid . "'"));
$mucview->assign('sendmessage', $this->genCallAjax('ajaxSendMessage', "'" . $jid . "'", "sendMessage(this, '" . $jid . "')", "true"));
$session=\ Sessionx::start();
$mucview->assign('exitmuc', $this->genCallAjax("ajaxExitMuc", "'" . $jid . "'", "'" . $session->username . "'"));
$sess=\ Session::start(APP_NAME);
$state=$sess->get(md5('muc' . $jid));
$mucview->assign('conference', $conference);
$mucview->assign('muclist', $this->prepareMucList($jid));
if($state==1) {
$mucview->assign('tabstyle', 'style="display: none;"');
$mucview->assign('panelstyle', 'style="display: block;"');
} else {
$mucview->assign('tabstyle', '');
$mucview->assign('panelstyle', '');
$mucview->assign('tabstyle', '');
$mucview->assign('panelstyle', '');
}
$html = $mucview->draw('_chat_muc', true);
$html=$mucview->draw('_chat_muc', true);
return $html;
}
function prepareMucList($jid) {
// Zeu muc list
$pd = new \modl\PresenceDAO();
$presences = $pd->getJid($jid);
$muclist = $this->tpl();
// Zeu muc list
$pd=new \ modl\ PresenceDAO();
$presences=$pd->getJid($jid);
$muclist=$this->tpl();
$muclist->assign('muclist', $presences);
return $muclist->draw('_chat_muc_list', true);
}
function ajaxToggleMuc($jid)
{
$hash = md5('muc'.$jid);
$sess = \Session::start(APP_NAME);
$state = $sess->get($hash);
if($state == 1)
function ajaxToggleMuc($jid) {
$hash=md5('muc' . $jid);
$sess=\ Session::start(APP_NAME);
$state=$sess->get($hash);
if($state==1) {
$sess->set($hash, 0);
else
} else {
$sess->set($hash, 1);
}
}
function colorNameMuc($ressource)
{
$colors = array(
0 => 'purple',
1 => 'purple',
2 => 'wine',
3 => 'yellow',
4 => 'orange',
5 => 'green',
6 => 'red',
7 => 'blue');
$s = base_convert(sha1($ressource), 16, 8);
if(isset($s[5]))
return $colors[(int)$s[5]];
else
function colorNameMuc($ressource) {
$colors=array(0=>'purple', 1=>'purple', 2=>'wine', 3=>'yellow', 4=>'orange', 5=>'green', 6=>'red', 7=>'blue');
$s=base_convert(sha1($ressource), 16, 8);
if(isset($s[5])) {
return $colors[(int) $s[5]];
} else {
return 'orange';
}
}
}

102
app/widgets/Explore/Explore.php

@ -1,106 +1,86 @@
<?php
class Explore extends WidgetCommon {
function load()
{
function load() {
$this->addcss('explore.css');
}
function display()
{
function display() {
$this->view->assign('contacts', $this->prepareContacts());
$this->view->assign('servers', $this->prepareServers());
$jid = $this->user->getLogin();
$server = explode('@', $jid);
$jid=$this->user->getLogin();
$server=explode('@', $jid);
$this->view->assign('myserver', Route::urlize('server', $server[1]));
}
function ajaxSearchContacts($form) {
$html = $this->prepareContacts($form);
$html=$this->prepareContacts($form);
RPC::call('movim_fill', 'contactsresult', $html);
RPC::commit();
}
function colorSearch($search, $text) {
return str_replace(
$search,
'<span style="background-color: yellow;">'.$search.'</span>',
$text
);
return str_replace($search, '<span style="background-color: yellow;">' . $search . '</span>', $text);
}
function prepareServers() {
$nd = new \modl\ItemDAO();
$groups = $nd->getGroupServers();
$chatrooms = $nd->getConferenceServers();
// A little filter
$i = 0;
foreach($chatrooms as $c) {
if(filter_var($c->server, FILTER_VALIDATE_EMAIL))
unset($chatrooms[$i]);
if(count(explode('.', $c->server)) < 3)
unset($chatrooms[$i]);
// A little filter
private function cleanServers($servers) {
$i=0;
foreach($servers as $c) {
if(filter_var($c->server, FILTER_VALIDATE_EMAIL)) {
unset($servers[$i]);
} elseif(count(explode('.', $c->server))<3) {
unset($servers[$i]);
}
$i++;
}
$html = '';
return $servers;
}
$groupsview = $this->tpl();
function prepareServers() {
$nd=new \ modl\ ItemDAO();
$groups=$this->cleanServers($nd->getGroupServers());
$chatrooms=$this->cleanServers($nd->getConferenceServers());
$html='';
$groupsview=$this->tpl();
$groupsview->assign('groups', $groups);
$html .= $groupsview->draw('_explore_groups', true);
$chatroomsview = $this->tpl();
$html.=$groupsview->draw('_explore_groups', true);
$chatroomsview=$this->tpl();
$chatroomsview->assign('chatrooms', $chatrooms);
$html .= $chatroomsview->draw('_explore_chatrooms', true);
$html.=$chatroomsview->draw('_explore_chatrooms', true);
return $html;
}
function prepareContacts($form = false) {
$html = '';
$cd = new \modl\ContactDAO();
$users = $cd->getAllPublic();
$gender = getGender();
$marital = getMarital();
function prepareContacts($form=false) {
$html='';
$cd=new \ modl\ ContactDAO();
$users=$cd->getAllPublic();
$gender=getGender();
$marital=getMarital();
if($users) {
$users = array_reverse($users);
$users=array_reverse($users);
foreach($users as $user) {
$html .= '
$html.='
<article class="block">
<header>
<a href="'.Route::urlize('friend', $user->jid).'">
<img class="avatar" src="'.$user->getPhoto('m').'"/>
<a href="' . Route::urlize('friend', $user->jid) . '">
<img class="avatar" src="' . $user->getPhoto('m') . '"/>
</a>
<span class="name">
<a href="'.Route::urlize('friend', $user->jid).'">'.$user->getTrueName().'</a>
<a href="' . Route::urlize('friend', $user->jid) . '">' . $user->getTrueName() . '</a>
</span>
<span class="asv">'.
$user->getAge().' '.
$gender[$user->gender].' '.
$marital[$user->marital].'
<span class="asv">' . $user->getAge() . ' ' . $gender[$user->gender] . ' ' . $marital[$user->marital] . '
</span>
</header>
<section class="content">'.prepareString($user->description).'</section>
<section class="content">' . prepareString($user->description) . '</section>
<footer></footer>
</article>
';
}
}
return $html;
}
}
Loading…
Cancel
Save