Browse Source

- Merge with edhelas

pull/16/head
Jaussoin Timothée 11 years ago
parent
commit
cf026ec378
  1. 8
      app/helpers/StringHelper.php
  2. 7
      app/widgets/Chat/Chat.php
  3. 4
      app/widgets/Chat/_chat_header.tpl
  4. 2
      app/widgets/Chats/_chats_add.tpl
  5. 2
      app/widgets/Chats/_chats_add_extend.tpl
  6. 52
      app/widgets/Contact/Contact.php
  7. 66
      app/widgets/Contact/_contact.tpl
  8. 1
      app/widgets/Contact/locales.ini
  9. 2
      app/widgets/Login/login.css
  10. 3
      app/widgets/Notifs/Notifs.php
  11. 5
      app/widgets/Notifs/_notifs_confirm.tpl
  12. 2
      app/widgets/Notifs/_notifs_from.tpl
  13. 4
      app/widgets/Notifs/notifs.js
  14. 1
      app/widgets/Roster/roster.tpl
  15. 1
      linker.php
  16. 1
      system/controllers/AjaxController.php
  17. 2
      themes/material/css/color.css

8
app/helpers/StringHelper.php

@ -196,6 +196,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
*/

7
app/widgets/Chat/Chat.php

@ -24,7 +24,9 @@ class Chat extends WidgetCommon
$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)
@ -237,7 +239,7 @@ class Chat extends WidgetCommon
function prepareChat($jid, $muc = false)
{
$view = $this->tpl();
$view->assign('jid', $jid);
$view->assign('messages', $this->prepareMessages($jid));
@ -302,7 +304,6 @@ class Chat extends WidgetCommon
}
$view->assign('contacts', $contacts);
return $view->draw('_chat_messages', true);
}

4
app/widgets/Chat/_chat_header.tpl

@ -4,7 +4,7 @@
</div>
<div>
<ul class="active">
<li onclick="Chats_ajaxClose('{$jid}'); MovimTpl.hidePanel();">
<li onclick="Chats_ajaxClose('{$jid|echapJS}'); MovimTpl.hidePanel();">
<span class="icon">
<i class="md md-close"></i>
</span>
@ -15,7 +15,7 @@
{if="$contact != null"}
{$contact->getTrueName()}
{else}
{$jid}
{$jid|echapJS}
{/if}
</h2>
</div>

2
app/widgets/Chats/_chats_add.tpl

@ -12,7 +12,7 @@
/>
</span>
<span>{$value->getTrueName()}</span>
<p>{$value->jid}</p>
<p class="wrap">{$value->jid}</p>
</li>
{/loop}
<li onclick="Chats_ajaxAddExtend()">

2
app/widgets/Chats/_chats_add_extend.tpl

@ -12,7 +12,7 @@
/>
</span>
<span>{$value->getTrueName()}</span>
<p>{$value->jid}</p>
<p class="wrap">{$value->jid}</p>
</li>
{$group = $value->groupname}
{/loop}

52
app/widgets/Contact/Contact.php

