Browse Source

- Add feed support to the Wall widget

- Add XEP 0277 (microblogging) tu Jaxl
- Add loadPicture and savePicture in Conf
- Add getWall & getComments to Jabber
pull/5/head
Jaussoin Timothée 15 years ago
parent
commit
aab5297c30
  1. 1
      loader.php
  2. 23
      system/Conf.php
  3. 21
      system/Jabber.php
  4. 35
      system/Widget/widgets/Profile/Profile.php
  5. 2
      system/Widget/widgets/Profile/profile.css
  6. 2
      system/Widget/widgets/Profile/profile.js
  7. 55
      system/Widget/widgets/Wall/Wall.php
  8. 14
      system/Widget/widgets/Wall/wall.css

1
loader.php

@ -6,6 +6,7 @@ define('APP_NAME', 'movim');
define('LIB_PATH', BASE_PATH.'system/');
define('PROPERTIES_PATH', BASE_PATH.'page/properties/');
define('THEMES_PATH', BASE_PATH . 'themes/');
define('USERS_PATH', BASE_PATH . 'user/');
define('SESSION_DB_FILE', BASE_PATH . 'session.db');
define('SESSION_MAX_AGE', 24 * 3600);

23
system/Conf.php

@ -5,7 +5,7 @@ class Conf
public static $conf_path = "/config";
function __construct() {
movim_log("test".date("H:i"));
}
/* Return the general configuration */
@ -109,6 +109,7 @@ class Conf
$serv = self::getServerConf();
mkdir($dir_conf);
mkdir($dir_conf.'/img');
$conf_xml =
'<?xml version="1.0" encoding="UTF-8"?>'."\n".
'<data>'."\n".
@ -136,6 +137,26 @@ class Conf
throw new MovimException(t("Couldn't create configuration files."));
}
}
/* Save a binary avatar to a file */
static function savePicture($jid, $contact, $data, $type) {
$dir_img = BASE_PATH . "/user/$jid/img";
if($type == "image/jpeg") {
if(!file_put_contents($dir_img.'/'.$contact.'.jpeg', base64_decode($data)))
throw new MovimException(t("Couldn't save img file %s", $contact.'.jpeg'));
}
}
/**
* Return the url of an image sotred in the user account
*/
static function loadPicture($jid, $name) {
$base_uri = str_replace('jajax.php', '', BASE_URI);
return $base_uri . "/user/".$jid."/img/".$name;
}
/* Actually reads the XML file if it exists */

21
system/Jabber.php

