Don't show empty addressees in noticelistitem

This commit is contained in:
Evan Prodromou 2011-05-30 16:20:34 -04:00
parent d544c78276
commit ac55efeecf

View File

@ -229,43 +229,15 @@ class NoticeListItem extends Widget
function showAddressees() function showAddressees()
{ {
$ga = $this->getGroupAddressees();
$pa = $this->getProfileAddressees();
$a = array_merge($ga, $pa);
if (!empty($a)) {
$this->out->elementStart('span', 'addressees'); $this->out->elementStart('span', 'addressees');
$first = true;
$cnt = $this->showGroupAddressees(true); foreach ($a as $addr) {
$cnt = $this->showProfileAddressees($cnt == 0);
$this->out->elementEnd('span', 'addressees');
}
function showGroupAddressees($first)
{
$groups = $this->getGroups();
foreach ($groups as $group) {
if (!$first) {
$this->out->text( _m('SEPARATOR',', '));
} else {
$first = false;
}
$this->out->element('a', array('href' => $group->homeUrl(),
'title' => $group->nickname,
'class' => 'addressee group'),
$group->getBestName());
}
return count($groups);
}
function getGroups()
{
return $this->notice->getGroups();
}
function showProfileAddressees($first)
{
$replies = $this->getReplyProfiles();
foreach ($replies as $reply) {
if (!$first) { if (!$first) {
// TRANS: Separator in profile addressees list. // TRANS: Separator in profile addressees list.
$this->out->text(_m('SEPARATOR',', ')); $this->out->text(_m('SEPARATOR',', '));
@ -273,13 +245,49 @@ class NoticeListItem extends Widget
// TRANS: Start of profile addressees list. // TRANS: Start of profile addressees list.
$first = false; $first = false;
} }
$this->out->element('a', array('href' => $reply->profileurl, $text = $addr['text'];
'title' => $reply->nickname, unset($addr['text']);
'class' => 'addressee account'), $this->out->element('a', $addr, $text);
$reply->getBestName()); }
$this->out->elementEnd('span', 'addressees');
}
} }
return count($replies); function getGroupAddressees()
{
$ga = array();
$groups = $this->getGroups();
foreach ($groups as $group) {
$ga[] = array('href' => $group->homeUrl(),
'title' => $group->nickname,
'class' => 'addressee group',
'text' => $group->getBestName());
}
return $ga;
}
function getGroups()
{
return $this->notice->getGroups();
}
function getProfileAddressees()
{
$pa = array();
$replies = $this->getReplyProfiles();
foreach ($replies as $reply) {
$pa[] = array('href' => $reply->profileurl,
'title' => $reply->nickname,
'class' => 'addressee account',
'text' => $reply->getBestName());
}
return $pa;
} }
function getReplyProfiles() function getReplyProfiles()