diff options
author | Robin Millette <millette@controlyourself.ca> | 2009-05-24 18:06:19 -0400 |
---|---|---|
committer | Robin Millette <millette@controlyourself.ca> | 2009-05-24 18:06:19 -0400 |
commit | bd70caace84758e6655f8db4957049492834a6c6 (patch) | |
tree | cf759810924da96bb78c2d0e2e6c31e22be1129f /lib/noticelist.php | |
parent | 8c2473a2275f25c144d8e6a41bf8c17fef465103 (diff) |
Only show number of attachments if > 1
Diffstat (limited to 'lib/noticelist.php')
-rw-r--r-- | lib/noticelist.php | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/noticelist.php b/lib/noticelist.php index e3361fc99..51b8987fe 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -207,14 +207,12 @@ class NoticeListItem extends Widget return 'shownotice' !== $this->out->args['action']; } - function attachmentCount() { - $f2p = new File_to_post; - $f2p->post_id = $this->notice->id; - $file = new File; - $file->joinAdd($f2p); - $file->selectAdd(); - $file->selectAdd('file.id as id'); - return $file->find(true); + function attachmentCount($discriminant = true) { + $file_oembed = new File_oembed; + $query = "select count(*) as c from file_oembed join file_to_post on file_oembed.file_id = file_to_post.file_id where post_id=" . $this->notice->id; + $file_oembed->query($query); + $file_oembed->fetch(); + return intval($file_oembed->c); } function showNoticeAttachmentsIcon() @@ -224,7 +222,6 @@ class NoticeListItem extends Widget } $href = common_local_url('shownotice', array('notice' => $this->notice->id)) . '#attachments'; - $this->out->elementStart('p', 'entry-attachments'); $this->out->element('a', array('href' => $href, 'title' => "# of attachments: $count"), $count === 1 ? '' : $count); $this->out->elementEnd('p'); |