mirror of
https://github.com/friendica/friendica
synced 2025-01-22 12:19:46 +00:00
notifications.php - move duplicated code in an own function
This commit is contained in:
parent
819b374401
commit
f09cd57165
1 changed files with 316 additions and 170 deletions
|
@ -247,66 +247,71 @@ function notifications_content(&$a) {
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
|
|
||||||
$tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
|
// $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
|
||||||
$tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
|
// $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
|
||||||
$tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
|
// $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
|
||||||
$tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
|
// $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
|
||||||
$tpl_item_posts = get_markup_template('notifications_posts_item.tpl');
|
// $tpl_item_posts = get_markup_template('notifications_posts_item.tpl');
|
||||||
|
|
||||||
if ($r) {
|
if ($r) {
|
||||||
|
|
||||||
foreach ($r as $it) {
|
$notifs = array(
|
||||||
switch($it['verb']){
|
'notifications' => $r,
|
||||||
case ACTIVITY_LIKE:
|
'ident' => 'network',
|
||||||
$notif_content[] = replace_macros($tpl_item_likes,array(
|
);
|
||||||
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
|
||||||
'$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
|
||||||
'$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
|
||||||
'$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
|
|
||||||
'$item_when' => relative_date($it['created'])
|
|
||||||
));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ACTIVITY_DISLIKE:
|
// foreach ($r as $it) {
|
||||||
$notif_content[] = replace_macros($tpl_item_dislikes,array(
|
// switch($it['verb']){
|
||||||
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
// case ACTIVITY_LIKE:
|
||||||
'$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
// $notif_content[] = replace_macros($tpl_item_likes,array(
|
||||||
'$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
// //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
'$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
|
// '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
'$item_when' => relative_date($it['created'])
|
// '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||||
));
|
// '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
|
||||||
break;
|
// '$item_when' => relative_date($it['created'])
|
||||||
|
// ));
|
||||||
case ACTIVITY_FRIEND:
|
// break;
|
||||||
|
//
|
||||||
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
|
// case ACTIVITY_DISLIKE:
|
||||||
$obj = parse_xml_string($xmlhead.$it['object']);
|
// $notif_content[] = replace_macros($tpl_item_dislikes,array(
|
||||||
$it['fname'] = $obj->title;
|
// //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
|
// '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
$notif_content[] = replace_macros($tpl_item_friends,array(
|
// '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||||
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
// '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
|
||||||
'$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
// '$item_when' => relative_date($it['created'])
|
||||||
'$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
// ));
|
||||||
'$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
|
// break;
|
||||||
'$item_when' => relative_date($it['created'])
|
//
|
||||||
));
|
// case ACTIVITY_FRIEND:
|
||||||
break;
|
//
|
||||||
|
// $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
|
||||||
default:
|
// $obj = parse_xml_string($xmlhead.$it['object']);
|
||||||
$item_text = (($it['id'] == $it['parent'])
|
// $it['fname'] = $obj->title;
|
||||||
? sprintf( t("%s created a new post"), $it['author-name'])
|
//
|
||||||
: sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']));
|
// $notif_content[] = replace_macros($tpl_item_friends,array(
|
||||||
$tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
|
// //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
|
// '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
$notif_content[] = replace_macros($tpl,array(
|
// '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||||
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
// '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
|
||||||
'$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
// '$item_when' => relative_date($it['created'])
|
||||||
'$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
// ));
|
||||||
'$item_text' => $item_text,
|
// break;
|
||||||
'$item_when' => relative_date($it['created'])
|
//
|
||||||
));
|
// default:
|
||||||
}
|
// $item_text = (($it['id'] == $it['parent'])
|
||||||
}
|
// ? sprintf( t("%s created a new post"), $it['author-name'])
|
||||||
|
// : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']));
|
||||||
|
// $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
|
||||||
|
//
|
||||||
|
// $notif_content[] = replace_macros($tpl,array(
|
||||||
|
// //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
|
// '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
|
// '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||||
|
// '$item_text' => $item_text,
|
||||||
|
// '$item_when' => relative_date($it['created'])
|
||||||
|
// ));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -326,14 +331,19 @@ function notifications_content(&$a) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (count($r) > 0) {
|
if (count($r) > 0) {
|
||||||
foreach ($r as $it) {
|
// foreach ($r as $it) {
|
||||||
$notif_content[] = replace_macros($not_tpl,array(
|
// $notif_content[] = replace_macros($not_tpl,array(
|
||||||
'$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
|
// '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
|
||||||
'$item_image' => proxy_url($it['photo'], false, PROXY_SIZE_MICRO),
|
// '$item_image' => proxy_url($it['photo'], false, PROXY_SIZE_MICRO),
|
||||||
'$item_text' => strip_tags(bbcode($it['msg'])),
|
// '$item_text' => strip_tags(bbcode($it['msg'])),
|
||||||
'$item_when' => relative_date($it['date'])
|
// '$item_when' => relative_date($it['date'])
|
||||||
));
|
// ));
|
||||||
}
|
// }
|
||||||
|
$notifs = array(
|
||||||
|
'notifications' => $r,
|
||||||
|
'ident' => 'system',
|
||||||
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$notif_nocontent = t('No more system notifications.');
|
$notif_nocontent = t('No more system notifications.');
|
||||||
}
|
}
|
||||||
|
@ -364,66 +374,71 @@ function notifications_content(&$a) {
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
|
|
||||||
$tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
|
// $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
|
||||||
$tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
|
// $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
|
||||||
$tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
|
// $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
|
||||||
$tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
|
// $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
|
||||||
$tpl_item_posts = get_markup_template('notifications_posts_item.tpl');
|
// $tpl_item_posts = get_markup_template('notifications_posts_item.tpl');
|
||||||
|
|
||||||
if (count($r) > 0) {
|
if (count($r) > 0) {
|
||||||
|
$notifs =array(
|
||||||
|
'notifications' => $r,
|
||||||
|
'ident' => 'personal'
|
||||||
|
);
|
||||||
|
|
||||||
foreach ($r as $it) {
|
|
||||||
switch($it['verb']){
|
|
||||||
case ACTIVITY_LIKE:
|
|
||||||
$notif_content[] = replace_macros($tpl_item_likes,array(
|
|
||||||
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
|
||||||
'$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
|
||||||
'$item_image' => $it['author-avatar'],
|
|
||||||
'$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
|
|
||||||
'$item_when' => relative_date($it['created'])
|
|
||||||
));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ACTIVITY_DISLIKE:
|
// foreach ($r as $it) {
|
||||||
$notif_content[] = replace_macros($tpl_item_dislikes,array(
|
// switch($it['verb']){
|
||||||
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
// case ACTIVITY_LIKE:
|
||||||
'$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
// $notif_content[] = replace_macros($tpl_item_likes,array(
|
||||||
'$item_image' => $it['author-avatar'],
|
// //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
'$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
|
// '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
'$item_when' => relative_date($it['created'])
|
// '$item_image' => $it['author-avatar'],
|
||||||
));
|
// '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
|
||||||
break;
|
// '$item_when' => relative_date($it['created'])
|
||||||
|
// ));
|
||||||
case ACTIVITY_FRIEND:
|
// break;
|
||||||
|
//
|
||||||
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
|
// case ACTIVITY_DISLIKE:
|
||||||
$obj = parse_xml_string($xmlhead.$it['object']);
|
// $notif_content[] = replace_macros($tpl_item_dislikes,array(
|
||||||
$it['fname'] = $obj->title;
|
// //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
|
// '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
$notif_content[] = replace_macros($tpl_item_friends,array(
|
// '$item_image' => $it['author-avatar'],
|
||||||
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
// '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
|
||||||
'$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
// '$item_when' => relative_date($it['created'])
|
||||||
'$item_image' => $it['author-avatar'],
|
// ));
|
||||||
'$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
|
// break;
|
||||||
'$item_when' => relative_date($it['created'])
|
//
|
||||||
));
|
// case ACTIVITY_FRIEND:
|
||||||
break;
|
//
|
||||||
|
// $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
|
||||||
default:
|
// $obj = parse_xml_string($xmlhead.$it['object']);
|
||||||
$item_text = (($it['id'] == $it['parent'])
|
// $it['fname'] = $obj->title;
|
||||||
? sprintf( t("%s created a new post"), $it['author-name'])
|
//
|
||||||
: sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']));
|
// $notif_content[] = replace_macros($tpl_item_friends,array(
|
||||||
$tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
|
// //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
|
// '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
$notif_content[] = replace_macros($tpl,array(
|
// '$item_image' => $it['author-avatar'],
|
||||||
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
// '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
|
||||||
'$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
// '$item_when' => relative_date($it['created'])
|
||||||
'$item_image' => $it['author-avatar'],
|
// ));
|
||||||
'$item_text' => $item_text,
|
// break;
|
||||||
'$item_when' => relative_date($it['created'])
|
//
|
||||||
));
|
// default:
|
||||||
}
|
// $item_text = (($it['id'] == $it['parent'])
|
||||||
}
|
// ? sprintf( t("%s created a new post"), $it['author-name'])
|
||||||
|
// : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']));
|
||||||
|
// $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
|
||||||
|
//
|
||||||
|
// $notif_content[] = replace_macros($tpl,array(
|
||||||
|
// //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
|
// '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
|
// '$item_image' => $it['author-avatar'],
|
||||||
|
// '$item_text' => $item_text,
|
||||||
|
// '$item_when' => relative_date($it['created'])
|
||||||
|
// ));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -444,60 +459,65 @@ function notifications_content(&$a) {
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
|
|
||||||
$tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
|
// $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
|
||||||
$tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
|
// $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
|
||||||
$tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
|
// $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
|
||||||
$tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
|
// $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
|
||||||
|
|
||||||
if (count($r) > 0) {
|
if (count($r) > 0) {
|
||||||
|
|
||||||
foreach ($r as $it) {
|
$notifs = array(
|
||||||
switch($it['verb']){
|
'notifications' => $r,
|
||||||
case ACTIVITY_LIKE:
|
'ident' => 'home',
|
||||||
$notif_content[] = replace_macros($tpl_item_likes,array(
|
);
|
||||||
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
|
||||||
'$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
|
||||||
'$item_image' => $it['author-avatar'],
|
|
||||||
'$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
|
|
||||||
'$item_when' => relative_date($it['created'])
|
|
||||||
));
|
|
||||||
|
|
||||||
break;
|
// foreach ($r as $it) {
|
||||||
case ACTIVITY_DISLIKE:
|
// switch($it['verb']){
|
||||||
$notif_content[] = replace_macros($tpl_item_dislikes,array(
|
// case ACTIVITY_LIKE:
|
||||||
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
// $notif_content[] = replace_macros($tpl_item_likes,array(
|
||||||
'$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
// //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
'$item_image' => $it['author-avatar'],
|
// '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
'$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
|
// '$item_image' => $it['author-avatar'],
|
||||||
'$item_when' => relative_date($it['created'])
|
// '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
|
||||||
));
|
// '$item_when' => relative_date($it['created'])
|
||||||
|
// ));
|
||||||
break;
|
//
|
||||||
case ACTIVITY_FRIEND:
|
// break;
|
||||||
|
// case ACTIVITY_DISLIKE:
|
||||||
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
|
// $notif_content[] = replace_macros($tpl_item_dislikes,array(
|
||||||
$obj = parse_xml_string($xmlhead.$it['object']);
|
// //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
$it['fname'] = $obj->title;
|
// '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
|
// '$item_image' => $it['author-avatar'],
|
||||||
$notif_content[] = replace_macros($tpl_item_friends,array(
|
// '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
|
||||||
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
// '$item_when' => relative_date($it['created'])
|
||||||
'$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
// ));
|
||||||
'$item_image' => $it['author-avatar'],
|
//
|
||||||
'$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
|
// break;
|
||||||
'$item_when' => relative_date($it['created'])
|
// case ACTIVITY_FRIEND:
|
||||||
));
|
//
|
||||||
|
// $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
|
||||||
break;
|
// $obj = parse_xml_string($xmlhead.$it['object']);
|
||||||
default:
|
// $it['fname'] = $obj->title;
|
||||||
$notif_content[] = replace_macros($tpl_item_comments,array(
|
//
|
||||||
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
// $notif_content[] = replace_macros($tpl_item_friends,array(
|
||||||
'$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
// //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
'$item_image' => $it['author-avatar'],
|
// '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
'$item_text' => sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']),
|
// '$item_image' => $it['author-avatar'],
|
||||||
'$item_when' => relative_date($it['created'])
|
// '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
|
||||||
));
|
// '$item_when' => relative_date($it['created'])
|
||||||
}
|
// ));
|
||||||
}
|
//
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// $notif_content[] = replace_macros($tpl_item_comments,array(
|
||||||
|
// //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
|
// '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
|
// '$item_image' => $it['author-avatar'],
|
||||||
|
// '$item_text' => sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']),
|
||||||
|
// '$item_when' => relative_date($it['created'])
|
||||||
|
// ));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$notif_nocontent = t('No more home notifications.');
|
$notif_nocontent = t('No more home notifications.');
|
||||||
|
@ -505,6 +525,9 @@ function notifications_content(&$a) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(count($notifs['notifications']) > 0 )
|
||||||
|
$notif_content = format_notifiations ($a, $notifs);
|
||||||
|
|
||||||
$o .= replace_macros($notif_tpl, array(
|
$o .= replace_macros($notif_tpl, array(
|
||||||
'$notif_header' => $notif_header,
|
'$notif_header' => $notif_header,
|
||||||
'$tabs' => $tabs,
|
'$tabs' => $tabs,
|
||||||
|
@ -512,6 +535,7 @@ function notifications_content(&$a) {
|
||||||
'$notif_nocontent' => $notif_nocontent,
|
'$notif_nocontent' => $notif_nocontent,
|
||||||
'$notif_ignored_lnk' => $notif_ignored_lnk,
|
'$notif_ignored_lnk' => $notif_ignored_lnk,
|
||||||
));
|
));
|
||||||
|
|
||||||
$o .= paginate($a);
|
$o .= paginate($a);
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
@ -561,4 +585,126 @@ function notifications_tabs($a) {
|
||||||
);
|
);
|
||||||
|
|
||||||
return $tabs;
|
return $tabs;
|
||||||
|
}
|
||||||
|
|
||||||
|
function format_notifiations(&$a, $notifs) {
|
||||||
|
|
||||||
|
$notif_content = array();
|
||||||
|
|
||||||
|
// The template files we need in different cases for formatting the content
|
||||||
|
$tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
|
||||||
|
$tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
|
||||||
|
$tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
|
||||||
|
$tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
|
||||||
|
$tpl_item_posts = get_markup_template('notifications_posts_item.tpl');
|
||||||
|
$tpl_notify = get_markup_template('notify.tpl');
|
||||||
|
|
||||||
|
if (count($notifs['notifications']) > 0) {
|
||||||
|
// switch ($notifs['ident']) {
|
||||||
|
// case 'system':
|
||||||
|
// $default_item_link = app::get_baseurl(true).'/notify/view/'. $it['id'];
|
||||||
|
// $default_item_image = proxy_url($it['photo'], false, PROXY_SIZE_MICRO);
|
||||||
|
// $default_item_text = strip_tags(bbcode($it['msg']));
|
||||||
|
// $default_item_when = relative_date($it['date']);
|
||||||
|
// $default_tpl = $tpl_notify;
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// case 'home':
|
||||||
|
// $default_item_link = app::get_baseurl(true).'/display/'.$it['pguid'];
|
||||||
|
// $default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
|
||||||
|
// $default_item_text = sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']);
|
||||||
|
// $default_item_when = relative_date($it['created']);
|
||||||
|
// $default_tpl = $tpl_item_comments;
|
||||||
|
// break;
|
||||||
|
//
|
||||||
|
// default:
|
||||||
|
// $default_item_link = app::get_baseurl(true).'/display/'.$it['pguid'];
|
||||||
|
// $default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
|
||||||
|
// $default_item_text = (($it['id'] == $it['parent'])
|
||||||
|
// ? sprintf( t("%s created a new post"), $it['author-name'])
|
||||||
|
// : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']));
|
||||||
|
// $default_item_when = relative_date($it['created']);
|
||||||
|
// $default_tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
foreach ($notifs['notifications'] as $it) {
|
||||||
|
|
||||||
|
switch ($notifs['ident']) {
|
||||||
|
case 'system':
|
||||||
|
$default_item_link = app::get_baseurl(true).'notify/view/'. $it['id'];
|
||||||
|
$default_item_image = proxy_url($it['photo'], false, PROXY_SIZE_MICRO);
|
||||||
|
$default_item_text = strip_tags(bbcode($it['msg']));
|
||||||
|
$default_item_when = relative_date($it['date']);
|
||||||
|
$default_tpl = $tpl_notify;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'home':
|
||||||
|
$default_item_link = app::get_baseurl(true).'/display/'.$it['pguid'];
|
||||||
|
$default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
|
||||||
|
$default_item_text = sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']);
|
||||||
|
$default_item_when = relative_date($it['created']);
|
||||||
|
$default_tpl = $tpl_item_comments;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$default_item_link = app::get_baseurl(true).'/display/'.$it['pguid'];
|
||||||
|
$default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO);
|
||||||
|
$default_item_text = (($it['id'] == $it['parent'])
|
||||||
|
? sprintf( t("%s created a new post"), $it['author-name'])
|
||||||
|
: sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']));
|
||||||
|
$default_item_when = relative_date($it['created']);
|
||||||
|
$default_tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
switch($it['verb']){
|
||||||
|
case ACTIVITY_LIKE:
|
||||||
|
$notif_content[] = replace_macros($tpl_item_likes,array(
|
||||||
|
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
|
'$item_link' => app::get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
|
'$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||||
|
'$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
|
||||||
|
'$item_when' => relative_date($it['created'])
|
||||||
|
));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ACTIVITY_DISLIKE:
|
||||||
|
$notif_content[] = replace_macros($tpl_item_dislikes,array(
|
||||||
|
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
|
'$item_link' => app::get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
|
'$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||||
|
'$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
|
||||||
|
'$item_when' => relative_date($it['created'])
|
||||||
|
));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ACTIVITY_FRIEND:
|
||||||
|
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
|
||||||
|
$obj = parse_xml_string($xmlhead.$it['object']);
|
||||||
|
$it['fname'] = $obj->title;
|
||||||
|
|
||||||
|
$notif_content[] = replace_macros($tpl_item_friends,array(
|
||||||
|
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
|
'$item_link' => app::get_baseurl(true).'/display/'.$it['pguid'],
|
||||||
|
'$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||||
|
'$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
|
||||||
|
'$item_when' => relative_date($it['created'])
|
||||||
|
));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$notif_content[] = replace_macros($default_tpl,array(
|
||||||
|
//'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
|
||||||
|
'$item_link' => $default_item_link,
|
||||||
|
'$item_image' => $default_item_image,
|
||||||
|
'$item_text' => $default_item_text,
|
||||||
|
'$item_when' => $default_item_when
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $notif_content;
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue