ping: show tags

This commit is contained in:
Fabio Comuni 2011-11-15 17:41:51 +01:00
parent 962467ee68
commit 9b2cbc33ae

View file

@ -8,9 +8,10 @@ function ping_init(&$a) {
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<result>"; <result>";
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
if(local_user()){ if(local_user()){
$tags = array();
$comments = array(); $comments = array();
$likes = array(); $likes = array();
$dislikes = array(); $dislikes = array();
@ -29,6 +30,11 @@ function ping_init(&$a) {
$network = count($r); $network = count($r);
foreach ($r as $it) { foreach ($r as $it) {
switch($it['verb']){ switch($it['verb']){
case ACTIVITY_TAG:
$obj = parse_xml_string($xmlhead.$it['object']);
$it['tname'] = $obj->content;
$tags[] = $it;
break;
case ACTIVITY_LIKE: case ACTIVITY_LIKE:
$likes[] = $it; $likes[] = $it;
break; break;
@ -36,7 +42,6 @@ function ping_init(&$a) {
$dislikes[] = $it; $dislikes[] = $it;
break; break;
case ACTIVITY_FRIEND: case ACTIVITY_FRIEND:
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
$obj = parse_xml_string($xmlhead.$it['object']); $obj = parse_xml_string($xmlhead.$it['object']);
$it['fname'] = $obj->title; $it['fname'] = $obj->title;
$friends[] = $it; $friends[] = $it;
@ -61,6 +66,11 @@ function ping_init(&$a) {
$home = count($r); $home = count($r);
foreach ($r as $it) { foreach ($r as $it) {
switch($it['verb']){ switch($it['verb']){
case ACTIVITY_TAG:
$obj = parse_xml_string($xmlhead.$it['object']);
$it['tname'] = $obj->content;
$tags[] = $it;
break;
case ACTIVITY_LIKE: case ACTIVITY_LIKE:
$likes[] = $it; $likes[] = $it;
break; break;
@ -68,7 +78,6 @@ function ping_init(&$a) {
$dislikes[] = $it; $dislikes[] = $it;
break; break;
case ACTIVITY_FRIEND: case ACTIVITY_FRIEND:
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
$obj = parse_xml_string($xmlhead.$it['object']); $obj = parse_xml_string($xmlhead.$it['object']);
$it['fname'] = $obj->title; $it['fname'] = $obj->title;
$friends[] = $it; $friends[] = $it;
@ -129,7 +138,7 @@ function ping_init(&$a) {
<home>$home</home>"; <home>$home</home>";
if ($register!=0) echo "<register>$register</register>"; if ($register!=0) echo "<register>$register</register>";
$tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends)+count($posts); $tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends)+count($posts)+count($tags);
echo ' <notif count="'.$tot.'">'; echo ' <notif count="'.$tot.'">';
if ($intro>0){ if ($intro>0){
@ -173,6 +182,11 @@ function ping_init(&$a) {
echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} posted") ) ); echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} posted") ) );
}; };
} }
if (count($tags)){
foreach ($tags as $i) {
echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} tagged %s's post with #%s"), $i['pname'], $i['tname'] ) );
};
}
echo " </notif>"; echo " </notif>";
} }