@ -98,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);
@ -167,12 +167,34 @@ class Contact extends WidgetCommon
$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)) {
@ -182,7 +204,7 @@ class Contact extends WidgetCommon
$view->assign('chat',
$this->call(
'ajaxChat',
"'".$cr->jid."'"));
"'".echapJS($cr->jid)."'"));
return $view->draw('_contact', true);
} else {
@ -190,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()
{
}

66
app/widgets/Contact/_contact.tpl

@ -1,12 +1,34 @@
{if="$contact != null"}
<header class="big" style="background-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0) 80%), url('{$contact->getPhoto('xxl')}');">
<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>
<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 />
@ -104,6 +126,46 @@
{/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"}
<br />

1
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'

2
app/widgets/Login/login.css

@ -1,5 +1,5 @@
body main {
background-color: #1C1D5B;
background-color: #3F51B5;
background-image: url(img/logo.svg);
background-repeat: no-repeat;

3
app/widgets/Notifs/Notifs.php

@ -39,6 +39,7 @@ class Notifs extends WidgetCommon
{
$html = $this->prepareNotifs();
RPC::call('movim_fill', 'notifs_widget', $html);
RPC::call('Notifs.refresh');
}
/*
@ -76,7 +77,7 @@ class Notifs extends WidgetCommon
function ajaxAccept($jid)
{
$jid = echapJid($jid);
$r = new AddItem;
$r->setTo($jid)
->setFrom($this->user->getLogin())

5
app/widgets/Notifs/_notifs_confirm.tpl

@ -2,15 +2,14 @@
<h3>{$c->__('notifs.manage')}</h3>
<br />
<h4 class="gray">{$c->__('wants_to_talk', $jid)}</h4>
<ul class="active">
<li onclick="Notifs_ajaxAccept('{$jid}'); Dialog.clear();">
<li onclick="Notifs_ajaxAccept('{$jid|echapJS}'); Dialog.clear();">
<span class="icon green">
<i class="md md-person-add"></i>
</span>
{$c->__('button.accept')}
</li>
<li onclick="Notifs_ajaxRefuse('{$jid}'); Dialog.clear();">
<li onclick="Notifs_ajaxRefuse('{$jid|echapJS}'); Dialog.clear();">
<span class="icon red">
<i class="md md-close"></i>
</span>

2
app/widgets/Notifs/_notifs_from.tpl

@ -19,7 +19,7 @@
{$c->__('button.add')}
</a>
-->
<a class="button flat" onclick="Notifs_ajaxAsk('{$value->jid}')">
<a class="button flat" data-jid="{$value->jid}">
{$c->__('notifs.manage')}
</a>
</div>

4
app/widgets/Notifs/notifs.js

@ -16,6 +16,10 @@ var Notifs = {
Notifs.reset(items);
movim_add_class(this, 'active');
}
items[i].querySelector('a.button.flat').onclick = function(e) {
Notifs_ajaxAsk(this.dataset.jid);
}
i++;
}

1
app/widgets/Roster/roster.tpl

@ -32,6 +32,7 @@
ng-if="myjid.ajiditems.rosterview.tune != '' || myjid.ajiditems.rosterview.type != '' "
ng-switch on="myjid.ajiditems.rosterview.type">
<i ng-switch-when="handheld" class="md md-smartphone"></i>
<i ng-switch-when="phone" class="md md-smartphone"></i>
<i ng-switch-when="web" class="md md-language"></i>
<i ng-switch-when="bot" class="md md-memory"></i>
<i ng-if="myjid.ajiditems.rosterview.tune" class="md md-play-arrow"></i>

1
linker.php

@ -145,6 +145,7 @@ $connector($config->websocketurl, array('xmpp'))->then(function($conn) use (&$st
// Fallback event, when the WebSocket is not enabled,
// we still handle browser to Movim requests
$stdin->on('data', function ($data) use ($loop) {
if(!isset($buffer)) $buffer = '';
if(substr($data, -3) == "END") {
$messages = explode("END", $buffer . substr($data, 0, -3));
$buffer = '';

1
system/controllers/AjaxController.php

@ -45,7 +45,6 @@ class AjaxController extends BaseController
$buffer .= "function " . $funcdef['object'] . '_'
. $funcdef['funcname'] . "(${parlist}) {";
$buffer .= "MovimWebsocket.send('".$funcdef['object']."', '".$funcdef['funcname']."', [${parlist}]);}\n";
}
return $buffer . "</script>\n";
}

2
themes/material/css/color.css

@ -90,7 +90,7 @@ form textarea:focus:invalid + label {
color: #F44336;
}
/* Default color : gray */
/* Default color : violet */
.button.color,
input[type=button].color,

Loading…
Cancel
Save