diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-05-26 17:28:12 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-05-26 17:28:12 -0400 |
commit | 0b53a820c2b4224b66b2a24f67302b4c5ca1deed (patch) | |
tree | 67086e31a9437327898920996bede11c1668f0e2 /lib/noticelist.php | |
parent | 40d4668c7c5cdd41d36b878ad87f7737117efc9c (diff) | |
parent | c93031c2aa49b8a044e896ca1e07f5f4f429308e (diff) |
Merge branch '0.8.x' of git@gitorious.org:laconica/dev into 0.8.x
Diffstat (limited to 'lib/noticelist.php')
-rw-r--r-- | lib/noticelist.php | 53 |
1 files changed, 16 insertions, 37 deletions
diff --git a/lib/noticelist.php b/lib/noticelist.php index a52132171..50a95cfcb 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -34,6 +34,7 @@ if (!defined('LACONICA')) { require_once INSTALLDIR.'/lib/favorform.php'; require_once INSTALLDIR.'/lib/disfavorform.php'; +require_once INSTALLDIR.'/lib/attachmentlist.php'; /** * widget for displaying a list of notices @@ -193,46 +194,24 @@ class NoticeListItem extends Widget $this->out->elementEnd('div'); } - function showNoticeAttachments() - { - $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'); - $count = $file->find(true); - if (!$count) return; - if (1 === $count) { - $href = common_local_url('attachment', array('attachment' => $file->id)); - $att_class = 'attachment'; - } else { - $href = common_local_url('attachments', array('notice' => $this->notice->id)); - $att_class = 'attachments'; - } - - $clip = theme_path('images/icons/clip', 'base'); - if ('shownotice' === $this->out->args['action']) { - $height = '96px'; - $width = '83%'; - $width_att = '15%'; - $clip .= '-big.png'; - $top = '70px'; - } else { - $height = '48px'; - $width = '90%'; - $width_att = '8%'; - $clip .= '.png'; - $top = '20px'; + function showNoticeAttachments() { + if ($this->isUsedInList()) { + return; } -if(0) - $this->out->elementStart('div', 'entry-attachments'); -else - $this->out->elementStart('p', array('class' => 'entry-attachments', 'style' => "float: right; width: $width_att; background: url($clip) no-repeat; text-align: right; height: $height;")); - $this->out->element('a', array('class' => $att_class, 'style' => "text-decoration: none; padding-top: $top; display: block; height: $height;", 'href' => $href, 'title' => "# of attachments: $count"), $count === 1 ? '' : $count); + $al = new AttachmentList($this->notice, $this->out); + $al->show(); + } + function isUsedInList() { + return 'shownotice' !== $this->out->args['action']; + } - $this->out->elementEnd('p'); + 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 showNoticeInfo() |