summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/attachmentlist.php6
-rw-r--r--lib/noticelist.php55
-rw-r--r--lib/router.php15
3 files changed, 38 insertions, 38 deletions
diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php
index 9485fe3d6..1be7b2fee 100644
--- a/lib/attachmentlist.php
+++ b/lib/attachmentlist.php
@@ -191,7 +191,7 @@ class AttachmentListItem extends Widget
}
function linkAttr() {
- return array('class' => 'attachment', 'href' => common_local_url('attachment', array('attachment' => $this->attachment->id)));
+ return array('class' => 'attachment', 'href' => $this->attachment->url, 'id' => 'attachment-' . $this->attachment->id);
}
function showLink() {
@@ -200,10 +200,6 @@ class AttachmentListItem extends Widget
$this->out->elementStart('h4');
$this->out->element('a', $attr, $text);
- if ($this->attachment->url !== $this->title())
- $this->out->element('span', null, " ({$this->attachment->url})");
-
-
$this->out->elementEnd('h4');
}
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');
}
diff --git a/lib/router.php b/lib/router.php
index 70ee0f3fb..39c005609 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -151,26 +151,35 @@ class Router
$m->connect('search/notice/rss?q=:q', array('action' => 'noticesearchrss'),
array('q' => '.+'));
+/*
+ $m->connect('attachment/ajax_by_url/*url',
+ array('action' => 'attachment_ajax'));
+*/
$m->connect('attachment/:attachment/ajax',
array('action' => 'attachment_ajax'),
- array('notice' => '[0-9]+'));
+ array('attachment' => '[0-9]+'));
+/*
+ TODO
+ not used right now, will revisit later
$m->connect('attachment/:attachment',
array('action' => 'attachment'),
- array('notice' => '[0-9]+'));
-
+ array('attachment' => '[0-9]+'));
+*/
// notice
$m->connect('notice/new', array('action' => 'newnotice'));
$m->connect('notice/new?replyto=:replyto',
array('action' => 'newnotice'),
array('replyto' => '[A-Za-z0-9_-]+'));
+/*
$m->connect('notice/:notice/attachments/ajax',
array('action' => 'attachments_ajax'),
array('notice' => '[0-9]+'));
$m->connect('notice/:notice/attachments',
array('action' => 'attachments'),
array('notice' => '[0-9]+'));
+*/
$m->connect('notice/:notice',
array('action' => 'shownotice'),
array('notice' => '[0-9]+'));