@ -76,7 +76,8 @@ class Jabber
'JAXL0092', // Software Version
'JAXL0203', // Delayed Delivery
'JAXL0202', // Entity Time
'JAXL0206' // Jabber over Bosh
'JAXL0206', // Jabber over Bosh
'JAXL0277' // Microblogging
));
// Defining call-backs
@ -223,6 +224,9 @@ class Jabber
$evt->runEvent('myvcardreceived', $payload);
} else {
Cache::c("vcard".$payload["from"], $payload);
movim_log($payload["vCardPhotoType"]);
$res = JAXLUtil::splitJid($payload['to']);
Conf::savePicture($res[0].'@'.$res[1], $payload['from'], $payload['vCardPhotoBinVal'], $payload["vCardPhotoType"]);
$evt->runEvent('vcardreceived', $payload);
}
} elseif($payload['queryXmlns'] == "jabber:iq:roster") {
@ -232,6 +236,9 @@ class Jabber
} elseif($payload['type'] == "set") {
$this->getRosterList();
}
} elseif($payload["pubsubNode"] == "urn:xmpp:microblog:0") {
movim_log($payload);
$evt->runEvent('streamreceived', $payload);
} else {
$evt->runEvent('none', var_export($payload, true));
}
@ -251,6 +258,14 @@ class Jabber
$this->jaxl->JAXL0054('getVCard', $jid, $this->jaxl->jid, false);
}
public function getWall($jid = false) {
$this->jaxl->JAXL0277('getItems', $jid);
}
public function getComments($jid, $id) {
$this->jaxl->JAXL0277('getComments', 'pubsub.jappix.com', $id);
}
/* Service discovery
*/
@ -258,7 +273,7 @@ class Jabber
{
//$this->jaxl->JAXL0030('discoInfo', $jid, $this->jaxl->jid, false, false);
//$this->jaxl->JAXL0030('discoItems', $jid, $this->jaxl->jid, false, false);mov
$this->jaxl->JAXL0060('getNodeItems', 'psgxs.linkmauve.fr', $this->jaxl->jid, 'blog');
$this->jaxl->JAXL0277('getItems', 'edhelas@jappix.com');
//psgxs.linkmauve.fr
}
@ -425,7 +440,7 @@ class Jabber
}
}
public function addContact($jid, $group, $alias) {
public function addContact($jid, $grJaxloup, $alias) {
if($this->checkJid($jid)) {
$this->jaxl->subscribe($jid);
$this->jaxl->addRoster($jid, $group, $alias);

35
system/Widget/widgets/Profile/Profile.php

@ -20,6 +20,8 @@
class Profile extends WidgetBase
{
private static $status;
function WidgetLoad()
{
@ -27,6 +29,13 @@ class Profile extends WidgetBase
$this->addjs('profile.js');
$this->registerEvent('myvcardreceived', 'onMyVcardReceived');
$this->registerEvent('incomemypresence', 'onMyPresence');
$this->status = array(
1 => array('chat', t('Chat')),
2 => array('dnd', t('Do not disturb')),
3 => array('away', t('Away')),
5 => array('xa', t('Away for a long time')),
);
}
function onMyVcardReceived($vcard)
@ -47,27 +56,25 @@ class Profile extends WidgetBase
function ajaxRefreshMyVcard()
{
$user = new User();
$xmpp = Jabber::getInstance($user->getLogin());
$xmpp = Jabber::getInstance();
$xmpp->getVCard($jid); // We send the vCard request
}
function ajaxPresence($presence)
{
$user = new User();
$xmpp = Jabber::getInstance($user->getLogin());
$xmpp = Jabber::getInstance();
$xmpp->setStatus(false, $presence);
}
function ajaxSetStatus($status, $show = false)
{
$user = new User();
$xmpp = Jabber::getInstance($user->getLogin());
$xmpp = Jabber::getInstance();
$xmpp->setStatus($status, $show);
}
function onMyPresence($presence)
{
movim_log($presence);
$uri = $this->respath();
RPC::call('movim_fill', 'presencebutton', RPC::cdata(
'<img id="presenceimage" class="'.$presence['show'].'" src="'.str_replace('jajax.php', '',$uri).'img/'.$presence['show'].'.png">'
@ -86,12 +93,7 @@ class Profile extends WidgetBase
$xmpp = Jabber::getInstance($user->getLogin());
$mypresence = $presences[$user->getLogin()][$xmpp->getResource()];
$array = array(
1 => array('chat', t('Chat')),
2 => array('dnd', t('Do not disturb')),
3 => array('away', t('Away')),
5 => array('xa', t('Away for a long time')),
);
// We set the status
$status = (isset($presences[$user->getLogin()]['status']))
@ -100,11 +102,16 @@ class Profile extends WidgetBase
?>
<div id="profile">
<div id="presencebutton" onclick="showPresence(this);">
<img id="presenceimage" class="<?php echo $array[$mypresence][0]; ?>" src="<?php echo $this->respath('img/'.$array[$mypresence][0].'.png'); ?>"><?php echo $array[$mypresence][1]; ?>
<img
id="presenceimage"
class="<?php echo $this->status[$mypresence][0]; ?>"
src="<?php echo $this->respath('img/'.$this->status[$mypresence][0].'.png'); ?>"
>
<?php echo $this->status[$mypresence][1]; ?>
</div>
<ul id="presencelist">
<?php foreach($array as $key) { ?>
<?php foreach($this->status as $key) { ?>
<li onclick="<?php $this->callAjax('ajaxSetStatus', "getStatusText()", "'$key[0]'");?> closePresence();">
<img src="<?php echo $this->respath('img/'.$key[0].'.png'); ?>">
<?php echo $key[1]; ?>

2
system/Widget/widgets/Profile/profile.css

@ -40,7 +40,7 @@
height: 2em;
}
#profile input#statusText:hover {
#profile #profilestatustext:hover {
border: 1px solid #DDD;
}

2
system/Widget/widgets/Profile/profile.js

@ -1,6 +1,6 @@
function getStatusText()
{
var dest = document.getElementById('statusText');
var dest = document.getElementById('profilestatustext');
var stuff = dest.value;
return stuff;
}

55
system/Widget/widgets/Wall/Wall.php

@ -24,30 +24,53 @@ class Wall extends WidgetBase
function WidgetLoad()
{
$this->addcss('wall.css');
$this->registerEvent('streamreceived', 'onStream');
}
function onStream($payload) {
$html = '';
$i = 0;
$user = new User();
$jid = $user->getLogin();
foreach($payload["pubsubItemsEntryContent"] as $key => $value) {
$html .= '
<div class="message" id="'.$payload["pubsubItemsId"][$i].'">
<img class="avatar" alt="test" src="'.Conf::loadPicture($jid, $payload["from"].".jpeg").'">
function ajaxDiscovery()
{
$user = new User();
$xmpp = Jabber::getInstance($user->getLogin());
$xmpp->discover();
<div class="content">
<span>'.$payload["pubsubItemsEntryAuthor"][$i].'</span> '.$value.'
</div>
<div class="comment">
<a href="#" onclick="'.$this->genCallAjax('ajaxGetComments', "'".$_GET['f']."'", "'".$payload["pubsubItemsId"][$i]."'").'">'.t('Get the comments').'</a>
</div>
</div>';
$i++;
}
if($html == '')
$html = t('The contact feed cannot be loaded, maybe the server cannot support it');
RPC::call('movim_fill', 'wall', RPC::cdata($html));
}
function ajaxWall($jid) {
$xmpp = Jabber::getInstance();
$xmpp->getWall($jid);
}
function ajaxGetComments($jid, $id) {
movim_log($id);
$xmpp = Jabber::getInstance();
$xmpp->getComments($jid, $id);
}
function build()
{
?>
<div id="wall">
<div onclick="<?php $this->callAjax('ajaxDiscovery');?>">gna !</div>
<div class="message">
<img class="avatar" width="70px" height="70px" alt="test">
<div class="content">
<?php echo t("This is my custom Wall widget.");?>
</div>
<div class="comment">
Commentaire 1
</div>
</div>
<script type="text/javascript">
<?php $this->callAjax('ajaxWall', "'".$_GET['f']."'");?>
</script>
<?php echo t('Loading the contact feed ...'); ?>
</div>
<?php
}

14
system/Widget/widgets/Wall/wall.css

@ -8,20 +8,24 @@
border-bottom: 1px solid #ECECEC;
width: 100%;
padding-bottom: 0.5em;
min-height: 75px;
min-height: 55px;
}
#wall .message span {
font-weight: bold;
}
#wall .message .comment {
margin-bottom: 0.3em;
background-color: #F3F3F3;
padding: 0.4em;
margin-left: 80px;
margin-left: 60px;
margin-right: 5px;
}
#wall .message .avatar {
width: 70px;
height: 70px;
width: 50px;
height: 50px;
margin: 5px;
margin-left: 0px;
display: block;
@ -32,6 +36,6 @@
#wall .message .content {
padding-top: 0.4em;
padding-bottom: 0.4em;
margin-left: 80px;
margin-left: 60px;
margin-right: 5px;
}
Loading…
Cancel
Save