don't show some bookmark elements if empty

This commit is contained in:
Evan Prodromou 2010-12-30 16:21:22 -08:00
parent 6fc7e5b05b
commit 682e11bb8b
2 changed files with 48 additions and 32 deletions

View File

@ -263,13 +263,15 @@ class BookmarkPlugin extends Plugin
$att->noticeCount()); $att->noticeCount());
} }
$out->elementStart('ul', array('class' => 'bookmark_tags'));
// Replies look like "for:" tags // Replies look like "for:" tags
$replies = $nli->notice->getReplies(); $replies = $nli->notice->getReplies();
$tags = $nli->notice->getTags();
if (!empty($replies)) { if (!empty($replies) || !empty($tags)) {
$out->elementStart('ul', array('class' => 'bookmark_tags'));
foreach ($replies as $reply) { foreach ($replies as $reply) {
$other = Profile::staticGet('id', $reply); $other = Profile::staticGet('id', $reply);
$out->elementStart('li'); $out->elementStart('li');
@ -280,45 +282,59 @@ class BookmarkPlugin extends Plugin
$out->elementEnd('li'); $out->elementEnd('li');
$out->text(' '); $out->text(' ');
} }
foreach ($tags as $tag) {
$out->elementStart('li');
$out->element('a',
array('rel' => 'tag',
'href' => Notice_tag::url($tag)),
$tag);
$out->elementEnd('li');
$out->text(' ');
}
$out->elementEnd('ul');
} }
$tags = $nli->notice->getTags(); if (!empty($nb->description)) {
$out->element('p',
foreach ($tags as $tag) { array('class' => 'bookmark_description'),
$out->elementStart('li'); $nb->description);
$out->element('a',
array('rel' => 'tag',
'href' => Notice_tag::url($tag)),
$tag);
$out->elementEnd('li');
$out->text(' ');
} }
$out->elementEnd('ul');
$out->element('p',
array('class' => 'bookmark_description'),
$nb->description);
if (common_config('attachments', 'show_thumbs')) { if (common_config('attachments', 'show_thumbs')) {
$al = new InlineAttachmentList($notice, $out); $haveThumbs = false;
$al->show(); foreach ($atts as $check) {
$thumbnail = File_thumbnail::staticGet('file_id', $check->id);
if (!empty($thumbnail)) {
$haveThumbs = true;
break;
}
}
if ($haveThumbs) {
$al = new InlineAttachmentList($notice, $out);
$al->show();
}
} }
$out->elementStart('p', array('style' => 'float: left')); $out->elementStart('p', array('class' => 'bookmark_info'));
$avatar = $profile->getAvatar(AVATAR_MINI_SIZE); $avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
$out->element('img', array('src' => ($avatar) ? $out->element('img',
$avatar->displayUrl() : array('src' => ($avatar) ?
Avatar::defaultImage(AVATAR_MINI_SIZE), $avatar->displayUrl() :
'class' => 'avatar photo bookmark_avatar', Avatar::defaultImage(AVATAR_MINI_SIZE),
'width' => AVATAR_MINI_SIZE, 'class' => 'avatar photo bookmark_avatar',
'height' => AVATAR_MINI_SIZE, 'width' => AVATAR_MINI_SIZE,
'alt' => $profile->getBestName())); 'height' => AVATAR_MINI_SIZE,
'alt' => $profile->getBestName()));
$out->raw(' '); $out->raw(' ');
$out->element('a', array('href' => $profile->profileurl,
'title' => $profile->getBestName()), $out->element('a',
array('href' => $profile->profileurl,
'title' => $profile->getBestName()),
$profile->nickname); $profile->nickname);
$nli->showNoticeLink(); $nli->showNoticeLink();
@ -758,4 +774,3 @@ class BookmarkPlugin extends Plugin
$activity->objects[0]->type == ActivityObject::BOOKMARK); $activity->objects[0]->type == ActivityObject::BOOKMARK);
} }
} }

View File

@ -2,3 +2,4 @@
.bookmark_mentions li { display: inline; } .bookmark_mentions li { display: inline; }
.bookmark_avatar { float: left } .bookmark_avatar { float: left }
.bookmark_notice_count { float: right } .bookmark_notice_count { float: right }
.bookmark_info { float: left }