summaryrefslogtreecommitdiff
path: root/lib/noticelist.php
diff options
context:
space:
mode:
authorRobin Millette <millette@controlyourself.ca>2009-05-24 04:43:34 -0400
committerRobin Millette <millette@controlyourself.ca>2009-05-24 04:43:34 -0400
commitb5ac6e31f2f148164860aeabec6899b75d7292ec (patch)
tree5016a9624a923793f231d066d7519e8e3a0a8075 /lib/noticelist.php
parent456f3eeb50fc1cafaa66ab5c0bdcdcaa5ca4bcd0 (diff)
Rearranged attachment info to only appear on each applicable notice page and thru an ajax popup.
Diffstat (limited to 'lib/noticelist.php')
-rw-r--r--lib/noticelist.php55
1 files changed, 25 insertions, 30 deletions
diff --git a/lib/noticelist.php b/lib/noticelist.php
index a52132171..e3361fc99 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
@@ -179,9 +180,10 @@ class NoticeListItem extends Widget
{
$this->showStart();
$this->showNotice();
- $this->showNoticeAttachments();
+ $this->showNoticeAttachmentsIcon();
$this->showNoticeInfo();
$this->showNoticeOptions();
+ $this->showNoticeAttachments();
$this->showEnd();
}
@@ -193,45 +195,38 @@ class NoticeListItem extends Widget
$this->out->elementEnd('div');
}
- function showNoticeAttachments()
- {
+ function showNoticeAttachments() {
+ if ($this->isUsedInList()) {
+ return;
+ }
+ $al = new AttachmentList($this->notice, $this->out);
+ $al->show();
+ }
+
+ function isUsedInList() {
+ 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');
- $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';
- }
+ return $file->find(true);
+ }
- $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 showNoticeAttachmentsIcon()
+ {
+ if (!($this->isUsedInList() && ($count = $this->attachmentCount()))) {
+ 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);
+ $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');
}